deepline 0.1.181 → 0.1.183

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 (70) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/child-play-await.ts +203 -6
  2. package/dist/bundling-sources/apps/play-runner-workers/src/child-play-submit.ts +8 -1
  3. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +633 -107
  4. package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +3 -2
  5. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +1932 -1838
  6. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +116 -0
  7. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +542 -78
  8. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/output-datasets.ts +124 -12
  9. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/receipts.ts +292 -11
  10. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/run-work-dispatcher.ts +519 -0
  11. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +2381 -0
  12. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-receipts.ts +18 -5
  13. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/work-budget.ts +130 -0
  14. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/worker-platform-budget.ts +39 -0
  15. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +2 -0
  16. package/dist/bundling-sources/sdk/src/client.ts +48 -5
  17. package/dist/bundling-sources/sdk/src/http.ts +23 -8
  18. package/dist/bundling-sources/sdk/src/play.ts +200 -26
  19. package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +56 -3
  20. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  21. package/dist/bundling-sources/sdk/src/types.ts +2 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +132 -10
  23. package/dist/bundling-sources/shared_libs/play-runtime/auth-scope-resolver.ts +92 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/batch-runtime.ts +4 -4
  25. package/dist/bundling-sources/shared_libs/play-runtime/batching-types.ts +8 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/child-run-id.ts +101 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1857 -314
  28. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +106 -6
  29. package/dist/bundling-sources/shared_libs/play-runtime/dedup-backend.ts +0 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/default-batch-strategies.ts +1 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/durability-store.ts +4 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +116 -16
  33. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +186 -20
  34. package/dist/bundling-sources/shared_libs/play-runtime/dynamic-worker-version.ts +2 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/execution-ledger-store.ts +133 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +245 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +5 -5
  38. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +14 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/lease-policy.ts +52 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +41 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +3 -2
  42. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +120 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +124 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +6 -2
  45. package/dist/bundling-sources/shared_libs/play-runtime/row-isolation.ts +48 -2
  46. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +158 -15
  47. package/dist/bundling-sources/shared_libs/play-runtime/run-terminal-source.ts +45 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +9 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +2037 -262
  50. package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +42 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-attempt-state-machine.ts +183 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-errors.ts +88 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +8 -1
  54. package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +103 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +19 -1
  56. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +343 -0
  57. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +43 -0
  58. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +11 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +139 -17
  60. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +437 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +83 -6
  62. package/dist/bundling-sources/shared_libs/security/safe-outbound-fetch.ts +24 -17
  63. package/dist/cli/index.js +85 -23
  64. package/dist/cli/index.mjs +85 -23
  65. package/dist/index.d.mts +4 -1
  66. package/dist/index.d.ts +4 -1
  67. package/dist/index.js +274 -35
  68. package/dist/index.mjs +274 -35
  69. package/dist/plays/bundle-play-file.mjs +2 -2
  70. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -352,10 +352,10 @@ var SDK_RELEASE = {
352
352
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
353
353
  // fields shipped in 0.1.153.
354
354
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
355
- version: "0.1.181",
355
+ version: "0.1.183",
356
356
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
357
357
  supportPolicy: {
358
- latest: "0.1.181",
358
+ latest: "0.1.183",
359
359
  minimumSupported: "0.1.53",
360
360
  deprecatedBelow: "0.1.53",
361
361
  commandMinimumSupported: [
@@ -513,6 +513,10 @@ var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
513
513
  var RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER = "x-deepline-runtime-scheduler-schema";
514
514
  var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
515
515
 
516
+ // ../shared_libs/play-runtime/test-runtime-seams.ts
517
+ var PLAY_RUNTIME_TEST_FAULT_HEADER = "x-deepline-test-fault";
518
+ var MAX_RUNTIME_TEST_POLICY_MS = 10 * 6e4;
519
+
516
520
  // src/http.ts
517
521
  var MAX_DIAGNOSTIC_HEADER_LENGTH = 120;
518
522
  var COWORK_NETWORK_HINT = "Claude Cowork appears to be running Deepline in a network-restricted sandbox. In Claude Desktop, open Settings > Capabilities, turn on Allow network egress, and set Domain allowlist to All domains for the Cowork session.";
@@ -627,12 +631,9 @@ var HttpClient = class {
627
631
  headers["x-deepline-play-artifact-r2-prefix"] = playArtifactR2Prefix;
628
632
  }
629
633
  const coordinatorUrl = typeof process !== "undefined" ? process.env?.DEEPLINE_COORDINATOR_URL : void 0;
634
+ const coordinatorInternalToken = typeof process !== "undefined" ? process.env?.DEEPLINE_INTERNAL_TOKEN : void 0;
630
635
  if (coordinatorUrl?.trim()) {
631
636
  headers[COORDINATOR_URL_OVERRIDE_HEADER] = coordinatorUrl.trim();
632
- const coordinatorInternalToken = typeof process !== "undefined" ? process.env?.DEEPLINE_INTERNAL_TOKEN : void 0;
633
- if (coordinatorInternalToken?.trim()) {
634
- headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
635
- }
636
637
  }
637
638
  const workerCallbackUrl = typeof process !== "undefined" ? process.env?.DEEPLINE_WORKER_CALLBACK_URL : void 0;
638
639
  if (workerCallbackUrl?.trim()) {
@@ -646,6 +647,13 @@ var HttpClient = class {
646
647
  if (syntheticRun && syntheticRun.trim() && syntheticRun.trim() !== "0") {
647
648
  headers[SYNTHETIC_RUN_HEADER] = "1";
648
649
  }
650
+ const runtimeTestFault = typeof process !== "undefined" ? process.env?.DEEPLINE_TEST_RUNTIME_FAULT : void 0;
651
+ if (runtimeTestFault?.trim()) {
652
+ headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
653
+ }
654
+ if (coordinatorInternalToken?.trim() && (coordinatorUrl?.trim() || workerCallbackUrl?.trim() || runtimeTestFault?.trim())) {
655
+ headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
656
+ }
649
657
  return headers;
650
658
  }
651
659
  /**
@@ -1059,6 +1067,20 @@ function resolveTimingWindow(input) {
1059
1067
  };
1060
1068
  }
1061
1069
 
1070
+ // ../shared_libs/play-runtime/run-terminal-source.ts
1071
+ var PLAY_RUN_LEDGER_EVENT_SOURCES = [
1072
+ "worker",
1073
+ "temporal",
1074
+ "convex",
1075
+ "coordinator",
1076
+ "system"
1077
+ ];
1078
+ function normalizePlayRunLedgerTerminalSource(value) {
1079
+ return PLAY_RUN_LEDGER_EVENT_SOURCES.includes(
1080
+ value
1081
+ ) ? value : null;
1082
+ }
1083
+
1062
1084
  // ../shared_libs/play-runtime/run-ledger.ts
1063
1085
  var LOG_TAIL_LIMIT = 100;
1064
1086
  function isRecord(value) {
@@ -1195,7 +1217,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
1195
1217
  ),
1196
1218
  resultTableNamespace: optionalNullableString(value.resultTableNamespace),
1197
1219
  resultSummary: value.resultSummary,
1198
- result: value.result
1220
+ result: value.result,
1221
+ terminalSource: normalizePlayRunLedgerTerminalSource(value.terminalSource)
1199
1222
  };
1200
1223
  }
1201
1224
  function normalizeStepStatus(value) {
@@ -1920,6 +1943,33 @@ function resolvePlayRunIntegrationMode(request) {
1920
1943
  request.integrationMode ?? process.env.DEEPLINE_EVAL_INTEGRATION_MODE
1921
1944
  );
1922
1945
  }
1946
+ function normalizeTestPolicyOverrides(value, source) {
1947
+ if (value && typeof value === "object" && !Array.isArray(value)) {
1948
+ return value;
1949
+ }
1950
+ throw new DeeplineError(
1951
+ `${source} must be a JSON object.`,
1952
+ void 0,
1953
+ "INVALID_TEST_POLICY_OVERRIDES"
1954
+ );
1955
+ }
1956
+ function parseEnvTestPolicyOverrides() {
1957
+ const raw = typeof process !== "undefined" ? process.env?.DEEPLINE_TEST_POLICY_OVERRIDES : void 0;
1958
+ const trimmed = raw?.trim();
1959
+ if (!trimmed) return void 0;
1960
+ let parsed;
1961
+ try {
1962
+ parsed = JSON.parse(trimmed);
1963
+ } catch (error) {
1964
+ const detail = error instanceof Error ? ` ${error.message}` : "";
1965
+ throw new DeeplineError(
1966
+ `DEEPLINE_TEST_POLICY_OVERRIDES must be valid JSON.${detail}`,
1967
+ void 0,
1968
+ "INVALID_TEST_POLICY_OVERRIDES"
1969
+ );
1970
+ }
1971
+ return normalizeTestPolicyOverrides(parsed, "DEEPLINE_TEST_POLICY_OVERRIDES");
1972
+ }
1923
1973
  function sleep2(ms) {
1924
1974
  return new Promise((resolve2) => setTimeout(resolve2, ms));
1925
1975
  }
@@ -2471,11 +2521,14 @@ var DeeplineClient = class {
2471
2521
  const headers = {
2472
2522
  [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
2473
2523
  ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
2474
- ...options?.responseIntent ? { [EXECUTE_RESPONSE_INTENT_HEADER]: options.responseIntent } : {}
2524
+ [EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
2475
2525
  };
2476
2526
  return this.http.post(
2477
2527
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
2478
- { payload: input },
2528
+ {
2529
+ payload: input,
2530
+ ...options?.metadata ? { metadata: options.metadata } : {}
2531
+ },
2479
2532
  headers,
2480
2533
  {
2481
2534
  forbiddenAsApiError: true,
@@ -2559,6 +2612,7 @@ var DeeplineClient = class {
2559
2612
  */
2560
2613
  async startPlayRun(request) {
2561
2614
  const integrationMode = resolvePlayRunIntegrationMode(request);
2615
+ const testPolicyOverrides = request.testPolicyOverrides ?? parseEnvTestPolicyOverrides();
2562
2616
  const forceToolRefresh = request.forceToolRefresh === true;
2563
2617
  const response = await this.http.post(
2564
2618
  "/api/v2/plays/run",
@@ -2586,7 +2640,8 @@ var DeeplineClient = class {
2586
2640
  // defaults to workers_edge; tests and runtime probes that want a
2587
2641
  // different profile pass `request.profile` explicitly.
2588
2642
  ...request.profile ? { profile: request.profile } : {},
2589
- ...integrationMode ? { integrationMode } : {}
2643
+ ...integrationMode ? { integrationMode } : {},
2644
+ ...testPolicyOverrides ? { testPolicyOverrides } : {}
2590
2645
  }
2591
2646
  );
2592
2647
  return normalizePlayRunStart(response);
@@ -2604,6 +2659,7 @@ var DeeplineClient = class {
2604
2659
  */
2605
2660
  async *startPlayRunStream(request, options) {
2606
2661
  const integrationMode = resolvePlayRunIntegrationMode(request);
2662
+ const testPolicyOverrides = request.testPolicyOverrides ?? parseEnvTestPolicyOverrides();
2607
2663
  const forceToolRefresh = request.forceToolRefresh === true;
2608
2664
  const body = {
2609
2665
  ...request.name ? { name: request.name } : {},
@@ -2626,7 +2682,8 @@ var DeeplineClient = class {
2626
2682
  ...forceToolRefresh ? { forceToolRefresh: true } : {},
2627
2683
  ...typeof request.waitForCompletionMs === "number" ? { waitForCompletionMs: request.waitForCompletionMs } : {},
2628
2684
  ...request.profile ? { profile: request.profile } : {},
2629
- ...integrationMode ? { integrationMode } : {}
2685
+ ...integrationMode ? { integrationMode } : {},
2686
+ ...testPolicyOverrides ? { testPolicyOverrides } : {}
2630
2687
  };
2631
2688
  for await (const event of this.http.streamSse(
2632
2689
  "/api/v2/plays/run?stream=true",
@@ -5280,6 +5337,73 @@ function createToolExecuteResult(input) {
5280
5337
  });
5281
5338
  return wrapper;
5282
5339
  }
5340
+ function attachToolResultListDataset(result, input) {
5341
+ const existing = result._metadata.lists[input.name];
5342
+ result._metadata.lists[input.name] = {
5343
+ path: input.path,
5344
+ count: input.count,
5345
+ keys: input.keys ?? existing?.keys ?? {}
5346
+ };
5347
+ const accessor = {
5348
+ path: input.path,
5349
+ count: input.count,
5350
+ keys: result._metadata.lists[input.name].keys
5351
+ };
5352
+ Object.defineProperty(accessor, "get", {
5353
+ value() {
5354
+ return input.dataset;
5355
+ },
5356
+ enumerable: false
5357
+ });
5358
+ result.extractedLists[input.name] = accessor;
5359
+ const serialized = input.dataset.toJSON();
5360
+ let root = { toolResponse: { raw: result.toolResponse.raw } };
5361
+ const candidates = [...candidateResultPaths(input.path)].filter(
5362
+ (candidate, index, all) => all.indexOf(candidate) === index
5363
+ );
5364
+ for (const candidate of candidates) {
5365
+ if (!Array.isArray(getAtPath(root, candidate))) continue;
5366
+ root = replaceAtPath(root, candidate, serialized.preview);
5367
+ break;
5368
+ }
5369
+ if (isRecord4(root) && isRecord4(root.toolResponse) && Object.prototype.hasOwnProperty.call(root.toolResponse, "raw")) {
5370
+ result.toolResponse.raw = root.toolResponse.raw;
5371
+ result.toolOutput.raw = root.toolResponse.raw;
5372
+ }
5373
+ return result;
5374
+ }
5375
+ function replaceAtPath(root, path, replacement) {
5376
+ const segments = parsePath(path);
5377
+ if (segments.length === 0 || segments.includes("*")) return root;
5378
+ const replace = (current, index) => {
5379
+ if (index >= segments.length) return replacement;
5380
+ const segment = segments[index];
5381
+ if (typeof segment === "number") {
5382
+ if (!Array.isArray(current)) return current;
5383
+ const copy = [...current];
5384
+ copy[segment] = replace(copy[segment], index + 1);
5385
+ return copy;
5386
+ }
5387
+ if (!isRecord4(current)) return current;
5388
+ return {
5389
+ ...current,
5390
+ [segment]: replace(current[segment], index + 1)
5391
+ };
5392
+ };
5393
+ return replace(root, 0);
5394
+ }
5395
+
5396
+ // ../shared_libs/play-runtime/query-result-dataset.ts
5397
+ var QUERY_RESULT_DATASET_PAGE_SIZE = 1e3;
5398
+ function isCustomerDbDatasetTool(toolId) {
5399
+ return /^(?:customer_db_)?query_customer_db$/.test(toolId);
5400
+ }
5401
+ function isSnowflakeQueryDatasetTool(toolId) {
5402
+ return /^snowflake_(?:snowflake_)?run_(?:semantic_)?query$/.test(toolId);
5403
+ }
5404
+ function isQueryResultDatasetTool(toolId) {
5405
+ return isCustomerDbDatasetTool(toolId) || isSnowflakeQueryDatasetTool(toolId);
5406
+ }
5283
5407
 
5284
5408
  // src/play.ts
5285
5409
  var DeeplineConditionalStepResolver = class _DeeplineConditionalStepResolver {
@@ -5455,9 +5579,13 @@ var DeeplineContext = class {
5455
5579
  /** Execute a tool and return the standard execution envelope. */
5456
5580
  execute: async (toolId, input) => {
5457
5581
  const response = await this.client.executeTool(toolId, input, {
5458
- includeToolMetadata: true
5582
+ includeToolMetadata: true,
5583
+ responseIntent: "dataset"
5584
+ });
5585
+ return toolExecutionEnvelopeToResult(toolId, response, {
5586
+ client: this.client,
5587
+ input
5459
5588
  });
5460
- return toolExecutionEnvelopeToResult(toolId, response);
5461
5589
  }
5462
5590
  };
5463
5591
  }
@@ -5652,32 +5780,143 @@ function extractorDescriptorRecord(value) {
5652
5780
  })
5653
5781
  );
5654
5782
  }
5655
- function toolExecutionEnvelopeToResult(fallbackToolId, response) {
5783
+ function rowsFromUnknown(value) {
5784
+ if (!Array.isArray(value)) return [];
5785
+ return value.map((row) => isRecord5(row) ? row : { value: row });
5786
+ }
5787
+ function finiteNonNegativeInteger(value) {
5788
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
5789
+ return null;
5790
+ }
5791
+ return Math.floor(value);
5792
+ }
5793
+ function finitePositiveInteger(value) {
5794
+ const integer = finiteNonNegativeInteger(value);
5795
+ return integer !== null && integer > 0 ? integer : null;
5796
+ }
5797
+ function stableHash(value) {
5798
+ let hash = 0;
5799
+ for (let index = 0; index < value.length; index += 1) {
5800
+ hash = Math.imul(31, hash) + value.charCodeAt(index);
5801
+ hash |= 0;
5802
+ }
5803
+ return Math.abs(hash).toString(36);
5804
+ }
5805
+ function attachSdkQueryResultDatasetResult(toolId, result, options) {
5806
+ if (!options || !isQueryResultDatasetTool(toolId)) return result;
5807
+ const raw = isRecord5(result.toolResponse.raw) ? result.toolResponse.raw : null;
5808
+ const dataset = isRecord5(raw?.dataset) ? raw.dataset : null;
5809
+ const totalRows = finiteNonNegativeInteger(dataset?.total_rows);
5810
+ const sql = typeof options.input.sql === "string" ? options.input.sql : typeof options.input.query === "string" ? options.input.query : typeof raw?.sql === "string" ? raw.sql : null;
5811
+ if (!dataset || totalRows === null || !sql) {
5812
+ return result;
5813
+ }
5814
+ const datasetLimit = finitePositiveInteger(dataset.returned_limit) ?? totalRows;
5815
+ const previewRows = rowsFromUnknown(raw?.rows).slice(0, 25);
5816
+ const fetchPage = async (offset, limit) => {
5817
+ if (limit <= 0 || offset >= totalRows) return [];
5818
+ const response = await options.client.executeTool(toolId, options.input, {
5819
+ includeToolMetadata: true,
5820
+ responseIntent: "dataset",
5821
+ metadata: {
5822
+ query_result_dataset: {
5823
+ limit: datasetLimit,
5824
+ offset,
5825
+ page_size: Math.min(limit, QUERY_RESULT_DATASET_PAGE_SIZE),
5826
+ total_rows: totalRows
5827
+ },
5828
+ ...isCustomerDbDatasetTool(toolId) ? {
5829
+ customer_db_dataset: {
5830
+ limit: datasetLimit,
5831
+ offset,
5832
+ page_size: Math.min(limit, QUERY_RESULT_DATASET_PAGE_SIZE),
5833
+ total_rows: totalRows
5834
+ }
5835
+ } : {}
5836
+ }
5837
+ });
5838
+ const pageRaw = isRecord5(response.toolResponse?.raw) ? response.toolResponse.raw : null;
5839
+ return rowsFromUnknown(pageRaw?.rows);
5840
+ };
5841
+ const collectRows = async (limit) => {
5842
+ const target = Math.min(limit ?? totalRows, totalRows, datasetLimit);
5843
+ const collected = [];
5844
+ for (let offset = 0; offset < target; offset += QUERY_RESULT_DATASET_PAGE_SIZE) {
5845
+ collected.push(
5846
+ ...await fetchPage(
5847
+ offset,
5848
+ Math.min(QUERY_RESULT_DATASET_PAGE_SIZE, target - offset)
5849
+ )
5850
+ );
5851
+ }
5852
+ return collected.slice(0, target);
5853
+ };
5854
+ const executionNonce = typeof result.job_id === "string" && result.job_id.trim() ? result.job_id.trim() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
5855
+ const safeNonce = executionNonce.replace(/[^A-Za-z0-9_.:-]/g, "_").slice(0, 64);
5856
+ const datasetScope = `${options.client.baseUrl}:${toolId}:${sql}:${datasetLimit}`;
5857
+ const playDataset = createDeferredPlayDataset({
5858
+ datasetKind: "csv",
5859
+ datasetId: `sdk-tool-list:${toolId}:${stableHash(datasetScope)}:${datasetLimit}:${safeNonce}`,
5860
+ count: Math.min(totalRows, datasetLimit),
5861
+ previewRows,
5862
+ sourceLabel: "query result rows",
5863
+ tableNamespace: null,
5864
+ resolvers: {
5865
+ count: async () => Math.min(totalRows, datasetLimit),
5866
+ peek: async (limit) => collectRows(limit),
5867
+ materialize: async (limit) => collectRows(limit),
5868
+ iterate: () => ({
5869
+ async *[Symbol.asyncIterator]() {
5870
+ const count = Math.min(totalRows, datasetLimit);
5871
+ for (let offset = 0; offset < count; offset += QUERY_RESULT_DATASET_PAGE_SIZE) {
5872
+ yield* await fetchPage(
5873
+ offset,
5874
+ Math.min(QUERY_RESULT_DATASET_PAGE_SIZE, count - offset)
5875
+ );
5876
+ }
5877
+ }
5878
+ })
5879
+ }
5880
+ });
5881
+ return attachToolResultListDataset(result, {
5882
+ name: "rows",
5883
+ path: "toolResponse.raw.rows",
5884
+ dataset: playDataset,
5885
+ count: Math.min(totalRows, datasetLimit)
5886
+ });
5887
+ }
5888
+ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
5656
5889
  const raw = response.toolResponse?.raw ?? null;
5657
5890
  const meta = response.toolResponse?.meta;
5658
5891
  const metadata = isRecord5(response._metadata) ? response._metadata.tool : null;
5659
5892
  const toolMetadata = isRecord5(metadata) ? metadata : {};
5660
- return createToolExecuteResult({
5661
- status: typeof response.status === "string" ? response.status : "completed",
5662
- jobId: typeof response.job_id === "string" ? response.job_id : void 0,
5663
- result: {
5664
- data: raw,
5665
- ...isRecord5(meta) ? { meta } : {}
5666
- },
5667
- metadata: {
5668
- toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
5669
- extractors: extractorDescriptorRecord(toolMetadata.extractors),
5670
- targetGetters: stringArrayRecord(toolMetadata.targetGetters),
5671
- listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
5672
- listIdentityGetters: stringArrayRecord(toolMetadata.listIdentityGetters)
5673
- },
5674
- execution: {
5675
- idempotent: true,
5676
- cached: false,
5677
- source: "live"
5678
- },
5679
- meta: isRecord5(response.meta) ? response.meta : void 0
5680
- });
5893
+ return attachSdkQueryResultDatasetResult(
5894
+ fallbackToolId,
5895
+ createToolExecuteResult({
5896
+ status: typeof response.status === "string" ? response.status : "completed",
5897
+ jobId: typeof response.job_id === "string" ? response.job_id : void 0,
5898
+ result: {
5899
+ data: raw,
5900
+ ...isRecord5(meta) ? { meta } : {}
5901
+ },
5902
+ metadata: {
5903
+ toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
5904
+ extractors: extractorDescriptorRecord(toolMetadata.extractors),
5905
+ targetGetters: stringArrayRecord(toolMetadata.targetGetters),
5906
+ listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
5907
+ listIdentityGetters: stringArrayRecord(
5908
+ toolMetadata.listIdentityGetters
5909
+ )
5910
+ },
5911
+ execution: {
5912
+ idempotent: true,
5913
+ cached: false,
5914
+ source: "live"
5915
+ },
5916
+ meta: isRecord5(response.meta) ? response.meta : void 0
5917
+ }),
5918
+ options
5919
+ );
5681
5920
  }
5682
5921
  function defineInput(schema) {
5683
5922
  if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
@@ -1749,9 +1749,9 @@ var PLAY_RUNTIME_PROVIDERS = {
1749
1749
  id: PLAY_RUNTIME_PROVIDER_IDS.hatchet,
1750
1750
  scheduler: PLAY_SCHEDULER_BACKENDS.hatchet,
1751
1751
  runner: PLAY_RUNTIME_BACKENDS.daytona,
1752
- dedup: PLAY_DEDUP_BACKENDS.durableObject,
1752
+ dedup: PLAY_DEDUP_BACKENDS.inMemory,
1753
1753
  artifactKind: PLAY_ARTIFACT_KINDS.cjsNode20,
1754
- label: "Hatchet scheduler + one-shot Daytona runner + DO dedup"
1754
+ label: "Hatchet scheduler + one-shot Daytona runner + receipt-backed in-process dedup"
1755
1755
  },
1756
1756
  local: {
1757
1757
  id: PLAY_RUNTIME_PROVIDER_IDS.local,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.181",
3
+ "version": "0.1.183",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {