deepline 0.1.32 → 0.1.35
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/README.md +33 -20
- package/dist/cli/index.js +1117 -381
- package/dist/cli/index.mjs +1058 -322
- package/dist/index.d.mts +131 -85
- package/dist/index.d.ts +131 -85
- package/dist/index.js +569 -124
- package/dist/index.mjs +570 -125
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +212 -1
- package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +129 -2
- package/dist/repo/apps/play-runner-workers/src/entry.ts +147 -64
- package/dist/repo/apps/play-runner-workers/src/workflow-retry.ts +50 -0
- package/dist/repo/sdk/src/client.ts +46 -33
- package/dist/repo/sdk/src/config.ts +109 -233
- package/dist/repo/sdk/src/http.ts +44 -4
- package/dist/repo/sdk/src/index.ts +8 -5
- package/dist/repo/sdk/src/play.ts +124 -45
- package/dist/repo/sdk/src/plays/harness-stub.ts +2 -2
- package/dist/repo/sdk/src/tool-output.ts +26 -7
- package/dist/repo/sdk/src/types.ts +48 -12
- package/dist/repo/sdk/src/version.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/run-failure.ts +49 -0
- package/dist/repo/shared_libs/play-runtime/scheduler-backend.ts +1 -1
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +138 -35
- package/package.json +1 -1
|
@@ -38,6 +38,64 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
38
38
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export type V2ToolExecuteOutput = {
|
|
42
|
+
raw: unknown;
|
|
43
|
+
meta?: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function parseV2ToolExecuteOutput(
|
|
47
|
+
data: Record<string, unknown>,
|
|
48
|
+
): V2ToolExecuteOutput | null {
|
|
49
|
+
const toolExecutionResult = data.toolExecutionResult;
|
|
50
|
+
if (!isRecord(toolExecutionResult)) return null;
|
|
51
|
+
const toolOutput = toolExecutionResult.toolOutput;
|
|
52
|
+
if (!isRecord(toolOutput)) return null;
|
|
53
|
+
const meta = isRecord(toolOutput.meta) ? toolOutput.meta : undefined;
|
|
54
|
+
return {
|
|
55
|
+
raw: Object.prototype.hasOwnProperty.call(toolOutput, 'raw')
|
|
56
|
+
? toolOutput.raw
|
|
57
|
+
: null,
|
|
58
|
+
...(meta ? { meta } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function adaptV2ExecuteResponseToToolResult(
|
|
63
|
+
data: Record<string, unknown>,
|
|
64
|
+
): { output?: V2ToolExecuteOutput; result: unknown } {
|
|
65
|
+
const output = parseV2ToolExecuteOutput(data);
|
|
66
|
+
if (!output) {
|
|
67
|
+
return { result: data.result ?? data };
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
output,
|
|
71
|
+
result: {
|
|
72
|
+
data: output.raw,
|
|
73
|
+
...(output.meta ? { meta: output.meta } : {}),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function toV2RawToolOutputPath(path: string): string {
|
|
79
|
+
const normalized = String(path || '')
|
|
80
|
+
.trim()
|
|
81
|
+
.replace(/^\./, '');
|
|
82
|
+
if (!normalized) return 'toolExecutionResult.toolOutput.raw';
|
|
83
|
+
if (
|
|
84
|
+
normalized === 'toolExecutionResult.toolOutput.raw' ||
|
|
85
|
+
normalized.startsWith('toolExecutionResult.toolOutput.raw.')
|
|
86
|
+
) {
|
|
87
|
+
return normalized;
|
|
88
|
+
}
|
|
89
|
+
const rawPath = normalized
|
|
90
|
+
.replace(/^result\.data\.?/, '')
|
|
91
|
+
.replace(/^result\.?/, '')
|
|
92
|
+
.replace(/^data\.?/, '')
|
|
93
|
+
.replace(/^\./, '');
|
|
94
|
+
return rawPath
|
|
95
|
+
? `toolExecutionResult.toolOutput.raw.${rawPath}`
|
|
96
|
+
: 'toolExecutionResult.toolOutput.raw';
|
|
97
|
+
}
|
|
98
|
+
|
|
41
99
|
function isMeaningfulValue(value: unknown): boolean {
|
|
42
100
|
if (value == null) return false;
|
|
43
101
|
if (typeof value === 'string') return value.trim().length > 0;
|
|
@@ -123,7 +181,37 @@ function normalizeResultPath(path: string): string {
|
|
|
123
181
|
.trim()
|
|
124
182
|
.replace(/^\./, '');
|
|
125
183
|
if (!trimmed) return '';
|
|
126
|
-
return trimmed
|
|
184
|
+
return toV2RawToolOutputPath(trimmed);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function toV2RawToolOutputPathPreservingProviderData(path: string): string {
|
|
188
|
+
const normalized = String(path || '')
|
|
189
|
+
.trim()
|
|
190
|
+
.replace(/^\./, '');
|
|
191
|
+
if (!normalized) return 'toolExecutionResult.toolOutput.raw';
|
|
192
|
+
if (
|
|
193
|
+
normalized === 'toolExecutionResult.toolOutput.raw' ||
|
|
194
|
+
normalized.startsWith('toolExecutionResult.toolOutput.raw.')
|
|
195
|
+
) {
|
|
196
|
+
return normalized;
|
|
197
|
+
}
|
|
198
|
+
const rawPath = normalized
|
|
199
|
+
.replace(/^result\.?/, '')
|
|
200
|
+
.replace(/^\./, '');
|
|
201
|
+
return rawPath
|
|
202
|
+
? `toolExecutionResult.toolOutput.raw.${rawPath}`
|
|
203
|
+
: 'toolExecutionResult.toolOutput.raw';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function candidateResultPaths(path: string): string[] {
|
|
207
|
+
const candidates = [
|
|
208
|
+
normalizeResultPath(path),
|
|
209
|
+
toV2RawToolOutputPathPreservingProviderData(path),
|
|
210
|
+
];
|
|
211
|
+
return candidates.filter(
|
|
212
|
+
(candidate, index, all) =>
|
|
213
|
+
candidate.length > 0 && all.indexOf(candidate) === index,
|
|
214
|
+
);
|
|
127
215
|
}
|
|
128
216
|
|
|
129
217
|
function normalizeRelativePath(path: string): string {
|
|
@@ -184,10 +272,10 @@ function findFirstTargetByPath(
|
|
|
184
272
|
paths: readonly string[] | undefined,
|
|
185
273
|
): ToolResultTargetMetadata | null {
|
|
186
274
|
for (const path of paths ?? []) {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
275
|
+
for (const candidate of candidateResultPaths(path)) {
|
|
276
|
+
const match = getFirstMeaningfulValueAtPath(result, candidate);
|
|
277
|
+
if (match) return match;
|
|
278
|
+
}
|
|
191
279
|
}
|
|
192
280
|
return null;
|
|
193
281
|
}
|
|
@@ -244,8 +332,7 @@ function resolveListRows(
|
|
|
244
332
|
const path = normalizeResultPath(rawPath);
|
|
245
333
|
if (!path) continue;
|
|
246
334
|
const candidates = [
|
|
247
|
-
|
|
248
|
-
path.replace(/^result\./, 'result.data.'),
|
|
335
|
+
...candidateResultPaths(rawPath),
|
|
249
336
|
].filter(
|
|
250
337
|
(candidate, index, all) =>
|
|
251
338
|
candidate && all.indexOf(candidate) === index,
|
|
@@ -303,29 +390,31 @@ function deriveListKeys(input: {
|
|
|
303
390
|
.trim()
|
|
304
391
|
.replace(/^\./, '');
|
|
305
392
|
if (!path) continue;
|
|
306
|
-
const resultPath
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
393
|
+
for (const resultPath of candidateResultPaths(path)) {
|
|
394
|
+
const directPrefix = `${listPrefix}.`;
|
|
395
|
+
if (resultPath.startsWith(directPrefix)) {
|
|
396
|
+
keys[target] = resultPath
|
|
397
|
+
.slice(directPrefix.length)
|
|
398
|
+
.replace(/^\[\d+\]\.?/, '');
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
const indexedPrefix = `${listPrefix}[0].`;
|
|
402
|
+
if (resultPath.startsWith(indexedPrefix)) {
|
|
403
|
+
keys[target] = resultPath.slice(indexedPrefix.length);
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
const wildcardPrefix = `${listPrefix}[*].`;
|
|
407
|
+
if (resultPath.startsWith(wildcardPrefix)) {
|
|
408
|
+
keys[target] = resultPath.slice(wildcardPrefix.length);
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
const dottedIndexPrefix = `${listPrefix}.0.`;
|
|
412
|
+
if (resultPath.startsWith(dottedIndexPrefix)) {
|
|
413
|
+
keys[target] = resultPath.slice(dottedIndexPrefix.length);
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
328
416
|
}
|
|
417
|
+
if (keys[target]) break;
|
|
329
418
|
}
|
|
330
419
|
}
|
|
331
420
|
if (Object.keys(keys).length === 0 && input.rows[0]) {
|
|
@@ -438,7 +527,14 @@ export function createToolExecuteResult<TResult = unknown>(input: {
|
|
|
438
527
|
execution: ToolResultExecutionMetadata;
|
|
439
528
|
}): ToolExecuteResult<TResult> {
|
|
440
529
|
const result = toResultEnvelope(input.result);
|
|
441
|
-
const resultRoot = {
|
|
530
|
+
const resultRoot = {
|
|
531
|
+
toolExecutionResult: {
|
|
532
|
+
toolOutput: {
|
|
533
|
+
raw: result.data,
|
|
534
|
+
...(result.meta ? { meta: result.meta } : {}),
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
};
|
|
442
538
|
const targets = buildTargets(
|
|
443
539
|
resultRoot,
|
|
444
540
|
input.metadata.resultIdentityGetters,
|
|
@@ -452,9 +548,13 @@ export function createToolExecuteResult<TResult = unknown>(input: {
|
|
|
452
548
|
};
|
|
453
549
|
const wrapper = {
|
|
454
550
|
status: input.status,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
551
|
+
toolOutput: {
|
|
552
|
+
raw: result.data,
|
|
553
|
+
...(result.meta ? { meta: result.meta } : {}),
|
|
554
|
+
},
|
|
555
|
+
meta: input.execution,
|
|
556
|
+
extractedValues: buildExtractedAccessors(targets),
|
|
557
|
+
extractedLists: buildListAccessors(resultRoot, lists),
|
|
458
558
|
} as ToolExecuteResult<TResult>;
|
|
459
559
|
Object.defineProperty(wrapper, '_metadata', {
|
|
460
560
|
value: metadata,
|
|
@@ -471,7 +571,7 @@ export function isToolExecuteResult(
|
|
|
471
571
|
typeof value.status === 'string' &&
|
|
472
572
|
'_metadata' in value &&
|
|
473
573
|
isRecord(value._metadata) &&
|
|
474
|
-
'
|
|
574
|
+
'toolOutput' in value
|
|
475
575
|
);
|
|
476
576
|
}
|
|
477
577
|
|
|
@@ -481,7 +581,10 @@ export function cloneToolExecuteResultWithExecution<TResult>(
|
|
|
481
581
|
): ToolExecuteResult<TResult> {
|
|
482
582
|
return createToolExecuteResult<TResult>({
|
|
483
583
|
status: value.status,
|
|
484
|
-
result:
|
|
584
|
+
result: {
|
|
585
|
+
data: value.toolOutput.raw,
|
|
586
|
+
...(value.toolOutput.meta ? { meta: value.toolOutput.meta } : {}),
|
|
587
|
+
} as TResult,
|
|
485
588
|
metadata: {
|
|
486
589
|
toolId: value._metadata.toolId,
|
|
487
590
|
resultIdentityGetters: Object.fromEntries(
|