@opengeni/db 6.5.0 → 6.6.0-canary.37090756480001

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 (118) hide show
  1. package/dist/browser-sessions.d.ts +1 -0
  2. package/dist/canonical-human-identities.js +4 -4
  3. package/dist/capability-integrations.d.ts +6 -0
  4. package/dist/capability-reconciliation.js +3 -3
  5. package/dist/{chunk-7PFJLY2U.js → chunk-43JGJFVU.js} +3 -3
  6. package/dist/{chunk-VWGYBPX4.js → chunk-5C2HMAVM.js} +2 -2
  7. package/dist/{chunk-LQ4IB3NH.js → chunk-7WTXQQCJ.js} +5 -5
  8. package/dist/{chunk-VTVNNCYZ.js → chunk-DBCRRNH4.js} +47 -17
  9. package/dist/chunk-DBCRRNH4.js.map +1 -0
  10. package/dist/{chunk-3MP2V2GC.js → chunk-HHCFFZ5K.js} +5 -5
  11. package/dist/{chunk-RP7EQP36.js → chunk-MFZQLJTT.js} +2 -2
  12. package/dist/{chunk-7ORQCNBA.js → chunk-MMRJMY2J.js} +46 -1
  13. package/dist/chunk-MMRJMY2J.js.map +1 -0
  14. package/dist/{chunk-YHIBDQ7N.js → chunk-OFI3UY3J.js} +2 -2
  15. package/dist/{chunk-S2TZ3F4L.js → chunk-P7YDM2RI.js} +3 -11
  16. package/dist/{chunk-S2TZ3F4L.js.map → chunk-P7YDM2RI.js.map} +1 -1
  17. package/dist/{chunk-NJIWKMV3.js → chunk-PGSWZSF3.js} +2 -2
  18. package/dist/{chunk-M3TGZ7B4.js → chunk-RU5WRVQA.js} +2 -2
  19. package/dist/{chunk-3ZYFTK7X.js → chunk-RWTOTE5Q.js} +4 -4
  20. package/dist/{chunk-JPYN5XKV.js → chunk-S2YPINYO.js} +2 -2
  21. package/dist/{chunk-25DAVPRJ.js → chunk-SG4QFBDY.js} +2 -2
  22. package/dist/{chunk-2X2GKAC4.js → chunk-V26GG56Q.js} +22 -7
  23. package/dist/chunk-V26GG56Q.js.map +1 -0
  24. package/dist/{chunk-3UKWSD43.js → chunk-VAEPQMM6.js} +2 -2
  25. package/dist/{chunk-UAR7ZDNG.js → chunk-Y77F3U76.js} +8058 -8024
  26. package/dist/chunk-Y77F3U76.js.map +1 -0
  27. package/dist/claude-subscription-tokens.d.ts +21 -0
  28. package/dist/claude-subscription-usage.d.ts +63 -0
  29. package/dist/computer-sessions.d.ts +1 -0
  30. package/dist/connect-attempts.js +4 -4
  31. package/dist/editable-artifact-durable-export.js +3 -3
  32. package/dist/editable-artifacts.js +4 -4
  33. package/dist/index.d.ts +193 -12
  34. package/dist/index.js +11798 -10858
  35. package/dist/index.js.map +1 -1
  36. package/dist/insights-model-bundle.d.ts +41 -4
  37. package/dist/insights-usage-bundle.d.ts +3 -4
  38. package/dist/insights.d.ts +28 -0
  39. package/dist/interaction-schema.d.ts +2 -0
  40. package/dist/managed-auth-session-sets.js +4 -4
  41. package/dist/mcp-operations.js +3 -3
  42. package/dist/migrate.js +2 -2
  43. package/dist/model-catalog.d.ts +6 -0
  44. package/dist/organization-integration-policy.js +4 -4
  45. package/dist/organization-model-providers.d.ts +9 -0
  46. package/dist/organization-usage.d.ts +9 -0
  47. package/dist/organization-xai-subscriptions.d.ts +48 -2
  48. package/dist/provision-roles.js +1 -1
  49. package/dist/retained-provider-commands.js +7 -7
  50. package/dist/runtime-posture.d.ts +3 -1
  51. package/dist/schema.d.ts +1640 -1509
  52. package/dist/schema.js +2 -2
  53. package/dist/session-attempt-writers.d.ts +1 -1
  54. package/dist/session-background-commands.d.ts +6 -0
  55. package/dist/session-background-commands.js +11 -7
  56. package/dist/session-command-output.js +6 -6
  57. package/dist/session-event-slices.js +4 -4
  58. package/dist/session-mcp-credential-rotation.js +6 -6
  59. package/dist/session-tenancy.js +4 -4
  60. package/dist/subscription-account-repository.d.ts +604 -0
  61. package/dist/subscription-credential-leases.d.ts +10 -0
  62. package/dist/subscription-pool-schema.d.ts +1642 -0
  63. package/dist/video-generation.js +4 -4
  64. package/dist/workspace-tool-defaults.js +5 -5
  65. package/dist/xai-subscription.d.ts +973 -572
  66. package/drizzle/0547_idle_command_containment.sql +218 -0
  67. package/drizzle/0583_session_tenancy_operator_permission.sql +103 -0
  68. package/drizzle/0584_agent_instruction_size_parity.sql +220 -0
  69. package/drizzle/0585_session_attention_cursor.sql +180 -0
  70. package/drizzle/0586_private_sessions_fleet_activation.sql +7 -0
  71. package/drizzle/0587_workflow_wake_session_lock_order.sql +119 -0
  72. package/drizzle/0588_insights_scoped_fact_projection.sql +318 -0
  73. package/drizzle/0589_organization_model_usage.sql +296 -0
  74. package/drizzle/0590_complete_insights_usage_amounts.sql +345 -0
  75. package/drizzle/0591_insights_aggregate_query_plans.sql +132 -0
  76. package/drizzle/0592_insights_claude_subscription_payers.sql +29 -0
  77. package/drizzle/0593_insights_private_ledger_filter.sql +56 -0
  78. package/drizzle/0594_organization_usage_hash_join.sql +9 -0
  79. package/package.json +7 -7
  80. package/src/browser-sessions.ts +6 -1
  81. package/src/capability-integrations.ts +46 -7
  82. package/src/company-brain-governed-writes.ts +4 -3
  83. package/src/computer-sessions.ts +8 -1
  84. package/src/database.ts +39 -4
  85. package/src/index.ts +1053 -307
  86. package/src/insights-model-bundle.ts +381 -331
  87. package/src/insights-usage-bundle.ts +49 -43
  88. package/src/insights.ts +301 -136
  89. package/src/lossless-json.ts +4 -10
  90. package/src/model-catalog.ts +64 -16
  91. package/src/organization-model-providers.ts +56 -1
  92. package/src/organization-usage.ts +36 -0
  93. package/src/provision-roles.ts +12 -0
  94. package/src/runtime-posture.ts +44 -0
  95. package/src/schema.ts +25 -314
  96. package/src/session-attempt-writers.ts +29 -1
  97. package/src/session-background-commands.ts +64 -13
  98. package/src/subscription-account-repository.ts +2155 -0
  99. package/src/subscription-credential-leases.ts +41 -0
  100. package/src/subscription-pool-schema.ts +341 -0
  101. package/src/workspace-model-connection-access.ts +48 -1
  102. package/src/xai-subscription.ts +78 -2021
  103. package/dist/chunk-2X2GKAC4.js.map +0 -1
  104. package/dist/chunk-7ORQCNBA.js.map +0 -1
  105. package/dist/chunk-UAR7ZDNG.js.map +0 -1
  106. package/dist/chunk-VTVNNCYZ.js.map +0 -1
  107. /package/dist/{chunk-7PFJLY2U.js.map → chunk-43JGJFVU.js.map} +0 -0
  108. /package/dist/{chunk-VWGYBPX4.js.map → chunk-5C2HMAVM.js.map} +0 -0
  109. /package/dist/{chunk-LQ4IB3NH.js.map → chunk-7WTXQQCJ.js.map} +0 -0
  110. /package/dist/{chunk-3MP2V2GC.js.map → chunk-HHCFFZ5K.js.map} +0 -0
  111. /package/dist/{chunk-RP7EQP36.js.map → chunk-MFZQLJTT.js.map} +0 -0
  112. /package/dist/{chunk-YHIBDQ7N.js.map → chunk-OFI3UY3J.js.map} +0 -0
  113. /package/dist/{chunk-NJIWKMV3.js.map → chunk-PGSWZSF3.js.map} +0 -0
  114. /package/dist/{chunk-M3TGZ7B4.js.map → chunk-RU5WRVQA.js.map} +0 -0
  115. /package/dist/{chunk-3ZYFTK7X.js.map → chunk-RWTOTE5Q.js.map} +0 -0
  116. /package/dist/{chunk-JPYN5XKV.js.map → chunk-S2YPINYO.js.map} +0 -0
  117. /package/dist/{chunk-25DAVPRJ.js.map → chunk-SG4QFBDY.js.map} +0 -0
  118. /package/dist/{chunk-3UKWSD43.js.map → chunk-VAEPQMM6.js.map} +0 -0
