@opengeni/db 5.0.1 → 6.0.0

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 (212) hide show
  1. package/dist/automations.d.ts +0 -2
  2. package/dist/canonical-human-identities.d.ts +4 -0
  3. package/dist/canonical-human-identities.js +3 -3
  4. package/dist/capability-components.d.ts +5 -13
  5. package/dist/capability-integrations.d.ts +23 -8
  6. package/dist/capability-reconciliation.d.ts +5 -0
  7. package/dist/capability-reconciliation.js +21 -0
  8. package/dist/capability-reconciliation.js.map +1 -0
  9. package/dist/{chunk-6T2GGYWE.js → chunk-4UJCXBR2.js} +4 -5800
  10. package/dist/chunk-4UJCXBR2.js.map +1 -0
  11. package/dist/{chunk-MWMXWHJD.js → chunk-7JCDSMX2.js} +2 -2
  12. package/dist/chunk-AJA2ZIUW.js +219 -0
  13. package/dist/chunk-AJA2ZIUW.js.map +1 -0
  14. package/dist/chunk-CDAT6EKW.js +247 -0
  15. package/dist/chunk-CDAT6EKW.js.map +1 -0
  16. package/dist/{chunk-DPONPYJD.js → chunk-CJI6G254.js} +70 -18
  17. package/dist/chunk-CJI6G254.js.map +1 -0
  18. package/dist/chunk-G32NVMRJ.js +276 -0
  19. package/dist/chunk-G32NVMRJ.js.map +1 -0
  20. package/dist/chunk-GABXCG3N.js +5811 -0
  21. package/dist/chunk-GABXCG3N.js.map +1 -0
  22. package/dist/{chunk-ERKVSPDX.js → chunk-LVY33EWL.js} +3 -3
  23. package/dist/{chunk-45CP2YKY.js → chunk-MAMBI2HR.js} +9 -3
  24. package/dist/{chunk-45CP2YKY.js.map → chunk-MAMBI2HR.js.map} +1 -1
  25. package/dist/{chunk-F73UKJY6.js → chunk-MN5PZMEK.js} +91 -108
  26. package/dist/chunk-MN5PZMEK.js.map +1 -0
  27. package/dist/chunk-PJI4MUZ7.js +131 -0
  28. package/dist/chunk-PJI4MUZ7.js.map +1 -0
  29. package/dist/{chunk-T6BWIGWJ.js → chunk-RIYHP2WU.js} +2 -2
  30. package/dist/{chunk-7HMK3B45.js → chunk-RL2MUXM3.js} +16 -7
  31. package/dist/chunk-RL2MUXM3.js.map +1 -0
  32. package/dist/{chunk-HQDVI2DB.js → chunk-SYKHLPTK.js} +4 -3
  33. package/dist/{chunk-HQDVI2DB.js.map → chunk-SYKHLPTK.js.map} +1 -1
  34. package/dist/{chunk-T6YLHJLS.js → chunk-XIXVVBW2.js} +198 -51
  35. package/dist/chunk-XIXVVBW2.js.map +1 -0
  36. package/dist/chunk-ZPJ6V2VG.js +156 -0
  37. package/dist/chunk-ZPJ6V2VG.js.map +1 -0
  38. package/dist/codex-capacity-recovery.d.ts +12 -0
  39. package/dist/codex-failure-eligibility.d.ts +9 -0
  40. package/dist/company-profile-schema.d.ts +4 -2
  41. package/dist/connect-attempts.d.ts +15 -0
  42. package/dist/connect-attempts.js +25 -0
  43. package/dist/connect-attempts.js.map +1 -0
  44. package/dist/connection-authority.d.ts +7 -63
  45. package/dist/connection-refresh-lock.d.ts +4 -0
  46. package/dist/connection-token-resolver.d.ts +8 -43
  47. package/dist/database-timing.d.ts +10 -0
  48. package/dist/database.d.ts +4 -0
  49. package/dist/editable-artifact-durable-export.js +2 -2
  50. package/dist/editable-artifacts.d.ts +9 -0
  51. package/dist/editable-artifacts.js +7 -5
  52. package/dist/index.d.ts +447 -78
  53. package/dist/index.js +12705 -12872
  54. package/dist/index.js.map +1 -1
  55. package/dist/insights-usage-bundle.d.ts +3 -0
  56. package/dist/integration-bindings.d.ts +1 -1
  57. package/dist/integration-facets.d.ts +18 -1
  58. package/dist/knowledge-entries-schema.d.ts +2 -0
  59. package/dist/knowledge-entries.d.ts +1 -0
  60. package/dist/knowledge-indexing.d.ts +1 -0
  61. package/dist/live-session-attempt.d.ts +35 -137
  62. package/dist/managed-auth-session-sets.js +3 -3
  63. package/dist/mcp-account-bindings.d.ts +4 -0
  64. package/dist/mcp-oauth.d.ts +11 -0
  65. package/dist/mcp-operations.js +2 -2
  66. package/dist/migrate.js +1 -1
  67. package/dist/organization-integration-policy.d.ts +51 -0
  68. package/dist/organization-integration-policy.js +18 -0
  69. package/dist/organization-integration-policy.js.map +1 -0
  70. package/dist/organization-usage.d.ts +20 -0
  71. package/dist/plugin-packages.d.ts +9 -12
  72. package/dist/pr-review.d.ts +0 -11
  73. package/dist/preference-registry-schema.d.ts +17 -0
  74. package/dist/provision-roles.js +1 -1
  75. package/dist/retained-provider-commands.d.ts +124 -6
  76. package/dist/retained-provider-commands.js +29 -97
  77. package/dist/retained-provider-commands.js.map +1 -1
  78. package/dist/retired-session-create-metadata.d.ts +4 -0
  79. package/dist/runtime-posture.d.ts +7 -5
  80. package/dist/schema.d.ts +876 -656
  81. package/dist/schema.js +5 -7
  82. package/dist/session-admission-block.d.ts +32 -0
  83. package/dist/session-attempt-writers.d.ts +4 -0
  84. package/dist/session-background-commands.js +5 -4
  85. package/dist/session-command-output.js +8 -126
  86. package/dist/session-command-output.js.map +1 -1
  87. package/dist/session-control.d.ts +5 -1
  88. package/dist/session-event-slices.d.ts +10 -0
  89. package/dist/session-event-slices.js +8 -222
  90. package/dist/session-event-slices.js.map +1 -1
  91. package/dist/session-file-attachments.d.ts +28 -0
  92. package/dist/session-goal-reports.d.ts +43 -0
  93. package/dist/session-mcp-approval.d.ts +4 -0
  94. package/dist/session-mcp-credential-rotation.js +5 -4
  95. package/dist/session-mcp-credential-rotation.js.map +1 -1
  96. package/dist/session-message-search.d.ts +22 -0
  97. package/dist/session-queue-commands.d.ts +2 -6
  98. package/dist/session-retry.d.ts +36 -0
  99. package/dist/session-tenancy.js +3 -3
  100. package/dist/skill-source-release-impact.d.ts +18 -0
  101. package/dist/skill-source-release.d.ts +9 -0
  102. package/dist/skills.d.ts +7 -1
  103. package/dist/user-resource-authority.d.ts +0 -8
  104. package/dist/video-generation.js +3 -3
  105. package/dist/workspace-tool-defaults.js +5 -4
  106. package/dist/workspace-tool-defaults.js.map +1 -1
  107. package/drizzle/0468_knowledge_relationship_projection.sql +30 -0
  108. package/drizzle/0469_knowledge_source_discovery.sql +85 -0
  109. package/drizzle/0470_organization_integration_policy.sql +151 -0
  110. package/drizzle/0471_usage_events_account_recent_index.sql +4 -0
  111. package/drizzle/0472_usage_events_workspace_recent_index.sql +4 -0
  112. package/drizzle/0473_organization_usage_analytical_capability.sql +237 -0
  113. package/drizzle/0474_goal_report_requirements.sql +156 -0
  114. package/drizzle/0475_session_event_history_statistics.sql +15 -0
  115. package/drizzle/0476_session_event_history_policy_planning.sql +29 -0
  116. package/drizzle/0477_managed_sign_in_methods.sql +303 -0
  117. package/drizzle/0478_sender_owned_connections.sql +2772 -0
  118. package/drizzle/0479_connection_create_idempotency.sql +16 -0
  119. package/drizzle/0480_private_session_organization_key_administration.sql +154 -0
  120. package/drizzle/0481_personal_connection_visibility_cleanup.sql +45 -0
  121. package/drizzle/0482_remove_packs.sql +417 -0
  122. package/drizzle/0483_preclaim_admission_block.sql +85 -0
  123. package/drizzle/0484_insights_usage_projection.sql +211 -0
  124. package/drizzle/0485_inherited_mcp_approval_policies.sql +6 -0
  125. package/drizzle/0486_reasoning_configuration_message_forks.sql +35 -0
  126. package/drizzle/0487_skill_catalog_message_forks.sql +26 -0
  127. package/drizzle/0488_permanent_skill_removal.sql +207 -0
  128. package/drizzle/0489_modal_command_byte_offsets.sql +17 -0
  129. package/drizzle/0490_periodic_capture_attempt_cadence.sql +6 -0
  130. package/drizzle/0491_warm_capture_holder_reclamation.sql +57 -0
  131. package/drizzle/0492_codex_accepted_source_authority.sql +249 -0
  132. package/drizzle/0493_stopping_command_error_containment.sql +58 -0
  133. package/drizzle/0494_mcp_account_bindings.sql +334 -0
  134. package/drizzle/0495_consented_sandbox_recovery.sql +220 -0
  135. package/drizzle/0496_supervised_command_settlement.sql +386 -0
  136. package/drizzle/0497_modal_inventory_owner_read_capability.sql +112 -0
  137. package/drizzle/0498_enrollment_membership_fence.sql +87 -0
  138. package/drizzle/0499_session_attachment_access.sql +224 -0
  139. package/drizzle/0500_session_execution_epoch.sql +37 -0
  140. package/drizzle/0501_session_sharing_execution.sql +591 -0
  141. package/drizzle/0502_active_message_boundary_forks.sql +30 -0
  142. package/package.json +17 -5
  143. package/src/automations.ts +17 -73
  144. package/src/canonical-human-identities.ts +17 -5
  145. package/src/capability-components.ts +7 -24
  146. package/src/capability-integrations.ts +301 -21
  147. package/src/capability-reconciliation.ts +19 -0
  148. package/src/codex-capacity-recovery.ts +47 -0
  149. package/src/codex-failure-eligibility.ts +93 -0
  150. package/src/connect-attempts.ts +49 -18
  151. package/src/connection-authority.ts +12 -158
  152. package/src/connection-refresh-lock.ts +22 -0
  153. package/src/connection-token-resolver.ts +58 -530
  154. package/src/database-timing.ts +43 -0
  155. package/src/database.ts +61 -26
  156. package/src/editable-artifacts.ts +1 -1
  157. package/src/index.ts +3578 -1273
  158. package/src/insights-model-bundle.ts +19 -7
  159. package/src/insights-usage-bundle.ts +16 -19
  160. package/src/integration-bindings.ts +2 -7
  161. package/src/integration-facets.ts +73 -6
  162. package/src/knowledge-entries.ts +8 -1
  163. package/src/live-session-attempt.ts +0 -22
  164. package/src/mcp-account-bindings.ts +12 -0
  165. package/src/mcp-oauth.ts +26 -0
  166. package/src/organization-integration-policy.ts +235 -0
  167. package/src/organization-usage.ts +83 -0
  168. package/src/plugin-packages.ts +226 -42
  169. package/src/pr-review.ts +7 -69
  170. package/src/preference-registry-schema.ts +1 -0
  171. package/src/provision-roles.ts +50 -37
  172. package/src/retained-provider-commands.ts +286 -9
  173. package/src/retired-session-create-metadata.ts +16 -0
  174. package/src/runtime-posture.ts +217 -13
  175. package/src/schema.ts +104 -120
  176. package/src/session-admission-block.ts +29 -0
  177. package/src/session-attempt-writers.ts +48 -0
  178. package/src/session-control.ts +21 -5
  179. package/src/session-event-slices.ts +76 -26
  180. package/src/session-file-attachments.ts +66 -0
  181. package/src/session-goal-reports.ts +255 -0
  182. package/src/session-mcp-approval.ts +30 -0
  183. package/src/session-message-search.ts +348 -0
  184. package/src/session-queue-commands.ts +60 -36
  185. package/src/session-retry.ts +319 -0
  186. package/src/skill-config-migration.ts +11 -2
  187. package/src/skill-source-release-impact.ts +33 -0
  188. package/src/skill-source-release.ts +67 -26
  189. package/src/skills.ts +44 -6
  190. package/src/user-resource-authority.ts +0 -56
  191. package/dist/chunk-6T2GGYWE.js.map +0 -1
  192. package/dist/chunk-7HMK3B45.js.map +0 -1
  193. package/dist/chunk-DPONPYJD.js.map +0 -1
  194. package/dist/chunk-F73UKJY6.js.map +0 -1
  195. package/dist/chunk-T6YLHJLS.js.map +0 -1
  196. package/dist/host-mcp-binding-match.d.ts +0 -5
  197. package/dist/host-mcp-bindings.d.ts +0 -79
  198. package/dist/host-mcp-resolvers.d.ts +0 -47
  199. package/dist/host-mcp-task-authority.d.ts +0 -43
  200. package/dist/host-selection-identity.d.ts +0 -6
  201. package/dist/pack-components.d.ts +0 -83
  202. package/dist/pack-installations.d.ts +0 -86
  203. package/src/host-mcp-binding-match.ts +0 -34
  204. package/src/host-mcp-bindings.ts +0 -777
  205. package/src/host-mcp-resolvers.ts +0 -266
  206. package/src/host-mcp-task-authority.ts +0 -384
  207. package/src/host-selection-identity.ts +0 -29
  208. package/src/pack-components.ts +0 -980
  209. package/src/pack-installations.ts +0 -950
  210. /package/dist/{chunk-MWMXWHJD.js.map → chunk-7JCDSMX2.js.map} +0 -0
  211. /package/dist/{chunk-ERKVSPDX.js.map → chunk-LVY33EWL.js.map} +0 -0
  212. /package/dist/{chunk-T6BWIGWJ.js.map → chunk-RIYHP2WU.js.map} +0 -0
