@opengeni/contracts 2.9.2 → 2.13.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/artifacts.d.ts +121 -0
  2. package/dist/atlassian.js +11 -11
  3. package/dist/{chunk-4IVHBXRI.js → chunk-7ABONTXE.js} +42 -2
  4. package/dist/chunk-7ABONTXE.js.map +1 -0
  5. package/dist/{chunk-7RMTKFJW.js → chunk-7Q6HPDY2.js} +8 -8
  6. package/dist/{chunk-AWNGBY5I.js → chunk-DPCCW6U7.js} +7395 -6619
  7. package/dist/chunk-DPCCW6U7.js.map +1 -0
  8. package/dist/{chunk-N6GRVXAJ.js → chunk-NPBM4QSK.js} +2 -2
  9. package/dist/connection-authority.js +11 -11
  10. package/dist/editable-artifact-codec-registry.js +2 -2
  11. package/dist/editable-artifact-live.js +2 -2
  12. package/dist/editable-artifact-serialized-commit.js +3 -3
  13. package/dist/editable-artifacts.js +13 -13
  14. package/dist/github-repository-contracts.d.ts +36 -0
  15. package/dist/github-repository-contracts.js +59 -0
  16. package/dist/github-repository-contracts.js.map +1 -0
  17. package/dist/github-repository.d.ts +14 -0
  18. package/dist/github-repository.js +36 -0
  19. package/dist/github-repository.js.map +1 -0
  20. package/dist/google-drive.js +12 -12
  21. package/dist/index.d.ts +809 -70
  22. package/dist/index.js +299 -135
  23. package/dist/mcp-oauth.d.ts +71 -0
  24. package/dist/model-context-inspector.d.ts +205 -0
  25. package/dist/model-picker-order.d.ts +23 -0
  26. package/dist/model-picker-order.js +42 -0
  27. package/dist/model-picker-order.js.map +1 -0
  28. package/dist/organization-membership-lifecycle.d.ts +17 -0
  29. package/dist/personal-github.js +11 -11
  30. package/dist/session-mcp-projections.d.ts +210 -0
  31. package/dist/session-titles.d.ts +35 -0
  32. package/dist/session-titles.js +9 -3
  33. package/dist/tool-catalog.d.ts +271 -0
  34. package/dist/workspace-learning-policy.d.ts +1 -1
  35. package/package.json +13 -1
  36. package/src/artifacts.ts +111 -1
  37. package/src/github-repository-contracts.ts +85 -0
  38. package/src/github-repository.ts +59 -0
  39. package/src/index.ts +486 -52
  40. package/src/mcp-oauth.ts +68 -0
  41. package/src/model-context-inspector.ts +104 -0
  42. package/src/model-picker-order.ts +87 -0
  43. package/src/organization-membership-lifecycle.ts +20 -0
  44. package/src/session-mcp-projections.ts +268 -0
  45. package/src/session-titles.ts +100 -0
  46. package/src/tool-catalog.ts +136 -0
  47. package/src/workspace-learning-policy.ts +4 -3
  48. package/dist/chunk-4IVHBXRI.js.map +0 -1
  49. package/dist/chunk-AWNGBY5I.js.map +0 -1
  50. /package/dist/{chunk-7RMTKFJW.js.map → chunk-7Q6HPDY2.js.map} +0 -0
  51. /package/dist/{chunk-N6GRVXAJ.js.map → chunk-NPBM4QSK.js.map} +0 -0
package/src/index.ts CHANGED
@@ -32,11 +32,13 @@ export * from "./editable-artifacts";
32
32
  export * from "./editable-artifact-committed-transaction";
33
33
  export * from "./editable-artifact-serialized-commit";
34
34
  export * from "./tool-catalog";
35
+ export * from "./mcp-oauth";
35
36
  export * from "./tool-result-spill";
36
37
  export * from "./interaction";
37
38
  export * from "./sandbox-file-artifacts";
38
39
  export * from "./permissions";
39
40
  export * from "./session-titles";
41
+ export * from "./session-mcp-projections";
40
42
  export * from "./session-topology-primitives";
41
43
  export * from "./agent-topology";
42
44
  export * from "./work-claims";
