@yolo-labs/yolo-cli 0.42.0 → 0.43.0
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.js +4 -743
- package/dist/deploy-cli.js +119 -9
- package/dist/deploy-config.js +80 -1
- package/dist/work-client.js +17 -20
- package/package.json +1 -1
- package/dist/plan-diff.js +0 -162
- package/dist/plan-export.js +0 -261
- package/dist/plan-get.js +0 -244
- package/dist/plan-import.js +0 -420
- package/dist/plan-list.js +0 -153
- package/dist/plan-open.js +0 -100
- package/dist/plan-state.js +0 -228
- package/dist/run-get.js +0 -130
- package/dist/run-lifecycle.js +0 -133
- package/dist/run-start.js +0 -110
- package/dist/run-transfer.js +0 -128
package/dist/run-transfer.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `yolo run transfer <runId> --to <agentId>` — change a Run's bound
|
|
3
|
-
* Operator. The handoff verb that closes the loop on the lifecycle
|
|
4
|
-
* slice's operator-binding implication.
|
|
5
|
-
*
|
|
6
|
-
* Natural use case: `yolo run start <planId>` makes substrate-cli
|
|
7
|
-
* the Operator; `yolo run transfer <runId> --to claude` hands the
|
|
8
|
-
* Run off to claude/codex for actual execution. The route's R4
|
|
9
|
-
* matrix permits self-transfer (current Operator → new agent),
|
|
10
|
-
* claim-user-driven (taking over a Run with operatorAgentId=null),
|
|
11
|
-
* and force-transfer of an unresponsive Operator.
|
|
12
|
-
*
|
|
13
|
-
* Target validation: the route enforces `isValidOperatorTarget` —
|
|
14
|
-
* target must be in OPERATOR_TIER_AGENT_IDS (claude, codex) or
|
|
15
|
-
* null (user-driven). Substrate-cli is NOT Operator-tier, so
|
|
16
|
-
* `--to substrate-cli` always fails at the route layer with 403
|
|
17
|
-
* NOT_AUTHORIZED + reason=invalid_transfer_target.
|
|
18
|
-
*
|
|
19
|
-
* Errors map to exit codes via the CLI wrapper:
|
|
20
|
-
* - 0 = success
|
|
21
|
-
* - 1 = http (404, 403 NOT_AUTHORIZED, 409 INVALID_STATE, 5xx)
|
|
22
|
-
* - 64 = usage (bad runId, missing env trio, --workspace mismatch,
|
|
23
|
-
* --to + --user-driven mutex violation, missing target)
|
|
24
|
-
*/
|
|
25
|
-
import { SUBSTRATE_CLI_RUN_SCOPES, WorkClientError, authenticatedRequest, mintSubstrateToken, } from './work-client.js';
|
|
26
|
-
import { resolveSubstrateContext } from './auth-context.js';
|
|
27
|
-
// ─── Public entry ─────────────────────────────────────────────────────────
|
|
28
|
-
const PLAN_RUN_ID_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,191}$/;
|
|
29
|
-
const AGENT_ID_MAX_LEN = 128;
|
|
30
|
-
export async function runRunTransfer(options) {
|
|
31
|
-
const env = options.env ?? process.env;
|
|
32
|
-
const format = options.outputFormat ?? 'summary';
|
|
33
|
-
if (!PLAN_RUN_ID_REGEX.test(options.planRunId)) {
|
|
34
|
-
return fail('usage', `invalid planRunId '${options.planRunId}': must match /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,191}$/`);
|
|
35
|
-
}
|
|
36
|
-
// Target must be a non-empty string ≤128 chars or explicit null.
|
|
37
|
-
// Mirrors the route's pre-store check so we fail fast without a
|
|
38
|
-
// network round-trip.
|
|
39
|
-
if (options.newOperatorAgentId !== null &&
|
|
40
|
-
(typeof options.newOperatorAgentId !== 'string' ||
|
|
41
|
-
options.newOperatorAgentId.length === 0 ||
|
|
42
|
-
options.newOperatorAgentId.length > AGENT_ID_MAX_LEN)) {
|
|
43
|
-
return fail('usage', `newOperatorAgentId must be a non-empty string ≤${AGENT_ID_MAX_LEN} chars or null`);
|
|
44
|
-
}
|
|
45
|
-
const auth = resolveSubstrateContext(env);
|
|
46
|
-
if (!auth.ok)
|
|
47
|
-
return fail('auth', auth.message);
|
|
48
|
-
const { sessionId, commonApiUrl, userToken } = auth.context;
|
|
49
|
-
let mint;
|
|
50
|
-
try {
|
|
51
|
-
mint = await mintSubstrateToken({
|
|
52
|
-
commonApiUrl,
|
|
53
|
-
userToken,
|
|
54
|
-
sessionId,
|
|
55
|
-
scopes: SUBSTRATE_CLI_RUN_SCOPES,
|
|
56
|
-
fetchImpl: options.fetchImpl,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
if (err instanceof WorkClientError) {
|
|
61
|
-
return fail('auth', `failed to mint substrate token: ${err.message}`, { status: err.status, code: err.code });
|
|
62
|
-
}
|
|
63
|
-
return fail('auth', `failed to mint substrate token: ${describeError(err)}`);
|
|
64
|
-
}
|
|
65
|
-
if (options.workspaceFlag && options.workspaceFlag !== mint.workspaceId) {
|
|
66
|
-
return fail('workspace_mismatch', `--workspace ${options.workspaceFlag} does not match the workspace bound to this session (${mint.workspaceId}).`);
|
|
67
|
-
}
|
|
68
|
-
const ctx = {
|
|
69
|
-
commonApiUrl,
|
|
70
|
-
delegatedToken: mint.token,
|
|
71
|
-
fetchImpl: options.fetchImpl,
|
|
72
|
-
};
|
|
73
|
-
const response = await authenticatedRequest(ctx, `/workspaces/${mint.workspaceId}/runs/${options.planRunId}/operator/transfer`, { method: 'POST', jsonBody: { newOperatorAgentId: options.newOperatorAgentId } });
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
const text = await safeReadText(response);
|
|
76
|
-
return fail('http', `work.transfer_run_operator failed: HTTP ${response.status} — ${text}`, {
|
|
77
|
-
status: response.status,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const json = (await response.json());
|
|
81
|
-
if (typeof json.planRunId !== 'string') {
|
|
82
|
-
return fail('http', 'work.transfer_run_operator response missing planRunId');
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
ok: true,
|
|
86
|
-
output: format === 'json' ? formatJson(json) : formatSummary(json),
|
|
87
|
-
response: json,
|
|
88
|
-
workspaceId: mint.workspaceId,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
// ─── Output formatting ────────────────────────────────────────────────────
|
|
92
|
-
export function formatSummary(response) {
|
|
93
|
-
const target = response.operatorAgentId === null
|
|
94
|
-
? 'user-driven (primaryOperator=null)'
|
|
95
|
-
: response.operatorAgentId;
|
|
96
|
-
// operatorCount surfaces the size of the additive operators[];
|
|
97
|
-
// the legacy operatorHistoryLength was removed in item 16.
|
|
98
|
-
const count = response.operatorCount ?? 0;
|
|
99
|
-
return `OK: transferred run ${response.planRunId} primary to ${target} (operatorCount=${count})`;
|
|
100
|
-
}
|
|
101
|
-
function formatJson(response) {
|
|
102
|
-
return JSON.stringify(response, null, 2);
|
|
103
|
-
}
|
|
104
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
105
|
-
function fail(kind, message, detail) {
|
|
106
|
-
return { ok: false, kind, message, detail };
|
|
107
|
-
}
|
|
108
|
-
function describeError(err) {
|
|
109
|
-
return err instanceof Error ? err.message : String(err);
|
|
110
|
-
}
|
|
111
|
-
async function safeReadText(response) {
|
|
112
|
-
try {
|
|
113
|
-
return await response.text();
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return '<no body>';
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
export function exitCodeForFailure(kind) {
|
|
120
|
-
switch (kind) {
|
|
121
|
-
case 'usage':
|
|
122
|
-
case 'auth':
|
|
123
|
-
case 'workspace_mismatch':
|
|
124
|
-
return 64;
|
|
125
|
-
case 'http':
|
|
126
|
-
return 1;
|
|
127
|
-
}
|
|
128
|
-
}
|