@opengeni/db 1.1.0 → 1.2.0
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.
- package/dist/canonical-human-identities.js +3 -3
- package/dist/capability-reconciliation.js +2 -2
- package/dist/{chunk-J4WFOVBV.js → chunk-3GAR5UN3.js} +2 -2
- package/dist/{chunk-Z5HJXH3X.js → chunk-3TGYFFZR.js} +2 -2
- package/dist/{chunk-GLA5YCQS.js → chunk-6EIEGHPK.js} +4 -4
- package/dist/{chunk-BLUQG54M.js → chunk-CONWNUSL.js} +2 -2
- package/dist/{chunk-EKXCF3FH.js → chunk-CYP72JTQ.js} +11 -4
- package/dist/{chunk-EKXCF3FH.js.map → chunk-CYP72JTQ.js.map} +1 -1
- package/dist/{chunk-VOB6TXSJ.js → chunk-FWQNHNOU.js} +39 -2
- package/dist/chunk-FWQNHNOU.js.map +1 -0
- package/dist/{chunk-7Z7ALFRE.js → chunk-GDN5TSZP.js} +2 -2
- package/dist/{chunk-M3SWH4MU.js → chunk-JICUP7ZR.js} +2 -2
- package/dist/{chunk-KJVOBLFC.js → chunk-JLVWBIEM.js} +3 -3
- package/dist/{chunk-BZV5ZDRY.js → chunk-LXPFNG4L.js} +2 -2
- package/dist/{chunk-SKYRM7R7.js → chunk-O2Y5E5M3.js} +68 -32
- package/dist/chunk-O2Y5E5M3.js.map +1 -0
- package/dist/{chunk-M2YGXCCQ.js → chunk-QFJNEXFL.js} +2 -2
- package/dist/{chunk-CIGHXFPD.js → chunk-UCIMHNII.js} +101 -21
- package/dist/chunk-UCIMHNII.js.map +1 -0
- package/dist/{chunk-ODKYBA3C.js → chunk-VDPCIFKL.js} +5 -5
- package/dist/{chunk-T5NHDEZW.js → chunk-YOYILDLY.js} +26 -1
- package/dist/chunk-YOYILDLY.js.map +1 -0
- package/dist/connect-attempts.js +3 -3
- package/dist/credit-balances.d.ts +18 -0
- package/dist/credit-promotion-policy.d.ts +10 -0
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/index.d.ts +21 -5
- package/dist/index.js +2369 -2247
- package/dist/index.js.map +1 -1
- package/dist/managed-auth-session-sets.js +3 -3
- package/dist/managed-user-setup.d.ts +1 -0
- package/dist/mcp-operations.js +2 -2
- package/dist/organization-integration-policy.js +3 -3
- package/dist/organization-membership-lifecycle.d.ts +1 -0
- package/dist/persistence-errors.d.ts +9 -6
- package/dist/provision-roles.js +1 -1
- package/dist/retained-provider-commands.js +6 -6
- package/dist/runtime-posture.d.ts +4 -4
- package/dist/schema.d.ts +121 -2
- package/dist/schema.js +3 -1
- package/dist/session-background-commands.js +4 -4
- package/dist/session-command-output.js +5 -5
- package/dist/session-event-slices.js +3 -3
- package/dist/session-mcp-credential-rotation.js +5 -5
- package/dist/session-tenancy.js +3 -3
- package/dist/video-generation.js +3 -3
- package/dist/workspace-tool-defaults.js +4 -4
- package/drizzle/0613_model_scoped_promotional_credits.sql +238 -0
- package/drizzle/0614_quiescence_command_containment.sql +7 -0
- package/drizzle/0615_credit_promotion_policy_validation.sql +63 -0
- package/package.json +7 -7
- package/src/credit-balances.ts +109 -0
- package/src/credit-promotion-policy.ts +12 -0
- package/src/database.ts +81 -42
- package/src/index.ts +201 -60
- package/src/managed-user-setup.ts +8 -0
- package/src/organization-membership-lifecycle.ts +8 -0
- package/src/persistence-errors.ts +17 -6
- package/src/provision-roles.ts +9 -0
- package/src/runtime-posture.ts +22 -0
- package/src/schema.ts +40 -1
- package/src/video-generation.ts +2 -7
- package/dist/chunk-CIGHXFPD.js.map +0 -1
- package/dist/chunk-SKYRM7R7.js.map +0 -1
- package/dist/chunk-T5NHDEZW.js.map +0 -1
- package/dist/chunk-VOB6TXSJ.js.map +0 -1
- /package/dist/{chunk-J4WFOVBV.js.map → chunk-3GAR5UN3.js.map} +0 -0
- /package/dist/{chunk-Z5HJXH3X.js.map → chunk-3TGYFFZR.js.map} +0 -0
- /package/dist/{chunk-GLA5YCQS.js.map → chunk-6EIEGHPK.js.map} +0 -0
- /package/dist/{chunk-BLUQG54M.js.map → chunk-CONWNUSL.js.map} +0 -0
- /package/dist/{chunk-7Z7ALFRE.js.map → chunk-GDN5TSZP.js.map} +0 -0
- /package/dist/{chunk-M3SWH4MU.js.map → chunk-JICUP7ZR.js.map} +0 -0
- /package/dist/{chunk-KJVOBLFC.js.map → chunk-JLVWBIEM.js.map} +0 -0
- /package/dist/{chunk-BZV5ZDRY.js.map → chunk-LXPFNG4L.js.map} +0 -0
- /package/dist/{chunk-M2YGXCCQ.js.map → chunk-QFJNEXFL.js.map} +0 -0
- /package/dist/{chunk-ODKYBA3C.js.map → chunk-VDPCIFKL.js.map} +0 -0
package/dist/connect-attempts.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
getConnectAttempt,
|
|
8
8
|
getConnectBeginReplay,
|
|
9
9
|
listPendingConnectAttempts
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-CONWNUSL.js";
|
|
11
|
+
import "./chunk-O2Y5E5M3.js";
|
|
12
|
+
import "./chunk-FWQNHNOU.js";
|
|
13
13
|
import "./chunk-P7YDM2RI.js";
|
|
14
14
|
import "./chunk-PZ5AY32C.js";
|
|
15
15
|
export {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BillingBalance } from "@opengeni/contracts";
|
|
2
|
+
import type { Database } from "./database.js";
|
|
3
|
+
/** Read totals and grant remainders from one database snapshot. */
|
|
4
|
+
type CreditBalanceSnapshot = BillingBalance & {
|
|
5
|
+
creditPolicyRevision?: number;
|
|
6
|
+
};
|
|
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): {
|
|
12
|
+
debitedMicros: number;
|
|
13
|
+
allocations: {
|
|
14
|
+
grantEntryId: string;
|
|
15
|
+
amountMicros: number;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Database } from "./database.js";
|
|
2
|
+
/** Runtime policy supersedes deployment bootstrap configuration. No process cache. */
|
|
3
|
+
export declare function readCreditPromotionPolicy(db: Database): Promise<{
|
|
4
|
+
defaultModelIds?: string[] | undefined;
|
|
5
|
+
signupModelIds?: string[] | undefined;
|
|
6
|
+
offers: Record<string, {
|
|
7
|
+
label: string;
|
|
8
|
+
eligibleModelIds?: string[] | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
} | null>;
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
listEditableArtifactIdsForSession,
|
|
11
11
|
touchEditableArtifactSessionLink,
|
|
12
12
|
transactionallyAuthorizeEditableArtifactActor
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-LXPFNG4L.js";
|
|
14
|
+
import "./chunk-O2Y5E5M3.js";
|
|
15
|
+
import "./chunk-FWQNHNOU.js";
|
|
16
16
|
import "./chunk-P7YDM2RI.js";
|
|
17
17
|
import "./chunk-PZ5AY32C.js";
|
|
18
18
|
export {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { readCreditPromotionPolicy } from "./credit-promotion-policy.js";
|
|
2
|
+
export { getBillingBalance, getSpendableCreditBalance, spendableCreditMicros, } from "./credit-balances.js";
|
|
1
3
|
export { SubscriptionAccountChangedError } from "./subscription-account-conflict.js";
|
|
2
4
|
import type { GoalAdmissionPausedReason } from "@opengeni/contracts";
|
|
3
5
|
export declare const getScheduledTaskClaudeProviderAccountAuthoritySnapshot: (db: Database, workspaceId: string, taskId: string) => Promise<{
|
|
@@ -96,6 +98,7 @@ import { type SQL } from "drizzle-orm";
|
|
|
96
98
|
export { frozenInitiatorForCommandActor, type FrozenTurnInitiator } from "./turn-initiator.js";
|
|
97
99
|
export { LOSSLESS_TEXT_PREFIX } from "./lossless-json.js";
|
|
98
100
|
import { type NewSessionDraftSnapshot } from "./new-session-drafts.js";
|
|
101
|
+
export { DatabaseTransactionError } from "./persistence-errors.js";
|
|
99
102
|
import { type SessionDiscoveryControl, type SessionCommandActor, type SessionTurnAttemptOutcome } from "./session-control.js";
|
|
100
103
|
import { type ConnectedMachineBackgroundCommandClaim } from "./session-background-commands.js";
|
|
101
104
|
import { type SessionRealtimeContinuityEntry } from "./session-realtime-context.js";
|
|
@@ -1046,6 +1049,7 @@ export declare function applyCreditLedgerEntry(db: Database, input: {
|
|
|
1046
1049
|
workspaceId?: string | null;
|
|
1047
1050
|
type: string;
|
|
1048
1051
|
amountMicros: number;
|
|
1052
|
+
eligibleModelIds?: string[] | undefined;
|
|
1049
1053
|
sourceType?: string | null;
|
|
1050
1054
|
sourceId?: string | null;
|
|
1051
1055
|
idempotencyKey: string;
|
|
@@ -1057,6 +1061,9 @@ export declare function applyCreditDebitUpToBalance(db: Database, input: {
|
|
|
1057
1061
|
workspaceId?: string | null;
|
|
1058
1062
|
type: string;
|
|
1059
1063
|
requestedAmountMicros: number;
|
|
1064
|
+
/** Canonical, accepted model ID. Omitted for non-model usage. */
|
|
1065
|
+
modelId?: string;
|
|
1066
|
+
creditPolicyRevision?: number | undefined;
|
|
1060
1067
|
sourceType?: string | null;
|
|
1061
1068
|
sourceId?: string | null;
|
|
1062
1069
|
idempotencyKey: string;
|
|
@@ -1112,7 +1119,6 @@ export declare function recordStripeWebhookEvent(db: Database, input: {
|
|
|
1112
1119
|
}): Promise<boolean>;
|
|
1113
1120
|
export declare function isStripeWebhookProcessed(db: Database, id: string): Promise<boolean>;
|
|
1114
1121
|
export declare function markStripeWebhookProcessed(db: Database, id: string): Promise<void>;
|
|
1115
|
-
export declare function getBillingBalance(db: Database, accountId: string): Promise<BillingBalance>;
|
|
1116
1122
|
/**
|
|
1117
1123
|
* Whether the organization holds a positive OpenGeni credit balance, whatever
|
|
1118
1124
|
* its source: a purchase, an operator grant, a test credit, or the one-time
|
|
@@ -8296,16 +8302,24 @@ export declare function reapStaleLeaseHolders(db: Database, input: {
|
|
|
8296
8302
|
drained: ReapDrainable[];
|
|
8297
8303
|
}>;
|
|
8298
8304
|
/** Settlement reasons for legacy retained commands that containment stopped
|
|
8299
|
-
* after a verified checkpoint.
|
|
8305
|
+
* after a verified checkpoint. None is exit proof: the command settles
|
|
8300
8306
|
* `lost` with no exit code. */
|
|
8301
8307
|
export declare const IDLE_COMMAND_CONTAINMENT_REASON = "idle_containment";
|
|
8302
8308
|
export declare const DEADLINE_COMMAND_CONTAINMENT_REASON = "provider_deadline_containment";
|
|
8309
|
+
export declare const QUIESCENCE_COMMAND_CONTAINMENT_REASON = "quiescence_containment";
|
|
8310
|
+
type SettledCommandOwner = {
|
|
8311
|
+
sessionId: string;
|
|
8312
|
+
attemptId: string;
|
|
8313
|
+
temporalWorkflowId: string;
|
|
8314
|
+
temporalWorkflowRunId: string;
|
|
8315
|
+
temporalActivityId: string;
|
|
8316
|
+
};
|
|
8303
8317
|
/** Bounded per-candidate containment inspection outcomes (metric labels). */
|
|
8304
|
-
export type CommandContainmentInspection = "idle_enrolled" | "deadline_enrolled" | "resumed_enrolled" | "not_eligible" | "inspection_failed";
|
|
8318
|
+
export type CommandContainmentInspection = "idle_enrolled" | "deadline_enrolled" | "quiescence_enrolled" | "resumed_enrolled" | "not_eligible" | "inspection_failed";
|
|
8305
8319
|
export type CommandContainmentEnrollment = ReapDrainable & {
|
|
8306
|
-
/** `idle`/`deadline` newly enrolled this call; `resumed` continues an
|
|
8320
|
+
/** `idle`/`deadline`/`quiescence` newly enrolled this call; `resumed` continues an
|
|
8307
8321
|
* existing enrollment whose drain has not committed yet. */
|
|
8308
|
-
mode: "idle" | "deadline" | "resumed";
|
|
8322
|
+
mode: "idle" | "deadline" | "quiescence" | "resumed";
|
|
8309
8323
|
};
|
|
8310
8324
|
/** Pending machine input that would start a turn in an idle session, by the
|
|
8311
8325
|
* wake class map: every immediate kind except terminal command results (held
|
|
@@ -8337,6 +8351,8 @@ export declare function enrollRetainedCommandContainment(db: Database, input: {
|
|
|
8337
8351
|
sandboxGroupId: string;
|
|
8338
8352
|
/** Omit to evaluate only the provider-deadline rule. */
|
|
8339
8353
|
idleCommandContainmentMs?: number | undefined;
|
|
8354
|
+
/** Internal recovery authority: caller verified exact Temporal settlement. */
|
|
8355
|
+
settledOwner?: SettledCommandOwner;
|
|
8340
8356
|
}): Promise<CommandContainmentEnrollment | null>;
|
|
8341
8357
|
export declare function reapStaleLeaseHoldersGlobal(db: Database, input: {
|
|
8342
8358
|
viewerHolderTtlMs: number;
|