deepline 0.3.521 → 0.3.523

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 (170) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +118 -0
  2. package/dist/bundling-sources/sdk/src/index.ts +3 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +47 -18
  5. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +1 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/db-session-renewal.ts +209 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +24 -7
  8. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +5 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +1 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +38 -5
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +92 -10
  12. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +96 -25
  13. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +29 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +139 -17
  15. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +26 -3
  16. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +145 -5
  17. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +190 -10
  18. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +85 -5
  19. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +21 -11
  20. package/dist/cli/{artifacts-TYPU37IU.mjs → artifacts-RBHR2DG4.mjs} +6 -6
  21. package/dist/cli/{artifacts-JGH464N2.js → artifacts-RZTS2JHZ.js} +18 -18
  22. package/dist/cli/auth-DPWYFQR5.js +43 -0
  23. package/dist/cli/{auth-XPQT6NUB.mjs → auth-ENQUQS56.mjs} +5 -5
  24. package/dist/cli/{billing-47AMHOMP.mjs → billing-6A27ULCX.mjs} +7 -7
  25. package/dist/cli/{billing-6D4KXBFJ.js → billing-6HONTJOY.js} +82 -82
  26. package/dist/cli/{chunk-DY6634MN.js → chunk-2BRDHM4S.js} +9 -9
  27. package/dist/cli/{chunk-LGU2NIOT.js → chunk-326WVSWS.js} +108 -96
  28. package/dist/cli/{chunk-UAZKOH3J.js → chunk-36LQQL5C.js} +5 -5
  29. package/dist/cli/{chunk-VYY5V4M5.js → chunk-4NWY7JBB.js} +11 -11
  30. package/dist/cli/{chunk-2DQPB5HT.mjs → chunk-4V63IJCL.mjs} +5 -5
  31. package/dist/cli/{chunk-4MONKWYE.mjs → chunk-5WFQXAD4.mjs} +5 -5
  32. package/dist/cli/{chunk-A6USUS4L.mjs → chunk-6DBRBWHC.mjs} +2 -2
  33. package/dist/cli/{chunk-4I7I5CGB.mjs → chunk-6OZ2WSHD.mjs} +1 -1
  34. package/dist/cli/{chunk-MD43YAL6.js → chunk-7GNKAACY.js} +6 -6
  35. package/dist/cli/{chunk-7IYDCHTG.mjs → chunk-7M5FRSFP.mjs} +2 -2
  36. package/dist/cli/{chunk-HHBJJYKL.mjs → chunk-DNXP3D5H.mjs} +5 -5
  37. package/dist/cli/{chunk-4DB6JV7X.mjs → chunk-F3WRLFFM.mjs} +2 -2
  38. package/dist/cli/{chunk-AMVKLEPH.js → chunk-FBMOBNJY.js} +2 -2
  39. package/dist/cli/{chunk-EZNZDOAG.mjs → chunk-H7275EZU.mjs} +5 -5
  40. package/dist/cli/{chunk-CBBCUYIN.mjs → chunk-HSVGP4CI.mjs} +2 -2
  41. package/dist/cli/{chunk-FTZX4QZN.js → chunk-HUC5SGJQ.js} +2 -2
  42. package/dist/cli/{chunk-4MN65FRF.js → chunk-HUIFUE4L.js} +53 -53
  43. package/dist/cli/{chunk-5T7QKHQL.mjs → chunk-I62LJ7NU.mjs} +1 -1
  44. package/dist/cli/{chunk-EW3EAEWZ.js → chunk-IEVXYHGJ.js} +5 -5
  45. package/dist/cli/{chunk-E4ZS2B2J.mjs → chunk-JCTTXLAZ.mjs} +1 -1
  46. package/dist/cli/{chunk-LNBMEFOI.mjs → chunk-JGZQBDYG.mjs} +4 -4
  47. package/dist/cli/{chunk-GNYSODBR.js → chunk-JMMNCJ7Z.js} +1 -1
  48. package/dist/cli/{chunk-7AUXX6M5.mjs → chunk-JVEFMOY2.mjs} +1 -1
  49. package/dist/cli/{chunk-3Q7HEEH2.js → chunk-K326BEVR.js} +10 -10
  50. package/dist/cli/{chunk-TBIWR7M2.mjs → chunk-KILRUAXF.mjs} +1 -1
  51. package/dist/cli/{chunk-6UHYXNCP.mjs → chunk-LZL6V5M5.mjs} +2 -2
  52. package/dist/cli/{chunk-EILHJRPW.js → chunk-MCXPJYBN.js} +3 -3
  53. package/dist/cli/{chunk-VE6FHVXZ.mjs → chunk-MHTRYBXY.mjs} +78 -1
  54. package/dist/cli/{chunk-VSH3AE5E.js → chunk-MT3WG3KR.js} +16 -16
  55. package/dist/cli/{chunk-PUKWFJXW.js → chunk-MZROKQV3.js} +44 -44
  56. package/dist/cli/{chunk-QGTWGHYD.js → chunk-N5MLEXZ7.js} +50 -8
  57. package/dist/cli/{chunk-ZO2XJVFH.mjs → chunk-NWTMQGPP.mjs} +6 -6
  58. package/dist/cli/{chunk-6V2RI3AL.mjs → chunk-PCORO245.mjs} +2 -2
  59. package/dist/cli/{chunk-MRU4N33M.js → chunk-PESMXAUG.js} +6 -6
  60. package/dist/cli/{chunk-4GGXAYKI.mjs → chunk-QMBL5ZIQ.mjs} +3 -3
  61. package/dist/cli/{chunk-A2B5AAU3.mjs → chunk-QOO5W5XS.mjs} +22 -10
  62. package/dist/cli/{chunk-HRWVEIAX.mjs → chunk-QSAC3IVI.mjs} +1 -1
  63. package/dist/cli/{chunk-HYR34KFA.js → chunk-QYXIODWH.js} +78 -1
  64. package/dist/cli/{chunk-Y7IR4LBU.mjs → chunk-RKREB7MU.mjs} +3 -3
  65. package/dist/cli/{chunk-JFQJNYTB.js → chunk-RQN4PHRE.js} +16 -16
  66. package/dist/cli/{chunk-6DCBTJZP.js → chunk-S4YKRH3W.js} +3 -3
  67. package/dist/cli/{chunk-ULW2KBKL.js → chunk-SBGKKOCC.js} +26 -26
  68. package/dist/cli/{chunk-DQURY3WH.mjs → chunk-SXTVJIGB.mjs} +1 -1
  69. package/dist/cli/{chunk-7LRALARF.mjs → chunk-U6DLLV3S.mjs} +1 -1
  70. package/dist/cli/{chunk-NNDAVVBG.mjs → chunk-UH3EAFFN.mjs} +2 -2
  71. package/dist/cli/{chunk-HSFLMTED.js → chunk-UQN4VTZL.js} +4 -4
  72. package/dist/cli/{chunk-HD3KYCDC.js → chunk-V46J3UTM.js} +7 -7
  73. package/dist/cli/{chunk-WL6WPW6X.js → chunk-WGVJA4I5.js} +14 -14
  74. package/dist/cli/{chunk-FQJFONFT.mjs → chunk-WVQOXYTQ.mjs} +44 -2
  75. package/dist/cli/{chunk-Y23TOHNV.js → chunk-XVXEARHC.js} +41 -41
  76. package/dist/cli/{chunk-6N72GHAV.js → chunk-XYL26236.js} +2 -2
  77. package/dist/cli/{chunk-YROP3H6T.js → chunk-ZWN4RXC2.js} +22 -22
  78. package/dist/cli/command-docs.js +2 -2
  79. package/dist/cli/command-docs.mjs +1 -1
  80. package/dist/cli/{csv-5TM2OSYP.js → csv-UBACJK75.js} +13 -13
  81. package/dist/cli/{csv-PM3WDXDF.mjs → csv-YFJ2JLUP.mjs} +4 -4
  82. package/dist/cli/{db-3LJ32FZM.js → db-2ZPA2LZ7.js} +27 -27
  83. package/dist/cli/{db-5P72NPRL.mjs → db-NKGYTAQO.mjs} +6 -6
  84. package/dist/cli/{describe-ZLCMBGHG.mjs → describe-GX7DRKWZ.mjs} +18 -18
  85. package/dist/cli/describe-WQZF7MEG.js +50 -0
  86. package/dist/cli/describe-core.d.mts +3 -3
  87. package/dist/cli/describe-core.d.ts +3 -3
  88. package/dist/cli/{executions-JMFL6AV7.mjs → executions-HTHQ7KKD.mjs} +6 -6
  89. package/dist/cli/{executions-4AJ5TQVY.js → executions-NXMRGPIL.js} +8 -8
  90. package/dist/cli/{feedback-I2BLXMGH.js → feedback-TGVQACRO.js} +10 -10
  91. package/dist/cli/{feedback-DKMG2QB7.mjs → feedback-USP4T34P.mjs} +5 -5
  92. package/dist/cli/{git-ARG223MY.mjs → git-KUONEHCD.mjs} +5 -5
  93. package/dist/cli/git-X3SCQREB.js +25 -0
  94. package/dist/cli/index.js +145 -145
  95. package/dist/cli/index.mjs +44 -44
  96. package/dist/cli/{legacy-noops-N7SVA7PL.js → legacy-noops-2JY3CQ24.js} +9 -9
  97. package/dist/cli/{legacy-noops-24LOAOZN.mjs → legacy-noops-B2GMHU42.mjs} +6 -6
  98. package/dist/cli/{monitors-RYQFWM2T.mjs → monitors-2OVBZJ6Z.mjs} +7 -7
  99. package/dist/cli/{monitors-XNCYLOJM.js → monitors-XI6I52AX.js} +100 -100
  100. package/dist/cli/{org-I33TKZXF.js → org-5TUQ2H6Y.js} +235 -72
  101. package/dist/cli/{org-ORIH56E5.mjs → org-BNJW764Y.mjs} +169 -6
  102. package/dist/cli/{pages-ME43HSBL.mjs → pages-QC3TQIPW.mjs} +6 -6
  103. package/dist/cli/{pages-2UXXGIMF.js → pages-UXCLX53Y.js} +18 -18
  104. package/dist/cli/{play-XEKNY46M.mjs → play-45PPG5SZ.mjs} +18 -18
  105. package/dist/cli/{play-F4QOFU37.js → play-KRWMZ7FG.js} +317 -317
  106. package/dist/cli/{providers-XKU44G74.mjs → providers-JDT35MRL.mjs} +6 -6
  107. package/dist/cli/{providers-E7DPCBNX.js → providers-RBUJ72Y3.js} +9 -9
  108. package/dist/cli/{quickstart-J7NVEXV5.mjs → quickstart-GD2SWGAC.mjs} +4 -4
  109. package/dist/cli/{quickstart-ICLF2F6A.js → quickstart-JZ4Q3HFT.js} +6 -6
  110. package/dist/cli/{run-HJMHUQBN.js → run-JEAHA367.js} +41 -41
  111. package/dist/cli/{run-MQ5ZONGL.mjs → run-KIZ3HBI2.mjs} +23 -23
  112. package/dist/cli/{search-GGRC77CV.mjs → search-5UFNXHFK.mjs} +8 -8
  113. package/dist/cli/search-6JULJMD7.js +33 -0
  114. package/dist/cli/{search-output-NY4GDBRU.mjs → search-output-HAXPKQO6.mjs} +4 -4
  115. package/dist/cli/{search-output-MXZTZI2P.js → search-output-W3RDSVLE.js} +6 -6
  116. package/dist/cli/{secrets-FA37G4Q2.mjs → secrets-JAWT66B2.mjs} +6 -6
  117. package/dist/cli/{secrets-PFESG72B.js → secrets-PC7C2Q32.js} +15 -15
  118. package/dist/cli/{sessions-BLLXPETU.mjs → sessions-325V7G35.mjs} +6 -6
  119. package/dist/cli/sessions-WFUCOJHZ.js +18 -0
  120. package/dist/cli/{settings-U26S7MPH.mjs → settings-FKHTA65P.mjs} +13 -13
  121. package/dist/cli/{settings-32VPG4Z2.js → settings-RGU6Y2QR.js} +86 -86
  122. package/dist/cli/{setup-4AXBCX7C.mjs → setup-43GOYTFC.mjs} +10 -10
  123. package/dist/cli/{setup-R6NSENH7.js → setup-ZMZ7HU2I.js} +50 -50
  124. package/dist/cli/skills-3XTQ6FFM.js +37 -0
  125. package/dist/cli/{skills-JUH7AVUL.mjs → skills-Q2VAHSXM.mjs} +8 -8
  126. package/dist/cli/{tools-FOYLU3FH.mjs → tools-BUH7ZWDS.mjs} +17 -17
  127. package/dist/cli/tools-UK2R4YXQ.js +57 -0
  128. package/dist/cli/{update-FUVX22VM.mjs → update-JFALWOHD.mjs} +10 -10
  129. package/dist/cli/update-LNKPHS54.js +35 -0
  130. package/dist/cli/{workflow-QLT22BLT.mjs → workflow-ISJKLY6X.mjs} +7 -7
  131. package/dist/cli/{workflow-JACZW4GJ.js → workflow-YELST32A.js} +17 -17
  132. package/dist/{client-DA71-2_u.d.mts → client-C2N7MofG.d.mts} +1 -1
  133. package/dist/{client-B-2Am2y6.d.ts → client-C7lTRJjw.d.ts} +1 -1
  134. package/dist/{client-core-BXbds1cb.d.mts → client-core-BTkDSKGn.d.mts} +79 -2
  135. package/dist/{client-core-C0IzDKMJ.d.ts → client-core-hmhBi7Ib.d.ts} +79 -2
  136. package/dist/{compiler-manifest-B4mIIbw7.d.ts → compiler-manifest-DsxsQP-T.d.mts} +14 -7
  137. package/dist/{compiler-manifest-B4mIIbw7.d.mts → compiler-manifest-DsxsQP-T.d.ts} +14 -7
  138. package/dist/{errors-Gj9i5Rkd.d.ts → errors-Bk5h1D-C.d.ts} +1 -1
  139. package/dist/{errors-C2F4qzAq.d.mts → errors-qdJUVQ3g.d.mts} +1 -1
  140. package/dist/{index-5JZBufdF.d.mts → index-PaupwX1B.d.mts} +1 -1
  141. package/dist/{index-BXtSj8bv.d.ts → index-bL66eHYz.d.ts} +1 -1
  142. package/dist/index.d.mts +7 -7
  143. package/dist/index.d.ts +7 -7
  144. package/dist/index.js +9 -9
  145. package/dist/index.mjs +6 -6
  146. package/dist/install-integrity.json +117 -116
  147. package/dist/plays/bundle-play-file.d.mts +3 -3
  148. package/dist/plays/bundle-play-file.d.ts +3 -3
  149. package/dist/plays/bundle-play-file.mjs +7 -5
  150. package/dist/plays/play-description.d.mts +2 -2
  151. package/dist/plays/play-description.d.ts +2 -2
  152. package/dist/plays/run-request.d.mts +2 -2
  153. package/dist/plays/run-request.d.ts +2 -2
  154. package/dist/release.d.mts +1 -1
  155. package/dist/release.d.ts +1 -1
  156. package/dist/release.js +2 -2
  157. package/dist/release.mjs +1 -1
  158. package/dist/server.d.mts +4 -4
  159. package/dist/server.d.ts +4 -4
  160. package/dist/server.js +5 -5
  161. package/dist/server.mjs +3 -3
  162. package/package.json +1 -1
  163. package/dist/cli/auth-JWR3VSNT.js +0 -43
  164. package/dist/cli/describe-GRS3IRSX.js +0 -50
  165. package/dist/cli/git-2LNT43A2.js +0 -25
  166. package/dist/cli/search-V6IBJ4TX.js +0 -33
  167. package/dist/cli/sessions-DNFTQOQH.js +0 -18
  168. package/dist/cli/skills-G4ZE3OS5.js +0 -37
  169. package/dist/cli/tools-27LHZFJD.js +0 -57
  170. package/dist/cli/update-KNZ7N242.js +0 -35
