@opengeni/db 3.7.4 → 3.8.2-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 (77) hide show
  1. package/dist/automations.d.ts +4 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/{chunk-O56DM5GZ.js → chunk-53A2PEHT.js} +328 -31
  4. package/dist/chunk-53A2PEHT.js.map +1 -0
  5. package/dist/{chunk-SZAWDXQC.js → chunk-5S4BQAHX.js} +3 -3
  6. package/dist/{chunk-S3TDDCS2.js → chunk-CITYUGMW.js} +3 -3
  7. package/dist/{chunk-4NAR7FBA.js → chunk-F5YOZEYQ.js} +49 -1
  8. package/dist/chunk-F5YOZEYQ.js.map +1 -0
  9. package/dist/{chunk-F6PBS6WE.js → chunk-HZV7O6JR.js} +2 -2
  10. package/dist/{chunk-5NNCGFQY.js → chunk-RLQVPOVR.js} +2 -2
  11. package/dist/{chunk-DZCYW2WT.js → chunk-UKOGHUGC.js} +2 -2
  12. package/dist/{chunk-US4IS6IV.js → chunk-X6TO5HII.js} +2 -2
  13. package/dist/{chunk-U4WPPEBH.js → chunk-Y53WEFYB.js} +2 -2
  14. package/dist/connection-token-resolver.d.ts +4 -0
  15. package/dist/editable-artifact-durable-export.js +2 -2
  16. package/dist/editable-artifacts.js +3 -3
  17. package/dist/index.d.ts +164 -14
  18. package/dist/index.js +7327 -5442
  19. package/dist/index.js.map +1 -1
  20. package/dist/insights.d.ts +9 -0
  21. package/dist/managed-auth-session-sets.js +3 -3
  22. package/dist/model-catalog.d.ts +153 -0
  23. package/dist/new-session-drafts.d.ts +12 -0
  24. package/dist/organization-membership-lifecycle.d.ts +8 -1
  25. package/dist/organization-model-providers.d.ts +101 -0
  26. package/dist/pack-components.d.ts +1 -0
  27. package/dist/pr-review.d.ts +9 -0
  28. package/dist/provision-roles.js +1 -1
  29. package/dist/runtime-posture.d.ts +7 -7
  30. package/dist/schema.d.ts +989 -2
  31. package/dist/schema.js +11 -1
  32. package/dist/session-background-commands.js +3 -3
  33. package/dist/session-control.d.ts +35 -0
  34. package/dist/session-queue-commands.d.ts +17 -0
  35. package/dist/session-tenancy.js +3 -3
  36. package/dist/video-generation.js +3 -3
  37. package/dist/xai-subscription.d.ts +8 -0
  38. package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
  39. package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
  40. package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
  41. package/drizzle/0390_organization_model_provider_connections.sql +197 -0
  42. package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
  43. package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
  44. package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
  45. package/drizzle/0394_session_selected_skill_activation.sql +20 -0
  46. package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
  47. package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
  48. package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
  49. package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
  50. package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
  51. package/package.json +6 -6
  52. package/src/automations.ts +9 -1
  53. package/src/connection-token-resolver.ts +12 -0
  54. package/src/index.ts +1551 -272
  55. package/src/insights-model-bundle.ts +54 -5
  56. package/src/insights.ts +53 -7
  57. package/src/model-catalog.ts +682 -0
  58. package/src/new-session-drafts.ts +66 -21
  59. package/src/organization-membership-lifecycle.ts +47 -5
  60. package/src/organization-model-providers.ts +614 -0
  61. package/src/pack-components.ts +15 -2
  62. package/src/pr-review.ts +19 -0
  63. package/src/provision-roles.ts +2 -0
  64. package/src/runtime-posture.ts +48 -0
  65. package/src/schema.ts +348 -32
  66. package/src/session-control.ts +170 -0
  67. package/src/session-queue-commands.ts +157 -82
  68. package/src/xai-subscription.ts +66 -14
  69. package/dist/chunk-4NAR7FBA.js.map +0 -1
  70. package/dist/chunk-O56DM5GZ.js.map +0 -1
  71. /package/dist/{chunk-SZAWDXQC.js.map → chunk-5S4BQAHX.js.map} +0 -0
  72. /package/dist/{chunk-S3TDDCS2.js.map → chunk-CITYUGMW.js.map} +0 -0
  73. /package/dist/{chunk-F6PBS6WE.js.map → chunk-HZV7O6JR.js.map} +0 -0
  74. /package/dist/{chunk-5NNCGFQY.js.map → chunk-RLQVPOVR.js.map} +0 -0
  75. /package/dist/{chunk-DZCYW2WT.js.map → chunk-UKOGHUGC.js.map} +0 -0
  76. /package/dist/{chunk-US4IS6IV.js.map → chunk-X6TO5HII.js.map} +0 -0
  77. /package/dist/{chunk-U4WPPEBH.js.map → chunk-Y53WEFYB.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/db",
3
- "version": "3.7.4",
3
+ "version": "3.8.2-canary.0",
4
4
  "description": "OpenGeni persistence: Drizzle schema, RLS-scoped query layer, the SQL migration runner, and role provisioning.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -78,11 +78,11 @@
78
78
  "prepublishOnly": "bash ../../scripts/prepublish-guard"
79
79
  },
