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

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 (49) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-B5Y3TCSP.js → chunk-3JGOYOWD.js} +2 -2
  3. package/dist/{chunk-NPKBYGAK.js → chunk-CZXYNVEU.js} +2 -2
  4. package/dist/{chunk-L2QFSPFP.js → chunk-DIFDLF2C.js} +2 -2
  5. package/dist/{chunk-XIYAXH47.js → chunk-GPKHEPVX.js} +2 -2
  6. package/dist/{chunk-CQF6G4IF.js → chunk-HUCU5BDD.js} +3 -3
  7. package/dist/{chunk-VU2IK37Y.js → chunk-OWZ36ST7.js} +2 -2
  8. package/dist/{chunk-DUB3LUVM.js → chunk-R6LIJYG6.js} +140 -8
  9. package/dist/chunk-R6LIJYG6.js.map +1 -0
  10. package/dist/{chunk-FRIYCNK2.js → chunk-SOLRMQCL.js} +3 -1
  11. package/dist/chunk-SOLRMQCL.js.map +1 -0
  12. package/dist/{chunk-PWJJKCTF.js → chunk-WU3MSPZS.js} +19 -2
  13. package/dist/chunk-WU3MSPZS.js.map +1 -0
  14. package/dist/editable-artifact-durable-export.js +2 -2
  15. package/dist/editable-artifacts.js +3 -3
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.js +37 -14
  18. package/dist/index.js.map +1 -1
  19. package/dist/managed-auth-session-sets.js +3 -3
  20. package/dist/provision-roles.js +1 -1
  21. package/dist/runtime-posture.d.ts +1 -1
  22. package/dist/schema.d.ts +85 -0
  23. package/dist/schema.js +1 -1
  24. package/dist/session-background-commands.js +4 -4
  25. package/dist/session-command-output.js +4 -4
  26. package/dist/session-control.d.ts +26 -1
  27. package/dist/session-event-slices.js +2 -2
  28. package/dist/session-tenancy.js +3 -3
  29. package/dist/video-generation.js +3 -3
  30. package/dist/workspace-artifacts.d.ts +1 -0
  31. package/drizzle/0420_workspace_pause_timers.sql +53 -0
  32. package/drizzle/0421_recovery_notification_claim_snapshot.sql +279 -0
  33. package/drizzle/0422_personal_workspace_organization_codex_inheritance.sql +363 -0
  34. package/package.json +6 -6
  35. package/src/index.ts +23 -5
  36. package/src/provision-roles.ts +1 -0
  37. package/src/runtime-posture.ts +1 -0
  38. package/src/schema.ts +20 -1
  39. package/src/session-control.ts +177 -4
  40. package/src/workspace-artifacts.ts +9 -0
  41. package/dist/chunk-DUB3LUVM.js.map +0 -1
  42. package/dist/chunk-FRIYCNK2.js.map +0 -1
  43. package/dist/chunk-PWJJKCTF.js.map +0 -1
  44. /package/dist/{chunk-B5Y3TCSP.js.map → chunk-3JGOYOWD.js.map} +0 -0
  45. /package/dist/{chunk-NPKBYGAK.js.map → chunk-CZXYNVEU.js.map} +0 -0
  46. /package/dist/{chunk-L2QFSPFP.js.map → chunk-DIFDLF2C.js.map} +0 -0
  47. /package/dist/{chunk-XIYAXH47.js.map → chunk-GPKHEPVX.js.map} +0 -0
  48. /package/dist/{chunk-CQF6G4IF.js.map → chunk-HUCU5BDD.js.map} +0 -0
  49. /package/dist/{chunk-VU2IK37Y.js.map → chunk-OWZ36ST7.js.map} +0 -0
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-XIYAXH47.js";
5
- import "./chunk-PWJJKCTF.js";
4
+ } from "./chunk-GPKHEPVX.js";
5
+ import "./chunk-WU3MSPZS.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-L2QFSPFP.js";
12
- import "./chunk-XIYAXH47.js";
13
- import "./chunk-PWJJKCTF.js";
11
+ } from "./chunk-DIFDLF2C.js";
12
+ import "./chunk-GPKHEPVX.js";
13
+ import "./chunk-WU3MSPZS.js";
14
14
  import "./chunk-PZ5AY32C.js";
