@opengeni/db 3.7.4 → 4.0.0-canary.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 (113) hide show
  1. package/dist/automations.d.ts +4 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/capability-integrations.d.ts +2 -0
  4. package/dist/{chunk-6DPJA36C.js → chunk-2XEZK4LF.js} +7 -1
  5. package/dist/chunk-2XEZK4LF.js.map +1 -0
  6. package/dist/{chunk-4NAR7FBA.js → chunk-3RI33YQN.js} +67 -1
  7. package/dist/chunk-3RI33YQN.js.map +1 -0
  8. package/dist/{chunk-SZAWDXQC.js → chunk-CJROYHSC.js} +3 -3
  9. package/dist/{chunk-DZCYW2WT.js → chunk-MX6V5F65.js} +2 -2
  10. package/dist/{chunk-S3TDDCS2.js → chunk-N5VXJ4I2.js} +151 -78
  11. package/dist/chunk-N5VXJ4I2.js.map +1 -0
  12. package/dist/{chunk-U4WPPEBH.js → chunk-NLFHMPUB.js} +2 -2
  13. package/dist/{chunk-5NNCGFQY.js → chunk-P6NSEG2S.js} +2 -2
  14. package/dist/{chunk-O56DM5GZ.js → chunk-QM6YOWHZ.js} +624 -57
  15. package/dist/chunk-QM6YOWHZ.js.map +1 -0
  16. package/dist/{chunk-US4IS6IV.js → chunk-RZNOSEMC.js} +2 -2
  17. package/dist/{chunk-F6PBS6WE.js → chunk-UFAMOUWL.js} +2 -2
  18. package/dist/codemode-operations.d.ts +5 -0
  19. package/dist/codex-token-resolver.d.ts +6 -2
  20. package/dist/connection-token-resolver.d.ts +8 -0
  21. package/dist/editable-artifact-durable-export.js +2 -2
  22. package/dist/editable-artifacts.js +3 -3
  23. package/dist/generated-images.d.ts +15 -0
  24. package/dist/index.d.ts +393 -91
  25. package/dist/index.js +9992 -6069
  26. package/dist/index.js.map +1 -1
  27. package/dist/insights.d.ts +9 -0
  28. package/dist/managed-auth-session-sets.js +3 -3
  29. package/dist/managed-user-setup.d.ts +3 -0
  30. package/dist/mcp-oauth.d.ts +80 -0
  31. package/dist/migrate.d.ts +1 -0
  32. package/dist/migrate.js +3 -1
  33. package/dist/model-catalog.d.ts +153 -0
  34. package/dist/model-context-snapshots.d.ts +20 -0
  35. package/dist/new-session-drafts.d.ts +12 -0
  36. package/dist/organization-membership-lifecycle.d.ts +8 -1
  37. package/dist/organization-model-providers.d.ts +101 -0
  38. package/dist/pack-components.d.ts +1 -0
  39. package/dist/pr-review.d.ts +9 -0
  40. package/dist/provision-roles.js +1 -1
  41. package/dist/runtime-posture.d.ts +8 -8
  42. package/dist/schema.d.ts +7708 -5050
  43. package/dist/schema.js +25 -1
  44. package/dist/session-background-commands.d.ts +18 -6
  45. package/dist/session-background-commands.js +15 -9
  46. package/dist/session-control.d.ts +37 -2
  47. package/dist/session-goal-pacing.d.ts +3 -6
  48. package/dist/session-queue-commands.d.ts +17 -0
  49. package/dist/session-tenancy.js +3 -3
  50. package/dist/tool-gateway-approvals.d.ts +31 -0
  51. package/dist/video-generation.js +3 -3
  52. package/dist/workspace-artifacts.d.ts +17 -3
  53. package/dist/xai-subscription.d.ts +8 -0
  54. package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
  55. package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
  56. package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
  57. package/drizzle/0390_organization_model_provider_connections.sql +197 -0
  58. package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
  59. package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
  60. package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
  61. package/drizzle/0394_session_selected_skill_activation.sql +20 -0
  62. package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
  63. package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
  64. package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
  65. package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
  66. package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
  67. package/drizzle/0400_session_attempt_model_context_snapshots.sql +65 -0
  68. package/drizzle/0401_organization_user_setup_token_transport.sql +178 -0
  69. package/drizzle/0402_session_input_wait_and_background_command_results.sql +1023 -0
  70. package/drizzle/0403_codex_unconditional_credential_leasing.sql +181 -0
  71. package/drizzle/0404_mcp_oauth_authorization_server.sql +471 -0
  72. package/drizzle/0405_tool_gateway_approval_capabilities.sql +184 -0
  73. package/drizzle/0406_workspace_html_site_sources.sql +71 -0
  74. package/package.json +6 -6
  75. package/src/automations.ts +9 -1
  76. package/src/capability-integrations.ts +8 -0
  77. package/src/codemode-operations.ts +31 -21
  78. package/src/codex-token-resolver.ts +16 -6
  79. package/src/connection-token-resolver.ts +52 -3
  80. package/src/generated-images.ts +70 -6
  81. package/src/index.ts +3894 -994
  82. package/src/insights-model-bundle.ts +54 -5
  83. package/src/insights.ts +53 -7
  84. package/src/managed-user-setup.ts +14 -3
  85. package/src/mcp-oauth.ts +488 -0
  86. package/src/migrate.ts +9 -1
  87. package/src/model-catalog.ts +682 -0
  88. package/src/model-context-snapshots.ts +151 -0
  89. package/src/new-session-drafts.ts +66 -21
  90. package/src/organization-membership-lifecycle.ts +47 -5
  91. package/src/organization-model-providers.ts +614 -0
  92. package/src/pack-components.ts +15 -2
  93. package/src/pr-review.ts +19 -0
  94. package/src/provision-roles.ts +4 -0
  95. package/src/runtime-posture.ts +64 -0
  96. package/src/schema.ts +666 -61
  97. package/src/session-background-commands.ts +180 -78
  98. package/src/session-control.ts +181 -12
  99. package/src/session-goal-pacing.ts +4 -8
  100. package/src/session-queue-commands.ts +157 -82
  101. package/src/tool-gateway-approvals.ts +168 -0
  102. package/src/workspace-artifacts.ts +633 -178
  103. package/src/xai-subscription.ts +66 -14
  104. package/dist/chunk-4NAR7FBA.js.map +0 -1
  105. package/dist/chunk-6DPJA36C.js.map +0 -1
  106. package/dist/chunk-O56DM5GZ.js.map +0 -1
  107. package/dist/chunk-S3TDDCS2.js.map +0 -1
  108. /package/dist/{chunk-SZAWDXQC.js.map → chunk-CJROYHSC.js.map} +0 -0
  109. /package/dist/{chunk-DZCYW2WT.js.map → chunk-MX6V5F65.js.map} +0 -0
  110. /package/dist/{chunk-U4WPPEBH.js.map → chunk-NLFHMPUB.js.map} +0 -0
  111. /package/dist/{chunk-5NNCGFQY.js.map → chunk-P6NSEG2S.js.map} +0 -0
  112. /package/dist/{chunk-US4IS6IV.js.map → chunk-RZNOSEMC.js.map} +0 -0
  113. /package/dist/{chunk-F6PBS6WE.js.map → chunk-UFAMOUWL.js.map} +0 -0
