@opengeni/db 4.0.0-canary.0 → 4.0.0-canary.2

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 (81) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-2XEZK4LF.js → chunk-7YZP2CSL.js} +23 -1
  3. package/dist/chunk-7YZP2CSL.js.map +1 -0
  4. package/dist/{chunk-P6NSEG2S.js → chunk-B5Y3TCSP.js} +2 -2
  5. package/dist/{chunk-CJROYHSC.js → chunk-CQF6G4IF.js} +3 -3
  6. package/dist/chunk-DUB3LUVM.js +4145 -0
  7. package/dist/chunk-DUB3LUVM.js.map +1 -0
  8. package/dist/{chunk-3RI33YQN.js → chunk-FRIYCNK2.js} +3 -1
  9. package/dist/{chunk-3RI33YQN.js.map → chunk-FRIYCNK2.js.map} +1 -1
  10. package/dist/{chunk-RZNOSEMC.js → chunk-L2QFSPFP.js} +2 -2
  11. package/dist/{chunk-NLFHMPUB.js → chunk-NPKBYGAK.js} +2 -2
  12. package/dist/{chunk-QM6YOWHZ.js → chunk-PWJJKCTF.js} +85 -4
  13. package/dist/chunk-PWJJKCTF.js.map +1 -0
  14. package/dist/{chunk-MX6V5F65.js → chunk-VU2IK37Y.js} +2 -2
  15. package/dist/{chunk-UFAMOUWL.js → chunk-XIYAXH47.js} +2 -2
  16. package/dist/editable-artifact-durable-export.js +2 -2
  17. package/dist/editable-artifacts.js +3 -3
  18. package/dist/index.d.ts +113 -7
  19. package/dist/index.js +9392 -11506
  20. package/dist/index.js.map +1 -1
  21. package/dist/managed-auth-session-sets.js +3 -3
  22. package/dist/migrate.d.ts +6 -0
  23. package/dist/migrate.js +3 -1
  24. package/dist/migration-runner-settings.d.ts +10 -0
  25. package/dist/new-session-drafts.d.ts +2 -0
  26. package/dist/provision-roles.js +1 -1
  27. package/dist/runtime-posture.d.ts +2 -2
  28. package/dist/schema.d.ts +270 -9
  29. package/dist/schema.js +3 -1
  30. package/dist/session-background-commands.d.ts +83 -0
  31. package/dist/session-background-commands.js +18 -3
  32. package/dist/session-command-output.d.ts +17 -0
  33. package/dist/session-command-output.js +130 -0
  34. package/dist/session-command-output.js.map +1 -0
  35. package/dist/session-event-slices.d.ts +28 -0
  36. package/dist/session-event-slices.js +225 -0
  37. package/dist/session-event-slices.js.map +1 -0
  38. package/dist/session-mcp-progress.d.ts +12 -0
  39. package/dist/session-tenancy.js +3 -3
  40. package/dist/site-publication-request.d.ts +18 -0
  41. package/dist/video-generation.js +3 -3
  42. package/dist/workspace-artifacts.d.ts +34 -4
  43. package/dist/xai-subscription.d.ts +2 -0
  44. package/drizzle/0407_connected_command_tracking_retirement.sql +245 -0
  45. package/drizzle/0408_scheduled_session_target_index.sql +4 -0
  46. package/drizzle/0409_new_session_draft_project_provenance.sql +321 -0
  47. package/drizzle/0410_new_session_draft_project_provenance_index.sql +5 -0
  48. package/drizzle/0411_new_session_draft_project_provenance_backfill.sql +53 -0
  49. package/drizzle/0412_new_session_draft_project_provenance_validation.sql +30 -0
  50. package/drizzle/0413_session_filter_activity.sql +96 -0
  51. package/drizzle/0414_scheduled_generated_producer_materialization.sql +287 -0
  52. package/drizzle/0415_command_completion_observation.sql +9 -0
  53. package/drizzle/0416_scheduled_inherited_tool_admission.sql +27 -0
  54. package/drizzle/0417_command_runner_failure_metadata.sql +17 -0
  55. package/drizzle/0418_site_direct_uploads.sql +151 -0
  56. package/drizzle/0419_background_command_launch_authority.sql +56 -0
  57. package/package.json +14 -6
  58. package/src/index.ts +1691 -217
  59. package/src/migrate.ts +10 -2
  60. package/src/migration-runner-settings.ts +21 -0
  61. package/src/new-session-drafts.ts +105 -1
  62. package/src/runtime-posture.ts +2 -0
  63. package/src/schema.ts +97 -3
  64. package/src/session-background-commands.ts +320 -4
  65. package/src/session-command-output.ts +158 -0
  66. package/src/session-control.ts +53 -21
  67. package/src/session-event-slices.ts +310 -0
  68. package/src/session-mcp-progress.ts +67 -0
  69. package/src/site-publication-request.ts +32 -0
  70. package/src/workspace-artifacts.ts +95 -96
  71. package/src/xai-subscription.ts +8 -0
  72. package/dist/chunk-2XEZK4LF.js.map +0 -1
  73. package/dist/chunk-N5VXJ4I2.js +0 -589
  74. package/dist/chunk-N5VXJ4I2.js.map +0 -1
  75. package/dist/chunk-QM6YOWHZ.js.map +0 -1
  76. /package/dist/{chunk-P6NSEG2S.js.map → chunk-B5Y3TCSP.js.map} +0 -0
  77. /package/dist/{chunk-CJROYHSC.js.map → chunk-CQF6G4IF.js.map} +0 -0
  78. /package/dist/{chunk-RZNOSEMC.js.map → chunk-L2QFSPFP.js.map} +0 -0
  79. /package/dist/{chunk-NLFHMPUB.js.map → chunk-NPKBYGAK.js.map} +0 -0
  80. /package/dist/{chunk-MX6V5F65.js.map → chunk-VU2IK37Y.js.map} +0 -0
  81. /package/dist/{chunk-UFAMOUWL.js.map → chunk-XIYAXH47.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-UFAMOUWL.js";
4
+ } from "./chunk-XIYAXH47.js";
5
5
 
