deepline 0.3.201 → 0.3.203
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/client.ts +62 -1
- package/dist/bundling-sources/sdk/src/http.ts +55 -6
- package/dist/bundling-sources/sdk/src/index.ts +1 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +4 -2
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +460 -96
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +11 -1
- package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +6 -2
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +401 -2
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +458 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-no-progress.ts +40 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +25 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +119 -171
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +37 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +238 -204
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +16 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +136 -25
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +64 -15
- package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +5 -5
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/result-receipt-policy.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +14 -5
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -1
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +3 -9
- package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +1 -1
- package/dist/cli/index.js +362 -55
- package/dist/cli/index.mjs +365 -57
- package/dist/index.d.mts +129 -1
- package/dist/index.d.ts +129 -1
- package/dist/index.js +64 -7
- package/dist/index.mjs +64 -7
- package/dist/install-integrity.json +3 -0
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
|
@@ -123,7 +123,10 @@ import {
|
|
|
123
123
|
TOOL_EXECUTION_ERROR_SCHEMA_HEADER,
|
|
124
124
|
TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
|
|
125
125
|
} from '../../shared_libs/plays/tool-execution-error';
|
|
126
|
-
import {
|
|
126
|
+
import {
|
|
127
|
+
decodePlayRunPublicStatus,
|
|
128
|
+
type PlayRunPublicStatus,
|
|
129
|
+
} from '../../shared_libs/play-runtime/run-lifecycle-policy.js';
|
|
127
130
|
import {
|
|
128
131
|
legacyRawFromToolResponseRawV2,
|
|
129
132
|
providerMetaFromToolResponseRawV2,
|
|
@@ -959,6 +962,8 @@ export type PlaySecretCheck = {
|
|
|
959
962
|
export type RunsNamespace = {
|
|
960
963
|
/** Get current run status by public run id. */
|
|
961
964
|
get: (runId: string, options?: RunsGetOptions) => Promise<PlayStatus>;
|
|
965
|
+
/** Read bounded scalar lifecycle and confirmed work counts only. */
|
|
966
|
+
status: (runId: string) => Promise<RunLifecycleStatus>;
|
|
962
967
|
/** Explicitly read the retained original input (may include customer data). */
|
|
963
968
|
input: (runId: string) => Promise<{
|
|
964
969
|
runId: string;
|
|
@@ -985,6 +990,8 @@ export type RunsNamespace = {
|
|
|
985
990
|
limit?: number;
|
|
986
991
|
offset?: number;
|
|
987
992
|
rowMode?: 'output' | 'all';
|
|
993
|
+
/** Cancel the page request, including its response body and retry waits. */
|
|
994
|
+
signal?: AbortSignal;
|
|
988
995
|
}) => Promise<PlaySheetRowsResult>;
|
|
989
996
|
/** Stop a running/waiting run. */
|
|
990
997
|
stop: (
|
|
@@ -1006,6 +1013,48 @@ export type RunsNamespace = {
|
|
|
1006
1013
|
};
|
|
1007
1014
|
};
|
|
1008
1015
|
|
|
1016
|
+
/** Result of the bounded `/api/v2/runs/:runId/status` endpoint. */
|
|
1017
|
+
export type RunLifecycleStatus =
|
|
1018
|
+
| { available: false; runId: string }
|
|
1019
|
+
| {
|
|
1020
|
+
available: true;
|
|
1021
|
+
runId: string;
|
|
1022
|
+
lifecycle: {
|
|
1023
|
+
status: PlayRunPublicStatus;
|
|
1024
|
+
updatedAt: number;
|
|
1025
|
+
startedAt: number | null;
|
|
1026
|
+
finishedAt: number | null;
|
|
1027
|
+
};
|
|
1028
|
+
steps: {
|
|
1029
|
+
observed: number;
|
|
1030
|
+
running: number;
|
|
1031
|
+
completed: number;
|
|
1032
|
+
failed: number;
|
|
1033
|
+
skipped: number;
|
|
1034
|
+
confirmed: boolean;
|
|
1035
|
+
};
|
|
1036
|
+
/** Sums across observed step.progress records, not unique output rows. */
|
|
1037
|
+
mapStepWork: {
|
|
1038
|
+
sourceSteps: number;
|
|
1039
|
+
completed: { value: number | null; confirmed: boolean };
|
|
1040
|
+
total: { value: number | null; confirmed: boolean };
|
|
1041
|
+
failed: { value: number | null; confirmed: boolean };
|
|
1042
|
+
startedRows: { value: number | null; confirmed: boolean };
|
|
1043
|
+
activeRows: { value: number | null; confirmed: boolean };
|
|
1044
|
+
waitingRows: { value: number | null; confirmed: boolean };
|
|
1045
|
+
completedRows: { value: number | null; confirmed: boolean };
|
|
1046
|
+
supersededRows: { value: number | null; confirmed: boolean };
|
|
1047
|
+
};
|
|
1048
|
+
datasets: {
|
|
1049
|
+
observed: number;
|
|
1050
|
+
persistedRows: { value: number | null; confirmed: boolean };
|
|
1051
|
+
succeededRows: { value: number | null; confirmed: boolean };
|
|
1052
|
+
failedRows: { value: number | null; confirmed: boolean };
|
|
1053
|
+
complete: { value: boolean | null; confirmed: boolean };
|
|
1054
|
+
};
|
|
1055
|
+
wait: { kind: string | null; until: number | null; confirmed: boolean };
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1009
1058
|
/** Options for {@link RunsNamespace.stopAll} / {@link DeeplineClient.stopAllRuns}. */
|
|
1010
1059
|
export type StopAllRunsOptions = {
|
|
1011
1060
|
/** Enumerate the candidate runs without cancelling or mutating anything. */
|
|
@@ -2845,6 +2894,7 @@ export class DeeplineClient {
|
|
|
2845
2894
|
this.http = new HttpClient(this.config);
|
|
2846
2895
|
this.runs = {
|
|
2847
2896
|
get: (runId, options) => this.getRunStatus(runId, options),
|
|
2897
|
+
status: (runId) => this.getRunLifecycleStatus(runId),
|
|
2848
2898
|
list: (options) => this.listRuns(options),
|
|
2849
2899
|
listPage: (options) => this.listRunsPage(options),
|
|
2850
2900
|
tail: (runId, options) => this.tailRun(runId, options),
|
|
@@ -4793,6 +4843,14 @@ export class DeeplineClient {
|
|
|
4793
4843
|
};
|
|
4794
4844
|
}
|
|
4795
4845
|
|
|
4846
|
+
/** Read only the bounded scalar projection; does not hydrate the run package. */
|
|
4847
|
+
async getRunLifecycleStatus(runId: string): Promise<RunLifecycleStatus> {
|
|
4848
|
+
const response = await this.http.get<RunLifecycleStatus>(
|
|
4849
|
+
`/api/v2/runs/${encodeURIComponent(runId)}/status`,
|
|
4850
|
+
);
|
|
4851
|
+
return response;
|
|
4852
|
+
}
|
|
4853
|
+
|
|
4796
4854
|
/**
|
|
4797
4855
|
* List play runs using the public runs resource model.
|
|
4798
4856
|
*
|
|
@@ -5256,6 +5314,8 @@ export class DeeplineClient {
|
|
|
5256
5314
|
limit?: number;
|
|
5257
5315
|
offset?: number;
|
|
5258
5316
|
rowMode?: 'output' | 'all';
|
|
5317
|
+
/** Cancel the page request, including its response body and retry waits. */
|
|
5318
|
+
signal?: AbortSignal;
|
|
5259
5319
|
}): Promise<PlaySheetRowsResult> {
|
|
5260
5320
|
const params = new URLSearchParams({
|
|
5261
5321
|
tableNamespace: input.tableNamespace,
|
|
@@ -5270,6 +5330,7 @@ export class DeeplineClient {
|
|
|
5270
5330
|
}
|
|
5271
5331
|
const result = await this.http.get<PlaySheetRowsResult>(
|
|
5272
5332
|
`/api/v2/plays/${encodeURIComponent(input.playName)}/sheet?${params.toString()}`,
|
|
5333
|
+
{ signal: input.signal },
|
|
5273
5334
|
);
|
|
5274
5335
|
const requestedRunId = input.runId?.trim() || '';
|
|
5275
5336
|
if (requestedRunId) {
|
|
@@ -59,6 +59,8 @@ interface RequestOptions {
|
|
|
59
59
|
headers?: Record<string, string>;
|
|
60
60
|
/** Per-request timeout override in milliseconds. */
|
|
61
61
|
timeout?: number;
|
|
62
|
+
/** Cancel this request, including body reads, failover, and retry waits. */
|
|
63
|
+
signal?: AbortSignal;
|
|
62
64
|
/**
|
|
63
65
|
* Retry HTTP 408/425/5xx JSON API responses. Use only for idempotent requests;
|
|
64
66
|
* most mutating API calls must fail loudly after the first server response.
|
|
@@ -93,6 +95,12 @@ type RequestAbortTaggedError = Error & {
|
|
|
93
95
|
[REQUEST_ABORT_MARKER]?: true;
|
|
94
96
|
};
|
|
95
97
|
|
|
98
|
+
function requestCancelledError(signal: AbortSignal): RequestAbortTaggedError {
|
|
99
|
+
const error = withErrorCause(new Error('Request aborted'), signal.reason);
|
|
100
|
+
(error as RequestAbortTaggedError)[REQUEST_ABORT_MARKER] = true;
|
|
101
|
+
return error;
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
function normalizeRequestAbortError(
|
|
97
105
|
error: unknown,
|
|
98
106
|
input: { timeoutMs: number; timedOut: boolean },
|
|
@@ -391,7 +399,11 @@ export class HttpClient {
|
|
|
391
399
|
|
|
392
400
|
const maxRetries = options?.maxRetries ?? this.config.maxRetries;
|
|
393
401
|
|
|
394
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
402
|
+
requestAttempts: for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
403
|
+
if (options?.signal?.aborted) {
|
|
404
|
+
lastError = requestCancelledError(options.signal);
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
395
407
|
if (attempt > 0) {
|
|
396
408
|
const backoffMs = Math.min(1000 * Math.pow(2, attempt - 1), 30_000);
|
|
397
409
|
const delayMs =
|
|
@@ -399,10 +411,19 @@ export class HttpClient {
|
|
|
399
411
|
? backoffMs
|
|
400
412
|
: Math.max(backoffMs, retryAfterDelayMs);
|
|
401
413
|
retryAfterDelayMs = null;
|
|
402
|
-
|
|
414
|
+
try {
|
|
415
|
+
await sleep(delayMs, options?.signal);
|
|
416
|
+
} catch (error) {
|
|
417
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
403
420
|
}
|
|
404
421
|
|
|
405
422
|
for (const candidateUrl of candidateUrls) {
|
|
423
|
+
if (options?.signal?.aborted) {
|
|
424
|
+
lastError = requestCancelledError(options.signal);
|
|
425
|
+
break requestAttempts;
|
|
426
|
+
}
|
|
406
427
|
const controller = new AbortController();
|
|
407
428
|
const timeoutMs = options?.timeout ?? this.config.timeout;
|
|
408
429
|
let requestTimedOut = false;
|
|
@@ -410,6 +431,10 @@ export class HttpClient {
|
|
|
410
431
|
requestTimedOut = true;
|
|
411
432
|
controller.abort();
|
|
412
433
|
}, timeoutMs);
|
|
434
|
+
const abortRequest = () => controller.abort();
|
|
435
|
+
options?.signal?.addEventListener('abort', abortRequest, {
|
|
436
|
+
once: true,
|
|
437
|
+
});
|
|
413
438
|
|
|
414
439
|
try {
|
|
415
440
|
const response = await fetch(candidateUrl, {
|
|
@@ -432,9 +457,10 @@ export class HttpClient {
|
|
|
432
457
|
return null as T;
|
|
433
458
|
}
|
|
434
459
|
|
|
435
|
-
|
|
436
|
-
|
|
460
|
+
// Receiving headers is not completion: a stalled response body must
|
|
461
|
+
// remain inside the same request deadline and abort its connection.
|
|
437
462
|
const body = await response.text();
|
|
463
|
+
clearTimeout(timeoutId);
|
|
438
464
|
const parsed = parseResponseBody(body);
|
|
439
465
|
|
|
440
466
|
const structuredToolError =
|
|
@@ -584,6 +610,10 @@ export class HttpClient {
|
|
|
584
610
|
return parsed as T;
|
|
585
611
|
} catch (error) {
|
|
586
612
|
clearTimeout(timeoutId);
|
|
613
|
+
if (options?.signal?.aborted) {
|
|
614
|
+
lastError = requestCancelledError(options.signal);
|
|
615
|
+
break requestAttempts;
|
|
616
|
+
}
|
|
587
617
|
if (error instanceof AuthError || error instanceof DeeplineError) {
|
|
588
618
|
throw error;
|
|
589
619
|
}
|
|
@@ -595,6 +625,9 @@ export class HttpClient {
|
|
|
595
625
|
timeoutMs,
|
|
596
626
|
timedOut: requestTimedOut,
|
|
597
627
|
});
|
|
628
|
+
} finally {
|
|
629
|
+
clearTimeout(timeoutId);
|
|
630
|
+
options?.signal?.removeEventListener('abort', abortRequest);
|
|
598
631
|
}
|
|
599
632
|
}
|
|
600
633
|
|
|
@@ -666,6 +699,7 @@ export class HttpClient {
|
|
|
666
699
|
RequestOptions,
|
|
667
700
|
| 'retryApiErrors'
|
|
668
701
|
| 'timeout'
|
|
702
|
+
| 'signal'
|
|
669
703
|
| 'maxRetries'
|
|
670
704
|
| 'exactUrlOnly'
|
|
671
705
|
| 'toolId'
|
|
@@ -1087,8 +1121,23 @@ function decodeSseFrame<TEvent extends LiveEventEnvelope>(
|
|
|
1087
1121
|
return parsed as TEvent;
|
|
1088
1122
|
}
|
|
1089
1123
|
|
|
1090
|
-
function sleep(ms: number): Promise<void> {
|
|
1091
|
-
return new Promise((resolve) =>
|
|
1124
|
+
function sleep(ms: number, signal?: AbortSignal): Promise<void> {
|
|
1125
|
+
return new Promise((resolve, reject) => {
|
|
1126
|
+
if (signal?.aborted) {
|
|
1127
|
+
reject(requestCancelledError(signal));
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
const timeoutId = setTimeout(() => {
|
|
1131
|
+
signal?.removeEventListener('abort', abort);
|
|
1132
|
+
resolve();
|
|
1133
|
+
}, ms);
|
|
1134
|
+
const abort = () => {
|
|
1135
|
+
clearTimeout(timeoutId);
|
|
1136
|
+
signal?.removeEventListener('abort', abort);
|
|
1137
|
+
reject(requestCancelledError(signal!));
|
|
1138
|
+
};
|
|
1139
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
1140
|
+
});
|
|
1092
1141
|
}
|
|
1093
1142
|
|
|
1094
1143
|
function withCoworkNetworkHint(message: string): string {
|
|
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
|
|
|
200
200
|
// getters keep their established compatibility behavior.
|
|
201
201
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
202
202
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
203
|
-
version: '0.3.
|
|
203
|
+
version: '0.3.203',
|
|
204
204
|
updateSummary:
|
|
205
205
|
'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
|
|
206
206
|
packageCapabilities: {
|
|
@@ -763,6 +763,14 @@ export interface PlayRunPackage {
|
|
|
763
763
|
path: string;
|
|
764
764
|
tableNamespace?: string;
|
|
765
765
|
rowCount?: number;
|
|
766
|
+
/** The materialized dataset count is exact only after this lifecycle completes. */
|
|
767
|
+
lifecycle?: {
|
|
768
|
+
phase: 'registered' | 'available' | 'failed';
|
|
769
|
+
complete: boolean;
|
|
770
|
+
persistedRowsAtLeast: number;
|
|
771
|
+
succeededRowsAtLeast: number;
|
|
772
|
+
failedRowsAtLeast: number;
|
|
773
|
+
};
|
|
766
774
|
sqlTableName?: string;
|
|
767
775
|
sqlQualifiedTableName?: string;
|
|
768
776
|
recovered?: true;
|
|
@@ -978,6 +978,9 @@ function isRetryableAppRuntimeAction(
|
|
|
978
978
|
): boolean {
|
|
979
979
|
return (
|
|
980
980
|
action === 'append_run_events' ||
|
|
981
|
+
// Retrying with the same owner refreshes the lock; a different owner
|
|
982
|
+
// remains excluded by the database predicate even if the first reply was lost.
|
|
983
|
+
action === 'acquire_runtime_receipt_execution_lock' ||
|
|
981
984
|
// Classification remains replay-safe for the durable outbox even though
|
|
982
985
|
// projectRunEventsViaAppRuntime disables in-process transport retries.
|
|
983
986
|
action === 'project_run_events' ||
|
|
@@ -994,8 +997,6 @@ function isRetryableAppRuntimeAction(
|
|
|
994
997
|
action === 'heartbeat_runtime_step_receipts' ||
|
|
995
998
|
action === 'claim_runtime_step_receipt' ||
|
|
996
999
|
action === 'claim_runtime_step_receipts' ||
|
|
997
|
-
// Replaying the same owner only renews its existing execution fence.
|
|
998
|
-
action === 'acquire_runtime_receipt_execution_lock' ||
|
|
999
1000
|
action === 'mark_runtime_step_receipt_running' ||
|
|
1000
1001
|
action === 'mark_runtime_step_receipts_running' ||
|
|
1001
1002
|
action === 'mark_runtime_step_receipts_queued' ||
|
|
@@ -1021,6 +1022,7 @@ function isRuntimeStepReceiptAction(
|
|
|
1021
1022
|
action: RuntimeApiRequest['action'],
|
|
1022
1023
|
): boolean {
|
|
1023
1024
|
return (
|
|
1025
|
+
action === 'acquire_runtime_receipt_execution_lock' ||
|
|
1024
1026
|
action === 'get_runtime_step_receipt' ||
|
|
1025
1027
|
action === 'get_runtime_step_receipts' ||
|
|
1026
1028
|
action === 'heartbeat_runtime_step_receipts' ||
|