deepline 0.1.301 → 0.1.303

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 (40) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +8 -0
  2. package/dist/bundling-sources/sdk/src/errors.ts +96 -36
  3. package/dist/bundling-sources/sdk/src/http.ts +82 -5
  4. package/dist/bundling-sources/sdk/src/index.ts +12 -0
  5. package/dist/bundling-sources/sdk/src/play.ts +29 -1
  6. package/dist/bundling-sources/sdk/src/release.ts +5 -3
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +120 -14
  8. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +59 -11
  10. package/dist/bundling-sources/shared_libs/play-runtime/execution-ledger-store.ts +3 -3
  11. package/dist/bundling-sources/shared_libs/play-runtime/execution-plan.ts +0 -15
  12. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +3 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +136 -36
  15. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +17 -12
  16. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +210 -5
  17. package/dist/bundling-sources/shared_libs/play-runtime/tool-result-paths.ts +15 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +4 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +33 -24
  20. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +4 -0
  21. package/dist/bundling-sources/shared_libs/plays/artifact-contract-version.ts +6 -0
  22. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +4 -0
  23. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +159 -12
  24. package/dist/bundling-sources/shared_libs/plays/contracts.ts +69 -1
  25. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +557 -0
  26. package/dist/cli/index.js +556 -183
  27. package/dist/cli/index.mjs +556 -183
  28. package/dist/index.d.mts +69 -40
  29. package/dist/index.d.ts +69 -40
  30. package/dist/index.js +480 -80
  31. package/dist/index.mjs +477 -80
  32. package/dist/plays/bundle-play-file.d.mts +4 -2
  33. package/dist/plays/bundle-play-file.d.ts +4 -2
  34. package/dist/plays/bundle-play-file.mjs +116 -19
  35. package/dist/tool-execution-error-YDz7UMl-.d.mts +440 -0
  36. package/dist/tool-execution-error-YDz7UMl-.d.ts +440 -0
  37. package/package.json +1 -1
  38. package/dist/bundling-sources/shared_libs/play-runtime/completed-receipt-cache.ts +0 -166
  39. package/dist/compiler-manifest-BjopNIqx.d.mts +0 -240
  40. package/dist/compiler-manifest-BjopNIqx.d.ts +0 -240
