deepline 0.1.52 → 0.1.54
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/apps/play-runner-workers/src/coordinator-entry.ts +17 -1
- 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
package/dist/index.d.mts
CHANGED
|
@@ -407,7 +407,7 @@ interface ToolMetadata extends ToolDefinition {
|
|
|
407
407
|
* ```typescript
|
|
408
408
|
* const result = await client.runPlay(code, null, 'my-play');
|
|
409
409
|
* if (result.success) {
|
|
410
|
-
* console.log('
|
|
410
|
+
* console.log('Run package:', result.result);
|
|
411
411
|
* console.log(`Completed in ${result.durationMs}ms`);
|
|
412
412
|
* } else {
|
|
413
413
|
* console.error('Failed:', result.error);
|
|
@@ -420,8 +420,10 @@ interface PlayRunResult {
|
|
|
420
420
|
success: boolean;
|
|
421
421
|
/** Public play-run identifier. */
|
|
422
422
|
runId: string;
|
|
423
|
-
/**
|
|
423
|
+
/** Canonical run package for current play runs; legacy clients may receive a raw result. */
|
|
424
424
|
result?: unknown;
|
|
425
|
+
/** Canonical compact run package when returned by the server. */
|
|
426
|
+
package?: PlayRunPackage;
|
|
425
427
|
/** All log lines emitted via `ctx.log()` during execution. */
|
|
426
428
|
logs: string[];
|
|
427
429
|
/** Wall-clock duration from submission to completion, in milliseconds. */
|
|
@@ -442,6 +444,51 @@ interface PlayProgressStatus {
|
|
|
442
444
|
/** Error message if the play has failed. */
|
|
443
445
|
error?: string;
|
|
444
446
|
}
|
|
447
|
+
type PlayRunActionPackage = {
|
|
448
|
+
kind: 'deepline_run_inspect';
|
|
449
|
+
runId: string;
|
|
450
|
+
api: {
|
|
451
|
+
method: 'GET';
|
|
452
|
+
path: string;
|
|
453
|
+
};
|
|
454
|
+
} | {
|
|
455
|
+
kind: 'deepline_db_query';
|
|
456
|
+
datasetPath: string;
|
|
457
|
+
tableNamespace?: string;
|
|
458
|
+
sql: string;
|
|
459
|
+
maxRows: number;
|
|
460
|
+
api: {
|
|
461
|
+
method: 'POST';
|
|
462
|
+
path: '/api/v2/db/query';
|
|
463
|
+
};
|
|
464
|
+
} | {
|
|
465
|
+
kind: 'deepline_run_export';
|
|
466
|
+
runId: string;
|
|
467
|
+
datasetPath: string;
|
|
468
|
+
format: 'csv';
|
|
469
|
+
};
|
|
470
|
+
interface PlayRunPackage {
|
|
471
|
+
schemaVersion: 1;
|
|
472
|
+
kind: 'play_run';
|
|
473
|
+
run: {
|
|
474
|
+
id: string;
|
|
475
|
+
playName: string;
|
|
476
|
+
status: string;
|
|
477
|
+
dashboardUrl?: string;
|
|
478
|
+
updatedAt?: number | null;
|
|
479
|
+
startedAt?: number | null;
|
|
480
|
+
finishedAt?: number | null;
|
|
481
|
+
durationMs?: number | null;
|
|
482
|
+
error?: string;
|
|
483
|
+
};
|
|
484
|
+
steps: Array<Record<string, unknown>>;
|
|
485
|
+
outputs: Record<string, Record<string, unknown>>;
|
|
486
|
+
next?: {
|
|
487
|
+
inspect?: PlayRunActionPackage;
|
|
488
|
+
export?: PlayRunActionPackage;
|
|
489
|
+
query?: PlayRunActionPackage;
|
|
490
|
+
};
|
|
491
|
+
}
|
|
445
492
|
/**
|
|
446
493
|
* Current status of a play execution, returned by {@link DeeplineClient.getPlayStatus}.
|
|
447
494
|
*
|
|
@@ -475,8 +522,13 @@ interface PlayStatus {
|
|
|
475
522
|
progress?: PlayProgressStatus;
|
|
476
523
|
/** Partial or final result. Available once the play returns. */
|
|
477
524
|
result?: unknown;
|
|
525
|
+
/** Compact typed run package returned by current run status endpoints. */
|
|
526
|
+
package?: PlayRunPackage;
|
|
527
|
+
/** Compact typed output summaries, mirrored from the run package when present. */
|
|
528
|
+
outputs?: PlayRunPackage['outputs'];
|
|
478
529
|
/** Scheduler-backed run metadata when returned by the status endpoint. */
|
|
479
530
|
run?: {
|
|
531
|
+
id?: string;
|
|
480
532
|
startTime?: string | null;
|
|
481
533
|
closeTime?: string | null;
|
|
482
534
|
[key: string]: unknown;
|
|
@@ -492,6 +544,8 @@ interface PlayStatus {
|
|
|
492
544
|
eventKey?: string;
|
|
493
545
|
until?: number;
|
|
494
546
|
} | null;
|
|
547
|
+
/** Structured follow-up actions for inspect/query/export. */
|
|
548
|
+
next?: PlayRunPackage['next'] | Record<string, unknown>;
|
|
495
549
|
}
|
|
496
550
|
type LiveEventScope = 'play' | 'agent';
|
|
497
551
|
interface LiveEventEnvelope<TPayload = unknown> {
|
|
@@ -773,6 +827,8 @@ interface PlayRunStart {
|
|
|
773
827
|
dashboardUrl?: string;
|
|
774
828
|
/** Terminal status returned when the start request used a short completion wait. */
|
|
775
829
|
finalStatus?: unknown;
|
|
830
|
+
/** Canonical compact run package returned by current SDK/API responses. */
|
|
831
|
+
package?: PlayRunPackage;
|
|
776
832
|
}
|
|
777
833
|
/**
|
|
778
834
|
* Result returned by {@link DeeplineClient.checkPlayArtifact}.
|
|
@@ -966,7 +1022,9 @@ type PlaySheetRowsResult = {
|
|
|
966
1022
|
deltaCursor?: number;
|
|
967
1023
|
};
|
|
968
1024
|
type RunsNamespace = {
|
|
969
|
-
get: (runId: string
|
|
1025
|
+
get: (runId: string, options?: {
|
|
1026
|
+
full?: boolean;
|
|
1027
|
+
}) => Promise<PlayStatus>;
|
|
970
1028
|
list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
|
|
971
1029
|
tail: (runId: string, options?: RunsTailOptions) => Promise<PlayStatus>;
|
|
972
1030
|
logs: (runId: string, options?: RunsLogsOptions) => Promise<RunsLogsResult>;
|
|
@@ -1107,7 +1165,7 @@ declare class DeeplineClient {
|
|
|
1107
1165
|
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
1108
1166
|
* });
|
|
1109
1167
|
* ```
|
|
1110
|
-
|
|
1168
|
+
*/
|
|
1111
1169
|
startPlayRun(request: StartPlayRunRequest): Promise<PlayRunStart>;
|
|
1112
1170
|
startPlayRunStream(request: StartPlayRunRequest, options?: {
|
|
1113
1171
|
signal?: AbortSignal;
|
|
@@ -1293,6 +1351,7 @@ declare class DeeplineClient {
|
|
|
1293
1351
|
*/
|
|
1294
1352
|
getPlayStatus(workflowId: string, options?: {
|
|
1295
1353
|
billing?: boolean;
|
|
1354
|
+
full?: boolean;
|
|
1296
1355
|
}): Promise<PlayStatus>;
|
|
1297
1356
|
/**
|
|
1298
1357
|
* Stream semantic play-run events using the same SSE feed as the dashboard.
|
|
@@ -1354,7 +1413,9 @@ declare class DeeplineClient {
|
|
|
1354
1413
|
* deepline runs get <run-id> --json
|
|
1355
1414
|
* ```
|
|
1356
1415
|
*/
|
|
1357
|
-
getRunStatus(runId: string
|
|
1416
|
+
getRunStatus(runId: string, options?: {
|
|
1417
|
+
full?: boolean;
|
|
1418
|
+
}): Promise<PlayStatus>;
|
|
1358
1419
|
/**
|
|
1359
1420
|
* List play runs using the public runs resource model.
|
|
1360
1421
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -407,7 +407,7 @@ interface ToolMetadata extends ToolDefinition {
|
|
|
407
407
|
* ```typescript
|
|
408
408
|
* const result = await client.runPlay(code, null, 'my-play');
|
|
409
409
|
* if (result.success) {
|
|
410
|
-
* console.log('
|
|
410
|
+
* console.log('Run package:', result.result);
|
|
411
411
|
* console.log(`Completed in ${result.durationMs}ms`);
|
|
412
412
|
* } else {
|
|
413
413
|
* console.error('Failed:', result.error);
|
|
@@ -420,8 +420,10 @@ interface PlayRunResult {
|
|
|
420
420
|
success: boolean;
|
|
421
421
|
/** Public play-run identifier. */
|
|
422
422
|
runId: string;
|
|
423
|
-
/**
|
|
423
|
+
/** Canonical run package for current play runs; legacy clients may receive a raw result. */
|
|
424
424
|
result?: unknown;
|
|
425
|
+
/** Canonical compact run package when returned by the server. */
|
|
426
|
+
package?: PlayRunPackage;
|
|
425
427
|
/** All log lines emitted via `ctx.log()` during execution. */
|
|
426
428
|
logs: string[];
|
|
427
429
|
/** Wall-clock duration from submission to completion, in milliseconds. */
|
|
@@ -442,6 +444,51 @@ interface PlayProgressStatus {
|
|
|
442
444
|
/** Error message if the play has failed. */
|
|
443
445
|
error?: string;
|
|
444
446
|
}
|
|
447
|
+
type PlayRunActionPackage = {
|
|
448
|
+
kind: 'deepline_run_inspect';
|
|
449
|
+
runId: string;
|
|
450
|
+
api: {
|
|
451
|
+
method: 'GET';
|
|
452
|
+
path: string;
|
|
453
|
+
};
|
|
454
|
+
} | {
|
|
455
|
+
kind: 'deepline_db_query';
|
|
456
|
+
datasetPath: string;
|
|
457
|
+
tableNamespace?: string;
|
|
458
|
+
sql: string;
|
|
459
|
+
maxRows: number;
|
|
460
|
+
api: {
|
|
461
|
+
method: 'POST';
|
|
462
|
+
path: '/api/v2/db/query';
|
|
463
|
+
};
|
|
464
|
+
} | {
|
|
465
|
+
kind: 'deepline_run_export';
|
|
466
|
+
runId: string;
|
|
467
|
+
datasetPath: string;
|
|
468
|
+
format: 'csv';
|
|
469
|
+
};
|
|
470
|
+
interface PlayRunPackage {
|
|
471
|
+
schemaVersion: 1;
|
|
472
|
+
kind: 'play_run';
|
|
473
|
+
run: {
|
|
474
|
+
id: string;
|
|
475
|
+
playName: string;
|
|
476
|
+
status: string;
|
|
477
|
+
dashboardUrl?: string;
|
|
478
|
+
updatedAt?: number | null;
|
|
479
|
+
startedAt?: number | null;
|
|
480
|
+
finishedAt?: number | null;
|
|
481
|
+
durationMs?: number | null;
|
|
482
|
+
error?: string;
|
|
483
|
+
};
|
|
484
|
+
steps: Array<Record<string, unknown>>;
|
|
485
|
+
outputs: Record<string, Record<string, unknown>>;
|
|
486
|
+
next?: {
|
|
487
|
+
inspect?: PlayRunActionPackage;
|
|
488
|
+
export?: PlayRunActionPackage;
|
|
489
|
+
query?: PlayRunActionPackage;
|
|
490
|
+
};
|
|
491
|
+
}
|
|
445
492
|
/**
|
|
446
493
|
* Current status of a play execution, returned by {@link DeeplineClient.getPlayStatus}.
|
|
447
494
|
*
|
|
@@ -475,8 +522,13 @@ interface PlayStatus {
|
|
|
475
522
|
progress?: PlayProgressStatus;
|
|
476
523
|
/** Partial or final result. Available once the play returns. */
|
|
477
524
|
result?: unknown;
|
|
525
|
+
/** Compact typed run package returned by current run status endpoints. */
|
|
526
|
+
package?: PlayRunPackage;
|
|
527
|
+
/** Compact typed output summaries, mirrored from the run package when present. */
|
|
528
|
+
outputs?: PlayRunPackage['outputs'];
|
|
478
529
|
/** Scheduler-backed run metadata when returned by the status endpoint. */
|
|
479
530
|
run?: {
|
|
531
|
+
id?: string;
|
|
480
532
|
startTime?: string | null;
|
|
481
533
|
closeTime?: string | null;
|
|
482
534
|
[key: string]: unknown;
|
|
@@ -492,6 +544,8 @@ interface PlayStatus {
|
|
|
492
544
|
eventKey?: string;
|
|
493
545
|
until?: number;
|
|
494
546
|
} | null;
|
|
547
|
+
/** Structured follow-up actions for inspect/query/export. */
|
|
548
|
+
next?: PlayRunPackage['next'] | Record<string, unknown>;
|
|
495
549
|
}
|
|
496
550
|
type LiveEventScope = 'play' | 'agent';
|
|
497
551
|
interface LiveEventEnvelope<TPayload = unknown> {
|
|
@@ -773,6 +827,8 @@ interface PlayRunStart {
|
|
|
773
827
|
dashboardUrl?: string;
|
|
774
828
|
/** Terminal status returned when the start request used a short completion wait. */
|
|
775
829
|
finalStatus?: unknown;
|
|
830
|
+
/** Canonical compact run package returned by current SDK/API responses. */
|
|
831
|
+
package?: PlayRunPackage;
|
|
776
832
|
}
|
|
777
833
|
/**
|
|
778
834
|
* Result returned by {@link DeeplineClient.checkPlayArtifact}.
|
|
@@ -966,7 +1022,9 @@ type PlaySheetRowsResult = {
|
|
|
966
1022
|
deltaCursor?: number;
|
|
967
1023
|
};
|
|
968
1024
|
type RunsNamespace = {
|
|
969
|
-
get: (runId: string
|
|
1025
|
+
get: (runId: string, options?: {
|
|
1026
|
+
full?: boolean;
|
|
1027
|
+
}) => Promise<PlayStatus>;
|
|
970
1028
|
list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
|
|
971
1029
|
tail: (runId: string, options?: RunsTailOptions) => Promise<PlayStatus>;
|
|
972
1030
|
logs: (runId: string, options?: RunsLogsOptions) => Promise<RunsLogsResult>;
|
|
@@ -1107,7 +1165,7 @@ declare class DeeplineClient {
|
|
|
1107
1165
|
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
1108
1166
|
* });
|
|
1109
1167
|
* ```
|
|
1110
|
-
|
|
1168
|
+
*/
|
|
1111
1169
|
startPlayRun(request: StartPlayRunRequest): Promise<PlayRunStart>;
|
|
1112
1170
|
startPlayRunStream(request: StartPlayRunRequest, options?: {
|
|
1113
1171
|
signal?: AbortSignal;
|
|
@@ -1293,6 +1351,7 @@ declare class DeeplineClient {
|
|
|
1293
1351
|
*/
|
|
1294
1352
|
getPlayStatus(workflowId: string, options?: {
|
|
1295
1353
|
billing?: boolean;
|
|
1354
|
+
full?: boolean;
|
|
1296
1355
|
}): Promise<PlayStatus>;
|
|
1297
1356
|
/**
|
|
1298
1357
|
* Stream semantic play-run events using the same SSE feed as the dashboard.
|
|
@@ -1354,7 +1413,9 @@ declare class DeeplineClient {
|
|
|
1354
1413
|
* deepline runs get <run-id> --json
|
|
1355
1414
|
* ```
|
|
1356
1415
|
*/
|
|
1357
|
-
getRunStatus(runId: string
|
|
1416
|
+
getRunStatus(runId: string, options?: {
|
|
1417
|
+
full?: boolean;
|
|
1418
|
+
}): Promise<PlayStatus>;
|
|
1358
1419
|
/**
|
|
1359
1420
|
* List play runs using the public runs resource model.
|
|
1360
1421
|
*
|
package/dist/index.js
CHANGED
|
@@ -216,12 +216,12 @@ function resolveConfig(options) {
|
|
|
216
216
|
|
|
217
217
|
// src/release.ts
|
|
218
218
|
var SDK_RELEASE = {
|
|
219
|
-
version: "0.1.
|
|
220
|
-
apiContract: "2026-05-
|
|
219
|
+
version: "0.1.54",
|
|
220
|
+
apiContract: "2026-05-run-response-package",
|
|
221
221
|
supportPolicy: {
|
|
222
|
-
latest: "0.1.
|
|
223
|
-
minimumSupported: "0.1.
|
|
224
|
-
deprecatedBelow: "0.1.
|
|
222
|
+
latest: "0.1.54",
|
|
223
|
+
minimumSupported: "0.1.53",
|
|
224
|
+
deprecatedBelow: "0.1.53"
|
|
225
225
|
}
|
|
226
226
|
};
|
|
227
227
|
|
|
@@ -555,15 +555,38 @@ function isTransientCompileManifestError(error) {
|
|
|
555
555
|
function isRecord(value) {
|
|
556
556
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
557
557
|
}
|
|
558
|
+
function isPlayRunPackage(value) {
|
|
559
|
+
return Boolean(
|
|
560
|
+
value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof value.run?.id === "string"
|
|
561
|
+
);
|
|
562
|
+
}
|
|
558
563
|
function normalizePlayStatus(raw) {
|
|
559
|
-
const
|
|
560
|
-
const
|
|
564
|
+
const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
|
|
565
|
+
const packageRun = runPackage?.run;
|
|
566
|
+
const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
|
|
567
|
+
const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
|
|
561
568
|
return {
|
|
562
569
|
...raw,
|
|
563
570
|
runId,
|
|
571
|
+
...runPackage ? { package: runPackage, outputs: runPackage.outputs } : {},
|
|
564
572
|
status
|
|
565
573
|
};
|
|
566
574
|
}
|
|
575
|
+
function normalizePlayRunStart(raw) {
|
|
576
|
+
const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
|
|
577
|
+
if (!runPackage) {
|
|
578
|
+
return raw;
|
|
579
|
+
}
|
|
580
|
+
const status = typeof runPackage.run.status === "string" ? runPackage.run.status : "running";
|
|
581
|
+
return {
|
|
582
|
+
workflowId: runPackage.run.id,
|
|
583
|
+
name: runPackage.run.playName,
|
|
584
|
+
status,
|
|
585
|
+
...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
|
|
586
|
+
...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
|
|
587
|
+
package: runPackage
|
|
588
|
+
};
|
|
589
|
+
}
|
|
567
590
|
function decodeBase64Bytes(value) {
|
|
568
591
|
const binary = atob(value);
|
|
569
592
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -593,25 +616,31 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
593
616
|
if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
|
|
594
617
|
return null;
|
|
595
618
|
}
|
|
596
|
-
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : state.runId;
|
|
597
|
-
const status = normalizeLiveStatus(payload.status) ?? state.status;
|
|
598
|
-
const
|
|
599
|
-
|
|
619
|
+
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
620
|
+
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
621
|
+
const progressPayload = isRecord(payload.progress) ? payload.progress : {};
|
|
622
|
+
const payloadLogs = readStringArray(payload.logs);
|
|
623
|
+
const progressLogs = readStringArray(progressPayload.logs);
|
|
624
|
+
const logs = payloadLogs.length > 0 ? payloadLogs : progressLogs;
|
|
625
|
+
if (logs.length > 0 || event.type === "play.run.snapshot" || event.type === "play.run.final_status" && !isPlayRunPackage(payload)) {
|
|
600
626
|
state.logs = logs;
|
|
601
627
|
}
|
|
602
628
|
if ("result" in payload) {
|
|
603
629
|
state.result = payload.result;
|
|
630
|
+
} else if (isPlayRunPackage(payload)) {
|
|
631
|
+
state.result = payload;
|
|
604
632
|
}
|
|
605
633
|
if (typeof payload.error === "string" && payload.error.trim()) {
|
|
606
634
|
state.error = payload.error;
|
|
607
635
|
}
|
|
608
636
|
state.runId = runId;
|
|
609
637
|
state.status = status;
|
|
610
|
-
const progressRecord =
|
|
638
|
+
const progressRecord = progressPayload;
|
|
611
639
|
const next = {
|
|
612
640
|
...payload,
|
|
613
641
|
runId,
|
|
614
642
|
status,
|
|
643
|
+
...isPlayRunPackage(payload) ? { package: payload, outputs: payload.outputs } : {},
|
|
615
644
|
progress: {
|
|
616
645
|
...progressRecord,
|
|
617
646
|
status: typeof progressRecord.status === "string" ? progressRecord.status : status,
|
|
@@ -627,7 +656,8 @@ function playRunResultFromStatus(status, startedAt, fallbackRunId) {
|
|
|
627
656
|
return {
|
|
628
657
|
success: status.status === "completed",
|
|
629
658
|
runId: status.runId || fallbackRunId,
|
|
630
|
-
result: status.result,
|
|
659
|
+
result: status.package ?? status.result,
|
|
660
|
+
...status.package ? { package: status.package } : {},
|
|
631
661
|
logs: status.progress?.logs ?? [],
|
|
632
662
|
durationMs: Date.now() - startedAt,
|
|
633
663
|
error: status.progress?.error ?? (status.status !== "completed" ? status.status : void 0)
|
|
@@ -657,7 +687,7 @@ var DeeplineClient = class {
|
|
|
657
687
|
this.config = resolveConfig(options);
|
|
658
688
|
this.http = new HttpClient(this.config);
|
|
659
689
|
this.runs = {
|
|
660
|
-
get: (runId) => this.getRunStatus(runId),
|
|
690
|
+
get: (runId, options2) => this.getRunStatus(runId, options2),
|
|
661
691
|
list: (options2) => this.listRuns(options2),
|
|
662
692
|
tail: (runId, options2) => this.tailRun(runId, options2),
|
|
663
693
|
logs: (runId, options2) => this.getRunLogs(runId, options2),
|
|
@@ -876,9 +906,9 @@ var DeeplineClient = class {
|
|
|
876
906
|
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
877
907
|
* });
|
|
878
908
|
* ```
|
|
879
|
-
|
|
909
|
+
*/
|
|
880
910
|
async startPlayRun(request) {
|
|
881
|
-
|
|
911
|
+
const response = await this.http.post("/api/v2/plays/run", {
|
|
882
912
|
...request.name ? { name: request.name } : {},
|
|
883
913
|
...request.revisionId ? { revisionId: request.revisionId } : {},
|
|
884
914
|
...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
|
|
@@ -901,6 +931,7 @@ var DeeplineClient = class {
|
|
|
901
931
|
// different profile pass `request.profile` explicitly.
|
|
902
932
|
...request.profile ? { profile: request.profile } : {}
|
|
903
933
|
});
|
|
934
|
+
return normalizePlayRunStart(response);
|
|
904
935
|
}
|
|
905
936
|
async *startPlayRunStream(request, options) {
|
|
906
937
|
const body = {
|
|
@@ -1184,6 +1215,9 @@ var DeeplineClient = class {
|
|
|
1184
1215
|
if (options?.billing === false) {
|
|
1185
1216
|
params.set("billing", "false");
|
|
1186
1217
|
}
|
|
1218
|
+
if (options?.full === true) {
|
|
1219
|
+
params.set("full", "true");
|
|
1220
|
+
}
|
|
1187
1221
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1188
1222
|
const response = await this.http.get(
|
|
1189
1223
|
`/api/v2/plays/run/${encodeURIComponent(workflowId)}${query}`
|
|
@@ -1272,9 +1306,14 @@ var DeeplineClient = class {
|
|
|
1272
1306
|
* deepline runs get <run-id> --json
|
|
1273
1307
|
* ```
|
|
1274
1308
|
*/
|
|
1275
|
-
async getRunStatus(runId) {
|
|
1309
|
+
async getRunStatus(runId, options) {
|
|
1310
|
+
const params = new URLSearchParams();
|
|
1311
|
+
if (options?.full === true) {
|
|
1312
|
+
params.set("full", "true");
|
|
1313
|
+
}
|
|
1314
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1276
1315
|
const response = await this.http.get(
|
|
1277
|
-
`/api/v2/runs/${encodeURIComponent(runId)}`
|
|
1316
|
+
`/api/v2/runs/${encodeURIComponent(runId)}${query}`
|
|
1278
1317
|
);
|
|
1279
1318
|
return normalizePlayStatus(response);
|
|
1280
1319
|
}
|
|
@@ -2191,6 +2230,9 @@ var DeeplinePlayJobImpl = class {
|
|
|
2191
2230
|
status.progress?.error || `Play run ${this.id} ended with ${status.status}.`
|
|
2192
2231
|
);
|
|
2193
2232
|
}
|
|
2233
|
+
if (status.package) {
|
|
2234
|
+
return status.package;
|
|
2235
|
+
}
|
|
2194
2236
|
const payload = status.result;
|
|
2195
2237
|
return (payload && "output" in payload ? payload.output : status.result) ?? null;
|
|
2196
2238
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -170,12 +170,12 @@ function resolveConfig(options) {
|
|
|
170
170
|
|
|
171
171
|
// src/release.ts
|
|
172
172
|
var SDK_RELEASE = {
|
|
173
|
-
version: "0.1.
|
|
174
|
-
apiContract: "2026-05-
|
|
173
|
+
version: "0.1.54",
|
|
174
|
+
apiContract: "2026-05-run-response-package",
|
|
175
175
|
supportPolicy: {
|
|
176
|
-
latest: "0.1.
|
|
177
|
-
minimumSupported: "0.1.
|
|
178
|
-
deprecatedBelow: "0.1.
|
|
176
|
+
latest: "0.1.54",
|
|
177
|
+
minimumSupported: "0.1.53",
|
|
178
|
+
deprecatedBelow: "0.1.53"
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
|
|
@@ -509,15 +509,38 @@ function isTransientCompileManifestError(error) {
|
|
|
509
509
|
function isRecord(value) {
|
|
510
510
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
511
511
|
}
|
|
512
|
+
function isPlayRunPackage(value) {
|
|
513
|
+
return Boolean(
|
|
514
|
+
value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof value.run?.id === "string"
|
|
515
|
+
);
|
|
516
|
+
}
|
|
512
517
|
function normalizePlayStatus(raw) {
|
|
513
|
-
const
|
|
514
|
-
const
|
|
518
|
+
const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
|
|
519
|
+
const packageRun = runPackage?.run;
|
|
520
|
+
const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
|
|
521
|
+
const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
|
|
515
522
|
return {
|
|
516
523
|
...raw,
|
|
517
524
|
runId,
|
|
525
|
+
...runPackage ? { package: runPackage, outputs: runPackage.outputs } : {},
|
|
518
526
|
status
|
|
519
527
|
};
|
|
520
528
|
}
|
|
529
|
+
function normalizePlayRunStart(raw) {
|
|
530
|
+
const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
|
|
531
|
+
if (!runPackage) {
|
|
532
|
+
return raw;
|
|
533
|
+
}
|
|
534
|
+
const status = typeof runPackage.run.status === "string" ? runPackage.run.status : "running";
|
|
535
|
+
return {
|
|
536
|
+
workflowId: runPackage.run.id,
|
|
537
|
+
name: runPackage.run.playName,
|
|
538
|
+
status,
|
|
539
|
+
...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
|
|
540
|
+
...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
|
|
541
|
+
package: runPackage
|
|
542
|
+
};
|
|
543
|
+
}
|
|
521
544
|
function decodeBase64Bytes(value) {
|
|
522
545
|
const binary = atob(value);
|
|
523
546
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -547,25 +570,31 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
547
570
|
if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
|
|
548
571
|
return null;
|
|
549
572
|
}
|
|
550
|
-
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : state.runId;
|
|
551
|
-
const status = normalizeLiveStatus(payload.status) ?? state.status;
|
|
552
|
-
const
|
|
553
|
-
|
|
573
|
+
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
574
|
+
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
575
|
+
const progressPayload = isRecord(payload.progress) ? payload.progress : {};
|
|
576
|
+
const payloadLogs = readStringArray(payload.logs);
|
|
577
|
+
const progressLogs = readStringArray(progressPayload.logs);
|
|
578
|
+
const logs = payloadLogs.length > 0 ? payloadLogs : progressLogs;
|
|
579
|
+
if (logs.length > 0 || event.type === "play.run.snapshot" || event.type === "play.run.final_status" && !isPlayRunPackage(payload)) {
|
|
554
580
|
state.logs = logs;
|
|
555
581
|
}
|
|
556
582
|
if ("result" in payload) {
|
|
557
583
|
state.result = payload.result;
|
|
584
|
+
} else if (isPlayRunPackage(payload)) {
|
|
585
|
+
state.result = payload;
|
|
558
586
|
}
|
|
559
587
|
if (typeof payload.error === "string" && payload.error.trim()) {
|
|
560
588
|
state.error = payload.error;
|
|
561
589
|
}
|
|
562
590
|
state.runId = runId;
|
|
563
591
|
state.status = status;
|
|
564
|
-
const progressRecord =
|
|
592
|
+
const progressRecord = progressPayload;
|
|
565
593
|
const next = {
|
|
566
594
|
...payload,
|
|
567
595
|
runId,
|
|
568
596
|
status,
|
|
597
|
+
...isPlayRunPackage(payload) ? { package: payload, outputs: payload.outputs } : {},
|
|
569
598
|
progress: {
|
|
570
599
|
...progressRecord,
|
|
571
600
|
status: typeof progressRecord.status === "string" ? progressRecord.status : status,
|
|
@@ -581,7 +610,8 @@ function playRunResultFromStatus(status, startedAt, fallbackRunId) {
|
|
|
581
610
|
return {
|
|
582
611
|
success: status.status === "completed",
|
|
583
612
|
runId: status.runId || fallbackRunId,
|
|
584
|
-
result: status.result,
|
|
613
|
+
result: status.package ?? status.result,
|
|
614
|
+
...status.package ? { package: status.package } : {},
|
|
585
615
|
logs: status.progress?.logs ?? [],
|
|
586
616
|
durationMs: Date.now() - startedAt,
|
|
587
617
|
error: status.progress?.error ?? (status.status !== "completed" ? status.status : void 0)
|
|
@@ -611,7 +641,7 @@ var DeeplineClient = class {
|
|
|
611
641
|
this.config = resolveConfig(options);
|
|
612
642
|
this.http = new HttpClient(this.config);
|
|
613
643
|
this.runs = {
|
|
614
|
-
get: (runId) => this.getRunStatus(runId),
|
|
644
|
+
get: (runId, options2) => this.getRunStatus(runId, options2),
|
|
615
645
|
list: (options2) => this.listRuns(options2),
|
|
616
646
|
tail: (runId, options2) => this.tailRun(runId, options2),
|
|
617
647
|
logs: (runId, options2) => this.getRunLogs(runId, options2),
|
|
@@ -830,9 +860,9 @@ var DeeplineClient = class {
|
|
|
830
860
|
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
831
861
|
* });
|
|
832
862
|
* ```
|
|
833
|
-
|
|
863
|
+
*/
|
|
834
864
|
async startPlayRun(request) {
|
|
835
|
-
|
|
865
|
+
const response = await this.http.post("/api/v2/plays/run", {
|
|
836
866
|
...request.name ? { name: request.name } : {},
|
|
837
867
|
...request.revisionId ? { revisionId: request.revisionId } : {},
|
|
838
868
|
...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
|
|
@@ -855,6 +885,7 @@ var DeeplineClient = class {
|
|
|
855
885
|
// different profile pass `request.profile` explicitly.
|
|
856
886
|
...request.profile ? { profile: request.profile } : {}
|
|
857
887
|
});
|
|
888
|
+
return normalizePlayRunStart(response);
|
|
858
889
|
}
|
|
859
890
|
async *startPlayRunStream(request, options) {
|
|
860
891
|
const body = {
|
|
@@ -1138,6 +1169,9 @@ var DeeplineClient = class {
|
|
|
1138
1169
|
if (options?.billing === false) {
|
|
1139
1170
|
params.set("billing", "false");
|
|
1140
1171
|
}
|
|
1172
|
+
if (options?.full === true) {
|
|
1173
|
+
params.set("full", "true");
|
|
1174
|
+
}
|
|
1141
1175
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1142
1176
|
const response = await this.http.get(
|
|
1143
1177
|
`/api/v2/plays/run/${encodeURIComponent(workflowId)}${query}`
|
|
@@ -1226,9 +1260,14 @@ var DeeplineClient = class {
|
|
|
1226
1260
|
* deepline runs get <run-id> --json
|
|
1227
1261
|
* ```
|
|
1228
1262
|
*/
|
|
1229
|
-
async getRunStatus(runId) {
|
|
1263
|
+
async getRunStatus(runId, options) {
|
|
1264
|
+
const params = new URLSearchParams();
|
|
1265
|
+
if (options?.full === true) {
|
|
1266
|
+
params.set("full", "true");
|
|
1267
|
+
}
|
|
1268
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1230
1269
|
const response = await this.http.get(
|
|
1231
|
-
`/api/v2/runs/${encodeURIComponent(runId)}`
|
|
1270
|
+
`/api/v2/runs/${encodeURIComponent(runId)}${query}`
|
|
1232
1271
|
);
|
|
1233
1272
|
return normalizePlayStatus(response);
|
|
1234
1273
|
}
|
|
@@ -2145,6 +2184,9 @@ var DeeplinePlayJobImpl = class {
|
|
|
2145
2184
|
status.progress?.error || `Play run ${this.id} ended with ${status.status}.`
|
|
2146
2185
|
);
|
|
2147
2186
|
}
|
|
2187
|
+
if (status.package) {
|
|
2188
|
+
return status.package;
|
|
2189
|
+
}
|
|
2148
2190
|
const payload = status.result;
|
|
2149
2191
|
return (payload && "output" in payload ? payload.output : status.result) ?? null;
|
|
2150
2192
|
}
|
|
@@ -686,8 +686,24 @@ async function createDynamicWorkflowInstance(input: {
|
|
|
686
686
|
});
|
|
687
687
|
}
|
|
688
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Returns the slug-rooted Durable Scope key for the workflow pool DO.
|
|
691
|
+
*
|
|
692
|
+
* The pool DO name is a *shared* (non-runId) key, so without slug-scoping
|
|
693
|
+
* a single Cloudflare account running multiple PR previews would collide
|
|
694
|
+
* on `workflow-pool:v2`. The slug isolates the pool per-preview.
|
|
695
|
+
*
|
|
696
|
+
* See docs/adr/0005-durable-scope.md.
|
|
697
|
+
*/
|
|
698
|
+
function workflowPoolDurableObjectName(env: CoordinatorEnv): string {
|
|
699
|
+
const slug = env.DEEPLINE_PLAY_PREVIEW_SLUG?.trim();
|
|
700
|
+
return slug ? `${slug}:${WORKFLOW_POOL_DO_NAME}` : WORKFLOW_POOL_DO_NAME;
|
|
701
|
+
}
|
|
702
|
+
|
|
689
703
|
function workflowPoolDurableObject(env: CoordinatorEnv): DurableObjectStub {
|
|
690
|
-
return env.PLAY_DEDUP.get(
|
|
704
|
+
return env.PLAY_DEDUP.get(
|
|
705
|
+
env.PLAY_DEDUP.idFromName(workflowPoolDurableObjectName(env)),
|
|
706
|
+
);
|
|
691
707
|
}
|
|
692
708
|
|
|
693
709
|
async function callWorkflowPool<T>(
|