@opengeni/core 3.0.1 → 3.1.2

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 (257) hide show
  1. package/README.md +4 -4
  2. package/dist/access/index.d.ts +131 -7
  3. package/dist/access/service-initiator.d.ts +3 -0
  4. package/dist/application/archived-session-imports.d.ts +6 -0
  5. package/dist/application/composer-submit.d.ts +1 -1
  6. package/dist/application/connect-operation.d.ts +6 -0
  7. package/dist/application/external-workspace-members.d.ts +13 -1
  8. package/dist/application/modal-native-live-declaration-join.d.ts +37 -0
  9. package/dist/application/modal-native-original-configuration.d.ts +79 -0
  10. package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
  11. package/dist/application/new-session-drafts.d.ts +29 -2
  12. package/dist/application/organization-privacy.d.ts +57 -0
  13. package/dist/application/prepared-mcp-connection.d.ts +31 -0
  14. package/dist/application/sandbox-recovery.d.ts +58 -0
  15. package/dist/application/session-commands.d.ts +3 -0
  16. package/dist/application/session-tenancy.d.ts +13 -4
  17. package/dist/billing/agent-run-admission.d.ts +21 -0
  18. package/dist/billing/limits.d.ts +27 -1
  19. package/dist/billing/model-call-admission.d.ts +34 -0
  20. package/dist/billing/model-usage-settlement.d.ts +112 -0
  21. package/dist/canonical-human-identities.js +1 -1
  22. package/dist/{chunk-VCZFFEPB.js → chunk-7T2SZ7BI.js} +16 -2
  23. package/dist/chunk-7T2SZ7BI.js.map +1 -0
  24. package/dist/{chunk-ZYCNLYGH.js → chunk-OMJFIIWK.js} +178 -12
  25. package/dist/chunk-OMJFIIWK.js.map +1 -0
  26. package/dist/{chunk-H7X52RI2.js → chunk-QI2M2B2K.js} +83 -8
  27. package/dist/chunk-QI2M2B2K.js.map +1 -0
  28. package/dist/{chunk-OF65T3PM.js → chunk-TTWTXQB2.js} +94 -6
  29. package/dist/chunk-TTWTXQB2.js.map +1 -0
  30. package/dist/codex-model-availability.d.ts +55 -0
  31. package/dist/default-session-model.d.ts +192 -0
  32. package/dist/dependencies.d.ts +41 -7
  33. package/dist/developer-setup-credential-ceiling.d.ts +10 -0
  34. package/dist/domain/agent-config-resolution.d.ts +49 -0
  35. package/dist/domain/automations.d.ts +8 -1
  36. package/dist/domain/capabilities.d.ts +112 -8
  37. package/dist/domain/connection-account-selection-error.d.ts +8 -0
  38. package/dist/domain/connector-tool-permissions.d.ts +62 -0
  39. package/dist/domain/direct-model-provider.d.ts +3 -0
  40. package/dist/domain/editable-artifacts/agent-application.d.ts +10 -1
  41. package/dist/domain/editable-artifacts/durable-export.d.ts +22 -1
  42. package/dist/domain/editable-artifacts/ports.d.ts +10 -0
  43. package/dist/domain/editable-artifacts/service.d.ts +3 -1
  44. package/dist/domain/editable-artifacts/types.d.ts +1 -1
  45. package/dist/domain/encryption-key.d.ts +12 -0
  46. package/dist/domain/insights-timing.d.ts +16 -0
  47. package/dist/domain/insights-usage.d.ts +27 -0
  48. package/dist/domain/insights.d.ts +21 -3
  49. package/dist/domain/knowledge-files.d.ts +1 -1
  50. package/dist/domain/knowledge-preparation.d.ts +10 -0
  51. package/dist/domain/knowledge-preparation.test.d.ts +1 -0
  52. package/dist/domain/knowledge-search.d.ts +15 -76
  53. package/dist/domain/mcp-account-bindings.d.ts +17 -0
  54. package/dist/domain/mcp-account-routes.d.ts +21 -0
  55. package/dist/domain/native-mcp-connection-admission.d.ts +3 -0
  56. package/dist/domain/organization-integration-catalog.d.ts +15 -0
  57. package/dist/domain/personal-connection-delegations.d.ts +73 -12
  58. package/dist/domain/pr-review.d.ts +121 -6
  59. package/dist/domain/realtime-voice-billing.d.ts +103 -0
  60. package/dist/domain/resources.d.ts +17 -1
  61. package/dist/domain/scheduled-task-access.d.ts +265 -0
  62. package/dist/domain/scheduled-task-account-audit.d.ts +27 -0
  63. package/dist/domain/scheduled-task-audience.d.ts +70 -0
  64. package/dist/domain/scheduled-tasks.d.ts +61 -18
  65. package/dist/domain/session-connection-accounts.d.ts +53 -0
  66. package/dist/domain/session-file-access.d.ts +4 -0
  67. package/dist/domain/session-native-connection-replacement.d.ts +14 -0
  68. package/dist/domain/session-start-timing.d.ts +7 -0
  69. package/dist/domain/session-tool-policy.d.ts +102 -4
  70. package/dist/domain/sessions.d.ts +179 -15
  71. package/dist/domain/site-audience.d.ts +52 -0
  72. package/dist/domain/skills.d.ts +29 -1
  73. package/dist/domain/slack-bot.d.ts +46 -1
  74. package/dist/domain/slack-publication-secret-safety.d.ts +1 -1
  75. package/dist/domain/vaults/index.d.ts +7 -0
  76. package/dist/domain/vaults/mapping.d.ts +25 -0
  77. package/dist/domain/vaults/provider-registry.d.ts +72 -0
  78. package/dist/domain/vaults/provider-sync.d.ts +176 -0
  79. package/dist/domain/vaults/provider-writes.d.ts +57 -0
  80. package/dist/domain/vaults/secret-resolver.d.ts +34 -0
  81. package/dist/domain/vaults/types.d.ts +24 -0
  82. package/dist/domain/vaults/vault-service.d.ts +35 -0
  83. package/dist/domain/voice-input-billing.d.ts +77 -0
  84. package/dist/domain/web-search-billing.d.ts +51 -0
  85. package/dist/domain/workspace-credits.d.ts +7 -0
  86. package/dist/editable-artifact-live/application.d.ts +2 -1
  87. package/dist/editable-artifact-live/server.d.ts +5 -1
  88. package/dist/editable-artifact-live/ticket.d.ts +2 -1
  89. package/dist/editable-artifact-live/types.d.ts +9 -0
  90. package/dist/editable-artifact-live.js +2 -2
  91. package/dist/editable-artifacts.js +10 -2
  92. package/dist/goal-admission.d.ts +627 -0
  93. package/dist/host-session-usage-limit.d.ts +15 -0
  94. package/dist/index.d.ts +43 -8
  95. package/dist/index.js +22682 -11743
  96. package/dist/index.js.map +1 -1
  97. package/dist/managed-session.d.ts +110 -7
  98. package/dist/model-call.d.ts +58 -0
  99. package/dist/model-catalog.d.ts +29 -3
  100. package/dist/model-provider-credentials.d.ts +43 -0
  101. package/dist/product-usage-metrics.d.ts +30 -0
  102. package/dist/rigs/index.d.ts +1 -13
  103. package/dist/sandbox/fleet.d.ts +58 -4
  104. package/dist/sandbox/routing.d.ts +42 -2
  105. package/dist/sandbox/runtime-settings.d.ts +27 -17
  106. package/dist/session-authorization.d.ts +10 -0
  107. package/dist/session-usage-limit-metrics.d.ts +60 -0
  108. package/dist/session-usage-limits.d.ts +89 -0
  109. package/dist/site-agent-clamp.d.ts +71 -0
  110. package/dist/site-session-origin.d.ts +39 -2
  111. package/dist/transcription.d.ts +120 -3
  112. package/dist/turn-surface.d.ts +20 -0
  113. package/dist/user-presence.d.ts +32 -0
  114. package/dist/workflow-wake-contract.d.ts +13 -1
  115. package/package.json +15 -22
  116. package/src/access/index.ts +961 -38
  117. package/src/access/service-initiator.ts +50 -0
  118. package/src/application/api-integration-servers.ts +9 -0
  119. package/src/application/archived-session-imports.ts +161 -0
  120. package/src/application/composer-submit.ts +3 -2
  121. package/src/application/connect-authority.ts +3 -3
  122. package/src/application/connect-operation.ts +37 -3
  123. package/src/application/external-continuation.ts +20 -3
  124. package/src/application/external-link-work-admission.ts +3 -0
  125. package/src/application/external-workspace-members.ts +51 -3
  126. package/src/application/modal-native-live-declaration-join.ts +196 -0
  127. package/src/application/modal-native-original-configuration.ts +261 -0
  128. package/src/application/modal-native-worker-host-transport.ts +263 -0
  129. package/src/application/new-session-drafts.ts +172 -55
  130. package/src/application/organization-privacy.ts +161 -0
  131. package/src/application/prepared-mcp-connection.ts +133 -0
  132. package/src/application/sandbox-recovery.ts +78 -0
  133. package/src/application/session-commands.ts +73 -1
  134. package/src/application/session-mcp-credential-rotation.ts +61 -18
  135. package/src/application/session-tenancy.ts +262 -44
  136. package/src/application/user-resource-grants.ts +1 -29
  137. package/src/billing/agent-run-admission.ts +117 -0
  138. package/src/billing/limits.ts +138 -14
  139. package/src/billing/model-call-admission.ts +118 -0
  140. package/src/billing/model-usage-settlement.ts +472 -0
  141. package/src/codex-model-availability.ts +264 -0
  142. package/src/default-session-model.ts +692 -0
  143. package/src/dependencies.ts +48 -6
  144. package/src/developer-setup-credential-ceiling.ts +60 -0
  145. package/src/domain/agent-config-resolution.ts +148 -0
  146. package/src/domain/automations.ts +76 -2
  147. package/src/domain/capabilities.ts +830 -181
  148. package/src/domain/connection-account-selection-error.ts +19 -0
  149. package/src/domain/connector-tool-permissions.ts +572 -0
  150. package/src/domain/direct-model-provider.ts +62 -0
  151. package/src/domain/editable-artifacts/agent-application.ts +44 -6
  152. package/src/domain/editable-artifacts/durable-export.ts +100 -5
  153. package/src/domain/editable-artifacts/in-memory.ts +6 -0
  154. package/src/domain/editable-artifacts/ports.ts +11 -0
  155. package/src/domain/editable-artifacts/service.ts +20 -0
  156. package/src/domain/editable-artifacts/types.ts +1 -1
  157. package/src/domain/encryption-key.ts +26 -0
  158. package/src/domain/file-owner.ts +16 -1
  159. package/src/domain/github-action-policies.ts +1 -1
  160. package/src/domain/github-skill-source.ts +3 -1
  161. package/src/domain/insights-timing.ts +95 -0
  162. package/src/domain/insights-usage.ts +67 -0
  163. package/src/domain/insights.ts +167 -43
  164. package/src/domain/knowledge-files.ts +10 -3
  165. package/src/domain/knowledge-messages.ts +1 -0
  166. package/src/domain/knowledge-preparation.test.ts +276 -0
  167. package/src/domain/knowledge-preparation.ts +147 -0
  168. package/src/domain/knowledge-search.test.ts +617 -5
  169. package/src/domain/knowledge-search.ts +240 -23
  170. package/src/domain/mcp-account-bindings.ts +169 -0
  171. package/src/domain/mcp-account-routes.ts +152 -0
  172. package/src/domain/native-mcp-connection-admission.ts +14 -0
  173. package/src/domain/organization-integration-catalog.ts +88 -0
  174. package/src/domain/personal-connection-delegations.ts +399 -257
  175. package/src/domain/pr-review.ts +24 -8
  176. package/src/domain/realtime-voice-billing.ts +425 -0
  177. package/src/domain/resources.ts +50 -4
  178. package/src/domain/scheduled-task-access.ts +1089 -0
  179. package/src/domain/scheduled-task-account-audit.ts +90 -0
  180. package/src/domain/scheduled-task-audience.ts +249 -0
  181. package/src/domain/scheduled-tasks.ts +1313 -374
  182. package/src/domain/session-connection-accounts.ts +239 -0
  183. package/src/domain/session-file-access.ts +47 -0
  184. package/src/domain/session-native-connection-replacement.ts +64 -0
  185. package/src/domain/session-start-timing.ts +60 -0
  186. package/src/domain/session-tool-policy.ts +489 -14
  187. package/src/domain/sessions.ts +2254 -717
  188. package/src/domain/site-audience.ts +130 -0
  189. package/src/domain/skills.ts +9 -0
  190. package/src/domain/slack-bot.ts +141 -4
  191. package/src/domain/slack-publication-secret-safety.ts +1 -1
  192. package/src/domain/vaults/index.ts +19 -0
  193. package/src/domain/vaults/mapping.ts +190 -0
  194. package/src/domain/vaults/provider-registry.ts +201 -0
  195. package/src/domain/vaults/provider-sync.ts +531 -0
  196. package/src/domain/vaults/provider-writes.ts +288 -0
  197. package/src/domain/vaults/secret-resolver.ts +464 -0
  198. package/src/domain/vaults/types.ts +26 -0
  199. package/src/domain/vaults/vault-service.ts +1316 -0
  200. package/src/domain/voice-input-billing.ts +330 -0
  201. package/src/domain/web-search-billing.ts +169 -0
  202. package/src/domain/workspace-credits.ts +13 -0
  203. package/src/editable-artifact-live/application.ts +8 -1
  204. package/src/editable-artifact-live/server.ts +154 -6
  205. package/src/editable-artifact-live/ticket.ts +86 -1
  206. package/src/editable-artifact-live/types.ts +10 -0
  207. package/src/goal-admission.ts +220 -0
  208. package/src/host-session-usage-limit.ts +25 -0
  209. package/src/index.ts +75 -11
  210. package/src/managed-session.ts +137 -6
  211. package/src/model-call.ts +79 -0
  212. package/src/model-catalog.ts +345 -91
  213. package/src/model-provider-credentials.ts +394 -0
  214. package/src/product-usage-metrics.ts +101 -0
  215. package/src/rigs/index.ts +23 -111
  216. package/src/sandbox/fleet.ts +253 -28
  217. package/src/sandbox/routing.ts +204 -43
  218. package/src/sandbox/runtime-settings.ts +159 -85
  219. package/src/session-authorization.ts +172 -23
  220. package/src/session-usage-limit-metrics.ts +95 -0
  221. package/src/session-usage-limits.ts +415 -0
  222. package/src/site-agent-clamp.ts +226 -0
  223. package/src/site-session-origin.ts +84 -5
  224. package/src/transcription.ts +123 -4
  225. package/src/turn-surface.ts +47 -0
  226. package/src/user-presence.ts +134 -0
  227. package/src/workflow-wake-contract.ts +14 -1
  228. package/dist/application/host-mcp-owner.d.ts +0 -6
  229. package/dist/application/host-mcp-resolvers.d.ts +0 -13
  230. package/dist/chunk-5WZYFL45.js +0 -266
  231. package/dist/chunk-5WZYFL45.js.map +0 -1
  232. package/dist/chunk-H7X52RI2.js.map +0 -1
  233. package/dist/chunk-OF65T3PM.js.map +0 -1
  234. package/dist/chunk-VCZFFEPB.js.map +0 -1
  235. package/dist/chunk-ZYCNLYGH.js.map +0 -1
  236. package/dist/domain/connection-authority.d.ts +0 -97
  237. package/dist/domain/connection-authority.js +0 -169
  238. package/dist/domain/connection-authority.js.map +0 -1
  239. package/dist/domain/environments.d.ts +0 -33
  240. package/dist/domain/host-mcp-authority-source-admission.d.ts +0 -10
  241. package/dist/domain/host-mcp-task-admission.d.ts +0 -18
  242. package/dist/domain/packs.d.ts +0 -59
  243. package/dist/domain/product-integration-pack.d.ts +0 -44
  244. package/dist/domain/product-integration-skill.gen.d.ts +0 -5
  245. package/dist/remote-mcp-credentials.d.ts +0 -23
  246. package/dist/remote-mcp-credentials.js +0 -11
  247. package/dist/remote-mcp-credentials.js.map +0 -1
  248. package/src/application/host-mcp-owner.ts +0 -41
  249. package/src/application/host-mcp-resolvers.ts +0 -84
  250. package/src/domain/connection-authority.ts +0 -329
  251. package/src/domain/environments.ts +0 -120
  252. package/src/domain/host-mcp-authority-source-admission.ts +0 -25
  253. package/src/domain/host-mcp-task-admission.ts +0 -121
  254. package/src/domain/packs.ts +0 -699
  255. package/src/domain/product-integration-pack.ts +0 -42
  256. package/src/domain/product-integration-skill.gen.ts +0 -52
  257. package/src/remote-mcp-credentials.ts +0 -361
