deepline 0.3.392 → 0.3.394

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 (153) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +156 -24
  2. package/dist/bundling-sources/sdk/src/compat.ts +9 -0
  3. package/dist/bundling-sources/sdk/src/http.ts +5 -1
  4. package/dist/bundling-sources/sdk/src/index.ts +5 -0
  5. package/dist/bundling-sources/sdk/src/plays/run-request.ts +182 -6
  6. package/dist/bundling-sources/sdk/src/release.ts +4 -1
  7. package/dist/bundling-sources/sdk/src/types.ts +13 -0
  8. package/dist/bundling-sources/shared_libs/integration-contracts/request-warnings.ts +64 -0
  9. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +315 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +41 -8
  11. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +895 -54
  12. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +41 -4
  13. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-policy.ts +28 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/durable-invocation-fence.ts +36 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +251 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +11 -3
  17. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +1 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +30 -1
  19. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +26 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +168 -10
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +252 -10
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +92 -58
  23. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +7 -1
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +30 -7
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1161 -316
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +28 -15
  27. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +24 -3
  28. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +32 -0
  29. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +103 -23
  30. package/dist/bundling-sources/shared_libs/plays/core.ts +1 -1
  31. package/dist/bundling-sources/shared_libs/plays/dataset.ts +172 -79
  32. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +173 -1
  33. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +18 -0
  34. package/dist/cli/auth-IHKISLJQ.js +39 -0
  35. package/dist/cli/{auth-6JSA2ZCW.mjs → auth-OSXDAVCF.mjs} +4 -4
  36. package/dist/cli/{billing-Q5BLQHIU.js → billing-EKLYOXUY.js} +101 -74
  37. package/dist/cli/{billing-MRRO643H.mjs → billing-ZNNKX3UR.mjs} +32 -5
  38. package/dist/cli/{chunk-4SFPVW7A.js → chunk-2MDDA7A4.js} +26 -26
  39. package/dist/cli/{chunk-JOFPQGXW.js → chunk-354JCXA2.js} +50 -50
  40. package/dist/cli/{chunk-7E66A24V.mjs → chunk-3HU47EGZ.mjs} +71 -9
  41. package/dist/cli/{chunk-DSWSEHRX.mjs → chunk-3HWALOL2.mjs} +1 -1
  42. package/dist/cli/{chunk-T7OKJ2T6.js → chunk-4P27AXEA.js} +73 -63
  43. package/dist/cli/{chunk-24VEN5PQ.mjs → chunk-5BB2RGAX.mjs} +190 -18
  44. package/dist/cli/{chunk-JSLPHFP7.js → chunk-6YAUMG27.js} +3 -2
  45. package/dist/cli/{chunk-MU6M3URX.mjs → chunk-BP33SIZF.mjs} +1 -1
  46. package/dist/cli/{chunk-WMS5U6YB.js → chunk-CS6RAIVY.js} +20 -19
  47. package/dist/cli/{chunk-CVLM3WMJ.js → chunk-E23BQ5SC.js} +242 -183
  48. package/dist/cli/{chunk-2GAHHSLB.mjs → chunk-FJGW5GXU.mjs} +3 -2
  49. package/dist/cli/{chunk-YN6YA7ZZ.mjs → chunk-JHIJIHFB.mjs} +79 -20
  50. package/dist/cli/{chunk-Q6EOHNRH.mjs → chunk-JI2B4RZP.mjs} +119 -6
  51. package/dist/cli/{chunk-5O4B6AUN.js → chunk-KB4SDX5S.js} +71 -9
  52. package/dist/cli/{chunk-RV6ALZIX.js → chunk-KGNTKMRG.js} +32 -7
  53. package/dist/cli/{chunk-6DBOU7UH.js → chunk-KI635JN4.js} +176 -87
  54. package/dist/cli/{chunk-2FQG2HU4.js → chunk-KIUMEOM5.js} +8 -8
  55. package/dist/cli/{chunk-Y6VOGHF2.mjs → chunk-KZZC33PY.mjs} +0 -181
  56. package/dist/cli/{chunk-2Q3GEFL4.mjs → chunk-M57J2SK4.mjs} +2 -2
  57. package/dist/cli/{chunk-R3O2CZ4H.mjs → chunk-MFB2VKBO.mjs} +2 -2
  58. package/dist/cli/{chunk-QGKPTBRR.js → chunk-MH73HMPV.js} +3 -3
  59. package/dist/cli/{chunk-BB3FNYFY.js → chunk-MLPU5SMZ.js} +2 -2
  60. package/dist/cli/{chunk-2G7DXFHI.mjs → chunk-NR3DFKNF.mjs} +27 -2
  61. package/dist/cli/{chunk-EY7RFC6A.js → chunk-QIQBYKLB.js} +15 -15
  62. package/dist/cli/{chunk-RIV2GS5E.js → chunk-RBJYWRCF.js} +638 -466
  63. package/dist/cli/{chunk-3VN4FTE3.js → chunk-RDXFGPJU.js} +1 -182
  64. package/dist/cli/{chunk-YAZCDBXX.mjs → chunk-TJI2EN6K.mjs} +3 -2
  65. package/dist/cli/chunk-UBKA33KY.mjs +310 -0
  66. package/dist/cli/{chunk-PAIMOGCM.js → chunk-UHNDVD3P.js} +125 -12
  67. package/dist/cli/{chunk-4TCT77UF.js → chunk-URWF7NGQ.js} +6 -1
  68. package/dist/cli/{chunk-2QLML6G4.mjs → chunk-UXFSWG3Q.mjs} +4 -4
  69. package/dist/cli/{chunk-UCKJQG25.js → chunk-VK6FYZLP.js} +8 -8
  70. package/dist/cli/{chunk-ZTACINO5.mjs → chunk-X63FDZJZ.mjs} +13 -3
  71. package/dist/cli/chunk-XDVT3GOM.js +310 -0
  72. package/dist/cli/{chunk-A3APGZFP.mjs → chunk-XRQ2AQL7.mjs} +2 -2
  73. package/dist/cli/{chunk-3FV4GBRK.mjs → chunk-XXUDVEXK.mjs} +97 -8
  74. package/dist/cli/{chunk-PQSA443V.mjs → chunk-ZI2ZNDJK.mjs} +6 -1
  75. package/dist/cli/{chunk-HGYBEAQP.mjs → chunk-ZYBGA4AR.mjs} +3 -3
  76. package/dist/cli/command-docs.js +2 -2
  77. package/dist/cli/command-docs.mjs +1 -1
  78. package/dist/cli/{csv-E4QGUIGI.mjs → csv-5AXRB35H.mjs} +3 -3
  79. package/dist/cli/{csv-26U5T24Z.js → csv-LU7O75WE.js} +12 -12
  80. package/dist/cli/{db-JTRJIAQW.mjs → db-7XP5UWEW.mjs} +6 -5
  81. package/dist/cli/{db-QHBFLMVL.js → db-F7YTFKVM.js} +31 -30
  82. package/dist/cli/{describe-FDV2V74F.js → describe-FRH32RDV.js} +24 -23
  83. package/dist/cli/{describe-E3DE3ZK3.mjs → describe-K4ES5LIL.mjs} +17 -16
  84. package/dist/cli/{executions-B3GTNPRE.mjs → executions-IEHEHJUO.mjs} +6 -5
  85. package/dist/cli/{executions-VZYOGVQY.js → executions-RZV5XPT2.js} +8 -7
  86. package/dist/cli/{feedback-CR55FJA2.js → feedback-3P65QTX3.js} +7 -7
  87. package/dist/cli/{feedback-4CEBR3OV.mjs → feedback-FPUVZBAN.mjs} +3 -3
  88. package/dist/cli/{git-NM2PHHZ4.mjs → git-GLVVP7TY.mjs} +4 -4
  89. package/dist/cli/git-MFFAWVVX.js +23 -0
  90. package/dist/cli/index.js +100 -96
  91. package/dist/cli/index.mjs +47 -43
  92. package/dist/cli/{legacy-noops-A7MSW5ND.mjs → legacy-noops-3MOI6NBM.mjs} +4 -4
  93. package/dist/cli/{legacy-noops-ZUA4YFIH.js → legacy-noops-XKSGZR7Q.js} +7 -7
  94. package/dist/cli/{monitors-NVPRQYP3.mjs → monitors-FTBGNEFG.mjs} +6 -5
  95. package/dist/cli/{monitors-ZE3TLZ4H.js → monitors-NZ2DYNST.js} +87 -86
  96. package/dist/cli/{org-U7A6DV5D.js → org-MCKDQXIV.js} +66 -65
  97. package/dist/cli/{org-KUBILNQV.mjs → org-V2J5RBCN.mjs} +6 -5
  98. package/dist/cli/{play-HRDXQ4QE.mjs → play-AJFGME3B.mjs} +11 -10
  99. package/dist/cli/play-WLSN2EO2.js +158 -0
  100. package/dist/cli/{providers-VD6YTVQZ.js → providers-2JEZ2264.js} +9 -8
  101. package/dist/cli/{providers-OHIWI453.mjs → providers-I6RQJZFZ.mjs} +6 -5
  102. package/dist/cli/{quickstart-UBV2FONF.mjs → quickstart-BIDQDMO4.mjs} +3 -3
  103. package/dist/cli/{quickstart-ETTCWPA4.js → quickstart-GJ2RPDU3.js} +5 -5
  104. package/dist/cli/run-identity-G257GQED.js +25 -0
  105. package/dist/cli/run-identity-MRNCEGV2.mjs +25 -0
  106. package/dist/cli/search-5VN4YD4I.js +27 -0
  107. package/dist/cli/{search-F44IZRT7.mjs → search-ELRXFWG5.mjs} +7 -6
  108. package/dist/cli/{secrets-CAEMRORF.js → secrets-53IT6VXD.js} +15 -14
  109. package/dist/cli/{secrets-R6XOJZKU.mjs → secrets-SQXGZXIC.mjs} +6 -5
  110. package/dist/cli/{sessions-RLN6UQS3.mjs → sessions-2X5QF7SL.mjs} +4 -4
  111. package/dist/cli/{sessions-6GC7OFTT.js → sessions-CAV5M77Y.js} +5 -5
  112. package/dist/cli/{settings-DPNVUAV2.js → settings-532WNAZO.js} +76 -75
  113. package/dist/cli/{settings-KIPAMRPP.mjs → settings-7P67VGCJ.mjs} +9 -8
  114. package/dist/cli/{setup-DTL3L5SG.js → setup-6L2VSUWJ.js} +41 -41
  115. package/dist/cli/{setup-TU2F7PU5.mjs → setup-QGGBV2LE.mjs} +6 -6
  116. package/dist/cli/{skills-UV5MYJ46.mjs → skills-3FE62WBG.mjs} +4 -4
  117. package/dist/cli/skills-S6NPZAN7.js +28 -0
  118. package/dist/cli/tools-647RLXQS.js +41 -0
  119. package/dist/cli/{tools-QRRNDCQ7.mjs → tools-DMR25DEF.mjs} +10 -9
  120. package/dist/cli/{update-4426TF35.mjs → update-6RZMHJZP.mjs} +6 -6
  121. package/dist/cli/update-WVTSC3EM.js +28 -0
  122. package/dist/cli/{workflow-N4U5VLZ3.mjs → workflow-L2DQRE6R.mjs} +7 -6
  123. package/dist/cli/{workflow-HNLOVISB.js → workflow-TX4F2PIX.js} +17 -16
  124. package/dist/{client-e6Qh5ZIg.d.mts → client-BktIPdIj.d.mts} +153 -4
  125. package/dist/{client-Uxuy-xQ2.d.ts → client-C3O1Ipf3.d.ts} +153 -4
  126. package/dist/{compiler-manifest-CY2v8ab0.d.ts → compiler-manifest-DLxUY5kI.d.mts} +124 -10
  127. package/dist/{compiler-manifest-CY2v8ab0.d.mts → compiler-manifest-DLxUY5kI.d.ts} +124 -10
  128. package/dist/{index-BZ6uzZJl.d.ts → index-B_GM9E3q.d.ts} +1 -1
  129. package/dist/{index-B9fBZH1g.d.mts → index-SCb0NvDb.d.mts} +1 -1
  130. package/dist/index.d.mts +5 -5
  131. package/dist/index.d.ts +5 -5
  132. package/dist/index.js +120 -29
  133. package/dist/index.mjs +111 -20
  134. package/dist/install-integrity.json +94 -88
  135. package/dist/plays/bundle-play-file.d.mts +3 -3
  136. package/dist/plays/bundle-play-file.d.ts +3 -3
  137. package/dist/plays/bundle-play-file.mjs +2 -2
  138. package/dist/plays/run-request.d.mts +2 -2
  139. package/dist/plays/run-request.d.ts +2 -2
  140. package/dist/plays/run-request.js +5 -2
  141. package/dist/plays/run-request.mjs +4 -1
  142. package/dist/release.d.mts +4 -1
  143. package/dist/release.d.ts +4 -1
  144. package/dist/release.js +2 -2
  145. package/dist/release.mjs +1 -1
  146. package/package.json +1 -1
  147. package/dist/cli/auth-67TAELQL.js +0 -39
  148. package/dist/cli/git-I5JTK6YU.js +0 -23
  149. package/dist/cli/play-A2V7YDU7.js +0 -157
  150. package/dist/cli/search-WWXMBVPH.js +0 -26
  151. package/dist/cli/skills-SWOSEZLB.js +0 -28
  152. package/dist/cli/tools-IL2YCDQ6.js +0 -40
  153. package/dist/cli/update-BERDPEYR.js +0 -28
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-NXGCO4JB.mjs";
15
15
  import {
16
16
  SDK_RELEASE
17
- } from "./chunk-YAZCDBXX.mjs";
17
+ } from "./chunk-TJI2EN6K.mjs";
18
18
 
