@opengeni/contracts 2.9.2 → 2.11.1-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 (41) hide show
  1. package/dist/atlassian.js +11 -11
  2. package/dist/{chunk-AWNGBY5I.js → chunk-6HOHS44G.js} +230 -29
  3. package/dist/chunk-6HOHS44G.js.map +1 -0
  4. package/dist/{chunk-4IVHBXRI.js → chunk-7ABONTXE.js} +42 -2
  5. package/dist/chunk-7ABONTXE.js.map +1 -0
  6. package/dist/{chunk-7RMTKFJW.js → chunk-7Q6HPDY2.js} +8 -8
  7. package/dist/{chunk-N6GRVXAJ.js → chunk-NPBM4QSK.js} +2 -2
  8. package/dist/connection-authority.js +11 -11
  9. package/dist/editable-artifact-codec-registry.js +2 -2
  10. package/dist/editable-artifact-live.js +2 -2
  11. package/dist/editable-artifact-serialized-commit.js +3 -3
  12. package/dist/editable-artifacts.js +13 -13
  13. package/dist/github-repository-contracts.d.ts +36 -0
  14. package/dist/github-repository-contracts.js +59 -0
  15. package/dist/github-repository-contracts.js.map +1 -0
  16. package/dist/github-repository.d.ts +14 -0
  17. package/dist/github-repository.js +36 -0
  18. package/dist/github-repository.js.map +1 -0
  19. package/dist/google-drive.js +12 -12
  20. package/dist/index.d.ts +492 -17
  21. package/dist/index.js +191 -135
  22. package/dist/model-picker-order.d.ts +23 -0
  23. package/dist/model-picker-order.js +42 -0
  24. package/dist/model-picker-order.js.map +1 -0
  25. package/dist/organization-membership-lifecycle.d.ts +17 -0
  26. package/dist/personal-github.js +11 -11
  27. package/dist/session-titles.d.ts +35 -0
  28. package/dist/session-titles.js +9 -3
  29. package/dist/workspace-learning-policy.d.ts +1 -1
  30. package/package.json +13 -1
  31. package/src/github-repository-contracts.ts +85 -0
  32. package/src/github-repository.ts +59 -0
  33. package/src/index.ts +336 -49
  34. package/src/model-picker-order.ts +87 -0
  35. package/src/organization-membership-lifecycle.ts +20 -0
  36. package/src/session-titles.ts +100 -0
  37. package/src/workspace-learning-policy.ts +4 -3
  38. package/dist/chunk-4IVHBXRI.js.map +0 -1
  39. package/dist/chunk-AWNGBY5I.js.map +0 -1
  40. /package/dist/{chunk-7RMTKFJW.js.map → chunk-7Q6HPDY2.js.map} +0 -0
  41. /package/dist/{chunk-N6GRVXAJ.js.map → chunk-NPBM4QSK.js.map} +0 -0