@@ -114,8 +114,31 @@ export async function prepareImageGenerationOperation(
114
114
  input.operationKey,
115
115
  );
116
116
  if (existing) {
117
- assertImageGenerationOperationMatches(existing, input);
118
- return { operation: existing, created: false };
117
+ assertImageGenerationOperationStableFieldsMatch(existing, input);
118
+ const bindingChanged = existing.providerBindingHash !== input.providerBindingHash;
119
+ const artifactChanged = existing.expectedArtifactId !== input.expectedArtifactId;
120
+ if (!bindingChanged && !artifactChanged) {
121
+ return { operation: existing, created: false };
122
+ }
123
+ if (existing.status !== "prepared" || !bindingChanged || !artifactChanged) {
124
+ throw new Error("Image generation retry does not match the reserved operation");
125
+ }
126
+ const [row] = await tx
127
+ .update(schema.imageGenerationOperations)
128
+ .set({
129
+ providerBindingHash: input.providerBindingHash,
130
+ expectedArtifactId: input.expectedArtifactId,
131
+ updatedAt: new Date(),
132
+ })
133
+ .where(
134
+ and(
135
+ eq(schema.imageGenerationOperations.id, existing.id),
136
+ eq(schema.imageGenerationOperations.status, "prepared"),
137
+ ),
138
+ )
139
+ .returning();
140
+ if (!row) throw new Error("Image generation retry does not match the reserved operation");
141
+ return { operation: mapImageGenerationOperation(row), created: false };
119
142
  }
