@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,5 +1,5 @@
1
1
  import type { Settings } from "@opengeni/config";
2
- import { mergeToolRefs, stableJson, type RepositoryResourceRef, type ResourceRef, type ToolRef, type WorkspaceSessionToolDefaults } from "@opengeni/contracts";
2
+ import { mergeToolRefs, stableJson, type RepositoryResourceRef, type ResourceRef, type ScheduledTaskToolPolicy, type ToolRef, type WorkspaceSessionToolDefaults } from "@opengeni/contracts";
3
3
  import { type SessionRlsActorContext, type Database } from "@opengeni/db";
4
4
  export declare function validateToolRefs(tools: ToolRef[], settings: McpSettings): ToolRef[];
5
5
  type McpSettings = Pick<Settings, "mcpServers">;
@@ -13,6 +13,22 @@ export declare function withDefaultEnabledCapabilityMcpTools(tools: ToolRef[], s
13
13
  * deployment + enabled-capability default.
14
14
  */
15
15
  export declare function withWorkspaceDefaultMcpTools(tools: ToolRef[], settings: McpSettings, runtimeSettings: McpSettings, defaults: WorkspaceSessionToolDefaults | null): ToolRef[];
16
+ /**
17
+ * The tools a run of a schedule that starts its own session gets now. A
18
+ * schedule that follows the workspace defaults gets the defaults as they are
19
+ * at this moment (never a copy saved earlier), minus the connectors a person
20
+ * turned off, plus its own tools. Without a policy it gets exactly its tools.
21
+ * The Opengeni carrier is never excluded.
22
+ */
23
+ export declare function scheduledTaskRunTools(input: {
24
+ agentConfig: {
25
+ tools: ToolRef[];
26
+ toolPolicy?: ScheduledTaskToolPolicy | undefined;
27
+ };
28
+ settings: McpSettings;
29
+ runtimeSettings: McpSettings;
30
+ workspaceDefaults: WorkspaceSessionToolDefaults | null;
31
+ }): ToolRef[];
16
32
  /** Drop stored refs that are no longer present in the current runtime registry. */
17
33
  export declare function availableToolRefs(tools: ToolRef[], settings: McpSettings): ToolRef[];
18
34
  /** A child or fixed-policy follow-up may narrow its allow-list, never widen it. */
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Scheduled-task access drift, the owner's explicit access refresh, and the
3
+ * in-app signal for runs that failed closed on connector access or ran without
4
+ * an unusable pinned account.
5
+ *
6
+ * A separate-agent task saves its connectors and (when an agent created it,
7
+ * migration 0428) its Opengeni tool policy. Connector accounts are never
8
+ * saved: every run resolves the owner's current accounts, except for accounts
9
+ * a person explicitly pinned. This module computes one plan: what the task's
10
+ * owner would get by saving it again now, and which pinned accounts can no
11
+ * longer be used. The refresh applies exactly that plan through the ordinary
12
+ * owner update path, so a refresh never widens beyond what the calling person
13
+ * could grant with an edit. See docs/scheduled-task-access.md.
14
+ */
15
+ import { type Settings, type FirstPartyMcpToolPolicySettings } from "@opengeni/config";
16
+ import { type AccessGrant, type ConnectionMetadata, type FirstPartyMcpToolName, type McpConnectionAccountBinding, type McpConnectionAccountSelection, type Permission, type RefreshScheduledTaskAccessRequest, type ScheduledTask, type ScheduledTaskAccountPlan, type ScheduledTaskAccessAttention, type ScheduledTaskAccessConnector, type ScheduledTaskPolicyDrift, type ScheduledTaskRun, type ScheduledTaskRunAccessFailure, type SessionAuthorizationPort, type SessionAuthorizationSurface, type ToolRef } from "@opengeni/contracts";
17
+ import { type Database, type ScheduledTaskCreatorPolicy } from "@opengeni/db";
18
+ import { type AccessGrantAuthorization } from "../access/index.js";
19
+ import type { ObjectStorageDependency } from "../dependencies.js";
20
+ import { type PersonalConnectionDelegationSource } from "./personal-connection-delegations.js";
21
+ export type ScheduledTaskConnectorPlan = {
22
+ tools: ToolRef[];
23
+ missing: ScheduledTaskAccessConnector[];
24
+ unavailable: ScheduledTaskAccessConnector[];
25
+ };
26
+ /**
27
+ * Connectors: keep every connector the task already uses that still exists,
28
+ * drop the ones this workspace no longer sets up, and add the workspace
29
+ * defaults a new schedule would get, except the ones the owner chose to keep
30
+ * off (`leaveOut`). A refresh never removes a connector the owner deliberately
31
+ * kept, so it only narrows what no longer exists.
32
+ */
33
+ export declare function planScheduledTaskConnectors(input: {
34
+ taskTools: readonly ToolRef[];
35
+ defaultTools: readonly ToolRef[];
36
+ availableServerIds: ReadonlySet<string>;
37
+ names: ReadonlyMap<string, string>;
38
+ leaveOut?: ReadonlySet<string>;
39
+ }): ScheduledTaskConnectorPlan;
40
+ export type ScheduledTaskPinnedAccountPlan = {
41
+ /** Pins that stay: their connector is still used (special surfaces always stay). */
42
+ kept: McpConnectionAccountSelection[];
43
+ /** Connectors with a pinned account the owner can no longer use. */
44
+ unavailable: ScheduledTaskAccessConnector[];
45
+ /** Connectors with a pin that the task no longer uses; saving drops the pin. */
46
+ dropped: ScheduledTaskAccessConnector[];
47
+ };
48
+ /**
49
+ * Person-pinned accounts against what the owner can use now. Unpinned
50
+ * connectors need no plan: every run resolves the owner's current accounts.
51
+ * A pin is unavailable when its connector is still used but the pinned
52
+ * account no longer resolves for the owner; runs then go without that
53
+ * connector, never with another account. A pin whose connector the task no
54
+ * longer uses is dropped by the next save. Special first-party surfaces keep
55
+ * their own account contract and are checked at admission.
56
+ */
57
+ export declare function planScheduledTaskPinnedAccounts(input: {
58
+ pins: readonly McpConnectionAccountSelection[];
59
+ connectionServerIds: readonly string[];
60
+ availableBindings: ReadonlyArray<{
61
+ canonicalServerId: string;
62
+ connectionId: string;
63
+ }>;
64
+ names: ReadonlyMap<string, string>;
65
+ }): ScheduledTaskPinnedAccountPlan;
66
+ /**
67
+ * What each connector of a scheduled run would act as if the run started
68
+ * now. `bindings` are every account the owner can use for the task's
69
+ * connectors right now, resolved the way a run resolves them. A connector
70
+ * without pins follows those accounts (Default); a pinned connector uses only
71
+ * the pinned accounts that still resolve and names the ones that do not.
72
+ * Special first-party surfaces keep their own account contract and are not
73
+ * listed; neither are host-supplied connectors (absent from
74
+ * `connectionServerIds`).
75
+ */
76
+ export declare function planScheduledTaskAccounts(input: {
77
+ connectionServerIds: readonly string[];
78
+ pins: readonly McpConnectionAccountSelection[];
79
+ bindings: ReadonlyArray<Pick<McpConnectionAccountBinding, "canonicalServerId" | "connectionId" | "accountLabel" | "subjectScope">>;
80
+ names: ReadonlyMap<string, string>;
81
+ }): ScheduledTaskAccountPlan;
82
+ export type ScheduledTaskOpenGeniToolPlan = {
83
+ missing: FirstPartyMcpToolName[];
84
+ policy: {
85
+ firstPartyMcpTools: FirstPartyMcpToolName[];
86
+ firstPartyMcpPermissions: Permission[];
87
+ } | null;
88
+ };
89
+ /** Permissions each first-party tool needs; the API passes its MCP registration table. */
90
+ export type FirstPartyToolPermissionRequirements = (tools: readonly FirstPartyMcpToolName[]) => readonly Permission[];
91
+ /**
92
+ * Opengeni tools of an agent-created task (migration 0428). A human- or
93
+ * API-created task has no frozen creator policy and already follows the
94
+ * deployment default at each run, so there is nothing to refresh. For a frozen
95
+ * policy the refresh adds the current default tools. Permissions stay
96
+ * least-privilege: a frozen permission is kept only while the refreshing
97
+ * person holds it, and the only permissions added are the ones the newly
98
+ * added tools need, within the default worker set and that person's grant. A
99
+ * refresh therefore never lifts a deliberately narrowed permission boundary
100
+ * for tools the task already had, and every addition follows a tool the drift
101
+ * report names. Default tools the owner chose to keep off (`leaveOut`) are
102
+ * neither reported nor added. The frozen session policy (agent access, scope,
103
+ * memory) is never touched.
104
+ */
105
+ export declare function planScheduledTaskOpenGeniTools(input: {
106
+ creatorPolicy: Pick<ScheduledTaskCreatorPolicy, "firstPartyMcpTools" | "firstPartyMcpPermissions"> | null;
107
+ settings: FirstPartyMcpToolPolicySettings;
108
+ grantPermissions: readonly Permission[];
109
+ grantPermissionMode?: AccessGrant["permissionMode"];
110
+ permissionsRequiredByTools: FirstPartyToolPermissionRequirements;
111
+ leaveOut?: ReadonlySet<FirstPartyMcpToolName>;
112
+ }): ScheduledTaskOpenGeniToolPlan;
113
+ /**
114
+ * Fold one run's `tool.auth_needed` facts into one entry per connector and
115
+ * reason. An agent's recommendation to set up a new capability or custom
116
+ * connector is a suggestion, not a failed frozen access, and is left out.
117
+ */
118
+ export declare function scheduledTaskRunAccessFailures(events: ReadonlyArray<{
119
+ payload: unknown;
120
+ occurredAt: string;
121
+ }>, names: ReadonlyMap<string, string>): ScheduledTaskRunAccessFailure[];
122
+ /**
123
+ * Whose access view this viewer may see: the owner's (only for the owner
124
+ * itself, as an entitled authenticated subject) or, for a task without an
125
+ * owner, the workspace's (for people who manage schedules). Null otherwise.
126
+ */
127
+ export declare function scheduledTaskAccessSource(task: Pick<ScheduledTask, "ownerSubjectId">, grant: AccessGrant): Exclude<PersonalConnectionDelegationSource, {
128
+ kind: "turn";
129
+ }> | null;
130
+ /**
131
+ * A signed-in person: the canonical managed cookie session (or a verified
132
+ * external owning user) or the exact built-in local human. Provenance stamps,
133
+ * never grant shape; API keys, services, delegated bearers and agent attempts
134
+ * do not qualify.
135
+ */
136
+ export declare function isScheduledTaskAccessRefreshHuman(authorization: AccessGrantAuthorization, workspaceId: string): boolean;
137
+ export type ScheduledTaskAccessPlan = {
138
+ drift: Omit<ScheduledTaskPolicyDrift, "canRefresh">;
139
+ /** What each connector would act as if a run started now (see `planScheduledTaskAccounts`). */
140
+ accounts: ScheduledTaskAccountPlan;
141
+ /** Connectors with a pinned account the task no longer uses (see the pin plan). */
142
+ droppedPins: ScheduledTaskAccessConnector[];
143
+ tools: ToolRef[];
144
+ creatorFirstPartyPolicy: ScheduledTaskOpenGeniToolPlan["policy"];
145
+ changed: boolean;
146
+ };
147
+ /** Request-local reads shared by every task one viewer's list decorates. */
148
+ export type ScheduledTaskAccessReadCache = {
149
+ registries: Map<string, Promise<Settings>>;
150
+ connections: Map<string, Promise<ConnectionMetadata[]>>;
151
+ };
152
+ export declare function scheduledTaskAccessReadCache(): ScheduledTaskAccessReadCache;
153
+ /**
154
+ * What saving `task` again would save for its owner now, and which of its
155
+ * pinned accounts the owner can no longer use, read-only. The connector
156
+ * registry used to judge availability is the calling person's, the same
157
+ * registry the owner update path validates against.
158
+ */
159
+ export declare function computeScheduledTaskAccessPlan(input: {
160
+ db: Database;
161
+ settings: Settings;
162
+ grant: AccessGrant;
163
+ task: ScheduledTask;
164
+ source: Exclude<PersonalConnectionDelegationSource, {
165
+ kind: "turn";
166
+ }>;
167
+ creatorPolicy: ScheduledTaskCreatorPolicy | null;
168
+ permissionsRequiredByTools: FirstPartyToolPermissionRequirements;
169
+ cache?: ScheduledTaskAccessReadCache;
170
+ workspaceSettings?: unknown;
171
+ /** Defaults the refreshing person chose to keep off; narrows what the plan adds. */
172
+ leaveOut?: RefreshScheduledTaskAccessRequest["leaveOut"];
173
+ }): Promise<ScheduledTaskAccessPlan>;
174
+ export declare function scheduledTaskPolicyDriftHasChanges(drift: Omit<ScheduledTaskPolicyDrift, "canRefresh">): boolean;
175
+ /**
176
+ * Attach `policyDrift` and `accountPlan` to each task this viewer can act on.
177
+ * A viewer who cannot act on a task receives it unchanged, so nobody else sees
178
+ * the owner's account labels. Both are advisory: a failure to compute them
179
+ * never fails the read, it only omits the fields.
180
+ */
181
+ export declare function withScheduledTaskPolicyDrift(input: {
182
+ db: Database;
183
+ settings: Settings;
184
+ authorization: AccessGrantAuthorization;
185
+ tasks: ScheduledTask[];
186
+ permissionsRequiredByTools: FirstPartyToolPermissionRequirements;
187
+ onError?: (error: unknown) => void;
188
+ }): Promise<ScheduledTask[]>;
189
+ /**
190
+ * The owner's explicit access refresh: re-save the task's connectors and (for
191
+ * an agent-created task) Opengeni tool policy with the calling person's
192
+ * current authority. Connector accounts are not part of it: unpinned
193
+ * connectors already follow the owner's current accounts, and pins change only
194
+ * when a person edits them (a pin whose connector is dropped goes with it).
195
+ * It is an ordinary owner edit whose
196
+ * content the server computes, so the owner check, Variable Set permission,
197
+ * model policy, target validation, personal-resource re-authorization and
198
+ * execution-digest update all run exactly as for a manual edit.
199
+ */
200
+ export declare function refreshScheduledTaskAccess(input: {
201
+ settings: Settings;
202
+ db: Database;
203
+ objectStorage: ObjectStorageDependency;
204
+ authorization: AccessGrantAuthorization;
205
+ taskId: string;
206
+ request: RefreshScheduledTaskAccessRequest;
207
+ permissionsRequiredByTools: FirstPartyToolPermissionRequirements;
208
+ sessionAuthorization?: SessionAuthorizationPort | null | undefined;
209
+ authorizationSurface?: SessionAuthorizationSurface | undefined;
210
+ }): Promise<ScheduledTask>;
211
+ /** Attach `accessFailures` to runs of a task this viewer can act on. */
212
+ export declare function withScheduledTaskRunAccessFailures<T extends ScheduledTaskRun>(input: {
213
+ db: Database;
214
+ settings: Settings;
215
+ grant: AccessGrant;
216
+ task: ScheduledTask;
217
+ runs: T[];
218
+ }): Promise<T[]>;
219
+ /**
220
+ * The in-app notice: schedules whose latest run failed closed on connector
221
+ * access and that no later run has cleared. A person is told about the
222
+ * schedules they own. A task without an owner has nobody to notify, so it is
223
+ * listed only for an organization key, configured key or service that manages
224
+ * schedules (the callers that create such tasks), never for every member.
225
+ */
226
+ export declare function scheduledTaskAttentionScope(grant: AccessGrant): {
227
+ ownerSubjectId: string | null;
228
+ includeOwnerless: boolean;
229
+ } | null;
230
+ /**
231
+ * Tasks among `tasks` with a person-pinned connector account that can no
232
+ * longer be used: the pin plan's `unavailableAccounts`, exactly what the
233
+ * drift reports, plus pins whose connector the workspace stopped setting up.
234
+ * A fresh occurrence runs without those connectors (or is
235
+ * skipped when the task requires its pinned accounts). Only the pin part of
236
+ * the plan is read, which does not depend on the creator policy. Advisory: a
237
+ * task whose plan cannot be computed is skipped.
238
+ */
239
+ export declare function scheduledTasksWithUnavailableAccounts(input: {
240
+ db: Database;
241
+ settings: Settings;
242
+ grant: AccessGrant;
243
+ tasks: readonly ScheduledTask[];
244
+ onError?: ((error: unknown) => void) | undefined;
245
+ }): Promise<Array<{
246
+ task: ScheduledTask;
247
+ unavailableAccounts: ScheduledTaskAccessConnector[];
248
+ }>>;
249
+ /**
250
+ * The owner's in-app notice: schedules whose latest run failed closed on
251
+ * connector access and that no later run has cleared, plus schedules with a
252
+ * pinned account that can no longer be used (their runs go without that
253
+ * connector), named by connector. Tasks needing both appear once.
254
+ */
255
+ export declare function listScheduledTaskAccessAttention(input: {
256
+ db: Database;
257
+ settings: Settings;
258
+ grant: AccessGrant;
259
+ onError?: ((error: unknown) => void) | undefined;
260
+ }): Promise<ScheduledTaskAccessAttention[]>;
261
+ /**
262
+ * Schedules with an unusable pinned account come first, then the most recent
263
+ * failed runs. Ties keep a stable order by task id.
264
+ */
265
+ export declare function orderScheduledTaskAccessAttention(items: readonly ScheduledTaskAccessAttention[]): ScheduledTaskAccessAttention[];
@@ -0,0 +1,27 @@
1
+ import type { AccessGrant, ScheduledTaskAgentConfig } from "@opengeni/contracts";
2
+ import { type Database } from "@opengeni/db";
3
+ /** The audit action written whenever a schedule's account or connector choices change. */
4
+ export declare const SCHEDULED_TASK_ACCOUNT_CHOICES_AUDIT_ACTION = "scheduled_task.account_choices_changed";
5
+ /**
6
+ * What changed in a schedule's account and connector choices, as audit
7
+ * metadata: each changed choice with its value before and after. Only the
8
+ * choices are recorded (server and connection ids), never a credential or an
9
+ * account label. Returns null when nothing changed; a new schedule without
10
+ * any choice records nothing.
11
+ */
12
+ export declare function scheduledTaskAccountChoiceChanges(before: ScheduledTaskAgentConfig | null, after: ScheduledTaskAgentConfig): Record<string, {
13
+ before: unknown;
14
+ after: unknown;
15
+ }> | null;
16
+ /**
17
+ * Record a change to a schedule's account or connector choices in the same
18
+ * transaction as the change, with who made it and through which kind of
19
+ * caller (a person, an agent, an API key or a service).
20
+ */
21
+ export declare function recordScheduledTaskAccountChoiceChanges(tx: Database, input: {
22
+ grant: AccessGrant;
23
+ taskId: string;
24
+ operation: "create" | "update";
25
+ before: ScheduledTaskAgentConfig | null;
26
+ after: ScheduledTaskAgentConfig;
27
+ }): Promise<void>;
@@ -0,0 +1,70 @@
1
+ import type { AccessGrant, PrivateScheduledTaskSummary, ScheduledTask, SessionVisibility } from "@opengeni/contracts";
2
+ import { type Database } from "@opengeni/db";
3
+ import { type PrivacySettings } from "../application/organization-privacy.js";
4
+ /**
5
+ * Who is reading schedules: the person (or the person an agent acts for),
6
+ * whether they administer the workspace, and whether, as an admin, they see
7
+ * that other people's Only me schedules exist. The organization can turn that
8
+ * last part off; a deployment can require it.
9
+ */
10
+ export type ScheduledTaskViewer = {
11
+ subjectId: string | null;
12
+ admin: boolean;
13
+ seesPrivateSummaries: boolean;
14
+ };
15
+ /**
16
+ * `full`: everything. `summary`: an admin's view of someone else's Only me
17
+ * schedule (owner, cadence, cost) and pause. `none`: indistinguishable from a
18
+ * schedule that does not exist.
19
+ */
20
+ export type ScheduledTaskAccess = "full" | "summary" | "none";
21
+ export declare function scheduledTaskViewerForGrant(db: Database, grant: AccessGrant, settings: PrivacySettings): Promise<ScheduledTaskViewer>;
22
+ export declare function scheduledTaskAccess(viewer: ScheduledTaskViewer, task: Pick<ScheduledTask, "visibility" | "ownerSubjectId">): ScheduledTaskAccess;
23
+ /** A schedule this caller may see in full; anything else is a plain 404. */
24
+ export declare function requireVisibleScheduledTask(db: Database, grant: AccessGrant, taskId: string, viewer?: ScheduledTaskViewer): Promise<ScheduledTask>;
25
+ /** An admin's summary of someone else's Only me schedule, or null. */
26
+ export declare function privateScheduledTaskSummaryForAdmin(db: Database, grant: AccessGrant, taskId: string, viewer: ScheduledTaskViewer): Promise<PrivateScheduledTaskSummary | null>;
27
+ /**
28
+ * A schedule this caller may pause: one they see in full, or, for an admin,
29
+ * someone else's Only me schedule, which they only ever see as a summary. That
30
+ * schedule often posts into a chat the admin cannot see, so it is read through
31
+ * the summary and never loaded in full.
32
+ */
33
+ export declare function requirePausableScheduledTask(db: Database, grant: AccessGrant, taskId: string, viewer: ScheduledTaskViewer): Promise<{
34
+ access: "full";
35
+ task: ScheduledTask;
36
+ } | {
37
+ access: "summary";
38
+ summary: PrivateScheduledTaskSummary;
39
+ }>;
40
+ /**
41
+ * Pause someone else's Only me schedule as a workspace admin and return its
42
+ * refreshed summary. Only its owner can change, run or resume it.
43
+ */
44
+ export declare function pausePrivateScheduledTaskAsAdmin(db: Database, grant: AccessGrant, taskId: string, viewer: ScheduledTaskViewer): Promise<PrivateScheduledTaskSummary>;
45
+ export declare const SCHEDULED_TASK_PRIVATE_TARGET_MESSAGE = "This schedule posts into an Only me chat, so it is Only me too.";
46
+ export declare const SCHEDULED_TASK_PRIVATE_OWNER_MESSAGE = "Only a person can have an Only me schedule.";
47
+ export declare const SCHEDULED_TASK_PRIVATE_DISABLED_MESSAGE = "Only me schedules are turned off for this organization.";
48
+ /**
49
+ * Whether this person may start something new as Only me in this workspace: a
50
+ * chat, a schedule or a Site. In their Personal workspace, whenever the
51
+ * platform offers private sessions; elsewhere, when the organization allows
52
+ * Only me and the deployment does not turn it off.
53
+ */
54
+ export declare function mayStartOnlyMe(db: Database, settings: PrivacySettings, workspaceId: string, subjectId: string): Promise<boolean>;
55
+ /**
56
+ * The audience to store for a created or edited schedule. A schedule that
57
+ * posts into an Only me chat, or writes to its owner's personal knowledge, is
58
+ * always Only me. Choosing Only me needs a human owner who may create Only me
59
+ * chats in this workspace.
60
+ */
61
+ export declare function resolveScheduledTaskVisibility(input: {
62
+ db: Database;
63
+ settings: PrivacySettings;
64
+ grant: AccessGrant;
65
+ requested: SessionVisibility | undefined;
66
+ current: Pick<ScheduledTask, "visibility"> | null;
67
+ targetSessionId: string | null;
68
+ personalKnowledge: boolean;
69
+ ownerSubjectId: string | null;
70
+ }): Promise<"user_private" | "workspace_shared">;
@@ -1,19 +1,14 @@
1
- import { type Settings } from "@opengeni/config";
2
- import type { AccessGrant, McpPersonalConnectionDelegation, ScheduledTask, ScheduledTaskAgentConfig, Session, SessionAuthorizationPort, SessionAuthorizationSurface, CreateScheduledTaskRequest as CreateScheduledTaskPayload, UpdateScheduledTaskRequest as UpdateScheduledTaskPayload } from "@opengeni/contracts";
3
- import { type KnowledgeContext, type Database, type TemporalScheduleCleanupClaim, type UpdateScheduledTaskInput } from "@opengeni/db";
1
+ import { type FirstPartyMcpToolPolicySettings, type Settings } from "@opengeni/config";
2
+ import type { AccessGrant, ScheduledTask, ScheduledTaskAgentConfig, Session, ToolRef, SessionAuthorizationPort, SessionAuthorizationSurface, CreateScheduledTaskRequest as CreateScheduledTaskPayload, UpdateScheduledTaskRequest as UpdateScheduledTaskPayload } from "@opengeni/contracts";
3
+ import { type KnowledgeContext, type Database, type ScheduledTaskCreatorPolicy, type SessionCommandActor, type TemporalScheduleCleanupClaim, type UpdateScheduledTaskInput } from "@opengeni/db";
4
4
  import { type AccessGrantAuthorization } from "../access/index.js";
5
5
  import type { SessionWorkflowClient } from "../dependencies.js";
6
6
  import type { ObjectStorageDependency } from "../dependencies.js";
7
- /**
8
- * Whether a raw scheduled-task payload explicitly set agentConfig.tools.
9
- * Zod's `.default([])` erases the distinction between "absent" and
10
- * "explicitly empty", so callers detect it on the raw payload — the same
11
- * contract sessions use: absent tools mean "give me the workspace defaults
12
- * (enabled capability MCP servers)", an explicit list (even empty) is taken
13
- * verbatim.
14
- */
7
+ import { type ScheduledTaskSlackChannelVerifier } from "./slack-bot.js";
15
8
  export declare function scheduledTaskToolsProvided(rawPayload: unknown): boolean;
16
- export declare function scheduledConnectionSurfaceEligibility(settings: Settings, target: Pick<Session, "firstPartyMcpTools" | "firstPartyMcpPermissions"> | null): {
9
+ /** Resolve the target's current tool policy before choosing its owner's accounts. */
10
+ export declare function scheduledConnectionTools(db: Database, workspaceId: string, settings: Settings, target: Session | null, taskTools: ToolRef[], subjectId?: string): Promise<ToolRef[]>;
11
+ export declare function scheduledConnectionSurfaceEligibility(settings: Settings, target: (Pick<Session, "firstPartyMcpTools" | "firstPartyMcpPermissions"> & Partial<Pick<Session, "toolPolicy" | "agent">>) | null, workspaceSettings?: unknown): {
17
12
  googleDrivePublicationEnabled: boolean;
18
13
  atlassianEnabled: boolean;
19
14
  };
@@ -25,10 +20,32 @@ export declare function createValidatedScheduledTask(input: {
25
20
  authorization?: AccessGrantAuthorization;
26
21
  payload: CreateScheduledTaskPayload;
27
22
  toolsProvided?: boolean;
28
- variableSetPreauthorized?: boolean;
29
23
  sessionAuthorization?: SessionAuthorizationPort | null | undefined;
30
24
  authorizationSurface?: SessionAuthorizationSurface | undefined;
25
+ /** Proves the bot may post in a newly chosen task Slack channel. */
26
+ verifySlackChannel?: ScheduledTaskSlackChannelVerifier | undefined;
31
27
  }): Promise<ScheduledTask>;
28
+ /**
29
+ * Freeze authenticated credential restrictions for every creation lane, and
30
+ * the creating session's boundary onto an agent-created task so the
31
+ * sessions generated for it inherit exactly what the creator could see and
32
+ * do, never the deployment default. Tools are the session's effective
33
+ * model-visible selection under the deployment ceiling; permissions are the
34
+ * session's effective first-party set intersected with what the calling
35
+ * grant actually holds (a narrowly delegated spawn token cannot hand a
36
+ * schedule more than itself). The session access policy is copied from the
37
+ * projection when it exposes those facts; each absent fact is stored as null
38
+ * so a generated session keeps its own default for that key.
39
+ */
40
+ export declare function frozenScheduledTaskCreatorPolicy(input: {
41
+ db: Database;
42
+ settings: Settings;
43
+ grant: AccessGrant;
44
+ authorization?: AccessGrantAuthorization | undefined;
45
+ actor: Extract<SessionCommandActor, {
46
+ type: "agent_attempt";
47
+ }> | null;
48
+ }): Promise<ScheduledTaskCreatorPolicy | null>;
32
49
  /**
33
50
  * Scheduled-task authority writes fail closed inside SECURITY DEFINER seams
34
51
  * (42501): a non-human writer delegating resources, an authorizer without
@@ -37,11 +54,19 @@ export declare function createValidatedScheduledTask(input: {
37
54
  */
38
55
  export declare function withScheduledTaskAuthorityWriteErrors<T>(run: () => Promise<T>): Promise<T>;
39
56
  /** API/MCP-facing update that maps authority-write denials to 409. */
40
- export declare function updateScheduledTaskForApi(db: Database, workspaceId: string, taskId: string, update: UpdateScheduledTaskInput, learning?: {
57
+ export declare function updateScheduledTaskForApi(db: Database, grant: AccessGrant, taskId: string, update: UpdateScheduledTaskInput, learning?: {
41
58
  authorization: AccessGrantAuthorization;
42
59
  request: NonNullable<UpdateScheduledTaskPayload["agentLearning"]>;
43
60
  restoreState: ScheduledTaskRestoreState;
44
61
  }): Promise<ScheduledTask>;
62
+ export declare function assertScheduledTaskMutationOwner(db: Database, grant: AccessGrant, taskId: string): Promise<void>;
63
+ /**
64
+ * An admin's pause of a schedule they do not own. Pausing is reversible and
65
+ * changes nothing else; only the owner can change, run or resume it again.
66
+ */
67
+ export declare function pauseScheduledTaskAsAdmin(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask>;
68
+ export declare const SCHEDULED_TASK_PAUSED_TRIGGER_MESSAGE = "This schedule is paused, so it cannot run now. Resume it first, then trigger it.";
69
+ export declare function triggerScheduledTaskForGrant(db: Database, grant: AccessGrant, workflowClient: SessionWorkflowClient, input: Parameters<SessionWorkflowClient["triggerScheduledTask"]>[0]): Promise<void>;
45
70
  export declare function validateScheduledTaskTarget(input: {
46
71
  db: Database;
47
72
  sessionAuthorization?: SessionAuthorizationPort | null | undefined;
@@ -53,13 +78,22 @@ export declare function validateScheduledTaskTarget(input: {
53
78
  rigId: string | null | undefined;
54
79
  agentConfig: ScheduledTaskAgentConfig;
55
80
  missingTargetStatus?: 404 | 422;
81
+ /** Leaving a cancelled chat still requires control, but not revivability. */
82
+ departingTarget?: boolean;
56
83
  }): Promise<Session | null>;
84
+ export declare const PERSONAL_MACHINE_SCHEDULE_AUDIENCE_MESSAGE = "Your personal machine can only run schedules that only you can see. Set Who can see it to Only me, or pick a shared machine.";
57
85
  export declare function validateScheduledTaskMachineTarget(input: {
58
86
  settings: Settings;
59
87
  db: Database;
60
88
  grant: AccessGrant;
61
89
  runMode: ScheduledTask["runMode"];
62
90
  agentConfig: ScheduledTaskAgentConfig;
91
+ /**
92
+ * Who can see the schedule. A personal machine runs only an Only me schedule
93
+ * of its owner; the owner check is the scoped lookup itself, which returns a
94
+ * personal machine to nobody else.
95
+ */
96
+ audience: "user_private" | "workspace_shared";
63
97
  requireOnline?: boolean;
64
98
  }): Promise<{
65
99
  sandboxId: string;
@@ -71,7 +105,13 @@ export declare function scheduledTaskRunForGrant<T extends {
71
105
  sessionId: string | null;
72
106
  }>(run: T, grant: AccessGrant): T;
73
107
  export declare function scheduledTaskAuthorityUpdateForGrant(grant: AccessGrant): Pick<UpdateScheduledTaskInput, "refreshPersonalResourceAuthority" | "authorityUpdatedBy" | "authorityUpdatedByContext" | "authorityUpdatedByActor">;
74
- export declare function validatedScheduledTaskUpdate(input: {
108
+ /**
109
+ * The validated update for a schedule edit, including its audience: a schedule
110
+ * that ends up posting into an Only me chat is Only me, and only its owner can
111
+ * change who sees it (the update itself is owner-only).
112
+ */
113
+ export declare function validatedScheduledTaskUpdate(input: Parameters<typeof validatedScheduledTaskUpdateWithoutAudience>[0]): Promise<UpdateScheduledTaskInput>;
114
+ declare function validatedScheduledTaskUpdateWithoutAudience(input: {
75
115
  settings: Settings;
76
116
  db: Database;
77
117
  objectStorage: ObjectStorageDependency;
@@ -83,11 +123,12 @@ export declare function validatedScheduledTaskUpdate(input: {
83
123
  toolsProvided?: boolean;
84
124
  sessionAuthorization?: SessionAuthorizationPort | null | undefined;
85
125
  authorizationSurface?: SessionAuthorizationSurface | undefined;
126
+ /** Proves the bot may post in a newly chosen task Slack channel. */
127
+ verifySlackChannel?: ScheduledTaskSlackChannelVerifier | undefined;
86
128
  }): Promise<UpdateScheduledTaskInput>;
87
129
  export declare function requireScheduledTaskForApi(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask>;
88
130
  export type ScheduledTaskRestoreState = {
89
131
  task: ScheduledTask;
90
- personalConnectionDelegations: McpPersonalConnectionDelegation[];
91
132
  learning?: {
92
133
  context: KnowledgeContext;
93
134
  scope: "workspace" | "personal";
@@ -95,7 +136,7 @@ export type ScheduledTaskRestoreState = {
95
136
  expectedVersion: number;
96
137
  };
97
138
  };
98
- export declare function captureScheduledTaskRestoreState(db: Database, task: ScheduledTask): Promise<ScheduledTaskRestoreState>;
139
+ export declare function captureScheduledTaskRestoreState(_db: Database, task: ScheduledTask): Promise<ScheduledTaskRestoreState>;
99
140
  export declare function restoreScheduledTask(db: Database, previous: ScheduledTaskRestoreState): Promise<ScheduledTask>;
100
141
  export declare class ScheduledTaskSyncError extends Error {
101
142
  readonly persistenceRestored: boolean;
@@ -113,6 +154,7 @@ export declare function deleteScheduledTaskLifecycle(input: {
113
154
  workspaceId: string;
114
155
  taskId: string;
115
156
  subjectId: string;
157
+ beforeDeleteCommit?: (tx: Database) => Promise<void>;
116
158
  preflightConnectorAuthorization: (task: ScheduledTask) => Promise<void>;
117
159
  cleanupConnectorAuthorization: (db: Database, task: ScheduledTask) => Promise<void>;
118
160
  processCleanupClaims?: (claims: readonly TemporalScheduleCleanupClaim[]) => Promise<void>;
@@ -164,4 +206,5 @@ export declare function manualScheduledTaskTriggerUsageKey(workspaceId: string,
164
206
  * provider, or treats ambient worker credentials as responder capability.
165
207
  * Mutable rig/variable-set metadata is revalidated again at dispatch.
166
208
  */
167
- export declare function validateIncidentTelemetryPreflightSelection(settings: Pick<Settings, "allowedFirstPartyMcpTools" | "defaultFirstPartyMcpTools">, agentConfig: ScheduledTaskAgentConfig): void;
209
+ export declare function validateIncidentTelemetryPreflightSelection(settings: FirstPartyMcpToolPolicySettings, agentConfig: ScheduledTaskAgentConfig): void;
210
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { AccessGrant, ConnectionAccountIntent, McpConnectionAccountBinding, McpPersonalConnectionDelegation } from "@opengeni/contracts";
2
+ import { type Settings } from "@opengeni/config";
3
+ import { type Database } from "@opengeni/db";
4
+ /** Freeze the authenticated request's eligible accounts before starting voice.
5
+ * The resulting lease snapshot, not a later participant or ambient connection,
6
+ * supplies authority to both live delegations and automatic transcript handoff. */
7
+ export declare function freezeSessionRealtimeConnectionAccounts(input: {
8
+ db: Database;
9
+ settings: Settings;
10
+ grant: AccessGrant;
11
+ workspaceId: string;
12
+ sessionId: string;
13
+ }): Promise<{
14
+ mcpAccountBindings: McpConnectionAccountBinding[] | null;
15
+ personalConnectionDelegations: McpPersonalConnectionDelegation[];
16
+ connectionAccountIntent: ConnectionAccountIntent | null;
17
+ }>;
18
+ /** One connector a continued turn runs without, and why. */
19
+ export type ContinuedConnectionAccountGap = {
20
+ serverId: string;
21
+ /** The picked account that can no longer be used; null when none was picked. */
22
+ connectionId: string | null;
23
+ reason: string;
24
+ };
25
+ /**
26
+ * Accounts for a turn that continues earlier work in this session: a goal
27
+ * continuation, a wait wake-up, a command or child result, or informational
28
+ * input delivered into the person's last message. It resolves the carried
29
+ * intent exactly as that person's next message with the same picks would be
30
+ * resolved now, against the session's current connectors and the person's
31
+ * current accounts. Nothing from an earlier turn's accounts is copied.
32
+ *
33
+ * A picked account that can no longer be used is never replaced by another
34
+ * account: its connector is left out of this turn. The same applies to a
35
+ * connector whose account can no longer be chosen automatically (for example
36
+ * several accounts now match and none was picked). Every other connector is
37
+ * unaffected.
38
+ *
39
+ * `db` is the claim transaction, so every read runs one at a time.
40
+ */
41
+ export declare function resolveContinuedConnectionAccounts(input: {
42
+ db: Database;
43
+ settings: Settings;
44
+ accountId: string;
45
+ workspaceId: string;
46
+ sessionId: string;
47
+ intent: ConnectionAccountIntent;
48
+ }): Promise<{
49
+ mcpAccountBindings: McpConnectionAccountBinding[] | null;
50
+ personalConnectionDelegations: McpPersonalConnectionDelegation[];
51
+ /** Connectors the turn runs without, because their account cannot be used. */
52
+ gaps: ContinuedConnectionAccountGap[];
53
+ }>;
@@ -0,0 +1,4 @@
1
+ import type { AccessGrant, FileAsset } from "@opengeni/contracts";
2
+ import type { SessionAuthorizationDependencies } from "../session-authorization.js";
3
+ /** A session attachment grant is never a generic file/Knowledge grant. */
4
+ export declare function readSessionAttachmentFiles(deps: SessionAuthorizationDependencies, grant: AccessGrant, sessionId: string, fileIds: readonly string[]): Promise<FileAsset[]>;
@@ -0,0 +1,14 @@
1
+ import type { ConnectionMetadata, McpServerConnectionRef } from "@opengeni/contracts";
2
+ /** Selection is restricted to the caller's already-authorized inventory. This
3
+ * projection grants no execution authority: subsequent admission and physical
4
+ * credential use still validate the exact native account normally. */
5
+ export declare function nativeSessionConnectionReplacement(input: {
6
+ accountId: string;
7
+ workspaceId: string;
8
+ subjectId: string | null;
9
+ serverUrl: string;
10
+ replacementServerUrl?: string;
11
+ currentRef: McpServerConnectionRef | null;
12
+ nativeConnectionId: string;
13
+ connections: ConnectionMetadata[];
14
+ }): McpServerConnectionRef;
@@ -0,0 +1,7 @@
1
+ import { type Observability } from "@opengeni/observability";
2
+ type SessionStartPhase = "workspace_read" | "idempotent_replay" | "model_catalog_initial" | "default_model" | "model_catalog_effective" | "capability_settings" | "resource_validation" | "rig_binding" | "model_admission" | "connection_freeze" | "initiator_freeze" | "allowance" | "shell_insert" | "initialize" | "event_fanout" | "workflow_wake" | "session_reload";
3
+ export type SessionStartObservability = Pick<Observability, "startSpan">;
4
+ /** Content-free child spans around existing work; export is never joined and
5
+ * diagnostic failures cannot alter the lifecycle or its exact error. */
6
+ export declare function measureSessionStartPhase<T>(observability: SessionStartObservability | null | undefined, phase: SessionStartPhase, work: () => Promise<T>): Promise<T>;
7
+ export {};