@@ -176,20 +176,291 @@ import {
176
176
  import { homedir } from "os";
177
177
  import { dirname, isAbsolute, join, resolve } from "path";
178
178
 
179
- // src/errors.ts
180
- var DeeplineError = class extends Error {
179
+ // ../shared_libs/tool-execution-error.ts
180
+ var DEEPLINE_ERROR_BRAND = /* @__PURE__ */ Symbol.for("deepline.error.v1");
181
+ var TOOL_EXECUTION_ERROR_BRAND = /* @__PURE__ */ Symbol.for(
182
+ "deepline.tool-execution-error.v1"
183
+ );
184
+ var PROVIDER_TRANSIENT_ERROR_BRAND = /* @__PURE__ */ Symbol.for(
185
+ "deepline.provider-transient-error.v1"
186
+ );
187
+ var LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION = 0;
188
+ var TOOL_EXECUTION_ERROR_SCHEMA_VERSION = 1;
189
+ var TOOL_EXECUTION_ERROR_SCHEMA_HEADER = "x-deepline-tool-error-schema";
190
+ var MAX_IDENTIFIER_LENGTH = 200;
191
+ var MAX_CODE_LENGTH = 160;
192
+ function nativeInstanceOf(constructor, value) {
193
+ return Reflect.apply(Function.prototype[Symbol.hasInstance], constructor, [
194
+ value
195
+ ]);
196
+ }
197
+ function hasBrand(value, brand) {
198
+ return typeof value === "object" && value !== null && value[brand] === true;
199
+ }
200
+ function applyBrand(value, brand) {
201
+ if (hasBrand(value, brand)) return;
202
+ Object.defineProperty(value, brand, {
203
+ configurable: false,
204
+ enumerable: false,
205
+ writable: false,
206
+ value: true
207
+ });
208
+ }
209
+ var DeeplineError = class _DeeplineError extends Error {
210
+ /** HTTP status when the failure crossed an HTTP boundary. */
211
+ statusCode;
212
+ /** Stable machine-readable error code when one exists. */
213
+ code;
214
+ /** Local diagnostic context; not a portable error contract. */
215
+ details;
216
+ /**
217
+ * Construct a Deepline error.
218
+ *
219
+ * SDK and runtime code construct these errors. Application and Play code
220
+ * normally catches the public subclasses instead.
221
+ *
222
+ * @param message Human-readable failure summary.
223
+ * @param statusCode HTTP status when one exists.
224
+ * @param code Stable machine-readable code when one exists.
225
+ * @param details Local diagnostic context; never a portable error contract.
226
+ */
181
227
  constructor(message, statusCode, code, details) {
182
228
  super(message);
229
+ this.name = "DeeplineError";
183
230
  this.statusCode = statusCode;
184
231
  this.code = code;
185
232
  this.details = details;
186
- this.name = "DeeplineError";
233
+ applyBrand(this, DEEPLINE_ERROR_BRAND);
234
+ }
235
+ static [Symbol.hasInstance](value) {
236
+ if (this !== _DeeplineError) return nativeInstanceOf(this, value);
237
+ return hasBrand(value, DEEPLINE_ERROR_BRAND);
187
238
  }
188
- statusCode;
189
- code;
190
- details;
191
239
  };
240
+ var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
241
+ /** Public tool id passed to `tools.execute`. */
242
+ toolId;
243
+ /** Provider responsible for the operation, or `null` when unattributed. */
244
+ provider;
245
+ /** Provider operation name, or `null` when unavailable. */
246
+ operation;
247
+ /** Boundary responsible for the failure. */
248
+ origin;
249
+ /** Stable reason family for policy and diagnostics. */
250
+ category;
251
+ /**
252
+ * Whether repeating the same semantic call is delivery-safe.
253
+ *
254
+ * This does not mean the error may be ignored. Waterfall fallthrough is
255
+ * represented by `ProviderTransientError`.
256
+ */
257
+ retryable;
258
+ /** Provider or Deepline request id, or `null` when unavailable. */
259
+ requestId;
260
+ /** Suggested same-call retry delay in milliseconds, or `null`. */
261
+ retryAfterMs;
262
+ /** Network failure kind, or `null` for non-network failures. */
263
+ networkKind;
264
+ /** Network boundary that failed, or `null` for non-network failures. */
265
+ networkScope;
266
+ /**
267
+ * Construct a structured tool error.
268
+ *
269
+ * Deepline constructs this from the versioned `tool_error` payload.
270
+ * Application and Play code should catch it rather than create it.
271
+ */
272
+ constructor(message, options) {
273
+ super(
274
+ message,
275
+ options.statusCode ?? void 0,
276
+ options.code ?? void 0,
277
+ options.details
278
+ );
279
+ this.name = "ToolExecutionError";
280
+ this.toolId = options.toolId;
281
+ this.provider = options.provider;
282
+ this.operation = options.operation;
283
+ this.origin = options.origin;
284
+ this.category = options.category;
285
+ this.retryable = options.retryable;
286
+ this.requestId = options.requestId;
287
+ this.retryAfterMs = options.retryAfterMs;
288
+ this.networkKind = options.networkKind;
289
+ this.networkScope = options.networkScope;
290
+ applyBrand(this, TOOL_EXECUTION_ERROR_BRAND);
291
+ if (isProviderTransientFailure(options)) {
292
+ applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
293
+ }
294
+ }
295
+ static [Symbol.hasInstance](value) {
296
+ if (this !== _ToolExecutionError) return nativeInstanceOf(this, value);
297
+ return hasBrand(value, TOOL_EXECUTION_ERROR_BRAND);
298
+ }
299
+ };
300
+ function brandAsToolExecutionError(value) {
301
+ applyBrand(value, TOOL_EXECUTION_ERROR_BRAND);
302
+ }
303
+ function isProviderTransientFailure(input2) {
304
+ return input2.origin === "provider" && (input2.category === "rate_limit" || input2.category === "network" || input2.category === "upstream");
305
+ }
306
+ var ProviderTransientError = class _ProviderTransientError extends ToolExecutionError {
307
+ /** Provider attribution is guaranteed for this subtype. */
308
+ origin = "provider";
309
+ /** Constructed by Deepline when a provider-owned transient failure arrives. */
310
+ constructor(message, options) {
311
+ super(message, {
312
+ ...options,
313
+ origin: "provider",
314
+ category: options.category
315
+ });
316
+ this.name = "ProviderTransientError";
317
+ this.category = options.category;
318
+ applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
319
+ }
320
+ static [Symbol.hasInstance](value) {
321
+ if (this !== _ProviderTransientError) return nativeInstanceOf(this, value);
322
+ return hasBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
323
+ }
324
+ };
325
+ function brandAsProviderTransientError(value) {
326
+ applyBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
327
+ }
328
+ function boundedString(value, maxLength = MAX_IDENTIFIER_LENGTH) {
329
+ if (typeof value !== "string") return null;
330
+ const normalized = value.trim();
331
+ return normalized ? normalized.slice(0, maxLength) : null;
332
+ }
333
+ function finiteNonNegativeInteger(value) {
334
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && Number.isInteger(value) ? value : null;
335
+ }
336
+ function normalizeToolExecutionOrigin(value, input2) {
337
+ const normalized = boundedString(value)?.toLowerCase();
338
+ if (normalized === "caller") return "caller";
339
+ if (normalized === "provider" || normalized === "provider_network") {
340
+ return "provider";
341
+ }
342
+ if (normalized === "upstream" && boundedString(input2?.provider) && boundedString(input2?.operation)) {
343
+ return "provider";
344
+ }
345
+ if (normalized === "deepline" || normalized === "deepline_billing" || normalized === "deepline_rate_limit" || normalized === "internal" || normalized === "server") {
346
+ return "deepline";
347
+ }
348
+ if (normalized === "provider_account") return "provider";
349
+ return "unknown";
350
+ }
351
+ function normalizeToolExecutionCategory(value) {
352
+ switch (boundedString(value)?.toLowerCase()) {
353
+ case "validation":
354
+ case "authorization":
355
+ case "rate_limit":
356
+ case "network":
357
+ case "upstream":
358
+ case "billing":
359
+ case "conflict":
360
+ case "internal":
361
+ return boundedString(value).toLowerCase();
362
+ case "authentication":
363
+ case "provider_auth":
364
+ case "provider_account":
365
+ return "authentication";
366
+ case "execution":
367
+ case "parse":
368
+ case "stub":
369
+ case "internal_native_search_performance":
370
+ return "internal";
371
+ default:
372
+ return "unknown";
373
+ }
374
+ }
375
+ function normalizeNetworkKind(value) {
376
+ switch (boundedString(value)?.toLowerCase()) {
377
+ case "timeout":
378
+ case "dns":
379
+ case "connect":
380
+ case "reset":
381
+ case "unavailable":
382
+ case "unknown":
383
+ return boundedString(value).toLowerCase();
384
+ default:
385
+ return null;
386
+ }
387
+ }
388
+ function normalizeNetworkScope(value) {
389
+ switch (boundedString(value)?.toLowerCase()) {
390
+ case "client_to_deepline":
391
+ case "runtime_to_deepline":
392
+ case "deepline_to_provider":
393
+ return boundedString(value).toLowerCase();
394
+ default:
395
+ return null;
396
+ }
397
+ }
398
+ function isRecord(value) {
399
+ return value !== null && typeof value === "object" && !Array.isArray(value);
400
+ }
401
+ function normalizeToolExecutionFailure(value) {
402
+ if (!isRecord(value) || value.schemaVersion !== TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
403
+ return null;
404
+ }
405
+ const toolId = boundedString(value.toolId);
406
+ if (!toolId) return null;
407
+ const provider = boundedString(value.provider);
408
+ const operation = boundedString(value.operation);
409
+ const origin = normalizeToolExecutionOrigin(value.origin, {
410
+ provider,
411
+ operation
412
+ });
413
+ const category = normalizeToolExecutionCategory(value.category);
414
+ const trustworthy = origin !== "unknown" && category !== "unknown" && typeof value.retryable === "boolean";
415
+ return {
416
+ schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
417
+ toolId,
418
+ provider,
419
+ operation,
420
+ code: boundedString(value.code, MAX_CODE_LENGTH),
421
+ origin,
422
+ category,
423
+ retryable: trustworthy ? value.retryable === true : false,
424
+ statusCode: finiteNonNegativeInteger(value.statusCode),
425
+ requestId: boundedString(value.requestId),
426
+ retryAfterMs: finiteNonNegativeInteger(value.retryAfterMs),
427
+ networkKind: normalizeNetworkKind(value.networkKind),
428
+ networkScope: normalizeNetworkScope(value.networkScope)
429
+ };
430
+ }
431
+ function serializeToolExecutionFailure(error) {
432
+ if (!(error instanceof ToolExecutionError)) return null;
433
+ return normalizeToolExecutionFailure({
434
+ schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
435
+ toolId: error.toolId,
436
+ provider: error.provider,
437
+ operation: error.operation,
438
+ code: error.code ?? null,
439
+ origin: error.origin,
440
+ category: error.category,
441
+ retryable: error.retryable,
442
+ statusCode: error.statusCode ?? null,
443
+ requestId: error.requestId,
444
+ retryAfterMs: error.retryAfterMs,
445
+ networkKind: error.networkKind,
446
+ networkScope: error.networkScope
447
+ });
448
+ }
449
+ function deserializeToolExecutionFailure(message, value, acceptedSchemaVersion) {
450
+ if (acceptedSchemaVersion === LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
451
+ return null;
452
+ }
453
+ const failure = normalizeToolExecutionFailure(value);
454
+ if (!failure) return null;
455
+ if (isProviderTransientFailure(failure)) {
456
+ return new ProviderTransientError(message, failure);
457
+ }
458
+ return new ToolExecutionError(message, failure);
459
+ }
460
+
461
+ // src/errors.ts
192
462
  var AuthError = class extends DeeplineError {
463
+ /** Constructed by the SDK when Deepline rejects the caller's credentials. */
193
464
  constructor(message = "Authentication failed. Check your DEEPLINE_API_KEY.") {
194
465
  super(message, 401, "AUTH_ERROR");
195
466
  this.name = "AuthError";
@@ -198,6 +469,7 @@ var AuthError = class extends DeeplineError {
198
469
  var RateLimitError = class extends DeeplineError {
199
470
  /** Milliseconds to wait before retrying, from the `Retry-After` response header. Defaults to 5000. */
200
471
  retryAfterMs;
472
+ /** Constructed by the SDK after exhausting HTTP-level rate-limit retries. */
201
473
  constructor(retryAfterMs = 5e3, message) {
202
474
  super(
203
475
  message ?? `Rate limited. Retry after ${retryAfterMs}ms.`,
@@ -208,7 +480,51 @@ var RateLimitError = class extends DeeplineError {
208
480
  this.retryAfterMs = retryAfterMs;
209
481
  }
210
482
  };
483
+ var ToolRateLimitError = class extends RateLimitError {
484
+ /** Public tool id passed to `tools.execute`. */
485
+ toolId;
486
+ /** Provider responsible for the operation, or `null`. */
487
+ provider;
488
+ /** Provider operation name, or `null`. */
489
+ operation;
490
+ /** Stable machine-readable failure code when one exists. */
491
+ code;
492
+ /** Boundary responsible for the failure. */
493
+ origin;
494
+ /** Stable reason family for policy and diagnostics. */
495
+ category;
496
+ /** Whether repeating the same semantic call is delivery-safe. */
497
+ retryable;
498
+ /** Provider or Deepline request id, or `null`. */
499
+ requestId;
500
+ /** Network failure kind, or `null` for non-network failures. */
501
+ networkKind;
502
+ /** Network boundary that failed, or `null` for non-network failures. */
503
+ networkScope;
504
+ /** Constructed by the SDK after a structured tool HTTP 429. */
505
+ constructor(message, options) {
506
+ super(options.retryAfterMs ?? 5e3, message);
507
+ this.name = "ToolRateLimitError";
508
+ this.statusCode = options.statusCode ?? 429;
509
+ this.code = options.code ?? void 0;
510
+ this.toolId = options.toolId;
511
+ this.provider = options.provider;
512
+ this.operation = options.operation;
513
+ this.origin = options.origin;
514
+ this.category = options.category;
515
+ this.retryable = options.retryable;
516
+ this.requestId = options.requestId;
517
+ this.networkKind = options.networkKind;
518
+ this.networkScope = options.networkScope;
519
+ this.details = options.details;
520
+ brandAsToolExecutionError(this);
521
+ if (isProviderTransientFailure(this)) {
522
+ brandAsProviderTransientError(this);
523
+ }
524
+ }
525
+ };
211
526
  var ConfigError = class extends DeeplineError {
527
+ /** Construct a local SDK configuration failure. */
212
528
  constructor(message) {
213
529
  super(message, void 0, "CONFIG_ERROR");
214
530
  this.name = "ConfigError";
@@ -664,6 +980,9 @@ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
664
980
  import { homedir as homedir3 } from "os";
665
981
  import { join as join2 } from "path";
666
982
 
983
+ // ../shared_libs/plays/artifact-contract-version.ts
984
+ var CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION = 2;
985
+
667
986
  // src/release.ts
668
987
  var SDK_RELEASE = {
669
988
  // 0.1.94 is claimed by PR #1527 — this watch-render fix ships as 0.1.95.
@@ -703,7 +1022,7 @@ var SDK_RELEASE = {
703
1022
  // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
704
1023
  // 0.1.254 removes the internal operations tree from the published SDK CLI.
705
1024
  // Operators use the checkout-local deepline-admin binary instead.
706
- version: "0.1.301",
1025
+ version: "0.1.303",
707
1026
  contracts: {
708
1027
  api: {
709
1028
  name: "sdk-http-api",
@@ -719,8 +1038,8 @@ var SDK_RELEASE = {
719
1038
  },
720
1039
  playArtifact: {
721
1040
  name: "play-artifact-runtime",
722
- currentVersion: 2,
723
- supportedVersions: [1, 2]
1041
+ currentVersion: CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION,
1042
+ supportedVersions: [1, CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION]
724
1043
  },
725
1044
  release: {
726
1045
  name: "production-sdk-release",
@@ -952,6 +1271,9 @@ function providerLabelFromToolId(toolId) {
952
1271
  const provider = normalized.split(/[_:./-]+/)[0];
953
1272
  return provider || normalized || "provider";
954
1273
  }
1274
+ function isRecord2(value) {
1275
+ return value !== null && typeof value === "object" && !Array.isArray(value);
1276
+ }
955
1277
  var HttpClient = class {
956
1278
  constructor(config) {
957
1279
  this.config = config;
@@ -1087,6 +1409,29 @@ var HttpClient = class {
1087
1409
  signal: controller.signal
1088
1410
  });
1089
1411
  clearTimeout(timeoutId);
1412
+ const body = await response.text();
1413
+ const parsed = parseResponseBody(body);
1414
+ const structuredToolError = options?.toolId && !response.ok ? deserializeToolExecutionFailure(
1415
+ apiErrorMessage(parsed, response.status),
1416
+ isRecord2(parsed) ? parsed.tool_error : null,
1417
+ TOOL_EXECUTION_ERROR_SCHEMA_VERSION
1418
+ ) : null;
1419
+ if (structuredToolError) {
1420
+ if (response.status === 429) {
1421
+ const retryAfter = parseRetryAfter(response);
1422
+ const failure = serializeToolExecutionFailure(structuredToolError);
1423
+ lastError = failure === null ? structuredToolError : new ToolRateLimitError(structuredToolError.message, {
1424
+ ...failure,
1425
+ retryAfterMs: failure.retryAfterMs ?? Math.max(0, retryAfter)
1426
+ });
1427
+ if (attempt < maxRetries) {
1428
+ retryAfterDelayMs = retryAfter;
1429
+ break;
1430
+ }
1431
+ throw lastError;
1432
+ }
1433
+ throw structuredToolError;
1434
+ }
1090
1435
  if (response.status === 429) {
1091
1436
  const retryAfter = parseRetryAfter(response);
1092
1437
  lastError = new RateLimitError(retryAfter);
@@ -1096,8 +1441,6 @@ var HttpClient = class {
1096
1441
  }
1097
1442
  throw lastError;
1098
1443
  }
1099
- const body = await response.text();
1100
- const parsed = parseResponseBody(body);
1101
1444
  if (response.status === 401 && !isProviderOriginatedHttpError(parsed) || response.status === 403 && !options?.forbiddenAsApiError) {
1102
1445
  throw new AuthError();
1103
1446
  }
@@ -1162,6 +1505,29 @@ var HttpClient = class {
1162
1505
  lastError,
1163
1506
  describeRequestTarget(path)
1164
1507
  );
1508
+ if (options?.toolId) {
1509
+ const code = mappedNetworkError.code;
1510
+ throw new ToolExecutionError(
1511
+ withCoworkNetworkHint(mappedNetworkError.message),
1512
+ {
1513
+ toolId: options.toolId,
1514
+ provider: providerLabelFromToolId(options.toolId),
1515
+ operation: options.toolId,
1516
+ code,
1517
+ origin: "deepline",
1518
+ category: "network",
1519
+ // A direct client timeout has ambiguous delivery. Fail closed unless
1520
+ // the server returns the authoritative action delivery contract.
1521
+ retryable: false,
1522
+ statusCode: null,
1523
+ requestId: null,
1524
+ retryAfterMs: null,
1525
+ networkKind: code === "NETWORK_TIMEOUT" ? "timeout" : code === "NETWORK_ABORTED" ? "unknown" : "unavailable",
1526
+ networkScope: "client_to_deepline",
1527
+ details: mappedNetworkError.details
1528
+ }
1529
+ );
1530
+ }
1165
1531
  throw new DeeplineError(
1166
1532
  withCoworkNetworkHint(mappedNetworkError.message),
1167
1533
  void 0,
@@ -1603,11 +1969,11 @@ var RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES = 64 * 1024;
1603
1969
  var ledgerIngressRedactor = createSecretRedactionContext();
1604
1970
 
1605
1971
  // ../shared_libs/play-runtime/activity-observation.ts
1606
- function isRecord(value) {
1972
+ function isRecord3(value) {
1607
1973
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
1608
1974
  }
1609
1975
  function isPlayActivityObservation(value) {
1610
- if (!isRecord(value) || value.schemaVersion !== 1 || typeof value.activityId !== "string" || !value.activityId.trim() || typeof value.observedAt !== "number" || !Number.isFinite(value.observedAt) || !isRecord(value.target) || !isRecord(value.state)) {
1976
+ if (!isRecord3(value) || value.schemaVersion !== 1 || typeof value.activityId !== "string" || !value.activityId.trim() || typeof value.observedAt !== "number" || !Number.isFinite(value.observedAt) || !isRecord3(value.target) || !isRecord3(value.state)) {
1611
1977
  return false;
1612
1978
  }
1613
1979
  const targetKinds = /* @__PURE__ */ new Set([
@@ -1872,7 +2238,7 @@ function projectPlayRunActivity(input2) {
1872
2238
 
1873
2239
  // ../shared_libs/play-runtime/run-ledger.ts
1874
2240
  var LOG_TAIL_LIMIT = 100;
1875
- function isRecord2(value) {
2241
+ function isRecord4(value) {
1876
2242
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
1877
2243
  }
1878
2244
  function finiteNumber(value) {
@@ -1968,21 +2334,21 @@ function createEmptyPlayRunLedgerSnapshot(input2) {
1968
2334
  };
1969
2335
  }
1970
2336
  function normalizePlayRunLedgerSnapshot(value, fallback) {
1971
- if (!isRecord2(value)) {
2337
+ if (!isRecord4(value)) {
1972
2338
  return createEmptyPlayRunLedgerSnapshot(fallback);
1973
2339
  }
1974
2340
  const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
1975
2341
  (entry) => typeof entry === "string" && Boolean(entry.trim())
1976
2342
  ) : [];
1977
- const rawSteps = isRecord2(value.stepsById) ? value.stepsById : {};
2343
+ const rawSteps = isRecord4(value.stepsById) ? value.stepsById : {};
1978
2344
  const stepsById = {};
1979
2345
  for (const [stepId, rawStep] of Object.entries(rawSteps)) {
1980
- if (!stepId.trim() || !isRecord2(rawStep)) continue;
2346
+ if (!stepId.trim() || !isRecord4(rawStep)) continue;
1981
2347
  const rawStatus = normalizeStepStatus(rawStep.status);
1982
2348
  if (!rawStatus) continue;
1983
2349
  const completedAt = finiteNumber(rawStep.completedAt);
1984
2350
  const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
1985
- const rawProgress = isRecord2(rawStep.progress) ? rawStep.progress : null;
2351
+ const rawProgress = isRecord4(rawStep.progress) ? rawStep.progress : null;
1986
2352
  stepsById[stepId] = {
1987
2353
  stepId,
1988
2354
  label: optionalString(rawStep.label),
@@ -1998,10 +2364,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
1998
2364
  progress: rawProgress ? normalizeStepProgress(rawProgress) : null
1999
2365
  };
2000
2366
  }
2001
- const rawDatasets = isRecord2(value.datasetsById) ? value.datasetsById : {};
2367
+ const rawDatasets = isRecord4(value.datasetsById) ? value.datasetsById : {};
2002
2368
  const datasetsById = {};
2003
2369
  for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
2004
- if (!datasetId.trim() || !isRecord2(rawDataset)) continue;
2370
+ if (!datasetId.trim() || !isRecord4(rawDataset)) continue;
2005
2371
  const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
2006
2372
  datasetsById[datasetId] = {
2007
2373
  datasetId,
@@ -2015,7 +2381,7 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
2015
2381
  updatedAt: finiteNumber(rawDataset.updatedAt) ?? 0
2016
2382
  };
2017
2383
  }
2018
- const rawActivities = isRecord2(value.activitiesById) ? value.activitiesById : {};
2384
+ const rawActivities = isRecord4(value.activitiesById) ? value.activitiesById : {};
2019
2385
  const activitiesById = {};
2020
2386
  for (const [activityId, rawActivity] of Object.entries(rawActivities)) {
2021
2387
  if (activityId.trim() && isPlayActivityObservation(rawActivity) && rawActivity.activityId === activityId) {
@@ -2164,18 +2530,18 @@ function normalizePlayRunLiveStatus(value) {
2164
2530
  function isTerminalPlayRunLiveStatus(status) {
2165
2531
  return isTerminalPlayRunLifecycleStatus(status);
2166
2532
  }
2167
- function isRecord3(value) {
2533
+ function isRecord5(value) {
2168
2534
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
2169
2535
  }
2170
2536
  function finiteNumber2(value) {
2171
2537
  return typeof value === "number" && Number.isFinite(value) ? value : null;
2172
2538
  }
2173
2539
  function extractTerminalRunLogTail(result) {
2174
- if (!isRecord3(result) || !isRecord3(result._metadata)) {
2540
+ if (!isRecord5(result) || !isRecord5(result._metadata)) {
2175
2541
  return null;
2176
2542
  }
2177
2543
  const runLogTail = result._metadata.runLogTail;
2178
- if (!isRecord3(runLogTail) || !Array.isArray(runLogTail.tail)) {
2544
+ if (!isRecord5(runLogTail) || !Array.isArray(runLogTail.tail)) {
2179
2545
  return null;
2180
2546
  }
2181
2547
  const logTail = runLogTail.tail.filter(
@@ -3069,7 +3435,7 @@ function resolveToolExecuteTimeoutMs(toolId, input2) {
3069
3435
  }
3070
3436
  var RUNS_FAILED_LOG_LIMIT = 20;
3071
3437
  var RUN_LOGS_PAGE_LIMIT = 1e3;
3072
- function isRecord4(value) {
3438
+ function isRecord6(value) {
3073
3439
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
3074
3440
  }
3075
3441
  function isPrebuiltPlayDescription(play) {
@@ -3232,7 +3598,7 @@ function updatePlayLiveStatusState(state, event) {
3232
3598
  }
3233
3599
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
3234
3600
  const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
3235
- const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
3601
+ const progressPayload = isRecord6(payload.progress) ? payload.progress : {};
3236
3602
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
3237
3603
  const payloadLogs = readStringArray(payload.logs);
3238
3604
  const progressLogs = readStringArray(progressPayload.logs);
@@ -3366,9 +3732,9 @@ var DeeplineClient = class {
3366
3732
  return fields.length > 0 ? { fields } : schema;
3367
3733
  }
3368
3734
  schemaMetadata(schema, key) {
3369
- if (!isRecord4(schema)) return null;
3735
+ if (!isRecord6(schema)) return null;
3370
3736
  const value = schema[key];
3371
- return isRecord4(value) ? value : null;
3737
+ return isRecord6(value) ? value : null;
3372
3738
  }
3373
3739
  playRunCommand(play, options) {
3374
3740
  const target = play.reference || play.name;
@@ -3417,7 +3783,7 @@ var DeeplineClient = class {
3417
3783
  aliases,
3418
3784
  inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
3419
3785
  outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
3420
- staticPipeline: isRecord4(play.staticPipeline) ? play.staticPipeline : isRecord4(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord4(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
3786
+ staticPipeline: isRecord6(play.staticPipeline) ? play.staticPipeline : isRecord6(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord6(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
3421
3787
  ...csvInput ? { csvInput } : {},
3422
3788
  ...rowOutputSchema ? { rowOutputSchema } : {},
3423
3789
  runCommand: runCommand2,
@@ -3588,6 +3954,9 @@ var DeeplineClient = class {
3588
3954
  async executeTool(toolId, input2, options) {
3589
3955
  const headers = {
3590
3956
  [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
3957
+ [TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
3958
+ TOOL_EXECUTION_ERROR_SCHEMA_VERSION
3959
+ ),
3591
3960
  ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
3592
3961
  [EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
3593
3962
  };
@@ -3602,7 +3971,8 @@ var DeeplineClient = class {
3602
3971
  forbiddenAsApiError: true,
3603
3972
  timeout: options?.timeout ?? resolveToolExecuteTimeoutMs(toolId, input2),
3604
3973
  maxRetries: options?.maxRetries ?? 0,
3605
- exactUrlOnly: true
3974
+ exactUrlOnly: true,
3975
+ toolId
3606
3976
  }
3607
3977
  );
3608
3978
  }
@@ -8283,14 +8653,14 @@ function sanitizeCsvProjectionInfo(input2) {
8283
8653
  const rows = input2.rows.map(stripCsvProjectionFields);
8284
8654
  return { rows, columns };
8285
8655
  }
8286
- function isRecord5(value) {
8656
+ function isRecord7(value) {
8287
8657
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
8288
8658
  }
8289
8659
  function isSerializedDataset(value) {
8290
- return isRecord5(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
8660
+ return isRecord7(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
8291
8661
  }
8292
8662
  function isPackagedDatasetOutput(value) {
8293
- return isRecord5(value) && value.kind === "dataset" && isRecord5(value.preview) && Array.isArray(value.preview.rows);
8663
+ return isRecord7(value) && value.kind === "dataset" && isRecord7(value.preview) && Array.isArray(value.preview.rows);
8294
8664
  }
8295
8665
  function pathParts(path) {
8296
8666
  return path.split(".").map((part) => part.trim()).filter(Boolean);
@@ -8298,7 +8668,7 @@ function pathParts(path) {
8298
8668
  function valueAtPath(root, path) {
8299
8669
  let cursor = root;
8300
8670
  for (const part of pathParts(path)) {
8301
- if (!isRecord5(cursor)) {
8671
+ if (!isRecord7(cursor)) {
8302
8672
  return void 0;
8303
8673
  }
8304
8674
  cursor = cursor[part];
@@ -8306,17 +8676,17 @@ function valueAtPath(root, path) {
8306
8676
  return cursor;
8307
8677
  }
8308
8678
  function totalRowsForDataset(result, datasetPath) {
8309
- const metadata = isRecord5(result._metadata) ? result._metadata : null;
8679
+ const metadata = isRecord7(result._metadata) ? result._metadata : null;
8310
8680
  const parentPath = datasetPath.split(".").slice(0, -1).join(".");
8311
8681
  const parent = parentPath ? valueAtPath({ result }, parentPath) : result;
8312
- return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord5(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
8682
+ return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord7(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
8313
8683
  }
8314
8684
  function rowArray(value) {
8315
8685
  if (!Array.isArray(value)) {
8316
8686
  return null;
8317
8687
  }
8318
8688
  const rows = value.filter(
8319
- (row) => isRecord5(row)
8689
+ (row) => isRecord7(row)
8320
8690
  );
8321
8691
  return rows.length === value.length ? rows : null;
8322
8692
  }
@@ -8340,7 +8710,7 @@ function inferColumns(rows) {
8340
8710
  return columns;
8341
8711
  }
8342
8712
  function columnsFromDatasetSummary(summary) {
8343
- if (!isRecord5(summary) || !isRecord5(summary.columnStats)) {
8713
+ if (!isRecord7(summary) || !isRecord7(summary.columnStats)) {
8344
8714
  return [];
8345
8715
  }
8346
8716
  return Object.keys(summary.columnStats).filter((column) => column);
@@ -8388,7 +8758,7 @@ function canonicalRowsInfoFromCandidate(input2) {
8388
8758
  datasetId: typeof candidate.value.datasetId === "string" ? candidate.value.datasetId : null,
8389
8759
  tableNamespace: typeof candidate.value.tableNamespace === "string" ? candidate.value.tableNamespace : null,
8390
8760
  ...candidate.value.recovered === true ? { recovered: true } : {},
8391
- ...isRecord5(candidate.value.exportUnavailable) && (candidate.value.exportUnavailable.reason === "empty_dataset" || candidate.value.exportUnavailable.reason === "shared_table_namespace") ? {
8761
+ ...isRecord7(candidate.value.exportUnavailable) && (candidate.value.exportUnavailable.reason === "empty_dataset" || candidate.value.exportUnavailable.reason === "shared_table_namespace") ? {
8392
8762
  exportUnavailableReason: candidate.value.exportUnavailable.reason,
8393
8763
  ...typeof candidate.value.exportUnavailable.message === "string" ? {
8394
8764
  exportUnavailableMessage: candidate.value.exportUnavailable.message
@@ -8436,7 +8806,7 @@ function collectDatasetCandidates(input2) {
8436
8806
  });
8437
8807
  return;
8438
8808
  }
8439
- if (!isRecord5(input2.value)) {
8809
+ if (!isRecord7(input2.value)) {
8440
8810
  return;
8441
8811
  }
8442
8812
  for (const [key, child] of Object.entries(input2.value)) {
@@ -8453,12 +8823,12 @@ function collectDatasetCandidates(input2) {
8453
8823
  }
8454
8824
  }
8455
8825
  function collectCanonicalRowsInfos(statusOrResult) {
8456
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
8457
- const result = isRecord5(root?.result) ? root.result : root;
8826
+ const root = isRecord7(statusOrResult) ? statusOrResult : null;
8827
+ const result = isRecord7(root?.result) ? root.result : root;
8458
8828
  if (!result) {
8459
8829
  return [];
8460
8830
  }
8461
- const metadata = isRecord5(result._metadata) ? result._metadata : null;
8831
+ const metadata = isRecord7(result._metadata) ? result._metadata : null;
8462
8832
  const totalFromMetadata = metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count;
8463
8833
  const candidates = [
8464
8834
  {
@@ -8482,8 +8852,8 @@ function collectCanonicalRowsInfos(statusOrResult) {
8482
8852
  total: totalFromMetadata ?? result.totalRows ?? result.rowCount ?? result.count
8483
8853
  }
8484
8854
  ];
8485
- if (isRecord5(result.output)) {
8486
- const outputMetadata = isRecord5(result.output._metadata) ? result.output._metadata : null;
8855
+ if (isRecord7(result.output)) {
8856
+ const outputMetadata = isRecord7(result.output._metadata) ? result.output._metadata : null;
8487
8857
  const outputTotalFromMetadata = outputMetadata?.totalRows ?? outputMetadata?.rowCount ?? outputMetadata?.count;
8488
8858
  candidates.push(
8489
8859
  {
@@ -8510,14 +8880,14 @@ function collectCanonicalRowsInfos(statusOrResult) {
8510
8880
  }
8511
8881
  if (Array.isArray(result.steps)) {
8512
8882
  result.steps.forEach((step, index) => {
8513
- if (!isRecord5(step) || !isRecord5(step.output)) {
8883
+ if (!isRecord7(step) || !isRecord7(step.output)) {
8514
8884
  return;
8515
8885
  }
8516
8886
  const source = typeof step.output.path === "string" ? step.output.path : typeof step.id === "string" ? `steps.${step.id}.output` : `steps.${index}.output`;
8517
8887
  candidates.push({
8518
8888
  source,
8519
8889
  value: step.output,
8520
- total: step.output.rowCount ?? (isRecord5(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord5(step.progress) ? step.progress.total : void 0)
8890
+ total: step.output.rowCount ?? (isRecord7(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord7(step.progress) ? step.progress.total : void 0)
8521
8891
  });
8522
8892
  });
8523
8893
  }
@@ -8545,15 +8915,15 @@ function collectCanonicalRowsInfos(statusOrResult) {
8545
8915
  return infos;
8546
8916
  }
8547
8917
  function collectPackagedDatasetCandidates(statusOrResult) {
8548
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
8918
+ const root = isRecord7(statusOrResult) ? statusOrResult : null;
8549
8919
  if (!root) {
8550
8920
  return [];
8551
8921
  }
8552
- const pkg = isRecord5(root.package) ? root.package : root;
8922
+ const pkg = isRecord7(root.package) ? root.package : root;
8553
8923
  const datasets = Array.isArray(pkg.datasets) ? pkg.datasets : [];
8554
8924
  const candidates = [];
8555
8925
  for (const output2 of datasets) {
8556
- if (!isRecord5(output2) || !isPackagedDatasetOutput(output2)) {
8926
+ if (!isRecord7(output2) || !isPackagedDatasetOutput(output2)) {
8557
8927
  continue;
8558
8928
  }
8559
8929
  const source = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
@@ -8563,18 +8933,18 @@ function collectPackagedDatasetCandidates(statusOrResult) {
8563
8933
  candidates.push({
8564
8934
  source,
8565
8935
  value: output2,
8566
- total: output2.rowCount ?? (isRecord5(output2.preview) ? output2.preview.totalRows : void 0)
8936
+ total: output2.rowCount ?? (isRecord7(output2.preview) ? output2.preview.totalRows : void 0)
8567
8937
  });
8568
8938
  }
8569
8939
  return candidates;
8570
8940
  }
8571
8941
  function collectPackagedStepDatasetCandidates(statusOrResult) {
8572
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
8942
+ const root = isRecord7(statusOrResult) ? statusOrResult : null;
8573
8943
  if (!root) return [];
8574
- const pkg = isRecord5(root.package) ? root.package : root;
8944
+ const pkg = isRecord7(root.package) ? root.package : root;
8575
8945
  const steps = Array.isArray(pkg.steps) ? pkg.steps : [];
8576
8946
  return steps.flatMap((step) => {
8577
- if (!isRecord5(step) || !isPackagedDatasetOutput(step.output)) return [];
8947
+ if (!isRecord7(step) || !isPackagedDatasetOutput(step.output)) return [];
8578
8948
  const source = typeof step.output.path === "string" && step.output.path.trim() ? step.output.path.trim() : null;
8579
8949
  return source ? [
8580
8950
  {
@@ -8586,8 +8956,8 @@ function collectPackagedStepDatasetCandidates(statusOrResult) {
8586
8956
  });
8587
8957
  }
8588
8958
  function collectSerializedDatasetRowsInfos(statusOrResult) {
8589
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
8590
- const result = isRecord5(root?.result) ? root.result : root;
8959
+ const root = isRecord7(statusOrResult) ? statusOrResult : null;
8960
+ const result = isRecord7(root?.result) ? root.result : root;
8591
8961
  const candidates = [];
8592
8962
  if (result) {
8593
8963
  collectDatasetCandidates({
@@ -8595,7 +8965,7 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
8595
8965
  path: "result",
8596
8966
  output: candidates
8597
8967
  });
8598
- if (isRecord5(result.output)) {
8968
+ if (isRecord7(result.output)) {
8599
8969
  collectDatasetCandidates({
8600
8970
  value: result.output,
8601
8971
  path: "result",
@@ -8673,13 +9043,13 @@ function summarizeSampleValue(value, depth = 0) {
8673
9043
  if (typeof parsed === "number" || typeof parsed === "boolean") return parsed;
8674
9044
  if (depth >= 3) {
8675
9045
  if (Array.isArray(parsed)) return [];
8676
- if (isRecord5(parsed)) return {};
9046
+ if (isRecord7(parsed)) return {};
8677
9047
  return compactScalar(parsed);
8678
9048
  }
8679
9049
  if (Array.isArray(parsed)) {
8680
9050
  return parsed.slice(0, 3).map((item) => summarizeSampleValue(item, depth + 1));
8681
9051
  }
8682
- if (isRecord5(parsed)) {
9052
+ if (isRecord7(parsed)) {
8683
9053
  const out = {};
8684
9054
  for (const [key, nested] of Object.entries(parsed)) {
8685
9055
  if (["__dl", "meta", "metadata"].includes(key)) {
@@ -8710,7 +9080,7 @@ function compactCell(value) {
8710
9080
  }
8711
9081
  return `[${parsed.length} items]`;
8712
9082
  }
8713
- if (isRecord5(parsed)) {
9083
+ if (isRecord7(parsed)) {
8714
9084
  for (const key of ["matched_result", "output"]) {
8715
9085
  if (parsed[key] !== null && parsed[key] !== void 0 && parsed[key] !== "") {
8716
9086
  return compactCell(parsed[key]);
@@ -9799,17 +10169,17 @@ function parsePositiveInteger2(value, flagName) {
9799
10169
  }
9800
10170
  return parsed;
9801
10171
  }
9802
- function isRecord6(value) {
10172
+ function isRecord8(value) {
9803
10173
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
9804
10174
  }
9805
10175
  function stringValue(value) {
9806
10176
  return typeof value === "string" ? value.trim() : "";
9807
10177
  }
9808
10178
  function extractionEntries(value) {
9809
- if (Array.isArray(value)) return value.filter(isRecord6);
9810
- if (!isRecord6(value)) return [];
10179
+ if (Array.isArray(value)) return value.filter(isRecord8);
10180
+ if (!isRecord8(value)) return [];
9811
10181
  return Object.entries(value).map(
9812
- ([name, entry]) => isRecord6(entry) ? { name, ...entry } : { name }
10182
+ ([name, entry]) => isRecord8(entry) ? { name, ...entry } : { name }
9813
10183
  );
9814
10184
  }
9815
10185
  var PlayBootstrapError = class extends Error {
@@ -10371,7 +10741,7 @@ function readCsvSampleRows(sample) {
10371
10741
  relax_column_count: true,
10372
10742
  trim: true
10373
10743
  });
10374
- return Array.isArray(parsedRows) ? parsedRows.filter(isRecord6) : [];
10744
+ return Array.isArray(parsedRows) ? parsedRows.filter(isRecord8) : [];
10375
10745
  }
10376
10746
  function readSourceCsvColumnSpecs(csvPath) {
10377
10747
  const sample = readCsvSample(csvPath);
@@ -10404,16 +10774,16 @@ function packagedCsvPathForPlay(csvPath) {
10404
10774
  return portablePath.startsWith(".") ? portablePath : `./${portablePath}`;
10405
10775
  }
10406
10776
  function getterNamesFromTool(tool, kind) {
10407
- const usageGuidance = isRecord6(tool?.usageGuidance) ? tool.usageGuidance : {};
10408
- const resultGuidance = isRecord6(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord6(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
10777
+ const usageGuidance = isRecord8(tool?.usageGuidance) ? tool.usageGuidance : {};
10778
+ const resultGuidance = isRecord8(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord8(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
10409
10779
  const key = kind === "list" ? "extractedLists" : "extractedValues";
10410
10780
  const snakeKey = kind === "list" ? "extracted_lists" : "extracted_values";
10411
10781
  return extractionEntries(resultGuidance[key] ?? resultGuidance[snakeKey]).map((entry) => stringValue(entry.name)).filter(Boolean);
10412
10782
  }
10413
10783
  function targetGettersFromTool(tool) {
10414
- const record = isRecord6(tool) ? tool : {};
10784
+ const record = isRecord8(tool) ? tool : {};
10415
10785
  const raw = record.targetGetters ?? record.target_getters;
10416
- if (!isRecord6(raw)) return {};
10786
+ if (!isRecord8(raw)) return {};
10417
10787
  const entries = [];
10418
10788
  for (const [target, value] of Object.entries(raw)) {
10419
10789
  const paths = Array.isArray(value) ? value.map((path) => typeof path === "string" ? path.trim() : "").filter(Boolean) : [];
@@ -10434,10 +10804,10 @@ function listRowCandidateKeysFromTool(tool) {
10434
10804
  return [...keys].sort();
10435
10805
  }
10436
10806
  function inputPropertyNames(schema) {
10437
- if (!isRecord6(schema)) return [];
10438
- if (isRecord6(schema.properties)) return Object.keys(schema.properties);
10807
+ if (!isRecord8(schema)) return [];
10808
+ if (isRecord8(schema.properties)) return Object.keys(schema.properties);
10439
10809
  if (Array.isArray(schema.fields)) {
10440
- return schema.fields.filter(isRecord6).map((field) => stringValue(field.name)).filter(Boolean);
10810
+ return schema.fields.filter(isRecord8).map((field) => stringValue(field.name)).filter(Boolean);
10441
10811
  }
10442
10812
  return [];
10443
10813
  }
@@ -10451,7 +10821,7 @@ function schemaFieldDetails(schema) {
10451
10821
  return { required, optional };
10452
10822
  }
10453
10823
  function jsonSchemaTypeExpression(schema) {
10454
- if (!isRecord6(schema)) return "unknown";
10824
+ if (!isRecord8(schema)) return "unknown";
10455
10825
  const type = schema.type;
10456
10826
  if (Array.isArray(type)) {
10457
10827
  return type.map((entry) => jsonSchemaTypeExpression({ ...schema, type: entry })).join(" | ");
@@ -10481,7 +10851,7 @@ function jsonSchemaTypeExpression(schema) {
10481
10851
  }
10482
10852
  }
10483
10853
  function objectPropertySchema(schema, property) {
10484
- return isRecord6(schema) && isRecord6(schema.properties) ? schema.properties[property] : null;
10854
+ return isRecord8(schema) && isRecord8(schema.properties) ? schema.properties[property] : null;
10485
10855
  }
10486
10856
  function playOutputHasField(schema, field) {
10487
10857
  return objectPropertySchema(schema, field) != null;
@@ -10657,14 +11027,14 @@ ${indent2.slice(2)}}`;
10657
11027
  }
10658
11028
  function requiredPlayInputFields(play) {
10659
11029
  const schema = play?.inputSchema;
10660
- if (!isRecord6(schema)) return [];
11030
+ if (!isRecord8(schema)) return [];
10661
11031
  if (Array.isArray(schema.required)) {
10662
11032
  return schema.required.filter(
10663
11033
  (value) => typeof value === "string"
10664
11034
  );
10665
11035
  }
10666
11036
  if (Array.isArray(schema.fields)) {
10667
- return schema.fields.filter(isRecord6).filter(
11037
+ return schema.fields.filter(isRecord8).filter(
10668
11038
  (field) => field.required === true && typeof field.name === "string"
10669
11039
  ).map((field) => String(field.name));
10670
11040
  }
@@ -10845,7 +11215,7 @@ function validateBootstrapRoutes(input2) {
10845
11215
  }
10846
11216
  }
10847
11217
  function staticPipelineSubsteps(pipeline) {
10848
- if (!isRecord6(pipeline)) return [];
11218
+ if (!isRecord8(pipeline)) return [];
10849
11219
  return [
10850
11220
  ...extractionEntries(pipeline.stages),
10851
11221
  ...extractionEntries(pipeline.substeps)
@@ -10853,7 +11223,7 @@ function staticPipelineSubsteps(pipeline) {
10853
11223
  }
10854
11224
  function playUsesMapBackedRuntime(play) {
10855
11225
  const pipeline = play?.staticPipeline;
10856
- if (!isRecord6(pipeline)) return false;
11226
+ if (!isRecord8(pipeline)) return false;
10857
11227
  if (stringValue(pipeline.tableNamespace)) return true;
10858
11228
  return staticPipelineSubsteps(pipeline).some((substep) => {
10859
11229
  if (stringValue(substep.type) === "map") return true;
@@ -10862,7 +11232,7 @@ function playUsesMapBackedRuntime(play) {
10862
11232
  aliases: [],
10863
11233
  runCommand: "",
10864
11234
  examples: [],
10865
- staticPipeline: isRecord6(substep.pipeline) ? substep.pipeline : null
11235
+ staticPipeline: isRecord8(substep.pipeline) ? substep.pipeline : null
10866
11236
  });
10867
11237
  });
10868
11238
  }
@@ -15600,7 +15970,7 @@ function extractPlayValidationErrors(value) {
15600
15970
  if (value instanceof DeeplineError) {
15601
15971
  return extractPlayValidationErrors(value.details);
15602
15972
  }
15603
- if (!isRecord7(value)) {
15973
+ if (!isRecord9(value)) {
15604
15974
  return [];
15605
15975
  }
15606
15976
  const directErrors = stringArrayField(value, "errors");
@@ -16040,7 +16410,7 @@ function shouldUseLocalOnlyPlayCheck() {
16040
16410
  const value = process.env.DEEPLINE_PLAY_CHECK_LOCAL_ONLY?.trim().toLowerCase();
16041
16411
  return value === "1" || value === "true" || value === "yes" || value === "on";
16042
16412
  }
16043
- function isRecord7(value) {
16413
+ function isRecord9(value) {
16044
16414
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
16045
16415
  }
16046
16416
  function stringValue2(value) {
@@ -16050,14 +16420,14 @@ function asArray(value) {
16050
16420
  return Array.isArray(value) ? value : [];
16051
16421
  }
16052
16422
  function extractionEntries2(value) {
16053
- if (Array.isArray(value)) return value.filter(isRecord7);
16054
- if (!isRecord7(value)) return [];
16423
+ if (Array.isArray(value)) return value.filter(isRecord9);
16424
+ if (!isRecord9(value)) return [];
16055
16425
  return Object.entries(value).map(
16056
- ([name, entry]) => isRecord7(entry) ? { name, ...entry } : { name }
16426
+ ([name, entry]) => isRecord9(entry) ? { name, ...entry } : { name }
16057
16427
  );
16058
16428
  }
16059
16429
  function firstRawPath(entry) {
16060
- const details = isRecord7(entry.details) ? entry.details : {};
16430
+ const details = isRecord9(entry.details) ? entry.details : {};
16061
16431
  const paths = [
16062
16432
  ...asArray(details.rawToolOutputPaths),
16063
16433
  ...asArray(details.raw_tool_output_paths),
@@ -16075,12 +16445,12 @@ function checkHintRawPath(value) {
16075
16445
  function collectStaticPipelineToolIds(staticPipeline) {
16076
16446
  const seen = /* @__PURE__ */ new Set();
16077
16447
  const visitPipeline = (pipeline) => {
16078
- if (!isRecord7(pipeline)) return;
16448
+ if (!isRecord9(pipeline)) return;
16079
16449
  for (const step of [
16080
16450
  ...asArray(pipeline.stages),
16081
16451
  ...asArray(pipeline.substeps)
16082
16452
  ]) {
16083
- if (!isRecord7(step)) continue;
16453
+ if (!isRecord9(step)) continue;
16084
16454
  if (step.type === "tool") {
16085
16455
  const toolId = stringValue2(step.toolId) || stringValue2(step.tool);
16086
16456
  if (toolId) seen.add(toolId);
@@ -16094,9 +16464,9 @@ function collectStaticPipelineToolIds(staticPipeline) {
16094
16464
  return [...seen].sort();
16095
16465
  }
16096
16466
  function toolGetterHintFromMetadata(toolId, tool) {
16097
- const usageGuidance = isRecord7(tool.usageGuidance) ? tool.usageGuidance : {};
16098
- const resultGuidance = isRecord7(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord7(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
16099
- const toolResponse = isRecord7(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord7(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
16467
+ const usageGuidance = isRecord9(tool.usageGuidance) ? tool.usageGuidance : {};
16468
+ const resultGuidance = isRecord9(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord9(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
16469
+ const toolResponse = isRecord9(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord9(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
16100
16470
  const lists = extractionEntries2(
16101
16471
  resultGuidance.extractedLists ?? resultGuidance.extracted_lists
16102
16472
  ).map((entry) => ({
@@ -19483,6 +19853,9 @@ function compileEnrichConfigToPlaySource(config, options = {}) {
19483
19853
  const inlineTypeImports = [
19484
19854
  ...new Set(inlineHandlers.flatMap((inline) => inline.typeImports ?? []))
19485
19855
  ].sort();
19856
+ const inlineRuntimeImports = [
19857
+ ...new Set(inlineHandlers.flatMap((inline) => inline.runtimeImports ?? []))
19858
+ ].sort();
19486
19859
  config.commands.forEach((command) => {
19487
19860
  if (isWaterfall(command)) {
19488
19861
  columnSteps.push(
@@ -19558,7 +19931,7 @@ function compileEnrichConfigToPlaySource(config, options = {}) {
19558
19931
  const typeImports = idiomaticGetters ? inlineTypeImports : [.../* @__PURE__ */ new Set([...inlineTypeImports, "DeeplinePlayRuntimeContext"])].sort();
19559
19932
  return [
19560
19933
  ...inlineRunJavascript && configHasRunJavascript(config) ? ["// @ts-nocheck", "/* eslint-disable */", ""] : [],
19561
- `import { definePlay, steps } from 'deepline';`,
19934
+ `import { ${["definePlay", "steps", ...inlineRuntimeImports].join(", ")} } from 'deepline';`,
19562
19935
  ...typeImports.length > 0 ? [`import type { ${typeImports.join(", ")} } from 'deepline';`] : [],
19563
19936
  ``,
19564
19937
  `type EnrichInput = { file: string; rowStart?: number | null; rowEnd?: number | null };`,
@@ -20374,7 +20747,7 @@ function isMarkedTestAiInferenceCommand(command) {
20374
20747
  if (normalizeEnrichPlayRef(command.tool) !== "run_javascript") {
20375
20748
  return false;
20376
20749
  }
20377
- return isRecord8(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
20750
+ return isRecord10(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
20378
20751
  }
20379
20752
  function enrichDebugEnabled(env = process.env) {
20380
20753
  const raw = String(env.DEEPLINE_DEBUG_ENRICH ?? "").trim().toLowerCase();
@@ -20638,7 +21011,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
20638
21011
  if (Array.isArray(value)) {
20639
21012
  return value.map(rewrite);
20640
21013
  }
20641
- if (!isRecord8(value)) {
21014
+ if (!isRecord10(value)) {
20642
21015
  return value;
20643
21016
  }
20644
21017
  const next = Object.fromEntries(
@@ -20647,7 +21020,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
20647
21020
  key === "rerunCommand" && typeof entry === "string" ? enrichCommand : rewrite(entry)
20648
21021
  ])
20649
21022
  );
20650
- if (isRecord8(next.next) && typeof next.next.run === "string") {
21023
+ if (isRecord10(next.next) && typeof next.next.run === "string") {
20651
21024
  next.next = { ...next.next, run: enrichCommand };
20652
21025
  }
20653
21026
  return next;
@@ -21118,7 +21491,7 @@ async function resolveWatchedGeneratedPlayStatus(input2) {
21118
21491
  }
21119
21492
  return input2.client.runs.get(runId, { full: true });
21120
21493
  }
21121
- function isRecord8(value) {
21494
+ function isRecord10(value) {
21122
21495
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
21123
21496
  }
21124
21497
  async function captureStdout(run, options = {}) {
@@ -21370,15 +21743,15 @@ function readFirstEnrichDatasetActions(value) {
21370
21743
  return null;
21371
21744
  }
21372
21745
  const record = candidate;
21373
- const actions = isRecord8(record.actions) ? record.actions : null;
21374
- const currentQuery = isRecord8(actions?.queryCurrentTable) ? actions.queryCurrentTable : null;
21375
- const legacyQuery = isRecord8(actions?.query) ? actions.query : null;
21746
+ const actions = isRecord10(record.actions) ? record.actions : null;
21747
+ const currentQuery = isRecord10(actions?.queryCurrentTable) ? actions.queryCurrentTable : null;
21748
+ const legacyQuery = isRecord10(actions?.query) ? actions.query : null;
21376
21749
  const query = currentQuery?.kind === "deepline_db_query" ? currentQuery : legacyQuery?.kind === "deepline_db_query" ? legacyQuery : null;
21377
21750
  if (query?.kind === "deepline_db_query") {
21378
21751
  return {
21379
21752
  dataset: record,
21380
21753
  query,
21381
- ...isRecord8(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
21754
+ ...isRecord10(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
21382
21755
  };
21383
21756
  }
21384
21757
  if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
@@ -21431,7 +21804,7 @@ function enrichCustomerDbJson(input2) {
21431
21804
  const dataset = actions.dataset;
21432
21805
  const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
21433
21806
  const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
21434
- const api = isRecord8(query.api) ? query.api : null;
21807
+ const api = isRecord10(query.api) ? query.api : null;
21435
21808
  const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
21436
21809
  const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
21437
21810
  if (!datasetPath) {
@@ -21500,11 +21873,11 @@ function sqlStringLiteral(value) {
21500
21873
  return `'${value.replace(/'/g, "''")}'`;
21501
21874
  }
21502
21875
  function failureAliasFromCellMeta(cellMeta) {
21503
- if (!isRecord8(cellMeta)) {
21876
+ if (!isRecord10(cellMeta)) {
21504
21877
  return null;
21505
21878
  }
21506
21879
  for (const [alias, meta] of Object.entries(cellMeta)) {
21507
- if (!isRecord8(meta)) {
21880
+ if (!isRecord10(meta)) {
21508
21881
  continue;
21509
21882
  }
21510
21883
  const failure = failureCellFromMeta(meta, {});
@@ -21997,7 +22370,7 @@ function exportableSheetRow2(row, sourceRowStart = 0) {
21997
22370
  return fallback;
21998
22371
  }
21999
22372
  function failureCellFromMeta(meta, fallback) {
22000
- if (!isRecord8(meta)) {
22373
+ if (!isRecord10(meta)) {
22001
22374
  return null;
22002
22375
  }
22003
22376
  const status = typeof meta.status === "string" ? meta.status.trim().toLowerCase() : "";
@@ -22017,7 +22390,7 @@ function failureCellFromMeta(meta, fallback) {
22017
22390
  };
22018
22391
  }
22019
22392
  function applyFailureCellMeta(row, cellMeta, fallback) {
22020
- if (!isRecord8(cellMeta)) {
22393
+ if (!isRecord10(cellMeta)) {
22021
22394
  return;
22022
22395
  }
22023
22396
  for (const [field, meta] of Object.entries(cellMeta)) {
@@ -22245,7 +22618,7 @@ function stableRowSnapshot(value) {
22245
22618
  }
22246
22619
  function cellFailureError(value) {
22247
22620
  const parsed = parseMaybeJsonObject(value);
22248
- if (!isRecord8(parsed)) {
22621
+ if (!isRecord10(parsed)) {
22249
22622
  const text = typeof parsed === "string" ? parsed.trim() : "";
22250
22623
  if (/^(?:[A-Za-z0-9_:-]+:\s*)?(?:Error|TypeError|ReferenceError|SyntaxError|RangeError):\s+/.test(
22251
22624
  text
@@ -22253,12 +22626,12 @@ function cellFailureError(value) {
22253
22626
  return { message: text };
22254
22627
  }
22255
22628
  }
22256
- if (!isRecord8(parsed)) {
22629
+ if (!isRecord10(parsed)) {
22257
22630
  return null;
22258
22631
  }
22259
22632
  const status = typeof parsed.status === "string" ? parsed.status.trim().toLowerCase() : "";
22260
22633
  const directError = typeof parsed.error === "string" ? parsed.error.trim() : typeof parsed.last_error === "string" ? parsed.last_error.trim() : "";
22261
- const result = isRecord8(parsed.result) ? parsed.result : null;
22634
+ const result = isRecord10(parsed.result) ? parsed.result : null;
22262
22635
  const resultError = typeof result?.error === "string" ? result.error.trim() : typeof result?.message === "string" ? result.message.trim() : "";
22263
22636
  if (!directError && !resultError && status !== "error" && status !== "failed") {
22264
22637
  return null;
@@ -22328,7 +22701,7 @@ function assignFlattenedFailurePath(target, field, value) {
22328
22701
  let cursor = target;
22329
22702
  for (const part of normalized.slice(0, -1)) {
22330
22703
  const existing = cursor[part];
22331
- if (!isRecord8(existing)) {
22704
+ if (!isRecord10(existing)) {
22332
22705
  const next = {};
22333
22706
  cursor[part] = next;
22334
22707
  cursor = next;
@@ -22492,10 +22865,10 @@ function waterfallExecutionSignal(status, spec) {
22492
22865
  let everyChildStatOnlyConditionSkipped = true;
22493
22866
  const childAliasesWithStats = /* @__PURE__ */ new Set();
22494
22867
  for (const childAlias of childAliases) {
22495
- for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord8)) {
22868
+ for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord10)) {
22496
22869
  sawChildStats = true;
22497
22870
  childAliasesWithStats.add(childAlias);
22498
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
22871
+ const execution = isRecord10(stat2.execution) ? stat2.execution : null;
22499
22872
  const executedSummary = parseExecutionSummary(
22500
22873
  execution?.["completed:executed"]
22501
22874
  );
@@ -22525,7 +22898,7 @@ function waterfallExecutionSignal(status, spec) {
22525
22898
  }
22526
22899
  function emptyWaterfallStatsEvidence(status, spec) {
22527
22900
  const summaries = collectColumnStats(status);
22528
- const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord8);
22901
+ const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord10);
22529
22902
  for (const stat2 of parentStats) {
22530
22903
  const nonEmpty = parseExecutionSummary(stat2.non_empty);
22531
22904
  if (nonEmpty?.total && nonEmpty.count === 0) {
@@ -22539,7 +22912,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
22539
22912
  let selectedRows = 0;
22540
22913
  let sawStatsForEveryChild = true;
22541
22914
  for (const childAlias of childAliases) {
22542
- const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord8);
22915
+ const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord10);
22543
22916
  if (!stat2) {
22544
22917
  sawStatsForEveryChild = false;
22545
22918
  break;
@@ -22548,7 +22921,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
22548
22921
  if ((nonEmpty?.count ?? 0) > 0) {
22549
22922
  return null;
22550
22923
  }
22551
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
22924
+ const execution = isRecord10(stat2.execution) ? stat2.execution : null;
22552
22925
  const executed = parseExecutionSummary(execution?.["completed:executed"]);
22553
22926
  const reused = parseExecutionSummary(execution?.["completed:reused"]);
22554
22927
  const skipped = parseExecutionSummary(execution?.["skipped:condition"]);
@@ -22590,11 +22963,11 @@ function collectStatusFailureJobs(input2) {
22590
22963
  const jobs = [];
22591
22964
  aliases.forEach((spec, aliasIndex) => {
22592
22965
  const { alias } = spec;
22593
- const stat2 = summaries.map((summary) => summary[alias]).find(isRecord8);
22966
+ const stat2 = summaries.map((summary) => summary[alias]).find(isRecord10);
22594
22967
  if (!stat2) {
22595
22968
  return;
22596
22969
  }
22597
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
22970
+ const execution = isRecord10(stat2.execution) ? stat2.execution : null;
22598
22971
  const failedCount = Math.min(
22599
22972
  selectedRows,
22600
22973
  Math.max(
@@ -22701,10 +23074,10 @@ function collectColumnStats(status) {
22701
23074
  value.forEach(visit);
22702
23075
  return;
22703
23076
  }
22704
- if (!isRecord8(value)) {
23077
+ if (!isRecord10(value)) {
22705
23078
  return;
22706
23079
  }
22707
- if (isRecord8(value.columnStats)) {
23080
+ if (isRecord10(value.columnStats)) {
22708
23081
  summaries.push(value.columnStats);
22709
23082
  }
22710
23083
  Object.values(value).forEach(visit);
@@ -22716,12 +23089,12 @@ function firstAliasExecutionCounts(input2) {
22716
23089
  const aliases = collectConfigScalarAliasOrder(input2.config);
22717
23090
  const summaries = collectColumnStats(input2.status);
22718
23091
  for (const alias of aliases) {
22719
- const stat2 = summaries.map((summary) => summary[alias]).find(isRecord8);
23092
+ const stat2 = summaries.map((summary) => summary[alias]).find(isRecord10);
22720
23093
  if (!stat2) continue;
22721
23094
  if (input2.forceAliases.has(normalizeAlias2(alias))) {
22722
23095
  return { executed: input2.selectedRows, reused: 0 };
22723
23096
  }
22724
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
23097
+ const execution = isRecord10(stat2.execution) ? stat2.execution : null;
22725
23098
  if (!execution) continue;
22726
23099
  return {
22727
23100
  executed: parseExecutionCount(execution["completed:executed"]),
@@ -22748,14 +23121,14 @@ function rewriteEnrichJsonStatus(input2) {
22748
23121
  if (Array.isArray(value)) {
22749
23122
  return value.map(rewrite);
22750
23123
  }
22751
- if (!isRecord8(value)) {
23124
+ if (!isRecord10(value)) {
22752
23125
  return value;
22753
23126
  }
22754
23127
  const next = {};
22755
23128
  for (const [key, entry] of Object.entries(value)) {
22756
23129
  next[key] = rewrite(entry);
22757
23130
  }
22758
- if (isRecord8(next.progress)) {
23131
+ if (isRecord10(next.progress)) {
22759
23132
  next.progress = {
22760
23133
  ...next.progress,
22761
23134
  ...selectedRows > 0 ? { total: selectedRows } : {},
@@ -22764,8 +23137,8 @@ function rewriteEnrichJsonStatus(input2) {
22764
23137
  ...failedRows > 0 ? { failed: failedRows, pending: 0 } : {}
22765
23138
  };
22766
23139
  }
22767
- if (isRecord8(next.summary)) {
22768
- const rowCounts = isRecord8(next.summary.rowCounts) ? next.summary.rowCounts : null;
23140
+ if (isRecord10(next.summary)) {
23141
+ const rowCounts = isRecord10(next.summary.rowCounts) ? next.summary.rowCounts : null;
22769
23142
  if (failedRows > 0) {
22770
23143
  next.summary = {
22771
23144
  ...next.summary,
@@ -22778,11 +23151,11 @@ function rewriteEnrichJsonStatus(input2) {
22778
23151
  };
22779
23152
  }
22780
23153
  }
22781
- if (isRecord8(next.columnStats) && selectedRows > 0) {
23154
+ if (isRecord10(next.columnStats) && selectedRows > 0) {
22782
23155
  const columnStats = { ...next.columnStats };
22783
23156
  for (const alias of forcedAliases) {
22784
- const stat2 = isRecord8(columnStats[alias]) ? columnStats[alias] : null;
22785
- const execution = isRecord8(stat2?.execution) ? stat2.execution : null;
23157
+ const stat2 = isRecord10(columnStats[alias]) ? columnStats[alias] : null;
23158
+ const execution = isRecord10(stat2?.execution) ? stat2.execution : null;
22786
23159
  if (!stat2 || !execution) continue;
22787
23160
  columnStats[alias] = {
22788
23161
  ...stat2,
@@ -22801,14 +23174,14 @@ function rewriteEnrichJsonStatus(input2) {
22801
23174
  return next;
22802
23175
  };
22803
23176
  const rewritten = rewrite(input2.status);
22804
- if (failedRows === 0 || !isRecord8(rewritten)) {
23177
+ if (failedRows === 0 || !isRecord10(rewritten)) {
22805
23178
  return rewritten;
22806
23179
  }
22807
23180
  const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
22808
23181
  return {
22809
23182
  ...rewritten,
22810
23183
  ...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
22811
- ...isRecord8(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
23184
+ ...isRecord10(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
22812
23185
  };
22813
23186
  }
22814
23187
  function summarizeFailedJobError(value) {
@@ -23414,7 +23787,7 @@ function materializeCsvCellValue(value) {
23414
23787
  return value;
23415
23788
  }
23416
23789
  function compactArrayEnvelopeCompleteValue(value) {
23417
- if (!isRecord8(value) || value.kind !== "array") {
23790
+ if (!isRecord10(value) || value.kind !== "array") {
23418
23791
  return null;
23419
23792
  }
23420
23793
  if (!Array.isArray(value.preview)) {
@@ -23428,7 +23801,7 @@ function compactArrayEnvelopeCompleteValue(value) {
23428
23801
  }
23429
23802
  function disambiguateCompactAiInferencePayload(value) {
23430
23803
  const parsed = parseMaybeJsonObject(value);
23431
- if (!isRecord8(parsed) || !cellFailureError(parsed)) {
23804
+ if (!isRecord10(parsed) || !cellFailureError(parsed)) {
23432
23805
  return value;
23433
23806
  }
23434
23807
  return {
@@ -23437,14 +23810,14 @@ function disambiguateCompactAiInferencePayload(value) {
23437
23810
  };
23438
23811
  }
23439
23812
  function compactAiInferenceCellForCsv(value) {
23440
- if (!isRecord8(value)) {
23813
+ if (!isRecord10(value)) {
23441
23814
  return value;
23442
23815
  }
23443
23816
  const extractedJson = value.extracted_json;
23444
23817
  if (extractedJson !== null && extractedJson !== void 0) {
23445
23818
  return disambiguateCompactAiInferencePayload(extractedJson);
23446
23819
  }
23447
- const result = isRecord8(value.result) ? value.result : null;
23820
+ const result = isRecord10(value.result) ? value.result : null;
23448
23821
  const object = result?.object;
23449
23822
  if (object !== null && object !== void 0) {
23450
23823
  return disambiguateCompactAiInferencePayload(object);
@@ -23461,12 +23834,12 @@ function compactAiInferenceCellForCsv(value) {
23461
23834
  }
23462
23835
  function materializeEnrichAliasCellForCsv(row, alias, options) {
23463
23836
  const direct = row[alias];
23464
- if (isRecord8(direct)) {
23837
+ if (isRecord10(direct)) {
23465
23838
  const completeArray = compactArrayEnvelopeCompleteValue(direct);
23466
23839
  if (completeArray) {
23467
23840
  return materializeCsvCellValue(completeArray);
23468
23841
  }
23469
- if (options?.compactAiCell && direct.status === "completed" && (isRecord8(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
23842
+ if (options?.compactAiCell && direct.status === "completed" && (isRecord10(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
23470
23843
  return materializeCsvCellValue(compactAiInferenceCellForCsv(direct));
23471
23844
  }
23472
23845
  if (Object.prototype.hasOwnProperty.call(direct, "matched_result") || Object.prototype.hasOwnProperty.call(direct, "matchedResult") || Object.prototype.hasOwnProperty.call(direct, "result")) {
@@ -23607,11 +23980,11 @@ function normalizeEnrichRowsForCsvExport(rows, config, options) {
23607
23980
  }
23608
23981
  function legacyMetadataFromRow(row) {
23609
23982
  const direct = parseLegacyMetadataCell(row._metadata);
23610
- if (direct && isRecord8(direct.columns)) {
23983
+ if (direct && isRecord10(direct.columns)) {
23611
23984
  return direct;
23612
23985
  }
23613
23986
  const relocated = parseLegacyMetadataCell(row.metadata);
23614
- if (relocated && isRecord8(relocated.columns)) {
23987
+ if (relocated && isRecord10(relocated.columns)) {
23615
23988
  return relocated;
23616
23989
  }
23617
23990
  const flattenedColumns = parseLegacyMetadataCell(row["metadata.columns"]);
@@ -23628,7 +24001,7 @@ function legacyMetadataFromRow(row) {
23628
24001
  }
23629
24002
  function parseLegacyMetadataCell(value) {
23630
24003
  const parsed = parseMaybeJsonObject(value);
23631
- if (isRecord8(parsed)) {
24004
+ if (isRecord10(parsed)) {
23632
24005
  return parsed;
23633
24006
  }
23634
24007
  if (typeof value !== "string") {
@@ -23645,12 +24018,12 @@ function parseLegacyMetadataCell(value) {
23645
24018
  for (const candidate of candidates) {
23646
24019
  try {
23647
24020
  const decoded = JSON.parse(candidate);
23648
- if (isRecord8(decoded)) {
24021
+ if (isRecord10(decoded)) {
23649
24022
  return decoded;
23650
24023
  }
23651
24024
  if (typeof decoded === "string") {
23652
24025
  const nested = JSON.parse(decoded);
23653
- if (isRecord8(nested)) {
24026
+ if (isRecord10(nested)) {
23654
24027
  return nested;
23655
24028
  }
23656
24029
  }
@@ -23660,8 +24033,8 @@ function parseLegacyMetadataCell(value) {
23660
24033
  return null;
23661
24034
  }
23662
24035
  function mergeLegacyMetadataRecords(base, enriched) {
23663
- const baseColumns = isRecord8(base.columns) ? base.columns : null;
23664
- const enrichedColumns = isRecord8(enriched.columns) ? enriched.columns : null;
24036
+ const baseColumns = isRecord10(base.columns) ? base.columns : null;
24037
+ const enrichedColumns = isRecord10(enriched.columns) ? enriched.columns : null;
23665
24038
  const merged = {
23666
24039
  ...base,
23667
24040
  ...enriched
@@ -28115,7 +28488,7 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
28115
28488
  }
28116
28489
  function extractionContractEntries(entries) {
28117
28490
  return entries.flatMap((entry) => {
28118
- if (!isRecord9(entry)) return [];
28491
+ if (!isRecord11(entry)) return [];
28119
28492
  const name = stringField2(entry, "name");
28120
28493
  const expression = stringField2(entry, "expression");
28121
28494
  return name && expression ? [{ name, expression }] : [];
@@ -28136,7 +28509,7 @@ function printMonitorTypeFilters(tool) {
28136
28509
  }
28137
28510
  console.log("Deploy filters (set in the monitor payload):");
28138
28511
  for (const name of names) {
28139
- const field = isRecord9(properties[name]) ? properties[name] : {};
28512
+ const field = isRecord11(properties[name]) ? properties[name] : {};
28140
28513
  const star = required.has(name) ? "*" : "";
28141
28514
  const enumVals = arrayField2(field, "enum").filter(
28142
28515
  (v) => typeof v === "string"
@@ -28148,14 +28521,14 @@ function printMonitorTypeFilters(tool) {
28148
28521
  }
28149
28522
  function printMonitorTypeStreams(tool) {
28150
28523
  const streams = arrayField2(tool, "streams", "output_streams").filter(
28151
- isRecord9
28524
+ isRecord11
28152
28525
  );
28153
28526
  if (!streams.length) return;
28154
28527
  console.log("");
28155
28528
  console.log("Filter columns (a play's sqlListeners.where, per stream):");
28156
28529
  for (const stream of streams) {
28157
28530
  const name = stringField2(stream, "stream");
28158
- const cols = arrayField2(stream, "columns").filter(isRecord9).map((col) => stringField2(col, "name")).filter(Boolean);
28531
+ const cols = arrayField2(stream, "columns").filter(isRecord11).map((col) => stringField2(col, "name")).filter(Boolean);
28159
28532
  console.log(`- ${name}: ${cols.join(", ")}`);
28160
28533
  }
28161
28534
  }
@@ -28173,7 +28546,7 @@ function printMonitorTypePricing(tool) {
28173
28546
  }
28174
28547
  console.log("Pricing (Deepline credits per accepted event):");
28175
28548
  for (const key of keys) {
28176
- const entry = isRecord9(byType[key]) ? byType[key] : {};
28549
+ const entry = isRecord11(byType[key]) ? byType[key] : {};
28177
28550
  const credits = numberField2(entry, "deepline_credits", "deeplineCredits");
28178
28551
  const display = stringField2(entry, "display");
28179
28552
  const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "see --json");
@@ -28218,8 +28591,8 @@ function printCompactToolContract(tool, requestedToolId) {
28218
28591
  return;
28219
28592
  }
28220
28593
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
28221
- const cost = isRecord9(contract.cost) ? contract.cost : {};
28222
- const getters = isRecord9(contract.getters) ? contract.getters : {};
28594
+ const cost = isRecord11(contract.cost) ? contract.cost : {};
28595
+ const getters = isRecord11(contract.getters) ? contract.getters : {};
28223
28596
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
28224
28597
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
28225
28598
  const inputFields = recursiveToolInputFieldsForDisplay(
@@ -28238,7 +28611,7 @@ function printCompactToolContract(tool, requestedToolId) {
28238
28611
  console.log("");
28239
28612
  console.log("Inputs:");
28240
28613
  for (const field of inputFields) {
28241
- if (!isRecord9(field)) continue;
28614
+ if (!isRecord11(field)) continue;
28242
28615
  const name = stringField2(field, "name");
28243
28616
  if (!name) continue;
28244
28617
  const required = field.required ? "*" : "";
@@ -28257,7 +28630,7 @@ function printCompactToolContract(tool, requestedToolId) {
28257
28630
  }
28258
28631
  console.log("");
28259
28632
  printToolExamplesOnly(tool, requestedToolId, { includeSamples: false });
28260
- const starterScript = isRecord9(contract.starterScript) ? contract.starterScript : {};
28633
+ const starterScript = isRecord11(contract.starterScript) ? contract.starterScript : {};
28261
28634
  const starterPath = stringField2(starterScript, "path");
28262
28635
  if (starterPath) {
28263
28636
  console.log("");
@@ -28271,14 +28644,14 @@ function printCompactToolContract(tool, requestedToolId) {
28271
28644
  console.log("Getters:");
28272
28645
  if (listGetters.length) console.log("Lists:");
28273
28646
  for (const entry of listGetters) {
28274
- if (isRecord9(entry))
28647
+ if (isRecord11(entry))
28275
28648
  console.log(
28276
28649
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
28277
28650
  );
28278
28651
  }
28279
28652
  if (valueGetters.length) console.log("Values:");
28280
28653
  for (const entry of valueGetters) {
28281
- if (isRecord9(entry))
28654
+ if (isRecord11(entry))
28282
28655
  console.log(
28283
28656
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
28284
28657
  );
@@ -28295,7 +28668,7 @@ function printToolPricingOnly(tool, requestedToolId, options = {}) {
28295
28668
  return;
28296
28669
  }
28297
28670
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
28298
- const cost = isRecord9(contract.cost) ? contract.cost : {};
28671
+ const cost = isRecord11(contract.cost) ? contract.cost : {};
28299
28672
  const pricingModel = stringField2(cost, "pricingModel") || "unknown";
28300
28673
  const billingMode = stringField2(cost, "billingMode") || "unknown";
28301
28674
  const unit = pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit";
@@ -28367,10 +28740,10 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
28367
28740
  ` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
28368
28741
  );
28369
28742
  console.log("});");
28370
- const getters = isRecord9(contract.getters) ? contract.getters : {};
28743
+ const getters = isRecord11(contract.getters) ? contract.getters : {};
28371
28744
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
28372
28745
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
28373
- const firstGetter = [...valueGetters, ...listGetters].find(isRecord9);
28746
+ const firstGetter = [...valueGetters, ...listGetters].find(isRecord11);
28374
28747
  if (firstGetter) {
28375
28748
  const name = stringField2(firstGetter, "name") || "value";
28376
28749
  const expression = stringField2(firstGetter, "expression");
@@ -28406,7 +28779,7 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
28406
28779
  }
28407
28780
  function printToolGettersOnly(tool, requestedToolId) {
28408
28781
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
28409
- const getters = isRecord9(contract.getters) ? contract.getters : {};
28782
+ const getters = isRecord11(contract.getters) ? contract.getters : {};
28410
28783
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
28411
28784
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
28412
28785
  console.log(`Getters: ${contract.toolId}`);
@@ -28419,7 +28792,7 @@ function printToolGettersOnly(tool, requestedToolId) {
28419
28792
  if (listGetters.length) {
28420
28793
  console.log("Lists:");
28421
28794
  for (const entry of listGetters) {
28422
- if (isRecord9(entry))
28795
+ if (isRecord11(entry))
28423
28796
  console.log(
28424
28797
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
28425
28798
  );
@@ -28428,7 +28801,7 @@ function printToolGettersOnly(tool, requestedToolId) {
28428
28801
  if (valueGetters.length) {
28429
28802
  console.log("Values:");
28430
28803
  for (const entry of valueGetters) {
28431
- if (isRecord9(entry))
28804
+ if (isRecord11(entry))
28432
28805
  console.log(
28433
28806
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
28434
28807
  );
@@ -28454,7 +28827,7 @@ function sampleValueForField(field) {
28454
28827
  function samplePayloadForInputFields(fields) {
28455
28828
  return Object.fromEntries(
28456
28829
  fields.slice(0, 4).flatMap((field) => {
28457
- if (!isRecord9(field)) return [];
28830
+ if (!isRecord11(field)) return [];
28458
28831
  const name = stringField2(field, "name");
28459
28832
  if (!name) return [];
28460
28833
  return [[name, sampleValueForField(field)]];
@@ -28572,12 +28945,12 @@ function formatListedToolCost(tool) {
28572
28945
  }
28573
28946
  function toolInputFieldsForDisplay(inputSchema) {
28574
28947
  if (Array.isArray(inputSchema.fields))
28575
- return inputSchema.fields.filter(isRecord9);
28576
- const jsonSchema = isRecord9(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
28577
- const properties = isRecord9(jsonSchema.properties) ? jsonSchema.properties : {};
28948
+ return inputSchema.fields.filter(isRecord11);
28949
+ const jsonSchema = isRecord11(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
28950
+ const properties = isRecord11(jsonSchema.properties) ? jsonSchema.properties : {};
28578
28951
  const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
28579
28952
  return Object.entries(properties).map(([name, value]) => {
28580
- const property = isRecord9(value) ? value : {};
28953
+ const property = isRecord11(value) ? value : {};
28581
28954
  return {
28582
28955
  name,
28583
28956
  type: typeof property.type === "string" ? property.type : "unknown",
@@ -28588,10 +28961,10 @@ function toolInputFieldsForDisplay(inputSchema) {
28588
28961
  });
28589
28962
  }
28590
28963
  function canonicalToolJsonSchema(inputSchema) {
28591
- return isRecord9(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
28964
+ return isRecord11(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
28592
28965
  }
28593
28966
  function declaredToolJsonSchema(inputSchema) {
28594
- if (isRecord9(inputSchema.jsonSchema)) {
28967
+ if (isRecord11(inputSchema.jsonSchema)) {
28595
28968
  return inputSchema.jsonSchema;
28596
28969
  }
28597
28970
  return Array.isArray(inputSchema.fields) ? null : inputSchema;
@@ -28616,7 +28989,7 @@ function publicToolInputSchemaForDescribe(inputSchema) {
28616
28989
  };
28617
28990
  const stripDescriptions = (value) => {
28618
28991
  if (Array.isArray(value)) return value.map(stripDescriptions);
28619
- if (!isRecord9(value)) return value;
28992
+ if (!isRecord11(value)) return value;
28620
28993
  return Object.fromEntries(
28621
28994
  Object.entries(value).flatMap(([key, nested]) => {
28622
28995
  if (key === "description" && typeof nested === "string" && exposesProviderSpend(nested)) {
@@ -28637,7 +29010,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
28637
29010
  for (const item of value) collectSchemaIds(item);
28638
29011
  return;
28639
29012
  }
28640
- if (!isRecord9(value)) return;
29013
+ if (!isRecord11(value)) return;
28641
29014
  if (typeof value.$id === "string" && value.$id.trim()) {
28642
29015
  schemasById.set(value.$id.trim(), value);
28643
29016
  }
@@ -28650,10 +29023,10 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
28650
29023
  let current = root;
28651
29024
  for (const rawSegment of ref.slice(2).split("/")) {
28652
29025
  const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
28653
- if (!isRecord9(current)) return schema;
29026
+ if (!isRecord11(current)) return schema;
28654
29027
  current = current[segment];
28655
29028
  }
28656
- return isRecord9(current) ? current : schema;
29029
+ return isRecord11(current) ? current : schema;
28657
29030
  };
28658
29031
  const addField = (field) => {
28659
29032
  const name = typeof field.name === "string" ? field.name : "";
@@ -28668,7 +29041,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
28668
29041
  if (ref && activeRefs.has(ref)) return;
28669
29042
  const schema = resolveRef(unresolvedSchema);
28670
29043
  const nextActiveRefs = ref ? /* @__PURE__ */ new Set([...activeRefs, ref]) : activeRefs;
28671
- const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type : isRecord9(schema.properties) ? "object" : schema.items ? "array" : "unknown";
29044
+ const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type : isRecord11(schema.properties) ? "object" : schema.items ? "array" : "unknown";
28672
29045
  if (path) {
28673
29046
  addField({
28674
29047
  name: path,
@@ -28679,12 +29052,12 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
28679
29052
  ...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
28680
29053
  });
28681
29054
  }
28682
- const properties = isRecord9(schema.properties) ? schema.properties : {};
29055
+ const properties = isRecord11(schema.properties) ? schema.properties : {};
28683
29056
  const requiredNames = new Set(
28684
29057
  Array.isArray(schema.required) ? schema.required.map(String) : []
28685
29058
  );
28686
29059
  for (const [name, value] of Object.entries(properties)) {
28687
- if (!isRecord9(value)) continue;
29060
+ if (!isRecord11(value)) continue;
28688
29061
  visit(
28689
29062
  value,
28690
29063
  path ? `${path}.${name}` : name,
@@ -28692,13 +29065,13 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
28692
29065
  nextActiveRefs
28693
29066
  );
28694
29067
  }
28695
- if (isRecord9(schema.items)) {
29068
+ if (isRecord11(schema.items)) {
28696
29069
  visit(schema.items, `${path}[]`, false, nextActiveRefs);
28697
29070
  }
28698
29071
  for (const keyword of ["anyOf", "oneOf", "allOf"]) {
28699
29072
  const branches = Array.isArray(schema[keyword]) ? schema[keyword] : [];
28700
29073
  for (const branch of branches) {
28701
- if (isRecord9(branch)) {
29074
+ if (isRecord11(branch)) {
28702
29075
  visit(branch, path, required, nextActiveRefs);
28703
29076
  }
28704
29077
  }
@@ -28726,14 +29099,14 @@ function printJsonPreview(label, payload) {
28726
29099
  }
28727
29100
  function samplePayload(samples, key) {
28728
29101
  const entry = samples[key];
28729
- if (!isRecord9(entry)) return void 0;
29102
+ if (!isRecord11(entry)) return void 0;
28730
29103
  return Object.prototype.hasOwnProperty.call(entry, "payload") ? entry.payload : entry;
28731
29104
  }
28732
29105
  function commandEnvelopeFromRawResponse(rawResponse) {
28733
- return isRecord9(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
29106
+ return isRecord11(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
28734
29107
  }
28735
29108
  function apifySyncRecoveryNext(rawResponse) {
28736
- if (!isRecord9(rawResponse) || rawResponse.status !== "running") return null;
29109
+ if (!isRecord11(rawResponse) || rawResponse.status !== "running") return null;
28737
29110
  const toolResponse = recordField2(rawResponse, "toolResponse");
28738
29111
  const raw = recordField2(toolResponse, "raw");
28739
29112
  if (raw.state !== "awaiting_apify") return null;
@@ -28756,7 +29129,7 @@ function apifySyncRecoveryNext(rawResponse) {
28756
29129
  }
28757
29130
  function listExtractorPathsFromUsageGuidance(tool) {
28758
29131
  const toolExecutionResult = tool.usageGuidance?.toolExecutionResult;
28759
- const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord9(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
29132
+ const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord11(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
28760
29133
  return extractedLists.flatMap((entry) => {
28761
29134
  const paths = entry.details?.candidatePaths ?? entry.details?.rawToolOutputPaths;
28762
29135
  if (!Array.isArray(paths)) return [];
@@ -28772,7 +29145,7 @@ function formatDecimal(value) {
28772
29145
  function formatUsd(value) {
28773
29146
  return `$${formatDecimal(value)}`;
28774
29147
  }
28775
- function isRecord9(value) {
29148
+ function isRecord11(value) {
28776
29149
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
28777
29150
  }
28778
29151
  function stringField2(source, ...keys) {
@@ -28799,7 +29172,7 @@ function arrayField2(source, ...keys) {
28799
29172
  function recordField2(source, ...keys) {
28800
29173
  for (const key of keys) {
28801
29174
  const value = source[key];
28802
- if (isRecord9(value)) return value;
29175
+ if (isRecord11(value)) return value;
28803
29176
  }
28804
29177
  return {};
28805
29178
  }
@@ -28865,7 +29238,7 @@ function parseJsonObjectArgument(raw, flagName) {
28865
29238
  }
28866
29239
  throw invalidJsonError(flagName, message);
28867
29240
  }
28868
- if (!isRecord9(parsed)) {
29241
+ if (!isRecord11(parsed)) {
28869
29242
  throw invalidJsonError(flagName, "expected an object.");
28870
29243
  }
28871
29244
  return parsed;
@@ -29012,7 +29385,7 @@ function buildToolExecuteBaseEnvelope(input2) {
29012
29385
  kind: summaryEntries.length > 0 ? "object" : "raw",
29013
29386
  summary: input2.summary
29014
29387
  };
29015
- const envelopeHasCanonicalOutput = isRecord9(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
29388
+ const envelopeHasCanonicalOutput = isRecord11(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
29016
29389
  const envelopeHasDeclaredOutput = Object.prototype.hasOwnProperty.call(
29017
29390
  envelope,
29018
29391
  "output"
@@ -29242,7 +29615,7 @@ async function executeTool(args) {
29242
29615
  {
29243
29616
  ...baseEnvelope,
29244
29617
  local: {
29245
- ...isRecord9(baseEnvelope.local) ? baseEnvelope.local : {},
29618
+ ...isRecord11(baseEnvelope.local) ? baseEnvelope.local : {},
29246
29619
  payload_file: jsonPath
29247
29620
  }
29248
29621
  },