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.mjs
CHANGED
|
@@ -689,7 +689,7 @@ var SDK_RELEASE = {
|
|
|
689
689
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
690
690
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
691
691
|
// release keeps lazy paging semantics independent of row residency.
|
|
692
|
-
version: "0.2.
|
|
692
|
+
version: "0.2.55",
|
|
693
693
|
contracts: {
|
|
694
694
|
api: {
|
|
695
695
|
name: "sdk-http-api",
|
|
@@ -1624,7 +1624,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1624
1624
|
if (value.length >= 4) exactSecrets.add(value);
|
|
1625
1625
|
}
|
|
1626
1626
|
for (const value of initialValues) register(value);
|
|
1627
|
-
function
|
|
1627
|
+
function redactString2(value) {
|
|
1628
1628
|
let output = value;
|
|
1629
1629
|
for (const secret of exactSecrets) {
|
|
1630
1630
|
output = output.replace(
|
|
@@ -1645,7 +1645,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1645
1645
|
return redactSecretLikeString(output);
|
|
1646
1646
|
}
|
|
1647
1647
|
function redact(value) {
|
|
1648
|
-
if (typeof value === "string") return
|
|
1648
|
+
if (typeof value === "string") return redactString2(value);
|
|
1649
1649
|
if (Array.isArray(value)) return value.map((entry) => redact(entry));
|
|
1650
1650
|
if (value && typeof value === "object") {
|
|
1651
1651
|
return Object.fromEntries(
|
|
@@ -1658,7 +1658,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1658
1658
|
return value;
|
|
1659
1659
|
}
|
|
1660
1660
|
function redactKnownSecrets(value) {
|
|
1661
|
-
if (typeof value === "string") return
|
|
1661
|
+
if (typeof value === "string") return redactString2(value);
|
|
1662
1662
|
if (Array.isArray(value)) {
|
|
1663
1663
|
return value.map((entry) => redactKnownSecrets(entry));
|
|
1664
1664
|
}
|
|
@@ -1674,7 +1674,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
return {
|
|
1676
1676
|
register,
|
|
1677
|
-
redactString,
|
|
1677
|
+
redactString: redactString2,
|
|
1678
1678
|
redactKnownSecrets,
|
|
1679
1679
|
redact
|
|
1680
1680
|
};
|
|
@@ -1694,12 +1694,334 @@ var RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES = 64 * 1024;
|
|
|
1694
1694
|
// ../shared_libs/play-runtime/ledger-safe-payload.ts
|
|
1695
1695
|
var ledgerIngressRedactor = createSecretRedactionContext();
|
|
1696
1696
|
|
|
1697
|
-
// ../shared_libs/play-runtime/
|
|
1697
|
+
// ../shared_libs/play-runtime/docflow-node-io.ts
|
|
1698
|
+
var DOCFLOW_NODE_IO_LIMITS = {
|
|
1699
|
+
maxPaths: 16,
|
|
1700
|
+
maxDepth: 3,
|
|
1701
|
+
maxObjectFields: 12,
|
|
1702
|
+
maxArrayItems: 3,
|
|
1703
|
+
maxStringBytes: 256,
|
|
1704
|
+
maxPhaseBytes: 2e3,
|
|
1705
|
+
maxErrorBytes: 512
|
|
1706
|
+
};
|
|
1707
|
+
var utf8Encoder = new TextEncoder();
|
|
1708
|
+
var PLAY_DATASET_BRAND = /* @__PURE__ */ Symbol.for("deepline.play.dataset");
|
|
1709
|
+
function ledgerSafeDocflowPreviewKey(key) {
|
|
1710
|
+
if (!key.startsWith("$")) return key;
|
|
1711
|
+
const stripped = key.replace(/^\$+/, "");
|
|
1712
|
+
return stripped || "output";
|
|
1713
|
+
}
|
|
1714
|
+
function utf8Bytes(value) {
|
|
1715
|
+
return utf8Encoder.encode(value).byteLength;
|
|
1716
|
+
}
|
|
1717
|
+
function truncateUtf8(value, maxBytes) {
|
|
1718
|
+
if (utf8Bytes(value) <= maxBytes) return value;
|
|
1719
|
+
let output = "";
|
|
1720
|
+
for (const character of value) {
|
|
1721
|
+
if (utf8Bytes(`${output}${character}\u2026`) > maxBytes) break;
|
|
1722
|
+
output += character;
|
|
1723
|
+
}
|
|
1724
|
+
return `${output}\u2026`;
|
|
1725
|
+
}
|
|
1726
|
+
function redactString(redactor, value, key) {
|
|
1727
|
+
if (!key) return redactor.redactString(value);
|
|
1728
|
+
const wrapped = redactor.redact({ [key]: value });
|
|
1729
|
+
return typeof wrapped[key] === "string" ? wrapped[key] : redactor.redactString(value);
|
|
1730
|
+
}
|
|
1731
|
+
function safeString(value, redactor, key) {
|
|
1732
|
+
if (typeof value !== "string") return void 0;
|
|
1733
|
+
return truncateUtf8(
|
|
1734
|
+
redactString(redactor, value, key),
|
|
1735
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
1736
|
+
);
|
|
1737
|
+
}
|
|
1738
|
+
function previewValue(value, input) {
|
|
1739
|
+
if (value === null) return { kind: "null" };
|
|
1740
|
+
if (value === void 0) return { kind: "unavailable", reason: "undefined" };
|
|
1741
|
+
if (typeof value === "string") {
|
|
1742
|
+
return {
|
|
1743
|
+
kind: "scalar",
|
|
1744
|
+
value: safeString(value, input.redactor, input.key) ?? ""
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
if (typeof value === "number") {
|
|
1748
|
+
return Number.isFinite(value) ? { kind: "scalar", value } : { kind: "unavailable", reason: "unsupported" };
|
|
1749
|
+
}
|
|
1750
|
+
if (typeof value === "boolean") return { kind: "scalar", value };
|
|
1751
|
+
if (typeof value === "bigint") {
|
|
1752
|
+
return { kind: "unavailable", reason: "bigint" };
|
|
1753
|
+
}
|
|
1754
|
+
if (typeof value === "function") {
|
|
1755
|
+
return { kind: "unavailable", reason: "function" };
|
|
1756
|
+
}
|
|
1757
|
+
if (typeof value === "symbol") {
|
|
1758
|
+
return { kind: "unavailable", reason: "symbol" };
|
|
1759
|
+
}
|
|
1760
|
+
if (typeof value !== "object") {
|
|
1761
|
+
return { kind: "unavailable", reason: "unsupported" };
|
|
1762
|
+
}
|
|
1763
|
+
try {
|
|
1764
|
+
const brand = readDataProperty(value, PLAY_DATASET_BRAND);
|
|
1765
|
+
const datasetKind = readDataProperty(value, "datasetKind");
|
|
1766
|
+
const datasetId = readDataProperty(value, "datasetId");
|
|
1767
|
+
const tableNamespace = readDataProperty(value, "tableNamespace");
|
|
1768
|
+
if (brand.ok && brand.value === true && datasetKind.ok && (datasetKind.value === "csv" || datasetKind.value === "map") && datasetId.ok && typeof datasetId.value === "string") {
|
|
1769
|
+
return {
|
|
1770
|
+
kind: "dataset",
|
|
1771
|
+
datasetId: safeString(datasetId.value, input.redactor, "datasetId") ?? "dataset",
|
|
1772
|
+
datasetKind: datasetKind.value,
|
|
1773
|
+
tableNamespace: tableNamespace.ok && tableNamespace.value === null ? null : tableNamespace.ok ? safeString(
|
|
1774
|
+
tableNamespace.value,
|
|
1775
|
+
input.redactor,
|
|
1776
|
+
"tableNamespace"
|
|
1777
|
+
) : void 0
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
const kind = readDataProperty(value, "kind");
|
|
1781
|
+
const count = readDataProperty(value, "count");
|
|
1782
|
+
const preview = readDataProperty(value, "preview");
|
|
1783
|
+
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)) {
|
|
1784
|
+
return {
|
|
1785
|
+
kind: "dataset",
|
|
1786
|
+
datasetId: safeString(datasetId.value, input.redactor, "datasetId") ?? "dataset",
|
|
1787
|
+
datasetKind: datasetKind.value,
|
|
1788
|
+
tableNamespace: tableNamespace.ok && tableNamespace.value === null ? null : tableNamespace.ok ? safeString(
|
|
1789
|
+
tableNamespace.value,
|
|
1790
|
+
input.redactor,
|
|
1791
|
+
"tableNamespace"
|
|
1792
|
+
) : void 0,
|
|
1793
|
+
rowCount: Math.max(0, Math.floor(count.value))
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
} catch {
|
|
1797
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
1798
|
+
}
|
|
1799
|
+
if (input.ancestors.has(value)) {
|
|
1800
|
+
return { kind: "unavailable", reason: "cycle" };
|
|
1801
|
+
}
|
|
1802
|
+
if (input.depth >= DOCFLOW_NODE_IO_LIMITS.maxDepth) {
|
|
1803
|
+
return { kind: "unavailable", reason: "depth" };
|
|
1804
|
+
}
|
|
1805
|
+
input.ancestors.add(value);
|
|
1806
|
+
try {
|
|
1807
|
+
if (Array.isArray(value)) {
|
|
1808
|
+
const items = [];
|
|
1809
|
+
for (let index = 0; index < Math.min(value.length, DOCFLOW_NODE_IO_LIMITS.maxArrayItems); index += 1) {
|
|
1810
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1811
|
+
value,
|
|
1812
|
+
String(index)
|
|
1813
|
+
);
|
|
1814
|
+
items.push(
|
|
1815
|
+
descriptor && "value" in descriptor ? previewValue(descriptor.value, {
|
|
1816
|
+
...input,
|
|
1817
|
+
depth: input.depth + 1
|
|
1818
|
+
}) : { kind: "unavailable", reason: "access_error" }
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
return {
|
|
1822
|
+
kind: "array",
|
|
1823
|
+
items,
|
|
1824
|
+
totalItems: value.length,
|
|
1825
|
+
...value.length > items.length ? { truncated: true } : {}
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
let descriptors;
|
|
1829
|
+
try {
|
|
1830
|
+
descriptors = Object.getOwnPropertyDescriptors(value);
|
|
1831
|
+
} catch {
|
|
1832
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
1833
|
+
}
|
|
1834
|
+
const entries = Object.entries(descriptors).filter(
|
|
1835
|
+
([, descriptor]) => descriptor.enumerable
|
|
1836
|
+
);
|
|
1837
|
+
const selected = entries.slice(0, DOCFLOW_NODE_IO_LIMITS.maxObjectFields);
|
|
1838
|
+
const fields = {};
|
|
1839
|
+
for (const [key, descriptor] of selected) {
|
|
1840
|
+
const safeKey = truncateUtf8(
|
|
1841
|
+
ledgerSafeDocflowPreviewKey(input.redactor.redactString(key)),
|
|
1842
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
1843
|
+
);
|
|
1844
|
+
fields[safeKey] = "value" in descriptor ? previewValue(descriptor.value, {
|
|
1845
|
+
...input,
|
|
1846
|
+
depth: input.depth + 1,
|
|
1847
|
+
key
|
|
1848
|
+
}) : { kind: "unavailable", reason: "access_error" };
|
|
1849
|
+
}
|
|
1850
|
+
return {
|
|
1851
|
+
kind: "object",
|
|
1852
|
+
fields,
|
|
1853
|
+
totalFields: entries.length,
|
|
1854
|
+
...entries.length > selected.length ? { truncated: true } : {}
|
|
1855
|
+
};
|
|
1856
|
+
} catch {
|
|
1857
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
1858
|
+
} finally {
|
|
1859
|
+
input.ancestors.delete(value);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
function readDataProperty(value, property) {
|
|
1863
|
+
if ((typeof value !== "object" || value === null) && typeof value !== "function") {
|
|
1864
|
+
return { ok: false };
|
|
1865
|
+
}
|
|
1866
|
+
try {
|
|
1867
|
+
let owner = value;
|
|
1868
|
+
while (owner) {
|
|
1869
|
+
const descriptor = Object.getOwnPropertyDescriptor(owner, property);
|
|
1870
|
+
if (descriptor) {
|
|
1871
|
+
return "value" in descriptor ? { ok: true, value: descriptor.value } : { ok: false };
|
|
1872
|
+
}
|
|
1873
|
+
owner = Object.getPrototypeOf(owner);
|
|
1874
|
+
}
|
|
1875
|
+
} catch {
|
|
1876
|
+
return { ok: false };
|
|
1877
|
+
}
|
|
1878
|
+
return { ok: false };
|
|
1879
|
+
}
|
|
1880
|
+
function buildPlayDocflowNodeErrorPreview(error, redactor = createSecretRedactionContext()) {
|
|
1881
|
+
try {
|
|
1882
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1883
|
+
return truncateUtf8(
|
|
1884
|
+
redactor.redactString(message),
|
|
1885
|
+
DOCFLOW_NODE_IO_LIMITS.maxErrorBytes
|
|
1886
|
+
);
|
|
1887
|
+
} catch {
|
|
1888
|
+
return "Non-Error value thrown (message unavailable)";
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1698
1891
|
function isRecord3(value) {
|
|
1699
1892
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1700
1893
|
}
|
|
1894
|
+
function normalizePreview(value, depth) {
|
|
1895
|
+
if (!isRecord3(value) || typeof value.kind !== "string") return null;
|
|
1896
|
+
if (value.kind === "null") return { kind: "null" };
|
|
1897
|
+
if (value.kind === "scalar") {
|
|
1898
|
+
if (typeof value.value === "string" || typeof value.value === "boolean" || typeof value.value === "number" && Number.isFinite(value.value)) {
|
|
1899
|
+
return previewValue(value.value, {
|
|
1900
|
+
depth: 0,
|
|
1901
|
+
ancestors: /* @__PURE__ */ new WeakSet(),
|
|
1902
|
+
redactor: createSecretRedactionContext()
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
return null;
|
|
1906
|
+
}
|
|
1907
|
+
if (value.kind === "unavailable") {
|
|
1908
|
+
const reason = value.reason;
|
|
1909
|
+
return typeof reason === "string" && [
|
|
1910
|
+
"undefined",
|
|
1911
|
+
"function",
|
|
1912
|
+
"symbol",
|
|
1913
|
+
"bigint",
|
|
1914
|
+
"cycle",
|
|
1915
|
+
"depth",
|
|
1916
|
+
"access_error",
|
|
1917
|
+
"limit",
|
|
1918
|
+
"unsupported"
|
|
1919
|
+
].includes(reason) ? {
|
|
1920
|
+
kind: "unavailable",
|
|
1921
|
+
reason
|
|
1922
|
+
} : null;
|
|
1923
|
+
}
|
|
1924
|
+
if (value.kind === "dataset") {
|
|
1925
|
+
const datasetId = safeString(
|
|
1926
|
+
value.datasetId,
|
|
1927
|
+
createSecretRedactionContext(),
|
|
1928
|
+
"datasetId"
|
|
1929
|
+
);
|
|
1930
|
+
if (!datasetId || value.datasetKind !== "csv" && value.datasetKind !== "map") {
|
|
1931
|
+
return null;
|
|
1932
|
+
}
|
|
1933
|
+
return {
|
|
1934
|
+
kind: "dataset",
|
|
1935
|
+
datasetId,
|
|
1936
|
+
datasetKind: value.datasetKind,
|
|
1937
|
+
...value.tableNamespace === null ? { tableNamespace: null } : typeof value.tableNamespace === "string" ? {
|
|
1938
|
+
tableNamespace: safeString(
|
|
1939
|
+
value.tableNamespace,
|
|
1940
|
+
createSecretRedactionContext(),
|
|
1941
|
+
"tableNamespace"
|
|
1942
|
+
)
|
|
1943
|
+
} : {},
|
|
1944
|
+
...typeof value.rowCount === "number" && Number.isFinite(value.rowCount) ? { rowCount: Math.max(0, Math.floor(value.rowCount)) } : {}
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
if (depth >= DOCFLOW_NODE_IO_LIMITS.maxDepth) {
|
|
1948
|
+
return { kind: "unavailable", reason: "depth" };
|
|
1949
|
+
}
|
|
1950
|
+
if (value.kind === "array" && Array.isArray(value.items)) {
|
|
1951
|
+
const items = value.items.slice(0, DOCFLOW_NODE_IO_LIMITS.maxArrayItems).map((item) => normalizePreview(item, depth + 1)).filter((item) => item !== null);
|
|
1952
|
+
const totalItems = typeof value.totalItems === "number" && Number.isFinite(value.totalItems) ? Math.max(items.length, Math.floor(value.totalItems)) : items.length;
|
|
1953
|
+
return {
|
|
1954
|
+
kind: "array",
|
|
1955
|
+
items,
|
|
1956
|
+
totalItems,
|
|
1957
|
+
...value.truncated === true || totalItems > items.length ? { truncated: true } : {}
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
if (value.kind === "object" && isRecord3(value.fields)) {
|
|
1961
|
+
const fields = {};
|
|
1962
|
+
for (const [key, field] of Object.entries(value.fields).slice(
|
|
1963
|
+
0,
|
|
1964
|
+
DOCFLOW_NODE_IO_LIMITS.maxObjectFields
|
|
1965
|
+
)) {
|
|
1966
|
+
const normalized = normalizePreview(field, depth + 1);
|
|
1967
|
+
if (normalized) fields[ledgerSafeDocflowPreviewKey(key)] = normalized;
|
|
1968
|
+
}
|
|
1969
|
+
const totalFields = typeof value.totalFields === "number" && Number.isFinite(value.totalFields) ? Math.max(Object.keys(fields).length, Math.floor(value.totalFields)) : Object.keys(fields).length;
|
|
1970
|
+
return {
|
|
1971
|
+
kind: "object",
|
|
1972
|
+
fields,
|
|
1973
|
+
totalFields,
|
|
1974
|
+
...value.truncated === true || totalFields > Object.keys(fields).length ? { truncated: true } : {}
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
return null;
|
|
1978
|
+
}
|
|
1979
|
+
function normalizePlayDocflowNodeIoState(value) {
|
|
1980
|
+
if (!isRecord3(value)) return void 0;
|
|
1981
|
+
const attempt = typeof value.attempt === "number" && Number.isFinite(value.attempt) ? Math.max(0, Math.floor(value.attempt)) : 0;
|
|
1982
|
+
const normalizeMap = (raw) => {
|
|
1983
|
+
if (!isRecord3(raw)) return void 0;
|
|
1984
|
+
const output = {};
|
|
1985
|
+
for (const [path, preview] of Object.entries(raw).slice(
|
|
1986
|
+
0,
|
|
1987
|
+
DOCFLOW_NODE_IO_LIMITS.maxPaths
|
|
1988
|
+
)) {
|
|
1989
|
+
const normalized = normalizePreview(preview, 0);
|
|
1990
|
+
if (!normalized) continue;
|
|
1991
|
+
const safePath = ledgerSafeDocflowPreviewKey(path);
|
|
1992
|
+
const candidate = { ...output, [safePath]: normalized };
|
|
1993
|
+
if (utf8Bytes(JSON.stringify(candidate)) > DOCFLOW_NODE_IO_LIMITS.maxPhaseBytes) {
|
|
1994
|
+
break;
|
|
1995
|
+
}
|
|
1996
|
+
output[safePath] = normalized;
|
|
1997
|
+
}
|
|
1998
|
+
return output;
|
|
1999
|
+
};
|
|
2000
|
+
const inputs = normalizeMap(value.inputs);
|
|
2001
|
+
const outputs = normalizeMap(value.outputs);
|
|
2002
|
+
const error = typeof value.error === "string" ? buildPlayDocflowNodeErrorPreview(value.error) : value.error === null ? null : void 0;
|
|
2003
|
+
return {
|
|
2004
|
+
attempt,
|
|
2005
|
+
...typeof value.invocationId === "string" && value.invocationId.trim() ? {
|
|
2006
|
+
invocationId: truncateUtf8(
|
|
2007
|
+
value.invocationId.trim(),
|
|
2008
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
2009
|
+
)
|
|
2010
|
+
} : {},
|
|
2011
|
+
...inputs ? { inputs } : {},
|
|
2012
|
+
...outputs ? { outputs } : {},
|
|
2013
|
+
...value.inputsTruncated === true ? { inputsTruncated: true } : {},
|
|
2014
|
+
...value.outputsTruncated === true ? { outputsTruncated: true } : {},
|
|
2015
|
+
...error !== void 0 ? { error } : {}
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
// ../shared_libs/play-runtime/activity-observation.ts
|
|
2020
|
+
function isRecord4(value) {
|
|
2021
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2022
|
+
}
|
|
1701
2023
|
function isPlayActivityObservation(value) {
|
|
1702
|
-
if (!
|
|
2024
|
+
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)) {
|
|
1703
2025
|
return false;
|
|
1704
2026
|
}
|
|
1705
2027
|
const targetKinds = /* @__PURE__ */ new Set([
|
|
@@ -1969,9 +2291,30 @@ function projectPlayRunActivity(input) {
|
|
|
1969
2291
|
return projection(fallback, now, normalizedStatus !== "waiting");
|
|
1970
2292
|
}
|
|
1971
2293
|
|
|
2294
|
+
// ../shared_libs/play-runtime/cell-provenance.ts
|
|
2295
|
+
function finiteNonNegativeInteger2(value) {
|
|
2296
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
2297
|
+
return null;
|
|
2298
|
+
}
|
|
2299
|
+
return Math.trunc(value);
|
|
2300
|
+
}
|
|
2301
|
+
function nonEmptyString(value) {
|
|
2302
|
+
if (typeof value !== "string") return null;
|
|
2303
|
+
const trimmed = value.trim();
|
|
2304
|
+
return trimmed ? trimmed : null;
|
|
2305
|
+
}
|
|
2306
|
+
function normalizeDatasetBornFrom(value) {
|
|
2307
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
2308
|
+
const record = value;
|
|
2309
|
+
const table = nonEmptyString(record.table);
|
|
2310
|
+
const rowCountIn = finiteNonNegativeInteger2(record.rowCountIn);
|
|
2311
|
+
if (!table || rowCountIn === null) return null;
|
|
2312
|
+
return { table, rowCountIn };
|
|
2313
|
+
}
|
|
2314
|
+
|
|
1972
2315
|
// ../shared_libs/play-runtime/run-ledger.ts
|
|
1973
2316
|
var LOG_TAIL_LIMIT = 100;
|
|
1974
|
-
function
|
|
2317
|
+
function isRecord5(value) {
|
|
1975
2318
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1976
2319
|
}
|
|
1977
2320
|
function finiteNumber(value) {
|
|
@@ -2067,21 +2410,21 @@ function createEmptyPlayRunLedgerSnapshot(input) {
|
|
|
2067
2410
|
};
|
|
2068
2411
|
}
|
|
2069
2412
|
function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
2070
|
-
if (!
|
|
2413
|
+
if (!isRecord5(value)) {
|
|
2071
2414
|
return createEmptyPlayRunLedgerSnapshot(fallback);
|
|
2072
2415
|
}
|
|
2073
2416
|
const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
|
|
2074
2417
|
(entry) => typeof entry === "string" && Boolean(entry.trim())
|
|
2075
2418
|
) : [];
|
|
2076
|
-
const rawSteps =
|
|
2419
|
+
const rawSteps = isRecord5(value.stepsById) ? value.stepsById : {};
|
|
2077
2420
|
const stepsById = {};
|
|
2078
2421
|
for (const [stepId, rawStep] of Object.entries(rawSteps)) {
|
|
2079
|
-
if (!stepId.trim() || !
|
|
2422
|
+
if (!stepId.trim() || !isRecord5(rawStep)) continue;
|
|
2080
2423
|
const rawStatus = normalizeStepStatus(rawStep.status);
|
|
2081
2424
|
if (!rawStatus) continue;
|
|
2082
2425
|
const completedAt = finiteNumber(rawStep.completedAt);
|
|
2083
2426
|
const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
|
|
2084
|
-
const rawProgress =
|
|
2427
|
+
const rawProgress = isRecord5(rawStep.progress) ? rawStep.progress : null;
|
|
2085
2428
|
stepsById[stepId] = {
|
|
2086
2429
|
stepId,
|
|
2087
2430
|
label: optionalString(rawStep.label),
|
|
@@ -2097,11 +2440,12 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2097
2440
|
progress: rawProgress ? normalizeStepProgress(rawProgress) : null
|
|
2098
2441
|
};
|
|
2099
2442
|
}
|
|
2100
|
-
const rawDatasets =
|
|
2443
|
+
const rawDatasets = isRecord5(value.datasetsById) ? value.datasetsById : {};
|
|
2101
2444
|
const datasetsById = {};
|
|
2102
2445
|
for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
|
|
2103
|
-
if (!datasetId.trim() || !
|
|
2446
|
+
if (!datasetId.trim() || !isRecord5(rawDataset)) continue;
|
|
2104
2447
|
const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
|
|
2448
|
+
const datasetBornFrom = normalizeDatasetBornFrom(rawDataset.bornFrom);
|
|
2105
2449
|
datasetsById[datasetId] = {
|
|
2106
2450
|
datasetId,
|
|
2107
2451
|
path: optionalString(rawDataset.path) ?? `datasets.${datasetId}`,
|
|
@@ -2111,10 +2455,14 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2111
2455
|
succeededRows: Math.max(0, finiteNumber(rawDataset.succeededRows) ?? 0),
|
|
2112
2456
|
failedRows: Math.max(0, finiteNumber(rawDataset.failedRows) ?? 0),
|
|
2113
2457
|
complete: rawDataset.complete === true,
|
|
2458
|
+
// ADR 0019 birth survives the snapshot round trip. A partial record is
|
|
2459
|
+
// dropped rather than half-admitted, so a dataset either states where its
|
|
2460
|
+
// rows came from or says nothing.
|
|
2461
|
+
...datasetBornFrom ? { bornFrom: datasetBornFrom } : {},
|
|
2114
2462
|
updatedAt: finiteNumber(rawDataset.updatedAt) ?? 0
|
|
2115
2463
|
};
|
|
2116
2464
|
}
|
|
2117
|
-
const rawActivities =
|
|
2465
|
+
const rawActivities = isRecord5(value.activitiesById) ? value.activitiesById : {};
|
|
2118
2466
|
const activitiesById = {};
|
|
2119
2467
|
for (const [activityId, rawActivity] of Object.entries(rawActivities)) {
|
|
2120
2468
|
if (activityId.trim() && isPlayActivityObservation(rawActivity) && rawActivity.activityId === activityId) {
|
|
@@ -2191,7 +2539,8 @@ function normalizeStepProgress(value) {
|
|
|
2191
2539
|
} : {},
|
|
2192
2540
|
...finiteNumber(value.startedAt) !== null ? { startedAt: finiteNumber(value.startedAt) } : {},
|
|
2193
2541
|
...finiteNumber(value.completedAt) !== null ? { completedAt: finiteNumber(value.completedAt) } : {},
|
|
2194
|
-
...finiteNumber(value.updatedAt) !== null ? { updatedAt: finiteNumber(value.updatedAt) } : {}
|
|
2542
|
+
...finiteNumber(value.updatedAt) !== null ? { updatedAt: finiteNumber(value.updatedAt) } : {},
|
|
2543
|
+
...normalizePlayDocflowNodeIoState(value.nodeIo) ? { nodeIo: normalizePlayDocflowNodeIoState(value.nodeIo) } : {}
|
|
2195
2544
|
};
|
|
2196
2545
|
}
|
|
2197
2546
|
|
|
@@ -2263,18 +2612,18 @@ function normalizePlayRunLiveStatus(value) {
|
|
|
2263
2612
|
function isTerminalPlayRunLiveStatus(status) {
|
|
2264
2613
|
return isTerminalPlayRunLifecycleStatus(status);
|
|
2265
2614
|
}
|
|
2266
|
-
function
|
|
2615
|
+
function isRecord6(value) {
|
|
2267
2616
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2268
2617
|
}
|
|
2269
2618
|
function finiteNumber2(value) {
|
|
2270
2619
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
2271
2620
|
}
|
|
2272
2621
|
function extractTerminalRunLogTail(result) {
|
|
2273
|
-
if (!
|
|
2622
|
+
if (!isRecord6(result) || !isRecord6(result._metadata)) {
|
|
2274
2623
|
return null;
|
|
2275
2624
|
}
|
|
2276
2625
|
const runLogTail = result._metadata.runLogTail;
|
|
2277
|
-
if (!
|
|
2626
|
+
if (!isRecord6(runLogTail) || !Array.isArray(runLogTail.tail)) {
|
|
2278
2627
|
return null;
|
|
2279
2628
|
}
|
|
2280
2629
|
const logTail = runLogTail.tail.filter(
|
|
@@ -2310,11 +2659,13 @@ function buildSnapshotFromLedger(snapshot) {
|
|
|
2310
2659
|
artifactTableNamespace: step.progress.artifactTableNamespace ?? step.artifactTableNamespace ?? null,
|
|
2311
2660
|
startedAt: step.startedAt ?? null,
|
|
2312
2661
|
completedAt: step.completedAt ?? null,
|
|
2313
|
-
updatedAt: step.progress.updatedAt ?? step.updatedAt ?? null
|
|
2662
|
+
updatedAt: step.progress.updatedAt ?? step.updatedAt ?? null,
|
|
2663
|
+
nodeIo: step.progress.nodeIo
|
|
2314
2664
|
} : null,
|
|
2315
2665
|
startedAt: step.startedAt ?? null,
|
|
2316
2666
|
completedAt: step.completedAt ?? null,
|
|
2317
|
-
updatedAt: step.updatedAt ?? null
|
|
2667
|
+
updatedAt: step.updatedAt ?? null,
|
|
2668
|
+
...step.progress?.nodeIo ? { nodeIo: step.progress.nodeIo } : {}
|
|
2318
2669
|
}));
|
|
2319
2670
|
const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
|
|
2320
2671
|
const rowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) && Object.keys(snapshot.stepsById).length > 0 ? summarizeRunRowOutcomes(snapshot) : null;
|
|
@@ -3064,8 +3415,17 @@ function resolvePlayRunRuntimeSelection(request) {
|
|
|
3064
3415
|
const configuredToken = process.env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
|
|
3065
3416
|
if (!configured) {
|
|
3066
3417
|
if (configuredNamespace || configuredToken) {
|
|
3418
|
+
const present = [];
|
|
3419
|
+
if (configuredNamespace) present.push("DEEPLINE_RUNTIME_NAMESPACE");
|
|
3420
|
+
if (configuredToken) present.push("DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN");
|
|
3421
|
+
const isPlural = present.length > 1;
|
|
3067
3422
|
throw new DeeplineError(
|
|
3068
|
-
|
|
3423
|
+
[
|
|
3424
|
+
`Incomplete play runtime selection: ${present.join(" and ")} ${isPlural ? "are" : "is"} set but DEEPLINE_RUNTIME_ENVIRONMENT is not.`,
|
|
3425
|
+
"Preview routing requires DEEPLINE_RUNTIME_ENVIRONMENT=preview together with DEEPLINE_RUNTIME_NAMESPACE; the token alone authorizes nothing.",
|
|
3426
|
+
`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).`,
|
|
3427
|
+
`To run against the app-native runtime, clear ${isPlural ? "them" : "it"} for this command: ${present.map((name) => `${name}=`).join(" ")} <your deepline command>`
|
|
3428
|
+
].join("\n"),
|
|
3069
3429
|
void 0,
|
|
3070
3430
|
"INVALID_RUNTIME_ENVIRONMENT"
|
|
3071
3431
|
);
|
|
@@ -3233,7 +3593,7 @@ function requireTargetBillingIdempotencyKey(value) {
|
|
|
3233
3593
|
}
|
|
3234
3594
|
return normalized;
|
|
3235
3595
|
}
|
|
3236
|
-
function
|
|
3596
|
+
function isRecord7(value) {
|
|
3237
3597
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
3238
3598
|
}
|
|
3239
3599
|
function isPrebuiltPlayDescription(play) {
|
|
@@ -3405,7 +3765,7 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
3405
3765
|
}
|
|
3406
3766
|
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
3407
3767
|
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
3408
|
-
const progressPayload =
|
|
3768
|
+
const progressPayload = isRecord7(payload.progress) ? payload.progress : {};
|
|
3409
3769
|
if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
|
|
3410
3770
|
const payloadLogs = readStringArray(payload.logs);
|
|
3411
3771
|
const progressLogs = readStringArray(progressPayload.logs);
|
|
@@ -3548,9 +3908,9 @@ var DeeplineClient = class {
|
|
|
3548
3908
|
return fields.length > 0 ? { fields } : schema;
|
|
3549
3909
|
}
|
|
3550
3910
|
schemaMetadata(schema, key) {
|
|
3551
|
-
if (!
|
|
3911
|
+
if (!isRecord7(schema)) return null;
|
|
3552
3912
|
const value = schema[key];
|
|
3553
|
-
return
|
|
3913
|
+
return isRecord7(value) ? value : null;
|
|
3554
3914
|
}
|
|
3555
3915
|
playRunCommand(play, options) {
|
|
3556
3916
|
const target = play.reference || play.name;
|
|
@@ -3599,7 +3959,7 @@ var DeeplineClient = class {
|
|
|
3599
3959
|
aliases,
|
|
3600
3960
|
inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
|
|
3601
3961
|
outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
|
|
3602
|
-
staticPipeline:
|
|
3962
|
+
staticPipeline: isRecord7(play.staticPipeline) ? play.staticPipeline : isRecord7(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord7(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
|
|
3603
3963
|
...csvInput ? { csvInput } : {},
|
|
3604
3964
|
...rowOutputSchema ? { rowOutputSchema } : {},
|
|
3605
3965
|
runCommand,
|
|
@@ -6063,7 +6423,7 @@ function isDeeplineExtractorTarget(value) {
|
|
|
6063
6423
|
}
|
|
6064
6424
|
|
|
6065
6425
|
// ../shared_libs/plays/dataset.ts
|
|
6066
|
-
var
|
|
6426
|
+
var PLAY_DATASET_BRAND2 = /* @__PURE__ */ Symbol.for("deepline.play.dataset");
|
|
6067
6427
|
var NODE_INSPECT_CUSTOM = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
6068
6428
|
var residentRowsByDataset = /* @__PURE__ */ new WeakMap();
|
|
6069
6429
|
var DEFAULT_MATERIALIZE_LIMIT = 1e4;
|
|
@@ -6090,7 +6450,7 @@ function inferPreviewColumns(rows) {
|
|
|
6090
6450
|
return columns.size > 0 ? [...columns] : void 0;
|
|
6091
6451
|
}
|
|
6092
6452
|
var DeferredPlayDataset = class {
|
|
6093
|
-
[
|
|
6453
|
+
[PLAY_DATASET_BRAND2] = true;
|
|
6094
6454
|
datasetKind;
|
|
6095
6455
|
datasetId;
|
|
6096
6456
|
backing;
|
|
@@ -6600,7 +6960,7 @@ var TARGET_FALLBACK_KEYS = {
|
|
|
6600
6960
|
status: [/^email_status$/i, /^status$/i],
|
|
6601
6961
|
email_status: [/^email_status$/i, /^status$/i]
|
|
6602
6962
|
};
|
|
6603
|
-
function
|
|
6963
|
+
function isRecord8(value) {
|
|
6604
6964
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6605
6965
|
}
|
|
6606
6966
|
function toV2RawToolOutputPath(path) {
|
|
@@ -6660,7 +7020,7 @@ function valuesAtSegments(current, segments, path = []) {
|
|
|
6660
7020
|
if (!Array.isArray(current)) return [];
|
|
6661
7021
|
return valuesAtSegments(current[segment], rest, [...path, segment]);
|
|
6662
7022
|
}
|
|
6663
|
-
if (!
|
|
7023
|
+
if (!isRecord8(current)) return [];
|
|
6664
7024
|
const directMatches = valuesAtSegments(current[segment], rest, [
|
|
6665
7025
|
...path,
|
|
6666
7026
|
segment
|
|
@@ -6690,7 +7050,7 @@ function getValuesAtPath(root, path) {
|
|
|
6690
7050
|
return valuesAtSegments(root, parsePath(path)).map((entry) => entry.value);
|
|
6691
7051
|
}
|
|
6692
7052
|
function toResultEnvelope(value) {
|
|
6693
|
-
if (
|
|
7053
|
+
if (isRecord8(value) && "data" in value) {
|
|
6694
7054
|
const envelope = { data: value.data };
|
|
6695
7055
|
if ("meta" in value) envelope.meta = value.meta;
|
|
6696
7056
|
return envelope;
|
|
@@ -6743,7 +7103,7 @@ function getAtPath(root, path) {
|
|
|
6743
7103
|
current = current[segment];
|
|
6744
7104
|
continue;
|
|
6745
7105
|
}
|
|
6746
|
-
if (!
|
|
7106
|
+
if (!isRecord8(current)) return void 0;
|
|
6747
7107
|
current = current[segment];
|
|
6748
7108
|
}
|
|
6749
7109
|
return current;
|
|
@@ -6760,7 +7120,7 @@ function normalizeString(value) {
|
|
|
6760
7120
|
}
|
|
6761
7121
|
function normalizeRows(value) {
|
|
6762
7122
|
if (!Array.isArray(value)) return null;
|
|
6763
|
-
return value.map((entry) =>
|
|
7123
|
+
return value.map((entry) => isRecord8(entry) ? entry : { value: entry });
|
|
6764
7124
|
}
|
|
6765
7125
|
function findFirstTargetByPath(result, paths) {
|
|
6766
7126
|
for (const path of paths ?? []) {
|
|
@@ -6819,7 +7179,7 @@ function findFirstTargetByKey(result, target, depth = 0, path = []) {
|
|
|
6819
7179
|
}
|
|
6820
7180
|
return null;
|
|
6821
7181
|
}
|
|
6822
|
-
if (!
|
|
7182
|
+
if (!isRecord8(result)) return null;
|
|
6823
7183
|
const patterns = TARGET_FALLBACK_KEYS[target] ?? [
|
|
6824
7184
|
new RegExp(`^${target}$`, "i")
|
|
6825
7185
|
];
|
|
@@ -6879,7 +7239,7 @@ function normalizeJobChangeStatus(value) {
|
|
|
6879
7239
|
function firstExperienceDate(value) {
|
|
6880
7240
|
if (!Array.isArray(value)) return null;
|
|
6881
7241
|
for (const entry of value) {
|
|
6882
|
-
if (!
|
|
7242
|
+
if (!isRecord8(entry)) continue;
|
|
6883
7243
|
const date = normalizeString(
|
|
6884
7244
|
entry.start_date ?? entry.started_at ?? entry.startDate
|
|
6885
7245
|
);
|
|
@@ -6888,10 +7248,10 @@ function firstExperienceDate(value) {
|
|
|
6888
7248
|
return null;
|
|
6889
7249
|
}
|
|
6890
7250
|
function normalizeJobChange(value) {
|
|
6891
|
-
const record =
|
|
6892
|
-
const nested =
|
|
6893
|
-
const output =
|
|
6894
|
-
const person =
|
|
7251
|
+
const record = isRecord8(value) ? value : {};
|
|
7252
|
+
const nested = isRecord8(record.job_change) ? record.job_change : record;
|
|
7253
|
+
const output = isRecord8(nested.output) ? nested.output : nested;
|
|
7254
|
+
const person = isRecord8(output.person) ? output.person : {};
|
|
6895
7255
|
const status = normalizeJobChangeStatus(
|
|
6896
7256
|
output.status ?? output.job_change_status ?? output.job_changed ?? output.changed
|
|
6897
7257
|
);
|
|
@@ -7265,7 +7625,7 @@ function attachToolResultListDataset(result, input) {
|
|
|
7265
7625
|
root = replaceAtPath(root, candidate, serialized.preview);
|
|
7266
7626
|
break;
|
|
7267
7627
|
}
|
|
7268
|
-
if (
|
|
7628
|
+
if (isRecord8(root) && isRecord8(root.toolResponse) && Object.prototype.hasOwnProperty.call(root.toolResponse, "raw")) {
|
|
7269
7629
|
result.toolResponse.raw = root.toolResponse.raw;
|
|
7270
7630
|
result.toolOutput.raw = root.toolResponse.raw;
|
|
7271
7631
|
}
|
|
@@ -7283,7 +7643,7 @@ function replaceAtPath(root, path, replacement) {
|
|
|
7283
7643
|
copy[segment] = replace(copy[segment], index + 1);
|
|
7284
7644
|
return copy;
|
|
7285
7645
|
}
|
|
7286
|
-
if (!
|
|
7646
|
+
if (!isRecord8(current)) return current;
|
|
7287
7647
|
return {
|
|
7288
7648
|
...current,
|
|
7289
7649
|
[segment]: replace(current[segment], index + 1)
|
|
@@ -7627,11 +7987,11 @@ var Deepline = class {
|
|
|
7627
7987
|
return new DeeplineContext(options);
|
|
7628
7988
|
}
|
|
7629
7989
|
};
|
|
7630
|
-
function
|
|
7990
|
+
function isRecord9(value) {
|
|
7631
7991
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7632
7992
|
}
|
|
7633
7993
|
function stringArrayRecord(value) {
|
|
7634
|
-
if (!
|
|
7994
|
+
if (!isRecord9(value)) return {};
|
|
7635
7995
|
return Object.fromEntries(
|
|
7636
7996
|
Object.entries(value).map(([key, paths]) => [
|
|
7637
7997
|
key,
|
|
@@ -7643,7 +8003,7 @@ function stringArray(value) {
|
|
|
7643
8003
|
return Array.isArray(value) ? value.map(String) : [];
|
|
7644
8004
|
}
|
|
7645
8005
|
function emailStatusExtractorConfig(value) {
|
|
7646
|
-
if (!
|
|
8006
|
+
if (!isRecord9(value)) return void 0;
|
|
7647
8007
|
const readPaths = (key) => {
|
|
7648
8008
|
const paths = stringArray(value[key]).map((path) => path.trim()).filter(Boolean);
|
|
7649
8009
|
return paths.length > 0 ? paths : void 0;
|
|
@@ -7670,7 +8030,7 @@ function emailStatusExtractorConfig(value) {
|
|
|
7670
8030
|
const paths = readPaths(key);
|
|
7671
8031
|
if (paths) config[key] = paths;
|
|
7672
8032
|
}
|
|
7673
|
-
if (
|
|
8033
|
+
if (isRecord9(value.statusMap)) {
|
|
7674
8034
|
config.statusMap = value.statusMap;
|
|
7675
8035
|
}
|
|
7676
8036
|
if (Array.isArray(value.rules)) {
|
|
@@ -7679,10 +8039,10 @@ function emailStatusExtractorConfig(value) {
|
|
|
7679
8039
|
return config;
|
|
7680
8040
|
}
|
|
7681
8041
|
function extractorDescriptorRecord(value) {
|
|
7682
|
-
if (!
|
|
8042
|
+
if (!isRecord9(value)) return {};
|
|
7683
8043
|
return Object.fromEntries(
|
|
7684
8044
|
Object.entries(value).flatMap(([key, descriptor]) => {
|
|
7685
|
-
if (!
|
|
8045
|
+
if (!isRecord9(descriptor)) return [];
|
|
7686
8046
|
const paths = stringArray(descriptor.paths).map((path) => path.trim()).filter(Boolean);
|
|
7687
8047
|
if (paths.length === 0) return [];
|
|
7688
8048
|
const transforms = stringArray(descriptor.transforms).map((transform) => transform.trim()).filter(Boolean);
|
|
@@ -7704,16 +8064,16 @@ function extractorDescriptorRecord(value) {
|
|
|
7704
8064
|
}
|
|
7705
8065
|
function rowsFromUnknown(value) {
|
|
7706
8066
|
if (!Array.isArray(value)) return [];
|
|
7707
|
-
return value.map((row) =>
|
|
8067
|
+
return value.map((row) => isRecord9(row) ? row : { value: row });
|
|
7708
8068
|
}
|
|
7709
|
-
function
|
|
8069
|
+
function finiteNonNegativeInteger3(value) {
|
|
7710
8070
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
7711
8071
|
return null;
|
|
7712
8072
|
}
|
|
7713
8073
|
return Math.floor(value);
|
|
7714
8074
|
}
|
|
7715
8075
|
function finitePositiveInteger(value) {
|
|
7716
|
-
const integer =
|
|
8076
|
+
const integer = finiteNonNegativeInteger3(value);
|
|
7717
8077
|
return integer !== null && integer > 0 ? integer : null;
|
|
7718
8078
|
}
|
|
7719
8079
|
function stableHash(value) {
|
|
@@ -7726,9 +8086,9 @@ function stableHash(value) {
|
|
|
7726
8086
|
}
|
|
7727
8087
|
function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
7728
8088
|
if (!options || !isQueryResultDatasetTool(toolId)) return result;
|
|
7729
|
-
const raw =
|
|
7730
|
-
const dataset =
|
|
7731
|
-
const totalRows =
|
|
8089
|
+
const raw = isRecord9(result.toolResponse.raw) ? result.toolResponse.raw : null;
|
|
8090
|
+
const dataset = isRecord9(raw?.dataset) ? raw.dataset : null;
|
|
8091
|
+
const totalRows = finiteNonNegativeInteger3(dataset?.total_rows);
|
|
7732
8092
|
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;
|
|
7733
8093
|
if (!dataset || totalRows === null || !sql) {
|
|
7734
8094
|
return result;
|
|
@@ -7759,7 +8119,7 @@ function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
|
7759
8119
|
} : {}
|
|
7760
8120
|
}
|
|
7761
8121
|
});
|
|
7762
|
-
const pageRaw =
|
|
8122
|
+
const pageRaw = isRecord9(response.toolResponse?.raw) ? response.toolResponse.raw : null;
|
|
7763
8123
|
return rowsFromUnknown(pageRaw?.rows);
|
|
7764
8124
|
};
|
|
7765
8125
|
const collectRows = async (limit) => {
|
|
@@ -7814,8 +8174,8 @@ function attachSdkQueryResultDatasetResult(toolId, result, options) {
|
|
|
7814
8174
|
function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
7815
8175
|
const raw = response.toolResponse?.raw ?? null;
|
|
7816
8176
|
const meta = response.toolResponse?.meta;
|
|
7817
|
-
const metadata =
|
|
7818
|
-
const toolMetadata =
|
|
8177
|
+
const metadata = isRecord9(response._metadata) ? response._metadata.tool : null;
|
|
8178
|
+
const toolMetadata = isRecord9(metadata) ? metadata : {};
|
|
7819
8179
|
return attachSdkQueryResultDatasetResult(
|
|
7820
8180
|
fallbackToolId,
|
|
7821
8181
|
createToolExecuteResult({
|
|
@@ -7823,7 +8183,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
|
7823
8183
|
jobId: typeof response.job_id === "string" ? response.job_id : void 0,
|
|
7824
8184
|
result: {
|
|
7825
8185
|
data: raw,
|
|
7826
|
-
...
|
|
8186
|
+
...isRecord9(meta) ? { meta } : {}
|
|
7827
8187
|
},
|
|
7828
8188
|
metadata: {
|
|
7829
8189
|
toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
|
|
@@ -7839,7 +8199,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
|
7839
8199
|
cached: false,
|
|
7840
8200
|
source: "live"
|
|
7841
8201
|
},
|
|
7842
|
-
meta:
|
|
8202
|
+
meta: isRecord9(response.meta) ? response.meta : void 0
|
|
7843
8203
|
}),
|
|
7844
8204
|
options
|
|
7845
8205
|
);
|