deepline 0.3.334 → 0.3.336

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 (104) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +53 -41
  3. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +14 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +81 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +53 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +48 -4
  7. package/dist/cli/auth-6RQLNYNF.js +31 -0
  8. package/dist/cli/{auth-PAEBUPRS.mjs → auth-M45QKCUL.mjs} +4 -4
  9. package/dist/cli/{billing-QGQJUM5G.mjs → billing-E7ADEFLX.mjs} +4 -4
  10. package/dist/cli/{billing-V746QMQC.js → billing-XCJVALTC.js} +71 -71
  11. package/dist/cli/{chunk-XXZSLV7B.js → chunk-2CJUQWW2.js} +6 -6
  12. package/dist/cli/{chunk-SBEWKGUA.mjs → chunk-4NJCGGHK.mjs} +1 -1
  13. package/dist/cli/{chunk-U724V33M.mjs → chunk-4S3G43M3.mjs} +2 -2
  14. package/dist/cli/{chunk-Z6VHC643.js → chunk-4WHJDGBC.js} +9 -9
  15. package/dist/cli/{chunk-R6O3YVIG.js → chunk-5S4FMN6T.js} +8 -8
  16. package/dist/cli/{chunk-P3ZX3NSE.mjs → chunk-B53RXFGP.mjs} +1 -1
  17. package/dist/cli/{chunk-NLHRXDIT.js → chunk-EBIISKOH.js} +2 -2
  18. package/dist/cli/{chunk-JNNOCMQY.js → chunk-EBU7LQ64.js} +18 -6
  19. package/dist/cli/{chunk-O564PHDU.mjs → chunk-GATWDGMB.mjs} +1 -1
  20. package/dist/cli/{chunk-UUB3FTKZ.js → chunk-I5XF4PWD.js} +6 -6
  21. package/dist/cli/{chunk-TVIWEQ4V.mjs → chunk-IT3AQZDG.mjs} +3 -3
  22. package/dist/cli/{chunk-VB7TNIUB.mjs → chunk-IU3TFWPR.mjs} +1 -1
  23. package/dist/cli/{chunk-6466HVYR.js → chunk-JEE7AKWP.js} +26 -26
  24. package/dist/cli/{chunk-GUMAWNWZ.mjs → chunk-JULF4SPK.mjs} +5 -5
  25. package/dist/cli/{chunk-GX2YGFQV.js → chunk-KZT7YX7R.js} +1 -1
  26. package/dist/cli/{chunk-GNHI4WZC.js → chunk-LDMQDERZ.js} +15 -15
  27. package/dist/cli/{chunk-7XXNMV6G.js → chunk-LOD6RKCD.js} +45 -45
  28. package/dist/cli/{chunk-FLMBKUHB.js → chunk-NCPAHNXJ.js} +60 -60
  29. package/dist/cli/{chunk-EJLUQARV.mjs → chunk-PWY5DNNP.mjs} +4 -4
  30. package/dist/cli/{chunk-SABEM6FL.js → chunk-Q2HYQOID.js} +48 -48
  31. package/dist/cli/{chunk-A7S4PRK2.mjs → chunk-TGMDQIYJ.mjs} +1 -1
  32. package/dist/cli/{chunk-Y2VN54ME.mjs → chunk-TV6BWFGU.mjs} +2 -2
  33. package/dist/cli/{chunk-EJVAWHQ7.mjs → chunk-VD45LDLL.mjs} +23 -10
  34. package/dist/cli/{chunk-TT2CLWMK.mjs → chunk-VOD4V4G4.mjs} +1 -1
  35. package/dist/cli/{chunk-SFLARO4Y.mjs → chunk-WIYWSYDS.mjs} +18 -6
  36. package/dist/cli/{chunk-O64RSXDZ.mjs → chunk-WWZJ6P22.mjs} +2 -2
  37. package/dist/cli/{chunk-6MVMTDL7.js → chunk-ZPLBQ24U.js} +4 -4
  38. package/dist/cli/{chunk-HIPRSI5H.js → chunk-ZXBVQAQW.js} +327 -314
  39. package/dist/cli/client-LNCVWDUS.js +20 -0
  40. package/dist/cli/{client-JIZWAGVW.mjs → client-MUO4FRKO.mjs} +3 -3
  41. package/dist/cli/{csv-7DCY7Z6R.mjs → csv-2RT3FVOD.mjs} +3 -3
  42. package/dist/cli/{csv-KAFKXAFU.js → csv-NGNI7CWG.js} +12 -12
  43. package/dist/cli/{db-5LJPO2VA.js → db-7GKM6IUK.js} +29 -29
  44. package/dist/cli/{db-KJBWUFPL.mjs → db-KUKHLFYS.mjs} +4 -4
  45. package/dist/cli/{describe-CPF4KDKZ.mjs → describe-6MJ4B7NU.mjs} +8 -8
  46. package/dist/cli/{describe-VJEEVOH6.js → describe-RDSWCQCO.js} +15 -15
  47. package/dist/cli/{executions-LJN5QOK7.mjs → executions-C7NXL7QR.mjs} +4 -4
  48. package/dist/cli/{executions-LPVCV5SC.js → executions-E6NAUIUO.js} +6 -6
  49. package/dist/cli/{feedback-3HYS6ECC.mjs → feedback-D52ZWOTA.mjs} +3 -3
  50. package/dist/cli/{feedback-K26WP7HJ.js → feedback-K5MAECHI.js} +6 -6
  51. package/dist/cli/getting-started.d.mts +47 -9
  52. package/dist/cli/getting-started.d.ts +47 -9
  53. package/dist/cli/getting-started.js +2 -2
  54. package/dist/cli/getting-started.mjs +1 -1
  55. package/dist/cli/git-E62XZHQW.js +23 -0
  56. package/dist/cli/{git-U4VBLXSS.mjs → git-YJLIAQJW.mjs} +4 -4
  57. package/dist/cli/index.js +79 -79
  58. package/dist/cli/index.mjs +31 -31
  59. package/dist/cli/{legacy-noops-ORHX2FMA.mjs → legacy-noops-PK6JF4Y5.mjs} +4 -4
  60. package/dist/cli/{legacy-noops-32YL3VF4.js → legacy-noops-V3BNZ4BV.js} +7 -7
  61. package/dist/cli/{monitors-5JJBEJS7.mjs → monitors-ABKZDCOX.mjs} +4 -4
  62. package/dist/cli/{monitors-NFE4ICED.js → monitors-ZC6CFUHS.js} +85 -85
  63. package/dist/cli/{org-RJYSDJ3W.mjs → org-JB46ECLU.mjs} +4 -4
  64. package/dist/cli/{org-7CJS35TF.js → org-RQGEMXS6.js} +60 -60
  65. package/dist/cli/play-TRKFECQV.js +153 -0
  66. package/dist/cli/{play-H2QUTJR2.mjs → play-WANQPXLR.mjs} +7 -7
  67. package/dist/cli/{providers-VUKRZWZY.js → providers-JRRQEOUN.js} +7 -7
  68. package/dist/cli/{providers-TEVRE4Q6.mjs → providers-T4FBXHMX.mjs} +4 -4
  69. package/dist/cli/{quickstart-36OGYQ2P.js → quickstart-35VIDBJK.js} +12 -12
  70. package/dist/cli/{quickstart-2MIHVSZO.mjs → quickstart-KTT4JBZY.mjs} +4 -4
  71. package/dist/cli/{search-IRRQSN6R.mjs → search-DZ5I6Q5Z.mjs} +5 -5
  72. package/dist/cli/search-KMMM4BRX.js +26 -0
  73. package/dist/cli/{secrets-K67ZKZZM.js → secrets-4FZIXXPT.js} +13 -13
  74. package/dist/cli/{secrets-3W6OVDVE.mjs → secrets-H6UBIMY7.mjs} +4 -4
  75. package/dist/cli/{sessions-AOMOV4HG.mjs → sessions-63S3OOVP.mjs} +4 -4
  76. package/dist/cli/{sessions-SLQ2QFLK.js → sessions-RDM6DBHZ.js} +5 -5
  77. package/dist/cli/{settings-L4IFYF5D.mjs → settings-JQQVY5I5.mjs} +7 -7
  78. package/dist/cli/{settings-2X7H6O4I.js → settings-S4AHAT3J.js} +74 -74
  79. package/dist/cli/{setup-2RY5APQS.js → setup-76X6E2IB.js} +49 -49
  80. package/dist/cli/{setup-CZYQTZ2K.mjs → setup-W6U2T7HU.mjs} +7 -7
  81. package/dist/cli/skills-HLLZUL4W.js +28 -0
  82. package/dist/cli/{skills-D2QQH5S7.mjs → skills-ONHUMRAF.mjs} +4 -4
  83. package/dist/cli/{tools-TYIEROJJ.mjs → tools-JEC63YLX.mjs} +6 -6
  84. package/dist/cli/tools-YSUGUPYH.js +40 -0
  85. package/dist/cli/{update-7YCSUWFP.mjs → update-3M5CUY4U.mjs} +6 -6
  86. package/dist/cli/update-ASHUXHC5.js +28 -0
  87. package/dist/cli/{workflow-42IFLYPN.js → workflow-PEU7CC4I.js} +15 -15
  88. package/dist/cli/{workflow-GGRUCLCI.mjs → workflow-SDT7YIQ7.mjs} +5 -5
  89. package/dist/index.js +6 -6
  90. package/dist/index.mjs +3 -3
  91. package/dist/install-integrity.json +76 -76
  92. package/dist/release.d.mts +1 -1
  93. package/dist/release.d.ts +1 -1
  94. package/dist/release.js +2 -2
  95. package/dist/release.mjs +1 -1
  96. package/package.json +1 -1
  97. package/dist/cli/auth-WR3XFOHN.js +0 -31
  98. package/dist/cli/client-6OBIO6GC.js +0 -20
  99. package/dist/cli/git-VMQTXKJQ.js +0 -23
  100. package/dist/cli/play-FUZYMPHF.js +0 -153
  101. package/dist/cli/search-DFSHYVZ5.js +0 -26
  102. package/dist/cli/skills-RIFYRYWL.js +0 -28
  103. package/dist/cli/tools-M7LTH6ZT.js +0 -40
  104. package/dist/cli/update-HC62SVSQ.js +0 -28
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.334',
203
+ version: '0.3.336',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -493,6 +493,7 @@ import {
493
493
  createRuntimeSheetDatasetPageReader,
494
494
  readRuntimeSheetDatasetRowKeys,
495
495
  RuntimeSheetAttemptSupersededError,
496
+ type RuntimeSheetDatasetPageReader,
496
497
  } from './runtime-api';
