@opengeni/db 1.4.0 → 1.4.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 (69) hide show
  1. package/dist/canonical-human-identities.js +2 -2
  2. package/dist/capability-reconciliation.js +1 -1
  3. package/dist/{chunk-27T4AP25.js → chunk-45EMCVJC.js} +22 -6
  4. package/dist/{chunk-27T4AP25.js.map → chunk-45EMCVJC.js.map} +1 -1
  5. package/dist/{chunk-EMYA6XNE.js → chunk-4SUZSKKW.js} +2 -2
  6. package/dist/{chunk-VCHK4D6S.js → chunk-57FM4RG4.js} +2 -2
  7. package/dist/{chunk-7QWWTVYH.js → chunk-5ROHLEN6.js} +29 -4
  8. package/dist/chunk-5ROHLEN6.js.map +1 -0
  9. package/dist/{chunk-BA52ITIY.js → chunk-7HP5NCRN.js} +2 -2
  10. package/dist/{chunk-UQELJ6OM.js → chunk-A4LPJOKP.js} +2 -2
  11. package/dist/{chunk-CKDHKQS4.js → chunk-DEMX4GWU.js} +4 -4
  12. package/dist/{chunk-GC5GUTV3.js → chunk-ISNA4KUA.js} +2 -2
  13. package/dist/{chunk-3WUCM7YF.js → chunk-JYKUR5KT.js} +2 -2
  14. package/dist/{chunk-EFANLEWI.js → chunk-LGXWM3UJ.js} +2 -2
  15. package/dist/{chunk-T3CYF3DH.js → chunk-NI3WPW2L.js} +35 -17
  16. package/dist/{chunk-T3CYF3DH.js.map → chunk-NI3WPW2L.js.map} +1 -1
  17. package/dist/{chunk-TRUEH4I2.js → chunk-PUOQEL6A.js} +2 -2
  18. package/dist/{chunk-NT7OGKYX.js → chunk-SG5YDHSE.js} +3 -3
  19. package/dist/{chunk-AMK3FNOW.js → chunk-WAFY2TCB.js} +3 -3
  20. package/dist/codemode-approvals.d.ts +7 -1
  21. package/dist/connect-attempts.js +2 -2
  22. package/dist/credit-balances.d.ts +25 -4
  23. package/dist/database.d.ts +15 -3
  24. package/dist/editable-artifact-durable-export.js +1 -1
  25. package/dist/editable-artifacts.js +2 -2
  26. package/dist/index.d.ts +24 -2
  27. package/dist/index.js +2782 -2509
  28. package/dist/index.js.map +1 -1
  29. package/dist/interaction-schema.d.ts +2 -0
  30. package/dist/managed-auth-session-sets.js +2 -2
  31. package/dist/mcp-operations.js +1 -1
  32. package/dist/modal-native-live-origin.d.ts +75 -0
  33. package/dist/organization-integration-policy.js +2 -2
  34. package/dist/provision-roles.js +1 -1
  35. package/dist/retained-provider-commands.d.ts +21 -21
  36. package/dist/retained-provider-commands.js +5 -5
  37. package/dist/runtime-posture.d.ts +1 -1
  38. package/dist/sandbox-interaction-idle.d.ts +22 -0
  39. package/dist/session-background-commands.js +3 -3
  40. package/dist/session-command-output.js +4 -4
  41. package/dist/session-event-slices.js +2 -2
  42. package/dist/session-mcp-credential-rotation.js +4 -4
  43. package/dist/session-tenancy.js +2 -2
  44. package/dist/video-generation.js +2 -2
  45. package/dist/workspace-tool-defaults.js +3 -3
  46. package/drizzle/0632_modal_native_live_origin.sql +239 -0
  47. package/package.json +7 -7
  48. package/src/codemode-approvals.ts +52 -22
  49. package/src/codemode-operations.ts +198 -181
  50. package/src/credit-balances.ts +58 -17
  51. package/src/database.ts +47 -8
  52. package/src/index.ts +453 -255
  53. package/src/modal-native-live-origin.ts +148 -0
  54. package/src/provision-roles.ts +12 -0
  55. package/src/runtime-posture.ts +32 -3
  56. package/src/sandbox-interaction-idle.ts +91 -0
  57. package/src/transcription-recordings.ts +3 -1
  58. package/dist/chunk-7QWWTVYH.js.map +0 -1
  59. /package/dist/{chunk-EMYA6XNE.js.map → chunk-4SUZSKKW.js.map} +0 -0
  60. /package/dist/{chunk-VCHK4D6S.js.map → chunk-57FM4RG4.js.map} +0 -0
  61. /package/dist/{chunk-BA52ITIY.js.map → chunk-7HP5NCRN.js.map} +0 -0
  62. /package/dist/{chunk-UQELJ6OM.js.map → chunk-A4LPJOKP.js.map} +0 -0
  63. /package/dist/{chunk-CKDHKQS4.js.map → chunk-DEMX4GWU.js.map} +0 -0
  64. /package/dist/{chunk-GC5GUTV3.js.map → chunk-ISNA4KUA.js.map} +0 -0
  65. /package/dist/{chunk-3WUCM7YF.js.map → chunk-JYKUR5KT.js.map} +0 -0
  66. /package/dist/{chunk-EFANLEWI.js.map → chunk-LGXWM3UJ.js.map} +0 -0
  67. /package/dist/{chunk-TRUEH4I2.js.map → chunk-PUOQEL6A.js.map} +0 -0
  68. /package/dist/{chunk-NT7OGKYX.js.map → chunk-SG5YDHSE.js.map} +0 -0
  69. /package/dist/{chunk-AMK3FNOW.js.map → chunk-WAFY2TCB.js.map} +0 -0
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  lockSessionEventWriteRows
3
- } from "./chunk-NT7OGKYX.js";
3
+ } from "./chunk-SG5YDHSE.js";
4
4
  import {
5
5
  withSessionActivityRlsContext
6
- } from "./chunk-27T4AP25.js";
6
+ } from "./chunk-45EMCVJC.js";
7
7
  import {
8
8
  sandboxRetainedProcesses,
9
9
  sessionBackgroundCommands,
@@ -140,4 +140,4 @@ async function appendSessionCommandOutput(db, input) {
140
140
  export {
141
141
  appendSessionCommandOutput
142
142
  };
143
- //# sourceMappingURL=chunk-AMK3FNOW.js.map
143
+ //# sourceMappingURL=chunk-WAFY2TCB.js.map
@@ -33,7 +33,13 @@ export declare function adoptCodemodeApproval(db: Database, input: CodemodeConti
33
33
  catalogDigest: string;
34
34
  effectDigest: string | null;
35
35
  }, onTerminal?: (tx: Database, operation: CodemodeOperation) => Promise<void>): Promise<CodemodeOperation | null>;
36
- /** Read a handle with the current exact attempt and same original caller; old bearer authority is insufficient. */
36
+ /**
37
+ * Read a handle with the current exact attempt and same original caller; old
38
+ * bearer authority is insufficient. This is a status read polled while a
39
+ * caller waits, so it is one plain snapshot select: it proves the exact live
40
+ * attempt in the same statement but takes no session/turn/attempt row locks
41
+ * and is not refused by a pending Pause/Steer, which owns the write fence only.
42
+ */
37
43
  export declare function readTurnCodemodeOperation(db: Database, input: CodemodeContinuationScope & {
38
44
  operationId: string;
39
45
  callerSubjectId: string;
@@ -7,8 +7,8 @@ import {
7
7
  getConnectAttempt,
8
8
  getConnectBeginReplay,
9
9
  listPendingConnectAttempts
10
- } from "./chunk-EFANLEWI.js";
11
- import "./chunk-27T4AP25.js";
10
+ } from "./chunk-LGXWM3UJ.js";
11
+ import "./chunk-45EMCVJC.js";
12
12
  import "./chunk-JL6TBB76.js";
13
13
  import "./chunk-P7YDM2RI.js";
14
14
  import "./chunk-PZ5AY32C.js";
@@ -5,14 +5,35 @@ type CreditBalanceSnapshot = BillingBalance & {
5
5
  creditPolicyRevision?: number;
6
6
  };
7
7
  export declare function getBillingBalance(db: Database, accountId: string, policyRevision?: number): Promise<CreditBalanceSnapshot>;
8
- /** Missing model means a non-model resource, which can only use general credits. */
9
- export declare function spendableCreditMicros(balance: BillingBalance, modelId?: string): number;
10
- export declare function getSpendableCreditBalance(db: Database, accountId: string, modelId?: string, policyRevision?: number): Promise<CreditBalanceSnapshot>;
11
- export declare function planCreditDebit(balance: BillingBalance, requestedMicros: number, modelId?: string): {
8
+ /**
9
+ * What a charge pays for. A canonical model ID uses grants scoped to that
10
+ * model; {@link VOICE_CREDIT_USAGE} (dictation and live voice) uses grants
11
+ * that cover voice, which are the verified-signup trial credits. Omitted means
12
+ * a non-model resource, which can only use general credits.
13
+ */
14
+ export type CreditUsage = string | {
15
+ readonly kind: "voice";
16
+ } | undefined;
17
+ /** Deployment-funded dictation and live voice. */
18
+ export declare const VOICE_CREDIT_USAGE: {
19
+ readonly kind: "voice";
20
+ };
21
+ export declare function spendableCreditMicros(balance: BillingBalance, usage?: CreditUsage): number;
22
+ export declare function getSpendableCreditBalance(db: Database, accountId: string, usage?: CreditUsage, policyRevision?: number): Promise<CreditBalanceSnapshot>;
23
+ export declare function planCreditDebit(balance: BillingBalance, requestedMicros: number, usage?: CreditUsage): {
12
24
  debitedMicros: number;
13
25
  allocations: {
14
26
  grantEntryId: string;
15
27
  amountMicros: number;
16
28
  }[];
17
29
  };
30
+ /**
31
+ * Allocations for an already-consumed charge of the full amount: covering
32
+ * grants pay what they can and general credit takes the rest, possibly going
33
+ * negative.
34
+ */
35
+ export declare function planPostUseCreditAllocations(balance: BillingBalance, amountMicros: number, usage: CreditUsage): {
36
+ grantEntryId: string;
37
+ amountMicros: number;
38
+ }[];
18
39
  export {};
@@ -191,8 +191,20 @@ export declare function withWorkspaceRls<T>(db: Database, workspaceId: string, f
191
191
  */
192
192
  export declare function withSessionActivityRlsContext<T>(db: Database, context: RlsContext & {
193
193
  workspaceId: string;
194
- }, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig, fenceMode?: "shared" | "none", organizationMembershipFence?: boolean): Promise<T>;
195
- export declare function withWorkspaceSessionActivityRls<T>(db: Database, workspaceId: string, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
194
+ }, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig, fenceMode?: "shared" | "none", organizationMembershipFence?: OrganizationMembershipFenceMode): Promise<T>;
195
+ /**
196
+ * `true`/`"exclusive"`: the callback reauthorizes or mutates under the
197
+ * organization-membership lifecycle lock. `"shared"`: the callback only reads
198
+ * membership-fenced authority and must never escalate to exclusive.
199
+ */
200
+ export type OrganizationMembershipFenceMode = boolean | "exclusive" | "shared";
201
+ /**
202
+ * `organizationMembershipFence` is required when the callback takes the
203
+ * organization-membership lifecycle lock (for example external-actor
204
+ * reauthorization): that lock precedes the session-tenancy fence and the
205
+ * canonical control/workspace/session prefix, never follows it.
206
+ */
207
+ export declare function withWorkspaceSessionActivityRls<T>(db: Database, workspaceId: string, fn: (db: SessionActivityDatabase) => Promise<T>, transactionConfig?: PgTransactionConfig, organizationMembershipFence?: boolean): Promise<T>;
196
208
  /**
197
209
  * Run one of several ordered workspace activity scopes inside a caller-owned
198
210
  * transaction. Each scope is fully finalized before restoring the caller's
@@ -211,7 +223,7 @@ export declare function retrySessionActivityRls<T>(db: Database, workspaceId: st
211
223
  /** Claim can inherit membership-fenced causal authority after locking the
212
224
  * session. Acquire that fence before tenancy/control/session instead. An
213
225
  * enclosing transaction must preserve this same lock prefix. */
214
- organizationMembershipFence?: boolean;
226
+ organizationMembershipFence?: OrganizationMembershipFenceMode;
215
227
  }, fn: (db: SessionActivityDatabase) => Promise<T>): Promise<T>;
216
228
  export declare function retryWorkspacePersistence<T>(db: Database, workspaceId: string, options: IdempotentPersistenceTransactionOptions, fn: (db: Database) => Promise<T>): Promise<T>;
217
229
  export declare function retryRlsPersistence<T>(db: Database, context: RlsContext, options: IdempotentPersistenceTransactionOptions, fn: (db: Database) => Promise<T>): Promise<T>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-27T4AP25.js";
4
+ } from "./chunk-45EMCVJC.js";
5
5
  import "./chunk-JL6TBB76.js";
