deepline 0.1.301 → 0.1.303
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 +8 -0
- package/dist/bundling-sources/sdk/src/errors.ts +96 -36
- package/dist/bundling-sources/sdk/src/http.ts +82 -5
- package/dist/bundling-sources/sdk/src/index.ts +12 -0
- package/dist/bundling-sources/sdk/src/play.ts +29 -1
- package/dist/bundling-sources/sdk/src/release.ts +5 -3
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +120 -14
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +59 -11
- package/dist/bundling-sources/shared_libs/play-runtime/execution-ledger-store.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/execution-plan.ts +0 -15
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +136 -36
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +17 -12
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +210 -5
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-paths.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +33 -24
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +4 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-contract-version.ts +6 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +4 -0
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +159 -12
- package/dist/bundling-sources/shared_libs/plays/contracts.ts +69 -1
- package/dist/bundling-sources/shared_libs/tool-execution-error.ts +557 -0
- package/dist/cli/index.js +556 -183
- package/dist/cli/index.mjs +556 -183
- package/dist/index.d.mts +69 -40
- package/dist/index.d.ts +69 -40
- package/dist/index.js +480 -80
- package/dist/index.mjs +477 -80
- package/dist/plays/bundle-play-file.d.mts +4 -2
- package/dist/plays/bundle-play-file.d.ts +4 -2
- package/dist/plays/bundle-play-file.mjs +116 -19
- package/dist/tool-execution-error-YDz7UMl-.d.mts +440 -0
- package/dist/tool-execution-error-YDz7UMl-.d.ts +440 -0
- package/package.json +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/completed-receipt-cache.ts +0 -166
- package/dist/compiler-manifest-BjopNIqx.d.mts +0 -240
- package/dist/compiler-manifest-BjopNIqx.d.ts +0 -240
package/dist/cli/index.js
CHANGED
|
@@ -191,20 +191,291 @@ var import_node_fs = require("fs");
|
|
|
191
191
|
var import_node_os = require("os");
|
|
192
192
|
var import_node_path = require("path");
|
|
193
193
|
|
|
194
|
-
//
|
|
195
|
-
var
|
|
194
|
+
// ../shared_libs/tool-execution-error.ts
|
|
195
|
+
var DEEPLINE_ERROR_BRAND = /* @__PURE__ */ Symbol.for("deepline.error.v1");
|
|
196
|
+
var TOOL_EXECUTION_ERROR_BRAND = /* @__PURE__ */ Symbol.for(
|
|
197
|
+
"deepline.tool-execution-error.v1"
|
|
198
|
+
);
|
|
199
|
+
var PROVIDER_TRANSIENT_ERROR_BRAND = /* @__PURE__ */ Symbol.for(
|
|
200
|
+
"deepline.provider-transient-error.v1"
|
|
201
|
+
);
|
|
202
|
+
var LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION = 0;
|
|
203
|
+
var TOOL_EXECUTION_ERROR_SCHEMA_VERSION = 1;
|
|
204
|
+
var TOOL_EXECUTION_ERROR_SCHEMA_HEADER = "x-deepline-tool-error-schema";
|
|
205
|
+
var MAX_IDENTIFIER_LENGTH = 200;
|
|
206
|
+
var MAX_CODE_LENGTH = 160;
|
|
207
|
+
function nativeInstanceOf(constructor, value) {
|
|
208
|
+
return Reflect.apply(Function.prototype[Symbol.hasInstance], constructor, [
|
|
209
|
+
value
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
function hasBrand(value, brand) {
|
|
213
|
+
return typeof value === "object" && value !== null && value[brand] === true;
|
|
214
|
+
}
|
|
215
|
+
function applyBrand(value, brand) {
|
|
216
|
+
if (hasBrand(value, brand)) return;
|
|
217
|
+
Object.defineProperty(value, brand, {
|
|
218
|
+
configurable: false,
|
|
219
|
+
enumerable: false,
|
|
220
|
+
writable: false,
|
|
221
|
+
value: true
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
var DeeplineError = class _DeeplineError extends Error {
|
|
225
|
+
/** HTTP status when the failure crossed an HTTP boundary. */
|
|
226
|
+
statusCode;
|
|
227
|
+
/** Stable machine-readable error code when one exists. */
|
|
228
|
+
code;
|
|
229
|
+
/** Local diagnostic context; not a portable error contract. */
|
|
230
|
+
details;
|
|
231
|
+
/**
|
|
232
|
+
* Construct a Deepline error.
|
|
233
|
+
*
|
|
234
|
+
* SDK and runtime code construct these errors. Application and Play code
|
|
235
|
+
* normally catches the public subclasses instead.
|
|
236
|
+
*
|
|
237
|
+
* @param message Human-readable failure summary.
|
|
238
|
+
* @param statusCode HTTP status when one exists.
|
|
239
|
+
* @param code Stable machine-readable code when one exists.
|
|
240
|
+
* @param details Local diagnostic context; never a portable error contract.
|
|
241
|
+
*/
|
|
196
242
|
constructor(message, statusCode, code, details) {
|
|
197
243
|
super(message);
|
|
244
|
+
this.name = "DeeplineError";
|
|
198
245
|
this.statusCode = statusCode;
|
|
199
246
|
this.code = code;
|
|
200
247
|
this.details = details;
|
|
201
|
-
this
|
|
248
|
+
applyBrand(this, DEEPLINE_ERROR_BRAND);
|
|
249
|
+
}
|
|
250
|
+
static [Symbol.hasInstance](value) {
|
|
251
|
+
if (this !== _DeeplineError) return nativeInstanceOf(this, value);
|
|
252
|
+
return hasBrand(value, DEEPLINE_ERROR_BRAND);
|
|
202
253
|
}
|
|
203
|
-
statusCode;
|
|
204
|
-
code;
|
|
205
|
-
details;
|
|
206
254
|
};
|
|
255
|
+
var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
|
|
256
|
+
/** Public tool id passed to `tools.execute`. */
|
|
257
|
+
toolId;
|
|
258
|
+
/** Provider responsible for the operation, or `null` when unattributed. */
|
|
259
|
+
provider;
|
|
260
|
+
/** Provider operation name, or `null` when unavailable. */
|
|
261
|
+
operation;
|
|
262
|
+
/** Boundary responsible for the failure. */
|
|
263
|
+
origin;
|
|
264
|
+
/** Stable reason family for policy and diagnostics. */
|
|
265
|
+
category;
|
|
266
|
+
/**
|
|
267
|
+
* Whether repeating the same semantic call is delivery-safe.
|
|
268
|
+
*
|
|
269
|
+
* This does not mean the error may be ignored. Waterfall fallthrough is
|
|
270
|
+
* represented by `ProviderTransientError`.
|
|
271
|
+
*/
|
|
272
|
+
retryable;
|
|
273
|
+
/** Provider or Deepline request id, or `null` when unavailable. */
|
|
274
|
+
requestId;
|
|
275
|
+
/** Suggested same-call retry delay in milliseconds, or `null`. */
|
|
276
|
+
retryAfterMs;
|
|
277
|
+
/** Network failure kind, or `null` for non-network failures. */
|
|
278
|
+
networkKind;
|
|
279
|
+
/** Network boundary that failed, or `null` for non-network failures. */
|
|
280
|
+
networkScope;
|
|
281
|
+
/**
|
|
282
|
+
* Construct a structured tool error.
|
|
283
|
+
*
|
|
284
|
+
* Deepline constructs this from the versioned `tool_error` payload.
|
|
285
|
+
* Application and Play code should catch it rather than create it.
|
|
286
|
+
*/
|
|
287
|
+
constructor(message, options) {
|
|
288
|
+
super(
|
|
289
|
+
message,
|
|
290
|
+
options.statusCode ?? void 0,
|
|
291
|
+
options.code ?? void 0,
|
|
292
|
+
options.details
|
|
293
|
+
);
|
|
294
|
+
this.name = "ToolExecutionError";
|
|
295
|
+
this.toolId = options.toolId;
|
|
296
|
+
this.provider = options.provider;
|
|
297
|
+
this.operation = options.operation;
|
|
298
|
+
this.origin = options.origin;
|
|
299
|
+
this.category = options.category;
|
|
300
|
+
this.retryable = options.retryable;
|
|
301
|
+
this.requestId = options.requestId;
|
|
302
|
+
this.retryAfterMs = options.retryAfterMs;
|
|
303
|
+
this.networkKind = options.networkKind;
|
|
304
|
+
this.networkScope = options.networkScope;
|
|
305
|
+
applyBrand(this, TOOL_EXECUTION_ERROR_BRAND);
|
|
306
|
+
if (isProviderTransientFailure(options)) {
|
|
307
|
+
applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
static [Symbol.hasInstance](value) {
|
|
311
|
+
if (this !== _ToolExecutionError) return nativeInstanceOf(this, value);
|
|
312
|
+
return hasBrand(value, TOOL_EXECUTION_ERROR_BRAND);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
function brandAsToolExecutionError(value) {
|
|
316
|
+
applyBrand(value, TOOL_EXECUTION_ERROR_BRAND);
|
|
317
|
+
}
|
|
318
|
+
function isProviderTransientFailure(input2) {
|
|
319
|
+
return input2.origin === "provider" && (input2.category === "rate_limit" || input2.category === "network" || input2.category === "upstream");
|
|
320
|
+
}
|
|
321
|
+
var ProviderTransientError = class _ProviderTransientError extends ToolExecutionError {
|
|
322
|
+
/** Provider attribution is guaranteed for this subtype. */
|
|
323
|
+
origin = "provider";
|
|
324
|
+
/** Constructed by Deepline when a provider-owned transient failure arrives. */
|
|
325
|
+
constructor(message, options) {
|
|
326
|
+
super(message, {
|
|
327
|
+
...options,
|
|
328
|
+
origin: "provider",
|
|
329
|
+
category: options.category
|
|
330
|
+
});
|
|
331
|
+
this.name = "ProviderTransientError";
|
|
332
|
+
this.category = options.category;
|
|
333
|
+
applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
|
|
334
|
+
}
|
|
335
|
+
static [Symbol.hasInstance](value) {
|
|
336
|
+
if (this !== _ProviderTransientError) return nativeInstanceOf(this, value);
|
|
337
|
+
return hasBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
function brandAsProviderTransientError(value) {
|
|
341
|
+
applyBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
|
|
342
|
+
}
|
|
343
|
+
function boundedString(value, maxLength = MAX_IDENTIFIER_LENGTH) {
|
|
344
|
+
if (typeof value !== "string") return null;
|
|
345
|
+
const normalized = value.trim();
|
|
346
|
+
return normalized ? normalized.slice(0, maxLength) : null;
|
|
347
|
+
}
|
|
348
|
+
function finiteNonNegativeInteger(value) {
|
|
349
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && Number.isInteger(value) ? value : null;
|
|
350
|
+
}
|
|
351
|
+
function normalizeToolExecutionOrigin(value, input2) {
|
|
352
|
+
const normalized = boundedString(value)?.toLowerCase();
|
|
353
|
+
if (normalized === "caller") return "caller";
|
|
354
|
+
if (normalized === "provider" || normalized === "provider_network") {
|
|
355
|
+
return "provider";
|
|
356
|
+
}
|
|
357
|
+
if (normalized === "upstream" && boundedString(input2?.provider) && boundedString(input2?.operation)) {
|
|
358
|
+
return "provider";
|
|
359
|
+
}
|
|
360
|
+
if (normalized === "deepline" || normalized === "deepline_billing" || normalized === "deepline_rate_limit" || normalized === "internal" || normalized === "server") {
|
|
361
|
+
return "deepline";
|
|
362
|
+
}
|
|
363
|
+
if (normalized === "provider_account") return "provider";
|
|
364
|
+
return "unknown";
|
|
365
|
+
}
|
|
366
|
+
function normalizeToolExecutionCategory(value) {
|
|
367
|
+
switch (boundedString(value)?.toLowerCase()) {
|
|
368
|
+
case "validation":
|
|
369
|
+
case "authorization":
|
|
370
|
+
case "rate_limit":
|
|
371
|
+
case "network":
|
|
372
|
+
case "upstream":
|
|
373
|
+
case "billing":
|
|
374
|
+
case "conflict":
|
|
375
|
+
case "internal":
|
|
376
|
+
return boundedString(value).toLowerCase();
|
|
377
|
+
case "authentication":
|
|
378
|
+
case "provider_auth":
|
|
379
|
+
case "provider_account":
|
|
380
|
+
return "authentication";
|
|
381
|
+
case "execution":
|
|
382
|
+
case "parse":
|
|
383
|
+
case "stub":
|
|
384
|
+
case "internal_native_search_performance":
|
|
385
|
+
return "internal";
|
|
386
|
+
default:
|
|
387
|
+
return "unknown";
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function normalizeNetworkKind(value) {
|
|
391
|
+
switch (boundedString(value)?.toLowerCase()) {
|
|
392
|
+
case "timeout":
|
|
393
|
+
case "dns":
|
|
394
|
+
case "connect":
|
|
395
|
+
case "reset":
|
|
396
|
+
case "unavailable":
|
|
397
|
+
case "unknown":
|
|
398
|
+
return boundedString(value).toLowerCase();
|
|
399
|
+
default:
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function normalizeNetworkScope(value) {
|
|
404
|
+
switch (boundedString(value)?.toLowerCase()) {
|
|
405
|
+
case "client_to_deepline":
|
|
406
|
+
case "runtime_to_deepline":
|
|
407
|
+
case "deepline_to_provider":
|
|
408
|
+
return boundedString(value).toLowerCase();
|
|
409
|
+
default:
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function isRecord(value) {
|
|
414
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
415
|
+
}
|
|
416
|
+
function normalizeToolExecutionFailure(value) {
|
|
417
|
+
if (!isRecord(value) || value.schemaVersion !== TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
const toolId = boundedString(value.toolId);
|
|
421
|
+
if (!toolId) return null;
|
|
422
|
+
const provider = boundedString(value.provider);
|
|
423
|
+
const operation = boundedString(value.operation);
|
|
424
|
+
const origin = normalizeToolExecutionOrigin(value.origin, {
|
|
425
|
+
provider,
|
|
426
|
+
operation
|
|
427
|
+
});
|
|
428
|
+
const category = normalizeToolExecutionCategory(value.category);
|
|
429
|
+
const trustworthy = origin !== "unknown" && category !== "unknown" && typeof value.retryable === "boolean";
|
|
430
|
+
return {
|
|
431
|
+
schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
|
|
432
|
+
toolId,
|
|
433
|
+
provider,
|
|
434
|
+
operation,
|
|
435
|
+
code: boundedString(value.code, MAX_CODE_LENGTH),
|
|
436
|
+
origin,
|
|
437
|
+
category,
|
|
438
|
+
retryable: trustworthy ? value.retryable === true : false,
|
|
439
|
+
statusCode: finiteNonNegativeInteger(value.statusCode),
|
|
440
|
+
requestId: boundedString(value.requestId),
|
|
441
|
+
retryAfterMs: finiteNonNegativeInteger(value.retryAfterMs),
|
|
442
|
+
networkKind: normalizeNetworkKind(value.networkKind),
|
|
443
|
+
networkScope: normalizeNetworkScope(value.networkScope)
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function serializeToolExecutionFailure(error) {
|
|
447
|
+
if (!(error instanceof ToolExecutionError)) return null;
|
|
448
|
+
return normalizeToolExecutionFailure({
|
|
449
|
+
schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
|
|
450
|
+
toolId: error.toolId,
|
|
451
|
+
provider: error.provider,
|
|
452
|
+
operation: error.operation,
|
|
453
|
+
code: error.code ?? null,
|
|
454
|
+
origin: error.origin,
|
|
455
|
+
category: error.category,
|
|
456
|
+
retryable: error.retryable,
|
|
457
|
+
statusCode: error.statusCode ?? null,
|
|
458
|
+
requestId: error.requestId,
|
|
459
|
+
retryAfterMs: error.retryAfterMs,
|
|
460
|
+
networkKind: error.networkKind,
|
|
461
|
+
networkScope: error.networkScope
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
function deserializeToolExecutionFailure(message, value, acceptedSchemaVersion) {
|
|
465
|
+
if (acceptedSchemaVersion === LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
const failure = normalizeToolExecutionFailure(value);
|
|
469
|
+
if (!failure) return null;
|
|
470
|
+
if (isProviderTransientFailure(failure)) {
|
|
471
|
+
return new ProviderTransientError(message, failure);
|
|
472
|
+
}
|
|
473
|
+
return new ToolExecutionError(message, failure);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// src/errors.ts
|
|
207
477
|
var AuthError = class extends DeeplineError {
|
|
478
|
+
/** Constructed by the SDK when Deepline rejects the caller's credentials. */
|
|
208
479
|
constructor(message = "Authentication failed. Check your DEEPLINE_API_KEY.") {
|
|
209
480
|
super(message, 401, "AUTH_ERROR");
|
|
210
481
|
this.name = "AuthError";
|
|
@@ -213,6 +484,7 @@ var AuthError = class extends DeeplineError {
|
|
|
213
484
|
var RateLimitError = class extends DeeplineError {
|
|
214
485
|
/** Milliseconds to wait before retrying, from the `Retry-After` response header. Defaults to 5000. */
|
|
215
486
|
retryAfterMs;
|
|
487
|
+
/** Constructed by the SDK after exhausting HTTP-level rate-limit retries. */
|
|
216
488
|
constructor(retryAfterMs = 5e3, message) {
|
|
217
489
|
super(
|
|
218
490
|
message ?? `Rate limited. Retry after ${retryAfterMs}ms.`,
|
|
@@ -223,7 +495,51 @@ var RateLimitError = class extends DeeplineError {
|
|
|
223
495
|
this.retryAfterMs = retryAfterMs;
|
|
224
496
|
}
|
|
225
497
|
};
|
|
498
|
+
var ToolRateLimitError = class extends RateLimitError {
|
|
499
|
+
/** Public tool id passed to `tools.execute`. */
|
|
500
|
+
toolId;
|
|
501
|
+
/** Provider responsible for the operation, or `null`. */
|
|
502
|
+
provider;
|
|
503
|
+
/** Provider operation name, or `null`. */
|
|
504
|
+
operation;
|
|
505
|
+
/** Stable machine-readable failure code when one exists. */
|
|
506
|
+
code;
|
|
507
|
+
/** Boundary responsible for the failure. */
|
|
508
|
+
origin;
|
|
509
|
+
/** Stable reason family for policy and diagnostics. */
|
|
510
|
+
category;
|
|
511
|
+
/** Whether repeating the same semantic call is delivery-safe. */
|
|
512
|
+
retryable;
|
|
513
|
+
/** Provider or Deepline request id, or `null`. */
|
|
514
|
+
requestId;
|
|
515
|
+
/** Network failure kind, or `null` for non-network failures. */
|
|
516
|
+
networkKind;
|
|
517
|
+
/** Network boundary that failed, or `null` for non-network failures. */
|
|
518
|
+
networkScope;
|
|
519
|
+
/** Constructed by the SDK after a structured tool HTTP 429. */
|
|
520
|
+
constructor(message, options) {
|
|
521
|
+
super(options.retryAfterMs ?? 5e3, message);
|
|
522
|
+
this.name = "ToolRateLimitError";
|
|
523
|
+
this.statusCode = options.statusCode ?? 429;
|
|
524
|
+
this.code = options.code ?? void 0;
|
|
525
|
+
this.toolId = options.toolId;
|
|
526
|
+
this.provider = options.provider;
|
|
527
|
+
this.operation = options.operation;
|
|
528
|
+
this.origin = options.origin;
|
|
529
|
+
this.category = options.category;
|
|
530
|
+
this.retryable = options.retryable;
|
|
531
|
+
this.requestId = options.requestId;
|
|
532
|
+
this.networkKind = options.networkKind;
|
|
533
|
+
this.networkScope = options.networkScope;
|
|
534
|
+
this.details = options.details;
|
|
535
|
+
brandAsToolExecutionError(this);
|
|
536
|
+
if (isProviderTransientFailure(this)) {
|
|
537
|
+
brandAsProviderTransientError(this);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
226
541
|
var ConfigError = class extends DeeplineError {
|
|
542
|
+
/** Construct a local SDK configuration failure. */
|
|
227
543
|
constructor(message) {
|
|
228
544
|
super(message, void 0, "CONFIG_ERROR");
|
|
229
545
|
this.name = "ConfigError";
|
|
@@ -679,6 +995,9 @@ var import_node_fs2 = require("fs");
|
|
|
679
995
|
var import_node_os3 = require("os");
|
|
680
996
|
var import_node_path2 = require("path");
|
|
681
997
|
|
|
998
|
+
// ../shared_libs/plays/artifact-contract-version.ts
|
|
999
|
+
var CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION = 2;
|
|
1000
|
+
|
|
682
1001
|
// src/release.ts
|
|
683
1002
|
var SDK_RELEASE = {
|
|
684
1003
|
// 0.1.94 is claimed by PR #1527 — this watch-render fix ships as 0.1.95.
|
|
@@ -718,7 +1037,7 @@ var SDK_RELEASE = {
|
|
|
718
1037
|
// 0.1.253 makes play-page browser opening opt-in and retires --no-open.
|
|
719
1038
|
// 0.1.254 removes the internal operations tree from the published SDK CLI.
|
|
720
1039
|
// Operators use the checkout-local deepline-admin binary instead.
|
|
721
|
-
version: "0.1.
|
|
1040
|
+
version: "0.1.303",
|
|
722
1041
|
contracts: {
|
|
723
1042
|
api: {
|
|
724
1043
|
name: "sdk-http-api",
|
|
@@ -734,8 +1053,8 @@ var SDK_RELEASE = {
|
|
|
734
1053
|
},
|
|
735
1054
|
playArtifact: {
|
|
736
1055
|
name: "play-artifact-runtime",
|
|
737
|
-
currentVersion:
|
|
738
|
-
supportedVersions: [1,
|
|
1056
|
+
currentVersion: CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION,
|
|
1057
|
+
supportedVersions: [1, CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION]
|
|
739
1058
|
},
|
|
740
1059
|
release: {
|
|
741
1060
|
name: "production-sdk-release",
|
|
@@ -967,6 +1286,9 @@ function providerLabelFromToolId(toolId) {
|
|
|
967
1286
|
const provider = normalized.split(/[_:./-]+/)[0];
|
|
968
1287
|
return provider || normalized || "provider";
|
|
969
1288
|
}
|
|
1289
|
+
function isRecord2(value) {
|
|
1290
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1291
|
+
}
|
|
970
1292
|
var HttpClient = class {
|
|
971
1293
|
constructor(config) {
|
|
972
1294
|
this.config = config;
|
|
@@ -1102,6 +1424,29 @@ var HttpClient = class {
|
|
|
1102
1424
|
signal: controller.signal
|
|
1103
1425
|
});
|
|
1104
1426
|
clearTimeout(timeoutId);
|
|
1427
|
+
const body = await response.text();
|
|
1428
|
+
const parsed = parseResponseBody(body);
|
|
1429
|
+
const structuredToolError = options?.toolId && !response.ok ? deserializeToolExecutionFailure(
|
|
1430
|
+
apiErrorMessage(parsed, response.status),
|
|
1431
|
+
isRecord2(parsed) ? parsed.tool_error : null,
|
|
1432
|
+
TOOL_EXECUTION_ERROR_SCHEMA_VERSION
|
|
1433
|
+
) : null;
|
|
1434
|
+
if (structuredToolError) {
|
|
1435
|
+
if (response.status === 429) {
|
|
1436
|
+
const retryAfter = parseRetryAfter(response);
|
|
1437
|
+
const failure = serializeToolExecutionFailure(structuredToolError);
|
|
1438
|
+
lastError = failure === null ? structuredToolError : new ToolRateLimitError(structuredToolError.message, {
|
|
1439
|
+
...failure,
|
|
1440
|
+
retryAfterMs: failure.retryAfterMs ?? Math.max(0, retryAfter)
|
|
1441
|
+
});
|
|
1442
|
+
if (attempt < maxRetries) {
|
|
1443
|
+
retryAfterDelayMs = retryAfter;
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
throw lastError;
|
|
1447
|
+
}
|
|
1448
|
+
throw structuredToolError;
|
|
1449
|
+
}
|
|
1105
1450
|
if (response.status === 429) {
|
|
1106
1451
|
const retryAfter = parseRetryAfter(response);
|
|
1107
1452
|
lastError = new RateLimitError(retryAfter);
|
|
@@ -1111,8 +1456,6 @@ var HttpClient = class {
|
|
|
1111
1456
|
}
|
|
1112
1457
|
throw lastError;
|
|
1113
1458
|
}
|
|
1114
|
-
const body = await response.text();
|
|
1115
|
-
const parsed = parseResponseBody(body);
|
|
1116
1459
|
if (response.status === 401 && !isProviderOriginatedHttpError(parsed) || response.status === 403 && !options?.forbiddenAsApiError) {
|
|
1117
1460
|
throw new AuthError();
|
|
1118
1461
|
}
|
|
@@ -1177,6 +1520,29 @@ var HttpClient = class {
|
|
|
1177
1520
|
lastError,
|
|
1178
1521
|
describeRequestTarget(path)
|
|
1179
1522
|
);
|
|
1523
|
+
if (options?.toolId) {
|
|
1524
|
+
const code = mappedNetworkError.code;
|
|
1525
|
+
throw new ToolExecutionError(
|
|
1526
|
+
withCoworkNetworkHint(mappedNetworkError.message),
|
|
1527
|
+
{
|
|
1528
|
+
toolId: options.toolId,
|
|
1529
|
+
provider: providerLabelFromToolId(options.toolId),
|
|
1530
|
+
operation: options.toolId,
|
|
1531
|
+
code,
|
|
1532
|
+
origin: "deepline",
|
|
1533
|
+
category: "network",
|
|
1534
|
+
// A direct client timeout has ambiguous delivery. Fail closed unless
|
|
1535
|
+
// the server returns the authoritative action delivery contract.
|
|
1536
|
+
retryable: false,
|
|
1537
|
+
statusCode: null,
|
|
1538
|
+
requestId: null,
|
|
1539
|
+
retryAfterMs: null,
|
|
1540
|
+
networkKind: code === "NETWORK_TIMEOUT" ? "timeout" : code === "NETWORK_ABORTED" ? "unknown" : "unavailable",
|
|
1541
|
+
networkScope: "client_to_deepline",
|
|
1542
|
+
details: mappedNetworkError.details
|
|
1543
|
+
}
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1180
1546
|
throw new DeeplineError(
|
|
1181
1547
|
withCoworkNetworkHint(mappedNetworkError.message),
|
|
1182
1548
|
void 0,
|
|
@@ -1618,11 +1984,11 @@ var RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES = 64 * 1024;
|
|
|
1618
1984
|
var ledgerIngressRedactor = createSecretRedactionContext();
|
|
1619
1985
|
|
|
1620
1986
|
// ../shared_libs/play-runtime/activity-observation.ts
|
|
1621
|
-
function
|
|
1987
|
+
function isRecord3(value) {
|
|
1622
1988
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1623
1989
|
}
|
|
1624
1990
|
function isPlayActivityObservation(value) {
|
|
1625
|
-
if (!
|
|
1991
|
+
if (!isRecord3(value) || value.schemaVersion !== 1 || typeof value.activityId !== "string" || !value.activityId.trim() || typeof value.observedAt !== "number" || !Number.isFinite(value.observedAt) || !isRecord3(value.target) || !isRecord3(value.state)) {
|
|
1626
1992
|
return false;
|
|
1627
1993
|
}
|
|
1628
1994
|
const targetKinds = /* @__PURE__ */ new Set([
|
|
@@ -1887,7 +2253,7 @@ function projectPlayRunActivity(input2) {
|
|
|
1887
2253
|
|
|
1888
2254
|
// ../shared_libs/play-runtime/run-ledger.ts
|
|
1889
2255
|
var LOG_TAIL_LIMIT = 100;
|
|
1890
|
-
function
|
|
2256
|
+
function isRecord4(value) {
|
|
1891
2257
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1892
2258
|
}
|
|
1893
2259
|
function finiteNumber(value) {
|
|
@@ -1983,21 +2349,21 @@ function createEmptyPlayRunLedgerSnapshot(input2) {
|
|
|
1983
2349
|
};
|
|
1984
2350
|
}
|
|
1985
2351
|
function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
1986
|
-
if (!
|
|
2352
|
+
if (!isRecord4(value)) {
|
|
1987
2353
|
return createEmptyPlayRunLedgerSnapshot(fallback);
|
|
1988
2354
|
}
|
|
1989
2355
|
const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
|
|
1990
2356
|
(entry) => typeof entry === "string" && Boolean(entry.trim())
|
|
1991
2357
|
) : [];
|
|
1992
|
-
const rawSteps =
|
|
2358
|
+
const rawSteps = isRecord4(value.stepsById) ? value.stepsById : {};
|
|
1993
2359
|
const stepsById = {};
|
|
1994
2360
|
for (const [stepId, rawStep] of Object.entries(rawSteps)) {
|
|
1995
|
-
if (!stepId.trim() || !
|
|
2361
|
+
if (!stepId.trim() || !isRecord4(rawStep)) continue;
|
|
1996
2362
|
const rawStatus = normalizeStepStatus(rawStep.status);
|
|
1997
2363
|
if (!rawStatus) continue;
|
|
1998
2364
|
const completedAt = finiteNumber(rawStep.completedAt);
|
|
1999
2365
|
const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
|
|
2000
|
-
const rawProgress =
|
|
2366
|
+
const rawProgress = isRecord4(rawStep.progress) ? rawStep.progress : null;
|
|
2001
2367
|
stepsById[stepId] = {
|
|
2002
2368
|
stepId,
|
|
2003
2369
|
label: optionalString(rawStep.label),
|
|
@@ -2013,10 +2379,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2013
2379
|
progress: rawProgress ? normalizeStepProgress(rawProgress) : null
|
|
2014
2380
|
};
|
|
2015
2381
|
}
|
|
2016
|
-
const rawDatasets =
|
|
2382
|
+
const rawDatasets = isRecord4(value.datasetsById) ? value.datasetsById : {};
|
|
2017
2383
|
const datasetsById = {};
|
|
2018
2384
|
for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
|
|
2019
|
-
if (!datasetId.trim() || !
|
|
2385
|
+
if (!datasetId.trim() || !isRecord4(rawDataset)) continue;
|
|
2020
2386
|
const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
|
|
2021
2387
|
datasetsById[datasetId] = {
|
|
2022
2388
|
datasetId,
|
|
@@ -2030,7 +2396,7 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
2030
2396
|
updatedAt: finiteNumber(rawDataset.updatedAt) ?? 0
|
|
2031
2397
|
};
|
|
2032
2398
|
}
|
|
2033
|
-
const rawActivities =
|
|
2399
|
+
const rawActivities = isRecord4(value.activitiesById) ? value.activitiesById : {};
|
|
2034
2400
|
const activitiesById = {};
|
|
2035
2401
|
for (const [activityId, rawActivity] of Object.entries(rawActivities)) {
|
|
2036
2402
|
if (activityId.trim() && isPlayActivityObservation(rawActivity) && rawActivity.activityId === activityId) {
|
|
@@ -2179,18 +2545,18 @@ function normalizePlayRunLiveStatus(value) {
|
|
|
2179
2545
|
function isTerminalPlayRunLiveStatus(status) {
|
|
2180
2546
|
return isTerminalPlayRunLifecycleStatus(status);
|
|
2181
2547
|
}
|
|
2182
|
-
function
|
|
2548
|
+
function isRecord5(value) {
|
|
2183
2549
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
2184
2550
|
}
|
|
2185
2551
|
function finiteNumber2(value) {
|
|
2186
2552
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
2187
2553
|
}
|
|
2188
2554
|
function extractTerminalRunLogTail(result) {
|
|
2189
|
-
if (!
|
|
2555
|
+
if (!isRecord5(result) || !isRecord5(result._metadata)) {
|
|
2190
2556
|
return null;
|
|
2191
2557
|
}
|
|
2192
2558
|
const runLogTail = result._metadata.runLogTail;
|
|
2193
|
-
if (!
|
|
2559
|
+
if (!isRecord5(runLogTail) || !Array.isArray(runLogTail.tail)) {
|
|
2194
2560
|
return null;
|
|
2195
2561
|
}
|
|
2196
2562
|
const logTail = runLogTail.tail.filter(
|
|
@@ -3084,7 +3450,7 @@ function resolveToolExecuteTimeoutMs(toolId, input2) {
|
|
|
3084
3450
|
}
|
|
3085
3451
|
var RUNS_FAILED_LOG_LIMIT = 20;
|
|
3086
3452
|
var RUN_LOGS_PAGE_LIMIT = 1e3;
|
|
3087
|
-
function
|
|
3453
|
+
function isRecord6(value) {
|
|
3088
3454
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
3089
3455
|
}
|
|
3090
3456
|
function isPrebuiltPlayDescription(play) {
|
|
@@ -3247,7 +3613,7 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
3247
3613
|
}
|
|
3248
3614
|
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
3249
3615
|
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
3250
|
-
const progressPayload =
|
|
3616
|
+
const progressPayload = isRecord6(payload.progress) ? payload.progress : {};
|
|
3251
3617
|
if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
|
|
3252
3618
|
const payloadLogs = readStringArray(payload.logs);
|
|
3253
3619
|
const progressLogs = readStringArray(progressPayload.logs);
|
|
@@ -3381,9 +3747,9 @@ var DeeplineClient = class {
|
|
|
3381
3747
|
return fields.length > 0 ? { fields } : schema;
|
|
3382
3748
|
}
|
|
3383
3749
|
schemaMetadata(schema, key) {
|
|
3384
|
-
if (!
|
|
3750
|
+
if (!isRecord6(schema)) return null;
|
|
3385
3751
|
const value = schema[key];
|
|
3386
|
-
return
|
|
3752
|
+
return isRecord6(value) ? value : null;
|
|
3387
3753
|
}
|
|
3388
3754
|
playRunCommand(play, options) {
|
|
3389
3755
|
const target = play.reference || play.name;
|
|
@@ -3432,7 +3798,7 @@ var DeeplineClient = class {
|
|
|
3432
3798
|
aliases,
|
|
3433
3799
|
inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
|
|
3434
3800
|
outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
|
|
3435
|
-
staticPipeline:
|
|
3801
|
+
staticPipeline: isRecord6(play.staticPipeline) ? play.staticPipeline : isRecord6(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord6(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
|
|
3436
3802
|
...csvInput ? { csvInput } : {},
|
|
3437
3803
|
...rowOutputSchema ? { rowOutputSchema } : {},
|
|
3438
3804
|
runCommand: runCommand2,
|
|
@@ -3603,6 +3969,9 @@ var DeeplineClient = class {
|
|
|
3603
3969
|
async executeTool(toolId, input2, options) {
|
|
3604
3970
|
const headers = {
|
|
3605
3971
|
[EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
|
|
3972
|
+
[TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
|
|
3973
|
+
TOOL_EXECUTION_ERROR_SCHEMA_VERSION
|
|
3974
|
+
),
|
|
3606
3975
|
...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
|
|
3607
3976
|
[EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
|
|
3608
3977
|
};
|
|
@@ -3617,7 +3986,8 @@ var DeeplineClient = class {
|
|
|
3617
3986
|
forbiddenAsApiError: true,
|
|
3618
3987
|
timeout: options?.timeout ?? resolveToolExecuteTimeoutMs(toolId, input2),
|
|
3619
3988
|
maxRetries: options?.maxRetries ?? 0,
|
|
3620
|
-
exactUrlOnly: true
|
|
3989
|
+
exactUrlOnly: true,
|
|
3990
|
+
toolId
|
|
3621
3991
|
}
|
|
3622
3992
|
);
|
|
3623
3993
|
}
|
|
@@ -8278,14 +8648,14 @@ function sanitizeCsvProjectionInfo(input2) {
|
|
|
8278
8648
|
const rows = input2.rows.map(stripCsvProjectionFields);
|
|
8279
8649
|
return { rows, columns };
|
|
8280
8650
|
}
|
|
8281
|
-
function
|
|
8651
|
+
function isRecord7(value) {
|
|
8282
8652
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
8283
8653
|
}
|
|
8284
8654
|
function isSerializedDataset(value) {
|
|
8285
|
-
return
|
|
8655
|
+
return isRecord7(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
|
|
8286
8656
|
}
|
|
8287
8657
|
function isPackagedDatasetOutput(value) {
|
|
8288
|
-
return
|
|
8658
|
+
return isRecord7(value) && value.kind === "dataset" && isRecord7(value.preview) && Array.isArray(value.preview.rows);
|
|
8289
8659
|
}
|
|
8290
8660
|
function pathParts(path) {
|
|
8291
8661
|
return path.split(".").map((part) => part.trim()).filter(Boolean);
|
|
@@ -8293,7 +8663,7 @@ function pathParts(path) {
|
|
|
8293
8663
|
function valueAtPath(root, path) {
|
|
8294
8664
|
let cursor = root;
|
|
8295
8665
|
for (const part of pathParts(path)) {
|
|
8296
|
-
if (!
|
|
8666
|
+
if (!isRecord7(cursor)) {
|
|
8297
8667
|
return void 0;
|
|
8298
8668
|
}
|
|
8299
8669
|
cursor = cursor[part];
|
|
@@ -8301,17 +8671,17 @@ function valueAtPath(root, path) {
|
|
|
8301
8671
|
return cursor;
|
|
8302
8672
|
}
|
|
8303
8673
|
function totalRowsForDataset(result, datasetPath) {
|
|
8304
|
-
const metadata =
|
|
8674
|
+
const metadata = isRecord7(result._metadata) ? result._metadata : null;
|
|
8305
8675
|
const parentPath = datasetPath.split(".").slice(0, -1).join(".");
|
|
8306
8676
|
const parent = parentPath ? valueAtPath({ result }, parentPath) : result;
|
|
8307
|
-
return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (
|
|
8677
|
+
return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord7(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
|
|
8308
8678
|
}
|
|
8309
8679
|
function rowArray(value) {
|
|
8310
8680
|
if (!Array.isArray(value)) {
|
|
8311
8681
|
return null;
|
|
8312
8682
|
}
|
|
8313
8683
|
const rows = value.filter(
|
|
8314
|
-
(row) =>
|
|
8684
|
+
(row) => isRecord7(row)
|
|
8315
8685
|
);
|
|
8316
8686
|
return rows.length === value.length ? rows : null;
|
|
8317
8687
|
}
|
|
@@ -8335,7 +8705,7 @@ function inferColumns(rows) {
|
|
|
8335
8705
|
return columns;
|
|
8336
8706
|
}
|
|
8337
8707
|
function columnsFromDatasetSummary(summary) {
|
|
8338
|
-
if (!
|
|
8708
|
+
if (!isRecord7(summary) || !isRecord7(summary.columnStats)) {
|
|
8339
8709
|
return [];
|
|
8340
8710
|
}
|
|
8341
8711
|
return Object.keys(summary.columnStats).filter((column) => column);
|
|
@@ -8383,7 +8753,7 @@ function canonicalRowsInfoFromCandidate(input2) {
|
|
|
8383
8753
|
datasetId: typeof candidate.value.datasetId === "string" ? candidate.value.datasetId : null,
|
|
8384
8754
|
tableNamespace: typeof candidate.value.tableNamespace === "string" ? candidate.value.tableNamespace : null,
|
|
8385
8755
|
...candidate.value.recovered === true ? { recovered: true } : {},
|
|
8386
|
-
...
|
|
8756
|
+
...isRecord7(candidate.value.exportUnavailable) && (candidate.value.exportUnavailable.reason === "empty_dataset" || candidate.value.exportUnavailable.reason === "shared_table_namespace") ? {
|
|
8387
8757
|
exportUnavailableReason: candidate.value.exportUnavailable.reason,
|
|
8388
8758
|
...typeof candidate.value.exportUnavailable.message === "string" ? {
|
|
8389
8759
|
exportUnavailableMessage: candidate.value.exportUnavailable.message
|
|
@@ -8431,7 +8801,7 @@ function collectDatasetCandidates(input2) {
|
|
|
8431
8801
|
});
|
|
8432
8802
|
return;
|
|
8433
8803
|
}
|
|
8434
|
-
if (!
|
|
8804
|
+
if (!isRecord7(input2.value)) {
|
|
8435
8805
|
return;
|
|
8436
8806
|
}
|
|
8437
8807
|
for (const [key, child] of Object.entries(input2.value)) {
|
|
@@ -8448,12 +8818,12 @@ function collectDatasetCandidates(input2) {
|
|
|
8448
8818
|
}
|
|
8449
8819
|
}
|
|
8450
8820
|
function collectCanonicalRowsInfos(statusOrResult) {
|
|
8451
|
-
const root =
|
|
8452
|
-
const result =
|
|
8821
|
+
const root = isRecord7(statusOrResult) ? statusOrResult : null;
|
|
8822
|
+
const result = isRecord7(root?.result) ? root.result : root;
|
|
8453
8823
|
if (!result) {
|
|
8454
8824
|
return [];
|
|
8455
8825
|
}
|
|
8456
|
-
const metadata =
|
|
8826
|
+
const metadata = isRecord7(result._metadata) ? result._metadata : null;
|
|
8457
8827
|
const totalFromMetadata = metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count;
|
|
8458
8828
|
const candidates = [
|
|
8459
8829
|
{
|
|
@@ -8477,8 +8847,8 @@ function collectCanonicalRowsInfos(statusOrResult) {
|
|
|
8477
8847
|
total: totalFromMetadata ?? result.totalRows ?? result.rowCount ?? result.count
|
|
8478
8848
|
}
|
|
8479
8849
|
];
|
|
8480
|
-
if (
|
|
8481
|
-
const outputMetadata =
|
|
8850
|
+
if (isRecord7(result.output)) {
|
|
8851
|
+
const outputMetadata = isRecord7(result.output._metadata) ? result.output._metadata : null;
|
|
8482
8852
|
const outputTotalFromMetadata = outputMetadata?.totalRows ?? outputMetadata?.rowCount ?? outputMetadata?.count;
|
|
8483
8853
|
candidates.push(
|
|
8484
8854
|
{
|
|
@@ -8505,14 +8875,14 @@ function collectCanonicalRowsInfos(statusOrResult) {
|
|
|
8505
8875
|
}
|
|
8506
8876
|
if (Array.isArray(result.steps)) {
|
|
8507
8877
|
result.steps.forEach((step, index) => {
|
|
8508
|
-
if (!
|
|
8878
|
+
if (!isRecord7(step) || !isRecord7(step.output)) {
|
|
8509
8879
|
return;
|
|
8510
8880
|
}
|
|
8511
8881
|
const source = typeof step.output.path === "string" ? step.output.path : typeof step.id === "string" ? `steps.${step.id}.output` : `steps.${index}.output`;
|
|
8512
8882
|
candidates.push({
|
|
8513
8883
|
source,
|
|
8514
8884
|
value: step.output,
|
|
8515
|
-
total: step.output.rowCount ?? (
|
|
8885
|
+
total: step.output.rowCount ?? (isRecord7(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord7(step.progress) ? step.progress.total : void 0)
|
|
8516
8886
|
});
|
|
8517
8887
|
});
|
|
8518
8888
|
}
|
|
@@ -8540,15 +8910,15 @@ function collectCanonicalRowsInfos(statusOrResult) {
|
|
|
8540
8910
|
return infos;
|
|
8541
8911
|
}
|
|
8542
8912
|
function collectPackagedDatasetCandidates(statusOrResult) {
|
|
8543
|
-
const root =
|
|
8913
|
+
const root = isRecord7(statusOrResult) ? statusOrResult : null;
|
|
8544
8914
|
if (!root) {
|
|
8545
8915
|
return [];
|
|
8546
8916
|
}
|
|
8547
|
-
const pkg =
|
|
8917
|
+
const pkg = isRecord7(root.package) ? root.package : root;
|
|
8548
8918
|
const datasets = Array.isArray(pkg.datasets) ? pkg.datasets : [];
|
|
8549
8919
|
const candidates = [];
|
|
8550
8920
|
for (const output2 of datasets) {
|
|
8551
|
-
if (!
|
|
8921
|
+
if (!isRecord7(output2) || !isPackagedDatasetOutput(output2)) {
|
|
8552
8922
|
continue;
|
|
8553
8923
|
}
|
|
8554
8924
|
const source = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
|
|
@@ -8558,18 +8928,18 @@ function collectPackagedDatasetCandidates(statusOrResult) {
|
|
|
8558
8928
|
candidates.push({
|
|
8559
8929
|
source,
|
|
8560
8930
|
value: output2,
|
|
8561
|
-
total: output2.rowCount ?? (
|
|
8931
|
+
total: output2.rowCount ?? (isRecord7(output2.preview) ? output2.preview.totalRows : void 0)
|
|
8562
8932
|
});
|
|
8563
8933
|
}
|
|
8564
8934
|
return candidates;
|
|
8565
8935
|
}
|
|
8566
8936
|
function collectPackagedStepDatasetCandidates(statusOrResult) {
|
|
8567
|
-
const root =
|
|
8937
|
+
const root = isRecord7(statusOrResult) ? statusOrResult : null;
|
|
8568
8938
|
if (!root) return [];
|
|
8569
|
-
const pkg =
|
|
8939
|
+
const pkg = isRecord7(root.package) ? root.package : root;
|
|
8570
8940
|
const steps = Array.isArray(pkg.steps) ? pkg.steps : [];
|
|
8571
8941
|
return steps.flatMap((step) => {
|
|
8572
|
-
if (!
|
|
8942
|
+
if (!isRecord7(step) || !isPackagedDatasetOutput(step.output)) return [];
|
|
8573
8943
|
const source = typeof step.output.path === "string" && step.output.path.trim() ? step.output.path.trim() : null;
|
|
8574
8944
|
return source ? [
|
|
8575
8945
|
{
|
|
@@ -8581,8 +8951,8 @@ function collectPackagedStepDatasetCandidates(statusOrResult) {
|
|
|
8581
8951
|
});
|
|
8582
8952
|
}
|
|
8583
8953
|
function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
8584
|
-
const root =
|
|
8585
|
-
const result =
|
|
8954
|
+
const root = isRecord7(statusOrResult) ? statusOrResult : null;
|
|
8955
|
+
const result = isRecord7(root?.result) ? root.result : root;
|
|
8586
8956
|
const candidates = [];
|
|
8587
8957
|
if (result) {
|
|
8588
8958
|
collectDatasetCandidates({
|
|
@@ -8590,7 +8960,7 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
8590
8960
|
path: "result",
|
|
8591
8961
|
output: candidates
|
|
8592
8962
|
});
|
|
8593
|
-
if (
|
|
8963
|
+
if (isRecord7(result.output)) {
|
|
8594
8964
|
collectDatasetCandidates({
|
|
8595
8965
|
value: result.output,
|
|
8596
8966
|
path: "result",
|
|
@@ -8668,13 +9038,13 @@ function summarizeSampleValue(value, depth = 0) {
|
|
|
8668
9038
|
if (typeof parsed === "number" || typeof parsed === "boolean") return parsed;
|
|
8669
9039
|
if (depth >= 3) {
|
|
8670
9040
|
if (Array.isArray(parsed)) return [];
|
|
8671
|
-
if (
|
|
9041
|
+
if (isRecord7(parsed)) return {};
|
|
8672
9042
|
return compactScalar(parsed);
|
|
8673
9043
|
}
|
|
8674
9044
|
if (Array.isArray(parsed)) {
|
|
8675
9045
|
return parsed.slice(0, 3).map((item) => summarizeSampleValue(item, depth + 1));
|
|
8676
9046
|
}
|
|
8677
|
-
if (
|
|
9047
|
+
if (isRecord7(parsed)) {
|
|
8678
9048
|
const out = {};
|
|
8679
9049
|
for (const [key, nested] of Object.entries(parsed)) {
|
|
8680
9050
|
if (["__dl", "meta", "metadata"].includes(key)) {
|
|
@@ -8705,7 +9075,7 @@ function compactCell(value) {
|
|
|
8705
9075
|
}
|
|
8706
9076
|
return `[${parsed.length} items]`;
|
|
8707
9077
|
}
|
|
8708
|
-
if (
|
|
9078
|
+
if (isRecord7(parsed)) {
|
|
8709
9079
|
for (const key of ["matched_result", "output"]) {
|
|
8710
9080
|
if (parsed[key] !== null && parsed[key] !== void 0 && parsed[key] !== "") {
|
|
8711
9081
|
return compactCell(parsed[key]);
|
|
@@ -9770,17 +10140,17 @@ function parsePositiveInteger2(value, flagName) {
|
|
|
9770
10140
|
}
|
|
9771
10141
|
return parsed;
|
|
9772
10142
|
}
|
|
9773
|
-
function
|
|
10143
|
+
function isRecord8(value) {
|
|
9774
10144
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
9775
10145
|
}
|
|
9776
10146
|
function stringValue(value) {
|
|
9777
10147
|
return typeof value === "string" ? value.trim() : "";
|
|
9778
10148
|
}
|
|
9779
10149
|
function extractionEntries(value) {
|
|
9780
|
-
if (Array.isArray(value)) return value.filter(
|
|
9781
|
-
if (!
|
|
10150
|
+
if (Array.isArray(value)) return value.filter(isRecord8);
|
|
10151
|
+
if (!isRecord8(value)) return [];
|
|
9782
10152
|
return Object.entries(value).map(
|
|
9783
|
-
([name, entry]) =>
|
|
10153
|
+
([name, entry]) => isRecord8(entry) ? { name, ...entry } : { name }
|
|
9784
10154
|
);
|
|
9785
10155
|
}
|
|
9786
10156
|
var PlayBootstrapError = class extends Error {
|
|
@@ -10342,7 +10712,7 @@ function readCsvSampleRows(sample) {
|
|
|
10342
10712
|
relax_column_count: true,
|
|
10343
10713
|
trim: true
|
|
10344
10714
|
});
|
|
10345
|
-
return Array.isArray(parsedRows) ? parsedRows.filter(
|
|
10715
|
+
return Array.isArray(parsedRows) ? parsedRows.filter(isRecord8) : [];
|
|
10346
10716
|
}
|
|
10347
10717
|
function readSourceCsvColumnSpecs(csvPath) {
|
|
10348
10718
|
const sample = readCsvSample(csvPath);
|
|
@@ -10375,16 +10745,16 @@ function packagedCsvPathForPlay(csvPath) {
|
|
|
10375
10745
|
return portablePath.startsWith(".") ? portablePath : `./${portablePath}`;
|
|
10376
10746
|
}
|
|
10377
10747
|
function getterNamesFromTool(tool, kind) {
|
|
10378
|
-
const usageGuidance =
|
|
10379
|
-
const resultGuidance =
|
|
10748
|
+
const usageGuidance = isRecord8(tool?.usageGuidance) ? tool.usageGuidance : {};
|
|
10749
|
+
const resultGuidance = isRecord8(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord8(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
|
|
10380
10750
|
const key = kind === "list" ? "extractedLists" : "extractedValues";
|
|
10381
10751
|
const snakeKey = kind === "list" ? "extracted_lists" : "extracted_values";
|
|
10382
10752
|
return extractionEntries(resultGuidance[key] ?? resultGuidance[snakeKey]).map((entry) => stringValue(entry.name)).filter(Boolean);
|
|
10383
10753
|
}
|
|
10384
10754
|
function targetGettersFromTool(tool) {
|
|
10385
|
-
const record =
|
|
10755
|
+
const record = isRecord8(tool) ? tool : {};
|
|
10386
10756
|
const raw = record.targetGetters ?? record.target_getters;
|
|
10387
|
-
if (!
|
|
10757
|
+
if (!isRecord8(raw)) return {};
|
|
10388
10758
|
const entries = [];
|
|
10389
10759
|
for (const [target, value] of Object.entries(raw)) {
|
|
10390
10760
|
const paths = Array.isArray(value) ? value.map((path) => typeof path === "string" ? path.trim() : "").filter(Boolean) : [];
|
|
@@ -10405,10 +10775,10 @@ function listRowCandidateKeysFromTool(tool) {
|
|
|
10405
10775
|
return [...keys].sort();
|
|
10406
10776
|
}
|
|
10407
10777
|
function inputPropertyNames(schema) {
|
|
10408
|
-
if (!
|
|
10409
|
-
if (
|
|
10778
|
+
if (!isRecord8(schema)) return [];
|
|
10779
|
+
if (isRecord8(schema.properties)) return Object.keys(schema.properties);
|
|
10410
10780
|
if (Array.isArray(schema.fields)) {
|
|
10411
|
-
return schema.fields.filter(
|
|
10781
|
+
return schema.fields.filter(isRecord8).map((field) => stringValue(field.name)).filter(Boolean);
|
|
10412
10782
|
}
|
|
10413
10783
|
return [];
|
|
10414
10784
|
}
|
|
@@ -10422,7 +10792,7 @@ function schemaFieldDetails(schema) {
|
|
|
10422
10792
|
return { required, optional };
|
|
10423
10793
|
}
|
|
10424
10794
|
function jsonSchemaTypeExpression(schema) {
|
|
10425
|
-
if (!
|
|
10795
|
+
if (!isRecord8(schema)) return "unknown";
|
|
10426
10796
|
const type = schema.type;
|
|
10427
10797
|
if (Array.isArray(type)) {
|
|
10428
10798
|
return type.map((entry) => jsonSchemaTypeExpression({ ...schema, type: entry })).join(" | ");
|
|
@@ -10452,7 +10822,7 @@ function jsonSchemaTypeExpression(schema) {
|
|
|
10452
10822
|
}
|
|
10453
10823
|
}
|
|
10454
10824
|
function objectPropertySchema(schema, property) {
|
|
10455
|
-
return
|
|
10825
|
+
return isRecord8(schema) && isRecord8(schema.properties) ? schema.properties[property] : null;
|
|
10456
10826
|
}
|
|
10457
10827
|
function playOutputHasField(schema, field) {
|
|
10458
10828
|
return objectPropertySchema(schema, field) != null;
|
|
@@ -10628,14 +10998,14 @@ ${indent2.slice(2)}}`;
|
|
|
10628
10998
|
}
|
|
10629
10999
|
function requiredPlayInputFields(play) {
|
|
10630
11000
|
const schema = play?.inputSchema;
|
|
10631
|
-
if (!
|
|
11001
|
+
if (!isRecord8(schema)) return [];
|
|
10632
11002
|
if (Array.isArray(schema.required)) {
|
|
10633
11003
|
return schema.required.filter(
|
|
10634
11004
|
(value) => typeof value === "string"
|
|
10635
11005
|
);
|
|
10636
11006
|
}
|
|
10637
11007
|
if (Array.isArray(schema.fields)) {
|
|
10638
|
-
return schema.fields.filter(
|
|
11008
|
+
return schema.fields.filter(isRecord8).filter(
|
|
10639
11009
|
(field) => field.required === true && typeof field.name === "string"
|
|
10640
11010
|
).map((field) => String(field.name));
|
|
10641
11011
|
}
|
|
@@ -10816,7 +11186,7 @@ function validateBootstrapRoutes(input2) {
|
|
|
10816
11186
|
}
|
|
10817
11187
|
}
|
|
10818
11188
|
function staticPipelineSubsteps(pipeline) {
|
|
10819
|
-
if (!
|
|
11189
|
+
if (!isRecord8(pipeline)) return [];
|
|
10820
11190
|
return [
|
|
10821
11191
|
...extractionEntries(pipeline.stages),
|
|
10822
11192
|
...extractionEntries(pipeline.substeps)
|
|
@@ -10824,7 +11194,7 @@ function staticPipelineSubsteps(pipeline) {
|
|
|
10824
11194
|
}
|
|
10825
11195
|
function playUsesMapBackedRuntime(play) {
|
|
10826
11196
|
const pipeline = play?.staticPipeline;
|
|
10827
|
-
if (!
|
|
11197
|
+
if (!isRecord8(pipeline)) return false;
|
|
10828
11198
|
if (stringValue(pipeline.tableNamespace)) return true;
|
|
10829
11199
|
return staticPipelineSubsteps(pipeline).some((substep) => {
|
|
10830
11200
|
if (stringValue(substep.type) === "map") return true;
|
|
@@ -10833,7 +11203,7 @@ function playUsesMapBackedRuntime(play) {
|
|
|
10833
11203
|
aliases: [],
|
|
10834
11204
|
runCommand: "",
|
|
10835
11205
|
examples: [],
|
|
10836
|
-
staticPipeline:
|
|
11206
|
+
staticPipeline: isRecord8(substep.pipeline) ? substep.pipeline : null
|
|
10837
11207
|
});
|
|
10838
11208
|
});
|
|
10839
11209
|
}
|
|
@@ -15571,7 +15941,7 @@ function extractPlayValidationErrors(value) {
|
|
|
15571
15941
|
if (value instanceof DeeplineError) {
|
|
15572
15942
|
return extractPlayValidationErrors(value.details);
|
|
15573
15943
|
}
|
|
15574
|
-
if (!
|
|
15944
|
+
if (!isRecord9(value)) {
|
|
15575
15945
|
return [];
|
|
15576
15946
|
}
|
|
15577
15947
|
const directErrors = stringArrayField(value, "errors");
|
|
@@ -16011,7 +16381,7 @@ function shouldUseLocalOnlyPlayCheck() {
|
|
|
16011
16381
|
const value = process.env.DEEPLINE_PLAY_CHECK_LOCAL_ONLY?.trim().toLowerCase();
|
|
16012
16382
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
16013
16383
|
}
|
|
16014
|
-
function
|
|
16384
|
+
function isRecord9(value) {
|
|
16015
16385
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
16016
16386
|
}
|
|
16017
16387
|
function stringValue2(value) {
|
|
@@ -16021,14 +16391,14 @@ function asArray(value) {
|
|
|
16021
16391
|
return Array.isArray(value) ? value : [];
|
|
16022
16392
|
}
|
|
16023
16393
|
function extractionEntries2(value) {
|
|
16024
|
-
if (Array.isArray(value)) return value.filter(
|
|
16025
|
-
if (!
|
|
16394
|
+
if (Array.isArray(value)) return value.filter(isRecord9);
|
|
16395
|
+
if (!isRecord9(value)) return [];
|
|
16026
16396
|
return Object.entries(value).map(
|
|
16027
|
-
([name, entry]) =>
|
|
16397
|
+
([name, entry]) => isRecord9(entry) ? { name, ...entry } : { name }
|
|
16028
16398
|
);
|
|
16029
16399
|
}
|
|
16030
16400
|
function firstRawPath(entry) {
|
|
16031
|
-
const details =
|
|
16401
|
+
const details = isRecord9(entry.details) ? entry.details : {};
|
|
16032
16402
|
const paths = [
|
|
16033
16403
|
...asArray(details.rawToolOutputPaths),
|
|
16034
16404
|
...asArray(details.raw_tool_output_paths),
|
|
@@ -16046,12 +16416,12 @@ function checkHintRawPath(value) {
|
|
|
16046
16416
|
function collectStaticPipelineToolIds(staticPipeline) {
|
|
16047
16417
|
const seen = /* @__PURE__ */ new Set();
|
|
16048
16418
|
const visitPipeline = (pipeline) => {
|
|
16049
|
-
if (!
|
|
16419
|
+
if (!isRecord9(pipeline)) return;
|
|
16050
16420
|
for (const step of [
|
|
16051
16421
|
...asArray(pipeline.stages),
|
|
16052
16422
|
...asArray(pipeline.substeps)
|
|
16053
16423
|
]) {
|
|
16054
|
-
if (!
|
|
16424
|
+
if (!isRecord9(step)) continue;
|
|
16055
16425
|
if (step.type === "tool") {
|
|
16056
16426
|
const toolId = stringValue2(step.toolId) || stringValue2(step.tool);
|
|
16057
16427
|
if (toolId) seen.add(toolId);
|
|
@@ -16065,9 +16435,9 @@ function collectStaticPipelineToolIds(staticPipeline) {
|
|
|
16065
16435
|
return [...seen].sort();
|
|
16066
16436
|
}
|
|
16067
16437
|
function toolGetterHintFromMetadata(toolId, tool) {
|
|
16068
|
-
const usageGuidance =
|
|
16069
|
-
const resultGuidance =
|
|
16070
|
-
const toolResponse =
|
|
16438
|
+
const usageGuidance = isRecord9(tool.usageGuidance) ? tool.usageGuidance : {};
|
|
16439
|
+
const resultGuidance = isRecord9(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord9(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
|
|
16440
|
+
const toolResponse = isRecord9(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord9(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
|
|
16071
16441
|
const lists = extractionEntries2(
|
|
16072
16442
|
resultGuidance.extractedLists ?? resultGuidance.extracted_lists
|
|
16073
16443
|
).map((entry) => ({
|
|
@@ -19454,6 +19824,9 @@ function compileEnrichConfigToPlaySource(config, options = {}) {
|
|
|
19454
19824
|
const inlineTypeImports = [
|
|
19455
19825
|
...new Set(inlineHandlers.flatMap((inline) => inline.typeImports ?? []))
|
|
19456
19826
|
].sort();
|
|
19827
|
+
const inlineRuntimeImports = [
|
|
19828
|
+
...new Set(inlineHandlers.flatMap((inline) => inline.runtimeImports ?? []))
|
|
19829
|
+
].sort();
|
|
19457
19830
|
config.commands.forEach((command) => {
|
|
19458
19831
|
if (isWaterfall(command)) {
|
|
19459
19832
|
columnSteps.push(
|
|
@@ -19529,7 +19902,7 @@ function compileEnrichConfigToPlaySource(config, options = {}) {
|
|
|
19529
19902
|
const typeImports = idiomaticGetters ? inlineTypeImports : [.../* @__PURE__ */ new Set([...inlineTypeImports, "DeeplinePlayRuntimeContext"])].sort();
|
|
19530
19903
|
return [
|
|
19531
19904
|
...inlineRunJavascript && configHasRunJavascript(config) ? ["// @ts-nocheck", "/* eslint-disable */", ""] : [],
|
|
19532
|
-
`import { definePlay, steps } from 'deepline';`,
|
|
19905
|
+
`import { ${["definePlay", "steps", ...inlineRuntimeImports].join(", ")} } from 'deepline';`,
|
|
19533
19906
|
...typeImports.length > 0 ? [`import type { ${typeImports.join(", ")} } from 'deepline';`] : [],
|
|
19534
19907
|
``,
|
|
19535
19908
|
`type EnrichInput = { file: string; rowStart?: number | null; rowEnd?: number | null };`,
|
|
@@ -20345,7 +20718,7 @@ function isMarkedTestAiInferenceCommand(command) {
|
|
|
20345
20718
|
if (normalizeEnrichPlayRef(command.tool) !== "run_javascript") {
|
|
20346
20719
|
return false;
|
|
20347
20720
|
}
|
|
20348
|
-
return
|
|
20721
|
+
return isRecord10(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
|
|
20349
20722
|
}
|
|
20350
20723
|
function enrichDebugEnabled(env = process.env) {
|
|
20351
20724
|
const raw = String(env.DEEPLINE_DEBUG_ENRICH ?? "").trim().toLowerCase();
|
|
@@ -20609,7 +20982,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
|
|
|
20609
20982
|
if (Array.isArray(value)) {
|
|
20610
20983
|
return value.map(rewrite);
|
|
20611
20984
|
}
|
|
20612
|
-
if (!
|
|
20985
|
+
if (!isRecord10(value)) {
|
|
20613
20986
|
return value;
|
|
20614
20987
|
}
|
|
20615
20988
|
const next = Object.fromEntries(
|
|
@@ -20618,7 +20991,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
|
|
|
20618
20991
|
key === "rerunCommand" && typeof entry === "string" ? enrichCommand : rewrite(entry)
|
|
20619
20992
|
])
|
|
20620
20993
|
);
|
|
20621
|
-
if (
|
|
20994
|
+
if (isRecord10(next.next) && typeof next.next.run === "string") {
|
|
20622
20995
|
next.next = { ...next.next, run: enrichCommand };
|
|
20623
20996
|
}
|
|
20624
20997
|
return next;
|
|
@@ -21089,7 +21462,7 @@ async function resolveWatchedGeneratedPlayStatus(input2) {
|
|
|
21089
21462
|
}
|
|
21090
21463
|
return input2.client.runs.get(runId, { full: true });
|
|
21091
21464
|
}
|
|
21092
|
-
function
|
|
21465
|
+
function isRecord10(value) {
|
|
21093
21466
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
21094
21467
|
}
|
|
21095
21468
|
async function captureStdout(run, options = {}) {
|
|
@@ -21341,15 +21714,15 @@ function readFirstEnrichDatasetActions(value) {
|
|
|
21341
21714
|
return null;
|
|
21342
21715
|
}
|
|
21343
21716
|
const record = candidate;
|
|
21344
|
-
const actions =
|
|
21345
|
-
const currentQuery =
|
|
21346
|
-
const legacyQuery =
|
|
21717
|
+
const actions = isRecord10(record.actions) ? record.actions : null;
|
|
21718
|
+
const currentQuery = isRecord10(actions?.queryCurrentTable) ? actions.queryCurrentTable : null;
|
|
21719
|
+
const legacyQuery = isRecord10(actions?.query) ? actions.query : null;
|
|
21347
21720
|
const query = currentQuery?.kind === "deepline_db_query" ? currentQuery : legacyQuery?.kind === "deepline_db_query" ? legacyQuery : null;
|
|
21348
21721
|
if (query?.kind === "deepline_db_query") {
|
|
21349
21722
|
return {
|
|
21350
21723
|
dataset: record,
|
|
21351
21724
|
query,
|
|
21352
|
-
...
|
|
21725
|
+
...isRecord10(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
|
|
21353
21726
|
};
|
|
21354
21727
|
}
|
|
21355
21728
|
if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
|
|
@@ -21402,7 +21775,7 @@ function enrichCustomerDbJson(input2) {
|
|
|
21402
21775
|
const dataset = actions.dataset;
|
|
21403
21776
|
const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
|
|
21404
21777
|
const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
|
|
21405
|
-
const api =
|
|
21778
|
+
const api = isRecord10(query.api) ? query.api : null;
|
|
21406
21779
|
const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
|
|
21407
21780
|
const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
|
|
21408
21781
|
if (!datasetPath) {
|
|
@@ -21471,11 +21844,11 @@ function sqlStringLiteral(value) {
|
|
|
21471
21844
|
return `'${value.replace(/'/g, "''")}'`;
|
|
21472
21845
|
}
|
|
21473
21846
|
function failureAliasFromCellMeta(cellMeta) {
|
|
21474
|
-
if (!
|
|
21847
|
+
if (!isRecord10(cellMeta)) {
|
|
21475
21848
|
return null;
|
|
21476
21849
|
}
|
|
21477
21850
|
for (const [alias, meta] of Object.entries(cellMeta)) {
|
|
21478
|
-
if (!
|
|
21851
|
+
if (!isRecord10(meta)) {
|
|
21479
21852
|
continue;
|
|
21480
21853
|
}
|
|
21481
21854
|
const failure = failureCellFromMeta(meta, {});
|
|
@@ -21968,7 +22341,7 @@ function exportableSheetRow2(row, sourceRowStart = 0) {
|
|
|
21968
22341
|
return fallback;
|
|
21969
22342
|
}
|
|
21970
22343
|
function failureCellFromMeta(meta, fallback) {
|
|
21971
|
-
if (!
|
|
22344
|
+
if (!isRecord10(meta)) {
|
|
21972
22345
|
return null;
|
|
21973
22346
|
}
|
|
21974
22347
|
const status = typeof meta.status === "string" ? meta.status.trim().toLowerCase() : "";
|
|
@@ -21988,7 +22361,7 @@ function failureCellFromMeta(meta, fallback) {
|
|
|
21988
22361
|
};
|
|
21989
22362
|
}
|
|
21990
22363
|
function applyFailureCellMeta(row, cellMeta, fallback) {
|
|
21991
|
-
if (!
|
|
22364
|
+
if (!isRecord10(cellMeta)) {
|
|
21992
22365
|
return;
|
|
21993
22366
|
}
|
|
21994
22367
|
for (const [field, meta] of Object.entries(cellMeta)) {
|
|
@@ -22216,7 +22589,7 @@ function stableRowSnapshot(value) {
|
|
|
22216
22589
|
}
|
|
22217
22590
|
function cellFailureError(value) {
|
|
22218
22591
|
const parsed = parseMaybeJsonObject(value);
|
|
22219
|
-
if (!
|
|
22592
|
+
if (!isRecord10(parsed)) {
|
|
22220
22593
|
const text = typeof parsed === "string" ? parsed.trim() : "";
|
|
22221
22594
|
if (/^(?:[A-Za-z0-9_:-]+:\s*)?(?:Error|TypeError|ReferenceError|SyntaxError|RangeError):\s+/.test(
|
|
22222
22595
|
text
|
|
@@ -22224,12 +22597,12 @@ function cellFailureError(value) {
|
|
|
22224
22597
|
return { message: text };
|
|
22225
22598
|
}
|
|
22226
22599
|
}
|
|
22227
|
-
if (!
|
|
22600
|
+
if (!isRecord10(parsed)) {
|
|
22228
22601
|
return null;
|
|
22229
22602
|
}
|
|
22230
22603
|
const status = typeof parsed.status === "string" ? parsed.status.trim().toLowerCase() : "";
|
|
22231
22604
|
const directError = typeof parsed.error === "string" ? parsed.error.trim() : typeof parsed.last_error === "string" ? parsed.last_error.trim() : "";
|
|
22232
|
-
const result =
|
|
22605
|
+
const result = isRecord10(parsed.result) ? parsed.result : null;
|
|
22233
22606
|
const resultError = typeof result?.error === "string" ? result.error.trim() : typeof result?.message === "string" ? result.message.trim() : "";
|
|
22234
22607
|
if (!directError && !resultError && status !== "error" && status !== "failed") {
|
|
22235
22608
|
return null;
|
|
@@ -22299,7 +22672,7 @@ function assignFlattenedFailurePath(target, field, value) {
|
|
|
22299
22672
|
let cursor = target;
|
|
22300
22673
|
for (const part of normalized.slice(0, -1)) {
|
|
22301
22674
|
const existing = cursor[part];
|
|
22302
|
-
if (!
|
|
22675
|
+
if (!isRecord10(existing)) {
|
|
22303
22676
|
const next = {};
|
|
22304
22677
|
cursor[part] = next;
|
|
22305
22678
|
cursor = next;
|
|
@@ -22463,10 +22836,10 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
22463
22836
|
let everyChildStatOnlyConditionSkipped = true;
|
|
22464
22837
|
const childAliasesWithStats = /* @__PURE__ */ new Set();
|
|
22465
22838
|
for (const childAlias of childAliases) {
|
|
22466
|
-
for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(
|
|
22839
|
+
for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord10)) {
|
|
22467
22840
|
sawChildStats = true;
|
|
22468
22841
|
childAliasesWithStats.add(childAlias);
|
|
22469
|
-
const execution =
|
|
22842
|
+
const execution = isRecord10(stat2.execution) ? stat2.execution : null;
|
|
22470
22843
|
const executedSummary = parseExecutionSummary(
|
|
22471
22844
|
execution?.["completed:executed"]
|
|
22472
22845
|
);
|
|
@@ -22496,7 +22869,7 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
22496
22869
|
}
|
|
22497
22870
|
function emptyWaterfallStatsEvidence(status, spec) {
|
|
22498
22871
|
const summaries = collectColumnStats(status);
|
|
22499
|
-
const parentStats = summaries.map((summary) => summary[spec.alias]).filter(
|
|
22872
|
+
const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord10);
|
|
22500
22873
|
for (const stat2 of parentStats) {
|
|
22501
22874
|
const nonEmpty = parseExecutionSummary(stat2.non_empty);
|
|
22502
22875
|
if (nonEmpty?.total && nonEmpty.count === 0) {
|
|
@@ -22510,7 +22883,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
|
|
|
22510
22883
|
let selectedRows = 0;
|
|
22511
22884
|
let sawStatsForEveryChild = true;
|
|
22512
22885
|
for (const childAlias of childAliases) {
|
|
22513
|
-
const stat2 = summaries.map((summary) => summary[childAlias]).find(
|
|
22886
|
+
const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord10);
|
|
22514
22887
|
if (!stat2) {
|
|
22515
22888
|
sawStatsForEveryChild = false;
|
|
22516
22889
|
break;
|
|
@@ -22519,7 +22892,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
|
|
|
22519
22892
|
if ((nonEmpty?.count ?? 0) > 0) {
|
|
22520
22893
|
return null;
|
|
22521
22894
|
}
|
|
22522
|
-
const execution =
|
|
22895
|
+
const execution = isRecord10(stat2.execution) ? stat2.execution : null;
|
|
22523
22896
|
const executed = parseExecutionSummary(execution?.["completed:executed"]);
|
|
22524
22897
|
const reused = parseExecutionSummary(execution?.["completed:reused"]);
|
|
22525
22898
|
const skipped = parseExecutionSummary(execution?.["skipped:condition"]);
|
|
@@ -22561,11 +22934,11 @@ function collectStatusFailureJobs(input2) {
|
|
|
22561
22934
|
const jobs = [];
|
|
22562
22935
|
aliases.forEach((spec, aliasIndex) => {
|
|
22563
22936
|
const { alias } = spec;
|
|
22564
|
-
const stat2 = summaries.map((summary) => summary[alias]).find(
|
|
22937
|
+
const stat2 = summaries.map((summary) => summary[alias]).find(isRecord10);
|
|
22565
22938
|
if (!stat2) {
|
|
22566
22939
|
return;
|
|
22567
22940
|
}
|
|
22568
|
-
const execution =
|
|
22941
|
+
const execution = isRecord10(stat2.execution) ? stat2.execution : null;
|
|
22569
22942
|
const failedCount = Math.min(
|
|
22570
22943
|
selectedRows,
|
|
22571
22944
|
Math.max(
|
|
@@ -22672,10 +23045,10 @@ function collectColumnStats(status) {
|
|
|
22672
23045
|
value.forEach(visit);
|
|
22673
23046
|
return;
|
|
22674
23047
|
}
|
|
22675
|
-
if (!
|
|
23048
|
+
if (!isRecord10(value)) {
|
|
22676
23049
|
return;
|
|
22677
23050
|
}
|
|
22678
|
-
if (
|
|
23051
|
+
if (isRecord10(value.columnStats)) {
|
|
22679
23052
|
summaries.push(value.columnStats);
|
|
22680
23053
|
}
|
|
22681
23054
|
Object.values(value).forEach(visit);
|
|
@@ -22687,12 +23060,12 @@ function firstAliasExecutionCounts(input2) {
|
|
|
22687
23060
|
const aliases = collectConfigScalarAliasOrder(input2.config);
|
|
22688
23061
|
const summaries = collectColumnStats(input2.status);
|
|
22689
23062
|
for (const alias of aliases) {
|
|
22690
|
-
const stat2 = summaries.map((summary) => summary[alias]).find(
|
|
23063
|
+
const stat2 = summaries.map((summary) => summary[alias]).find(isRecord10);
|
|
22691
23064
|
if (!stat2) continue;
|
|
22692
23065
|
if (input2.forceAliases.has(normalizeAlias2(alias))) {
|
|
22693
23066
|
return { executed: input2.selectedRows, reused: 0 };
|
|
22694
23067
|
}
|
|
22695
|
-
const execution =
|
|
23068
|
+
const execution = isRecord10(stat2.execution) ? stat2.execution : null;
|
|
22696
23069
|
if (!execution) continue;
|
|
22697
23070
|
return {
|
|
22698
23071
|
executed: parseExecutionCount(execution["completed:executed"]),
|
|
@@ -22719,14 +23092,14 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
22719
23092
|
if (Array.isArray(value)) {
|
|
22720
23093
|
return value.map(rewrite);
|
|
22721
23094
|
}
|
|
22722
|
-
if (!
|
|
23095
|
+
if (!isRecord10(value)) {
|
|
22723
23096
|
return value;
|
|
22724
23097
|
}
|
|
22725
23098
|
const next = {};
|
|
22726
23099
|
for (const [key, entry] of Object.entries(value)) {
|
|
22727
23100
|
next[key] = rewrite(entry);
|
|
22728
23101
|
}
|
|
22729
|
-
if (
|
|
23102
|
+
if (isRecord10(next.progress)) {
|
|
22730
23103
|
next.progress = {
|
|
22731
23104
|
...next.progress,
|
|
22732
23105
|
...selectedRows > 0 ? { total: selectedRows } : {},
|
|
@@ -22735,8 +23108,8 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
22735
23108
|
...failedRows > 0 ? { failed: failedRows, pending: 0 } : {}
|
|
22736
23109
|
};
|
|
22737
23110
|
}
|
|
22738
|
-
if (
|
|
22739
|
-
const rowCounts =
|
|
23111
|
+
if (isRecord10(next.summary)) {
|
|
23112
|
+
const rowCounts = isRecord10(next.summary.rowCounts) ? next.summary.rowCounts : null;
|
|
22740
23113
|
if (failedRows > 0) {
|
|
22741
23114
|
next.summary = {
|
|
22742
23115
|
...next.summary,
|
|
@@ -22749,11 +23122,11 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
22749
23122
|
};
|
|
22750
23123
|
}
|
|
22751
23124
|
}
|
|
22752
|
-
if (
|
|
23125
|
+
if (isRecord10(next.columnStats) && selectedRows > 0) {
|
|
22753
23126
|
const columnStats = { ...next.columnStats };
|
|
22754
23127
|
for (const alias of forcedAliases) {
|
|
22755
|
-
const stat2 =
|
|
22756
|
-
const execution =
|
|
23128
|
+
const stat2 = isRecord10(columnStats[alias]) ? columnStats[alias] : null;
|
|
23129
|
+
const execution = isRecord10(stat2?.execution) ? stat2.execution : null;
|
|
22757
23130
|
if (!stat2 || !execution) continue;
|
|
22758
23131
|
columnStats[alias] = {
|
|
22759
23132
|
...stat2,
|
|
@@ -22772,14 +23145,14 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
22772
23145
|
return next;
|
|
22773
23146
|
};
|
|
22774
23147
|
const rewritten = rewrite(input2.status);
|
|
22775
|
-
if (failedRows === 0 || !
|
|
23148
|
+
if (failedRows === 0 || !isRecord10(rewritten)) {
|
|
22776
23149
|
return rewritten;
|
|
22777
23150
|
}
|
|
22778
23151
|
const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
|
|
22779
23152
|
return {
|
|
22780
23153
|
...rewritten,
|
|
22781
23154
|
...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
|
|
22782
|
-
...
|
|
23155
|
+
...isRecord10(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
|
|
22783
23156
|
};
|
|
22784
23157
|
}
|
|
22785
23158
|
function summarizeFailedJobError(value) {
|
|
@@ -23385,7 +23758,7 @@ function materializeCsvCellValue(value) {
|
|
|
23385
23758
|
return value;
|
|
23386
23759
|
}
|
|
23387
23760
|
function compactArrayEnvelopeCompleteValue(value) {
|
|
23388
|
-
if (!
|
|
23761
|
+
if (!isRecord10(value) || value.kind !== "array") {
|
|
23389
23762
|
return null;
|
|
23390
23763
|
}
|
|
23391
23764
|
if (!Array.isArray(value.preview)) {
|
|
@@ -23399,7 +23772,7 @@ function compactArrayEnvelopeCompleteValue(value) {
|
|
|
23399
23772
|
}
|
|
23400
23773
|
function disambiguateCompactAiInferencePayload(value) {
|
|
23401
23774
|
const parsed = parseMaybeJsonObject(value);
|
|
23402
|
-
if (!
|
|
23775
|
+
if (!isRecord10(parsed) || !cellFailureError(parsed)) {
|
|
23403
23776
|
return value;
|
|
23404
23777
|
}
|
|
23405
23778
|
return {
|
|
@@ -23408,14 +23781,14 @@ function disambiguateCompactAiInferencePayload(value) {
|
|
|
23408
23781
|
};
|
|
23409
23782
|
}
|
|
23410
23783
|
function compactAiInferenceCellForCsv(value) {
|
|
23411
|
-
if (!
|
|
23784
|
+
if (!isRecord10(value)) {
|
|
23412
23785
|
return value;
|
|
23413
23786
|
}
|
|
23414
23787
|
const extractedJson = value.extracted_json;
|
|
23415
23788
|
if (extractedJson !== null && extractedJson !== void 0) {
|
|
23416
23789
|
return disambiguateCompactAiInferencePayload(extractedJson);
|
|
23417
23790
|
}
|
|
23418
|
-
const result =
|
|
23791
|
+
const result = isRecord10(value.result) ? value.result : null;
|
|
23419
23792
|
const object = result?.object;
|
|
23420
23793
|
if (object !== null && object !== void 0) {
|
|
23421
23794
|
return disambiguateCompactAiInferencePayload(object);
|
|
@@ -23432,12 +23805,12 @@ function compactAiInferenceCellForCsv(value) {
|
|
|
23432
23805
|
}
|
|
23433
23806
|
function materializeEnrichAliasCellForCsv(row, alias, options) {
|
|
23434
23807
|
const direct = row[alias];
|
|
23435
|
-
if (
|
|
23808
|
+
if (isRecord10(direct)) {
|
|
23436
23809
|
const completeArray = compactArrayEnvelopeCompleteValue(direct);
|
|
23437
23810
|
if (completeArray) {
|
|
23438
23811
|
return materializeCsvCellValue(completeArray);
|
|
23439
23812
|
}
|
|
23440
|
-
if (options?.compactAiCell && direct.status === "completed" && (
|
|
23813
|
+
if (options?.compactAiCell && direct.status === "completed" && (isRecord10(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
|
|
23441
23814
|
return materializeCsvCellValue(compactAiInferenceCellForCsv(direct));
|
|
23442
23815
|
}
|
|
23443
23816
|
if (Object.prototype.hasOwnProperty.call(direct, "matched_result") || Object.prototype.hasOwnProperty.call(direct, "matchedResult") || Object.prototype.hasOwnProperty.call(direct, "result")) {
|
|
@@ -23578,11 +23951,11 @@ function normalizeEnrichRowsForCsvExport(rows, config, options) {
|
|
|
23578
23951
|
}
|
|
23579
23952
|
function legacyMetadataFromRow(row) {
|
|
23580
23953
|
const direct = parseLegacyMetadataCell(row._metadata);
|
|
23581
|
-
if (direct &&
|
|
23954
|
+
if (direct && isRecord10(direct.columns)) {
|
|
23582
23955
|
return direct;
|
|
23583
23956
|
}
|
|
23584
23957
|
const relocated = parseLegacyMetadataCell(row.metadata);
|
|
23585
|
-
if (relocated &&
|
|
23958
|
+
if (relocated && isRecord10(relocated.columns)) {
|
|
23586
23959
|
return relocated;
|
|
23587
23960
|
}
|
|
23588
23961
|
const flattenedColumns = parseLegacyMetadataCell(row["metadata.columns"]);
|
|
@@ -23599,7 +23972,7 @@ function legacyMetadataFromRow(row) {
|
|
|
23599
23972
|
}
|
|
23600
23973
|
function parseLegacyMetadataCell(value) {
|
|
23601
23974
|
const parsed = parseMaybeJsonObject(value);
|
|
23602
|
-
if (
|
|
23975
|
+
if (isRecord10(parsed)) {
|
|
23603
23976
|
return parsed;
|
|
23604
23977
|
}
|
|
23605
23978
|
if (typeof value !== "string") {
|
|
@@ -23616,12 +23989,12 @@ function parseLegacyMetadataCell(value) {
|
|
|
23616
23989
|
for (const candidate of candidates) {
|
|
23617
23990
|
try {
|
|
23618
23991
|
const decoded = JSON.parse(candidate);
|
|
23619
|
-
if (
|
|
23992
|
+
if (isRecord10(decoded)) {
|
|
23620
23993
|
return decoded;
|
|
23621
23994
|
}
|
|
23622
23995
|
if (typeof decoded === "string") {
|
|
23623
23996
|
const nested = JSON.parse(decoded);
|
|
23624
|
-
if (
|
|
23997
|
+
if (isRecord10(nested)) {
|
|
23625
23998
|
return nested;
|
|
23626
23999
|
}
|
|
23627
24000
|
}
|
|
@@ -23631,8 +24004,8 @@ function parseLegacyMetadataCell(value) {
|
|
|
23631
24004
|
return null;
|
|
23632
24005
|
}
|
|
23633
24006
|
function mergeLegacyMetadataRecords(base, enriched) {
|
|
23634
|
-
const baseColumns =
|
|
23635
|
-
const enrichedColumns =
|
|
24007
|
+
const baseColumns = isRecord10(base.columns) ? base.columns : null;
|
|
24008
|
+
const enrichedColumns = isRecord10(enriched.columns) ? enriched.columns : null;
|
|
23636
24009
|
const merged = {
|
|
23637
24010
|
...base,
|
|
23638
24011
|
...enriched
|
|
@@ -28067,7 +28440,7 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
28067
28440
|
}
|
|
28068
28441
|
function extractionContractEntries(entries) {
|
|
28069
28442
|
return entries.flatMap((entry) => {
|
|
28070
|
-
if (!
|
|
28443
|
+
if (!isRecord11(entry)) return [];
|
|
28071
28444
|
const name = stringField2(entry, "name");
|
|
28072
28445
|
const expression = stringField2(entry, "expression");
|
|
28073
28446
|
return name && expression ? [{ name, expression }] : [];
|
|
@@ -28088,7 +28461,7 @@ function printMonitorTypeFilters(tool) {
|
|
|
28088
28461
|
}
|
|
28089
28462
|
console.log("Deploy filters (set in the monitor payload):");
|
|
28090
28463
|
for (const name of names) {
|
|
28091
|
-
const field =
|
|
28464
|
+
const field = isRecord11(properties[name]) ? properties[name] : {};
|
|
28092
28465
|
const star = required.has(name) ? "*" : "";
|
|
28093
28466
|
const enumVals = arrayField2(field, "enum").filter(
|
|
28094
28467
|
(v) => typeof v === "string"
|
|
@@ -28100,14 +28473,14 @@ function printMonitorTypeFilters(tool) {
|
|
|
28100
28473
|
}
|
|
28101
28474
|
function printMonitorTypeStreams(tool) {
|
|
28102
28475
|
const streams = arrayField2(tool, "streams", "output_streams").filter(
|
|
28103
|
-
|
|
28476
|
+
isRecord11
|
|
28104
28477
|
);
|
|
28105
28478
|
if (!streams.length) return;
|
|
28106
28479
|
console.log("");
|
|
28107
28480
|
console.log("Filter columns (a play's sqlListeners.where, per stream):");
|
|
28108
28481
|
for (const stream of streams) {
|
|
28109
28482
|
const name = stringField2(stream, "stream");
|
|
28110
|
-
const cols = arrayField2(stream, "columns").filter(
|
|
28483
|
+
const cols = arrayField2(stream, "columns").filter(isRecord11).map((col) => stringField2(col, "name")).filter(Boolean);
|
|
28111
28484
|
console.log(`- ${name}: ${cols.join(", ")}`);
|
|
28112
28485
|
}
|
|
28113
28486
|
}
|
|
@@ -28125,7 +28498,7 @@ function printMonitorTypePricing(tool) {
|
|
|
28125
28498
|
}
|
|
28126
28499
|
console.log("Pricing (Deepline credits per accepted event):");
|
|
28127
28500
|
for (const key of keys) {
|
|
28128
|
-
const entry =
|
|
28501
|
+
const entry = isRecord11(byType[key]) ? byType[key] : {};
|
|
28129
28502
|
const credits = numberField2(entry, "deepline_credits", "deeplineCredits");
|
|
28130
28503
|
const display = stringField2(entry, "display");
|
|
28131
28504
|
const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "see --json");
|
|
@@ -28170,8 +28543,8 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
28170
28543
|
return;
|
|
28171
28544
|
}
|
|
28172
28545
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
28173
|
-
const cost =
|
|
28174
|
-
const getters =
|
|
28546
|
+
const cost = isRecord11(contract.cost) ? contract.cost : {};
|
|
28547
|
+
const getters = isRecord11(contract.getters) ? contract.getters : {};
|
|
28175
28548
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
28176
28549
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
28177
28550
|
const inputFields = recursiveToolInputFieldsForDisplay(
|
|
@@ -28190,7 +28563,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
28190
28563
|
console.log("");
|
|
28191
28564
|
console.log("Inputs:");
|
|
28192
28565
|
for (const field of inputFields) {
|
|
28193
|
-
if (!
|
|
28566
|
+
if (!isRecord11(field)) continue;
|
|
28194
28567
|
const name = stringField2(field, "name");
|
|
28195
28568
|
if (!name) continue;
|
|
28196
28569
|
const required = field.required ? "*" : "";
|
|
@@ -28209,7 +28582,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
28209
28582
|
}
|
|
28210
28583
|
console.log("");
|
|
28211
28584
|
printToolExamplesOnly(tool, requestedToolId, { includeSamples: false });
|
|
28212
|
-
const starterScript =
|
|
28585
|
+
const starterScript = isRecord11(contract.starterScript) ? contract.starterScript : {};
|
|
28213
28586
|
const starterPath = stringField2(starterScript, "path");
|
|
28214
28587
|
if (starterPath) {
|
|
28215
28588
|
console.log("");
|
|
@@ -28223,14 +28596,14 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
28223
28596
|
console.log("Getters:");
|
|
28224
28597
|
if (listGetters.length) console.log("Lists:");
|
|
28225
28598
|
for (const entry of listGetters) {
|
|
28226
|
-
if (
|
|
28599
|
+
if (isRecord11(entry))
|
|
28227
28600
|
console.log(
|
|
28228
28601
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
28229
28602
|
);
|
|
28230
28603
|
}
|
|
28231
28604
|
if (valueGetters.length) console.log("Values:");
|
|
28232
28605
|
for (const entry of valueGetters) {
|
|
28233
|
-
if (
|
|
28606
|
+
if (isRecord11(entry))
|
|
28234
28607
|
console.log(
|
|
28235
28608
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
28236
28609
|
);
|
|
@@ -28247,7 +28620,7 @@ function printToolPricingOnly(tool, requestedToolId, options = {}) {
|
|
|
28247
28620
|
return;
|
|
28248
28621
|
}
|
|
28249
28622
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
28250
|
-
const cost =
|
|
28623
|
+
const cost = isRecord11(contract.cost) ? contract.cost : {};
|
|
28251
28624
|
const pricingModel = stringField2(cost, "pricingModel") || "unknown";
|
|
28252
28625
|
const billingMode = stringField2(cost, "billingMode") || "unknown";
|
|
28253
28626
|
const unit = pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit";
|
|
@@ -28319,10 +28692,10 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
28319
28692
|
` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
|
|
28320
28693
|
);
|
|
28321
28694
|
console.log("});");
|
|
28322
|
-
const getters =
|
|
28695
|
+
const getters = isRecord11(contract.getters) ? contract.getters : {};
|
|
28323
28696
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
28324
28697
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
28325
|
-
const firstGetter = [...valueGetters, ...listGetters].find(
|
|
28698
|
+
const firstGetter = [...valueGetters, ...listGetters].find(isRecord11);
|
|
28326
28699
|
if (firstGetter) {
|
|
28327
28700
|
const name = stringField2(firstGetter, "name") || "value";
|
|
28328
28701
|
const expression = stringField2(firstGetter, "expression");
|
|
@@ -28358,7 +28731,7 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
|
28358
28731
|
}
|
|
28359
28732
|
function printToolGettersOnly(tool, requestedToolId) {
|
|
28360
28733
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
28361
|
-
const getters =
|
|
28734
|
+
const getters = isRecord11(contract.getters) ? contract.getters : {};
|
|
28362
28735
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
28363
28736
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
28364
28737
|
console.log(`Getters: ${contract.toolId}`);
|
|
@@ -28371,7 +28744,7 @@ function printToolGettersOnly(tool, requestedToolId) {
|
|
|
28371
28744
|
if (listGetters.length) {
|
|
28372
28745
|
console.log("Lists:");
|
|
28373
28746
|
for (const entry of listGetters) {
|
|
28374
|
-
if (
|
|
28747
|
+
if (isRecord11(entry))
|
|
28375
28748
|
console.log(
|
|
28376
28749
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
28377
28750
|
);
|
|
@@ -28380,7 +28753,7 @@ function printToolGettersOnly(tool, requestedToolId) {
|
|
|
28380
28753
|
if (valueGetters.length) {
|
|
28381
28754
|
console.log("Values:");
|
|
28382
28755
|
for (const entry of valueGetters) {
|
|
28383
|
-
if (
|
|
28756
|
+
if (isRecord11(entry))
|
|
28384
28757
|
console.log(
|
|
28385
28758
|
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
28386
28759
|
);
|
|
@@ -28406,7 +28779,7 @@ function sampleValueForField(field) {
|
|
|
28406
28779
|
function samplePayloadForInputFields(fields) {
|
|
28407
28780
|
return Object.fromEntries(
|
|
28408
28781
|
fields.slice(0, 4).flatMap((field) => {
|
|
28409
|
-
if (!
|
|
28782
|
+
if (!isRecord11(field)) return [];
|
|
28410
28783
|
const name = stringField2(field, "name");
|
|
28411
28784
|
if (!name) return [];
|
|
28412
28785
|
return [[name, sampleValueForField(field)]];
|
|
@@ -28524,12 +28897,12 @@ function formatListedToolCost(tool) {
|
|
|
28524
28897
|
}
|
|
28525
28898
|
function toolInputFieldsForDisplay(inputSchema) {
|
|
28526
28899
|
if (Array.isArray(inputSchema.fields))
|
|
28527
|
-
return inputSchema.fields.filter(
|
|
28528
|
-
const jsonSchema =
|
|
28529
|
-
const properties =
|
|
28900
|
+
return inputSchema.fields.filter(isRecord11);
|
|
28901
|
+
const jsonSchema = isRecord11(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
28902
|
+
const properties = isRecord11(jsonSchema.properties) ? jsonSchema.properties : {};
|
|
28530
28903
|
const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
|
|
28531
28904
|
return Object.entries(properties).map(([name, value]) => {
|
|
28532
|
-
const property =
|
|
28905
|
+
const property = isRecord11(value) ? value : {};
|
|
28533
28906
|
return {
|
|
28534
28907
|
name,
|
|
28535
28908
|
type: typeof property.type === "string" ? property.type : "unknown",
|
|
@@ -28540,10 +28913,10 @@ function toolInputFieldsForDisplay(inputSchema) {
|
|
|
28540
28913
|
});
|
|
28541
28914
|
}
|
|
28542
28915
|
function canonicalToolJsonSchema(inputSchema) {
|
|
28543
|
-
return
|
|
28916
|
+
return isRecord11(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
28544
28917
|
}
|
|
28545
28918
|
function declaredToolJsonSchema(inputSchema) {
|
|
28546
|
-
if (
|
|
28919
|
+
if (isRecord11(inputSchema.jsonSchema)) {
|
|
28547
28920
|
return inputSchema.jsonSchema;
|
|
28548
28921
|
}
|
|
28549
28922
|
return Array.isArray(inputSchema.fields) ? null : inputSchema;
|
|
@@ -28568,7 +28941,7 @@ function publicToolInputSchemaForDescribe(inputSchema) {
|
|
|
28568
28941
|
};
|
|
28569
28942
|
const stripDescriptions = (value) => {
|
|
28570
28943
|
if (Array.isArray(value)) return value.map(stripDescriptions);
|
|
28571
|
-
if (!
|
|
28944
|
+
if (!isRecord11(value)) return value;
|
|
28572
28945
|
return Object.fromEntries(
|
|
28573
28946
|
Object.entries(value).flatMap(([key, nested]) => {
|
|
28574
28947
|
if (key === "description" && typeof nested === "string" && exposesProviderSpend(nested)) {
|
|
@@ -28589,7 +28962,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
28589
28962
|
for (const item of value) collectSchemaIds(item);
|
|
28590
28963
|
return;
|
|
28591
28964
|
}
|
|
28592
|
-
if (!
|
|
28965
|
+
if (!isRecord11(value)) return;
|
|
28593
28966
|
if (typeof value.$id === "string" && value.$id.trim()) {
|
|
28594
28967
|
schemasById.set(value.$id.trim(), value);
|
|
28595
28968
|
}
|
|
@@ -28602,10 +28975,10 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
28602
28975
|
let current = root;
|
|
28603
28976
|
for (const rawSegment of ref.slice(2).split("/")) {
|
|
28604
28977
|
const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
28605
|
-
if (!
|
|
28978
|
+
if (!isRecord11(current)) return schema;
|
|
28606
28979
|
current = current[segment];
|
|
28607
28980
|
}
|
|
28608
|
-
return
|
|
28981
|
+
return isRecord11(current) ? current : schema;
|
|
28609
28982
|
};
|
|
28610
28983
|
const addField = (field) => {
|
|
28611
28984
|
const name = typeof field.name === "string" ? field.name : "";
|
|
@@ -28620,7 +28993,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
28620
28993
|
if (ref && activeRefs.has(ref)) return;
|
|
28621
28994
|
const schema = resolveRef(unresolvedSchema);
|
|
28622
28995
|
const nextActiveRefs = ref ? /* @__PURE__ */ new Set([...activeRefs, ref]) : activeRefs;
|
|
28623
|
-
const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type :
|
|
28996
|
+
const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type : isRecord11(schema.properties) ? "object" : schema.items ? "array" : "unknown";
|
|
28624
28997
|
if (path) {
|
|
28625
28998
|
addField({
|
|
28626
28999
|
name: path,
|
|
@@ -28631,12 +29004,12 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
28631
29004
|
...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
|
|
28632
29005
|
});
|
|
28633
29006
|
}
|
|
28634
|
-
const properties =
|
|
29007
|
+
const properties = isRecord11(schema.properties) ? schema.properties : {};
|
|
28635
29008
|
const requiredNames = new Set(
|
|
28636
29009
|
Array.isArray(schema.required) ? schema.required.map(String) : []
|
|
28637
29010
|
);
|
|
28638
29011
|
for (const [name, value] of Object.entries(properties)) {
|
|
28639
|
-
if (!
|
|
29012
|
+
if (!isRecord11(value)) continue;
|
|
28640
29013
|
visit(
|
|
28641
29014
|
value,
|
|
28642
29015
|
path ? `${path}.${name}` : name,
|
|
@@ -28644,13 +29017,13 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
|
28644
29017
|
nextActiveRefs
|
|
28645
29018
|
);
|
|
28646
29019
|
}
|
|
28647
|
-
if (
|
|
29020
|
+
if (isRecord11(schema.items)) {
|
|
28648
29021
|
visit(schema.items, `${path}[]`, false, nextActiveRefs);
|
|
28649
29022
|
}
|
|
28650
29023
|
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
28651
29024
|
const branches = Array.isArray(schema[keyword]) ? schema[keyword] : [];
|
|
28652
29025
|
for (const branch of branches) {
|
|
28653
|
-
if (
|
|
29026
|
+
if (isRecord11(branch)) {
|
|
28654
29027
|
visit(branch, path, required, nextActiveRefs);
|
|
28655
29028
|
}
|
|
28656
29029
|
}
|
|
@@ -28678,14 +29051,14 @@ function printJsonPreview(label, payload) {
|
|
|
28678
29051
|
}
|
|
28679
29052
|
function samplePayload(samples, key) {
|
|
28680
29053
|
const entry = samples[key];
|
|
28681
|
-
if (!
|
|
29054
|
+
if (!isRecord11(entry)) return void 0;
|
|
28682
29055
|
return Object.prototype.hasOwnProperty.call(entry, "payload") ? entry.payload : entry;
|
|
28683
29056
|
}
|
|
28684
29057
|
function commandEnvelopeFromRawResponse(rawResponse) {
|
|
28685
|
-
return
|
|
29058
|
+
return isRecord11(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
|
|
28686
29059
|
}
|
|
28687
29060
|
function apifySyncRecoveryNext(rawResponse) {
|
|
28688
|
-
if (!
|
|
29061
|
+
if (!isRecord11(rawResponse) || rawResponse.status !== "running") return null;
|
|
28689
29062
|
const toolResponse = recordField2(rawResponse, "toolResponse");
|
|
28690
29063
|
const raw = recordField2(toolResponse, "raw");
|
|
28691
29064
|
if (raw.state !== "awaiting_apify") return null;
|
|
@@ -28708,7 +29081,7 @@ function apifySyncRecoveryNext(rawResponse) {
|
|
|
28708
29081
|
}
|
|
28709
29082
|
function listExtractorPathsFromUsageGuidance(tool) {
|
|
28710
29083
|
const toolExecutionResult = tool.usageGuidance?.toolExecutionResult;
|
|
28711
|
-
const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists :
|
|
29084
|
+
const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord11(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
|
|
28712
29085
|
return extractedLists.flatMap((entry) => {
|
|
28713
29086
|
const paths = entry.details?.candidatePaths ?? entry.details?.rawToolOutputPaths;
|
|
28714
29087
|
if (!Array.isArray(paths)) return [];
|
|
@@ -28724,7 +29097,7 @@ function formatDecimal(value) {
|
|
|
28724
29097
|
function formatUsd(value) {
|
|
28725
29098
|
return `$${formatDecimal(value)}`;
|
|
28726
29099
|
}
|
|
28727
|
-
function
|
|
29100
|
+
function isRecord11(value) {
|
|
28728
29101
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
28729
29102
|
}
|
|
28730
29103
|
function stringField2(source, ...keys) {
|
|
@@ -28751,7 +29124,7 @@ function arrayField2(source, ...keys) {
|
|
|
28751
29124
|
function recordField2(source, ...keys) {
|
|
28752
29125
|
for (const key of keys) {
|
|
28753
29126
|
const value = source[key];
|
|
28754
|
-
if (
|
|
29127
|
+
if (isRecord11(value)) return value;
|
|
28755
29128
|
}
|
|
28756
29129
|
return {};
|
|
28757
29130
|
}
|
|
@@ -28817,7 +29190,7 @@ function parseJsonObjectArgument(raw, flagName) {
|
|
|
28817
29190
|
}
|
|
28818
29191
|
throw invalidJsonError(flagName, message);
|
|
28819
29192
|
}
|
|
28820
|
-
if (!
|
|
29193
|
+
if (!isRecord11(parsed)) {
|
|
28821
29194
|
throw invalidJsonError(flagName, "expected an object.");
|
|
28822
29195
|
}
|
|
28823
29196
|
return parsed;
|
|
@@ -28964,7 +29337,7 @@ function buildToolExecuteBaseEnvelope(input2) {
|
|
|
28964
29337
|
kind: summaryEntries.length > 0 ? "object" : "raw",
|
|
28965
29338
|
summary: input2.summary
|
|
28966
29339
|
};
|
|
28967
|
-
const envelopeHasCanonicalOutput =
|
|
29340
|
+
const envelopeHasCanonicalOutput = isRecord11(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
|
|
28968
29341
|
const envelopeHasDeclaredOutput = Object.prototype.hasOwnProperty.call(
|
|
28969
29342
|
envelope,
|
|
28970
29343
|
"output"
|
|
@@ -29194,7 +29567,7 @@ async function executeTool(args) {
|
|
|
29194
29567
|
{
|
|
29195
29568
|
...baseEnvelope,
|
|
29196
29569
|
local: {
|
|
29197
|
-
...
|
|
29570
|
+
...isRecord11(baseEnvelope.local) ? baseEnvelope.local : {},
|
|
29198
29571
|
payload_file: jsonPath
|
|
29199
29572
|
}
|
|
29200
29573
|
},
|