@@ -2430,6 +2430,68 @@ export type WorkspaceCreateResult = {
2430
2430
  request_id?: string;
2431
2431
  };
2432
2432
 
2433
+ /** One key a service account holds. Never key material. */
2434
+ export type WorkspaceServiceAccountKey = {
2435
+ id: string;
2436
+ keyPrefix: string;
2437
+ keyLast4: string;
2438
+ status: string;
2439
+ createdAt: number;
2440
+ lastUsedAt: number | null;
2441
+ };
2442
+
2443
+ /**
2444
+ * A workspace member that is not a person: it owns API keys so production
2445
+ * credentials keep working when people leave. It cannot sign in, and its role
2446
+ * is read, run, or member.
2447
+ */
2448
+ export type WorkspaceServiceAccount = {
2449
+ id: string;
2450
+ userId: string;
2451
+ memberId: string | null;
2452
+ name: string;
2453
+ role: string | null;
2454
+ createdAt: number;
2455
+ createdByUserId: string;
2456
+ activeKeyCount: number;
2457
+ lastUsedAt: number | null;
2458
+ /** Present for admins; null for other members. */
2459
+ keys: WorkspaceServiceAccountKey[] | null;
2460
+ };
2461
+
2462
+ /** Create, change, and delete service accounts and their keys. Admin only, except list. */
2463
+ export type WorkspaceServiceAccountsNamespace = {
2464
+ list: () => Promise<{ serviceAccounts: WorkspaceServiceAccount[] }>;
2465
+ create: (options: {
2466
+ name: string;
2467
+ role: string;
2468
+ }) => Promise<{ serviceAccount: WorkspaceServiceAccount }>;
2469
+ setRole: (
2470
+ serviceAccountId: string,
2471
+ role: string,
2472
+ ) => Promise<{ serviceAccount: WorkspaceServiceAccount }>;
2473
+ delete: (
2474
+ serviceAccountId: string,
2475
+ ) => Promise<{ id: string; revokedKeyCount: number }>;
2476
+ /**
2477
+ * A service account holds one active key; this is refused while it has one.
2478
+ * The returned `apiKey` is shown once; Deepline stores only its hash.
2479
+ */
2480
+ createKey: (
2481
+ serviceAccountId: string,
2482
+ ) => Promise<{ apiKey: string; key: WorkspaceServiceAccountKey }>;
2483
+ /** Revoke the active key and issue its replacement in one step; shown once. */
2484
+ rotateKey: (serviceAccountId: string) => Promise<{
2485
+ apiKey: string;
2486
+ key: WorkspaceServiceAccountKey;
2487
+ revokedKeyIds: string[];
2488
+ }>;
2489
+ revokeKey: (
2490
+ serviceAccountId: string,
2491
+ keyId: string,
2492
+ ) => Promise<{ keyId: string; status: string }>;
2493
+ };
2494
+
2433
2495
  /** Deliberate workspace lifecycle operations. */