6
6
  import "./chunk-P7YDM2RI.js";
7
7
  import "./chunk-PZ5AY32C.js";
@@ -10,8 +10,8 @@ import {
10
10
  listEditableArtifactIdsForSession,
11
11
  touchEditableArtifactSessionLink,
12
12
  transactionallyAuthorizeEditableArtifactActor
13
- } from "./chunk-TRUEH4I2.js";
14
- import "./chunk-27T4AP25.js";
13
+ } from "./chunk-PUOQEL6A.js";
14
+ import "./chunk-45EMCVJC.js";
15
15
  import "./chunk-JL6TBB76.js";
16
16
  import "./chunk-P7YDM2RI.js";
17
17
  import "./chunk-PZ5AY32C.js";
package/dist/index.d.ts CHANGED
@@ -3,10 +3,12 @@ export * from "./voice-transcription-settlement.js";
3
3
  import { type ConnectionMetadataWithVerification } from "./connection-metadata.js";
4
4
  export { getConnectionMetadata, listConnectionsMetadata, type ConnectionMetadataWithVerification, } from "./connection-metadata.js";
5
5
  export { readCreditPromotionPolicy } from "./credit-promotion-policy.js";
6
- export { getBillingBalance, getSpendableCreditBalance, spendableCreditMicros, } from "./credit-balances.js";
6
+ import { type CreditUsage } from "./credit-balances.js";
7
+ export { getBillingBalance, getSpendableCreditBalance, spendableCreditMicros, VOICE_CREDIT_USAGE, type CreditUsage, } from "./credit-balances.js";
7
8
  import { type TurnAttemptFenceRejectReason } from "./session-attempt-fence.js";