@@ -1,6 +1,6 @@
1
- import type { Settings } from "@opengeni/config";
2
- import { type Session, type SessionEffectiveToolPolicy, type SessionToolPolicy, type ToolRef } from "@opengeni/contracts";
3
- import { type Database } from "@opengeni/db";
1
+ import { type Settings } from "@opengeni/config";
2
+ import { FirstPartyMcpToolName, type AgentToolEnvironment, type AgentMediaAttachment, type Session, type SessionTurn, type SessionEffectiveToolPolicy, type SessionToolPolicy, type ToolRef } from "@opengeni/contracts";
3
+ import { requireWorkspace, type Database } from "@opengeni/db";
4
4
  export type ResolvedSessionToolPolicy = {
5
5
  toolRefs: ToolRef[];
6
6
  effectivePolicy: SessionEffectiveToolPolicy;
@@ -23,9 +23,107 @@ export declare function defaultSessionMcpServerIds(servers: Iterable<{
23
23
  * `defaultMcpServerIds` is the current configured omitted-tools default.
24
24
  */
25
25
  export declare function resolveSessionToolPolicy(input: SessionToolPolicyInput): ResolvedSessionToolPolicy;
26
+ /** Null is ordinary work; an empty list is a frozen scheduled selection. */
27
+ export declare function scheduledTurnMcpServerIds(turn: Pick<SessionTurn, "metadata">): string[] | null;
28
+ /** The accepted scheduled built-in selection, including an explicit empty list. */
29
+ export declare function scheduledTurnFirstPartyMcpTools(turn: Pick<SessionTurn, "metadata">): FirstPartyMcpToolName[] | null;
30
+ /**
31
+ * Execution's canonical turn selection. Ordinary turns use the durable session
32
+ * policy, not the queue's omitted-tools `[]`. Scheduled turns instead retain
33
+ * their frozen registry and refs, including an explicitly empty selection.
34
+ */
35
+ export declare function resolveTurnToolPolicy(input: Omit<SessionToolPolicyInput, "sessionTools"> & {
36
+ session: Pick<Session, "tools">;
37
+ turn: Pick<SessionTurn, "tools" | "metadata">;
38
+ }): ResolvedSessionToolPolicy;
39
+ /** Resolve availability and defaults from the same subject-scoped registry read. */
40
+ export declare function workspaceSessionToolPolicyContext(db: Database, workspaceId: string, settings: Settings, subjectId?: string,
41
+ /** An in-flight read of this exact workspace a caller already started. */
42
+ workspaceRead?: ReturnType<typeof requireWorkspace>): Promise<{
43
+ workspaceServerIds: string[];
44
+ workspaceDefaultServerIds: string[];
45
+ }>;
26
46
  /** Current full runtime registry IDs, including configured static servers. */
27
47
  export declare function workspaceSessionToolPolicyServerIds(db: Database, workspaceId: string, settings: Settings, subjectId?: string): Promise<string[]>;
28
48
  /** Current omitted-tools defaults: every configured runtime MCP is on. */
29
49
  export declare function workspaceSessionToolPolicyDefaultServerIds(db: Database, workspaceId: string, settings: Settings, subjectId?: string): Promise<string[]>;
50
+ /**
51
+ * The omitted-tools default for one resolved runtime registry and one
52
+ * workspace settings bag. Pure so a caller that already holds both never has
53
+ * to re-query the capability registry to agree with the worker and the
54
+ * composer on which connectors a `workspace_default` session executes with.
55
+ */
56
+ export declare function workspaceSessionToolPolicyDefaultServerIdsFor(runtimeMcpServers: Iterable<{
57
+ id: string;
58
+ }>, workspaceSettings: unknown): string[];
59
+ /** Metadata only: no MCP listing, provider probes, account selection or credentials. */
60
+ export type SessionEffectiveToolsContext = {
61
+ settings: Settings;
62
+ humanInputEnabled: boolean;
63
+ hasWorkspaceSkills: boolean;
64
+ workspaceSettings?: unknown;
65
+ objectStorageAvailable: boolean;
66
+ activeSandboxBackends?: ReadonlyMap<string, Settings["sandboxBackend"]>;
67
+ /** Exact build options after adapter/credential resolution, keyed by session. No pool-readiness inference. */
68
+ mediaAttachments?: ReadonlyMap<string, AgentMediaAttachment>;
69
+ routerInHistory?: boolean;
70
+ routerHistorySessionIds?: ReadonlySet<string>;
71
+ };
72
+ /**
73
+ * Resolve one context for a response page, not one catalog per session. Legacy
74
+ * rows require no additional reads and never acquire an effectiveTools field.
75
+ */
76
+ export declare function workspaceSessionEffectiveToolsContext(deps: {
77
+ db: Database;
78
+ settings: Settings;
79
+ objectStorage?: unknown;
80
+ }, workspaceId: string, subjectId: string, sessions: readonly Session[],
81
+ /** An in-flight read of this exact workspace a caller already started. */
82
+ workspaceRead?: ReturnType<typeof requireWorkspace>): Promise<SessionEffectiveToolsContext>;
83
+ /** The server can prove attachment policy, not successful future provider calls. */
84
+ export declare function sessionEffectiveToolProjectionInput(session: Session & {
85
+ agent: NonNullable<Session["agent"]>;
86
+ }, toolRefs: readonly ToolRef[], context?: SessionEffectiveToolsContext): {
87
+ config: {
88
+ version: 1;
89
+ from: "all" | "none";
90
+ capabilities: {
91
+ webSearch: boolean;
92
+ humanInput: boolean;
93
+ skills: "manage" | "read" | false;
94
+ goals: boolean;
95
+ subagents: boolean;
96
+ knowledge: boolean;
97
+ schedules: boolean;
98
+ artifacts: boolean;
99
+ browser: boolean;
100
+ secrets: boolean;
101
+ media: boolean;
102
+ workspaceFiles: boolean;
103
+ workspaceConnectors: boolean;
104
+ workspaceAdmin: boolean;
105
+ };
106
+ unavailable: ("artifacts" | "browser" | "goals" | "humanInput" | "knowledge" | "media" | "schedules" | "secrets" | "skills" | "subagents" | "webSearch" | "workspaceAdmin" | "workspaceConnectors" | "workspaceFiles")[];
107
+ unavailableReasons?: Partial<Record<"artifacts" | "browser" | "goals" | "humanInput" | "knowledge" | "media" | "schedules" | "secrets" | "skills" | "subagents" | "webSearch" | "workspaceAdmin" | "workspaceConnectors" | "workspaceFiles", string>> | undefined;
108
+ identity: string | null;
109
+ renderer: "markdown" | "opengeni";
110
+ source: "deployment_default" | "inherited" | "legacy_conversion" | "request" | "workspace_default";
111
+ };
112
+ firstPartyMcpTools: ("admin_action_call" | "admin_action_describe" | "admin_actions_search" | "artifacts_archive" | "artifacts_create" | "artifacts_get_source" | "artifacts_list" | "artifacts_prepare_upload" | "artifacts_publish" | "artifacts_restore" | "artifacts_rollback" | "atlassian_get" | "atlassian_search" | "atlassian_sources_list" | "browser_act" | "browser_auth" | "browser_clipboard" | "browser_debug" | "browser_download_save" | "browser_downloads" | "browser_identity" | "browser_lifecycle" | "browser_observe" | "browser_open" | "browser_publish" | "browser_read" | "browser_screenshot" | "browser_tabs" | "capability_authorization_request" | "capability_catalog_search" | "command_read" | "command_wait" | "company_profile_confirm" | "company_profile_propose" | "computer_act" | "computer_clipboard" | "computer_lifecycle" | "computer_observe" | "computer_open" | "computer_targets" | "connected_machine_enable_screen_control" | "connected_machine_enroll_token" | "connected_machine_remove" | "custom_mcp_setup_request" | "editable_artifact_apply" | "editable_artifact_create" | "editable_artifact_export" | "editable_artifact_export_status" | "editable_artifact_get" | "editable_artifact_import" | "editable_artifact_inspect" | "editable_artifact_list" | "environment_list" | "environment_set_variable" | "fiken_bank_accounts_list" | "fiken_companies_list" | "fiken_contact_create" | "fiken_contacts_list" | "fiken_invoice_draft_create" | "fiken_invoice_get" | "fiken_invoices_list" | "fiken_products_list" | "fiken_purchases_list" | "fiken_sales_list" | "github_connect_link" | "github_repositories_list" | "goal_complete" | "goal_pause" | "goal_progress" | "goal_resume" | "goal_set" | "goal_update" | "inbox_tidy" | "instruction_policy_get" | "instruction_policy_propose" | "instruction_policy_save" | "interaction_discover" | "interaction_request_human" | "knowledge_archive" | "knowledge_browse" | "knowledge_correct" | "knowledge_get" | "knowledge_prepare_save" | "knowledge_propose" | "knowledge_retain_file" | "knowledge_retain_message" | "knowledge_save" | "knowledge_search" | "memory_correct" | "memory_save" | "memory_search" | "notification_withdraw" | "notify_user" | "preference_propose" | "preference_registry_get" | "preference_registry_summary" | "project_create" | "project_delete" | "project_get" | "project_list" | "project_reorder" | "project_update" | "reddit_accounts_list" | "reddit_mentions_live" | "reddit_post_reply" | "reddit_posts_sync" | "reddit_search_live" | "reddit_thread_fetch" | "remember" | "remember_confirm" | "rig_get" | "rig_list" | "rig_promote" | "rig_propose_change" | "rig_verify" | "run_on" | "sandbox_attach" | "sandbox_file_publish" | "sandbox_provision" | "sandbox_swap" | "sandboxes_list" | "scheduled_task_runs_list" | "scheduled_tasks_create" | "scheduled_tasks_delete" | "scheduled_tasks_get" | "scheduled_tasks_list" | "scheduled_tasks_pause" | "scheduled_tasks_resume" | "scheduled_tasks_trigger" | "scheduled_tasks_update" | "secret_delete" | "secret_get" | "secret_move" | "secret_save" | "secret_search" | "session_create" | "session_events" | "session_get" | "session_human_input_respond" | "session_message_status" | "session_pause" | "session_resume" | "session_send_message" | "session_set_model" | "session_set_project" | "session_steer" | "session_target_get" | "session_target_set" | "session_wait" | "sessions_list" | "set_other_session_title" | "set_session_title" | "site_data_define_collection" | "site_data_describe" | "site_data_export" | "site_data_import" | "site_data_query" | "site_data_reset" | "site_data_write" | "site_files_delete" | "site_files_list" | "site_files_upload" | "site_hostname_check" | "site_publication_apply_fix" | "site_publication_get" | "site_publication_update" | "site_sql_define_query" | "site_sql_enable" | "site_sql_execute" | "site_sql_export" | "site_sql_import" | "site_sql_inspect" | "site_sql_migrate" | "site_sql_query" | "site_sql_reset" | "site_sql_run" | "slack_bot_channel_history" | "slack_bot_delete_message" | "slack_bot_file_content" | "slack_bot_file_info" | "slack_bot_list_channels" | "slack_bot_list_files" | "slack_bot_list_users" | "slack_bot_post_message" | "slack_bot_prepare_message" | "slack_bot_search" | "slack_bot_send_prepared_message" | "slack_bot_thread_replies" | "slack_bot_upload_file" | "social_connections_list" | "social_daily_analysis_context" | "social_mentions_live" | "social_post_reply" | "social_posts_recent" | "social_posts_sync" | "social_search_live" | "social_thread_fetch" | "task_note_archive" | "task_note_promote_instruction_policy" | "task_note_promote_knowledge" | "task_note_promote_preference" | "task_note_replace" | "task_note_save" | "task_notes_list" | "variable_set_get_variable" | "variable_set_list" | "variable_set_set_variable" | "wait_for_input" | "work_claim_release" | "work_claim_upsert" | "x_accounts_list" | "x_mentions_live" | "x_post_reply" | "x_posts_sync" | "x_search_live" | "x_thread_fetch")[];
113
+ firstPartyModelNames: Map<"admin_action_call" | "admin_action_describe" | "admin_actions_search" | "artifacts_archive" | "artifacts_create" | "artifacts_get_source" | "artifacts_list" | "artifacts_prepare_upload" | "artifacts_publish" | "artifacts_restore" | "artifacts_rollback" | "atlassian_get" | "atlassian_search" | "atlassian_sources_list" | "browser_act" | "browser_auth" | "browser_clipboard" | "browser_debug" | "browser_download_save" | "browser_downloads" | "browser_identity" | "browser_lifecycle" | "browser_observe" | "browser_open" | "browser_publish" | "browser_read" | "browser_screenshot" | "browser_tabs" | "capability_authorization_request" | "capability_catalog_search" | "command_read" | "command_wait" | "company_profile_confirm" | "company_profile_propose" | "computer_act" | "computer_clipboard" | "computer_lifecycle" | "computer_observe" | "computer_open" | "computer_targets" | "connected_machine_enable_screen_control" | "connected_machine_enroll_token" | "connected_machine_remove" | "custom_mcp_setup_request" | "editable_artifact_apply" | "editable_artifact_create" | "editable_artifact_export" | "editable_artifact_export_status" | "editable_artifact_get" | "editable_artifact_import" | "editable_artifact_inspect" | "editable_artifact_list" | "environment_list" | "environment_set_variable" | "fiken_bank_accounts_list" | "fiken_companies_list" | "fiken_contact_create" | "fiken_contacts_list" | "fiken_invoice_draft_create" | "fiken_invoice_get" | "fiken_invoices_list" | "fiken_products_list" | "fiken_purchases_list" | "fiken_sales_list" | "github_connect_link" | "github_repositories_list" | "goal_complete" | "goal_pause" | "goal_progress" | "goal_resume" | "goal_set" | "goal_update" | "inbox_tidy" | "instruction_policy_get" | "instruction_policy_propose" | "instruction_policy_save" | "interaction_discover" | "interaction_request_human" | "knowledge_archive" | "knowledge_browse" | "knowledge_correct" | "knowledge_get" | "knowledge_prepare_save" | "knowledge_propose" | "knowledge_retain_file" | "knowledge_retain_message" | "knowledge_save" | "knowledge_search" | "memory_correct" | "memory_save" | "memory_search" | "notification_withdraw" | "notify_user" | "preference_propose" | "preference_registry_get" | "preference_registry_summary" | "project_create" | "project_delete" | "project_get" | "project_list" | "project_reorder" | "project_update" | "reddit_accounts_list" | "reddit_mentions_live" | "reddit_post_reply" | "reddit_posts_sync" | "reddit_search_live" | "reddit_thread_fetch" | "remember" | "remember_confirm" | "rig_get" | "rig_list" | "rig_promote" | "rig_propose_change" | "rig_verify" | "run_on" | "sandbox_attach" | "sandbox_file_publish" | "sandbox_provision" | "sandbox_swap" | "sandboxes_list" | "scheduled_task_runs_list" | "scheduled_tasks_create" | "scheduled_tasks_delete" | "scheduled_tasks_get" | "scheduled_tasks_list" | "scheduled_tasks_pause" | "scheduled_tasks_resume" | "scheduled_tasks_trigger" | "scheduled_tasks_update" | "secret_delete" | "secret_get" | "secret_move" | "secret_save" | "secret_search" | "session_create" | "session_events" | "session_get" | "session_human_input_respond" | "session_message_status" | "session_pause" | "session_resume" | "session_send_message" | "session_set_model" | "session_set_project" | "session_steer" | "session_target_get" | "session_target_set" | "session_wait" | "sessions_list" | "set_other_session_title" | "set_session_title" | "site_data_define_collection" | "site_data_describe" | "site_data_export" | "site_data_import" | "site_data_query" | "site_data_reset" | "site_data_write" | "site_files_delete" | "site_files_list" | "site_files_upload" | "site_hostname_check" | "site_publication_apply_fix" | "site_publication_get" | "site_publication_update" | "site_sql_define_query" | "site_sql_enable" | "site_sql_execute" | "site_sql_export" | "site_sql_import" | "site_sql_inspect" | "site_sql_migrate" | "site_sql_query" | "site_sql_reset" | "site_sql_run" | "slack_bot_channel_history" | "slack_bot_delete_message" | "slack_bot_file_content" | "slack_bot_file_info" | "slack_bot_list_channels" | "slack_bot_list_files" | "slack_bot_list_users" | "slack_bot_post_message" | "slack_bot_prepare_message" | "slack_bot_search" | "slack_bot_send_prepared_message" | "slack_bot_thread_replies" | "slack_bot_upload_file" | "social_connections_list" | "social_daily_analysis_context" | "social_mentions_live" | "social_post_reply" | "social_posts_recent" | "social_posts_sync" | "social_search_live" | "social_thread_fetch" | "task_note_archive" | "task_note_promote_instruction_policy" | "task_note_promote_knowledge" | "task_note_promote_preference" | "task_note_replace" | "task_note_save" | "task_notes_list" | "variable_set_get_variable" | "variable_set_list" | "variable_set_set_variable" | "wait_for_input" | "work_claim_release" | "work_claim_upsert" | "x_accounts_list" | "x_mentions_live" | "x_post_reply" | "x_posts_sync" | "x_search_live" | "x_thread_fetch", string>;
114
+ nativeComputerTools: boolean;
115
+ mcpServerIds: string[];
116
+ productServerIds: ReadonlySet<string>;
117
+ environment: AgentToolEnvironment;
118
+ runtimeToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
119
+ hostedToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
120
+ sandboxToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
121
+ routerToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
122
+ upfrontToolNames: Set<string>;
123
+ mediaAttachment: AgentMediaAttachment | {
124
+ readonly image: null;
125
+ readonly video: false;
126
+ } | undefined;
127
+ };
30
128
  /** Add a bounded, secret-safe effective projection to a session response. */
31
- export declare function sessionWithEffectiveToolPolicy(session: Session, workspaceServerIds: Iterable<string>, workspaceDefaultServerIds?: Iterable<string>): Session;
129
+ export declare function sessionWithEffectiveToolPolicy(session: Session, workspaceServerIds: Iterable<string>, workspaceDefaultServerIds?: Iterable<string>, effectiveToolsContext?: SessionEffectiveToolsContext): Session;
@@ -1,8 +1,13 @@
1
- import { type HostMcpCreateSelection } from "@opengeni/contracts/host-mcp-bindings";
1
+ import type { SessionRetryRequest, SessionRetryResponse, SessionTurnSurface } from "@opengeni/contracts";
2
+ import { type ProductUsageMetricsSink } from "../product-usage-metrics.js";
3
+ import { type SessionStartObservability } from "./session-start-timing.js";
2
4
  import { type Settings } from "@opengeni/config";
3
- import { SessionSpawnDenial, type AccessGrant, type ComposerDraft, type CreateSessionResponse, type GoalSpec, type FirstPartyMcpToolName, type McpPersonalConnectionDelegation, type McpConnectionAuthoritySelection, type Permission, type PersonalResourceAttachmentIntent, type ReasoningEffort, type ResourceRef, type Session, type SessionAgentAccess, type SessionCommandReceipt, type SessionScopeSubjectId, type SessionMemoryScope, type SessionSkill, type SessionEvent, SessionMcpApprovalPolicy, type SessionMcpCredentialUpdateInput, type SessionMcpServerMetadata, type SubmittedTimelineAnnotation, type TimelineAnnotation, type UpdateSessionMcpApprovalPolicyResponse, type UpdateSessionToolPolicyRequest, type SessionAuthorizationPort, type SessionToolPolicy, type SessionTurn, type SessionPromptRouting, type SessionGoalSnapshot, type ToolRef, type TurnInitiator, type TurnInitiatorContext, type TurnExecutionPolicyV1, type VariableSet, type XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
4
- import { type CreateSessionMcpServerInput, type Database, type UpdateSessionMcpServerCredentialsInput, type SessionCommandActor, type NewSessionDraftSnapshot } from "@opengeni/db";
5
+ import type { CodeSearchDeploymentPolicy } from "@opengeni/contracts/code-search";
6
+ import { type AgentConfigCreator, type ResolvedAgentConfig, type UpdateSessionAgentRequest, type VaultPolicy } from "@opengeni/contracts";
7
+ import { SessionSpawnDenial, type AccessGrant, type ComposerDraft, type CreateSessionResponse, type GoalSpec, type FirstPartyMcpToolName, type McpPersonalConnectionDelegation, type McpConnectionAccountBinding, type ConnectionAccountIntent, type McpConnectionAccountSelection, type Permission, type PersonalResourceAttachmentIntent, type ReasoningEffort, type ResourceRef, type Session, type SessionAgentAccess, type SessionCommandReceipt, type SessionScopeSubjectId, type SessionMemoryScope, type SessionSkill, type SessionEvent, SessionMcpApprovalPolicy, SetSessionModelRequest, type SessionMcpCredentialUpdateInput, type SessionMcpServerMetadata, type SubmittedTimelineAnnotation, type TimelineAnnotation, type UpdateSessionMcpApprovalPolicyResponse, type UpdateSessionToolPolicyRequest, type UpdateSessionSkillsRequest, type SessionAuthorizationPort, type SessionAuthorizationSurface, type SessionToolPolicy, type SessionTurn, type SessionPromptRouting, type SessionGoalSnapshot, type ToolRef, type TurnInitiator, type TurnInitiatorContext, type TurnExecutionPolicyV1, type VariableSet, type XaiProviderAccountAuthoritySnapshotV1, type ClaudeProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
8
+ import { type SetSessionKeepLiveResult, type CreateSessionMcpServerInput, type Database, type FrozenTurnInitiator, type UpdateSessionMcpServerCredentialsInput, type SessionCommandActor, type NewSessionDraftSnapshot } from "@opengeni/db";
5
9
  import { type EventBus } from "@opengeni/events";
10
+ import { HTTPException } from "hono/http-exception";
6
11
  import { type AccessGrantAuthorization } from "../access/index.js";
7
12
  import type { AcceptSessionUserMessageDependencies, ApiRouteDeps, SessionWorkflowClient } from "../dependencies.js";
8
13
  /** Transport-neutral typed denial raised only after its audit row committed. */
@@ -34,6 +39,15 @@ export declare function resolveFirstPartyMcpToolsForCreate(requested: FirstParty
34
39
  default: readonly FirstPartyMcpToolName[];
35
40
  allowed: readonly FirstPartyMcpToolName[];
36
41
  }): FirstPartyMcpToolName[];
42
+ /**
43
+ * An explicit first-party tool selection is a promise, not a best-effort
44
+ * default: a tool the deployment disables fails the request, naming every such
45
+ * tool and the allowed set, instead of silently shrinking the selection.
46
+ * `retained` names tools the caller may echo from its stored selection; those
47
+ * stay deployment-filtered like any default, so a later policy change never
48
+ * blocks an unrelated edit.
49
+ */
50
+ export declare function requireDeploymentFirstPartyMcpTools(requested: readonly FirstPartyMcpToolName[], allowed: readonly FirstPartyMcpToolName[], retained?: Iterable<FirstPartyMcpToolName>, hint?: string): void;
37
51
  export declare function sessionSpawnDenialEnvelope(error: SessionSpawnDeniedError): {
38
52
  readonly error: {
39
53
  readonly code: "nested_agent_depth_exceeded" | "nested_agent_depth_override_forbidden";
@@ -66,9 +80,17 @@ export type FrozenCreationInitiator = {
66
80
  type: "agent_attempt";
67
81
  }>;
68
82
  };
83
+ /** Attribution is immutable accepted-work data, never the current request principal. */
84
+ export declare function initiatingHumanForAllowance(frozen: Pick<FrozenTurnInitiator, "initiator" | "initiatingHumanSubjectId">): string | null;
69
85
  export declare function creationInitiatorForGrant(grant: AccessGrant): FrozenCreationInitiator;
70
86
  export declare function normalizedSessionMcpCredentialHeaders(headers: Record<string, string> | undefined): Record<string, string>;
71
87
  export declare function settingsWithSessionMcpServerMetadata(settings: Settings, servers: SessionMcpServerMetadata[]): Settings;
88
+ export declare function validateSessionMcpCredentialUpdates(input: {
89
+ settings: Settings;
90
+ grant: AccessGrant;
91
+ session: Session;
92
+ updates: SessionMcpCredentialUpdateInput[];
93
+ }): UpdateSessionMcpServerCredentialsInput[];
72
94
  export type CreateSessionOutcome = {
73
95
  session: CreateSessionResponse;
74
96
  /** The committed create/start effect represented by this request. */
@@ -87,6 +109,26 @@ type AgentChildSessionCreatePresentation = {
87
109
  * This is deliberately separate from the public REST request contract. */
88
110
  automaticTitleCandidate?: string | null;
89
111
  };
112
+ /** Trusted entry-point options for creating a session outside the REST body. */
113
+ export type SessionCreateRequestOptions = {
114
+ /**
115
+ * Product surface when the entry point knows it (for example Slack or an
116
+ * in-process embedding host). Omitted derives it from the grant.
117
+ */
118
+ surface?: SessionTurnSurface;
119
+ /**
120
+ * Agent-configuration creator kind (renderer default and default-config
121
+ * policy). Omitted derives `slack` from a Slack surface, else the public API.
122
+ */
123
+ agentConfigCreator?: AgentConfigCreator;
124
+ /**
125
+ * Built-in tools to guarantee on top of the defaults a new session follows,
126
+ * for an entry point whose sessions need their own tools (a chat surface's
127
+ * read tools). Ignored when the request names an explicit built-in list.
128
+ * Trusted entry points only; not part of the public create request.
129
+ */
130
+ firstPartyMcpToolAdditions?: readonly FirstPartyMcpToolName[];
131
+ };
90
132
  /** @internal Exported for the keyed-create repair regression. */
91
133
  export declare function freezeAgentChildAutomaticTitleInCreatorContext(context: TurnInitiatorContext | undefined, title: string | null | undefined): TurnInitiatorContext | undefined;
92
134
  /** @internal Keyed repair must use the committed winner, not the retry payload. */
@@ -106,7 +148,6 @@ export declare function createAndStartSessionWithOutcome(input: {
106
148
  captureInitialTurnAuthority?: (tx: Database, sessionId: string, turnId: string) => Promise<void>;
107
149
  /** Internal replay identity; the verified caller must also capture authority.
108
150
  * Supplying selection metadata alone never grants runtime use. */
109
- selectedHostMcpDelegations?: HostMcpCreateSelection[];
110
151
  /** The custom workspace model was frozen by an earlier accepted boundary or
111
152
  * inherited from an existing session, so retirement must not invalidate it. */
112
153
  retainWorkspaceGatewayModel?: boolean;
@@ -121,6 +162,15 @@ export declare function createAndStartSessionWithOutcome(input: {
121
162
  workspaceId: string;
122
163
  visibility?: "user_private" | "workspace_shared";
123
164
  initialMessage: string;
165
+ /** Content-free product surface the create request entered through. */
166
+ surface?: SessionTurnSurface | null;
167
+ /**
168
+ * Live product usage counters: a newly created session (never a replay)
169
+ * counts once, and its initial user message once unless deferred.
170
+ */
171
+ metrics?: ProductUsageMetricsSink | null;
172
+ /** Optional content-free child spans; never a lifecycle dependency. */
173
+ startupObservability?: SessionStartObservability | null;
124
174
  /** Create the session shell without an initial user event/agent turn. */
125
175
  deferInitialTurn?: boolean;
126
176
  modelContext?: string | null;
@@ -158,15 +208,23 @@ export declare function createAndStartSessionWithOutcome(input: {
158
208
  policyRole?: string | null;
159
209
  firstPartyMcpPermissions?: Permission[] | null;
160
210
  firstPartyMcpTools: FirstPartyMcpToolName[];
211
+ agentConfig?: ResolvedAgentConfig | null;
212
+ vaultPolicy?: VaultPolicy;
161
213
  agentAccess?: SessionAgentAccess;
162
214
  scopeSubjectId?: SessionScopeSubjectId | null;
163
215
  memoryScope?: SessionMemoryScope;
164
216
  mcpServers?: CreateSessionMcpServerInput[];
217
+ mcpApprovalPolicies?: Record<string, SessionMcpApprovalPolicy>;
165
218
  sessionMcpServers?: SessionMcpServerMetadata[];
166
219
  personalConnectionDelegations?: McpPersonalConnectionDelegation[];
220
+ mcpAccountBindings?: McpConnectionAccountBinding[] | null;
221
+ /** The creator's account intent, carried by work that continues the first turn. */
222
+ connectionAccountIntent?: ConnectionAccountIntent | null;
167
223
  initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
168
224
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
225
+ claudeProviderAccountAuthoritySnapshot?: ClaudeProviderAccountAuthoritySnapshotV1;
169
226
  parentSessionId?: string | null;
227
+ codeSearchDeploymentPolicy?: CodeSearchDeploymentPolicy;
170
228
  createIdempotencyKey?: string | null;
171
229
  selectedInstalledSkillIds?: string[];
172
230
  sandboxGroupId?: string | null;
@@ -202,6 +260,13 @@ export declare function createAndStartSessionWithOutcome(input: {
202
260
  /** Backward-compatible entity-returning create path used by existing callers. */
203
261
  export declare function createAndStartSession(input: Parameters<typeof createAndStartSessionWithOutcome>[0]): Promise<CreateSessionResponse>;
204
262
  export declare function workflowIdForSession(sessionId: string): string;
263
+ /**
264
+ * The one 422 for a model that is not selectable in the live catalog (retired,
265
+ * removed, or never offered). The message keeps its historical text; the typed
266
+ * cause lets the API envelope add `details.code: "model_unavailable"` so
267
+ * clients can ask for another model instead of offering a futile retry.
268
+ */
269
+ export declare function modelUnavailableHttpException(model: string): HTTPException;
205
270
  /**
206
271
  * Reject an explicit model that the host does not expose. The set of usable
207
272
  * models is the union surfaced by `configuredAllowedModels` (the built-in
@@ -210,8 +275,9 @@ export declare function workflowIdForSession(sessionId: string): string;
210
275
  * the API edge with 422 rather than enqueuing a turn the worker can't honor.
211
276
  *
212
277
  * `model` is the effective value selected by the caller's boundary. Top-level
213
- * omission defaults to `settings.openaiModel`; child-session omission inherits
214
- * the worker-signed calling turn before reaching this helper. Centralized here
278
+ * omission resolves the new-chat default (`resolveDefaultSessionModel`);
279
+ * child-session omission inherits the worker-signed calling turn before
280
+ * reaching this helper. Centralized here
215
281
  * so every model-carrying choke point
216
282
  * (create-session, user-message/turn-accept, queued-turn update, and
217
283
  * scheduled-task agentConfig — a scheduled task is a session the worker runs
@@ -238,10 +304,10 @@ export declare function assertSessionAllowsProductModel(session: Pick<Session, "
238
304
  * worker's authoritative post-resolution gate would fail. `model` is the
239
305
  * EFFECTIVE value the caller is about to persist: pass the explicit value at
240
306
  * message/turn-update/scheduled-task edges (omitted inherits an
241
- * already-validated stored default), but at session CREATION pass
242
- * `payload.model ?? settings.openaiModel` — an omitted model stamps the
243
- * deployment default onto the session, and under a restricted policy that
244
- * default may be exactly the provider the policy exists to block.
307
+ * already-validated stored default), but at session CREATION pass the
308
+ * effective model: an omitted model stamps the resolved default onto the
309
+ * session, and under a restricted policy that default may be exactly the
310
+ * provider the policy exists to block.
245
311
  */
246
312
  export declare function assertWorkspaceModelPolicyAllows(db: Database, settings: Settings, workspaceId: string, model: string | null | undefined): Promise<void>;
247
313
  export declare function requireQueuedTurnForApi(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<SessionTurn>;
@@ -281,11 +347,15 @@ type PostUserMessageTurnInput = {
281
347
  clientEventId?: string;
282
348
  mcpCredentialUpdates?: UpdateSessionMcpServerCredentialsInput[];
283
349
  personalConnectionDelegations?: McpPersonalConnectionDelegation[];
284
- selectedHostMcpDelegations?: HostMcpCreateSelection[];
350
+ mcpAccountBindings?: McpConnectionAccountBinding[] | null;
351
+ /** The sender's account intent, carried by work that continues this turn. */
352
+ connectionAccountIntent?: ConnectionAccountIntent | null;
285
353
  captureTurnAuthority?: (tx: Database, turnId: string) => Promise<void>;
286
354
  personalResourceAttachment?: PersonalResourceAttachmentIntent;
287
355
  delivery?: "send" | "steer";
288
356
  origin?: "human" | "operator";
357
+ /** Content-free product surface the request entered through. */
358
+ surface?: SessionTurnSurface | null;
289
359
  actor?: string;
290
360
  actorLabel?: string;
291
361
  commandActor?: SessionCommandActor;
@@ -340,11 +410,13 @@ export declare function resolveSessionCreateScope(input: {
340
410
  };
341
411
  parent: SessionCreateScope | null;
342
412
  }): SessionCreateScope;
343
- declare function createSessionForRequestInFileScope(unresolvedDeps: ApiRouteDeps, grant: AccessGrant, workspaceId: string, rawPayload: unknown, authorization?: AccessGrantAuthorization, agentChildPresentation?: AgentChildSessionCreatePresentation): Promise<CreateSessionRequestOutcome>;
413
+ /** Explicit recovery, never a new prompt or a Pause/Resume command. */
414
+ export declare function retryFailedSession(deps: ApiRouteDeps, grant: AccessGrant, workspaceId: string, sessionId: string, request: SessionRetryRequest): Promise<SessionRetryResponse>;
415
+ declare function createSessionForRequestInFileScope(unresolvedDeps: ApiRouteDeps, grant: AccessGrant, workspaceId: string, rawPayload: unknown, authorization?: AccessGrantAuthorization, agentChildPresentation?: AgentChildSessionCreatePresentation, requestOptions?: SessionCreateRequestOptions): Promise<CreateSessionRequestOutcome>;
344
416
  /** @internal Fixed public projection; the committed session outcome remains authoritative. */
345
417
  export declare function reportSessionUsageRecordingFailure(_error: unknown): void;
346
418
  /** Backward-compatible entity-returning request path for REST and core callers. */
347
- export declare function createSessionForRequest(deps: ApiRouteDeps, grant: AccessGrant, workspaceId: string, rawPayload: unknown, authorization?: AccessGrantAuthorization): Promise<CreateSessionResponse>;
419
+ export declare function createSessionForRequest(deps: ApiRouteDeps, grant: AccessGrant, workspaceId: string, rawPayload: unknown, authorization?: AccessGrantAuthorization, requestOptions?: SessionCreateRequestOptions): Promise<CreateSessionResponse>;
348
420
  /**
349
421
  * Full accept-user-message flow shared by the `user.message` branch of
350
422
  * `POST /sessions/:id/events` and the first-party MCP `session_send_message`
@@ -364,10 +436,14 @@ declare function acceptSessionUserMessageInFileScope(deps: AcceptSessionUserMess
364
436
  latencyMode?: "standard" | "priority" | "fast" | null;
365
437
  clientEventId?: string;
366
438
  mcpCredentialUpdates?: SessionMcpCredentialUpdateInput[];
367
- connectionAuthorities?: McpConnectionAuthoritySelection[];
368
- selectedHostMcpDelegations?: HostMcpCreateSelection[];
439
+ connectionAccounts?: McpConnectionAccountSelection[];
369
440
  delivery?: "send" | "steer";
370
441
  origin?: "human" | "operator";
442
+ /**
443
+ * Product surface when the entry point knows it (for example Slack or an
444
+ * in-process embedding host). Omitted derives it from the grant.
445
+ */
446
+ surface?: SessionTurnSurface;
371
447
  controlEtag?: string | null;
372
448
  expectedDraftRevision?: number | null;
373
449
  personalResourceAttachment?: PersonalResourceAttachmentIntent;
@@ -408,6 +484,29 @@ export declare function updateSessionTitle(deps: {
408
484
  title: string | null;
409
485
  relatedSessionAccess: "target" | "root";
410
486
  }>;
487
+ /**
488
+ * Set or clear the session's keep-live exemption from the idle-session archive.
489
+ * Archived sessions are read-only and reject the change.
490
+ */
491
+ export declare function setSessionRetention(deps: {
492
+ db: Database;
493
+ sessionAuthorization?: SessionAuthorizationPort | null;
494
+ }, grant: AccessGrant, sessionId: string, keepLive: boolean): Promise<{
495
+ result: SetSessionKeepLiveResult;
496
+ relatedSessionAccess: "target" | "root";
497
+ }>;
498
+ /** Change future defaults without accepting a prompt or touching accepted work. */
499
+ export declare function setSessionModel(deps: Pick<ApiRouteDeps, "db" | "bus" | "settings" | "catalogSourceSettings" | "sessionAuthorization">, grant: AccessGrant, sessionId: string, request: SetSessionModelRequest, surface?: SessionAuthorizationSurface): Promise<{
500
+ model: string;
501
+ reasoningEffort: "high" | "low" | "max" | "medium" | "minimal" | "none" | "xhigh";
502
+ latencyMode: "fast" | "priority" | "standard";
503
+ eventId: string;
504
+ receiptId: string;
505
+ timestamp: string;
506
+ replay: boolean;
507
+ sessionId: string;
508
+ effectiveFrom: "future_turns";
509
+ }>;
411
510
  /**
412
511
  * Update one existing session MCP server's approval policy. The database
413
512
  * serializes this write with attempt claim under the session lock: an already
@@ -431,7 +530,72 @@ export declare function updateSessionToolPolicy(deps: {
431
530
  settings: Settings;
432
531
  sessionAuthorization?: SessionAuthorizationPort | null;
433
532
  }, grant: AccessGrant, sessionId: string, request: UpdateSessionToolPolicyRequest): Promise<Session>;
533
+ /**
534
+ * Replace a running session's agent configuration (`PUT .../agent`). Omitted
535
+ * request fields keep their current values; a legacy (null) session converts
536
+ * from its current effective state without widening. The configuration and
537
+ * its write-through to the legacy tool columns (and the instructions alias)
538
+ * commit under the same tool-policy version CAS, so tool-policy and agent
539
+ * updates cannot race. Effective from the next attempt. Agent callers may only
540
+ * narrow; a child never widens past its parent.
541
+ */
542
+ export declare function updateSessionAgent(deps: {
543
+ db: Database;
544
+ bus: EventBus;
545
+ settings: Settings;
546
+ sessionAuthorization?: SessionAuthorizationPort | null;
547
+ }, grant: AccessGrant, sessionId: string, request: UpdateSessionAgentRequest): Promise<Session>;
548
+ /**
549
+ * Replace the Skills a session carries itself. The worker reads them at the
550
+ * start of every attempt, so the change applies from the next attempt; work
551
+ * already running keeps the Skill index it started with. Shares the
552
+ * tool-policy version (409 when stale) with the other agent-configuration
553
+ * writes. An agent may only remove Skills, never add or change one.
554
+ */
555
+ export declare function updateSessionSkills(deps: {
556
+ db: Database;
557
+ bus: EventBus;
558
+ sessionAuthorization?: SessionAuthorizationPort | null;
559
+ }, grant: AccessGrant, sessionId: string, request: UpdateSessionSkillsRequest): Promise<Session>;
434
560
  export declare function readSessionLineage(deps: Pick<ApiRouteDeps, "db" | "sessionAuthorization">, grant: AccessGrant, sessionId: string): Promise<import("@opengeni/db").SessionLineage>;
561
+ /**
562
+ * A server attached in the same root create request is selected by that
563
+ * attachment. Neither `tools` (an allow-list over the workspace/deployment
564
+ * registry) nor the workspace-default expansion can name it, so without this
565
+ * the attached endpoint was stored but never contacted and the model saw no
566
+ * tools. This grants nothing beyond the attach itself: the caller already
567
+ * passed `mcp_servers:attach` for exactly this endpoint, and the server's own
568
+ * approval policy still governs every call. An explicit ref for the same id
569
+ * wins unchanged so a caller can still mark it `eager` or `optional`; the
570
+ * added ref is strict, exactly like listing `{ kind: "mcp", id }` explicitly.
571
+ * Child creates never reach here: an inherited snapshot keeps the parent's
572
+ * selection and a child may only narrow it.
573
+ */
574
+ export declare function withSameRequestSessionMcpServerTools(tools: ToolRef[], attachedServers: ReadonlyArray<{
575
+ id: string;
576
+ }>): ToolRef[];
577
+ /**
578
+ * The executable MCP tool list a follow-up on an existing session freezes
579
+ * connector accounts against.
580
+ *
581
+ * A `workspace_default` session stores only the tool snapshot taken when it
582
+ * was created and expands the current workspace defaults at run time, so a
583
+ * connector enabled after creation never enters the stored column. The
584
+ * composer projects that same expansion and submits account selections for
585
+ * it, so freezing against the stored column rejected every such selection as
586
+ * unmatched and never froze its personal delegation. Resolve through the one
587
+ * ID-only policy resolver the API projection and the worker use, with the
588
+ * same omitted-tools default, so all three agree on the executable set.
589
+ */
590
+ export declare function sessionToolsForConnectionAccounts(input: {
591
+ session: Pick<Session, "tools" | "toolPolicy">;
592
+ /** The resolved runtime registry, including session-local servers. */
593
+ runtimeMcpServers: Iterable<{
594
+ id: string;
595
+ }>;
596
+ /** The current omitted-tools default for this workspace. */
597
+ defaultMcpServerIds: Iterable<string>;
598
+ }): ToolRef[];
435
599
  /** Keep original-file ownership scoped across admission, history hydration and setup. */
436
600
  export declare function createSessionForRequestWithOutcome(...args: Parameters<typeof createSessionForRequestInFileScope>): Promise<CreateSessionRequestOutcome>;
437
601
  export declare function acceptSessionUserMessageWithOutcome(...args: Parameters<typeof acceptSessionUserMessageInFileScope>): ReturnType<typeof acceptSessionUserMessageInFileScope>;
@@ -0,0 +1,52 @@
1
+ import type { AccessGrant, WorkspaceArtifactVisibility } from "@opengeni/contracts";
2
+ import { type Database, type WorkspaceArtifactViewer } from "@opengeni/db";
3
+ import type { PrivacySettings } from "../application/organization-privacy.js";
4
+ /**
5
+ * A Site has an audience, like a chat and a schedule: the whole workspace, or
6
+ * only its owner ("Only me"). Everyone with workspace access sees workspace
7
+ * Sites. An Only me Site is visible to its owner alone; admins cannot see it,
8
+ * exactly like an Only me chat. Only the owner changes the audience.
9
+ *
10
+ * Every surface that reads or changes Sites (HTTP, agent tools, the artifact
11
+ * library, Site tools and Site conversations) resolves its viewer here and
12
+ * passes it to the database layer, which filters by it.
13
+ */
14
+ export declare const SITE_PRIVATE_OWNER_MESSAGE = "Only a person can have an Only me Site.";
15
+ export declare const SITE_PRIVATE_DISABLED_MESSAGE = "Only me is turned off for this organization.";
16
+ export declare const SITE_AUDIENCE_HUMAN_MESSAGE = "Only the Site's owner can change who can see it, from Opengeni.";
17
+ /**
18
+ * The person a request reads Sites as: the human caller, or the human an exact
19
+ * agent attempt acts for. Keys, services and runs without a person see
20
+ * workspace Sites only.
21
+ */
22
+ export declare function siteViewerForGrant(db: Database, grant: AccessGrant): Promise<WorkspaceArtifactViewer>;
23
+ /**
24
+ * The audience and owner to store for a new Site. An explicit choice wins;
25
+ * Only me needs a person who may start Only me work here. Without one, a Site
26
+ * published from a chat starts with that chat's audience, so a Site made in an
27
+ * Only me chat stays Only me until its owner shares it. Anything else starts
28
+ * shared with the workspace, as every Site did before audiences existed.
29
+ */
30
+ export declare function resolveNewSiteAudience(input: {
31
+ db: Database;
32
+ settings: PrivacySettings;
33
+ grant: AccessGrant;
34
+ viewer: WorkspaceArtifactViewer;
35
+ requested: WorkspaceArtifactVisibility | undefined;
36
+ sourceSessionId: string | null;
37
+ }): Promise<{
38
+ visibility: "user_private" | "workspace_shared";
39
+ ownerSubjectId: string | null;
40
+ }>;
41
+ /**
42
+ * The stored audience for an owner's change. Sharing with the workspace is
43
+ * always allowed; limiting to Only me needs Only me to be allowed for them.
44
+ * Whether the caller owns the Site is checked atomically by the database.
45
+ */
46
+ export declare function resolveSiteAudienceChange(input: {
47
+ db: Database;
48
+ settings: PrivacySettings;
49
+ grant: AccessGrant;
50
+ viewer: WorkspaceArtifactViewer;
51
+ requested: WorkspaceArtifactVisibility;
52
+ }): Promise<"user_private" | "workspace_shared">;
@@ -1,4 +1,4 @@
1
- import type { SkillFile, SkillInstallInput, SkillRevisionInput, SkillSaveInput } from "@opengeni/contracts";
1
+ import type { SkillFile, SkillInstallInput, SkillRevisionInput, SkillSaveInput, SkillRemoveInput } from "@opengeni/contracts";
2
2
  import { listSkillRecords, type Database, type SkillReadContext } from "@opengeni/db";
3
3
  export { replayPortableSkillInstall } from "@opengeni/db";
4
4
  /** Canonical text-only folder; rejects invalid Unicode before PostgreSQL conversion. */
@@ -6,8 +6,27 @@ export declare function validateSkillFiles(files: readonly SkillFile[]): SkillFi
6
6
  /** Separate from the historical SKILL.md hash, which must never be rewritten. */
7
7
  export declare function skillBundleHash(files: readonly SkillFile[]): string;
8
8
  export declare const listSkills: typeof listSkillRecords;
9
+ export declare function removeSkill(db: Database, input: SkillRemoveInput): Promise<{
10
+ removed?: boolean | undefined;
11
+ operationId: string;
12
+ skillId: string;
13
+ revisionId: string;
14
+ outcome: "applied" | "pending" | "preserved";
15
+ decision?: "rejected" | undefined;
16
+ pendingReason?: "approval" | "source_finalization" | undefined;
17
+ skillReview?: {
18
+ removalOperationId?: string | undefined;
19
+ sourceOperationId: string;
20
+ skillId: string;
21
+ revisionId: string;
22
+ expectedRevisionId: string | null;
23
+ expectedScopeVersion: number;
24
+ } | undefined;
25
+ replayed: boolean;
26
+ }>;
9
27
  export declare function readSkill(db: Database, context: SkillReadContext, skillId: string, revisionId?: string): Promise<import("@opengeni/contracts").SkillRecord | null>;
10
28
  export declare function saveSkill(db: Database, input: SkillSaveInput): Promise<{
29
+ removed?: boolean | undefined;
11
30
  operationId: string;
12
31
  skillId: string;
13
32
  revisionId: string;
@@ -15,6 +34,7 @@ export declare function saveSkill(db: Database, input: SkillSaveInput): Promise<
15
34
  decision?: "rejected" | undefined;
16
35
  pendingReason?: "approval" | "source_finalization" | undefined;
17
36
  skillReview?: {
37
+ removalOperationId?: string | undefined;
18
38
  sourceOperationId: string;
19
39
  skillId: string;
20
40
  revisionId: string;
@@ -24,6 +44,7 @@ export declare function saveSkill(db: Database, input: SkillSaveInput): Promise<
24
44
  replayed: boolean;
25
45
  }>;
26
46
  export declare function installSkill(db: Database, input: SkillInstallInput): Promise<{
47
+ removed?: boolean | undefined;
27
48
  operationId: string;
28
49
  skillId: string;
29
50
  revisionId: string;
@@ -31,6 +52,7 @@ export declare function installSkill(db: Database, input: SkillInstallInput): Pr
31
52
  decision?: "rejected" | undefined;
32
53
  pendingReason?: "approval" | "source_finalization" | undefined;
33
54
  skillReview?: {
55
+ removalOperationId?: string | undefined;
34
56
  sourceOperationId: string;
35
57
  skillId: string;
36
58
  revisionId: string;
@@ -40,6 +62,7 @@ export declare function installSkill(db: Database, input: SkillInstallInput): Pr
40
62
  replayed: boolean;
41
63
  }>;
42
64
  export declare function approveSkill(db: Database, input: SkillRevisionInput): Promise<{
65
+ removed?: boolean | undefined;
43
66
  operationId: string;
44
67
  skillId: string;
45
68
  revisionId: string;
@@ -47,6 +70,7 @@ export declare function approveSkill(db: Database, input: SkillRevisionInput): P
47
70
  decision?: "rejected" | undefined;
48
71
  pendingReason?: "approval" | "source_finalization" | undefined;
49
72
  skillReview?: {
73
+ removalOperationId?: string | undefined;
50
74
  sourceOperationId: string;
51
75
  skillId: string;
52
76
  revisionId: string;
@@ -56,6 +80,7 @@ export declare function approveSkill(db: Database, input: SkillRevisionInput): P
56
80
  replayed: boolean;
57
81
  }>;
58
82
  export declare function rejectSkill(db: Database, input: SkillRevisionInput): Promise<{
83
+ removed?: boolean | undefined;
59
84
  operationId: string;
60
85
  skillId: string;
61
86
  revisionId: string;
@@ -63,6 +88,7 @@ export declare function rejectSkill(db: Database, input: SkillRevisionInput): Pr
63
88
  decision?: "rejected" | undefined;
64
89
  pendingReason?: "approval" | "source_finalization" | undefined;
65
90
  skillReview?: {
91
+ removalOperationId?: string | undefined;
66
92
  sourceOperationId: string;
67
93
  skillId: string;
68
94
  revisionId: string;
@@ -72,6 +98,7 @@ export declare function rejectSkill(db: Database, input: SkillRevisionInput): Pr
72
98
  replayed: boolean;
73
99
  }>;
74
100
  export declare function restoreSkill(db: Database, input: SkillRevisionInput): Promise<{
101
+ removed?: boolean | undefined;
75
102
  operationId: string;
76
103
  skillId: string;
77
104
  revisionId: string;
@@ -79,6 +106,7 @@ export declare function restoreSkill(db: Database, input: SkillRevisionInput): P
79
106
  decision?: "rejected" | undefined;
80
107
  pendingReason?: "approval" | "source_finalization" | undefined;
81
108
  skillReview?: {
109
+ removalOperationId?: string | undefined;
82
110
  sourceOperationId: string;
83
111
  skillId: string;
84
112
  revisionId: string;