@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,22 +1,125 @@
1
1
  import type { Context } from "hono";
2
2
  import type { ManagedAuth } from "./managed-auth-type.js";
3
- import type { Database } from "@opengeni/db";
3
+ import { type Database } from "@opengeni/db";
4
4
  import type { ManagedAuthSessionSetMode } from "@opengeni/contracts/managed-auth-session-sets";
5
5
  import { type ManagedAuthSessionAdapter } from "./managed-auth-session-sets.js";
6
+ /** Better Auth `logger.log` sink; a no-op outside a managed-auth session lookup. */
7
+ export declare function recordManagedAuthLoggedFailure(args: readonly unknown[]): void;
8
+ export declare function withManagedAuthSessionLookup<T>(lookup: () => Promise<T>): Promise<T>;
6
9
  type ActorMutationLeaseRuntime = {
7
10
  monotonicNow: () => number;
8
11
  schedule: (callback: () => void, delayMs: number) => ReturnType<typeof setTimeout>;
9
12
  cancel: (timer: ReturnType<typeof setTimeout>) => void;
10
13
  terminate: () => void;
11
14
  };
15
+ /** Bind admission to this auth instance, including all session-set modes. */
16
+ export declare function configureManagedUserAdmission(auth: ManagedAuth, emails: readonly string[] | undefined): void;
17
+ export declare function getManagedSession(...args: Parameters<typeof resolveManagedSession>): Promise<import("./managed-auth-session-sets.js").ManagedAuthResolvedSession | {
18
+ session: {
19
+ id: string;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ userId: string;
23
+ expiresAt: Date;
24
+ token: string;
25
+ ipAddress?: string | null | undefined;
26
+ userAgent?: string | null | undefined;
27
+ } | {
28
+ [x: string]: any;
29
+ [x: number]: any;
30
+ [x: symbol]: any;
31
+ id: string;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ userId: string;
35
+ expiresAt: Date;
36
+ token: string;
37
+ ipAddress?: string | null | undefined;
38
+ userAgent?: string | null | undefined;
39
+ };
40
+ user: {
41
+ id: string;
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+ email: string;
45
+ emailVerified: boolean;
46
+ name: string;
47
+ image?: string | null | undefined;
48
+ } | {
49
+ [x: string]: any;
50
+ [x: number]: any;
51
+ [x: symbol]: any;
52
+ id: string;
53
+ createdAt: Date;
54
+ updatedAt: Date;
55
+ email: string;
56
+ emailVerified: boolean;
57
+ name: string;
58
+ image?: string | null | undefined;
59
+ };
60
+ } | null>;
61
+ /**
62
+ * Bearer prefix of a native app credential. The credential is a dedicated
63
+ * Better Auth session the person approved from a signed-in browser (see the
64
+ * native app sign-in route); the prefix only routes it to this resolver.
65
+ */
66
+ export declare const NATIVE_APP_CREDENTIAL_PREFIX = "ogapp_";
12
67
  /**
13
- * Read a Better Auth session without bypassing its sliding-cookie renewal.
14
- *
15
- * Better Auth can refresh the durable session while resolving `getSession`.
16
- * Programmatic callers must explicitly request and forward the returned cookie
17
- * headers; the HTTP handler does this automatically, but direct API calls do not.
68
+ * Resolve a native app credential exactly as the legacy managed cookie path
69
+ * resolves a browser session: Better Auth validates expiry and renews the
70
+ * durable session, then the canonical human session must still be valid. A
71
+ * native credential never reads or selects a browser session set; each app
72
+ * account holds its own independently revocable session.
18
73
  */