@@ -335,6 +335,7 @@ export declare function failBrowserSessionOperation(db: Database, input: {
335
335
  operationId: string;
336
336
  browserSessionId: string;
337
337
  state?: "failed" | "outcome_unknown";
338
+ onlyIfPreparedCreate?: boolean;
338
339
  error: InteractionErrorValue;
339
340
  }): Promise<BrowserSessionMutationResponseValue>;
340
341
  export declare function prepareBrowserSessionSuspend(db: Database, input: PrepareBrowserSessionLifecycleInput): Promise<BrowserSessionMutationResponseValue>;
@@ -11,10 +11,10 @@ import {
11
11
  getCanonicalHumanIdentityProjection,
12
12
  synchronizeCanonicalHumanLoginBindings,
13
13
  validateCanonicalHumanSession
14
- } from "./chunk-M3TGZ7B4.js";
15
- import "./chunk-2X2GKAC4.js";
16
- import "./chunk-UAR7ZDNG.js";
17
- import "./chunk-S2TZ3F4L.js";
14
+ } from "./chunk-RU5WRVQA.js";
15
+ import "./chunk-V26GG56Q.js";
16
+ import "./chunk-Y77F3U76.js";
17
+ import "./chunk-P7YDM2RI.js";
18
18
  import "./chunk-PZ5AY32C.js";
