deepline 0.2.53 → 0.2.55
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/sdk/src/client.ts +17 -1
- package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +43 -1
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +30 -1
- package/dist/bundling-sources/shared_libs/play-runtime/cell-provenance.ts +231 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1094 -128
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +178 -9
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +634 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-observation.ts +64 -0
- package/dist/bundling-sources/shared_libs/play-runtime/dynamic-worker-version.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +251 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-node-scope.ts +160 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +43 -5
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +26 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +83 -0
- package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +3 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +49 -1
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +375 -29
- package/dist/bundling-sources/shared_libs/plays/docflow-binding-owner.ts +636 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-binding.ts +598 -0
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +1645 -0
- package/dist/bundling-sources/shared_libs/plays/play-exports.ts +202 -0
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +16 -1
- package/dist/bundling-sources/shared_libs/plays/ts-ast.ts +48 -0
- package/dist/cli/index.js +994 -312
- package/dist/cli/index.mjs +994 -312
- package/dist/{compiler-manifest-Cj3--4ZJ.d.mts → compiler-manifest-Bl8kmLx9.d.mts} +118 -0
- package/dist/{compiler-manifest-Cj3--4ZJ.d.ts → compiler-manifest-Bl8kmLx9.d.ts} +118 -0
- package/dist/index.d.mts +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +419 -59
- package/dist/index.mjs +419 -59
- package/dist/install-integrity.json +12 -2
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/plays/bundle-play-file.mjs +1361 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -763,7 +763,7 @@ var SDK_RELEASE = {
|
|
|
763
763
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
764
764
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
765
765
|
// release keeps lazy paging semantics independent of row residency.
|
|
766
|
-
version: "0.2.
|
|
766
|
+
version: "0.2.55",
|
|
767
767
|
contracts: {
|
|
768
768
|
api: {
|
|
769
769
|
name: "sdk-http-api",
|
|
@@ -1698,7 +1698,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1698
1698
|
if (value.length >= 4) exactSecrets.add(value);
|
|
1699
1699
|
}
|
|
1700
1700
|
for (const value of initialValues) register(value);
|
|
1701
|
-
function
|
|
1701
|
+
function redactString2(value) {
|
|
1702
1702
|
let output = value;
|
|
1703
1703
|
for (const secret of exactSecrets) {
|
|
1704
1704
|
output = output.replace(
|
|
@@ -1719,7 +1719,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1719
1719
|
return redactSecretLikeString(output);
|
|
1720
1720
|
}
|
|
1721
1721
|
function redact(value) {
|
|
1722
|
-
if (typeof value === "string") return
|
|
1722
|
+
if (typeof value === "string") return redactString2(value);
|
|
1723
1723
|
if (Array.isArray(value)) return value.map((entry) => redact(entry));
|
|
1724
1724
|
if (value && typeof value === "object") {
|
|
1725
1725
|
return Object.fromEntries(
|
|
@@ -1732,7 +1732,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1732
1732
|
return value;
|
|
1733
1733
|
}
|
|
1734
1734
|
function redactKnownSecrets(value) {
|
|
1735
|
-
if (typeof value === "string") return
|
|
1735
|
+
if (typeof value === "string") return redactString2(value);
|
|
1736
1736
|
if (Array.isArray(value)) {
|
|
1737
1737
|
return value.map((entry) => redactKnownSecrets(entry));
|
|
1738
1738
|
}
|
|
@@ -1748,7 +1748,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1748
1748
|
}
|
|
1749
1749
|
return {
|
|
1750
1750
|
register,
|
|
1751
|
-
redactString,
|
|
1751
|
+
redactString: redactString2,
|
|
1752
1752
|
redactKnownSecrets,
|
|
1753
1753
|
redact
|
|
1754
1754
|
};
|
|
@@ -1768,12 +1768,334 @@ var RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES = 64 * 1024;
|
|
|
1768
1768
|
// ../shared_libs/play-runtime/ledger-safe-payload.ts
|
|
1769
1769
|
var ledgerIngressRedactor = createSecretRedactionContext();
|
|
1770
1770
|
|
|
1771
|
-
// ../shared_libs/play-runtime/
|
|
1771
|
+
// ../shared_libs/play-runtime/docflow-node-io.ts
|
|
1772
|
+
var DOCFLOW_NODE_IO_LIMITS = {
|
|
1773
|
+
maxPaths: 16,
|
|
1774
|
+
maxDepth: 3,
|
|
1775
|
+
maxObjectFields: 12,
|
|
1776
|
+
maxArrayItems: 3,
|
|
1777
|
+
maxStringBytes: 256,
|
|
1778
|
+
maxPhaseBytes: 2e3,
|
|
1779
|
+
maxErrorBytes: 512
|
|
1780
|
+
};
|
|
1781
|
+
var utf8Encoder = new TextEncoder();
|
|
1782
|
+
var PLAY_DATASET_BRAND = /* @__PURE__ */ Symbol.for("deepline.play.dataset");
|
|
1783
|
+
function ledgerSafeDocflowPreviewKey(key) {
|
|
1784
|
+
if (!key.startsWith("$")) return key;
|
|
1785
|
+
const stripped = key.replace(/^\$+/, "");
|
|
1786
|
+
return stripped || "output";
|
|
1787
|
+
}
|
|
1788
|
+
function utf8Bytes(value) {
|
|
1789
|
+
return utf8Encoder.encode(value).byteLength;
|
|
1790
|
+
}
|
|
1791
|
+
function truncateUtf8(value, maxBytes) {
|
|
1792
|
+
if (utf8Bytes(value) <= maxBytes) return value;
|
|
1793
|
+
let output = "";
|
|
1794
|
+
for (const character of value) {
|
|
1795
|
+
if (utf8Bytes(`${output}${character}\u2026`) > maxBytes) break;
|
|
1796
|
+
output += character;
|
|
1797
|
+
}
|
|
1798
|
+
return `${output}\u2026`;
|
|
1799
|
+
}
|
|
1800
|
+
function redactString(redactor, value, key) {
|
|
1801
|
+
if (!key) return redactor.redactString(value);
|
|
1802
|
+
const wrapped = redactor.redact({ [key]: value });
|
|
1803
|
+
return typeof wrapped[key] === "string" ? wrapped[key] : redactor.redactString(value);
|
|
1804
|
+
}
|
|
1805
|
+
function safeString(value, redactor, key) {
|
|
1806
|
+
if (typeof value !== "string") return void 0;
|
|
1807
|
+
return truncateUtf8(
|
|
1808
|
+
redactString(redactor, value, key),
|
|
1809
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
function previewValue(value, input) {
|
|
1813
|
+
if (value === null) return { kind: "null" };
|
|
1814
|
+
if (value === void 0) return { kind: "unavailable", reason: "undefined" };
|
|
1815
|
+
if (typeof value === "string") {
|
|
1816
|
+
return {
|
|
1817
|
+
kind: "scalar",
|
|
1818
|
+
value: safeString(value, input.redactor, input.key) ?? ""
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
if (typeof value === "number") {
|
|
1822
|
+
return Number.isFinite(value) ? { kind: "scalar", value } : { kind: "unavailable", reason: "unsupported" };
|
|
1823
|
+
}
|
|
1824
|
+
if (typeof value === "boolean") return { kind: "scalar", value };
|
|
1825
|
+
if (typeof value === "bigint") {
|
|
1826
|
+
return { kind: "unavailable", reason: "bigint" };
|
|
1827
|
+
}
|
|
1828
|
+
if (typeof value === "function") {
|
|
1829
|
+
return { kind: "unavailable", reason: "function" };
|
|
1830
|
+
}
|
|
1831
|
+
if (typeof value === "symbol") {
|
|
1832
|
+
return { kind: "unavailable", reason: "symbol" };
|
|
1833
|
+
}
|
|
1834
|
+
if (typeof value !== "object") {
|
|
1835
|
+
return { kind: "unavailable", reason: "unsupported" };
|
|
1836
|
+
}
|
|
1837
|
+
try {
|
|
1838
|
+
const brand = readDataProperty(value, PLAY_DATASET_BRAND);
|
|
1839
|
+
const datasetKind = readDataProperty(value, "datasetKind");
|
|
1840
|
+
const datasetId = readDataProperty(value, "datasetId");
|
|
1841
|
+
const tableNamespace = readDataProperty(value, "tableNamespace");
|
|
1842
|
+
if (brand.ok && brand.value === true && datasetKind.ok && (datasetKind.value === "csv" || datasetKind.value === "map") && datasetId.ok && typeof datasetId.value === "string") {
|
|
1843
|
+
return {
|
|
1844
|
+
kind: "dataset",
|
|
1845
|
+
datasetId: safeString(datasetId.value, input.redactor, "datasetId") ?? "dataset",
|
|
1846
|
+
datasetKind: datasetKind.value,
|
|
1847
|
+
tableNamespace: tableNamespace.ok && tableNamespace.value === null ? null : tableNamespace.ok ? safeString(
|
|
1848
|
+
tableNamespace.value,
|
|
1849
|
+
input.redactor,
|
|
1850
|
+
"tableNamespace"
|
|
1851
|
+
) : void 0
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
const kind = readDataProperty(value, "kind");
|
|
1855
|
+
const count = readDataProperty(value, "count");
|
|
1856
|
+
const preview = readDataProperty(value, "preview");
|
|
1857
|
+
if (kind.ok && kind.value === "dataset" && datasetKind.ok && (datasetKind.value === "csv" || datasetKind.value === "map") && datasetId.ok && typeof datasetId.value === "string" && count.ok && typeof count.value === "number" && preview.ok && Array.isArray(preview.value)) {
|
|
1858
|
+
return {
|
|
1859
|
+
kind: "dataset",
|
|
1860
|
+
datasetId: safeString(datasetId.value, input.redactor, "datasetId") ?? "dataset",
|
|
1861
|
+
datasetKind: datasetKind.value,
|
|
1862
|
+
tableNamespace: tableNamespace.ok && tableNamespace.value === null ? null : tableNamespace.ok ? safeString(
|
|
1863
|
+
tableNamespace.value,
|
|
1864
|
+
input.redactor,
|
|
1865
|
+
"tableNamespace"
|
|
1866
|
+
) : void 0,
|
|
1867
|
+
rowCount: Math.max(0, Math.floor(count.value))
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
} catch {
|
|
1871
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
1872
|
+
}
|
|
1873
|
+
if (input.ancestors.has(value)) {
|
|
1874
|
+
return { kind: "unavailable", reason: "cycle" };
|
|
1875
|
+
}
|
|
1876
|
+
if (input.depth >= DOCFLOW_NODE_IO_LIMITS.maxDepth) {
|
|
1877
|
+
return { kind: "unavailable", reason: "depth" };
|
|
1878
|
+
}
|
|
1879
|
+
input.ancestors.add(value);
|
|
1880
|
+
try {
|
|
1881
|
+
if (Array.isArray(value)) {
|
|
1882
|
+
const items = [];
|
|
1883
|
+
for (let index = 0; index < Math.min(value.length, DOCFLOW_NODE_IO_LIMITS.maxArrayItems); index += 1) {
|
|
1884
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1885
|
+
value,
|
|
1886
|
+
String(index)
|
|
1887
|
+
);
|
|
1888
|
+
items.push(
|
|
1889
|
+
descriptor && "value" in descriptor ? previewValue(descriptor.value, {
|
|
1890
|
+
...input,
|
|
1891
|
+
depth: input.depth + 1
|
|
1892
|
+
}) : { kind: "unavailable", reason: "access_error" }
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
return {
|
|
1896
|
+
kind: "array",
|
|
1897
|
+
items,
|
|
1898
|
+
totalItems: value.length,
|
|
1899
|
+
...value.length > items.length ? { truncated: true } : {}
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
let descriptors;
|
|
1903
|
+
try {
|
|
1904
|
+
descriptors = Object.getOwnPropertyDescriptors(value);
|
|
1905
|
+
} catch {
|
|
1906
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
1907
|
+
}
|
|
1908
|
+
const entries = Object.entries(descriptors).filter(
|
|
1909
|
+
([, descriptor]) => descriptor.enumerable
|
|
1910
|
+
);
|
|
1911
|
+
const selected = entries.slice(0, DOCFLOW_NODE_IO_LIMITS.maxObjectFields);
|
|
1912
|
+
const fields = {};
|
|
1913
|
+
for (const [key, descriptor] of selected) {
|
|
1914
|
+
const safeKey = truncateUtf8(
|
|
1915
|
+
ledgerSafeDocflowPreviewKey(input.redactor.redactString(key)),
|
|
1916
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
1917
|
+
);
|
|
1918
|
+
fields[safeKey] = "value" in descriptor ? previewValue(descriptor.value, {
|
|
1919
|
+
...input,
|
|
1920
|
+
depth: input.depth + 1,
|
|
1921
|
+
key
|
|
1922
|
+
}) : { kind: "unavailable", reason: "access_error" };
|
|
1923
|
+
}
|
|
1924
|
+
return {
|
|
1925
|
+
kind: "object",
|
|
1926
|
+
fields,
|
|
1927
|
+
totalFields: entries.length,
|
|
1928
|
+
...entries.length > selected.length ? { truncated: true } : {}
|
|
1929
|
+
};
|
|
1930
|
+
} catch {
|
|
1931
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
1932
|
+
} finally {
|
|
1933
|
+
input.ancestors.delete(value);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
function readDataProperty(value, property) {
|
|
1937
|
+
if ((typeof value !== "object" || value === null) && typeof value !== "function") {
|
|
1938
|
+
return { ok: false };
|
|
1939
|
+
}
|
|
1940
|
+
try {
|
|
1941
|
+
let owner = value;
|
|
1942
|
+
while (owner) {
|
|
1943
|
+
const descriptor = Object.getOwnPropertyDescriptor(owner, property);
|
|
1944
|
+
if (descriptor) {
|
|
1945
|
+
return "value" in descriptor ? { ok: true, value: descriptor.value } : { ok: false };
|
|
1946
|
+
}
|
|
1947
|
+
owner = Object.getPrototypeOf(owner);
|
|
1948
|
+
}
|
|
1949
|
+
} catch {
|
|
1950
|
+
return { ok: false };
|
|
1951
|
+
}
|
|
1952
|
+
return { ok: false };
|
|
1953
|
+
}
|
|
1954
|
+
function buildPlayDocflowNodeErrorPreview(error, redactor = createSecretRedactionContext()) {
|
|
1955
|
+
try {
|
|
1956
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1957
|
+
return truncateUtf8(
|
|
1958
|
+
redactor.redactString(message),
|
|
1959
|
+
DOCFLOW_NODE_IO_LIMITS.maxErrorBytes
|
|
1960
|
+
);
|
|
1961
|
+
} catch {
|
|
1962
|
+
return "Non-Error value thrown (message unavailable)";
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1772
1965
|
function isRecord3(value) {
|
|
1773
1966
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1774
1967
|
}
|
|
1968
|
+
function normalizePreview(value, depth) {
|
|
1969
|
+
if (!isRecord3(value) || typeof value.kind !== "string") return null;
|
|
1970
|
+
if (value.kind === "null") return { kind: "null" };
|
|
1971
|
+
if (value.kind === "scalar") {
|
|
1972
|
+
if (typeof value.value === "string" || typeof value.value === "boolean" || typeof value.value === "number" && Number.isFinite(value.value)) {
|
|
1973
|
+
return previewValue(value.value, {
|
|
1974
|
+
depth: 0,
|
|
1975
|
+
ancestors: /* @__PURE__ */ new WeakSet(),
|
|
1976
|
+
redactor: createSecretRedactionContext()
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
return null;
|
|
1980
|
+
}
|
|
1981
|
+
if (value.kind === "unavailable") {
|
|
1982
|
+
const reason = value.reason;
|
|
1983
|
+
return typeof reason === "string" && [
|
|
1984
|
+
"undefined",
|
|
1985
|
+
"function",
|
|
1986
|
+
"symbol",
|
|
1987
|
+
"bigint",
|
|
1988
|
+
"cycle",
|
|
1989
|
+
"depth",
|
|
1990
|
+
"access_error",
|
|
1991
|
+
"limit",
|
|
1992
|
+
"unsupported"
|
|
1993
|
+
].includes(reason) ? {
|
|
1994
|
+
kind: "unavailable",
|
|
1995
|
+
reason
|
|
1996
|
+
} : null;
|
|
1997
|
+
}
|
|
1998
|
+
if (value.kind === "dataset") {
|
|
1999
|
+
const datasetId = safeString(
|
|
2000
|
+
value.datasetId,
|
|
2001
|
+
createSecretRedactionContext(),
|
|
2002
|
+
"datasetId"
|
|
2003
|
+
);
|
|
2004
|
+
if (!datasetId || value.datasetKind !== "csv" && value.datasetKind !== "map") {
|
|
2005
|
+
return null;
|
|
2006
|
+
}
|
|
2007
|
+
return {
|
|
2008
|
+
kind: "dataset",
|
|
2009
|
+
datasetId,
|
|
2010
|
+
datasetKind: value.datasetKind,
|
|
2011
|
+
...value.tableNamespace === null ? { tableNamespace: null } : typeof value.tableNamespace === "string" ? {
|
|
2012
|
+
tableNamespace: safeString(
|
|
2013
|
+
value.tableNamespace,
|
|
2014
|
+
createSecretRedactionContext(),
|
|
2015
|
+
"tableNamespace"
|
|
2016
|
+
)
|
|
2017
|
+
} : {},
|
|
2018
|
+
...typeof value.rowCount === "number" && Number.isFinite(value.rowCount) ? { rowCount: Math.max(0, Math.floor(value.rowCount)) } : {}
|
|
2019
|
+
};
|
|
2020
|
+
}
|
|
2021
|
+
if (depth >= DOCFLOW_NODE_IO_LIMITS.maxDepth) {
|
|
2022
|
+
return { kind: "unavailable", reason: "depth" };
|
|
2023
|
+
}
|
|
2024
|
+
if (value.kind === "array" && Array.isArray(value.items)) {
|
|
2025
|
+
const items = value.items.slice(0, DOCFLOW_NODE_IO_LIMITS.maxArrayItems).map((item) => normalizePreview(item, depth + 1)).filter((item) => item !== null);
|
|
2026
|
+
const totalItems = typeof value.totalItems === "number" && Number.isFinite(value.totalItems) ? Math.max(items.length, Math.floor(value.totalItems)) : items.length;
|
|
2027
|
+
return {
|
|
2028
|
+
kind: "array",
|
|
2029
|
+
items,
|
|
2030
|
+
totalItems,
|
|
2031
|
+
...value.truncated === true || totalItems > items.length ? { truncated: true } : {}
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
if (value.kind === "object" && isRecord3(value.fields)) {
|
|
2035
|
+
const fields = {};
|
|
2036
|
+
for (const [key, field] of Object.entries(value.fields).slice(
|
|
2037
|
+
0,
|
|
2038
|
+
DOCFLOW_NODE_IO_LIMITS.maxObjectFields
|
|
2039
|
+
)) {
|
|
2040
|
+
const normalized = normalizePreview(field, depth + 1);
|
|
2041
|
+
if (normalized) fields[ledgerSafeDocflowPreviewKey(key)] = normalized;
|
|
2042
|
+
}
|
|
2043
|
+
const totalFields = typeof value.totalFields === "number" && Number.isFinite(value.totalFields) ? Math.max(Object.keys(fields).length, Math.floor(value.totalFields)) : Object.keys(fields).length;
|
|
2044
|
+
return {
|
|
2045
|
+
kind: "object",
|
|
2046
|
+
fields,
|
|
2047
|
+
totalFields,
|
|
2048
|
+
...value.truncated === true || totalFields > Object.keys(fields).length ? { truncated: true } : {}
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
return null;
|
|
2052
|
+
}
|
|
2053
|
+
function normalizePlayDocflowNodeIoState(value) {
|
|
2054
|
+
if (!isRecord3(value)) return void 0;
|
|
2055
|
+
const attempt = typeof value.attempt === "number" && Number.isFinite(value.attempt) ? Math.max(0, Math.floor(value.attempt)) : 0;
|
|
2056
|
+
const normalizeMap = (raw) => {
|
|
2057
|
+
if (!isRecord3(raw)) return void 0;
|
|
2058
|
+
const output = {};
|
|
2059
|
+
for (const [path, preview] of Object.entries(raw).slice(
|
|
2060
|
+
0,
|
|
2061
|
+
DOCFLOW_NODE_IO_LIMITS.maxPaths
|
|
2062
|
+
)) {
|
|
2063
|
+
const normalized = normalizePreview(preview, 0);
|
|
2064
|
+
if (!normalized) continue;
|
|
2065
|
+
const safePath = ledgerSafeDocflowPreviewKey(path);
|
|
2066
|
+
const candidate = { ...output, [safePath]: normalized };
|
|
2067
|
+
if (utf8Bytes(JSON.stringify(candidate)) > DOCFLOW_NODE_IO_LIMITS.maxPhaseBytes) {
|
|
2068
|
+
break;
|
|
2069
|
+
}
|
|
2070
|
+
output[safePath] = normalized;
|
|
2071
|
+
}
|
|
2072
|
+
return output;
|
|
2073
|
+
};
|
|
2074
|
+
const inputs = normalizeMap(value.inputs);
|
|
2075
|
+
const outputs = normalizeMap(value.outputs);
|
|
2076
|
+
const error = typeof value.error === "string" ? buildPlayDocflowNodeErrorPreview(value.error) : value.error === null ? null : void 0;
|
|
2077
|
+
return {
|
|
2078
|
+
attempt,
|
|
2079
|
+
...typeof value.invocationId === "string" && value.invocationId.trim() ? {
|
|
2080
|
+
invocationId: truncateUtf8(
|
|
2081
|
+
value.invocationId.trim(),
|
|
2082
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
2083
|
+
)
|
|
2084
|
+
} : {},
|
|
2085
|
+
...inputs ? { inputs } : {},
|
|
2086
|
+
...outputs ? { outputs } : {},
|
|
2087
|
+
...value.inputsTruncated === true ? { inputsTruncated: true } : {},
|
|
2088
|
+
...value.outputsTruncated === true ? { outputsTruncated: true } : {},
|
|
2089
|
+
...error !== void 0 ? { error } : {}
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
// ../shared_libs/play-runtime/activity-observation.ts
|
|
2094
|
+
function isRecord4(value) {
|
|
2095
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2096
|
+
}
|
|
1775
2097
|
function isPlayActivityObservation(value) {
|
|
1776
|
-
if (!
|
|
2098
|
+
if (!isRecord4(value) || value.schemaVersion !== 1 || typeof value.activityId !== "string" || !value.activityId.trim() || typeof value.observedAt !== "number" || !Number.isFinite(value.observedAt) || !isRecord4(value.target) || !isRecord4(value.state)) {
|
|
1777
2099
|
return false;
|
|
1778
2100
|
}
|
|
1779
2101
|
const targetKinds = /* @__PURE__ */ new Set([
|
|
@@ -2043,9 +2365,30 @@ function projectPlayRunActivity(input) {
|
|
|
2043
2365
|
return projection(fallback, now, normalizedStatus !== "waiting");
|
|
2044
2366
|
}
|
|
2045
2367
|
|
|
2368
|
+
// ../shared_libs/play-runtime/cell-provenance.ts
|
|
2369
|
+
function finiteNonNegativeInteger2(value) {
|
|
2370
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
2371
|
+
return null;
|
|
2372
|
+
}
|
|
2373
|
+
return Math.trunc(value);
|
|
2374
|
+
}
|
|
2375
|
+
function nonEmptyString(value) {
|
|
2376
|
+
if (typeof value !== "string") return null;
|
|
2377
|
+
const trimmed = value.trim();
|
|
2378
|
+
return trimmed ? trimmed : null;
|
|
2379
|
+
}
|
|
2380
|
+
function normalizeDatasetBornFrom(value) {
|
|
2381
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
2382
|
+
const record = value;
|
|
2383
|
+
const table = nonEmptyString(record.table);
|
|
2384
|
+
const rowCountIn = finiteNonNegativeInteger2(record.rowCountIn);
|
|
2385
|
+
if (!table || rowCountIn === null) return null;
|
|
2386
|
+
return { table, rowCountIn };
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2046
2389
|
// ../shared_libs/play-runtime/run-ledger.ts
|
|
2047
2390
|
var LOG_TAIL_LIMIT = 100;
|
|
2048
|
-
function
|
|
2391
|
+
function isRecord5(value) {
|
|
2049
2392
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2050
2393
|
}
|
|
2051
2394
|
function finiteNumber(value) {
|
|
@@ -2141,21 +2484,21 @@ function createEmptyPlayRunLedgerSnapshot(input) {
|
|
|
2141
2484
|
};
|
|
2142
2485
|
}
|
|
2143
2486
|
function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
2144
|
-
if (!
|
|
2487
|
+
if (!isRecord5(value)) {
|
|
2145
2488
|
return createEmptyPlayRunLedgerSnapshot(fallback);
|
|
2146
2489
|
}
|
|
2147
2490
|
const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
|
|
2148
2491
|
(entry) => typeof entry === "string" && Boolean(entry.trim())
|
|
2149
2492
|
) : [];
|
|
2150
|
-
const rawSteps =
|
|
2493
|
+
const rawSteps = isRecord5(value.stepsById) ? value.stepsById : {};
|
|
2151
2494
|
const stepsById = {};
|
|
2152
2495
|
for (const [stepId, rawStep] of Object.entries(rawSteps)) {
|
|
2153
|
-
if (!stepId.trim() || !
|
|
2496
|
+
if (!stepId.trim() || !isRecord5(rawStep)) continue;
|
|
2154
2497
|
const rawStatus = normalizeStepStatus(rawStep.status);
|
|
2155
2498
|
if (!rawStatus) continue;
|
|
2156
2499
|
const completedAt = finiteNumber(rawStep.completedAt);
|
|
2157
2500
|
const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
|
|
2158
|
-
const rawProgress =
|
|
2501
|
+
const rawProgress = isRecord5(rawStep.progress) ? rawStep.progress : null;
|
|
2159
2502
|
stepsById[stepId] = {
|
|
2160
2503
|
stepId,
|
|
2161
2504
|
label: optionalString(rawStep.label),
|
|
@@ -2171,11 +2514,12 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2171
2514
|
progress: rawProgress ? normalizeStepProgress(rawProgress) : null
|
|
2172
2515
|
};
|
|
2173
2516
|
}
|
|
2174
|
-
const rawDatasets =
|
|
2517
|
+
const rawDatasets = isRecord5(value.datasetsById) ? value.datasetsById : {};
|
|
2175
2518
|
const datasetsById = {};
|
|
2176
2519
|
for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
|
|
2177
|
-
if (!datasetId.trim() || !
|
|
2520
|
+
if (!datasetId.trim() || !isRecord5(rawDataset)) continue;
|
|
2178
2521
|
const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
|
|
2522
|
+
const datasetBornFrom = normalizeDatasetBornFrom(rawDataset.bornFrom);
|
|
2179
2523
|
datasetsById[datasetId] = {
|
|
2180
2524
|
datasetId,
|
|
2181
2525
|
path: optionalString(rawDataset.path) ?? `datasets.${datasetId}`,
|
|
@@ -2185,10 +2529,14 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2185
2529
|
succeededRows: Math.max(0, finiteNumber(rawDataset.succeededRows) ?? 0),
|
|
2186
2530
|
failedRows: Math.max(0, finiteNumber(rawDataset.failedRows) ?? 0),
|
|
2187
2531
|
complete: rawDataset.complete === true,
|
|
2532
|
+
// ADR 0019 birth survives the snapshot round trip. A partial record is
|
|
2533
|
+
// dropped rather than half-admitted, so a dataset either states where its
|
|
2534
|
+
// rows came from or says nothing.
|
|
2535
|
+
...datasetBornFrom ? { bornFrom: datasetBornFrom } : {},
|
|
2188
2536
|
updatedAt: finiteNumber(rawDataset.updatedAt) ?? 0
|
|
2189
2537
|
};
|
|
2190
2538
|
}
|
|
2191
|
-
const rawActivities =
|
|
2539
|
+
const rawActivities = isRecord5(value.activitiesById) ? value.activitiesById : {};
|
|
2192
2540
|
const activitiesById = {};
|
|
2193
2541
|
for (const [activityId, rawActivity] of Object.entries(rawActivities)) {
|
|
2194
2542
|
if (activityId.trim() && isPlayActivityObservation(rawActivity) && rawActivity.activityId === activityId) {
|
|
@@ -2265,7 +2613,8 @@ function normalizeStepProgress(value) {
|
|
|
2265
2613
|
} : {},
|
|
2266
2614
|
...finiteNumber(value.startedAt) !== null ? { startedAt: finiteNumber(value.startedAt) } : {},
|
|
2267
2615
|
...finiteNumber(value.completedAt) !== null ? { completedAt: finiteNumber(value.completedAt) } : {},
|
|
2268
|
-
...finiteNumber(value.updatedAt) !== null ? { updatedAt: finiteNumber(value.updatedAt) } : {}
|
|
2616
|
+
...finiteNumber(value.updatedAt) !== null ? { updatedAt: finiteNumber(value.updatedAt) } : {},
|
|
2617
|
+
...normalizePlayDocflowNodeIoState(value.nodeIo) ? { nodeIo: normalizePlayDocflowNodeIoState(value.nodeIo) } : {}
|
|
2269
2618
|
};
|
|
2270
2619
|
}
|
|
2271
2620
|
|
|
@@ -2337,18 +2686,18 @@ function normalizePlayRunLiveStatus(value) {
|
|
|
2337
2686
|
function isTerminalPlayRunLiveStatus(status) {
|
|
2338
2687
|
return isTerminalPlayRunLifecycleStatus(status);
|
|
2339
2688
|
}
|
|
2340
|
-
function
|
|
2689
|
+
function isRecord6(value) {
|
|
2341
2690
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2342
2691
|
}
|
|
2343
2692
|
function finiteNumber2(value) {
|
|
2344
2693
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
2345
2694
|
}
|
|
2346
2695
|
function extractTerminalRunLogTail(result) {
|
|
2347
|
-
if (!
|
|
2696
|
+
if (!isRecord6(result) || !isRecord6(result._metadata)) {
|
|
2348
2697
|
return null;
|
|
2349
2698
|
}
|
|
2350
2699
|
const runLogTail = result._metadata.runLogTail;
|
|
2351
|
-
if (!
|
|
2700
|
+
if (!isRecord6(runLogTail) || !Array.isArray(runLogTail.tail)) {
|
|
2352
2701
|
return null;
|
|
2353
2702
|
}
|
|
2354
2703
|
const logTail = runLogTail.tail.filter(
|
|
@@ -2384,11 +2733,13 @@ function buildSnapshotFromLedger(snapshot) {
|
|
|
2384
2733
|
artifactTableNamespace: step.progress.artifactTableNamespace ?? step.artifactTableNamespace ?? null,
|
|
2385
2734
|
startedAt: step.startedAt ?? null,
|
|
2386
2735
|
completedAt: step.completedAt ?? null,
|
|
2387
|
-
updatedAt: step.progress.updatedAt ?? step.updatedAt ?? null
|
|
2736
|
+
updatedAt: step.progress.updatedAt ?? step.updatedAt ?? null,
|
|
2737
|
+
nodeIo: step.progress.nodeIo
|
|
2388
2738
|
} : null,
|
|
2389
2739
|
startedAt: step.startedAt ?? null,
|
|
2390
2740
|
completedAt: step.completedAt ?? null,
|
|
2391
|
-
updatedAt: step.updatedAt ?? null
|
|
2741
|
+
updatedAt: step.updatedAt ?? null,
|
|
2742
|
+
...step.progress?.nodeIo ? { nodeIo: step.progress.nodeIo } : {}
|
|
2392
2743
|
}));
|
|
2393
2744
|
const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
|
|
2394
2745
|
const rowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) && Object.keys(snapshot.stepsById).length > 0 ? summarizeRunRowOutcomes(snapshot) : null;
|
|
@@ -3138,8 +3489,17 @@ function resolvePlayRunRuntimeSelection(request) {
|
|
|
3138
3489
|
const configuredToken = process.env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
|
|
3139
3490
|
if (!configured) {
|
|
3140
3491
|
if (configuredNamespace || configuredToken) {
|
|
3492
|
+
const present = [];
|
|
3493
|
+
if (configuredNamespace) present.push("DEEPLINE_RUNTIME_NAMESPACE");
|
|
3494
|
+
if (configuredToken) present.push("DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN");
|
|
3495
|
+
const isPlural = present.length > 1;
|
|
3141
3496
|
throw new DeeplineError(
|
|
3142
|
-
|
|
3497
|
+
[
|
|
3498
|
+
`Incomplete play runtime selection: ${present.join(" and ")} ${isPlural ? "are" : "is"} set but DEEPLINE_RUNTIME_ENVIRONMENT is not.`,
|
|
3499
|
+
"Preview routing requires DEEPLINE_RUNTIME_ENVIRONMENT=preview together with DEEPLINE_RUNTIME_NAMESPACE; the token alone authorizes nothing.",
|
|
3500
|
+
`If you did not export ${isPlural ? "these" : "this"} yourself, ${isPlural ? "they were" : "it was"} most likely auto-loaded from a .env or .env.local in the current directory (bun loads those automatically, and in a git worktree .env.local is usually a symlink to the main checkout).`,
|
|
3501
|
+
`To run against the app-native runtime, clear ${isPlural ? "them" : "it"} for this command: ${present.map((name) => `${name}=`).join(" ")} <your deepline command>`
|
|
3502
|
+
].join("\n"),
|
|
3143
3503
|
void 0,
|
|
3144
3504
|
"INVALID_RUNTIME_ENVIRONMENT"
|
|
3145
3505
|
);
|
|
@@ -3307,7 +3667,7 @@ function requireTargetBillingIdempotencyKey(value) {
|
|
|
3307
3667
|
}
|
|
3308
3668
|
return normalized;
|
|
3309
3669
|
}
|
|
3310
|
-
function
|
|
3670
|
+
function isRecord7(value) {
|
|
3311
3671
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
3312
3672
|
}
|
|
3313
3673
|
function isPrebuiltPlayDescription(play) {
|
|
@@ -3479,7 +3839,7 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
3479
3839
|
}
|
|
3480
3840
|
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
3481
3841
|
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
3482
|
-
const progressPayload =
|
|
3842
|
+
const progressPayload = isRecord7(payload.progress) ? payload.progress : {};
|
|
3483
3843
|
if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
|
|
3484
3844
|
const payloadLogs = readStringArray(payload.logs);
|
|
3485
3845
|
const progressLogs = readStringArray(progressPayload.logs);
|
|
@@ -3622,9 +3982,9 @@ var DeeplineClient = class {
|
|
|
3622
3982
|
return fields.length > 0 ? { fields } : schema;
|
|
3623
3983
|
}
|
|
3624
3984
|
schemaMetadata(schema, key) {
|
|
3625
|
-
if (!
|
|
3985
|
+
if (!isRecord7(schema)) return null;
|
|
3626
3986
|
const value = schema[key];
|
|
3627
|
-
return
|
|
3987
|
+
return isRecord7(value) ? value : null;
|
|
3628
3988
|
}
|
|
3629
3989
|
playRunCommand(play, options) {
|
|
3630
3990
|
const target = play.reference || play.name;
|
|
@@ -3673,7 +4033,7 @@ var DeeplineClient = class {
|
|
|
3673
4033
|
aliases,
|
|
3674
4034
|
inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
|
|
3675
4035
|
outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
|
|
3676
|
-
staticPipeline:
|
|
4036
|
+
staticPipeline: isRecord7(play.staticPipeline) ? play.staticPipeline : isRecord7(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord7(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
|
|
3677
4037
|
...csvInput ? { csvInput } : {},
|
|
3678
4038
|
...rowOutputSchema ? { rowOutputSchema } : {},
|
|
3679
4039
|
runCommand,
|
|
@@ -6137,7 +6497,7 @@ function isDeeplineExtractorTarget(value) {
|
|
|
6137
6497
|
}
|
|
6138
6498
|
|
|
6139
6499
|
// ../shared_libs/plays/dataset.ts
|
|
6140
|
-
var
|
|
6500
|
+
var PLAY_DATASET_BRAND2 = /* @__PURE__ */ Symbol.for("deepline.play.dataset");
|
|
6141
6501
|
var NODE_INSPECT_CUSTOM = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
6142
6502
|
var residentRowsByDataset = /* @__PURE__ */ new WeakMap();
|
|
6143
6503
|
var DEFAULT_MATERIALIZE_LIMIT = 1e4;
|
|
@@ -6164,7 +6524,7 @@ function inferPreviewColumns(rows) {
|
|
|
6164
6524
|
return columns.size > 0 ? [...columns] : void 0;
|
|
6165
6525
|
}
|
|
6166
6526
|
var DeferredPlayDataset = class {
|
|
6167
|
-
[
|
|
6527
|
+
[PLAY_DATASET_BRAND2] = true;
|
|
6168
6528
|
datasetKind;
|
|
6169
6529
|
datasetId;
|
|
6170
6530
|
backing;
|
|
@@ -6674,7 +7034,7 @@ var TARGET_FALLBACK_KEYS = {
|
|
|
6674
7034
|
status: [/^email_status$/i, /^status$/i],
|
|
6675
7035
|
email_status: [/^email_status$/i, /^status$/i]
|
|
6676
7036
|
};
|
|
6677
|
-
function
|
|
7037
|
+
function isRecord8(value) {
|
|
6678
7038
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6679
7039
|
}
|
|
6680
7040
|
function toV2RawToolOutputPath(path) {
|
|
@@ -6734,7 +7094,7 @@ function valuesAtSegments(current, segments, path = []) {
|
|
|
6734
7094
|
if (!Array.isArray(current)) return [];
|
|
6735
7095
|
return valuesAtSegments(current[segment], rest, [...path, segment]);
|
|
6736
7096
|
}
|
|
6737
|
-
if (!
|
|
7097
|
+
if (!isRecord8(current)) return [];
|
|
6738
7098
|
const directMatches = valuesAtSegments(current[segment], rest, [
|
|
6739
7099
|
...path,
|
|
6740
7100
|
segment
|
|
@@ -6764,7 +7124,7 @@ function getValuesAtPath(root, path) {
|
|
|
6764
7124
|
return valuesAtSegments(root, parsePath(path)).map((entry) => entry.value);
|
|
6765
7125
|
}
|
|
6766
7126
|
function toResultEnvelope(value) {
|
|
6767
|
-
if (
|
|
7127
|
+
if (isRecord8(value) && "data" in value) {
|
|
6768
7128
|
const envelope = { data: value.data };
|
|
6769
7129
|
if ("meta" in value) envelope.meta = value.meta;
|
|
6770
7130
|
return envelope;
|
|
@@ -6817,7 +7177,7 @@ function getAtPath(root, path) {
|
|
|
6817
7177
|
current = current[segment];
|
|
6818
7178
|
continue;
|
|
6819
7179
|
}
|
|
6820
|
-
if (!
|
|
7180
|
+
if (!isRecord8(current)) return void 0;
|
|
6821
7181
|
current = current[segment];
|
|
6822
7182
|
}
|
|
6823
7183
|
return current;
|
|
@@ -6834,7 +7194,7 @@ function normalizeString(value) {
|
|
|
6834
7194
|
}
|
|
6835
7195
|
function normalizeRows(value) {
|
|
6836
7196
|
if (!Array.isArray(value)) return null;
|
|
6837
|
-
return value.map((entry) =>
|
|
7197
|
+
return value.map((entry) => isRecord8(entry) ? entry : { value: entry });
|
|
6838
7198
|
}
|
|
6839
7199
|
function findFirstTargetByPath(result, paths) {
|
|
6840
7200
|
for (const path of paths ?? []) {
|
|
@@ -6893,7 +7253,7 @@ function findFirstTargetByKey(result, target, depth = 0, path = []) {
|
|
|
6893
7253
|
}
|
|
6894
7254
|
return null;
|
|
6895
7255
|
}
|
|
6896
|
-
if (!
|
|
7256
|
+
if (!isRecord8(result)) return null;
|
|
6897
7257
|
const patterns = TARGET_FALLBACK_KEYS[target] ?? [
|
|
6898
7258
|
new RegExp(`^${target}$`, "i")
|
|
6899
7259
|
];
|
|
@@ -6953,7 +7313,7 @@ function normalizeJobChangeStatus(value) {
|
|
|
6953
7313
|
function firstExperienceDate(value) {
|
|
6954
7314
|
if (!Array.isArray(value)) return null;
|
|
6955
7315
|
for (const entry of value) {
|
|
6956
|
-
if (!
|
|
7316
|
+
if (!isRecord8(entry)) continue;
|
|
6957
7317
|
const date = normalizeString(
|
|
6958
7318
|
entry.start_date ?? entry.started_at ?? entry.startDate
|
|
6959
7319
|
);
|
|
@@ -6962,10 +7322,10 @@ function firstExperienceDate(value) {
|
|
|
6962
7322
|
return null;
|
|
6963
7323
|
}
|
|
6964
7324
|
function normalizeJobChange(value) {
|
|
6965
|
-
const record =
|
|
6966
|
-
const nested =
|
|
6967
|
-
const output =
|
|
6968
|
-
const person =
|
|
7325
|
+
const record = isRecord8(value) ? value : {};
|
|
7326
|
+
const nested = isRecord8(record.job_change) ? record.job_change : record;
|
|
7327
|
+
const output = isRecord8(nested.output) ? nested.output : nested;
|
|
7328
|
+
const person = isRecord8(output.person) ? output.person : {};
|
|
6969
7329
|
const status = normalizeJobChangeStatus(
|
|
6970
7330
|
output.status ?? output.job_change_status ?? output.job_changed ?? output.changed
|
|
6971
7331
|
);
|
|
@@ -7339,7 +7699,7 @@ function attachToolResultListDataset(result, input) {
|
|
|
7339
7699
|
root = replaceAtPath(root, candidate, serialized.preview);
|
|
7340
7700
|
break;
|
|
7341
7701
|
}
|
|
7342
|
-
if (
|
|
7702
|
+
if (isRecord8(root) && isRecord8(root.toolResponse) && Object.prototype.hasOwnProperty.call(root.toolResponse, "raw")) {
|
|
7343
7703
|
result.toolResponse.raw = root.toolResponse.raw;
|
|
7344
7704
|
result.toolOutput.raw = root.toolResponse.raw;
|
|
7345
7705
|
}
|
|
@@ -7357,7 +7717,7 @@ function replaceAtPath(root, path, replacement) {
|
|
|
7357
7717
|
copy[segment] = replace(copy[segment], index + 1);
|
|
7358
7718
|
return copy;
|
|
7359
7719
|
}
|
|
7360
|
-
if (!
|
|
7720
|
+
if (!isRecord8(current)) return current;
|
|
7361
7721
|
return {
|
|
7362
7722
|
...current,
|
|
7363
7723
|
[segment]: replace(current[segment], index + 1)
|
|
@@ -7701,11 +8061,11 @@ var Deepline = class {
|
|
|
7701
8061
|
return new DeeplineContext(options);
|
|
7702
8062
|
}
|
|
7703
8063
|
};
|
|
7704
|
-
function
|
|
8064
|
+
function isRecord9(value) {
|
|
7705
8065
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7706
8066
|
}
|
|
7707
8067
|
function stringArrayRecord(value) {
|
|
7708
|
-
if (!
|
|
8068
|
+
if (!isRecord9(value)) return {};
|
|
7709
8069
|
return Object.fromEntries(
|
|
7710
8070
|
Object.entries(value).map(([key, paths]) => [
|
|
7711
8071
|
key,
|
|
@@ -7717,7 +8077,7 @@ function stringArray(value) {
|
|
|
7717
8077
|
return Array.isArray(value) ? value.map(String) : [];
|
|
7718
8078
|
}
|
|
7719
8079
|
function emailStatusExtractorConfig(value) {
|
|
7720
|
-
if (!
|
|
8080
|
+
if (!isRecord9(value)) return void 0;
|
|
7721
8081
|
const readPaths = (key) => {
|
|
7722
8082
|
const paths = stringArray(value[key]).map((path) => path.trim()).filter(Boolean);
|
|
7723
8083
|
return paths.length > 0 ? paths : void 0;
|
|
@@ -7744,7 +8104,7 @@ function emailStatusExtractorConfig(value) {
|
|
|
7744
8104
|
const paths = readPaths(key);
|
|
7745
8105
|
if (paths) config[key] = paths;
|
|
7746
8106
|
}
|
|
7747
|
-
if (
|
|
8107
|
+
if (isRecord9(value.statusMap)) {
|
|
7748
8108
|
config.statusMap = value.statusMap;
|
|
7749
8109
|
}
|
|
7750
8110
|
if (Array.isArray(value.rules)) {
|
|
@@ -7753,10 +8113,10 @@ function emailStatusExtractorConfig(value) {
|
|
|
7753
8113
|
return config;
|
|
7754
8114
|
}
|
|
7755
8115
|
function extractorDescriptorRecord(value) {
|
|
7756
|
-
if (!
|
|
8116
|
+
if (!isRecord9(value)) return {};
|
|
7757
8117
|
return Object.fromEntries(
|
|
7758
8118
|
Object.entries(value).flatMap(([key, descriptor]) => {
|
|
7759
|
-
if (!
|
|
8119
|
+
if (!isRecord9(descriptor)) return [];
|
|
7760
8120
|
const paths = stringArray(descriptor.paths).map((path) => path.trim()).filter(Boolean);
|
|
7761
8121
|
if (paths.length === 0) return [];
|
|
7762
8122
|
const transforms = stringArray(descriptor.transforms).map((transform) => transform.trim()).filter(Boolean);
|
|
@@ -7778,16 +8138,16 @@ function extractorDescriptorRecord(value) {
|
|
|
7778
8138
|
}
|
|
7779
8139
|
function rowsFromUnknown(value) {
|
|
7780
8140
|
if (!Array.isArray(value)) return [];
|
|
7781
|
-
return value.map((row) =>
|
|
8141
|
+
return value.map((row) => isRecord9(row) ? row : { value: row });
|
|
7782
8142
|
}
|
|
7783
|
-
function
|
|
8143
|
+
function finiteNonNegativeInteger3(value) {
|
|
7784
8144
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
7785
8145
|
return null;
|
|
7786
8146
|
}
|
|
7787
8147
|
return Math.floor(value);
|
|
7788
8148
|
}
|
|
7789
8149
|
function finitePositiveInteger(value) {
|
|
7790
|
-
const integer =
|
|
8150
|
+
const integer = finiteNonNegativeInteger3(value);
|
|
7791
8151
|
return integer !== null && integer > 0 ? integer : null;
|
|
7792
8152
|
}
|
|
7793
8153
|
function stableHash(value) {
|
|
@@ -7800,9 +8160,9 @@ function stableHash(value) {
|
|
|
7800
8160
|
}
|
|
7801
8161
|
function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
7802
8162
|
if (!options || !isQueryResultDatasetTool(toolId)) return result;
|
|
7803
|
-
const raw =
|
|
7804
|
-
const dataset =
|
|
7805
|
-
const totalRows =
|
|
8163
|
+
const raw = isRecord9(result.toolResponse.raw) ? result.toolResponse.raw : null;
|
|
8164
|
+
const dataset = isRecord9(raw?.dataset) ? raw.dataset : null;
|
|
8165
|
+
const totalRows = finiteNonNegativeInteger3(dataset?.total_rows);
|
|
7806
8166
|
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;
|
|
7807
8167
|
if (!dataset || totalRows === null || !sql) {
|
|
7808
8168
|
return result;
|
|
@@ -7833,7 +8193,7 @@ function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
|
7833
8193
|
} : {}
|
|
7834
8194
|
}
|
|
7835
8195
|
});
|
|
7836
|
-
const pageRaw =
|
|
8196
|
+
const pageRaw = isRecord9(response.toolResponse?.raw) ? response.toolResponse.raw : null;
|
|
7837
8197
|
return rowsFromUnknown(pageRaw?.rows);
|
|
7838
8198
|
};
|
|
7839
8199
|
const collectRows = async (limit) => {
|
|
@@ -7888,8 +8248,8 @@ function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
|
7888
8248
|
function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
7889
8249
|
const raw = response.toolResponse?.raw ?? null;
|
|
7890
8250
|
const meta = response.toolResponse?.meta;
|
|
7891
|
-
const metadata =
|
|
7892
|
-
const toolMetadata =
|
|
8251
|
+
const metadata = isRecord9(response._metadata) ? response._metadata.tool : null;
|
|
8252
|
+
const toolMetadata = isRecord9(metadata) ? metadata : {};
|
|
7893
8253
|
return attachSdkQueryResultDatasetResult(
|
|
7894
8254
|
fallbackToolId,
|
|
7895
8255
|
createToolExecuteResult({
|
|
@@ -7897,7 +8257,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
|
7897
8257
|
jobId: typeof response.job_id === "string" ? response.job_id : void 0,
|
|
7898
8258
|
result: {
|
|
7899
8259
|
data: raw,
|
|
7900
|
-
...
|
|
8260
|
+
...isRecord9(meta) ? { meta } : {}
|
|
7901
8261
|
},
|
|
7902
8262
|
metadata: {
|
|
7903
8263
|
toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
|
|
@@ -7913,7 +8273,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
|
7913
8273
|
cached: false,
|
|
7914
8274
|
source: "live"
|
|
7915
8275
|
},
|
|
7916
|
-
meta:
|
|
8276
|
+
meta: isRecord9(response.meta) ? response.meta : void 0
|
|
7917
8277
|
}),
|
|
7918
8278
|
options
|
|
7919
8279
|
);
|