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
@@ -1,6 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
+ var _chunkXDVT3GOMjs = require('./chunk-XDVT3GOM.js');
5
+
6
+
7
+
4
8
  var _chunkXNYIZMNQjs = require('./chunk-XNYIZMNQ.js');
5
9
 
6
10
 
@@ -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,18 +112,122 @@ 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 _chunk7P5AA3SNjs.DeeplineError) || ![404, 405].includes(_nullishCoalesce(error.statusCode, () => ( 0))))
122
+ throw error;
123
+ }
124
+ if (capability && !["caller-intent-v1", "unsupported"].includes(
125
+ _nullishCoalesce(capability.admissionContract, () => ( ""))
126
+ )) {
127
+ throw new (0, _chunk7P5AA3SNjs.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 = _optionalChain([capability, 'optionalAccess', _5 => _5.admissionContract]) === "caller-intent-v1";
135
+ if (supportsCallerIntent && (!_optionalChain([capability, 'optionalAccess', _6 => _6.orgId]) || request.admissionOrgId && request.admissionOrgId !== capability.orgId)) {
136
+ throw new (0, _chunk7P5AA3SNjs.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 (0, _chunk7P5AA3SNjs.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 && _optionalChain([capability, 'optionalAccess', _7 => _7.strictTotalBudget]) !== "fail-closed-v1") {
150
+ throw new (0, _chunk7P5AA3SNjs.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 ? _nullishCoalesce(request.workflowId, () => ( _chunkXDVT3GOMjs.buildCallerPlayWorkflowId.call(void 0, _nullishCoalesce(request.name, () => ( "play")), wireBody))) : void 0;
165
+ const submittedBody = workflowId ? { workflowId, ...wireBody } : wireBody;
166
+ if (workflowId && !_chunkXDVT3GOMjs.callerPlayWorkflowIdMatchesRequest.call(void 0, workflowId, submittedBody)) {
167
+ throw new (0, _chunk7P5AA3SNjs.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 || !_optionalChain([capability, 'optionalAccess', _8 => _8.orgId])) {
175
+ throw new (0, _chunk7P5AA3SNjs.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 _chunk7P5AA3SNjs.DeeplineError && ["NETWORK_TIMEOUT", "NETWORK_ERROR", "FETCH_FAILED"].includes(
205
+ _nullishCoalesce(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 (0, _chunk7P5AA3SNjs.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 _chunk7P5AA3SNjs.DeeplineError ? error.statusCode : void 0,
211
+ error instanceof _chunk7P5AA3SNjs.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) {
118
229
  return Boolean(
119
- value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof _optionalChain([value, 'access', _5 => _5.run, 'optionalAccess', _6 => _6.id]) === "string"
230
+ value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof _optionalChain([value, 'access', _9 => _9.run, 'optionalAccess', _10 => _10.id]) === "string"
120
231
  );
121
232
  }
122
233
  function normalizePlayRunStart(raw) {
@@ -156,7 +267,7 @@ function schemaMetadata(schema, key) {
156
267
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
157
268
  }
158
269
  function stringMetadata(metadata, key) {
159
- const value = _optionalChain([metadata, 'optionalAccess', _7 => _7[key]]);
270
+ const value = _optionalChain([metadata, 'optionalAccess', _11 => _11[key]]);
160
271
  return typeof value === "string" && value.trim() ? value.trim() : null;
161
272
  }
162
273
  function inputFieldFromCsvArg(csvArg) {
@@ -164,7 +275,7 @@ function inputFieldFromCsvArg(csvArg) {
164
275
  const match = /^\(?\s*input\.([A-Za-z_$][\w$]*)\s*\)?(?:\s*\?\?[\s\S]+)?$/.exec(
165
276
  csvArg.trim()
166
277
  );
167
- return _nullishCoalesce(_optionalChain([match, 'optionalAccess', _8 => _8[1]]), () => ( null));
278
+ return _nullishCoalesce(_optionalChain([match, 'optionalAccess', _12 => _12[1]]), () => ( null));
168
279
  }
169
280
  function fileInputBindingsFromPlaySchema(inputSchema) {
170
281
  const csvInput = schemaMetadata(inputSchema, "csvInput");
@@ -295,7 +406,7 @@ async function uploadStagedFileToPresignedUrl(input) {
295
406
  return;
296
407
  }
297
408
  const text = await response.text().catch(() => "");
298
- const egressDenied = response.status === 403 && _optionalChain([response, 'access', _9 => _9.headers, 'access', _10 => _10.get, 'call', _11 => _11("x-deny-reason"), 'optionalAccess', _12 => _12.trim, 'call', _13 => _13(), 'access', _14 => _14.toLowerCase, 'call', _15 => _15()]) === "host_not_allowed";
409
+ const egressDenied = response.status === 403 && _optionalChain([response, 'access', _13 => _13.headers, 'access', _14 => _14.get, 'call', _15 => _15("x-deny-reason"), 'optionalAccess', _16 => _16.trim, 'call', _17 => _17(), 'access', _18 => _18.toLowerCase, 'call', _19 => _19()]) === "host_not_allowed";
299
410
  lastError = new (0, _chunk7P5AA3SNjs.DeeplineError)(
300
411
  `Direct storage upload of ${input.logicalPath} failed: ${response.status} ${text.slice(0, 200)}`,
301
412
  response.status,
@@ -470,7 +581,7 @@ async function stageFileInputs(input) {
470
581
  if (localFiles.length === 0) {
471
582
  return { inputFile: null, packagedFiles: [] };
472
583
  }
473
- _optionalChain([input, 'access', _16 => _16.onStaging, 'optionalCall', _17 => _17(localFiles.length)]);
584
+ _optionalChain([input, 'access', _20 => _20.onStaging, 'optionalCall', _21 => _21(localFiles.length)]);
474
585
  const uploads = await Promise.all(
475
586
  localFiles.map(
476
587
  async ({ file }) => createStagedFileUpload(file.logicalPath, await file.read(), input.codec)
@@ -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 },
@@ -558,4 +670,5 @@ function createSessionPlayRunHttp(fetchImpl = (...args) => fetch(...args)) {
558
670
 
559
671
 
560
672
 
561
- exports.isTerminalPlayRunLifecycleStatus = isTerminalPlayRunLifecycleStatus; exports.decodePlayRunPublicStatus = decodePlayRunPublicStatus; exports.PLAY_RUN_START_PATH = PLAY_RUN_START_PATH; exports.PLAY_RUN_START_STREAM_PATH = PLAY_RUN_START_STREAM_PATH; exports.PLAY_FILES_STAGE_PATH = PLAY_FILES_STAGE_PATH; exports.PLAY_FILES_STAGE_MINT_PATH = PLAY_FILES_STAGE_MINT_PATH; exports.buildPlayRunStartBody = buildPlayRunStartBody; exports.startPlayRun = startPlayRun; exports.isPlayRunPackage = isPlayRunPackage; exports.normalizePlayRunStart = normalizePlayRunStart; exports.buildNamedPlayRunRequest = buildNamedPlayRunRequest; exports.CSV_DATA_INPUT_KEY = CSV_DATA_INPUT_KEY; exports.fileInputBindingsFromPlaySchema = fileInputBindingsFromPlaySchema; exports.fileInputBindingsFromStaticPipeline = fileInputBindingsFromStaticPipeline; exports.playRunFileInputBindings = playRunFileInputBindings; exports.getDottedInputValue = getDottedInputValue; exports.setDottedInputValue = setDottedInputValue; exports.webStagedFileCodec = webStagedFileCodec; exports.stagedFileContentType = stagedFileContentType; exports.createStagedFileUpload = createStagedFileUpload; exports.STAGE_LEGACY_MULTIPART_MAX_BYTES = STAGE_LEGACY_MULTIPART_MAX_BYTES; exports.mintStagedPlayFileUploads = mintStagedPlayFileUploads; exports.stagePlayFiles = stagePlayFiles; exports.stageFileInputs = stageFileInputs; exports.createSessionPlayRunHttp = createSessionPlayRunHttp;
673
+
674
+ exports.isTerminalPlayRunLifecycleStatus = isTerminalPlayRunLifecycleStatus; exports.decodePlayRunPublicStatus = decodePlayRunPublicStatus; exports.PLAY_RUN_START_PATH = PLAY_RUN_START_PATH; exports.PLAY_RUN_START_STREAM_PATH = PLAY_RUN_START_STREAM_PATH; exports.PLAY_FILES_STAGE_PATH = PLAY_FILES_STAGE_PATH; exports.PLAY_FILES_STAGE_MINT_PATH = PLAY_FILES_STAGE_MINT_PATH; exports.buildPlayRunStartBody = buildPlayRunStartBody; exports.preparePlayRunAdmission = preparePlayRunAdmission; exports.startPlayRun = startPlayRun; exports.isPlayRunPackage = isPlayRunPackage; exports.normalizePlayRunStart = normalizePlayRunStart; exports.buildNamedPlayRunRequest = buildNamedPlayRunRequest; exports.CSV_DATA_INPUT_KEY = CSV_DATA_INPUT_KEY; exports.fileInputBindingsFromPlaySchema = fileInputBindingsFromPlaySchema; exports.fileInputBindingsFromStaticPipeline = fileInputBindingsFromStaticPipeline; exports.playRunFileInputBindings = playRunFileInputBindings; exports.getDottedInputValue = getDottedInputValue; exports.setDottedInputValue = setDottedInputValue; exports.webStagedFileCodec = webStagedFileCodec; exports.stagedFileContentType = stagedFileContentType; exports.createStagedFileUpload = createStagedFileUpload; exports.STAGE_LEGACY_MULTIPART_MAX_BYTES = STAGE_LEGACY_MULTIPART_MAX_BYTES; exports.mintStagedPlayFileUploads = mintStagedPlayFileUploads; exports.stagePlayFiles = stagePlayFiles; exports.stageFileInputs = stageFileInputs; exports.createSessionPlayRunHttp = createSessionPlayRunHttp;
@@ -693,7 +693,12 @@ Authoring rules:
693
693
  Dataset handles are async: await rows.count(), rows.first(),
694
694
  rows.peek(n), rows.materialize(n), or for await. Array methods on a
695
695
  handle fail [[cli:plays check]][[mcp:deepline_check_play]].
696
- Tool calls: rowCtx.tools.execute({ id, tool, input, description }). Read
696
+ Tool calls: rowCtx.tools.execute({ id, tool, input, description,
697
+ staleAfterSeconds }). In authoring edition 11, choose freshness explicitly:
698
+ 0 for fresh logical work, a positive integer for the maximum reusable
699
+ result age in seconds, or null for indefinite result reuse. A matching
700
+ completed operation receipt can still recover that operation after resume.
701
+ Read
697
702
  results through the getters [[cli:describe]][[mcp:deepline_describe_tool]] lists:
698
703
  result.extractedValues.<name>.get() and
699
704
  result.extractedLists.<name>.get(). A field with no getter is under
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  npmSupportsAllowScripts,
3
3
  readNpmVersion
4
- } from "./chunk-MU6M3URX.mjs";
4
+ } from "./chunk-BP33SIZF.mjs";
5
5
  import {
6
6
  resolveShellSpawn,
7
7
  runSkillsCommand
8
- } from "./chunk-ZTACINO5.mjs";
8
+ } from "./chunk-X63FDZJZ.mjs";
9
9
  import {
10
10
  printCommandEnvelope
11
- } from "./chunk-2G7DXFHI.mjs";
11
+ } from "./chunk-NR3DFKNF.mjs";
12
12
  import {
13
13
  autoDetectBaseUrl
14
- } from "./chunk-2GAHHSLB.mjs";
14
+ } from "./chunk-FJGW5GXU.mjs";
15
15
 
16
16
  // src/cli/commands/update.ts
17
17
  import { spawn, spawnSync } from "child_process";
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkCVLM3WMJjs = require('./chunk-CVLM3WMJ.js');
3
+ var _chunkE23BQ5SCjs = require('./chunk-E23BQ5SC.js');
4
4
 
5
5
 
6
6
 
7
- var _chunkRV6ALZIXjs = require('./chunk-RV6ALZIX.js');
7
+ var _chunkKGNTKMRGjs = require('./chunk-KGNTKMRG.js');
8
8
 
9
9
 
10
10
 
11
- var _chunkWMS5U6YBjs = require('./chunk-WMS5U6YB.js');
11
+ var _chunkCS6RAIVYjs = require('./chunk-CS6RAIVY.js');
12
12
 
13
13
  // src/cli/commands/search.ts
14
14
  var _commander = require('commander');
@@ -18,7 +18,7 @@ var _fs = require('fs');
18
18
  var _path = require('path');
19
19
  var SEARCH_REF_TTL_MS = 15 * 6e4;
20
20
  function lastSearchPath() {
21
- return _path.join.call(void 0, _chunkWMS5U6YBjs.sdkCliStateDirPath.call(void 0, _chunkWMS5U6YBjs.resolveConfig.call(void 0, ).baseUrl), "last-search.json");
21
+ return _path.join.call(void 0, _chunkCS6RAIVYjs.sdkCliStateDirPath.call(void 0, _chunkCS6RAIVYjs.resolveConfig.call(void 0, ).baseUrl), "last-search.json");
22
22
  }
23
23
  function rememberSearchRef(searchRef) {
24
24
  try {
@@ -259,7 +259,7 @@ function searchRow(item) {
259
259
  }
260
260
  function renderSearchResults(result) {
261
261
  if (result.results.length === 0)
262
- return _chunkRV6ALZIXjs.renderCommandEnvelopeText.call(void 0, result);
262
+ return _chunkKGNTKMRGjs.renderCommandEnvelopeText.call(void 0, result);
263
263
  const rows = result.results.map(searchRow);
264
264
  const kinds = new Set(rows.map((row) => row.kind));
265
265
  const onlyTools = kinds.size === 1 && kinds.has("tool");
@@ -283,7 +283,7 @@ function renderSearchResults(result) {
283
283
  actions: _optionalChain([render, 'optionalAccess', _11 => _11.actions])
284
284
  };
285
285
  const followUps = _optionalChain([remaining, 'access', _12 => _12.sections, 'optionalAccess', _13 => _13.length]) || _optionalChain([remaining, 'access', _14 => _14.actions, 'optionalAccess', _15 => _15.length]) ? `
286
- ${_chunkRV6ALZIXjs.renderCommandEnvelopeText.call(void 0, { render: remaining })}` : "";
286
+ ${_chunkKGNTKMRGjs.renderCommandEnvelopeText.call(void 0, { render: remaining })}` : "";
287
287
  const notes = rows.flatMap(
288
288
  (row) => row.notes.map((note) => ` ${row.id}: ${note}`)
289
289
  );
@@ -360,7 +360,7 @@ async function runSearch(queryInput, options, types, exclude = []) {
360
360
  console.error(USAGE);
361
361
  return 1;
362
362
  }
363
- const { search_ref: searchRef, ...result } = await new (0, _chunkCVLM3WMJjs.DeeplineClient)().search({
363
+ const { search_ref: searchRef, ...result } = await new (0, _chunkE23BQ5SCjs.DeeplineClient)().search({
364
364
  query,
365
365
  types,
366
366
  exclude,
@@ -374,7 +374,7 @@ async function runSearch(queryInput, options, types, exclude = []) {
374
374
  });
375
375
  if (searchRef) rememberSearchRef(searchRef);
376
376
  pointAtDescribe(result);
377
- _chunkRV6ALZIXjs.printCommandEnvelope.call(void 0, result, {
377
+ _chunkKGNTKMRGjs.printCommandEnvelope.call(void 0, result, {
378
378
  json: options.json === true,
379
379
  text: renderSearchResults(result)
380
380
  });
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GAMFK2ZP.mjs";
4
4
  import {
5
5
  printCommandEnvelope
6
- } from "./chunk-2G7DXFHI.mjs";
6
+ } from "./chunk-NR3DFKNF.mjs";
7
7
  import {
8
8
  DEFAULT_SKILL_AGENTS,
9
9
  KNOWN_SKILL_AGENTS,
@@ -22,10 +22,13 @@ import {
22
22
  sdkCliStateDirPath,
23
23
  skillsAgentPathSegment,
24
24
  writeSdkSkillsLocalVersion
25
- } from "./chunk-2GAHHSLB.mjs";
25
+ } from "./chunk-FJGW5GXU.mjs";
26
26
  import {
27
27
  DeeplineError
28
28
  } from "./chunk-NXGCO4JB.mjs";
29
+ import {
30
+ SDK_RELEASE
31
+ } from "./chunk-TJI2EN6K.mjs";
29
32
 
30
33
  // src/cli/commands/skills.ts
31
34
  import { spawn as spawn2 } from "child_process";
@@ -317,6 +320,10 @@ async function checkSdkCompatibility(baseUrl, options = {}) {
317
320
  }
318
321
  if (options.skillsVersion !== void 0) {
319
322
  url.searchParams.set("skills_version", options.skillsVersion ?? "");
323
+ url.searchParams.set(
324
+ "skills_cli_capability",
325
+ String(SDK_RELEASE.packageCapabilities.skillsGuidance)
326
+ );
320
327
  }
321
328
  if (options.catalog) {
322
329
  url.searchParams.set("catalog_tool_id", options.catalog.toolId);
@@ -1417,8 +1424,10 @@ async function fetchSkillsUpdate(baseUrl, localVersion) {
1417
1424
  method: "POST",
1418
1425
  headers: { "Content-Type": "application/json" },
1419
1426
  body: JSON.stringify({
1427
+ sdk_cli: { version: SDK_VERSION },
1420
1428
  skills: {
1421
- version: localVersion
1429
+ version: localVersion,
1430
+ capability: SDK_RELEASE.packageCapabilities.skillsGuidance
1422
1431
  }
1423
1432
  }),
1424
1433
  signal: controller.signal
@@ -2368,6 +2377,7 @@ export {
2368
2377
  enforceSdkCompatibilityResponse,
2369
2378
  resolveShellSpawn,
2370
2379
  isFailureReportingDisabled,
2380
+ redactFailureText,
2371
2381
  sanitizeCommand,
2372
2382
  failureReportHeaders,
2373
2383
  resolveSdkCliFailureExitCode,
@@ -0,0 +1,310 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ../plays/row-identity.ts
2
+ var POSTGRES_IDENTIFIER_MAX_LENGTH = 63;
3
+ var MAP_KEY_NAMESPACE_MAX_LENGTH = POSTGRES_IDENTIFIER_MAX_LENGTH;
4
+ var SHA256_INITIAL_HASH = [
5
+ 1779033703,
6
+ 3144134277,
7
+ 1013904242,
8
+ 2773480762,
9
+ 1359893119,
10
+ 2600822924,
11
+ 528734635,
12
+ 1541459225
13
+ ];
14
+ var SHA256_ROUND_CONSTANTS = [
15
+ 1116352408,
16
+ 1899447441,
17
+ 3049323471,
18
+ 3921009573,
19
+ 961987163,
20
+ 1508970993,
21
+ 2453635748,
22
+ 2870763221,
23
+ 3624381080,
24
+ 310598401,
25
+ 607225278,
26
+ 1426881987,
27
+ 1925078388,
28
+ 2162078206,
29
+ 2614888103,
30
+ 3248222580,
31
+ 3835390401,
32
+ 4022224774,
33
+ 264347078,
34
+ 604807628,
35
+ 770255983,
36
+ 1249150122,
37
+ 1555081692,
38
+ 1996064986,
39
+ 2554220882,
40
+ 2821834349,
41
+ 2952996808,
42
+ 3210313671,
43
+ 3336571891,
44
+ 3584528711,
45
+ 113926993,
46
+ 338241895,
47
+ 666307205,
48
+ 773529912,
49
+ 1294757372,
50
+ 1396182291,
51
+ 1695183700,
52
+ 1986661051,
53
+ 2177026350,
54
+ 2456956037,
55
+ 2730485921,
56
+ 2820302411,
57
+ 3259730800,
58
+ 3345764771,
59
+ 3516065817,
60
+ 3600352804,
61
+ 4094571909,
62
+ 275423344,
63
+ 430227734,
64
+ 506948616,
65
+ 659060556,
66
+ 883997877,
67
+ 958139571,
68
+ 1322822218,
69
+ 1537002063,
70
+ 1747873779,
71
+ 1955562222,
72
+ 2024104815,
73
+ 2227730452,
74
+ 2361852424,
75
+ 2428436474,
76
+ 2756734187,
77
+ 3204031479,
78
+ 3329325298
79
+ ];
80
+ function stableValue(value) {
81
+ if (Array.isArray(value)) {
82
+ return value.map((entry) => stableValue(entry));
83
+ }
84
+ if (value && typeof value === "object") {
85
+ return Object.fromEntries(
86
+ Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, stableValue(entry)])
87
+ );
88
+ }
89
+ return value;
90
+ }
91
+ function stableStringify(value) {
92
+ return JSON.stringify(stableValue(value));
93
+ }
94
+ function rightRotate32(value, bits) {
95
+ return value >>> bits | value << 32 - bits;
96
+ }
97
+ function sha256Hex(input) {
98
+ const bytes = Array.from(new TextEncoder().encode(input));
99
+ const bitLength = bytes.length * 8;
100
+ bytes.push(128);
101
+ while (bytes.length % 64 !== 56) {
102
+ bytes.push(0);
103
+ }
104
+ const highBits = Math.floor(bitLength / 4294967296);
105
+ const lowBits = bitLength >>> 0;
106
+ bytes.push(
107
+ highBits >>> 24 & 255,
108
+ highBits >>> 16 & 255,
109
+ highBits >>> 8 & 255,
110
+ highBits & 255,
111
+ lowBits >>> 24 & 255,
112
+ lowBits >>> 16 & 255,
113
+ lowBits >>> 8 & 255,
114
+ lowBits & 255
115
+ );
116
+ const hash = [...SHA256_INITIAL_HASH];
117
+ const words = new Array(64).fill(0);
118
+ for (let offset = 0; offset < bytes.length; offset += 64) {
119
+ for (let index = 0; index < 16; index += 1) {
120
+ const wordOffset = offset + index * 4;
121
+ words[index] = (_nullishCoalesce(bytes[wordOffset], () => ( 0))) << 24 | (_nullishCoalesce(bytes[wordOffset + 1], () => ( 0))) << 16 | (_nullishCoalesce(bytes[wordOffset + 2], () => ( 0))) << 8 | (_nullishCoalesce(bytes[wordOffset + 3], () => ( 0)));
122
+ }
123
+ for (let index = 16; index < 64; index += 1) {
124
+ const s0 = rightRotate32(words[index - 15], 7) ^ rightRotate32(words[index - 15], 18) ^ words[index - 15] >>> 3;
125
+ const s1 = rightRotate32(words[index - 2], 17) ^ rightRotate32(words[index - 2], 19) ^ words[index - 2] >>> 10;
126
+ words[index] = words[index - 16] + s0 + words[index - 7] + s1 >>> 0;
127
+ }
128
+ let [a, b, c, d, e, f, g, h] = hash;
129
+ for (let index = 0; index < 64; index += 1) {
130
+ const s1 = rightRotate32(e, 6) ^ rightRotate32(e, 11) ^ rightRotate32(e, 25);
131
+ const ch = e & f ^ ~e & g;
132
+ const temp1 = h + s1 + ch + SHA256_ROUND_CONSTANTS[index] + words[index] >>> 0;
133
+ const s0 = rightRotate32(a, 2) ^ rightRotate32(a, 13) ^ rightRotate32(a, 22);
134
+ const maj = a & b ^ a & c ^ b & c;
135
+ const temp2 = s0 + maj >>> 0;
136
+ h = g;
137
+ g = f;
138
+ f = e;
139
+ e = d + temp1 >>> 0;
140
+ d = c;
141
+ c = b;
142
+ b = a;
143
+ a = temp1 + temp2 >>> 0;
144
+ }
145
+ hash[0] = hash[0] + a >>> 0;
146
+ hash[1] = hash[1] + b >>> 0;
147
+ hash[2] = hash[2] + c >>> 0;
148
+ hash[3] = hash[3] + d >>> 0;
149
+ hash[4] = hash[4] + e >>> 0;
150
+ hash[5] = hash[5] + f >>> 0;
151
+ hash[6] = hash[6] + g >>> 0;
152
+ hash[7] = hash[7] + h >>> 0;
153
+ }
154
+ return hash.map((word) => word.toString(16).padStart(8, "0")).join("");
155
+ }
156
+ function sanitizeIdentifierPart(value) {
157
+ return value.trim().replace(/[^a-z0-9]+/gi, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toLowerCase();
158
+ }
159
+ function validateIdentifierPart(rawValue, label, maxLength) {
160
+ const sanitized = sanitizeIdentifierPart(rawValue);
161
+ if (!sanitized) {
162
+ throw new Error(`${label} must contain a letter or number.`);
163
+ }
164
+ if (sanitized.length > maxLength) {
165
+ throw new Error(
166
+ `${label} is too long after normalization (${sanitized.length}/${maxLength}): "${sanitized}".`
167
+ );
168
+ }
169
+ return sanitized;
170
+ }
171
+ function normalizeTableNamespace(value) {
172
+ return validateIdentifierPart(
173
+ value,
174
+ "ctx.dataset() key",
175
+ MAP_KEY_NAMESPACE_MAX_LENGTH
176
+ );
177
+ }
178
+
179
+ // ../play-runtime/run-identity.ts
180
+ function sanitizePlayNameForWorkflowSegment(value) {
181
+ return value.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
182
+ }
183
+ function buildPlayWorkflowFamilyKey(playName) {
184
+ const normalized = playName.split("/").map(sanitizePlayNameForWorkflowSegment).filter(Boolean).join("/");
185
+ return normalized || "play";
186
+ }
187
+ function buildPlayWorkflowRunSuffix(now) {
188
+ const pad = (value, size = 2) => String(value).padStart(size, "0");
189
+ return [
190
+ now.getUTCFullYear(),
191
+ pad(now.getUTCMonth() + 1),
192
+ pad(now.getUTCDate()),
193
+ "t",
194
+ pad(now.getUTCHours()),
195
+ pad(now.getUTCMinutes()),
196
+ pad(now.getUTCSeconds()),
197
+ "-",
198
+ pad(now.getUTCMilliseconds(), 3)
199
+ ].join("");
200
+ }
201
+ var CANONICAL_PLAY_RUN_TIMESTAMP_RE = /\/run\/(\d{4})(\d{2})(\d{2})t(\d{2})(\d{2})(\d{2})-(\d{3})(?:-|$)/;
202
+ function canonicalPlayRunStartedAtMs(runId) {
203
+ const match = CANONICAL_PLAY_RUN_TIMESTAMP_RE.exec(runId);
204
+ if (!match) return null;
205
+ const [, year, month, day, hour, minute, second, millisecond] = match;
206
+ const value = Date.UTC(
207
+ Number(year),
208
+ Number(month) - 1,
209
+ Number(day),
210
+ Number(hour),
211
+ Number(minute),
212
+ Number(second),
213
+ Number(millisecond)
214
+ );
215
+ if (!Number.isFinite(value)) return null;
216
+ const roundTrip = new Date(value);
217
+ return roundTrip.getUTCFullYear() === Number(year) && roundTrip.getUTCMonth() === Number(month) - 1 && roundTrip.getUTCDate() === Number(day) && roundTrip.getUTCHours() === Number(hour) && roundTrip.getUTCMinutes() === Number(minute) && roundTrip.getUTCSeconds() === Number(second) && roundTrip.getUTCMilliseconds() === Number(millisecond) ? value : null;
218
+ }
219
+ function buildRunEntropySuffix() {
220
+ const randomUuid = _optionalChain([globalThis, 'access', _ => _.crypto, 'optionalAccess', _2 => _2.randomUUID, 'optionalCall', _3 => _3()]);
221
+ if (randomUuid) {
222
+ return randomUuid.replace(/-/g, "").slice(0, 8);
223
+ }
224
+ return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
225
+ }
226
+ function buildPlayWorkflowId(playName, now, options = {}) {
227
+ const familyKey = buildPlayWorkflowFamilyKey(playName);
228
+ const timestamp = _nullishCoalesce(now, () => ( /* @__PURE__ */ new Date()));
229
+ const unique = _nullishCoalesce(options.unique, () => ( now === void 0));
230
+ const entropy = unique ? `-${buildRunEntropySuffix()}` : "";
231
+ return `play/${familyKey}/run/${buildPlayWorkflowRunSuffix(timestamp)}${entropy}`;
232
+ }
233
+ function buildCallerPlayWorkflowId(playName, request, now) {
234
+ const { workflowId: _ignored, ...intent } = request;
235
+ const wireIntent = JSON.parse(JSON.stringify(intent));
236
+ return `${buildPlayWorkflowId(playName, now, { unique: true })}-caller-${sha256Hex(stableStringify(wireIntent))}`;
237
+ }
238
+ function callerPlayWorkflowIdMatchesRequest(workflowId, request) {
239
+ const match = /^play\/[a-z0-9/-]+\/run\/\d{8}t\d{6}-\d{3}-[a-z0-9]{8}-caller-([a-f0-9]{64})$/.exec(
240
+ workflowId
241
+ );
242
+ if (!match || canonicalPlayRunStartedAtMs(workflowId) === null) return false;
243
+ const { workflowId: _ignored, ...intent } = request;
244
+ return match[1] === sha256Hex(stableStringify(JSON.parse(JSON.stringify(intent))));
245
+ }
246
+ function buildPlayRunIdentity(playName, now, options = {}) {
247
+ const workflowId = buildPlayWorkflowId(playName, now, {
248
+ unique: _nullishCoalesce(options.unique, () => ( now === void 0))
249
+ });
250
+ return {
251
+ workflowId,
252
+ runId: workflowId,
253
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(playName)
254
+ };
255
+ }
256
+ function buildAsyncPlayRunIdentity(input) {
257
+ const digest = sha256Hex(
258
+ `${input.parentRunId}\0${input.invocationKey}`
259
+ ).slice(0, 20);
260
+ const parentStartedAt = _nullishCoalesce(canonicalPlayRunStartedAtMs(input.parentRunId), () => ( 0));
261
+ const base = buildPlayWorkflowId("async-child", new Date(parentStartedAt), {
262
+ unique: false
263
+ });
264
+ const workflowId = `${base}-async-${digest}`;
265
+ return {
266
+ workflowId,
267
+ runId: workflowId,
268
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(input.playName)
269
+ };
270
+ }
271
+ function buildRerunPlayRunIdentity(input) {
272
+ const digest = sha256Hex(
273
+ `rerun\0${input.sourceRunId}\0${input.idempotencyKey}`
274
+ ).slice(0, 20);
275
+ const startedAt = _nullishCoalesce(canonicalPlayRunStartedAtMs(input.sourceRunId), () => ( (typeof input.sourceStartedAtMs === "number" && Number.isFinite(input.sourceStartedAtMs) ? input.sourceStartedAtMs : 0)));
276
+ const base = buildPlayWorkflowId(input.playName, new Date(startedAt), {
277
+ unique: false
278
+ });
279
+ const workflowId = `${base}-rerun-${digest}`;
280
+ return {
281
+ workflowId,
282
+ runId: workflowId,
283
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(input.playName)
284
+ };
285
+ }
286
+ function buildAsyncPlayRequestFingerprint(input) {
287
+ return sha256Hex(
288
+ stableStringify({
289
+ key: input.key,
290
+ playRef: input.playRef,
291
+ input: input.childInput
292
+ })
293
+ );
294
+ }
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+ exports.stableStringify = stableStringify; exports.sha256Hex = sha256Hex; exports.normalizeTableNamespace = normalizeTableNamespace; exports.buildPlayWorkflowFamilyKey = buildPlayWorkflowFamilyKey; exports.buildPlayWorkflowRunSuffix = buildPlayWorkflowRunSuffix; exports.canonicalPlayRunStartedAtMs = canonicalPlayRunStartedAtMs; exports.buildPlayWorkflowId = buildPlayWorkflowId; exports.buildCallerPlayWorkflowId = buildCallerPlayWorkflowId; exports.callerPlayWorkflowIdMatchesRequest = callerPlayWorkflowIdMatchesRequest; exports.buildPlayRunIdentity = buildPlayRunIdentity; exports.buildAsyncPlayRunIdentity = buildAsyncPlayRunIdentity; exports.buildRerunPlayRunIdentity = buildRerunPlayRunIdentity; exports.buildAsyncPlayRequestFingerprint = buildAsyncPlayRequestFingerprint;