deepline 0.1.52 → 0.1.53
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 +246 -82
- package/dist/cli/index.mjs +246 -82
- package/dist/index.d.mts +66 -5
- package/dist/index.d.ts +66 -5
- package/dist/index.js +60 -18
- package/dist/index.mjs +60 -18
- package/dist/repo/sdk/src/client.ts +92 -19
- package/dist/repo/sdk/src/play.ts +3 -0
- package/dist/repo/sdk/src/release.ts +5 -5
- package/dist/repo/sdk/src/types.ts +60 -2
- package/package.json +1 -1
|
@@ -46,6 +46,7 @@ import type {
|
|
|
46
46
|
PlayRunResult,
|
|
47
47
|
PlayRunStart,
|
|
48
48
|
PlayStatus,
|
|
49
|
+
PlayRunPackage,
|
|
49
50
|
PlayLiveEvent,
|
|
50
51
|
PlayListItem,
|
|
51
52
|
PlayDescription,
|
|
@@ -158,7 +159,7 @@ export type PlaySheetRowsResult = {
|
|
|
158
159
|
};
|
|
159
160
|
|
|
160
161
|
export type RunsNamespace = {
|
|
161
|
-
get: (runId: string) => Promise<PlayStatus>;
|
|
162
|
+
get: (runId: string, options?: { full?: boolean }) => Promise<PlayStatus>;
|
|
162
163
|
list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
|
|
163
164
|
tail: (runId: string, options?: RunsTailOptions) => Promise<PlayStatus>;
|
|
164
165
|
logs: (runId: string, options?: RunsLogsOptions) => Promise<RunsLogsResult>;
|
|
@@ -179,22 +180,69 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
179
180
|
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
function isPlayRunPackage(value: unknown): value is PlayRunPackage {
|
|
184
|
+
return Boolean(
|
|
185
|
+
value &&
|
|
186
|
+
typeof value === 'object' &&
|
|
187
|
+
!Array.isArray(value) &&
|
|
188
|
+
(value as Record<string, unknown>).kind === 'play_run' &&
|
|
189
|
+
(value as Record<string, unknown>).run &&
|
|
190
|
+
typeof (value as { run?: { id?: unknown } }).run?.id === 'string',
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
182
194
|
function normalizePlayStatus(raw: Record<string, unknown>): PlayStatus {
|
|
195
|
+
const runPackage = isPlayRunPackage(raw)
|
|
196
|
+
? raw
|
|
197
|
+
: isPlayRunPackage(raw.package)
|
|
198
|
+
? raw.package
|
|
199
|
+
: null;
|
|
200
|
+
const packageRun = runPackage?.run;
|
|
183
201
|
const status =
|
|
184
|
-
typeof raw.status === 'string'
|
|
202
|
+
typeof raw.status === 'string'
|
|
203
|
+
? raw.status
|
|
204
|
+
: typeof packageRun?.status === 'string'
|
|
205
|
+
? packageRun.status
|
|
206
|
+
: 'running';
|
|
185
207
|
const runId =
|
|
186
208
|
typeof raw.runId === 'string'
|
|
187
209
|
? raw.runId
|
|
188
210
|
: typeof raw.workflowId === 'string'
|
|
189
211
|
? raw.workflowId
|
|
190
|
-
: '';
|
|
212
|
+
: packageRun?.id ?? '';
|
|
191
213
|
return {
|
|
192
214
|
...(raw as unknown as Omit<PlayStatus, 'runId' | 'status'>),
|
|
193
215
|
runId,
|
|
216
|
+
...(runPackage ? { package: runPackage, outputs: runPackage.outputs } : {}),
|
|
194
217
|
status: status as PlayStatus['status'],
|
|
195
218
|
};
|
|
196
219
|
}
|
|
197
220
|
|
|
221
|
+
function normalizePlayRunStart(raw: Record<string, unknown>): PlayRunStart {
|
|
222
|
+
const runPackage = isPlayRunPackage(raw)
|
|
223
|
+
? raw
|
|
224
|
+
: isPlayRunPackage(raw.package)
|
|
225
|
+
? raw.package
|
|
226
|
+
: null;
|
|
227
|
+
if (!runPackage) {
|
|
228
|
+
return raw as unknown as PlayRunStart;
|
|
229
|
+
}
|
|
230
|
+
const status =
|
|
231
|
+
typeof runPackage.run.status === 'string' ? runPackage.run.status : 'running';
|
|
232
|
+
return {
|
|
233
|
+
workflowId: runPackage.run.id,
|
|
234
|
+
name: runPackage.run.playName,
|
|
235
|
+
status,
|
|
236
|
+
...(runPackage.run.dashboardUrl
|
|
237
|
+
? { dashboardUrl: runPackage.run.dashboardUrl }
|
|
238
|
+
: {}),
|
|
239
|
+
...(TERMINAL_PLAY_STATUSES.has(status)
|
|
240
|
+
? { finalStatus: runPackage }
|
|
241
|
+
: {}),
|
|
242
|
+
package: runPackage,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
198
246
|
function decodeBase64Bytes(value: string): Uint8Array {
|
|
199
247
|
const binary = atob(value);
|
|
200
248
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -259,18 +307,32 @@ function updatePlayLiveStatusState(
|
|
|
259
307
|
const runId =
|
|
260
308
|
typeof payload.runId === 'string' && payload.runId
|
|
261
309
|
? payload.runId
|
|
310
|
+
: isPlayRunPackage(payload)
|
|
311
|
+
? payload.run.id
|
|
262
312
|
: state.runId;
|
|
263
|
-
const status =
|
|
264
|
-
|
|
313
|
+
const status =
|
|
314
|
+
normalizeLiveStatus(payload.status) ??
|
|
315
|
+
(isPlayRunPackage(payload)
|
|
316
|
+
? normalizeLiveStatus(payload.run.status)
|
|
317
|
+
: null) ??
|
|
318
|
+
state.status;
|
|
319
|
+
const progressPayload = isRecord(payload.progress)
|
|
320
|
+
? payload.progress
|
|
321
|
+
: {};
|
|
322
|
+
const payloadLogs = readStringArray(payload.logs);
|
|
323
|
+
const progressLogs = readStringArray(progressPayload.logs);
|
|
324
|
+
const logs = payloadLogs.length > 0 ? payloadLogs : progressLogs;
|
|
265
325
|
if (
|
|
266
326
|
logs.length > 0 ||
|
|
267
327
|
event.type === 'play.run.snapshot' ||
|
|
268
|
-
event.type === 'play.run.final_status'
|
|
328
|
+
(event.type === 'play.run.final_status' && !isPlayRunPackage(payload))
|
|
269
329
|
) {
|
|
270
330
|
state.logs = logs;
|
|
271
331
|
}
|
|
272
332
|
if ('result' in payload) {
|
|
273
333
|
state.result = payload.result;
|
|
334
|
+
} else if (isPlayRunPackage(payload)) {
|
|
335
|
+
state.result = payload;
|
|
274
336
|
}
|
|
275
337
|
if (typeof payload.error === 'string' && payload.error.trim()) {
|
|
276
338
|
state.error = payload.error;
|
|
@@ -278,16 +340,14 @@ function updatePlayLiveStatusState(
|
|
|
278
340
|
state.runId = runId;
|
|
279
341
|
state.status = status;
|
|
280
342
|
|
|
281
|
-
const progressRecord =
|
|
282
|
-
payload.progress &&
|
|
283
|
-
typeof payload.progress === 'object' &&
|
|
284
|
-
!Array.isArray(payload.progress)
|
|
285
|
-
? (payload.progress as Record<string, unknown>)
|
|
286
|
-
: {};
|
|
343
|
+
const progressRecord = progressPayload;
|
|
287
344
|
const next: PlayStatus = {
|
|
288
345
|
...(payload as unknown as Omit<PlayStatus, 'runId' | 'status' | 'progress'>),
|
|
289
346
|
runId,
|
|
290
347
|
status,
|
|
348
|
+
...(isPlayRunPackage(payload)
|
|
349
|
+
? { package: payload, outputs: payload.outputs }
|
|
350
|
+
: {}),
|
|
291
351
|
progress: {
|
|
292
352
|
...progressRecord,
|
|
293
353
|
status:
|
|
@@ -311,7 +371,8 @@ function playRunResultFromStatus(
|
|
|
311
371
|
return {
|
|
312
372
|
success: status.status === 'completed',
|
|
313
373
|
runId: status.runId || fallbackRunId,
|
|
314
|
-
result: status.result,
|
|
374
|
+
result: status.package ?? status.result,
|
|
375
|
+
...(status.package ? { package: status.package } : {}),
|
|
315
376
|
logs: status.progress?.logs ?? [],
|
|
316
377
|
durationMs: Date.now() - startedAt,
|
|
317
378
|
error:
|
|
@@ -366,7 +427,7 @@ export class DeeplineClient {
|
|
|
366
427
|
this.config = resolveConfig(options);
|
|
367
428
|
this.http = new HttpClient(this.config);
|
|
368
429
|
this.runs = {
|
|
369
|
-
get: (runId) => this.getRunStatus(runId),
|
|
430
|
+
get: (runId, options) => this.getRunStatus(runId, options),
|
|
370
431
|
list: (options) => this.listRuns(options),
|
|
371
432
|
tail: (runId, options) => this.tailRun(runId, options),
|
|
372
433
|
logs: (runId, options) => this.getRunLogs(runId, options),
|
|
@@ -647,9 +708,9 @@ export class DeeplineClient {
|
|
|
647
708
|
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
648
709
|
* });
|
|
649
710
|
* ```
|
|
650
|
-
|
|
711
|
+
*/
|
|
651
712
|
async startPlayRun(request: StartPlayRunRequest): Promise<PlayRunStart> {
|
|
652
|
-
|
|
713
|
+
const response = await this.http.post<Record<string, unknown>>('/api/v2/plays/run', {
|
|
653
714
|
...(request.name ? { name: request.name } : {}),
|
|
654
715
|
...(request.revisionId ? { revisionId: request.revisionId } : {}),
|
|
655
716
|
...(request.artifactStorageKey
|
|
@@ -688,6 +749,7 @@ export class DeeplineClient {
|
|
|
688
749
|
// different profile pass `request.profile` explicitly.
|
|
689
750
|
...(request.profile ? { profile: request.profile } : {}),
|
|
690
751
|
});
|
|
752
|
+
return normalizePlayRunStart(response);
|
|
691
753
|
}
|
|
692
754
|
|
|
693
755
|
async *startPlayRunStream(
|
|
@@ -1124,12 +1186,15 @@ export class DeeplineClient {
|
|
|
1124
1186
|
*/
|
|
1125
1187
|
async getPlayStatus(
|
|
1126
1188
|
workflowId: string,
|
|
1127
|
-
options?: { billing?: boolean },
|
|
1189
|
+
options?: { billing?: boolean; full?: boolean },
|
|
1128
1190
|
): Promise<PlayStatus> {
|
|
1129
1191
|
const params = new URLSearchParams();
|
|
1130
1192
|
if (options?.billing === false) {
|
|
1131
1193
|
params.set('billing', 'false');
|
|
1132
1194
|
}
|
|
1195
|
+
if (options?.full === true) {
|
|
1196
|
+
params.set('full', 'true');
|
|
1197
|
+
}
|
|
1133
1198
|
const query = params.size > 0 ? `?${params.toString()}` : '';
|
|
1134
1199
|
const response = await this.http.get<Record<string, unknown>>(
|
|
1135
1200
|
`/api/v2/plays/run/${encodeURIComponent(workflowId)}${query}`,
|
|
@@ -1236,9 +1301,17 @@ export class DeeplineClient {
|
|
|
1236
1301
|
* deepline runs get <run-id> --json
|
|
1237
1302
|
* ```
|
|
1238
1303
|
*/
|
|
1239
|
-
async getRunStatus(
|
|
1304
|
+
async getRunStatus(
|
|
1305
|
+
runId: string,
|
|
1306
|
+
options?: { full?: boolean },
|
|
1307
|
+
): Promise<PlayStatus> {
|
|
1308
|
+
const params = new URLSearchParams();
|
|
1309
|
+
if (options?.full === true) {
|
|
1310
|
+
params.set('full', 'true');
|
|
1311
|
+
}
|
|
1312
|
+
const query = params.size > 0 ? `?${params.toString()}` : '';
|
|
1240
1313
|
const response = await this.http.get<Record<string, unknown>>(
|
|
1241
|
-
`/api/v2/runs/${encodeURIComponent(runId)}`,
|
|
1314
|
+
`/api/v2/runs/${encodeURIComponent(runId)}${query}`,
|
|
1242
1315
|
);
|
|
1243
1316
|
return normalizePlayStatus(response);
|
|
1244
1317
|
}
|
|
@@ -838,6 +838,9 @@ class DeeplinePlayJobImpl<TOutput = unknown> implements PlayJob<TOutput> {
|
|
|
838
838
|
`Play run ${this.id} ended with ${status.status}.`,
|
|
839
839
|
);
|
|
840
840
|
}
|
|
841
|
+
if (status.package) {
|
|
842
|
+
return status.package as TOutput;
|
|
843
|
+
}
|
|
841
844
|
const payload = status.result as { output?: unknown } | undefined;
|
|
842
845
|
return ((payload && 'output' in payload
|
|
843
846
|
? payload.output
|
|
@@ -50,11 +50,11 @@ export type SdkRelease = {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
export const SDK_RELEASE = {
|
|
53
|
-
version: '0.1.
|
|
54
|
-
apiContract: '2026-05-
|
|
53
|
+
version: '0.1.53',
|
|
54
|
+
apiContract: '2026-05-run-response-package',
|
|
55
55
|
supportPolicy: {
|
|
56
|
-
latest: '0.1.
|
|
57
|
-
minimumSupported: '0.1.
|
|
58
|
-
deprecatedBelow: '0.1.
|
|
56
|
+
latest: '0.1.53',
|
|
57
|
+
minimumSupported: '0.1.53',
|
|
58
|
+
deprecatedBelow: '0.1.53',
|
|
59
59
|
},
|
|
60
60
|
} as const satisfies SdkRelease;
|
|
@@ -264,7 +264,7 @@ export interface ToolMetadata extends ToolDefinition {
|
|
|
264
264
|
* ```typescript
|
|
265
265
|
* const result = await client.runPlay(code, null, 'my-play');
|
|
266
266
|
* if (result.success) {
|
|
267
|
-
* console.log('
|
|
267
|
+
* console.log('Run package:', result.result);
|
|
268
268
|
* console.log(`Completed in ${result.durationMs}ms`);
|
|
269
269
|
* } else {
|
|
270
270
|
* console.error('Failed:', result.error);
|
|
@@ -277,8 +277,10 @@ export interface PlayRunResult {
|
|
|
277
277
|
success: boolean;
|
|
278
278
|
/** Public play-run identifier. */
|
|
279
279
|
runId: string;
|
|
280
|
-
/**
|
|
280
|
+
/** Canonical run package for current play runs; legacy clients may receive a raw result. */
|
|
281
281
|
result?: unknown;
|
|
282
|
+
/** Canonical compact run package when returned by the server. */
|
|
283
|
+
package?: PlayRunPackage;
|
|
282
284
|
/** All log lines emitted via `ctx.log()` during execution. */
|
|
283
285
|
logs: string[];
|
|
284
286
|
/** Wall-clock duration from submission to completion, in milliseconds. */
|
|
@@ -301,6 +303,53 @@ export interface PlayProgressStatus {
|
|
|
301
303
|
error?: string;
|
|
302
304
|
}
|
|
303
305
|
|
|
306
|
+
export type PlayRunActionPackage =
|
|
307
|
+
| {
|
|
308
|
+
kind: 'deepline_run_inspect';
|
|
309
|
+
runId: string;
|
|
310
|
+
api: { method: 'GET'; path: string };
|
|
311
|
+
}
|
|
312
|
+
| {
|
|
313
|
+
kind: 'deepline_db_query';
|
|
314
|
+
datasetPath: string;
|
|
315
|
+
tableNamespace?: string;
|
|
316
|
+
sql: string;
|
|
317
|
+
maxRows: number;
|
|
318
|
+
api: {
|
|
319
|
+
method: 'POST';
|
|
320
|
+
path: '/api/v2/db/query';
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
| {
|
|
324
|
+
kind: 'deepline_run_export';
|
|
325
|
+
runId: string;
|
|
326
|
+
datasetPath: string;
|
|
327
|
+
format: 'csv';
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export interface PlayRunPackage {
|
|
331
|
+
schemaVersion: 1;
|
|
332
|
+
kind: 'play_run';
|
|
333
|
+
run: {
|
|
334
|
+
id: string;
|
|
335
|
+
playName: string;
|
|
336
|
+
status: string;
|
|
337
|
+
dashboardUrl?: string;
|
|
338
|
+
updatedAt?: number | null;
|
|
339
|
+
startedAt?: number | null;
|
|
340
|
+
finishedAt?: number | null;
|
|
341
|
+
durationMs?: number | null;
|
|
342
|
+
error?: string;
|
|
343
|
+
};
|
|
344
|
+
steps: Array<Record<string, unknown>>;
|
|
345
|
+
outputs: Record<string, Record<string, unknown>>;
|
|
346
|
+
next?: {
|
|
347
|
+
inspect?: PlayRunActionPackage;
|
|
348
|
+
export?: PlayRunActionPackage;
|
|
349
|
+
query?: PlayRunActionPackage;
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
304
353
|
/**
|
|
305
354
|
* Current status of a play execution, returned by {@link DeeplineClient.getPlayStatus}.
|
|
306
355
|
*
|
|
@@ -340,8 +389,13 @@ export interface PlayStatus {
|
|
|
340
389
|
progress?: PlayProgressStatus;
|
|
341
390
|
/** Partial or final result. Available once the play returns. */
|
|
342
391
|
result?: unknown;
|
|
392
|
+
/** Compact typed run package returned by current run status endpoints. */
|
|
393
|
+
package?: PlayRunPackage;
|
|
394
|
+
/** Compact typed output summaries, mirrored from the run package when present. */
|
|
395
|
+
outputs?: PlayRunPackage['outputs'];
|
|
343
396
|
/** Scheduler-backed run metadata when returned by the status endpoint. */
|
|
344
397
|
run?: {
|
|
398
|
+
id?: string;
|
|
345
399
|
startTime?: string | null;
|
|
346
400
|
closeTime?: string | null;
|
|
347
401
|
[key: string]: unknown;
|
|
@@ -357,6 +411,8 @@ export interface PlayStatus {
|
|
|
357
411
|
eventKey?: string;
|
|
358
412
|
until?: number;
|
|
359
413
|
} | null;
|
|
414
|
+
/** Structured follow-up actions for inspect/query/export. */
|
|
415
|
+
next?: PlayRunPackage['next'] | Record<string, unknown>;
|
|
360
416
|
}
|
|
361
417
|
|
|
362
418
|
export type LiveEventScope = 'play' | 'agent';
|
|
@@ -654,6 +710,8 @@ export interface PlayRunStart {
|
|
|
654
710
|
dashboardUrl?: string;
|
|
655
711
|
/** Terminal status returned when the start request used a short completion wait. */
|
|
656
712
|
finalStatus?: unknown;
|
|
713
|
+
/** Canonical compact run package returned by current SDK/API responses. */
|
|
714
|
+
package?: PlayRunPackage;
|
|
657
715
|
}
|
|
658
716
|
|
|
659
717
|
/**
|