120
143
  const [row] = await tx
121
144
  .insert(schema.imageGenerationOperations)
@@ -154,11 +177,19 @@ export async function beginImageGenerationOperation(
154
177
  workspaceId: string;
155
178
  operationId: string;
156
179
  operationKey: string;
180
+ providerBindingHash: string;
181
+ expectedArtifactId: string;
157
182
  },
158
183
  ): Promise<{ operation: ImageGenerationOperation; started: boolean }> {
159
184
  let started = false;
160
185
  const operation = await mutateImageGenerationOperation(db, input, async (tx, current) => {
161
186
  if (current.status !== "prepared") return current;
187
+ if (
188
+ current.providerBindingHash !== input.providerBindingHash ||
189
+ current.expectedArtifactId !== input.expectedArtifactId
190
+ ) {
191
+ throw new Error("Image generation operation binding changed before provider dispatch");
192
+ }
162
193
  const now = new Date();
163
194
  const [row] = await tx
164
195
  .update(schema.imageGenerationOperations)
@@ -176,6 +207,41 @@ export async function beginImageGenerationOperation(
176
207
  return { operation, started };
177
208
  }
178
209
 
210
+ /**
211
+ * Return a paid-operation row to its retryable prepared state when a durable
212
+ * provider-dispatch fence rejected before any provider request was admitted.
213
+ * This is intentionally narrower than outcome reconciliation: a caller must
214
+ * prove the provider boundary was never crossed before using this transition.
215
+ */
216
+ export async function resetImageGenerationOperationBeforeProviderDispatch(
217
+ db: Database,
218
+ input: {
219
+ accountId: string;
220
+ workspaceId: string;
221
+ operationId: string;
222
+ operationKey: string;
223
+ error: string;
224
+ },
225
+ ): Promise<ImageGenerationOperation> {
226
+ return await mutateImageGenerationOperation(db, input, async (tx, current) => {
227
+ if (current.status !== "provider_started") return current;
228
+ const [row] = await tx
229
+ .update(schema.imageGenerationOperations)
230
+ .set({
231
+ status: "prepared",
232
+ providerStartedAt: null,
233
+ completedAt: null,
234
+ lastError: input.error.slice(0, 4_096),
235
+ updatedAt: new Date(),
236
+ })
237
+ .where(eq(schema.imageGenerationOperations.id, current.id))
238
+ .returning();
239
+ if (!row)
240
+ throw new Error("Failed to reset image generation operation before provider dispatch");
241
+ return mapImageGenerationOperation(row);
242
+ });
243
+ }
244
+
179
245
  export async function markImageGenerationOperationOutcomeUnknown(
180
246
  db: Database,
181
247
  input: {
@@ -717,7 +783,7 @@ function mapImageGenerationOperation(
717
783
  };
718
784
  }
719
785
 
720
- function assertImageGenerationOperationMatches(
786
+ function assertImageGenerationOperationStableFieldsMatch(
721
787
  operation: ImageGenerationOperation,
722
788
  input: PrepareImageGenerationOperationInput,
723
789
  ): void {
@@ -730,10 +796,8 @@ function assertImageGenerationOperationMatches(
730
796
  operation.operationKey !== input.operationKey ||
731
797
  operation.toolCallId !== input.toolCallId ||
732
798
  operation.providerId !== input.providerId ||
733
- operation.providerBindingHash !== input.providerBindingHash ||
734
799
  operation.modelId !== input.modelId ||
735
- operation.requestDigest !== input.requestDigest ||
736
- operation.expectedArtifactId !== input.expectedArtifactId
800
+ operation.requestDigest !== input.requestDigest
737
801
  ) {
738
802
  throw new Error("Image generation retry does not match the reserved operation");
739
803
  }