19
- export declare function getManagedSession(c: Context, auth: ManagedAuth, options?: {
74
+ export declare function getNativeAppManagedSession(auth: ManagedAuth, credential: string, db: Database | undefined): Promise<{
75
+ session: {
76
+ id: string;
77
+ createdAt: Date;
78
+ updatedAt: Date;
79
+ userId: string;
80
+ expiresAt: Date;
81
+ token: string;
82
+ ipAddress?: string | null | undefined;
83
+ userAgent?: string | null | undefined;
84
+ } | {
85
+ [x: string]: any;
86
+ [x: number]: any;
87
+ [x: symbol]: any;
88
+ id: string;
89
+ createdAt: Date;
90
+ updatedAt: Date;
91
+ userId: string;
92
+ expiresAt: Date;
93
+ token: string;
94
+ ipAddress?: string | null | undefined;
95
+ userAgent?: string | null | undefined;
96
+ };
97
+ user: {
98
+ id: string;
99
+ createdAt: Date;
100
+ updatedAt: Date;
101
+ email: string;
102
+ emailVerified: boolean;
103
+ name: string;
104
+ image?: string | null | undefined;
105
+ } | {
106
+ [x: string]: any;
107
+ [x: number]: any;
108
+ [x: symbol]: any;
109
+ id: string;
110
+ createdAt: Date;
111
+ updatedAt: Date;
112
+ email: string;
113
+ emailVerified: boolean;
114
+ name: string;
115
+ image?: string | null | undefined;
116
+ };
117
+ } | null>;
118
+ export declare function assertManagedUserAdmission(auth: ManagedAuth, user: {
119
+ email: string;
120
+ emailVerified: boolean;
121
+ } | null | undefined): void;
122
+ declare function resolveManagedSession(c: Context, auth: ManagedAuth, options?: {
20
123
  db?: Database | undefined;
21
124
  allowIdentityRecovery?: boolean | undefined;
22
125
  sessionSetMode?: ManagedAuthSessionSetMode | undefined;
@@ -0,0 +1,58 @@
1
+ import type { AccessGrant } from "@opengeni/contracts";
2
+ import type { SingleModelCallRequest, SingleModelCallResult } from "@opengeni/runtime";
3
+ /**
4
+ * Stateless single model calls: one request to one workspace model with no
5
+ * tools, no agent loop and no session. The public chat completions endpoint
6
+ * is the transport; agentic work uses sessions. The host-owned service picks
7
+ * the model, credential and subscription account exactly as a turn would,
8
+ * admits the call against the same funding rules and settles actual usage.
9
+ */
10
+ export type ModelCallCaller = {
11
+ grant: AccessGrant;
12
+ accountId: string;
13
+ workspaceId: string;
14
+ /** The authenticated subject whose model and subscription authority apply. */
15
+ subjectId: string;
16
+ };
17
+ export type ModelCallInput = ModelCallCaller & {
18
+ /** Product model id or alias; null selects the workspace default model. */
19
+ model: string | null;
20
+ request: Omit<SingleModelCallRequest, "signal">;
21
+ /** Server-generated identity; the settlement idempotency key derives from it. */
22
+ requestId: string;
23
+ signal?: AbortSignal;
24
+ onTextDelta?: (delta: string) => void | Promise<void>;
25
+ };
26
+ export type ModelCallOutput = {
27
+ /** Canonical product model id that served the call. */
28
+ model: string;
29
+ result: SingleModelCallResult;
30
+ };
31
+ export type ModelCallModel = {
32
+ id: string;
33
+ label: string;
34
+ providerLabel: string;
35
+ };
36
+ export interface ModelCallService {
37
+ /** Models the caller may use for a single call, in catalog order. */
38
+ listModels(caller: ModelCallCaller): Promise<ModelCallModel[]>;
39
+ call(input: ModelCallInput): Promise<ModelCallOutput>;
40
+ }
41
+ export type ModelCallErrorType = "invalid_request_error" | "not_found_error" | "insufficient_quota" | "rate_limit_error" | "api_error" | "service_unavailable";
42
+ /**
43
+ * A refusal or failure with a public status and an OpenAI-style error type.
44
+ * Messages are safe to return to the caller.
45
+ */
46
+ export declare class ModelCallError extends Error {
47
+ readonly status: number;
48
+ readonly type: ModelCallErrorType;
49
+ readonly code: string | null;
50
+ readonly param: string | null;
51
+ constructor(input: {
52
+ status: number;
53
+ type: ModelCallErrorType;
54
+ message: string;
55
+ code?: string | null;
56
+ param?: string | null;
57
+ });
58
+ }
@@ -1,7 +1,7 @@
1
1
  import { type ConnectionModelRestrictions } from "@opengeni/db";
2
- import { type ConfiguredModel, type Settings } from "@opengeni/config";
2
+ import { type ClaudeConnectionCatalog, type ConfiguredModel, type Settings } from "@opengeni/config";
3
3
  import { type ModelAvailabilityV1, type ModelCredentialReadinessV1, type WorkspaceModelPolicyContract } from "@opengeni/contracts";
4
- import { type Database } from "@opengeni/db";
4
+ import { type Database, type OrganizationClaudeModelAdmissionAuthority } from "@opengeni/db";
5
5
  export type ResolvedCatalogSettings = {
6
6
  settings: Settings;
7
7
  source: "code" | "database";
@@ -15,9 +15,10 @@ export type ResolvedCatalogSettings = {
15
15
  */
16
16
  export declare function isWorkspaceGatewayCustomModelId(settings: Settings, modelId: string): boolean;
17
17
  export declare function isWorkspaceOpenRouterCustomModelId(settings: Settings, modelId: string): boolean;
18
+ export declare function isWorkspaceOpperCustomModelId(settings: Settings, modelId: string): boolean;
18
19
  export type WorkspaceCustomModelReference = {
19
20
  scope: "workspace" | "organization";
20
- providerKind: "vercel_gateway" | "openrouter";
21
+ providerKind: "vercel_gateway" | "openrouter" | "anthropic" | "claude_subscription" | "opper";
21
22
  upstreamModelId: string;
22
23
  };
23
24
  export declare function workspaceCustomModelReference(settings: Settings, modelId: string): WorkspaceCustomModelReference | null;
@@ -26,6 +27,12 @@ export declare function lockActiveCustomModelForAdmission(db: Database, input: {
26
27
  accountId: string;
27
28
  workspaceId: string;
28
29
  reference: WorkspaceCustomModelReference;
30
+ /**
31
+ * The accepted Claude authority this admission re-reads. Every caller
32
+ * states it: an organization Claude model is never admitted without it,
33
+ * so an omitted value would refuse that model silently.
34
+ */
35
+ claudeAuthority: OrganizationClaudeModelAdmissionAuthority | null;
29
36
  }): Promise<boolean>;
30
37
  /**
31
38
  * Resolve the deployment catalog without making synchronous env settings read
@@ -70,8 +77,12 @@ export type WorkspaceModelSelectionInput = {
70
77
  xaiSubscriptionActive?: boolean;
71
78
  workspaceGatewayConnectionActive?: boolean;
72
79
  workspaceOpenRouterConnectionActive?: boolean;
80
+ workspaceOpperConnectionActive?: boolean;
81
+ claudeConnections?: ClaudeConnectionCatalog;
82
+ workspaceClaudeConnections?: ClaudeConnectionCatalog;
73
83
  organizationGatewayConnectionActive?: boolean;
74
84
  organizationOpenRouterConnectionActive?: boolean;
85
+ organizationOpperConnectionActive?: boolean;
75
86
  workspaceGatewayCustomModels?: readonly {
76
87
  upstreamModelId: string;
77
88
  label?: string | null;
@@ -88,6 +99,14 @@ export type WorkspaceModelSelectionInput = {
88
99
  upstreamModelId: string;
89
100
  label?: string | null;
90
101
  }[];
102
+ workspaceOpperCustomModels?: readonly {
103
+ upstreamModelId: string;
104
+ label?: string | null;
105
+ }[];
106
+ organizationOpperCustomModels?: readonly {
107
+ upstreamModelId: string;
108
+ label?: string | null;
109
+ }[];
91
110
  credentialReadinessObservations?: Readonly<Record<string, ModelCredentialReadinessObservation>> | undefined;
92
111
  observations?: Readonly<Record<string, ModelAvailabilityObservation>> | undefined;
93
112
  now?: Date | undefined;
@@ -99,6 +118,13 @@ export type WorkspaceModelSelection = {
99
118
  policyAllowed: boolean;
100
119
  availability: ModelAvailabilityV1;
101
120
  };
121
+ /**
122
+ * Stable fresh-selection admission, independent of transient observations.
123
+ * Missing catalog membership is handled by the caller's lookup. Resolver-based
124
+ * deployment credentials (Azure AD/managed identity) are resolved at execution;
125
+ * absent, stale or failed observations cannot make their definition uncreatable.
126
+ */
127
+ export declare function isWorkspaceModelAdmissible(selection: WorkspaceModelSelection): boolean;
102
128
  /**
103
129
  * One shared picker/tool decision. Catalog membership, credential readiness,
104
130
  * workspace policy, and optional provider-health observations are evaluated in
@@ -0,0 +1,43 @@
1
+ import { type Settings } from "@opengeni/config";
2
+ import { type Database } from "@opengeni/db";
3
+ /**
4
+ * Execution-time provider overlays for one workspace: subscription catalog
5
+ * providers plus the decrypted workspace and organization provider keys a
6
+ * model call needs. Agent turns (worker claim) and stateless single model
7
+ * calls (API) apply the same overlays, so both resolve a model to the same
8
+ * provider and credential.
9
+ */
10
+ /**
11
+ * When the workspace has an active Codex subscription connected and the feature
12
+ * is enabled, inject a synthetic "codex-subscription" registry provider so a
13
+ * `codex/<slug>` model id routes through the ChatGPT backend. No secrets touch
14
+ * this overlay (metadata-only read); the per-request bearer is resolved later via
15
+ * codexRequestStorage. Idempotent and a no-op when not applicable.
16
+ */
17
+ export declare function settingsWithCodexCredential(db: Database, workspaceId: string, settings: Settings, activeOverride?: boolean): Promise<Settings>;
18
+ /** Pure: append the synthetic codex-subscription provider, idempotently. */
19
+ export declare function withCodexProvider(settings: Settings): Settings;
20
+ /**
21
+ * Pure: append the synthetic SuperGrok/xAI subscription provider,
22
+ * idempotently. The overlay is catalogue metadata only; the exact account,
23
+ * authority snapshot, and bearer remain frozen later at turn admission.
24
+ */
25
+ export declare function withXaiSubscriptionProvider(settings: Settings): Settings;
26
+ export declare function settingsWithWorkspaceGatewayCredential(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
27
+ export declare function settingsWithWorkspaceOpenRouterCredential(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
28
+ /** Overlay the workspace Opper catalog and, when active, its decrypted key. */
29
+ export declare function settingsWithWorkspaceOpperCredential(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
30
+ export declare function settingsWithOrganizationProviderCredentials(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
31
+ /**
32
+ * Apply every execution overlay in the order the worker claim uses, then
33
+ * install the selected customer direct connection when the model names one.
34
+ * `codexSubscriptionActive` is the caller's single readiness observation, so
35
+ * routing and billing decide from the same read.
36
+ */
37
+ export declare function settingsWithModelProviderCredentials(db: Database, input: {
38
+ accountId: string;
39
+ workspaceId: string;
40
+ settings: Settings;
41
+ productModelId: string | null | undefined;
42
+ codexSubscriptionActive: boolean;
43
+ }): Promise<Settings>;
@@ -0,0 +1,30 @@
1
+ import { type SessionTurnSurface } from "@opengeni/contracts";
2
+ import type { Observability } from "@opengeni/observability";
3
+ /**
4
+ * Live, content-free product usage counters recorded where work is accepted.
5
+ * Every label is a closed set: the product surface (or `unknown` when no
6
+ * surface was captured), who created a session (`subject` or `service`), and
7
+ * whether the session is a root. No workspace, user, model or text value ever
8
+ * becomes a label.
9
+ */
10
+ export type ProductUsageMetricsSink = Pick<Observability, "incrementCounter">;
11
+ export declare const PRODUCT_USAGE_SURFACE_LABELS: readonly ["web", "slack", "api_key", "embedded", "scheduled", "agent", "voice", "site", "automation", "mcp", "system", "unknown"];
12
+ export type ProductUsageSurfaceLabel = (typeof PRODUCT_USAGE_SURFACE_LABELS)[number];
13
+ export declare const SESSION_CREATED_BY_KINDS: readonly ["subject", "service"];
14
+ export type SessionCreatedByKind = (typeof SESSION_CREATED_BY_KINDS)[number];
15
+ export declare function productUsageSurfaceLabel(surface: SessionTurnSurface | null | undefined): ProductUsageSurfaceLabel;
16
+ /** Count one newly created session. Never throws; replays must not call it. */
17
+ export declare function recordSessionCreated(sink: ProductUsageMetricsSink | null | undefined, input: {
18
+ surface: SessionTurnSurface | null | undefined;
19
+ createdByKind: string | null | undefined;
20
+ parentSessionId: string | null | undefined;
21
+ }): void;
22
+ /** Count one newly accepted user message. Never throws; replays must not call it. */
23
+ export declare function recordUserMessageAccepted(sink: ProductUsageMetricsSink | null | undefined, input: {
24
+ surface: SessionTurnSurface | null | undefined;
25
+ }): void;
26
+ /**
27
+ * Publish every closed series at zero so dashboards can tell a quiet surface
28
+ * from missing instrumentation. Never throws.
29
+ */
30
+ export declare function registerProductUsageMetricBaselines(sink: ProductUsageMetricsSink | null | undefined): void;
@@ -1,18 +1,9 @@
1
- import type { AccessGrant, CreateRigRequest, RigDefinitionEditPayload, ProposeRigChangeRequest, Rig, RigChange, ResourceAuthorityScope, RigVersion, UpdateRigRequest } from "@opengeni/contracts";
1
+ import type { AccessGrant, CreateRigRequest, RigDefinitionEditPayload, ProposeRigChangeRequest, Rig, RigChange, RigVersion, UpdateRigRequest } from "@opengeni/contracts";
2
2
  import { type Database } from "@opengeni/db";
3
3
  export * from "./provider-images.js";
4
4
  export declare const MAX_RIGS_PER_WORKSPACE = 50;
5
5
  export declare const MAX_CHECKS_PER_RIG = 100;
6
6
  export declare const MAX_CREDENTIAL_HOOKS_PER_RIG = 50;
7
- export declare const MAX_DEFAULT_VARIABLE_SETS_PER_RIG = 25;
8
- export declare const RIG_DEFAULT_VARIABLE_SET_LOAD_CONCURRENCY = 4;
9
- type VariableSetEnvironment = {
10
- values: Record<string, string>;
11
- } | null;
12
- /** Load complete rig defaults concurrently while preserving listed precedence. */
13
- export declare function loadRigDefaultVariableSetEnvironment(variableSetIds: readonly string[], load: (variableSetId: string) => Promise<VariableSetEnvironment>): Promise<Record<string, string>>;
14
- /** Rig defaults layer below the session's explicitly selected variable set. */
15
- export declare function mergeRigDefaultVariableSetEnvironment(rigDefaultValues: Record<string, string>, sessionValues: Record<string, string>): Record<string, string>;
16
7
  export type RigServices = {
17
8
  db: Database;
18
9
  };
@@ -26,9 +17,6 @@ export declare function recordRigAuditEvent(db: Database, input: {
26
17
  export declare function rigActorForGrant(grant: AccessGrant): string;
27
18
  export declare function requireRigForApi(db: Database, grant: AccessGrant, rigId: string): Promise<Rig>;
28
19
  export declare function requireRigChangeForApi(db: Database, workspaceId: string, rigId: string, changeId: string): Promise<RigChange>;
29
- /** A resource may depend only on Variable Sets whose audience is no narrower
30
- * than its own. User-owned rigs may use anything visible to their owner. */
31
- export declare function variableSetScopeAllowedForRig(rigScope: ResourceAuthorityScope, variableSetScope: ResourceAuthorityScope): boolean;
32
20
  export declare function createRigForApi(deps: RigServices, grant: AccessGrant, payload: CreateRigRequest, options?: {
33
21
  allowOrganization?: boolean;
34
22
  }): Promise<Rig>;
@@ -1,5 +1,6 @@
1
- import type { Settings } from "@opengeni/config";
2
- import type { SandboxBackend } from "@opengeni/contracts";
1
+ import type { VaultProviderRegistry } from "@opengeni/vaults";
2
+ import { type Settings } from "@opengeni/config";
3
+ import { type SandboxBackend, type SecretResolver } from "@opengeni/contracts";
3
4
  import { type Database, type SandboxRecord } from "@opengeni/db";
4
5
  import type { EventBus } from "@opengeni/events";
5
6
  import { type BackendUnresolvableCode, type ControlRpc, type SelfhostedRelayConfig, type SelfhostedOpStreamDeps, type SelfhostedOperationAdmission, type SelfhostedOperationResourcePolicy } from "@opengeni/runtime/sandbox";
@@ -68,7 +69,7 @@ export type FleetSandboxEntry = {
68
69
  /** The sandbox id used as the attach/swap/run_on `target`. For the session's
69
70
  * own group box this is the group id (a null active pointer == this box). */
70
71
  id: string;
71
- kind: "modal" | "selfhosted" | "opensandbox";
72
+ kind: Exclude<SandboxBackend, "none">;
72
73
  name: string;
73
74
  liveness: FleetLiveness;
74
75
  /** True for the session's currently-active sandbox (the routing target). */
@@ -117,8 +118,21 @@ export type FleetSwapResult = {
117
118
  activeSandboxId: string | null;
118
119
  activeEpoch: number;
119
120
  reason?: string;
120
- code?: BackendUnresolvableCode | "invalid_working_directory" | "concurrent_swap" | "recovery_in_progress" | "recovery_degraded" | "recovery_unrecoverable";
121
+ code?: BackendUnresolvableCode | "invalid_working_directory" | "concurrent_swap" | PersonalMachineRefusalCode | "recovery_in_progress" | "recovery_degraded" | "recovery_unrecoverable";
121
122
  };
123
+ export type PersonalMachineRefusalCode = "personal_machine_permission_required" | "personal_machine_not_permitted";
124
+ /**
125
+ * Plain refusal for a personal ("Only me") Connected Machine that the database
126
+ * admission (`authorize_session_attempt_personal_machine`) turned down. The
127
+ * function raises SQLSTATE 42501 for policy refusals and P0002 when a required
128
+ * owner, authority or enrollment row is not current. Only failures of that
129
+ * admission statement are mapped; anything else is a real failure and stays an
130
+ * error. The raw database error is never shown.
131
+ */
132
+ export declare function personalMachineRefusal(error: unknown): {
133
+ code: PersonalMachineRefusalCode;
134
+ reason: string;
135
+ } | null;
122
136
  /**
123
137
  * List the fleet: the session's own group box when it has one (a synthetic
124
138
  * entry) + the workspace's first-class selfhosted sandboxes (each probed for
@@ -210,9 +224,31 @@ export type RunOnSelfhostedMachine = {
210
224
  * the active attempt that owns the one-off operation.
211
225
  */
212
226
  transientExecEnvironment?: Readonly<Record<string, string>>;
227
+ /**
228
+ * The calling attempt's secret resolver (W1, DL-9). exec splices
229
+ * `{{secret:…}}` / `{{secretfile:…}}` in the machine's dialect and delivers
230
+ * values in ExecRequest.env; write resolves its content; read resolves
231
+ * nothing. Absent: references pass through literally.
232
+ */
233
+ secretResolver?: SecretResolver | null;
213
234
  };
235
+ /**
236
+ * The secret resolver for a `run_on` call made by an exact agent attempt (the
237
+ * MCP claims). Gated by the session's `secrets` capability (default on).
238
+ */
239
+ export declare function createRunOnSecretResolver(services: Pick<FleetServices, "db" | "settings">, attempt: {
240
+ accountId: string;
241
+ workspaceId: string;
242
+ sessionId: string;
243
+ turnId: string;
244
+ attemptId: string;
245
+ executionGeneration: number;
246
+ },
247
+ /** Connected vaults (1Password, host) for the attempt's acting human. */
248
+ providersForSubject?: (subjectId: string | null) => VaultProviderRegistry): Promise<SecretResolver>;
214
249
  export type RunOnOptions = {
215
250
  transientExecEnvironment?: Readonly<Record<string, string>>;
251
+ secretResolver?: SecretResolver | null;
216
252
  };
217
253
  /**
218
254
  * Execute the one-off machine operation once the workspace/enrollment lookup has
@@ -221,6 +257,24 @@ export type RunOnOptions = {
221
257
  * the production ownership lookup or requiring a real machine.
222
258
  */
223
259
  export declare function executeRunOnSelfhostedMachine(machine: RunOnSelfhostedMachine, target: string, op: RunOnOp): Promise<RunOnResult>;
260
+ /**
261
+ * Run one short command on a specific enrolled machine for an action a person
262
+ * or agent took outside a session's routing (opening a macOS settings pane).
263
+ * The caller has already authorized the actor for this enrollment; `access` is
264
+ * the same scope the caller used to read it. `execTimeoutMs` bounds the command.
265
+ */
266
+ export declare function runOnEnrollmentDirect(services: Pick<FleetServices, "db" | "settings" | "bus">, input: {
267
+ access: string | {
268
+ accountId: string;
269
+ workspaceId: string;
270
+ subjectId: string;
271
+ };
272
+ enrollmentId: string;
273
+ /** Display label for results (machine name or sandbox id). */
274
+ target: string;
275
+ cmd: string;
276
+ execTimeoutMs: number;
277
+ }): Promise<RunOnResult>;
224
278
  /**
225
279
  * Run a ONE-OFF op against a SPECIFIC target WITHOUT changing the active pointer
226
280
  * (the design `run_on`). Only selfhosted targets are routable as a one-off here
@@ -1,7 +1,7 @@
1
1
  import { type Settings } from "@opengeni/config";
2
- import { type Database, type SandboxRetainedProcess } from "@opengeni/db";
2
+ import { type Database, type EnrollmentRecord, type SandboxRetainedProcess } from "@opengeni/db";
3
3
  import { type EventBus } from "@opengeni/events";
4
- import { type EstablishedSandboxSession, type ResolvedActiveBackend, type RoutingRetainedProcess, type RoutingRetainedProcessTerminalProof, type RoutingSandboxOperationObserver, type SelfhostedRelayConfig } from "@opengeni/runtime/sandbox";
4
+ import { type EstablishedSandboxSession, type ResolvedActiveBackend, type RoutingRetainedProcess, type RoutingRetainedProcessTerminalProof, type RoutingSandboxOperationObserver, type RoutingSandboxCaptureWaitObserver, type SelfhostedRelayConfig } from "@opengeni/runtime/sandbox";
5
5
  type DirectRetainedProcessRoute = {
6
6
  providerSessionId: number;
7
7
  providerBackend: string;
@@ -11,6 +11,12 @@ type DirectRetainedProcessRoute = {
11
11
  routeTargetId: string | null;
12
12
  routeEpoch: number;
13
13
  };
14
+ /** Inline filesystem subprocesses stay durably retained for cancellation and
15
+ * recovery, but are not model-visible session background commands. */
16
+ export declare function directRetainedProcessBackgroundCommand(process: Pick<RoutingRetainedProcess, "id">, operation: string, purpose?: "synchronous_filesystem"): {
17
+ commandId: string;
18
+ command: string;
19
+ } | undefined;
14
20
  /** API-direct requests always use active-route authority. The default active
15
21
  * pointer is represented by a null target id; it is not a home-route write. */
16
22
  export declare function directRetainedProcessMatchesBackend(durable: DirectRetainedProcessRoute, process: RoutingRetainedProcess, backend: ResolvedActiveBackend): boolean;
@@ -24,8 +30,38 @@ export type ChannelARoutingServices = {
24
30
  settings: Settings;
25
31
  bus?: EventBus;
26
32
  onSandboxOperation?: RoutingSandboxOperationObserver;
33
+ onSandboxCaptureWait?: RoutingSandboxCaptureWaitObserver;
27
34
  waitSignal?: AbortSignal;
28
35
  };
36
+ /**
37
+ * Whose access a Channel-A request uses to reach a Connected Machine. A person
38
+ * uses their own. An agent acts for the person who started its turn, never as
39
+ * itself, so it reaches the same machines that person can; a personal (Only me)
40
+ * machine additionally needs that exact running attempt's per-chat permission,
41
+ * rechecked before every routed operation like the worker's turn path.
42
+ */
43
+ export type ChannelAMachineAuthority = {
44
+ subjectId: string;
45
+ personalMachineAttempt: {
46
+ turnId: string;
47
+ attemptId: string;
48
+ executionGeneration: number;
49
+ } | null;
50
+ };
51
+ /**
52
+ * Resolve a Connected Machine's live runner for one Channel-A request. The
53
+ * machine's audience can change in place, so its current scope is read from the
54
+ * enrollment itself. An agent attempt reaches a personal machine only through
55
+ * the same attempt admission as swap and run_on; everything else keeps the
56
+ * caller-scoped lookup.
57
+ */
58
+ export declare function resolveChannelAMachineConnection(db: Database, input: {
59
+ accountId: string;
60
+ workspaceId: string;
61
+ sessionId: string;
62
+ machineWorkspaceId: string;
63
+ enrollmentId: string;
64
+ }, authority: ChannelAMachineAuthority): Promise<EnrollmentRecord | null>;
29
65
  /** Map the deployment relay URL to the leaf's `SelfhostedRelayConfig` shape. The
30
66
  * relay URL (`OPENGENI_SELFHOSTED_RELAY_URL`) may carry a path (the relay's wss
31
67
  * route); a path-less URL defaults to the relay's `/stream` route (M8b). */
@@ -55,6 +91,10 @@ export declare function wrapChannelABoxWithRouting(services: ChannelARoutingServ
55
91
  workspaceId: string;
56
92
  sessionId: string;
57
93
  resourceSubjectId: string;
94
+ /** Whose access reaches Connected Machines (see ChannelAMachineAuthority).
95
+ * Resolved lazily, once, only when a request routes to a machine. Omitted,
96
+ * the request uses `resourceSubjectId`'s own access. */
97
+ machineAuthority?: () => Promise<ChannelAMachineAuthority>;
58
98
  homeLease?: {
59
99
  sandboxGroupId: string;
60
100
  leaseEpoch: number;
@@ -1,5 +1,5 @@
1
- import type { Settings } from "@opengeni/config";
2
- import { CapabilityPack, type RigVersion, type Session, type SandboxBackend, type SandboxOs } from "@opengeni/contracts";
1
+ import { type Settings } from "@opengeni/config";
2
+ import { type AccessGrant, type RigVersion, type Session, type SandboxBackend, type SandboxOs } from "@opengeni/contracts";
3
3
  import { type Database } from "@opengeni/db";
4
4
  import { resolveModalCheckpointProviderBinding } from "@opengeni/runtime/sandbox";
5
5
  export type ManagedSessionGroupBackend = Exclude<SandboxBackend, "none" | "selfhosted">;
@@ -14,24 +14,25 @@ export type ManagedSessionGroupBackend = Exclude<SandboxBackend, "none" | "selfh
14
14
  * fallback to expose.
15
15
  */
16
16
  export declare function managedSessionGroupBackend(deploymentBackend: SandboxBackend, sessionBackend: SandboxBackend): ManagedSessionGroupBackend | null;
17
+ /** Display name and kind for the session's own managed box. The kind is the
18
+ * real provider. Callers must not collapse local, Docker, or other providers
19
+ * into Modal. */
20
+ export declare function sessionGroupMachinePresentation(backend: ManagedSessionGroupBackend): {
21
+ name: string;
22
+ kind: ManagedSessionGroupBackend;
23
+ };
17
24
  /** A machine-home row carries the machine's host OS; its managed group uses the
18
25
  * platform's canonical managed-sandbox OS instead. Ordinary sessions preserve
19
26
  * their explicitly selected OS. */
20
27
  export declare function managedSessionGroupOs(sessionBackend: SandboxBackend, sessionOs: SandboxOs): SandboxOs;
21
- /** Pre-V2 Packs are the sole compatibility path where a Pack can still own a
22
- * sandbox image. V2 installations select a Rig instead. Keep this predicate at
23
- * the shared runtime boundary so turns, API-direct tools, viewers, Browser and
24
- * Computer cannot resolve different physical machines for the same session. */
25
- export declare function packInstallationUsesLegacyRuntime(input: {
26
- manifestSnapshot: unknown | null;
27
- manifestDigest: string | null;
28
- }): boolean;
29
- export declare function resolveWorkspaceLegacyRuntimePacks(db: Database, workspaceId: string): Promise<CapabilityPack[]>;
30
- export declare function legacySandboxRuntimeFromPacks(packs: readonly CapabilityPack[]): {
31
- sandboxImage: string | null;
32
- sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null;
33
- };
34
- export declare function settingsWithPackSandboxImage(settings: Settings, sandboxImage: string | null, sandboxProviderImages?: CapabilityPack["sandboxProviderImages"] | null): Settings;
28
+ /**
29
+ * Apply a workspace's selected sandbox image. The deployment keeps authority:
30
+ * only an image that is on its allowlist right now is used, so removing an
31
+ * entry returns every workspace that chose it to the deployment image. The
32
+ * lease treats the image as shared state, so a change rotates a live box
33
+ * through the normal capture-and-restore path instead of reusing it.
34
+ */
35
+ export declare function settingsWithWorkspaceSandboxImage(settings: Settings, workspaceSettings: unknown, backend: SandboxBackend): Settings;
35
36
  export declare function settingsWithRigImage(settings: Settings, rigImage: string | null): Settings;
36
37
  export declare function rigProviderImageSourceImage(settings: Settings, backend: SandboxBackend): string | null;
37
38
  export type RigProviderImageSelectionReason = "selected" | "missing" | "provider_unsupported" | "not_ready" | "not_cold_boot_validated" | "content_mismatch" | "provider_binding_unavailable" | "provider_binding_mismatch";
@@ -49,7 +50,16 @@ export type SessionSandboxRuntime = {
49
50
  image: string | null;
50
51
  rigVersion: RigVersion | null;
51
52
  };
52
- export declare function resolveSessionSandboxRuntime(db: Database, settings: Settings, session: Pick<Session, "workspaceId" | "sandboxBackend" | "rigId" | "rigVersionId">): Promise<SessionSandboxRuntime>;
53
+ /** Who a direct attach resolves a session's Sandbox Environment as: an explicit
54
+ * subject (null for a service attach), or the authenticated route grant. */
55
+ export type SessionAttachRigAuthority = {
56
+ subjectId: string | null;
57
+ } | {
58
+ grant: AccessGrant;
59
+ };
60
+ export declare function resolveSessionSandboxRuntime(db: Database, settings: Settings, session: Pick<Session, "accountId" | "workspaceId" | "sandboxBackend" | "rigId" | "rigVersionId">,
61
+ /** Who drives the attach; pass the route grant whenever one exists. */
62
+ authority: SessionAttachRigAuthority): Promise<SessionSandboxRuntime>;
53
63
  /** Resolve provider-native cold-create optimization only for the single CAS
54
64
  * winner. Ordinary API calls never perform provider identity I/O. */
55
65
  export declare function providerSettingsForSessionSandboxRuntime(runtime: SessionSandboxRuntime, backend: SandboxBackend): Promise<Settings>;
@@ -2,6 +2,16 @@ import { SessionAuthorizationActor, SessionAuthorizationListScope, type AccessGr
2
2
  import { type Database, type SessionRlsActorContext } from "@opengeni/db";
3
3
  import type { AppDependencies } from "./dependencies.js";
4
4
  export type SessionAuthorizationDependencies = Pick<AppDependencies, "db" | "sessionAuthorization">;
5
+ /** Scope read reuse to one request; it never outlives `fn`. */
6
+ export declare function withSessionAuthorizationReadReuse<T>(fn: (reuse: {
7
+ handOffToToolDispatch(): void;
8
+ }) => Promise<T>): Promise<T>;
9
+ /**
10
+ * Invoke a tool handler so that authorization checks it starts before its
11
+ * first await reuse the route's reads. Later checks, and every other dispatch
12
+ * in the same request, read fresh.
13
+ */
14
+ export declare function dispatchWithSessionAuthorizationReadReuse<T>(handler: () => T): T;
5
15
  /** Maximum time an omitted host hint leaves a live session stream unchecked. */
6
16
  export declare const SESSION_AUTHORIZATION_DEFAULT_REAUTHORIZE_MS = 15000;
7
17
  export declare class SessionAuthorizationDeniedError extends Error {