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/cli/index.mjs
CHANGED
|
@@ -1030,7 +1030,7 @@ var SDK_RELEASE = {
|
|
|
1030
1030
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
1031
1031
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
1032
1032
|
// release keeps lazy paging semantics independent of row residency.
|
|
1033
|
-
version: "0.2.
|
|
1033
|
+
version: "0.2.55",
|
|
1034
1034
|
contracts: {
|
|
1035
1035
|
api: {
|
|
1036
1036
|
name: "sdk-http-api",
|
|
@@ -1965,7 +1965,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1965
1965
|
if (value.length >= 4) exactSecrets.add(value);
|
|
1966
1966
|
}
|
|
1967
1967
|
for (const value of initialValues) register(value);
|
|
1968
|
-
function
|
|
1968
|
+
function redactString2(value) {
|
|
1969
1969
|
let output2 = value;
|
|
1970
1970
|
for (const secret of exactSecrets) {
|
|
1971
1971
|
output2 = output2.replace(
|
|
@@ -1986,7 +1986,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1986
1986
|
return redactSecretLikeString(output2);
|
|
1987
1987
|
}
|
|
1988
1988
|
function redact(value) {
|
|
1989
|
-
if (typeof value === "string") return
|
|
1989
|
+
if (typeof value === "string") return redactString2(value);
|
|
1990
1990
|
if (Array.isArray(value)) return value.map((entry) => redact(entry));
|
|
1991
1991
|
if (value && typeof value === "object") {
|
|
1992
1992
|
return Object.fromEntries(
|
|
@@ -1999,7 +1999,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
1999
1999
|
return value;
|
|
2000
2000
|
}
|
|
2001
2001
|
function redactKnownSecrets(value) {
|
|
2002
|
-
if (typeof value === "string") return
|
|
2002
|
+
if (typeof value === "string") return redactString2(value);
|
|
2003
2003
|
if (Array.isArray(value)) {
|
|
2004
2004
|
return value.map((entry) => redactKnownSecrets(entry));
|
|
2005
2005
|
}
|
|
@@ -2015,7 +2015,7 @@ function createSecretRedactionContext(initialValues = []) {
|
|
|
2015
2015
|
}
|
|
2016
2016
|
return {
|
|
2017
2017
|
register,
|
|
2018
|
-
redactString,
|
|
2018
|
+
redactString: redactString2,
|
|
2019
2019
|
redactKnownSecrets,
|
|
2020
2020
|
redact
|
|
2021
2021
|
};
|
|
@@ -2035,12 +2035,334 @@ var RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES = 64 * 1024;
|
|
|
2035
2035
|
// ../shared_libs/play-runtime/ledger-safe-payload.ts
|
|
2036
2036
|
var ledgerIngressRedactor = createSecretRedactionContext();
|
|
2037
2037
|
|
|
2038
|
-
// ../shared_libs/play-runtime/
|
|
2038
|
+
// ../shared_libs/play-runtime/docflow-node-io.ts
|
|
2039
|
+
var DOCFLOW_NODE_IO_LIMITS = {
|
|
2040
|
+
maxPaths: 16,
|
|
2041
|
+
maxDepth: 3,
|
|
2042
|
+
maxObjectFields: 12,
|
|
2043
|
+
maxArrayItems: 3,
|
|
2044
|
+
maxStringBytes: 256,
|
|
2045
|
+
maxPhaseBytes: 2e3,
|
|
2046
|
+
maxErrorBytes: 512
|
|
2047
|
+
};
|
|
2048
|
+
var utf8Encoder = new TextEncoder();
|
|
2049
|
+
var PLAY_DATASET_BRAND = /* @__PURE__ */ Symbol.for("deepline.play.dataset");
|
|
2050
|
+
function ledgerSafeDocflowPreviewKey(key) {
|
|
2051
|
+
if (!key.startsWith("$")) return key;
|
|
2052
|
+
const stripped = key.replace(/^\$+/, "");
|
|
2053
|
+
return stripped || "output";
|
|
2054
|
+
}
|
|
2055
|
+
function utf8Bytes(value) {
|
|
2056
|
+
return utf8Encoder.encode(value).byteLength;
|
|
2057
|
+
}
|
|
2058
|
+
function truncateUtf8(value, maxBytes) {
|
|
2059
|
+
if (utf8Bytes(value) <= maxBytes) return value;
|
|
2060
|
+
let output2 = "";
|
|
2061
|
+
for (const character of value) {
|
|
2062
|
+
if (utf8Bytes(`${output2}${character}\u2026`) > maxBytes) break;
|
|
2063
|
+
output2 += character;
|
|
2064
|
+
}
|
|
2065
|
+
return `${output2}\u2026`;
|
|
2066
|
+
}
|
|
2067
|
+
function redactString(redactor, value, key) {
|
|
2068
|
+
if (!key) return redactor.redactString(value);
|
|
2069
|
+
const wrapped = redactor.redact({ [key]: value });
|
|
2070
|
+
return typeof wrapped[key] === "string" ? wrapped[key] : redactor.redactString(value);
|
|
2071
|
+
}
|
|
2072
|
+
function safeString(value, redactor, key) {
|
|
2073
|
+
if (typeof value !== "string") return void 0;
|
|
2074
|
+
return truncateUtf8(
|
|
2075
|
+
redactString(redactor, value, key),
|
|
2076
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
2077
|
+
);
|
|
2078
|
+
}
|
|
2079
|
+
function previewValue(value, input2) {
|
|
2080
|
+
if (value === null) return { kind: "null" };
|
|
2081
|
+
if (value === void 0) return { kind: "unavailable", reason: "undefined" };
|
|
2082
|
+
if (typeof value === "string") {
|
|
2083
|
+
return {
|
|
2084
|
+
kind: "scalar",
|
|
2085
|
+
value: safeString(value, input2.redactor, input2.key) ?? ""
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
if (typeof value === "number") {
|
|
2089
|
+
return Number.isFinite(value) ? { kind: "scalar", value } : { kind: "unavailable", reason: "unsupported" };
|
|
2090
|
+
}
|
|
2091
|
+
if (typeof value === "boolean") return { kind: "scalar", value };
|
|
2092
|
+
if (typeof value === "bigint") {
|
|
2093
|
+
return { kind: "unavailable", reason: "bigint" };
|
|
2094
|
+
}
|
|
2095
|
+
if (typeof value === "function") {
|
|
2096
|
+
return { kind: "unavailable", reason: "function" };
|
|
2097
|
+
}
|
|
2098
|
+
if (typeof value === "symbol") {
|
|
2099
|
+
return { kind: "unavailable", reason: "symbol" };
|
|
2100
|
+
}
|
|
2101
|
+
if (typeof value !== "object") {
|
|
2102
|
+
return { kind: "unavailable", reason: "unsupported" };
|
|
2103
|
+
}
|
|
2104
|
+
try {
|
|
2105
|
+
const brand = readDataProperty(value, PLAY_DATASET_BRAND);
|
|
2106
|
+
const datasetKind = readDataProperty(value, "datasetKind");
|
|
2107
|
+
const datasetId = readDataProperty(value, "datasetId");
|
|
2108
|
+
const tableNamespace = readDataProperty(value, "tableNamespace");
|
|
2109
|
+
if (brand.ok && brand.value === true && datasetKind.ok && (datasetKind.value === "csv" || datasetKind.value === "map") && datasetId.ok && typeof datasetId.value === "string") {
|
|
2110
|
+
return {
|
|
2111
|
+
kind: "dataset",
|
|
2112
|
+
datasetId: safeString(datasetId.value, input2.redactor, "datasetId") ?? "dataset",
|
|
2113
|
+
datasetKind: datasetKind.value,
|
|
2114
|
+
tableNamespace: tableNamespace.ok && tableNamespace.value === null ? null : tableNamespace.ok ? safeString(
|
|
2115
|
+
tableNamespace.value,
|
|
2116
|
+
input2.redactor,
|
|
2117
|
+
"tableNamespace"
|
|
2118
|
+
) : void 0
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
const kind = readDataProperty(value, "kind");
|
|
2122
|
+
const count = readDataProperty(value, "count");
|
|
2123
|
+
const preview = readDataProperty(value, "preview");
|
|
2124
|
+
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)) {
|
|
2125
|
+
return {
|
|
2126
|
+
kind: "dataset",
|
|
2127
|
+
datasetId: safeString(datasetId.value, input2.redactor, "datasetId") ?? "dataset",
|
|
2128
|
+
datasetKind: datasetKind.value,
|
|
2129
|
+
tableNamespace: tableNamespace.ok && tableNamespace.value === null ? null : tableNamespace.ok ? safeString(
|
|
2130
|
+
tableNamespace.value,
|
|
2131
|
+
input2.redactor,
|
|
2132
|
+
"tableNamespace"
|
|
2133
|
+
) : void 0,
|
|
2134
|
+
rowCount: Math.max(0, Math.floor(count.value))
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
} catch {
|
|
2138
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
2139
|
+
}
|
|
2140
|
+
if (input2.ancestors.has(value)) {
|
|
2141
|
+
return { kind: "unavailable", reason: "cycle" };
|
|
2142
|
+
}
|
|
2143
|
+
if (input2.depth >= DOCFLOW_NODE_IO_LIMITS.maxDepth) {
|
|
2144
|
+
return { kind: "unavailable", reason: "depth" };
|
|
2145
|
+
}
|
|
2146
|
+
input2.ancestors.add(value);
|
|
2147
|
+
try {
|
|
2148
|
+
if (Array.isArray(value)) {
|
|
2149
|
+
const items = [];
|
|
2150
|
+
for (let index = 0; index < Math.min(value.length, DOCFLOW_NODE_IO_LIMITS.maxArrayItems); index += 1) {
|
|
2151
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
2152
|
+
value,
|
|
2153
|
+
String(index)
|
|
2154
|
+
);
|
|
2155
|
+
items.push(
|
|
2156
|
+
descriptor && "value" in descriptor ? previewValue(descriptor.value, {
|
|
2157
|
+
...input2,
|
|
2158
|
+
depth: input2.depth + 1
|
|
2159
|
+
}) : { kind: "unavailable", reason: "access_error" }
|
|
2160
|
+
);
|
|
2161
|
+
}
|
|
2162
|
+
return {
|
|
2163
|
+
kind: "array",
|
|
2164
|
+
items,
|
|
2165
|
+
totalItems: value.length,
|
|
2166
|
+
...value.length > items.length ? { truncated: true } : {}
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
let descriptors;
|
|
2170
|
+
try {
|
|
2171
|
+
descriptors = Object.getOwnPropertyDescriptors(value);
|
|
2172
|
+
} catch {
|
|
2173
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
2174
|
+
}
|
|
2175
|
+
const entries = Object.entries(descriptors).filter(
|
|
2176
|
+
([, descriptor]) => descriptor.enumerable
|
|
2177
|
+
);
|
|
2178
|
+
const selected = entries.slice(0, DOCFLOW_NODE_IO_LIMITS.maxObjectFields);
|
|
2179
|
+
const fields = {};
|
|
2180
|
+
for (const [key, descriptor] of selected) {
|
|
2181
|
+
const safeKey = truncateUtf8(
|
|
2182
|
+
ledgerSafeDocflowPreviewKey(input2.redactor.redactString(key)),
|
|
2183
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
2184
|
+
);
|
|
2185
|
+
fields[safeKey] = "value" in descriptor ? previewValue(descriptor.value, {
|
|
2186
|
+
...input2,
|
|
2187
|
+
depth: input2.depth + 1,
|
|
2188
|
+
key
|
|
2189
|
+
}) : { kind: "unavailable", reason: "access_error" };
|
|
2190
|
+
}
|
|
2191
|
+
return {
|
|
2192
|
+
kind: "object",
|
|
2193
|
+
fields,
|
|
2194
|
+
totalFields: entries.length,
|
|
2195
|
+
...entries.length > selected.length ? { truncated: true } : {}
|
|
2196
|
+
};
|
|
2197
|
+
} catch {
|
|
2198
|
+
return { kind: "unavailable", reason: "access_error" };
|
|
2199
|
+
} finally {
|
|
2200
|
+
input2.ancestors.delete(value);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function readDataProperty(value, property) {
|
|
2204
|
+
if ((typeof value !== "object" || value === null) && typeof value !== "function") {
|
|
2205
|
+
return { ok: false };
|
|
2206
|
+
}
|
|
2207
|
+
try {
|
|
2208
|
+
let owner = value;
|
|
2209
|
+
while (owner) {
|
|
2210
|
+
const descriptor = Object.getOwnPropertyDescriptor(owner, property);
|
|
2211
|
+
if (descriptor) {
|
|
2212
|
+
return "value" in descriptor ? { ok: true, value: descriptor.value } : { ok: false };
|
|
2213
|
+
}
|
|
2214
|
+
owner = Object.getPrototypeOf(owner);
|
|
2215
|
+
}
|
|
2216
|
+
} catch {
|
|
2217
|
+
return { ok: false };
|
|
2218
|
+
}
|
|
2219
|
+
return { ok: false };
|
|
2220
|
+
}
|
|
2221
|
+
function buildPlayDocflowNodeErrorPreview(error, redactor = createSecretRedactionContext()) {
|
|
2222
|
+
try {
|
|
2223
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2224
|
+
return truncateUtf8(
|
|
2225
|
+
redactor.redactString(message),
|
|
2226
|
+
DOCFLOW_NODE_IO_LIMITS.maxErrorBytes
|
|
2227
|
+
);
|
|
2228
|
+
} catch {
|
|
2229
|
+
return "Non-Error value thrown (message unavailable)";
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2039
2232
|
function isRecord3(value) {
|
|
2040
2233
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2041
2234
|
}
|
|
2235
|
+
function normalizePreview(value, depth) {
|
|
2236
|
+
if (!isRecord3(value) || typeof value.kind !== "string") return null;
|
|
2237
|
+
if (value.kind === "null") return { kind: "null" };
|
|
2238
|
+
if (value.kind === "scalar") {
|
|
2239
|
+
if (typeof value.value === "string" || typeof value.value === "boolean" || typeof value.value === "number" && Number.isFinite(value.value)) {
|
|
2240
|
+
return previewValue(value.value, {
|
|
2241
|
+
depth: 0,
|
|
2242
|
+
ancestors: /* @__PURE__ */ new WeakSet(),
|
|
2243
|
+
redactor: createSecretRedactionContext()
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
return null;
|
|
2247
|
+
}
|
|
2248
|
+
if (value.kind === "unavailable") {
|
|
2249
|
+
const reason = value.reason;
|
|
2250
|
+
return typeof reason === "string" && [
|
|
2251
|
+
"undefined",
|
|
2252
|
+
"function",
|
|
2253
|
+
"symbol",
|
|
2254
|
+
"bigint",
|
|
2255
|
+
"cycle",
|
|
2256
|
+
"depth",
|
|
2257
|
+
"access_error",
|
|
2258
|
+
"limit",
|
|
2259
|
+
"unsupported"
|
|
2260
|
+
].includes(reason) ? {
|
|
2261
|
+
kind: "unavailable",
|
|
2262
|
+
reason
|
|
2263
|
+
} : null;
|
|
2264
|
+
}
|
|
2265
|
+
if (value.kind === "dataset") {
|
|
2266
|
+
const datasetId = safeString(
|
|
2267
|
+
value.datasetId,
|
|
2268
|
+
createSecretRedactionContext(),
|
|
2269
|
+
"datasetId"
|
|
2270
|
+
);
|
|
2271
|
+
if (!datasetId || value.datasetKind !== "csv" && value.datasetKind !== "map") {
|
|
2272
|
+
return null;
|
|
2273
|
+
}
|
|
2274
|
+
return {
|
|
2275
|
+
kind: "dataset",
|
|
2276
|
+
datasetId,
|
|
2277
|
+
datasetKind: value.datasetKind,
|
|
2278
|
+
...value.tableNamespace === null ? { tableNamespace: null } : typeof value.tableNamespace === "string" ? {
|
|
2279
|
+
tableNamespace: safeString(
|
|
2280
|
+
value.tableNamespace,
|
|
2281
|
+
createSecretRedactionContext(),
|
|
2282
|
+
"tableNamespace"
|
|
2283
|
+
)
|
|
2284
|
+
} : {},
|
|
2285
|
+
...typeof value.rowCount === "number" && Number.isFinite(value.rowCount) ? { rowCount: Math.max(0, Math.floor(value.rowCount)) } : {}
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
if (depth >= DOCFLOW_NODE_IO_LIMITS.maxDepth) {
|
|
2289
|
+
return { kind: "unavailable", reason: "depth" };
|
|
2290
|
+
}
|
|
2291
|
+
if (value.kind === "array" && Array.isArray(value.items)) {
|
|
2292
|
+
const items = value.items.slice(0, DOCFLOW_NODE_IO_LIMITS.maxArrayItems).map((item) => normalizePreview(item, depth + 1)).filter((item) => item !== null);
|
|
2293
|
+
const totalItems = typeof value.totalItems === "number" && Number.isFinite(value.totalItems) ? Math.max(items.length, Math.floor(value.totalItems)) : items.length;
|
|
2294
|
+
return {
|
|
2295
|
+
kind: "array",
|
|
2296
|
+
items,
|
|
2297
|
+
totalItems,
|
|
2298
|
+
...value.truncated === true || totalItems > items.length ? { truncated: true } : {}
|
|
2299
|
+
};
|
|
2300
|
+
}
|
|
2301
|
+
if (value.kind === "object" && isRecord3(value.fields)) {
|
|
2302
|
+
const fields = {};
|
|
2303
|
+
for (const [key, field] of Object.entries(value.fields).slice(
|
|
2304
|
+
0,
|
|
2305
|
+
DOCFLOW_NODE_IO_LIMITS.maxObjectFields
|
|
2306
|
+
)) {
|
|
2307
|
+
const normalized = normalizePreview(field, depth + 1);
|
|
2308
|
+
if (normalized) fields[ledgerSafeDocflowPreviewKey(key)] = normalized;
|
|
2309
|
+
}
|
|
2310
|
+
const totalFields = typeof value.totalFields === "number" && Number.isFinite(value.totalFields) ? Math.max(Object.keys(fields).length, Math.floor(value.totalFields)) : Object.keys(fields).length;
|
|
2311
|
+
return {
|
|
2312
|
+
kind: "object",
|
|
2313
|
+
fields,
|
|
2314
|
+
totalFields,
|
|
2315
|
+
...value.truncated === true || totalFields > Object.keys(fields).length ? { truncated: true } : {}
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
return null;
|
|
2319
|
+
}
|
|
2320
|
+
function normalizePlayDocflowNodeIoState(value) {
|
|
2321
|
+
if (!isRecord3(value)) return void 0;
|
|
2322
|
+
const attempt = typeof value.attempt === "number" && Number.isFinite(value.attempt) ? Math.max(0, Math.floor(value.attempt)) : 0;
|
|
2323
|
+
const normalizeMap = (raw) => {
|
|
2324
|
+
if (!isRecord3(raw)) return void 0;
|
|
2325
|
+
const output2 = {};
|
|
2326
|
+
for (const [path, preview] of Object.entries(raw).slice(
|
|
2327
|
+
0,
|
|
2328
|
+
DOCFLOW_NODE_IO_LIMITS.maxPaths
|
|
2329
|
+
)) {
|
|
2330
|
+
const normalized = normalizePreview(preview, 0);
|
|
2331
|
+
if (!normalized) continue;
|
|
2332
|
+
const safePath = ledgerSafeDocflowPreviewKey(path);
|
|
2333
|
+
const candidate = { ...output2, [safePath]: normalized };
|
|
2334
|
+
if (utf8Bytes(JSON.stringify(candidate)) > DOCFLOW_NODE_IO_LIMITS.maxPhaseBytes) {
|
|
2335
|
+
break;
|
|
2336
|
+
}
|
|
2337
|
+
output2[safePath] = normalized;
|
|
2338
|
+
}
|
|
2339
|
+
return output2;
|
|
2340
|
+
};
|
|
2341
|
+
const inputs = normalizeMap(value.inputs);
|
|
2342
|
+
const outputs = normalizeMap(value.outputs);
|
|
2343
|
+
const error = typeof value.error === "string" ? buildPlayDocflowNodeErrorPreview(value.error) : value.error === null ? null : void 0;
|
|
2344
|
+
return {
|
|
2345
|
+
attempt,
|
|
2346
|
+
...typeof value.invocationId === "string" && value.invocationId.trim() ? {
|
|
2347
|
+
invocationId: truncateUtf8(
|
|
2348
|
+
value.invocationId.trim(),
|
|
2349
|
+
DOCFLOW_NODE_IO_LIMITS.maxStringBytes
|
|
2350
|
+
)
|
|
2351
|
+
} : {},
|
|
2352
|
+
...inputs ? { inputs } : {},
|
|
2353
|
+
...outputs ? { outputs } : {},
|
|
2354
|
+
...value.inputsTruncated === true ? { inputsTruncated: true } : {},
|
|
2355
|
+
...value.outputsTruncated === true ? { outputsTruncated: true } : {},
|
|
2356
|
+
...error !== void 0 ? { error } : {}
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
// ../shared_libs/play-runtime/activity-observation.ts
|
|
2361
|
+
function isRecord4(value) {
|
|
2362
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2363
|
+
}
|
|
2042
2364
|
function isPlayActivityObservation(value) {
|
|
2043
|
-
if (!
|
|
2365
|
+
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)) {
|
|
2044
2366
|
return false;
|
|
2045
2367
|
}
|
|
2046
2368
|
const targetKinds = /* @__PURE__ */ new Set([
|
|
@@ -2310,9 +2632,30 @@ function projectPlayRunActivity(input2) {
|
|
|
2310
2632
|
return projection(fallback, now, normalizedStatus !== "waiting");
|
|
2311
2633
|
}
|
|
2312
2634
|
|
|
2635
|
+
// ../shared_libs/play-runtime/cell-provenance.ts
|
|
2636
|
+
function finiteNonNegativeInteger2(value) {
|
|
2637
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
2638
|
+
return null;
|
|
2639
|
+
}
|
|
2640
|
+
return Math.trunc(value);
|
|
2641
|
+
}
|
|
2642
|
+
function nonEmptyString(value) {
|
|
2643
|
+
if (typeof value !== "string") return null;
|
|
2644
|
+
const trimmed = value.trim();
|
|
2645
|
+
return trimmed ? trimmed : null;
|
|
2646
|
+
}
|
|
2647
|
+
function normalizeDatasetBornFrom(value) {
|
|
2648
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
2649
|
+
const record = value;
|
|
2650
|
+
const table = nonEmptyString(record.table);
|
|
2651
|
+
const rowCountIn = finiteNonNegativeInteger2(record.rowCountIn);
|
|
2652
|
+
if (!table || rowCountIn === null) return null;
|
|
2653
|
+
return { table, rowCountIn };
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2313
2656
|
// ../shared_libs/play-runtime/run-ledger.ts
|
|
2314
2657
|
var LOG_TAIL_LIMIT = 100;
|
|
2315
|
-
function
|
|
2658
|
+
function isRecord5(value) {
|
|
2316
2659
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2317
2660
|
}
|
|
2318
2661
|
function finiteNumber(value) {
|
|
@@ -2408,21 +2751,21 @@ function createEmptyPlayRunLedgerSnapshot(input2) {
|
|
|
2408
2751
|
};
|
|
2409
2752
|
}
|
|
2410
2753
|
function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
2411
|
-
if (!
|
|
2754
|
+
if (!isRecord5(value)) {
|
|
2412
2755
|
return createEmptyPlayRunLedgerSnapshot(fallback);
|
|
2413
2756
|
}
|
|
2414
2757
|
const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
|
|
2415
2758
|
(entry) => typeof entry === "string" && Boolean(entry.trim())
|
|
2416
2759
|
) : [];
|
|
2417
|
-
const rawSteps =
|
|
2760
|
+
const rawSteps = isRecord5(value.stepsById) ? value.stepsById : {};
|
|
2418
2761
|
const stepsById = {};
|
|
2419
2762
|
for (const [stepId, rawStep] of Object.entries(rawSteps)) {
|
|
2420
|
-
if (!stepId.trim() || !
|
|
2763
|
+
if (!stepId.trim() || !isRecord5(rawStep)) continue;
|
|
2421
2764
|
const rawStatus = normalizeStepStatus(rawStep.status);
|
|
2422
2765
|
if (!rawStatus) continue;
|
|
2423
2766
|
const completedAt = finiteNumber(rawStep.completedAt);
|
|
2424
2767
|
const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
|
|
2425
|
-
const rawProgress =
|
|
2768
|
+
const rawProgress = isRecord5(rawStep.progress) ? rawStep.progress : null;
|
|
2426
2769
|
stepsById[stepId] = {
|
|
2427
2770
|
stepId,
|
|
2428
2771
|
label: optionalString(rawStep.label),
|
|
@@ -2438,11 +2781,12 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2438
2781
|
progress: rawProgress ? normalizeStepProgress(rawProgress) : null
|
|
2439
2782
|
};
|
|
2440
2783
|
}
|
|
2441
|
-
const rawDatasets =
|
|
2784
|
+
const rawDatasets = isRecord5(value.datasetsById) ? value.datasetsById : {};
|
|
2442
2785
|
const datasetsById = {};
|
|
2443
2786
|
for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
|
|
2444
|
-
if (!datasetId.trim() || !
|
|
2787
|
+
if (!datasetId.trim() || !isRecord5(rawDataset)) continue;
|
|
2445
2788
|
const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
|
|
2789
|
+
const datasetBornFrom = normalizeDatasetBornFrom(rawDataset.bornFrom);
|
|
2446
2790
|
datasetsById[datasetId] = {
|
|
2447
2791
|
datasetId,
|
|
2448
2792
|
path: optionalString(rawDataset.path) ?? `datasets.${datasetId}`,
|
|
@@ -2452,10 +2796,14 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2452
2796
|
succeededRows: Math.max(0, finiteNumber(rawDataset.succeededRows) ?? 0),
|
|
2453
2797
|
failedRows: Math.max(0, finiteNumber(rawDataset.failedRows) ?? 0),
|
|
2454
2798
|
complete: rawDataset.complete === true,
|
|
2799
|
+
// ADR 0019 birth survives the snapshot round trip. A partial record is
|
|
2800
|
+
// dropped rather than half-admitted, so a dataset either states where its
|
|
2801
|
+
// rows came from or says nothing.
|
|
2802
|
+
...datasetBornFrom ? { bornFrom: datasetBornFrom } : {},
|
|
2455
2803
|
updatedAt: finiteNumber(rawDataset.updatedAt) ?? 0
|
|
2456
2804
|
};
|
|
2457
2805
|
}
|
|
2458
|
-
const rawActivities =
|
|
2806
|
+
const rawActivities = isRecord5(value.activitiesById) ? value.activitiesById : {};
|
|
2459
2807
|
const activitiesById = {};
|
|
2460
2808
|
for (const [activityId, rawActivity] of Object.entries(rawActivities)) {
|
|
2461
2809
|
if (activityId.trim() && isPlayActivityObservation(rawActivity) && rawActivity.activityId === activityId) {
|
|
@@ -2532,7 +2880,8 @@ function normalizeStepProgress(value) {
|
|
|
2532
2880
|
} : {},
|
|
2533
2881
|
...finiteNumber(value.startedAt) !== null ? { startedAt: finiteNumber(value.startedAt) } : {},
|
|
2534
2882
|
...finiteNumber(value.completedAt) !== null ? { completedAt: finiteNumber(value.completedAt) } : {},
|
|
2535
|
-
...finiteNumber(value.updatedAt) !== null ? { updatedAt: finiteNumber(value.updatedAt) } : {}
|
|
2883
|
+
...finiteNumber(value.updatedAt) !== null ? { updatedAt: finiteNumber(value.updatedAt) } : {},
|
|
2884
|
+
...normalizePlayDocflowNodeIoState(value.nodeIo) ? { nodeIo: normalizePlayDocflowNodeIoState(value.nodeIo) } : {}
|
|
2536
2885
|
};
|
|
2537
2886
|
}
|
|
2538
2887
|
|
|
@@ -2604,18 +2953,18 @@ function normalizePlayRunLiveStatus(value) {
|
|
|
2604
2953
|
function isTerminalPlayRunLiveStatus(status) {
|
|
2605
2954
|
return isTerminalPlayRunLifecycleStatus(status);
|
|
2606
2955
|
}
|
|
2607
|
-
function
|
|
2956
|
+
function isRecord6(value) {
|
|
2608
2957
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2609
2958
|
}
|
|
2610
2959
|
function finiteNumber2(value) {
|
|
2611
2960
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
2612
2961
|
}
|
|
2613
2962
|
function extractTerminalRunLogTail(result) {
|
|
2614
|
-
if (!
|
|
2963
|
+
if (!isRecord6(result) || !isRecord6(result._metadata)) {
|
|
2615
2964
|
return null;
|
|
2616
2965
|
}
|
|
2617
2966
|
const runLogTail = result._metadata.runLogTail;
|
|
2618
|
-
if (!
|
|
2967
|
+
if (!isRecord6(runLogTail) || !Array.isArray(runLogTail.tail)) {
|
|
2619
2968
|
return null;
|
|
2620
2969
|
}
|
|
2621
2970
|
const logTail = runLogTail.tail.filter(
|
|
@@ -2651,11 +3000,13 @@ function buildSnapshotFromLedger(snapshot) {
|
|
|
2651
3000
|
artifactTableNamespace: step.progress.artifactTableNamespace ?? step.artifactTableNamespace ?? null,
|
|
2652
3001
|
startedAt: step.startedAt ?? null,
|
|
2653
3002
|
completedAt: step.completedAt ?? null,
|
|
2654
|
-
updatedAt: step.progress.updatedAt ?? step.updatedAt ?? null
|
|
3003
|
+
updatedAt: step.progress.updatedAt ?? step.updatedAt ?? null,
|
|
3004
|
+
nodeIo: step.progress.nodeIo
|
|
2655
3005
|
} : null,
|
|
2656
3006
|
startedAt: step.startedAt ?? null,
|
|
2657
3007
|
completedAt: step.completedAt ?? null,
|
|
2658
|
-
updatedAt: step.updatedAt ?? null
|
|
3008
|
+
updatedAt: step.updatedAt ?? null,
|
|
3009
|
+
...step.progress?.nodeIo ? { nodeIo: step.progress.nodeIo } : {}
|
|
2659
3010
|
}));
|
|
2660
3011
|
const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
|
|
2661
3012
|
const rowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) && Object.keys(snapshot.stepsById).length > 0 ? summarizeRunRowOutcomes(snapshot) : null;
|
|
@@ -3405,8 +3756,17 @@ function resolvePlayRunRuntimeSelection(request) {
|
|
|
3405
3756
|
const configuredToken = process.env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
|
|
3406
3757
|
if (!configured) {
|
|
3407
3758
|
if (configuredNamespace || configuredToken) {
|
|
3759
|
+
const present = [];
|
|
3760
|
+
if (configuredNamespace) present.push("DEEPLINE_RUNTIME_NAMESPACE");
|
|
3761
|
+
if (configuredToken) present.push("DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN");
|
|
3762
|
+
const isPlural = present.length > 1;
|
|
3408
3763
|
throw new DeeplineError(
|
|
3409
|
-
|
|
3764
|
+
[
|
|
3765
|
+
`Incomplete play runtime selection: ${present.join(" and ")} ${isPlural ? "are" : "is"} set but DEEPLINE_RUNTIME_ENVIRONMENT is not.`,
|
|
3766
|
+
"Preview routing requires DEEPLINE_RUNTIME_ENVIRONMENT=preview together with DEEPLINE_RUNTIME_NAMESPACE; the token alone authorizes nothing.",
|
|
3767
|
+
`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).`,
|
|
3768
|
+
`To run against the app-native runtime, clear ${isPlural ? "them" : "it"} for this command: ${present.map((name) => `${name}=`).join(" ")} <your deepline command>`
|
|
3769
|
+
].join("\n"),
|
|
3410
3770
|
void 0,
|
|
3411
3771
|
"INVALID_RUNTIME_ENVIRONMENT"
|
|
3412
3772
|
);
|
|
@@ -3574,7 +3934,7 @@ function requireTargetBillingIdempotencyKey(value) {
|
|
|
3574
3934
|
}
|
|
3575
3935
|
return normalized;
|
|
3576
3936
|
}
|
|
3577
|
-
function
|
|
3937
|
+
function isRecord7(value) {
|
|
3578
3938
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
3579
3939
|
}
|
|
3580
3940
|
function isPrebuiltPlayDescription(play) {
|
|
@@ -3746,7 +4106,7 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
3746
4106
|
}
|
|
3747
4107
|
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
3748
4108
|
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
3749
|
-
const progressPayload =
|
|
4109
|
+
const progressPayload = isRecord7(payload.progress) ? payload.progress : {};
|
|
3750
4110
|
if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
|
|
3751
4111
|
const payloadLogs = readStringArray(payload.logs);
|
|
3752
4112
|
const progressLogs = readStringArray(progressPayload.logs);
|
|
@@ -3889,9 +4249,9 @@ var DeeplineClient = class {
|
|
|
3889
4249
|
return fields.length > 0 ? { fields } : schema;
|
|
3890
4250
|
}
|
|
3891
4251
|
schemaMetadata(schema, key) {
|
|
3892
|
-
if (!
|
|
4252
|
+
if (!isRecord7(schema)) return null;
|
|
3893
4253
|
const value = schema[key];
|
|
3894
|
-
return
|
|
4254
|
+
return isRecord7(value) ? value : null;
|
|
3895
4255
|
}
|
|
3896
4256
|
playRunCommand(play, options) {
|
|
3897
4257
|
const target = play.reference || play.name;
|
|
@@ -3940,7 +4300,7 @@ var DeeplineClient = class {
|
|
|
3940
4300
|
aliases,
|
|
3941
4301
|
inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
|
|
3942
4302
|
outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
|
|
3943
|
-
staticPipeline:
|
|
4303
|
+
staticPipeline: isRecord7(play.staticPipeline) ? play.staticPipeline : isRecord7(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord7(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
|
|
3944
4304
|
...csvInput ? { csvInput } : {},
|
|
3945
4305
|
...rowOutputSchema ? { rowOutputSchema } : {},
|
|
3946
4306
|
runCommand: runCommand2,
|
|
@@ -9136,14 +9496,14 @@ function sanitizeCsvProjectionInfo(input2) {
|
|
|
9136
9496
|
const rows = input2.rows.map(stripCsvProjectionFields);
|
|
9137
9497
|
return { rows, columns };
|
|
9138
9498
|
}
|
|
9139
|
-
function
|
|
9499
|
+
function isRecord8(value) {
|
|
9140
9500
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
9141
9501
|
}
|
|
9142
9502
|
function isSerializedDataset(value) {
|
|
9143
|
-
return
|
|
9503
|
+
return isRecord8(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
|
|
9144
9504
|
}
|
|
9145
9505
|
function isPackagedDatasetOutput(value) {
|
|
9146
|
-
return
|
|
9506
|
+
return isRecord8(value) && value.kind === "dataset" && isRecord8(value.preview) && Array.isArray(value.preview.rows);
|
|
9147
9507
|
}
|
|
9148
9508
|
function pathParts(path) {
|
|
9149
9509
|
return path.split(".").map((part) => part.trim()).filter(Boolean);
|
|
@@ -9151,7 +9511,7 @@ function pathParts(path) {
|
|
|
9151
9511
|
function valueAtPath(root, path) {
|
|
9152
9512
|
let cursor = root;
|
|
9153
9513
|
for (const part of pathParts(path)) {
|
|
9154
|
-
if (!
|
|
9514
|
+
if (!isRecord8(cursor)) {
|
|
9155
9515
|
return void 0;
|
|
9156
9516
|
}
|
|
9157
9517
|
cursor = cursor[part];
|
|
@@ -9159,17 +9519,17 @@ function valueAtPath(root, path) {
|
|
|
9159
9519
|
return cursor;
|
|
9160
9520
|
}
|
|
9161
9521
|
function totalRowsForDataset(result, datasetPath) {
|
|
9162
|
-
const metadata =
|
|
9522
|
+
const metadata = isRecord8(result._metadata) ? result._metadata : null;
|
|
9163
9523
|
const parentPath = datasetPath.split(".").slice(0, -1).join(".");
|
|
9164
9524
|
const parent = parentPath ? valueAtPath({ result }, parentPath) : result;
|
|
9165
|
-
return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (
|
|
9525
|
+
return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord8(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
|
|
9166
9526
|
}
|
|
9167
9527
|
function rowArray(value) {
|
|
9168
9528
|
if (!Array.isArray(value)) {
|
|
9169
9529
|
return null;
|
|
9170
9530
|
}
|
|
9171
9531
|
const rows = value.filter(
|
|
9172
|
-
(row) =>
|
|
9532
|
+
(row) => isRecord8(row)
|
|
9173
9533
|
);
|
|
9174
9534
|
return rows.length === value.length ? rows : null;
|
|
9175
9535
|
}
|
|
@@ -9193,7 +9553,7 @@ function inferColumns(rows) {
|
|
|
9193
9553
|
return columns;
|
|
9194
9554
|
}
|
|
9195
9555
|
function columnsFromDatasetSummary(summary) {
|
|
9196
|
-
if (!
|
|
9556
|
+
if (!isRecord8(summary) || !isRecord8(summary.columnStats)) {
|
|
9197
9557
|
return [];
|
|
9198
9558
|
}
|
|
9199
9559
|
return Object.keys(summary.columnStats).filter((column) => column);
|
|
@@ -9241,7 +9601,7 @@ function canonicalRowsInfoFromCandidate(input2) {
|
|
|
9241
9601
|
datasetId: typeof candidate.value.datasetId === "string" ? candidate.value.datasetId : null,
|
|
9242
9602
|
tableNamespace: typeof candidate.value.tableNamespace === "string" ? candidate.value.tableNamespace : null,
|
|
9243
9603
|
...candidate.value.recovered === true ? { recovered: true } : {},
|
|
9244
|
-
...
|
|
9604
|
+
...isRecord8(candidate.value.exportUnavailable) && (candidate.value.exportUnavailable.reason === "empty_dataset" || candidate.value.exportUnavailable.reason === "shared_table_namespace") ? {
|
|
9245
9605
|
exportUnavailableReason: candidate.value.exportUnavailable.reason,
|
|
9246
9606
|
...typeof candidate.value.exportUnavailable.message === "string" ? {
|
|
9247
9607
|
exportUnavailableMessage: candidate.value.exportUnavailable.message
|
|
@@ -9289,7 +9649,7 @@ function collectDatasetCandidates(input2) {
|
|
|
9289
9649
|
});
|
|
9290
9650
|
return;
|
|
9291
9651
|
}
|
|
9292
|
-
if (!
|
|
9652
|
+
if (!isRecord8(input2.value)) {
|
|
9293
9653
|
return;
|
|
9294
9654
|
}
|
|
9295
9655
|
for (const [key, child] of Object.entries(input2.value)) {
|
|
@@ -9306,12 +9666,12 @@ function collectDatasetCandidates(input2) {
|
|
|
9306
9666
|
}
|
|
9307
9667
|
}
|
|
9308
9668
|
function collectCanonicalRowsInfos(statusOrResult) {
|
|
9309
|
-
const root =
|
|
9310
|
-
const result =
|
|
9669
|
+
const root = isRecord8(statusOrResult) ? statusOrResult : null;
|
|
9670
|
+
const result = isRecord8(root?.result) ? root.result : root;
|
|
9311
9671
|
if (!result) {
|
|
9312
9672
|
return [];
|
|
9313
9673
|
}
|
|
9314
|
-
const metadata =
|
|
9674
|
+
const metadata = isRecord8(result._metadata) ? result._metadata : null;
|
|
9315
9675
|
const totalFromMetadata = metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count;
|
|
9316
9676
|
const candidates = [
|
|
9317
9677
|
{
|
|
@@ -9335,8 +9695,8 @@ function collectCanonicalRowsInfos(statusOrResult) {
|
|
|
9335
9695
|
total: totalFromMetadata ?? result.totalRows ?? result.rowCount ?? result.count
|
|
9336
9696
|
}
|
|
9337
9697
|
];
|
|
9338
|
-
if (
|
|
9339
|
-
const outputMetadata =
|
|
9698
|
+
if (isRecord8(result.output)) {
|
|
9699
|
+
const outputMetadata = isRecord8(result.output._metadata) ? result.output._metadata : null;
|
|
9340
9700
|
const outputTotalFromMetadata = outputMetadata?.totalRows ?? outputMetadata?.rowCount ?? outputMetadata?.count;
|
|
9341
9701
|
candidates.push(
|
|
9342
9702
|
{
|
|
@@ -9363,14 +9723,14 @@ function collectCanonicalRowsInfos(statusOrResult) {
|
|
|
9363
9723
|
}
|
|
9364
9724
|
if (Array.isArray(result.steps)) {
|
|
9365
9725
|
result.steps.forEach((step, index) => {
|
|
9366
|
-
if (!
|
|
9726
|
+
if (!isRecord8(step) || !isRecord8(step.output)) {
|
|
9367
9727
|
return;
|
|
9368
9728
|
}
|
|
9369
9729
|
const source = typeof step.output.path === "string" ? step.output.path : typeof step.id === "string" ? `steps.${step.id}.output` : `steps.${index}.output`;
|
|
9370
9730
|
candidates.push({
|
|
9371
9731
|
source,
|
|
9372
9732
|
value: step.output,
|
|
9373
|
-
total: step.output.rowCount ?? (
|
|
9733
|
+
total: step.output.rowCount ?? (isRecord8(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord8(step.progress) ? step.progress.total : void 0)
|
|
9374
9734
|
});
|
|
9375
9735
|
});
|
|
9376
9736
|
}
|
|
@@ -9398,15 +9758,15 @@ function collectCanonicalRowsInfos(statusOrResult) {
|
|
|
9398
9758
|
return infos;
|
|
9399
9759
|
}
|
|
9400
9760
|
function collectPackagedDatasetCandidates(statusOrResult) {
|
|
9401
|
-
const root =
|
|
9761
|
+
const root = isRecord8(statusOrResult) ? statusOrResult : null;
|
|
9402
9762
|
if (!root) {
|
|
9403
9763
|
return [];
|
|
9404
9764
|
}
|
|
9405
|
-
const pkg =
|
|
9765
|
+
const pkg = isRecord8(root.package) ? root.package : root;
|
|
9406
9766
|
const datasets = Array.isArray(pkg.datasets) ? pkg.datasets : [];
|
|
9407
9767
|
const candidates = [];
|
|
9408
9768
|
for (const output2 of datasets) {
|
|
9409
|
-
if (!
|
|
9769
|
+
if (!isRecord8(output2) || !isPackagedDatasetOutput(output2)) {
|
|
9410
9770
|
continue;
|
|
9411
9771
|
}
|
|
9412
9772
|
const source = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
|
|
@@ -9416,18 +9776,18 @@ function collectPackagedDatasetCandidates(statusOrResult) {
|
|
|
9416
9776
|
candidates.push({
|
|
9417
9777
|
source,
|
|
9418
9778
|
value: output2,
|
|
9419
|
-
total: output2.rowCount ?? (
|
|
9779
|
+
total: output2.rowCount ?? (isRecord8(output2.preview) ? output2.preview.totalRows : void 0)
|
|
9420
9780
|
});
|
|
9421
9781
|
}
|
|
9422
9782
|
return candidates;
|
|
9423
9783
|
}
|
|
9424
9784
|
function collectPackagedStepDatasetCandidates(statusOrResult) {
|
|
9425
|
-
const root =
|
|
9785
|
+
const root = isRecord8(statusOrResult) ? statusOrResult : null;
|
|
9426
9786
|
if (!root) return [];
|
|
9427
|
-
const pkg =
|
|
9787
|
+
const pkg = isRecord8(root.package) ? root.package : root;
|
|
9428
9788
|
const steps = Array.isArray(pkg.steps) ? pkg.steps : [];
|
|
9429
9789
|
return steps.flatMap((step) => {
|
|
9430
|
-
if (!
|
|
9790
|
+
if (!isRecord8(step) || !isPackagedDatasetOutput(step.output)) return [];
|
|
9431
9791
|
const source = typeof step.output.path === "string" && step.output.path.trim() ? step.output.path.trim() : null;
|
|
9432
9792
|
return source ? [
|
|
9433
9793
|
{
|
|
@@ -9439,8 +9799,8 @@ function collectPackagedStepDatasetCandidates(statusOrResult) {
|
|
|
9439
9799
|
});
|
|
9440
9800
|
}
|
|
9441
9801
|
function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
9442
|
-
const root =
|
|
9443
|
-
const result =
|
|
9802
|
+
const root = isRecord8(statusOrResult) ? statusOrResult : null;
|
|
9803
|
+
const result = isRecord8(root?.result) ? root.result : root;
|
|
9444
9804
|
const candidates = [];
|
|
9445
9805
|
if (result) {
|
|
9446
9806
|
collectDatasetCandidates({
|
|
@@ -9448,7 +9808,7 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
9448
9808
|
path: "result",
|
|
9449
9809
|
output: candidates
|
|
9450
9810
|
});
|
|
9451
|
-
if (
|
|
9811
|
+
if (isRecord8(result.output)) {
|
|
9452
9812
|
collectDatasetCandidates({
|
|
9453
9813
|
value: result.output,
|
|
9454
9814
|
path: "result",
|
|
@@ -9526,13 +9886,13 @@ function summarizeSampleValue(value, depth = 0) {
|
|
|
9526
9886
|
if (typeof parsed === "number" || typeof parsed === "boolean") return parsed;
|
|
9527
9887
|
if (depth >= 3) {
|
|
9528
9888
|
if (Array.isArray(parsed)) return [];
|
|
9529
|
-
if (
|
|
9889
|
+
if (isRecord8(parsed)) return {};
|
|
9530
9890
|
return compactScalar(parsed);
|
|
9531
9891
|
}
|
|
9532
9892
|
if (Array.isArray(parsed)) {
|
|
9533
9893
|
return parsed.slice(0, 3).map((item) => summarizeSampleValue(item, depth + 1));
|
|
9534
9894
|
}
|
|
9535
|
-
if (
|
|
9895
|
+
if (isRecord8(parsed)) {
|
|
9536
9896
|
const out = {};
|
|
9537
9897
|
for (const [key, nested] of Object.entries(parsed)) {
|
|
9538
9898
|
if (["__dl", "meta", "metadata"].includes(key)) {
|
|
@@ -9563,7 +9923,7 @@ function compactCell(value) {
|
|
|
9563
9923
|
}
|
|
9564
9924
|
return `[${parsed.length} items]`;
|
|
9565
9925
|
}
|
|
9566
|
-
if (
|
|
9926
|
+
if (isRecord8(parsed)) {
|
|
9567
9927
|
for (const key of ["matched_result", "output"]) {
|
|
9568
9928
|
if (parsed[key] !== null && parsed[key] !== void 0 && parsed[key] !== "") {
|
|
9569
9929
|
return compactCell(parsed[key]);
|
|
@@ -10652,17 +11012,17 @@ function parsePositiveInteger2(value, flagName) {
|
|
|
10652
11012
|
}
|
|
10653
11013
|
return parsed;
|
|
10654
11014
|
}
|
|
10655
|
-
function
|
|
11015
|
+
function isRecord9(value) {
|
|
10656
11016
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
10657
11017
|
}
|
|
10658
11018
|
function stringValue(value) {
|
|
10659
11019
|
return typeof value === "string" ? value.trim() : "";
|
|
10660
11020
|
}
|
|
10661
11021
|
function extractionEntries(value) {
|
|
10662
|
-
if (Array.isArray(value)) return value.filter(
|
|
10663
|
-
if (!
|
|
11022
|
+
if (Array.isArray(value)) return value.filter(isRecord9);
|
|
11023
|
+
if (!isRecord9(value)) return [];
|
|
10664
11024
|
return Object.entries(value).map(
|
|
10665
|
-
([name, entry]) =>
|
|
11025
|
+
([name, entry]) => isRecord9(entry) ? { name, ...entry } : { name }
|
|
10666
11026
|
);
|
|
10667
11027
|
}
|
|
10668
11028
|
var PlayBootstrapError = class extends Error {
|
|
@@ -11224,7 +11584,7 @@ function readCsvSampleRows(sample) {
|
|
|
11224
11584
|
relax_column_count: true,
|
|
11225
11585
|
trim: true
|
|
11226
11586
|
});
|
|
11227
|
-
return Array.isArray(parsedRows) ? parsedRows.filter(
|
|
11587
|
+
return Array.isArray(parsedRows) ? parsedRows.filter(isRecord9) : [];
|
|
11228
11588
|
}
|
|
11229
11589
|
function readSourceCsvColumnSpecs(csvPath) {
|
|
11230
11590
|
const sample = readCsvSample(csvPath);
|
|
@@ -11257,16 +11617,16 @@ function packagedCsvPathForPlay(csvPath) {
|
|
|
11257
11617
|
return portablePath.startsWith(".") ? portablePath : `./${portablePath}`;
|
|
11258
11618
|
}
|
|
11259
11619
|
function getterNamesFromTool(tool, kind) {
|
|
11260
|
-
const usageGuidance =
|
|
11261
|
-
const resultGuidance =
|
|
11620
|
+
const usageGuidance = isRecord9(tool?.usageGuidance) ? tool.usageGuidance : {};
|
|
11621
|
+
const resultGuidance = isRecord9(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord9(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
|
|
11262
11622
|
const key = kind === "list" ? "extractedLists" : "extractedValues";
|
|
11263
11623
|
const snakeKey = kind === "list" ? "extracted_lists" : "extracted_values";
|
|
11264
11624
|
return extractionEntries(resultGuidance[key] ?? resultGuidance[snakeKey]).map((entry) => stringValue(entry.name)).filter(Boolean);
|
|
11265
11625
|
}
|
|
11266
11626
|
function targetGettersFromTool(tool) {
|
|
11267
|
-
const record =
|
|
11627
|
+
const record = isRecord9(tool) ? tool : {};
|
|
11268
11628
|
const raw = record.targetGetters ?? record.target_getters;
|
|
11269
|
-
if (!
|
|
11629
|
+
if (!isRecord9(raw)) return {};
|
|
11270
11630
|
const entries = [];
|
|
11271
11631
|
for (const [target, value] of Object.entries(raw)) {
|
|
11272
11632
|
const paths = Array.isArray(value) ? value.map((path) => typeof path === "string" ? path.trim() : "").filter(Boolean) : [];
|
|
@@ -11287,10 +11647,10 @@ function listRowCandidateKeysFromTool(tool) {
|
|
|
11287
11647
|
return [...keys].sort();
|
|
11288
11648
|
}
|
|
11289
11649
|
function inputPropertyNames(schema) {
|
|
11290
|
-
if (!
|
|
11291
|
-
if (
|
|
11650
|
+
if (!isRecord9(schema)) return [];
|
|
11651
|
+
if (isRecord9(schema.properties)) return Object.keys(schema.properties);
|
|
11292
11652
|
if (Array.isArray(schema.fields)) {
|
|
11293
|
-
return schema.fields.filter(
|
|
11653
|
+
return schema.fields.filter(isRecord9).map((field) => stringValue(field.name)).filter(Boolean);
|
|
11294
11654
|
}
|
|
11295
11655
|
return [];
|
|
11296
11656
|
}
|
|
@@ -11304,7 +11664,7 @@ function schemaFieldDetails(schema) {
|
|
|
11304
11664
|
return { required, optional };
|
|
11305
11665
|
}
|
|
11306
11666
|
function jsonSchemaTypeExpression(schema) {
|
|
11307
|
-
if (!
|
|
11667
|
+
if (!isRecord9(schema)) return "unknown";
|
|
11308
11668
|
const type = schema.type;
|
|
11309
11669
|
if (Array.isArray(type)) {
|
|
11310
11670
|
return type.map((entry) => jsonSchemaTypeExpression({ ...schema, type: entry })).join(" | ");
|
|
@@ -11334,7 +11694,7 @@ function jsonSchemaTypeExpression(schema) {
|
|
|
11334
11694
|
}
|
|
11335
11695
|
}
|
|
11336
11696
|
function objectPropertySchema(schema, property) {
|
|
11337
|
-
return
|
|
11697
|
+
return isRecord9(schema) && isRecord9(schema.properties) ? schema.properties[property] : null;
|
|
11338
11698
|
}
|
|
11339
11699
|
function playOutputHasField(schema, field) {
|
|
11340
11700
|
return objectPropertySchema(schema, field) != null;
|
|
@@ -11510,14 +11870,14 @@ ${indent2.slice(2)}}`;
|
|
|
11510
11870
|
}
|
|
11511
11871
|
function requiredPlayInputFields(play) {
|
|
11512
11872
|
const schema = play?.inputSchema;
|
|
11513
|
-
if (!
|
|
11873
|
+
if (!isRecord9(schema)) return [];
|
|
11514
11874
|
if (Array.isArray(schema.required)) {
|
|
11515
11875
|
return schema.required.filter(
|
|
11516
11876
|
(value) => typeof value === "string"
|
|
11517
11877
|
);
|
|
11518
11878
|
}
|
|
11519
11879
|
if (Array.isArray(schema.fields)) {
|
|
11520
|
-
return schema.fields.filter(
|
|
11880
|
+
return schema.fields.filter(isRecord9).filter(
|
|
11521
11881
|
(field) => field.required === true && typeof field.name === "string"
|
|
11522
11882
|
).map((field) => String(field.name));
|
|
11523
11883
|
}
|
|
@@ -11698,7 +12058,7 @@ function validateBootstrapRoutes(input2) {
|
|
|
11698
12058
|
}
|
|
11699
12059
|
}
|
|
11700
12060
|
function staticPipelineSubsteps(pipeline) {
|
|
11701
|
-
if (!
|
|
12061
|
+
if (!isRecord9(pipeline)) return [];
|
|
11702
12062
|
return [
|
|
11703
12063
|
...extractionEntries(pipeline.stages),
|
|
11704
12064
|
...extractionEntries(pipeline.substeps)
|
|
@@ -11706,7 +12066,7 @@ function staticPipelineSubsteps(pipeline) {
|
|
|
11706
12066
|
}
|
|
11707
12067
|
function playUsesMapBackedRuntime(play) {
|
|
11708
12068
|
const pipeline = play?.staticPipeline;
|
|
11709
|
-
if (!
|
|
12069
|
+
if (!isRecord9(pipeline)) return false;
|
|
11710
12070
|
if (stringValue(pipeline.tableNamespace)) return true;
|
|
11711
12071
|
return staticPipelineSubsteps(pipeline).some((substep) => {
|
|
11712
12072
|
if (stringValue(substep.type) === "map") return true;
|
|
@@ -11715,7 +12075,7 @@ function playUsesMapBackedRuntime(play) {
|
|
|
11715
12075
|
aliases: [],
|
|
11716
12076
|
runCommand: "",
|
|
11717
12077
|
examples: [],
|
|
11718
|
-
staticPipeline:
|
|
12078
|
+
staticPipeline: isRecord9(substep.pipeline) ? substep.pipeline : null
|
|
11719
12079
|
});
|
|
11720
12080
|
});
|
|
11721
12081
|
}
|
|
@@ -12319,8 +12679,7 @@ import {
|
|
|
12319
12679
|
sep
|
|
12320
12680
|
} from "path";
|
|
12321
12681
|
import { builtinModules } from "module";
|
|
12322
|
-
import { Parser } from "acorn";
|
|
12323
|
-
import { tsPlugin } from "acorn-typescript";
|
|
12682
|
+
import { Parser as Parser2 } from "acorn";
|
|
12324
12683
|
import { build, transformSync } from "esbuild";
|
|
12325
12684
|
|
|
12326
12685
|
// ../node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
@@ -15708,6 +16067,22 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
|
|
|
15708
16067
|
description: "Whether the dataset returns all rows or only newly admitted rows.",
|
|
15709
16068
|
errorMessage: 'ctx.dataset run mode must be "upsert" or "net_new".'
|
|
15710
16069
|
},
|
|
16070
|
+
"ctx.dataset.run.undrawnColumns": {
|
|
16071
|
+
schema: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
16072
|
+
fixtures: {
|
|
16073
|
+
valid: ["miss_reason"],
|
|
16074
|
+
invalid: [],
|
|
16075
|
+
absent: void 0,
|
|
16076
|
+
unresolved: { expression: "undrawnColumns" },
|
|
16077
|
+
edition1: ["miss_reason"]
|
|
16078
|
+
},
|
|
16079
|
+
referenceType: "readonly string[]",
|
|
16080
|
+
required: false,
|
|
16081
|
+
resolution: "static-when-present",
|
|
16082
|
+
issueCode: "play_authoring_dataset_option_invalid",
|
|
16083
|
+
description: "Computed columns deliberately left out of the authored @mermaid diagram.",
|
|
16084
|
+
errorMessage: "ctx.dataset run undrawnColumns must be a non-empty array of static column-name strings."
|
|
16085
|
+
},
|
|
15711
16086
|
"ctx.step.id": {
|
|
15712
16087
|
schema: Type.String({ minLength: 1 }),
|
|
15713
16088
|
fixtures: {
|
|
@@ -16195,7 +16570,7 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
|
|
|
16195
16570
|
"export type StepProgramOutput<TProgram> = TProgram extends StepProgram<unknown, infer Output, unknown> ? Output : never;",
|
|
16196
16571
|
"export type DatasetRowKey<InputRow extends object> = (keyof InputRow & string) | readonly (keyof InputRow & string)[] | ((row: InputRow, index: number) => string | number | readonly unknown[]);",
|
|
16197
16572
|
"export type DatasetDefinitionOptions<InputRow extends object> = { key?: DatasetRowKey<InputRow> };",
|
|
16198
|
-
`export type DatasetRunOptions<InputRow extends object> = { description?: ${cloudReferenceType("ctx.dataset.run.description")}; key?: DatasetRowKey<InputRow>; onRowError?: ${cloudReferenceType("ctx.dataset.run.onRowError")}; mode?: ${cloudReferenceType("ctx.dataset.run.mode")} };`,
|
|
16573
|
+
`export type DatasetRunOptions<InputRow extends object> = { description?: ${cloudReferenceType("ctx.dataset.run.description")}; key?: DatasetRowKey<InputRow>; onRowError?: ${cloudReferenceType("ctx.dataset.run.onRowError")}; mode?: ${cloudReferenceType("ctx.dataset.run.mode")}; undrawnColumns?: ${cloudReferenceType("ctx.dataset.run.undrawnColumns")} };`,
|
|
16199
16574
|
"export type DatasetBuilder<InputRow extends object, OutputRow extends object> = {",
|
|
16200
16575
|
" withColumn<Name extends string, Value>(name: Name, resolver: ColumnResolver<OutputRow, Value>): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;",
|
|
16201
16576
|
" withColumn<Name extends string, Value>(name: Name, definition: DatasetColumnDefinition<OutputRow, Value> & { readonly runIf: (row: OutputRow, index: number) => boolean | Promise<boolean> }): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;",
|
|
@@ -16226,6 +16601,125 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
|
|
|
16226
16601
|
"export type DefinedPlay<TInput, TOutput extends PlayReturnObject> = ((ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>) & { readonly name: string; readonly __inputType?: TInput; readonly __outputType?: TOutput; readonly runtime?: PlayBindings['runtime']; readonly compatibility?: PlayBindings['compatibility'] };"
|
|
16227
16602
|
];
|
|
16228
16603
|
|
|
16604
|
+
// ../shared_libs/plays/ts-ast.ts
|
|
16605
|
+
import { Parser } from "acorn";
|
|
16606
|
+
import { tsPlugin } from "acorn-typescript";
|
|
16607
|
+
var TypeScriptParser = Parser.extend(
|
|
16608
|
+
tsPlugin({
|
|
16609
|
+
allowSatisfies: true,
|
|
16610
|
+
jsx: {
|
|
16611
|
+
allowNamespaces: true,
|
|
16612
|
+
allowNamespacedObjects: true
|
|
16613
|
+
}
|
|
16614
|
+
})
|
|
16615
|
+
);
|
|
16616
|
+
function isAstNode(value) {
|
|
16617
|
+
return value !== null && typeof value === "object" && "type" in value;
|
|
16618
|
+
}
|
|
16619
|
+
function astArray(value) {
|
|
16620
|
+
return Array.isArray(value) ? value.filter(isAstNode) : [];
|
|
16621
|
+
}
|
|
16622
|
+
function parsePlaySourceForAnalysis(sourceCode) {
|
|
16623
|
+
try {
|
|
16624
|
+
return TypeScriptParser.parse(sourceCode, {
|
|
16625
|
+
ecmaVersion: "latest",
|
|
16626
|
+
sourceType: "module",
|
|
16627
|
+
allowHashBang: true
|
|
16628
|
+
});
|
|
16629
|
+
} catch {
|
|
16630
|
+
return null;
|
|
16631
|
+
}
|
|
16632
|
+
}
|
|
16633
|
+
|
|
16634
|
+
// ../shared_libs/plays/play-exports.ts
|
|
16635
|
+
var PLAY_DEFAULT_EXPORT = "default";
|
|
16636
|
+
function getIdentifierName(node) {
|
|
16637
|
+
return isAstNode(node) && node.type === "Identifier" ? typeof node.name === "string" ? node.name : null : null;
|
|
16638
|
+
}
|
|
16639
|
+
function unwrapStaticExpression(node) {
|
|
16640
|
+
let current = node;
|
|
16641
|
+
while (current && (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression")) {
|
|
16642
|
+
current = isAstNode(current.expression) ? current.expression : null;
|
|
16643
|
+
}
|
|
16644
|
+
return current;
|
|
16645
|
+
}
|
|
16646
|
+
function isDefinePlayCall(node) {
|
|
16647
|
+
const expression = unwrapStaticExpression(node);
|
|
16648
|
+
if (!expression || expression.type !== "CallExpression") return false;
|
|
16649
|
+
const callee = isAstNode(expression.callee) ? expression.callee : null;
|
|
16650
|
+
if (!callee) return false;
|
|
16651
|
+
if (callee.type === "Identifier") {
|
|
16652
|
+
return callee.name === "definePlay" || callee.name === "defineWorkflow";
|
|
16653
|
+
}
|
|
16654
|
+
if (callee.type === "MemberExpression" && !callee.computed && isAstNode(callee.property) && callee.property.type === "Identifier") {
|
|
16655
|
+
return callee.property.name === "definePlay" || callee.property.name === "defineWorkflow";
|
|
16656
|
+
}
|
|
16657
|
+
return false;
|
|
16658
|
+
}
|
|
16659
|
+
function listPlayFileExports(sourceCode) {
|
|
16660
|
+
const ast = parsePlaySourceForAnalysis(sourceCode);
|
|
16661
|
+
if (!ast) return null;
|
|
16662
|
+
const declarations = /* @__PURE__ */ new Map();
|
|
16663
|
+
const namedExports = /* @__PURE__ */ new Map();
|
|
16664
|
+
let defaultExpression = null;
|
|
16665
|
+
const recordDeclarations = (declaration, exported) => {
|
|
16666
|
+
for (const declarator of astArray(declaration.declarations)) {
|
|
16667
|
+
const name = getIdentifierName(declarator.id);
|
|
16668
|
+
if (!name) continue;
|
|
16669
|
+
declarations.set(
|
|
16670
|
+
name,
|
|
16671
|
+
isAstNode(declarator.init) ? declarator.init : null
|
|
16672
|
+
);
|
|
16673
|
+
if (exported) namedExports.set(name, name);
|
|
16674
|
+
}
|
|
16675
|
+
};
|
|
16676
|
+
for (const statement of astArray(ast.body)) {
|
|
16677
|
+
if (statement.type === "VariableDeclaration") {
|
|
16678
|
+
recordDeclarations(statement, false);
|
|
16679
|
+
continue;
|
|
16680
|
+
}
|
|
16681
|
+
if (statement.type === "ExportDefaultDeclaration") {
|
|
16682
|
+
defaultExpression = isAstNode(statement.declaration) ? statement.declaration : null;
|
|
16683
|
+
continue;
|
|
16684
|
+
}
|
|
16685
|
+
if (statement.type === "TSExportAssignment") {
|
|
16686
|
+
defaultExpression = isAstNode(statement.expression) ? statement.expression : null;
|
|
16687
|
+
continue;
|
|
16688
|
+
}
|
|
16689
|
+
if (statement.type !== "ExportNamedDeclaration") continue;
|
|
16690
|
+
if (isAstNode(statement.declaration) && statement.declaration.type === "VariableDeclaration") {
|
|
16691
|
+
recordDeclarations(statement.declaration, true);
|
|
16692
|
+
}
|
|
16693
|
+
for (const specifier of astArray(statement.specifiers)) {
|
|
16694
|
+
const localName = getIdentifierName(specifier.local);
|
|
16695
|
+
const exportedName = getIdentifierName(specifier.exported);
|
|
16696
|
+
if (localName && exportedName) namedExports.set(exportedName, localName);
|
|
16697
|
+
}
|
|
16698
|
+
}
|
|
16699
|
+
const defaultLocalName = getIdentifierName(
|
|
16700
|
+
unwrapStaticExpression(defaultExpression)
|
|
16701
|
+
);
|
|
16702
|
+
const defaultIsPlay = defaultLocalName ? isDefinePlayCall(declarations.get(defaultLocalName) ?? null) : isDefinePlayCall(defaultExpression);
|
|
16703
|
+
const exports = [];
|
|
16704
|
+
const aliasedLocals = /* @__PURE__ */ new Set();
|
|
16705
|
+
if (defaultIsPlay) {
|
|
16706
|
+
const aliases = defaultLocalName ? [...namedExports.entries()].filter(([, local]) => local === defaultLocalName).map(([exported]) => exported) : [];
|
|
16707
|
+
if (defaultLocalName) aliasedLocals.add(defaultLocalName);
|
|
16708
|
+
exports.push({ name: PLAY_DEFAULT_EXPORT, aliases });
|
|
16709
|
+
}
|
|
16710
|
+
for (const [exportedName, localName] of namedExports) {
|
|
16711
|
+
if (exportedName === PLAY_DEFAULT_EXPORT) continue;
|
|
16712
|
+
if (aliasedLocals.has(localName)) continue;
|
|
16713
|
+
if (!isDefinePlayCall(declarations.get(localName) ?? null)) continue;
|
|
16714
|
+
exports.push({ name: exportedName, aliases: [] });
|
|
16715
|
+
}
|
|
16716
|
+
return exports;
|
|
16717
|
+
}
|
|
16718
|
+
|
|
16719
|
+
// ../shared_libs/plays/docflow.ts
|
|
16720
|
+
var MERMAID_NODE_ATTRIBUTES = ["label", "type", "in", "out", "arm"];
|
|
16721
|
+
var LEGACY_DOCFLOW_ATTRIBUTES = ["id", ...MERMAID_NODE_ATTRIBUTES];
|
|
16722
|
+
|
|
16229
16723
|
// ../shared_libs/plays/secret-guardrails.ts
|
|
16230
16724
|
var SECRET_ENV_PATTERN = /\bprocess(?:\.env|\[['"]env['"]\])(?:\.|\[['"])([A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET|PASSWORD|PRIVATE[_-]?KEY|ACCESS[_-]?KEY)[A-Z0-9_]*)(?:['"]\])?/g;
|
|
16231
16725
|
var PRIVATE_KEY_PATTERN = /-----BEGIN (?:RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/;
|
|
@@ -16249,7 +16743,7 @@ function collectInlineSecretFindings(sourceCode) {
|
|
|
16249
16743
|
var MAX_PLAY_BUNDLE_BYTES = 30 * 1024 * 1024;
|
|
16250
16744
|
|
|
16251
16745
|
// ../shared_libs/plays/bundling/index.ts
|
|
16252
|
-
var PLAY_BUNDLE_CACHE_VERSION =
|
|
16746
|
+
var PLAY_BUNDLE_CACHE_VERSION = 33;
|
|
16253
16747
|
var PLAY_ARTIFACT_CACHE_DIR = join7(
|
|
16254
16748
|
tmpdir2(),
|
|
16255
16749
|
`deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION}`
|
|
@@ -16262,15 +16756,6 @@ var NODE_BUILTIN_SET = new Set(
|
|
|
16262
16756
|
function extractDefinedPlayName(sourceCode) {
|
|
16263
16757
|
return extractDefinedPlayMetadata(sourceCode, null)?.name ?? null;
|
|
16264
16758
|
}
|
|
16265
|
-
var TypeScriptParser = Parser.extend(
|
|
16266
|
-
tsPlugin({
|
|
16267
|
-
allowSatisfies: true,
|
|
16268
|
-
jsx: {
|
|
16269
|
-
allowNamespaces: true,
|
|
16270
|
-
allowNamespacedObjects: true
|
|
16271
|
-
}
|
|
16272
|
-
})
|
|
16273
|
-
);
|
|
16274
16759
|
function parsePlaySourceAst(sourceCode) {
|
|
16275
16760
|
try {
|
|
16276
16761
|
return TypeScriptParser.parse(sourceCode, {
|
|
@@ -16287,7 +16772,7 @@ function parsePlaySourceAst(sourceCode) {
|
|
|
16287
16772
|
legalComments: "none",
|
|
16288
16773
|
sourcemap: false
|
|
16289
16774
|
}).code;
|
|
16290
|
-
return
|
|
16775
|
+
return Parser2.parse(transformed, {
|
|
16291
16776
|
ecmaVersion: "latest",
|
|
16292
16777
|
sourceType: "module",
|
|
16293
16778
|
allowHashBang: true
|
|
@@ -16297,17 +16782,11 @@ function parsePlaySourceAst(sourceCode) {
|
|
|
16297
16782
|
}
|
|
16298
16783
|
}
|
|
16299
16784
|
}
|
|
16300
|
-
function
|
|
16785
|
+
function getIdentifierName2(node) {
|
|
16301
16786
|
return isAstNode(node) && node.type === "Identifier" ? typeof node.name === "string" ? node.name : null : null;
|
|
16302
16787
|
}
|
|
16303
|
-
function isAstNode(value) {
|
|
16304
|
-
return value !== null && typeof value === "object" && "type" in value;
|
|
16305
|
-
}
|
|
16306
|
-
function astArray(value) {
|
|
16307
|
-
return Array.isArray(value) ? value.filter(isAstNode) : [];
|
|
16308
|
-
}
|
|
16309
16788
|
function memberExpressionPath(node) {
|
|
16310
|
-
const expression =
|
|
16789
|
+
const expression = unwrapStaticExpression2(node);
|
|
16311
16790
|
if (!expression) return null;
|
|
16312
16791
|
if (expression.type === "Identifier" && typeof expression.name === "string") {
|
|
16313
16792
|
return [expression.name];
|
|
@@ -16365,7 +16844,7 @@ function buildPlayMetadataContext(ast) {
|
|
|
16365
16844
|
for (const statement of astArray(ast.body)) {
|
|
16366
16845
|
if (statement.type === "VariableDeclaration") {
|
|
16367
16846
|
for (const declaration of astArray(statement.declarations)) {
|
|
16368
|
-
const name =
|
|
16847
|
+
const name = getIdentifierName2(declaration.id);
|
|
16369
16848
|
if (!name) continue;
|
|
16370
16849
|
const initializer = isAstNode(declaration.init) ? declaration.init : null;
|
|
16371
16850
|
declarations.set(
|
|
@@ -16388,7 +16867,7 @@ function buildPlayMetadataContext(ast) {
|
|
|
16388
16867
|
for (const declaration of astArray(
|
|
16389
16868
|
statement.declaration.declarations
|
|
16390
16869
|
)) {
|
|
16391
|
-
const name =
|
|
16870
|
+
const name = getIdentifierName2(declaration.id);
|
|
16392
16871
|
if (!name) continue;
|
|
16393
16872
|
const initializer = isAstNode(declaration.init) ? declaration.init : null;
|
|
16394
16873
|
declarations.set(
|
|
@@ -16402,8 +16881,8 @@ function buildPlayMetadataContext(ast) {
|
|
|
16402
16881
|
}
|
|
16403
16882
|
}
|
|
16404
16883
|
for (const specifier of astArray(statement.specifiers)) {
|
|
16405
|
-
const localName =
|
|
16406
|
-
const exportedName =
|
|
16884
|
+
const localName = getIdentifierName2(specifier.local);
|
|
16885
|
+
const exportedName = getIdentifierName2(specifier.exported) ?? (isAstNode(specifier.exported) && specifier.exported.type === "Literal" && typeof specifier.exported.value === "string" ? specifier.exported.value : null);
|
|
16407
16886
|
if (localName && exportedName) {
|
|
16408
16887
|
namedExports.set(exportedName, localName);
|
|
16409
16888
|
}
|
|
@@ -16420,7 +16899,7 @@ function buildPlayMetadataContext(ast) {
|
|
|
16420
16899
|
}
|
|
16421
16900
|
return { declarations, namedExports, commonJsExports, defaultExport };
|
|
16422
16901
|
}
|
|
16423
|
-
function
|
|
16902
|
+
function unwrapStaticExpression2(node) {
|
|
16424
16903
|
let current = node ?? null;
|
|
16425
16904
|
while (current && (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression")) {
|
|
16426
16905
|
current = isAstNode(current.expression) ? current.expression : null;
|
|
@@ -16428,7 +16907,7 @@ function unwrapStaticExpression(node) {
|
|
|
16428
16907
|
return current;
|
|
16429
16908
|
}
|
|
16430
16909
|
function staticStringFromExpression(node, context, seen = /* @__PURE__ */ new Set(), trimResult = true) {
|
|
16431
|
-
const expression =
|
|
16910
|
+
const expression = unwrapStaticExpression2(node);
|
|
16432
16911
|
if (!expression) return null;
|
|
16433
16912
|
if (expression.type === "Literal") {
|
|
16434
16913
|
const value = expression.value;
|
|
@@ -16458,7 +16937,7 @@ function staticStringFromExpression(node, context, seen = /* @__PURE__ */ new Se
|
|
|
16458
16937
|
if (!value?.trim()) return null;
|
|
16459
16938
|
return trimResult ? value.trim() : value;
|
|
16460
16939
|
}
|
|
16461
|
-
const identifier =
|
|
16940
|
+
const identifier = getIdentifierName2(expression);
|
|
16462
16941
|
if (!identifier || seen.has(identifier)) return null;
|
|
16463
16942
|
seen.add(identifier);
|
|
16464
16943
|
return staticStringFromExpression(
|
|
@@ -16483,10 +16962,10 @@ function propertyNameFromKey(property) {
|
|
|
16483
16962
|
return null;
|
|
16484
16963
|
}
|
|
16485
16964
|
function objectExpressionFromNode(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
16486
|
-
const expression =
|
|
16965
|
+
const expression = unwrapStaticExpression2(node);
|
|
16487
16966
|
if (!expression) return null;
|
|
16488
16967
|
if (expression.type === "ObjectExpression") return expression;
|
|
16489
|
-
const identifier =
|
|
16968
|
+
const identifier = getIdentifierName2(expression);
|
|
16490
16969
|
if (!identifier || seen.has(identifier)) return null;
|
|
16491
16970
|
seen.add(identifier);
|
|
16492
16971
|
return objectExpressionFromNode(
|
|
@@ -16553,12 +17032,12 @@ function staticPropertyNames(node, context, ancestors = /* @__PURE__ */ new Set(
|
|
|
16553
17032
|
return names;
|
|
16554
17033
|
}
|
|
16555
17034
|
function staticNumberFromExpression(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
16556
|
-
const expression =
|
|
17035
|
+
const expression = unwrapStaticExpression2(node);
|
|
16557
17036
|
if (!expression) return null;
|
|
16558
17037
|
if (expression.type === "Literal" && typeof expression.value === "number") {
|
|
16559
17038
|
return expression.value;
|
|
16560
17039
|
}
|
|
16561
|
-
const identifier =
|
|
17040
|
+
const identifier = getIdentifierName2(expression);
|
|
16562
17041
|
if (!identifier || seen.has(identifier)) return null;
|
|
16563
17042
|
seen.add(identifier);
|
|
16564
17043
|
return staticNumberFromExpression(
|
|
@@ -16647,7 +17126,7 @@ function stringPropertyFromObjectExpression(node, propertyName, context, seenObj
|
|
|
16647
17126
|
return value;
|
|
16648
17127
|
}
|
|
16649
17128
|
function isDefinePlayCallee(node) {
|
|
16650
|
-
const callee =
|
|
17129
|
+
const callee = unwrapStaticExpression2(node);
|
|
16651
17130
|
if (!callee) return false;
|
|
16652
17131
|
if (callee.type === "Identifier" && (callee.name === "definePlay" || callee.name === "defineWorkflow")) {
|
|
16653
17132
|
return true;
|
|
@@ -16659,7 +17138,7 @@ function isDefinePlayCallee(node) {
|
|
|
16659
17138
|
return false;
|
|
16660
17139
|
}
|
|
16661
17140
|
function playMetadataFromDefinePlayCall(node, context) {
|
|
16662
|
-
const expression =
|
|
17141
|
+
const expression = unwrapStaticExpression2(node);
|
|
16663
17142
|
if (!expression || expression.type !== "CallExpression" || !isDefinePlayCallee(isAstNode(expression.callee) ? expression.callee : null)) {
|
|
16664
17143
|
return null;
|
|
16665
17144
|
}
|
|
@@ -16705,13 +17184,13 @@ function resolveExportExpression(exportName, context) {
|
|
|
16705
17184
|
if (exportName === "default") {
|
|
16706
17185
|
const commonJsDefault = context.commonJsExports.get("default");
|
|
16707
17186
|
if (commonJsDefault) {
|
|
16708
|
-
const commonJsDefaultIdentifier =
|
|
16709
|
-
|
|
17187
|
+
const commonJsDefaultIdentifier = getIdentifierName2(
|
|
17188
|
+
unwrapStaticExpression2(commonJsDefault)
|
|
16710
17189
|
);
|
|
16711
17190
|
return commonJsDefaultIdentifier ? context.declarations.get(commonJsDefaultIdentifier) ?? commonJsDefault : commonJsDefault;
|
|
16712
17191
|
}
|
|
16713
|
-
const defaultExpression =
|
|
16714
|
-
const defaultIdentifier =
|
|
17192
|
+
const defaultExpression = unwrapStaticExpression2(context.defaultExport);
|
|
17193
|
+
const defaultIdentifier = getIdentifierName2(defaultExpression);
|
|
16715
17194
|
if (!defaultIdentifier) {
|
|
16716
17195
|
const defaultExportName = context.namedExports.get("default");
|
|
16717
17196
|
return defaultExportName ? context.declarations.get(defaultExportName) ?? null : defaultExpression;
|
|
@@ -16721,8 +17200,8 @@ function resolveExportExpression(exportName, context) {
|
|
|
16721
17200
|
if (exportName) {
|
|
16722
17201
|
const commonJsExport = context.commonJsExports.get(exportName);
|
|
16723
17202
|
if (commonJsExport) {
|
|
16724
|
-
const commonJsExportIdentifier =
|
|
16725
|
-
|
|
17203
|
+
const commonJsExportIdentifier = getIdentifierName2(
|
|
17204
|
+
unwrapStaticExpression2(commonJsExport)
|
|
16726
17205
|
);
|
|
16727
17206
|
return commonJsExportIdentifier ? context.declarations.get(commonJsExportIdentifier) ?? commonJsExport : commonJsExport;
|
|
16728
17207
|
}
|
|
@@ -16748,7 +17227,7 @@ function extractDefinedPlayMetadata(sourceCode, exportName) {
|
|
|
16748
17227
|
context
|
|
16749
17228
|
);
|
|
16750
17229
|
if (directDefaultMetadata) return directDefaultMetadata;
|
|
16751
|
-
const defaultIdentifier =
|
|
17230
|
+
const defaultIdentifier = getIdentifierName2(context.defaultExport);
|
|
16752
17231
|
if (defaultIdentifier) {
|
|
16753
17232
|
const defaultMetadata = playMetadataFromDefinePlayCall(
|
|
16754
17233
|
context.declarations.get(defaultIdentifier),
|
|
@@ -17292,6 +17771,79 @@ function isInternalGlueStepId(stepId) {
|
|
|
17292
17771
|
return typeof stepId === "string" && stepId.startsWith(INTERNAL_GLUE_NODE_ID_PREFIX);
|
|
17293
17772
|
}
|
|
17294
17773
|
|
|
17774
|
+
// ../shared_libs/play-runtime/log-provenance.ts
|
|
17775
|
+
var LOG_PROVENANCE_CLASSES = [
|
|
17776
|
+
"user",
|
|
17777
|
+
"lifecycle",
|
|
17778
|
+
"replay",
|
|
17779
|
+
"infra",
|
|
17780
|
+
"diagnostic",
|
|
17781
|
+
"receipt"
|
|
17782
|
+
];
|
|
17783
|
+
var LOG_PROVENANCE_POLICY = {
|
|
17784
|
+
user: { watch: true, ui: true, debug: true },
|
|
17785
|
+
lifecycle: { watch: true, ui: true, debug: true },
|
|
17786
|
+
replay: { watch: false, ui: false, debug: true },
|
|
17787
|
+
infra: { watch: false, ui: false, debug: true },
|
|
17788
|
+
diagnostic: { watch: true, ui: true, debug: true },
|
|
17789
|
+
receipt: { watch: false, ui: false, debug: true }
|
|
17790
|
+
};
|
|
17791
|
+
function logProvenanceReaches(provenance, surface) {
|
|
17792
|
+
return LOG_PROVENANCE_POLICY[provenance][surface];
|
|
17793
|
+
}
|
|
17794
|
+
var PROVENANCE_SENTINEL = "";
|
|
17795
|
+
var PROVENANCE_PREFIX = `${PROVENANCE_SENTINEL}prov:`;
|
|
17796
|
+
function readProvenanceTag(line) {
|
|
17797
|
+
if (!line.startsWith(PROVENANCE_PREFIX)) {
|
|
17798
|
+
return { provenance: null, line };
|
|
17799
|
+
}
|
|
17800
|
+
const end = line.indexOf(PROVENANCE_SENTINEL, PROVENANCE_PREFIX.length);
|
|
17801
|
+
if (end === -1) {
|
|
17802
|
+
return { provenance: null, line };
|
|
17803
|
+
}
|
|
17804
|
+
const candidate = line.slice(PROVENANCE_PREFIX.length, end);
|
|
17805
|
+
const provenance = LOG_PROVENANCE_CLASSES.includes(
|
|
17806
|
+
candidate
|
|
17807
|
+
) ? candidate : null;
|
|
17808
|
+
return { provenance, line: line.slice(end + 1) };
|
|
17809
|
+
}
|
|
17810
|
+
function classifyLegacyLogLine(line) {
|
|
17811
|
+
const message = stripLeadingTimestamp(line);
|
|
17812
|
+
if (/recovered (?:from checkpoint|response from checkpoint)/i.test(message)) {
|
|
17813
|
+
return "replay";
|
|
17814
|
+
}
|
|
17815
|
+
if (/^\[perf\] runtime receipt\b/i.test(message)) {
|
|
17816
|
+
return "receipt";
|
|
17817
|
+
}
|
|
17818
|
+
if (/^\[perf\] runtime (?:map|state)\b/i.test(message) || /\[worker\] picked up run\b/.test(message) || /\[worker\] heartbeat\b/.test(message) || /\[worker\] progress completedRows=\d+ totalRows=\d+ rowUpdates=\d+/.test(
|
|
17819
|
+
message
|
|
17820
|
+
) || /\[worker\] step started\b/.test(message) || /\[worker\] Preparing run files\b/.test(message) || /\[worker\] Run files ready\b/.test(message) || /\[worker\] Runtime ready\b/.test(message) || /\[worker\] Sandbox (?:starting|create start|create done|workspace ready|upload start|runner uploaded)\b/.test(
|
|
17821
|
+
message
|
|
17822
|
+
) || /^\[event\] play\.step\.progress\b/.test(message) || /^\[event\] play\.run\.snapshot\b/.test(message) || /^\[event\] play\.sheet\.summary\b/.test(message)) {
|
|
17823
|
+
return "infra";
|
|
17824
|
+
}
|
|
17825
|
+
if (/^\[warn\]/i.test(message) || /^\[error\]/i.test(message) || /^\[runtime\.[a-z_]*(?:failure|error)\]/i.test(message)) {
|
|
17826
|
+
return "diagnostic";
|
|
17827
|
+
}
|
|
17828
|
+
return "user";
|
|
17829
|
+
}
|
|
17830
|
+
function classifyLogLine(line) {
|
|
17831
|
+
const tagged = readProvenanceTag(line);
|
|
17832
|
+
if (tagged.provenance !== null) {
|
|
17833
|
+
return { provenance: tagged.provenance, line: tagged.line };
|
|
17834
|
+
}
|
|
17835
|
+
return { provenance: classifyLegacyLogLine(tagged.line), line: tagged.line };
|
|
17836
|
+
}
|
|
17837
|
+
function stripLeadingTimestamp(line) {
|
|
17838
|
+
const match = line.match(/^\[([^\]]+)\]\s*([\s\S]*)$/);
|
|
17839
|
+
if (!match) {
|
|
17840
|
+
return line;
|
|
17841
|
+
}
|
|
17842
|
+
const inner = match[1] ?? "";
|
|
17843
|
+
const isTimestamp = !Number.isNaN(new Date(inner).getTime());
|
|
17844
|
+
return isTimestamp ? match[2] ?? line : line;
|
|
17845
|
+
}
|
|
17846
|
+
|
|
17295
17847
|
// ../shared_libs/play-runtime/fixture-behavior.ts
|
|
17296
17848
|
var FIXTURE_BEHAVIOR_VERSION = 1;
|
|
17297
17849
|
var FIXTURE_BEHAVIOR_RESPONSE_VERSION = 2;
|
|
@@ -18269,11 +18821,12 @@ function formatUnresolvedPackagedFiles(filePath, unresolvedFileReferences) {
|
|
|
18269
18821
|
const details = unresolvedFileReferences.map((unresolved) => `${unresolved.sourceFragment}: ${unresolved.message}`).join("; ");
|
|
18270
18822
|
return `Failed to package local ctx.csv(...) files in ${filePath}: ${details}`;
|
|
18271
18823
|
}
|
|
18272
|
-
async function collectBundledPlayGraph(entryFile, profile = null) {
|
|
18824
|
+
async function collectBundledPlayGraph(entryFile, profile = null, entryExportName = PLAY_DEFAULT_EXPORT) {
|
|
18273
18825
|
const playBundler = await loadPlayBundler();
|
|
18274
18826
|
const nodes = /* @__PURE__ */ new Map();
|
|
18275
18827
|
const visiting = /* @__PURE__ */ new Set();
|
|
18276
18828
|
const artifactKind = resolveEnabledExecutionProfile(profile).artifactKind;
|
|
18829
|
+
const rootPath = normalizePlayPath(entryFile);
|
|
18277
18830
|
const visit = async (filePath) => {
|
|
18278
18831
|
const absolutePath = normalizePlayPath(filePath);
|
|
18279
18832
|
const cached = nodes.get(absolutePath);
|
|
@@ -18288,7 +18841,8 @@ async function collectBundledPlayGraph(entryFile, profile = null) {
|
|
|
18288
18841
|
visiting.add(absolutePath);
|
|
18289
18842
|
try {
|
|
18290
18843
|
const bundleResult = await playBundler.bundlePlayFile(absolutePath, {
|
|
18291
|
-
target: artifactKind
|
|
18844
|
+
target: artifactKind,
|
|
18845
|
+
...absolutePath === rootPath && entryExportName !== PLAY_DEFAULT_EXPORT ? { exportName: entryExportName } : {}
|
|
18292
18846
|
});
|
|
18293
18847
|
if (bundleResult.success === false) {
|
|
18294
18848
|
throw new Error(
|
|
@@ -18478,6 +19032,12 @@ var TERMINAL_PLAY_STATUSES2 = /* @__PURE__ */ new Set([
|
|
|
18478
19032
|
var PLAY_START_TRANSIENT_RETRY_DELAYS_MS = [500, 1500];
|
|
18479
19033
|
var PLAY_PROGRESS_HEARTBEAT_INTERVAL_MS = 15e3;
|
|
18480
19034
|
var PLAY_STATUS_HEARTBEAT_INTERVAL_MS = 15e3;
|
|
19035
|
+
function watchSurfaceReaches(state, provenance) {
|
|
19036
|
+
if (logProvenanceReaches(provenance, "watch")) {
|
|
19037
|
+
return true;
|
|
19038
|
+
}
|
|
19039
|
+
return state.verbose === true && logProvenanceReaches(provenance, "debug");
|
|
19040
|
+
}
|
|
18481
19041
|
function getEventPayload(event) {
|
|
18482
19042
|
return event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
18483
19043
|
}
|
|
@@ -18514,6 +19074,13 @@ function getStatusFromLiveEvent(event) {
|
|
|
18514
19074
|
}
|
|
18515
19075
|
function readLiveRunField(event, field) {
|
|
18516
19076
|
const payload = getEventPayload(event);
|
|
19077
|
+
if (field === "waitKind") {
|
|
19078
|
+
const wait = payload.wait ?? getRunRecordFromPackage(payload)?.wait;
|
|
19079
|
+
if (wait && typeof wait === "object" && !Array.isArray(wait)) {
|
|
19080
|
+
const kind = wait.kind;
|
|
19081
|
+
if (typeof kind === "string" && kind.trim()) return kind.trim();
|
|
19082
|
+
}
|
|
19083
|
+
}
|
|
18517
19084
|
const run = getRunRecordFromPackage(payload);
|
|
18518
19085
|
const records = [payload, payload.progress, run, run?.progress].filter(
|
|
18519
19086
|
(value) => Boolean(value && typeof value === "object" && !Array.isArray(value))
|
|
@@ -18660,6 +19227,9 @@ function emitLiveDebugTableHints(input2) {
|
|
|
18660
19227
|
process.stdout
|
|
18661
19228
|
);
|
|
18662
19229
|
}
|
|
19230
|
+
if (!watchSurfaceReaches(input2.state, "infra")) {
|
|
19231
|
+
return;
|
|
19232
|
+
}
|
|
18663
19233
|
const tableNamespace = extractTableNamespaceFromLiveEvent(input2.event);
|
|
18664
19234
|
if (!tableNamespace) {
|
|
18665
19235
|
return;
|
|
@@ -18685,15 +19255,17 @@ function describeLiveEventPhase(event) {
|
|
|
18685
19255
|
const runId = eventRunId ? ` ${eventRunId}` : "";
|
|
18686
19256
|
return status ? `${status}${runId}` : null;
|
|
18687
19257
|
}
|
|
18688
|
-
if (event.type === "play.step.
|
|
19258
|
+
if (event.type === "play.step.progress") {
|
|
18689
19259
|
const label = typeof payload.label === "string" && payload.label.trim() ? payload.label.trim() : formatStepLabelFromNodeId(payload.stepId);
|
|
18690
19260
|
if (!label) {
|
|
18691
19261
|
return null;
|
|
18692
19262
|
}
|
|
18693
19263
|
const completed = typeof payload.completed === "number" ? payload.completed : null;
|
|
18694
19264
|
const total = typeof payload.total === "number" ? payload.total : null;
|
|
18695
|
-
|
|
18696
|
-
|
|
19265
|
+
if (completed === null || total === null) {
|
|
19266
|
+
return null;
|
|
19267
|
+
}
|
|
19268
|
+
return `step ${label} ${completed}/${total}`;
|
|
18697
19269
|
}
|
|
18698
19270
|
if (event.type === "play.sheet.summary" || event.type === "play.sheet.delta") {
|
|
18699
19271
|
const table = typeof payload.tableNamespace === "string" ? payload.tableNamespace : "";
|
|
@@ -18732,6 +19304,7 @@ function formatStepLabelFromNodeId(raw) {
|
|
|
18732
19304
|
return value;
|
|
18733
19305
|
}
|
|
18734
19306
|
}
|
|
19307
|
+
var TERMINAL_STEP_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "skipped"]);
|
|
18735
19308
|
function getStepTransitionLineFromLiveEvent(event, state) {
|
|
18736
19309
|
if (event.type !== "play.step.status") {
|
|
18737
19310
|
return null;
|
|
@@ -18750,7 +19323,16 @@ function getStepTransitionLineFromLiveEvent(event, state) {
|
|
|
18750
19323
|
if (state.printedStepStatuses.get(stepId) === status) {
|
|
18751
19324
|
return null;
|
|
18752
19325
|
}
|
|
19326
|
+
state.terminalStepIds ??= /* @__PURE__ */ new Set();
|
|
19327
|
+
const isTerminal = TERMINAL_STEP_STATUSES.has(status);
|
|
19328
|
+
const isReplayEcho = !isTerminal && state.terminalStepIds.has(stepId);
|
|
18753
19329
|
state.printedStepStatuses.set(stepId, status);
|
|
19330
|
+
if (isTerminal) {
|
|
19331
|
+
state.terminalStepIds.add(stepId);
|
|
19332
|
+
}
|
|
19333
|
+
if (isReplayEcho && !watchSurfaceReaches(state, "replay")) {
|
|
19334
|
+
return null;
|
|
19335
|
+
}
|
|
18754
19336
|
return `step ${label}: ${status}`;
|
|
18755
19337
|
}
|
|
18756
19338
|
function formatProgressCounts(input2) {
|
|
@@ -19141,6 +19723,7 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
|
|
|
19141
19723
|
const state = {
|
|
19142
19724
|
lastLogIndex: 0,
|
|
19143
19725
|
emittedRunnerStarted: false,
|
|
19726
|
+
verbose: input2.verboseLogs === true,
|
|
19144
19727
|
lastProgressSignature: null,
|
|
19145
19728
|
lastProgressHeartbeatAt: 0,
|
|
19146
19729
|
lastStatusHeartbeatAt: 0
|
|
@@ -19505,7 +20088,9 @@ var BULKY_RETURN_KEYS = /* @__PURE__ */ new Set([
|
|
|
19505
20088
|
"sequenceTrace",
|
|
19506
20089
|
"logs"
|
|
19507
20090
|
]);
|
|
19508
|
-
function formatPlayLogLine(
|
|
20091
|
+
function formatPlayLogLine(rawLine, status, state) {
|
|
20092
|
+
const classified = classifyLogLine(rawLine);
|
|
20093
|
+
const line = classified.line;
|
|
19509
20094
|
const timestampMatch = line.match(/^\[([^\]]+)\]\s*(.*)$/);
|
|
19510
20095
|
const parsedTimestamp = timestampMatch?.[1] ? new Date(timestampMatch[1]) : null;
|
|
19511
20096
|
const timestamp = parsedTimestamp && !Number.isNaN(parsedTimestamp.getTime()) ? parsedTimestamp.toLocaleTimeString("en-US", {
|
|
@@ -19523,11 +20108,6 @@ function formatPlayLogLine(line, status, state) {
|
|
|
19523
20108
|
state.emittedRunnerStarted = true;
|
|
19524
20109
|
return `${prefix}runner started`;
|
|
19525
20110
|
}
|
|
19526
|
-
if (/\[worker\] step started\b/.test(message) || /\[worker\] Preparing run files\b/.test(message) || /\[worker\] Run files ready\b/.test(message) || /\[worker\] Runtime ready\b/.test(message) || /\[worker\] Sandbox (?:starting|create start|create done|workspace ready|upload start|runner uploaded)\b/.test(
|
|
19527
|
-
message
|
|
19528
|
-
)) {
|
|
19529
|
-
return null;
|
|
19530
|
-
}
|
|
19531
20111
|
const stages = (status?.contract?.staticPipeline?.stages ?? []).filter((stage) => stage.tableNamespace);
|
|
19532
20112
|
const sourceLabelForNamespace = (namespace) => {
|
|
19533
20113
|
const stage = stages.find((entry) => entry.tableNamespace === namespace);
|
|
@@ -19548,6 +20128,9 @@ function formatPlayLogLine(line, status, state) {
|
|
|
19548
20128
|
const [, results, executed, cached] = mapDone;
|
|
19549
20129
|
return `${prefix}done: ${formatInteger(Number(results))} results, ${formatInteger(Number(executed))} executed, ${formatInteger(Number(cached))} cached`;
|
|
19550
20130
|
}
|
|
20131
|
+
if (!watchSurfaceReaches(state, classified.provenance)) {
|
|
20132
|
+
return null;
|
|
20133
|
+
}
|
|
19551
20134
|
return `${prefix}${message}`;
|
|
19552
20135
|
}
|
|
19553
20136
|
function isDatasetResultEnvelope(value) {
|
|
@@ -21127,7 +21710,7 @@ function extractPlayValidationErrors(value) {
|
|
|
21127
21710
|
if (value instanceof DeeplineError) {
|
|
21128
21711
|
return extractPlayValidationErrors(value.details);
|
|
21129
21712
|
}
|
|
21130
|
-
if (!
|
|
21713
|
+
if (!isRecord10(value)) {
|
|
21131
21714
|
return [];
|
|
21132
21715
|
}
|
|
21133
21716
|
const directErrors = stringArrayField(value, "errors");
|
|
@@ -21364,6 +21947,7 @@ function parsePlayRunOptions(args) {
|
|
|
21364
21947
|
const debugFixtureProviderPacing = args.includes(
|
|
21365
21948
|
"--debug-fixture-provider-pacing"
|
|
21366
21949
|
);
|
|
21950
|
+
const verboseLogs = args.includes("--logs") || debugMapLatency;
|
|
21367
21951
|
let waitTimeoutMs = null;
|
|
21368
21952
|
let profile = null;
|
|
21369
21953
|
let fixtureBehavior = null;
|
|
@@ -21500,6 +22084,7 @@ function parsePlayRunOptions(args) {
|
|
|
21500
22084
|
revisionSelector,
|
|
21501
22085
|
watch,
|
|
21502
22086
|
emitLogs,
|
|
22087
|
+
verboseLogs,
|
|
21503
22088
|
jsonOutput,
|
|
21504
22089
|
fullJson,
|
|
21505
22090
|
waitTimeoutMs,
|
|
@@ -21586,7 +22171,7 @@ function printPlayCheckLimits(limits) {
|
|
|
21586
22171
|
` bundle: ${formatByteBudget(limits.bundle.usedBytes, limits.bundle.limitBytes)}`
|
|
21587
22172
|
);
|
|
21588
22173
|
}
|
|
21589
|
-
function
|
|
22174
|
+
function isRecord10(value) {
|
|
21590
22175
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
21591
22176
|
}
|
|
21592
22177
|
function stringValue2(value) {
|
|
@@ -21596,14 +22181,14 @@ function asArray(value) {
|
|
|
21596
22181
|
return Array.isArray(value) ? value : [];
|
|
21597
22182
|
}
|
|
21598
22183
|
function extractionEntries2(value) {
|
|
21599
|
-
if (Array.isArray(value)) return value.filter(
|
|
21600
|
-
if (!
|
|
22184
|
+
if (Array.isArray(value)) return value.filter(isRecord10);
|
|
22185
|
+
if (!isRecord10(value)) return [];
|
|
21601
22186
|
return Object.entries(value).map(
|
|
21602
|
-
([name, entry]) =>
|
|
22187
|
+
([name, entry]) => isRecord10(entry) ? { name, ...entry } : { name }
|
|
21603
22188
|
);
|
|
21604
22189
|
}
|
|
21605
22190
|
function firstRawPath(entry) {
|
|
21606
|
-
const details =
|
|
22191
|
+
const details = isRecord10(entry.details) ? entry.details : {};
|
|
21607
22192
|
const paths = [
|
|
21608
22193
|
...asArray(details.rawToolOutputPaths),
|
|
21609
22194
|
...asArray(details.raw_tool_output_paths),
|
|
@@ -21621,12 +22206,12 @@ function checkHintRawPath(value) {
|
|
|
21621
22206
|
function collectStaticPipelineToolIds(staticPipeline) {
|
|
21622
22207
|
const seen = /* @__PURE__ */ new Set();
|
|
21623
22208
|
const visitPipeline = (pipeline) => {
|
|
21624
|
-
if (!
|
|
22209
|
+
if (!isRecord10(pipeline)) return;
|
|
21625
22210
|
for (const step of [
|
|
21626
22211
|
...asArray(pipeline.stages),
|
|
21627
22212
|
...asArray(pipeline.substeps)
|
|
21628
22213
|
]) {
|
|
21629
|
-
if (!
|
|
22214
|
+
if (!isRecord10(step)) continue;
|
|
21630
22215
|
if (step.type === "tool") {
|
|
21631
22216
|
const toolId = stringValue2(step.toolId) || stringValue2(step.tool);
|
|
21632
22217
|
if (toolId) seen.add(toolId);
|
|
@@ -21640,9 +22225,9 @@ function collectStaticPipelineToolIds(staticPipeline) {
|
|
|
21640
22225
|
return [...seen].sort();
|
|
21641
22226
|
}
|
|
21642
22227
|
function toolGetterHintFromMetadata(toolId, tool) {
|
|
21643
|
-
const usageGuidance =
|
|
21644
|
-
const resultGuidance =
|
|
21645
|
-
const toolResponse =
|
|
22228
|
+
const usageGuidance = isRecord10(tool.usageGuidance) ? tool.usageGuidance : {};
|
|
22229
|
+
const resultGuidance = isRecord10(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord10(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
|
|
22230
|
+
const toolResponse = isRecord10(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord10(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
|
|
21646
22231
|
const lists = extractionEntries2(
|
|
21647
22232
|
resultGuidance.extractedLists ?? resultGuidance.extracted_lists
|
|
21648
22233
|
).map((entry) => ({
|
|
@@ -21738,6 +22323,11 @@ function printRecognizedSummary(recognized) {
|
|
|
21738
22323
|
for (const dataset of recognized.datasets ?? []) {
|
|
21739
22324
|
const columns = dataset.columns?.length ? ` (${dataset.columns.length} col${dataset.columns.length === 1 ? "" : "s"}: ${dataset.columns.join(", ")})` : "";
|
|
21740
22325
|
console.log(` dataset ${dataset.name}${columns}`);
|
|
22326
|
+
if (dataset.undrawnColumns?.length) {
|
|
22327
|
+
console.log(
|
|
22328
|
+
` undrawn (declared): ${dataset.undrawnColumns.join(", ")}`
|
|
22329
|
+
);
|
|
22330
|
+
}
|
|
21741
22331
|
}
|
|
21742
22332
|
if (recognized.inputs?.length) {
|
|
21743
22333
|
console.log(` inputs: ${recognized.inputs.join(", ")}`);
|
|
@@ -21823,16 +22413,16 @@ function partitionMirroredErrors(errors, issues) {
|
|
|
21823
22413
|
async function handlePlayCheck(args) {
|
|
21824
22414
|
const options = parsePlayCheckOptions(args);
|
|
21825
22415
|
if (!isFileTarget(options.target)) {
|
|
21826
|
-
const
|
|
22416
|
+
const client2 = new DeeplineClient();
|
|
21827
22417
|
try {
|
|
21828
|
-
await assertCanonicalNamedPlayReference(
|
|
22418
|
+
await assertCanonicalNamedPlayReference(client2, options.target, {
|
|
21829
22419
|
command: "check"
|
|
21830
22420
|
});
|
|
21831
|
-
const play = await
|
|
22421
|
+
const play = await client2.describePlay(
|
|
21832
22422
|
parseReferencedPlayTarget2(options.target).playName,
|
|
21833
22423
|
{ compact: true }
|
|
21834
22424
|
);
|
|
21835
|
-
const
|
|
22425
|
+
const result = {
|
|
21836
22426
|
valid: true,
|
|
21837
22427
|
target: options.target,
|
|
21838
22428
|
name: play.name,
|
|
@@ -21845,10 +22435,10 @@ async function handlePlayCheck(args) {
|
|
|
21845
22435
|
note: "Named/prebuilt play contract is available. No run was started."
|
|
21846
22436
|
};
|
|
21847
22437
|
if (options.jsonOutput) {
|
|
21848
|
-
process.stdout.write(`${JSON.stringify(
|
|
22438
|
+
process.stdout.write(`${JSON.stringify(result)}
|
|
21849
22439
|
`);
|
|
21850
22440
|
} else {
|
|
21851
|
-
console.log(`\u2713 ${
|
|
22441
|
+
console.log(`\u2713 ${result.reference} passed named play contract check`);
|
|
21852
22442
|
console.log(" no run started; no Deepline credits spent");
|
|
21853
22443
|
if (play.runCommand) console.log(` run: ${play.runCommand}`);
|
|
21854
22444
|
}
|
|
@@ -21873,41 +22463,58 @@ async function handlePlayCheck(args) {
|
|
|
21873
22463
|
}
|
|
21874
22464
|
const absolutePlayPath = resolve11(options.target);
|
|
21875
22465
|
const sourceCode = readFileSync8(absolutePlayPath, "utf-8");
|
|
22466
|
+
const exportNames = resolvePlayCheckExportNames(sourceCode);
|
|
22467
|
+
const outcomes = [];
|
|
22468
|
+
for (const exportName of exportNames) {
|
|
22469
|
+
outcomes.push(
|
|
22470
|
+
await checkOneExportedPlay({
|
|
22471
|
+
absolutePlayPath,
|
|
22472
|
+
sourceCode,
|
|
22473
|
+
exportName,
|
|
22474
|
+
target: options.target
|
|
22475
|
+
})
|
|
22476
|
+
);
|
|
22477
|
+
}
|
|
22478
|
+
const merged = mergePlayCheckExportOutcomes(outcomes);
|
|
22479
|
+
if (options.jsonOutput) {
|
|
22480
|
+
process.stdout.write(`${JSON.stringify(merged.json)}
|
|
22481
|
+
`);
|
|
22482
|
+
} else {
|
|
22483
|
+
printPlayCheckOutcomes(outcomes, options.target);
|
|
22484
|
+
}
|
|
22485
|
+
return merged.valid ? 0 : 1;
|
|
22486
|
+
}
|
|
22487
|
+
function resolvePlayCheckExportNames(sourceCode) {
|
|
22488
|
+
const exports = listPlayFileExports(sourceCode);
|
|
22489
|
+
if (!exports || exports.length === 0) return [PLAY_DEFAULT_EXPORT];
|
|
22490
|
+
return exports.map((entry) => entry.name);
|
|
22491
|
+
}
|
|
22492
|
+
async function checkOneExportedPlay(input2) {
|
|
22493
|
+
const { absolutePlayPath, sourceCode, exportName } = input2;
|
|
22494
|
+
const fallbackName = extractPlayName(sourceCode, absolutePlayPath);
|
|
21876
22495
|
let graph;
|
|
21877
22496
|
try {
|
|
21878
|
-
graph = await collectBundledPlayGraph(absolutePlayPath);
|
|
22497
|
+
graph = await collectBundledPlayGraph(absolutePlayPath, null, exportName);
|
|
21879
22498
|
} catch (error) {
|
|
21880
|
-
|
|
21881
|
-
|
|
21882
|
-
|
|
21883
|
-
|
|
21884
|
-
|
|
21885
|
-
|
|
21886
|
-
|
|
21887
|
-
|
|
21888
|
-
}
|
|
21889
|
-
return 1;
|
|
22499
|
+
return {
|
|
22500
|
+
exportName,
|
|
22501
|
+
playName: fallbackName,
|
|
22502
|
+
stage: "bundle",
|
|
22503
|
+
result: {
|
|
22504
|
+
valid: false,
|
|
22505
|
+
errors: [error instanceof Error ? error.message : String(error)]
|
|
22506
|
+
}
|
|
22507
|
+
};
|
|
21890
22508
|
}
|
|
21891
|
-
const playName = graph.root.playName ??
|
|
22509
|
+
const playName = graph.root.playName ?? fallbackName;
|
|
21892
22510
|
const descriptionErrors = collectMissingPlayDescriptionErrors(graph);
|
|
21893
22511
|
if (descriptionErrors.length > 0) {
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
|
|
21897
|
-
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
errors: descriptionErrors
|
|
21901
|
-
})}
|
|
21902
|
-
`
|
|
21903
|
-
);
|
|
21904
|
-
} else {
|
|
21905
|
-
console.error(`\u2717 ${playName} failed local play check`);
|
|
21906
|
-
for (const error of descriptionErrors) {
|
|
21907
|
-
console.error(` ${error}`);
|
|
21908
|
-
}
|
|
21909
|
-
}
|
|
21910
|
-
return 1;
|
|
22512
|
+
return {
|
|
22513
|
+
exportName,
|
|
22514
|
+
playName,
|
|
22515
|
+
stage: "authoring",
|
|
22516
|
+
result: { valid: false, errors: descriptionErrors }
|
|
22517
|
+
};
|
|
21911
22518
|
}
|
|
21912
22519
|
const client2 = new DeeplineClient();
|
|
21913
22520
|
const integrationMode = resolveEvalIntegrationMode();
|
|
@@ -21922,64 +22529,136 @@ async function handlePlayCheck(args) {
|
|
|
21922
22529
|
sourceFiles: graph.root.sourceFiles,
|
|
21923
22530
|
description: graph.root.playDescription ?? void 0,
|
|
21924
22531
|
artifact: graph.root.artifact,
|
|
22532
|
+
...exportName === PLAY_DEFAULT_EXPORT ? {} : { exportName },
|
|
21925
22533
|
...importedPlays.length > 0 ? { importedPlays } : {},
|
|
21926
22534
|
...integrationMode ? { integrationMode } : {}
|
|
21927
22535
|
});
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
21932
|
-
|
|
21933
|
-
|
|
21934
|
-
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
`${JSON.stringify({ name: playName, ...enrichedResult })}
|
|
21939
|
-
`
|
|
21940
|
-
);
|
|
21941
|
-
} else if (enrichedResult.valid) {
|
|
21942
|
-
const summary = enrichedResult.summary?.trim();
|
|
21943
|
-
console.log(
|
|
21944
|
-
summary ? `\u2713 ${playName} valid \u2014 ${summary}` : `\u2713 ${playName} passed cloud play check`
|
|
21945
|
-
);
|
|
21946
|
-
if (enrichedResult.artifactHash) {
|
|
21947
|
-
console.log(` artifact: ${enrichedResult.artifactHash.slice(0, 12)}`);
|
|
22536
|
+
return {
|
|
22537
|
+
exportName,
|
|
22538
|
+
playName,
|
|
22539
|
+
result: {
|
|
22540
|
+
...result,
|
|
22541
|
+
errors: result.valid ? result.errors : addPlayCheckRepairHints({
|
|
22542
|
+
errors: result.errors,
|
|
22543
|
+
sourceCode: graph.root.sourceCode
|
|
22544
|
+
}),
|
|
22545
|
+
toolGetterHints: result.toolGetterHints ?? await buildToolGetterHints(client2, result.staticPipeline)
|
|
21948
22546
|
}
|
|
21949
|
-
|
|
21950
|
-
|
|
22547
|
+
};
|
|
22548
|
+
}
|
|
22549
|
+
function mergePlayCheckExportOutcomes(outcomes) {
|
|
22550
|
+
const primary = outcomes[0];
|
|
22551
|
+
const valid = outcomes.every((outcome) => outcome.result.valid);
|
|
22552
|
+
const base = {
|
|
22553
|
+
name: primary.playName,
|
|
22554
|
+
...primary.stage ? { stage: primary.stage } : {},
|
|
22555
|
+
...primary.result,
|
|
22556
|
+
valid
|
|
22557
|
+
};
|
|
22558
|
+
if (outcomes.length === 1) {
|
|
22559
|
+
return { valid, json: base };
|
|
22560
|
+
}
|
|
22561
|
+
const errors = [...primary.result.errors];
|
|
22562
|
+
const seenErrors = new Set(errors);
|
|
22563
|
+
const warnings = [...primary.result.warnings ?? []];
|
|
22564
|
+
const seenWarnings = new Set(warnings);
|
|
22565
|
+
const issues = [...primary.result.issues ?? []];
|
|
22566
|
+
const seenIssues = new Set(
|
|
22567
|
+
issues.map((issue) => `${issue.code} ${issue.path ?? ""} ${issue.message}`)
|
|
22568
|
+
);
|
|
22569
|
+
for (const outcome of outcomes.slice(1)) {
|
|
22570
|
+
for (const error of outcome.result.errors) {
|
|
22571
|
+
if (seenErrors.has(error)) continue;
|
|
22572
|
+
seenErrors.add(error);
|
|
22573
|
+
errors.push(`[export ${outcome.exportName}] ${error}`);
|
|
22574
|
+
}
|
|
22575
|
+
for (const warning of outcome.result.warnings ?? []) {
|
|
22576
|
+
if (seenWarnings.has(warning)) continue;
|
|
22577
|
+
seenWarnings.add(warning);
|
|
22578
|
+
warnings.push(`[export ${outcome.exportName}] ${warning}`);
|
|
22579
|
+
}
|
|
22580
|
+
for (const issue of outcome.result.issues ?? []) {
|
|
22581
|
+
const key = `${issue.code} ${issue.path ?? ""} ${issue.message}`;
|
|
22582
|
+
if (seenIssues.has(key)) continue;
|
|
22583
|
+
seenIssues.add(key);
|
|
22584
|
+
issues.push({ ...issue, exportName: outcome.exportName });
|
|
21951
22585
|
}
|
|
21952
|
-
|
|
21953
|
-
|
|
21954
|
-
|
|
21955
|
-
|
|
21956
|
-
|
|
22586
|
+
}
|
|
22587
|
+
return {
|
|
22588
|
+
valid,
|
|
22589
|
+
json: {
|
|
22590
|
+
...base,
|
|
22591
|
+
errors,
|
|
22592
|
+
...warnings.length > 0 || primary.result.warnings ? { warnings } : {},
|
|
22593
|
+
...issues.length > 0 || primary.result.issues ? { issues } : {},
|
|
22594
|
+
exports: outcomes.map((outcome) => ({
|
|
22595
|
+
...outcome.result,
|
|
22596
|
+
exportName: outcome.exportName,
|
|
22597
|
+
name: outcome.playName,
|
|
22598
|
+
...outcome.stage ? { stage: outcome.stage } : {}
|
|
22599
|
+
}))
|
|
21957
22600
|
}
|
|
21958
|
-
|
|
21959
|
-
|
|
21960
|
-
|
|
21961
|
-
|
|
21962
|
-
|
|
21963
|
-
|
|
22601
|
+
};
|
|
22602
|
+
}
|
|
22603
|
+
function playCheckFailureStage(outcome) {
|
|
22604
|
+
if (outcome.stage === "bundle") return "to bundle";
|
|
22605
|
+
if (outcome.stage === "authoring") return "local play check";
|
|
22606
|
+
return outcome.result.limits ? "cloud play check" : "local play check";
|
|
22607
|
+
}
|
|
22608
|
+
function printPlayCheckOutcome(outcome, target, prefix) {
|
|
22609
|
+
const { result, playName } = outcome;
|
|
22610
|
+
if (!result.valid) {
|
|
22611
|
+
console.error(
|
|
22612
|
+
`\u2717 ${prefix}${playName} failed ${playCheckFailureStage(outcome)}`
|
|
21964
22613
|
);
|
|
21965
|
-
printToolGetterHints(enrichedResult.toolGetterHints);
|
|
21966
|
-
} else {
|
|
21967
|
-
console.error(`\u2717 ${playName} failed cloud play check`);
|
|
21968
22614
|
const { unstructuredErrors } = partitionMirroredErrors(
|
|
21969
|
-
|
|
21970
|
-
|
|
22615
|
+
result.errors,
|
|
22616
|
+
result.issues
|
|
21971
22617
|
);
|
|
21972
22618
|
for (const error of unstructuredErrors) {
|
|
21973
22619
|
console.error(` ${error}`);
|
|
21974
22620
|
}
|
|
21975
22621
|
printPlayCheckIssues(
|
|
21976
|
-
|
|
22622
|
+
result.issues,
|
|
21977
22623
|
(line) => console.error(line),
|
|
21978
|
-
|
|
22624
|
+
result.warnings
|
|
21979
22625
|
);
|
|
21980
|
-
printToolGetterHints(
|
|
22626
|
+
printToolGetterHints(result.toolGetterHints);
|
|
22627
|
+
return;
|
|
22628
|
+
}
|
|
22629
|
+
const summary = result.summary?.trim();
|
|
22630
|
+
console.log(
|
|
22631
|
+
summary ? `\u2713 ${prefix}${playName} valid \u2014 ${summary}` : `\u2713 ${prefix}${playName} passed ${result.limits ? "cloud" : "local"} play check`
|
|
22632
|
+
);
|
|
22633
|
+
if (result.artifactHash) {
|
|
22634
|
+
console.log(` artifact: ${result.artifactHash.slice(0, 12)}`);
|
|
22635
|
+
}
|
|
22636
|
+
if (result.sourceHash) {
|
|
22637
|
+
console.log(` source: ${result.sourceHash.slice(0, 12)}`);
|
|
22638
|
+
}
|
|
22639
|
+
printPlayCheckLimits(result.limits);
|
|
22640
|
+
if (result.artifactHash && outcome.exportName === PLAY_DEFAULT_EXPORT) {
|
|
22641
|
+
console.log(
|
|
22642
|
+
` publish: deepline plays publish ${shellQuote2(target)} --expected-artifact ${result.artifactHash}`
|
|
22643
|
+
);
|
|
22644
|
+
}
|
|
22645
|
+
printPlayTriggers(result.triggers);
|
|
22646
|
+
printRecognizedSummary(result.recognized);
|
|
22647
|
+
printPlayCheckIssues(
|
|
22648
|
+
result.issues,
|
|
22649
|
+
(line) => console.log(line),
|
|
22650
|
+
result.warnings
|
|
22651
|
+
);
|
|
22652
|
+
printToolGetterHints(result.toolGetterHints);
|
|
22653
|
+
}
|
|
22654
|
+
function printPlayCheckOutcomes(outcomes, target) {
|
|
22655
|
+
if (outcomes.length === 1) {
|
|
22656
|
+
printPlayCheckOutcome(outcomes[0], target, "");
|
|
22657
|
+
return;
|
|
22658
|
+
}
|
|
22659
|
+
for (const outcome of outcomes) {
|
|
22660
|
+
printPlayCheckOutcome(outcome, target, `[${outcome.exportName}] `);
|
|
21981
22661
|
}
|
|
21982
|
-
return enrichedResult.valid ? 0 : 1;
|
|
21983
22662
|
}
|
|
21984
22663
|
async function handleFileBackedRun(options, hooks) {
|
|
21985
22664
|
if (options.target.kind !== "file") {
|
|
@@ -22113,6 +22792,7 @@ async function handleFileBackedRun(options, hooks) {
|
|
|
22113
22792
|
playName,
|
|
22114
22793
|
jsonOutput: options.jsonOutput,
|
|
22115
22794
|
emitLogs: options.emitLogs,
|
|
22795
|
+
verboseLogs: options.verboseLogs,
|
|
22116
22796
|
waitTimeoutMs: options.waitTimeoutMs,
|
|
22117
22797
|
open: options.open,
|
|
22118
22798
|
progress,
|
|
@@ -22292,6 +22972,7 @@ async function handleNamedRun(options, hooks) {
|
|
|
22292
22972
|
playName,
|
|
22293
22973
|
jsonOutput: options.jsonOutput,
|
|
22294
22974
|
emitLogs: options.emitLogs,
|
|
22975
|
+
verboseLogs: options.verboseLogs,
|
|
22295
22976
|
waitTimeoutMs: options.waitTimeoutMs,
|
|
22296
22977
|
open: options.open,
|
|
22297
22978
|
progress,
|
|
@@ -26056,7 +26737,7 @@ function isMarkedTestAiInferenceCommand(command) {
|
|
|
26056
26737
|
if (normalizeEnrichPlayRef(command.tool) !== "run_javascript") {
|
|
26057
26738
|
return false;
|
|
26058
26739
|
}
|
|
26059
|
-
return
|
|
26740
|
+
return isRecord11(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
|
|
26060
26741
|
}
|
|
26061
26742
|
function enrichDebugEnabled(env = process.env) {
|
|
26062
26743
|
const raw = String(env.DEEPLINE_DEBUG_ENRICH ?? "").trim().toLowerCase();
|
|
@@ -26320,7 +27001,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
|
|
|
26320
27001
|
if (Array.isArray(value)) {
|
|
26321
27002
|
return value.map(rewrite);
|
|
26322
27003
|
}
|
|
26323
|
-
if (!
|
|
27004
|
+
if (!isRecord11(value)) {
|
|
26324
27005
|
return value;
|
|
26325
27006
|
}
|
|
26326
27007
|
const next = Object.fromEntries(
|
|
@@ -26329,7 +27010,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
|
|
|
26329
27010
|
key === "rerunCommand" && typeof entry === "string" ? enrichCommand : rewrite(entry)
|
|
26330
27011
|
])
|
|
26331
27012
|
);
|
|
26332
|
-
if (
|
|
27013
|
+
if (isRecord11(next.next) && typeof next.next.run === "string") {
|
|
26333
27014
|
next.next = { ...next.next, run: enrichCommand };
|
|
26334
27015
|
}
|
|
26335
27016
|
return next;
|
|
@@ -26811,7 +27492,7 @@ async function resolveWatchedGeneratedPlayStatus(input2) {
|
|
|
26811
27492
|
}
|
|
26812
27493
|
return input2.client.runs.get(runId, { full: true });
|
|
26813
27494
|
}
|
|
26814
|
-
function
|
|
27495
|
+
function isRecord11(value) {
|
|
26815
27496
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
26816
27497
|
}
|
|
26817
27498
|
async function captureStdout(run, options = {}) {
|
|
@@ -27063,15 +27744,15 @@ function readFirstEnrichDatasetActions(value) {
|
|
|
27063
27744
|
return null;
|
|
27064
27745
|
}
|
|
27065
27746
|
const record = candidate;
|
|
27066
|
-
const actions =
|
|
27067
|
-
const currentQuery =
|
|
27068
|
-
const legacyQuery =
|
|
27747
|
+
const actions = isRecord11(record.actions) ? record.actions : null;
|
|
27748
|
+
const currentQuery = isRecord11(actions?.queryCurrentTable) ? actions.queryCurrentTable : null;
|
|
27749
|
+
const legacyQuery = isRecord11(actions?.query) ? actions.query : null;
|
|
27069
27750
|
const query = currentQuery?.kind === "deepline_db_query" ? currentQuery : legacyQuery?.kind === "deepline_db_query" ? legacyQuery : null;
|
|
27070
27751
|
if (query?.kind === "deepline_db_query") {
|
|
27071
27752
|
return {
|
|
27072
27753
|
dataset: record,
|
|
27073
27754
|
query,
|
|
27074
|
-
...
|
|
27755
|
+
...isRecord11(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
|
|
27075
27756
|
};
|
|
27076
27757
|
}
|
|
27077
27758
|
if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
|
|
@@ -27124,7 +27805,7 @@ function enrichCustomerDbJson(input2) {
|
|
|
27124
27805
|
const dataset = actions.dataset;
|
|
27125
27806
|
const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
|
|
27126
27807
|
const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
|
|
27127
|
-
const api =
|
|
27808
|
+
const api = isRecord11(query.api) ? query.api : null;
|
|
27128
27809
|
const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
|
|
27129
27810
|
const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
|
|
27130
27811
|
if (!datasetPath) {
|
|
@@ -27193,11 +27874,11 @@ function sqlStringLiteral(value) {
|
|
|
27193
27874
|
return `'${value.replace(/'/g, "''")}'`;
|
|
27194
27875
|
}
|
|
27195
27876
|
function failureAliasFromCellMeta(cellMeta) {
|
|
27196
|
-
if (!
|
|
27877
|
+
if (!isRecord11(cellMeta)) {
|
|
27197
27878
|
return null;
|
|
27198
27879
|
}
|
|
27199
27880
|
for (const [alias, meta] of Object.entries(cellMeta)) {
|
|
27200
|
-
if (!
|
|
27881
|
+
if (!isRecord11(meta)) {
|
|
27201
27882
|
continue;
|
|
27202
27883
|
}
|
|
27203
27884
|
const failure = failureCellFromMeta(meta, {});
|
|
@@ -27691,7 +28372,7 @@ function exportableSheetRow2(row, sourceRowStart = 0) {
|
|
|
27691
28372
|
return fallback;
|
|
27692
28373
|
}
|
|
27693
28374
|
function failureCellFromMeta(meta, fallback) {
|
|
27694
|
-
if (!
|
|
28375
|
+
if (!isRecord11(meta)) {
|
|
27695
28376
|
return null;
|
|
27696
28377
|
}
|
|
27697
28378
|
const status = typeof meta.status === "string" ? meta.status.trim().toLowerCase() : "";
|
|
@@ -27711,7 +28392,7 @@ function failureCellFromMeta(meta, fallback) {
|
|
|
27711
28392
|
};
|
|
27712
28393
|
}
|
|
27713
28394
|
function applyFailureCellMeta(row, cellMeta, fallback) {
|
|
27714
|
-
if (!
|
|
28395
|
+
if (!isRecord11(cellMeta)) {
|
|
27715
28396
|
return;
|
|
27716
28397
|
}
|
|
27717
28398
|
for (const [field, meta] of Object.entries(cellMeta)) {
|
|
@@ -27939,7 +28620,7 @@ function stableRowSnapshot(value) {
|
|
|
27939
28620
|
}
|
|
27940
28621
|
function cellFailureError(value) {
|
|
27941
28622
|
const parsed = parseMaybeJsonObject(value);
|
|
27942
|
-
if (!
|
|
28623
|
+
if (!isRecord11(parsed)) {
|
|
27943
28624
|
const text = typeof parsed === "string" ? parsed.trim() : "";
|
|
27944
28625
|
if (/^(?:[A-Za-z0-9_:-]+:\s*)?(?:Error|TypeError|ReferenceError|SyntaxError|RangeError):\s+/.test(
|
|
27945
28626
|
text
|
|
@@ -27947,12 +28628,12 @@ function cellFailureError(value) {
|
|
|
27947
28628
|
return { message: text };
|
|
27948
28629
|
}
|
|
27949
28630
|
}
|
|
27950
|
-
if (!
|
|
28631
|
+
if (!isRecord11(parsed)) {
|
|
27951
28632
|
return null;
|
|
27952
28633
|
}
|
|
27953
28634
|
const status = typeof parsed.status === "string" ? parsed.status.trim().toLowerCase() : "";
|
|
27954
28635
|
const directError = typeof parsed.error === "string" ? parsed.error.trim() : typeof parsed.last_error === "string" ? parsed.last_error.trim() : "";
|
|
27955
|
-
const result =
|
|
28636
|
+
const result = isRecord11(parsed.result) ? parsed.result : null;
|
|
27956
28637
|
const resultError = typeof result?.error === "string" ? result.error.trim() : typeof result?.message === "string" ? result.message.trim() : "";
|
|
27957
28638
|
if (!directError && !resultError && status !== "error" && status !== "failed") {
|
|
27958
28639
|
return null;
|
|
@@ -28022,7 +28703,7 @@ function assignFlattenedFailurePath(target, field, value) {
|
|
|
28022
28703
|
let cursor = target;
|
|
28023
28704
|
for (const part of normalized.slice(0, -1)) {
|
|
28024
28705
|
const existing = cursor[part];
|
|
28025
|
-
if (!
|
|
28706
|
+
if (!isRecord11(existing)) {
|
|
28026
28707
|
const next = {};
|
|
28027
28708
|
cursor[part] = next;
|
|
28028
28709
|
cursor = next;
|
|
@@ -28186,10 +28867,10 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
28186
28867
|
let everyChildStatOnlyConditionSkipped = true;
|
|
28187
28868
|
const childAliasesWithStats = /* @__PURE__ */ new Set();
|
|
28188
28869
|
for (const childAlias of childAliases) {
|
|
28189
|
-
for (const stat4 of summaries.map((summary) => summary[childAlias]).filter(
|
|
28870
|
+
for (const stat4 of summaries.map((summary) => summary[childAlias]).filter(isRecord11)) {
|
|
28190
28871
|
sawChildStats = true;
|
|
28191
28872
|
childAliasesWithStats.add(childAlias);
|
|
28192
|
-
const execution =
|
|
28873
|
+
const execution = isRecord11(stat4.execution) ? stat4.execution : null;
|
|
28193
28874
|
const executedSummary = parseExecutionSummary(
|
|
28194
28875
|
execution?.["completed:executed"]
|
|
28195
28876
|
);
|
|
@@ -28219,7 +28900,7 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
28219
28900
|
}
|
|
28220
28901
|
function emptyWaterfallStatsEvidence(status, spec) {
|
|
28221
28902
|
const summaries = collectColumnStats(status);
|
|
28222
|
-
const parentStats = summaries.map((summary) => summary[spec.alias]).filter(
|
|
28903
|
+
const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord11);
|
|
28223
28904
|
for (const stat4 of parentStats) {
|
|
28224
28905
|
const nonEmpty = parseExecutionSummary(stat4.non_empty);
|
|
28225
28906
|
if (nonEmpty?.total && nonEmpty.count === 0) {
|
|
@@ -28233,7 +28914,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
|
|
|
28233
28914
|
let selectedRows = 0;
|
|
28234
28915
|
let sawStatsForEveryChild = true;
|
|
28235
28916
|
for (const childAlias of childAliases) {
|
|
28236
|
-
const stat4 = summaries.map((summary) => summary[childAlias]).find(
|
|
28917
|
+
const stat4 = summaries.map((summary) => summary[childAlias]).find(isRecord11);
|
|
28237
28918
|
if (!stat4) {
|
|
28238
28919
|
sawStatsForEveryChild = false;
|
|
28239
28920
|
break;
|
|
@@ -28242,7 +28923,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
|
|
|
28242
28923
|
if ((nonEmpty?.count ?? 0) > 0) {
|
|
28243
28924
|
return null;
|
|
28244
28925
|
}
|
|
28245
|
-
const execution =
|
|
28926
|
+
const execution = isRecord11(stat4.execution) ? stat4.execution : null;
|
|
28246
28927
|
const executed = parseExecutionSummary(execution?.["completed:executed"]);
|
|
28247
28928
|
const reused = parseExecutionSummary(execution?.["completed:reused"]);
|
|
28248
28929
|
const skipped = parseExecutionSummary(execution?.["skipped:condition"]);
|
|
@@ -28284,11 +28965,11 @@ function collectStatusFailureJobs(input2) {
|
|
|
28284
28965
|
const jobs = [];
|
|
28285
28966
|
aliases.forEach((spec, aliasIndex) => {
|
|
28286
28967
|
const { alias } = spec;
|
|
28287
|
-
const stat4 = summaries.map((summary) => summary[alias]).find(
|
|
28968
|
+
const stat4 = summaries.map((summary) => summary[alias]).find(isRecord11);
|
|
28288
28969
|
if (!stat4) {
|
|
28289
28970
|
return;
|
|
28290
28971
|
}
|
|
28291
|
-
const execution =
|
|
28972
|
+
const execution = isRecord11(stat4.execution) ? stat4.execution : null;
|
|
28292
28973
|
const failedCount = Math.min(
|
|
28293
28974
|
selectedRows,
|
|
28294
28975
|
Math.max(
|
|
@@ -28395,10 +29076,10 @@ function collectColumnStats(status) {
|
|
|
28395
29076
|
value.forEach(visit);
|
|
28396
29077
|
return;
|
|
28397
29078
|
}
|
|
28398
|
-
if (!
|
|
29079
|
+
if (!isRecord11(value)) {
|
|
28399
29080
|
return;
|
|
28400
29081
|
}
|
|
28401
|
-
if (
|
|
29082
|
+
if (isRecord11(value.columnStats)) {
|
|
28402
29083
|
summaries.push(value.columnStats);
|
|
28403
29084
|
}
|
|
28404
29085
|
Object.values(value).forEach(visit);
|
|
@@ -28410,12 +29091,12 @@ function firstAliasExecutionCounts(input2) {
|
|
|
28410
29091
|
const aliases = collectConfigScalarAliasOrder(input2.config);
|
|
28411
29092
|
const summaries = collectColumnStats(input2.status);
|
|
28412
29093
|
for (const alias of aliases) {
|
|
28413
|
-
const stat4 = summaries.map((summary) => summary[alias]).find(
|
|
29094
|
+
const stat4 = summaries.map((summary) => summary[alias]).find(isRecord11);
|
|
28414
29095
|
if (!stat4) continue;
|
|
28415
29096
|
if (input2.forceAliases.has(normalizeAlias2(alias))) {
|
|
28416
29097
|
return { executed: input2.selectedRows, reused: 0 };
|
|
28417
29098
|
}
|
|
28418
|
-
const execution =
|
|
29099
|
+
const execution = isRecord11(stat4.execution) ? stat4.execution : null;
|
|
28419
29100
|
if (!execution) continue;
|
|
28420
29101
|
return {
|
|
28421
29102
|
executed: parseExecutionCount(execution["completed:executed"]),
|
|
@@ -28442,14 +29123,14 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
28442
29123
|
if (Array.isArray(value)) {
|
|
28443
29124
|
return value.map(rewrite);
|
|
28444
29125
|
}
|
|
28445
|
-
if (!
|
|
29126
|
+
if (!isRecord11(value)) {
|
|
28446
29127
|
return value;
|
|
28447
29128
|
}
|
|
28448
29129
|
const next = {};
|
|
28449
29130
|
for (const [key, entry] of Object.entries(value)) {
|
|
28450
29131
|
next[key] = rewrite(entry);
|
|
28451
29132
|
}
|
|
28452
|
-
if (
|
|
29133
|
+
if (isRecord11(next.progress)) {
|
|
28453
29134
|
next.progress = {
|
|
28454
29135
|
...next.progress,
|
|
28455
29136
|
...selectedRows > 0 ? { total: selectedRows } : {},
|
|
@@ -28458,8 +29139,8 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
28458
29139
|
...failedRows > 0 ? { failed: failedRows, pending: 0 } : {}
|
|
28459
29140
|
};
|
|
28460
29141
|
}
|
|
28461
|
-
if (
|
|
28462
|
-
const rowCounts =
|
|
29142
|
+
if (isRecord11(next.summary)) {
|
|
29143
|
+
const rowCounts = isRecord11(next.summary.rowCounts) ? next.summary.rowCounts : null;
|
|
28463
29144
|
if (failedRows > 0) {
|
|
28464
29145
|
next.summary = {
|
|
28465
29146
|
...next.summary,
|
|
@@ -28472,11 +29153,11 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
28472
29153
|
};
|
|
28473
29154
|
}
|
|
28474
29155
|
}
|
|
28475
|
-
if (
|
|
29156
|
+
if (isRecord11(next.columnStats) && selectedRows > 0) {
|
|
28476
29157
|
const columnStats = { ...next.columnStats };
|
|
28477
29158
|
for (const alias of forcedAliases) {
|
|
28478
|
-
const stat4 =
|
|
28479
|
-
const execution =
|
|
29159
|
+
const stat4 = isRecord11(columnStats[alias]) ? columnStats[alias] : null;
|
|
29160
|
+
const execution = isRecord11(stat4?.execution) ? stat4.execution : null;
|
|
28480
29161
|
if (!stat4 || !execution) continue;
|
|
28481
29162
|
columnStats[alias] = {
|
|
28482
29163
|
...stat4,
|
|
@@ -28495,14 +29176,14 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
28495
29176
|
return next;
|
|
28496
29177
|
};
|
|
28497
29178
|
const rewritten = rewrite(input2.status);
|
|
28498
|
-
if (failedRows === 0 || !
|
|
29179
|
+
if (failedRows === 0 || !isRecord11(rewritten)) {
|
|
28499
29180
|
return rewritten;
|
|
28500
29181
|
}
|
|
28501
29182
|
const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
|
|
28502
29183
|
return {
|
|
28503
29184
|
...rewritten,
|
|
28504
29185
|
...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
|
|
28505
|
-
...
|
|
29186
|
+
...isRecord11(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
|
|
28506
29187
|
};
|
|
28507
29188
|
}
|
|
28508
29189
|
function summarizeFailedJobError(value) {
|
|
@@ -29126,7 +29807,7 @@ function materializeCsvCellValue(value) {
|
|
|
29126
29807
|
return value;
|
|
29127
29808
|
}
|
|
29128
29809
|
function compactArrayEnvelopeCompleteValue(value) {
|
|
29129
|
-
if (!
|
|
29810
|
+
if (!isRecord11(value) || value.kind !== "array") {
|
|
29130
29811
|
return null;
|
|
29131
29812
|
}
|
|
29132
29813
|
if (!Array.isArray(value.preview)) {
|
|
@@ -29140,7 +29821,7 @@ function compactArrayEnvelopeCompleteValue(value) {
|
|
|
29140
29821
|
}
|
|
29141
29822
|
function disambiguateCompactAiInferencePayload(value) {
|
|
29142
29823
|
const parsed = parseMaybeJsonObject(value);
|
|
29143
|
-
if (!
|
|
29824
|
+
if (!isRecord11(parsed) || !cellFailureError(parsed)) {
|
|
29144
29825
|
return value;
|
|
29145
29826
|
}
|
|
29146
29827
|
return {
|
|
@@ -29149,14 +29830,14 @@ function disambiguateCompactAiInferencePayload(value) {
|
|
|
29149
29830
|
};
|
|
29150
29831
|
}
|
|
29151
29832
|
function compactAiInferenceCellForCsv(value) {
|
|
29152
|
-
if (!
|
|
29833
|
+
if (!isRecord11(value)) {
|
|
29153
29834
|
return value;
|
|
29154
29835
|
}
|
|
29155
29836
|
const extractedJson = value.extracted_json;
|
|
29156
29837
|
if (extractedJson !== null && extractedJson !== void 0) {
|
|
29157
29838
|
return disambiguateCompactAiInferencePayload(extractedJson);
|
|
29158
29839
|
}
|
|
29159
|
-
const result =
|
|
29840
|
+
const result = isRecord11(value.result) ? value.result : null;
|
|
29160
29841
|
const object = result?.object;
|
|
29161
29842
|
if (object !== null && object !== void 0) {
|
|
29162
29843
|
return disambiguateCompactAiInferencePayload(object);
|
|
@@ -29173,12 +29854,12 @@ function compactAiInferenceCellForCsv(value) {
|
|
|
29173
29854
|
}
|
|
29174
29855
|
function materializeEnrichAliasCellForCsv(row, alias, options) {
|
|
29175
29856
|
const direct = row[alias];
|
|
29176
|
-
if (
|
|
29857
|
+
if (isRecord11(direct)) {
|
|
29177
29858
|
const completeArray = compactArrayEnvelopeCompleteValue(direct);
|
|
29178
29859
|
if (completeArray) {
|
|
29179
29860
|
return materializeCsvCellValue(completeArray);
|
|
29180
29861
|
}
|
|
29181
|
-
if (options?.compactAiCell && direct.status === "completed" && (
|
|
29862
|
+
if (options?.compactAiCell && direct.status === "completed" && (isRecord11(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
|
|
29182
29863
|
return materializeCsvCellValue(compactAiInferenceCellForCsv(direct));
|
|
29183
29864
|
}
|
|
29184
29865
|
if (Object.prototype.hasOwnProperty.call(direct, "matched_result") || Object.prototype.hasOwnProperty.call(direct, "matchedResult") || Object.prototype.hasOwnProperty.call(direct, "result")) {
|
|
@@ -29319,11 +30000,11 @@ function normalizeEnrichRowsForCsvExport(rows, config, options) {
|
|
|
29319
30000
|
}
|
|
29320
30001
|
function legacyMetadataFromRow(row) {
|
|
29321
30002
|
const direct = parseLegacyMetadataCell(row._metadata);
|
|
29322
|
-
if (direct &&
|
|
30003
|
+
if (direct && isRecord11(direct.columns)) {
|
|
29323
30004
|
return direct;
|
|
29324
30005
|
}
|
|
29325
30006
|
const relocated = parseLegacyMetadataCell(row.metadata);
|
|
29326
|
-
if (relocated &&
|
|
30007
|
+
if (relocated && isRecord11(relocated.columns)) {
|
|
29327
30008
|
return relocated;
|
|
29328
30009
|
}
|
|
29329
30010
|
const flattenedColumns = parseLegacyMetadataCell(row["metadata.columns"]);
|
|
@@ -29340,7 +30021,7 @@ function legacyMetadataFromRow(row) {
|
|
|
29340
30021
|
}
|
|
29341
30022
|
function parseLegacyMetadataCell(value) {
|
|
29342
30023
|
const parsed = parseMaybeJsonObject(value);
|
|
29343
|
-
if (
|
|
30024
|
+
if (isRecord11(parsed)) {
|
|
29344
30025
|
return parsed;
|
|
29345
30026
|
}
|
|
29346
30027
|
if (typeof value !== "string") {
|
|
@@ -29357,12 +30038,12 @@ function parseLegacyMetadataCell(value) {
|
|
|
29357
30038
|
for (const candidate of candidates) {
|
|
29358
30039
|
try {
|
|
29359
30040
|
const decoded = JSON.parse(candidate);
|
|
29360
|
-
if (
|
|
30041
|
+
if (isRecord11(decoded)) {
|
|
29361
30042
|
return decoded;
|
|
29362
30043
|
}
|
|
29363
30044
|
if (typeof decoded === "string") {
|
|
29364
30045
|
const nested = JSON.parse(decoded);
|
|
29365
|
-
if (
|
|
30046
|
+
if (isRecord11(nested)) {
|
|
29366
30047
|
return nested;
|
|
29367
30048
|
}
|
|
29368
30049
|
}
|
|
@@ -29372,8 +30053,8 @@ function parseLegacyMetadataCell(value) {
|
|
|
29372
30053
|
return null;
|
|
29373
30054
|
}
|
|
29374
30055
|
function mergeLegacyMetadataRecords(base, enriched) {
|
|
29375
|
-
const baseColumns =
|
|
29376
|
-
const enrichedColumns =
|
|
30056
|
+
const baseColumns = isRecord11(base.columns) ? base.columns : null;
|
|
30057
|
+
const enrichedColumns = isRecord11(enriched.columns) ? enriched.columns : null;
|
|
29377
30058
|
const merged = {
|
|
29378
30059
|
...base,
|
|
29379
30060
|
...enriched
|
|
@@ -34193,7 +34874,7 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
34193
34874
|
}
|
|
34194
34875
|
function extractionContractEntries(entries) {
|
|
34195
34876
|
return entries.flatMap((entry) => {
|
|
34196
|
-
if (!
|
|
34877
|
+
if (!isRecord12(entry)) return [];
|
|
34197
34878
|
const name = stringField2(entry, "name");
|
|
34198
34879
|
const expression = stringField2(entry, "expression");
|
|
34199
34880
|
return name && expression ? [{ name, expression }] : [];
|
|
@@ -34214,7 +34895,7 @@ function printMonitorTypeFilters(tool) {
|
|
|
34214
34895
|
}
|
|
34215
34896
|
console.log("Deploy filters (set in the monitor payload):");
|
|
34216
34897
|
for (const name of names) {
|
|
34217
|
-
const field =
|
|
34898
|
+
const field = isRecord12(properties[name]) ? properties[name] : {};
|
|
34218
34899
|
const star = required.has(name) ? "*" : "";
|
|
34219
34900
|
const enumVals = arrayField2(field, "enum").filter(
|
|
34220
34901
|
(v) => typeof v === "string"
|
|
@@ -34226,14 +34907,14 @@ function printMonitorTypeFilters(tool) {
|
|
|
34226
34907
|
}
|
|
34227
34908
|
function printMonitorTypeStreams(tool) {
|
|
34228
34909
|
const streams = arrayField2(tool, "streams", "output_streams").filter(
|
|
34229
|
-
|
|
34910
|
+
isRecord12
|
|
34230
34911
|
);
|
|
34231
34912
|
if (!streams.length) return;
|
|
34232
34913
|
console.log("");
|
|
34233
34914
|
console.log("Filter columns (a play's sqlListeners.where, per stream):");
|
|
34234
34915
|
for (const stream of streams) {
|
|
34235
34916
|
const name = stringField2(stream, "stream");
|
|
34236
|
-
const cols = arrayField2(stream, "columns").filter(
|
|
34917
|
+
const cols = arrayField2(stream, "columns").filter(isRecord12).map((col) => stringField2(col, "name")).filter(Boolean);
|
|
34237
34918
|
console.log(`- ${name}: ${cols.join(", ")}`);
|
|
34238
34919
|
}
|
|
34239
34920
|
}
|
|
@@ -34251,7 +34932,7 @@ function printMonitorTypePricing(tool) {
|
|
|
34251
34932
|
}
|
|
34252
34933
|
console.log("Pricing (Deepline credits per accepted event):");
|
|
34253
34934
|
for (const key of keys) {
|
|
34254
|
-
const entry =
|
|
34935
|
+
const entry = isRecord12(byType[key]) ? byType[key] : {};
|
|
34255
34936
|
const credits = numberField2(entry, "deepline_credits", "deeplineCredits");
|
|
34256
34937
|
const display = stringField2(entry, "display");
|
|
34257
34938
|
const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "see --json");
|
|
@@ -34296,8 +34977,8 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
34296
34977
|
return;
|
|
34297
34978
|
}
|
|
34298
34979
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
34299
|
-
const cost =
|
|
34300
|
-
const getters =
|
|
34980
|
+
const cost = isRecord12(contract.cost) ? contract.cost : {};
|
|
34981
|
+
const getters = isRecord12(contract.getters) ? contract.getters : {};
|
|
34301
34982
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
34302
34983
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
34303
34984
|
const inputFields = recursiveToolInputFieldsForDisplay(
|
|
@@ -34312,7 +34993,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
34312
34993
|
console.log(`Tags: ${contract.categories.join(", ")}`);
|
|
34313
34994
|
}
|
|
34314
34995
|
if (contract.deprecated === true) {
|
|
34315
|
-
const deprecation =
|
|
34996
|
+
const deprecation = isRecord12(contract.deprecation) ? contract.deprecation : {};
|
|
34316
34997
|
const message = stringField2(deprecation, "message");
|
|
34317
34998
|
const replacementToolId = stringField2(
|
|
34318
34999
|
deprecation,
|
|
@@ -34339,7 +35020,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
34339
35020
|
console.log("");
|
|
34340
35021
|
console.log("Inputs:");
|
|
34341
35022
|
for (const field of inputFields) {
|
|
34342
|
-
if (!
|
|
35023
|
+
if (!isRecord12(field)) continue;
|
|
34343
35024
|
const name = stringField2(field, "name");
|
|
34344
35025
|
if (!name) continue;
|
|
34345
35026
|
const required = field.required ? "*" : "";
|
|
@@ -34358,7 +35039,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
34358
35039
|
}
|
|
34359
35040
|
console.log("");
|
|
34360
35041
|
printToolExamplesOnly(tool, requestedToolId, { includeSamples: false });
|
|
34361
|
-
const starterScript =
|
|
35042
|
+
const starterScript = isRecord12(contract.starterScript) ? contract.starterScript : {};
|
|
34362
35043
|
const starterPath = stringField2(starterScript, "path");
|
|
34363
35044
|
if (starterPath) {
|
|
34364
35045
|
console.log("");
|
|
@@ -34372,14 +35053,14 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
34372
35053
|
console.log("Getters:");
|
|
34373
35054
|
if (listGetters.length) console.log("Lists:");
|
|
34374
35055
|
for (const entry of listGetters) {
|
|
34375
|
-
if (
|
|
35056
|
+
if (isRecord12(entry))
|
|
34376
35057
|
console.log(
|
|
34377
35058
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
34378
35059
|
);
|
|
34379
35060
|
}
|
|
34380
35061
|
if (valueGetters.length) console.log("Values:");
|
|
34381
35062
|
for (const entry of valueGetters) {
|
|
34382
|
-
if (
|
|
35063
|
+
if (isRecord12(entry))
|
|
34383
35064
|
console.log(
|
|
34384
35065
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
34385
35066
|
);
|
|
@@ -34396,7 +35077,7 @@ function printToolPricingOnly(tool, requestedToolId, options = {}) {
|
|
|
34396
35077
|
return;
|
|
34397
35078
|
}
|
|
34398
35079
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
34399
|
-
const cost =
|
|
35080
|
+
const cost = isRecord12(contract.cost) ? contract.cost : {};
|
|
34400
35081
|
const pricingModel = stringField2(cost, "pricingModel") || "unknown";
|
|
34401
35082
|
const billingMode = stringField2(cost, "billingMode") || "unknown";
|
|
34402
35083
|
const unit = pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit";
|
|
@@ -34468,10 +35149,10 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
34468
35149
|
` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
|
|
34469
35150
|
);
|
|
34470
35151
|
console.log("});");
|
|
34471
|
-
const getters =
|
|
35152
|
+
const getters = isRecord12(contract.getters) ? contract.getters : {};
|
|
34472
35153
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
34473
35154
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
34474
|
-
const firstGetter = [...valueGetters, ...listGetters].find(
|
|
35155
|
+
const firstGetter = [...valueGetters, ...listGetters].find(isRecord12);
|
|
34475
35156
|
if (firstGetter) {
|
|
34476
35157
|
const name = stringField2(firstGetter, "name") || "value";
|
|
34477
35158
|
const expression = stringField2(firstGetter, "expression");
|
|
@@ -34507,7 +35188,7 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
|
34507
35188
|
}
|
|
34508
35189
|
function printToolGettersOnly(tool, requestedToolId) {
|
|
34509
35190
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
34510
|
-
const getters =
|
|
35191
|
+
const getters = isRecord12(contract.getters) ? contract.getters : {};
|
|
34511
35192
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
34512
35193
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
34513
35194
|
console.log(`Getters: ${contract.toolId}`);
|
|
@@ -34520,7 +35201,7 @@ function printToolGettersOnly(tool, requestedToolId) {
|
|
|
34520
35201
|
if (listGetters.length) {
|
|
34521
35202
|
console.log("Lists:");
|
|
34522
35203
|
for (const entry of listGetters) {
|
|
34523
|
-
if (
|
|
35204
|
+
if (isRecord12(entry))
|
|
34524
35205
|
console.log(
|
|
34525
35206
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
34526
35207
|
);
|
|
@@ -34529,7 +35210,7 @@ function printToolGettersOnly(tool, requestedToolId) {
|
|
|
34529
35210
|
if (valueGetters.length) {
|
|
34530
35211
|
console.log("Values:");
|
|
34531
35212
|
for (const entry of valueGetters) {
|
|
34532
|
-
if (
|
|
35213
|
+
if (isRecord12(entry))
|
|
34533
35214
|
console.log(
|
|
34534
35215
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
34535
35216
|
);
|
|
@@ -34555,7 +35236,7 @@ function sampleValueForField(field) {
|
|
|
34555
35236
|
function samplePayloadForInputFields(fields) {
|
|
34556
35237
|
return Object.fromEntries(
|
|
34557
35238
|
fields.slice(0, 4).flatMap((field) => {
|
|
34558
|
-
if (!
|
|
35239
|
+
if (!isRecord12(field)) return [];
|
|
34559
35240
|
const name = stringField2(field, "name");
|
|
34560
35241
|
if (!name) return [];
|
|
34561
35242
|
return [[name, sampleValueForField(field)]];
|
|
@@ -34673,12 +35354,12 @@ function formatListedToolCost(tool) {
|
|
|
34673
35354
|
}
|
|
34674
35355
|
function toolInputFieldsForDisplay(inputSchema) {
|
|
34675
35356
|
if (Array.isArray(inputSchema.fields))
|
|
34676
|
-
return inputSchema.fields.filter(
|
|
34677
|
-
const jsonSchema =
|
|
34678
|
-
const properties =
|
|
35357
|
+
return inputSchema.fields.filter(isRecord12);
|
|
35358
|
+
const jsonSchema = isRecord12(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
35359
|
+
const properties = isRecord12(jsonSchema.properties) ? jsonSchema.properties : {};
|
|
34679
35360
|
const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
|
|
34680
35361
|
return Object.entries(properties).map(([name, value]) => {
|
|
34681
|
-
const property =
|
|
35362
|
+
const property = isRecord12(value) ? value : {};
|
|
34682
35363
|
return {
|
|
34683
35364
|
name,
|
|
34684
35365
|
type: typeof property.type === "string" ? property.type : "unknown",
|
|
@@ -34689,10 +35370,10 @@ function toolInputFieldsForDisplay(inputSchema) {
|
|
|
34689
35370
|
});
|
|
34690
35371
|
}
|
|
34691
35372
|
function canonicalToolJsonSchema(inputSchema) {
|
|
34692
|
-
return
|
|
35373
|
+
return isRecord12(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
34693
35374
|
}
|
|
34694
35375
|
function declaredToolJsonSchema(inputSchema) {
|
|
34695
|
-
if (
|
|
35376
|
+
if (isRecord12(inputSchema.jsonSchema)) {
|
|
34696
35377
|
return inputSchema.jsonSchema;
|
|
34697
35378
|
}
|
|
34698
35379
|
return Array.isArray(inputSchema.fields) ? null : inputSchema;
|
|
@@ -34717,7 +35398,7 @@ function publicToolInputSchemaForDescribe(inputSchema) {
|
|
|
34717
35398
|
};
|
|
34718
35399
|
const stripDescriptions = (value) => {
|
|
34719
35400
|
if (Array.isArray(value)) return value.map(stripDescriptions);
|
|
34720
|
-
if (!
|
|
35401
|
+
if (!isRecord12(value)) return value;
|
|
34721
35402
|
return Object.fromEntries(
|
|
34722
35403
|
Object.entries(value).flatMap(([key, nested]) => {
|
|
34723
35404
|
if (key === "description" && typeof nested === "string" && exposesProviderSpend(nested)) {
|
|
@@ -34738,7 +35419,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
34738
35419
|
for (const item of value) collectSchemaIds(item);
|
|
34739
35420
|
return;
|
|
34740
35421
|
}
|
|
34741
|
-
if (!
|
|
35422
|
+
if (!isRecord12(value)) return;
|
|
34742
35423
|
if (typeof value.$id === "string" && value.$id.trim()) {
|
|
34743
35424
|
schemasById.set(value.$id.trim(), value);
|
|
34744
35425
|
}
|
|
@@ -34751,10 +35432,10 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
34751
35432
|
let current = root;
|
|
34752
35433
|
for (const rawSegment of ref.slice(2).split("/")) {
|
|
34753
35434
|
const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
34754
|
-
if (!
|
|
35435
|
+
if (!isRecord12(current)) return schema;
|
|
34755
35436
|
current = current[segment];
|
|
34756
35437
|
}
|
|
34757
|
-
return
|
|
35438
|
+
return isRecord12(current) ? current : schema;
|
|
34758
35439
|
};
|
|
34759
35440
|
const addField = (field) => {
|
|
34760
35441
|
const name = typeof field.name === "string" ? field.name : "";
|
|
@@ -34769,7 +35450,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
34769
35450
|
if (ref && activeRefs.has(ref)) return;
|
|
34770
35451
|
const schema = resolveRef(unresolvedSchema);
|
|
34771
35452
|
const nextActiveRefs = ref ? /* @__PURE__ */ new Set([...activeRefs, ref]) : activeRefs;
|
|
34772
|
-
const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type :
|
|
35453
|
+
const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type : isRecord12(schema.properties) ? "object" : schema.items ? "array" : "unknown";
|
|
34773
35454
|
if (path) {
|
|
34774
35455
|
addField({
|
|
34775
35456
|
name: path,
|
|
@@ -34780,12 +35461,12 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
34780
35461
|
...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
|
|
34781
35462
|
});
|
|
34782
35463
|
}
|
|
34783
|
-
const properties =
|
|
35464
|
+
const properties = isRecord12(schema.properties) ? schema.properties : {};
|
|
34784
35465
|
const requiredNames = new Set(
|
|
34785
35466
|
Array.isArray(schema.required) ? schema.required.map(String) : []
|
|
34786
35467
|
);
|
|
34787
35468
|
for (const [name, value] of Object.entries(properties)) {
|
|
34788
|
-
if (!
|
|
35469
|
+
if (!isRecord12(value)) continue;
|
|
34789
35470
|
visit(
|
|
34790
35471
|
value,
|
|
34791
35472
|
path ? `${path}.${name}` : name,
|
|
@@ -34793,13 +35474,13 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
34793
35474
|
nextActiveRefs
|
|
34794
35475
|
);
|
|
34795
35476
|
}
|
|
34796
|
-
if (
|
|
35477
|
+
if (isRecord12(schema.items)) {
|
|
34797
35478
|
visit(schema.items, `${path}[]`, false, nextActiveRefs);
|
|
34798
35479
|
}
|
|
34799
35480
|
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
34800
35481
|
const branches = Array.isArray(schema[keyword]) ? schema[keyword] : [];
|
|
34801
35482
|
for (const branch of branches) {
|
|
34802
|
-
if (
|
|
35483
|
+
if (isRecord12(branch)) {
|
|
34803
35484
|
visit(branch, path, required, nextActiveRefs);
|
|
34804
35485
|
}
|
|
34805
35486
|
}
|
|
@@ -34827,14 +35508,14 @@ function printJsonPreview(label, payload) {
|
|
|
34827
35508
|
}
|
|
34828
35509
|
function samplePayload(samples, key) {
|
|
34829
35510
|
const entry = samples[key];
|
|
34830
|
-
if (!
|
|
35511
|
+
if (!isRecord12(entry)) return void 0;
|
|
34831
35512
|
return Object.prototype.hasOwnProperty.call(entry, "payload") ? entry.payload : entry;
|
|
34832
35513
|
}
|
|
34833
35514
|
function commandEnvelopeFromRawResponse(rawResponse) {
|
|
34834
|
-
return
|
|
35515
|
+
return isRecord12(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
|
|
34835
35516
|
}
|
|
34836
35517
|
function extractToolExecutionWarningMessages(rawResponse) {
|
|
34837
|
-
if (!
|
|
35518
|
+
if (!isRecord12(rawResponse)) return [];
|
|
34838
35519
|
const candidates = [
|
|
34839
35520
|
recordField2(recordField2(rawResponse, "toolResponse"), "meta"),
|
|
34840
35521
|
recordField2(
|
|
@@ -34851,7 +35532,7 @@ function extractToolExecutionWarningMessages(rawResponse) {
|
|
|
34851
35532
|
for (const warning of warnings) {
|
|
34852
35533
|
if (typeof warning === "string" && warning.trim()) {
|
|
34853
35534
|
messages.push(warning.trim());
|
|
34854
|
-
} else if (
|
|
35535
|
+
} else if (isRecord12(warning)) {
|
|
34855
35536
|
const message = stringField2(warning, "message");
|
|
34856
35537
|
if (message) messages.push(message);
|
|
34857
35538
|
}
|
|
@@ -34860,7 +35541,7 @@ function extractToolExecutionWarningMessages(rawResponse) {
|
|
|
34860
35541
|
return [...new Set(messages)];
|
|
34861
35542
|
}
|
|
34862
35543
|
function apifySyncRecoveryNext(rawResponse) {
|
|
34863
|
-
if (!
|
|
35544
|
+
if (!isRecord12(rawResponse) || rawResponse.status !== "running") return null;
|
|
34864
35545
|
const toolResponse = recordField2(rawResponse, "toolResponse");
|
|
34865
35546
|
const raw = recordField2(toolResponse, "raw");
|
|
34866
35547
|
if (raw.state !== "awaiting_apify") return null;
|
|
@@ -34883,7 +35564,7 @@ function apifySyncRecoveryNext(rawResponse) {
|
|
|
34883
35564
|
}
|
|
34884
35565
|
function listExtractorPathsFromUsageGuidance(tool) {
|
|
34885
35566
|
const toolExecutionResult = tool.usageGuidance?.toolExecutionResult;
|
|
34886
|
-
const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists :
|
|
35567
|
+
const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord12(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
|
|
34887
35568
|
return extractedLists.flatMap((entry) => {
|
|
34888
35569
|
const paths = entry.details?.candidatePaths ?? entry.details?.rawToolOutputPaths;
|
|
34889
35570
|
if (!Array.isArray(paths)) return [];
|
|
@@ -34899,7 +35580,7 @@ function formatDecimal(value) {
|
|
|
34899
35580
|
function formatUsd(value) {
|
|
34900
35581
|
return `$${formatDecimal(value)}`;
|
|
34901
35582
|
}
|
|
34902
|
-
function
|
|
35583
|
+
function isRecord12(value) {
|
|
34903
35584
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
34904
35585
|
}
|
|
34905
35586
|
function stringField2(source, ...keys) {
|
|
@@ -34926,7 +35607,7 @@ function arrayField2(source, ...keys) {
|
|
|
34926
35607
|
function recordField2(source, ...keys) {
|
|
34927
35608
|
for (const key of keys) {
|
|
34928
35609
|
const value = source[key];
|
|
34929
|
-
if (
|
|
35610
|
+
if (isRecord12(value)) return value;
|
|
34930
35611
|
}
|
|
34931
35612
|
return {};
|
|
34932
35613
|
}
|
|
@@ -34992,7 +35673,7 @@ function parseJsonObjectArgument(raw, flagName) {
|
|
|
34992
35673
|
}
|
|
34993
35674
|
throw invalidJsonError(flagName, message);
|
|
34994
35675
|
}
|
|
34995
|
-
if (!
|
|
35676
|
+
if (!isRecord12(parsed)) {
|
|
34996
35677
|
throw invalidJsonError(flagName, "expected an object.");
|
|
34997
35678
|
}
|
|
34998
35679
|
return parsed;
|
|
@@ -35142,7 +35823,7 @@ function buildToolExecuteBaseEnvelope(input2) {
|
|
|
35142
35823
|
kind: summaryEntries.length > 0 ? "object" : "raw",
|
|
35143
35824
|
summary: input2.summary
|
|
35144
35825
|
};
|
|
35145
|
-
const envelopeHasCanonicalOutput =
|
|
35826
|
+
const envelopeHasCanonicalOutput = isRecord12(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
|
|
35146
35827
|
const envelopeHasDeclaredOutput = Object.prototype.hasOwnProperty.call(
|
|
35147
35828
|
envelope,
|
|
35148
35829
|
"output"
|
|
@@ -35375,7 +36056,7 @@ async function executeTool(args) {
|
|
|
35375
36056
|
{
|
|
35376
36057
|
...baseEnvelope,
|
|
35377
36058
|
local: {
|
|
35378
|
-
...
|
|
36059
|
+
...isRecord12(baseEnvelope.local) ? baseEnvelope.local : {},
|
|
35379
36060
|
payload_file: jsonPath
|
|
35380
36061
|
}
|
|
35381
36062
|
},
|
|
@@ -36094,6 +36775,7 @@ var DEFAULT_V1_SKILL_NAMES = [
|
|
|
36094
36775
|
"build-tam",
|
|
36095
36776
|
"clay-to-deepline",
|
|
36096
36777
|
"deepline-analytics",
|
|
36778
|
+
"deepline-engine",
|
|
36097
36779
|
"deepline-feedback",
|
|
36098
36780
|
"deepline-gtm",
|
|
36099
36781
|
"deepline-plays",
|