6
6
  // src/managed-auth-session-sets.ts
7
7
  import {
@@ -296,4 +296,4 @@ export {
296
296
  reapManagedAuthIsolatedSessions,
297
297
  reapExpiredManagedAuthSessionSets
298
298
  };
299
- //# sourceMappingURL=chunk-MX6V5F65.js.map
299
+ //# sourceMappingURL=chunk-VU2IK37Y.js.map
@@ -4,7 +4,7 @@ import {
4
4
  sessions,
5
5
  workspaceSessionActivityRevisions,
6
6
  workspaces
7
- } from "./chunk-QM6YOWHZ.js";
7
+ } from "./chunk-PWJJKCTF.js";
8
8
 
9
9
  // src/persistence-errors.ts
10
10
  var SQLSTATE_KEYS = ["sqlState", "sqlstate", "code"];
@@ -755,4 +755,4 @@ export {
755
755
  withAccountRls,
756
756
  dbBindingFor
757
757
  };
758
- //# sourceMappingURL=chunk-UFAMOUWL.js.map
758
+ //# sourceMappingURL=chunk-XIYAXH47.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-UFAMOUWL.js";
5
- import "./chunk-QM6YOWHZ.js";
4
+ } from "./chunk-XIYAXH47.js";
5
+ import "./chunk-PWJJKCTF.js";
6
6
  import "./chunk-PZ5AY32C.js";
7
7
 
8
8
  // src/editable-artifact-durable-export.ts