@@ -0,0 +1,131 @@
1
+ import {
2
+ lockSessionEventWriteRows
3
+ } from "./chunk-GABXCG3N.js";
4
+ import {
5
+ withSessionActivityRlsContext
6
+ } from "./chunk-CJI6G254.js";
7
+ import {
8
+ sandboxRetainedProcesses,
9
+ sessionBackgroundCommands,
10
+ sessionEvents,
11
+ sessions
12
+ } from "./chunk-MN5PZMEK.js";
13
+ import {
14
+ fromPostgresLosslessJson,
15
+ withLosslessContentWriteVersion
16
+ } from "./chunk-S2TZ3F4L.js";
17
+
18
+ // src/session-command-output.ts
19
+ import { and, eq } from "drizzle-orm";
20
+ async function appendSessionCommandOutput(db, input) {
21
+ if (!input.chunkId || input.chunkId.length > 200)
22
+ throw new Error("Invalid command output chunk ID");
23
+ if (!input.chunk) return [];
24
+ return await withSessionActivityRlsContext(db, input, async (tx) => {
25
+ const events = [];
26
+ const locks = await lockSessionEventWriteRows(tx, {
27
+ workspaceId: input.workspaceId,
28
+ controlLock: "share",
29
+ sessionIds: [input.sessionId]
30
+ });
31
+ const session = locks.sessions[0];
32
+ if (!session || session.accountId !== input.accountId)
33
+ throw new Error("Command output session not found");
34
+ const [command] = await tx.select({ id: sessionBackgroundCommands.id }).from(sessionBackgroundCommands).where(
35
+ and(
36
+ eq(sessionBackgroundCommands.accountId, input.accountId),
37
+ eq(sessionBackgroundCommands.workspaceId, input.workspaceId),
38
+ eq(sessionBackgroundCommands.sessionId, input.sessionId),
39
+ eq(sessionBackgroundCommands.id, input.commandId)
40
+ )
41
+ ).limit(1);
42
+ if (!command) {
43
+ const [process] = await tx.select({ id: sandboxRetainedProcesses.id }).from(sandboxRetainedProcesses).where(
44
+ and(
45
+ eq(sandboxRetainedProcesses.accountId, input.accountId),
46
+ eq(sandboxRetainedProcesses.workspaceId, input.workspaceId),
47
+ eq(sandboxRetainedProcesses.sessionId, input.sessionId),
48
+ eq(sandboxRetainedProcesses.id, input.commandId)
49
+ )
50
+ ).limit(1);
51
+ if (!process) throw new Error("Command output has no retained command identity");
52
+ }
53
+ let sequence = session.lastSequence;
54
+ let part = 0;
55
+ for (let offset = 0; offset < input.chunk.length; ) {
56
+ let end = Math.min(offset + 16384, input.chunk.length);
57
+ if (end < input.chunk.length && /[\uD800-\uDBFF]/u.test(input.chunk[end - 1])) end -= 1;
58
+ const clientEventId = `command-output:${input.commandId}:${input.chunkId}:${input.stream}:${part++}`;
59
+ const chunk = input.chunk.slice(offset, end);
60
+ offset = end;
61
+ const [existing] = await tx.select({
62
+ payload: sessionEvents.payload,
63
+ version: sessionEvents.payloadCodecVersion
64
+ }).from(sessionEvents).where(
65
+ and(
66
+ eq(sessionEvents.workspaceId, input.workspaceId),
67
+ eq(sessionEvents.sessionId, input.sessionId),
68
+ eq(sessionEvents.clientEventId, clientEventId)
69
+ )
70
+ ).limit(1);
71
+ if (existing) {
72
+ const payload = fromPostgresLosslessJson(existing.payload, existing.version);
73
+ if (payload.chunk !== chunk || payload.commandId !== input.commandId || payload.stream !== input.stream) {
74
+ throw new Error("Command output retry changed the captured chunk");
75
+ }
76
+ continue;
77
+ }
78
+ const [inserted] = await tx.insert(sessionEvents).values(
79
+ withLosslessContentWriteVersion(
80
+ {
81
+ accountId: input.accountId,
82
+ workspaceId: input.workspaceId,
83
+ sessionId: input.sessionId,
84
+ sequence: ++sequence,
85
+ type: "sandbox.command.output.delta",
86
+ clientEventId,
87
+ payload: {
88
+ commandId: input.commandId,
89
+ stream: input.stream,
90
+ streamFidelity: input.streamFidelity ?? "separate",
91
+ chunk
92
+ }
93
+ },
94
+ "payload",
95
+ "payloadCodecVersion"
96
+ )
97
+ ).returning();
98
+ if (inserted)
99
+ events.push({
100
+ id: inserted.id,
101
+ workspaceId: input.workspaceId,
102
+ sessionId: input.sessionId,
103
+ sequence: inserted.sequence,
104
+ type: "sandbox.command.output.delta",
105
+ payload: fromPostgresLosslessJson(inserted.payload, inserted.payloadCodecVersion),
106
+ occurredAt: inserted.occurredAt.toISOString(),
107
+ clientEventId,
108
+ turnId: null,
109
+ turnGeneration: null,
110
+ turnAttemptId: null,
111
+ turnAssociation: null,
112
+ duplicateOfEventId: null,
113
+ duplicateReason: null
114
+ });
115
+ }
116
+ if (sequence !== session.lastSequence) {
117
+ await tx.update(sessions).set({ lastSequence: sequence }).where(
118
+ and(
119
+ eq(sessions.workspaceId, input.workspaceId),
120
+ eq(sessions.id, input.sessionId)
121
+ )
122
+ );
123
+ }
124
+ return events;
125
+ });
126
+ }
127
+
128
+ export {
129
+ appendSessionCommandOutput
130
+ };
131
+ //# sourceMappingURL=chunk-PJI4MUZ7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-command-output.ts"],"sourcesContent":["import { and, eq } from \"drizzle-orm\";\nimport type { SessionEvent } from \"@opengeni/contracts\";\nimport type { Database } from \"./database\";\nimport { withSessionActivityRlsContext } from \"./database\";\nimport { lockSessionEventWriteRows } from \"./session-control\";\nimport { fromPostgresLosslessJson, withLosslessContentWriteVersion } from \"./lossless-json\";\nimport * as schema from \"./schema\";\n\nexport type SessionCommandOutputInput = {\n accountId: string;\n workspaceId: string;\n sessionId: string;\n commandId: string;\n /** Stable identity of this consumed provider chunk, reused on persistence retry. */\n chunkId: string;\n stream: \"stdout\" | \"stderr\";\n streamFidelity?: \"separate\" | \"merged\";\n chunk: string;\n};\n\n/** Capture is independent of terminal observation and remains valid after the\n * launching attempt ends. Only an exact retained process/background command in\n * this session is eligible; this helper never creates command authority. */\nexport async function appendSessionCommandOutput(\n db: Database,\n input: SessionCommandOutputInput,\n): Promise<SessionEvent[]> {\n if (!input.chunkId || input.chunkId.length > 200)\n throw new Error(\"Invalid command output chunk ID\");\n if (!input.chunk) return [];\n return await withSessionActivityRlsContext(db, input, async (tx) => {\n const events: SessionEvent[] = [];\n const locks = await lockSessionEventWriteRows(tx, {\n workspaceId: input.workspaceId,\n controlLock: \"share\",\n sessionIds: [input.sessionId],\n });\n const session = locks.sessions[0];\n if (!session || session.accountId !== input.accountId)\n throw new Error(\"Command output session not found\");\n const [command] = await tx\n .select({ id: schema.sessionBackgroundCommands.id })\n .from(schema.sessionBackgroundCommands)\n .where(\n and(\n eq(schema.sessionBackgroundCommands.accountId, input.accountId),\n eq(schema.sessionBackgroundCommands.workspaceId, input.workspaceId),\n eq(schema.sessionBackgroundCommands.sessionId, input.sessionId),\n eq(schema.sessionBackgroundCommands.id, input.commandId),\n ),\n )\n .limit(1);\n if (!command) {\n const [process] = await tx\n .select({ id: schema.sandboxRetainedProcesses.id })\n .from(schema.sandboxRetainedProcesses)\n .where(\n and(\n eq(schema.sandboxRetainedProcesses.accountId, input.accountId),\n eq(schema.sandboxRetainedProcesses.workspaceId, input.workspaceId),\n eq(schema.sandboxRetainedProcesses.sessionId, input.sessionId),\n eq(schema.sandboxRetainedProcesses.id, input.commandId),\n ),\n )\n .limit(1);\n if (!process) throw new Error(\"Command output has no retained command identity\");\n }\n let sequence = session.lastSequence;\n let part = 0;\n for (let offset = 0; offset < input.chunk.length;) {\n let end = Math.min(offset + 16_384, input.chunk.length);\n if (end < input.chunk.length && /[\\uD800-\\uDBFF]/u.test(input.chunk[end - 1]!)) end -= 1;\n const clientEventId = `command-output:${input.commandId}:${input.chunkId}:${input.stream}:${part++}`;\n const chunk = input.chunk.slice(offset, end);\n offset = end;\n const [existing] = await tx\n .select({\n payload: schema.sessionEvents.payload,\n version: schema.sessionEvents.payloadCodecVersion,\n })\n .from(schema.sessionEvents)\n .where(\n and(\n eq(schema.sessionEvents.workspaceId, input.workspaceId),\n eq(schema.sessionEvents.sessionId, input.sessionId),\n eq(schema.sessionEvents.clientEventId, clientEventId),\n ),\n )\n .limit(1);\n if (existing) {\n const payload = fromPostgresLosslessJson(existing.payload, existing.version) as Record<\n string,\n unknown\n >;\n if (\n payload.chunk !== chunk ||\n payload.commandId !== input.commandId ||\n payload.stream !== input.stream\n ) {\n throw new Error(\"Command output retry changed the captured chunk\");\n }\n continue;\n }\n const [inserted] = await tx\n .insert(schema.sessionEvents)\n .values(\n withLosslessContentWriteVersion(\n {\n accountId: input.accountId,\n workspaceId: input.workspaceId,\n sessionId: input.sessionId,\n sequence: ++sequence,\n type: \"sandbox.command.output.delta\",\n clientEventId,\n payload: {\n commandId: input.commandId,\n stream: input.stream,\n streamFidelity: input.streamFidelity ?? \"separate\",\n chunk,\n },\n },\n \"payload\",\n \"payloadCodecVersion\",\n ),\n )\n .returning();\n if (inserted)\n events.push({\n id: inserted.id,\n workspaceId: input.workspaceId,\n sessionId: input.sessionId,\n sequence: inserted.sequence,\n type: \"sandbox.command.output.delta\",\n payload: fromPostgresLosslessJson(inserted.payload, inserted.payloadCodecVersion),\n occurredAt: inserted.occurredAt.toISOString(),\n clientEventId,\n turnId: null,\n turnGeneration: null,\n turnAttemptId: null,\n turnAssociation: null,\n duplicateOfEventId: null,\n duplicateReason: null,\n });\n }\n if (sequence !== session.lastSequence) {\n await tx\n .update(schema.sessions)\n .set({ lastSequence: sequence })\n .where(\n and(\n eq(schema.sessions.workspaceId, input.workspaceId),\n eq(schema.sessions.id, input.sessionId),\n ),\n );\n }\n return events;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,KAAK,UAAU;AAuBxB,eAAsB,2BACpB,IACA,OACyB;AACzB,MAAI,CAAC,MAAM,WAAW,MAAM,QAAQ,SAAS;AAC3C,UAAM,IAAI,MAAM,iCAAiC;AACnD,MAAI,CAAC,MAAM,MAAO,QAAO,CAAC;AAC1B,SAAO,MAAM,8BAA8B,IAAI,OAAO,OAAO,OAAO;AAClE,UAAM,SAAyB,CAAC;AAChC,UAAM,QAAQ,MAAM,0BAA0B,IAAI;AAAA,MAChD,aAAa,MAAM;AAAA,MACnB,aAAa;AAAA,MACb,YAAY,CAAC,MAAM,SAAS;AAAA,IAC9B,CAAC;AACD,UAAM,UAAU,MAAM,SAAS,CAAC;AAChC,QAAI,CAAC,WAAW,QAAQ,cAAc,MAAM;AAC1C,YAAM,IAAI,MAAM,kCAAkC;AACpD,UAAM,CAAC,OAAO,IAAI,MAAM,GACrB,OAAO,EAAE,IAAW,0BAA0B,GAAG,CAAC,EAClD,KAAY,yBAAyB,EACrC;AAAA,MACC;AAAA,QACE,GAAU,0BAA0B,WAAW,MAAM,SAAS;AAAA,QAC9D,GAAU,0BAA0B,aAAa,MAAM,WAAW;AAAA,QAClE,GAAU,0BAA0B,WAAW,MAAM,SAAS;AAAA,QAC9D,GAAU,0BAA0B,IAAI,MAAM,SAAS;AAAA,MACzD;AAAA,IACF,EACC,MA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7
7
  withWorkspaceSubjectSessionActivityRls
