@opengeni/db 0.28.9 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/attached-browser-devices.d.ts +42 -0
  2. package/dist/attempt-tool-catalogs.d.ts +16 -0
  3. package/dist/browser-auth.d.ts +91 -0
  4. package/dist/browser-identities.d.ts +128 -0
  5. package/dist/browser-sessions.d.ts +272 -0
  6. package/dist/browser-state-artifacts.d.ts +17 -0
  7. package/dist/capability-components.d.ts +37 -0
  8. package/dist/capability-integrations.d.ts +192 -0
  9. package/dist/chunk-F5FT7BEZ.js +3535 -0
  10. package/dist/chunk-F5FT7BEZ.js.map +1 -0
  11. package/dist/chunk-ISI2TIUG.js +639 -0
  12. package/dist/chunk-ISI2TIUG.js.map +1 -0
  13. package/dist/chunk-MWDVXQOL.js +11639 -0
  14. package/dist/chunk-MWDVXQOL.js.map +1 -0
  15. package/dist/chunk-NBE6CHRI.js +955 -0
  16. package/dist/chunk-NBE6CHRI.js.map +1 -0
  17. package/dist/{chunk-VHBFHMPC.js → chunk-YHZXQ7HP.js} +754 -11
  18. package/dist/chunk-YHZXQ7HP.js.map +1 -0
  19. package/dist/codemode-operations.d.ts +117 -0
  20. package/dist/codex-token-resolver.d.ts +2 -2
  21. package/dist/company-profile-schema.d.ts +798 -0
  22. package/dist/company-profile.d.ts +268 -0
  23. package/dist/computer-sessions.d.ts +109 -0
  24. package/dist/connection-token-resolver.d.ts +9 -4
  25. package/dist/database.d.ts +52 -3
  26. package/dist/editable-artifact-durable-export.d.ts +153 -0
  27. package/dist/editable-artifact-durable-export.js +788 -0
  28. package/dist/editable-artifact-durable-export.js.map +1 -0
  29. package/dist/editable-artifact-materialization.d.ts +123 -0
  30. package/dist/editable-artifacts-schema.d.ts +4152 -0
  31. package/dist/editable-artifacts.d.ts +610 -0
  32. package/dist/editable-artifacts.js +26 -0
  33. package/dist/editable-artifacts.js.map +1 -0
  34. package/dist/generated-images.d.ts +139 -0
  35. package/dist/index.d.ts +698 -111
  36. package/dist/index.js +27573 -10322
  37. package/dist/index.js.map +1 -1
  38. package/dist/insights.d.ts +51 -4
  39. package/dist/integration-bindings.d.ts +70 -0
  40. package/dist/integration-features.d.ts +99 -0
  41. package/dist/interaction-revisions.d.ts +3 -0
  42. package/dist/interaction-schema.d.ts +5372 -0
  43. package/dist/knowledge-source-sync-schema.d.ts +1679 -0
  44. package/dist/knowledge-source-sync.d.ts +274 -0
  45. package/dist/memory-governance.d.ts +2 -2
  46. package/dist/memory-slack-delivery.d.ts +101 -0
  47. package/dist/new-session-drafts.d.ts +2 -2
  48. package/dist/pack-components.d.ts +76 -0
  49. package/dist/pack-installations.d.ts +86 -0
  50. package/dist/persistence-errors.d.ts +3 -3
  51. package/dist/plugin-packages.d.ts +126 -0
  52. package/dist/preference-registry.d.ts +1 -1
  53. package/dist/provision-roles.d.ts +9 -1
  54. package/dist/provision-roles.js +1 -1
  55. package/dist/runtime-posture.d.ts +18 -6
  56. package/dist/schema.d.ts +18342 -9099
  57. package/dist/schema.js +165 -1
  58. package/dist/scoped-knowledge.d.ts +97 -1
  59. package/dist/session-control.d.ts +4 -4
  60. package/dist/session-queue-commands.d.ts +19 -11
  61. package/dist/session-realtime-context.d.ts +2 -2
  62. package/dist/session-realtime-ledger.d.ts +4 -4
  63. package/dist/session-realtime-mirror.d.ts +2 -2
  64. package/dist/session-realtime-state.d.ts +1 -1
  65. package/dist/session-realtime-terminal.d.ts +1 -1
  66. package/dist/session-realtime.d.ts +7 -7
  67. package/dist/session-tool-call-settlement.d.ts +1 -1
  68. package/dist/slack-user-link-access.d.ts +54 -0
  69. package/dist/transcription-recordings.d.ts +2 -2
  70. package/dist/turn-initiator.d.ts +2 -2
  71. package/dist/video-generation.d.ts +216 -0
  72. package/dist/video-generation.js +66 -0
  73. package/dist/video-generation.js.map +1 -0
  74. package/dist/workspace-artifacts.d.ts +1 -1
  75. package/dist/workspace-instruction-policies.d.ts +1 -1
  76. package/dist/workspace-learning-policy-schema.d.ts +932 -0
  77. package/dist/workspace-learning-policy.d.ts +161 -0
  78. package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
  79. package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
  80. package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
  81. package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
  82. package/drizzle/0187_generated_image_artifacts.sql +173 -0
  83. package/drizzle/0188_image_generation_retention_failure.sql +25 -0
  84. package/drizzle/0189_retained_session_image_formats.sql +13 -0
  85. package/drizzle/0190_timeline_annotations.sql +31 -0
  86. package/drizzle/0191_editable_artifact_engine.sql +3853 -0
  87. package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
  88. package/drizzle/0193_editable_artifact_authorization.sql +190 -0
  89. package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
  90. package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
  91. package/drizzle/0196_rig_provider_images.sql +152 -0
  92. package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
  93. package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
  94. package/drizzle/0199_workspace_learning_policy.sql +980 -0
  95. package/drizzle/0201_company_profile_authority.sql +849 -0
  96. package/drizzle/0202_document_index_checkpoints.sql +85 -0
  97. package/drizzle/0203_durable_video_generation.sql +353 -0
  98. package/drizzle/0204_video_generation_funding.sql +44 -0
  99. package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
  100. package/drizzle/0206_browser_sessions.sql +646 -0
  101. package/drizzle/0207_browser_identities.sql +379 -0
  102. package/drizzle/0208_attached_browser_devices.sql +165 -0
  103. package/drizzle/0209_computer_sessions.sql +575 -0
  104. package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
  105. package/drizzle/0211_editable_artifact_session_links.sql +58 -0
  106. package/drizzle/0212_slack_installation_bindings.sql +348 -0
  107. package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
  108. package/drizzle/0214_session_activity_commit_gate.sql +262 -0
  109. package/drizzle/0215_capabilities_platform.sql +980 -0
  110. package/drizzle/0216_pack_component_ownership.sql +235 -0
  111. package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
  112. package/package.json +18 -5
  113. package/src/attached-browser-devices.ts +371 -0
  114. package/src/attempt-tool-catalogs.ts +131 -0
  115. package/src/browser-auth.ts +1896 -0
  116. package/src/browser-identities.ts +1168 -0
  117. package/src/browser-sessions.ts +2005 -0
  118. package/src/browser-state-artifacts.ts +59 -0
  119. package/src/capability-components.ts +166 -0
  120. package/src/capability-integrations.ts +1663 -0
  121. package/src/codemode-operations.ts +674 -0
  122. package/src/company-profile-schema.ts +143 -0
  123. package/src/company-profile.ts +968 -0
  124. package/src/computer-sessions.ts +1130 -0
  125. package/src/connection-token-resolver.ts +270 -25
  126. package/src/database.ts +427 -23
  127. package/src/editable-artifact-durable-export.ts +1201 -0
  128. package/src/editable-artifact-materialization.ts +893 -0
  129. package/src/editable-artifacts-schema.ts +879 -0
  130. package/src/editable-artifacts.ts +5404 -0
  131. package/src/generated-images.ts +740 -0
  132. package/src/index.ts +5917 -1182
  133. package/src/insights.ts +160 -13
  134. package/src/integration-bindings.ts +455 -0
  135. package/src/integration-features.ts +859 -0
  136. package/src/interaction-revisions.ts +40 -0
  137. package/src/interaction-schema.ts +1303 -0
  138. package/src/knowledge-source-sync-schema.ts +192 -0
  139. package/src/knowledge-source-sync.ts +1922 -0
  140. package/src/memory-slack-delivery.ts +801 -0
  141. package/src/pack-components.ts +954 -0
  142. package/src/pack-installations.ts +929 -0
  143. package/src/persistence-errors.ts +4 -7
  144. package/src/plugin-packages.ts +1186 -0
  145. package/src/provision-roles.ts +302 -1
  146. package/src/runtime-posture-cli.ts +9 -0
  147. package/src/runtime-posture.ts +508 -5
  148. package/src/schema.ts +5117 -3119
  149. package/src/scoped-knowledge-schema.ts +1 -1
  150. package/src/scoped-knowledge.ts +655 -3
  151. package/src/session-control.ts +8 -5
  152. package/src/session-queue-commands.ts +187 -14
  153. package/src/session-realtime-context.ts +2 -2
  154. package/src/session-realtime-ledger.ts +3 -3
  155. package/src/session-realtime.ts +7 -7
  156. package/src/session-tool-call-settlement.ts +9 -0
  157. package/src/slack-user-link-access.ts +702 -0
  158. package/src/video-generation.ts +1452 -0
  159. package/src/workspace-learning-policy-schema.ts +139 -0
  160. package/src/workspace-learning-policy.ts +595 -0
  161. package/dist/chunk-P6CUHXQZ.js +0 -7248
  162. package/dist/chunk-P6CUHXQZ.js.map +0 -1
  163. package/dist/chunk-VHBFHMPC.js.map +0 -1
