@opengeni/db 1.3.0 → 1.4.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 (91) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/capability-reconciliation.js +2 -2
  3. package/dist/{chunk-7QWWTVYH.js → chunk-5ROHLEN6.js} +29 -4
  4. package/dist/chunk-5ROHLEN6.js.map +1 -0
  5. package/dist/{chunk-AQMH2ZEH.js → chunk-A4J7EECR.js} +2 -2
  6. package/dist/{chunk-VQX54TK3.js → chunk-B5C5SBSI.js} +3 -3
  7. package/dist/{chunk-OI6YZXTU.js → chunk-DKFEUGM4.js} +2 -2
  8. package/dist/{chunk-HYBQABBJ.js → chunk-HUKBIZGH.js} +2 -2
  9. package/dist/{chunk-LRSIODCQ.js → chunk-IT3EYY2C.js} +6 -4
  10. package/dist/{chunk-LRSIODCQ.js.map → chunk-IT3EYY2C.js.map} +1 -1
  11. package/dist/{chunk-DSNEIW5E.js → chunk-JL6TBB76.js} +2 -1
  12. package/dist/chunk-JL6TBB76.js.map +1 -0
  13. package/dist/{chunk-OEFNTGR3.js → chunk-JWBEE4CL.js} +4 -4
  14. package/dist/{chunk-BRVBLQAL.js → chunk-K5MTNKJU.js} +4 -4
  15. package/dist/{chunk-6UKNJ43T.js → chunk-NZ2SP55O.js} +2 -2
  16. package/dist/{chunk-3XHC5KC5.js → chunk-OKCBARX6.js} +2 -2
  17. package/dist/{chunk-PNWWNEDM.js → chunk-OV5AUIBA.js} +2 -2
  18. package/dist/{chunk-BID3CNN3.js → chunk-TODVDGMO.js} +36 -18
  19. package/dist/{chunk-BID3CNN3.js.map → chunk-TODVDGMO.js.map} +1 -1
  20. package/dist/{chunk-6S5T6FSP.js → chunk-W75DRYG3.js} +5 -5
  21. package/dist/{chunk-7S3O33NM.js → chunk-Y72DP3JF.js} +2 -2
  22. package/dist/codemode-approvals.d.ts +7 -1
  23. package/dist/connect-attempts.js +3 -3
  24. package/dist/connection-metadata.d.ts +416 -0
  25. package/dist/credit-balances.d.ts +25 -4
  26. package/dist/database.d.ts +7 -1
  27. package/dist/editable-artifact-durable-export.js +2 -2
  28. package/dist/editable-artifacts.js +3 -3
  29. package/dist/index.d.ts +51 -8
  30. package/dist/index.js +10826 -10129
  31. package/dist/index.js.map +1 -1
  32. package/dist/legacy-tool-action-reviews.d.ts +75 -0
  33. package/dist/managed-auth-session-sets.js +3 -3
  34. package/dist/mcp-operations.js +2 -2
  35. package/dist/modal-native-live-origin.d.ts +75 -0
  36. package/dist/organization-integration-policy.js +3 -3
  37. package/dist/organization-slack-bots.d.ts +1 -1
  38. package/dist/provision-roles.js +1 -1
  39. package/dist/retained-provider-commands.d.ts +21 -21
  40. package/dist/retained-provider-commands.js +6 -6
  41. package/dist/runtime-posture.d.ts +1 -1
  42. package/dist/sandbox-interaction-idle.d.ts +22 -0
  43. package/dist/schema.js +1 -1
  44. package/dist/session-background-commands.js +4 -4
  45. package/dist/session-command-output.js +5 -5
  46. package/dist/session-event-slices.js +3 -3
  47. package/dist/session-mcp-credential-rotation.js +5 -5
  48. package/dist/session-realtime-billing.d.ts +48 -0
  49. package/dist/session-realtime.d.ts +8 -2
  50. package/dist/session-tenancy.js +3 -3
  51. package/dist/video-generation.js +3 -3
  52. package/dist/voice-transcription-settlement.d.ts +36 -0
  53. package/dist/workspace-tool-defaults.js +4 -4
  54. package/drizzle/0623_voice_transcription_attribution.sql +128 -0
  55. package/drizzle/0624_azure_live_realtime_model.sql +30 -0
  56. package/drizzle/0625_transcription_billing_refusal_codes.sql +29 -0
  57. package/drizzle/0632_modal_native_live_origin.sql +239 -0
  58. package/package.json +7 -7
  59. package/src/codemode-approvals.ts +52 -22
  60. package/src/codemode-operations.ts +198 -181
  61. package/src/connection-metadata.ts +166 -0
  62. package/src/credit-balances.ts +58 -17
  63. package/src/database.ts +9 -0
  64. package/src/index.ts +540 -412
  65. package/src/insights-unified.ts +2 -1
  66. package/src/legacy-tool-action-reviews.ts +242 -0
  67. package/src/modal-native-live-origin.ts +148 -0
  68. package/src/organization-slack-bots.ts +1 -1
  69. package/src/provision-roles.ts +12 -0
  70. package/src/runtime-posture.ts +32 -3
  71. package/src/sandbox-interaction-idle.ts +91 -0
  72. package/src/schema.ts +1 -0
  73. package/src/session-realtime-billing.ts +135 -0
  74. package/src/session-realtime-ledger.ts +9 -4
  75. package/src/session-realtime.ts +20 -2
  76. package/src/tool-action-reviews.ts +129 -18
  77. package/src/transcription-recordings.ts +3 -1
  78. package/src/voice-transcription-settlement.ts +94 -0
  79. package/dist/chunk-7QWWTVYH.js.map +0 -1
  80. package/dist/chunk-DSNEIW5E.js.map +0 -1
  81. /package/dist/{chunk-AQMH2ZEH.js.map → chunk-A4J7EECR.js.map} +0 -0
  82. /package/dist/{chunk-VQX54TK3.js.map → chunk-B5C5SBSI.js.map} +0 -0
  83. /package/dist/{chunk-OI6YZXTU.js.map → chunk-DKFEUGM4.js.map} +0 -0
  84. /package/dist/{chunk-HYBQABBJ.js.map → chunk-HUKBIZGH.js.map} +0 -0
  85. /package/dist/{chunk-OEFNTGR3.js.map → chunk-JWBEE4CL.js.map} +0 -0
  86. /package/dist/{chunk-BRVBLQAL.js.map → chunk-K5MTNKJU.js.map} +0 -0
  87. /package/dist/{chunk-6UKNJ43T.js.map → chunk-NZ2SP55O.js.map} +0 -0
  88. /package/dist/{chunk-3XHC5KC5.js.map → chunk-OKCBARX6.js.map} +0 -0
  89. /package/dist/{chunk-PNWWNEDM.js.map → chunk-OV5AUIBA.js.map} +0 -0
  90. /package/dist/{chunk-6S5T6FSP.js.map → chunk-W75DRYG3.js.map} +0 -0
  91. /package/dist/{chunk-7S3O33NM.js.map → chunk-Y72DP3JF.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  cancelUnacceptedVideoGenerationsForToolCallsInTransaction
3
- } from "./chunk-BID3CNN3.js";
3
+ } from "./chunk-TODVDGMO.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-LRSIODCQ.js";
17
+ } from "./chunk-IT3EYY2C.js";
18
18
  import {
19
19
  auditEvents,
20
20
  codexCapacityWaiters,
@@ -42,7 +42,7 @@ import {
42
42
  workspaceInferenceControls,
43
43
  workspaceMemberships,
44
44
  workspaces
45
- } from "./chunk-DSNEIW5E.js";
45
+ } from "./chunk-JL6TBB76.js";
46
46
  import {
47
47
  LOSSLESS_CONTENT_CODEC_VERSION,
48
48
  fromPostgresLosslessJson,
@@ -6449,4 +6449,4 @@ export {
6449
6449
  setWorkspacePauseTimerInTransaction,
6450
6450
  fireWorkspacePauseTimerInTransaction
6451
6451
  };
6452
- //# sourceMappingURL=chunk-OEFNTGR3.js.map
6452
+ //# sourceMappingURL=chunk-JWBEE4CL.js.map
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  lockSessionEventWriteRows
3
- } from "./chunk-OEFNTGR3.js";
3
+ } from "./chunk-JWBEE4CL.js";
4
4
  import {
5
5
  withSessionActivityRlsContext
6
- } from "./chunk-LRSIODCQ.js";
6
+ } from "./chunk-IT3EYY2C.js";
7
7
  import {
8
8
  sandboxRetainedProcesses,
9
9
  sessionBackgroundCommands,
10
10
  sessionEvents,
11
11
  sessions
12
- } from "./chunk-DSNEIW5E.js";
12
+ } from "./chunk-JL6TBB76.js";
13
13
  import {
14
14
  fromPostgresLosslessJson,
15
15
  withLosslessContentWriteVersion
@@ -140,4 +140,4 @@ async function appendSessionCommandOutput(db, input) {
140
140
  export {
141
141
  appendSessionCommandOutput
142
142
  };
143
- //# sourceMappingURL=chunk-BRVBLQAL.js.map
143
+ //# sourceMappingURL=chunk-K5MTNKJU.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-LRSIODCQ.js";
4
+ } from "./chunk-IT3EYY2C.js";
5
5
 
6
6
  // src/canonical-human-identities.ts
7
7
  import { createHash } from "crypto";
@@ -318,4 +318,4 @@ export {
318
318
  getCanonicalHumanIdentityProjection,
319
319
  applyCanonicalHumanIdentityOperation
320
320
  };
321
- //# sourceMappingURL=chunk-6UKNJ43T.js.map
321
+ //# sourceMappingURL=chunk-NZ2SP55O.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-LRSIODCQ.js";
4
+ } from "./chunk-IT3EYY2C.js";
5
5
 