2434
2496
  export type WorkspacesNamespace = {
2435
2497
  /** One page of current workspace memberships and effective grants. */
@@ -2451,6 +2513,7 @@ export type WorkspacesNamespace = {
2451
2513
  name: string;
2452
2514
  idempotencyKey: string;
2453
2515
  }) => Promise<WorkspaceCreateResult>;
2516
+ serviceAccounts: WorkspaceServiceAccountsNamespace;
2454
2517
  };
2455
2518
 
2456
2519
  /** One authenticated per-request usage event from `/api/v2/usage/events`. */
@@ -3170,6 +3233,49 @@ export class DeeplineClient {
3170
3233
  { role: grants.join(',') },
3171
3234
  ),
3172
3235
  create: (options) => this.createWorkspace(options),
3236
+ serviceAccounts: {
3237
+ list: () => this.http.get('/api/v2/auth/workspace/service-accounts'),
3238
+ // Creating an account or a key is not idempotent, so a transport
3239
+ // retry or localhost failover after a lost response could report a
3240
+ // false failure or mint a second live key. Surface the ambiguity;
3241
+ // `list` shows what exists.
3242
+ create: (options) =>
3243
+ this.http.post(
3244
+ '/api/v2/auth/workspace/service-accounts',
3245
+ options,
3246
+ undefined,
3247
+ { maxRetries: 0, exactUrlOnly: true },
3248
+ ),
3249
+ setRole: (serviceAccountId, role) =>
3250
+ this.http.patch(
3251
+ `/api/v2/auth/workspace/service-accounts/${encodeURIComponent(serviceAccountId)}`,
3252
+ { role },
3253
+ ),
3254
+ delete: (serviceAccountId) =>
3255
+ this.http.delete(
3256
+ `/api/v2/auth/workspace/service-accounts/${encodeURIComponent(serviceAccountId)}`,
3257
+ ),
3258
+ createKey: (serviceAccountId) =>
3259
+ this.http.post(
3260
+ `/api/v2/auth/workspace/service-accounts/${encodeURIComponent(serviceAccountId)}/keys`,
3261
+ {},
3262
+ undefined,
3263
+ { maxRetries: 0, exactUrlOnly: true },
3264
+ ),
3265
+ // A retried rotate after a lost response would revoke the key it
3266
+ // just issued, so it is not retried either.
3267
+ rotateKey: (serviceAccountId) =>
3268
+ this.http.post(
3269
+ `/api/v2/auth/workspace/service-accounts/${encodeURIComponent(serviceAccountId)}/keys/rotate`,
3270
+ {},
3271
+ undefined,
3272
+ { maxRetries: 0, exactUrlOnly: true },
3273
+ ),
3274
+ revokeKey: (serviceAccountId, keyId) =>
3275
+ this.http.delete(
3276
+ `/api/v2/auth/workspace/service-accounts/${encodeURIComponent(serviceAccountId)}/keys/${encodeURIComponent(keyId)}`,
3277
+ ),
3278
+ },
3173
3279
  };