15
15
  export {
16
16
  EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
package/dist/index.d.ts CHANGED
@@ -10307,3 +10307,8 @@ export * from "./session-tenancy.js";
10307
10307
  export * from "./governed-learning-activation.js";
10308
10308
  export * from "./automations.js";
10309
10309
  export * from "./organization-model-providers.js";
10310
+ export { setWorkspacePauseTimerInTransaction, fireWorkspacePauseTimerInTransaction, } from "./session-control.js";
10311
+ export declare function listDueWorkspacePauseTimers(db: Database, limit?: number): Promise<{
10312
+ workspace_id: string;
10313
+ timer_id: string;
10314
+ }[]>;
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  replayAppliedSessionFork,
15
15
  sessionTenancyProductActivated,
16
16
  transitionSessionVisibility
17
- } from "./chunk-B5Y3TCSP.js";
17
+ } from "./chunk-3JGOYOWD.js";
18
18
  import {
19
19
  AgentCommandAuthorityError,
20
20
  CHILD_LIFECYCLE_DEDUPE_PREFIX,
@@ -27,6 +27,7 @@ import {
27
27
  TOOL_RESULT_TYPE_BY_CALL_TYPE,
28
28
  WORKSPACE_CONTROL_REQUEST_LOCK_TIMEOUT_MS,
29
29
  WorkspaceControlBusyError,
30
+ WorkspacePauseTimerInputError,
30
31
  assertAgentCommandAuthorityInTransaction,
31
32
  assertSessionAuthoritySnapshot,
32
33
  autoResumeSessionBranchInTransaction,
@@ -55,6 +56,7 @@ import {
55
56
  evaluateSessionControls,
56
57
  evaluateSessionDiscoveryControls,
57
58
  evaluateSessionWriteAdmissionControl,
59
+ fireWorkspacePauseTimerInTransaction,
58
60
  getCompletedSessionPromptCommandReceipt,
59
61
  historyCallId,
60
62
  historyItemType,
@@ -79,13 +81,14 @@ import {
79
81
  serializeEffectiveSessionControl,
80
82
  sessionAuthoritySnapshotMatchesSession,
81
83
  sessionAuthoritySnapshotsEqual,
84
+ setWorkspacePauseTimerInTransaction,
82
85
  settleClaimedConnectedMachineBackgroundCommandWithMutation,
83
86
  settleConnectedMachineSessionBackgroundCommandWithMutation,
84
87
  settleSessionBackgroundCommandForRetainedProcessInTransaction,
85
88
  updateSessionCommandReceiptResult,
86
89
  workspaceControlLockBudget,
87
90
  workspaceControlRequestLockTimeoutMs
88
- } from "./chunk-DUB3LUVM.js";
91
+ } from "./chunk-R6LIJYG6.js";
89
92
  import {
90
93
  ACTIVE_VIDEO_GENERATION_STATUSES,
91
94
  VideoGenerationCapacityError,
@@ -117,7 +120,7 @@ import {
117
120
  settleVideoGenerationFailure,
118
121
  settleVideoGenerationReady,
119
122
  updateWorkspaceVideoGenerationPolicy
120
- } from "./chunk-CQF6G4IF.js";
123
+ } from "./chunk-HUCU5BDD.js";
121
124
  import {
122
125
  ManagedAuthActorMutationInFlightError,
123
126
  ManagedAuthLoginSlotAlreadyExistsError,
@@ -140,7 +143,7 @@ import {
140
143
  reapManagedAuthIsolatedSessions,
141
144
  releaseManagedAuthActorMutationLease,
142
145
  validateManagedAuthActorMutationLease
143
- } from "./chunk-VU2IK37Y.js";
146
+ } from "./chunk-OWZ36ST7.js";
144
147
  import {
145
148
  migrate,
146
149
  runMigrations
@@ -167,7 +170,7 @@ import {
167
170
  inspectRuntimeDatabasePosture,
168
171
  provisionRoles,
169
172
  runtimeDatabaseReadyCheck
170
- } from "./chunk-FRIYCNK2.js";
173
+ } from "./chunk-SOLRMQCL.js";
171
174
  import {
172
175
  CanonicalHumanIdentityAuthorityError,
173
176
  CanonicalHumanIdentityConflictError,
@@ -181,7 +184,7 @@ import {
181
184
  getCanonicalHumanIdentityProjection,
182
185
  synchronizeCanonicalHumanLoginBindings,
183
186
  validateCanonicalHumanSession
184
- } from "./chunk-NPKBYGAK.js";
187
+ } from "./chunk-CZXYNVEU.js";
185
188
  import {
186
189
  EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
187
190
  EDITABLE_ARTIFACT_KERNEL_TAIL_MAX_BYTES,
@@ -192,7 +195,7 @@ import {
192
195
  PostgresEditableArtifactStore,
193
196
  listEditableArtifactIdsForSession,
194
197
  touchEditableArtifactSessionLink
195
- } from "./chunk-L2QFSPFP.js";
198
+ } from "./chunk-DIFDLF2C.js";
196
199
  import {
197
200
  SandboxProviderReadLockUnavailableError,
198
201
  SessionEventPersistenceError,
@@ -228,7 +231,7 @@ import {
228
231
  withWorkspaceSubjectRls,
229
232
  withWorkspaceSubjectSessionActivityRls,
230
233
  withWorkspaceUsageLock
231
- } from "./chunk-XIYAXH47.js";
234
+ } from "./chunk-GPKHEPVX.js";
232
235
  import {
233
236
  LOSSLESS_CONTENT_CODEC_VERSION,
234
237
  LOSSLESS_JSON_STRING_PREFIX,
@@ -466,7 +469,7 @@ import {
466
469
  xaiRotationSettings,
467
470
  xaiSessionAccountPins,
468
471
  xaiSubscriptionCredentials
469
- } from "./chunk-PWJJKCTF.js";
472
+ } from "./chunk-WU3MSPZS.js";
470
473
  import "./chunk-PZ5AY32C.js";
471
474
 
472
475
  // src/index.ts
@@ -32894,6 +32897,12 @@ async function listWorkspaceArtifacts(db, workspaceId, options = {}) {
32894
32897
  const cursor = options.cursor ? decodeListCursor(options.cursor) : null;
32895
32898
  const visibility = and38(
32896
32899
  eq39(workspaceArtifacts.workspaceId, workspaceId),
32900
+ ...options.sourceSessionId ? [
32901
+ sql51`exists (select 1 from ${workspaceArtifactVersions} as published_version
32902
+ where published_version.artifact_id = ${workspaceArtifacts.id}
32903
+ and published_version.workspace_id = ${workspaceArtifacts.workspaceId}
32904
+ and published_version.source_session_id = ${options.sourceSessionId}::uuid)`
32905
+ ] : [],
32897
32906
  ...options.status ? [eq39(workspaceArtifacts.status, options.status)] : [],
32898
32907
  ...cursor ? [
32899
32908
  or9(
@@ -54685,7 +54694,7 @@ async function effectiveCodexCredentialPoolCondition(scopedDb, workspaceId) {
54685
54694
  async function lockOrganizationCodexSubscriptionSources(scopedDb, accountId) {
54686
54695
  const rows = await scopedDb.execute(sql68`
54687
54696
  select workspace_id
54688
- from list_organization_workspace_ids(${accountId}::uuid)
54697
+ from list_organization_codex_workspace_ids(${accountId}::uuid)
54689
54698
  order by workspace_id
54690
54699
  `);
54691
54700
  const workspaceIds = rows.map((row) => row.workspace_id);
@@ -54720,9 +54729,6 @@ async function setWorkspaceCodexSubscriptionModeInTransaction(scopedDb, input) {
54720
54729
  if (current.accountId !== input.accountId) {
54721
54730
  throw new Error("Codex source account does not match the workspace account");
54722
54731
  }
54723
- if (current.workspaceKind === "personal" && input.mode !== "automatic") {
54724
- throw new Error("personal workspaces always use workspace Codex subscriptions");
54725
- }
54726
54732
  const effectiveSourceBeforeMutation = input.effectiveSourceBeforeMutation ?? current.effectiveSource;
54727
54733
  let next = current;
54728
54734
  if (current.mode !== input.mode) {
@@ -56367,7 +56373,7 @@ async function wakeOrganizationCodexCapacityWaitersInTransaction(tx, input) {
56367
56373
  const wakeTargets = [];
56368
56374
  await setRlsContext(tx, { accountId: input.accountId, workspaceId: null });
56369
56375
  const workspaceRows = await tx.execute(sql68`
56370
- select workspace_id from list_organization_workspace_ids(${input.accountId}::uuid)
56376
+ select workspace_id from list_organization_codex_workspace_ids(${input.accountId}::uuid)
56371
56377
  order by workspace_id
56372
56378
  `);
56373
56379
  for (const { workspace_id: workspaceId } of workspaceRows) {
@@ -88827,6 +88833,13 @@ async function workspaceControlProjection(db, workspaceId) {
88827
88833
  const [control] = await scopedDb.select().from(workspaceInferenceControls).where(eq53(workspaceInferenceControls.workspaceId, workspaceId)).limit(1);
88828
88834
  if (!control) throw new Error(`Workspace ${workspaceId} has no inference control`);
88829
88835
  return {
88836
+ timer: control.timerId ? {
88837
+ id: control.timerId,
88838
+ action: control.timerAction,
88839
+ dueAt: control.timerDueAt.toISOString(),
88840
+ pauseForSeconds: control.timerPauseForSeconds
88841
+ } : null,
88842
+ serverTime: (/* @__PURE__ */ new Date()).toISOString(),
88830
88843
  state: control.workspaceState,
88831
88844
  revision: Number(control.revision),
88832
88845
  reason: control.reason,
@@ -89301,6 +89314,12 @@ async function fetchCodexRateLimitResetCreditsForAccount2(db, settings, workspac
89301
89314
  function buildConnectionTokenResolver2(db, settings, deps = connectionBrokerDeps(), options = {}) {
89302
89315
  return buildConnectionTokenResolver(db, settings, deps, options);
89303
89316
  }
89317
+ async function listDueWorkspacePauseTimers(db, limit = 100) {
89318
+ return await rawRows(
89319
+ db,
89320
+ sql68`select * from opengeni_private.list_due_workspace_pause_timers(${limit})`
89321
+ );
89322
+ }
89304
89323
  export {
89305
89324
  ACTIVE_SESSION_HISTORY_MAX_JSON_BYTES,
89306
89325
  ACTIVE_SESSION_HISTORY_MAX_JSON_NODES,
@@ -89620,6 +89639,7 @@ export {
89620
89639
  WorkspaceMemberManagementError,
89621
89640
  WorkspaceOpenRouterCustomModelHistoryLimitError,
89622
89641
  WorkspaceOpenRouterCustomModelLimitError,
89642
+ WorkspacePauseTimerInputError,
89623
89643
  XAI_CREDENTIAL_LEASE_TTL_MS,
89624
89644
  abandonCodexResetRedemptionBeforeProvider,
89625
89645
  abandonRecordingForTurnAttempt,
@@ -90114,6 +90134,7 @@ export {
90114
90134
  findCompletedImportBatch,
90115
90135
  findComputerSessionControlRecordByOperation,
90116
90136
  findWorkspaceByExternalIdentity,
90137
+ fireWorkspacePauseTimerInTransaction,
90117
90138
  flushSessionRealtimeTranscriptTailInTransaction,
90118
90139
  forceDrainOverLimitViewerOnlyBoxes,
90119
90140
  forkSessionContent,
@@ -90428,6 +90449,7 @@ export {
90428
90449
  listDistinctRigVersionIdsInGroup,
90429
90450
  listDistinctVariableSetIdsInGroup,
90430
90451
  listDistinctVariableSetSelectionsInGroup,
90452
+ listDueWorkspacePauseTimers,
90431
90453
  listEditableArtifactIdsForSession,
90432
90454
  listEligibleKnowledgeClaims,
90433
90455
  listEnabledMcpCapabilityServerIds,
@@ -90979,6 +91001,7 @@ export {
90979
91001
  setWorkspaceCodexSubscriptionModeInTransaction,
90980
91002
  setWorkspaceDefaultRig,
90981
91003
  setWorkspaceEnvironmentVariable,
91004
+ setWorkspacePauseTimerInTransaction,
90982
91005
  setXaiSessionAccountPin,
90983
91006
  settleAutomationRun,
90984
91007
  settleBrowserDownloadSaveFailure,