80
80
  "dependencies": {
81
- "@opengeni/codemode": "^0.4.22",
82
- "@opengeni/codex": "^0.2.20",
83
- "@opengeni/config": "^0.22.5",
84
- "@opengeni/contracts": "^2.9.2",
85
- "@opengeni/network": "^0.2.3",
81
+ "@opengeni/codemode": "^0.4.25-canary.0",
82
+ "@opengeni/codex": "^0.2.20-canary.2",
83
+ "@opengeni/config": "^0.23.2-canary.0",
84
+ "@opengeni/contracts": "^2.11.1-canary.0",
85
+ "@opengeni/network": "^0.2.3-canary.7",
86
86
  "drizzle-orm": "^0.45.2",
87
87
  "postgres": "^3.4.7"
88
88
  },
@@ -223,6 +223,8 @@ export async function createAutomationTrigger(
223
223
  createdBySubjectId: string;
224
224
  request: CreateAutomationTriggerRequest;
225
225
  adapterId: string;
226
+ /** Trusted database-only admission seam. Throwing rolls creation back. */
227
+ beforeCreateCommit?: (tx: Database) => Promise<void>;
226
228
  },
227
229
  ): Promise<AutomationTrigger> {
228
230
  return await withWorkspaceRls(
@@ -289,6 +291,7 @@ export async function createAutomationTrigger(
289
291
  throw new Error("Automation Pack trigger must use its frozen manifest template");
290
292
  }
291
293
  }
294
+ await input.beforeCreateCommit?.(tx);
292
295
  const [head] = await tx
293
296
  .insert(schema.automationTriggers)
294
297
  .values({
@@ -438,6 +441,8 @@ export async function updateAutomationTrigger(
438
441
  triggerId: string;
439
442
  subjectId: string;
440
443
  request: UpdateAutomationTriggerRequest;
444
+ /** Trusted database-only admission seam. Throwing rolls the revision back. */
445
+ beforeUpdateCommit?: (tx: Database) => Promise<void>;
441
446
  },
442
447
  ): Promise<AutomationTrigger | null> {
443
448
  return await withWorkspaceRls(
@@ -478,6 +483,7 @@ export async function updateAutomationTrigger(
478
483
  "Pack-owned automation triggers must be managed through their Pack setup API",
479
484
  );
480
485
  }
486
+ await input.beforeUpdateCommit?.(tx);
481
487
  const revisionNumber = existing.head.currentRevision + 1;
482
488
  const [head] = await tx
483
489
  .update(schema.automationTriggers)
@@ -696,7 +702,9 @@ export async function claimAutomationRun(
696
702
  .for("update")
697
703
  .limit(1);
698
704
  if (!row) return null;
699
- if (row.status === "dispatched" || row.status === "skipped") return mapRunExecution(row);
705
+ if (row.status === "dispatched" || row.status === "skipped" || row.status === "failed") {
706
+ return mapRunExecution(row);
707
+ }
700
708
  const [updated] = await tx
701
709
  .update(schema.automationRuns)
702
710
  .set({
@@ -114,6 +114,8 @@ export type ResolveConnectionCredentialResult =
114
114
  | {
115
115
  status: "ok";
116
116
  headers: Record<string, string>;
117
+ /** Credential authority is owned by the embedding host, not the native connection store. */
118
+ authoritySource?: "host";
117
119
  /** Present when the credential bundle or embedding host supplied explicit placements. */
118
120
  placements?: ConnectionCredentialPlacement[];
119
121
  connectionId: string;
@@ -133,6 +135,8 @@ export type ResolveConnectionCredentialResult =
133
135
  status: "auth_needed";
134
136
  reason: McpCredentialAuthNeededReason;
135
137
  providerDomain: string;
138
+ /** Credential authority is owned by the embedding host, not the native connection store. */
139
+ authoritySource?: "host";
136
140
  provider?: string;
137
141
  connectionId?: string;
138
142
  scopes?: string[];
@@ -270,6 +274,9 @@ export function buildHostConnectionTokenResolver(
270
274
  serverId: input.serverId,
271
275
  connectionRef: {
272
276
  providerDomain: input.connectionRef.providerDomain,
277
+ ...(input.connectionRef.authoritySource
278
+ ? { authoritySource: input.connectionRef.authoritySource }
279
+ : {}),
273
280
  ...(input.connectionRef.provider ? { provider: input.connectionRef.provider } : {}),
274
281
  ...(input.connectionRef.connectionId
275
282
  ? { connectionId: input.connectionRef.connectionId }
@@ -303,6 +310,7 @@ export function buildHostConnectionTokenResolver(
303
310
  status: "auth_needed",
304
311
  reason: result.reason,
305
312
  providerDomain: result.providerDomain,
313
+ authoritySource: "host",
306
314
  ...(result.provider ? { provider: result.provider } : {}),
307
315
  ...(result.connectionId ? { connectionId: result.connectionId } : {}),
308
316
  ...(result.scopes ? { scopes: [...result.scopes] } : {}),
@@ -339,6 +347,7 @@ export function buildHostConnectionTokenResolver(
339
347
  return {
340
348
  status: "ok",
341
349
  headers,
350
+ authoritySource: "host",
342
351
  ...(explicitPlacements ? { placements: explicitPlacements } : {}),
343
352
  connectionId: result.connectionId,
344
353
  ...(expiresAt !== undefined ? { expiresAt } : {}),
@@ -835,6 +844,9 @@ export function buildConnectionTokenResolver(
835
844
  let credentialWorkspaceId = input.workspaceId;
836
845
  let expectedAuthorityGeneration: number | undefined;
837
846
  let connectionUseAttribution: ConnectionUseAttribution | undefined;
847
+ if (ref.authoritySource === "host") {
848
+ return authNeeded(ref, "unsupported_auth", ref.connectionId);
849
+ }
838
850
  // Repository-scoped provider bindings require a broker that can prove the
839
851
  // selected-resource boundary. The generic standalone credential store has
840
852
  // no provider-specific containment adapter, so it must fail closed instead