@opengeni/contracts 0.44.1 → 1.0.1

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/atlassian.js +10 -8
  2. package/dist/canonical-human-identities.d.ts +157 -0
  3. package/dist/canonical-human-identities.js +23 -0
  4. package/dist/canonical-human-identities.js.map +1 -0
  5. package/dist/chunk-CM6BMECR.js +24 -0
  6. package/dist/chunk-CM6BMECR.js.map +1 -0
  7. package/dist/{chunk-FJBG5E4O.js → chunk-JBCIY7QD.js} +12 -12
  8. package/dist/chunk-JUFK3T4Q.js +80 -0
  9. package/dist/chunk-JUFK3T4Q.js.map +1 -0
  10. package/dist/{chunk-H5BVCZKF.js → chunk-LW7OH6CS.js} +2 -2
  11. package/dist/{chunk-52SGB2QO.js → chunk-M5ZGRVIQ.js} +37 -6
  12. package/dist/chunk-M5ZGRVIQ.js.map +1 -0
  13. package/dist/{chunk-VA22KRHS.js → chunk-NX5JNF4L.js} +6533 -4923
  14. package/dist/chunk-NX5JNF4L.js.map +1 -0
  15. package/dist/codex-provider-account-authority.d.ts +23 -0
  16. package/dist/codex-provider-account-authority.js +23 -0
  17. package/dist/codex-provider-account-authority.js.map +1 -0
  18. package/dist/editable-artifact-codec-registry.js +5 -5
  19. package/dist/editable-artifact-live.js +3 -3
  20. package/dist/editable-artifact-serialized-commit.js +4 -4
  21. package/dist/editable-artifacts.js +27 -27
  22. package/dist/google-drive.d.ts +88 -1
  23. package/dist/google-drive.js +75 -13
  24. package/dist/google-drive.js.map +1 -1
  25. package/dist/index.d.ts +1385 -122
  26. package/dist/index.js +406 -80
  27. package/dist/interaction.d.ts +1415 -20
  28. package/dist/knowledge.d.ts +616 -0
  29. package/dist/slack-task-policy.d.ts +294 -0
  30. package/dist/task-notes.d.ts +128 -0
  31. package/dist/video-generation.d.ts +48 -0
  32. package/dist/video-generation.js +9 -1
  33. package/dist/xai-provider-account-authority.d.ts +23 -0
  34. package/dist/xai-provider-account-authority.js +9 -0
  35. package/dist/xai-provider-account-authority.js.map +1 -0
  36. package/package.json +13 -1
  37. package/src/artifacts.ts +1 -1
  38. package/src/canonical-human-identities.ts +93 -0
  39. package/src/codex-provider-account-authority.ts +37 -0
  40. package/src/google-drive.ts +76 -4
  41. package/src/index.ts +921 -270
  42. package/src/interaction.ts +886 -5
  43. package/src/knowledge.ts +222 -0
  44. package/src/slack-task-policy.ts +215 -0
  45. package/src/task-notes.ts +92 -0
  46. package/src/video-generation.ts +43 -6
  47. package/src/xai-provider-account-authority.ts +37 -0
  48. package/dist/chunk-52SGB2QO.js.map +0 -1
  49. package/dist/chunk-VA22KRHS.js.map +0 -1
  50. /package/dist/{chunk-FJBG5E4O.js.map → chunk-JBCIY7QD.js.map} +0 -0
  51. /package/dist/{chunk-H5BVCZKF.js.map → chunk-LW7OH6CS.js.map} +0 -0
package/src/index.ts CHANGED
@@ -10,8 +10,10 @@ import { MemorySlackPublicationDistribution } from "./memory-slack-delivery";
10
10
  import { WorkspaceInstructionPolicyRoleKeyInput } from "./workspace-instruction-policies";
11
11
  import { ClientResumableVoiceInputConfig } from "./transcription-recordings";
12
12
  import { MediaGenerationResult } from "./video-generation";
13
+ import { KnowledgeProviderCitation } from "./knowledge";
13
14
 
14
15
  export * from "./slack-bot-scopes";
16
+ export * from "./slack-task-policy";
15
17
  export * from "./atlassian";
16
18
  export * from "./connector-destinations";
17
19
  export * from "./memory-slack-delivery";