@@ -0,0 +1,268 @@
1
+ import { CompanyProfileLearningWrite, type CompanyProfileContent as CompanyProfileContentType, type CompanyProfileDiffResponse, type CompanyProfileHead, type CompanyProfileListResponse, type CompanyProfileMutationResponse, type CompanyProfilePrincipalKind, type CompanyProfileRevision } from "@opengeni/contracts";
2
+ import type { Database } from "./database.js";
3
+ export type CompanyProfileAttemptClaims = {
4
+ accountId: string;
5
+ workspaceId: string;
6
+ sessionId: string;
7
+ turnId: string;
8
+ attemptId: string;
9
+ executionGeneration: number;
10
+ };
11
+ export declare class CompanyProfileConflictError extends Error {
12
+ readonly currentHead: CompanyProfileHead | null;
13
+ readonly name = "CompanyProfileConflictError";
14
+ readonly code = "COMPANY_PROFILE_CONFLICT";
15
+ constructor(currentHead: CompanyProfileHead | null);
16
+ }
17
+ export declare class CompanyProfileOperationReuseError extends Error {
18
+ readonly name = "CompanyProfileOperationReuseError";
19
+ readonly code = "COMPANY_PROFILE_OPERATION_REUSED";
20
+ constructor();
21
+ }
22
+ export declare class CompanyProfileNotFoundError extends Error {
23
+ readonly name = "CompanyProfileNotFoundError";
24
+ constructor(message?: string);
25
+ }
26
+ export declare class CompanyProfileInvalidOperationError extends Error {
27
+ readonly name = "CompanyProfileInvalidOperationError";
28
+ }
29
+ export declare class CompanyProfileSnapshotAuthorityError extends Error {
30
+ readonly name = "CompanyProfileSnapshotAuthorityError";
31
+ }
32
+ export declare function updateCompanyProfile(db: Database, input: {
33
+ operationId?: string;
34
+ accountId: string;
35
+ workspaceId: string;
36
+ profile: CompanyProfileContentType;
37
+ expectedCurrentRevisionId: string | null;
38
+ expectedActivationVersion: number;
39
+ actorSubjectId: string;
40
+ principalKind: CompanyProfilePrincipalKind;
41
+ reason: string;
42
+ }): Promise<CompanyProfileMutationResponse>;
43
+ export declare function activateCompanyProfileRevision(db: Database, input: {
44
+ operationId?: string;
45
+ accountId: string;
46
+ workspaceId: string;
47
+ revisionId: string;
48
+ expectedCurrentRevisionId: string | null;
49
+ expectedActivationVersion: number;
50
+ actorSubjectId: string;
51
+ principalKind: CompanyProfilePrincipalKind;
52
+ reason: string;
53
+ }): Promise<{
54
+ revision: {
55
+ id: string;
56
+ revision: number;
57
+ contentHash: string;
58
+ operationId: string;
59
+ accountId: string;
60
+ intent: "active" | "proposal";
61
+ profile: {
62
+ identity: string | null;
63
+ mission: string | null;
64
+ products: {
65
+ key: string;
66
+ content: string;
67
+ }[];
68
+ customers: {
69
+ key: string;
70
+ content: string;
71
+ }[];
72
+ goals: {
73
+ key: string;
74
+ content: string;
75
+ }[];
76
+ constraints: {
77
+ key: string;
78
+ content: string;
79
+ }[];
80
+ };
81
+ provenance: {
82
+ source: "durable_learning" | "human" | "migration";
83
+ sourceId: string | null;
84
+ };
85
+ supersedesRevisionId: string | null;
86
+ createdBySubjectId: string;
87
+ createdAt: string;
88
+ } | null;
89
+ head: {
90
+ accountId: string;
91
+ revisionId: string;
92
+ revision: number;
93
+ contentHash: string;
94
+ activationVersion: number;
95
+ activatedAt: string;
96
+ } | null;
97
+ event: {
98
+ id: string;
99
+ operationId: string;
100
+ accountId: string;
101
+ type: "activate" | "rollback";
102
+ activationVersion: number;
103
+ oldRevision: {
104
+ id: string;
105
+ revision: number;
106
+ contentHash: string;
107
+ } | null;
108
+ newRevision: {
109
+ id: string;
110
+ revision: number;
111
+ contentHash: string;
112
+ } | null;
113
+ actorSubjectId: string;
114
+ reason: string;
115
+ createdAt: string;
116
+ } | null;
117
+ }>;
118
+ export declare function rollbackCompanyProfileRevision(db: Database, input: {
119
+ operationId?: string;
120
+ accountId: string;
121
+ workspaceId: string;
122
+ targetRevisionId: string;
123
+ expectedCurrentRevisionId: string;
124
+ expectedActivationVersion: number;
125
+ actorSubjectId: string;
126
+ principalKind: CompanyProfilePrincipalKind;
127
+ reason: string;
128
+ }): Promise<{
129
+ revision: {
130
+ id: string;
131
+ revision: number;
132
+ contentHash: string;
133
+ operationId: string;
134
+ accountId: string;
135
+ intent: "active" | "proposal";
136
+ profile: {
137
+ identity: string | null;
138
+ mission: string | null;
139
+ products: {
140
+ key: string;
141
+ content: string;
142
+ }[];
143
+ customers: {
144
+ key: string;
145
+ content: string;
146
+ }[];
147
+ goals: {
148
+ key: string;
149
+ content: string;
150
+ }[];
151
+ constraints: {
152
+ key: string;
153
+ content: string;
154
+ }[];
155
+ };
156
+ provenance: {
157
+ source: "durable_learning" | "human" | "migration";
158
+ sourceId: string | null;
159
+ };
160
+ supersedesRevisionId: string | null;
161
+ createdBySubjectId: string;
162
+ createdAt: string;
163
+ } | null;
164
+ head: {
165
+ accountId: string;
166
+ revisionId: string;
167
+ revision: number;
168
+ contentHash: string;
169
+ activationVersion: number;
170
+ activatedAt: string;
171
+ } | null;
172
+ event: {
173
+ id: string;
174
+ operationId: string;
175
+ accountId: string;
176
+ type: "activate" | "rollback";
177
+ activationVersion: number;
178
+ oldRevision: {
179
+ id: string;
180
+ revision: number;
181
+ contentHash: string;
182
+ } | null;
183
+ newRevision: {
184
+ id: string;
185
+ revision: number;
186
+ contentHash: string;
187
+ } | null;
188
+ actorSubjectId: string;
189
+ reason: string;
190
+ createdAt: string;
191
+ } | null;
192
+ }>;
193
+ export type CompanyProfileLearningWriteResult = {
194
+ outcome: "applied" | "proposed";
195
+ revision: CompanyProfileRevision;
196
+ head: CompanyProfileHead | null;
197
+ effectiveBoundary: "next_accepted_attempt";
198
+ rollbackToken: string | null;
199
+ };
200
+ export declare function writeCompanyProfileLearning(db: Database, rawInput: CompanyProfileLearningWrite): Promise<CompanyProfileLearningWriteResult>;
201
+ export declare function rollbackCompanyProfileLearning(db: Database, input: {
202
+ operationId: string;
203
+ accountId: string;
204
+ workspaceId: string;
205
+ actorSubjectId: string;
206
+ actorKind: "human" | "agent" | "service";
207
+ token: string;
208
+ reason: string;
209
+ }): Promise<CompanyProfileMutationResponse>;
210
+ export declare function listCompanyProfile(db: Database, input: {
211
+ accountId: string;
212
+ workspaceId: string;
213
+ afterRevision?: number;
214
+ limit: number;
215
+ }): Promise<CompanyProfileListResponse>;
216
+ export declare function getCompanyProfileRevision(db: Database, input: {
217
+ accountId: string;
218
+ workspaceId: string;
219
+ revisionId: string;
220
+ }): Promise<CompanyProfileRevision>;
221
+ export declare function diffCompanyProfileRevisions(db: Database, input: {
222
+ accountId: string;
223
+ workspaceId: string;
224
+ fromRevisionId: string;
225
+ toRevisionId: string;
226
+ }): Promise<CompanyProfileDiffResponse>;
227
+ export declare function getOrCreateCompanyProfileSnapshot(db: Database, claims: CompanyProfileAttemptClaims): Promise<{
228
+ id: string;
229
+ accountId: string;
230
+ workspaceId: string;
231
+ sessionId: string;
232
+ turnId: string;
233
+ attemptId: string;
234
+ executionGeneration: number;
235
+ snapshotHash: string;
236
+ createdAt: string;
237
+ profile: {
238
+ id: string;
239
+ revision: number;
240
+ contentHash: string;
241
+ activationVersion: number;
242
+ activatedAt: string;
243
+ provenance: {
244
+ source: "durable_learning" | "human" | "migration";
245
+ sourceIdHash: string | null;
246
+ };
247
+ profile: {
248
+ identity: string | null;
249
+ mission: string | null;
250
+ products: {
251
+ key: string;
252
+ content: string;
253
+ }[];
254
+ customers: {
255
+ key: string;
256
+ content: string;
257
+ }[];
258
+ goals: {
259
+ key: string;
260
+ content: string;
261
+ }[];
262
+ constraints: {
263
+ key: string;
264
+ content: string;
265
+ }[];
266
+ };
267
+ } | null;
268
+ }>;
@@ -0,0 +1,109 @@
1
+ import { ComputerSession, type ComputerSessionCapabilities as ComputerSessionCapabilitiesValue, type ComputerSessionListResponse as ComputerSessionListResponseValue, type ComputerSessionMutationResponse as ComputerSessionMutationResponseValue, type InteractionControllerBinding as InteractionControllerBindingValue, type InteractionError as InteractionErrorValue, type InteractionLifecycleOperationKind, type InteractionLifecycleOperationReceipt as InteractionLifecycleOperationReceiptValue, type InteractionPlacement } from "@opengeni/contracts";
2
+ import { type Database } from "./database.js";
3
+ import * as schema from "./schema.js";
4
+ type InteractionOperationRow = typeof schema.interactionOperations.$inferSelect;
5
+ export declare class ComputerSessionNotFoundError extends Error {
6
+ readonly name = "ComputerSessionNotFoundError";
7
+ }
8
+ export declare class ComputerSessionOperationConflictError extends Error {
9
+ readonly name = "ComputerSessionOperationConflictError";
10
+ }
11
+ export declare class ComputerSessionStateError extends Error {
12
+ readonly name = "ComputerSessionStateError";
13
+ }
14
+ export type PrepareComputerSessionCreateInput = {
15
+ accountId: string;
16
+ workspaceId: string;
17
+ operationId: string;
18
+ associatedSessionId: string;
19
+ actorSubjectId: string;
20
+ name: string;
21
+ placement: InteractionPlacement;
22
+ };
23
+ export type PrepareComputerSessionEndInput = {
24
+ accountId: string;
25
+ workspaceId: string;
26
+ computerSessionId: string;
27
+ operationId: string;
28
+ actorSubjectId: string;
29
+ };
30
+ /** Internal executor view. Plaintext controller credentials are derived from
31
+ * this durable fence and never stored here. */
32
+ export type ComputerSessionControlRecord = {
33
+ session: ComputerSession;
34
+ tokenGeneration: number;
35
+ sourceSessionId: string;
36
+ createOperationId: string;
37
+ operation: null | {
38
+ operationId: string;
39
+ kind: InteractionLifecycleOperationKind;
40
+ state: InteractionOperationRow["state"];
41
+ controllerGeneration: string | null;
42
+ actorSubjectId: string;
43
+ };
44
+ };
45
+ export declare function computerSessionCreateRequestDigest(input: PrepareComputerSessionCreateInput): string;
46
+ export declare function listComputerSessions(db: Database, input: {
47
+ accountId: string;
48
+ workspaceId: string;
49
+ }): Promise<ComputerSessionListResponseValue>;
50
+ export declare function getComputerSession(db: Database, input: {
51
+ accountId: string;
52
+ workspaceId: string;
53
+ computerSessionId: string;
54
+ }): Promise<ComputerSession>;
55
+ export declare function getComputerSessionControlRecord(db: Database, input: {
56
+ accountId: string;
57
+ workspaceId: string;
58
+ computerSessionId: string;
59
+ operationId?: string;
60
+ }): Promise<ComputerSessionControlRecord>;
61
+ export declare function findComputerSessionControlRecordByOperation(db: Database, input: {
62
+ accountId: string;
63
+ workspaceId: string;
64
+ operationId: string;
65
+ }): Promise<ComputerSessionControlRecord | null>;
66
+ export declare function prepareComputerSessionCreate(db: Database, input: PrepareComputerSessionCreateInput): Promise<ComputerSessionMutationResponseValue>;
67
+ export declare function dispatchComputerSessionOperation(db: Database, input: {
68
+ accountId: string;
69
+ workspaceId: string;
70
+ operationId: string;
71
+ computerSessionId: string;
72
+ controllerGeneration: string;
73
+ controller?: InteractionControllerBindingValue;
74
+ }): Promise<InteractionLifecycleOperationReceiptValue>;
75
+ export declare function activateComputerSession(db: Database, input: {
76
+ accountId: string;
77
+ workspaceId: string;
78
+ operationId: string;
79
+ computerSessionId: string;
80
+ controller: InteractionControllerBindingValue;
81
+ platform: "linux" | "macos" | "windows";
82
+ adapter: string;
83
+ seatId: string;
84
+ displayId: string;
85
+ capabilities: ComputerSessionCapabilitiesValue;
86
+ }): Promise<ComputerSessionMutationResponseValue>;
87
+ export declare function failComputerSessionOperation(db: Database, input: {
88
+ accountId: string;
89
+ workspaceId: string;
90
+ operationId: string;
91
+ computerSessionId: string;
92
+ state?: "failed" | "outcome_unknown";
93
+ error: InteractionErrorValue;
94
+ }): Promise<ComputerSessionMutationResponseValue>;
95
+ export declare function prepareComputerSessionEnd(db: Database, input: PrepareComputerSessionEndInput): Promise<ComputerSessionMutationResponseValue>;
96
+ export declare function completeComputerSessionEnd(db: Database, input: {
97
+ accountId: string;
98
+ workspaceId: string;
99
+ operationId: string;
100
+ computerSessionId: string;
101
+ expectedControllerGeneration: string | null;
102
+ }): Promise<ComputerSessionMutationResponseValue>;
103
+ export declare function touchComputerSessionController(db: Database, input: {
104
+ accountId: string;
105
+ workspaceId: string;
106
+ computerSessionId: string;
107
+ controllerGeneration: string;
108
+ }): Promise<boolean>;
109
+ export {};
@@ -1,9 +1,9 @@
1
1
  import { environmentsEncryptionKeyBytes, type McpServerConnectionRef, type Settings } from "@opengeni/config";
2
- import type { ConnectionKind, ConnectionCredentialsPort, ConnectionStatus, McpConnectionResourceScope, McpCredentialAuthNeededReason, McpCredentialsRequest, TurnInitiator, TurnInitiatorContext } from "@opengeni/contracts";
2
+ import type { ConnectionCredentialPlacement, ConnectionKind, ConnectionCredentialsPort, ConnectionStatus, McpConnectionResourceScope, McpCredentialAuthNeededReason, McpCredentialsRequest, TurnInitiator, TurnInitiatorContext } from "@opengeni/contracts";
3
3
  import { type DnsLookup, type FetchLike } from "@opengeni/network";
4
4
  export { isPrivateAddress } from "@opengeni/network";
5
- import { encryptEnvironmentValue } from "./environment-crypto";
6
- import type { Database } from "./database";
5
+ import { encryptEnvironmentValue } from "./environment-crypto.js";
6
+ import type { Database } from "./database.js";
7
7
  export type ConnectionCredentialForBroker = {
8
8
  id: string;
9
9
  accountId: string;
@@ -45,6 +45,8 @@ export type ConnectionStatusGuard = {
45
45
  export type ResolveConnectionCredentialResult = {
46
46
  status: "ok";
47
47
  headers: Record<string, string>;
48
+ /** Present when the credential bundle or embedding host supplied explicit placements. */
49
+ placements?: ConnectionCredentialPlacement[];
48
50
  connectionId: string;
49
51
  /** Exact durable version when the credential came from the local connection store. */
50
52
  connectionVersion?: number;
@@ -70,6 +72,8 @@ export type ResolveConnectionCredentialInput = {
70
72
  connectionRef: McpServerConnectionRef;
71
73
  /** Exact MCP destination whose request would receive the resolved headers. */
72
74
  destinationUrl: string;
75
+ /** Defaults to header-only MCP transport. */
76
+ credentialTarget?: "mcp" | "http_api";
73
77
  forceRefresh?: boolean;
74
78
  };
75
79
  export type HostMcpCredentialResolverContext = {
@@ -83,12 +87,13 @@ export type HostMcpCredentialResolverContext = {
83
87
  initiator: TurnInitiator;
84
88
  initiatorContext: TurnInitiatorContext;
85
89
  surface: McpCredentialsRequest["surface"];
90
+ allowOfficialGmailRestDestination?: boolean;
86
91
  };
87
92
  export declare class HostMcpCredentialScopeError extends Error {
88
93
  constructor(field: "accountId" | "workspaceId" | "sessionId");
89
94
  }
90
95
  export declare class HostMcpCredentialBindingError extends Error {
91
- constructor(field: "provider" | "providerDomain" | "connectionId" | "scopes" | "resource" | "selectedResources" | "destinationUrl");
96
+ constructor(field: "provider" | "providerDomain" | "connectionId" | "scopes" | "resource" | "selectedResources" | "destinationUrl" | "credentialPlacements");
92
97
  }
93
98
  /**
94
99
  * Adapts the public embedding credential port to the runtime's connection
@@ -1,9 +1,18 @@
1
1
  import { type SQL } from "drizzle-orm";
2
2
  import type { PgDatabase, PgTransactionConfig } from "drizzle-orm/pg-core";
3
3
  import postgres from "postgres";
4
- import { type IdempotentPersistenceTransactionOptions } from "./persistence-errors";
5
- import * as schema from "./schema";
4
+ import { type IdempotentPersistenceTransactionOptions } from "./persistence-errors.js";
5
+ import * as schema from "./schema.js";
6
6
  export type Database = PgDatabase<any, typeof schema>;
7
+ declare const sessionActivityDatabaseBrand: unique symbol;
8
+ /**
9
+ * A workspace-scoped transaction whose session activity commit gate is open.
10
+ * Session-row writers accept this narrower handle so new call sites cannot
11
+ * accidentally bypass the once-per-transaction revision finalizer.
12
+ */
13
+ export type SessionActivityDatabase = Database & {
14
+ readonly [sessionActivityDatabaseBrand]: true;
15
+ };
7
16
  export type DbClient = {
8
17
  db: Database;
9
18
  close: () => Promise<void>;
@@ -97,6 +106,29 @@ export declare function rlsStrategyFor(db: Database): RlsStrategy;
97
106
  * an unknown driver result rather than silently treating it as an empty query.
98
107
  */
99
108
  export declare function rawRows<T extends Record<string, unknown>>(executor: Pick<Database, "execute">, query: SQL): Promise<T[]>;
109
+ export type SandboxProviderReadLockIdentity = {
110
+ workspaceId: string;
111
+ sandboxGroupId: string;
112
+ leaseEpoch: number;
113
+ instanceId: string;
114
+ };
115
+ export declare class SandboxProviderReadLockUnavailableError extends Error {
116
+ constructor();
117
+ }
118
+ /**
119
+ * Cross-process exclusive boundary for one exact live provider instance's
120
+ * API-direct read request. Modal accepts concurrent commands from one attached
121
+ * handle, but independent API replicas reconstruct different handles; issuing
122
+ * overlapping command groups through those handles can make an otherwise valid
123
+ * read fail transiently. Keep concurrency inside one batched request while
124
+ * serializing only separate requests that target the same lease identity.
125
+ *
126
+ * The callback intentionally runs while one transaction-pinned DB connection
127
+ * holds the advisory lock. The direct lease holder separately prevents drain,
128
+ * and the abort-aware bounded poll prevents a disconnected HTTP request from
129
+ * occupying the connection indefinitely.
130
+ */
131
+ export declare function withSandboxProviderReadLock<T>(db: Database, identity: SandboxProviderReadLockIdentity, signal: AbortSignal | undefined, fn: () => Promise<T>): Promise<T>;
100
132
  export declare function createDb(databaseUrl: string, options?: CreateDbOptions): DbClient;
101
133
  /**
102
134
  * Register a host's `rlsStrategy`/`userLookup` against an externally-constructed
@@ -119,7 +151,23 @@ export declare function withRlsContext<T>(db: Database, context: RlsContext, fn:
119
151
  */
120
152
  export declare function withDatabaseStatementTimeout<T>(db: Database, timeoutMs: number, fn: (db: Database) => Promise<T>): Promise<T>;
121
153
  export declare function rlsContextForWorkspace(db: Database, workspaceId: string): Promise<RlsContext>;
122
- export declare function withWorkspaceRls<T>(db: Database, workspaceId: string, fn: (db: Database) => Promise<T>): Promise<T>;
154
+ export declare function withWorkspaceRls<T>(db: Database, workspaceId: string, fn: (db: Database) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
155
+ /**
156
+ * Run one workspace transaction with explicit once-per-transaction session
157
+ * activity finalization. Nested callers reuse the outer gate; only its owner
158
+ * finalizes immediately before the enclosing RLS transaction commits.
159
+ */
160
+ export declare function withSessionActivityRlsContext<T>(db: Database, context: RlsContext & {
161
+ workspaceId: string;
162
+ }, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
163
+ export declare function withWorkspaceSessionActivityRls<T>(db: Database, workspaceId: string, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
164
+ /**
165
+ * Open one nested savepoint without losing the gate brand. Drizzle correctly
166
+ * preserves the backend-local gate GUCs, but its structural transaction type
167
+ * cannot express that provenance; keep the single trusted rebrand here.
168
+ */
169
+ export declare function withSessionActivitySavepoint<T>(db: SessionActivityDatabase, fn: (db: SessionActivityDatabase) => Promise<T>): Promise<T>;
170
+ export declare function retrySessionActivityRls<T>(db: Database, workspaceId: string, options: IdempotentPersistenceTransactionOptions, fn: (db: SessionActivityDatabase) => Promise<T>): Promise<T>;
123
171
  export declare function retryWorkspacePersistence<T>(db: Database, workspaceId: string, options: IdempotentPersistenceTransactionOptions, fn: (db: Database) => Promise<T>): Promise<T>;
124
172
  export declare function retryRlsPersistence<T>(db: Database, context: RlsContext, options: IdempotentPersistenceTransactionOptions, fn: (db: Database) => Promise<T>): Promise<T>;
125
173
  /**
@@ -128,6 +176,7 @@ export declare function retryRlsPersistence<T>(db: Database, context: RlsContext
128
176
  * even if a future query accidentally omits its explicit subject predicate.
129
177
  */
130
178
  export declare function withWorkspaceSubjectRls<T>(db: Database, workspaceId: string, subjectId: string, fn: (db: Database) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
179
+ export declare function withWorkspaceSubjectSessionActivityRls<T>(db: Database, workspaceId: string, subjectId: string, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
131
180
  /** Apply and verify actor-private RLS on an already transaction-pinned handle. */
132
181
  export declare function setSubjectRlsContext(db: Database, subjectId: string): Promise<void>;
133
182
  export declare function withWorkspaceUsageLock<T>(db: Database, workspaceId: string, fn: (db: Database) => Promise<T>): Promise<T>;
@@ -0,0 +1,153 @@
1
+ import { type Database } from "./database.js";
2
+ export type PersistedEditableArtifactExportScope = Readonly<{
3
+ accountId: string;
4
+ workspaceId: string;
5
+ }>;
6
+ export type PersistedEditableArtifactExportActor = Readonly<{
7
+ kind: "human";
8
+ subjectId: string;
9
+ replicaId: string;
10
+ }> | Readonly<{
11
+ kind: "agent";
12
+ subjectId: string;
13
+ replicaId: string;
14
+ sessionId: string;
15
+ turnId: string;
16
+ attemptId: string;
17
+ generation: number;
18
+ }> | Readonly<{
19
+ kind: "service";
20
+ subjectId: string;
21
+ replicaId: string;
22
+ service: string;
23
+ }>;
24
+ export type PersistedEditableArtifactExportModality = "spreadsheet" | "document" | "presentation";
25
+ export type PersistedEditableArtifactExportFormat = "xlsx" | "pptx" | "docx" | "pdf" | "png" | "webp";
26
+ export type PersistedEditableArtifactExportProfile = Readonly<{
27
+ modality: PersistedEditableArtifactExportModality;
28
+ format: PersistedEditableArtifactExportFormat;
29
+ codecId: string;
30
+ codecVersion: string;
31
+ kernelVersion: string;
32
+ fontRegistryHash: string;
33
+ policyHash: string;
34
+ normalizedOptions: string;
35
+ }>;
36
+ export type PersistedEditableArtifactPinnedVersion = Readonly<{
37
+ scope: PersistedEditableArtifactExportScope;
38
+ artifactId: string;
39
+ id: string;
40
+ modality: PersistedEditableArtifactExportModality;
41
+ snapshotId: string;
42
+ headSequence: number;
43
+ causalFrontier: readonly Readonly<{
44
+ replicaId: string;
45
+ counter: number;
46
+ }>[] | null;
47
+ nativeRevision: number | null;
48
+ stateHash: string;
49
+ name: string;
50
+ pinned: true;
51
+ createdBySubjectId: string;
52
+ createdAt: string;
53
+ }>;
54
+ export type PersistedEditableArtifactMaterializationResult = Readonly<{
55
+ id: string;
56
+ byteSize: number;
57
+ contentHash: string;
58
+ mimeType: string;
59
+ verifiedAt: string;
60
+ createdAt: string;
61
+ }>;
62
+ export type PersistedEditableArtifactMaterializationJob = Readonly<{
63
+ scope: PersistedEditableArtifactExportScope;
64
+ artifactId: string;
65
+ id: string;
66
+ versionId: string;
67
+ inputSnapshotId: string;
68
+ targetHeadSequence: number;
69
+ stateHash: string;
70
+ format: PersistedEditableArtifactExportFormat;
71
+ state: "pending" | "running" | "succeeded" | "failed";
72
+ attemptCount: number;
73
+ errorCode: string | null;
74
+ createdAt: string;
75
+ startedAt: string | null;
76
+ completedAt: string | null;
77
+ result: PersistedEditableArtifactMaterializationResult | null;
78
+ }>;
79
+ export type PersistedEditableArtifactExportSnapshot = Readonly<{
80
+ modality: PersistedEditableArtifactExportModality;
81
+ snapshotId: string;
82
+ coveredHeadSequence: number;
83
+ stateHash: string;
84
+ coveredCausalFrontier: readonly Readonly<{
85
+ replicaId: string;
86
+ counter: number;
87
+ }>[] | null;
88
+ nativeRevision: number | null;
89
+ }>;
90
+ type ExportContext = Readonly<{
91
+ scope: PersistedEditableArtifactExportScope;
92
+ artifactId: string;
93
+ actor: PersistedEditableArtifactExportActor;
94
+ }>;
95
+ export type PinPersistedEditableArtifactVersionRequest = ExportContext & Readonly<{
96
+ expectedAuthorizationRevision: number;
97
+ authorityKey: string;
98
+ receiptId: string;
99
+ versionId: string;
100
+ idempotencyKey: string;
101
+ requestHash: string;
102
+ name: string;
103
+ snapshot: PersistedEditableArtifactExportSnapshot;
104
+ }>;
105
+ export type EnqueuePersistedEditableArtifactMaterializationRequest = ExportContext & Readonly<{
106
+ expectedAuthorizationRevision: number;
107
+ authorityKey: string;
108
+ receiptId: string;
109
+ jobId: string;
110
+ idempotencyKey: string;
111
+ requestHash: string;
112
+ versionId: string;
113
+ profile: PersistedEditableArtifactExportProfile;
114
+ }>;
115
+ export type PersistedEditableArtifactAuthorizationResult<T> = Readonly<{
116
+ kind: "result";
117
+ value: T;
118
+ }> | Readonly<{
119
+ kind: "authorization_stale";
120
+ }>;
121
+ export declare class EditableArtifactDurableExportPersistenceError extends Error {
122
+ readonly code: "not_found" | "idempotency_conflict" | "snapshot_conflict" | "unsupported_format" | "database_contract_violation";
123
+ constructor(code: "not_found" | "idempotency_conflict" | "snapshot_conflict" | "unsupported_format" | "database_contract_violation", message: string, options?: ErrorOptions);
124
+ }
125
+ /** Tenant-scoped public version/export persistence; global claiming remains separate. */
126
+ export declare class PostgresEditableArtifactDurableExportStore {
127
+ private readonly db;
128
+ constructor(db: Database);
129
+ pinVersion(requestInput: PinPersistedEditableArtifactVersionRequest): Promise<PersistedEditableArtifactAuthorizationResult<Readonly<{
130
+ version: PersistedEditableArtifactPinnedVersion;
131
+ replayed: boolean;
132
+ }>>>;
133
+ enqueueMaterialization(requestInput: EnqueuePersistedEditableArtifactMaterializationRequest): Promise<PersistedEditableArtifactAuthorizationResult<Readonly<{
134
+ job: PersistedEditableArtifactMaterializationJob;
135
+ replayed: boolean;
136
+ }>>>;
137
+ readVersion(input: ExportContext & {
138
+ expectedAuthorizationRevision: number;
139
+ versionId: string;
140
+ }): Promise<PersistedEditableArtifactAuthorizationResult<PersistedEditableArtifactPinnedVersion | null>>;
141
+ readMaterialization(input: ExportContext & {
142
+ expectedAuthorizationRevision: number;
143
+ jobId: string;
144
+ }): Promise<PersistedEditableArtifactAuthorizationResult<PersistedEditableArtifactMaterializationJob | null>>;
145
+ readMaterializationDownload(input: ExportContext & {
146
+ expectedAuthorizationRevision: number;
147
+ jobId: string;
148
+ }): Promise<PersistedEditableArtifactAuthorizationResult<Readonly<{
149
+ job: PersistedEditableArtifactMaterializationJob | null;
150
+ objectReference: string | null;
151
+ }>>>;
152
+ }
153
+ export {};