@@ -8,9 +8,9 @@ import {
8
8
  PostgresEditableArtifactStore,
9
9
  listEditableArtifactIdsForSession,
10
10
  touchEditableArtifactSessionLink
11
- } from "./chunk-RZNOSEMC.js";
12
- import "./chunk-UFAMOUWL.js";
13
- import "./chunk-QM6YOWHZ.js";
11
+ } from "./chunk-L2QFSPFP.js";
12
+ import "./chunk-XIYAXH47.js";
13
+ import "./chunk-PWJJKCTF.js";
14
14
  import "./chunk-PZ5AY32C.js";
15
15
  export {
16
16
  EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
package/dist/index.d.ts CHANGED
@@ -601,6 +601,13 @@ export declare function revokeOrganizationApiKey(db: Database, accountId: string
601
601
  export declare function findActiveApiKeyByHash(db: Database, keyHash: string): Promise<(ApiKey & {
602
602
  credentialKind: schema.ApiKeyCredentialKind;
603
603
  }) | null>;
604
+ export declare function findActiveWorkspaceApiKeyById(db: Database, input: {
605
+ accountId: string;
606
+ workspaceId: string;
607
+ apiKeyId: string;
608
+ }): Promise<(ApiKey & {
609
+ credentialKind: schema.ApiKeyCredentialKind;
610
+ }) | null>;
604
611
  export type GitHubInstallation = {
605
612
  id: string;
606
613
  accountId: string;
@@ -2791,7 +2798,9 @@ export declare function requireScheduledTaskTargetInTransaction(tx: Database, in
2791
2798
  taskId: string;
2792
2799
  targetSessionId: string;
2793
2800
  }): Promise<void>;
2794
- export declare function listScheduledTasks(db: Database, workspaceId: string, limit?: number, offset?: number): Promise<ScheduledTask[]>;
2801
+ /** Authoritative current targets, batched after session visibility has been resolved. */
2802
+ export declare function scheduledSessionIds(db: Database, workspaceId: string, sessionIds: string[]): Promise<Set<string>>;
2803
+ export declare function listScheduledTasks(db: Database, workspaceId: string, limit?: number, offset?: number, sessionId?: string): Promise<ScheduledTask[]>;
2795
2804
  /**
2796
2805
  * Internal connector-control traversal. Keep the whole keyset walk on one
2797
2806
  * repeatable-read snapshot so task creation/update performed after discovery
@@ -4374,6 +4383,11 @@ export type ReconcileXaiCapacityWaitResult = {
4374
4383
  waiter: XaiCapacityWait | null;
4375
4384
  events: SessionEvent[];
4376
4385
  };
4386
+ export declare function resolveXaiWaiterSubject(db: Database, workspaceId: string, sessionId: string): Promise<{
4387
+ subjectId: string;
4388
+ snapshot: XaiProviderAccountAuthoritySnapshotV1;
4389
+ turnId: string;
4390
+ } | null>;
4377
4391
  /**
4378
4392
  * Atomically close one exact xAI attempt and preserve its logical turn behind a
4379
4393
  * durable provider-capacity waiter. The immutable authority snapshot and, for
@@ -4837,7 +4851,7 @@ export type ConnectorActionInvocation = {
4837
4851
  serverId: string;
4838
4852
  toolName: string;
4839
4853
  arguments: unknown;
4840
- /** Explicit per-session MCP approval, rather than a connector-policy decision. */
4854
+ /** Explicit per-session approval or capability-authorized mutation ledger mode. */
4841
4855
  approvalMode?: "session_mcp" | "connector_write";
4842
4856
  };
4843
4857
  export type PrepareConnectorActionApprovalResult = {
@@ -4874,7 +4888,7 @@ type ResolvedConnectorActionPolicy = {
4874
4888
  managed: true;
4875
4889
  source: "explicit";
4876
4890
  entry: null;
4877
- decision: "ask";
4891
+ decision: "allow" | "ask";
4878
4892
  actionName: string;
4879
4893
  } | {
4880
4894
  managed: true;
@@ -4889,7 +4903,7 @@ export declare function resolveConnectorActionPolicy(snapshot: readonly Connecto
4889
4903
  toolName: string;
4890
4904
  actionName: string;
4891
4905
  }): ResolvedConnectorActionPolicy;
4892
- export declare function upsertConnectorActionPolicy(db: Database, input: {
4906
+ export type ConnectorActionPolicyWrite = {
4893
4907
  accountId: string;
4894
4908
  workspaceId: string;
4895
4909
  subjectId: string;
@@ -4898,10 +4912,20 @@ export declare function upsertConnectorActionPolicy(db: Database, input: {
4898
4912
  toolName: string;
4899
4913
  actionName: string;
4900
4914
  policy: ConnectorActionPolicyDecision;
4901
- }): Promise<{
4915
+ };
4916
+ export declare function upsertConnectorActionPolicies(db: Database, inputs: readonly ConnectorActionPolicyWrite[]): Promise<Array<{
4917
+ policy: typeof schema.connectorActionPolicies.$inferSelect;
4918
+ changed: boolean;
4919
+ }>>;
4920
+ export declare function upsertConnectorActionPolicy(db: Database, input: ConnectorActionPolicyWrite): Promise<{
4902
4921
  policy: typeof schema.connectorActionPolicies.$inferSelect;
4903
4922
  changed: boolean;
4904
4923
  }>;
4924
+ export declare function listConnectorActionPolicies(db: Database, input: {
4925
+ accountId: string;
4926
+ workspaceId: string;
4927
+ connectionIds: readonly string[];
4928
+ }): Promise<ConnectorActionPolicySnapshotEntry[]>;
4905
4929
  /**
4906
4930
  * Install a risk-appropriate connector default without overwriting an explicit
4907
4931
  * user choice that already exists for the same immutable connector action.
@@ -5139,6 +5163,8 @@ export type SessionListSnapshotCursor = {
5139
5163
  parentSessionFilter: string;
5140
5164
  search: string | null;
5141
5165
  archiveMode: "active" | "archived";
5166
+ /** Additive filter identity; absent on legacy snapshot cursors. */
5167
+ filter?: string;
5142
5168
  };
5143
5169
  export type SessionListKeysetCursor = {
5144
5170
  kind: "keyset";
@@ -5150,9 +5176,28 @@ export type SessionListKeysetCursor = {
5150
5176
  parentSessionFilter: string;
5151
5177
  search: string | null;
5152
5178
  archiveMode: "active" | "archived";
5179
+ /** Canonical identity for channel, creator, and time-bound filters. */
5180
+ filter?: string;
5153
5181
  };
5154
5182
  export type SessionListCursor = SessionListSnapshotCursor | SessionListKeysetCursor;
5155
- export type ListSessionsForSubjectOptions = ListSessionsOptions & {
5183
+ export type SessionListFilterOptions = {
5184
+ /** Exact workspace project; null selects unfiled sessions. */
5185
+ channelId?: string | null;
5186
+ /** Exact frozen creator identity. */
5187
+ createdBy?: {
5188
+ kind: "subject" | "service";
5189
+ subjectId: string;
5190
+ };
5191
+ /** Inclusive activity lower bound. */
5192
+ updatedFrom?: Date;
5193
+ /** Exclusive activity upper bound. */
5194
+ updatedBefore?: Date;
5195
+ /** Inclusive creation lower bound. */
5196
+ createdFrom?: Date;
5197
+ /** Exclusive creation upper bound. */
5198
+ createdBefore?: Date;
5199
+ };
5200
+ export type ListSessionsForSubjectOptions = ListSessionsOptions & SessionListFilterOptions & {
5156
5201
  subjectId: string;
5157
5202
  cursor?: SessionListCursor | undefined;
5158
5203
  search?: string | undefined;
@@ -5675,8 +5720,14 @@ export declare function adoptConnectedMachineSessionBackgroundCommand(db: Databa
5675
5720
  cancelRequestedAt: string | null;
5676
5721
  exitCode: number | null;
5677
5722
  settlementReason: string | null;
5723
+ failure?: {
5724
+ code: string;
5725
+ detail?: Record<string, string> | undefined;
5726
+ retryable: false;
5727
+ } | undefined;
5678
5728
  startedAt: string;
5679
5729
  settledAt: string | null;
5730
+ completionObservedAt?: string | null | undefined;
5680
5731
  updatedAt: string;
5681
5732
  }>;
5682
5733
  /** Transfer one exact managed retained process from a live turn attempt to its
@@ -5703,8 +5754,14 @@ export declare function adoptManagedSessionBackgroundCommand(db: Database, input
5703
5754
  cancelRequestedAt: string | null;
5704
5755
  exitCode: number | null;
5705
5756
  settlementReason: string | null;
5757
+ failure?: {
5758
+ code: string;
5759
+ detail?: Record<string, string> | undefined;
5760
+ retryable: false;
5761
+ } | undefined;
5706
5762
  startedAt: string;
5707
5763
  settledAt: string | null;
5764
+ completionObservedAt?: string | null | undefined;
5708
5765
  updatedAt: string;
5709
5766
  }>;
5710
5767
  export type InstallOrReadTurnExecutionPolicyForAttemptResult = {
@@ -9080,7 +9137,7 @@ export type SetSessionGoalStatusEvent = {
9080
9137
  rationale?: string;
9081
9138
  } | {
9082
9139
  type: "goal.resumed";
9083
- actor: "api";
9140
+ actor: "api" | "agent";
9084
9141
  };
9085
9142
  /** Status mutation and its timeline fact share the same session-first commit. */
9086
9143
  export declare function setSessionGoalStatusWithEvent(db: Database, workspaceId: string, sessionId: string, input: {
@@ -9397,6 +9454,9 @@ export declare function reconcileSessionAttemptQuiescence(db: Database, input: {
9397
9454
  export declare function settleSessionAttemptInterruptions(db: Database, workspaceId: string, sessionId: string, attemptId: string): Promise<SessionAttemptInterruptionSettlement>;
9398
9455
  export type SessionWorkPeek = {
9399
9456
  kind: "runnable";
9457
+ } | {
9458
+ kind: "sandbox-lifecycle-wait";
9459
+ ref: SandboxLifecycleWait;
9400
9460
  } | {
9401
9461
  kind: "approval-pending";
9402
9462
  triggerEventId: string;
@@ -9456,6 +9516,11 @@ export type FailSessionWorkBeforeAttemptClaimInput = {
9456
9516
  workflowId: string;
9457
9517
  trigger: SessionWorkTrigger;
9458
9518
  error: string;
9519
+ /** Already-classified admission facts from the failed worker activity. */
9520
+ admissionFailure?: {
9521
+ disposition: "retryable" | "permanent";
9522
+ code: "db_deadlock" | "db_serialization_failure" | "db_failure" | "claim_invariant";
9523
+ };
9459
9524
  };
9460
9525
  export type FailSessionWorkBeforeAttemptClaimResult = {
9461
9526
  action: "failed";
@@ -9470,6 +9535,27 @@ export type FailSessionWorkBeforeAttemptClaimResult = {
9470
9535
  turnId: null;
9471
9536
  events: [];
9472
9537
  };
9538
+ export type RecoverSessionWorkFailedBeforeAttemptClaimInput = {
9539
+ accountId: string;
9540
+ sessionId: string;
9541
+ workflowId: string;
9542
+ operationId: string;
9543
+ expectedFailureEventSequence: number;
9544
+ expectedLastSequence: number;
9545
+ failedUpdateIds: string[];
9546
+ };
9547
+ export type RecoverSessionWorkFailedBeforeAttemptClaimResult = {
9548
+ action: "recovered";
9549
+ event: SessionEvent;
9550
+ workflowWakeRevision: number;
9551
+ restoredUpdateIds: string[];
9552
+ } | {
9553
+ action: "already_recovered";
9554
+ event: SessionEvent;
9555
+ } | {
9556
+ action: "stale";
9557
+ event: null;
9558
+ };
9473
9559
  /**
9474
9560
  * Terminally settle a permanent admission failure that happened before an
9475
9561
  * attempt row existed. The workflow supplies the exact trigger recorded in
@@ -9479,6 +9565,17 @@ export type FailSessionWorkBeforeAttemptClaimResult = {
9479
9565
  * fabricated because provider/tool execution never started.
9480
9566
  */
9481
9567
  export declare function failSessionWorkBeforeAttemptClaim(db: Database, workspaceId: string, input: FailSessionWorkBeforeAttemptClaimInput): Promise<FailSessionWorkBeforeAttemptClaimResult>;
9568
+ /**
9569
+ * Repair the exact terminal shape written by an older worker after a
9570
+ * session-level pre-claim database failure. This is deliberately narrower than
9571
+ * Resume: it accepts only a failed session with no live turn/attempt, an exact
9572
+ * root-session `pre_claim_failure` status event with no turn association, and
9573
+ * the caller-named complete set of undelivered failed child updates durably
9574
+ * tied to that failure epoch whose frozen parent turns still carry human
9575
+ * authority. The restored updates, audit event, runnable session state, and
9576
+ * signal-with-start wake commit atomically.
9577
+ */
9578
+ export declare function recoverSessionWorkFailedBeforeAttemptClaim(db: Database, workspaceId: string, input: RecoverSessionWorkFailedBeforeAttemptClaimInput): Promise<RecoverSessionWorkFailedBeforeAttemptClaimResult>;
9482
9579
  /**
9483
9580
  * Commit the workflow's terminal-for-now idle decision and its parent delivery
9484
9581
  * source in one transaction. A crash after commit leaves a pending outbox row for
@@ -9489,6 +9586,7 @@ export declare function settleSessionIdleWithParentOutbox(db: Database, workspac
9489
9586
  action: "settled";
9490
9587
  changed: boolean;
9491
9588
  episodeKey: string;
9589
+ notifyParent: boolean;
9492
9590
  events: SessionEvent[];
9493
9591
  } | {
9494
9592
  action: "stale";
@@ -9497,6 +9595,12 @@ export declare function settleSessionIdleWithParentOutbox(db: Database, workspac
9497
9595
  }>;
9498
9596
  export declare function buildChildCompletionDigest(summaries: string[], trailing: string): string;
9499
9597
  export declare function setTemporalWorkflowId(db: Database, workspaceId: string, sessionId: string, workflowId: string): Promise<void>;
9598
+ export type SandboxLifecycleWait = {
9599
+ version: 1;
9600
+ sandboxGroupId: string;
9601
+ leaseEpoch: number;
9602
+ reason: "rotation_in_progress";
9603
+ };
9500
9604
  type SessionTurnRecordingSettlementBase = {
9501
9605
  recordingId: string;
9502
9606
  producerId?: string | null;
@@ -9680,6 +9784,7 @@ export type RequestSessionTurnRecoveryInput = {
9680
9784
  attemptId: string;
9681
9785
  reason: string;
9682
9786
  detail?: Record<string, unknown>;
9787
+ sandboxLifecycleWait?: SandboxLifecycleWait;
9683
9788
  providerRecoveryCount?: number;
9684
9789
  fromStatuses?: SessionTurnStatus[];
9685
9790
  providerArtifactInvalidation?: {
@@ -9960,6 +10065,7 @@ export type SessionBackgroundCommandTerminalSettlement = {
9960
10065
  events: SessionEvent[];
9961
10066
  };
9962
10067
  export declare function settleConnectedMachineSessionBackgroundCommand(db: Database, input: {
10068
+ failure?: SessionBackgroundCommand["failure"];
9963
10069
  accountId: string;
9964
10070
  workspaceId: string;
9965
10071
  sessionId: string;