19
19
  // src/errors.ts
20
20
  var CustomerDbQueryOutcomeUnknownError = class extends DeeplineError {
@@ -1739,7 +1739,8 @@ var HttpClient = class {
1739
1739
  applyExplicitHeaders(headers, { "Content-Type": "application/json" });
1740
1740
  }
1741
1741
  let lastError = null;
1742
- for (const candidateUrl of buildCandidateUrls(url)) {
1742
+ const candidateUrls = options?.exactUrlOnly ? [url] : buildCandidateUrls(url);
1743
+ for (const candidateUrl of candidateUrls) {
1743
1744
  try {
1744
1745
  const response = await fetch(candidateUrl, {
1745
1746
  method,
@@ -6,14 +6,14 @@ import {
6
6
  } from "./chunk-6IKARAYD.mjs";
7
7
  import {
8
8
  PLAY_RUN_START_STREAM_PATH,
9
- buildPlayRunStartBody,
10
9
  decodePlayRunPublicStatus,
11
10
  isPlayRunPackage,
12
11
  isTerminalPlayRunLifecycleStatus,
13
12
  mintStagedPlayFileUploads,
13
+ preparePlayRunAdmission,
14
14
  stagePlayFiles,
15
15
  startPlayRun
16
- } from "./chunk-Q6EOHNRH.mjs";
16
+ } from "./chunk-JI2B4RZP.mjs";
17
17
  import {
18
18
  COORDINATOR_INTERNAL_TOKEN_HEADER,
19
19
  CustomerDbQueryOutcomeUnknownError,
@@ -21,7 +21,7 @@ import {
21
21
  RETAINED_PIPELINE_RECEIVERS_HEADER,
22
22
  RUNTIME_ENVIRONMENT_TOKEN_HEADER,
23
23
  resolveConfig
24
- } from "./chunk-2GAHHSLB.mjs";
24
+ } from "./chunk-FJGW5GXU.mjs";
25
25
  import {
26
26
  DeeplineError,
27
27
  TOOL_EXECUTION_ERROR_SCHEMA_HEADER,
@@ -3256,6 +3256,7 @@ var DeeplineClient = class _DeeplineClient {
3256
3256
  input: (runId) => this.getRunInput(runId),
3257
3257
  rerun: (runId, options2) => this.rerun(runId, options2),
3258
3258
  exportDatasetRows: (input) => this.getPlaySheetRows(input),
3259
+ rowHistory: (input) => this.getPlayRunRowHistory(input),
3259
3260
  stop: (runId, options2) => this.stopRun(runId, options2),
3260
3261
  stopAll: ((options2) => this.stopAllRuns(options2))
3261
3262
  };
@@ -3264,6 +3265,7 @@ var DeeplineClient = class _DeeplineClient {
3264
3265
  planQuery: (input) => planCustomerDbQuery(input)
3265
3266
  };
3266
3267
  this.billing = {
3268
+ quote: (input) => this.http.post("/api/v2/billing/quote", input),
3267
3269
  entitlements: () => this.http.get("/api/v2/billing/entitlements"),
3268
3270
  topUp: (options2) => this.topUpBillingBalance(options2),
3269
3271
  topUpWithReceipt: (options2) => this.topUpBillingBalanceWithReceipt(options2),
@@ -3737,14 +3739,62 @@ var DeeplineClient = class _DeeplineClient {
3737
3739
  * });
3738
3740
  * ```
3739
3741
  */
3740
- async startPlayRun(request) {
3742
+ async startPlayRun(request, options) {
3741
3743
  const resolved = resolveStartPlayRunRequest(request, this.environment);
3742
3744
  return startPlayRun(
3743
3745
  this.http,
3744
3746
  resolved.request,
3745
- runtimeSelectionHeaders(resolved.runtime, this.environment)
3747
+ runtimeSelectionHeaders(resolved.runtime, this.environment),
3748
+ options?.onSubmission
3746
3749
  );
3747
3750
  }
3751
+ /**
3752
+ * Prepare a tenant-scoped start intent without executing it. Its stream
3753
+ * sender retains the exact body and transport selected during preparation.
3754
+ */
3755
+ async preparePlayRunAdmission(request, options) {
3756
+ const resolved = resolveStartPlayRunRequest(request, this.environment);
3757
+ const prepared = await preparePlayRunAdmission(
3758
+ this.http,
3759
+ resolved.request,
3760
+ options?.onSubmission
3761
+ );
3762
+ const bodyJson = JSON.stringify(prepared.body);
3763
+ const headers = runtimeSelectionHeaders(resolved.runtime, this.environment);
3764
+ const http = this.http;
3765
+ let submitted = false;
3766
+ return {
3767
+ ...prepared,
3768
+ async *startStream(streamOptions) {
3769
+ if (submitted && !prepared.supportsCallerIntent) {
3770
+ throw new DeeplineError(
3771
+ "This server has not enabled caller-owned admission recovery. Do not retry an ambiguous start.",
3772
+ 409,
3773
+ "PLAY_RUN_ADMISSION_RECOVERY_UNSUPPORTED"
3774
+ );
3775
+ }
3776
+ if (submitted) {
3777
+ await preparePlayRunAdmission(
3778
+ http,
3779
+ JSON.parse(bodyJson)
3780
+ );
3781
+ }
3782
+ submitted = true;
3783
+ for await (const event of http.streamSse(
3784
+ PLAY_RUN_START_STREAM_PATH,
3785
+ {
3786
+ method: "POST",
3787
+ body: JSON.parse(bodyJson),
3788
+ headers,
3789
+ signal: streamOptions?.signal,
3790
+ exactUrlOnly: true
3791
+ }
3792
+ )) {
3793
+ if (event.scope === "play") yield event;
3794
+ }
3795
+ }
3796
+ };
3797
+ }
3748
3798
  /**
3749
3799
  * Submit a play run through the legacy event response.
3750
3800
  *
@@ -3759,21 +3809,8 @@ var DeeplineClient = class _DeeplineClient {
3759
3809
  * @returns Async generator of play-scoped live events.
3760
3810
  */
3761
3811
  async *startPlayRunStream(request, options) {
3762
- const resolved = resolveStartPlayRunRequest(request, this.environment);
3763
- const body = buildPlayRunStartBody(resolved.request);
3764
- for await (const event of this.http.streamSse(
3765
- PLAY_RUN_START_STREAM_PATH,
3766
- {
3767
- method: "POST",
3768
- body,
3769
- headers: runtimeSelectionHeaders(resolved.runtime, this.environment),
3770
- signal: options?.signal
3771
- }
3772
- )) {
3773
- if (event.scope === "play") {
3774
- yield event;
3775
- }
3776
- }
3812
+ const prepared = await this.preparePlayRunAdmission(request, options);
3813
+ yield* prepared.startStream({ signal: options?.signal });
3777
3814
  }
3778
3815
  /**
3779
3816
  * Register a bundled play artifact.
@@ -4795,6 +4832,21 @@ var DeeplineClient = class _DeeplineClient {
4795
4832
  { headers, retryApiErrors: true }
4796
4833
  );
4797
4834
  }
4835
+ /**
4836
+ * Read one page of immutable admitted and terminal rows for a Play Run dataset.
4837
+ * Follow nextCursor; coverage explicitly identifies unavailable or incomplete history.
4838
+ */
4839
+ async getPlayRunRowHistory(input) {
4840
+ const params = new URLSearchParams({
4841
+ runId: input.runId,
4842
+ tableNamespace: input.tableNamespace
4843
+ });
4844
+ if (input.limit !== void 0) params.set("limit", String(input.limit));
4845
+ if (input.cursor !== void 0) params.set("cursor", input.cursor);
4846
+ return this.http.get(
4847
+ `/api/v2/plays/${encodeURIComponent(input.playName)}/sheet/history?${params}`
4848
+ );
4849
+ }
4798
4850
  /**
4799
4851
  * Export persisted runtime-sheet rows for a play dataset/table namespace.
4800
4852
  *
@@ -5004,6 +5056,13 @@ var DeeplineClient = class _DeeplineClient {
5004
5056
  async getNotificationSettings() {
5005
5057
  return this.http.get("/api/v2/settings/notifications");
5006
5058
  }
5059
+ /** Save provider-owned credential fields without starting an OAuth browser flow. */
5060
+ async setIntegrationCredentials(provider, credentials) {
5061
+ return this.http.post("/api/v2/integrations/connect", {
5062
+ provider,
5063
+ credentials
5064
+ });
5065
+ }
5007
5066
  /** Start the Slack OAuth flow required by product notifications. */
5008
5067
  async connectNotificationSlack(options) {
5009
5068
  return this.http.post("/api/v2/integrations/connect", {
@@ -1,3 +1,7 @@
1
+ import {
2
+ buildCallerPlayWorkflowId,
3
+ callerPlayWorkflowIdMatchesRequest
4
+ } from "./chunk-UBKA33KY.mjs";
1
5
  import {
2
6
  apiErrorCodeFromResponse,
3
7
  apiErrorMessage
@@ -74,6 +78,9 @@ var PLAY_FILES_STAGE_PATH = "/api/v2/plays/files/stage";
74
78
  var PLAY_FILES_STAGE_MINT_PATH = `${PLAY_FILES_STAGE_PATH}/mint`;
75
79
  function buildPlayRunStartBody(request) {
76
80
  return {
81
+ ...request.admissionOrgId ? { admissionOrgId: request.admissionOrgId } : {},
82
+ ...request.workflowId ? { workflowId: request.workflowId } : {},
83
+ ...request.maxTotalCredits !== void 0 ? { maxTotalCredits: request.maxTotalCredits } : {},
77
84
  ...request.name ? { name: request.name } : {},
78
85
  ...request.revisionId ? { revisionId: request.revisionId } : {},
79
86
  ...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
@@ -105,13 +112,117 @@ function buildPlayRunStartBody(request) {
105
112
  ...request.testPolicyOverrides ? { testPolicyOverrides: request.testPolicyOverrides } : {}
106
113
  };
107
114
  }
108
- async function startPlayRun(http, request, headers) {
109
- const response = await http.post(
110
- PLAY_RUN_START_PATH,
111
- buildPlayRunStartBody(request),
112
- headers,
113
- { maxRetries: 0, exactUrlOnly: true }
115
+ async function preparePlayRunAdmission(http, request, onSubmission) {
116
+ let capability = null;
117
+ if (http.get) {
118
+ try {
119
+ capability = await http.get(PLAY_RUN_START_PATH);
120
+ } catch (error) {
121
+ if (!(error instanceof DeeplineError) || ![404, 405].includes(error.statusCode ?? 0))
122
+ throw error;
123
+ }
124
+ if (capability && !["caller-intent-v1", "unsupported"].includes(
125
+ capability.admissionContract ?? ""
126
+ )) {
127
+ throw new DeeplineError(
128
+ "The server admission capability response is unknown; execution was not submitted.",
129
+ 503,
130
+ "PLAY_RUN_ADMISSION_CAPABILITY_UNKNOWN"
131
+ );
132
+ }
133
+ }
134
+ const supportsCallerIntent = capability?.admissionContract === "caller-intent-v1";
135
+ if (supportsCallerIntent && (!capability?.orgId || request.admissionOrgId && request.admissionOrgId !== capability.orgId)) {
136
+ throw new DeeplineError(
137
+ "The admission workspace could not be pinned to this request; execution was not submitted.",
138
+ 409,
139
+ "PLAY_RUN_ADMISSION_TENANT_CONFLICT"
140
+ );
141
+ }
142
+ if (request.workflowId && !supportsCallerIntent) {
143
+ throw new DeeplineError(
144
+ "This server has not enabled caller-owned admission recovery. Do not retry an ambiguous start.",
145
+ 409,
146
+ "PLAY_RUN_ADMISSION_RECOVERY_UNSUPPORTED"
147
+ );
148
+ }
149
+ if (request.maxTotalCredits !== void 0 && capability?.strictTotalBudget !== "fail-closed-v1") {
150
+ throw new DeeplineError(
151
+ "This server cannot honor a strict total Play budget. Execution was not submitted.",
152
+ 409,
153
+ "PLAY_TOTAL_BUDGET_UNSUPPORTED"
154
+ );
155
+ }
156
+ const wireBody = JSON.parse(
157
+ JSON.stringify(
158
+ buildPlayRunStartBody({
159
+ ...request,
160
+ ...supportsCallerIntent ? { admissionOrgId: capability.orgId } : {}
161
+ })
162
+ )
114
163
  );
164
+ const workflowId = supportsCallerIntent ? request.workflowId ?? buildCallerPlayWorkflowId(request.name ?? "play", wireBody) : void 0;
165
+ const submittedBody = workflowId ? { workflowId, ...wireBody } : wireBody;
166
+ if (workflowId && !callerPlayWorkflowIdMatchesRequest(workflowId, submittedBody)) {
167
+ throw new DeeplineError(
168
+ "workflowId must be the caller run ID of this same immutable request.",
169
+ 400,
170
+ "PLAY_RUN_START_INTENT_CONFLICT"
171
+ );
172
+ }
173
+ if (onSubmission) {
174
+ if (!workflowId || !capability?.orgId) {
175
+ throw new DeeplineError(
176
+ "This server cannot persist a recoverable submission intent. Execution was not submitted.",
177
+ 409,
178
+ "PLAY_RUN_ADMISSION_RECOVERY_UNSUPPORTED"
179
+ );
180
+ }
181
+ await onSubmission({
182
+ workflowId,
183
+ orgId: capability.orgId,
184
+ request: submittedBody
185
+ });
186
+ }
187
+ return { body: submittedBody, workflowId, supportsCallerIntent };
188
+ }
189
+ async function startPlayRun(http, request, headers, onSubmission) {
190
+ const {
191
+ body: submittedBody,
192
+ workflowId,
193
+ supportsCallerIntent
194
+ } = await preparePlayRunAdmission(http, request, onSubmission);
195
+ let response;
196
+ try {
197
+ response = await http.post(
198
+ PLAY_RUN_START_PATH,
199
+ submittedBody,
200
+ headers,
201
+ { maxRetries: 0, exactUrlOnly: true }
202
+ );
203
+ } catch (error) {
204
+ if (error instanceof DeeplineError && ["NETWORK_TIMEOUT", "NETWORK_ERROR", "FETCH_FAILED"].includes(
205
+ error.code ?? ""
206
+ ) || error instanceof TypeError || error instanceof Error && ["AbortError", "TimeoutError"].includes(error.name)) {
207
+ const originalMessage = error instanceof Error ? error.message : "Transport failed";
208
+ const failure = new DeeplineError(
209
+ workflowId ? `${originalMessage} Admission outcome is unknown for ${workflowId}. Inspect this run before retrying; reuse this workflowId for the same immutable request.` : `${originalMessage} Admission outcome is unknown. This server did not prove caller-owned recovery support; inspect existing runs before starting again.`,
210
+ error instanceof DeeplineError ? error.statusCode : void 0,
211
+ error instanceof DeeplineError ? error.code : "NETWORK_ERROR",
212
+ {
213
+ ...workflowId ? { runId: workflowId, workflowId } : {},
214
+ admissionState: "unknown",
215
+ recoverySupported: supportsCallerIntent,
216
+ next: {
217
+ inspect: workflowId ? `deepline runs get ${workflowId} --json` : "deepline runs list --json"
218
+ }
219
+ }
220
+ );
221
+ Object.assign(failure, { cause: error });
222
+ throw failure;
223
+ }
224
+ throw error;
225
+ }
115
226
  return normalizePlayRunStart(response);
116
227
  }
117
228
  function isPlayRunPackage(value) {
@@ -520,6 +631,7 @@ function createSessionPlayRunHttp(fetchImpl = (...args) => fetch(...args)) {
520
631
  return parsed;
521
632
  };
522
633
  return {
634
+ get: (path) => send(path, { method: "GET" }),
523
635
  post: (path, body, headers) => send(path, {
524
636
  method: "POST",
525
637
  headers: { "content-type": "application/json", ...headers },
@@ -540,6 +652,7 @@ export {
540
652
  PLAY_FILES_STAGE_PATH,
541
653
  PLAY_FILES_STAGE_MINT_PATH,
542
654
  buildPlayRunStartBody,
655
+ preparePlayRunAdmission,
543
656
  startPlayRun,
544
657
  isPlayRunPackage,
545
658
  normalizePlayRunStart,
@@ -2,6 +2,13 @@
2
2
  var _typebox = require('@sinclair/typebox');
3
3
  var _value = require('@sinclair/typebox/value');
4
4
  var PLAY_AUTHORING_CONTRACT_EDITION = 10;
5
+ var EXPLICIT_FRESHNESS_STALE_AFTER_SECONDS_DESCRIPTION = [
6
+ "Edition 11 requires an explicit choice.",
7
+ "`0` starts a fresh logical call, though a matching operation receipt may recover that same operation after resume;",
8
+ "`null` allows indefinite result reuse;",
9
+ "a positive integer is the maximum result age in seconds.",
10
+ "Omitted values retain legacy behavior in older editions."
11
+ ].join(" ");
5
12
  var SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS = [
6
13
  1,
7
14
  2,
@@ -12,7 +19,8 @@ var SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS = [
12
19
  7,
13
20
  8,
14
21
  9,
15
- 10
22
+ 10,
23
+ 11
16
24
  ];
17
25
  var PLAY_AUTHORING_CONTRACT_CHANGELOG_DETAILS = [
18
26
  {
@@ -74,6 +82,12 @@ var PLAY_AUTHORING_CONTRACT_CHANGELOG_DETAILS = [
74
82
  compatibilityOwner: "Plays Runtime",
75
83
  newWritesEnd: null,
76
84
  readerRemoval: null
85
+ },
86
+ {
87
+ changed: 'Requires explicit freshness and semantic identity for supported durable calls, and gives CSV datasets source-row identity so every input occurrence is processed even when key or rowIdentity: "key" is supplied. Edition 10 retains its list-getter behavior and editions 1\u201310 retain their admitted CSV identity and completed receipts; non-CSV datasets keep explicit key deduplication.',
88
+ compatibilityOwner: "Plays Runtime",
89
+ newWritesEnd: null,
90
+ readerRemoval: null
77
91
  }
78
92
  ];
79
93
  function playToolListGetterMode(edition = PLAY_AUTHORING_CONTRACT_EDITION) {
@@ -735,7 +749,7 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
735
749
  required: false,
736
750
  resolution: "runtime-allowed",
737
751
  issueCode: "play_authoring_durable_policy_invalid",
738
- description: "`0` always executes; `null`/omitted never expires; a positive integer is a TTL in seconds.",
752
+ description: EXPLICIT_FRESHNESS_STALE_AFTER_SECONDS_DESCRIPTION,
739
753
  errorMessage: "staleAfterSeconds must be null, 0 (always execute), or a positive whole number of seconds."
740
754
  },
741
755
  "ctx.tools.execute.id": {
@@ -985,6 +999,22 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
985
999
  description: "Stable field or fields used for durable row identity.",
986
1000
  errorMessage: "ctx.dataset run key must be a non-empty field, field list, or key function."
987
1001
  },
1002
+ "ctx.dataset.run.rowIdentity": {
1003
+ schema: _typebox.Type.Union([_typebox.Type.Literal("source_row"), _typebox.Type.Literal("key")]),
1004
+ fixtures: {
1005
+ valid: "source_row",
1006
+ invalid: "dedupe",
1007
+ absent: void 0,
1008
+ unresolved: { expression: "rowIdentity" },
1009
+ edition1: "key"
1010
+ },
1011
+ referenceType: "'source_row' | 'key'",
1012
+ required: false,
1013
+ resolution: "static-when-present",
1014
+ issueCode: "play_authoring_dataset_option_invalid",
1015
+ description: "Edition 11 CSV inputs always use source-row occurrence identity, even with rowIdentity: key; key-based deduplication remains available for non-CSV inputs and editions 1\u201310.",
1016
+ errorMessage: 'ctx.dataset run rowIdentity must be "source_row" or "key".'
1017
+ },
988
1018
  "ctx.dataset.run.onRowError": {
989
1019
  schema: _typebox.Type.Union([_typebox.Type.Literal("isolate"), _typebox.Type.Literal("fail")]),
990
1020
  fixtures: {
@@ -1078,7 +1108,7 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
1078
1108
  required: false,
1079
1109
  resolution: "runtime-dynamic",
1080
1110
  issueCode: "play_authoring_durable_policy_invalid",
1081
- description: "Checkpoint freshness: null/omitted never expires, 0 always executes.",
1111
+ description: EXPLICIT_FRESHNESS_STALE_AFTER_SECONDS_DESCRIPTION,
1082
1112
  errorMessage: "staleAfterSeconds must be null, 0 (always execute), or a positive whole number of seconds."
1083
1113
  },
1084
1114
  "ctx.fetch.key": {
@@ -1111,7 +1141,7 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
1111
1141
  required: false,
1112
1142
  resolution: "runtime-dynamic",
1113
1143
  issueCode: "play_authoring_durable_policy_invalid",
1114
- description: "Fetch freshness: null/omitted never expires, 0 always executes.",
1144
+ description: EXPLICIT_FRESHNESS_STALE_AFTER_SECONDS_DESCRIPTION,
1115
1145
  errorMessage: "staleAfterSeconds must be null, 0 (always execute), or a positive whole number of seconds."
1116
1146
  },
1117
1147
  "ctx.runPlay.key": {
@@ -1356,6 +1386,38 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
1356
1386
  description: "One non-empty Customer DB SQL string; the deprecated SqlQuery object is accepted only without parameter values.",
1357
1387
  errorMessage: "ctx.customerDb.query statement must be a non-empty SQL string. Deprecated SqlQuery objects cannot contain parameter values."
1358
1388
  },
1389
+ "ctx.customerDb.query.options.id": {
1390
+ schema: _typebox.Type.String({ pattern: "\\S" }),
1391
+ fixtures: {
1392
+ valid: "customer-report-read",
1393
+ invalid: "",
1394
+ absent: void 0,
1395
+ unresolved: { expression: "operationId" },
1396
+ edition1: "query"
1397
+ },
1398
+ referenceType: "string",
1399
+ required: true,
1400
+ resolution: "runtime-dynamic",
1401
+ issueCode: "play_authoring_tool_request_invalid",
1402
+ description: "Stable operation identity for Customer DB query recovery.",
1403
+ errorMessage: "ctx.customerDb.query options.id must be a non-empty stable string."
1404
+ },
1405
+ "ctx.customerDb.query.options.staleAfterSeconds": {
1406
+ schema: _typebox.Type.Literal(0),
1407
+ fixtures: {
1408
+ valid: 0,
1409
+ invalid: 1,
1410
+ absent: void 0,
1411
+ unresolved: { expression: "ttl" },
1412
+ edition1: 0
1413
+ },
1414
+ referenceType: "number | null",
1415
+ required: false,
1416
+ resolution: "runtime-dynamic",
1417
+ issueCode: "play_authoring_durable_policy_invalid",
1418
+ description: "Customer DB queries always execute with freshness 0.",
1419
+ errorMessage: "Customer DB queries must use staleAfterSeconds: 0."
1420
+ },
1359
1421
  "ctx.customerDb.query.options.maxRows": {
1360
1422
  schema: _typebox.Type.Integer({ minimum: 1 }),
1361
1423
  fixtures: {
@@ -1598,18 +1660,18 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
1598
1660
  "export type DatasetColumnRunInput<Row, Value> = { readonly row: Row; readonly ctx: DeeplinePlayRuntimeContext; readonly index: number; readonly previousCell?: PreviousCell<Value> };",
1599
1661
  "export type DatasetColumnDefinition<Row, Value> = { readonly run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>; readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean> };",
1600
1662
  "export type ConditionalStepResolver<Row, Value, Else = null> = { readonly kind: 'conditional'; readonly when: (row: Row, index: number) => boolean | Promise<boolean>; readonly run: StepResolver<Row, Value>; readonly elseValue: Else; else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>; };",
1601
- "export type StepOptions<Row, Value = unknown> = { readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: number };",
1663
+ "export type StepOptions<Row, Value = unknown> = { readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: DurableCallStaleAfterSeconds };",
1602
1664
  "export type StepProgramOptions = { readonly continueOnProviderUnavailable?: boolean };",
1603
1665
  "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly continueOnProviderUnavailable?: boolean; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
1604
1666
  "export type StepProgramResolver<Input, Return> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<never, Return>; readonly __inputType?: (input: Input) => void };",
1605
1667
  "export type RunnableStepProgram<Input, Return> = Pick<StepProgram<Input, never, Return>, 'kind' | 'steps' | 'returnResolver' | '__inputType'>;",
1606
1668
  "export type RunnableColumnStepProgram<Return> = Pick<StepProgramResolver<unknown, Return>, 'kind' | 'steps' | 'returnResolver'>;",
1607
- "export type PlayStepProgramStep = { readonly name: string; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: number; readonly resolver: StepResolver<Record<string, unknown>, unknown> | ConditionalStepResolver<Record<string, unknown>, unknown> | StepProgramResolver<Record<string, unknown>, unknown> };",
1669
+ "export type PlayStepProgramStep = { readonly name: string; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: DurableCallStaleAfterSeconds; readonly resolver: StepResolver<Record<string, unknown>, unknown> | ConditionalStepResolver<Record<string, unknown>, unknown> | StepProgramResolver<Record<string, unknown>, unknown> };",
1608
1670
  "export type ColumnResolver<Row, Value> = StepResolver<Row, Value> | ConditionalStepResolver<Row, Value> | RunnableColumnStepProgram<Value>;",
1609
1671
  "export type StepProgramOutput<TProgram> = TProgram extends StepProgram<unknown, infer Output, unknown> ? Output : never;",
1610
1672
  "export type DatasetRowKey<InputRow extends object> = (keyof InputRow & string) | readonly (keyof InputRow & string)[] | ((row: InputRow, index: number) => string | number | readonly unknown[]);",
1611
1673
  "export type DatasetDefinitionOptions<InputRow extends object> = { key?: DatasetRowKey<InputRow> };",
1612
- `export type DatasetRunOptions<InputRow extends object> = { description?: ${cloudReferenceType("ctx.dataset.run.description")}; key?: DatasetRowKey<InputRow>; onRowError?: ${cloudReferenceType("ctx.dataset.run.onRowError")}; mode?: ${cloudReferenceType("ctx.dataset.run.mode")}; undrawnColumns?: ${cloudReferenceType("ctx.dataset.run.undrawnColumns")} };`,
1674
+ `export type DatasetRunOptions<InputRow extends object> = { description?: ${cloudReferenceType("ctx.dataset.run.description")}; key?: DatasetRowKey<InputRow>; rowIdentity?: ${cloudReferenceType("ctx.dataset.run.rowIdentity")}; onRowError?: ${cloudReferenceType("ctx.dataset.run.onRowError")}; mode?: ${cloudReferenceType("ctx.dataset.run.mode")}; undrawnColumns?: ${cloudReferenceType("ctx.dataset.run.undrawnColumns")} };`,
1613
1675
  "export type DatasetBuilder<InputRow extends object, OutputRow extends object> = {",
1614
1676
  " withColumn<Name extends string, Value>(name: Name, resolver: ColumnResolver<OutputRow, Value>): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;",
1615
1677
  " withColumn<Name extends string, Value>(name: Name, definition: DatasetColumnDefinition<OutputRow, Value> & { readonly runIf: (row: OutputRow, index: number) => boolean | Promise<boolean> }): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;",
@@ -1629,8 +1691,8 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
1629
1691
  " readonly run: { readonly id: string };",
1630
1692
  ` runSteps<TInput extends Record<string, unknown>, TOutput>(program: RunnableStepProgram<TInput, TOutput>, input: TInput, options?: { description?: ${cloudReferenceType("ctx.runSteps.options.description")} }): Promise<TOutput>;`,
1631
1693
  " tools: { execute<K extends string>(request: ToolExecutionRequest<K>): Promise<ToolExecutionOutput<K>> };",
1632
- ` customerDb: { query<TRow extends Record<string, unknown> = Record<string, unknown>>(statement: SqlQuery, options?: { maxRows?: ${cloudReferenceType("ctx.customerDb.query.options.maxRows")}; timeoutMs?: ${cloudReferenceType("ctx.customerDb.query.options.timeoutMs")} }): Promise<TRow[]> };`,
1633
- ` tool<K extends string>(key: ${cloudReferenceType("ctx.tool.key")}, toolId: K, input: ${cloudReferenceType("ctx.tool.input")}, options?: { description?: ${cloudReferenceType("ctx.tool.options.description")} }): Promise<ToolExecutionOutput<K>>;`,
1694
+ ` customerDb: { query<TRow extends Record<string, unknown> = Record<string, unknown>>(statement: SqlQuery, options?: { id?: ${cloudReferenceType("ctx.customerDb.query.options.id")}; staleAfterSeconds?: ${cloudReferenceType("ctx.customerDb.query.options.staleAfterSeconds")}; maxRows?: ${cloudReferenceType("ctx.customerDb.query.options.maxRows")}; timeoutMs?: ${cloudReferenceType("ctx.customerDb.query.options.timeoutMs")} }): Promise<TRow[]> };`,
1695
+ ` tool<K extends string>(key: ${cloudReferenceType("ctx.tool.key")}, toolId: K, input: ${cloudReferenceType("ctx.tool.input")}, options?: { description?: ${cloudReferenceType("ctx.tool.options.description")}; staleAfterSeconds?: DurableCallStaleAfterSeconds }): Promise<ToolExecutionOutput<K>>;`,
1634
1696
  " step<T>(id: string, run: () => T | Promise<T>, options?: RuntimeStepOptions): Promise<T>;",
1635
1697
  " fetch(key: string, url: string | URL, init?: RequestInit & { headers?: HeadersInit & { 'Idempotency-Key'?: string; 'X-Idempotency-Key'?: string }; auth?: SecretAuthInput }, options?: FetchOptions): Promise<PlayFetchResponse>;",
1636
1698
  " secrets: { get(name: string): SecretPromise; bearer(secret: string | SecretPromise | SecretHandle): SecretAuth; header(header: string, secret: string | SecretPromise | SecretHandle): SecretAuth };",
@@ -3,7 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkWMS5U6YBjs = require('./chunk-WMS5U6YB.js');
6
+ var _chunkCS6RAIVYjs = require('./chunk-CS6RAIVY.js');
7
+
7
8
 
8
9
 
9
10
  var _chunk7P5AA3SNjs = require('./chunk-7P5AA3SN.js');
@@ -225,8 +226,8 @@ var BROWSER_OPEN_COOLDOWN_MS = 3e4;
225
226
  var SAME_URL_BROWSER_OPEN_COOLDOWN_MS = 5 * 6e4;
226
227
  var defaultBrowserCommandRunner = childProcess;
227
228
  function getAuthedHttpClient() {
228
- const config = _chunkWMS5U6YBjs.resolveConfig.call(void 0, );
229
- return { config, http: new (0, _chunkWMS5U6YBjs.HttpClient)(config) };
229
+ const config = _chunkCS6RAIVYjs.resolveConfig.call(void 0, );
230
+ return { config, http: new (0, _chunkCS6RAIVYjs.HttpClient)(config) };
230
231
  }
231
232
  function stableOsUserId() {
232
233
  try {
@@ -566,7 +567,7 @@ function collectLocalEnvInfo() {
566
567
  os: `${process.platform} ${process.arch}`,
567
568
  node_version: process.version,
568
569
  home_dir: homeDir,
569
- agent_runtime: _chunkWMS5U6YBjs.detectAgentRuntime.call(void 0, )
570
+ agent_runtime: _chunkCS6RAIVYjs.detectAgentRuntime.call(void 0, )
570
571
  };
571
572
  const env = process.env;
572
573
  const optional = {
@@ -813,9 +814,9 @@ function markdownTableFromRows(rows, preferredColumns = []) {
813
814
  }
814
815
  function withAgentCommandContext(value) {
815
816
  const valueRecord = value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
816
- return _chunkWMS5U6YBjs.detectAgentRuntime.call(void 0, ) !== "unknown" && valueRecord && !Object.prototype.hasOwnProperty.call(valueRecord, "command_context") ? {
817
+ return _chunkCS6RAIVYjs.detectAgentRuntime.call(void 0, ) !== "unknown" && valueRecord && !Object.prototype.hasOwnProperty.call(valueRecord, "command_context") ? {
817
818
  ...valueRecord,
818
- command_context: _chunkWMS5U6YBjs.resolveCliCommandContext.call(void 0, )
819
+ command_context: _chunkCS6RAIVYjs.resolveCliCommandContext.call(void 0, )
819
820
  } : value;
820
821
  }
821
822
  function printJson(value, fields) {
@@ -828,8 +829,30 @@ function printCompactJson(value) {
828
829
  process.stdout.write(`${JSON.stringify(withAgentCommandContext(value))}
829
830
  `);
830
831
  }
832
+ function cliToolExecutionFailure(error) {
833
+ const failure = _chunk7P5AA3SNjs.serializeToolExecutionFailure.call(void 0, error);
834
+ if (!failure) return null;
835
+ const { publicDetails: _publicDetails, ...facts } = failure;
836
+ return facts;
837
+ }
838
+ function formatToolExecutionErrorDiagnostic(error) {
839
+ const failure = cliToolExecutionFailure(error);
840
+ if (!failure) return null;
841
+ const lines = [
842
+ `Tool: ${failure.toolId}${failure.provider ? `; provider: ${failure.provider}` : ""}${failure.operation ? `; operation: ${failure.operation}` : ""}.`,
843
+ `Failure: ${failure.origin} / ${failure.category}. Same-call retry: ${failure.retryable ? `safe${failure.retryAfterMs === null ? "" : ` after ${failure.retryAfterMs}ms`}` : "unsafe"}.`
844
+ ];
845
+ if (failure.networkKind || failure.networkScope) {
846
+ lines.push(
847
+ `Network: ${_nullishCoalesce(failure.networkKind, () => ( "unknown"))}${failure.networkScope ? ` (${failure.networkScope})` : ""}.`
848
+ );
849
+ }
850
+ if (failure.requestId) lines.push(`Request: ${failure.requestId}.`);
851
+ return lines.join("\n");
852
+ }
831
853
  function errorToJsonPayload(error) {
832
854
  const message = error instanceof Error ? error.message : String(error);
855
+ const toolFailure = cliToolExecutionFailure(error);
833
856
  const maybeRecord = error && typeof error === "object" ? error : null;
834
857
  const code = typeof _optionalChain([maybeRecord, 'optionalAccess', _22 => _22.code]) === "string" ? maybeRecord.code : error instanceof SyntaxError ? "INVALID_JSON" : "CLI_ERROR";
835
858
  const details = {};
@@ -868,6 +891,7 @@ function errorToJsonPayload(error) {
868
891
  error: {
869
892
  message,
870
893
  code,
894
+ ...toolFailure ? { tool_error: toolFailure } : {},
871
895
  ...Object.keys(details).length > 0 ? { details } : {}
872
896
  }
873
897
  };
@@ -975,4 +999,5 @@ function printCommandEnvelope(envelope, options = {}) {
975
999
 
976
1000
 
977
1001
 
978
- exports.parseJsonFields = parseJsonFields; exports.jsonFieldArgs = jsonFieldArgs; exports.describeArgs = describeArgs; exports.getAuthedHttpClient = getAuthedHttpClient; exports.openInBrowser = openInBrowser; exports.sleep = sleep; exports.collectLocalEnvInfo = collectLocalEnvInfo; exports.readCsvRows = readCsvRows; exports.csvStringFromRows = csvStringFromRows; exports.csvSafeJsonString = csvSafeJsonString; exports.recordRows = recordRows; exports.dataExportRows = dataExportRows; exports.dataExportColumns = dataExportColumns; exports.dataExportCsvString = dataExportCsvString; exports.markdownTableFromRows = markdownTableFromRows; exports.printJson = printJson; exports.printCompactJson = printCompactJson; exports.errorToJsonPayload = errorToJsonPayload; exports.formatProviderConcurrencyDiagnostic = formatProviderConcurrencyDiagnostic; exports.printJsonError = printJsonError; exports.shouldEmitJson = shouldEmitJson; exports.argsWantJson = argsWantJson; exports.createTimestampedName = createTimestampedName; exports.clip = clip; exports.renderCommandEnvelopeText = renderCommandEnvelopeText; exports.printCommandEnvelope = printCommandEnvelope;
1002
+
1003
+ exports.parseJsonFields = parseJsonFields; exports.jsonFieldArgs = jsonFieldArgs; exports.describeArgs = describeArgs; exports.getAuthedHttpClient = getAuthedHttpClient; exports.openInBrowser = openInBrowser; exports.sleep = sleep; exports.collectLocalEnvInfo = collectLocalEnvInfo; exports.readCsvRows = readCsvRows; exports.csvStringFromRows = csvStringFromRows; exports.csvSafeJsonString = csvSafeJsonString; exports.recordRows = recordRows; exports.dataExportRows = dataExportRows; exports.dataExportColumns = dataExportColumns; exports.dataExportCsvString = dataExportCsvString; exports.markdownTableFromRows = markdownTableFromRows; exports.printJson = printJson; exports.printCompactJson = printCompactJson; exports.formatToolExecutionErrorDiagnostic = formatToolExecutionErrorDiagnostic; exports.errorToJsonPayload = errorToJsonPayload; exports.formatProviderConcurrencyDiagnostic = formatProviderConcurrencyDiagnostic; exports.printJsonError = printJsonError; exports.shouldEmitJson = shouldEmitJson; exports.argsWantJson = argsWantJson; exports.createTimestampedName = createTimestampedName; exports.clip = clip; exports.renderCommandEnvelopeText = renderCommandEnvelopeText; exports.printCommandEnvelope = printCommandEnvelope;