497
498
  import { executionGatewayDecodedBodyBytes } from './execution-gateway-response-size';
498
499
  import {
@@ -3304,6 +3305,35 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
3304
3305
  base64: (value: SecretValue): SecretValue => createBase64SecretValue(value),
3305
3306
  };
3306
3307
 
3308
+ private createRuntimeSheetDatasetPageReader(
3309
+ tableNamespace: string,
3310
+ rowMode?: 'output' | 'all',
3311
+ ): RuntimeSheetDatasetPageReader {
3312
+ if (this.#options.createRuntimeSheetDatasetPageReader) {
3313
+ return this.#options.createRuntimeSheetDatasetPageReader({
3314
+ orgId: this.#options.orgId,
3315
+ executorToken: this.#options.executorToken!,
3316
+ playName: this.#options.playName!,
3317
+ runId: this.#options.runId!,
3318
+ tableNamespace,
3319
+ rowMode,
3320
+ });
3321
+ }
3322
+ return createRuntimeSheetDatasetPageReader({
3323
+ context: {
3324
+ baseUrl: this.#options.baseUrl!,
3325
+ executorToken: this.#options.executorToken!,
3326
+ dbSessionStrategy: this.#options.dbSessionStrategy,
3327
+ playName: this.#options.playName!,
3328
+ userEmail: this.#options.userEmail,
3329
+ runId: this.#options.runId!,
3330
+ },
3331
+ tableNamespace,
3332
+ runId: this.#options.runId!,
3333
+ rowMode,
3334
+ });
3335
+ }
3336
+
3307
3337
  constructor(options: ContextOptions) {
3308
3338
  this.rootRuntimeContract =
3309
3339
  options.artifactRuntimeContract ??
@@ -9017,18 +9047,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
9017
9047
  at: Date.now(),
9018
9048
  });
