deepline 0.1.63 → 0.1.65
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/cli/index.js +933 -533
- package/dist/cli/index.mjs +837 -421
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +102 -49
- package/dist/index.mjs +98 -45
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +9 -10
- package/dist/repo/apps/play-runner-workers/src/runtime/dataset-handles.ts +36 -27
- package/dist/repo/apps/play-runner-workers/src/runtime/tool-http-errors.ts +5 -2
- package/dist/repo/sdk/src/client.ts +71 -63
- package/dist/repo/sdk/src/errors.ts +5 -1
- package/dist/repo/sdk/src/http.ts +69 -17
- package/dist/repo/sdk/src/plays/local-file-discovery.ts +93 -24
- package/dist/repo/sdk/src/release.ts +2 -2
- package/dist/repo/sdk/src/tool-output.ts +40 -20
- package/dist/repo/shared_libs/play-runtime/batch-runtime.ts +10 -3
- package/dist/repo/shared_libs/play-runtime/batching-types.ts +15 -4
- package/dist/repo/shared_libs/play-runtime/coordinator-headers.ts +2 -1
- package/dist/repo/shared_libs/play-runtime/dedup-backend.ts +0 -0
- package/dist/repo/shared_libs/play-runtime/default-batch-strategies.ts +3 -4
- package/dist/repo/shared_libs/play-runtime/run-failure.ts +1 -3
- package/dist/repo/shared_libs/play-runtime/step-lifecycle-tracker.ts +4 -1
- package/dist/repo/shared_libs/play-runtime/tool-batch-executor.ts +4 -1
- package/dist/repo/shared_libs/plays/dataset.ts +10 -11
- package/package.json +1 -1
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { readFile, stat } from 'node:fs/promises';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
basename,
|
|
5
|
+
dirname,
|
|
6
|
+
extname,
|
|
7
|
+
isAbsolute,
|
|
8
|
+
join,
|
|
9
|
+
relative,
|
|
10
|
+
resolve,
|
|
11
|
+
} from 'node:path';
|
|
4
12
|
|
|
5
13
|
export interface PlayLocalFileReference {
|
|
6
14
|
sourceFragment: string;
|
|
@@ -33,7 +41,17 @@ export interface PlayStagedFileRef {
|
|
|
33
41
|
|
|
34
42
|
type ConstMap = Map<string, string>;
|
|
35
43
|
|
|
36
|
-
const SOURCE_EXTENSIONS = [
|
|
44
|
+
const SOURCE_EXTENSIONS = [
|
|
45
|
+
'.ts',
|
|
46
|
+
'.tsx',
|
|
47
|
+
'.mts',
|
|
48
|
+
'.cts',
|
|
49
|
+
'.js',
|
|
50
|
+
'.jsx',
|
|
51
|
+
'.mjs',
|
|
52
|
+
'.cjs',
|
|
53
|
+
'.json',
|
|
54
|
+
];
|
|
37
55
|
|
|
38
56
|
function sha256(buffer: Buffer): string {
|
|
39
57
|
return createHash('sha256').update(buffer).digest('hex');
|
|
@@ -50,19 +68,28 @@ function contentTypeForFile(filePath: string): string {
|
|
|
50
68
|
function stripCommentsToSpaces(source: string): string {
|
|
51
69
|
return source
|
|
52
70
|
.replace(/\/\*[\s\S]*?\*\//g, (match) => match.replace(/[^\n]/g, ' '))
|
|
53
|
-
.replace(
|
|
54
|
-
|
|
71
|
+
.replace(
|
|
72
|
+
/(^|[^:])\/\/.*$/gm,
|
|
73
|
+
(match, prefix: string) =>
|
|
74
|
+
prefix + ' '.repeat(Math.max(0, match.length - prefix.length)),
|
|
55
75
|
);
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
function unquoteStringLiteral(literal: string): string | null {
|
|
59
79
|
const trimmed = literal.trim();
|
|
60
80
|
const quote = trimmed[0];
|
|
61
|
-
if (
|
|
81
|
+
if (
|
|
82
|
+
(quote !== '"' && quote !== "'") ||
|
|
83
|
+
trimmed[trimmed.length - 1] !== quote
|
|
84
|
+
) {
|
|
62
85
|
return null;
|
|
63
86
|
}
|
|
64
87
|
try {
|
|
65
|
-
return JSON.parse(
|
|
88
|
+
return JSON.parse(
|
|
89
|
+
quote === '"'
|
|
90
|
+
? trimmed
|
|
91
|
+
: `"${trimmed.slice(1, -1).replace(/"/g, '\\"')}"`,
|
|
92
|
+
);
|
|
66
93
|
} catch {
|
|
67
94
|
return trimmed.slice(1, -1);
|
|
68
95
|
}
|
|
@@ -116,7 +143,10 @@ function isRuntimeInputExpression(expression: string): boolean {
|
|
|
116
143
|
return /(^|[^\w$])input([^\w$]|$)/.test(expression);
|
|
117
144
|
}
|
|
118
145
|
|
|
119
|
-
function resolveStringExpression(
|
|
146
|
+
function resolveStringExpression(
|
|
147
|
+
expression: string,
|
|
148
|
+
constants: ConstMap,
|
|
149
|
+
): string | null {
|
|
120
150
|
const value = stripOuterParens(expression);
|
|
121
151
|
if (/^(['"])(?:\\.|(?!\1)[\s\S])*\1$/.test(value)) {
|
|
122
152
|
return unquoteStringLiteral(value);
|
|
@@ -129,7 +159,9 @@ function resolveStringExpression(expression: string, constants: ConstMap): strin
|
|
|
129
159
|
}
|
|
130
160
|
const parts = splitTopLevelPlus(value);
|
|
131
161
|
if (parts) {
|
|
132
|
-
const resolved = parts.map((part) =>
|
|
162
|
+
const resolved = parts.map((part) =>
|
|
163
|
+
resolveStringExpression(part, constants),
|
|
164
|
+
);
|
|
133
165
|
return resolved.every((part): part is string => part != null)
|
|
134
166
|
? resolved.join('')
|
|
135
167
|
: null;
|
|
@@ -140,7 +172,9 @@ function resolveStringExpression(expression: string, constants: ConstMap): strin
|
|
|
140
172
|
function collectTopLevelStringConstants(sourceCode: string): ConstMap {
|
|
141
173
|
const constants: ConstMap = new Map();
|
|
142
174
|
const source = stripCommentsToSpaces(sourceCode);
|
|
143
|
-
for (const match of source.matchAll(
|
|
175
|
+
for (const match of source.matchAll(
|
|
176
|
+
/(?:^|\n)\s*const\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+)/g,
|
|
177
|
+
)) {
|
|
144
178
|
const resolved = resolveStringExpression(match[2]!, constants);
|
|
145
179
|
if (resolved != null) {
|
|
146
180
|
constants.set(match[1]!, resolved);
|
|
@@ -190,7 +224,10 @@ function findCallOpenParen(source: string, afterCsvIndex: number): number {
|
|
|
190
224
|
return source[index] === '(' ? index : -1;
|
|
191
225
|
}
|
|
192
226
|
|
|
193
|
-
function firstCallArgument(
|
|
227
|
+
function firstCallArgument(
|
|
228
|
+
source: string,
|
|
229
|
+
openParen: number,
|
|
230
|
+
): { text: string; start: number; end: number } | null {
|
|
194
231
|
let depth = 0;
|
|
195
232
|
let quote: string | null = null;
|
|
196
233
|
let escaped = false;
|
|
@@ -235,7 +272,9 @@ function localImportSpecifiers(sourceCode: string): string[] {
|
|
|
235
272
|
)) {
|
|
236
273
|
if (match[1]?.startsWith('.')) specifiers.push(match[1]);
|
|
237
274
|
}
|
|
238
|
-
for (const match of source.matchAll(
|
|
275
|
+
for (const match of source.matchAll(
|
|
276
|
+
/\brequire\s*\(\s*(['"])(\.[^'"]*)\1\s*\)/g,
|
|
277
|
+
)) {
|
|
239
278
|
specifiers.push(match[2]!);
|
|
240
279
|
}
|
|
241
280
|
return specifiers;
|
|
@@ -252,20 +291,34 @@ async function fileExists(filePath: string): Promise<boolean> {
|
|
|
252
291
|
|
|
253
292
|
function isPathInsideDirectory(filePath: string, directory: string): boolean {
|
|
254
293
|
const relativePath = relative(directory, filePath);
|
|
255
|
-
return
|
|
294
|
+
return (
|
|
295
|
+
relativePath === '' ||
|
|
296
|
+
(!relativePath.startsWith('..') && !isAbsolute(relativePath))
|
|
297
|
+
);
|
|
256
298
|
}
|
|
257
299
|
|
|
258
|
-
async function resolveLocalImport(
|
|
259
|
-
|
|
300
|
+
async function resolveLocalImport(
|
|
301
|
+
fromFile: string,
|
|
302
|
+
specifier: string,
|
|
303
|
+
): Promise<string> {
|
|
304
|
+
const base = isAbsolute(specifier)
|
|
305
|
+
? resolve(specifier)
|
|
306
|
+
: resolve(dirname(fromFile), specifier);
|
|
260
307
|
const candidates: string[] = [base];
|
|
261
308
|
const explicitExtension = extname(base).toLowerCase();
|
|
262
309
|
|
|
263
310
|
if (!explicitExtension) {
|
|
264
|
-
candidates.push(
|
|
265
|
-
|
|
311
|
+
candidates.push(
|
|
312
|
+
...SOURCE_EXTENSIONS.map((extension) => `${base}${extension}`),
|
|
313
|
+
);
|
|
314
|
+
candidates.push(
|
|
315
|
+
...SOURCE_EXTENSIONS.map((extension) => join(base, `index${extension}`)),
|
|
316
|
+
);
|
|
266
317
|
} else if (['.js', '.jsx', '.mjs', '.cjs'].includes(explicitExtension)) {
|
|
267
318
|
const stem = base.slice(0, -explicitExtension.length);
|
|
268
|
-
candidates.push(
|
|
319
|
+
candidates.push(
|
|
320
|
+
...SOURCE_EXTENSIONS.map((extension) => `${stem}${extension}`),
|
|
321
|
+
);
|
|
269
322
|
}
|
|
270
323
|
|
|
271
324
|
for (const candidate of candidates) {
|
|
@@ -274,7 +327,9 @@ async function resolveLocalImport(fromFile: string, specifier: string): Promise<
|
|
|
274
327
|
}
|
|
275
328
|
}
|
|
276
329
|
|
|
277
|
-
throw new Error(
|
|
330
|
+
throw new Error(
|
|
331
|
+
`Could not resolve local import "${specifier}" from ${fromFile}`,
|
|
332
|
+
);
|
|
278
333
|
}
|
|
279
334
|
|
|
280
335
|
export async function discoverPackagedLocalFiles(
|
|
@@ -298,12 +353,17 @@ export async function discoverPackagedLocalFiles(
|
|
|
298
353
|
const constants = collectTopLevelStringConstants(sourceCode);
|
|
299
354
|
const childVisits: Promise<void>[] = [];
|
|
300
355
|
|
|
301
|
-
for (const match of scanSource.matchAll(
|
|
356
|
+
for (const match of scanSource.matchAll(
|
|
357
|
+
/\b([A-Za-z_$][\w$]*)\s*\.\s*csv\b/g,
|
|
358
|
+
)) {
|
|
302
359
|
const target = match[1]!;
|
|
303
360
|
if (target !== 'ctx' && !target.endsWith('Ctx')) {
|
|
304
361
|
continue;
|
|
305
362
|
}
|
|
306
|
-
const openParen = findCallOpenParen(
|
|
363
|
+
const openParen = findCallOpenParen(
|
|
364
|
+
scanSource,
|
|
365
|
+
match.index! + match[0].length,
|
|
366
|
+
);
|
|
307
367
|
if (openParen < 0) {
|
|
308
368
|
continue;
|
|
309
369
|
}
|
|
@@ -317,15 +377,22 @@ export async function discoverPackagedLocalFiles(
|
|
|
317
377
|
const resolvedPath = resolveStringExpression(argument.text, constants);
|
|
318
378
|
if (resolvedPath == null) {
|
|
319
379
|
unresolved.push({
|
|
320
|
-
sourceFragment: sourceCode
|
|
380
|
+
sourceFragment: sourceCode
|
|
381
|
+
.slice(argument.start, argument.end)
|
|
382
|
+
.trim(),
|
|
321
383
|
message:
|
|
322
384
|
'Could not resolve this ctx.csv(...) path at submit time. Use a string literal, a top-level const string, or pass a runtime input like input.file.',
|
|
323
385
|
});
|
|
324
386
|
} else {
|
|
325
387
|
const absoluteCsvPath = resolve(dirname(absolutePath), resolvedPath);
|
|
326
|
-
if (
|
|
388
|
+
if (
|
|
389
|
+
isAbsolute(resolvedPath) ||
|
|
390
|
+
!isPathInsideDirectory(absoluteCsvPath, packagingRoot)
|
|
391
|
+
) {
|
|
327
392
|
unresolved.push({
|
|
328
|
-
sourceFragment: sourceCode
|
|
393
|
+
sourceFragment: sourceCode
|
|
394
|
+
.slice(argument.start, argument.end)
|
|
395
|
+
.trim(),
|
|
329
396
|
message:
|
|
330
397
|
'ctx.csv(...) packaged file paths must be relative paths inside the play directory. Pass external files at runtime with input.file instead.',
|
|
331
398
|
});
|
|
@@ -334,7 +401,9 @@ export async function discoverPackagedLocalFiles(
|
|
|
334
401
|
const buffer = await readFile(absoluteCsvPath);
|
|
335
402
|
const stats = await stat(absoluteCsvPath);
|
|
336
403
|
files.set(absoluteCsvPath, {
|
|
337
|
-
sourceFragment: sourceCode
|
|
404
|
+
sourceFragment: sourceCode
|
|
405
|
+
.slice(argument.start, argument.end)
|
|
406
|
+
.trim(),
|
|
338
407
|
logicalPath: resolvedPath,
|
|
339
408
|
absolutePath: absoluteCsvPath,
|
|
340
409
|
bytes: stats.size,
|
|
@@ -50,10 +50,10 @@ export type SdkRelease = {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
export const SDK_RELEASE = {
|
|
53
|
-
version: '0.1.
|
|
53
|
+
version: '0.1.65',
|
|
54
54
|
apiContract: '2026-05-play-bootstrap-dataset-summary',
|
|
55
55
|
supportPolicy: {
|
|
56
|
-
latest: '0.1.
|
|
56
|
+
latest: '0.1.65',
|
|
57
57
|
minimumSupported: '0.1.53',
|
|
58
58
|
deprecatedBelow: '0.1.53',
|
|
59
59
|
},
|
|
@@ -86,7 +86,9 @@ function normalizeScalarString(value: unknown): string | null {
|
|
|
86
86
|
*/
|
|
87
87
|
function getByDottedPath(root: unknown, dottedPath: string): unknown {
|
|
88
88
|
let current = root;
|
|
89
|
-
for (const segment of String(dottedPath || '')
|
|
89
|
+
for (const segment of String(dottedPath || '')
|
|
90
|
+
.split('.')
|
|
91
|
+
.filter(Boolean)) {
|
|
90
92
|
if (!isPlainObject(current) || !(segment in current)) {
|
|
91
93
|
return null;
|
|
92
94
|
}
|
|
@@ -111,8 +113,12 @@ function normalizeRows(value: unknown): Array<Record<string, unknown>> | null {
|
|
|
111
113
|
* Generate candidate root objects to search for lists.
|
|
112
114
|
* Tries: raw payload → V2 toolResponse.raw → legacy payload.output.body → legacy payload.result → legacy payload.result.data.
|
|
113
115
|
*/
|
|
114
|
-
function candidateRoots(
|
|
115
|
-
|
|
116
|
+
function candidateRoots(
|
|
117
|
+
payload: unknown,
|
|
118
|
+
): Array<{ path: string | null; value: unknown }> {
|
|
119
|
+
const roots: Array<{ path: string | null; value: unknown }> = [
|
|
120
|
+
{ path: null, value: payload },
|
|
121
|
+
];
|
|
116
122
|
if (isPlainObject(payload) && isPlainObject(payload.toolResponse)) {
|
|
117
123
|
roots.push({ path: 'toolResponse', value: payload.toolResponse });
|
|
118
124
|
if (Object.prototype.hasOwnProperty.call(payload.toolResponse, 'raw')) {
|
|
@@ -150,7 +156,10 @@ function findBestArrayCandidate(
|
|
|
150
156
|
if (depth > 5) return null;
|
|
151
157
|
|
|
152
158
|
const directRows = normalizeRows(value);
|
|
153
|
-
const hasObjectRow =
|
|
159
|
+
const hasObjectRow =
|
|
160
|
+
directRows?.some((row) =>
|
|
161
|
+
Object.keys(row).some((key) => key !== 'value'),
|
|
162
|
+
) ?? false;
|
|
154
163
|
let best: { path: string; rows: Array<Record<string, unknown>> } | null =
|
|
155
164
|
directRows && directRows.length > 0 && hasObjectRow
|
|
156
165
|
? { path: pathPrefix, rows: directRows }
|
|
@@ -220,7 +229,10 @@ export function tryConvertToList(
|
|
|
220
229
|
options?: { listExtractorPaths?: string[] },
|
|
221
230
|
): ListConversionResult | null {
|
|
222
231
|
const listExtractorPaths = Array.isArray(options?.listExtractorPaths)
|
|
223
|
-
? options?.listExtractorPaths.filter(
|
|
232
|
+
? options?.listExtractorPaths.filter(
|
|
233
|
+
(entry): entry is string =>
|
|
234
|
+
typeof entry === 'string' && entry.trim().length > 0,
|
|
235
|
+
)
|
|
224
236
|
: [];
|
|
225
237
|
|
|
226
238
|
if (listExtractorPaths.length > 0) {
|
|
@@ -229,7 +241,9 @@ export function tryConvertToList(
|
|
|
229
241
|
const resolved = getByDottedPath(root.value, extractorPath);
|
|
230
242
|
const rows = normalizeRows(resolved);
|
|
231
243
|
if (rows && rows.length > 0) {
|
|
232
|
-
const sourcePath = root.path
|
|
244
|
+
const sourcePath = root.path
|
|
245
|
+
? `${root.path}.${extractorPath}`
|
|
246
|
+
: extractorPath;
|
|
233
247
|
return { rows, strategy: 'configured_paths', sourcePath };
|
|
234
248
|
}
|
|
235
249
|
}
|
|
@@ -322,11 +336,14 @@ export function writeCsvOutputFile(
|
|
|
322
336
|
}
|
|
323
337
|
|
|
324
338
|
const escapeCell = (value: unknown): string => {
|
|
325
|
-
const normalized =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
339
|
+
const normalized =
|
|
340
|
+
value == null
|
|
341
|
+
? ''
|
|
342
|
+
: typeof value === 'string' ||
|
|
343
|
+
typeof value === 'number' ||
|
|
344
|
+
typeof value === 'boolean'
|
|
345
|
+
? String(value)
|
|
346
|
+
: JSON.stringify(value);
|
|
330
347
|
if (/[",\n]/.test(normalized)) {
|
|
331
348
|
return `"${normalized.replace(/"/g, '""')}"`;
|
|
332
349
|
}
|
|
@@ -345,7 +362,8 @@ export function writeCsvOutputFile(
|
|
|
345
362
|
const preview = [
|
|
346
363
|
previewColumns.join(','),
|
|
347
364
|
...previewRows.map((row) =>
|
|
348
|
-
previewColumns.map((column) => escapeCell(row[column])).join(',')
|
|
365
|
+
previewColumns.map((column) => escapeCell(row[column])).join(','),
|
|
366
|
+
),
|
|
349
367
|
].join('\n');
|
|
350
368
|
|
|
351
369
|
return {
|
|
@@ -378,14 +396,16 @@ export function extractSummaryFields(payload: unknown): Record<string, Scalar> {
|
|
|
378
396
|
const candidates = candidateRoots(payload);
|
|
379
397
|
for (const candidate of candidates) {
|
|
380
398
|
if (!isPlainObject(candidate.value)) continue;
|
|
381
|
-
const summaryEntries = Object.entries(candidate.value).filter(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
399
|
+
const summaryEntries = Object.entries(candidate.value).filter(
|
|
400
|
+
([, value]) => {
|
|
401
|
+
return (
|
|
402
|
+
value == null ||
|
|
403
|
+
typeof value === 'string' ||
|
|
404
|
+
typeof value === 'number' ||
|
|
405
|
+
typeof value === 'boolean'
|
|
406
|
+
);
|
|
407
|
+
},
|
|
408
|
+
);
|
|
389
409
|
if (summaryEntries.length === 0) continue;
|
|
390
410
|
return Object.fromEntries(summaryEntries) as Record<string, Scalar>;
|
|
391
411
|
}
|
|
@@ -132,7 +132,9 @@ export function compileRequestsWithStrategy<TRequest>(input: {
|
|
|
132
132
|
export async function executeWaterfallProviders<TRequest, TResult>(input: {
|
|
133
133
|
providers: string[];
|
|
134
134
|
getPendingRequests: () => TRequest[];
|
|
135
|
-
getCachedResults: (
|
|
135
|
+
getCachedResults: (
|
|
136
|
+
provider: string,
|
|
137
|
+
) => Array<ChunkExecutionResult<TRequest, TResult>> | null;
|
|
136
138
|
storeCachedResults: (
|
|
137
139
|
provider: string,
|
|
138
140
|
results: Array<ChunkExecutionResult<TRequest, TResult>>,
|
|
@@ -177,6 +179,11 @@ export async function executeWaterfallProviders<TRequest, TResult>(input: {
|
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
|
|
180
|
-
export function resolveWaterfallToolId(
|
|
181
|
-
|
|
182
|
+
export function resolveWaterfallToolId(
|
|
183
|
+
provider: string,
|
|
184
|
+
toolName: string,
|
|
185
|
+
): string {
|
|
186
|
+
return toolName.startsWith(`${provider}_`)
|
|
187
|
+
? toolName
|
|
188
|
+
: `${provider}_${toolName}`;
|
|
182
189
|
}
|
|
@@ -10,7 +10,10 @@ export type BatchCompileItem<TSingle extends object> = {
|
|
|
10
10
|
payload: TSingle;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export type BatchCompileResult<
|
|
13
|
+
export type BatchCompileResult<
|
|
14
|
+
TBatch extends object,
|
|
15
|
+
TSingle extends object,
|
|
16
|
+
> = {
|
|
14
17
|
batchOperation: string;
|
|
15
18
|
batchPayload: TBatch;
|
|
16
19
|
items: Array<BatchCompileItem<TSingle>>;
|
|
@@ -58,7 +61,10 @@ export type AnyBatchOperationStrategy = {
|
|
|
58
61
|
batchOperation: string;
|
|
59
62
|
kind: BatchStrategyKind;
|
|
60
63
|
maxBatchSize: number;
|
|
61
|
-
canBatchWith(
|
|
64
|
+
canBatchWith(
|
|
65
|
+
left: Record<string, unknown>,
|
|
66
|
+
right: Record<string, unknown>,
|
|
67
|
+
): boolean;
|
|
62
68
|
toBucketKey(payload: Record<string, unknown>): string;
|
|
63
69
|
toItemKey(payload: Record<string, unknown>): string;
|
|
64
70
|
compile(payloads: Record<string, unknown>[]): {
|
|
@@ -81,8 +87,13 @@ export type AnyBatchOperationStrategy = {
|
|
|
81
87
|
|
|
82
88
|
export type BatchStrategyMap = Record<string, AnyBatchOperationStrategy>;
|
|
83
89
|
|
|
84
|
-
type StrictBatchOperationStrategy =
|
|
85
|
-
|
|
90
|
+
type StrictBatchOperationStrategy = BatchOperationStrategy<
|
|
91
|
+
Record<string, unknown>,
|
|
92
|
+
Record<string, unknown>,
|
|
93
|
+
object,
|
|
94
|
+
unknown,
|
|
95
|
+
unknown
|
|
96
|
+
>;
|
|
86
97
|
|
|
87
98
|
export function defineBatchStrategyMap<
|
|
88
99
|
TStrategies extends Record<string, StrictBatchOperationStrategy>,
|
|
@@ -31,7 +31,8 @@ function resolveInternalCoordinatorToken(): string | null {
|
|
|
31
31
|
// Read lazily so the helper is safe to import in environments without
|
|
32
32
|
// env access (e.g. workerd build-time bundling).
|
|
33
33
|
const fromEnv =
|
|
34
|
-
(typeof process !== 'undefined' &&
|
|
34
|
+
(typeof process !== 'undefined' &&
|
|
35
|
+
process?.env?.DEEPLINE_INTERNAL_TOKEN?.trim()) ||
|
|
35
36
|
null;
|
|
36
37
|
if (fromEnv) return fromEnv;
|
|
37
38
|
if (!warnedAboutMissingInternalToken) {
|
|
Binary file
|
|
@@ -109,10 +109,9 @@ const testRateLimitBatchStrategy: BatchOperationStrategy<
|
|
|
109
109
|
},
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
export const DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
112
|
+
export const DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES = defineBatchStrategyMap({
|
|
113
|
+
test_rate_limit: testRateLimitBatchStrategy,
|
|
114
|
+
});
|
|
116
115
|
|
|
117
116
|
export function getDefaultPlayRuntimeBatchStrategy(
|
|
118
117
|
operation: string | null | undefined,
|
|
@@ -27,9 +27,7 @@ export function isCloudflareDurableObjectCodeUpdatedError(
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function normalizePlayRunFailure(
|
|
31
|
-
error: unknown,
|
|
32
|
-
): PlayRunFailureDetails {
|
|
30
|
+
export function normalizePlayRunFailure(error: unknown): PlayRunFailureDetails {
|
|
33
31
|
const cause = toErrorText(error);
|
|
34
32
|
if (isCloudflareDurableObjectCodeUpdatedError(cause)) {
|
|
35
33
|
return {
|
|
@@ -24,7 +24,10 @@ export class PlayStepLifecycleTracker {
|
|
|
24
24
|
|
|
25
25
|
constructor(
|
|
26
26
|
private readonly nodes: readonly PlayStepLifecycleNode[],
|
|
27
|
-
private readonly getProgress: () => Record<
|
|
27
|
+
private readonly getProgress: () => Record<
|
|
28
|
+
string,
|
|
29
|
+
PlayStepLifecycleProgress
|
|
30
|
+
>,
|
|
28
31
|
private readonly emit: (event: PlayStepLifecycleEvent) => void,
|
|
29
32
|
private readonly now: () => number = Date.now,
|
|
30
33
|
) {}
|
|
@@ -55,7 +55,10 @@ export function createToolBatchExecutor(
|
|
|
55
55
|
): ToolBatchExecutor {
|
|
56
56
|
return {
|
|
57
57
|
async executeToolBatch(request) {
|
|
58
|
-
const providerBatchSize = Math.max(
|
|
58
|
+
const providerBatchSize = Math.max(
|
|
59
|
+
1,
|
|
60
|
+
Math.floor(request.providerBatchSize),
|
|
61
|
+
);
|
|
59
62
|
const batches = chunkToolBatchItems(request.items, providerBatchSize);
|
|
60
63
|
const results: ToolBatchItemResult[] = [];
|
|
61
64
|
for (let batchIndex = 0; batchIndex < batches.length; batchIndex += 1) {
|
|
@@ -172,8 +172,8 @@ function inferPreviewColumns<T>(rows: readonly T[]): string[] | undefined {
|
|
|
172
172
|
export function isPlayDataset<T>(value: unknown): value is PlayDataset<T> {
|
|
173
173
|
return Boolean(
|
|
174
174
|
value &&
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
typeof value === 'object' &&
|
|
176
|
+
(value as Record<PropertyKey, unknown>)[PLAY_DATASET_BRAND] === true,
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -182,13 +182,13 @@ export function isSerializedPlayDataset<T>(
|
|
|
182
182
|
): value is SerializedPlayDataset<T> {
|
|
183
183
|
return Boolean(
|
|
184
184
|
value &&
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
typeof value === 'object' &&
|
|
186
|
+
!Array.isArray(value) &&
|
|
187
|
+
(value as Record<string, unknown>).kind === 'dataset' &&
|
|
188
|
+
typeof (value as Record<string, unknown>).datasetKind === 'string' &&
|
|
189
|
+
typeof (value as Record<string, unknown>).datasetId === 'string' &&
|
|
190
|
+
typeof (value as Record<string, unknown>).count === 'number' &&
|
|
191
|
+
Array.isArray((value as Record<string, unknown>).preview),
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -506,8 +506,7 @@ export function createPlayDataset<T>(
|
|
|
506
506
|
tableNamespace: metadata?.tableNamespace ?? null,
|
|
507
507
|
resolvers: {
|
|
508
508
|
count: async () => materializedRows.length,
|
|
509
|
-
peek: async (limit) =>
|
|
510
|
-
materializedRows.slice(0, Math.max(0, limit)),
|
|
509
|
+
peek: async (limit) => materializedRows.slice(0, Math.max(0, limit)),
|
|
511
510
|
materialize: async (limit) =>
|
|
512
511
|
limit === undefined
|
|
513
512
|
? [...materializedRows]
|