3174
3280
  this.monitors = {
3175
3281
  status: () => this.getMonitorsAccess(),
@@ -5876,6 +5982,18 @@ export class DeeplineClient {
5876
5982
  return this.http.get('/api/v2/settings/notifications');
5877
5983
  }
5878
5984
 
5985
+ /** Fresh balance of the active workspace's own provider credential. */
5986
+ async getIntegrationBalance(provider: string): Promise<{
5987
+ provider: string;
5988
+ credentialScope: 'customer';
5989
+ unit: string;
5990
+ observedAt: string;
5991
+ balance: { value: number; status: 'reported'; source: string };
5992
+ }> {
5993
+ const params = new URLSearchParams({ provider });
5994
+ return this.http.get(`/api/v2/integrations/balance?${params}`);
5995
+ }
5996
+
5879
5997
  /** Get the dashboard link where a workspace owner or admin can connect a provider. */
5880
5998
  async getIntegrationConnectLink(
5881
5999
  provider: string,
@@ -131,6 +131,9 @@ export type {
131
131
  BillingUsageOptions,
132
132
  BillingUsageResult,
133
133
  WorkspaceCreateResult,
134
+ WorkspaceServiceAccount,
135
+ WorkspaceServiceAccountKey,
136
+ WorkspaceServiceAccountsNamespace,
134
137
  WorkspacesNamespace,
135
138
  MonitorsNamespace,
136
139
  MonitorsAccessStatus,
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
205
205
  // getters keep their established compatibility behavior.
206
206
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
207
207
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
208
- version: '0.3.521',
208
+ version: '0.3.523',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -364,6 +364,7 @@ import {
364
364
  import {
365
365
  isAlwaysFreshIntegrationTool,
366
366
  isAlwaysFreshIntegrationWriteTool,
367
+ reusableWindowEligibility,
367
368
  } from './tool-cache-policy';
368
369
  import { isAbortLikeError, isRowIsolationExemptError } from './row-isolation';
369
370
  import {
@@ -7348,8 +7349,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7348
7349
  return this.currentExecutionScope.logical.runId;
7349
7350
  }
7350
7351
 
7352
+ /**
7353
+ * `id` keeps its admitted meaning: inside an inline child it is the
7354
+ * composition namespace, which repeats across parent runs. `rootId` is the
7355
+ * run at the root of the inline composition tree (the executing run), so it
7356
+ * is the per-run value authors need for external idempotency keys.
7357
+ */
7351
7358
  get run(): PlayAuthoringRunScope {
7352
- return { id: this.currentRunId, actor: this.#options.runActor ?? null };
7359
+ return {
7360
+ id: this.currentRunId,
7361
+ rootId: this.currentExecutionScope.logical.rootRunId,
7362
+ actor: this.#options.runActor ?? null,
7363
+ };
7353
7364
  }
7354
7365
 
7355
7366
  private get currentReceiptOwnerRunId(): string {
@@ -14696,27 +14707,39 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14696
14707
  // A positive or null window on any tool call is the author's explicit
14697
14708
  // acceptance of reuse, including for writes, sends and purchases: a hit
14698
14709
  // returns the recorded answer and suppresses that repeat on purpose. Only
14699
- // calls that are structurally not answers stay refused: event waits,
14700
- // live datasets, Customer DB SQL mutations and Workspace operations.
14710
+ // calls that are structurally not answers stay refused, by the same rule
14711
+ // `plays check` applies (reusableWindowEligibility). This refusal is the
14712
+ // backstop for dynamic tool ids and inputs the checker cannot read.
14713
+ const reuseVerdict = reusableWindowEligibility({
14714
+ kind: 'tool',
14715
+ toolId,
14716
+ input,
14717
+ });
14718
+ if (policy.effective !== 0 && 'message' in reuseVerdict) {
14719
+ throw new Error(reuseVerdict.message);
14720
+ }
14701
14721
  const eventWait =
14702
14722
  policy.effective === 0 && !refreshMayPublish
14703
14723
  ? null
14704
14724
  : ((await this.#options.getIntegrationEventWaitHandler?.(toolId)) ??
14705
14725
  null);
14706
- const mustExecuteEveryTime = Boolean(
14707
- eventWait ||
14708
- liveDataset ||
14709
- sqlMutation ||
14710
- isAlwaysFreshIntegrationTool(toolId),
14711
- );
14726
+ // A registered event-wait handler refuses reuse even for a tool id the
14727
+ // rule does not list.
14728
+ const effectiveVerdict = eventWait
14729
+ ? reusableWindowEligibility({
14730
+ kind: 'tool',
14731
+ toolId,
14732
+ input,
14733
+ eventWait: true,
14734
+ })
14735
+ : reuseVerdict;
14736
+ if (policy.effective !== 0 && 'message' in effectiveVerdict) {
14737
+ throw new Error(effectiveVerdict.message);
14738
+ }
14739
+ const mustExecuteEveryTime = 'message' in effectiveVerdict;
14712
14740
  // A refresh of a reusable call still publishes its fresh result as the
14713
14741
  // request's newest shared result; an authored 0 never does.
14714
14742
  const publishLatestOnRefresh = refreshMayPublish && !mustExecuteEveryTime;
14715
- if (policy.effective !== 0 && mustExecuteEveryTime) {
14716
- throw new Error(
14717
- `Tool ${toolId} cannot reuse an older result; use staleAfterSeconds: 0. Live datasets, event waits, Customer DB mutations, and Workspace operations are never reused.`,
14718
- );
14719
- }
14720
14743
 
14721
14744
  // Independent lookups of one tool's identity: the first call per tool pays
14722
14745
  // two gateway requests, so ask for both at once.
@@ -17276,13 +17299,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17276
17299
  }
17277
17300
  } else if (
17278
17301
  this.usesExplicitFreshness &&
17279
- !reusableReadMethod &&
17280
17302
  options?.staleAfterSeconds !== undefined &&
17281
17303
  options.staleAfterSeconds !== 0
17282
17304
  ) {
17283
- throw new Error(
17284
- 'Edition 11 mutating or non-read-only fetches require staleAfterSeconds: 0.',
17285
- );
17305
+ const verdict = reusableWindowEligibility({ kind: 'fetch', method });
17306
+ if ('message' in verdict) throw new Error(verdict.message);
17286
17307
  }
17287
17308
  const urlContainsResolvedSecret =
17288
17309
  this.secretRedactor.containsRegisteredSecret(url, {
@@ -20518,6 +20539,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
20518
20539
  .catch(() => null);
20519
20540
  const retrySafeTransientHttp =
20520
20541
  retryPolicy?.retrySafeTransientHttp === true;
20542
+ const providerServerErrorReplay =
20543
+ retryPolicy?.providerServerErrorReplay ?? 'never';
20521
20544
  const requiresExecutionFence =
20522
20545
  retryPolicy?.requiresExecutionFence === true;
20523
20546
  // Fenced execution is an operation-specific opt-in. A gateway may
@@ -21824,6 +21847,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21824
21847
  transientHttpRetrySafe:
21825
21848
  retrySafeTransientHttp || fixtureReplaySafe,
21826
21849
  executionFenced: usesDurableInvocationFence,
21850
+ providerServerErrorReplay,
21827
21851
  });
21828
21852
  let failure = classifyToolExecuteHttpFailure({
21829
21853
  toolId,
@@ -21840,6 +21864,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21840
21864
  transientHttpRetrySafe:
21841
21865
  retrySafeTransientHttp || fixtureReplaySafe,
21842
21866
  executionFenced: usesDurableInvocationFence,
21867
+ providerServerErrorReplay,
21843
21868
  providerLatencyMs:
21844
21869
  Date.now() - dispatchedProviderCallStartedAt,
21845
21870
  });
@@ -21865,6 +21890,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21865
21890
  transientHttpRetrySafe:
21866
21891
  retrySafeTransientHttp || fixtureReplaySafe,
21867
21892
  executionFenced: usesDurableInvocationFence,
21893
+ providerServerErrorReplay,
21868
21894
  providerLatencyMs:
21869
21895
  Date.now() - dispatchedProviderCallStartedAt,
21870
21896
  });
@@ -22378,6 +22404,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22378
22404
  fixtureReplaySafe ||
22379
22405
  Boolean(asyncExecutionRecovery),
22380
22406
  executionFenced: usesDurableInvocationFence,
22407
+ providerServerErrorReplay,
22381
22408
  });
22382
22409
  const failure =
22383
22410
  preclassifiedHttpFailure.current?.failure ??
@@ -22394,6 +22421,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22394
22421
  fixtureReplaySafe ||
22395
22422
  Boolean(asyncExecutionRecovery),
22396
22423
  executionFenced: usesDurableInvocationFence,
22424
+ providerServerErrorReplay,
22397
22425
  ...(providerCallElapsedMs !== null
22398
22426
  ? { providerLatencyMs: providerCallElapsedMs }
22399
22427
  : {}),
@@ -22636,6 +22664,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22636
22664
  const billingRetryIdentity = toolExecuteBillingRetryIdentity({
22637
22665
  failure,
22638
22666
  executionFenced: usesDurableInvocationFence,
22667
+ asyncExecutionRecovery: Boolean(asyncExecutionRecovery),
22639
22668
  httpFailureAttempt,
22640
22669
  invocationAttempt,
22641
22670
  });
@@ -1153,6 +1153,7 @@ export interface ContextOptions {
1153
1153
  ) => Promise<{
1154
1154
  retrySafeTransientHttp?: boolean;
1155
1155
  requiresExecutionFence?: boolean;
1156
+ providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
1156
1157
  } | null>;
1157
1158
  getToolActionCacheVersion?: (toolId: string) => Promise<string> | string;
1158
1159
  /**
@@ -0,0 +1,209 @@
1
+ import { randomUUID } from 'node:crypto';
2
+
3
+ import {
4
+ DB_LOGICAL_TABLES,
5
+ DB_SESSION_OPERATIONS,
6
+ PRELOADED_RUNTIME_DB_SESSION_TTL_SECONDS,
7
+ createDbSessionResponseSchema,
8
+ type CreateDbSessionResponse,
9
+ type PreloadedRuntimeDbSession,
10
+ } from './db-session';
11
+ import {
12
+ dbSessionPostgresUrlAad,
13
+ decryptDbSessionPostgresUrl,
14
+ encryptDbSessionPostgresUrl,
15
+ } from './db-session-crypto';
16
+
17
+ /**
18
+ * Admission seals a run's Runtime DB sessions once, for the executor-token
19
+ * lifetime. A run that sleeps or waits past that lifetime would otherwise wake
20
+ * with sessions that every reader rejects as expired. Each attempt's
21
+ * executor-token issuance therefore renews them, under the attempt lease,
22
+ * whenever they would expire before the attempt's own token does. This slack
23
+ * keeps the first attempt of a promptly claimed run on its admission sessions:
24
+ * it is smaller than the runner's post-runtime headroom, so user code can never
25
+ * outlive a session it reused.
26
+ */
27
+ export const PRELOADED_RUNTIME_DB_SESSION_ATTEMPT_RENEWAL_SLACK_MS = 5 * 60_000;
28
+
29
+ /** The lifetime a renewed session receives, from the renewing attempt's start. */
30
+ export const PRELOADED_RUNTIME_DB_SESSION_RENEWAL_TTL_MS =
31
+ PRELOADED_RUNTIME_DB_SESSION_TTL_SECONDS * 1000;
32
+
33
+ function sessionExpiresAtMs(preloaded: unknown): number | null {
34
+ if (!preloaded || typeof preloaded !== 'object') return null;
35
+ const session = (preloaded as { session?: unknown }).session;
36
+ if (!session || typeof session !== 'object') return null;
37
+ const expiresAt = (session as { expiresAt?: unknown }).expiresAt;
38
+ if (typeof expiresAt !== 'string') return null;
39
+ const parsed = Date.parse(expiresAt);
40
+ return Number.isFinite(parsed) ? parsed : null;
41
+ }
42
+
43
+ /**
44
+ * Whether a new attempt starting at `nowMs` needs renewed sessions: some
45
+ * stored session would expire before a token minted now. An entry without a
46
+ * readable expiry is never matched by a reader, so renewal leaves it alone and
47
+ * it cannot make renewal due.
48
+ */
49
+ export function preloadedRuntimeDbSessionsRenewalDue(
50
+ sessions: readonly unknown[],
51
+ nowMs: number,
52
+ ): boolean {
53
+ return sessions.some((preloaded) => sessionRenewalDue(preloaded, nowMs));
54
+ }
55
+
56
+ function sessionRenewalDue(preloaded: unknown, nowMs: number): boolean {
57
+ const expiresAtMs = sessionExpiresAtMs(preloaded);
58
+ return (
59
+ expiresAtMs !== null &&
60
+ expiresAtMs <
61
+ nowMs +
62
+ PRELOADED_RUNTIME_DB_SESSION_RENEWAL_TTL_MS -
63
+ PRELOADED_RUNTIME_DB_SESSION_ATTEMPT_RENEWAL_SLACK_MS
64
+ );
65
+ }
66
+
67
+ /**
68
+ * Re-seal each stored session that is due (it would expire before a token
69
+ * minted now) with a fresh id and expiry and nothing else
70
+ * changed: the same org, Play, table namespace, logical table, operations,
71
+ * limits, relations, execution role, and database location. The database URL
72
+ * is the one admission sealed, decrypted with the run's own unwrap key (which
73
+ * also authenticates the stored metadata) and sealed again under that key, so
74
+ * a renewal can never widen scope or move a run to another location.
75
+ *
76
+ * Entries that are not due, and entries that a reader could never use for
77
+ * this run (malformed, another org or Play, a public-key envelope that was
78
+ * never a preload, or a bundle that does not authenticate under the run's
79
+ * key), are returned unchanged (the same object), so their readers keep
80
+ * failing exactly as before. An unrenewable expired entry therefore leaves
81
+ * the array identical and cannot make every later attempt renew again.
82
+ */
83
+ export async function renewPreloadedRuntimeDbSessions(input: {
84
+ sessions: readonly PreloadedRuntimeDbSession[];
85
+ unwrapKey: string;
86
+ orgId: string;
87
+ playName: string;
88
+ nowMs: number;
89
+ }): Promise<PreloadedRuntimeDbSession[]> {
90
+ const unwrapKey = input.unwrapKey.trim();
91
+ if (!unwrapKey) {
92
+ throw new Error(
93
+ 'Renewing preloaded Runtime DB sessions requires the run unwrap key.',
94
+ );
95
+ }
96
+ const expiresAt = new Date(
97
+ input.nowMs + PRELOADED_RUNTIME_DB_SESSION_RENEWAL_TTL_MS,
98
+ ).toISOString();
99
+ return await Promise.all(
100
+ input.sessions.map(async (preloaded) => {
101
+ if (!sessionRenewalDue(preloaded, input.nowMs)) return preloaded;
102
+ const parsed = createDbSessionResponseSchema.safeParse(
103
+ preloaded?.session,
104
+ );
105
+ if (!parsed.success) return preloaded;
106
+ const session = parsed.data;
107
+ if (
108
+ session.target.orgId !== input.orgId ||
109
+ session.playName !== input.playName
110
+ ) {
111
+ return preloaded;
112
+ }
113
+ // Spread the stored object so fields this build does not know survive;
114
+ // the AAD is computed from the parsed view every reader also uses.
115
+ const stored = preloaded.session as unknown as Record<string, unknown>;
116
+ const {
117
+ postgresUrl,
118
+ encryptedPostgresUrl,
119
+ ...sessionWithoutUrl
120
+ }: CreateDbSessionResponse = session;
121
+ const renewedIdentity = { sessionId: randomUUID(), expiresAt };
122
+ if (!encryptedPostgresUrl) {
123
+ // Harness-only plain sessions carry no sealed URL to re-key.
124
+ return {
125
+ ...preloaded,
126
+ session: {
127
+ ...stored,
128
+ ...renewedIdentity,
129
+ } as unknown as CreateDbSessionResponse,
130
+ };
131
+ }
132
+ if (encryptedPostgresUrl.alg !== 'A256GCM') return preloaded;
133
+ void postgresUrl;
134
+ let sealedUrl: string;
135
+ try {
136
+ sealedUrl = await decryptDbSessionPostgresUrl({
137
+ encrypted: encryptedPostgresUrl,
138
+ secret: unwrapKey,
139
+ aad: dbSessionPostgresUrlAad(sessionWithoutUrl),
140
+ });
141
+ } catch {
142
+ // Every reader fails this same unwrap loudly when it uses the entry.
143
+ // Renewal never re-seals a bundle it could not authenticate.
144
+ return preloaded;
145
+ }
146
+ return {
147
+ ...preloaded,
148
+ session: {
149
+ ...stored,
150
+ ...renewedIdentity,
151
+ encryptedPostgresUrl: await encryptDbSessionPostgresUrl({
152
+ postgresUrl: sealedUrl,
153
+ secret: unwrapKey,
154
+ aad: dbSessionPostgresUrlAad({
155
+ ...sessionWithoutUrl,
156
+ ...renewedIdentity,
157
+ }),
158
+ }),
159
+ } as unknown as CreateDbSessionResponse,
160
+ };
161
+ }),
162
+ );
163
+ }
164
+
165
+ /**
166
+ * Read an executor-token response's optional `preloadedDbSessions`. Returns
167
+ * the array only when every entry is a well-formed preloaded session whose
168
+ * envelope agrees with its session target; otherwise null, so the caller keeps
169
+ * the launch's stored sessions. Absence, an empty array, or any malformed entry
170
+ * all mean "nothing renewed".
171
+ */
172
+ export function parseRenewedPreloadedRuntimeDbSessions(
173
+ value: unknown,
174
+ ): PreloadedRuntimeDbSession[] | null {
175
+ if (!Array.isArray(value) || value.length === 0) return null;
176
+ const parsed: PreloadedRuntimeDbSession[] = [];
177
+ for (const entry of value) {
178
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
179
+ return null;
180
+ }
181
+ const candidate = entry as Record<string, unknown>;
182
+ const { tableNamespace, logicalTable, operations } = candidate;
183
+ if (
184
+ typeof tableNamespace !== 'string' ||
185
+ !tableNamespace.trim() ||
186
+ typeof logicalTable !== 'string' ||
187
+ !(DB_LOGICAL_TABLES as readonly string[]).includes(logicalTable) ||
188
+ !Array.isArray(operations) ||
189
+ operations.length === 0 ||
190
+ !operations.every(
191
+ (operation) =>
192
+ typeof operation === 'string' &&
193
+ (DB_SESSION_OPERATIONS as readonly string[]).includes(operation),
194
+ )
195
+ ) {
196
+ return null;
197
+ }
198
+ const session = createDbSessionResponseSchema.safeParse(candidate.session);
199
+ if (
200
+ !session.success ||
201
+ session.data.target.tableNamespace !== tableNamespace ||
202
+ session.data.target.logicalTable !== logicalTable
203
+ ) {
204
+ return null;
205
+ }
206
+ parsed.push(entry as PreloadedRuntimeDbSession);
207
+ }
208
+ return parsed;
209
+ }
@@ -47,16 +47,33 @@ export const DURABLE_RUNS_ROLLOUT = {
47
47
  sharedReadCacheWrites: true,
48
48
  /**
49
49
  * A provider's 5xx is retried inside the attempt with exponential backoff
50
- * and jitter, sending the same provider idempotency key, even for an
51
- * action not declared transient-HTTP safe. Only successes are final; a
52
- * provider that ignores idempotency keys may see a write twice. The
53
- * runner and the gateway's previous-outcome check use this same decision,
54
- * so both must run it before it is flipped.
50
+ * and jitter, sending the same provider idempotency key, but only for an
51
+ * action that is classified for it (`retry.providerServerErrorReplay` of
52
+ * `idempotent_key` or `read_safe`, or `retrySafeTransientHttp`). A write,
53
+ * upsert, create or send, a paid call whose 5xx is ambiguous after
54
+ * dispatch, and any unclassified action is never resent. Only successes are
55
+ * final for the classified actions. The runner decides; the gateway
56
+ * previous-outcome check only validates the recorded outcome.
57
+ *
58
+ * Known limit: a provider that ignores idempotency keys may still apply a
59
+ * classified write twice if its classification is wrong, so a new replaying
60
+ * action needs review (`tests/fixtures/provider-server-error-replay.json`).
61
+ * Each call is retried at most twice (3 sends), a provider Retry-After wait
62
+ * is capped at 30 s, and the retries never charge the run-wide retry
63
+ * budget. Off again stops new retries; a call already retried keeps its
64
+ * recorded attempts.
55
65
  */
56
- retryProviderServerErrors: false,
66
+ retryProviderServerErrors: true,
57
67
  /**
58
68
  * `runs resume` continues a stopped run. Off, the API refuses with
59
69
  * `resume_unavailable`; readers for resumed runs ship regardless.
70
+ *
71
+ * Turning it off again refuses new resumes and stops keeping staged input
72
+ * for runs that stop afterwards. Input already kept stays until the switch
73
+ * returns (the expiry sweep idles while off), and a resumed run keeps its
74
+ * epoch state. Stopped runs' answers are compacted again while it is off, so
75
+ * a resume after re-enabling may re-execute calls whose answers were
76
+ * compacted in between.
60
77
  */
61
- runsResume: false,
78
+ runsResume: true,
62
79
  } as const;