9019
9049
 
9020
- const runtimeBackedMapPageReader = createRuntimeSheetDatasetPageReader({
9021
- context: {
9022
- baseUrl: this.#options.baseUrl!,
9023
- executorToken: this.#options.executorToken!,
9024
- dbSessionStrategy: this.#options.dbSessionStrategy,
9025
- playName: this.#options.playName!,
9026
- userEmail: this.#options.userEmail,
9027
- runId: this.#options.runId!,
9028
- },
9029
- tableNamespace: resolvedTableNamespace,
9030
- runId: this.#options.runId!,
9031
- });
9050
+ const runtimeBackedMapPageReader =
9051
+ this.createRuntimeSheetDatasetPageReader(resolvedTableNamespace);
9032
9052
  const readRuntimeBackedMapRows = async (input: {
9033
9053
  limit: number;
9034
9054
  offset: number;
@@ -9758,19 +9778,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
9758
9778
  // Output mode selects enriched rows when this replay's earlier
9759
9779
  // invocation also persisted isolated failures.
9760
9780
  const finalizationRowMode = resumedPendingRowsOnly ? 'output' : 'all';
9761
- const finalizationPageReader = createRuntimeSheetDatasetPageReader({
9762
- context: {
9763
- baseUrl: this.#options.baseUrl!,
9764
- executorToken: this.#options.executorToken!,
9765
- dbSessionStrategy: this.#options.dbSessionStrategy,
9766
- playName: this.#options.playName!,
9767
- userEmail: this.#options.userEmail,
9768
- runId: this.#options.runId!,
9769
- },
9770
- tableNamespace: resolvedTableNamespace,
9771
- runId: this.#options.runId!,
9772
- rowMode: finalizationRowMode,
9773
- });
9781
+ const finalizationPageReader = this.createRuntimeSheetDatasetPageReader(
9782
+ resolvedTableNamespace,
9783
+ finalizationRowMode,
9784
+ );
9774
9785
  results = await reconcileNodeRuntimeMapResultsWithPersistedSheet({
9775
9786
  mapName: normalizedMapNamespace,
9776
9787
  tableNamespace: resolvedTableNamespace,
@@ -9841,18 +9852,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
9841
9852
  this.#options.runId,
9842
9853
  );
9843
9854
  const fullPersistedPageReader = runtimeSheetBacked
9844
- ? createRuntimeSheetDatasetPageReader({
9845
- context: {
9846
- baseUrl: this.#options.baseUrl!,
9847
- executorToken: this.#options.executorToken!,
9848
- dbSessionStrategy: this.#options.dbSessionStrategy,
9849
- playName: this.#options.playName!,
9850
- userEmail: this.#options.userEmail,
9851
- runId: this.#options.runId!,
9852
- },
9853
- tableNamespace: resolvedTableNamespace,
9854
- runId: this.#options.runId!,
9855
- })
9855
+ ? this.createRuntimeSheetDatasetPageReader(resolvedTableNamespace)
9856
9856
  : null;
9857
9857
  const materializeFullPersistedMapRows = async (limit?: number) => {
9858
9858
  if (!runtimeSheetBacked) {
@@ -10752,9 +10752,14 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
10752
10752
  return [
10753
10753
  {
10754
10754
  inputIndex: executionRowIndex(index),
10755
- data: this.toPersistedOutputRow(
10756
- this.toOutputRow(item as Record<string, unknown>),
10757
- ),
10755
+ // Checkpoint replay must keep the admitted identity even
10756
+ // when restored output columns change the default row hash.
10757
+ data: {
10758
+ ...this.toPersistedOutputRow(
10759
+ this.toOutputRow(item as Record<string, unknown>),
10760
+ ),
10761
+ ...mapRowOutcomeRuntimeFields({ key: rowKey }),
10762
+ },
10758
10763
  ...(runtimeOptions?.authoredInputDigests?.[index]
10759
10764
  ? {
10760
10765
  authoredInputDigest:
@@ -11155,7 +11160,14 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
11155
11160
  return [
11156
11161
  {
11157
11162
  inputIndex: executionRowIndex(index),
11158
- data: this.toPersistedOutputRow(baseRow),
11163
+ // Preserve the admitted key rather than rehashing the
11164
+ // waiting row after persisted output fields are restored.
11165
+ data: {
11166
+ ...this.toPersistedOutputRow(baseRow),
11167
+ ...mapRowOutcomeRuntimeFields({
11168
+ key: keyForIndex(index),
11169
+ }),
11170
+ },
11159
11171
  ...(runtimeOptions?.authoredInputDigests?.[index]
11160
11172
  ? {
11161
11173
  authoredInputDigest:
@@ -12,6 +12,7 @@ import type { PlayDatasetColumnTypes } from '../play-data-plane/contracts';
12
12
  import type { PlayStructuredDefinition } from '../plays/definition';
13
13
  import type { PlayStaticPipeline } from '../plays/static-pipeline';
14
14
  import type { PlayLogContext, PlayLogMetadata } from './log-context';
15
+ import type { RuntimeSheetDatasetPageReader } from './runtime-api';
15
16
  import type {
16
17
  AsyncPlayRunRef,
17
18
  DurableCallStaleAfterSeconds,
@@ -772,6 +773,15 @@ export type IntegrationEventWaitHandler = {
772
773
  suspendAfterTimeoutMs?: number;
773
774
  };
774
775
 
776
+ export type RuntimeSheetDatasetPageReaderScope = {
777
+ orgId?: string;
778
+ executorToken: string;
779
+ playName: string;
780
+ runId: string;
781
+ tableNamespace: string;
782
+ rowMode?: 'output' | 'all';
783
+ };
784
+
775
785
  export interface ContextOptions {
776
786
  /**
777
787
  * Immutable worker projection resolved once from the admitted Play artifact.
@@ -822,6 +832,10 @@ export interface ContextOptions {
822
832
  * execution gateway and must never fall back to minting direct DB sessions.
823
833
  */
824
834
  dbSessionStrategy?: 'preloaded' | 'gateway_only' | 'trusted_dynamic';
835
+ /** Runner-owned reader; scoped database authority stays outside authored code. */
836
+ createRuntimeSheetDatasetPageReader?: (
837
+ scope: RuntimeSheetDatasetPageReaderScope,
838
+ ) => RuntimeSheetDatasetPageReader;
825
839
  vercelProtectionBypassToken?: string | null;
826
840
  /** Optional per-run integration execution mode for provider calls. */
827
841
  integrationMode?: 'live' | 'eval_stub' | 'fixture';
@@ -112,6 +112,9 @@ const PRODUCT_NOTIFICATION_UNSUBSCRIBE_PURPOSE =
112
112
  const MONITOR_FLEET_DISPATCH_AUDIENCE =
113
113
  'deepline.monitor_fleet.dispatch' as const;
114
114
  const MONITOR_FLEET_DISPATCH_PURPOSE = 'monitor_fleet_dispatch' as const;
115
+ const AUTO_RECHARGE_TRIGGER_AUDIENCE =
116
+ 'deepline.billing.auto_recharge_trigger' as const;
117
+ const AUTO_RECHARGE_TRIGGER_PURPOSE = 'auto_recharge_trigger' as const;
115
118
  const INTERNAL_BOOTSTRAP_TOKEN_DERIVATION_LABEL =
116
119
  'deepline:internal-bootstrap-token:v1';
117
120
  const WORKFLOW_EXECUTOR_KEY_DERIVATION_LABEL =
@@ -245,6 +248,18 @@ export type ProductNotificationUnsubscribeTokenClaims = {
245
248
  v: typeof INTERNAL_BOOTSTRAP_TOKEN_VERSION;
246
249
  };
247
250
 
251
+ /** Capability to ask the recharge controller to evaluate one workspace. */
252
+ export type AutoRechargeTriggerTokenClaims = {
253
+ aud: typeof AUTO_RECHARGE_TRIGGER_AUDIENCE;
254
+ exp: number;
255
+ iat: number;
256
+ iss: typeof INTERNAL_BOOTSTRAP_TOKEN_ISSUER;
257
+ org_id: string;
258
+ purpose: typeof AUTO_RECHARGE_TRIGGER_PURPOSE;
259
+ sub: 'credit_balance_reaction';
260
+ v: typeof INTERNAL_BOOTSTRAP_TOKEN_VERSION;
261
+ };
262
+
248
263
  /** Capability scoped to one durable Monitor Fleet control-plane operation. */
249
264
  export type MonitorFleetDispatchTokenClaims = {
250
265
  aud: typeof MONITOR_FLEET_DISPATCH_AUDIENCE;
@@ -1512,6 +1527,72 @@ export async function verifyProductNotificationUnsubscribeToken(
1512
1527
  return claims as ProductNotificationUnsubscribeTokenClaims;
1513
1528
  }
1514
1529
 
1530
+ /**
1531
+ * Mints a short-lived capability for the balance-triggered recharge
1532
+ * evaluation. It carries no amount: the controller decides from saved policy.
1533
+ */
1534
+ export async function mintAutoRechargeTriggerToken(input: {
1535
+ orgId: string;
1536
+ nowMs?: number;
1537
+ }): Promise<string> {
1538
+ const issuedAt = Math.floor((input.nowMs ?? Date.now()) / 1000);
1539
+ const claims: AutoRechargeTriggerTokenClaims = {
1540
+ v: INTERNAL_BOOTSTRAP_TOKEN_VERSION,
1541
+ iss: INTERNAL_BOOTSTRAP_TOKEN_ISSUER,
1542
+ aud: AUTO_RECHARGE_TRIGGER_AUDIENCE,
1543
+ purpose: AUTO_RECHARGE_TRIGGER_PURPOSE,
1544
+ org_id: input.orgId,
1545
+ sub: 'credit_balance_reaction',
1546
+ iat: issuedAt,
1547
+ exp: issuedAt + INTERNAL_BOOTSTRAP_TOKEN_TTL_SECONDS,
1548
+ };
1549
+ const signingInput = `${encodeJson({ alg: 'HS256', typ: 'JWT' })}.${encodeJson(claims)}`;
1550
+ return `${signingInput}.${await signTokenMaterial(signingInput)}`;
1551
+ }
1552
+
1553
+ export async function verifyAutoRechargeTriggerToken(
1554
+ token: string,
1555
+ nowMs = Date.now(),
1556
+ ): Promise<AutoRechargeTriggerTokenClaims> {
1557
+ const segments = token.split('.');
1558
+ if (segments.length !== 3)
1559
+ throw new Error('Invalid automatic recharge trigger token.');
1560
+ const [encodedHeader, encodedClaims, signature] = segments;
1561
+ const header = decodeJson<Record<string, unknown>>(encodedHeader);
1562
+ if (header.alg !== 'HS256' || header.typ !== 'JWT') {
1563
+ throw new Error('Invalid automatic recharge trigger token.');
1564
+ }
1565
+ const expectedSignature = await signTokenMaterial(
1566
+ `${encodedHeader}.${encodedClaims}`,
1567
+ );
1568
+ if (
1569
+ !timingSafeEqual(fromBase64Url(signature), fromBase64Url(expectedSignature))
1570
+ ) {
1571
+ throw new Error('Invalid automatic recharge trigger token.');
1572
+ }
1573
+ const claims = decodeJson<Record<string, unknown>>(encodedClaims);
1574
+ if (
1575
+ claims.v !== INTERNAL_BOOTSTRAP_TOKEN_VERSION ||
1576
+ claims.iss !== INTERNAL_BOOTSTRAP_TOKEN_ISSUER ||
1577
+ claims.aud !== AUTO_RECHARGE_TRIGGER_AUDIENCE ||
1578
+ claims.purpose !== AUTO_RECHARGE_TRIGGER_PURPOSE ||
1579
+ claims.sub !== 'credit_balance_reaction' ||
1580
+ typeof claims.org_id !== 'string' ||
1581
+ !claims.org_id ||
1582
+ typeof claims.iat !== 'number' ||
1583
+ !Number.isFinite(claims.iat) ||
1584
+ typeof claims.exp !== 'number' ||
1585
+ !Number.isFinite(claims.exp)
1586
+ ) {
1587
+ throw new Error('Invalid automatic recharge trigger token.');
1588
+ }
1589
+ const nowSeconds = Math.floor(nowMs / 1000);
1590
+ if (claims.exp <= nowSeconds || claims.iat > nowSeconds + 30) {
1591
+ throw new Error('Automatic recharge trigger token expired.');
1592
+ }
1593
+ return claims as AutoRechargeTriggerTokenClaims;
1594
+ }
1595
+
1515
1596
  export async function mintMonitorFleetDispatchToken(input: {
1516
1597
  orgId: string;
1517
1598
  operation: 'dispatch' | 'daily_sync' | 'job_dispatch';
@@ -87,6 +87,7 @@ import { getPlayRuntimeBatchStrategy } from '../play-runtime-batching-registry';
87
87
  import type { ToolResultMetadataInput } from '../tool-result';
88
88
  import type {
89
89
  ContextOptions,
90
+ RuntimeSheetDatasetPageReaderScope,
90
91
  IntegrationEventWaitBoundary,
91
92
  IntegrationEventWaitHandler,
92
93
  IntegrationEventWaitRuntimeContext,
@@ -121,6 +122,8 @@ import {
121
122
  import {
122
123
  resolveRuntimeReferencedPlay,
123
124
  createCompleteRuntimeMapRowsOperation,
125
+ createRuntimeSheetDatasetPageReader,
126
+ type RuntimeSheetDatasetPageReader,
124
127
  readRuntimeSheetDatasetRowKeys,
125
128
  readRuntimeSheetDatasetRows,
126
129
  releaseRuntimeWorkReceipts,
@@ -1319,6 +1322,48 @@ export function assertPlayRunnerRuntimeSheetPersistenceContext(
1319
1322
  }
1320
1323
  }
1321
1324
 
1325
+ /** Keep launch-scoped database authority in the runner that admitted it. */
1326
+ export function createPlayRunnerRuntimeSheetDatasetPageReader(input: {
1327
+ context: PlayRunnerExecutionConfig['context'];
1328
+ preloadedDbSessions: PlayRunnerExecutionConfig['context']['preloadedDbSessions'];
1329
+ postgresSessionUnwrapKey: string | null;
1330
+ abortSignal: AbortSignal;
1331
+ scope: RuntimeSheetDatasetPageReaderScope;
1332
+ }): RuntimeSheetDatasetPageReader {
1333
+ const { context, scope } = input;
1334
+ assertPlayRunnerRuntimeSheetPersistenceContext(context);
1335
+ const rootRunId = context.runId ?? context.workflowId;
1336
+ if (
1337
+ scope.orgId !== context.orgId ||
1338
+ scope.playName !== context.playName ||
1339
+ scope.runId !== rootRunId ||
1340
+ scope.executorToken !== context.executorToken
1341
+ ) {
1342
+ throw new Error(
1343
+ 'Runtime Sheet reader scope does not match the run launch authority.',
1344
+ );
1345
+ }
1346
+ return createRuntimeSheetDatasetPageReader({
1347
+ context: {
1348
+ baseUrl: context.baseUrl,
1349
+ executorToken: scope.executorToken,
1350
+ orgId: scope.orgId,
1351
+ playName: scope.playName,
1352
+ runId: scope.runId,
1353
+ userEmail: context.userEmail,
1354
+ dbSessionStrategy: context.dbSessionStrategy,
1355
+ preloadedDbSessions: input.preloadedDbSessions,
1356
+ postgresSessionUnwrapKey: input.postgresSessionUnwrapKey,
1357
+ vercelProtectionBypassToken: context.vercelProtectionBypassToken,
1358
+ runtimeTestFaultHeader: context.runtimeTestFaultHeader ?? null,
1359
+ abortSignal: input.abortSignal,
1360
+ },
1361
+ tableNamespace: scope.tableNamespace,
1362
+ runId: scope.runId,
1363
+ rowMode: scope.rowMode,
1364
+ });
1365
+ }
1366
+
1322
1367
  function collectReturnedDatasets(value: unknown): unknown[] {
1323
1368
  const datasets: unknown[] = [];
1324
1369
  const seen = new Set<unknown>();
@@ -2277,6 +2322,14 @@ async function run(
2277
2322
  }
2278
2323
  },
2279
2324
  dbSessionStrategy: config.context.dbSessionStrategy,
2325
+ createRuntimeSheetDatasetPageReader: (scope) =>
2326
+ createPlayRunnerRuntimeSheetDatasetPageReader({
2327
+ context: config.context,
2328
+ preloadedDbSessions: runtimePreloadedDbSessions,
2329
+ postgresSessionUnwrapKey: runtimePostgresSessionUnwrapKey,
2330
+ abortSignal: persistenceSignal,
2331
+ scope,
2332
+ }),
2280
2333
  fetchImpl: safeNodeStreamingOutboundFetch,
2281
2334
  vercelProtectionBypassToken: config.context.vercelProtectionBypassToken,
2282
2335
  orgId: config.context.orgId,
@@ -10593,6 +10593,36 @@ function terminalWorkCounterSegmentFromRunnerResult(
10593
10593
  });
10594
10594
  }
10595
10595
 
10596
+ /** Close the admitted invocation in the same durable fact as its terminal. */
10597
+ function terminalWorkCounterProgressEventsFromRunnerResult(
10598
+ result: unknown,
10599
+ runId: string,
10600
+ attempt: number,
10601
+ occurredAt: number,
10602
+ ): PlayRunLedgerEvent[] {
10603
+ if (!result || typeof result !== 'object' || Array.isArray(result)) return [];
10604
+ const envelope = result as { status?: unknown; stats?: unknown };
10605
+ if (envelope.status !== 'completed' && envelope.status !== 'failed')
10606
+ return [];
10607
+ const counters = runtimeWorkCountersFromStats(envelope.stats);
10608
+ const segment = terminalWorkCounterSegmentFromRunnerResult(result, attempt);
10609
+ // Historical or malformed telemetry must stay visibly unconfirmed.
10610
+ if (!counters || counters.provider429s === undefined || !segment) return [];
10611
+ return [
10612
+ {
10613
+ type: 'work.counters',
10614
+ runId,
10615
+ source: 'worker',
10616
+ occurredAt,
10617
+ ...segment,
10618
+ logicalCalls: counters.logicalCalls,
10619
+ providerRequests: counters.providerRequests,
10620
+ provider429s: counters.provider429s,
10621
+ final: true,
10622
+ },
10623
+ ];
10624
+ }
10625
+
10596
10626
  /**
10597
10627
  * Reduce an ordinary detached-runner completion at terminal ingress.
10598
10628
  *
@@ -15040,12 +15070,20 @@ export async function executePostgresSchedulerClaim(
15040
15070
  terminalLogLines: terminalLogProjection.lines,
15041
15071
  terminalLogContexts: terminalLogProjection.lineContexts,
15042
15072
  terminalLogMetadata: terminalLogProjection.lineMetadata,
15043
- terminalProgressEvents: options.terminalProgressEvents,
15044
15073
  terminalLogIds: terminalLogProjection.lineIds,
15045
15074
  terminalWorkCounterSegment: terminalWorkCounterSegmentFromRunnerResult(
15046
15075
  output,
15047
15076
  claim.attempt,
15048
15077
  ),
15078
+ terminalProgressEvents: [
15079
+ ...terminalWorkCounterProgressEventsFromRunnerResult(
15080
+ output,
15081
+ claim.runId,
15082
+ claim.attempt,
15083
+ runnerTerminalReceivedAtMs ?? Date.now(),
15084
+ ),
15085
+ ...(options.terminalProgressEvents ?? []),
15086
+ ],
15049
15087
  },
15050
15088
  options,
15051
15089
  );
@@ -15109,9 +15147,15 @@ export async function executePostgresSchedulerClaim(
15109
15147
  ...(options.preserveRunnerTerminal
15110
15148
  ? { preserveRunnerTerminal: true }
15111
15149
  : {}),
15112
- ...(options.terminalProgressEvents?.length
15113
- ? { terminalProgressEvents: options.terminalProgressEvents }
15114
- : {}),
15150
+ terminalProgressEvents: [
15151
+ ...terminalWorkCounterProgressEventsFromRunnerResult(
15152
+ terminalFailureResult,
15153
+ claim.runId,
15154
+ claim.attempt,
15155
+ runnerTerminalReceivedAtMs ?? Date.now(),
15156
+ ),
15157
+ ...(options.terminalProgressEvents ?? []),
15158
+ ],
15115
15159
  },
15116
15160
  options,
15117
15161
  );
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkQ2HYQOIDjs = require('./chunk-Q2HYQOID.js');
13
+ require('./chunk-I5XF4PWD.js');
14
+ require('./chunk-ZPLBQ24U.js');
15
+ require('./chunk-XNYIZMNQ.js');
16
+ require('./chunk-KZT7YX7R.js');
17
+ require('./chunk-7P5AA3SN.js');
18
+ require('./chunk-OG64RBAC.js');
19
+ require('./chunk-COGTRVWW.js');
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkQ2HYQOIDjs.EXIT_WORKSPACE_MISMATCH; exports.clearPendingClaim = _chunkQ2HYQOIDjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkQ2HYQOIDjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkQ2HYQOIDjs.handleRegister; exports.handleStatus = _chunkQ2HYQOIDjs.handleStatus; exports.handleWait = _chunkQ2HYQOIDjs.handleWait; exports.readPendingAuthClaim = _chunkQ2HYQOIDjs.readPendingAuthClaim; exports.registerAuthCommands = _chunkQ2HYQOIDjs.registerAuthCommands; exports.reportSetupCompleted = _chunkQ2HYQOIDjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkQ2HYQOIDjs.resolvePendingAuthClaimForResume;
@@ -9,11 +9,11 @@ import {
9
9
  registerAuthCommands,
10
10
  reportSetupCompleted,
11
11
  resolvePendingAuthClaimForResume
12
- } from "./chunk-U724V33M.mjs";
13
- import "./chunk-A7S4PRK2.mjs";
14
- import "./chunk-VB7TNIUB.mjs";
12
+ } from "./chunk-4S3G43M3.mjs";
13
+ import "./chunk-TGMDQIYJ.mjs";
14
+ import "./chunk-IU3TFWPR.mjs";
15
15
  import "./chunk-DLIRSHV6.mjs";
16
- import "./chunk-P3ZX3NSE.mjs";
16
+ import "./chunk-B53RXFGP.mjs";
17
17
  import "./chunk-NXGCO4JB.mjs";
18
18
  import "./chunk-WZYKRD7T.mjs";
19
19
  import "./chunk-KRD6H754.mjs";
@@ -2,7 +2,7 @@ import {
2
2
  DeeplineClient,
3
3
  iterateCursorPages,
4
4
  requireBillingIdempotencyKey
5
- } from "./chunk-TT2CLWMK.mjs";
5
+ } from "./chunk-VOD4V4G4.mjs";
6
6
  import "./chunk-CBVIJSHF.mjs";
7
7
  import {
8
8
  createTimestampedName,
@@ -10,13 +10,13 @@ import {
10
10
  openInBrowser,
11
11
  printCommandEnvelope,
12
12
  shouldEmitJson
13
- } from "./chunk-A7S4PRK2.mjs";
13
+ } from "./chunk-TGMDQIYJ.mjs";
14
14
  import {
15
15
  AuthError,
16
16
  ConfigError
17
- } from "./chunk-VB7TNIUB.mjs";
17
+ } from "./chunk-IU3TFWPR.mjs";
18
18
  import "./chunk-DLIRSHV6.mjs";
19
- import "./chunk-P3ZX3NSE.mjs";
19
+ import "./chunk-B53RXFGP.mjs";
20
20
  import "./chunk-6IKARAYD.mjs";
21
21
  import {
22
22
  DeeplineError