19
19
  export {
20
20
  CanonicalHumanIdentityAuthorityError,
@@ -180,6 +180,12 @@ export declare class ApiIntegrationInstallationVersionConflictError extends Erro
180
180
  readonly name = "ApiIntegrationInstallationVersionConflictError";
181
181
  constructor(capabilityId: string, expectedVersion: number, actualVersion: number);
182
182
  }
183
+ /** A known rejection of the selected credential, not an internal install failure. */
184
+ export declare class ApiIntegrationConnectionReferenceError extends Error {
185
+ readonly reason: "not_found" | "inactive" | "provider_mismatch" | "kind_mismatch" | "scope_mismatch";
186
+ readonly name = "ApiIntegrationConnectionReferenceError";
187
+ constructor(reason: "not_found" | "inactive" | "provider_mismatch" | "kind_mismatch" | "scope_mismatch", message: string);
188
+ }
183
189
  export declare function installApiIntegration(db: Database, input: InstallApiIntegrationInput): Promise<InstalledApiIntegration>;
184
190
  export declare function listInstalledApiIntegrations(db: Database, workspaceId: string, subjectId?: string): Promise<ApiIntegrationRuntime[]>;
185
191
  /**
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  withWorkspaceRls
3
- } from "./chunk-2X2GKAC4.js";
4
- import "./chunk-UAR7ZDNG.js";
5
- import "./chunk-S2TZ3F4L.js";
3
+ } from "./chunk-V26GG56Q.js";
4
+ import "./chunk-Y77F3U76.js";
5
+ import "./chunk-P7YDM2RI.js";
6
6
  import "./chunk-PZ5AY32C.js";
7
7
 
8
8
  // src/capability-reconciliation.ts
@@ -6,7 +6,7 @@ import {
6
6
  setSubjectRlsContext,
7
7
  withRlsContext,
8
8
  withWorkspaceRls
9
- } from "./chunk-2X2GKAC4.js";
9
+ } from "./chunk-V26GG56Q.js";
10
10
  import {
11
11
  connections,
12
12
  creditLedgerEntries,
@@ -18,7 +18,7 @@ import {
18
18
  workspaceVideoGenerationPolicies,
19
19
  workspaceVideoGenerationQuotas,
20
20
  workspaces
21
- } from "./chunk-UAR7ZDNG.js";
21
+ } from "./chunk-Y77F3U76.js";
22
22
 
23
23
  // src/video-generation.ts
24
24
  import {
@@ -1332,4 +1332,4 @@ export {
1332
1332
  mediaGenerationResultForStoredOperation,
1333
1333
  getVideoGenerationOperationSummary
1334
1334
  };
1335
- //# sourceMappingURL=chunk-7PFJLY2U.js.map
1335
+ //# sourceMappingURL=chunk-43JGJFVU.js.map
@@ -5,7 +5,7 @@ import {
5
5
  withWorkspaceRls,
6
6
  withWorkspaceSubjectRls,
7
7
  withWorkspaceSubjectSessionActivityRls
8
- } from "./chunk-2X2GKAC4.js";
8
+ } from "./chunk-V26GG56Q.js";
9
9
 
10
10
  // src/session-tenancy.ts
11
11
  import { createHash } from "crypto";
@@ -502,4 +502,4 @@ export {
502
502
  forkSessionContent,
503
503
  replayAppliedSessionFork
504
504
  };
505
- //# sourceMappingURL=chunk-VWGYBPX4.js.map
505
+ //# sourceMappingURL=chunk-5C2HMAVM.js.map
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  appendSessionCommandOutput
3
- } from "./chunk-3MP2V2GC.js";
3
+ } from "./chunk-HHCFFZ5K.js";
4
4
  import {
5
5
  lockSessionEventWriteRows
6
- } from "./chunk-VTVNNCYZ.js";
6
+ } from "./chunk-DBCRRNH4.js";
7
7
  import {
8
8
  withRlsContext,
9
9
  withSessionActivityRlsContext
10
- } from "./chunk-2X2GKAC4.js";
10
+ } from "./chunk-V26GG56Q.js";
11
11
  import {
12
12
  sandboxRetainedProcesses
13
- } from "./chunk-UAR7ZDNG.js";
13
+ } from "./chunk-Y77F3U76.js";
14
14
 
15
15
  // src/retained-provider-commands.ts
16
16
  import { and, eq, sql } from "drizzle-orm";
@@ -299,4 +299,4 @@ export {
299
299
  retainedProcessCancellationRequested,
300
300
  requestRetainedProcessDeadlineCancellation
301
301
  };
302
- //# sourceMappingURL=chunk-LQ4IB3NH.js.map
302
+ //# sourceMappingURL=chunk-7WTXQQCJ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  cancelUnacceptedVideoGenerationsForToolCallsInTransaction
3
- } from "./chunk-7PFJLY2U.js";
3
+ } from "./chunk-43JGJFVU.js";
4
4
  import {
5
5
  external_exports
6
6
  } from "./chunk-4UJCXBR2.js";
@@ -14,7 +14,7 @@ import {
14
14
  withSessionActivityRlsContext,
15
15
  withWorkspaceRls,
16
16
  withWorkspaceSubjectRls
17
- } from "./chunk-2X2GKAC4.js";
17
+ } from "./chunk-V26GG56Q.js";
18
18
  import {
19
19
  auditEvents,
20
20
  codexCapacityWaiters,
@@ -39,12 +39,12 @@ import {
39
39
  workspaceInferenceControls,
40
40
  workspaceMemberships,
41
41
  workspaces
42
- } from "./chunk-UAR7ZDNG.js";
42
+ } from "./chunk-Y77F3U76.js";
43
43
  import {
44
44
  LOSSLESS_CONTENT_CODEC_VERSION,
45
45
  fromPostgresLosslessJson,
46
46
  withLosslessContentWriteVersion
47
- } from "./chunk-S2TZ3F4L.js";
47
+ } from "./chunk-P7YDM2RI.js";
48
48
 
49
49
  // src/session-background-commands.ts
50
50
  import { SessionCommandFailure } from "@opengeni/contracts";
@@ -4976,22 +4976,49 @@ function commandPreview(value) {
4976
4976
  if (/[\uD800-\uDBFF]$/.test(preview)) preview = preview.slice(0, -1);
4977
4977
  return `${preview}\u2026`;
4978
4978
  }
4979
+ var UNOBSERVABLE_RETAINED_PROCESS_OUTCOMES = [
4980
+ "process_observation_unavailable",
4981
+ "quarantined_process_observation_unavailable",
4982
+ "provider_binding_missing",
4983
+ "quarantined_provider_binding_missing",
4984
+ "provider_binding_mismatch",
4985
+ "quarantined_provider_binding_mismatch"
4986
+ ];
4987
+ function unobservableRetainedProcessOutcomeSql(outcome) {
4988
+ return sql9`${outcome} in (${sql9.join(
4989
+ UNOBSERVABLE_RETAINED_PROCESS_OUTCOMES.map((value) => sql9`${value}`),
4990
+ sql9`, `
4991
+ )})`;
4992
+ }
4979
4993
  var commandObservationUnavailable = sql9`
4980
- ${sessionBackgroundCommands.state} in ('running','stopping') and exists (
4981
- select 1 from sandbox_retained_processes process
4982
- where process.id = ${sessionBackgroundCommands.retainedProcessId}
4983
- and process.account_id = ${sessionBackgroundCommands.accountId}
4984
- and process.workspace_id = ${sessionBackgroundCommands.workspaceId}
4985
- and process.session_id = ${sessionBackgroundCommands.sessionId}
4986
- and process.state = 'active'
4987
- and process.last_reconcile_outcome in ('process_observation_unavailable',
4988
- 'quarantined_process_observation_unavailable', 'provider_binding_missing',
4989
- 'quarantined_provider_binding_missing', 'provider_binding_mismatch',
4990
- 'quarantined_provider_binding_mismatch'))`;
4994
+ ${sessionBackgroundCommands.state} in ('running','stopping') and (
4995
+ (${sessionBackgroundCommands.provider} = 'connected_machine'
4996
+ and coalesce(${sessionBackgroundCommands.lastReconcileOutcome}
4997
+ in ('provider_offline', 'provider_error'), false))
4998
+ or exists (
4999
+ select 1 from sandbox_retained_processes process
5000
+ where process.id = ${sessionBackgroundCommands.retainedProcessId}
5001
+ and process.account_id = ${sessionBackgroundCommands.accountId}
5002
+ and process.workspace_id = ${sessionBackgroundCommands.workspaceId}
5003
+ and process.session_id = ${sessionBackgroundCommands.sessionId}
5004
+ and process.state = 'active'
5005
+ and ${unobservableRetainedProcessOutcomeSql(sql9`process.last_reconcile_outcome`)}))`;
4991
5006
  var commandReadColumns = {
4992
5007
  ...getTableColumns(sessionBackgroundCommands),
4993
5008
  observationUnavailable: commandObservationUnavailable
4994
5009
  };
5010
+ function connectedCommandReconciliation(row) {
5011
+ const outcome = row.lastReconcileOutcome;
5012
+ const observedAt = row.reconcileProofObservedAt?.toISOString();
5013
+ return {
5014
+ // Legacy diagnostic text is not a public message or a routing locator.
5015
+ lastOutcome: outcome === null ? null : /^[a-z][a-z0-9_]{0,63}$/.test(outcome) ? outcome : "unknown",
5016
+ attempts: row.reconcileAttempts,
5017
+ dueAt: row.reconcileAfter.toISOString(),
5018
+ claimedAt: row.reconcileClaimedAt?.toISOString() ?? null,
5019
+ terminalProof: observedAt && row.reconcileProofOutcome === "exited" && row.reconcileProofExitCode !== null ? { outcome: "exited", exitCode: row.reconcileProofExitCode, observedAt } : observedAt && row.reconcileProofOutcome === "lost" ? { outcome: "lost", exitCode: null, observedAt } : null
5020
+ };
5021
+ }
4995
5022
  function mapCommand(row) {
4996
5023
  const terminal = row.state === "exited" || row.state === "lost";
4997
5024
  const legacyFailureCode = row.provider === "connected_machine" ? /^op_failure_([A-Za-z0-9_-]{1,128})$/.exec(row.settlementReason ?? "")?.[1] : void 0;
@@ -5010,6 +5037,7 @@ function mapCommand(row) {
5010
5037
  provider: row.provider,
5011
5038
  state: row.state,
5012
5039
  ...!terminal && row.observationUnavailable ? { observationStatus: "unavailable" } : {},
5040
+ ...row.provider === "connected_machine" ? { reconciliation: connectedCommandReconciliation(row) } : {},
5013
5041
  commandPreview: row.commandPreview,
5014
5042
  ...row.commandText !== null ? { commandText: row.commandText } : {},
5015
5043
  cancelRequestedAt: row.cancelRequestedAt?.toISOString() ?? null,
@@ -5711,7 +5739,7 @@ async function readSessionBackgroundCommandOutput(db, input) {
5711
5739
  );
5712
5740
  const page = projectCommandOutputPage({ ...input, rows });
5713
5741
  const terminal = command.state === "exited" || command.state === "lost";
5714
- const observed = terminal ? await observeSessionBackgroundCommandCompletion(db, input) : command;
5742
+ const observed = terminal && command.completionObservedAt === null ? await observeSessionBackgroundCommandCompletion(db, input) : command;
5715
5743
  return {
5716
5744
  commandId: command.id,
5717
5745
  state: command.state,
@@ -5813,6 +5841,8 @@ export {
5813
5841
  renderRealtimeHumanInputResponseContext,
5814
5842
  SESSION_BACKGROUND_COMMAND_REASON_MAX_BYTES,
5815
5843
  boundedSessionBackgroundCommandReason,
5844
+ UNOBSERVABLE_RETAINED_PROCESS_OUTCOMES,
5845
+ unobservableRetainedProcessOutcomeSql,
5816
5846
  backgroundCommandActivityForSessions,
5817
5847
  listSessionBackgroundCommands,
5818
5848
  insertManagedSessionBackgroundCommandInTransaction,
@@ -5876,4 +5906,4 @@ export {
5876
5906
  setWorkspacePauseTimerInTransaction,
5877
5907
  fireWorkspacePauseTimerInTransaction
5878
5908
  };
5879
- //# sourceMappingURL=chunk-VTVNNCYZ.js.map
5909
+ //# sourceMappingURL=chunk-DBCRRNH4.js.map