deepline 0.1.302 → 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/errors.ts +40 -22
- package/dist/bundling-sources/sdk/src/index.ts +9 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- 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/tool-execution-error.ts +132 -3
- package/dist/cli/index.js +56 -5
- package/dist/cli/index.mjs +56 -5
- package/dist/index.d.mts +32 -24
- package/dist/index.d.ts +32 -24
- package/dist/index.js +87 -22
- package/dist/index.mjs +87 -22
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/{tool-execution-error-9mH4i-mJ.d.mts → tool-execution-error-YDz7UMl-.d.mts} +127 -5
- package/dist/{tool-execution-error-9mH4i-mJ.d.ts → tool-execution-error-YDz7UMl-.d.ts} +127 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -42,33 +42,68 @@ function applyBrand(value, brand) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
var DeeplineError = class _DeeplineError extends Error {
|
|
45
|
+
/** HTTP status when the failure crossed an HTTP boundary. */
|
|
46
|
+
statusCode;
|
|
47
|
+
/** Stable machine-readable error code when one exists. */
|
|
48
|
+
code;
|
|
49
|
+
/** Local diagnostic context; not a portable error contract. */
|
|
50
|
+
details;
|
|
51
|
+
/**
|
|
52
|
+
* Construct a Deepline error.
|
|
53
|
+
*
|
|
54
|
+
* SDK and runtime code construct these errors. Application and Play code
|
|
55
|
+
* normally catches the public subclasses instead.
|
|
56
|
+
*
|
|
57
|
+
* @param message Human-readable failure summary.
|
|
58
|
+
* @param statusCode HTTP status when one exists.
|
|
59
|
+
* @param code Stable machine-readable code when one exists.
|
|
60
|
+
* @param details Local diagnostic context; never a portable error contract.
|
|
61
|
+
*/
|
|
45
62
|
constructor(message, statusCode, code, details) {
|
|
46
63
|
super(message);
|
|
64
|
+
this.name = "DeeplineError";
|
|
47
65
|
this.statusCode = statusCode;
|
|
48
66
|
this.code = code;
|
|
49
67
|
this.details = details;
|
|
50
|
-
this.name = "DeeplineError";
|
|
51
68
|
applyBrand(this, DEEPLINE_ERROR_BRAND);
|
|
52
69
|
}
|
|
53
|
-
statusCode;
|
|
54
|
-
code;
|
|
55
|
-
details;
|
|
56
70
|
static [Symbol.hasInstance](value) {
|
|
57
71
|
if (this !== _DeeplineError) return nativeInstanceOf(this, value);
|
|
58
72
|
return hasBrand(value, DEEPLINE_ERROR_BRAND);
|
|
59
73
|
}
|
|
60
74
|
};
|
|
61
75
|
var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
|
|
76
|
+
/** Public tool id passed to `tools.execute`. */
|
|
62
77
|
toolId;
|
|
78
|
+
/** Provider responsible for the operation, or `null` when unattributed. */
|
|
63
79
|
provider;
|
|
80
|
+
/** Provider operation name, or `null` when unavailable. */
|
|
64
81
|
operation;
|
|
82
|
+
/** Boundary responsible for the failure. */
|
|
65
83
|
origin;
|
|
84
|
+
/** Stable reason family for policy and diagnostics. */
|
|
66
85
|
category;
|
|
86
|
+
/**
|
|
87
|
+
* Whether repeating the same semantic call is delivery-safe.
|
|
88
|
+
*
|
|
89
|
+
* This does not mean the error may be ignored. Waterfall fallthrough is
|
|
90
|
+
* represented by `ProviderTransientError`.
|
|
91
|
+
*/
|
|
67
92
|
retryable;
|
|
93
|
+
/** Provider or Deepline request id, or `null` when unavailable. */
|
|
68
94
|
requestId;
|
|
95
|
+
/** Suggested same-call retry delay in milliseconds, or `null`. */
|
|
69
96
|
retryAfterMs;
|
|
97
|
+
/** Network failure kind, or `null` for non-network failures. */
|
|
70
98
|
networkKind;
|
|
99
|
+
/** Network boundary that failed, or `null` for non-network failures. */
|
|
71
100
|
networkScope;
|
|
101
|
+
/**
|
|
102
|
+
* Construct a structured tool error.
|
|
103
|
+
*
|
|
104
|
+
* Deepline constructs this from the versioned `tool_error` payload.
|
|
105
|
+
* Application and Play code should catch it rather than create it.
|
|
106
|
+
*/
|
|
72
107
|
constructor(message, options) {
|
|
73
108
|
super(
|
|
74
109
|
message,
|
|
@@ -104,7 +139,9 @@ function isProviderTransientFailure(input) {
|
|
|
104
139
|
return input.origin === "provider" && (input.category === "rate_limit" || input.category === "network" || input.category === "upstream");
|
|
105
140
|
}
|
|
106
141
|
var ProviderTransientError = class _ProviderTransientError extends ToolExecutionError {
|
|
142
|
+
/** Provider attribution is guaranteed for this subtype. */
|
|
107
143
|
origin = "provider";
|
|
144
|
+
/** Constructed by Deepline when a provider-owned transient failure arrives. */
|
|
108
145
|
constructor(message, options) {
|
|
109
146
|
super(message, {
|
|
110
147
|
...options,
|
|
@@ -258,6 +295,7 @@ function deserializeToolExecutionFailure(message, value, acceptedSchemaVersion)
|
|
|
258
295
|
|
|
259
296
|
// src/errors.ts
|
|
260
297
|
var AuthError = class extends DeeplineError {
|
|
298
|
+
/** Constructed by the SDK when Deepline rejects the caller's credentials. */
|
|
261
299
|
constructor(message = "Authentication failed. Check your DEEPLINE_API_KEY.") {
|
|
262
300
|
super(message, 401, "AUTH_ERROR");
|
|
263
301
|
this.name = "AuthError";
|
|
@@ -266,6 +304,7 @@ var AuthError = class extends DeeplineError {
|
|
|
266
304
|
var RateLimitError = class extends DeeplineError {
|
|
267
305
|
/** Milliseconds to wait before retrying, from the `Retry-After` response header. Defaults to 5000. */
|
|
268
306
|
retryAfterMs;
|
|
307
|
+
/** Constructed by the SDK after exhausting HTTP-level rate-limit retries. */
|
|
269
308
|
constructor(retryAfterMs = 5e3, message) {
|
|
270
309
|
super(
|
|
271
310
|
message ?? `Rate limited. Retry after ${retryAfterMs}ms.`,
|
|
@@ -277,16 +316,27 @@ var RateLimitError = class extends DeeplineError {
|
|
|
277
316
|
}
|
|
278
317
|
};
|
|
279
318
|
var ToolRateLimitError = class extends RateLimitError {
|
|
319
|
+
/** Public tool id passed to `tools.execute`. */
|
|
280
320
|
toolId;
|
|
321
|
+
/** Provider responsible for the operation, or `null`. */
|
|
281
322
|
provider;
|
|
323
|
+
/** Provider operation name, or `null`. */
|
|
282
324
|
operation;
|
|
325
|
+
/** Stable machine-readable failure code when one exists. */
|
|
283
326
|
code;
|
|
327
|
+
/** Boundary responsible for the failure. */
|
|
284
328
|
origin;
|
|
329
|
+
/** Stable reason family for policy and diagnostics. */
|
|
285
330
|
category;
|
|
331
|
+
/** Whether repeating the same semantic call is delivery-safe. */
|
|
286
332
|
retryable;
|
|
333
|
+
/** Provider or Deepline request id, or `null`. */
|
|
287
334
|
requestId;
|
|
335
|
+
/** Network failure kind, or `null` for non-network failures. */
|
|
288
336
|
networkKind;
|
|
337
|
+
/** Network boundary that failed, or `null` for non-network failures. */
|
|
289
338
|
networkScope;
|
|
339
|
+
/** Constructed by the SDK after a structured tool HTTP 429. */
|
|
290
340
|
constructor(message, options) {
|
|
291
341
|
super(options.retryAfterMs ?? 5e3, message);
|
|
292
342
|
this.name = "ToolRateLimitError";
|
|
@@ -309,6 +359,7 @@ var ToolRateLimitError = class extends RateLimitError {
|
|
|
309
359
|
}
|
|
310
360
|
};
|
|
311
361
|
var ConfigError = class extends DeeplineError {
|
|
362
|
+
/** Construct a local SDK configuration failure. */
|
|
312
363
|
constructor(message) {
|
|
313
364
|
super(message, void 0, "CONFIG_ERROR");
|
|
314
365
|
this.name = "ConfigError";
|
|
@@ -635,7 +686,7 @@ var SDK_RELEASE = {
|
|
|
635
686
|
// 0.1.253 makes play-page browser opening opt-in and retires --no-open.
|
|
636
687
|
// 0.1.254 removes the internal operations tree from the published SDK CLI.
|
|
637
688
|
// Operators use the checkout-local deepline-admin binary instead.
|
|
638
|
-
version: "0.1.
|
|
689
|
+
version: "0.1.303",
|
|
639
690
|
contracts: {
|
|
640
691
|
api: {
|
|
641
692
|
name: "sdk-http-api",
|
|
@@ -6080,6 +6131,11 @@ function normalizeTableNamespace(value) {
|
|
|
6080
6131
|
);
|
|
6081
6132
|
}
|
|
6082
6133
|
|
|
6134
|
+
// ../shared_libs/play-runtime/tool-result-paths.ts
|
|
6135
|
+
function listNameFromDeclaredPath(path) {
|
|
6136
|
+
return String(path || "").split(".").filter(Boolean).at(-1)?.replace(/[^A-Za-z0-9_$]/g, "") || null;
|
|
6137
|
+
}
|
|
6138
|
+
|
|
6083
6139
|
// ../shared_libs/play-runtime/tool-result.ts
|
|
6084
6140
|
var TARGET_FALLBACK_KEYS = {
|
|
6085
6141
|
email: [/^email$/i, /^address$/i, /email/i],
|
|
@@ -6420,38 +6476,33 @@ function coerceToEnum(value, descriptor) {
|
|
|
6420
6476
|
function resolveListRows(result, listExtractorPaths) {
|
|
6421
6477
|
const lists = {};
|
|
6422
6478
|
for (const rawPath of listExtractorPaths ?? []) {
|
|
6479
|
+
const listName = listNameFromDeclaredPath(rawPath);
|
|
6480
|
+
if (!listName) continue;
|
|
6423
6481
|
const path = normalizeResultPath(rawPath);
|
|
6424
6482
|
if (!path) continue;
|
|
6425
6483
|
const candidates = [...candidateResultPaths(rawPath)].filter(
|
|
6426
6484
|
(candidate, index, all) => candidate && all.indexOf(candidate) === index
|
|
6427
6485
|
);
|
|
6428
|
-
let
|
|
6429
|
-
let rows = null;
|
|
6486
|
+
let resolved = null;
|
|
6430
6487
|
let emptyMatch = null;
|
|
6431
6488
|
for (const candidate of candidates) {
|
|
6432
|
-
|
|
6433
|
-
if (!
|
|
6489
|
+
const candidateRows = normalizeRows(getAtPath(result, candidate));
|
|
6490
|
+
if (!candidateRows) {
|
|
6434
6491
|
continue;
|
|
6435
6492
|
}
|
|
6436
|
-
if (
|
|
6437
|
-
|
|
6493
|
+
if (candidateRows.length > 0) {
|
|
6494
|
+
resolved = { path: candidate, rows: candidateRows };
|
|
6438
6495
|
break;
|
|
6439
6496
|
}
|
|
6440
|
-
emptyMatch ??= { path: candidate, rows };
|
|
6441
|
-
}
|
|
6442
|
-
if (!rows && emptyMatch) {
|
|
6443
|
-
resolvedPath = emptyMatch.path;
|
|
6444
|
-
rows = emptyMatch.rows;
|
|
6497
|
+
emptyMatch ??= { path: candidate, rows: candidateRows };
|
|
6445
6498
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
const name = storedPath.split(".").filter(Boolean).at(-1)?.replace(/\[\d+\]$/, "");
|
|
6449
|
-
const listName = name || storedPath;
|
|
6499
|
+
resolved ??= emptyMatch;
|
|
6500
|
+
if (!resolved) continue;
|
|
6450
6501
|
const existing = lists[listName];
|
|
6451
|
-
if (existing?.rows.length && rows.length === 0) {
|
|
6502
|
+
if (existing?.rows.length && resolved.rows.length === 0) {
|
|
6452
6503
|
continue;
|
|
6453
6504
|
}
|
|
6454
|
-
lists[listName] =
|
|
6505
|
+
lists[listName] = resolved;
|
|
6455
6506
|
}
|
|
6456
6507
|
return lists;
|
|
6457
6508
|
}
|
|
@@ -6685,6 +6736,7 @@ function createToolExecuteResult(input) {
|
|
|
6685
6736
|
toolId: input.metadata.toolId,
|
|
6686
6737
|
execution: input.execution,
|
|
6687
6738
|
targets,
|
|
6739
|
+
listExtractorPaths: [...input.metadata.listExtractorPaths ?? []],
|
|
6688
6740
|
...input.metadata.extractors ? { extractors: input.metadata.extractors } : {},
|
|
6689
6741
|
lists
|
|
6690
6742
|
};
|
|
@@ -6726,6 +6778,19 @@ function attachToolResultListDataset(result, input) {
|
|
|
6726
6778
|
count: input.count,
|
|
6727
6779
|
keys: input.keys ?? existing?.keys ?? {}
|
|
6728
6780
|
};
|
|
6781
|
+
const declaredPaths = result._metadata.listExtractorPaths ?? [];
|
|
6782
|
+
const inputCandidates = new Set(candidateResultPaths(input.path));
|
|
6783
|
+
const equivalentDeclaration = declaredPaths.find(
|
|
6784
|
+
(path) => candidateResultPaths(path).some(
|
|
6785
|
+
(candidate) => inputCandidates.has(candidate)
|
|
6786
|
+
)
|
|
6787
|
+
);
|
|
6788
|
+
result._metadata.listExtractorPaths = equivalentDeclaration ? [...declaredPaths] : [
|
|
6789
|
+
...declaredPaths.filter(
|
|
6790
|
+
(path) => listNameFromDeclaredPath(path) !== input.name
|
|
6791
|
+
),
|
|
6792
|
+
input.path
|
|
6793
|
+
];
|
|
6729
6794
|
const accessor = {
|
|
6730
6795
|
path: input.path,
|
|
6731
6796
|
count: input.count,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as ToolExecutionErrorSchemaVersion, P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../tool-execution-error-
|
|
2
|
-
export { b as PLAY_ARTIFACT_KINDS } from '../tool-execution-error-
|
|
1
|
+
import { T as ToolExecutionErrorSchemaVersion, P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../tool-execution-error-YDz7UMl-.mjs';
|
|
2
|
+
export { b as PLAY_ARTIFACT_KINDS } from '../tool-execution-error-YDz7UMl-.mjs';
|
|
3
3
|
|
|
4
4
|
type PlayPackageImport = {
|
|
5
5
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as ToolExecutionErrorSchemaVersion, P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../tool-execution-error-
|
|
2
|
-
export { b as PLAY_ARTIFACT_KINDS } from '../tool-execution-error-
|
|
1
|
+
import { T as ToolExecutionErrorSchemaVersion, P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../tool-execution-error-YDz7UMl-.js';
|
|
2
|
+
export { b as PLAY_ARTIFACT_KINDS } from '../tool-execution-error-YDz7UMl-.js';
|
|
3
3
|
|
|
4
4
|
type PlayPackageImport = {
|
|
5
5
|
name: string;
|
|
@@ -240,25 +240,89 @@ type PlayCompilerManifest = {
|
|
|
240
240
|
declare const TOOL_EXECUTION_ERROR_SCHEMA_VERSION: 1;
|
|
241
241
|
declare const SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS: readonly [0, 1];
|
|
242
242
|
type ToolExecutionErrorSchemaVersion = (typeof SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS)[number];
|
|
243
|
+
/**
|
|
244
|
+
* The boundary responsible for a failed tool call.
|
|
245
|
+
*
|
|
246
|
+
* Use `provider` to distinguish a provider answer from caller input and
|
|
247
|
+
* Deepline infrastructure. `unknown` fails closed and must not trigger a
|
|
248
|
+
* waterfall fallback.
|
|
249
|
+
*
|
|
250
|
+
* @sdkReference errors 020
|
|
251
|
+
*/
|
|
243
252
|
type ToolExecutionErrorOrigin = 'caller' | 'provider' | 'deepline' | 'unknown';
|
|
253
|
+
/**
|
|
254
|
+
* The stable reason family for a failed tool call.
|
|
255
|
+
*
|
|
256
|
+
* Branch on this field only after narrowing to `ToolExecutionError`. Catch
|
|
257
|
+
* `ProviderTransientError` when the policy is simply “try the next read
|
|
258
|
+
* provider”; it is the safer and shorter waterfall contract.
|
|
259
|
+
*
|
|
260
|
+
* @sdkReference errors 030
|
|
261
|
+
*/
|
|
244
262
|
type ToolExecutionErrorCategory = 'validation' | 'authentication' | 'authorization' | 'rate_limit' | 'network' | 'upstream' | 'billing' | 'conflict' | 'internal' | 'unknown';
|
|
263
|
+
/**
|
|
264
|
+
* The transport failure observed when `category` is `network`.
|
|
265
|
+
*
|
|
266
|
+
* This is `null` for failures that are not network failures.
|
|
267
|
+
*
|
|
268
|
+
* @sdkReference errors 040
|
|
269
|
+
*/
|
|
245
270
|
type ToolExecutionNetworkKind = 'timeout' | 'dns' | 'connect' | 'reset' | 'unavailable' | 'unknown';
|
|
271
|
+
/**
|
|
272
|
+
* The request boundary on which a network failure occurred.
|
|
273
|
+
*
|
|
274
|
+
* `deepline_to_provider` is provider-side. Client and runtime scopes are
|
|
275
|
+
* Deepline transport failures and never qualify as provider fallthrough.
|
|
276
|
+
*
|
|
277
|
+
* @sdkReference errors 050
|
|
278
|
+
*/
|
|
246
279
|
type ToolExecutionNetworkScope = 'client_to_deepline' | 'runtime_to_deepline' | 'deepline_to_provider';
|
|
280
|
+
/**
|
|
281
|
+
* Portable version-1 `tool_error` payload.
|
|
282
|
+
*
|
|
283
|
+
* This allowlisted shape crosses the API, runtime, and SDK boundaries.
|
|
284
|
+
* `message` remains on the Error object and is deliberately not a policy
|
|
285
|
+
* field.
|
|
286
|
+
*
|
|
287
|
+
* @sdkReference errors 064
|
|
288
|
+
*/
|
|
247
289
|
type ToolExecutionFailureV1 = {
|
|
290
|
+
/** Payload version. */
|
|
248
291
|
schemaVersion: typeof TOOL_EXECUTION_ERROR_SCHEMA_VERSION;
|
|
292
|
+
/** Public tool id passed to `tools.execute`. */
|
|
249
293
|
toolId: string;
|
|
294
|
+
/** Provider responsible for the operation, or `null`. */
|
|
250
295
|
provider: string | null;
|
|
296
|
+
/** Provider operation name, or `null`. */
|
|
251
297
|
operation: string | null;
|
|
298
|
+
/** Stable machine-readable failure code, or `null`. */
|
|
252
299
|
code: string | null;
|
|
300
|
+
/** Boundary responsible for the failure. */
|
|
253
301
|
origin: ToolExecutionErrorOrigin;
|
|
302
|
+
/** Stable reason family. */
|
|
254
303
|
category: ToolExecutionErrorCategory;
|
|
304
|
+
/** Whether repeating the same semantic call is delivery-safe. */
|
|
255
305
|
retryable: boolean;
|
|
306
|
+
/** HTTP status when one exists, or `null`. */
|
|
256
307
|
statusCode: number | null;
|
|
308
|
+
/** Provider or Deepline request id, or `null`. */
|
|
257
309
|
requestId: string | null;
|
|
310
|
+
/** Suggested same-call retry delay in milliseconds, or `null`. */
|
|
258
311
|
retryAfterMs: number | null;
|
|
312
|
+
/** Network failure kind, or `null`. */
|
|
259
313
|
networkKind: ToolExecutionNetworkKind | null;
|
|
314
|
+
/** Network boundary that failed, or `null`. */
|
|
260
315
|
networkScope: ToolExecutionNetworkScope | null;
|
|
261
316
|
};
|
|
317
|
+
/**
|
|
318
|
+
* Constructor input for a structured tool failure.
|
|
319
|
+
*
|
|
320
|
+
* Deepline creates these values while decoding the versioned wire payload.
|
|
321
|
+
* Customer code normally reads `ToolExecutionError` fields instead of
|
|
322
|
+
* constructing an error.
|
|
323
|
+
*
|
|
324
|
+
* @sdkReference errors 065
|
|
325
|
+
*/
|
|
262
326
|
type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> & {
|
|
263
327
|
/**
|
|
264
328
|
* Local diagnostic context inherited from DeeplineError. This is not part of
|
|
@@ -266,18 +330,40 @@ type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> &
|
|
|
266
330
|
*/
|
|
267
331
|
details?: Record<string, unknown>;
|
|
268
332
|
};
|
|
333
|
+
/**
|
|
334
|
+
* Provider-owned failure categories that may fall through to another read
|
|
335
|
+
* provider.
|
|
336
|
+
*
|
|
337
|
+
* @sdkReference errors 060
|
|
338
|
+
*/
|
|
269
339
|
type ProviderTransientErrorCategory = 'rate_limit' | 'network' | 'upstream';
|
|
270
340
|
/**
|
|
271
341
|
* Base error class shared by the SDK and play runtime.
|
|
272
342
|
*
|
|
273
343
|
* The global brand preserves `instanceof DeeplineError` when a bundled play
|
|
274
344
|
* and the runtime load separate physical copies of this module.
|
|
345
|
+
*
|
|
346
|
+
* @sdkReference errors 010
|
|
275
347
|
*/
|
|
276
348
|
declare class DeeplineError extends Error {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
349
|
+
/** HTTP status when the failure crossed an HTTP boundary. */
|
|
350
|
+
statusCode?: number;
|
|
351
|
+
/** Stable machine-readable error code when one exists. */
|
|
352
|
+
code?: string;
|
|
353
|
+
/** Local diagnostic context; not a portable error contract. */
|
|
354
|
+
details?: Record<string, unknown>;
|
|
355
|
+
/**
|
|
356
|
+
* Construct a Deepline error.
|
|
357
|
+
*
|
|
358
|
+
* SDK and runtime code construct these errors. Application and Play code
|
|
359
|
+
* normally catches the public subclasses instead.
|
|
360
|
+
*
|
|
361
|
+
* @param message Human-readable failure summary.
|
|
362
|
+
* @param statusCode HTTP status when one exists.
|
|
363
|
+
* @param code Stable machine-readable code when one exists.
|
|
364
|
+
* @param details Local diagnostic context; never a portable error contract.
|
|
365
|
+
*/
|
|
366
|
+
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>);
|
|
281
367
|
static [Symbol.hasInstance](value: unknown): boolean;
|
|
282
368
|
}
|
|
283
369
|
/**
|
|
@@ -286,18 +372,45 @@ declare class DeeplineError extends Error {
|
|
|
286
372
|
* `retryable` means Deepline's delivery/idempotency contract says it is safe
|
|
287
373
|
* to repeat the same semantic call. It does not describe durable receipt
|
|
288
374
|
* repairability and does not make arbitrary side-effecting fallbacks safe.
|
|
375
|
+
*
|
|
376
|
+
* In a Play, catch `ProviderTransientError` to continue a read waterfall and
|
|
377
|
+
* let every other `ToolExecutionError` remain loud. In an SDK client, catch
|
|
378
|
+
* this base class when you need structured diagnostics for every tool failure.
|
|
379
|
+
*
|
|
380
|
+
* @sdkReference errors 070
|
|
289
381
|
*/
|
|
290
382
|
declare class ToolExecutionError extends DeeplineError {
|
|
383
|
+
/** Public tool id passed to `tools.execute`. */
|
|
291
384
|
readonly toolId: string;
|
|
385
|
+
/** Provider responsible for the operation, or `null` when unattributed. */
|
|
292
386
|
readonly provider: string | null;
|
|
387
|
+
/** Provider operation name, or `null` when unavailable. */
|
|
293
388
|
readonly operation: string | null;
|
|
389
|
+
/** Boundary responsible for the failure. */
|
|
294
390
|
readonly origin: ToolExecutionErrorOrigin;
|
|
391
|
+
/** Stable reason family for policy and diagnostics. */
|
|
295
392
|
readonly category: ToolExecutionErrorCategory;
|
|
393
|
+
/**
|
|
394
|
+
* Whether repeating the same semantic call is delivery-safe.
|
|
395
|
+
*
|
|
396
|
+
* This does not mean the error may be ignored. Waterfall fallthrough is
|
|
397
|
+
* represented by `ProviderTransientError`.
|
|
398
|
+
*/
|
|
296
399
|
readonly retryable: boolean;
|
|
400
|
+
/** Provider or Deepline request id, or `null` when unavailable. */
|
|
297
401
|
readonly requestId: string | null;
|
|
402
|
+
/** Suggested same-call retry delay in milliseconds, or `null`. */
|
|
298
403
|
readonly retryAfterMs: number | null;
|
|
404
|
+
/** Network failure kind, or `null` for non-network failures. */
|
|
299
405
|
readonly networkKind: ToolExecutionNetworkKind | null;
|
|
406
|
+
/** Network boundary that failed, or `null` for non-network failures. */
|
|
300
407
|
readonly networkScope: ToolExecutionNetworkScope | null;
|
|
408
|
+
/**
|
|
409
|
+
* Construct a structured tool error.
|
|
410
|
+
*
|
|
411
|
+
* Deepline constructs this from the versioned `tool_error` payload.
|
|
412
|
+
* Application and Play code should catch it rather than create it.
|
|
413
|
+
*/
|
|
301
414
|
constructor(message: string, options: ToolExecutionErrorOptions);
|
|
302
415
|
static [Symbol.hasInstance](value: unknown): boolean;
|
|
303
416
|
}
|
|
@@ -305,14 +418,23 @@ declare class ToolExecutionError extends DeeplineError {
|
|
|
305
418
|
* A provider-owned transient failure that is safe to handle as an empty
|
|
306
419
|
* waterfall leg. Validation, auth, billing, Deepline, and unknown failures
|
|
307
420
|
* never satisfy this type.
|
|
421
|
+
*
|
|
422
|
+
* `retryable` remains independent: it says whether the same semantic call may
|
|
423
|
+
* be repeated safely. Falling through to a different read provider depends on
|
|
424
|
+
* this class, not on `retryable`.
|
|
425
|
+
*
|
|
426
|
+
* @sdkReference errors 080
|
|
308
427
|
*/
|
|
309
428
|
declare class ProviderTransientError extends ToolExecutionError {
|
|
429
|
+
/** Provider attribution is guaranteed for this subtype. */
|
|
310
430
|
readonly origin: "provider";
|
|
431
|
+
/** Provider failure category that made this error eligible for fallthrough. */
|
|
311
432
|
readonly category: ProviderTransientErrorCategory;
|
|
433
|
+
/** Constructed by Deepline when a provider-owned transient failure arrives. */
|
|
312
434
|
constructor(message: string, options: Omit<ToolExecutionErrorOptions, 'origin' | 'category'> & {
|
|
313
435
|
category: ProviderTransientErrorCategory;
|
|
314
436
|
});
|
|
315
437
|
static [Symbol.hasInstance](value: unknown): boolean;
|
|
316
438
|
}
|
|
317
439
|
|
|
318
|
-
export { DeeplineError as D, type PlayArtifactKind as P, type ToolExecutionErrorSchemaVersion as T, type PlayCompilerManifest as a, PLAY_ARTIFACT_KINDS as b, ToolExecutionError as c, type ToolExecutionErrorOptions as d, ProviderTransientError as e };
|
|
440
|
+
export { DeeplineError as D, type PlayArtifactKind as P, type ToolExecutionErrorSchemaVersion as T, type PlayCompilerManifest as a, PLAY_ARTIFACT_KINDS as b, ToolExecutionError as c, type ToolExecutionErrorOptions as d, ProviderTransientError as e, type ProviderTransientErrorCategory as f, type ToolExecutionErrorCategory as g, type ToolExecutionErrorOrigin as h, type ToolExecutionFailureV1 as i, type ToolExecutionNetworkKind as j, type ToolExecutionNetworkScope as k };
|
|
@@ -240,25 +240,89 @@ type PlayCompilerManifest = {
|
|
|
240
240
|
declare const TOOL_EXECUTION_ERROR_SCHEMA_VERSION: 1;
|
|
241
241
|
declare const SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS: readonly [0, 1];
|
|
242
242
|
type ToolExecutionErrorSchemaVersion = (typeof SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS)[number];
|
|
243
|
+
/**
|
|
244
|
+
* The boundary responsible for a failed tool call.
|
|
245
|
+
*
|
|
246
|
+
* Use `provider` to distinguish a provider answer from caller input and
|
|
247
|
+
* Deepline infrastructure. `unknown` fails closed and must not trigger a
|
|
248
|
+
* waterfall fallback.
|
|
249
|
+
*
|
|
250
|
+
* @sdkReference errors 020
|
|
251
|
+
*/
|
|
243
252
|
type ToolExecutionErrorOrigin = 'caller' | 'provider' | 'deepline' | 'unknown';
|
|
253
|
+
/**
|
|
254
|
+
* The stable reason family for a failed tool call.
|
|
255
|
+
*
|
|
256
|
+
* Branch on this field only after narrowing to `ToolExecutionError`. Catch
|
|
257
|
+
* `ProviderTransientError` when the policy is simply “try the next read
|
|
258
|
+
* provider”; it is the safer and shorter waterfall contract.
|
|
259
|
+
*
|
|
260
|
+
* @sdkReference errors 030
|
|
261
|
+
*/
|
|
244
262
|
type ToolExecutionErrorCategory = 'validation' | 'authentication' | 'authorization' | 'rate_limit' | 'network' | 'upstream' | 'billing' | 'conflict' | 'internal' | 'unknown';
|
|
263
|
+
/**
|
|
264
|
+
* The transport failure observed when `category` is `network`.
|
|
265
|
+
*
|
|
266
|
+
* This is `null` for failures that are not network failures.
|
|
267
|
+
*
|
|
268
|
+
* @sdkReference errors 040
|
|
269
|
+
*/
|
|
245
270
|
type ToolExecutionNetworkKind = 'timeout' | 'dns' | 'connect' | 'reset' | 'unavailable' | 'unknown';
|
|
271
|
+
/**
|
|
272
|
+
* The request boundary on which a network failure occurred.
|
|
273
|
+
*
|
|
274
|
+
* `deepline_to_provider` is provider-side. Client and runtime scopes are
|
|
275
|
+
* Deepline transport failures and never qualify as provider fallthrough.
|
|
276
|
+
*
|
|
277
|
+
* @sdkReference errors 050
|
|
278
|
+
*/
|
|
246
279
|
type ToolExecutionNetworkScope = 'client_to_deepline' | 'runtime_to_deepline' | 'deepline_to_provider';
|
|
280
|
+
/**
|
|
281
|
+
* Portable version-1 `tool_error` payload.
|
|
282
|
+
*
|
|
283
|
+
* This allowlisted shape crosses the API, runtime, and SDK boundaries.
|
|
284
|
+
* `message` remains on the Error object and is deliberately not a policy
|
|
285
|
+
* field.
|
|
286
|
+
*
|
|
287
|
+
* @sdkReference errors 064
|
|
288
|
+
*/
|
|
247
289
|
type ToolExecutionFailureV1 = {
|
|
290
|
+
/** Payload version. */
|
|
248
291
|
schemaVersion: typeof TOOL_EXECUTION_ERROR_SCHEMA_VERSION;
|
|
292
|
+
/** Public tool id passed to `tools.execute`. */
|
|
249
293
|
toolId: string;
|
|
294
|
+
/** Provider responsible for the operation, or `null`. */
|
|
250
295
|
provider: string | null;
|
|
296
|
+
/** Provider operation name, or `null`. */
|
|
251
297
|
operation: string | null;
|
|
298
|
+
/** Stable machine-readable failure code, or `null`. */
|
|
252
299
|
code: string | null;
|
|
300
|
+
/** Boundary responsible for the failure. */
|
|
253
301
|
origin: ToolExecutionErrorOrigin;
|
|
302
|
+
/** Stable reason family. */
|
|
254
303
|
category: ToolExecutionErrorCategory;
|
|
304
|
+
/** Whether repeating the same semantic call is delivery-safe. */
|
|
255
305
|
retryable: boolean;
|
|
306
|
+
/** HTTP status when one exists, or `null`. */
|
|
256
307
|
statusCode: number | null;
|
|
308
|
+
/** Provider or Deepline request id, or `null`. */
|
|
257
309
|
requestId: string | null;
|
|
310
|
+
/** Suggested same-call retry delay in milliseconds, or `null`. */
|
|
258
311
|
retryAfterMs: number | null;
|
|
312
|
+
/** Network failure kind, or `null`. */
|
|
259
313
|
networkKind: ToolExecutionNetworkKind | null;
|
|
314
|
+
/** Network boundary that failed, or `null`. */
|
|
260
315
|
networkScope: ToolExecutionNetworkScope | null;
|
|
261
316
|
};
|
|
317
|
+
/**
|
|
318
|
+
* Constructor input for a structured tool failure.
|
|
319
|
+
*
|
|
320
|
+
* Deepline creates these values while decoding the versioned wire payload.
|
|
321
|
+
* Customer code normally reads `ToolExecutionError` fields instead of
|
|
322
|
+
* constructing an error.
|
|
323
|
+
*
|
|
324
|
+
* @sdkReference errors 065
|
|
325
|
+
*/
|
|
262
326
|
type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> & {
|
|
263
327
|
/**
|
|
264
328
|
* Local diagnostic context inherited from DeeplineError. This is not part of
|
|
@@ -266,18 +330,40 @@ type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> &
|
|
|
266
330
|
*/
|
|
267
331
|
details?: Record<string, unknown>;
|
|
268
332
|
};
|
|
333
|
+
/**
|
|
334
|
+
* Provider-owned failure categories that may fall through to another read
|
|
335
|
+
* provider.
|
|
336
|
+
*
|
|
337
|
+
* @sdkReference errors 060
|
|
338
|
+
*/
|
|
269
339
|
type ProviderTransientErrorCategory = 'rate_limit' | 'network' | 'upstream';
|
|
270
340
|
/**
|
|
271
341
|
* Base error class shared by the SDK and play runtime.
|
|
272
342
|
*
|
|
273
343
|
* The global brand preserves `instanceof DeeplineError` when a bundled play
|
|
274
344
|
* and the runtime load separate physical copies of this module.
|
|
345
|
+
*
|
|
346
|
+
* @sdkReference errors 010
|
|
275
347
|
*/
|
|
276
348
|
declare class DeeplineError extends Error {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
349
|
+
/** HTTP status when the failure crossed an HTTP boundary. */
|
|
350
|
+
statusCode?: number;
|
|
351
|
+
/** Stable machine-readable error code when one exists. */
|
|
352
|
+
code?: string;
|
|
353
|
+
/** Local diagnostic context; not a portable error contract. */
|
|
354
|
+
details?: Record<string, unknown>;
|
|
355
|
+
/**
|
|
356
|
+
* Construct a Deepline error.
|
|
357
|
+
*
|
|
358
|
+
* SDK and runtime code construct these errors. Application and Play code
|
|
359
|
+
* normally catches the public subclasses instead.
|
|
360
|
+
*
|
|
361
|
+
* @param message Human-readable failure summary.
|
|
362
|
+
* @param statusCode HTTP status when one exists.
|
|
363
|
+
* @param code Stable machine-readable code when one exists.
|
|
364
|
+
* @param details Local diagnostic context; never a portable error contract.
|
|
365
|
+
*/
|
|
366
|
+
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>);
|
|
281
367
|
static [Symbol.hasInstance](value: unknown): boolean;
|
|
282
368
|
}
|
|
283
369
|
/**
|
|
@@ -286,18 +372,45 @@ declare class DeeplineError extends Error {
|
|
|
286
372
|
* `retryable` means Deepline's delivery/idempotency contract says it is safe
|
|
287
373
|
* to repeat the same semantic call. It does not describe durable receipt
|
|
288
374
|
* repairability and does not make arbitrary side-effecting fallbacks safe.
|
|
375
|
+
*
|
|
376
|
+
* In a Play, catch `ProviderTransientError` to continue a read waterfall and
|
|
377
|
+
* let every other `ToolExecutionError` remain loud. In an SDK client, catch
|
|
378
|
+
* this base class when you need structured diagnostics for every tool failure.
|
|
379
|
+
*
|
|
380
|
+
* @sdkReference errors 070
|
|
289
381
|
*/
|
|
290
382
|
declare class ToolExecutionError extends DeeplineError {
|
|
383
|
+
/** Public tool id passed to `tools.execute`. */
|
|
291
384
|
readonly toolId: string;
|
|
385
|
+
/** Provider responsible for the operation, or `null` when unattributed. */
|
|
292
386
|
readonly provider: string | null;
|
|
387
|
+
/** Provider operation name, or `null` when unavailable. */
|
|
293
388
|
readonly operation: string | null;
|
|
389
|
+
/** Boundary responsible for the failure. */
|
|
294
390
|
readonly origin: ToolExecutionErrorOrigin;
|
|
391
|
+
/** Stable reason family for policy and diagnostics. */
|
|
295
392
|
readonly category: ToolExecutionErrorCategory;
|
|
393
|
+
/**
|
|
394
|
+
* Whether repeating the same semantic call is delivery-safe.
|
|
395
|
+
*
|
|
396
|
+
* This does not mean the error may be ignored. Waterfall fallthrough is
|
|
397
|
+
* represented by `ProviderTransientError`.
|
|
398
|
+
*/
|
|
296
399
|
readonly retryable: boolean;
|
|
400
|
+
/** Provider or Deepline request id, or `null` when unavailable. */
|
|
297
401
|
readonly requestId: string | null;
|
|
402
|
+
/** Suggested same-call retry delay in milliseconds, or `null`. */
|
|
298
403
|
readonly retryAfterMs: number | null;
|
|
404
|
+
/** Network failure kind, or `null` for non-network failures. */
|
|
299
405
|
readonly networkKind: ToolExecutionNetworkKind | null;
|
|
406
|
+
/** Network boundary that failed, or `null` for non-network failures. */
|
|
300
407
|
readonly networkScope: ToolExecutionNetworkScope | null;
|
|
408
|
+
/**
|
|
409
|
+
* Construct a structured tool error.
|
|
410
|
+
*
|
|
411
|
+
* Deepline constructs this from the versioned `tool_error` payload.
|
|
412
|
+
* Application and Play code should catch it rather than create it.
|
|
413
|
+
*/
|
|
301
414
|
constructor(message: string, options: ToolExecutionErrorOptions);
|
|
302
415
|
static [Symbol.hasInstance](value: unknown): boolean;
|
|
303
416
|
}
|
|
@@ -305,14 +418,23 @@ declare class ToolExecutionError extends DeeplineError {
|
|
|
305
418
|
* A provider-owned transient failure that is safe to handle as an empty
|
|
306
419
|
* waterfall leg. Validation, auth, billing, Deepline, and unknown failures
|
|
307
420
|
* never satisfy this type.
|
|
421
|
+
*
|
|
422
|
+
* `retryable` remains independent: it says whether the same semantic call may
|
|
423
|
+
* be repeated safely. Falling through to a different read provider depends on
|
|
424
|
+
* this class, not on `retryable`.
|
|
425
|
+
*
|
|
426
|
+
* @sdkReference errors 080
|
|
308
427
|
*/
|
|
309
428
|
declare class ProviderTransientError extends ToolExecutionError {
|
|
429
|
+
/** Provider attribution is guaranteed for this subtype. */
|
|
310
430
|
readonly origin: "provider";
|
|
431
|
+
/** Provider failure category that made this error eligible for fallthrough. */
|
|
311
432
|
readonly category: ProviderTransientErrorCategory;
|
|
433
|
+
/** Constructed by Deepline when a provider-owned transient failure arrives. */
|
|
312
434
|
constructor(message: string, options: Omit<ToolExecutionErrorOptions, 'origin' | 'category'> & {
|
|
313
435
|
category: ProviderTransientErrorCategory;
|
|
314
436
|
});
|
|
315
437
|
static [Symbol.hasInstance](value: unknown): boolean;
|
|
316
438
|
}
|
|
317
439
|
|
|
318
|
-
export { DeeplineError as D, type PlayArtifactKind as P, type ToolExecutionErrorSchemaVersion as T, type PlayCompilerManifest as a, PLAY_ARTIFACT_KINDS as b, ToolExecutionError as c, type ToolExecutionErrorOptions as d, ProviderTransientError as e };
|
|
440
|
+
export { DeeplineError as D, type PlayArtifactKind as P, type ToolExecutionErrorSchemaVersion as T, type PlayCompilerManifest as a, PLAY_ARTIFACT_KINDS as b, ToolExecutionError as c, type ToolExecutionErrorOptions as d, ProviderTransientError as e, type ProviderTransientErrorCategory as f, type ToolExecutionErrorCategory as g, type ToolExecutionErrorOrigin as h, type ToolExecutionFailureV1 as i, type ToolExecutionNetworkKind as j, type ToolExecutionNetworkScope as k };
|