@@ -245,7 +247,7 @@ export type CapabilityDescriptor = {
245
247
  FileSystem: { available: boolean; readOnly: boolean };
246
248
  Terminal: {
247
249
  available: boolean;
248
- transport: "sse-events" | "pty-ws" | null;
250
+ transport: "sse-events" | "pty-ws" | "relay-pty" | null;
249
251
  pty: boolean;
250
252
  };
251
253
  Git: { available: boolean };
@@ -567,7 +569,7 @@ export const CAPABILITY_DESCRIPTORS: Record<SandboxBackend, CapabilityDescriptor
567
569
  os: { supported: ["linux", "macos", "windows"], default: "linux" },
568
570
  capabilities: {
569
571
  FileSystem: { available: true, readOnly: false },
570
- Terminal: { available: true, transport: "pty-ws", pty: true }, // real PTY over the relay
572
+ Terminal: { available: true, transport: "relay-pty", pty: true }, // real PTY over the relay
571
573
  Git: { available: true },
572
574
  DesktopStream: { available: true, transport: "vnc-ws" }, // proclaimed; consent-gated at enroll
573
575
  Recording: { available: true }, // boot invariant: == DesktopStream.available
@@ -625,6 +627,7 @@ export const ErrorEnvelope = z.object({
625
627
  code: ErrorCode,
626
628
  message: z.string(),
627
629
  retryable: z.boolean(),
630
+ outcomeUnknown: z.boolean().optional(),
628
631
  requestId: z.string().optional(),
629
632
  details: z.record(z.string(), z.unknown()).optional(),
630
633
  }),
@@ -798,6 +801,7 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
798
801
  "set_session_title",
799
802
  "goal_set",
800
803
  "goal_update",
804
+ "goal_progress",
801
805
  "goal_complete",
802
806
  "goal_pause",
803
807
  "memory_search",
@@ -805,6 +809,9 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
805
809
  "memory_correct",
806
810
  "preference_registry_summary",
807
811
  "preference_registry_get",
812
+ "task_notes_list",
813
+ "task_note_save",
814
+ "task_note_archive",
808
815
  "sandboxes_list",
809
816
  "sandbox_attach",
810
817
  "sandbox_swap",
@@ -830,13 +837,17 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
830
837
  "browser_tabs",
831
838
  "browser_observe",
832
839
  "browser_act",
840
+ "browser_clipboard",
833
841
  "browser_debug",
842
+ "browser_auth",
843
+ "interaction_request_human",
834
844
  "browser_identity",
835
845
  "browser_publish",
836
846
  "browser_lifecycle",
837
847
  "computer_open",
838
848
  "computer_targets",
839
849
  "computer_observe",
850
+ "computer_clipboard",
840
851
  "computer_act",
841
852
  "computer_lifecycle",
842
853
  "variable_set_list",
@@ -886,6 +897,16 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
886
897
  "slack_bot_file_content",
887
898
  "slack_bot_post_message",
888
899
  "slack_bot_delete_message",
900
+ "fiken_companies_list",
901
+ "fiken_contacts_list",
902
+ "fiken_contact_create",
903
+ "fiken_products_list",
904
+ "fiken_invoices_list",
905
+ "fiken_invoice_get",
906
+ "fiken_invoice_draft_create",
907
+ "fiken_bank_accounts_list",
908
+ "fiken_purchases_list",
909
+ "fiken_sales_list",
889
910
  "atlassian_sources_list",
890
911
  "atlassian_search",
891
912
  "atlassian_get",
@@ -917,13 +938,17 @@ export const FIRST_PARTY_IN_PROCESS_TOOL_NAMES = [
917
938
  "browser_tabs",
918
939
  "browser_observe",
919
940
  "browser_act",
941
+ "browser_clipboard",
920
942
  "browser_debug",
943
+ "browser_auth",
944
+ "interaction_request_human",
921
945
  "browser_identity",
922
946
  "browser_publish",
923
947
  "browser_lifecycle",
924
948
  "computer_open",
925
949
  "computer_targets",
926
950
  "computer_observe",
951
+ "computer_clipboard",
927
952
  "computer_act",
928
953
  "computer_lifecycle",
929
954
  ] as const satisfies readonly FirstPartyMcpToolName[];
@@ -932,9 +957,27 @@ const FIRST_PARTY_IN_PROCESS_TOOL_NAME_SET = new Set<FirstPartyMcpToolName>(
932
957
  FIRST_PARTY_IN_PROCESS_TOOL_NAMES,
933
958
  );
934
959
 
960
+ /**
961
+ * Names accepted for stored-selection compatibility but intentionally omitted
962
+ * from the remote first-party `opengeni` MCP server.
963
+ *
964
+ * `slack_bot_post_message` cannot accept a model/caller-supplied UUID as a
965
+ * trustworthy logical-delivery identity. Server-owned Slack delivery paths
966
+ * call the internal client directly with their own durable operation IDs.
967
+ */
968
+ const FIRST_PARTY_COMPATIBILITY_ONLY_TOOL_NAMES = [
969
+ "slack_bot_post_message",
970
+ ] as const satisfies readonly FirstPartyMcpToolName[];
971
+
972
+ const FIRST_PARTY_COMPATIBILITY_ONLY_TOOL_NAME_SET = new Set<FirstPartyMcpToolName>(
973
+ FIRST_PARTY_COMPATIBILITY_ONLY_TOOL_NAMES,
974
+ );
975
+
935
976
  /** Exact catalog registered by the remote first-party `opengeni` MCP server. */
936
977
  export const FIRST_PARTY_REMOTE_MCP_TOOL_NAMES = FIRST_PARTY_MCP_TOOL_NAMES.filter(
937
- (name) => !FIRST_PARTY_IN_PROCESS_TOOL_NAME_SET.has(name),
978
+ (name) =>
979
+ !FIRST_PARTY_IN_PROCESS_TOOL_NAME_SET.has(name) &&
980
+ !FIRST_PARTY_COMPATIBILITY_ONLY_TOOL_NAME_SET.has(name),
938
981
  ) satisfies readonly FirstPartyMcpToolName[];
939
982
 
940
983
  /** Authored CodeMode paths for the canonical collaborative artifact surface. */
@@ -960,6 +1003,7 @@ export const DEFAULT_FIRST_PARTY_MCP_TOOLS = FIRST_PARTY_MCP_TOOL_NAMES.filter(
960
1003
  !name.startsWith("x_") &&
961
1004
  !name.startsWith("reddit_") &&
962
1005
  !name.startsWith("slack_bot_") &&
1006
+ !name.startsWith("fiken_") &&
963
1007
  !name.startsWith("atlassian_"),
964
1008
  ) satisfies readonly FirstPartyMcpToolName[];
965
1009
 
@@ -982,6 +1026,255 @@ export type UsageLimitsMode = z.infer<typeof UsageLimitsMode>;
982
1026
  export const AccountRole = z.enum(["owner", "admin", "member"]);
983
1027
  export type AccountRole = z.infer<typeof AccountRole>;
984
1028
 
1029
+ /**
1030
+ * Settled tenancy vocabulary for resources that may outlive or be used from
1031
+ * more than one workspace. This names authority only; parsing one of these
1032
+ * contracts never authorizes access by itself.
1033
+ */
1034
+ export const ResourceAuthorityScope = z.enum(["organization", "workspace", "user"]);
1035
+ export type ResourceAuthorityScope = z.infer<typeof ResourceAuthorityScope>;
1036
+
1037
+ export const ResourceAuthorityListScope = z.enum([
1038
+ "effective",
1039
+ "organization",
1040
+ "workspace",
1041
+ "user",
1042
+ ]);
1043
+ export type ResourceAuthorityListScope = z.infer<typeof ResourceAuthorityListScope>;
1044
+
1045
+ export const OrganizationMembershipStatus = z.enum([
1046
+ "provisioning",
1047
+ "active",
1048
+ "suspended",
1049
+ "revoked",
1050
+ ]);
1051
+ export type OrganizationMembershipStatus = z.infer<typeof OrganizationMembershipStatus>;
1052
+
1053
+ export const PersonalResourceRetentionMode = z.enum(["retain", "delete_after"]);
1054
+ export type PersonalResourceRetentionMode = z.infer<typeof PersonalResourceRetentionMode>;
1055
+
1056
+ export const SessionTenancyVisibility = z.enum(["user_private", "workspace_shared"]);
1057
+ export type SessionTenancyVisibility = z.infer<typeof SessionTenancyVisibility>;
1058
+
1059
+ /** Public/session API vocabulary. Persistence keeps the explicit tenancy names. */
1060
+ export const SessionVisibility = z.enum(["private", "workspace"]);
1061
+ export type SessionVisibility = z.infer<typeof SessionVisibility>;
1062
+
1063
+ export function sessionVisibilityToPublic(value: SessionTenancyVisibility): SessionVisibility {
1064
+ return value === "user_private" ? "private" : "workspace";
1065
+ }
1066
+
1067
+ export function sessionVisibilityFromPublic(value: SessionVisibility): SessionTenancyVisibility {
1068
+ return value === "private" ? "user_private" : "workspace_shared";
1069
+ }
1070
+
1071
+ export const UserResourceGrantMode = z.enum(["once", "session", "always"]);
1072
+ export type UserResourceGrantMode = z.infer<typeof UserResourceGrantMode>;
1073
+
1074
+ /** Canonical non-wildcard action named by a personal-resource grant. */
1075
+ export const UserResourceGrantAction = z
1076
+ .string()
1077
+ .min(1)
1078
+ .max(64)
1079
+ .regex(/^[a-z0-9](?:[a-z0-9._:-]*[a-z0-9])?$/u);
1080
+ export type UserResourceGrantAction = z.infer<typeof UserResourceGrantAction>;
1081
+
1082
+ export const UserResourceGrantStatus = z.enum(["active", "consumed", "revoked", "expired"]);
1083
+ export type UserResourceGrantStatus = z.infer<typeof UserResourceGrantStatus>;
1084
+
1085
+ function refineUserResourceGrantFence(
1086
+ value: {
1087
+ mode: UserResourceGrantMode;
1088
+ sessionId: string | null;
1089
+ authorityEpoch: number | null;
1090
+ },
1091
+ context: z.RefinementCtx,
1092
+ ): void {
1093
+ const sessionBoundMode = value.mode === "once" || value.mode === "session";
1094
+ const hasSession = value.sessionId !== null;
1095
+ const hasAuthorityEpoch = value.authorityEpoch !== null;
1096
+
1097
+ if (sessionBoundMode && !hasSession) {
1098
+ context.addIssue({
1099
+ code: "custom",
1100
+ path: ["sessionId"],
1101
+ message: "once and session grants require an exact sessionId",
1102
+ });
1103
+ }
1104
+ if (sessionBoundMode && !hasAuthorityEpoch) {
1105
+ context.addIssue({
1106
+ code: "custom",
1107
+ path: ["authorityEpoch"],
1108
+ message: "once and session grants require an authorityEpoch fence",
1109
+ });
1110
+ }
1111
+ if (!sessionBoundMode && (hasSession || hasAuthorityEpoch)) {
1112
+ context.addIssue({
1113
+ code: "custom",
1114
+ path: ["mode"],
1115
+ message: "always grants must not carry a session or authority-epoch fence",
1116
+ });
1117
+ }
1118
+ if (hasSession !== hasAuthorityEpoch) {
1119
+ context.addIssue({
1120
+ code: "custom",
1121
+ path: ["authorityEpoch"],
1122
+ message: "sessionId and authorityEpoch must be present or absent together",
1123
+ });
1124
+ }
1125
+ }
1126
+
1127
+ /** Self-only organization membership projection; no subject identifier leaks. */
1128
+ export const OrganizationMembershipProjection = z.object({
1129
+ id: z.string().uuid(),
1130
+ organizationId: z.string().uuid(),
1131
+ status: OrganizationMembershipStatus,
1132
+ personalWorkspaceId: z.string().uuid().nullable(),
1133
+ personalRetentionUntil: z.string().datetime({ offset: true }).nullable(),
1134
+ });
1135
+ export type OrganizationMembershipProjection = z.infer<typeof OrganizationMembershipProjection>;
1136
+
1137
+ /**
1138
+ * Exact active-membership facts returned by managed-human login provisioning.
1139
+ * Retention is intentionally absent because the narrow provisioning capability
1140
+ * neither reads nor mutates offboarding policy.
1141
+ */
1142
+ export const ManagedOrganizationMembershipProjection = z.object({
1143
+ id: z.string().uuid(),
1144
+ organizationId: z.string().uuid(),
1145
+ status: z.literal("active"),
1146
+ personalWorkspaceId: z.string().uuid(),
1147
+ });
1148
+ export type ManagedOrganizationMembershipProjection = z.infer<
1149
+ typeof ManagedOrganizationMembershipProjection
1150
+ >;
1151
+
1152
+ export const ListManagedOrganizationMembershipsResponse = z.object({
1153
+ memberships: z.array(ManagedOrganizationMembershipProjection),
1154
+ });
1155
+ export type ListManagedOrganizationMembershipsResponse = z.infer<
1156
+ typeof ListManagedOrganizationMembershipsResponse
1157
+ >;
1158
+
1159
+ /**
1160
+ * Opaque user-resource authority projection. Ownership is represented by the
1161
+ * server-issued authority id, never a raw subject or membership id.
1162
+ */
1163
+ export const UserResourceAuthorityProjection = z.object({
1164
+ id: z.string().uuid(),
1165
+ organizationId: z.string().uuid(),
1166
+ scope: z.literal("user"),
1167
+ resourceKind: z.string().min(1).max(64),
1168
+ originWorkspaceId: z.string().uuid().nullable(),
1169
+ generation: z.number().int().positive(),
1170
+ status: z.enum(["active", "retained", "revoked"]),
1171
+ });
1172
+ export type UserResourceAuthorityProjection = z.infer<typeof UserResourceAuthorityProjection>;
1173
+
1174
+ /**
1175
+ * Opaque grant projection. A grant is still inert until a server-side access
1176
+ * boundary proves the organization, owner, workspace, session context, and
1177
+ * current authority epoch.
1178
+ */
1179
+ export const UserResourceGrantProjection = z
1180
+ .object({
1181
+ id: z.string().uuid(),
1182
+ authorityId: z.string().uuid(),
1183
+ organizationId: z.string().uuid(),
1184
+ workspaceId: z.string().uuid(),
1185
+ sessionId: z.string().uuid().nullable(),
1186
+ action: UserResourceGrantAction,
1187
+ mode: UserResourceGrantMode,
1188
+ context: SessionTenancyVisibility,
1189
+ authorityEpoch: z.number().int().positive().nullable(),
1190
+ generation: z.number().int().positive(),
1191
+ status: UserResourceGrantStatus,
1192
+ expiresAt: z.string().datetime({ offset: true }).nullable(),
1193
+ })
1194
+ .superRefine(refineUserResourceGrantFence);
1195
+ export type UserResourceGrantProjection = z.infer<typeof UserResourceGrantProjection>;
1196
+
1197
+ /**
1198
+ * Extensible immutable delegation payload for accepted work. It contains only
1199
+ * opaque authority/grant identity and execution fences, never owner identity
1200
+ * or credential material.
1201
+ */
1202
+ export const UserResourceDelegation = z
1203
+ .object({
1204
+ authorityId: z.string().uuid(),
1205
+ grantId: z.string().uuid(),
1206
+ organizationId: z.string().uuid(),
1207
+ workspaceId: z.string().uuid(),
1208
+ sessionId: z.string().uuid().nullable(),
1209
+ action: UserResourceGrantAction,
1210
+ mode: UserResourceGrantMode,
1211
+ context: SessionTenancyVisibility,
1212
+ authorityEpoch: z.number().int().positive().nullable(),
1213
+ authorityGeneration: z.number().int().positive(),
1214
+ grantGeneration: z.number().int().positive(),
1215
+ resourceVersionId: z.string().uuid().nullable().optional(),
1216
+ })
1217
+ .superRefine(refineUserResourceGrantFence);
1218
+ export type UserResourceDelegation = z.infer<typeof UserResourceDelegation>;
1219
+
1220
+ /**
1221
+ * Compatibility envelope for future resource selectors. Omitted scope and
1222
+ * authority parse to workspace-only behavior; user authority is impossible
1223
+ * without one complete opaque delegation.
1224
+ */
1225
+ export const ResourceAuthorityEnvelope = z
1226
+ .object({
1227
+ scope: ResourceAuthorityScope.default("workspace"),
1228
+ userDelegation: UserResourceDelegation.optional(),
1229
+ })
1230
+ .superRefine((value, context) => {
1231
+ if (value.scope === "user" && value.userDelegation === undefined) {
1232
+ context.addIssue({
1233
+ code: "custom",
1234
+ path: ["userDelegation"],
1235
+ message: "user scope requires an explicit immutable delegation",
1236
+ });
1237
+ }
1238
+ if (value.scope !== "user" && value.userDelegation !== undefined) {
1239
+ context.addIssue({
1240
+ code: "custom",
1241
+ path: ["userDelegation"],
1242
+ message: "only user scope may carry a user delegation",
1243
+ });
1244
+ }
1245
+ });
1246
+ export type ResourceAuthorityEnvelope = z.infer<typeof ResourceAuthorityEnvelope>;
1247
+
1248
+ /** Secret-safe generic session tenancy metadata for an authorized viewer. */
1249
+ export const SessionTenancyProjection = z.object({
1250
+ visibility: SessionTenancyVisibility,
1251
+ authorityEpoch: z.number().int().positive(),
1252
+ ownedByCurrentUser: z.boolean(),
1253
+ fork: z
1254
+ .object({
1255
+ sourceVisibility: SessionTenancyVisibility,
1256
+ sourceAuthorityEpoch: z.number().int().positive(),
1257
+ forkedAt: z.string().datetime({ offset: true }),
1258
+ })
1259
+ .nullable(),
1260
+ });
1261
+ export type SessionTenancyProjection = z.infer<typeof SessionTenancyProjection>;
1262
+
1263
+ /** Secret-safe public projection used by activated session APIs. */
1264
+ export const SessionTenancyPublicProjection = z.object({
1265
+ visibility: SessionVisibility,
1266
+ authorityEpoch: z.number().int().positive(),
1267
+ ownedByCurrentUser: z.boolean(),
1268
+ fork: z
1269
+ .object({
1270
+ sourceVisibility: SessionVisibility,
1271
+ sourceAuthorityEpoch: z.number().int().positive(),
1272
+ forkedAt: z.string().datetime({ offset: true }),
1273
+ })
1274
+ .nullable(),
1275
+ });
1276
+ export type SessionTenancyPublicProjection = z.infer<typeof SessionTenancyPublicProjection>;
1277
+
985
1278
  export const ManagedAccount = z.object({
986
1279
  id: z.string().uuid(),
987
1280
  name: z.string(),
@@ -1422,12 +1715,17 @@ export const DEFAULT_WORKSPACE_SLACK_REACTION_SUMMON_SETTINGS = {
1422
1715
  channelPolicy: { mode: "bot_member" },
1423
1716
  } as const satisfies WorkspaceSlackReactionSummonSettings;
1424
1717
 
1718
+ export const WorkspaceMemoryPromptMode = z.enum(["legacy_standing", "retrieval_only"]);
1719
+ export type WorkspaceMemoryPromptMode = z.infer<typeof WorkspaceMemoryPromptMode>;
1720
+
1425
1721
  // Validates the KNOWN keys of workspaces.settings; passthrough keeps unknown
1426
- // (future) keys rather than stripping them. memoryEnabled defaults off;
1722
+ // (future) keys rather than stripping them. memoryEnabled defaults off and the
1723
+ // reversible Memory V1 containment rollout defaults to legacy standing context;
1427
1724
  // voiceInput defaults to enabled when the deployment has a provider.
1428
1725
  export const WorkspaceSettingsSchema = z
1429
1726
  .object({
1430
1727
  memoryEnabled: z.boolean().optional(),
1728
+ memoryPromptMode: WorkspaceMemoryPromptMode.optional(),
1431
1729
  /** Preferred workspace voice-input toggle. */
1432
1730
  voiceInput: WorkspaceVoiceInputSettings.optional(),
1433
1731
  /**
@@ -1457,6 +1755,12 @@ export function resolveWorkspaceMemoryEnabled(settings: unknown): boolean {
1457
1755
  return parsed.success ? parsed.data.memoryEnabled === true : false;
1458
1756
  }
1459
1757
 
1758
+ /** Reversible Memory V1 prompt rollout. Absent preserves legacy composition. */
1759
+ export function resolveWorkspaceMemoryPromptMode(settings: unknown): WorkspaceMemoryPromptMode {
1760
+ const parsed = WorkspaceSettingsSchema.safeParse(settings ?? {});
1761
+ return parsed.success ? (parsed.data.memoryPromptMode ?? "legacy_standing") : "legacy_standing";
1762
+ }
1763
+
1460
1764
  /** Default Codex compaction mode for new Codex sessions (remote_v2 when unset). */
1461
1765
  export function resolveWorkspaceCodexCompactionDefault(settings: unknown): CodexCompactionMode {
1462
1766
  const parsed = WorkspaceSettingsSchema.safeParse(settings ?? {});
@@ -1527,6 +1831,7 @@ export function workspaceSlackReactionChannelAllowed(
1527
1831
  export const UpdateWorkspaceSettingsRequest = z
1528
1832
  .object({
1529
1833
  memoryEnabled: z.boolean().optional(),
1834
+ memoryPromptMode: WorkspaceMemoryPromptMode.optional(),
1530
1835
  voiceInput: WorkspaceVoiceInputSettings.optional(),
1531
1836
  /** @deprecated Prefer `voiceInput`. Kept for one compatibility release. */
1532
1837
  transcription: WorkspaceTranscriptionPolicy.optional(),
@@ -1594,6 +1899,8 @@ const reservedServiceTurnInitiatorContextKeys = new Set([
1594
1899
  "backfill",
1595
1900
  "label",
1596
1901
  "provenanceError",
1902
+ "opengeniSiteAuthConnectionId",
1903
+ "opengeniSiteAuthMaintenanceOperationId",
1597
1904
  "via",
1598
1905
  "viaTruncated",
1599
1906
  ]);
@@ -1695,6 +2002,11 @@ export const DelegatedAccessTokenPayload = z
1695
2002
  // Model-visible first-party tool selection for a worker-bound session.
1696
2003
  // This is visibility only; permissions remain the authorization boundary.
1697
2004
  firstPartyMcpTools: z.array(FirstPartyMcpToolName).optional(),
2005
+ // Trusted root-relative depth facts frozen when the worker prepares this
2006
+ // attempt. They shape only the model-visible tool catalog; the database
2007
+ // remains authoritative for admission and concurrent policy changes.
2008
+ nestedAgentDepth: NestedAgentDepthValue.optional(),
2009
+ effectiveMaxNestedAgentDepth: NestedAgentDepthValue.optional(),
1698
2010
  // The turn making the call (the caller's identity), HMAC-signed by the worker
1699
2011
  // at turn setup. Lets a tool classify WHO is calling from the token itself,
1700
2012
  // instead of racily re-reading the session's live active_turn_id — e.g. the
@@ -1715,6 +2027,23 @@ export const DelegatedAccessTokenPayload = z
1715
2027
  payload.executionGeneration,
1716
2028
  ];
1717
2029
  const exactAttemptClaimCount = exactAttemptClaims.filter((value) => value !== undefined).length;
2030
+ const depthClaimCount = [payload.nestedAgentDepth, payload.effectiveMaxNestedAgentDepth].filter(
2031
+ (value) => value !== undefined,
2032
+ ).length;
2033
+ if (depthClaimCount !== 0 && depthClaimCount !== 2) {
2034
+ ctx.addIssue({
2035
+ code: z.ZodIssueCode.custom,
2036
+ path: ["nestedAgentDepth"],
2037
+ message: "nested-agent depth claims must be supplied together",
2038
+ });
2039
+ }
2040
+ if (depthClaimCount > 0 && payload.principalKind !== "agent_attempt") {
2041
+ ctx.addIssue({
2042
+ code: z.ZodIssueCode.custom,
2043
+ path: ["principalKind"],
2044
+ message: "nested-agent depth claims require an agent_attempt principal",
2045
+ });
2046
+ }
1718
2047
  if (
1719
2048
  payload.principalKind === "human_session" &&
1720
2049
  (exactAttemptClaimCount !== 0 || payload.serviceInitiator !== undefined)
@@ -2371,9 +2700,9 @@ export type InsightsModelUsageRow = z.infer<typeof InsightsModelUsageRow>;
2371
2700
 
2372
2701
  export const InsightsSeriesPoint = z.object({
2373
2702
  label: z.string().min(1),
2374
- /** Day-bucketed sum of usage_events.model.cost (workspace-wide) or filtered facts when provider/model set. */
2703
+ /** UTC hour/day-bucketed sum of usage_events.model.cost (workspace-wide) or filtered facts when provider/model set. */
2375
2704
  modelCostUsd: z.number().nonnegative(),
2376
- /** Day-bucketed hypothetical provider-rate USD for calls with captured pricing. */
2705
+ /** UTC hour/day-bucketed hypothetical provider-rate USD for calls with captured pricing. */
2377
2706
  estimatedProviderUsd: z.number().nonnegative(),
2378
2707
  estimatedProviderCostKnownCalls: z.number().int().nonnegative(),
2379
2708
  warmSeconds: z.number().nonnegative(),
@@ -3697,6 +4026,7 @@ export const DocumentSearchResult = z.object({
3697
4026
  authorityKind: DocumentAuthorityKind,
3698
4027
  authorityWorkspaceId: z.string().uuid().nullable(),
3699
4028
  authoritySubjectId: z.string().nullable(),
4029
+ citation: KnowledgeProviderCitation.nullable().optional(),
3700
4030
  });
3701
4031
  export type DocumentSearchResult = z.infer<typeof DocumentSearchResult>;
3702
4032
 
@@ -3726,6 +4056,7 @@ export const IndexedDocumentProvenance = z.object({
3726
4056
  authoritySubjectId: z.string().nullable(),
3727
4057
  createdBy: z.string().nullable(),
3728
4058
  createdAt: z.string(),
4059
+ citation: KnowledgeProviderCitation.nullable().optional(),
3729
4060
  });
3730
4061
  export type IndexedDocumentProvenance = z.infer<typeof IndexedDocumentProvenance>;
3731
4062
 
@@ -4293,6 +4624,86 @@ export type SessionGoalStatus = z.infer<typeof SessionGoalStatus>;
4293
4624
  export const SessionGoalCreatedBy = z.enum(["api", "agent", "scheduled_task"]);
4294
4625
  export type SessionGoalCreatedBy = z.infer<typeof SessionGoalCreatedBy>;
4295
4626
 
4627
+ export const SessionGoalMutationPolicy = z.enum([
4628
+ "review_changes",
4629
+ "preserve_intent",
4630
+ "autonomous_adaptation",
4631
+ ]);
4632
+ export type SessionGoalMutationPolicy = z.infer<typeof SessionGoalMutationPolicy>;
4633
+
4634
+ export const SessionGoalChangeKind = z.enum(["refinement", "adaptation", "replacement"]);
4635
+ export type SessionGoalChangeKind = z.infer<typeof SessionGoalChangeKind>;
4636
+
4637
+ export const SESSION_GOAL_TEXT_MAX_BYTES = 8 * 1024;
4638
+ export const SESSION_GOAL_SUCCESS_CRITERIA_MAX_BYTES = 8 * 1024;
4639
+ export const SESSION_GOAL_RATIONALE_MAX_BYTES = 2 * 1024;
4640
+ export const SESSION_GOAL_PROGRESS_MAX_BYTES = 4 * 1024;
4641
+
4642
+ export function sessionGoalUtf8Bytes(value: string): number {
4643
+ return new TextEncoder().encode(value).byteLength;
4644
+ }
4645
+
4646
+ function boundedSessionGoalString(maxBytes: number, field: string) {
4647
+ return z
4648
+ .string()
4649
+ .min(1)
4650
+ .refine((value) => sessionGoalUtf8Bytes(value) <= maxBytes, {
4651
+ message: `${field} exceeds ${maxBytes} UTF-8 bytes`,
4652
+ });
4653
+ }
4654
+
4655
+ const SessionGoalTextWrite = boundedSessionGoalString(SESSION_GOAL_TEXT_MAX_BYTES, "goal text");
4656
+ const SessionGoalSuccessCriteriaWrite = boundedSessionGoalString(
4657
+ SESSION_GOAL_SUCCESS_CRITERIA_MAX_BYTES,
4658
+ "goal success criteria",
4659
+ );
4660
+ const SessionGoalRationaleWrite = boundedSessionGoalString(
4661
+ SESSION_GOAL_RATIONALE_MAX_BYTES,
4662
+ "goal rationale",
4663
+ );
4664
+
4665
+ export const SessionGoalSnapshot = z.discriminatedUnion("state", [
4666
+ z.object({ state: z.literal("none"), capturedAt: z.string() }),
4667
+ z.object({
4668
+ state: z.enum(["active", "paused", "completed"]),
4669
+ goalId: z.string().uuid(),
4670
+ objectiveRevision: z.number().int().positive(),
4671
+ text: SessionGoalTextWrite,
4672
+ successCriteria: SessionGoalSuccessCriteriaWrite.nullable(),
4673
+ mutationPolicy: SessionGoalMutationPolicy,
4674
+ capturedAt: z.string(),
4675
+ }),
4676
+ ]);
4677
+ export type SessionGoalSnapshot = z.infer<typeof SessionGoalSnapshot>;
4678
+
4679
+ export const SessionGoalRevision = z.object({
4680
+ id: z.string().uuid(),
4681
+ accountId: z.string().uuid(),
4682
+ workspaceId: z.string().uuid(),
4683
+ sessionId: z.string().uuid(),
4684
+ goalId: z.string().uuid(),
4685
+ disposition: z.enum(["applied", "proposed", "rejected"]),
4686
+ changeKind: SessionGoalChangeKind,
4687
+ baseObjectiveRevision: z.number().int().nonnegative(),
4688
+ resultObjectiveRevision: z.number().int().positive().nullable(),
4689
+ text: z.string().min(1),
4690
+ successCriteria: z.string().nullable(),
4691
+ mutationPolicy: SessionGoalMutationPolicy,
4692
+ rationale: z.string().min(1),
4693
+ actor: z.enum(["agent", "api", "scheduled_task"]),
4694
+ actorTurnId: z.string().uuid().nullable(),
4695
+ actorAttemptId: z.string().uuid().nullable(),
4696
+ proposalId: z.string().uuid().nullable(),
4697
+ createdAt: z.string(),
4698
+ });
4699
+ export type SessionGoalRevision = z.infer<typeof SessionGoalRevision>;
4700
+
4701
+ export const ApplySessionGoalRevisionRequest = z.object({
4702
+ expectedObjectiveRevision: z.number().int().positive(),
4703
+ rationale: SessionGoalRationaleWrite.optional(),
4704
+ });
4705
+ export type ApplySessionGoalRevisionRequest = z.infer<typeof ApplySessionGoalRevisionRequest>;
4706
+
4296
4707
  export const SessionGoalPausedReason = z.enum([
4297
4708
  "agent",
4298
4709
  "user_pause",
@@ -4351,6 +4762,8 @@ export const SessionGoal = z.object({
4351
4762
  pausedReason: z.string().nullable(),
4352
4763
  createdBy: SessionGoalCreatedBy,
4353
4764
  version: z.number().int().positive(),
4765
+ objectiveRevision: z.number().int().positive(),
4766
+ mutationPolicy: SessionGoalMutationPolicy,
4354
4767
  autoContinuations: z.number().int().nonnegative(),
4355
4768
  noProgressStreak: z.number().int().nonnegative(),
4356
4769
  maxAutoContinuations: z.number().int().positive().nullable(),
@@ -4364,16 +4777,26 @@ export const SessionGoal = z.object({
4364
4777
  export type SessionGoal = z.infer<typeof SessionGoal>;
4365
4778
 
4366
4779
  export const GoalSpec = z.object({
4367
- text: z.string().min(1),
4368
- successCriteria: z.string().min(1).optional(),
4780
+ text: SessionGoalTextWrite,
4781
+ successCriteria: SessionGoalSuccessCriteriaWrite.optional(),
4369
4782
  maxAutoContinuations: z.number().int().positive().optional(),
4783
+ mutationPolicy: SessionGoalMutationPolicy.optional(),
4370
4784
  });
4371
4785
  export type GoalSpec = z.infer<typeof GoalSpec>;
4372
4786
 
4373
- export const UpdateSessionGoalRequest = z.object({
4374
- status: z.enum(["paused", "active"]),
4375
- rationale: z.string().min(1).optional(),
4376
- });
4787
+ export const UpdateSessionGoalRequest = z.union([
4788
+ z.object({
4789
+ status: z.enum(["paused", "active"]),
4790
+ rationale: SessionGoalRationaleWrite.optional(),
4791
+ }),
4792
+ z.object({
4793
+ text: SessionGoalTextWrite,
4794
+ successCriteria: SessionGoalSuccessCriteriaWrite.nullable().optional(),
4795
+ mutationPolicy: SessionGoalMutationPolicy.optional(),
4796
+ rationale: SessionGoalRationaleWrite,
4797
+ expectedObjectiveRevision: z.number().int().positive(),
4798
+ }),
4799
+ ]);
4377
4800
  export type UpdateSessionGoalRequest = z.infer<typeof UpdateSessionGoalRequest>;
4378
4801
 
4379
4802
  export const UpdateSessionRequest = z.object({
@@ -4669,8 +5092,26 @@ export const SessionRealtimeInboundEntry = z
4669
5092
  delegationItemId: z.string().max(1024).nullable().optional(),
4670
5093
  text: z.string().max(131_072).nullable().optional(),
4671
5094
  payload: z.record(z.string(), z.unknown()).optional(),
5095
+ // Application context attached to the exact delegation/transcript message.
5096
+ // It is ordinary model-visible user-message content when materialized, not
5097
+ // a secret or instruction-authority boundary.
5098
+ modelContext: z.string().trim().min(1).max(32768).optional(),
4672
5099
  })
4673
- .strict();
5100
+ .strict()
5101
+ .superRefine((entry, context) => {
5102
+ if (
5103
+ entry.modelContext !== undefined &&
5104
+ entry.kind !== "delegation_call" &&
5105
+ entry.kind !== "user_transcript" &&
5106
+ entry.kind !== "assistant_transcript"
5107
+ ) {
5108
+ context.addIssue({
5109
+ code: "custom",
5110
+ path: ["modelContext"],
5111
+ message: "modelContext requires a delegation or finalized transcript entry",
5112
+ });
5113
+ }
5114
+ });
4674
5115
  export type SessionRealtimeInboundEntry = z.infer<typeof SessionRealtimeInboundEntry>;
4675
5116
 
4676
5117
  export const SyncSessionRealtimeLedgerRequest = SessionRealtimeOwnerProof.extend({
@@ -4702,6 +5143,7 @@ export type SyncSessionRealtimeLedgerResponse = z.infer<typeof SyncSessionRealti
4702
5143
 
4703
5144
  export const SessionRealtimeModel = z.enum([
4704
5145
  "gpt-live-1-boulder-alpha",
5146
+ "supergrok/grok-voice-think-fast-2.0",
4705
5147
  "opengeni-gateway/openai/gpt-realtime-2.1",
4706
5148
  "opengeni-gateway/openai/gpt-realtime-mini",
4707
5149
  "opengeni-gateway/xai/grok-voice-think-fast-2.0",
@@ -4714,7 +5156,7 @@ export type SessionRealtimeModel = z.infer<typeof SessionRealtimeModel>;
4714
5156
  export const WorkspaceRealtimeModelCatalogItem = z.object({
4715
5157
  id: SessionRealtimeModel,
4716
5158
  label: z.string().min(1),
4717
- provider: z.enum(["OpenGeni", "Connected Codex", "Your Gateway"]),
5159
+ provider: z.enum(["OpenGeni", "Connected Codex", "Connected SuperGrok", "Your Gateway"]),
4718
5160
  description: z.string().min(1),
4719
5161
  available: z.boolean(),
4720
5162
  unavailableReason: z.string().nullable(),
@@ -4808,11 +5250,14 @@ export const SessionAuthorizationOperation = z.enum([
4808
5250
  "session.human_input.read",
4809
5251
  "session.human_input.write",
4810
5252
  "session.title.write",
5253
+ "session.channel.write",
4811
5254
  "session.mcp.approval_policy.write",
4812
5255
  "session.tool_policy.write",
4813
5256
  "session.goal.read",
4814
5257
  "session.goal.write",
4815
5258
  "session.child.create",
5259
+ "session.visibility.write",
5260
+ "session.fork.create",
4816
5261
  ]);
4817
5262
  export type SessionAuthorizationOperation = z.infer<typeof SessionAuthorizationOperation>;
4818
5263
 
@@ -5135,6 +5580,28 @@ export function renderTimelineAnnotationsForModel(
5135
5580
  ].join("\n");
5136
5581
  }
5137
5582
 
5583
+ export const MODEL_CONTEXT_LABEL = "[Application context attached to this user message]" as const;
5584
+
5585
+ /**
5586
+ * Build one canonical user-role message body. `modelContext` is ordinary
5587
+ * message content: it is model-visible in the same chronological position as
5588
+ * the visible text, but presentation layers may omit it. It is not a secret or
5589
+ * an instruction-authority boundary.
5590
+ */
5591
+ export function renderUserMessageContentForModel(
5592
+ text: string,
5593
+ annotations: readonly TimelineAnnotation[],
5594
+ modelContext?: string | null,
5595
+ ): string | Array<{ type: "input_text"; text: string }> {
5596
+ const visibleContent = renderTimelineAnnotationsForModel(text, annotations);
5597
+ const context = modelContext?.trim();
5598
+ if (!context) return visibleContent;
5599
+ return [
5600
+ { type: "input_text", text: `${MODEL_CONTEXT_LABEL}\n${context}` },
5601
+ { type: "input_text", text: visibleContent },
5602
+ ];
5603
+ }
5604
+
5138
5605
  export const SessionTurn = z
5139
5606
  .object({
5140
5607
  id: z.string().uuid(),
@@ -5744,12 +6211,16 @@ export const VariableSetVariableName = z
5744
6211
  .max(128);
5745
6212
  export type VariableSetVariableName = z.infer<typeof VariableSetVariableName>;
5746
6213
 
5747
- function withVariableSetIdAlias<T extends z.ZodRawShape>(shape: T) {
6214
+ function withVariableSetIdAlias<T extends z.ZodRawShape>(
6215
+ shape: T,
6216
+ options: { rejectKeys?: readonly string[] } = {},
6217
+ ) {
5748
6218
  return z.preprocess((input) => {
5749
6219
  if (!input || typeof input !== "object" || Array.isArray(input)) {
5750
6220
  return input;
5751
6221
  }
5752
6222
  const record = input as Record<string, unknown>;
6223
+ if (options.rejectKeys?.some((key) => Object.hasOwn(record, key))) return null;
5753
6224
  if (record.variableSetId !== undefined || record.environmentId === undefined) {
5754
6225
  return record;
5755
6226
  }
@@ -6070,6 +6541,40 @@ export const UpdateRigRequest = z.object({
6070
6541
  });
6071
6542
  export type UpdateRigRequest = z.infer<typeof UpdateRigRequest>;
6072
6543
 
6544
+ // Workspace-shared channels organize root sessions ("workstreams") by work
6545
+ // type in the rail. Pure organizational metadata: filing a session into a
6546
+ // channel never affects execution, authority, memory, or history.
6547
+ export const Channel = z.object({
6548
+ id: z.string().uuid(),
6549
+ accountId: z.string().uuid(),
6550
+ workspaceId: z.string().uuid(),
6551
+ name: z.string(),
6552
+ description: z.string().nullable(),
6553
+ createdBy: z.string().nullable(),
6554
+ createdAt: z.string(),
6555
+ updatedAt: z.string(),
6556
+ });
6557
+ export type Channel = z.infer<typeof Channel>;
6558
+
6559
+ export const CreateChannelRequest = z.object({
6560
+ name: z.string().trim().min(1).max(80),
6561
+ description: z.string().max(2000).optional(),
6562
+ });
6563
+ export type CreateChannelRequest = z.infer<typeof CreateChannelRequest>;
6564
+
6565
+ export const UpdateChannelRequest = z.object({
6566
+ name: z.string().trim().min(1).max(80).optional(),
6567
+ description: z.string().max(2000).nullable().optional(),
6568
+ });
6569
+ export type UpdateChannelRequest = z.infer<typeof UpdateChannelRequest>;
6570
+
6571
+ // Re-files one session (rail organization only). null moves it back to the
6572
+ // unfiled inbox.
6573
+ export const UpdateSessionChannelRequest = z.object({
6574
+ channelId: z.string().uuid().nullable(),
6575
+ });
6576
+ export type UpdateSessionChannelRequest = z.infer<typeof UpdateSessionChannelRequest>;
6577
+
6073
6578
  // setup_append: the exact command that already worked (+ an optional note).
6074
6579
  export const RigSetupAppendPayload = z.object({
6075
6580
  command: z.string().min(1).max(8192),
@@ -6418,47 +6923,48 @@ export const CreateScheduledTaskRequest = /* @__PURE__ */ z.union([
6418
6923
  ]);
6419
6924
  export type CreateScheduledTaskRequest = z.infer<typeof CreateScheduledTaskRequest>;
6420
6925
 
6421
- export const UpdateScheduledTaskRequest = /* @__PURE__ */ withVariableSetIdAlias({
6422
- name: z.string().min(1).optional(),
6423
- schedule: ScheduledTaskScheduleSpec.optional(),
6424
- runMode: ScheduledTaskRunMode.optional(),
6425
- overlapPolicy: ScheduledTaskOverlapPolicy.optional(),
6426
- action: ScheduledTaskAction.optional(),
6427
- targetSessionId: z.string().uuid().nullable().optional(),
6428
- agentConfig: ScheduledTaskAgentConfig.optional(),
6429
- status: ScheduledTaskStatus.optional(),
6430
- variableSetId: z.string().uuid().nullable().optional(),
6431
- environmentId: z.string().uuid().nullable().optional(),
6432
- // The rig each run binds to (M3); null clears it. Its active version is
6433
- // resolved per fire, so an update takes effect on the next dispatch.
6434
- rigId: z.string().uuid().nullable().optional(),
6435
- metadata: z.record(z.string(), z.unknown()).optional(),
6436
- }).superRefine((value, context) => {
6437
- if (value.targetSessionId && value.runMode && value.runMode !== "existing_session") {
6438
- context.addIssue({
6439
- code: "custom",
6440
- path: ["targetSessionId"],
6441
- message: "targetSessionId requires runMode=existing_session",
6442
- });
6443
- }
6444
- if (value.runMode === "existing_session" && value.targetSessionId === null) {
6445
- context.addIssue({
6446
- code: "custom",
6447
- path: ["targetSessionId"],
6448
- message: "targetSessionId cannot be null when runMode=existing_session",
6449
- });
6450
- }
6451
- if (
6452
- value.agentConfig?.goal &&
6453
- (value.runMode === "existing_session" || Boolean(value.targetSessionId))
6454
- ) {
6455
- context.addIssue({
6456
- code: "custom",
6457
- path: ["agentConfig", "goal"],
6458
- message: "agentConfig.goal cannot be used with an existing-session target",
6459
- });
6460
- }
6461
- });
6926
+ export const UpdateScheduledTaskRequest =
6927
+ /* @__PURE__ */ withVariableSetIdAlias({
6928
+ name: z.string().min(1).optional(),
6929
+ schedule: ScheduledTaskScheduleSpec.optional(),
6930
+ runMode: ScheduledTaskRunMode.optional(),
6931
+ overlapPolicy: ScheduledTaskOverlapPolicy.optional(),
6932
+ action: ScheduledTaskAction.optional(),
6933
+ targetSessionId: z.string().uuid().nullable().optional(),
6934
+ agentConfig: ScheduledTaskAgentConfig.optional(),
6935
+ status: ScheduledTaskStatus.optional(),
6936
+ variableSetId: z.string().uuid().nullable().optional(),
6937
+ environmentId: z.string().uuid().nullable().optional(),
6938
+ // The rig each run binds to (M3); null clears it. Its active version is
6939
+ // resolved per fire, so an update takes effect on the next dispatch.
6940
+ rigId: z.string().uuid().nullable().optional(),
6941
+ metadata: z.record(z.string(), z.unknown()).optional(),
6942
+ }).superRefine((value, context) => {
6943
+ if (value.targetSessionId && value.runMode && value.runMode !== "existing_session") {
6944
+ context.addIssue({
6945
+ code: "custom",
6946
+ path: ["targetSessionId"],
6947
+ message: "targetSessionId requires runMode=existing_session",
6948
+ });
6949
+ }
6950
+ if (value.runMode === "existing_session" && value.targetSessionId === null) {
6951
+ context.addIssue({
6952
+ code: "custom",
6953
+ path: ["targetSessionId"],
6954
+ message: "targetSessionId cannot be null when runMode=existing_session",
6955
+ });
6956
+ }
6957
+ if (
6958
+ value.agentConfig?.goal &&
6959
+ (value.runMode === "existing_session" || Boolean(value.targetSessionId))
6960
+ ) {
6961
+ context.addIssue({
6962
+ code: "custom",
6963
+ path: ["agentConfig", "goal"],
6964
+ message: "agentConfig.goal cannot be used with an existing-session target",
6965
+ });
6966
+ }
6967
+ });
6462
6968
  export type UpdateScheduledTaskRequest = z.infer<typeof UpdateScheduledTaskRequest>;
6463
6969
 
6464
6970
  /**
@@ -6668,10 +7174,10 @@ export const CapabilityPackComponentReference = z.discriminatedUnion("kind", [
6668
7174
  z
6669
7175
  .object({
6670
7176
  key: CapabilityPackComponentKey,
6671
- kind: z.literal("feature"),
7177
+ kind: z.literal("facet"),
6672
7178
  capabilityId: z.string().min(1).max(512),
6673
7179
  instanceKey: CapabilityPackInstanceKey,
6674
- featureKey: z.string().min(1).max(200),
7180
+ facetKey: z.string().min(1).max(200),
6675
7181
  bindingKey: CapabilityPackInstanceKey,
6676
7182
  configDigest: z.string().regex(/^[0-9a-f]{64}$/),
6677
7183
  required: z.boolean().default(true),
@@ -6880,7 +7386,7 @@ export type PackComponentResolutionStatus = z.infer<typeof PackComponentResoluti
6880
7386
  export const PackComponentResolution = z
6881
7387
  .object({
6882
7388
  key: CapabilityPackComponentKey,
6883
- kind: z.enum(["plugin", "skill", "integration", "feature", "inline_skill"]),
7389
+ kind: z.enum(["plugin", "skill", "integration", "facet", "inline_skill"]),
6884
7390
  capabilityId: z.string().min(1).max(512),
6885
7391
  required: z.boolean(),
6886
7392
  status: PackComponentResolutionStatus,
@@ -6956,7 +7462,7 @@ export const PackUninstallPreview = z
6956
7462
  z
6957
7463
  .object({
6958
7464
  key: CapabilityPackComponentKey,
6959
- kind: z.enum(["plugin", "skill", "integration", "feature", "inline_skill"]),
7465
+ kind: z.enum(["plugin", "skill", "integration", "facet", "inline_skill"]),
6960
7466
  capabilityId: z.string().min(1).max(512),
6961
7467
  retainedByOtherOwners: z.boolean(),
6962
7468
  })
@@ -7102,6 +7608,48 @@ export const OpenGeniSlackBotConnectionMetadata = z
7102
7608
  .passthrough();
7103
7609
  export type OpenGeniSlackBotConnectionMetadata = z.infer<typeof OpenGeniSlackBotConnectionMetadata>;
7104
7610
 
7611
+ export const FIKEN_PROVIDER_DOMAIN = "fiken.no" as const;
7612
+ export const FIKEN_CREDENTIAL_ROLE = "fiken_api_token" as const;
7613
+ export const FIKEN_CREDENTIAL_LABEL = "Fiken API token" as const;
7614
+
7615
+ export const FikenCompanySummary = z.object({
7616
+ slug: z.string().min(1).max(128),
7617
+ name: z.string().min(1).max(256),
7618
+ organizationNumber: z.string().max(64).nullable(),
7619
+ });
7620
+ export type FikenCompanySummary = z.infer<typeof FikenCompanySummary>;
7621
+
7622
+ export const FikenConnectionMetadata = z
7623
+ .object({
7624
+ credentialRole: z.literal(FIKEN_CREDENTIAL_ROLE),
7625
+ credentialLabel: z.literal(FIKEN_CREDENTIAL_LABEL),
7626
+ companies: z.array(FikenCompanySummary).max(100),
7627
+ defaultCompanySlug: z.string().min(1).max(128).nullable(),
7628
+ verifiedAt: z.string().datetime({ offset: true }),
7629
+ })
7630
+ .passthrough();
7631
+ export type FikenConnectionMetadata = z.infer<typeof FikenConnectionMetadata>;
7632
+
7633
+ export const FikenInstallRequest = z.object({
7634
+ apiToken: z.string().min(16).max(512),
7635
+ defaultCompanySlug: z.string().min(1).max(128).optional(),
7636
+ /** Existing Fiken connection to rewrite in place (reconnect). */
7637
+ connectionId: z.string().uuid().optional(),
7638
+ });
7639
+ export type FikenInstallRequest = z.infer<typeof FikenInstallRequest>;
7640
+
7641
+ export const FikenOAuthStartRequest = z.object({
7642
+ /** Existing Fiken connection to re-authorize in place (reconnect). */
7643
+ connectionId: z.string().uuid().optional(),
7644
+ });
7645
+ export type FikenOAuthStartRequest = z.infer<typeof FikenOAuthStartRequest>;
7646
+
7647
+ export const FikenOAuthStartResponse = z.object({
7648
+ authorizationUrl: z.string().url(),
7649
+ expiresAt: z.string().datetime({ offset: true }),
7650
+ });
7651
+ export type FikenOAuthStartResponse = z.infer<typeof FikenOAuthStartResponse>;
7652
+
7105
7653
  export const ConnectionMetadata = z.object({
7106
7654
  id: z.string().uuid(),
7107
7655
  accountId: z.string().uuid(),
@@ -7514,7 +8062,7 @@ export type CapabilityInstallation = z.infer<typeof CapabilityInstallation>;
7514
8062
 
7515
8063
  export const CreateCapabilityCatalogItemRequest = z.object({
7516
8064
  id: z.string().min(1).optional(),
7517
- kind: CapabilityKind.exclude(["pack"]),
8065
+ kind: z.literal("mcp"),
7518
8066
  source: CapabilitySource.default("manual"),
7519
8067
  name: z.string().min(1),
7520
8068
  description: z.string().min(1).optional(),
@@ -7528,7 +8076,7 @@ export const CreateCapabilityCatalogItemRequest = z.object({
7528
8076
  });
7529
8077
  export type CreateCapabilityCatalogItemRequest = z.infer<typeof CreateCapabilityCatalogItemRequest>;
7530
8078
 
7531
- export const EnableCapabilityRequest = withVariableSetIdAlias({
8079
+ export const EnableCapabilityRequest = z.object({
7532
8080
  config: z.record(z.string(), z.unknown()).default({}),
7533
8081
  metadata: z.record(z.string(), z.unknown()).default({}),
7534
8082
  connectionRef: McpServerConnectionRef.optional(),
@@ -7539,14 +8087,6 @@ export const EnableCapabilityRequest = withVariableSetIdAlias({
7539
8087
  * and never returned by the API — responses expose header names only.
7540
8088
  */
7541
8089
  headers: z.record(z.string(), z.string()).default({}),
7542
- /**
7543
- * Initial variableSet attachment for kind=pack capabilities. Mirrors the
7544
- * dedicated POST /packs/:id/enable body: required to enable an
7545
- * variableSet.required pack through the unified capability-enable path,
7546
- * optional otherwise. Ignored by non-pack capabilities.
7547
- */
7548
- variableSetId: z.string().uuid().optional(),
7549
- environmentId: z.string().uuid().optional(),
7550
8090
  });
7551
8091
  export type EnableCapabilityRequest = z.infer<typeof EnableCapabilityRequest>;
7552
8092
 
@@ -7566,6 +8106,9 @@ export type DiscoverMcpCapabilitiesResponse = z.infer<typeof DiscoverMcpCapabili
7566
8106
  export const SkillImportSource = z.enum(["github", "skills_sh"]);
7567
8107
  export type SkillImportSource = z.infer<typeof SkillImportSource>;
7568
8108
 
8109
+ export const SkillInstallationSource = z.enum(["library", "github", "skills_sh", "pack"]);
8110
+ export type SkillInstallationSource = z.infer<typeof SkillInstallationSource>;
8111
+
7569
8112
  export const PreviewSkillImportRequest = z.object({
7570
8113
  url: z.string().url().max(2048),
7571
8114
  });
@@ -7605,6 +8148,15 @@ export const InstallSkillRequest = z.object({
7605
8148
  });
7606
8149
  export type InstallSkillRequest = z.infer<typeof InstallSkillRequest>;
7607
8150
 
8151
+ export const InstallLibrarySkillRequest = z
8152
+ .object({
8153
+ expectedVersion: z.string().min(1).max(96),
8154
+ expectedContentSha256: z.string().regex(/^[0-9a-f]{64}$/),
8155
+ expectedInstallationVersion: z.number().int().positive().optional(),
8156
+ })
8157
+ .strict();
8158
+ export type InstallLibrarySkillRequest = z.infer<typeof InstallLibrarySkillRequest>;
8159
+
7608
8160
  export const InstalledSkill = z.object({
7609
8161
  capabilityId: z.string().min(1),
7610
8162
  pluginId: z.string().uuid(),
@@ -7613,7 +8165,8 @@ export const InstalledSkill = z.object({
7613
8165
  pluginInstallationId: z.string().uuid(),
7614
8166
  facetInstallationId: z.string().uuid(),
7615
8167
  installationVersion: z.number().int().positive(),
7616
- source: SkillImportSource,
8168
+ source: SkillInstallationSource,
8169
+ version: z.string().min(1).max(96),
7617
8170
  sourceUrl: z.string().url(),
7618
8171
  sourceCommit: z.string().regex(/^[0-9a-f]{40,64}$/),
7619
8172
  contentSha256: z.string().regex(/^[0-9a-f]{64}$/),
@@ -7629,6 +8182,38 @@ export const CapabilityComponentOwner = z.object({
7629
8182
  });
7630
8183
  export type CapabilityComponentOwner = z.infer<typeof CapabilityComponentOwner>;
7631
8184
 
8185
+ export const InstalledSkillSummary = z
8186
+ .object({
8187
+ capabilityId: z.string().min(1),
8188
+ pluginKey: z.string().min(1).max(200),
8189
+ installationVersion: z.number().int().positive(),
8190
+ name: z.string().min(1).max(200),
8191
+ description: z.string().max(4000),
8192
+ category: z.string().min(1).max(100),
8193
+ tags: z.array(z.string().min(1).max(100)).max(64),
8194
+ provenance: z.string().min(1).max(4000),
8195
+ source: SkillInstallationSource,
8196
+ version: z.string().min(1).max(96),
8197
+ sourceUrl: z.string().url().max(2048),
8198
+ repositoryUrl: z.string().url().max(2048),
8199
+ sourceCommit: z.string().regex(/^[0-9a-f]{40,64}$/),
8200
+ sourcePath: z.string().min(1).max(1024),
8201
+ contentSha256: z.string().regex(/^[0-9a-f]{64}$/),
8202
+ fileCount: z.number().int().positive().max(128),
8203
+ totalBytes: z.number().int().positive().max(1048576),
8204
+ license: z.string().min(1).max(200).nullable(),
8205
+ installedAt: z.string().datetime({ offset: true }),
8206
+ updatedAt: z.string().datetime({ offset: true }),
8207
+ owners: z.array(CapabilityComponentOwner).min(1),
8208
+ })
8209
+ .strict();
8210
+ export type InstalledSkillSummary = z.infer<typeof InstalledSkillSummary>;
8211
+
8212
+ export const ListInstalledSkillsResponse = z
8213
+ .object({ skills: z.array(InstalledSkillSummary).max(1000) })
8214
+ .strict();
8215
+ export type ListInstalledSkillsResponse = z.infer<typeof ListInstalledSkillsResponse>;
8216
+
7632
8217
  export const SkillUninstallPreview = z.object({
7633
8218
  capabilityId: z.string().min(1),
7634
8219
  installed: z.boolean(),
@@ -7654,26 +8239,29 @@ export type UninstallSkillResult = z.infer<typeof UninstallSkillResult>;
7654
8239
  export const ApiIntegrationProtocol = z.enum(["openapi", "graphql"]);
7655
8240
  export type ApiIntegrationProtocol = z.infer<typeof ApiIntegrationProtocol>;
7656
8241
 
7657
- export const IntegrationFeatureKey = z
8242
+ export const IntegrationDefinitionProvenance = z.enum(["curated", "workspace"]);
8243
+ export type IntegrationDefinitionProvenance = z.infer<typeof IntegrationDefinitionProvenance>;
8244
+
8245
+ export const IntegrationFacetKey = z
7658
8246
  .string()
7659
8247
  .min(1)
7660
8248
  .max(200)
7661
8249
  .regex(/^[a-z0-9](?:[a-z0-9._/-]*[a-z0-9])?$/);
7662
- export type IntegrationFeatureKey = z.infer<typeof IntegrationFeatureKey>;
8250
+ export type IntegrationFacetKey = z.infer<typeof IntegrationFacetKey>;
7663
8251
 
7664
- export const IntegrationFeatureKind = z.enum([
8252
+ export const IntegrationFacetKind = z.enum([
7665
8253
  "tools",
7666
8254
  "knowledge_source",
7667
8255
  "inbound_trigger",
7668
8256
  "delivery_destination",
7669
8257
  "identity_link",
7670
8258
  ]);
7671
- export type IntegrationFeatureKind = z.infer<typeof IntegrationFeatureKind>;
8259
+ export type IntegrationFacetKind = z.infer<typeof IntegrationFacetKind>;
7672
8260
 
7673
- export const IntegrationFeatureStatus = z.enum(["active", "paused", "needs_attention", "disabled"]);
7674
- export type IntegrationFeatureStatus = z.infer<typeof IntegrationFeatureStatus>;
8261
+ export const IntegrationFacetStatus = z.enum(["active", "paused", "needs_attention", "disabled"]);
8262
+ export type IntegrationFacetStatus = z.infer<typeof IntegrationFacetStatus>;
7675
8263
 
7676
- const IntegrationFeatureJsonObject = z.record(z.string(), z.unknown()).superRefine((value, ctx) => {
8264
+ const IntegrationFacetJsonObject = z.record(z.string(), z.unknown()).superRefine((value, ctx) => {
7677
8265
  let serialized: string;
7678
8266
  try {
7679
8267
  serialized = JSON.stringify(value);
@@ -7682,40 +8270,50 @@ const IntegrationFeatureJsonObject = z.record(z.string(), z.unknown()).superRefi
7682
8270
  return;
7683
8271
  }
7684
8272
  if (new TextEncoder().encode(serialized).byteLength > 131_072) {
7685
- ctx.addIssue({ code: "custom", message: "must not exceed 131072 UTF-8 bytes" });
8273
+ ctx.addIssue({
8274
+ code: "custom",
8275
+ message: "must not exceed 131072 UTF-8 bytes",
8276
+ });
7686
8277
  }
7687
8278
  });
7688
8279
 
7689
- export const IntegrationFeatureDefinitionSummary = z
8280
+ export const IntegrationFacetDefinitionSummary = z
7690
8281
  .object({
7691
- featureKey: IntegrationFeatureKey,
7692
- kind: IntegrationFeatureKind.exclude(["tools"]),
7693
- configSchema: IntegrationFeatureJsonObject,
7694
- capabilities: IntegrationFeatureJsonObject,
8282
+ facetKey: IntegrationFacetKey,
8283
+ kind: IntegrationFacetKind.exclude(["tools"]),
8284
+ configSchema: IntegrationFacetJsonObject,
8285
+ capabilities: IntegrationFacetJsonObject,
7695
8286
  })
7696
8287
  .strict();
7697
- export type IntegrationFeatureDefinitionSummary = z.infer<
7698
- typeof IntegrationFeatureDefinitionSummary
7699
- >;
8288
+ export type IntegrationFacetDefinitionSummary = z.infer<typeof IntegrationFacetDefinitionSummary>;
7700
8289
 
7701
- export const ApiIntegrationPresetSummary = z
8290
+ export const IntegrationDefinitionSummary = z
7702
8291
  .object({
7703
8292
  id: z.string().min(1).max(128),
7704
8293
  name: z.string().min(1).max(200),
7705
8294
  summary: z.string().min(1).max(1000),
7706
- family: z.enum(["google", "microsoft"]),
7707
8295
  protocol: z.literal("openapi"),
7708
- providerDomain: z.string().min(1).max(253),
7709
- scopes: z.array(z.string().min(1).max(1024)).max(256),
7710
- features: z.array(IntegrationFeatureDefinitionSummary).max(128),
8296
+ provider: z
8297
+ .object({
8298
+ id: z.enum(["google", "microsoft"]),
8299
+ domain: z.string().min(1).max(253),
8300
+ })
8301
+ .strict(),
8302
+ authentication: z
8303
+ .object({
8304
+ kind: z.literal("oauth2"),
8305
+ scopes: z.array(z.string().min(1).max(1024)).max(256),
8306
+ })
8307
+ .strict(),
8308
+ facets: z.array(IntegrationFacetDefinitionSummary).max(128),
7711
8309
  })
7712
8310
  .strict();
7713
- export type ApiIntegrationPresetSummary = z.infer<typeof ApiIntegrationPresetSummary>;
8311
+ export type IntegrationDefinitionSummary = z.infer<typeof IntegrationDefinitionSummary>;
7714
8312
 
7715
- export const ListApiIntegrationPresetsResponse = z
7716
- .object({ presets: z.array(ApiIntegrationPresetSummary).max(128) })
8313
+ export const ListIntegrationDefinitionsResponse = z
8314
+ .object({ definitions: z.array(IntegrationDefinitionSummary).max(128) })
7717
8315
  .strict();
7718
- export type ListApiIntegrationPresetsResponse = z.infer<typeof ListApiIntegrationPresetsResponse>;
8316
+ export type ListIntegrationDefinitionsResponse = z.infer<typeof ListIntegrationDefinitionsResponse>;
7719
8317
 
7720
8318
  export const IntegrationInstanceKey = z
7721
8319
  .string()
@@ -7724,16 +8322,16 @@ export const IntegrationInstanceKey = z
7724
8322
  .regex(/^[a-z0-9](?:[a-z0-9._/-]*[a-z0-9])?$/);
7725
8323
  export type IntegrationInstanceKey = z.infer<typeof IntegrationInstanceKey>;
7726
8324
 
7727
- export const IntegrationFeatureBindingSummary = z
8325
+ export const IntegrationFacetBindingSummary = z
7728
8326
  .object({
7729
8327
  id: z.string().uuid(),
7730
- featureKey: IntegrationFeatureKey,
7731
- kind: IntegrationFeatureKind.exclude(["tools"]),
8328
+ facetKey: IntegrationFacetKey,
8329
+ kind: IntegrationFacetKind.exclude(["tools"]),
7732
8330
  bindingKey: IntegrationInstanceKey,
7733
8331
  displayName: z.string().min(1).max(200),
7734
8332
  connectionId: z.string().uuid().nullable(),
7735
- status: IntegrationFeatureStatus,
7736
- config: IntegrationFeatureJsonObject,
8333
+ status: IntegrationFacetStatus,
8334
+ config: IntegrationFacetJsonObject,
7737
8335
  version: z.number().int().positive(),
7738
8336
  hasCursor: z.boolean(),
7739
8337
  lastSuccessAt: z.string().datetime({ offset: true }).nullable(),
@@ -7742,73 +8340,76 @@ export const IntegrationFeatureBindingSummary = z
7742
8340
  updatedAt: z.string().datetime({ offset: true }),
7743
8341
  })
7744
8342
  .strict();
7745
- export type IntegrationFeatureBindingSummary = z.infer<typeof IntegrationFeatureBindingSummary>;
8343
+ export type IntegrationFacetBindingSummary = z.infer<typeof IntegrationFacetBindingSummary>;
7746
8344
 
7747
- export const IntegrationInstanceFeaturesResponse = z
8345
+ export const IntegrationInstanceFacetsResponse = z
7748
8346
  .object({
7749
8347
  capabilityId: z.string().min(1).max(512),
7750
8348
  instanceKey: IntegrationInstanceKey,
7751
8349
  providerDomain: z.string().min(1).max(253),
7752
8350
  connectionId: z.string().uuid().nullable(),
7753
- features: z
8351
+ facets: z
7754
8352
  .array(
7755
8353
  z
7756
8354
  .object({
7757
- definition: IntegrationFeatureDefinitionSummary,
7758
- binding: IntegrationFeatureBindingSummary.nullable(),
8355
+ definition: IntegrationFacetDefinitionSummary,
8356
+ binding: IntegrationFacetBindingSummary.nullable(),
7759
8357
  })
7760
8358
  .strict(),
7761
8359
  )
7762
8360
  .max(128),
7763
8361
  })
7764
8362
  .strict();
7765
- export type IntegrationInstanceFeaturesResponse = z.infer<
7766
- typeof IntegrationInstanceFeaturesResponse
7767
- >;
8363
+ export type IntegrationInstanceFacetsResponse = z.infer<typeof IntegrationInstanceFacetsResponse>;
7768
8364
 
7769
- export const UpsertIntegrationFeatureRequest = z
8365
+ export const UpsertIntegrationFacetRequest = z
7770
8366
  .object({
7771
8367
  displayName: z.string().min(1).max(200),
7772
- config: IntegrationFeatureJsonObject.default({}),
8368
+ config: IntegrationFacetJsonObject.default({}),
7773
8369
  expectedVersion: z.number().int().positive().optional(),
7774
8370
  idempotencyKey: z.string().uuid(),
7775
8371
  })
7776
8372
  .strict();
7777
- export type UpsertIntegrationFeatureRequest = z.infer<typeof UpsertIntegrationFeatureRequest>;
8373
+ export type UpsertIntegrationFacetRequest = z.infer<typeof UpsertIntegrationFacetRequest>;
7778
8374
 
7779
- export const MutateIntegrationFeatureRequest = z
8375
+ export const MutateIntegrationFacetRequest = z
7780
8376
  .object({
7781
8377
  expectedVersion: z.number().int().positive(),
7782
8378
  idempotencyKey: z.string().uuid(),
7783
8379
  })
7784
8380
  .strict();
7785
- export type MutateIntegrationFeatureRequest = z.infer<typeof MutateIntegrationFeatureRequest>;
8381
+ export type MutateIntegrationFacetRequest = z.infer<typeof MutateIntegrationFacetRequest>;
7786
8382
 
7787
- export const IntegrationFeatureMutationResult = z
8383
+ export const IntegrationFacetMutationResult = z
7788
8384
  .object({
7789
8385
  capabilityId: z.string().min(1).max(512),
7790
8386
  instanceKey: IntegrationInstanceKey,
7791
- featureKey: IntegrationFeatureKey,
8387
+ facetKey: IntegrationFacetKey,
7792
8388
  status: z.enum(["configured", "paused", "active"]),
7793
- binding: IntegrationFeatureBindingSummary,
8389
+ binding: IntegrationFacetBindingSummary,
7794
8390
  })
7795
8391
  .strict();
7796
- export type IntegrationFeatureMutationResult = z.infer<typeof IntegrationFeatureMutationResult>;
8392
+ export type IntegrationFacetMutationResult = z.infer<typeof IntegrationFacetMutationResult>;
7797
8393
 
7798
- export const IntegrationFeatureRemovalResult = z
8394
+ export const IntegrationFacetRemovalResult = z
7799
8395
  .object({
7800
8396
  capabilityId: z.string().min(1).max(512),
7801
8397
  instanceKey: IntegrationInstanceKey,
7802
- featureKey: IntegrationFeatureKey,
8398
+ facetKey: IntegrationFacetKey,
7803
8399
  status: z.enum(["not_configured", "removed", "retained_by_other_owners"]),
7804
- binding: IntegrationFeatureBindingSummary.nullable(),
8400
+ binding: IntegrationFacetBindingSummary.nullable(),
7805
8401
  remainingOwners: z.array(CapabilityComponentOwner),
7806
8402
  })
7807
8403
  .strict();
7808
- export type IntegrationFeatureRemovalResult = z.infer<typeof IntegrationFeatureRemovalResult>;
8404
+ export type IntegrationFacetRemovalResult = z.infer<typeof IntegrationFacetRemovalResult>;
7809
8405
 
7810
- export const ApiIntegrationSource = z.discriminatedUnion("kind", [
7811
- z.object({ kind: z.literal("preset"), presetId: z.string().min(1).max(128) }).strict(),
8406
+ export const IntegrationSource = z.discriminatedUnion("kind", [
8407
+ z
8408
+ .object({
8409
+ kind: z.literal("definition"),
8410
+ definitionId: z.string().min(1).max(128),
8411
+ })
8412
+ .strict(),
7812
8413
  z
7813
8414
  .object({
7814
8415
  kind: z.literal("openapi"),
@@ -7831,11 +8432,11 @@ export const ApiIntegrationSource = z.discriminatedUnion("kind", [
7831
8432
  })
7832
8433
  .strict(),
7833
8434
  ]);
7834
- export type ApiIntegrationSource = z.infer<typeof ApiIntegrationSource>;
8435
+ export type IntegrationSource = z.infer<typeof IntegrationSource>;
7835
8436
 
7836
8437
  export const PreviewApiIntegrationRequest = z
7837
8438
  .object({
7838
- source: ApiIntegrationSource,
8439
+ source: IntegrationSource,
7839
8440
  connectionId: z.string().uuid().optional(),
7840
8441
  ownership: ConnectionOwnership.optional(),
7841
8442
  })
@@ -7844,7 +8445,7 @@ export type PreviewApiIntegrationRequest = z.infer<typeof PreviewApiIntegrationR
7844
8445
 
7845
8446
  export const ApiIntegrationOAuthStartRequest = z
7846
8447
  .object({
7847
- presetId: z.string().min(1).max(128),
8448
+ definitionId: z.string().min(1).max(128),
7848
8449
  ownership: ConnectionOwnership.optional(),
7849
8450
  connectionId: z.string().uuid().optional(),
7850
8451
  returnPath: z.string().min(1).max(2048).optional(),
@@ -7861,7 +8462,7 @@ export const ApiIntegrationOAuthConnectionMetadata = z
7861
8462
  providerPrincipalId: z.string().min(1).max(512),
7862
8463
  providerEmail: z.string().min(1).max(512).nullable(),
7863
8464
  providerDisplayName: z.string().min(1).max(512).nullable(),
7864
- authorizedPresetIds: z.array(z.string().min(1).max(128)).min(1).max(32),
8465
+ authorizedDefinitionIds: z.array(z.string().min(1).max(128)).min(1).max(32),
7865
8466
  verifiedAt: z.string().datetime({ offset: true }),
7866
8467
  })
7867
8468
  .passthrough();
@@ -7911,10 +8512,10 @@ export type ApiIntegrationToolPreview = z.infer<typeof ApiIntegrationToolPreview
7911
8512
 
7912
8513
  export const ApiIntegrationPreview = z
7913
8514
  .object({
7914
- source: ApiIntegrationSource,
7915
- presetId: z.string().min(1).max(128).nullable(),
8515
+ source: IntegrationSource,
8516
+ definitionId: z.string().min(1).max(200),
8517
+ definitionProvenance: IntegrationDefinitionProvenance,
7916
8518
  protocol: ApiIntegrationProtocol,
7917
- integrationId: z.string().min(1).max(200),
7918
8519
  capabilityId: z.string().min(1).max(512),
7919
8520
  pluginKey: z.string().min(1).max(200),
7920
8521
  serverId: SessionMcpServerId,
@@ -7937,7 +8538,7 @@ export type ApiIntegrationPreview = z.infer<typeof ApiIntegrationPreview>;
7937
8538
 
7938
8539
  export const InstallApiIntegrationRequest = z
7939
8540
  .object({
7940
- source: ApiIntegrationSource,
8541
+ source: IntegrationSource,
7941
8542
  expectedRevisionId: z.string().min(1).max(96),
7942
8543
  expectedContentSha256: z.string().regex(/^[0-9a-f]{64}$/),
7943
8544
  connectionId: z.string().uuid().optional(),
@@ -7985,7 +8586,8 @@ export const ApiIntegrationInstallationSummary = z
7985
8586
  name: z.string().min(1),
7986
8587
  description: z.string().nullable(),
7987
8588
  protocol: ApiIntegrationProtocol,
7988
- presetId: z.string().min(1).max(128).nullable(),
8589
+ definitionId: z.string().min(1).max(200),
8590
+ definitionProvenance: IntegrationDefinitionProvenance,
7989
8591
  providerDomain: z.string().min(1),
7990
8592
  baseUrl: z.string().url(),
7991
8593
  sourceUrl: z.string().url().nullable(),
@@ -8065,13 +8667,17 @@ export const PluginManifest = z
8065
8667
  .array(
8066
8668
  z.discriminatedUnion("kind", [
8067
8669
  z
8068
- .object({ key: PluginComponentKey, kind: z.literal("skill"), url: z.string().url() })
8670
+ .object({
8671
+ key: PluginComponentKey,
8672
+ kind: z.literal("skill"),
8673
+ url: z.string().url(),
8674
+ })
8069
8675
  .strict(),
8070
8676
  z
8071
8677
  .object({
8072
8678
  key: PluginComponentKey,
8073
8679
  kind: z.literal("integration"),
8074
- source: ApiIntegrationSource,
8680
+ source: IntegrationSource,
8075
8681
  })
8076
8682
  .strict(),
8077
8683
  z
@@ -8166,7 +8772,12 @@ export const InstallPluginRequest = z
8166
8772
  expectedManifestDigest: z.string().regex(/^[0-9a-f]{64}$/),
8167
8773
  expectedComponents: z
8168
8774
  .array(
8169
- z.object({ key: PluginComponentKey, digest: z.string().regex(/^[0-9a-f]{64}$/) }).strict(),
8775
+ z
8776
+ .object({
8777
+ key: PluginComponentKey,
8778
+ digest: z.string().regex(/^[0-9a-f]{64}$/),
8779
+ })
8780
+ .strict(),
8170
8781
  )
8171
8782
  .min(1)
8172
8783
  .max(64),
@@ -8276,6 +8887,8 @@ export const Session = z.object({
8276
8887
  // the workspace runtime registry.
8277
8888
  effectiveToolPolicy: SessionEffectiveToolPolicy.optional(),
8278
8889
  metadata: z.record(z.string(), z.unknown()),
8890
+ /** Additive public tenancy projection; omitted by legacy/internal readers. */
8891
+ tenancy: SessionTenancyPublicProjection.optional(),
8279
8892
  /** Frozen creator fact used only for creation attribution/idempotent repair. */
8280
8893
  createdBy: TurnInitiator,
8281
8894
  createdByContext: TurnInitiatorContext,
@@ -8307,6 +8920,9 @@ export const Session = z.object({
8307
8920
  // Both null ⇒ a rig-less session (byte-for-byte today's behavior).
8308
8921
  rigId: z.string().uuid().nullable().default(null),
8309
8922
  rigVersionId: z.string().uuid().nullable().default(null),
8923
+ // Workspace channel this session is filed under (rail organization only;
8924
+ // a session tree is grouped by its ROOT session's channel). Null = unfiled.
8925
+ channelId: z.string().uuid().nullable().default(null),
8310
8926
  // Non-default first-party MCP token permissions (manager-style sessions);
8311
8927
  // null means the fixed worker default set.
8312
8928
  firstPartyMcpPermissions: z.array(Permission).nullable(),
@@ -8486,6 +9102,7 @@ export type SessionLineageResponse = z.infer<typeof SessionLineageResponse>;
8486
9102
 
8487
9103
  export const SessionEventType = z.enum([
8488
9104
  "session.created",
9105
+ "session.visibility.changed",
8489
9106
  // Defensive read/transport projection for a malformed or historically
8490
9107
  // oversized retained event envelope. The original row stays durable; this
8491
9108
  // explicit synthetic type prevents unbounded free-form envelope fields from
@@ -8536,6 +9153,9 @@ export const SessionEventType = z.enum([
8536
9153
  "artifact.created",
8537
9154
  "goal.set",
8538
9155
  "goal.updated",
9156
+ "goal.progress",
9157
+ "goal.rewrite.proposed",
9158
+ "goal.rewrite.rejected",
8539
9159
  "goal.completed",
8540
9160
  "goal.paused",
8541
9161
  "goal.resumed",
@@ -8739,6 +9359,9 @@ export const SESSION_EVENT_SEMANTIC_CLASS_TYPES = {
8739
9359
  "user.humanInputResponse",
8740
9360
  "goal.set",
8741
9361
  "goal.updated",
9362
+ "goal.progress",
9363
+ "goal.rewrite.proposed",
9364
+ "goal.rewrite.rejected",
8742
9365
  "goal.completed",
8743
9366
  "goal.paused",
8744
9367
  "goal.resumed",
@@ -10645,130 +11268,138 @@ export const SessionControlResponse = z.object({
10645
11268
  });
10646
11269
  export type SessionControlResponse = z.infer<typeof SessionControlResponse>;
10647
11270
 
10648
- export const CreateSessionRequest = withVariableSetIdAlias({
10649
- /**
10650
- * Optional UUID preallocated by an embedding host. This lets the host durably
10651
- * link its own projection before OpenGeni admits the initial turn. Replays
10652
- * must pair it with the same idempotency key; OpenGeni never derives host
10653
- * identity or authorization from the UUID.
10654
- */
10655
- requestedSessionId: z.string().uuid().optional(),
10656
- initialMessage: z.string().min(1).optional(),
10657
- // Creates the durable session shell without fabricating a user message or
10658
- // starting an underlying agent turn. Realtime can then become the first
10659
- // interaction and use the ordinary Send/Steer path when it delegates.
10660
- startMode: z.literal("realtime").optional(),
10661
- // System-level host context for the initial turn only. Unlike `instructions`,
10662
- // this does not persist into later turns and is never emitted as a user event.
10663
- turnInstructions: z.string().trim().min(1).max(32768).optional(),
10664
- // Per-session agent persona/system instructions (org-visible metadata, NOT a
10665
- // secret). Rides the SAME system-level instructions channel the per-workspace
10666
- // agentInstructions rides, composed AFTER the workspace persona so it refines
10667
- // it for this one session how a host delivers per-agent-type prompts without
10668
- // leaking them into the user-visible timeline (it is NEVER emitted as an
10669
- // event, unlike goal/initialMessage). Trimmed, non-empty. The 32768-char cap
10670
- // matches the codebase's largest free-form string convention (workspace
10671
- // variable set variable values). Absent byte-identical to today.
10672
- instructions: z.string().trim().min(1).max(32768).optional(),
10673
- // Immutable prompt-policy role binding for matching one activated role
10674
- // policy. This never derives from or grants a human workspace membership
10675
- // role. Existing callers may continue to use normalized metadata.role as a
10676
- // compatibility fallback by omitting this field.
10677
- policyRole: WorkspaceInstructionPolicyRoleKeyInput.optional(),
10678
- // For an agent-created child, omission inherits the trusted immediate
10679
- // parent's repository/file context. An explicit array, including [], is
10680
- // authoritative. Top-level omission remains []. Presence is resolved from
10681
- // the raw request because this Zod default erases absent-vs-empty.
10682
- resources: z.array(ResourceRef).default([]),
10683
- // Inline skills are fixed onto the session. Child omission inherits the
10684
- // trusted parent's selection; an explicit array, including [], wins.
10685
- skills: SessionSkills.default([]),
10686
- // The same child omission rule applies to selected MCP tool refs. Top-level
10687
- // omission still applies workspace-default capability MCP tools; explicit []
10688
- // suppresses those defaults (the first-party OpenGeni server remains added).
10689
- tools: z.array(ToolRef).default([]),
10690
- metadata: z.record(z.string(), z.unknown()).default({}),
10691
- model: z.string().min(1).optional(),
10692
- reasoningEffort: ReasoningEffort.optional(),
10693
- latencyMode: LatencyMode.optional(),
10694
- sandboxBackend: SandboxBackend.optional(),
10695
- // The enrolled machine (a sandbox id) to run this session on; seeds the
10696
- // active-sandbox pointer at creation so the FIRST turn routes to the chosen
10697
- // machine (race-free: the pointer is committed before the worker turn
10698
- // workflow can read it). An invalid/unowned/offline target fails the create.
10699
- targetSandboxId: z.string().uuid().optional(),
10700
- // The working directory the targeted machine runs the session under — the
10701
- // path/cwd base for its agent exec, terminal, and file dock. Free-form pass-
10702
- // through: a launch-workspace_root-relative subdir or an absolute machine path
10703
- // (the agent's resolve_cwd handles both). Only valid WITH targetSandboxId
10704
- // (workingDir alone is a 422); omitted the machine's default workspace_root.
10705
- workingDir: z.string().min(1).optional(),
10706
- // Variable set attachment is fixed at session creation; follow-up
10707
- // user.message events cannot switch or add one.
10708
- variableSetId: z.string().uuid().optional(),
10709
- environmentId: z.string().uuid().optional(),
10710
- // The rig to bind this session to (M3). Its ACTIVE version is resolved and
10711
- // FROZEN onto the session at create. Omitted ⇒ inherit the workspace default;
10712
- // null explicitly create a rig-less session; UUID bind that exact rig.
10713
- // An id that does not name a rig in the workspace is a 422.
10714
- rigId: z.string().uuid().nullable().optional(),
10715
- goal: GoalSpec.optional(),
10716
- clientEventId: SessionOperationKey.optional(),
10717
- // Workspace-scoped CREATE idempotency key: collapses concurrent/retried
10718
- // create calls carrying the same key to a single session (partial unique
10719
- // index on (workspace_id, create_idempotency_key)). Distinct from
10720
- // clientEventId, whose uniqueness is per-session and so cannot dedup the
10721
- // creation of a brand-new session. Absent means no create-dedup (each call
10722
- // is an independent create).
10723
- idempotencyKey: z.string().min(1).max(200).optional(),
10724
- // The exact actor-private pre-session draft revision represented by this
10725
- // create. The durable initializer consumes only this revision. A newer draft
10726
- // written by a sibling tab survives, while every failed pre-initialization
10727
- // create leaves the submitted draft intact.
10728
- expectedNewSessionDraftRevision: z.number().int().nonnegative().optional(),
10729
- // A child may lower its inherited limit freely; an increase requires
10730
- // workspace:admin and is checked again at the DB transaction boundary.
10731
- maxNestedAgentDepth: NestedAgentDepthValue.optional(),
10732
- // Permissions the session's first-party MCP token should carry. A top-level
10733
- // omission uses the deployment's worker default; a child omission inherits
10734
- // the creating session's effective grant. An explicit set is capped at
10735
- // creation: every requested permission must be held by the creating grant.
10736
- // A goal-bearing session whose explicit/effective set omits goals:manage is
10737
- // rejected; creation never silently expands a child beyond that set.
10738
- firstPartyMcpPermissions: z.array(Permission).optional(),
10739
- // Exact model-visible selection from the broad first-party OpenGeni MCP
10740
- // catalog. Omission selects the safe non-connector default; [] intentionally
10741
- // exposes none.
10742
- // This does not grant authority: every registered tool is permission-gated.
10743
- firstPartyMcpTools: z.array(FirstPartyMcpToolName).optional(),
10744
- // Third-party MCP servers attached only to this session. For an agent-created
10745
- // child, omission snapshots its trusted immediate parent's server definitions,
10746
- // policies, connection refs, and encrypted credentials. Explicit arrays,
10747
- // including [], are authoritative; non-empty explicit arrays require attach
10748
- // permission. Credential headers are write-only: create responses and events
10749
- // expose only SessionMcpServerMetadata.
10750
- mcpServers: z.array(SessionMcpServerInput).max(SESSION_MCP_SERVERS_MAX).default([]),
10751
- // Shared-sandbox placement (addendum 05 §D.1). Three-way union; OMITTED
10752
- // today's behavior (a context-dependent default resolved server-side: from
10753
- // inside a session "shared" with the creator's box, top-level → "new").
10754
- // - "shared": join the CREATOR's box. Requires a parent session (inferred
10755
- // from the worker-signed sessionId claim, never caller-supplied);
10756
- // top-level "shared" is a 422.
10757
- // - "new": mint a fresh singleton box (group the new session's id).
10758
- // - {groupId}: join a SPECIFIC sibling group in THIS workspace (manager
10759
- // fan-out). Validated workspace-scoped (cross-workspace404).
10760
- // A shared spawn inherits the box's (backend, os) it is literally the same
10761
- // box; the child cannot pick its own backend. Cross-workspace sharing is
10762
- // forbidden by construction (the parent/group reads are RLS-workspace-scoped).
10763
- // ENV-AWARE: the box's variable set is fixed at creation, so a share requires
10764
- // the SAME variableSetId as the creator's box. On a mismatch the inherited
10765
- // default silently falls back to an own box; an explicit "shared"/{groupId}
10766
- // request 422s at create (instead of the first turn dying on the SDK's
10767
- // manifest-env guard).
10768
- sandbox: z
10769
- .union([z.literal("shared"), z.literal("new"), z.object({ groupId: z.string().uuid() })])
10770
- .optional(),
10771
- }).superRefine((value, context) => {
11271
+ export const CreateSessionRequest = withVariableSetIdAlias(
11272
+ {
11273
+ /**
11274
+ * Optional UUID preallocated by an embedding host. This lets the host durably
11275
+ * link its own projection before OpenGeni admits the initial turn. Replays
11276
+ * must pair it with the same idempotency key; OpenGeni never derives host
11277
+ * identity or authorization from the UUID.
11278
+ */
11279
+ requestedSessionId: z.string().uuid().optional(),
11280
+ initialMessage: z.string().min(1).optional(),
11281
+ // Creates the durable session shell without fabricating a user message or
11282
+ // starting an underlying agent turn. Realtime can then become the first
11283
+ // interaction and use the ordinary Send/Steer path when it delegates.
11284
+ startMode: z.literal("realtime").optional(),
11285
+ // Model-visible application context attached to the initial user message.
11286
+ // Standard timeline rendering omits it, while full event/audit reads retain
11287
+ // it. This is ordinary user-role content, not secret or privileged input.
11288
+ modelContext: z.string().trim().min(1).max(32768).optional(),
11289
+ // Per-session agent persona/system instructions (org-visible metadata, NOT a
11290
+ // secret). Rides the SAME system-level instructions channel the per-workspace
11291
+ // agentInstructions rides, composed AFTER the workspace persona so it refines
11292
+ // it for this one session how a host delivers per-agent-type prompts without
11293
+ // leaking them into the user-visible timeline (it is NEVER emitted as an
11294
+ // event, unlike goal/initialMessage). Trimmed, non-empty. The 32768-char cap
11295
+ // matches the codebase's largest free-form string convention (workspace
11296
+ // variable set variable values). Absent byte-identical to today.
11297
+ instructions: z.string().trim().min(1).max(32768).optional(),
11298
+ // Immutable prompt-policy role binding for matching one activated role
11299
+ // policy. This never derives from or grants a human workspace membership
11300
+ // role. Existing callers may continue to use normalized metadata.role as a
11301
+ // compatibility fallback by omitting this field.
11302
+ policyRole: WorkspaceInstructionPolicyRoleKeyInput.optional(),
11303
+ // For an agent-created child, omission inherits the trusted immediate
11304
+ // parent's repository/file context. An explicit array, including [], is
11305
+ // authoritative. Top-level omission remains []. Presence is resolved from
11306
+ // the raw request because this Zod default erases absent-vs-empty.
11307
+ resources: z.array(ResourceRef).default([]),
11308
+ // Inline skills are fixed onto the session. Child omission inherits the
11309
+ // trusted parent's selection; an explicit array, including [], wins.
11310
+ skills: SessionSkills.default([]),
11311
+ // The same child omission rule applies to selected MCP tool refs. Top-level
11312
+ // omission still applies workspace-default capability MCP tools; explicit []
11313
+ // suppresses those defaults (the first-party OpenGeni server remains added).
11314
+ tools: z.array(ToolRef).default([]),
11315
+ metadata: z.record(z.string(), z.unknown()).default({}),
11316
+ model: z.string().min(1).optional(),
11317
+ reasoningEffort: ReasoningEffort.optional(),
11318
+ latencyMode: LatencyMode.optional(),
11319
+ sandboxBackend: SandboxBackend.optional(),
11320
+ // The enrolled machine (a sandbox id) to run this session on; seeds the
11321
+ // active-sandbox pointer at creation so the FIRST turn routes to the chosen
11322
+ // machine (race-free: the pointer is committed before the worker turn
11323
+ // workflow can read it). An invalid/unowned/offline target fails the create.
11324
+ targetSandboxId: z.string().uuid().optional(),
11325
+ // The working directory the targeted machine runs the session under — the
11326
+ // path/cwd base for its agent exec, terminal, and file dock. Free-form pass-
11327
+ // through: a launch-workspace_root-relative subdir or an absolute machine path
11328
+ // (the agent's resolve_cwd handles both). Only valid WITH targetSandboxId
11329
+ // (workingDir alone is a 422); omitted the machine's default workspace_root.
11330
+ workingDir: z.string().min(1).optional(),
11331
+ // Variable set attachment is fixed at session creation; follow-up
11332
+ // user.message events cannot switch or add one.
11333
+ variableSetId: z.string().uuid().optional(),
11334
+ environmentId: z.string().uuid().optional(),
11335
+ // The rig to bind this session to (M3). Its ACTIVE version is resolved and
11336
+ // FROZEN onto the session at create. Omitted inherit the workspace default;
11337
+ // null ⇒ explicitly create a rig-less session; UUID ⇒ bind that exact rig.
11338
+ // An id that does not name a rig in the workspace is a 422.
11339
+ rigId: z.string().uuid().nullable().optional(),
11340
+ // The workspace channel to file this session under (rail organization only).
11341
+ // Omitted/null unfiled (inbox). An id that does not name a channel in the
11342
+ // workspace is a 422.
11343
+ channelId: z.string().uuid().nullable().optional(),
11344
+ goal: GoalSpec.optional(),
11345
+ clientEventId: SessionOperationKey.optional(),
11346
+ // Workspace-scoped CREATE idempotency key: collapses concurrent/retried
11347
+ // create calls carrying the same key to a single session (partial unique
11348
+ // index on (workspace_id, create_idempotency_key)). Distinct from
11349
+ // clientEventId, whose uniqueness is per-session and so cannot dedup the
11350
+ // creation of a brand-new session. Absent means no create-dedup (each call
11351
+ // is an independent create).
11352
+ idempotencyKey: z.string().min(1).max(200).optional(),
11353
+ // The exact actor-private pre-session draft revision represented by this
11354
+ // create. The durable initializer consumes only this revision. A newer draft
11355
+ // written by a sibling tab survives, while every failed pre-initialization
11356
+ // create leaves the submitted draft intact.
11357
+ expectedNewSessionDraftRevision: z.number().int().nonnegative().optional(),
11358
+ // A child may lower its inherited limit freely; an increase requires
11359
+ // workspace:admin and is checked again at the DB transaction boundary.
11360
+ maxNestedAgentDepth: NestedAgentDepthValue.optional(),
11361
+ // Permissions the session's first-party MCP token should carry. A top-level
11362
+ // omission uses the deployment's worker default; a child omission inherits
11363
+ // the creating session's effective grant. An explicit set is capped at
11364
+ // creation: every requested permission must be held by the creating grant.
11365
+ // A goal-bearing session whose explicit/effective set omits goals:manage is
11366
+ // rejected; creation never silently expands a child beyond that set.
11367
+ firstPartyMcpPermissions: z.array(Permission).optional(),
11368
+ // Exact model-visible selection from the broad first-party OpenGeni MCP
11369
+ // catalog. Omission selects the safe non-connector default; [] intentionally
11370
+ // exposes none.
11371
+ // This does not grant authority: every registered tool is permission-gated.
11372
+ firstPartyMcpTools: z.array(FirstPartyMcpToolName).optional(),
11373
+ // Third-party MCP servers attached only to this session. For an agent-created
11374
+ // child, omission snapshots its trusted immediate parent's server definitions,
11375
+ // policies, connection refs, and encrypted credentials. Explicit arrays,
11376
+ // including [], are authoritative; non-empty explicit arrays require attach
11377
+ // permission. Credential headers are write-only: create responses and events
11378
+ // expose only SessionMcpServerMetadata.
11379
+ mcpServers: z.array(SessionMcpServerInput).max(SESSION_MCP_SERVERS_MAX).default([]),
11380
+ // Shared-sandbox placement (addendum 05 §D.1). Three-way union; OMITTED
11381
+ // today's behavior (a context-dependent default resolved server-side: from
11382
+ // inside a session → "shared" with the creator's box, top-level"new").
11383
+ // - "shared": join the CREATOR's box. Requires a parent session (inferred
11384
+ // from the worker-signed sessionId claim, never caller-supplied);
11385
+ // top-level "shared" is a 422.
11386
+ // - "new": mint a fresh singleton box (group the new session's id).
11387
+ // - {groupId}: join a SPECIFIC sibling group in THIS workspace (manager
11388
+ // fan-out). Validated workspace-scoped (cross-workspace 404).
11389
+ // A shared spawn inherits the box's (backend, os) it is literally the same
11390
+ // box; the child cannot pick its own backend. Cross-workspace sharing is
11391
+ // forbidden by construction (the parent/group reads are RLS-workspace-scoped).
11392
+ // ENV-AWARE: the box's variable set is fixed at creation, so a share requires
11393
+ // the SAME variableSetId as the creator's box. On a mismatch the inherited
11394
+ // default silently falls back to an own box; an explicit "shared"/{groupId}
11395
+ // request 422s at create (instead of the first turn dying on the SDK's
11396
+ // manifest-env guard).
11397
+ sandbox: z
11398
+ .union([z.literal("shared"), z.literal("new"), z.object({ groupId: z.string().uuid() })])
11399
+ .optional(),
11400
+ },
11401
+ { rejectKeys: ["turnInstructions"] },
11402
+ ).superRefine((value, context) => {
10772
11403
  if (value.startMode !== "realtime" && value.initialMessage === undefined) {
10773
11404
  context.addIssue({
10774
11405
  code: z.ZodIssueCode.custom,
@@ -10783,6 +11414,13 @@ export const CreateSessionRequest = withVariableSetIdAlias({
10783
11414
  message: "initialMessage must be omitted when startMode is realtime",
10784
11415
  });
10785
11416
  }
11417
+ if (value.startMode === "realtime" && value.modelContext !== undefined) {
11418
+ context.addIssue({
11419
+ code: z.ZodIssueCode.custom,
11420
+ path: ["modelContext"],
11421
+ message: "modelContext requires an initialMessage; attach it to a realtime entry instead",
11422
+ });
11423
+ }
10786
11424
  });
10787
11425
  export type CreateSessionRequest = z.infer<typeof CreateSessionRequest>;
10788
11426
 
@@ -10969,9 +11607,9 @@ export const SessionUserMessagePayload = z
10969
11607
  .object({
10970
11608
  text: z.string().default(""),
10971
11609
  annotations: SubmittedTimelineAnnotations.default([]),
10972
- // System-level host context for this exact turn only. Persisted on the
10973
- // turn for retry/recovery, never copied into the visible user message.
10974
- turnInstructions: z.string().trim().min(1).max(32768).optional(),
11610
+ // Model-visible application context attached to this exact user message.
11611
+ // It is retained in full event/history data but omitted by standard UI.
11612
+ modelContext: z.string().trim().min(1).max(32768).optional(),
10975
11613
  resources: z.array(ResourceRef).default([]),
10976
11614
  model: z.string().min(1).optional(),
10977
11615
  reasoningEffort: ReasoningEffort.optional(),
@@ -11016,8 +11654,8 @@ export const SteerSessionMessageRequest = z
11016
11654
  .object({
11017
11655
  text: z.string().default(""),
11018
11656
  annotations: SubmittedTimelineAnnotations.default([]),
11019
- // Same per-turn system-level context as a queued user.message.
11020
- turnInstructions: z.string().trim().min(1).max(32768).optional(),
11657
+ // Same model-visible message context as a queued user.message.
11658
+ modelContext: z.string().trim().min(1).max(32768).optional(),
11021
11659
  resources: z.array(ResourceRef).default([]),
11022
11660
  model: z.string().min(1).optional(),
11023
11661
  reasoningEffort: ReasoningEffort.optional(),
@@ -11171,7 +11809,7 @@ export const SessionCapabilities = z.object({
11171
11809
  reason: CapabilityUnavailableReason.nullable(),
11172
11810
  }),
11173
11811
  Terminal: z.object({
11174
- transport: z.enum(["sse-events", "pty-ws"]).nullable(),
11812
+ transport: z.enum(["sse-events", "pty-ws", "relay-pty"]).nullable(),
11175
11813
  ptyCapable: z.boolean(),
11176
11814
  shell: z.string(),
11177
11815
  // The direct-to-provider ttyd PTY-over-websocket URL (pty-ws) resolved on the
@@ -11288,7 +11926,7 @@ export const AttachViewerResponse = /* @__PURE__ */ ViewerHolder.extend({
11288
11926
  terminalUrl: z.string().nullable(),
11289
11927
  terminalToken: z.string().nullable(),
11290
11928
  terminalExpiresAt: z.string().nullable(),
11291
- terminalTransport: z.literal("pty-ws").nullable(),
11929
+ terminalTransport: z.enum(["pty-ws", "relay-pty"]).nullable(),
11292
11930
  });
11293
11931
  export type AttachViewerResponse = z.infer<typeof AttachViewerResponse>;
11294
11932
 
@@ -11828,7 +12466,7 @@ export const ModelCredentialSourceV1 =
11828
12466
  z
11829
12467
  .object({
11830
12468
  kind: z.literal("connected_subscription"),
11831
- provider: z.literal("codex"),
12469
+ provider: z.enum(["codex", "xai"]),
11832
12470
  })
11833
12471
  .strict(),
11834
12472
  z
@@ -12039,7 +12677,7 @@ export const ClientModel = /* @__PURE__ */ defineModelContractSchema(() =>
12039
12677
  provider: z.string(), // provider id
12040
12678
  providerLabel: z.string(),
12041
12679
  api: z.enum(["responses", "chat"]),
12042
- source: z.enum(["opengeni", "codex", "workspace_gateway"]).optional(),
12680
+ source: z.enum(["opengeni", "codex", "supergrok", "workspace_gateway"]).optional(),
12043
12681
  contextWindowTokens: z.number().int().positive().optional(),
12044
12682
  // Additive normalized definition metadata. Optional so older server payloads
12045
12683
  // remain parseable; current servers project the complete V1 set.
@@ -12172,7 +12810,7 @@ export type WorkspaceModelCatalogResponse = z.infer<typeof WorkspaceModelCatalog
12172
12810
  * that rollout boundary. Mutating clients send this value in
12173
12811
  * `x-opengeni-api-contract`; the API rejects any other value before routing.
12174
12812
  */
12175
- export const OPENGENI_API_CONTRACT_REVISION = "2026-08-social-provider-tools-v1" as const;
12813
+ export const OPENGENI_API_CONTRACT_REVISION = "2026-08-model-context-v1" as const;
12176
12814
  export const OPENGENI_API_CONTRACT_HEADER = "x-opengeni-api-contract" as const;
12177
12815
  /** Bounded request/response identifier shared by browser, ingress, and API diagnostics. */
12178
12816
  export const OPENGENI_CORRELATION_HEADER = "x-opengeni-correlation-id" as const;
@@ -12200,6 +12838,15 @@ export const ClientConfig = /* @__PURE__ */ defineModelContractSchema(() =>
12200
12838
  }),
12201
12839
  )
12202
12840
  .default([]),
12841
+ firstPartyMcpTools: z
12842
+ .object({
12843
+ default: z.array(FirstPartyMcpToolName),
12844
+ allowed: z.array(FirstPartyMcpToolName),
12845
+ })
12846
+ .default({
12847
+ default: [...DEFAULT_FIRST_PARTY_MCP_TOOLS],
12848
+ allowed: [...FIRST_PARTY_MCP_TOOL_NAMES],
12849
+ }),
12203
12850
  fileUploads: z.object({
12204
12851
  enabled: z.boolean(),
12205
12852
  maxSizeBytes: z.number().int().positive(),
@@ -12334,9 +12981,13 @@ export function evaluateWorkspaceModelPolicy(
12334
12981
  }
12335
12982
 
12336
12983
  export * from "./codex-fleet-policy";
12984
+ export * from "./xai-provider-account-authority";
12337
12985
  export * from "./workspace-instruction-policies";
12338
12986
  export * from "./company-profile";
12339
12987
  export * from "./workspace-learning-policy";
12340
12988
  export * from "./workspace-state";
12341
12989
  export * from "./preference-registry";
12342
12990
  export * from "./scoped-knowledge";
12991
+ export * from "./knowledge";
12992
+ export * from "./task-notes";
12993
+ export * from "./canonical-human-identities";