@opengeni/db 0.14.3 → 0.17.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 (67) hide show
  1. package/dist/{chunk-Y5WZZVQK.js → chunk-SK7YYHBI.js} +5 -2
  2. package/dist/chunk-SK7YYHBI.js.map +1 -0
  3. package/dist/{chunk-ELMUCYZF.js → chunk-T6RSJT6C.js} +202 -43
  4. package/dist/chunk-T6RSJT6C.js.map +1 -0
  5. package/dist/chunk-TLAC622R.js +4990 -0
  6. package/dist/chunk-TLAC622R.js.map +1 -0
  7. package/dist/codex-token-resolver.d.ts +64 -0
  8. package/dist/connection-token-resolver.d.ts +90 -0
  9. package/dist/environment-crypto.d.ts +11 -0
  10. package/dist/event-payload-sanitizer.d.ts +32 -0
  11. package/dist/index.d.ts +6374 -10
  12. package/dist/index.js +8075 -2776
  13. package/dist/index.js.map +1 -1
  14. package/dist/insights.d.ts +157 -0
  15. package/dist/memory-domain.d.ts +44 -0
  16. package/dist/migrate.d.ts +5 -7
  17. package/dist/migrate.js +1 -1
  18. package/dist/new-session-drafts.d.ts +49 -0
  19. package/dist/persistence-errors.d.ts +69 -0
  20. package/dist/preference-registry-schema.d.ts +1147 -0
  21. package/dist/preference-registry.d.ts +878 -0
  22. package/dist/provision-roles.d.ts +4 -6489
  23. package/dist/provision-roles.js +1 -1
  24. package/dist/role-relationships.d.ts +35 -0
  25. package/dist/runtime-posture-cli.d.ts +1 -0
  26. package/dist/runtime-posture.d.ts +103 -0
  27. package/dist/schema.d.ts +25330 -3
  28. package/dist/schema.js +31 -1
  29. package/dist/session-control.d.ts +331 -0
  30. package/dist/session-queue-commands.d.ts +186 -0
  31. package/dist/session-tool-call-settlement.d.ts +32 -0
  32. package/dist/turn-initiator.d.ts +28 -0
  33. package/dist/workspace-artifacts.d.ts +62 -0
  34. package/dist/workspace-instruction-policies-schema.d.ts +735 -0
  35. package/dist/workspace-instruction-policies.d.ts +64 -0
  36. package/drizzle/0136_unified_session_tool_policy.sql +1 -1
  37. package/drizzle/0137_preference_registry.sql +1347 -0
  38. package/drizzle/0138_sandbox_checkpoint_artifacts_and_deadlines.sql +1074 -0
  39. package/drizzle/0139_codex_provider_artifact_invalidations.sql +51 -0
  40. package/drizzle/0140_sandbox_restore_and_reaper_fences.sql +276 -0
  41. package/drizzle/0142_sandbox_archive_capture_gate.sql +80 -0
  42. package/drizzle/0143_session_codex_compaction_mode.sql +20 -0
  43. package/drizzle/0144_sandbox_viewer_force_drain_gate.sql +95 -0
  44. package/drizzle/0145_model_call_facts.sql +96 -0
  45. package/drizzle/0146_slack_bot_delete_idempotency.sql +105 -0
  46. package/drizzle/0147_draft_latency_mode.sql +12 -0
  47. package/drizzle/0148_session_turn_latency_mode.sql +12 -0
  48. package/drizzle/0149_workspace_artifacts.sql +348 -0
  49. package/drizzle/0150_slack_task_interactions.sql +344 -0
  50. package/package.json +6 -6
  51. package/src/index.ts +5766 -275
  52. package/src/insights.ts +837 -0
  53. package/src/migrate.ts +9 -1
  54. package/src/new-session-drafts.ts +4 -0
  55. package/src/preference-registry-schema.ts +170 -0
  56. package/src/preference-registry.ts +1220 -0
  57. package/src/provision-roles.ts +95 -22
  58. package/src/role-relationships.ts +132 -0
  59. package/src/runtime-posture.ts +47 -27
  60. package/src/schema.ts +875 -19
  61. package/src/session-queue-commands.ts +39 -6
  62. package/src/workspace-artifacts.ts +751 -0
  63. package/dist/chunk-DW24CKCT.js +0 -4046
  64. package/dist/chunk-DW24CKCT.js.map +0 -1
  65. package/dist/chunk-ELMUCYZF.js.map +0 -1
  66. package/dist/chunk-Y5WZZVQK.js.map +0 -1
  67. package/dist/schema-DhkRhcuQ.d.ts +0 -22666
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  metadataWithTurnExecutionPolicyV1,
3
3
  mergeResourceRefs,
