deepline 0.1.181 → 0.1.182
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.
- package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +241 -4
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/output-datasets.ts +124 -12
- package/dist/bundling-sources/sdk/src/client.ts +7 -5
- package/dist/bundling-sources/sdk/src/play.ts +200 -26
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +263 -44
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +120 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +139 -17
- package/dist/cli/index.js +11 -8
- package/dist/cli/index.mjs +11 -8
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +213 -28
- package/dist/index.mjs +213 -28
- 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.
|
|
355
|
+
version: "0.1.182",
|
|
356
356
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
357
357
|
supportPolicy: {
|
|
358
|
-
latest: "0.1.
|
|
358
|
+
latest: "0.1.182",
|
|
359
359
|
minimumSupported: "0.1.53",
|
|
360
360
|
deprecatedBelow: "0.1.53",
|
|
361
361
|
commandMinimumSupported: [
|
|
@@ -2471,11 +2471,14 @@ var DeeplineClient = class {
|
|
|
2471
2471
|
const headers = {
|
|
2472
2472
|
[EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
|
|
2473
2473
|
...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
|
|
2474
|
-
|
|
2474
|
+
[EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
|
|
2475
2475
|
};
|
|
2476
2476
|
return this.http.post(
|
|
2477
2477
|
`/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
|
|
2478
|
-
{
|
|
2478
|
+
{
|
|
2479
|
+
payload: input,
|
|
2480
|
+
...options?.metadata ? { metadata: options.metadata } : {}
|
|
2481
|
+
},
|
|
2479
2482
|
headers,
|
|
2480
2483
|
{
|
|
2481
2484
|
forbiddenAsApiError: true,
|
|
@@ -5280,6 +5283,73 @@ function createToolExecuteResult(input) {
|
|
|
5280
5283
|
});
|
|
5281
5284
|
return wrapper;
|
|
5282
5285
|
}
|
|
5286
|
+
function attachToolResultListDataset(result, input) {
|
|
5287
|
+
const existing = result._metadata.lists[input.name];
|
|
5288
|
+
result._metadata.lists[input.name] = {
|
|
5289
|
+
path: input.path,
|
|
5290
|
+
count: input.count,
|
|
5291
|
+
keys: input.keys ?? existing?.keys ?? {}
|
|
5292
|
+
};
|
|
5293
|
+
const accessor = {
|
|
5294
|
+
path: input.path,
|
|
5295
|
+
count: input.count,
|
|
5296
|
+
keys: result._metadata.lists[input.name].keys
|
|
5297
|
+
};
|
|
5298
|
+
Object.defineProperty(accessor, "get", {
|
|
5299
|
+
value() {
|
|
5300
|
+
return input.dataset;
|
|
5301
|
+
},
|
|
5302
|
+
enumerable: false
|
|
5303
|
+
});
|
|
5304
|
+
result.extractedLists[input.name] = accessor;
|
|
5305
|
+
const serialized = input.dataset.toJSON();
|
|
5306
|
+
let root = { toolResponse: { raw: result.toolResponse.raw } };
|
|
5307
|
+
const candidates = [...candidateResultPaths(input.path)].filter(
|
|
5308
|
+
(candidate, index, all) => all.indexOf(candidate) === index
|
|
5309
|
+
);
|
|
5310
|
+
for (const candidate of candidates) {
|
|
5311
|
+
if (!Array.isArray(getAtPath(root, candidate))) continue;
|
|
5312
|
+
root = replaceAtPath(root, candidate, serialized.preview);
|
|
5313
|
+
break;
|
|
5314
|
+
}
|
|
5315
|
+
if (isRecord4(root) && isRecord4(root.toolResponse) && Object.prototype.hasOwnProperty.call(root.toolResponse, "raw")) {
|
|
5316
|
+
result.toolResponse.raw = root.toolResponse.raw;
|
|
5317
|
+
result.toolOutput.raw = root.toolResponse.raw;
|
|
5318
|
+
}
|
|
5319
|
+
return result;
|
|
5320
|
+
}
|
|
5321
|
+
function replaceAtPath(root, path, replacement) {
|
|
5322
|
+
const segments = parsePath(path);
|
|
5323
|
+
if (segments.length === 0 || segments.includes("*")) return root;
|
|
5324
|
+
const replace = (current, index) => {
|
|
5325
|
+
if (index >= segments.length) return replacement;
|
|
5326
|
+
const segment = segments[index];
|
|
5327
|
+
if (typeof segment === "number") {
|
|
5328
|
+
if (!Array.isArray(current)) return current;
|
|
5329
|
+
const copy = [...current];
|
|
5330
|
+
copy[segment] = replace(copy[segment], index + 1);
|
|
5331
|
+
return copy;
|
|
5332
|
+
}
|
|
5333
|
+
if (!isRecord4(current)) return current;
|
|
5334
|
+
return {
|
|
5335
|
+
...current,
|
|
5336
|
+
[segment]: replace(current[segment], index + 1)
|
|
5337
|
+
};
|
|
5338
|
+
};
|
|
5339
|
+
return replace(root, 0);
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
// ../shared_libs/play-runtime/query-result-dataset.ts
|
|
5343
|
+
var QUERY_RESULT_DATASET_PAGE_SIZE = 1e3;
|
|
5344
|
+
function isCustomerDbDatasetTool(toolId) {
|
|
5345
|
+
return /^(?:customer_db_)?query_customer_db$/.test(toolId);
|
|
5346
|
+
}
|
|
5347
|
+
function isSnowflakeQueryDatasetTool(toolId) {
|
|
5348
|
+
return /^snowflake_(?:snowflake_)?run_(?:semantic_)?query$/.test(toolId);
|
|
5349
|
+
}
|
|
5350
|
+
function isQueryResultDatasetTool(toolId) {
|
|
5351
|
+
return isCustomerDbDatasetTool(toolId) || isSnowflakeQueryDatasetTool(toolId);
|
|
5352
|
+
}
|
|
5283
5353
|
|
|
5284
5354
|
// src/play.ts
|
|
5285
5355
|
var DeeplineConditionalStepResolver = class _DeeplineConditionalStepResolver {
|
|
@@ -5455,9 +5525,13 @@ var DeeplineContext = class {
|
|
|
5455
5525
|
/** Execute a tool and return the standard execution envelope. */
|
|
5456
5526
|
execute: async (toolId, input) => {
|
|
5457
5527
|
const response = await this.client.executeTool(toolId, input, {
|
|
5458
|
-
includeToolMetadata: true
|
|
5528
|
+
includeToolMetadata: true,
|
|
5529
|
+
responseIntent: "dataset"
|
|
5530
|
+
});
|
|
5531
|
+
return toolExecutionEnvelopeToResult(toolId, response, {
|
|
5532
|
+
client: this.client,
|
|
5533
|
+
input
|
|
5459
5534
|
});
|
|
5460
|
-
return toolExecutionEnvelopeToResult(toolId, response);
|
|
5461
5535
|
}
|
|
5462
5536
|
};
|
|
5463
5537
|
}
|
|
@@ -5652,32 +5726,143 @@ function extractorDescriptorRecord(value) {
|
|
|
5652
5726
|
})
|
|
5653
5727
|
);
|
|
5654
5728
|
}
|
|
5655
|
-
function
|
|
5729
|
+
function rowsFromUnknown(value) {
|
|
5730
|
+
if (!Array.isArray(value)) return [];
|
|
5731
|
+
return value.map((row) => isRecord5(row) ? row : { value: row });
|
|
5732
|
+
}
|
|
5733
|
+
function finiteNonNegativeInteger(value) {
|
|
5734
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
5735
|
+
return null;
|
|
5736
|
+
}
|
|
5737
|
+
return Math.floor(value);
|
|
5738
|
+
}
|
|
5739
|
+
function finitePositiveInteger(value) {
|
|
5740
|
+
const integer = finiteNonNegativeInteger(value);
|
|
5741
|
+
return integer !== null && integer > 0 ? integer : null;
|
|
5742
|
+
}
|
|
5743
|
+
function stableHash(value) {
|
|
5744
|
+
let hash = 0;
|
|
5745
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
5746
|
+
hash = Math.imul(31, hash) + value.charCodeAt(index);
|
|
5747
|
+
hash |= 0;
|
|
5748
|
+
}
|
|
5749
|
+
return Math.abs(hash).toString(36);
|
|
5750
|
+
}
|
|
5751
|
+
function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
5752
|
+
if (!options || !isQueryResultDatasetTool(toolId)) return result;
|
|
5753
|
+
const raw = isRecord5(result.toolResponse.raw) ? result.toolResponse.raw : null;
|
|
5754
|
+
const dataset = isRecord5(raw?.dataset) ? raw.dataset : null;
|
|
5755
|
+
const totalRows = finiteNonNegativeInteger(dataset?.total_rows);
|
|
5756
|
+
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;
|
|
5757
|
+
if (!dataset || totalRows === null || !sql) {
|
|
5758
|
+
return result;
|
|
5759
|
+
}
|
|
5760
|
+
const datasetLimit = finitePositiveInteger(dataset.returned_limit) ?? totalRows;
|
|
5761
|
+
const previewRows = rowsFromUnknown(raw?.rows).slice(0, 25);
|
|
5762
|
+
const fetchPage = async (offset, limit) => {
|
|
5763
|
+
if (limit <= 0 || offset >= totalRows) return [];
|
|
5764
|
+
const response = await options.client.executeTool(toolId, options.input, {
|
|
5765
|
+
includeToolMetadata: true,
|
|
5766
|
+
responseIntent: "dataset",
|
|
5767
|
+
metadata: {
|
|
5768
|
+
query_result_dataset: {
|
|
5769
|
+
limit: datasetLimit,
|
|
5770
|
+
offset,
|
|
5771
|
+
page_size: Math.min(limit, QUERY_RESULT_DATASET_PAGE_SIZE),
|
|
5772
|
+
total_rows: totalRows
|
|
5773
|
+
},
|
|
5774
|
+
...isCustomerDbDatasetTool(toolId) ? {
|
|
5775
|
+
customer_db_dataset: {
|
|
5776
|
+
limit: datasetLimit,
|
|
5777
|
+
offset,
|
|
5778
|
+
page_size: Math.min(limit, QUERY_RESULT_DATASET_PAGE_SIZE),
|
|
5779
|
+
total_rows: totalRows
|
|
5780
|
+
}
|
|
5781
|
+
} : {}
|
|
5782
|
+
}
|
|
5783
|
+
});
|
|
5784
|
+
const pageRaw = isRecord5(response.toolResponse?.raw) ? response.toolResponse.raw : null;
|
|
5785
|
+
return rowsFromUnknown(pageRaw?.rows);
|
|
5786
|
+
};
|
|
5787
|
+
const collectRows = async (limit) => {
|
|
5788
|
+
const target = Math.min(limit ?? totalRows, totalRows, datasetLimit);
|
|
5789
|
+
const collected = [];
|
|
5790
|
+
for (let offset = 0; offset < target; offset += QUERY_RESULT_DATASET_PAGE_SIZE) {
|
|
5791
|
+
collected.push(
|
|
5792
|
+
...await fetchPage(
|
|
5793
|
+
offset,
|
|
5794
|
+
Math.min(QUERY_RESULT_DATASET_PAGE_SIZE, target - offset)
|
|
5795
|
+
)
|
|
5796
|
+
);
|
|
5797
|
+
}
|
|
5798
|
+
return collected.slice(0, target);
|
|
5799
|
+
};
|
|
5800
|
+
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)}`;
|
|
5801
|
+
const safeNonce = executionNonce.replace(/[^A-Za-z0-9_.:-]/g, "_").slice(0, 64);
|
|
5802
|
+
const datasetScope = `${options.client.baseUrl}:${toolId}:${sql}:${datasetLimit}`;
|
|
5803
|
+
const playDataset = createDeferredPlayDataset({
|
|
5804
|
+
datasetKind: "csv",
|
|
5805
|
+
datasetId: `sdk-tool-list:${toolId}:${stableHash(datasetScope)}:${datasetLimit}:${safeNonce}`,
|
|
5806
|
+
count: Math.min(totalRows, datasetLimit),
|
|
5807
|
+
previewRows,
|
|
5808
|
+
sourceLabel: "query result rows",
|
|
5809
|
+
tableNamespace: null,
|
|
5810
|
+
resolvers: {
|
|
5811
|
+
count: async () => Math.min(totalRows, datasetLimit),
|
|
5812
|
+
peek: async (limit) => collectRows(limit),
|
|
5813
|
+
materialize: async (limit) => collectRows(limit),
|
|
5814
|
+
iterate: () => ({
|
|
5815
|
+
async *[Symbol.asyncIterator]() {
|
|
5816
|
+
const count = Math.min(totalRows, datasetLimit);
|
|
5817
|
+
for (let offset = 0; offset < count; offset += QUERY_RESULT_DATASET_PAGE_SIZE) {
|
|
5818
|
+
yield* await fetchPage(
|
|
5819
|
+
offset,
|
|
5820
|
+
Math.min(QUERY_RESULT_DATASET_PAGE_SIZE, count - offset)
|
|
5821
|
+
);
|
|
5822
|
+
}
|
|
5823
|
+
}
|
|
5824
|
+
})
|
|
5825
|
+
}
|
|
5826
|
+
});
|
|
5827
|
+
return attachToolResultListDataset(result, {
|
|
5828
|
+
name: "rows",
|
|
5829
|
+
path: "toolResponse.raw.rows",
|
|
5830
|
+
dataset: playDataset,
|
|
5831
|
+
count: Math.min(totalRows, datasetLimit)
|
|
5832
|
+
});
|
|
5833
|
+
}
|
|
5834
|
+
function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
5656
5835
|
const raw = response.toolResponse?.raw ?? null;
|
|
5657
5836
|
const meta = response.toolResponse?.meta;
|
|
5658
5837
|
const metadata = isRecord5(response._metadata) ? response._metadata.tool : null;
|
|
5659
5838
|
const toolMetadata = isRecord5(metadata) ? metadata : {};
|
|
5660
|
-
return
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5839
|
+
return attachSdkQueryResultDatasetResult(
|
|
5840
|
+
fallbackToolId,
|
|
5841
|
+
createToolExecuteResult({
|
|
5842
|
+
status: typeof response.status === "string" ? response.status : "completed",
|
|
5843
|
+
jobId: typeof response.job_id === "string" ? response.job_id : void 0,
|
|
5844
|
+
result: {
|
|
5845
|
+
data: raw,
|
|
5846
|
+
...isRecord5(meta) ? { meta } : {}
|
|
5847
|
+
},
|
|
5848
|
+
metadata: {
|
|
5849
|
+
toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
|
|
5850
|
+
extractors: extractorDescriptorRecord(toolMetadata.extractors),
|
|
5851
|
+
targetGetters: stringArrayRecord(toolMetadata.targetGetters),
|
|
5852
|
+
listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
|
|
5853
|
+
listIdentityGetters: stringArrayRecord(
|
|
5854
|
+
toolMetadata.listIdentityGetters
|
|
5855
|
+
)
|
|
5856
|
+
},
|
|
5857
|
+
execution: {
|
|
5858
|
+
idempotent: true,
|
|
5859
|
+
cached: false,
|
|
5860
|
+
source: "live"
|
|
5861
|
+
},
|
|
5862
|
+
meta: isRecord5(response.meta) ? response.meta : void 0
|
|
5863
|
+
}),
|
|
5864
|
+
options
|
|
5865
|
+
);
|
|
5681
5866
|
}
|
|
5682
5867
|
function defineInput(schema) {
|
|
5683
5868
|
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|