8
- } from "./chunk-DPONPYJD.js";
8
+ } from "./chunk-CJI6G254.js";
9
9
 
10
10
  // src/session-tenancy.ts
11
11
  import { createHash } from "crypto";
@@ -502,4 +502,4 @@ export {
502
502
  forkSessionContent,
503
503
  replayAppliedSessionFork
504
504
  };
505
- //# sourceMappingURL=chunk-T6BWIGWJ.js.map
505
+ //# sourceMappingURL=chunk-RIYHP2WU.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-DPONPYJD.js";
4
+ } from "./chunk-CJI6G254.js";
5
5
 
6
6
  // src/canonical-human-identities.ts
7
7
  import { createHash } from "crypto";
@@ -159,6 +159,7 @@ async function synchronizeCanonicalHumanLoginBindings(db, authUserId) {
159
159
  const existing = projection.loginBindings.find(
160
160
  (binding) => binding.providerId === account.providerId && binding.providerAccountId === account.providerAccountId
161
161
  );
162
+ if (existing && existing.status !== "active") break;
162
163
  if (existing?.status === "active") {
163
164
  authority = {
164
165
  identityId: projection.activeIdentity.id,
@@ -244,16 +245,24 @@ async function getCanonicalHumanIdentityProjection(db, authUserId) {
244
245
  }
245
246
  async function applyCanonicalHumanIdentityOperation(db, input) {
246
247
  try {
247
- if (input.actorFence) {
248
+ if (input.actorFence || input.verifiedRecovery) {
248
249
  return await db.transaction(async (tx) => {
249
250
  const txDb = tx;
250
- await rawRows(
251
- txDb,
252
- sql`select managed_auth_actor_mutation_fence(
251
+ if (input.actorFence)
252
+ await rawRows(
253
+ txDb,
254
+ sql`select managed_auth_actor_mutation_fence(
253
255
  ${input.actorFence.authorityHash}, ${input.actorFence.actorEpoch}::bigint,
254
256
  ${input.actorFence.requestId}::uuid
255
257
  )`
256
- );
258
+ );
259
+ if (input.verifiedRecovery)
260
+ await rawRows(
261
+ txDb,
262
+ sql`select assert_managed_sign_in_recovery(
263
+ ${input.authUserId},${input.verifiedRecovery.authSessionId},${input.bindingId}::uuid,
264
+ ${JSON.stringify({ operationId: input.operationId, expectedIdentityRevision: input.expectedIdentityRevision, requestDigest: input.verifiedRecovery.requestDigest })}::jsonb)`
265
+ );
257
266
  return await applyCanonicalHumanIdentityOperationInner(txDb, input);
258
267
  });
259
268
  }
@@ -309,4 +318,4 @@ export {
309
318
  getCanonicalHumanIdentityProjection,
310
319
  applyCanonicalHumanIdentityOperation
311
320
  };
312
- //# sourceMappingURL=chunk-7HMK3B45.js.map
321
+ //# sourceMappingURL=chunk-RL2MUXM3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/canonical-human-identities.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n CanonicalHumanIdentityMutationResponse,\n CanonicalHumanIdentityProjection,\n type CanonicalHumanIdentityMutationOutcome,\n type CanonicalHumanIdentityMutationResponse as CanonicalHumanIdentityMutationResponseType,\n type CanonicalHumanIdentityProjection as CanonicalHumanIdentityProjectionType,\n} from \"@opengeni/contracts/canonical-human-identities\";\nimport { sql } from \"drizzle-orm\";\nimport type { Database } from \"./database\";\nimport { rawRows } from \"./database\";\nimport { nestedPostgresSqlState } from \"./persistence-errors\";\n\nexport type CanonicalHumanSessionAuthority = {\n identityId: string;\n identityRevision: number;\n authRevision: number;\n identityStatus: \"active\" | \"recovery_required\" | \"disputed\" | \"disabled\";\n};\n\nexport type CanonicalHumanExactLoginBinding = {\n id: string;\n identityId: string;\n revision: number;\n status: \"active\" | \"recovery_pending\" | \"stale\" | \"disputed\" | \"revoked\";\n};\n\nexport async function getCanonicalHumanExactLoginBindingForAuthUser(\n db: Database,\n input: { authUserId: string; providerId: string },\n): Promise<CanonicalHumanExactLoginBinding> {\n const [row] = await rawRows<{\n result:\n | (Omit<CanonicalHumanExactLoginBinding, \"revision\"> & { revision: number | string })\n | null;\n }>(\n db,\n sql`\n select get_canonical_human_exact_login_binding(\n ${input.authUserId}, ${input.providerId}\n ) as result\n `,\n );\n if (!row?.result) {\n throw new CanonicalHumanIdentityAuthorityError(\n \"Authentication did not prove exactly one canonical login binding\",\n );\n }\n return { ...row.result, revision: Number(row.result.revision) };\n}\n\nexport class CanonicalHumanIdentityConflictError extends Error {\n readonly name = \"CanonicalHumanIdentityConflictError\";\n readonly code = \"CANONICAL_HUMAN_IDENTITY_CONFLICT\";\n\n constructor() {\n super(\"The canonical human identity changed in another request\");\n }\n}\n\nexport class CanonicalHumanIdentityOperationReuseError extends Error {\n readonly name = \"CanonicalHumanIdentityOperationReuseError\";\n readonly code = \"CANONICAL_HUMAN_IDENTITY_OPERATION_REUSED\";\n\n constructor() {\n super(\"The canonical human identity operation id was already used for another request\");\n }\n}\n\nexport class CanonicalHumanIdentityMutationInFlightError extends Error {\n readonly name = \"CanonicalHumanIdentityMutationInFlightError\";\n readonly code = \"CANONICAL_HUMAN_IDENTITY_MUTATION_IN_FLIGHT\";\n\n constructor() {\n super(\"Another request is still using this browser actor\");\n }\n}\n\nexport class CanonicalHumanIdentityNotFoundError extends Error {\n readonly name = \"CanonicalHumanIdentityNotFoundError\";\n\n constructor(message = \"Canonical human identity was not found\") {\n super(message);\n }\n}\n\nexport class CanonicalHumanIdentityAuthorityError extends Error {\n readonly name = \"CanonicalHumanIdentityAuthorityError\";\n}\n\nfunction deterministicOperationId(seed: string): string {\n const bytes = createHash(\"sha256\").update(seed, \"utf8\").digest().subarray(0, 16);\n bytes[6] = (bytes[6]! & 0x0f) | 0x50;\n bytes[8] = (bytes[8]! & 0x3f) | 0x80;\n const hex = bytes.toString(\"hex\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nfunction projectionValue(value: unknown): unknown {\n if (typeof value === \"string\") return JSON.parse(value);\n return value;\n}\n\nfunction mapSqlError(error: unknown): never {\n const state = nestedPostgresSqlState(error);\n if (state === \"40001\") throw new CanonicalHumanIdentityConflictError();\n if (state === \"23505\") throw new CanonicalHumanIdentityOperationReuseError();\n if (state === \"55P03\") throw new CanonicalHumanIdentityMutationInFlightError();\n if (state === \"P0002\") throw new CanonicalHumanIdentityNotFoundError();\n if (state === \"42501\") {\n throw new CanonicalHumanIdentityAuthorityError(\n error instanceof Error ? error.message : \"Canonical human identity authority denied\",\n );\n }\n throw error;\n}\n\nexport async function ensureCanonicalHumanIdentity(\n db: Database,\n input: { authUserId: string; displayName: string },\n): Promise<CanonicalHumanSessionAuthority> {\n try {\n const [row] = await rawRows<{\n identityId: string;\n identityRevision: number | string;\n authRevision: number | string;\n identityStatus: CanonicalHumanSessionAuthority[\"identityStatus\"];\n }>(\n db,\n sql`\n select\n identity_id as \"identityId\",\n identity_revision as \"identityRevision\",\n auth_revision as \"authRevision\",\n identity_status as \"identityStatus\"\n from ensure_canonical_human_identity(${input.authUserId}, ${input.displayName})\n `,\n );\n if (!row) throw new CanonicalHumanIdentityNotFoundError();\n return {\n identityId: row.identityId,\n identityRevision: Number(row.identityRevision),\n authRevision: Number(row.authRevision),\n identityStatus: row.identityStatus,\n };\n } catch (error) {\n mapSqlError(error);\n }\n}\n\nexport async function ensureCanonicalHumanIdentityForAuthUser(\n db: Database,\n authUserId: string,\n): Promise<CanonicalHumanSessionAuthority> {\n try {\n const existing = await getCanonicalHumanIdentityProjection(db, authUserId);\n return {\n identityId: existing.activeIdentity.id,\n identityRevision: existing.activeIdentity.identityRevision,\n authRevision: existing.activeIdentity.authRevision,\n identityStatus: existing.activeIdentity.status,\n };\n } catch (error) {\n if (!(error instanceof CanonicalHumanIdentityNotFoundError)) throw error;\n }\n const [user] = await rawRows<{ displayName: string }>(\n db,\n sql`\n select coalesce(nullif(btrim(name), ''), email) as \"displayName\"\n from auth_users\n where id = ${authUserId}\n limit 1\n `,\n );\n if (!user) throw new CanonicalHumanIdentityNotFoundError(\"Authentication user was not found\");\n return await ensureCanonicalHumanIdentity(db, {\n authUserId,\n displayName: user.displayName,\n });\n}\n\nexport async function synchronizeCanonicalHumanLoginBindings(\n db: Database,\n authUserId: string,\n): Promise<CanonicalHumanSessionAuthority> {\n let authority = await ensureCanonicalHumanIdentityForAuthUser(db, authUserId);\n const accounts = await rawRows<{\n id: string;\n providerId: string;\n providerAccountId: string;\n }>(\n db,\n sql`\n select\n id,\n lower(provider_id) as \"providerId\",\n account_id as \"providerAccountId\"\n from auth_identities\n where user_id = ${authUserId}\n order by created_at, id\n `,\n );\n\n for (const account of accounts) {\n for (let attempt = 0; attempt < 4; attempt += 1) {\n const projection = await getCanonicalHumanIdentityProjection(db, authUserId);\n if (projection.activeIdentity.status !== \"active\") {\n return {\n identityId: projection.activeIdentity.id,\n identityRevision: projection.activeIdentity.identityRevision,\n authRevision: projection.activeIdentity.authRevision,\n identityStatus: projection.activeIdentity.status,\n };\n }\n const existing = projection.loginBindings.find(\n (binding) =>\n binding.providerId === account.providerId &&\n binding.providerAccountId === account.providerAccountId,\n );\n // A revoked/recovery binding is not an invitation to relink. Reconnection\n // belongs to the explicit OAuth-proof transaction, never a session hook.\n if (existing && existing.status !== \"active\") break;\n if (existing?.status === \"active\") {\n authority = {\n identityId: projection.activeIdentity.id,\n identityRevision: projection.activeIdentity.identityRevision,\n authRevision: projection.activeIdentity.authRevision,\n identityStatus: projection.activeIdentity.status,\n };\n break;\n }\n try {\n const result = await applyCanonicalHumanIdentityOperation(db, {\n operationId: deterministicOperationId(\n `canonical-human-account-link\\n${account.id}\\n${projection.activeIdentity.identityRevision}`,\n ),\n authUserId,\n expectedIdentityRevision: projection.activeIdentity.identityRevision,\n operationType: \"link\",\n providerId: account.providerId,\n providerAccountId: account.providerAccountId,\n reason: \"Synchronize verified authentication account\",\n });\n authority = {\n identityId: result.identity.activeIdentity.id,\n identityRevision: result.identity.activeIdentity.identityRevision,\n authRevision: result.identity.activeIdentity.authRevision,\n identityStatus: result.identity.activeIdentity.status,\n };\n break;\n } catch (error) {\n if (error instanceof CanonicalHumanIdentityConflictError && attempt < 3) continue;\n if (error instanceof CanonicalHumanIdentityAuthorityError) {\n const currentProjection = await getCanonicalHumanIdentityProjection(db, authUserId);\n if (currentProjection.activeIdentity.status !== \"active\") {\n return {\n identityId: currentProjection.activeIdentity.id,\n identityRevision: currentProjection.activeIdentity.identityRevision,\n authRevision: currentProjection.activeIdentity.authRevision,\n identityStatus: currentProjection.activeIdentity.status,\n };\n }\n }\n throw error;\n }\n }\n }\n return authority;\n}\n\nexport async function validateCanonicalHumanSession(\n db: Database,\n input: { authSessionId: string; authUserId: string; allowRecovery?: boolean },\n): Promise<boolean> {\n try {\n const [row] = await rawRows<{ valid: boolean }>(\n db,\n sql`\n select validate_canonical_human_session(\n ${input.authSessionId},\n ${input.authUserId},\n ${input.allowRecovery ?? false}\n ) as valid\n `,\n );\n return row?.valid === true;\n } catch (error) {\n mapSqlError(error);\n }\n}\n\nexport async function getCanonicalHumanIdentityProjection(\n db: Database,\n authUserId: string,\n): Promise<CanonicalHumanIdentityProjectionType> {\n try {\n const [row] = await rawRows<{ projection: unknown }>(\n db,\n sql`\n select get_canonical_human_identity_projection(${authUserId}) as projection\n `,\n );\n if (row?.projection === null || row?.projection === undefined) {\n throw new CanonicalHumanIdentityNotFoundError();\n }\n return CanonicalHumanIdentityProjection.parse(projectionValue(row.projection));\n } catch (error) {\n if (error instanceof CanonicalHumanIdentityNotFoundError) throw error;\n mapSqlError(error);\n }\n}\n\nexport type ApplyCanonicalHumanIdentityOperationInput = {\n operationId: string;\n authUserId: string;\n expectedIdentityRevision: number;\n operationType: \"link\" | \"unlink\" | \"begin_recovery\" | \"recover\";\n bindingId?: string | null;\n providerId?: string | null;\n providerAccountId?: string | null;\n reason: string;\n verifiedRecovery?: { authSessionId: string; requestDigest: string };\n actorFence?: {\n authorityHash: string;\n actorEpoch: string;\n requestId: string;\n };\n};\n\nexport async function applyCanonicalHumanIdentityOperation(\n db: Database,\n input: ApplyCanonicalHumanIdentityOperationInput,\n): Promise<CanonicalHumanIdentityMutationResponseType> {\n try {\n if (input.actorFence || input.verifiedRecovery) {\n return await db.transaction(async (tx) => {\n const txDb = tx as unknown as Database;\n if (input.actorFence)\n await rawRows(\n txDb,\n sql`select managed_auth_actor_mutation_fence(\n ${input.actorFence!.authorityHash}, ${input.actorFence!.actorEpoch}::bigint,\n ${input.actorFence!.requestId}::uuid\n )`,\n );\n if (input.verifiedRecovery)\n await rawRows(\n txDb,\n sql`select assert_managed_sign_in_recovery(\n ${input.authUserId},${input.verifiedRecovery.authSessionId},${input.bindingId}::uuid,\n ${JSON.stringify({ operationId: input.operationId, expectedIdentityRevision: input.expectedIdentityRevision, requestDigest: input.verifiedRecovery.requestDigest })}::jsonb)`,\n );\n return await applyCanonicalHumanIdentityOperationInner(txDb, input);\n });\n }\n return await applyCanonicalHumanIdentityOperationInner(db, input);\n } catch (error) {\n if (\n error instanceof CanonicalHumanIdentityConflictError ||\n error instanceof CanonicalHumanIdentityOperationReuseError ||\n error instanceof CanonicalHumanIdentityMutationInFlightError ||\n error instanceof CanonicalHumanIdentityNotFoundError ||\n error instanceof CanonicalHumanIdentityAuthorityError\n ) {\n throw error;\n }\n mapSqlError(error);\n }\n}\n\nasync function applyCanonicalHumanIdentityOperationInner(\n db: Database,\n input: ApplyCanonicalHumanIdentityOperationInput,\n): Promise<CanonicalHumanIdentityMutationResponseType> {\n const [row] = await rawRows<{\n outcome: CanonicalHumanIdentityMutationOutcome;\n identityId: string;\n identityRevision: number | string;\n authRevision: number | string;\n }>(\n db,\n sql`\n select\n outcome,\n identity_id as \"identityId\",\n identity_revision as \"identityRevision\",\n auth_revision as \"authRevision\"\n from apply_canonical_human_identity_operation(\n ${input.operationId},\n ${input.authUserId},\n ${input.expectedIdentityRevision},\n ${input.operationType},\n ${input.bindingId ?? null},\n ${input.providerId ?? null},\n ${input.providerAccountId ?? null},\n ${input.reason}\n )\n `,\n );\n if (!row) throw new CanonicalHumanIdentityNotFoundError();\n const identity = await getCanonicalHumanIdentityProjection(db, input.authUserId);\n return CanonicalHumanIdentityMutationResponse.parse({\n outcome: row.outcome,\n operationId: input.operationId,\n identity,\n });\n}\n"],"mappings":";;;;;;AA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ACqD;AACrD,QAAM,CAAC,GAAG,IAAI,MAAM;AAAA,IAMlB;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAOQ,MAAM,WAAW;AAAA,YACjB,MAAM,UAAU;AAAA,YAChB,MAAM,wBAAwB;AAAA,YAC9B,MAAM,aAAa;AAAA,YACnB,MAAM,aAAa,IAAI;AAAA,YACvB,MAAM,cAAc,IAAI;AAAA,YACxB,MAAM,qBAAqB,IAAI;AAAA,YAC/B,MAAM,MAAM;AAAA;AAAA;AAAA,EAGtB;AACA,MAAI,CAAC,IAAK,OAAM,IAAI,oCAAoC;AACxD,QAAM,WAAW,MAAM,oCAAoC,IAAI,MAAM,UAAU;AAC/E,SAAO,uCAAuC,MAAM;AAAA,IAClD,SAAS,IAAI;AAAA,IACb,aAAa,MAAM;AAAA,IACnB;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-DPONPYJD.js";
4
+ } from "./chunk-CJI6G254.js";
5
5
 
6
6
  // src/editable-artifacts.ts
7
7
  import { createHash } from "crypto";
@@ -3538,6 +3538,7 @@ export {
3538
3538
  EDITABLE_ARTIFACT_KERNEL_TAIL_MAX_BYTES,
3539
3539
  PostgresEditableArtifactLiveTicketStore,
3540
3540
  PostgresEditableArtifactStore,
3541
- PostgresEditableArtifactLiveReadStore
3541
+ PostgresEditableArtifactLiveReadStore,
3542
+ transactionallyAuthorizeEditableArtifactActor
3542
3543
  };
3543
- //# sourceMappingURL=chunk-HQDVI2DB.js.map
3544
+ //# sourceMappingURL=chunk-SYKHLPTK.js.map