6
6
  // src/editable-artifacts.ts
7
7
  import { createHash } from "crypto";
@@ -3592,4 +3592,4 @@ export {
3592
3592
  PostgresEditableArtifactLiveReadStore,
3593
3593
  transactionallyAuthorizeEditableArtifactActor
3594
3594
  };
3595
- //# sourceMappingURL=chunk-3XHC5KC5.js.map
3595
+ //# sourceMappingURL=chunk-OKCBARX6.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  setSubjectRlsContext,
3
3
  withRlsContext
4
- } from "./chunk-LRSIODCQ.js";
4
+ } from "./chunk-IT3EYY2C.js";
5
5
 
6
6
  // src/connection-token-resolver.ts
7
7
  import { normalizeSlackScopes, OFFICIAL_SLACK_MCP_URL } from "@opengeni/contracts/slack-rest-mcp";
@@ -857,4 +857,4 @@ export {
857
857
  refreshOAuthConnectionCredential,
858
858
  isPrivateAddress
859
859
  };
860
- //# sourceMappingURL=chunk-PNWWNEDM.js.map
860
+ //# sourceMappingURL=chunk-OV5AUIBA.js.map
@@ -7,7 +7,7 @@ import {
7
7
  withAccountRls,
8
8
  withRlsContext,
9
9
  withWorkspaceRls
10
- } from "./chunk-LRSIODCQ.js";
10
+ } from "./chunk-IT3EYY2C.js";
11
11
  import {
12
12
  connections,
13
13
  creditDebitAllocations,
@@ -20,7 +20,7 @@ import {
20
20
  workspaceVideoGenerationPolicies,
21
21
  workspaceVideoGenerationQuotas,
22
22
  workspaces
23
- } from "./chunk-DSNEIW5E.js";
23
+ } from "./chunk-JL6TBB76.js";
24
24
 