8
9
  export type { TurnAttemptFenceRejectReason } from "./session-attempt-fence.js";
9
10
  export { resolveConnectorActionPolicy, connectorActionPolicyDecision, projectConnectorToolPermission, connectorActionPoliciesForAccountRoutes, connectorToolPolicyRevision, ConnectorToolPermissionConflictError, } from "./connector-action-policy.js";
11
+ export { lockLiveNativeOriginalOriginTx, type ModalNativeLiveOriginScope, type ModalNativeLiveOriginProjection, type ModalNativeLiveOriginResult, } from "./modal-native-live-origin.js";
10
12
  export { SubscriptionAccountChangedError } from "./subscription-account-conflict.js";
11
13
  import type { GoalAdmissionPausedReason } from "@opengeni/contracts";
12
14
  export declare const getScheduledTaskClaudeProviderAccountAuthoritySnapshot: (db: Database, workspaceId: string, taskId: string) => Promise<{
@@ -1099,6 +1101,11 @@ export declare function applyCreditDebitAfterUse(db: Database, input: {
1099
1101
  idempotencyKey: string;
1100
1102
  metadata?: Record<string, unknown>;
1101
1103
  occurredAt?: Date;
1104
+ /**
1105
+ * What the charge paid for. When set, grants covering it pay first (oldest
1106
+ * first) and general credit takes the rest. Omitted: general credit only.
1107
+ */
1108
+ usage?: CreditUsage;
1102
1109
  }): Promise<{
1103
1110
  balance: BillingBalance;
1104
1111
  debitedMicros: number;
@@ -8406,6 +8413,9 @@ export declare function confirmDrainCold(db: Database, input: {
8406
8413
  idleCommandContainmentMs?: number | undefined;
8407
8414
  }): Promise<{
8408
8415
  wentCold: boolean;
8416
+ /** The missing provider was an unpublished warming replacement: its loss
8417
+ * recorded no lost workspace (see `unpublishedWarmingLoss`). */
8418
+ unpublishedProviderLost?: boolean;
8409
8419
  backgroundCommandEvents?: SessionEvent[];
8410
8420
  }>;
8411
8421
  export declare class SandboxWorkspaceMutationFencedError extends Error {
@@ -8458,13 +8468,24 @@ export type SandboxWorkspaceMutationPhysicalSettlement = Readonly<{
8458
8468
  operation: string;
8459
8469
  outcome: "resolved";
8460
8470
  }>;
8471
+ /** Durable terminal truth of the retained process whose concurrent settlement
8472
+ * fenced a physically settled mutation's output. */
8473
+ export type SandboxRetainedProcessTerminalState = Readonly<{
8474
+ state: "exited" | "lost";
8475
+ exitCode: number | null;
8476
+ }>;
8461
8477
  /** The exact provider outcome committed before its output failed an acceptance
8462
8478
  * fence. A generic admission fence or failed transaction carries no receipt.
8463
8479
  * This error never authorizes accepting output or replaying provider work. */
8464
8480
  export declare class SandboxWorkspaceMutationOutputRejectedError extends SandboxWorkspaceMutationFencedError {
8465
8481
  readonly name = "SandboxWorkspaceMutationOutputRejectedError";
8466
8482
  readonly physicalSettlement: SandboxWorkspaceMutationPhysicalSettlement;
8467
- constructor(code: SandboxWorkspaceMutationFencedError["code"], message: string, physicalSettlement: SandboxWorkspaceMutationPhysicalSettlement);
8483
+ /** Non-null only when the fence was the retained process itself having
8484
+ * already reached a durable terminal state (for example the reaper settled
8485
+ * the exit between admission and settlement). The output stays rejected;
8486
+ * callers may report this stored terminal truth instead of failing. */
8487
+ readonly retainedProcessTerminal: SandboxRetainedProcessTerminalState | null;
8488
+ constructor(code: SandboxWorkspaceMutationFencedError["code"], message: string, physicalSettlement: SandboxWorkspaceMutationPhysicalSettlement, retainedProcessTerminal?: SandboxRetainedProcessTerminalState | null);
8468
8489
  matchesPhysicalSettlement(input: {
8469
8490
  accountId: string;
8470
8491
  workspaceId: string;
@@ -11984,6 +12005,7 @@ export * from "./codemode-approvals.js";
11984
12005
  export * from "./tool-action-reviews.js";
11985
12006
  export * from "./browser-sessions.js";
11986
12007
  export * from "./browser-deadline-checkpoints.js";
12008
+ export * from "./sandbox-interaction-idle.js";
11987
12009
  export * from "./computer-sessions.js";
11988
12010
  export * from "./browser-identities.js";
11989
12011
  export * from "./browser-state-artifacts.js";