deepline 0.3.524 → 0.3.526
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/agent-runtime.ts +98 -0
- package/dist/bundling-sources/sdk/src/client-core.ts +8 -0
- package/dist/bundling-sources/sdk/src/http-core.ts +14 -0
- package/dist/bundling-sources/sdk/src/plays/play-description.ts +1 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +10 -0
- package/dist/bundling-sources/shared_libs/observability/dlq.ts +33 -5
- package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
- package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +38 -0
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +94 -9
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure-class.ts +98 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-retry-summary.ts +202 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +60 -8
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +112 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +39 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-inventory.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +52 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-retry-facts.ts +62 -0
- package/dist/cli/{auth-QXJMVLPN.mjs → auth-JATW5XZE.mjs} +5 -5
- package/dist/cli/auth-L2POG3LL.js +43 -0
- package/dist/cli/{billing-N5R4HTHT.js → billing-TSHBJIJS.js} +83 -83
- package/dist/cli/{billing-SNSIFM4B.mjs → billing-UT5LIESH.mjs} +8 -8
- package/dist/cli/{chunk-PFKWKWUJ.mjs → chunk-26ULNPQ7.mjs} +2 -2
- package/dist/cli/{chunk-OQ5G7RFQ.mjs → chunk-2GJW4RAQ.mjs} +70 -3
- package/dist/cli/{chunk-HLAFGQPV.mjs → chunk-2JNX3MDG.mjs} +5 -2
- package/dist/cli/{chunk-V7KUBDEB.js → chunk-3MYI3IXW.js} +144 -141
- package/dist/cli/{chunk-WOEPDSO3.js → chunk-3ZEV5BS5.js} +26 -26
- package/dist/cli/{chunk-ATATJNJ6.js → chunk-46HEYGLY.js} +9 -9
- package/dist/cli/{chunk-I75VRGQG.js → chunk-477PXM65.js} +22 -22
- package/dist/cli/{chunk-RVHUW4TN.js → chunk-5YAJGRWB.js} +17 -17
- package/dist/cli/{chunk-T43FF5PF.mjs → chunk-6COGHW7B.mjs} +2 -2
- package/dist/cli/{chunk-V4RJ57MA.js → chunk-6DHEV6IA.js} +2 -2
- package/dist/cli/{chunk-VHTVXS5A.js → chunk-6H56LKJB.js} +16 -16
- package/dist/cli/{chunk-YKFW3NNA.mjs → chunk-6JMWATX5.mjs} +5 -5
- package/dist/cli/{chunk-II3BJKCH.mjs → chunk-77RAGJIZ.mjs} +2 -2
- package/dist/cli/{chunk-ITJ7NB2D.mjs → chunk-7AOFSZJM.mjs} +3 -1
- package/dist/cli/{chunk-OCT4SUJA.js → chunk-7COEN3IR.js} +146 -79
- package/dist/cli/{chunk-XURWFEXM.mjs → chunk-7FCD34YS.mjs} +31 -17
- package/dist/cli/{chunk-BXVYVIMB.js → chunk-B33J4YCC.js} +3 -3
- package/dist/cli/{chunk-RTDX5NNN.mjs → chunk-BFH3DJYV.mjs} +84 -57
- package/dist/cli/{chunk-GJYLC4JB.mjs → chunk-BNH4Y35W.mjs} +2 -2
- package/dist/cli/{chunk-GMO3JDZA.mjs → chunk-BVITYMBK.mjs} +2 -2
- package/dist/cli/{chunk-7QM6DNR4.js → chunk-BYEF4RBX.js} +11 -11
- package/dist/cli/{chunk-536TGWR6.mjs → chunk-C3EW6I65.mjs} +2 -2
- package/dist/cli/{chunk-HTYT2OHB.js → chunk-CDP3LMDT.js} +6 -6
- package/dist/cli/{chunk-YXVYPYIP.js → chunk-CYN2AHR6.js} +10 -10
- package/dist/cli/{chunk-CH7JVSA7.mjs → chunk-D2XMFXFM.mjs} +8 -8
- package/dist/cli/{chunk-2ZWNIS54.js → chunk-D5OEUPPM.js} +269 -269
- package/dist/cli/{chunk-FXTV5B3D.mjs → chunk-DY2AT3JQ.mjs} +12 -12
- package/dist/cli/{chunk-Z4MOEQSY.js → chunk-ED2N4NRI.js} +21 -21
- package/dist/cli/{chunk-RIX26ZJD.mjs → chunk-EEYZLTXX.mjs} +1 -1
- package/dist/cli/{chunk-7E6B7VMS.js → chunk-F5KFGF45.js} +5 -5
- package/dist/cli/{chunk-TZTWH53O.js → chunk-FMPGWAIR.js} +1 -1
- package/dist/cli/{chunk-R2VZVHJP.mjs → chunk-GESIFFQX.mjs} +1 -1
- package/dist/cli/{chunk-YCIXY66B.mjs → chunk-HPACLONQ.mjs} +2 -2
- package/dist/cli/{chunk-WCVIPZWX.mjs → chunk-IMP7WR22.mjs} +5 -5
- package/dist/cli/{chunk-KSQXBLRW.mjs → chunk-IWLDJQGV.mjs} +3 -3
- package/dist/cli/{chunk-EQNAQENZ.js → chunk-J5OXJ4JI.js} +2 -2
- package/dist/cli/{chunk-NUC7ZVDG.mjs → chunk-MQB25LMV.mjs} +5 -5
- package/dist/cli/{chunk-RUULUCBP.js → chunk-O7WUATQC.js} +97 -70
- package/dist/cli/{chunk-NMU3VR5U.js → chunk-PMH4GLMD.js} +1 -0
- package/dist/cli/{chunk-S3A4IXBQ.mjs → chunk-PSX3WHIH.mjs} +1 -0
- package/dist/cli/{chunk-LRWDZDBS.js → chunk-RZJWHL7L.js} +5 -5
- package/dist/cli/{chunk-66N76YZG.js → chunk-SCLRGDF4.js} +44 -44
- package/dist/cli/{chunk-SMWFOGUT.js → chunk-SJ6KUCGM.js} +53 -53
- package/dist/cli/{chunk-PFKKZVFK.js → chunk-TBQC2XS3.js} +41 -41
- package/dist/cli/{chunk-2ZX7XSAQ.mjs → chunk-TCLJXJAG.mjs} +4 -4
- package/dist/cli/{chunk-YGOI5ZE5.mjs → chunk-TVHDWS5U.mjs} +1 -1
- package/dist/cli/{chunk-MW3YMPD2.mjs → chunk-TXJW6RIM.mjs} +1 -1
- package/dist/cli/{chunk-KKPBCB6D.mjs → chunk-U6OUX47C.mjs} +2 -2
- package/dist/cli/{chunk-GTGJBZVH.js → chunk-UTCGCES2.js} +7 -7
- package/dist/cli/{chunk-V2YIBBVT.mjs → chunk-UUIC2JFZ.mjs} +1 -1
- package/dist/cli/{chunk-JDIQBZ6O.js → chunk-UWCEBS7F.js} +14 -14
- package/dist/cli/{chunk-ANKD3AIR.js → chunk-WBY3R55B.js} +2 -2
- package/dist/cli/{chunk-SF4QJVBE.js → chunk-WITNIMLE.js} +3 -3
- package/dist/cli/{chunk-7OQGZBDG.js → chunk-WL6GAZBD.js} +31 -17
- package/dist/cli/{chunk-R457IMHJ.mjs → chunk-WOLY6SU4.mjs} +1 -1
- package/dist/cli/{chunk-3WWTBQHC.mjs → chunk-XVIMOB2U.mjs} +2 -2
- package/dist/cli/{chunk-NTLBZUHD.js → chunk-XYIECA7M.js} +4 -2
- package/dist/cli/{chunk-BXIQD2IY.mjs → chunk-Y47OCS5V.mjs} +1 -1
- package/dist/cli/{chunk-EO55Y4QW.mjs → chunk-YNFPZVII.mjs} +5 -5
- package/dist/cli/{chunk-BN5VKY4X.js → chunk-ZS2WHWWL.js} +7 -7
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-HT2JBCW2.mjs → csv-4BLFRED6.mjs} +4 -4
- package/dist/cli/{csv-Q2LWKXAV.js → csv-KSJB5Z3M.js} +13 -13
- package/dist/cli/{db-XEV4WEE4.js → db-G7Z5CKO2.js} +28 -28
- package/dist/cli/{db-CS3XQ2LX.mjs → db-OVW6C3DV.mjs} +7 -7
- package/dist/cli/describe-KMYR2JBC.js +50 -0
- package/dist/cli/describe-OEFTD7WQ.mjs +50 -0
- package/dist/cli/describe-core.d.mts +4 -2
- package/dist/cli/describe-core.d.ts +4 -2
- package/dist/cli/describe-core.js +5 -5
- package/dist/cli/describe-core.mjs +4 -4
- package/dist/cli/{executions-L6XFG5MP.mjs → executions-7ZKQ4ZU3.mjs} +7 -7
- package/dist/cli/{executions-JCC34WAD.js → executions-O7USCBCW.js} +9 -9
- package/dist/cli/{feedback-AWBDO5I6.mjs → feedback-KUBL5E3I.mjs} +61 -13
- package/dist/cli/{feedback-HV2M2G7N.js → feedback-Y55WCRIQ.js} +65 -17
- package/dist/cli/{git-S4LRXTRX.mjs → git-C6ZAU5JA.mjs} +5 -5
- package/dist/cli/git-NBVQ3VGW.js +25 -0
- package/dist/cli/index.js +145 -145
- package/dist/cli/index.mjs +44 -44
- package/dist/cli/{legacy-noops-7MOKBL4O.mjs → legacy-noops-MUXD4HRC.mjs} +6 -6
- package/dist/cli/{legacy-noops-RGSZUD6V.js → legacy-noops-OVWX4KB3.js} +9 -9
- package/dist/cli/{monitors-XQNXDZPQ.mjs → monitors-2ZSGBY52.mjs} +8 -8
- package/dist/cli/{monitors-JEFM2C5W.js → monitors-3QVYGYWA.js} +101 -101
- package/dist/cli/{org-KTMJZGTN.mjs → org-RDSPE5FB.mjs} +7 -7
- package/dist/cli/{org-GYLA5V32.js → org-S6Z3SDLI.js} +87 -87
- package/dist/cli/{pages-WOMU2T2O.mjs → pages-K5DSMHLJ.mjs} +7 -7
- package/dist/cli/{pages-RY4U7OCL.js → pages-VUWF2OR7.js} +19 -19
- package/dist/cli/{play-KOYGGNYS.mjs → play-PZLXOYEX.mjs} +151 -102
- package/dist/cli/{play-2Q6MWJ3D.js → play-SQOJTUFC.js} +756 -707
- package/dist/cli/{providers-7YKDITJC.mjs → providers-AMIGP3D4.mjs} +7 -7
- package/dist/cli/{providers-HOIRHMN2.js → providers-FZBEPUOI.js} +10 -10
- package/dist/cli/{quickstart-RDXHSMVX.mjs → quickstart-HNOQKGOF.mjs} +4 -4
- package/dist/cli/{quickstart-OWCJOSQA.js → quickstart-QIHZDBGM.js} +6 -6
- package/dist/cli/{run-MT2ABKO5.js → run-IQGM3TO2.js} +46 -46
- package/dist/cli/{run-RT73NDP5.mjs → run-JDW6BDNT.mjs} +27 -27
- package/dist/cli/search-BNWRL3YY.js +33 -0
- package/dist/cli/{search-CJPKIGSA.mjs → search-DMVUKJ23.mjs} +9 -9
- package/dist/cli/{search-output-AREMA544.mjs → search-output-5UAPUUHH.mjs} +4 -4
- package/dist/cli/{search-output-OSBZ7WK6.js → search-output-UUW6UNHF.js} +6 -6
- package/dist/cli/{secrets-BTIY2FEJ.mjs → secrets-46KSTPFN.mjs} +7 -7
- package/dist/cli/{secrets-OV6KH633.js → secrets-U532KN24.js} +16 -16
- package/dist/cli/sessions-JZUONXH4.js +22 -0
- package/dist/cli/sessions-RUNWYHYX.mjs +22 -0
- package/dist/cli/{settings-7BQIC7QN.mjs → settings-56L3WHCY.mjs} +14 -14
- package/dist/cli/{settings-LBIECYDB.js → settings-O2A37FFA.js} +87 -87
- package/dist/cli/{setup-QZE7QR3F.js → setup-ETFSMSCH.js} +50 -50
- package/dist/cli/{setup-XPTSNNES.mjs → setup-Q27X6JZY.mjs} +10 -10
- package/dist/cli/skills-IKDJ5JDN.js +37 -0
- package/dist/cli/{skills-TGGKIQLT.mjs → skills-WFQRZL4D.mjs} +8 -8
- package/dist/cli/tools-B735AA67.js +57 -0
- package/dist/cli/{tools-MKIFX2TQ.mjs → tools-EV6CKJOX.mjs} +20 -20
- package/dist/cli/update-CNNURAM3.js +35 -0
- package/dist/cli/{update-5R3D3WNH.mjs → update-KIPPFVCH.mjs} +10 -10
- package/dist/cli/{views-VPWEINIA.js → views-DNZ2HFTA.js} +19 -19
- package/dist/cli/{views-VHKDHHUP.mjs → views-LMJXWD4N.mjs} +7 -7
- package/dist/cli/{workflow-D5DF65N6.mjs → workflow-3XKUQ73U.mjs} +8 -8
- package/dist/cli/{workflow-7K2VEQ4V.js → workflow-ZUDTIOK6.js} +18 -18
- package/dist/{client-C5_6W8yd.d.mts → client-Bd2meveV.d.mts} +1 -1
- package/dist/{client-iXW4TOat.d.ts → client-CBCVhL8U.d.ts} +1 -1
- package/dist/{client-core-Dob428Z4.d.mts → client-core-CGj8V9mw.d.mts} +67 -0
- package/dist/{client-core-B-GPfmaC.d.ts → client-core-CsRRWCFy.d.ts} +67 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/index.mjs +7 -7
- package/dist/install-integrity.json +121 -118
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/play-description.js +2 -2
- package/dist/plays/play-description.mjs +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +6 -6
- package/dist/server.mjs +4 -4
- package/package.json +1 -1
- package/dist/cli/auth-OKPHHMMP.js +0 -43
- package/dist/cli/describe-5G5NXO5E.js +0 -50
- package/dist/cli/describe-OUTXLDGZ.mjs +0 -50
- package/dist/cli/git-GDPTG52F.js +0 -25
- package/dist/cli/search-7VBA6IGS.js +0 -33
- package/dist/cli/sessions-3CO3ZFOD.mjs +0 -18
- package/dist/cli/sessions-B3WNEWRW.js +0 -18
- package/dist/cli/skills-TXBRTWEV.js +0 -37
- package/dist/cli/tools-RZJV4X3J.js +0 -57
- package/dist/cli/update-YWGGPWUA.js +0 -35
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
1
2
|
import { homedir } from 'node:os';
|
|
3
|
+
import { basename, join } from 'node:path';
|
|
2
4
|
|
|
3
5
|
const EXPLICIT_AGENT_RUNTIMES = new Set([
|
|
4
6
|
'claude_code',
|
|
@@ -67,6 +69,102 @@ export function agentSessionIdFromEnvironment(
|
|
|
67
69
|
return null;
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
const SESSION_UUID_RE =
|
|
73
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
74
|
+
|
|
75
|
+
/** Whether a value has the UUID shape Claude and Codex session IDs use. */
|
|
76
|
+
export function isAgentSessionId(value: string): boolean {
|
|
77
|
+
return SESSION_UUID_RE.test(value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The VM home of a Claude Cowork session, `/sessions/<name>`, taken from HOME
|
|
82
|
+
* or, when HOME is the bare `/sessions`, the working directory. These are the
|
|
83
|
+
* same homes isCoworkLikeSandbox treats as Cowork.
|
|
84
|
+
*/
|
|
85
|
+
export function coworkSessionHome(
|
|
86
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
87
|
+
cwd: string = process.cwd(),
|
|
88
|
+
): string | null {
|
|
89
|
+
const home = env.HOME?.trim() || homedir();
|
|
90
|
+
const path = home === '/sessions' ? cwd : home;
|
|
91
|
+
return path.match(/^\/sessions\/(?!\.\.?(?:\/|$))[^/]+/)?.[0] ?? null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Directories holding Claude transcripts as `<root>/<project>/<id>.jsonl`:
|
|
96
|
+
* CLAUDE_CONFIG_DIR, the Cowork session's mounted config dir, then ~/.claude.
|
|
97
|
+
*/
|
|
98
|
+
export function claudeProjectsRoots(
|
|
99
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
100
|
+
cwd: string = process.cwd(),
|
|
101
|
+
): string[] {
|
|
102
|
+
const roots: string[] = [];
|
|
103
|
+
const configDir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
104
|
+
if (configDir) roots.push(join(configDir, 'projects'));
|
|
105
|
+
const coworkHome = coworkSessionHome(env, cwd);
|
|
106
|
+
if (coworkHome) roots.push(coworkProjectsRoot(coworkHome));
|
|
107
|
+
roots.push(join(env.HOME?.trim() || homedir(), '.claude', 'projects'));
|
|
108
|
+
return [...new Set(roots)];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Cowork mounts each session's own Claude config dir at `~/mnt/.claude`, so
|
|
113
|
+
* its transcripts live in `~/mnt/.claude/projects/<project>/<id>.jsonl`.
|
|
114
|
+
*/
|
|
115
|
+
function coworkProjectsRoot(coworkHome: string): string {
|
|
116
|
+
return join(coworkHome, 'mnt', '.claude', 'projects');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type AgentTranscript = { sessionId: string; filePath: string };
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The transcript of the Claude Cowork session this process runs in, or null
|
|
123
|
+
* outside Cowork or before the transcript exists. Cowork does not reliably
|
|
124
|
+
* pass CLAUDE_CODE_SESSION_ID to commands, but each session has its own
|
|
125
|
+
* config dir, so its newest transcript is the current session.
|
|
126
|
+
*/
|
|
127
|
+
export function coworkTranscriptFromEnvironment(
|
|
128
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
129
|
+
cwd: string = process.cwd(),
|
|
130
|
+
): AgentTranscript | null {
|
|
131
|
+
const coworkHome = coworkSessionHome(env, cwd);
|
|
132
|
+
if (!coworkHome) return null;
|
|
133
|
+
const root = coworkProjectsRoot(coworkHome);
|
|
134
|
+
let newest: (AgentTranscript & { mtimeMs: number }) | null = null;
|
|
135
|
+
for (const project of readDirectoryNames(root)) {
|
|
136
|
+
for (const fileName of readDirectoryNames(join(root, project))) {
|
|
137
|
+
const sessionId = basename(fileName, '.jsonl');
|
|
138
|
+
if (!fileName.endsWith('.jsonl') || !SESSION_UUID_RE.test(sessionId)) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const filePath = join(root, project, fileName);
|
|
142
|
+
let mtimeMs: number;
|
|
143
|
+
try {
|
|
144
|
+
const stat = statSync(filePath);
|
|
145
|
+
if (!stat.isFile()) continue;
|
|
146
|
+
mtimeMs = stat.mtimeMs;
|
|
147
|
+
} catch {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (!newest || mtimeMs > newest.mtimeMs) {
|
|
151
|
+
newest = { sessionId, filePath, mtimeMs };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return newest
|
|
156
|
+
? { sessionId: newest.sessionId, filePath: newest.filePath }
|
|
157
|
+
: null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function readDirectoryNames(dir: string): string[] {
|
|
161
|
+
try {
|
|
162
|
+
return readdirSync(dir);
|
|
163
|
+
} catch {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
70
168
|
export function isCoworkLikeSandbox(): boolean {
|
|
71
169
|
const pluginMode = truthyEnv('DEEPLINE_PLUGIN_MODE');
|
|
72
170
|
const claudeRemote = truthyEnv('CLAUDE_CODE_REMOTE');
|
|
@@ -639,6 +639,11 @@ export type RunsGetOptions = {
|
|
|
639
639
|
configuration?: boolean;
|
|
640
640
|
/** Include terminal runtime diagnostics (`run.performance`) without full results. */
|
|
641
641
|
performance?: boolean;
|
|
642
|
+
/**
|
|
643
|
+
* Include `run.retries`: fixed-size attempt, sandbox, platform-recovery and
|
|
644
|
+
* resume counts. Costs one extra scheduler read, so polls should omit it.
|
|
645
|
+
*/
|
|
646
|
+
retries?: boolean;
|
|
642
647
|
/** Attach a bounded end-of-stream window for a failed run. */
|
|
643
648
|
failedLogs?: boolean;
|
|
644
649
|
/** Requested failed-log lines to attach (default 20, hard-capped at 20). */
|
|
@@ -5050,6 +5055,9 @@ export class DeeplineClient {
|
|
|
5050
5055
|
if (options?.performance === true) {
|
|
5051
5056
|
params.append('include', 'performance');
|
|
5052
5057
|
}
|
|
5058
|
+
if (options?.retries === true) {
|
|
5059
|
+
params.append('include', 'retries');
|
|
5060
|
+
}
|
|
5053
5061
|
const query = params.size > 0 ? `?${params.toString()}` : '';
|
|
5054
5062
|
const response = await this.http.get<Record<string, unknown>>(
|
|
5055
5063
|
`/api/v2/runs/${encodeURIComponent(runId)}${query}`,
|
|
@@ -66,6 +66,18 @@ const REQUEST_TIMEOUT_MARKER = Symbol('deeplineRequestTimeout');
|
|
|
66
66
|
const REQUEST_ABORT_MARKER = Symbol('deeplineRequestAbort');
|
|
67
67
|
const MAX_AUTOMATIC_RETRY_WAIT_MS = 30_000;
|
|
68
68
|
|
|
69
|
+
function deploymentProtectionRedirect(
|
|
70
|
+
headers: Record<string, string>,
|
|
71
|
+
): RequestRedirect | undefined {
|
|
72
|
+
// Fetch strips Authorization on cross-origin redirects, but keeps this
|
|
73
|
+
// custom credential. Stop at the first redirect when it is present.
|
|
74
|
+
return Object.keys(headers).some(
|
|
75
|
+
(name) => name.toLowerCase() === 'x-vercel-protection-bypass',
|
|
76
|
+
)
|
|
77
|
+
? 'manual'
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
69
81
|
interface RequestOptions {
|
|
70
82
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
71
83
|
body?: unknown;
|
|
@@ -605,6 +617,7 @@ export class HttpClient {
|
|
|
605
617
|
headers,
|
|
606
618
|
body: requestBody,
|
|
607
619
|
signal: controller.signal,
|
|
620
|
+
redirect: deploymentProtectionRedirect(headers),
|
|
608
621
|
});
|
|
609
622
|
|
|
610
623
|
networkPhase = 'reading_body';
|
|
@@ -946,6 +959,7 @@ export class HttpClient {
|
|
|
946
959
|
? JSON.stringify(options.body)
|
|
947
960
|
: undefined,
|
|
948
961
|
signal: options?.signal,
|
|
962
|
+
redirect: deploymentProtectionRedirect(headers),
|
|
949
963
|
});
|
|
950
964
|
options?.onResponse?.(response);
|
|
951
965
|
|
|
@@ -154,6 +154,7 @@ export function describePlayDetail(
|
|
|
154
154
|
const play = detail.play;
|
|
155
155
|
return {
|
|
156
156
|
...describePlayListItem(play, options),
|
|
157
|
+
...(play.ownerType === 'org' && play._id ? { playId: play._id } : {}),
|
|
157
158
|
currentPublishedVersion:
|
|
158
159
|
play.currentPublishedVersion ?? play.liveRevision?.version ?? null,
|
|
159
160
|
latestRunId: play.latestRunId ?? detail.latestRuns[0]?.workflowId ?? null,
|
|
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
|
|
|
205
205
|
// getters keep their established compatibility behavior.
|
|
206
206
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
207
207
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
208
|
-
version: '0.3.
|
|
208
|
+
version: '0.3.526',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -11,6 +11,7 @@ export type {
|
|
|
11
11
|
import type { PlayCompilerManifest } from '../../shared_libs/plays/compiler-manifest';
|
|
12
12
|
import type { RunGetStatus, RunLifecycleStatus } from './client';
|
|
13
13
|
import type { PlayGrepMatch } from '../../shared_libs/plays/play-grep-search';
|
|
14
|
+
import type { RunRetrySummary } from '../../shared_libs/play-runtime/run-retry-summary';
|
|
14
15
|
import type { PlayRunRuntimeSelection } from '../../shared_libs/play-runtime/runtime-environment';
|
|
15
16
|
import type {
|
|
16
17
|
PlayActivityObservation,
|
|
@@ -934,6 +935,13 @@ export interface PlayRunPackage {
|
|
|
934
935
|
*/
|
|
935
936
|
performance?: TerminalRuntimePerformance;
|
|
936
937
|
performanceUnavailableReason?: TerminalRuntimePerformanceUnavailableReason;
|
|
938
|
+
/**
|
|
939
|
+
* Fixed-size failure-driven retry counts for the current resume epoch, on
|
|
940
|
+
* `include=retries` (`runs get` asks for it). Durable waits are not
|
|
941
|
+
* counted. Absent on older servers.
|
|
942
|
+
*/
|
|
943
|
+
retries?: RunRetrySummary;
|
|
944
|
+
retriesUnavailableReason?: 'not_recorded' | 'invalid_facts' | 'read_failed';
|
|
937
945
|
/** Canonical explanation of what this run is doing or waiting on. */
|
|
938
946
|
activity?: PlayRunActivityProjection | null;
|
|
939
947
|
};
|
|
@@ -1818,6 +1826,8 @@ export interface ProductNotificationConfigurationResponse {
|
|
|
1818
1826
|
|
|
1819
1827
|
export interface PlayDescription {
|
|
1820
1828
|
name: string;
|
|
1829
|
+
/** Stable workspace-owned Play definition ID. */
|
|
1830
|
+
playId?: string;
|
|
1821
1831
|
/** Stable registry key. Same value `plays list` reports for this play. */
|
|
1822
1832
|
playKey?: string;
|
|
1823
1833
|
reference?: string;
|
|
@@ -338,13 +338,18 @@ export type DurableRunNextActionKind =
|
|
|
338
338
|
|
|
339
339
|
/**
|
|
340
340
|
* Why a stopped durable run stopped. `play_error`: the Play's own error (the
|
|
341
|
-
* customer's). `
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* `
|
|
341
|
+
* customer's). `provider_failure`: a provider call failed the run, by the
|
|
342
|
+
* run's structured failure origin (as the public run event classes it).
|
|
343
|
+
* `platform_recovery_exhausted`: Deepline's automatic recovery ran out
|
|
344
|
+
* (resume it). `platform_failure`: another platform failure the runtime
|
|
345
|
+
* recognizes. `cancelled`: cancelled (code names a platform cancel).
|
|
346
|
+
* `unknown`: no stored terminal error. Readers must tolerate classes they do
|
|
347
|
+
* not know: older servers never send `provider_failure`, and a newer one may
|
|
348
|
+
* add a class.
|
|
345
349
|
*/
|
|
346
350
|
export const DURABLE_RUN_FAILURE_CLASSES = [
|
|
347
351
|
'play_error',
|
|
352
|
+
'provider_failure',
|
|
348
353
|
'platform_recovery_exhausted',
|
|
349
354
|
'platform_failure',
|
|
350
355
|
'cancelled',
|
|
@@ -354,7 +359,11 @@ export type DurableRunFailureClass =
|
|
|
354
359
|
(typeof DURABLE_RUN_FAILURE_CLASSES)[number];
|
|
355
360
|
|
|
356
361
|
/** `failureCause` list filter of the `durable-play-runs` quarantined listing. */
|
|
357
|
-
export const DURABLE_RUN_FAILURE_CAUSE_FILTERS = [
|
|
362
|
+
export const DURABLE_RUN_FAILURE_CAUSE_FILTERS = [
|
|
363
|
+
'platform',
|
|
364
|
+
'provider',
|
|
365
|
+
'play',
|
|
366
|
+
] as const;
|
|
358
367
|
export type DurableRunFailureCauseFilter =
|
|
359
368
|
(typeof DURABLE_RUN_FAILURE_CAUSE_FILTERS)[number];
|
|
360
369
|
|
|
@@ -1425,6 +1434,25 @@ const DLQ_PATH_METADATA: Readonly<Record<string, DlqPathMetadata>> = {
|
|
|
1425
1434
|
},
|
|
1426
1435
|
],
|
|
1427
1436
|
},
|
|
1437
|
+
'mcp-event-deliveries': {
|
|
1438
|
+
lookupIndex: {
|
|
1439
|
+
table: 'mcpEventDeliveries',
|
|
1440
|
+
index: 'by_state_next_attempt',
|
|
1441
|
+
key: 'state + nextAttemptAt',
|
|
1442
|
+
bounded: true,
|
|
1443
|
+
},
|
|
1444
|
+
transitions: [
|
|
1445
|
+
{
|
|
1446
|
+
action: 'retry',
|
|
1447
|
+
fromStates: ['dead_lettered'],
|
|
1448
|
+
toState: 'pending',
|
|
1449
|
+
enabled: false,
|
|
1450
|
+
requiresApproval: true,
|
|
1451
|
+
reason:
|
|
1452
|
+
'Manual replay is unavailable because it must revalidate the grant and preserve the webhook event ID.',
|
|
1453
|
+
},
|
|
1454
|
+
],
|
|
1455
|
+
},
|
|
1428
1456
|
'notification-deliveries': {
|
|
1429
1457
|
lookupIndex: {
|
|
1430
1458
|
table: 'productNotificationDeliveries',
|
|
@@ -298,6 +298,15 @@ export const OPERATIONS_QUEUE_CATALOG = [
|
|
|
298
298
|
600_000,
|
|
299
299
|
3_600_000,
|
|
300
300
|
),
|
|
301
|
+
queue(
|
|
302
|
+
'mcp-event-deliveries',
|
|
303
|
+
'MCP event deliveries',
|
|
304
|
+
'leased_workset',
|
|
305
|
+
'mcp',
|
|
306
|
+
'Deliver authorized Play events to verified callbacks',
|
|
307
|
+
120_000,
|
|
308
|
+
300_000,
|
|
309
|
+
),
|
|
301
310
|
queue(
|
|
302
311
|
'notification-deliveries',
|
|
303
312
|
'Notification deliveries',
|
|
@@ -287,6 +287,7 @@ export const QUEUE_CONNECTOR_BACKENDS: Readonly<
|
|
|
287
287
|
'stripe-financial-inbox': 'provider',
|
|
288
288
|
'async-usage-recovery': 'postgres-outbox',
|
|
289
289
|
'notification-deliveries': 'workpool',
|
|
290
|
+
'mcp-event-deliveries': 'convex',
|
|
290
291
|
'inbound-demo-form-submissions': 'convex',
|
|
291
292
|
'inbound-demo-sales': 'convex',
|
|
292
293
|
'usage-rollup-fold': 'postgres-outbox',
|
|
@@ -296,6 +296,7 @@ import {
|
|
|
296
296
|
latestCacheResultKey,
|
|
297
297
|
latestCacheResultOutput,
|
|
298
298
|
type LegacySlotSearch,
|
|
299
|
+
type ReplayRefusal,
|
|
299
300
|
parseLatestCacheResult,
|
|
300
301
|
type ReplayMismatchPolicy,
|
|
301
302
|
toolReadSemanticKey,
|
|
@@ -3215,6 +3216,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
3215
3216
|
>();
|
|
3216
3217
|
/** Authored calls whose unverified recovery was already reported. */
|
|
3217
3218
|
private readonly unverifiedRecoveryReported = new Set<string>();
|
|
3219
|
+
/** Replay refusals already reported, by code, operation and authored id. */
|
|
3220
|
+
private readonly replayRefusalsReported = new Map<string, number>();
|
|
3218
3221
|
/**
|
|
3219
3222
|
* Parent-level inline-child aggregates. Maintained only by the single-writer
|
|
3220
3223
|
* progress path (never per child) so concurrent fan-out cannot contend. See
|
|
@@ -4473,6 +4476,40 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4473
4476
|
};
|
|
4474
4477
|
}
|
|
4475
4478
|
|
|
4479
|
+
/**
|
|
4480
|
+
* One structured line per replay refusal, emitted where the refusal is
|
|
4481
|
+
* decided, so a Play that catches the error cannot hide it. Rate-limited
|
|
4482
|
+
* per code, operation and authored id: the first refusal and then powers of
|
|
4483
|
+
* two, each carrying the running count. Never carries inputs, outputs or
|
|
4484
|
+
* secrets. Written to the run log and to the runner's stderr, which the
|
|
4485
|
+
* runtime log shipper forwards.
|
|
4486
|
+
*/
|
|
4487
|
+
private reportReplayRefusal(refusal: ReplayRefusal): void {
|
|
4488
|
+
const reportKey = `${refusal.code}:${refusal.operation}:${refusal.callId}`;
|
|
4489
|
+
const count = (this.replayRefusalsReported.get(reportKey) ?? 0) + 1;
|
|
4490
|
+
this.replayRefusalsReported.set(reportKey, count);
|
|
4491
|
+
if ((count & (count - 1)) !== 0) return;
|
|
4492
|
+
const line = JSON.stringify({
|
|
4493
|
+
event: 'durable_replay_refused',
|
|
4494
|
+
code: refusal.code,
|
|
4495
|
+
operation: refusal.operation,
|
|
4496
|
+
call_key: refusal.callId,
|
|
4497
|
+
ordinal: refusal.ordinal,
|
|
4498
|
+
rung: refusal.rung,
|
|
4499
|
+
reason: refusal.reason,
|
|
4500
|
+
...(refusal.slot ? { slot: refusal.slot } : {}),
|
|
4501
|
+
...(refusal.recordedIdentitySources
|
|
4502
|
+
? { recorded_identity_sources: refusal.recordedIdentitySources }
|
|
4503
|
+
: {}),
|
|
4504
|
+
run_id: this.currentRunId,
|
|
4505
|
+
org_id: this.#options.orgId ?? null,
|
|
4506
|
+
play_name: this.#options.playName ?? null,
|
|
4507
|
+
refusal_count: count,
|
|
4508
|
+
});
|
|
4509
|
+
this.runtimeLog(line, { level: 'error' });
|
|
4510
|
+
console.error(line);
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4476
4513
|
/** Rate-limited: once per authored call per run context. */
|
|
4477
4514
|
private reportLegacyOperationRecovery(
|
|
4478
4515
|
operation: DurableCtxOperation,
|
|
@@ -4553,6 +4590,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4553
4590
|
callId: input.id,
|
|
4554
4591
|
onLegacyRecoveryProven: () =>
|
|
4555
4592
|
this.reportLegacyOperationRecovery(input.operation, input.id),
|
|
4593
|
+
onRefusal: (refusal) => this.reportReplayRefusal(refusal),
|
|
4556
4594
|
runId: this.currentReceiptOwnerRunId,
|
|
4557
4595
|
receiptOwnerRunId: this.currentReceiptOwnerRunId,
|
|
4558
4596
|
// Launches admitted without run-scoped keys wrote this operation under
|
|
@@ -43,6 +43,35 @@ export type CompletedCall = {
|
|
|
43
43
|
inputFingerprint?: string;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* One replay refusal, as decided. Carries no input, output or secret: only
|
|
48
|
+
* identities the authored source already names and which check failed.
|
|
49
|
+
*/
|
|
50
|
+
export type ReplayRefusal = {
|
|
51
|
+
code: 'DURABLE_REPLAY_INPUT_MISMATCH' | 'DURABLE_REPLAY_UNVERIFIABLE_LEGACY_SLOT';
|
|
52
|
+
operation: string;
|
|
53
|
+
callId: string;
|
|
54
|
+
/** This call's call-order occurrence in its scope, when known. */
|
|
55
|
+
ordinal: number | null;
|
|
56
|
+
/**
|
|
57
|
+
* The check that refused:
|
|
58
|
+
* - `binding`: a bound receipt of another request identity;
|
|
59
|
+
* - `legacy_ownership`: a pre-binding receipt nothing proves is this call's.
|
|
60
|
+
*/
|
|
61
|
+
rung: 'binding' | 'legacy_ownership';
|
|
62
|
+
reason:
|
|
63
|
+
| 'input_changed'
|
|
64
|
+
| 'credential_or_action_changed'
|
|
65
|
+
| 'no_identity_source'
|
|
66
|
+
| 'no_recorded_identity'
|
|
67
|
+
| 'recorded_identity_mismatch'
|
|
68
|
+
| 'slot_taken_by_sibling';
|
|
69
|
+
/** Binding refusals: which slot held the other request. */
|
|
70
|
+
slot?: 'exact_request' | 'call_order' | 'legacy_key';
|
|
71
|
+
/** Legacy refusals: where the recorded identities came from. */
|
|
72
|
+
recordedIdentitySources?: Array<'value_receipt_key' | 'result_metadata'>;
|
|
73
|
+
};
|
|
74
|
+
|
|
46
75
|
/**
|
|
47
76
|
* A call's view of the other call-order slots of its authored id and scope,
|
|
48
77
|
* used only for receipts recorded before bindings. See
|
|
@@ -296,6 +325,28 @@ function sharesLatestResult<T>(
|
|
|
296
325
|
* canonical result receipt and the cache/receipt keys in its execution
|
|
297
326
|
* metadata. Each hashes the request it was recorded for.
|
|
298
327
|
*/
|
|
328
|
+
function recordedIdentitySources(
|
|
329
|
+
call: CompletedCall,
|
|
330
|
+
): Array<'value_receipt_key' | 'result_metadata'> {
|
|
331
|
+
const sources: Array<'value_receipt_key' | 'result_metadata'> = [];
|
|
332
|
+
if (call.valueReceiptKey) sources.push('value_receipt_key');
|
|
333
|
+
const value = call.value;
|
|
334
|
+
const result = isSerializedToolExecuteResult(value)
|
|
335
|
+
? deserializeToolExecuteResult(value)
|
|
336
|
+
: isToolExecuteResult(value)
|
|
337
|
+
? value
|
|
338
|
+
: null;
|
|
339
|
+
const execution = result?._metadata?.execution;
|
|
340
|
+
if (
|
|
341
|
+
[execution?.cacheKey, execution?.receiptKey, execution?.resultReceiptKey].some(
|
|
342
|
+
(key) => typeof key === 'string' && key.trim(),
|
|
343
|
+
)
|
|
344
|
+
) {
|
|
345
|
+
sources.push('result_metadata');
|
|
346
|
+
}
|
|
347
|
+
return sources;
|
|
348
|
+
}
|
|
349
|
+
|
|
299
350
|
function recordedRequestIdentities(call: CompletedCall): string[] {
|
|
300
351
|
const keys = new Set<string>();
|
|
301
352
|
if (call.valueReceiptKey) keys.add(call.valueReceiptKey);
|
|
@@ -408,6 +459,11 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
408
459
|
* means `fail`: a call is a read only when its caller proves it.
|
|
409
460
|
*/
|
|
410
461
|
replayMismatchPolicy?: () => Promise<ReplayMismatchPolicy>;
|
|
462
|
+
/**
|
|
463
|
+
* Called once per refusal, where it is decided and before the error is
|
|
464
|
+
* thrown, so a Play that catches the error cannot hide it.
|
|
465
|
+
*/
|
|
466
|
+
onRefusal?: (refusal: ReplayRefusal) => void;
|
|
411
467
|
/** Names the call in a mismatch error. */
|
|
412
468
|
operation?: string;
|
|
413
469
|
callId?: string;
|
|
@@ -825,13 +881,29 @@ async function executeWithFreshnessReceiptOnce<T>(
|
|
|
825
881
|
*/
|
|
826
882
|
const recoverUnbound = async (recorded: CompletedCall) => {
|
|
827
883
|
const search = input.legacySlotSearch;
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
884
|
+
const proven =
|
|
885
|
+
input.operationKeyEncodesRequest === true ||
|
|
886
|
+
(await recordedIdentityMatches(recorded));
|
|
887
|
+
const owned = proven && (!search || search.consume(search.ownIndex));
|
|
832
888
|
if (!owned) {
|
|
833
889
|
const found = await searchLegacySlots();
|
|
834
890
|
if (found) return found;
|
|
891
|
+
const sources = recordedIdentitySources(recorded);
|
|
892
|
+
input.onRefusal?.({
|
|
893
|
+
code: 'DURABLE_REPLAY_UNVERIFIABLE_LEGACY_SLOT',
|
|
894
|
+
operation: input.operation ?? 'call',
|
|
895
|
+
callId: input.callId ?? 'unknown',
|
|
896
|
+
ordinal: search?.ownIndex ?? null,
|
|
897
|
+
rung: 'legacy_ownership',
|
|
898
|
+
reason: proven
|
|
899
|
+
? 'slot_taken_by_sibling'
|
|
900
|
+
: !input.legacyRequestIdentities
|
|
901
|
+
? 'no_identity_source'
|
|
902
|
+
: sources.length === 0
|
|
903
|
+
? 'no_recorded_identity'
|
|
904
|
+
: 'recorded_identity_mismatch',
|
|
905
|
+
recordedIdentitySources: sources,
|
|
906
|
+
});
|
|
835
907
|
throw new DurableReplayUnverifiableLegacySlotError(
|
|
836
908
|
input.operation ?? 'call',
|
|
837
909
|
input.callId ?? 'unknown',
|
|
@@ -884,7 +956,10 @@ async function executeWithFreshnessReceiptOnce<T>(
|
|
|
884
956
|
* run and executes; a call that may write fails loudly instead of returning
|
|
885
957
|
* another request's output or repeating a write.
|
|
886
958
|
*/
|
|
887
|
-
const refuseOrExecute = async (
|
|
959
|
+
const refuseOrExecute = async (
|
|
960
|
+
recorded: CompletedCall,
|
|
961
|
+
slot: 'exact_request' | 'call_order' | 'legacy_key',
|
|
962
|
+
) => {
|
|
888
963
|
const policy = input.replayMismatchPolicy
|
|
889
964
|
? await input.replayMismatchPolicy()
|
|
890
965
|
: 'fail';
|
|
@@ -893,21 +968,31 @@ async function executeWithFreshnessReceiptOnce<T>(
|
|
|
893
968
|
recorded.inputFingerprint !== undefined
|
|
894
969
|
? recorded.inputFingerprint === input.inputFingerprint
|
|
895
970
|
: recorded === exact;
|
|
971
|
+
const reason = sameInput ? 'credential_or_action_changed' : 'input_changed';
|
|
972
|
+
input.onRefusal?.({
|
|
973
|
+
code: 'DURABLE_REPLAY_INPUT_MISMATCH',
|
|
974
|
+
operation: input.operation ?? 'call',
|
|
975
|
+
callId: input.callId ?? 'unknown',
|
|
976
|
+
ordinal: input.legacySlotSearch?.ownIndex ?? null,
|
|
977
|
+
rung: 'binding',
|
|
978
|
+
reason,
|
|
979
|
+
slot,
|
|
980
|
+
});
|
|
896
981
|
throw new DurableReplayInputMismatchError(
|
|
897
982
|
input.operation ?? 'call',
|
|
898
983
|
input.callId ?? 'unknown',
|
|
899
|
-
|
|
984
|
+
reason,
|
|
900
985
|
);
|
|
901
986
|
};
|
|
902
987
|
if (exact && ownsOperation(exact) === 'no') {
|
|
903
988
|
// The exact-request slot is keyed by the input itself: only the
|
|
904
989
|
// credential scope or action revision differs.
|
|
905
|
-
await refuseOrExecute(exact);
|
|
990
|
+
await refuseOrExecute(exact, 'exact_request');
|
|
906
991
|
} else if (callOrder) {
|
|
907
992
|
if (ownsOperation(callOrder) === 'unverified') {
|
|
908
993
|
return recoverUnbound(callOrder);
|
|
909
994
|
}
|
|
910
|
-
await refuseOrExecute(callOrder);
|
|
995
|
+
await refuseOrExecute(callOrder, 'call_order');
|
|
911
996
|
} else if (
|
|
912
997
|
!exact &&
|
|
913
998
|
input.legacySlotSearch &&
|
|
@@ -925,7 +1010,7 @@ async function executeWithFreshnessReceiptOnce<T>(
|
|
|
925
1010
|
const owner = ownsOperation(legacy);
|
|
926
1011
|
if (owner === 'unverified') return recoverUnbound(legacy);
|
|
927
1012
|
if (owner === 'yes') return outcome(legacy, 'operation_recovery');
|
|
928
|
-
await refuseOrExecute(legacy);
|
|
1013
|
+
await refuseOrExecute(legacy, 'legacy_key');
|
|
929
1014
|
}
|
|
930
1015
|
}
|
|
931
1016
|
if (candidateManifests.status === 'rejected') {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a failed Play run's structured failure belongs to.
|
|
3
|
+
*
|
|
4
|
+
* One classifier for every reader of a run's structured failure (`errors[0]`
|
|
5
|
+
* of the terminal result, or its ledger summary): the public run event and
|
|
6
|
+
* the durable scheduler's inventory read the same code sets, so they cannot
|
|
7
|
+
* disagree about a provider failure. No value imports, so the scheduler's
|
|
8
|
+
* light SQL module can use it.
|
|
9
|
+
*/
|
|
10
|
+
import type {
|
|
11
|
+
ToolExecutionErrorCategory,
|
|
12
|
+
ToolExecutionErrorOrigin,
|
|
13
|
+
} from '../plays/tool-execution-error';
|
|
14
|
+
|
|
15
|
+
/** Mirrors `PROVIDER_EXHAUSTED_CODE` in `run-failure.ts`. */
|
|
16
|
+
export const PROVIDER_EXHAUSTED_FAILURE_CODE = 'PROVIDER_EXHAUSTED';
|
|
17
|
+
|
|
18
|
+
export const PLATFORM_RUN_FAILURE_CODES = [
|
|
19
|
+
'BILLING_UNAVAILABLE',
|
|
20
|
+
'MODAL_PAYLOAD_UPLOAD_TIMEOUT',
|
|
21
|
+
'PLATFORM_DEPLOY_INTERRUPTED',
|
|
22
|
+
'PLATFORM_WORKER_SUBREQUEST_INTERRUPTED',
|
|
23
|
+
'PLATFORM_WORKFLOW_ENDPOINT_INTERRUPTED',
|
|
24
|
+
'RUN_STORAGE_FAILED',
|
|
25
|
+
'RUNTIME_RUNNER_LOST',
|
|
26
|
+
'RUNTIME_SANDBOX_INSPECTION_UNAVAILABLE',
|
|
27
|
+
'RUNTIME_SANDBOX_KILLED',
|
|
28
|
+
'RUNTIME_SANDBOX_LOST',
|
|
29
|
+
'RUNTIME_SANDBOX_START_FAILED',
|
|
30
|
+
'WORKSPACE_STORAGE_NOT_READY',
|
|
31
|
+
] as const;
|
|
32
|
+
|
|
33
|
+
export const CALLER_RUN_FAILURE_CODES = [
|
|
34
|
+
'OUTPUT_TOO_LARGE',
|
|
35
|
+
'PLAY_CALL_DEPTH_EXCEEDED',
|
|
36
|
+
'RUNTIME_LIMIT_EXCEEDED',
|
|
37
|
+
// The controlled memory abort is the same caller-side resource fact as the
|
|
38
|
+
// OOM it replaces: the run's byte profile, not Deepline's platform, is what
|
|
39
|
+
// has to change before a retry can succeed.
|
|
40
|
+
'RUNTIME_SANDBOX_MEMORY_ABORT',
|
|
41
|
+
'RUNTIME_SANDBOX_OOM',
|
|
42
|
+
'RUNTIME_SUSPENDED_CHECKPOINT_TOO_LARGE',
|
|
43
|
+
] as const;
|
|
44
|
+
|
|
45
|
+
export const ACCOUNT_POLICY_RUN_FAILURE_CODES = [
|
|
46
|
+
'INSUFFICIENT_CREDITS',
|
|
47
|
+
'MONTHLY_CREDIT_CAP_EXCEEDED',
|
|
48
|
+
'RUN_CREDIT_CAP_EXCEEDED',
|
|
49
|
+
'SANDBOX_CAPACITY_EXCEEDED',
|
|
50
|
+
] as const;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Codes whose class wins over the failure's `origin`: a provider-origin
|
|
54
|
+
* failure carrying one of these is not a provider failure.
|
|
55
|
+
*/
|
|
56
|
+
export const RUN_FAILURE_CODES_CLASSED_BEFORE_ORIGIN = [
|
|
57
|
+
...ACCOUNT_POLICY_RUN_FAILURE_CODES,
|
|
58
|
+
...PLATFORM_RUN_FAILURE_CODES,
|
|
59
|
+
...CALLER_RUN_FAILURE_CODES,
|
|
60
|
+
] as const;
|
|
61
|
+
|
|
62
|
+
export type PlayRunFailureClass =
|
|
63
|
+
| 'account_policy'
|
|
64
|
+
| 'platform_failure'
|
|
65
|
+
| 'caller_failure'
|
|
66
|
+
| 'provider_failure'
|
|
67
|
+
| 'unknown_failure';
|
|
68
|
+
|
|
69
|
+
const ACCOUNT_POLICY = new Set<string>(ACCOUNT_POLICY_RUN_FAILURE_CODES);
|
|
70
|
+
const PLATFORM = new Set<string>(PLATFORM_RUN_FAILURE_CODES);
|
|
71
|
+
const CALLER = new Set<string>(CALLER_RUN_FAILURE_CODES);
|
|
72
|
+
|
|
73
|
+
export function playRunFailureClass(failure: {
|
|
74
|
+
readonly code: string;
|
|
75
|
+
readonly phase: string;
|
|
76
|
+
readonly origin?: ToolExecutionErrorOrigin;
|
|
77
|
+
readonly category?: ToolExecutionErrorCategory;
|
|
78
|
+
}): PlayRunFailureClass {
|
|
79
|
+
const code = failure.code.trim().toUpperCase();
|
|
80
|
+
if (ACCOUNT_POLICY.has(code)) return 'account_policy';
|
|
81
|
+
if (PLATFORM.has(code)) return 'platform_failure';
|
|
82
|
+
if (CALLER.has(code)) return 'caller_failure';
|
|
83
|
+
if (code === PROVIDER_EXHAUSTED_FAILURE_CODE) return 'provider_failure';
|
|
84
|
+
|
|
85
|
+
if (failure.origin === 'provider') return 'provider_failure';
|
|
86
|
+
if (failure.origin === 'caller') return 'caller_failure';
|
|
87
|
+
if (failure.origin === 'deepline') {
|
|
88
|
+
return failure.category === 'billing'
|
|
89
|
+
? 'account_policy'
|
|
90
|
+
: 'platform_failure';
|
|
91
|
+
}
|
|
92
|
+
if (failure.origin === 'unknown') return 'unknown_failure';
|
|
93
|
+
if (failure.phase === 'infrastructure' || failure.phase === 'storage') {
|
|
94
|
+
return 'platform_failure';
|
|
95
|
+
}
|
|
96
|
+
if (failure.phase === 'billing') return 'account_policy';
|
|
97
|
+
return 'unknown_failure';
|
|
98
|
+
}
|