25
25
  // src/video-generation.ts
26
26
  import {
@@ -345,7 +345,8 @@ async function getBillingBalance(db, accountId, policyRevision) {
345
345
  else policy->'offers'->(g.metadata->>'creditOfferId')->'eligibleModelIds' end,
346
346
  policy->'defaultModelIds'
347
347
  ) from current_policy), to_jsonb(g.eligible_model_ids)),
348
- 'remainingMicros', g.amount_micros - coalesce(used.amount, 0)
348
+ 'remainingMicros', g.amount_micros - coalesce(used.amount, 0),
349
+ 'coversVoice', g.source_type = 'verified_signup_trial'
349
350
  ) order by g.created_at, g.id)
350
351
  from ${creditLedgerEntries} g
351
352
  left join (
@@ -371,30 +372,45 @@ async function getBillingBalance(db, accountId, policyRevision) {
371
372
  };
372
373
  });
373
374
  }
374
- function spendableCreditMicros(balance, modelId) {
375
+ var VOICE_CREDIT_USAGE = Object.freeze({ kind: "voice" });
376
+ function grantCovers(grant, usage) {
377
+ if (!usage) return false;
378
+ if (typeof usage === "string") return grant.eligibleModelIds.includes(usage);
379
+ return grant.coversVoice === true;
380
+ }
381
+ function spendableCreditMicros(balance, usage) {
375
382
  return Math.max(0, balance.generalBalanceMicros ?? balance.balanceMicros) + (balance.promotionalCredits ?? []).reduce(
376
- (sum, grant) => sum + (modelId && grant.eligibleModelIds.includes(modelId) ? grant.remainingMicros : 0),
383
+ (sum, grant) => sum + (grantCovers(grant, usage) ? grant.remainingMicros : 0),
377
384
  0
378
385
  );
379
386
  }
380
- async function getSpendableCreditBalance(db, accountId, modelId, policyRevision) {
387
+ async function getSpendableCreditBalance(db, accountId, usage, policyRevision) {
381
388
  const balance = await getBillingBalance(db, accountId, policyRevision);
382
- return { ...balance, balanceMicros: spendableCreditMicros(balance, modelId) };
389
+ return { ...balance, balanceMicros: spendableCreditMicros(balance, usage) };
390
+ }
391
+ function allocateToCoveringGrants(balance, amountMicros, usage) {
392
+ let remaining = amountMicros;
393
+ const allocations = [];
394
+ for (const grant of balance.promotionalCredits ?? []) {
395
+ if (!remaining || !grantCovers(grant, usage) || grant.remainingMicros <= 0) continue;
396
+ const allocated = Math.min(remaining, grant.remainingMicros);
397
+ allocations.push({ grantEntryId: grant.grantId, amountMicros: allocated });
398
+ remaining -= allocated;
399
+ }
400
+ return allocations;
383
401
  }
384
- function planCreditDebit(balance, requestedMicros, modelId) {
402
+ function planCreditDebit(balance, requestedMicros, usage) {
385
403
  if (!Number.isSafeInteger(requestedMicros) || requestedMicros <= 0) {
386
404
  throw new Error("credit debit requires a positive, safe integer micro amount");
387
405
  }
388
- const debitedMicros = Math.min(requestedMicros, spendableCreditMicros(balance, modelId));
389
- let remaining = debitedMicros;
390
- const allocations = [];
391
- for (const grant of balance.promotionalCredits ?? []) {
392
- if (!remaining || !modelId || !grant.eligibleModelIds.includes(modelId)) continue;
393
- const amountMicros = Math.min(remaining, grant.remainingMicros);
394
- allocations.push({ grantEntryId: grant.grantId, amountMicros });
395
- remaining -= amountMicros;
406
+ const debitedMicros = Math.min(requestedMicros, spendableCreditMicros(balance, usage));
407
+ return { debitedMicros, allocations: allocateToCoveringGrants(balance, debitedMicros, usage) };
408
+ }
409
+ function planPostUseCreditAllocations(balance, amountMicros, usage) {
410
+ if (!Number.isSafeInteger(amountMicros) || amountMicros <= 0) {
411
+ throw new Error("credit debit requires a positive, safe integer micro amount");
396
412
  }
397
- return { debitedMicros, allocations };
413
+ return allocateToCoveringGrants(balance, amountMicros, usage);
398
414
  }
399
415
 
400
416
  // src/video-generation.ts
@@ -1378,9 +1394,11 @@ export {
1378
1394
  checkWorkspaceAllowance,
1379
1395
  maintainWorkspaceAllowances,
1380
1396
  getBillingBalance,
1397
+ VOICE_CREDIT_USAGE,
1381
1398
  spendableCreditMicros,
1382
1399
  getSpendableCreditBalance,
1383
1400
  planCreditDebit,
1401
+ planPostUseCreditAllocations,
1384
1402
  ACTIVE_VIDEO_GENERATION_STATUSES,
1385
1403
  VideoGenerationConflictError,
1386
1404
  VideoGenerationCapacityError,
@@ -1412,4 +1430,4 @@ export {
1412
1430
  mediaGenerationResultForStoredOperation,
1413
1431
  getVideoGenerationOperationSummary
1414
1432
  };
1415
- //# sourceMappingURL=chunk-BID3CNN3.js.map
1433
+ //# sourceMappingURL=chunk-TODVDGMO.js.map