4
+ ResourceRef,
5
+ resourceMountPath,
6
+ stableJson,
4
7
  turnExecutionPolicyAuditMetadata,
8
+ type LatencyMode,
5
9
  type ReasoningEffort,
6
- type ResourceRef,
7
10
  type TurnExecutionPolicyV1,
8
11
  } from "@opengeni/contracts";
9
12
  import { and, asc, eq, inArray, sql } from "drizzle-orm";
@@ -367,6 +370,27 @@ function draftIsNonEmpty(draft: ComposerDraftRow): boolean {
367
370
  return draft.text.length > 0 || draft.resources.length > 0 || draft.sourceTurnId !== null;
368
371
  }
369
372
 
373
+ function withCanonicalResourceMountPaths(resources: readonly unknown[]): unknown[] {
374
+ const seen = new Set<string>();
375
+ const canonical: unknown[] = [];
376
+ for (const value of resources) {
377
+ const parsed = ResourceRef.safeParse(value);
378
+ if (!parsed.success) {
379
+ canonical.push(value);
380
+ continue;
381
+ }
382
+ const normalized = {
383
+ ...(value as Record<string, unknown>),
384
+ mountPath: resourceMountPath(parsed.data),
385
+ };
386
+ const key = stableJson(normalized);
387
+ if (seen.has(key)) continue;
388
+ seen.add(key);
389
+ canonical.push(normalized);
390
+ }
391
+ return canonical;
392
+ }
393
+
370
394
  export async function getComposerDraftInTransaction(
371
395
  db: Database,
372
396
  input: {
@@ -403,6 +427,7 @@ export async function saveComposerDraftInTransaction(
403
427
  resources: ResourceRef[];
404
428
  model: string;
405
429
  reasoningEffort: ReasoningEffort;
430
+ latencyMode?: LatencyMode;
406
431
  },
407
432
  ): Promise<ComposerDraftRow> {
408
433
  await lockWorkspaceInferenceControl(db, input.workspaceId, "share");
@@ -430,11 +455,12 @@ export async function saveComposerDraftInTransaction(
430
455
  subjectId: input.subjectId,
431
456
  revision,
432
457
  text: input.text,
433
- resources: input.resources,
458
+ resources: withCanonicalResourceMountPaths(input.resources),
434
459
  tools: [],
435
460
  toolsProvided: false,
436
461
  model: input.model,
437
462
  reasoningEffort: input.reasoningEffort,
463
+ latencyMode: input.latencyMode ?? "standard",
438
464
  // A queue edit is still the same accepted work item. Preserve its frozen
439
465
  // initiator through arbitrary draft saves; only a genuinely new compose or
440
466
  // Steer captures the submitting actor.
@@ -802,11 +828,12 @@ export async function editQueuedTurnInTransaction(
802
828
  subjectId: input.subjectId,
803
829
  revision: nextDraftRevision,
804
830
  text: turn.prompt,
805
- resources: turn.resources,
831
+ resources: withCanonicalResourceMountPaths(turn.resources),
806
832
  tools: [],
807
833
  toolsProvided: false,
808
834
  model: turn.model,
809
835
  reasoningEffort: turn.reasoningEffort,
836
+ latencyMode: turn.latencyMode,
810
837
  sourceTurnId: turn.id,
811
838
  sourceTurnVersion: turn.version,
812
839
  updatedAt: new Date(),
@@ -1122,6 +1149,7 @@ export async function submitHumanPromptInTransaction(
1122
1149
  resources: ResourceRef[];
1123
1150
  model?: string | null;
1124
1151
  reasoningEffort?: ReasoningEffort | null;
1152
+ latencyMode?: LatencyMode | null;
1125
1153
  reasoningEffortFallback: ReasoningEffort;
1126
1154
  /** Trusted API/core admission snapshot. Omitted only by legacy low-level callers. */
1127
1155
  turnExecutionPolicy?: TurnExecutionPolicyV1;
@@ -1149,9 +1177,10 @@ export async function submitHumanPromptInTransaction(
1149
1177
  expectedDraftRevision: input.expectedDraftRevision ?? null,
1150
1178
  text: input.text,
1151
1179
  turnInstructions: input.turnInstructions ?? null,
1152
- resources: input.resources,
1180
+ resources: withCanonicalResourceMountPaths(input.resources),
1153
1181
  model: input.model ?? null,
1154
1182
  reasoningEffort: input.reasoningEffort ?? null,
1183
+ latencyMode: input.latencyMode ?? null,
1155
1184
  source: input.source,
1156
1185
  mcpCredentialUpdates: input.mcpCredentialUpdates ?? [],
1157
1186
  ...(input.actor.type === "service"
@@ -1256,15 +1285,17 @@ export async function submitHumanPromptInTransaction(
1256
1285
  draft &&
1257
1286
  canonicalSessionCommandHash({
1258
1287
  text: draft.text,
1259
- resources: draft.resources,
1288
+ resources: withCanonicalResourceMountPaths(draft.resources),
1260
1289
  model: draft.model,
1261
1290
  reasoningEffort: draft.reasoningEffort,
1291
+ latencyMode: draft.latencyMode,
1262
1292
  }) !==
1263
1293
  canonicalSessionCommandHash({
1264
1294
  text: input.text,
1265
- resources: input.resources,
1295
+ resources: withCanonicalResourceMountPaths(input.resources),
1266
1296
  model: input.model ?? session.model,
1267
1297
  reasoningEffort: input.reasoningEffort ?? input.reasoningEffortFallback,
1298
+ latencyMode: input.turnExecutionPolicy?.latencyMode ?? input.latencyMode ?? "standard",
1268
1299
  })
1269
1300
  ) {
1270
1301
  throw new QueueCommandConflictError(
@@ -1384,6 +1415,7 @@ export async function submitHumanPromptInTransaction(
1384
1415
  ...(input.resources.length ? { resources: input.resources } : {}),
1385
1416
  ...(input.model ? { model: input.model } : {}),
1386
1417
  ...(input.reasoningEffort ? { reasoningEffort: input.reasoningEffort } : {}),
1418
+ ...(input.latencyMode ? { latencyMode: input.latencyMode } : {}),
1387
1419
  delivery: input.delivery,
1388
1420
  initiator: frozenInitiator.initiator,
1389
1421
  }),
@@ -1413,6 +1445,7 @@ export async function submitHumanPromptInTransaction(
1413
1445
  toolsProvided: false,
1414
1446
  model: input.model ?? session.model,
1415
1447
  reasoningEffort: input.reasoningEffort ?? input.reasoningEffortFallback,
1448
+ latencyMode: input.turnExecutionPolicy?.latencyMode ?? input.latencyMode ?? "standard",
1416
1449
  sandboxBackend: session.sandboxBackend,
1417
1450
  metadata: input.turnExecutionPolicy
1418
1451
  ? metadataWithTurnExecutionPolicyV1({}, input.turnExecutionPolicy)