package/src/index.ts CHANGED
@@ -2106,7 +2106,7 @@ export const HistoricalMemoryPromptMode = z.enum(["legacy_standing", "retrieval_
2106
2106
  export type HistoricalMemoryPromptMode = z.infer<typeof HistoricalMemoryPromptMode>;
2107
2107
 
2108
2108
  // Validates the KNOWN keys of workspaces.settings; passthrough keeps unknown
2109
- // (future) keys rather than stripping them. memoryEnabled defaults off and the
2109
+ // (future) keys rather than stripping them. memoryEnabled defaults on and the
2110
2110
  // Memory V1 prompt mode is always retrieval-only composition;
2111
2111
  // voiceInput defaults to enabled when the deployment has a provider.
2112
2112
  export const WorkspaceSettingsSchema = z
@@ -2143,10 +2143,12 @@ export const WorkspaceSettingsSchema = z
2143
2143
  .passthrough();
2144
2144
  export type WorkspaceSettings = z.infer<typeof WorkspaceSettingsSchema>;
2145
2145
 
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;
2146
+ // Resolve the effective memoryEnabled flag from a raw settings bag. Omission
2147
+ // defaults on; malformed settings still fail closed so invalid state cannot
2148
+ // unexpectedly enable durable retention.
2149
+ export function resolveWorkspaceMemoryEnabled(settings?: unknown): boolean {
2150
+ const parsed = WorkspaceSettingsSchema.safeParse(settings === undefined ? {} : settings);
2151
+ return parsed.success ? parsed.data.memoryEnabled !== false : false;
2150
2152
  }
2151
2153
 
2152
2154
  /** Explicit defaults for new chats/schedules, or null for deployment defaults. */
@@ -2300,6 +2302,127 @@ export const UpdateWorkspaceModelPolicyRequest = z.object({
2300
2302
  });
2301
2303
  export type UpdateWorkspaceModelPolicyRequest = z.infer<typeof UpdateWorkspaceModelPolicyRequest>;
2302
2304
 
2305
+ export const WORKSPACE_GATEWAY_CUSTOM_MODEL_UPSTREAM_ID_MAX_LENGTH = 238;
2306
+
2307
+ export const CreateWorkspaceGatewayCustomModelRequest = z
2308
+ .object({
2309
+ operationId: z.string().uuid(),
2310
+ upstreamModelId: z
2311
+ .string()
2312
+ .max(WORKSPACE_GATEWAY_CUSTOM_MODEL_UPSTREAM_ID_MAX_LENGTH)
2313
+ .regex(/^[!-{}-~]+$/),
2314
+ label: z
2315
+ .string()
2316
+ .min(1)
2317
+ .max(128)
2318
+ .refine((value) => new TextEncoder().encode(value).byteLength <= 128, {
2319
+ message: "label must be at most 128 UTF-8 bytes",
2320
+ })
2321
+ .refine((value) => !/[\r\n|]/u.test(value), {
2322
+ message: "label must not contain newlines or the | field separator",
2323
+ })
2324
+ .optional(),
2325
+ })
2326
+ .strict();
2327
+ export type CreateWorkspaceGatewayCustomModelRequest = z.infer<
2328
+ typeof CreateWorkspaceGatewayCustomModelRequest
2329
+ >;
2330
+
2331
+ export const DeleteWorkspaceGatewayCustomModelRequest = z
2332
+ .object({
2333
+ expectedVersion: z.number().int().positive(),
2334
+ operationId: z.string().uuid(),
2335
+ })
2336
+ .strict();
2337
+ export type DeleteWorkspaceGatewayCustomModelRequest = z.infer<
2338
+ typeof DeleteWorkspaceGatewayCustomModelRequest
2339
+ >;
2340
+
2341
+ export const WorkspaceGatewayCustomModel = z.object({
2342
+ id: z.string().uuid(),
2343
+ upstreamModelId: z.string(),
2344
+ label: z.string().nullable(),
2345
+ version: z.number().int().positive(),
2346
+ createdAt: z.string().datetime(),
2347
+ updatedAt: z.string().datetime(),
2348
+ });
2349
+ export type WorkspaceGatewayCustomModel = z.infer<typeof WorkspaceGatewayCustomModel>;
2350
+
2351
+ export const WorkspaceGatewayCustomModelsResponse = z.object({
2352
+ models: z.array(WorkspaceGatewayCustomModel),
2353
+ });
2354
+ export type WorkspaceGatewayCustomModelsResponse = z.infer<
2355
+ typeof WorkspaceGatewayCustomModelsResponse
2356
+ >;
2357
+
2358
+ export const CreateWorkspaceOpenRouterCustomModelRequest = CreateWorkspaceGatewayCustomModelRequest;
2359
+ export type CreateWorkspaceOpenRouterCustomModelRequest = z.infer<
2360
+ typeof CreateWorkspaceOpenRouterCustomModelRequest
2361
+ >;
2362
+
2363
+ export const DeleteWorkspaceOpenRouterCustomModelRequest = DeleteWorkspaceGatewayCustomModelRequest;
2364
+ export type DeleteWorkspaceOpenRouterCustomModelRequest = z.infer<
2365
+ typeof DeleteWorkspaceOpenRouterCustomModelRequest
2366
+ >;
2367
+
2368
+ export const WorkspaceOpenRouterCustomModel = WorkspaceGatewayCustomModel;
2369
+ export type WorkspaceOpenRouterCustomModel = z.infer<typeof WorkspaceOpenRouterCustomModel>;
2370
+
2371
+ export const WorkspaceOpenRouterCustomModelsResponse = z.object({
2372
+ models: z.array(WorkspaceOpenRouterCustomModel),
2373
+ });
2374
+ export type WorkspaceOpenRouterCustomModelsResponse = z.infer<
2375
+ typeof WorkspaceOpenRouterCustomModelsResponse
2376
+ >;
2377
+
2378
+ export const CreateOrganizationProviderCustomModelRequest =
2379
+ CreateWorkspaceGatewayCustomModelRequest;
2380
+ export type CreateOrganizationProviderCustomModelRequest = z.infer<
2381
+ typeof CreateOrganizationProviderCustomModelRequest
2382
+ >;
2383
+ export const DeleteOrganizationProviderCustomModelRequest =
2384
+ DeleteWorkspaceGatewayCustomModelRequest;
2385
+ export type DeleteOrganizationProviderCustomModelRequest = z.infer<
2386
+ typeof DeleteOrganizationProviderCustomModelRequest
2387
+ >;
2388
+ export const OrganizationProviderCustomModel = WorkspaceGatewayCustomModel;
2389
+ export type OrganizationProviderCustomModel = z.infer<typeof OrganizationProviderCustomModel>;
2390
+ export const OrganizationProviderCustomModelsResponse = z.object({
2391
+ models: z.array(OrganizationProviderCustomModel),
2392
+ });
2393
+ export type OrganizationProviderCustomModelsResponse = z.infer<
2394
+ typeof OrganizationProviderCustomModelsResponse
2395
+ >;
2396
+
2397
+ export const OrganizationModelProviderKind = z.enum(["vercel_gateway", "openrouter"]);
2398
+ export type OrganizationModelProviderKind = z.infer<typeof OrganizationModelProviderKind>;
2399
+ export const OrganizationModelProviderConnectionResponse = z.object({
2400
+ providerKind: OrganizationModelProviderKind,
2401
+ status: z.enum(["active", "revoked"]),
2402
+ version: z.number().int().positive(),
2403
+ createdAt: z.string().datetime(),
2404
+ updatedAt: z.string().datetime(),
2405
+ });
2406
+ export type OrganizationModelProviderConnectionResponse = z.infer<
2407
+ typeof OrganizationModelProviderConnectionResponse
2408
+ >;
2409
+ export const UpsertOrganizationModelProviderConnectionRequest = z
2410
+ .object({
2411
+ operationId: z.string().uuid(),
2412
+ expectedVersion: z.number().int().nonnegative().optional(),
2413
+ apiKey: z.string().trim().min(1).max(8192),
2414
+ })
2415
+ .strict();
2416
+ export type UpsertOrganizationModelProviderConnectionRequest = z.infer<
2417
+ typeof UpsertOrganizationModelProviderConnectionRequest
2418
+ >;
2419
+ export const RevokeOrganizationModelProviderConnectionRequest = z
2420
+ .object({ operationId: z.string().uuid(), expectedVersion: z.number().int().positive() })
2421
+ .strict();
2422
+ export type RevokeOrganizationModelProviderConnectionRequest = z.infer<
2423
+ typeof RevokeOrganizationModelProviderConnectionRequest
2424
+ >;
2425
+
2303
2426
  const turnInitiatorIdentityFields = {
2304
2427
  subjectId: z.string().min(1),
2305
2428
  /** Immutable display snapshot; never an authorization input. */
@@ -3252,6 +3375,9 @@ export const InsightsModelUsageRow = z.object({
3252
3375
  /** Hypothetical provider-rate USD; never an OpenGeni charge. */
3253
3376
  estimatedProviderUsd: z.number().nonnegative(),
3254
3377
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3378
+ /** OpenGeni credit price at the captured rate, whether or not credits paid for the call. */
3379
+ equivalentCreditUsd: z.number().nonnegative(),
3380
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3255
3381
  });
3256
3382
  export type InsightsModelUsageRow = z.infer<typeof InsightsModelUsageRow>;
3257
3383
 
@@ -3262,6 +3388,9 @@ export const InsightsSeriesPoint = z.object({
3262
3388
  /** UTC hour/day-bucketed hypothetical provider-rate USD for calls with captured pricing. */
3263
3389
  estimatedProviderUsd: z.number().nonnegative(),
3264
3390
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3391
+ /** UTC hour/day-bucketed equivalent OpenGeni credit price for calls with captured pricing. */
3392
+ equivalentCreditUsd: z.number().nonnegative(),
3393
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3265
3394
  warmSeconds: z.number().nonnegative(),
3266
3395
  inputTokens: z.number().nonnegative(),
3267
3396
  outputTokens: z.number().nonnegative(),
@@ -3296,6 +3425,8 @@ export const InsightsSpendDriver = z.object({
3296
3425
  creditUsd: z.number().nonnegative(),
3297
3426
  estimatedProviderUsd: z.number().nonnegative(),
3298
3427
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3428
+ equivalentCreditUsd: z.number().nonnegative(),
3429
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3299
3430
  tokens: z.number().nonnegative(),
3300
3431
  cacheHitPct: z.number().int().min(0).max(100),
3301
3432
  pctOfCreditUsd: z.number().int().min(0).max(100),
@@ -3348,6 +3479,8 @@ export const InsightsScheduleRow = z.object({
3348
3479
  creditUsd: z.number().nonnegative().nullable(),
3349
3480
  estimatedProviderUsd: z.number().nonnegative().nullable(),
3350
3481
  estimatedProviderCostKnownCalls: z.number().int().nonnegative().nullable(),
3482
+ equivalentCreditUsd: z.number().nonnegative().nullable(),
3483
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative().nullable(),
3351
3484
  tokens: z.number().nonnegative().nullable(),
3352
3485
  cacheHitPct: z.number().int().min(0).max(100).nullable(),
3353
3486
  billing: InsightsBillingPath.nullable(),
@@ -3375,6 +3508,8 @@ export const InsightsModelCallRow = z.object({
3375
3508
  creditUsd: z.number().nonnegative(),
3376
3509
  /** Hypothetical provider-rate USD; null when historical pricing is unavailable. */
3377
3510
  estimatedProviderUsd: z.number().nonnegative().nullable(),
3511
+ /** Equivalent OpenGeni credit price; null when historical pricing is unavailable. */
3512
+ equivalentCreditUsd: z.number().nonnegative().nullable(),
3378
3513
  pricingSource: InsightsPricingSource.nullable(),
3379
3514
  });
3380
3515
  export type InsightsModelCallRow = z.infer<typeof InsightsModelCallRow>;
@@ -3423,6 +3558,11 @@ export const WorkspaceInsightsSnapshot = z.object({
3423
3558
  priorEstimatedProviderUsd: z.number().nonnegative(),
3424
3559
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3425
3560
  priorEstimatedProviderCostKnownCalls: z.number().int().nonnegative(),
3561
+ /** Equivalent OpenGeni credit price across calls whose historical price was captured. */
3562
+ equivalentCreditUsd: z.number().nonnegative(),
3563
+ priorEquivalentCreditUsd: z.number().nonnegative(),
3564
+ equivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3565
+ priorEquivalentCreditCostKnownCalls: z.number().int().nonnegative(),
3426
3566
  modelCalls: z.number().int().nonnegative(),
3427
3567
  priorInputTokens: z.number().nonnegative(),
3428
3568
  priorTotalTokens: z.number().nonnegative(),
@@ -3847,6 +3987,8 @@ export const McpServerConnectionRef = z
3847
3987
  .object({
3848
3988
  /** Opaque host or standalone connection identifier. */
3849
3989
  connectionId: z.string().min(1).optional(),
3990
+ /** Host-owned credential authority; omission keeps OpenGeni's native connection authority. */
3991
+ authoritySource: z.literal("host").optional(),
3850
3992
  /** Stable provider family (for example github, gitlab, or azure_devops). */
3851
3993
  provider: z.string().min(1).max(128).optional(),
3852
3994
  /** Provider host or tenant domain. */
@@ -3861,6 +4003,13 @@ export const McpServerConnectionRef = z
3861
4003
  })
3862
4004
  .strict()
3863
4005
  .superRefine((reference, context) => {
4006
+ if (reference.authoritySource === "host" && !reference.connectionId) {
4007
+ context.addIssue({
4008
+ code: "custom",
4009
+ message: "host authority requires connectionId",
4010
+ path: ["connectionId"],
4011
+ });
4012
+ }
3864
4013
  if (!reference.selectedResources) return;
3865
4014
  if (!reference.connectionId) {
3866
4015
  context.addIssue({
@@ -4237,6 +4386,14 @@ export type GitHubUserInstallationAccess = GitHubInstallationSummary & {
4237
4386
  repositories: GitHubUserRepositoryAccess[];
4238
4387
  };
4239
4388
 
4389
+ export type GitHubAppRepositoryBranchPage = {
4390
+ installationId: number;
4391
+ repositoryId: number;
4392
+ defaultBranch: string;
4393
+ branches: string[];
4394
+ nextPage: number | null;
4395
+ };
4396
+
4240
4397
  export type GitHubAppApiPort = {
4241
4398
  /**
4242
4399
  * Exchange one fresh GitHub user-authorization code and prove current
@@ -4268,6 +4425,18 @@ export type GitHubAppApiPort = {
4268
4425
  installationId: number;
4269
4426
  }) => Promise<GitHubInstallationSummary | null>;
4270
4427
  listRepositories?: (input: { installationIds?: number[] }) => Promise<GitHubRepository[]>;
4428
+ /**
4429
+ * List one bounded page of branch suggestions for one exact repository.
4430
+ * Implementations must keep the provider credential server-side and scope
4431
+ * it to exactly `repositoryId`; the caller separately rechecks the durable
4432
+ * workspace binding immediately before and after this provider request.
4433
+ */
4434
+ listRepositoryBranches?: (input: {
4435
+ installationId: number;
4436
+ repositoryId: number;
4437
+ page: number;
4438
+ limit: number;
4439
+ }) => Promise<GitHubAppRepositoryBranchPage>;
4271
4440
  };
4272
4441
 
4273
4442
  export const BillingBalance = z.object({
@@ -8787,6 +8956,10 @@ export const ScheduledTaskRunAcceptedExecution = /* @__PURE__ */ z
8787
8956
  resolvedModel: z.string().min(1),
8788
8957
  resolvedReasoningEffort: ReasoningEffort,
8789
8958
  resolvedLatencyMode: LatencyMode,
8959
+ /** Secret-safe TurnExecutionPolicyV1 accepted with this occurrence. Kept
8960
+ * structurally open here because the canonical policy schema is declared
8961
+ * later in this package; consumers must parse it with TurnExecutionPolicyV1. */
8962
+ turnExecutionPolicy: z.unknown().optional(),
8790
8963
  resolvedSandboxBackend: SandboxBackend,
8791
8964
  resolvedSandboxOs: SandboxOs,
8792
8965
  resolvedTools: z.array(ToolRef).max(SCHEDULED_TASK_TOOL_MAX_COUNT),
@@ -9554,6 +9727,12 @@ export const CapabilityPackSkill = z
9554
9727
  message: "skill name must be a single path segment of letters, digits, '.', '_' or '-'",
9555
9728
  }),
9556
9729
  description: z.string().min(1).max(2048).optional(),
9730
+ // Workspace-managed Skills are available to every session in the
9731
+ // workspace. Session-selected Skills remain installed and inspectable, but
9732
+ // enter model context only when their immutable definition is attached to
9733
+ // a session explicitly. This is the hard contamination boundary for Packs
9734
+ // that guide implementation agents rather than customer-facing agents.
9735
+ activationMode: z.enum(["workspace_managed", "session_selected"]).optional(),
9557
9736
  files: z.array(CapabilityPackSkillFile).min(1).max(64),
9558
9737
  })
9559
9738
  .superRefine((skill, ctx) => {
@@ -9581,8 +9760,11 @@ export type CapabilityPackSkill = z.infer<typeof CapabilityPackSkill>;
9581
9760
  // Inline skill content fixed onto one session at creation. It intentionally
9582
9761
  // uses the exact same validated directory shape as a pack skill, but has a
9583
9762
  // different semantic owner and lifecycle. Session readers can inspect it; it
9584
- // is configuration, never a secret store.
9585
- export const SessionSkill = CapabilityPackSkill;
9763
+ // is configuration, never a secret store. Pack activation policy is consumed
9764
+ // at admission and cannot become part of the session-owned artifact.
9765
+ export const SessionSkill = CapabilityPackSkill.transform(
9766
+ ({ activationMode: _activationMode, ...skill }) => skill,
9767
+ );
9586
9768
  export type SessionSkill = z.infer<typeof SessionSkill>;
9587
9769
 
9588
9770
  export const SessionSkills = z
@@ -10490,6 +10672,15 @@ function compareDescending(left: number | string, right: number | string): numbe
10490
10672
  export const ConnectionCredentialBundle = z.record(z.string(), z.unknown());
10491
10673
  export type ConnectionCredentialBundle = z.infer<typeof ConnectionCredentialBundle>;
10492
10674
 
10675
+ export const VERCEL_AI_GATEWAY_CREDENTIAL_OPERATION_ID_METADATA_KEY =
10676
+ "vercelAiGatewayCredentialOperationId" as const;
10677
+ export const VERCEL_AI_GATEWAY_CREDENTIAL_OPERATION_DIGEST_METADATA_KEY =
10678
+ "vercelAiGatewayCredentialOperationDigest" as const;
10679
+ export const OPENROUTER_CREDENTIAL_OPERATION_ID_METADATA_KEY =
10680
+ "openRouterCredentialOperationId" as const;
10681
+ export const OPENROUTER_CREDENTIAL_OPERATION_DIGEST_METADATA_KEY =
10682
+ "openRouterCredentialOperationDigest" as const;
10683
+
10493
10684
  export const CreateConnectionRequest = z.object({
10494
10685
  providerDomain: z.string().min(1),
10495
10686
  kind: ConnectionKind,
@@ -10500,6 +10691,7 @@ export const CreateConnectionRequest = z.object({
10500
10691
  grantedScopes: z.array(z.string().min(1)).default([]),
10501
10692
  expiresAt: z.string().datetime({ offset: true }).nullable().optional(),
10502
10693
  metadata: z.record(z.string(), z.unknown()).default({}),
10694
+ operationId: z.string().uuid().optional(),
10503
10695
  });
10504
10696
  export type CreateConnectionRequest = z.infer<typeof CreateConnectionRequest>;
10505
10697
 
@@ -10555,6 +10747,8 @@ export const UpdateConnectionRequest = z.object({
10555
10747
  grantedScopes: z.array(z.string().min(1)).optional(),
10556
10748
  expiresAt: z.string().datetime({ offset: true }).nullable().optional(),
10557
10749
  metadata: z.record(z.string(), z.unknown()).optional(),
10750
+ expectedVersion: z.number().int().positive().optional(),
10751
+ operationId: z.string().uuid().optional(),
10558
10752
  });
10559
10753
  export type UpdateConnectionRequest = z.infer<typeof UpdateConnectionRequest>;
10560
10754
 
@@ -10750,11 +10944,14 @@ export const CapabilityCatalogItem = z.object({
10750
10944
  /** @deprecated Compatibility explanation paired with enabled. */
10751
10945
  enabledReason: z.string().nullable().default(null),
10752
10946
  // 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.
10947
+ // Native workspace refs retain an exact row id. Native subject refs omit it
10948
+ // so each caller resolves their own row. The first-party catalog projects a
10949
+ // host-owned installation as null for old-browser safety; the schema remains
10950
+ // tolerant of additive host projections from embedding-specific catalogs.
10755
10951
  connectionRef: z
10756
10952
  .object({
10757
10953
  connectionId: z.string().min(1).optional(),
10954
+ authoritySource: z.literal("host").optional(),
10758
10955
  providerDomain: z.string().min(1),
10759
10956
  kind: z.string().min(1),
10760
10957
  subjectScope: z.enum(["workspace", "subject"]).optional(),
@@ -12317,44 +12514,81 @@ export function resolveSessionEventTypeFilters(input: ResolveSessionEventTypeFil
12317
12514
  return { includeTypes: [...included], excludeTypes: [...excluded] };
12318
12515
  }
12319
12516
 
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
- });
12517
+ export const ToolAuthNeededReason = z.enum([
12518
+ "missing_connection",
12519
+ "expired",
12520
+ "insufficient_scope",
12521
+ "refresh_failed",
12522
+ "personal_authority_unavailable",
12523
+ "unsupported_auth",
12524
+ "resource_scope_unavailable",
12525
+ ]);
12526
+ export type ToolAuthNeededReason = z.infer<typeof ToolAuthNeededReason>;
12527
+
12528
+ export const ToolAuthNeededPayload = z
12529
+ .object({
12530
+ serverId: z.string().min(1),
12531
+ toolName: z.string().min(1).nullable().optional(),
12532
+ providerDomain: z.string().min(1),
12533
+ provider: z.string().min(1).max(128).optional(),
12534
+ // Embedded hosts may use an opaque connection identity; never assume an
12535
+ // OpenGeni UUID on the public event wire.
12536
+ connectionId: z.string().min(1).nullable().optional(),
12537
+ /** The failed binding is owned by the embedding host, not OpenGeni's connection broker. */
12538
+ authoritySource: z.literal("host").optional(),
12539
+ /**
12540
+ * Legacy-compatible reason. Host-owned event writers pin this to
12541
+ * unsupported_auth so a pre-host-authority browser cannot launch native
12542
+ * OAuth for the opaque id.
12543
+ */
12544
+ reason: ToolAuthNeededReason,
12545
+ /** Exact host recovery reason consumed by host-aware clients. */
12546
+ hostReason: ToolAuthNeededReason.optional(),
12547
+ scopes: z.array(z.string().min(1)).optional(),
12548
+ resource: z.string().min(1).optional(),
12549
+ selectedResources: McpConnectionResourceScopes.optional(),
12550
+ authorizationUrl: z.string().url().optional(),
12551
+ subjectId: z.string().min(1).nullable().optional(),
12552
+ // A catalog recommendation is still a tool-level authorization condition:
12553
+ // the agent may describe and request it, but only the authenticated host UI
12554
+ // can start setup. Keeping this nested and optional preserves the established
12555
+ // auth-needed event for ordinary failed MCP calls.
12556
+ capability: z
12557
+ .object({
12558
+ id: z.string().min(1).max(512),
12559
+ name: z.string().min(1).max(256),
12560
+ kind: CapabilityKind,
12561
+ source: CapabilitySource,
12562
+ action: z.enum(["connect", "add_credentials", "enable"]),
12563
+ rationale: z.string().min(1).max(2000),
12564
+ requiredVariables: z.array(VariableSetVariableName).max(64).default([]),
12565
+ })
12566
+ .optional(),
12567
+ })
12568
+ .superRefine((payload, context) => {
12569
+ if (payload.authoritySource === "host") {
12570
+ if (payload.reason !== "unsupported_auth") {
12571
+ context.addIssue({
12572
+ code: "custom",
12573
+ message: "host auth-needed events require the legacy-safe unsupported_auth reason",
12574
+ path: ["reason"],
12575
+ });
12576
+ }
12577
+ if (!payload.hostReason) {
12578
+ context.addIssue({
12579
+ code: "custom",
12580
+ message: "host auth-needed events require hostReason",
12581
+ path: ["hostReason"],
12582
+ });
12583
+ }
12584
+ } else if (payload.hostReason) {
12585
+ context.addIssue({
12586
+ code: "custom",
12587
+ message: "hostReason is reserved for host-owned auth-needed events",
12588
+ path: ["hostReason"],
12589
+ });
12590
+ }
12591
+ });
12358
12592
  export type ToolAuthNeededPayload = z.infer<typeof ToolAuthNeededPayload>;
12359
12593
 
12360
12594
  /** A host-owned non-tool credential needed by the active run. */
@@ -13123,6 +13357,8 @@ export const SessionEvent = z.object({
13123
13357
  workspaceId: z.string().uuid(),
13124
13358
  sessionId: z.string().uuid(),
13125
13359
  sequence: z.number().int().positive(),
13360
+ /** Server-owned durable high-water mark for a synthetic compact event. */
13361
+ coveredThrough: z.number().int().positive().optional(),
13126
13362
  type: SessionEventType,
13127
13363
  payload: z.unknown().default({}),
13128
13364
  occurredAt: z.string(),
@@ -13712,6 +13948,15 @@ export function boundSessionEvent(
13712
13948
  const turnGeneration = canonicalSessionEventGeneration(source.turnGeneration);
13713
13949
  const turnAttemptId = canonicalOptionalSessionEventUuid(source.turnAttemptId);
13714
13950
  const duplicateOfEventId = canonicalOptionalSessionEventUuid(source.duplicateOfEventId);
13951
+ const rawCoveredThrough = source.coveredThrough.readable
13952
+ ? source.coveredThrough.value
13953
+ : undefined;
13954
+ const coveredThrough =
13955
+ typeof rawCoveredThrough === "number" &&
13956
+ Number.isSafeInteger(rawCoveredThrough) &&
13957
+ rawCoveredThrough >= sequence
13958
+ ? rawCoveredThrough
13959
+ : undefined;
13715
13960
  const envelopeFields = [
13716
13961
  sessionEventCustomSerializerProjection(event),
13717
13962
  sessionEventAdditionalTopLevelFieldProjection(event),
@@ -13747,6 +13992,14 @@ export function boundSessionEvent(
13747
13992
  source.duplicateReason.readable,
13748
13993
  )
13749
13994
  : null,
13995
+ !source.coveredThrough.readable || rawCoveredThrough !== coveredThrough
13996
+ ? sessionEventEnvelopeFieldProjection(
13997
+ "coveredThrough",
13998
+ rawCoveredThrough,
13999
+ coveredThrough,
14000
+ source.coveredThrough.readable,
14001
+ )
14002
+ : null,
13750
14003
  ...sessionEventCanonicalFieldProjections(source, {
13751
14004
  id,
13752
14005
  workspaceId,
@@ -13789,6 +14042,7 @@ export function boundSessionEvent(
13789
14042
  workspaceId,
13790
14043
  sessionId,
13791
14044
  sequence,
14045
+ ...(coveredThrough === undefined ? {} : { coveredThrough }),
13792
14046
  type: typeIsSafe ? (rawType as SessionEvent["type"]) : "session.event.envelope_omitted",
13793
14047
  payload,
13794
14048
  occurredAt,
@@ -13809,6 +14063,7 @@ export function boundSessionEvent(
13809
14063
  workspaceId,
13810
14064
  sessionId,
13811
14065
  sequence,
14066
+ ...(coveredThrough === undefined ? {} : { coveredThrough }),
13812
14067
  type: "session.event.envelope_omitted",
13813
14068
  payload: boundSessionEventPayload(
13814
14069
  {
@@ -13907,6 +14162,7 @@ const SESSION_EVENT_OWN_DATA_FIELDS = [
13907
14162
  "workspaceId",
13908
14163
  "sessionId",
13909
14164
  "sequence",
14165
+ "coveredThrough",
13910
14166
  "type",
13911
14167
  "payload",
13912
14168
  "occurredAt",
@@ -14155,6 +14411,17 @@ export const CreateSessionRequest = withVariableSetIdAlias(
14155
14411
  // Inline skills are fixed onto the session. Child omission inherits the
14156
14412
  // trusted parent's selection; an explicit array, including [], wins.
14157
14413
  skills: SessionSkills.default([]),
14414
+ // Immutable workspace Skill identities to copy onto this session at
14415
+ // creation. This is the explicit opt-in path for session-selected Pack
14416
+ // Skills: installation alone never exposes them to model context. Child
14417
+ // omission still inherits the parent's already-materialized session Skills.
14418
+ installedSkillIds: z
14419
+ .array(z.string().min(1).max(512))
14420
+ .max(32)
14421
+ .refine((ids) => new Set(ids).size === ids.length, {
14422
+ message: "installed Skill identities must be unique",
14423
+ })
14424
+ .optional(),
14158
14425
  // The same child omission rule applies to selected MCP tool refs. Top-level
14159
14426
  // omission still applies workspace-default capability MCP tools; explicit []
14160
14427
  // suppresses those defaults (the first-party OpenGeni server remains added).
@@ -15534,6 +15801,12 @@ export const ModelCredentialSourceV1 =
15534
15801
  mechanism: z.literal("api_key"),
15535
15802
  })
15536
15803
  .strict(),
15804
+ z
15805
+ .object({
15806
+ kind: z.literal("organization_connection"),
15807
+ mechanism: z.literal("api_key"),
15808
+ })
15809
+ .strict(),
15537
15810
  ]),
15538
15811
  );
15539
15812
  export type ModelCredentialSourceV1 = z.infer<typeof ModelCredentialSourceV1>;
@@ -15552,13 +15825,23 @@ export const ModelBillingAttributionV1 =
15552
15825
  /* @__PURE__ */ defineModelContractSchema(() =>
15553
15826
  z
15554
15827
  .object({
15555
- upstreamPayer: z.enum(["deployment", "workspace", "connected_subscription"]),
15828
+ upstreamPayer: z.enum([
15829
+ "deployment",
15830
+ "workspace",
15831
+ "organization",
15832
+ "connected_subscription",
15833
+ ]),
15556
15834
  metering: z.enum(["opengeni_credits", "external"]),
15557
15835
  })
15558
15836
  .strict(),
15559
15837
  );
15560
15838
  export type ModelBillingAttributionV1 = z.infer<typeof ModelBillingAttributionV1>;
15561
15839
 
15840
+ export const ModelCostClassV1 = /* @__PURE__ */ defineModelContractSchema(() =>
15841
+ z.enum(["free", "credits", "subscription", "workspace", "organization"]),
15842
+ );
15843
+ export type ModelCostClassV1 = z.infer<typeof ModelCostClassV1>;
15844
+
15562
15845
  export const TURN_EXECUTION_POLICY_METADATA_KEY = "turnExecutionPolicyV1" as const;
15563
15846
 
15564
15847
  export const TurnExecutionModelSourceV1 =
@@ -15709,6 +15992,7 @@ export const ModelPricingV1 = /* @__PURE__ */ defineModelContractSchema(() =>
15709
15992
  z.object({
15710
15993
  inputMicrosPerMillionTokens: z.number().int().nonnegative(),
15711
15994
  cachedInputMicrosPerMillionTokens: z.number().int().nonnegative().optional(),
15995
+ cacheWriteMicrosPerMillionTokens: z.number().int().nonnegative().optional(),
15712
15996
  outputMicrosPerMillionTokens: z.number().int().nonnegative(),
15713
15997
  marginBps: z.number().int().min(0).max(100_000).optional(),
15714
15998
  }),
@@ -15746,7 +16030,9 @@ export const ClientModel = /* @__PURE__ */ defineModelContractSchema(() =>
15746
16030
  provider: z.string(), // provider id
15747
16031
  providerLabel: z.string(),
15748
16032
  api: z.enum(["responses", "chat"]),
15749
- source: z.enum(["opengeni", "codex", "supergrok", "workspace_gateway"]).optional(),
16033
+ source: z
16034
+ .enum(["opengeni", "codex", "supergrok", "workspace_gateway", "openrouter"])
16035
+ .optional(),
15750
16036
  contextWindowTokens: z.number().int().positive().optional(),
15751
16037
  // Additive normalized definition metadata. Optional so older server payloads
15752
16038
  // remain parseable; current servers project the complete V1 set.
@@ -15768,6 +16054,7 @@ export const ClientModel = /* @__PURE__ */ defineModelContractSchema(() =>
15768
16054
  .optional(),
15769
16055
  credentialSource: ModelCredentialSourceV1.optional(),
15770
16056
  billing: ModelBillingAttributionV1.optional(),
16057
+ cost: ModelCostClassV1.optional(),
15771
16058
  capabilities: ModelCapabilitiesV1.optional(),
15772
16059
  pricing: ModelPricingScheduleV1.optional(),
15773
16060
  definitionVersion: z