@@ -45,6 +47,7 @@ export {
45
47
  CreateWorkspaceArtifactRequest,
46
48
  PublishWorkspaceArtifactVersionRequest,
47
49
  RollbackWorkspaceArtifactRequest,
50
+ SetWorkspaceArtifactStatusRequest,
48
51
  WorkspaceArtifact,
49
52
  WorkspaceArtifactContentResponse,
50
53
  WorkspaceArtifactDetailResponse,
@@ -54,7 +57,11 @@ export {
54
57
  WorkspaceArtifactListQuery,
55
58
  WorkspaceArtifactListResponse,
56
59
  WorkspaceArtifactMutationResponse,
60
+ WorkspaceArtifactRequestedTools,
57
61
  WorkspaceArtifactSlug,
62
+ WorkspaceArtifactSourceBundle,
63
+ WorkspaceArtifactSourceFile,
64
+ WorkspaceArtifactSourcePath,
58
65
  WorkspaceArtifactStatus,
59
66
  WorkspaceArtifactVersion,
60
67
  WORKSPACE_ARTIFACT_CURSOR_MAX_CHARS,
@@ -62,6 +69,9 @@ export {
62
69
  WORKSPACE_ARTIFACT_HTML_MAX_UTF8_BYTES,
63
70
  WORKSPACE_ARTIFACT_LIST_DEFAULT,
64
71
  WORKSPACE_ARTIFACT_LIST_MAX,
72
+ WORKSPACE_ARTIFACT_REQUESTED_TOOLS_MAX,
73
+ WORKSPACE_ARTIFACT_SOURCE_MAX_FILES,
74
+ WORKSPACE_ARTIFACT_SOURCE_MAX_UTF8_BYTES,
65
75
  WORKSPACE_ARTIFACT_TITLE_MAX_CHARS,
66
76
  normalizeWorkspaceArtifactSlug,
67
77
  } from "./artifacts";
@@ -760,7 +770,7 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
760
770
  "goal_set",
761
771
  "goal_update",
762
772
  "goal_progress",
763
- "goal_wait",
773
+ "wait_for_input",
764
774
  "goal_complete",
765
775
  "goal_pause",
766
776
  "memory_search",
@@ -800,6 +810,7 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
800
810
  "session_get",
801
811
  "session_events",
802
812
  "session_wait",
813
+ "command_wait",
803
814
  "session_create",
804
815
  "session_send_message",
805
816
  "session_pause",
@@ -891,6 +902,8 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
891
902
  "artifacts_create",
892
903
  "artifacts_publish",
893
904
  "artifacts_rollback",
905
+ "artifacts_archive",
906
+ "artifacts_restore",
894
907
  "sandbox_file_publish",
895
908
  "editable_artifact_list",
896
909
  "editable_artifact_create",
@@ -2106,7 +2119,7 @@ export const HistoricalMemoryPromptMode = z.enum(["legacy_standing", "retrieval_
2106
2119
  export type HistoricalMemoryPromptMode = z.infer<typeof HistoricalMemoryPromptMode>;
2107
2120
 
2108
2121
  // Validates the KNOWN keys of workspaces.settings; passthrough keeps unknown
2109
- // (future) keys rather than stripping them. memoryEnabled defaults off and the
2122
+ // (future) keys rather than stripping them. memoryEnabled defaults on and the
2110
2123
  // Memory V1 prompt mode is always retrieval-only composition;
2111
2124
  // voiceInput defaults to enabled when the deployment has a provider.
2112
2125
  export const WorkspaceSettingsSchema = z
@@ -2143,10 +2156,12 @@ export const WorkspaceSettingsSchema = z
2143
2156
  .passthrough();
2144
2157
  export type WorkspaceSettings = z.infer<typeof WorkspaceSettingsSchema>;
2145
2158
 
2146
- // Resolve the effective memoryEnabled flag from a raw settings bag (default off).
2147
- export function resolveWorkspaceMemoryEnabled(settings: unknown): boolean {
2148
- const parsed = WorkspaceSettingsSchema.safeParse(settings ?? {});
2149
- return parsed.success ? parsed.data.memoryEnabled === true : false;
2159
+ // Resolve the effective memoryEnabled flag from a raw settings bag. Omission
2160
+ // defaults on; malformed settings still fail closed so invalid state cannot
2161
+ // unexpectedly enable durable retention.
2162
+ export function resolveWorkspaceMemoryEnabled(settings?: unknown): boolean {
2163
+ const parsed = WorkspaceSettingsSchema.safeParse(settings === undefined ? {} : settings);
2164
+ return parsed.success ? parsed.data.memoryEnabled !== false : false;
2150
2165
  }
2151
2166
 
2152
2167
  /** Explicit defaults for new chats/schedules, or null for deployment defaults. */
@@ -2300,6 +2315,127 @@ export const UpdateWorkspaceModelPolicyRequest = z.object({
2300
2315
  });
2301
2316
  export type UpdateWorkspaceModelPolicyRequest = z.infer<typeof UpdateWorkspaceModelPolicyRequest>;
2302
2317
 
2318
+ export const WORKSPACE_GATEWAY_CUSTOM_MODEL_UPSTREAM_ID_MAX_LENGTH = 238;
2319
+
2320
+ export const CreateWorkspaceGatewayCustomModelRequest = z
2321
+ .object({
2322
+ operationId: z.string().uuid(),
2323
+ upstreamModelId: z
2324
+ .string()
2325
+ .max(WORKSPACE_GATEWAY_CUSTOM_MODEL_UPSTREAM_ID_MAX_LENGTH)
2326
+ .regex(/^[!-{}-~]+$/),
2327
+ label: z
2328
+ .string()
2329
+ .min(1)
2330
+ .max(128)
2331
+ .refine((value) => new TextEncoder().encode(value).byteLength <= 128, {
2332
+ message: "label must be at most 128 UTF-8 bytes",
2333
+ })
2334
+ .refine((value) => !/[\r\n|]/u.test(value), {
2335
+ message: "label must not contain newlines or the | field separator",
2336
+ })
2337
+ .optional(),
2338
+ })
2339
+ .strict();
2340
+ export type CreateWorkspaceGatewayCustomModelRequest = z.infer<
2341
+ typeof CreateWorkspaceGatewayCustomModelRequest
2342
+ >;
2343
+
2344
+ export const DeleteWorkspaceGatewayCustomModelRequest = z
2345
+ .object({
2346
+ expectedVersion: z.number().int().positive(),
2347
+ operationId: z.string().uuid(),
2348
+ })
2349
+ .strict();
2350
+ export type DeleteWorkspaceGatewayCustomModelRequest = z.infer<
2351
+ typeof DeleteWorkspaceGatewayCustomModelRequest
2352
+ >;
2353
+
2354
+ export const WorkspaceGatewayCustomModel = z.object({
2355
+ id: z.string().uuid(),
2356
+ upstreamModelId: z.string(),
2357
+ label: z.string().nullable(),
2358
+ version: z.number().int().positive(),
2359
+ createdAt: z.string().datetime(),
2360
+ updatedAt: z.string().datetime(),
2361
+ });
2362
+ export type WorkspaceGatewayCustomModel = z.infer<typeof WorkspaceGatewayCustomModel>;
2363
+
2364
+ export const WorkspaceGatewayCustomModelsResponse = z.object({
2365
+ models: z.array(WorkspaceGatewayCustomModel),
2366
+ });
2367
+ export type WorkspaceGatewayCustomModelsResponse = z.infer<
2368
+ typeof WorkspaceGatewayCustomModelsResponse
2369
+ >;
2370
+
2371
+ export const CreateWorkspaceOpenRouterCustomModelRequest = CreateWorkspaceGatewayCustomModelRequest;
2372
+ export type CreateWorkspaceOpenRouterCustomModelRequest = z.infer<
2373
+ typeof CreateWorkspaceOpenRouterCustomModelRequest
2374
+ >;
2375
+
2376
+ export const DeleteWorkspaceOpenRouterCustomModelRequest = DeleteWorkspaceGatewayCustomModelRequest;
2377
+ export type DeleteWorkspaceOpenRouterCustomModelRequest = z.infer<
2378
+ typeof DeleteWorkspaceOpenRouterCustomModelRequest
2379
+ >;
2380
+
2381
+ export const WorkspaceOpenRouterCustomModel = WorkspaceGatewayCustomModel;
2382
+ export type WorkspaceOpenRouterCustomModel = z.infer<typeof WorkspaceOpenRouterCustomModel>;
2383
+
2384
+ export const WorkspaceOpenRouterCustomModelsResponse = z.object({
2385
+ models: z.array(WorkspaceOpenRouterCustomModel),
2386
+ });
2387
+ export type WorkspaceOpenRouterCustomModelsResponse = z.infer<
2388
+ typeof WorkspaceOpenRouterCustomModelsResponse
2389
+ >;
2390
+
2391
+ export const CreateOrganizationProviderCustomModelRequest =
2392
+ CreateWorkspaceGatewayCustomModelRequest;
2393
+ export type CreateOrganizationProviderCustomModelRequest = z.infer<
2394
+ typeof CreateOrganizationProviderCustomModelRequest
2395
+ >;
2396
+ export const DeleteOrganizationProviderCustomModelRequest =
2397
+ DeleteWorkspaceGatewayCustomModelRequest;
2398
+ export type DeleteOrganizationProviderCustomModelRequest = z.infer<
2399
+ typeof DeleteOrganizationProviderCustomModelRequest
2400
+ >;
2401
+ export const OrganizationProviderCustomModel = WorkspaceGatewayCustomModel;
2402
+ export type OrganizationProviderCustomModel = z.infer<typeof OrganizationProviderCustomModel>;
2403
+ export const OrganizationProviderCustomModelsResponse = z.object({
2404
+ models: z.array(OrganizationProviderCustomModel),
2405
+ });
2406
+ export type OrganizationProviderCustomModelsResponse = z.infer<
2407
+ typeof OrganizationProviderCustomModelsResponse
2408
+ >;
2409
+
2410
+ export const OrganizationModelProviderKind = z.enum(["vercel_gateway", "openrouter"]);
2411
+ export type OrganizationModelProviderKind = z.infer<typeof OrganizationModelProviderKind>;
2412
+ export const OrganizationModelProviderConnectionResponse = z.object({
2413
+ providerKind: OrganizationModelProviderKind,
2414
+ status: z.enum(["active", "revoked"]),
2415
+ version: z.number().int().positive(),
2416
+ createdAt: z.string().datetime(),
2417
+ updatedAt: z.string().datetime(),
2418
+ });
2419
+ export type OrganizationModelProviderConnectionResponse = z.infer<
2420
+ typeof OrganizationModelProviderConnectionResponse
2421
+ >;
2422
+ export const UpsertOrganizationModelProviderConnectionRequest = z
2423
+ .object({
2424
+ operationId: z.string().uuid(),
2425
+ expectedVersion: z.number().int().nonnegative().optional(),
2426
+ apiKey: z.string().trim().min(1).max(8192),
2427
+ })
2428
+ .strict();
2429
+ export type UpsertOrganizationModelProviderConnectionRequest = z.infer<
2430
+ typeof UpsertOrganizationModelProviderConnectionRequest
2431
+ >;
2432
+ export const RevokeOrganizationModelProviderConnectionRequest = z
2433
+ .object({ operationId: z.string().uuid(), expectedVersion: z.number().int().positive() })
2434
+ .strict();
2435
+ export type RevokeOrganizationModelProviderConnectionRequest = z.infer<
2436
+ typeof RevokeOrganizationModelProviderConnectionRequest
2437
+ >;
2438
+
2303
2439
  const turnInitiatorIdentityFields = {
2304
2440
  subjectId: z.string().min(1),
2305
2441
  /** Immutable display snapshot; never an authorization input. */
@@ -3252,6 +3388,9 @@ export const InsightsModelUsageRow = z.object({
3252
3388
  /** Hypothetical provider-rate USD; never an OpenGeni charge. */
3253
3389
  estimatedProviderUsd: z.number().nonnegative(),
3254
3390
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3391
+ /** OpenGeni credit price at the captured rate, whether or not credits paid for the call. */
3392
+ equivalentCreditUsd: z.number().nonnegative(),
3393
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3255
3394
  });
3256
3395
  export type InsightsModelUsageRow = z.infer<typeof InsightsModelUsageRow>;
3257
3396
 
@@ -3262,6 +3401,9 @@ export const InsightsSeriesPoint = z.object({
3262
3401
  /** UTC hour/day-bucketed hypothetical provider-rate USD for calls with captured pricing. */
3263
3402
  estimatedProviderUsd: z.number().nonnegative(),
3264
3403
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3404
+ /** UTC hour/day-bucketed equivalent OpenGeni credit price for calls with captured pricing. */
3405
+ equivalentCreditUsd: z.number().nonnegative(),
3406
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3265
3407
  warmSeconds: z.number().nonnegative(),
3266
3408
  inputTokens: z.number().nonnegative(),
3267
3409
  outputTokens: z.number().nonnegative(),
@@ -3296,6 +3438,8 @@ export const InsightsSpendDriver = z.object({
3296
3438
  creditUsd: z.number().nonnegative(),
3297
3439
  estimatedProviderUsd: z.number().nonnegative(),
3298
3440
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3441
+ equivalentCreditUsd: z.number().nonnegative(),
3442
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3299
3443
  tokens: z.number().nonnegative(),
3300
3444
  cacheHitPct: z.number().int().min(0).max(100),
3301
3445
  pctOfCreditUsd: z.number().int().min(0).max(100),
@@ -3348,6 +3492,8 @@ export const InsightsScheduleRow = z.object({
3348
3492
  creditUsd: z.number().nonnegative().nullable(),
3349
3493
  estimatedProviderUsd: z.number().nonnegative().nullable(),
3350
3494
  estimatedProviderCostKnownCalls: z.number().int().nonnegative().nullable(),
3495
+ equivalentCreditUsd: z.number().nonnegative().nullable(),
3496
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative().nullable(),
3351
3497
  tokens: z.number().nonnegative().nullable(),
3352
3498
  cacheHitPct: z.number().int().min(0).max(100).nullable(),
3353
3499
  billing: InsightsBillingPath.nullable(),
@@ -3375,6 +3521,8 @@ export const InsightsModelCallRow = z.object({
3375
3521
  creditUsd: z.number().nonnegative(),
3376
3522
  /** Hypothetical provider-rate USD; null when historical pricing is unavailable. */
3377
3523
  estimatedProviderUsd: z.number().nonnegative().nullable(),
3524
+ /** Equivalent OpenGeni credit price; null when historical pricing is unavailable. */
3525
+ equivalentCreditUsd: z.number().nonnegative().nullable(),
3378
3526
  pricingSource: InsightsPricingSource.nullable(),
3379
3527
  });
3380
3528
  export type InsightsModelCallRow = z.infer<typeof InsightsModelCallRow>;
@@ -3423,6 +3571,11 @@ export const WorkspaceInsightsSnapshot = z.object({
3423
3571
  priorEstimatedProviderUsd: z.number().nonnegative(),
3424
3572
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3425
3573
  priorEstimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3574
+ /** Equivalent OpenGeni credit price across calls whose historical price was captured. */
3575
+ equivalentCreditUsd: z.number().nonnegative(),
3576
+ priorEquivalentCreditUsd: z.number().nonnegative(),
3577
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3578
+ priorEquivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3426
3579
  modelCalls: z.number().int().nonnegative(),
3427
3580
  priorInputTokens: z.number().nonnegative(),
3428
3581
  priorTotalTokens: z.number().nonnegative(),
@@ -3847,6 +4000,8 @@ export const McpServerConnectionRef = z
3847
4000
  .object({
3848
4001
  /** Opaque host or standalone connection identifier. */
3849
4002
  connectionId: z.string().min(1).optional(),
4003
+ /** Host-owned credential authority; omission keeps OpenGeni's native connection authority. */
4004
+ authoritySource: z.literal("host").optional(),
3850
4005
  /** Stable provider family (for example github, gitlab, or azure_devops). */
3851
4006
  provider: z.string().min(1).max(128).optional(),
3852
4007
  /** Provider host or tenant domain. */
@@ -3861,6 +4016,13 @@ export const McpServerConnectionRef = z
3861
4016
  })
3862
4017
  .strict()
3863
4018
  .superRefine((reference, context) => {
4019
+ if (reference.authoritySource === "host" && !reference.connectionId) {
4020
+ context.addIssue({
4021
+ code: "custom",
4022
+ message: "host authority requires connectionId",
4023
+ path: ["connectionId"],
4024
+ });
4025
+ }
3864
4026
  if (!reference.selectedResources) return;
3865
4027
  if (!reference.connectionId) {
3866
4028
  context.addIssue({
@@ -4237,6 +4399,14 @@ export type GitHubUserInstallationAccess = GitHubInstallationSummary & {
4237
4399
  repositories: GitHubUserRepositoryAccess[];
4238
4400
  };
4239
4401
 
4402
+ export type GitHubAppRepositoryBranchPage = {
4403
+ installationId: number;
4404
+ repositoryId: number;
4405
+ defaultBranch: string;
4406
+ branches: string[];
4407
+ nextPage: number | null;
4408
+ };
4409
+
4240
4410
  export type GitHubAppApiPort = {
4241
4411
  /**
4242
4412
  * Exchange one fresh GitHub user-authorization code and prove current
@@ -4268,6 +4438,18 @@ export type GitHubAppApiPort = {
4268
4438
  installationId: number;
4269
4439
  }) => Promise<GitHubInstallationSummary | null>;
4270
4440
  listRepositories?: (input: { installationIds?: number[] }) => Promise<GitHubRepository[]>;
4441
+ /**
4442
+ * List one bounded page of branch suggestions for one exact repository.
4443
+ * Implementations must keep the provider credential server-side and scope
4444
+ * it to exactly `repositoryId`; the caller separately rechecks the durable
4445
+ * workspace binding immediately before and after this provider request.
4446
+ */
4447
+ listRepositoryBranches?: (input: {
4448
+ installationId: number;
4449
+ repositoryId: number;
4450
+ page: number;
4451
+ limit: number;
4452
+ }) => Promise<GitHubAppRepositoryBranchPage>;
4271
4453
  };
4272
4454
 
4273
4455
  export const BillingBalance = z.object({
@@ -5827,7 +6009,7 @@ export const SessionGoalContinuation = z.object({
5827
6009
  nextAttemptAt: z.string().datetime({ offset: true }).nullable(),
5828
6010
  lastError: z.string().nullable(),
5829
6011
  /**
5830
- * The agent's stated reason for a `held_for_input` hold (`goal_wait`), so a
6012
+ * The agent's stated reason for a `held_for_input` hold (`wait_for_input`), so a
5831
6013
  * human can see why the goal is waiting and until when (`nextAttemptAt`).
5832
6014
  * Null for every other state; omitted by older servers.
5833
6015
  */
@@ -7324,6 +7506,8 @@ export const SessionSystemUpdateKind = z.enum([
7324
7506
  "goal_continuation",
7325
7507
  "agent_message",
7326
7508
  "agent_steer_instruction",
7509
+ "session_wait_timeout",
7510
+ "background_command_result",
7327
7511
  "child_terminal_result",
7328
7512
  "media_generation_result",
7329
7513
  "child_requires_action",
@@ -7337,7 +7521,7 @@ export type SessionSystemUpdateKind = z.infer<typeof SessionSystemUpdateKind>;
7337
7521
  /**
7338
7522
  * How a newly pending machine input affects an idle receiving session.
7339
7523
  * `immediate` registers a workflow wake in the same commit (the behaviour of
7340
- * every pre-existing kind) and ends a `goal_wait` hold at the next idle
7524
+ * every pre-existing kind) and ends a `wait_for_input` hold at the next idle
7341
7525
  * evaluation; `deferred` only inserts the durable pending row plus its
7342
7526
  * `system.update.pending` event and is delivered coalesced with the next claim.
7343
7527
  */
@@ -7351,6 +7535,8 @@ export const SESSION_SYSTEM_UPDATE_WAKE_CLASS: Record<
7351
7535
  goal_continuation: "immediate",
7352
7536
  agent_message: "immediate",
7353
7537
  agent_steer_instruction: "immediate",
7538
+ session_wait_timeout: "immediate",
7539
+ background_command_result: "immediate",
7354
7540
  child_terminal_result: "immediate",
7355
7541
  media_generation_result: "immediate",
7356
7542
  child_requires_action: "immediate",
@@ -7534,6 +7720,29 @@ export const SessionSystemUpdatePayload = z.discriminatedUnion("type", [
7534
7720
  operationId: z.string().uuid(),
7535
7721
  })
7536
7722
  .passthrough(),
7723
+ z
7724
+ .object({
7725
+ type: z.literal("session_wait_timeout"),
7726
+ waitTurnId: z.string().uuid(),
7727
+ deadlineAt: z.string().datetime({ offset: true }),
7728
+ reason: boundedUtf8String(2 * 1024),
7729
+ })
7730
+ .passthrough(),
7731
+ z
7732
+ .object({
7733
+ type: z.literal("background_command_result"),
7734
+ commandId: z.string().uuid(),
7735
+ state: z.enum(["exited", "lost"]),
7736
+ exitCode: z.number().int().nullable(),
7737
+ reason: boundedUtf8String(512),
7738
+ outputLocator: z
7739
+ .object({
7740
+ eventType: z.literal("sandbox.command.output.delta"),
7741
+ commandId: z.string().uuid(),
7742
+ })
7743
+ .strict(),
7744
+ })
7745
+ .passthrough(),
7537
7746
  z
7538
7747
  .object({
7539
7748
  type: z.literal("child_terminal_result"),
@@ -8787,6 +8996,10 @@ export const ScheduledTaskRunAcceptedExecution = /* @__PURE__ */ z
8787
8996
  resolvedModel: z.string().min(1),
8788
8997
  resolvedReasoningEffort: ReasoningEffort,
8789
8998
  resolvedLatencyMode: LatencyMode,
8999
+ /** Secret-safe TurnExecutionPolicyV1 accepted with this occurrence. Kept
9000
+ * structurally open here because the canonical policy schema is declared
9001
+ * later in this package; consumers must parse it with TurnExecutionPolicyV1. */
9002
+ turnExecutionPolicy: z.unknown().optional(),
8790
9003
  resolvedSandboxBackend: SandboxBackend,
8791
9004
  resolvedSandboxOs: SandboxOs,
8792
9005
  resolvedTools: z.array(ToolRef).max(SCHEDULED_TASK_TOOL_MAX_COUNT),
@@ -9554,6 +9767,12 @@ export const CapabilityPackSkill = z
9554
9767
  message: "skill name must be a single path segment of letters, digits, '.', '_' or '-'",
9555
9768
  }),
9556
9769
  description: z.string().min(1).max(2048).optional(),
9770
+ // Workspace-managed Skills are available to every session in the
9771
+ // workspace. Session-selected Skills remain installed and inspectable, but
9772
+ // enter model context only when their immutable definition is attached to
9773
+ // a session explicitly. This is the hard contamination boundary for Packs
9774
+ // that guide implementation agents rather than customer-facing agents.
9775
+ activationMode: z.enum(["workspace_managed", "session_selected"]).optional(),
9557
9776
  files: z.array(CapabilityPackSkillFile).min(1).max(64),
9558
9777
  })
9559
9778
  .superRefine((skill, ctx) => {
@@ -9581,8 +9800,11 @@ export type CapabilityPackSkill = z.infer<typeof CapabilityPackSkill>;
9581
9800
  // Inline skill content fixed onto one session at creation. It intentionally
9582
9801
  // uses the exact same validated directory shape as a pack skill, but has a
9583
9802
  // different semantic owner and lifecycle. Session readers can inspect it; it
9584
- // is configuration, never a secret store.
9585
- export const SessionSkill = CapabilityPackSkill;
9803
+ // is configuration, never a secret store. Pack activation policy is consumed
9804
+ // at admission and cannot become part of the session-owned artifact.
9805
+ export const SessionSkill = CapabilityPackSkill.transform(
9806
+ ({ activationMode: _activationMode, ...skill }) => skill,
9807
+ );
9586
9808
  export type SessionSkill = z.infer<typeof SessionSkill>;
9587
9809
 
9588
9810
  export const SessionSkills = z
@@ -10490,6 +10712,15 @@ function compareDescending(left: number | string, right: number | string): numbe
10490
10712
  export const ConnectionCredentialBundle = z.record(z.string(), z.unknown());
10491
10713
  export type ConnectionCredentialBundle = z.infer<typeof ConnectionCredentialBundle>;
10492
10714
 
10715
+ export const VERCEL_AI_GATEWAY_CREDENTIAL_OPERATION_ID_METADATA_KEY =
10716
+ "vercelAiGatewayCredentialOperationId" as const;
10717
+ export const VERCEL_AI_GATEWAY_CREDENTIAL_OPERATION_DIGEST_METADATA_KEY =
10718
+ "vercelAiGatewayCredentialOperationDigest" as const;
10719
+ export const OPENROUTER_CREDENTIAL_OPERATION_ID_METADATA_KEY =
10720
+ "openRouterCredentialOperationId" as const;
10721
+ export const OPENROUTER_CREDENTIAL_OPERATION_DIGEST_METADATA_KEY =
10722
+ "openRouterCredentialOperationDigest" as const;
10723
+
10493
10724
  export const CreateConnectionRequest = z.object({
10494
10725
  providerDomain: z.string().min(1),
10495
10726
  kind: ConnectionKind,
@@ -10500,6 +10731,7 @@ export const CreateConnectionRequest = z.object({
10500
10731
  grantedScopes: z.array(z.string().min(1)).default([]),
10501
10732
  expiresAt: z.string().datetime({ offset: true }).nullable().optional(),
10502
10733
  metadata: z.record(z.string(), z.unknown()).default({}),
10734
+ operationId: z.string().uuid().optional(),
10503
10735
  });
10504
10736
  export type CreateConnectionRequest = z.infer<typeof CreateConnectionRequest>;
10505
10737
 
@@ -10555,6 +10787,8 @@ export const UpdateConnectionRequest = z.object({
10555
10787
  grantedScopes: z.array(z.string().min(1)).optional(),
10556
10788
  expiresAt: z.string().datetime({ offset: true }).nullable().optional(),
10557
10789
  metadata: z.record(z.string(), z.unknown()).optional(),
10790
+ expectedVersion: z.number().int().positive().optional(),
10791
+ operationId: z.string().uuid().optional(),
10558
10792
  });
10559
10793
  export type UpdateConnectionRequest = z.infer<typeof UpdateConnectionRequest>;
10560
10794
 
@@ -10750,11 +10984,14 @@ export const CapabilityCatalogItem = z.object({
10750
10984
  /** @deprecated Compatibility explanation paired with enabled. */
10751
10985
  enabledReason: z.string().nullable().default(null),
10752
10986
  // The non-secret connection binding stored with an enabled installation.
10753
- // Workspace refs retain an exact row id. Subject refs deliberately omit it:
10754
- // each caller resolves their own visible row by provider/kind at runtime.
10987
+ // Native workspace refs retain an exact row id. Native subject refs omit it
10988
+ // so each caller resolves their own row. The first-party catalog projects a
10989
+ // host-owned installation as null for old-browser safety; the schema remains
10990
+ // tolerant of additive host projections from embedding-specific catalogs.
10755
10991
  connectionRef: z
10756
10992
  .object({
10757
10993
  connectionId: z.string().min(1).optional(),
10994
+ authoritySource: z.literal("host").optional(),
10758
10995
  providerDomain: z.string().min(1),
10759
10996
  kind: z.string().min(1),
10760
10997
  subjectScope: z.enum(["workspace", "subject"]).optional(),
@@ -11980,6 +12217,8 @@ export const SessionEventType = z.enum([
11980
12217
  "sandbox.operation.failed",
11981
12218
  "session.command.backgrounded",
11982
12219
  "session.command.finished",
12220
+ "session.wait.started",
12221
+ "session.wait.finished",
11983
12222
  "sandbox.command.output.delta",
11984
12223
  "artifact.created",
11985
12224
  "goal.set",
@@ -12185,6 +12424,8 @@ export const SESSION_EVENT_SEMANTIC_CLASS_TYPES = {
12185
12424
  control: [
12186
12425
  "session.status.changed",
12187
12426
  "session.command.backgrounded",
12427
+ "session.wait.started",
12428
+ "session.wait.finished",
12188
12429
  "session.requiresAction",
12189
12430
  "session.humanInput.requested",
12190
12431
  "user.pause",
@@ -12317,44 +12558,81 @@ export function resolveSessionEventTypeFilters(input: ResolveSessionEventTypeFil
12317
12558
  return { includeTypes: [...included], excludeTypes: [...excluded] };
12318
12559
  }
12319
12560
 
12320
- export const ToolAuthNeededPayload = z.object({
12321
- serverId: z.string().min(1),
12322
- toolName: z.string().min(1).nullable().optional(),
12323
- providerDomain: z.string().min(1),
12324
- provider: z.string().min(1).max(128).optional(),
12325
- // Embedded hosts may use an opaque connection identity; never assume an
12326
- // OpenGeni UUID on the public event wire.
12327
- connectionId: z.string().min(1).nullable().optional(),
12328
- reason: z.enum([
12329
- "missing_connection",
12330
- "expired",
12331
- "insufficient_scope",
12332
- "refresh_failed",
12333
- "personal_authority_unavailable",
12334
- "unsupported_auth",
12335
- "resource_scope_unavailable",
12336
- ]),
12337
- scopes: z.array(z.string().min(1)).optional(),
12338
- resource: z.string().min(1).optional(),
12339
- selectedResources: McpConnectionResourceScopes.optional(),
12340
- authorizationUrl: z.string().url().optional(),
12341
- subjectId: z.string().min(1).nullable().optional(),
12342
- // A catalog recommendation is still a tool-level authorization condition:
12343
- // the agent may describe and request it, but only the authenticated host UI
12344
- // can start setup. Keeping this nested and optional preserves the established
12345
- // auth-needed event for ordinary failed MCP calls.
12346
- capability: z
12347
- .object({
12348
- id: z.string().min(1).max(512),
12349
- name: z.string().min(1).max(256),
12350
- kind: CapabilityKind,
12351
- source: CapabilitySource,
12352
- action: z.enum(["connect", "add_credentials", "enable"]),
12353
- rationale: z.string().min(1).max(2000),
12354
- requiredVariables: z.array(VariableSetVariableName).max(64).default([]),
12355
- })
12356
- .optional(),
12357
- });
12561
+ export const ToolAuthNeededReason = z.enum([
12562
+ "missing_connection",
12563
+ "expired",
12564
+ "insufficient_scope",
12565
+ "refresh_failed",
12566
+ "personal_authority_unavailable",
12567
+ "unsupported_auth",
12568
+ "resource_scope_unavailable",
12569
+ ]);
12570
+ export type ToolAuthNeededReason = z.infer<typeof ToolAuthNeededReason>;
12571
+
12572
+ export const ToolAuthNeededPayload = z
12573
+ .object({
12574
+ serverId: z.string().min(1),
12575
+ toolName: z.string().min(1).nullable().optional(),
12576
+ providerDomain: z.string().min(1),
12577
+ provider: z.string().min(1).max(128).optional(),
12578
+ // Embedded hosts may use an opaque connection identity; never assume an
12579
+ // OpenGeni UUID on the public event wire.
12580
+ connectionId: z.string().min(1).nullable().optional(),
12581
+ /** The failed binding is owned by the embedding host, not OpenGeni's connection broker. */
12582
+ authoritySource: z.literal("host").optional(),
12583
+ /**
12584
+ * Legacy-compatible reason. Host-owned event writers pin this to
12585
+ * unsupported_auth so a pre-host-authority browser cannot launch native
12586
+ * OAuth for the opaque id.
12587
+ */
12588
+ reason: ToolAuthNeededReason,
12589
+ /** Exact host recovery reason consumed by host-aware clients. */
12590
+ hostReason: ToolAuthNeededReason.optional(),
12591
+ scopes: z.array(z.string().min(1)).optional(),
12592
+ resource: z.string().min(1).optional(),
12593
+ selectedResources: McpConnectionResourceScopes.optional(),
12594
+ authorizationUrl: z.string().url().optional(),
12595
+ subjectId: z.string().min(1).nullable().optional(),
12596
+ // A catalog recommendation is still a tool-level authorization condition:
12597
+ // the agent may describe and request it, but only the authenticated host UI
12598
+ // can start setup. Keeping this nested and optional preserves the established
12599
+ // auth-needed event for ordinary failed MCP calls.
12600
+ capability: z
12601
+ .object({
12602
+ id: z.string().min(1).max(512),
12603
+ name: z.string().min(1).max(256),
12604
+ kind: CapabilityKind,
12605
+ source: CapabilitySource,
12606
+ action: z.enum(["connect", "add_credentials", "enable"]),
12607
+ rationale: z.string().min(1).max(2000),
12608
+ requiredVariables: z.array(VariableSetVariableName).max(64).default([]),
12609
+ })
12610
+ .optional(),
12611
+ })
12612
+ .superRefine((payload, context) => {
12613
+ if (payload.authoritySource === "host") {
12614
+ if (payload.reason !== "unsupported_auth") {
12615
+ context.addIssue({
12616
+ code: "custom",
12617
+ message: "host auth-needed events require the legacy-safe unsupported_auth reason",
12618
+ path: ["reason"],
12619
+ });
12620
+ }
12621
+ if (!payload.hostReason) {
12622
+ context.addIssue({
12623
+ code: "custom",
12624
+ message: "host auth-needed events require hostReason",
12625
+ path: ["hostReason"],
12626
+ });
12627
+ }
12628
+ } else if (payload.hostReason) {
12629
+ context.addIssue({
12630
+ code: "custom",
12631
+ message: "hostReason is reserved for host-owned auth-needed events",
12632
+ path: ["hostReason"],
12633
+ });
12634
+ }
12635
+ });
12358
12636
  export type ToolAuthNeededPayload = z.infer<typeof ToolAuthNeededPayload>;
12359
12637
 
12360
12638
  /** A host-owned non-tool credential needed by the active run. */
@@ -12555,6 +12833,16 @@ export type TerminalPtyExitedPayload = z.infer<typeof TerminalPtyExitedPayload>;
12555
12833
  // --- A2 FileSystem request/response (NOT events; returned inline) ------------
12556
12834
  export const FsNodeType = z.enum(["file", "dir", "symlink", "other"]);
12557
12835
  export type FsNodeType = z.infer<typeof FsNodeType>;
12836
+ /** Optional identity copied from one stream-capabilities response. File callers
12837
+ * use it to fail with a retryable route conflict instead of reinterpreting a
12838
+ * canonical path after the selected sandbox or effective root changes. */
12839
+ export const FileSystemRouteIdentity = z
12840
+ .object({
12841
+ epoch: z.number().int().nonnegative(),
12842
+ root: z.string().min(1).max(4_096),
12843
+ })
12844
+ .strict();
12845
+ export type FileSystemRouteIdentity = z.infer<typeof FileSystemRouteIdentity>;
12558
12846
  // The Pierre-tree node. `children` is present only when the dir was listed with
12559
12847
  // depth>0; the tree lazy-expands via repeated depth-1 lists at deeper paths.
12560
12848
  export interface FsTreeNode {
@@ -12589,6 +12877,7 @@ export const FsListRequest = z.object({
12589
12877
  depth: z.number().int().min(0).max(8).default(1),
12590
12878
  maxEntries: z.number().int().positive().max(20_000).default(2_000),
12591
12879
  includeHidden: z.boolean().default(true),
12880
+ route: FileSystemRouteIdentity.optional(),
12592
12881
  });
12593
12882
  export type FsListRequest = z.infer<typeof FsListRequest>;
12594
12883
  export const FsListResponse = z.object({
@@ -12621,6 +12910,7 @@ export const FsReadRequest = z.object({
12621
12910
  .positive()
12622
12911
  .max(25 * 1024 * 1024)
12623
12912
  .default(5 * 1024 * 1024),
12913
+ route: FileSystemRouteIdentity.optional(),
12624
12914
  });
12625
12915
  export type FsReadRequest = z.infer<typeof FsReadRequest>;
12626
12916
  export const FsReadResponse = z.object({
@@ -12640,6 +12930,7 @@ export const FsWriteRequest = z.object({
12640
12930
  content: z.string(),
12641
12931
  overwrite: z.boolean().default(true), // false + existing path => 409
12642
12932
  createParents: z.boolean().default(true),
12933
+ route: FileSystemRouteIdentity.optional(),
12643
12934
  });
12644
12935
  export type FsWriteRequest = z.infer<typeof FsWriteRequest>;
12645
12936
  export const FsWriteResponse = z.object({
@@ -12652,6 +12943,7 @@ export type FsWriteResponse = z.infer<typeof FsWriteResponse>;
12652
12943
  export const FsDeleteRequest = z.object({
12653
12944
  path: z.string(),
12654
12945
  recursive: z.boolean().default(false), // required true to delete a non-empty dir
12946
+ route: FileSystemRouteIdentity.optional(),
12655
12947
  });
12656
12948
  export type FsDeleteRequest = z.infer<typeof FsDeleteRequest>;
12657
12949
  export const FsDeleteResponse = z.object({
@@ -12664,6 +12956,7 @@ export const FsMoveRequest = z.object({
12664
12956
  newPath: z.string(),
12665
12957
  overwrite: z.boolean().default(false), // false + existing destination => 409
12666
12958
  createParents: z.boolean().default(true),
12959
+ route: FileSystemRouteIdentity.optional(),
12667
12960
  });
12668
12961
  export type FsMoveRequest = z.infer<typeof FsMoveRequest>;
12669
12962
  export const FsMoveResponse = z.object({
@@ -12676,6 +12969,7 @@ export type FsMoveResponse = z.infer<typeof FsMoveResponse>;
12676
12969
  export const FsMkdirRequest = z.object({
12677
12970
  path: z.string(),
12678
12971
  recursive: z.boolean().default(true), // false + existing path => 400
12972
+ route: FileSystemRouteIdentity.optional(),
12679
12973
  });
12680
12974
  export type FsMkdirRequest = z.infer<typeof FsMkdirRequest>;
12681
12975
  export const FsMkdirResponse = z.object({
@@ -13123,6 +13417,8 @@ export const SessionEvent = z.object({
13123
13417
  workspaceId: z.string().uuid(),
13124
13418
  sessionId: z.string().uuid(),
13125
13419
  sequence: z.number().int().positive(),
13420
+ /** Server-owned durable high-water mark for a synthetic compact event. */
13421
+ coveredThrough: z.number().int().positive().optional(),
13126
13422
  type: SessionEventType,
13127
13423
  payload: z.unknown().default({}),
13128
13424
  occurredAt: z.string(),
@@ -13712,6 +14008,15 @@ export function boundSessionEvent(
13712
14008
  const turnGeneration = canonicalSessionEventGeneration(source.turnGeneration);
13713
14009
  const turnAttemptId = canonicalOptionalSessionEventUuid(source.turnAttemptId);
13714
14010
  const duplicateOfEventId = canonicalOptionalSessionEventUuid(source.duplicateOfEventId);
14011
+ const rawCoveredThrough = source.coveredThrough.readable
14012
+ ? source.coveredThrough.value
14013
+ : undefined;
14014
+ const coveredThrough =
14015
+ typeof rawCoveredThrough === "number" &&
14016
+ Number.isSafeInteger(rawCoveredThrough) &&
14017
+ rawCoveredThrough >= sequence
14018
+ ? rawCoveredThrough
14019
+ : undefined;
13715
14020
  const envelopeFields = [
13716
14021
  sessionEventCustomSerializerProjection(event),
13717
14022
  sessionEventAdditionalTopLevelFieldProjection(event),
@@ -13747,6 +14052,14 @@ export function boundSessionEvent(
13747
14052
  source.duplicateReason.readable,
13748
14053
  )
13749
14054
  : null,
14055
+ !source.coveredThrough.readable || rawCoveredThrough !== coveredThrough
14056
+ ? sessionEventEnvelopeFieldProjection(
14057
+ "coveredThrough",
14058
+ rawCoveredThrough,
14059
+ coveredThrough,
14060
+ source.coveredThrough.readable,
14061
+ )
14062
+ : null,
13750
14063
  ...sessionEventCanonicalFieldProjections(source, {
13751
14064
  id,
13752
14065
  workspaceId,
@@ -13789,6 +14102,7 @@ export function boundSessionEvent(
13789
14102
  workspaceId,
13790
14103
  sessionId,
13791
14104
  sequence,
14105
+ ...(coveredThrough === undefined ? {} : { coveredThrough }),
13792
14106
  type: typeIsSafe ? (rawType as SessionEvent["type"]) : "session.event.envelope_omitted",
13793
14107
  payload,
13794
14108
  occurredAt,
@@ -13809,6 +14123,7 @@ export function boundSessionEvent(
13809
14123
  workspaceId,
13810
14124
  sessionId,
13811
14125
  sequence,
14126
+ ...(coveredThrough === undefined ? {} : { coveredThrough }),
13812
14127
  type: "session.event.envelope_omitted",
13813
14128
  payload: boundSessionEventPayload(
13814
14129
  {
@@ -13907,6 +14222,7 @@ const SESSION_EVENT_OWN_DATA_FIELDS = [
13907
14222
  "workspaceId",
13908
14223
  "sessionId",
13909
14224
  "sequence",
14225
+ "coveredThrough",
13910
14226
  "type",
13911
14227
  "payload",
13912
14228
  "occurredAt",
@@ -14155,6 +14471,17 @@ export const CreateSessionRequest = withVariableSetIdAlias(
14155
14471
  // Inline skills are fixed onto the session. Child omission inherits the
14156
14472
  // trusted parent's selection; an explicit array, including [], wins.
14157
14473
  skills: SessionSkills.default([]),
14474
+ // Immutable workspace Skill identities to copy onto this session at
14475
+ // creation. This is the explicit opt-in path for session-selected Pack
14476
+ // Skills: installation alone never exposes them to model context. Child
14477
+ // omission still inherits the parent's already-materialized session Skills.
14478
+ installedSkillIds: z
14479
+ .array(z.string().min(1).max(512))
14480
+ .max(32)
14481
+ .refine((ids) => new Set(ids).size === ids.length, {
14482
+ message: "installed Skill identities must be unique",
14483
+ })
14484
+ .optional(),
14158
14485
  // The same child omission rule applies to selected MCP tool refs. Top-level
14159
14486
  // omission still applies workspace-default capability MCP tools; explicit []
14160
14487
  // suppresses those defaults (the first-party OpenGeni server remains added).
@@ -15534,6 +15861,12 @@ export const ModelCredentialSourceV1 =
15534
15861
  mechanism: z.literal("api_key"),
15535
15862
  })
15536
15863
  .strict(),
15864
+ z
15865
+ .object({
15866
+ kind: z.literal("organization_connection"),
15867
+ mechanism: z.literal("api_key"),
15868
+ })
15869
+ .strict(),
15537
15870
  ]),
15538
15871
  );
15539
15872
  export type ModelCredentialSourceV1 = z.infer<typeof ModelCredentialSourceV1>;
@@ -15552,13 +15885,23 @@ export const ModelBillingAttributionV1 =
15552
15885
  /* @__PURE__ */ defineModelContractSchema(() =>
15553
15886
  z
15554
15887
  .object({
15555
- upstreamPayer: z.enum(["deployment", "workspace", "connected_subscription"]),
15888
+ upstreamPayer: z.enum([
15889
+ "deployment",
15890
+ "workspace",
15891
+ "organization",
15892
+ "connected_subscription",
15893
+ ]),
15556
15894
  metering: z.enum(["opengeni_credits", "external"]),
15557
15895
  })
15558
15896
  .strict(),
15559
15897
  );
15560
15898
  export type ModelBillingAttributionV1 = z.infer<typeof ModelBillingAttributionV1>;
15561
15899
 
15900
+ export const ModelCostClassV1 = /* @__PURE__ */ defineModelContractSchema(() =>
15901
+ z.enum(["free", "credits", "subscription", "workspace", "organization"]),
15902
+ );
15903
+ export type ModelCostClassV1 = z.infer<typeof ModelCostClassV1>;
15904
+
15562
15905
  export const TURN_EXECUTION_POLICY_METADATA_KEY = "turnExecutionPolicyV1" as const;
15563
15906
 
15564
15907
  export const TurnExecutionModelSourceV1 =
@@ -15628,6 +15971,92 @@ export const TurnExecutionPolicyV1 = /* @__PURE__ */ defineModelContractSchema((
15628
15971
  );
15629
15972
  export type TurnExecutionPolicyV1 = z.infer<typeof TurnExecutionPolicyV1>;
15630
15973
 
15974
+ /**
15975
+ * Secret-safe Codex allocator policy accepted with the first durable lease of
15976
+ * a logical turn. Account ids are policy references only; credential material
15977
+ * and provider tokens must never be stored here.
15978
+ */
15979
+ export const CODEX_CREDENTIAL_POLICY_SNAPSHOT_METADATA_KEY =
15980
+ "codexCredentialPolicySnapshotV1" as const;
15981
+
15982
+ export const CodexCredentialPolicySnapshotV1 = /* @__PURE__ */ defineModelContractSchema(() =>
15983
+ z
15984
+ .object({
15985
+ schemaVersion: z.literal(1),
15986
+ activeCredentialId: z.string().min(1).max(256).nullable(),
15987
+ rotationEnabled: z.boolean(),
15988
+ rotationStrategy: z.string().min(1).max(64),
15989
+ /** Effective allocator source; absent only on pre-source snapshots. */
15990
+ source: z.enum(["workspace", "organization", "disabled"]).optional(),
15991
+ pinnedCredentialId: z.string().min(1).max(256).nullable(),
15992
+ pinSource: z.enum(["manual", "policy"]).nullable(),
15993
+ lastCredentialId: z.string().min(1).max(256).nullable(),
15994
+ })
15995
+ .strict()
15996
+ .superRefine((policy, context) => {
15997
+ if ((policy.pinnedCredentialId === null) !== (policy.pinSource === null)) {
15998
+ context.addIssue({
15999
+ code: "custom",
16000
+ path: ["pinSource"],
16001
+ message: "pinnedCredentialId and pinSource must both be null or both be present",
16002
+ });
16003
+ }
16004
+ }),
16005
+ );
16006
+ export type CodexCredentialPolicySnapshotV1 = z.infer<typeof CodexCredentialPolicySnapshotV1>;
16007
+
16008
+ export type CodexCredentialPolicySnapshotReadV1 =
16009
+ | { kind: "absent" }
16010
+ | { kind: "valid"; policy: CodexCredentialPolicySnapshotV1 };
16011
+
16012
+ /**
16013
+ * Read the accepted Codex allocator policy from turn metadata. A present but
16014
+ * malformed snapshot fails closed; only a missing key is legacy metadata.
16015
+ */
16016
+ export function readCodexCredentialPolicySnapshotV1(
16017
+ metadata: unknown,
16018
+ ): CodexCredentialPolicySnapshotReadV1 {
16019
+ if (metadata === null || metadata === undefined) {
16020
+ return { kind: "absent" };
16021
+ }
16022
+ if (typeof metadata !== "object" || Array.isArray(metadata)) {
16023
+ throw new Error(
16024
+ "Malformed Codex credential policy snapshot metadata: turn metadata is not an object",
16025
+ );
16026
+ }
16027
+ const record = metadata as Record<string, unknown>;
16028
+ if (
16029
+ !Object.prototype.hasOwnProperty.call(record, CODEX_CREDENTIAL_POLICY_SNAPSHOT_METADATA_KEY)
16030
+ ) {
16031
+ return { kind: "absent" };
16032
+ }
16033
+ const parsed = CodexCredentialPolicySnapshotV1.safeParse(
16034
+ record[CODEX_CREDENTIAL_POLICY_SNAPSHOT_METADATA_KEY],
16035
+ );
16036
+ if (!parsed.success) {
16037
+ const paths = [
16038
+ ...new Set(
16039
+ parsed.error.issues.map((issue) =>
16040
+ issue.path.length === 0 ? "policy" : `policy.${issue.path.join(".")}`,
16041
+ ),
16042
+ ),
16043
+ ].join(", ");
16044
+ throw new Error(`Malformed Codex credential policy snapshot metadata at ${paths || "policy"}`);
16045
+ }
16046
+ return { kind: "valid", policy: parsed.data };
16047
+ }
16048
+
16049
+ /** Merge a trusted Codex allocator policy snapshot into turn metadata. */
16050
+ export function metadataWithCodexCredentialPolicySnapshotV1(
16051
+ metadata: Readonly<Record<string, unknown>> | null | undefined,
16052
+ policy: CodexCredentialPolicySnapshotV1,
16053
+ ): Record<string, unknown> {
16054
+ return {
16055
+ ...(metadata ?? {}),
16056
+ [CODEX_CREDENTIAL_POLICY_SNAPSHOT_METADATA_KEY]: CodexCredentialPolicySnapshotV1.parse(policy),
16057
+ };
16058
+ }
16059
+
15631
16060
  export type TurnExecutionPolicyReadV1 =
15632
16061
  | { kind: "absent" }
15633
16062
  | { kind: "valid"; policy: TurnExecutionPolicyV1 };
@@ -15709,6 +16138,7 @@ export const ModelPricingV1 = /* @__PURE__ */ defineModelContractSchema(() =>
15709
16138
  z.object({
15710
16139
  inputMicrosPerMillionTokens: z.number().int().nonnegative(),
15711
16140
  cachedInputMicrosPerMillionTokens: z.number().int().nonnegative().optional(),
16141
+ cacheWriteMicrosPerMillionTokens: z.number().int().nonnegative().optional(),
15712
16142
  outputMicrosPerMillionTokens: z.number().int().nonnegative(),
15713
16143
  marginBps: z.number().int().min(0).max(100_000).optional(),
15714
16144
  }),
@@ -15746,7 +16176,9 @@ export const ClientModel = /* @__PURE__ */ defineModelContractSchema(() =>
15746
16176
  provider: z.string(), // provider id
15747
16177
  providerLabel: z.string(),
15748
16178
  api: z.enum(["responses", "chat"]),
15749
- source: z.enum(["opengeni", "codex", "supergrok", "workspace_gateway"]).optional(),
16179
+ source: z
16180
+ .enum(["opengeni", "codex", "supergrok", "workspace_gateway", "openrouter"])
16181
+ .optional(),
15750
16182
  contextWindowTokens: z.number().int().positive().optional(),
15751
16183
  // Additive normalized definition metadata. Optional so older server payloads
15752
16184
  // remain parseable; current servers project the complete V1 set.
@@ -15768,6 +16200,7 @@ export const ClientModel = /* @__PURE__ */ defineModelContractSchema(() =>
15768
16200
  .optional(),
15769
16201
  credentialSource: ModelCredentialSourceV1.optional(),
15770
16202
  billing: ModelBillingAttributionV1.optional(),
16203
+ cost: ModelCostClassV1.optional(),
15771
16204
  capabilities: ModelCapabilitiesV1.optional(),
15772
16205
  pricing: ModelPricingScheduleV1.optional(),
15773
16206
  definitionVersion: z
@@ -16062,6 +16495,7 @@ export * from "./xai-provider-account-authority";
16062
16495
  export * from "./workspace-instruction-policies";
16063
16496
  export * from "./company-profile";
16064
16497
  export * from "./company-brain";
16498
+ export * from "./model-context-inspector";
16065
16499
  export * from "./workspace-learning-policy";
16066
16500
  export * from "./workspace-learning-administration";
16067
16501
  export * from "./workspace-state";