Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/shared/offered-agent-models.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"response": {
"version": 1,
"models": "1 to 512 entries, each { model, price?, identity?, priceKnown? (false only, never with price), free? (true only), tested? (true only), limits? { contextWindow, maxOutputTokens } }; slash IDs require exact identity; legacy names have no identity",
"models": "1 to 512 entries, each { model, displayName? (Code API 1.31: the name people read, 1 to 100 characters on one line; the id stays the key), price?, identity?, priceKnown? (false only, never with price), free? (true only), tested? (true only), limits? { contextWindow, maxOutputTokens } }; slash IDs require exact identity; legacy names have no identity",
"modelNamePattern": "^(?:[A-Za-z0-9][A-Za-z0-9._:-]{0,127}|[a-z0-9][a-z0-9._-]{0,62}\\/[a-z0-9][a-z0-9._-]{0,62}(?::[a-z0-9][a-z0-9._-]{0,31})?)$",
"modelsMax": 512,
"identity": {
Expand Down
2 changes: 2 additions & 0 deletions docs/architecture/company-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ A hit means a query does not itself prove per-row company isolation. It is not a
| forwarding | packages/broker/src/aws/index-expiry.ts:34:76:pk | entry.pk | Generic runtime pk forwarding; preserves caller/loaded record identity rather than assigning a new record family. | all indexed record constructors with indexExpiresAt (generic index maintenance) |
| forwarding | packages/broker/src/aws/index-expiry.ts:34:90:sk | entry.sk | Runtime sort component forwarded within the feeding partition; not an independent record family. | all indexed record constructors with indexExpiresAt (generic index maintenance) |
| forwarding | packages/broker/src/aws/session-steps.ts:233:44:computed | [key] | Runtime property name forwarding; family-bearing pk/entityType constructors are inventoried separately. | invokePublicKey |
| forwarding | packages/broker/src/aws/slack-direct-front.ts:138:17:pk | partition | The direct message event's own claim partition (`ORG#<company>#CHANNEL_CLAIM#slack/DIRECT_EVENT#<event>`), built once per event from the company the workspace is bound to and passed to the claim; the key family is unchanged. | pk:CHANNEL_CLAIM |
| forwarding | packages/broker/src/aws/slack-direct-front.ts:157:19:pk | partition | The same event partition, for the once-only failure-reply marker (sort key REPLY) beside the claim; no new key family. | pk:CHANNEL_CLAIM |
| forwarding | packages/broker/src/aws/slack-interactivity.ts:618:54:computed | [callbackId === "agentx_feedback_review_changes_submission" ? "feedback_note" : callbackId === "agentx_workflow_checks_retry_submission" ? "workflow_checks"&#10; : callbackId === WORKFLOW_FINDINGS_SUBMISSION ? firstInputBlock(asRecord(payload.view)) : "workflow_feedback"] | Runtime property name forwarding; family-bearing pk/entityType constructors are inventoried separately. | confirmationKey |
| forwarding | packages/broker/src/aws/slack-interactivity.ts:638:53:computed | [field] | Runtime property name forwarding; family-bearing pk/entityType constructors are inventoried separately. | confirmationKey |
| forwarding | packages/broker/src/aws/stuck-setup.ts:73:120:sk | sk | Runtime sort component forwarded within the feeding partition; not an independent record family. | setupWatchKey and workspaceKey in developer/task-records.ts / core/task-flow/keys.ts |
Expand Down
20 changes: 11 additions & 9 deletions packages/broker/src/aws/company-engine-model-routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Guided onboarding PR 14 (DEC 254n item 1): the company's own engine model on the deployed developer API (contracts company-engine-model.ts; core-host/company-engine-model.ts reads it).
//
// GET /v1/dev/company/engine-model any member of the company -> { model, source, offered, preselect }
// GET /v1/dev/company/engine-model any member of the company -> { model, source, offered, preselect, displayNames }
// PUT /v1/dev/company/engine-model owner or admin of the company { model: <id> | null } -> the same view (null clears it: the install default applies again)
//
// Rules:
Expand All @@ -17,7 +17,7 @@ import { routeNotServed, CompanyEngineModelBodySchema, agentXError, companyLog,
import { Membership, membershipKey } from "./company-check.js";
import type { DeveloperCaller } from "./developer-routes.js";
import type { AdaptedHttpRequest } from "./lambda.js";
import { COMPANY_ENGINE_MODEL_ENTITY, companyEngineModelKey, offeredEngineModels, readCompanyEngineModel, type EngineModelOfferedReader } from "../core-host/company-engine-model.js";
import { COMPANY_ENGINE_MODEL_ENTITY, companyEngineModelKey, displayNamesOf, offeredEngineModelList, readCompanyEngineModel, type EngineModelOfferedReader, type OfferedEngineModelList } from "../core-host/company-engine-model.js";
import { roleMay } from "../developer/role-may.js";

export const COMPANY_ENGINE_MODEL_PATH = "/v1/dev/company/engine-model";
Expand Down Expand Up @@ -67,11 +67,13 @@ function bodyOf(request: AdaptedHttpRequest): unknown {
try { return JSON.parse(request.body) as unknown; } catch { return undefined; }
}

const viewOf = (own: string | undefined, install: string | undefined, offered: string[]): CompanyEngineModelView => {
const viewOf = (own: string | undefined, install: string | undefined, list: OfferedEngineModelList): CompanyEngineModelView => {
const offered = list.ids;
// A company that chose none runs on the install default when its sources offer it, else on the best offered model (the gateway's first: it lists the model it prefers first); the same rule the start and each step follow.
const replaced = own === undefined && install !== undefined && !offered.includes(install);
const model = own ?? (replaced ? offered[0]! : install) ?? null;
return { model, source: own === undefined ? "install" : "company", ...(replaced ? { defaultNotOffered: install } : {}), offered, preselect: model !== null && offered.includes(model) ? model : offered[0]! };
const preselect = model !== null && offered.includes(model) ? model : offered[0]!;
return { model, source: own === undefined ? "install" : "company", ...(replaced ? { defaultNotOffered: install } : {}), offered, preselect, displayNames: displayNamesOf([model, replaced ? install : undefined, ...offered, preselect], list.names) };
};

export async function routeCompanyEngineModel(ctx: CompanyEngineModelContext, caller: DeveloperCaller, companyId: string, request: AdaptedHttpRequest): Promise<unknown> {
Expand All @@ -82,8 +84,8 @@ export async function routeCompanyEngineModel(ctx: CompanyEngineModelContext, ca
const readOwn = async (): Promise<string | undefined> => {
try { return await readCompanyEngineModel(reader, company); } catch { throw agentXError("RUNTIME_UNAVAILABLE", ENGINE_MODEL_SETTING_UNAVAILABLE); }
};
const readOffered = async (): Promise<string[]> => {
try { return await offeredEngineModels(ctx.wiring.offered, company); } catch { throw agentXError("RUNTIME_UNAVAILABLE", ENGINE_MODEL_LIST_UNAVAILABLE); }
const readOffered = async (): Promise<OfferedEngineModelList> => {
try { return await offeredEngineModelList(ctx.wiring.offered, company); } catch { throw agentXError("RUNTIME_UNAVAILABLE", ENGINE_MODEL_LIST_UNAVAILABLE); }
};
const installModel = (): string | undefined => {
try { return ctx.wiring.installModel(); } catch { return undefined; }
Expand All @@ -100,8 +102,8 @@ export async function routeCompanyEngineModel(ctx: CompanyEngineModelContext, ca
if (!parsed.success) throw agentXError("CONFIG_INVALID", ENGINE_MODEL_BODY_INVALID);
const chosen = parsed.data.model;
const previous = await readOwn();
const offered = await readOffered();
if (chosen !== null && !offered.includes(chosen)) throw agentXError("CONFIG_INVALID", ENGINE_MODEL_NOT_OFFERED_TO_COMPANY);
const list = await readOffered();
if (chosen !== null && !list.ids.includes(chosen)) throw agentXError("CONFIG_INVALID", ENGINE_MODEL_NOT_OFFERED_TO_COMPANY);

const at = new Date(ctx.now()).toISOString();
const key = companyEngineModelKey(company);
Expand All @@ -122,5 +124,5 @@ export async function routeCompanyEngineModel(ctx: CompanyEngineModelContext, ca
if (!(error instanceof Error && error.name === "ConditionalCheckFailedException")) companyLog(company, ctx.wiring.log)({ event: "company.engine_model_validation_not_cleared" });
}
companyLog(company, ctx.wiring.log)({ event: chosen === null ? "company.engine_model_cleared" : "company.engine_model_set", actor: caller.developerId });
return viewOf(chosen ?? undefined, installModel(), offered);
return viewOf(chosen ?? undefined, installModel(), list);
}
20 changes: 11 additions & 9 deletions packages/broker/src/aws/company-learning-model-routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// DEC 254zzz63: the company's own lessons LEARNING model on the deployed developer API (contracts company-learning-model.ts; core-host/company-learning-model.ts reads it). Mirrors the
// company engine model route (company-engine-model-routes.ts, DEC 254n item 1).
//
// GET /v1/dev/company/learning-model any member of the company -> { model, source, offered, preselect }
// GET /v1/dev/company/learning-model any member of the company -> { model, source, offered, preselect, displayNames }
// PUT /v1/dev/company/learning-model owner or admin of the company { model: <claude id> | null } -> the same view (null clears it: the install default applies again)
//
// Rules:
Expand All @@ -18,7 +18,7 @@ import { routeNotServed, CompanyLearningModelBodySchema, agentXError, companyLog
import { Membership, membershipKey } from "./company-check.js";
import type { DeveloperCaller } from "./developer-routes.js";
import type { AdaptedHttpRequest } from "./lambda.js";
import { offeredEngineModels, type EngineModelOfferedReader } from "../core-host/company-engine-model.js";
import { displayNamesOf, offeredEngineModelList, type EngineModelOfferedReader, type OfferedEngineModelList } from "../core-host/company-engine-model.js";
import { COMPANY_LEARNING_MODEL_ENTITY, companyLearningModelKey, isLearnableModel, readCompanyLearningModel } from "../core-host/company-learning-model.js";
import { roleMay } from "../developer/role-may.js";

Expand Down Expand Up @@ -68,9 +68,11 @@ function bodyOf(request: AdaptedHttpRequest): unknown {
try { return JSON.parse(request.body) as unknown; } catch { return undefined; }
}

const viewOf = (own: string | undefined, install: string | undefined, offered: string[]): CompanyLearningModelView => {
const viewOf = (own: string | undefined, install: string | undefined, list: OfferedEngineModelList): CompanyLearningModelView => {
const offered = list.ids;
const model = own ?? install ?? null;
return { model, source: own === undefined ? "install" : "company", offered, preselect: model !== null && offered.includes(model) ? model : offered[0] ?? null };
const preselect = model !== null && offered.includes(model) ? model : offered[0] ?? null;
return { model, source: own === undefined ? "install" : "company", offered, preselect, displayNames: displayNamesOf([model, ...offered, preselect], list.names) };
};

export async function routeCompanyLearningModel(ctx: CompanyLearningModelContext, caller: DeveloperCaller, companyId: string, request: AdaptedHttpRequest): Promise<unknown> {
Expand All @@ -82,8 +84,8 @@ export async function routeCompanyLearningModel(ctx: CompanyLearningModelContext
try { return await readCompanyLearningModel(reader, company); } catch { throw agentXError("RUNTIME_UNAVAILABLE", LEARNING_MODEL_SETTING_UNAVAILABLE); }
};
// Only the Claude models Code can price are offered here: the learning route is the company's own Anthropic account, and the per-call cap is priced from the catalog.
const readOffered = async (): Promise<string[]> => {
try { return (await offeredEngineModels(ctx.wiring.offered, company)).filter(isLearnableModel); } catch { throw agentXError("RUNTIME_UNAVAILABLE", LEARNING_MODEL_LIST_UNAVAILABLE); }
const readOffered = async (): Promise<OfferedEngineModelList> => {
try { const all = await offeredEngineModelList(ctx.wiring.offered, company); return { ids: all.ids.filter(isLearnableModel), names: all.names }; } catch { throw agentXError("RUNTIME_UNAVAILABLE", LEARNING_MODEL_LIST_UNAVAILABLE); }
};
const installModel = (): string | undefined => {
try { return ctx.wiring.installModel(); } catch { return undefined; }
Expand All @@ -100,8 +102,8 @@ export async function routeCompanyLearningModel(ctx: CompanyLearningModelContext
if (!parsed.success) throw agentXError("CONFIG_INVALID", LEARNING_MODEL_BODY_INVALID);
const chosen = parsed.data.model;
const previous = await readOwn();
const offered = await readOffered();
if (chosen !== null && !offered.includes(chosen)) throw agentXError("CONFIG_INVALID", LEARNING_MODEL_NOT_OFFERED_TO_COMPANY);
const list = await readOffered();
if (chosen !== null && !list.ids.includes(chosen)) throw agentXError("CONFIG_INVALID", LEARNING_MODEL_NOT_OFFERED_TO_COMPANY);

const at = new Date(ctx.now()).toISOString();
const key = companyLearningModelKey(company);
Expand All @@ -114,5 +116,5 @@ export async function routeCompanyLearningModel(ctx: CompanyLearningModelContext
await ctx.documentClient.send(new TransactWriteCommand({ TransactItems: [setting, audit] }));
} catch { throw agentXError("RUNTIME_UNAVAILABLE", LEARNING_MODEL_SETTING_UNAVAILABLE); }
companyLog(company, ctx.wiring.log)({ event: chosen === null ? "company.learning_model_cleared" : "company.learning_model_set", actor: caller.developerId });
return viewOf(chosen ?? undefined, installModel(), offered);
return viewOf(chosen ?? undefined, installModel(), list);
}
Loading
Loading