@@ -6,6 +6,7 @@ import type { ToolResultMetadataInput } from '../tool-result';
6
6
 
7
7
  /** The app's runtime tool metadata as the runner receives it over HTTP. */
8
8
  export type RuntimeToolMetadata = {
9
+ /** The pre-edition-11 shared-cache gate; only the legacy latest-cache path reads it. */
9
10
  reusableResult?: { supported: boolean; unavailableReason: string | null };
10
11
  provider?: string | null;
11
12
  operation?: string | null;
@@ -17,6 +18,7 @@ export type RuntimeToolMetadata = {
17
18
  idempotencyScope?: 'invocation';
18
19
  retrySafeTransientHttp?: boolean;
19
20
  requiresExecutionFence?: boolean;
21
+ providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
20
22
  };
21
23
  targetGetters?: Record<string, string[]>;
22
24
  listExtractorPaths?: string[];
@@ -102,6 +104,9 @@ export function createRuntimeToolHooks(input: {
102
104
  return {
103
105
  retrySafeTransientHttp: metadata.retry?.retrySafeTransientHttp === true,
104
106
  requiresExecutionFence: metadata.retry?.requiresExecutionFence === true,
107
+ // Absent (an older metadata reader or an unclassified action) is `never`.
108
+ providerServerErrorReplay:
109
+ metadata.retry?.providerServerErrorReplay ?? 'never',
105
110
  };
106
111
  },
107
112
  getToolActionCacheVersion: async (toolId) => {
@@ -254,6 +254,7 @@ export function createRuntimeSandboxPlacementBackend(input: {
254
254
  to: nextProvider,
255
255
  stage: 'acquisition',
256
256
  reason,
257
+ atMs: Date.now(),
257
258
  }),
258
259
  );
259
260
  }