agentic-engineering-harness 0.6.14 → 0.6.16
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/operations/liveness.d.ts +1 -35
- package/dist/operations/liveness.js +1 -307
- package/dist/operations/liveness.js.map +1 -1
- package/dist/operations/livenessV2.d.ts +34 -0
- package/dist/operations/livenessV2.js +339 -0
- package/dist/operations/livenessV2.js.map +1 -0
- package/dist/operations/mcp.d.ts +1 -0
- package/dist/operations/mcp.js +13 -3
- package/dist/operations/mcp.js.map +1 -1
- package/dist/operations/state.d.ts +9 -1
- package/dist/operations/state.js +21 -92
- package/dist/operations/state.js.map +1 -1
- package/dist/operations/supervisor.d.ts +1 -0
- package/dist/operations/supervisor.js +130 -55
- package/dist/operations/supervisor.js.map +1 -1
- package/dist/operations/wakeBudget.d.ts +15 -0
- package/dist/operations/wakeBudget.js +142 -0
- package/dist/operations/wakeBudget.js.map +1 -0
- package/dist/paseo/runtime.d.ts +1 -1
- package/dist/paseo/runtime.js +85 -324
- package/dist/paseo/runtime.js.map +1 -1
- package/dist/paseo/sdk.d.ts +5 -0
- package/dist/paseo/sdk.js +23 -4
- package/dist/paseo/sdk.js.map +1 -1
- package/package.json +1 -1
package/dist/paseo/runtime.js
CHANGED
|
@@ -35,71 +35,36 @@ export async function launchManagedPaseoAgent(root, options, deps = DEFAULT_DEPS
|
|
|
35
35
|
try {
|
|
36
36
|
const created = fromSdk(await deps.sdk.create(root, { ...options, waitForFinish: false }));
|
|
37
37
|
await registerManagedAgent(root, options, created);
|
|
38
|
-
await trace(root, "agent.launch", {
|
|
39
|
-
|
|
40
|
-
agentId: created.id ?? "",
|
|
41
|
-
provider: options.provider,
|
|
42
|
-
model: options.model ?? "",
|
|
43
|
-
modeId: options.modeId ?? "",
|
|
44
|
-
modeSource: options.modeSource ?? "",
|
|
45
|
-
status: created.status ?? "unknown"
|
|
46
|
-
});
|
|
47
|
-
if (!created.id || options.prompt === undefined || options.waitForFinish === false) {
|
|
38
|
+
await trace(root, "agent.launch", { transport: "sdk", agentId: created.id ?? "", provider: options.provider, model: options.model ?? "", modeId: options.modeId ?? "", modeSource: options.modeSource ?? "", status: created.status ?? "unknown" });
|
|
39
|
+
if (!created.id || options.prompt === undefined || options.waitForFinish === false)
|
|
48
40
|
return created;
|
|
49
|
-
}
|
|
50
41
|
return waitManagedPaseoAgent(root, created.id, options.timeoutSeconds ?? secondsFromMs(options.timeoutMs), deps);
|
|
51
42
|
}
|
|
52
43
|
catch (error) {
|
|
53
44
|
if (!sdkCanFallback(error))
|
|
54
45
|
throw error;
|
|
55
|
-
await trace(root, "fallback.cli", {
|
|
56
|
-
operation: "launch",
|
|
57
|
-
provider: options.provider,
|
|
58
|
-
model: options.model ?? "",
|
|
59
|
-
modeId: options.modeId ?? "",
|
|
60
|
-
reason: errorMessage(error)
|
|
61
|
-
});
|
|
46
|
+
await trace(root, "fallback.cli", { operation: "launch", provider: options.provider, model: options.model ?? "", modeId: options.modeId ?? "", reason: errorMessage(error) });
|
|
62
47
|
return launchCli(root, options, deps, `SDK unavailable: ${errorMessage(error)}`);
|
|
63
48
|
}
|
|
64
49
|
}
|
|
65
|
-
await trace(root, "fallback.cli", {
|
|
66
|
-
operation: "launch",
|
|
67
|
-
provider: options.provider,
|
|
68
|
-
model: options.model ?? "",
|
|
69
|
-
modeId: options.modeId ?? "",
|
|
70
|
-
reason: "AEH_PASEO_FORCE_CLI=1"
|
|
71
|
-
});
|
|
50
|
+
await trace(root, "fallback.cli", { operation: "launch", provider: options.provider, model: options.model ?? "", modeId: options.modeId ?? "", reason: "AEH_PASEO_FORCE_CLI=1" });
|
|
72
51
|
return launchCli(root, options, deps, "AEH_PASEO_FORCE_CLI=1 forced the compatibility lifecycle.");
|
|
73
52
|
}
|
|
74
53
|
export async function materializeManagedPaseoAgent(root, options, deps = DEFAULT_DEPS) {
|
|
75
|
-
if (forceCli())
|
|
54
|
+
if (forceCli())
|
|
76
55
|
throw new PaseoSdkUnavailableError("Idle agent materialization is SDK-only; AEH_PASEO_FORCE_CLI=1 is active.");
|
|
77
|
-
}
|
|
78
56
|
await ensurePreflight(root, options, deps);
|
|
79
57
|
const trace = deps.trace ?? DEFAULT_DEPS.trace;
|
|
80
58
|
await traceResolvedIdentity(root, options, trace);
|
|
81
59
|
try {
|
|
82
|
-
const result = fromSdk(await deps.sdk.materialize(root, {
|
|
83
|
-
...options,
|
|
84
|
-
prompt: undefined,
|
|
85
|
-
waitForFinish: false
|
|
86
|
-
}));
|
|
60
|
+
const result = fromSdk(await deps.sdk.materialize(root, { ...options, prompt: undefined, waitForFinish: false }));
|
|
87
61
|
await registerManagedAgent(root, options, result);
|
|
88
|
-
await trace(root, "agent.materialize", {
|
|
89
|
-
transport: "sdk",
|
|
90
|
-
agentId: result.id ?? "",
|
|
91
|
-
provider: options.provider,
|
|
92
|
-
model: options.model ?? "",
|
|
93
|
-
modeId: options.modeId ?? "",
|
|
94
|
-
modeSource: options.modeSource ?? "",
|
|
95
|
-
workspaceId: result.workspaceId ?? ""
|
|
96
|
-
});
|
|
62
|
+
await trace(root, "agent.materialize", { transport: "sdk", agentId: result.id ?? "", provider: options.provider, model: options.model ?? "", modeId: options.modeId ?? "", modeSource: options.modeSource ?? "", workspaceId: result.workspaceId ?? "" });
|
|
97
63
|
return result;
|
|
98
64
|
}
|
|
99
65
|
catch (error) {
|
|
100
|
-
if (sdkCanFallback(error))
|
|
66
|
+
if (sdkCanFallback(error))
|
|
101
67
|
throw new PaseoSdkUnavailableError(`Paseo SDK is required to materialize an idle visible agent. ${errorMessage(error)}`, { cause: error });
|
|
102
|
-
}
|
|
103
68
|
throw error;
|
|
104
69
|
}
|
|
105
70
|
}
|
|
@@ -108,40 +73,18 @@ export async function dispatchManagedPaseoAgent(root, agentId, prompt, timeoutSe
|
|
|
108
73
|
if (!forceCli()) {
|
|
109
74
|
try {
|
|
110
75
|
const result = fromSdk(await deps.sdk.dispatch(root, agentId, prompt, timeoutMs(timeoutSeconds)));
|
|
111
|
-
await trace(root, "agent.dispatch", {
|
|
112
|
-
transport: "sdk",
|
|
113
|
-
agentId,
|
|
114
|
-
status: result.status ?? "unknown"
|
|
115
|
-
});
|
|
76
|
+
await trace(root, "agent.dispatch", { transport: "sdk", agentId, status: result.status ?? "unknown" });
|
|
116
77
|
return result;
|
|
117
78
|
}
|
|
118
79
|
catch (error) {
|
|
119
80
|
if (!sdkCanFallback(error))
|
|
120
81
|
throw error;
|
|
121
|
-
await trace(root, "fallback.cli", {
|
|
122
|
-
operation: "dispatch",
|
|
123
|
-
agentId,
|
|
124
|
-
reason: errorMessage(error)
|
|
125
|
-
});
|
|
82
|
+
await trace(root, "fallback.cli", { operation: "dispatch", agentId, reason: errorMessage(error) });
|
|
126
83
|
}
|
|
127
84
|
}
|
|
128
|
-
const send = await deps.run(`paseo send ${quote(agentId)} --no-wait ${quote(prompt)}`, {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
await trace(root, "agent.dispatch", {
|
|
133
|
-
transport: "cli",
|
|
134
|
-
agentId,
|
|
135
|
-
exitCode: send.exitCode
|
|
136
|
-
});
|
|
137
|
-
return {
|
|
138
|
-
id: agentId,
|
|
139
|
-
exitCode: send.exitCode,
|
|
140
|
-
stdout: send.stdout,
|
|
141
|
-
stderr: send.stderr,
|
|
142
|
-
status: send.exitCode === 0 ? "working" : "failed",
|
|
143
|
-
transport: "cli"
|
|
144
|
-
};
|
|
85
|
+
const send = await deps.run(`paseo send ${quote(agentId)} --no-wait ${quote(prompt)}`, { cwd: root, timeoutMs: 60_000 });
|
|
86
|
+
await trace(root, "agent.dispatch", { transport: "cli", agentId, exitCode: send.exitCode });
|
|
87
|
+
return { id: agentId, exitCode: send.exitCode, stdout: send.stdout, stderr: send.stderr, status: send.exitCode === 0 ? "working" : "failed", transport: "cli" };
|
|
145
88
|
}
|
|
146
89
|
export async function waitManagedPaseoAgent(root, agentId, timeoutSeconds, deps = DEFAULT_DEPS, baseline) {
|
|
147
90
|
const timeout = timeoutMs(timeoutSeconds);
|
|
@@ -150,92 +93,58 @@ export async function waitManagedPaseoAgent(root, agentId, timeoutSeconds, deps
|
|
|
150
93
|
const native = deps.native ?? DEFAULT_DEPS.native;
|
|
151
94
|
try {
|
|
152
95
|
const result = fromNativeWait(await native.wait(root, agentId, timeout, baseline));
|
|
153
|
-
await trace(root, "agent.wait.completed", {
|
|
154
|
-
transport: "sdk",
|
|
155
|
-
observation: "subscription",
|
|
156
|
-
agentId,
|
|
157
|
-
status: result.status ?? "unknown"
|
|
158
|
-
});
|
|
96
|
+
await trace(root, "agent.wait.completed", { transport: "sdk", observation: "subscription", agentId, status: result.status ?? "unknown" });
|
|
159
97
|
return result;
|
|
160
98
|
}
|
|
161
99
|
catch (error) {
|
|
162
100
|
if (!sdkCanFallback(error))
|
|
163
101
|
throw error;
|
|
164
|
-
await trace(root, "agent.wait.fallback", {
|
|
165
|
-
agentId,
|
|
166
|
-
from: "subscription",
|
|
167
|
-
to: "sdk-wait",
|
|
168
|
-
reason: errorMessage(error)
|
|
169
|
-
});
|
|
102
|
+
await trace(root, "agent.wait.fallback", { agentId, from: "subscription", to: "sdk-wait", reason: errorMessage(error) });
|
|
170
103
|
try {
|
|
171
|
-
const result = {
|
|
172
|
-
|
|
173
|
-
observation: "sdk-wait"
|
|
174
|
-
};
|
|
175
|
-
await trace(root, "agent.wait.completed", {
|
|
176
|
-
transport: "sdk",
|
|
177
|
-
observation: "sdk-wait",
|
|
178
|
-
agentId,
|
|
179
|
-
status: result.status ?? "unknown"
|
|
180
|
-
});
|
|
104
|
+
const result = { ...fromSdk(await deps.sdk.wait(root, agentId, timeout)), observation: "sdk-wait" };
|
|
105
|
+
await trace(root, "agent.wait.completed", { transport: "sdk", observation: "sdk-wait", agentId, status: result.status ?? "unknown" });
|
|
181
106
|
return result;
|
|
182
107
|
}
|
|
183
108
|
catch (sdkError) {
|
|
184
109
|
if (!sdkCanFallback(sdkError))
|
|
185
110
|
throw sdkError;
|
|
186
|
-
await trace(root, "fallback.cli", {
|
|
187
|
-
operation: "wait",
|
|
188
|
-
agentId,
|
|
189
|
-
reason: errorMessage(sdkError)
|
|
190
|
-
});
|
|
111
|
+
await trace(root, "fallback.cli", { operation: "wait", agentId, reason: errorMessage(sdkError) });
|
|
191
112
|
}
|
|
192
113
|
}
|
|
193
114
|
}
|
|
194
115
|
const timeoutSec = timeoutSeconds ?? 1800;
|
|
195
|
-
const wait = await deps.run(`paseo wait ${quote(agentId)} --timeout ${timeoutSec}`, {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
const logs = await deps.run(`paseo logs ${quote(agentId)} --tail 200`, {
|
|
200
|
-
cwd: root,
|
|
201
|
-
timeoutMs: 60_000
|
|
202
|
-
});
|
|
203
|
-
const result = {
|
|
204
|
-
id: agentId,
|
|
205
|
-
exitCode: wait.exitCode,
|
|
206
|
-
stdout: logs.stdout || wait.stdout,
|
|
207
|
-
stderr: [wait.stderr, logs.stderr].filter(Boolean).join("\n"),
|
|
208
|
-
status: wait.exitCode === 0 ? "idle" : "failed",
|
|
209
|
-
transport: "cli",
|
|
210
|
-
observation: "cli-wait"
|
|
211
|
-
};
|
|
212
|
-
await trace(root, "agent.wait.completed", {
|
|
213
|
-
transport: "cli",
|
|
214
|
-
observation: "cli-wait",
|
|
215
|
-
agentId,
|
|
216
|
-
status: result.status ?? "unknown"
|
|
217
|
-
});
|
|
116
|
+
const wait = await deps.run(`paseo wait ${quote(agentId)} --timeout ${timeoutSec}`, { cwd: root, timeoutMs: (timeoutSec + 30) * 1000 });
|
|
117
|
+
const logs = await deps.run(`paseo logs ${quote(agentId)} --tail 200`, { cwd: root, timeoutMs: 60_000 });
|
|
118
|
+
const result = { id: agentId, exitCode: wait.exitCode, stdout: logs.stdout || wait.stdout, stderr: [wait.stderr, logs.stderr].filter(Boolean).join("\n"), status: wait.exitCode === 0 ? "idle" : "failed", transport: "cli", observation: "cli-wait" };
|
|
119
|
+
await trace(root, "agent.wait.completed", { transport: "cli", observation: "cli-wait", agentId, status: result.status ?? "unknown" });
|
|
218
120
|
return result;
|
|
219
121
|
}
|
|
220
122
|
export async function continueManagedPaseoAgent(root, agentId, prompt, timeoutSeconds, deps = DEFAULT_DEPS) {
|
|
123
|
+
const trace = deps.trace ?? DEFAULT_DEPS.trace;
|
|
124
|
+
if (!forceCli()) {
|
|
125
|
+
try {
|
|
126
|
+
const result = { ...fromSdk(await deps.sdk.run(root, agentId, prompt, timeoutMs(timeoutSeconds))), observation: "sdk-run" };
|
|
127
|
+
await trace(root, "agent.turn.completed", { transport: "sdk", observation: "sdk-run", agentId, status: result.status ?? "unknown" });
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (!sdkCanFallback(error))
|
|
132
|
+
throw error;
|
|
133
|
+
await trace(root, "agent.turn.fallback", { agentId, from: "sdk-run", to: "subscription", reason: errorMessage(error) });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
221
136
|
let baseline;
|
|
222
137
|
if (!forceCli()) {
|
|
223
138
|
const native = deps.native ?? DEFAULT_DEPS.native;
|
|
224
139
|
if (typeof native.capture === "function") {
|
|
225
140
|
try {
|
|
226
141
|
baseline = await native.capture(root, agentId);
|
|
227
|
-
await
|
|
228
|
-
agentId,
|
|
229
|
-
assistantMessage: baseline.lastAssistantMessage ? "present" : "absent"
|
|
230
|
-
});
|
|
142
|
+
await trace(root, "agent.turn.baseline", { agentId, assistantMessage: baseline.lastAssistantMessage ? "present" : "absent" });
|
|
231
143
|
}
|
|
232
144
|
catch (error) {
|
|
233
145
|
if (!sdkCanFallback(error))
|
|
234
146
|
throw error;
|
|
235
|
-
await
|
|
236
|
-
agentId,
|
|
237
|
-
reason: errorMessage(error)
|
|
238
|
-
});
|
|
147
|
+
await trace(root, "agent.turn.baseline.skipped", { agentId, reason: errorMessage(error) });
|
|
239
148
|
}
|
|
240
149
|
}
|
|
241
150
|
}
|
|
@@ -254,10 +163,7 @@ export async function probeManagedPaseoAgent(root, agentId, deps = DEFAULT_DEPS)
|
|
|
254
163
|
return false;
|
|
255
164
|
}
|
|
256
165
|
}
|
|
257
|
-
const probe = await deps.run(`paseo logs ${quote(agentId)} --tail 1`, {
|
|
258
|
-
cwd: root,
|
|
259
|
-
timeoutMs: 30_000
|
|
260
|
-
});
|
|
166
|
+
const probe = await deps.run(`paseo logs ${quote(agentId)} --tail 1`, { cwd: root, timeoutMs: 30_000 });
|
|
261
167
|
return probe.exitCode === 0;
|
|
262
168
|
}
|
|
263
169
|
export async function inspectManagedPaseoAgent(root, agentId, deps = DEFAULT_DEPS) {
|
|
@@ -281,10 +187,7 @@ export async function listManagedPaseoAgents(root, labels = {}, deps = DEFAULT_D
|
|
|
281
187
|
catch (error) {
|
|
282
188
|
if (!sdkCanFallback(error))
|
|
283
189
|
throw error;
|
|
284
|
-
await trace(root, "agent.list.cli.required", {
|
|
285
|
-
reason: errorMessage(error),
|
|
286
|
-
labelCount: Object.keys(labels).length
|
|
287
|
-
});
|
|
190
|
+
await trace(root, "agent.list.cli.required", { reason: errorMessage(error), labelCount: Object.keys(labels).length });
|
|
288
191
|
}
|
|
289
192
|
}
|
|
290
193
|
return (await listCliAgents(root, deps)).filter((agent) => Object.entries(labels).every(([key, value]) => agent.labels?.[key] === value));
|
|
@@ -295,154 +198,76 @@ async function ensurePreflight(root, options, deps) {
|
|
|
295
198
|
try {
|
|
296
199
|
const result = await native.preflight(root, options.provider, options.model, options.cwd);
|
|
297
200
|
if (!result.ok) {
|
|
298
|
-
const available = result.availableModels?.length
|
|
299
|
-
? ` Available models: ${result.availableModels.join(", ")}.`
|
|
300
|
-
: "";
|
|
201
|
+
const available = result.availableModels?.length ? ` Available models: ${result.availableModels.join(", ")}.` : "";
|
|
301
202
|
throw new Error(`Paseo provider preflight failed: ${result.message}${available}`);
|
|
302
203
|
}
|
|
303
204
|
}
|
|
304
205
|
catch (error) {
|
|
305
|
-
if (sdkCanFallback(error))
|
|
306
|
-
await trace(root, "provider.preflight.skipped", {
|
|
307
|
-
|
|
308
|
-
model: options.model ?? "",
|
|
309
|
-
reason: errorMessage(error)
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
206
|
+
if (sdkCanFallback(error))
|
|
207
|
+
await trace(root, "provider.preflight.skipped", { provider: options.provider, model: options.model ?? "", reason: errorMessage(error) });
|
|
208
|
+
else
|
|
313
209
|
throw error;
|
|
314
|
-
}
|
|
315
210
|
}
|
|
316
211
|
if (!options.modeId)
|
|
317
212
|
return;
|
|
318
213
|
if (options.modeSource === "aeh-managed") {
|
|
319
|
-
await trace(root, "provider.mode.preflight", {
|
|
320
|
-
ok: true,
|
|
321
|
-
provider: options.provider,
|
|
322
|
-
modeId: options.modeId,
|
|
323
|
-
source: "aeh-inline-config",
|
|
324
|
-
message: "AEH injects this primary OpenCode agent through the session launch environment; ambient provider mode discovery is not authoritative for the dedicated helper."
|
|
325
|
-
});
|
|
214
|
+
await trace(root, "provider.mode.preflight", { ok: true, provider: options.provider, modeId: options.modeId, source: "aeh-inline-config", message: "AEH injects this primary OpenCode agent through the session launch environment; ambient provider mode discovery is not authoritative for the dedicated helper." });
|
|
326
215
|
return;
|
|
327
216
|
}
|
|
328
217
|
const mode = await native.preflightMode(root, options.provider, options.modeId, options.cwd);
|
|
329
218
|
if (!mode.ok) {
|
|
330
|
-
const available = mode.availableModes.length
|
|
331
|
-
? ` Available modes: ${mode.availableModes.join(", ")}.`
|
|
332
|
-
: "";
|
|
219
|
+
const available = mode.availableModes.length ? ` Available modes: ${mode.availableModes.join(", ")}.` : "";
|
|
333
220
|
throw new Error(`Paseo mode preflight failed: ${mode.message}${available}`);
|
|
334
221
|
}
|
|
335
222
|
}
|
|
336
223
|
async function traceResolvedIdentity(root, options, trace) {
|
|
337
224
|
if (!options.modeId)
|
|
338
225
|
return;
|
|
339
|
-
await trace(root, "agent.identity", {
|
|
340
|
-
provider: options.provider,
|
|
341
|
-
model: options.model ?? "",
|
|
342
|
-
modeId: options.modeId,
|
|
343
|
-
source: options.modeSource ?? "provider-mode",
|
|
344
|
-
sessionScopedEnv: options.env?.OPENCODE_CONFIG_CONTENT ? true : false
|
|
345
|
-
});
|
|
226
|
+
await trace(root, "agent.identity", { provider: options.provider, model: options.model ?? "", modeId: options.modeId, source: options.modeSource ?? "provider-mode", sessionScopedEnv: options.env?.OPENCODE_CONFIG_CONTENT ? true : false });
|
|
346
227
|
}
|
|
347
228
|
async function launchCli(root, options, deps, fallbackReason) {
|
|
348
|
-
if (options.prompt === undefined && options.systemPrompt !== undefined)
|
|
229
|
+
if (options.prompt === undefined && options.systemPrompt !== undefined)
|
|
349
230
|
throw new PaseoSdkUnavailableError(`Paseo SDK is required to create an idle systemPrompt-only agent. Refusing CLI fallback because it would expose session instructions as a user turn. ${fallbackReason}`);
|
|
350
|
-
|
|
351
|
-
if (options.env && Object.keys(options.env).length) {
|
|
231
|
+
if (options.env && Object.keys(options.env).length)
|
|
352
232
|
throw new PaseoSdkUnavailableError(`Paseo SDK is required for session-scoped launch environment used by provider ${options.provider}${options.modeId ? ` mode ${options.modeId}` : ""}. Refusing CLI fallback because dropping that environment could change the native execution identity or permissions. ${fallbackReason}`);
|
|
353
|
-
}
|
|
354
233
|
const capabilities = await deps.detectCapabilities(root, deps.run);
|
|
355
234
|
const prompt = options.prompt;
|
|
356
235
|
if (prompt === undefined)
|
|
357
236
|
throw new Error("Paseo CLI fallback requires a prompt.");
|
|
358
237
|
const timeout = options.timeoutSeconds ?? Math.max(1, Math.ceil((options.timeoutMs ?? 1_800_000) / 1000));
|
|
359
238
|
if (options.outputSchema) {
|
|
360
|
-
if (!capabilities.outputSchema)
|
|
239
|
+
if (!capabilities.outputSchema)
|
|
361
240
|
throw new Error(`Installed Paseo${capabilities.version ? ` ${capabilities.version}` : ""} does not advertise --output-schema required by this agent.`);
|
|
362
|
-
}
|
|
363
|
-
const parts = [
|
|
364
|
-
"paseo run --quiet",
|
|
365
|
-
`--title ${quote(options.title)}`,
|
|
366
|
-
`--provider ${quote(options.provider)}`
|
|
367
|
-
];
|
|
241
|
+
const parts = ["paseo run --quiet", `--title ${quote(options.title)}`, `--provider ${quote(options.provider)}`];
|
|
368
242
|
if (options.workspaceId)
|
|
369
243
|
parts.push(`--workspace ${quote(options.workspaceId)}`);
|
|
370
244
|
if (options.model)
|
|
371
245
|
parts.push(`--model ${quote(options.model)}`);
|
|
372
246
|
parts.push(`--output-schema ${quote(JSON.stringify(options.outputSchema))}`, quote(prompt));
|
|
373
|
-
const result = await deps.run(parts.join(" "), {
|
|
374
|
-
|
|
375
|
-
timeoutMs: timeout * 1000
|
|
376
|
-
});
|
|
377
|
-
return {
|
|
378
|
-
exitCode: result.exitCode,
|
|
379
|
-
stdout: result.stdout,
|
|
380
|
-
stderr: [fallbackReason, result.stderr].filter(Boolean).join("\n"),
|
|
381
|
-
status: result.exitCode === 0 ? "idle" : "failed",
|
|
382
|
-
transport: "cli"
|
|
383
|
-
};
|
|
247
|
+
const result = await deps.run(parts.join(" "), { cwd: root, timeoutMs: timeout * 1000 });
|
|
248
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: [fallbackReason, result.stderr].filter(Boolean).join("\n"), status: result.exitCode === 0 ? "idle" : "failed", transport: "cli" };
|
|
384
249
|
}
|
|
385
|
-
const command = buildPaseoBackgroundRunCommand({
|
|
386
|
-
title: options.title,
|
|
387
|
-
provider: options.provider,
|
|
388
|
-
model: options.model,
|
|
389
|
-
workspaceId: options.workspaceId,
|
|
390
|
-
prompt
|
|
391
|
-
}, capabilities);
|
|
250
|
+
const command = buildPaseoBackgroundRunCommand({ title: options.title, provider: options.provider, model: options.model, workspaceId: options.workspaceId, prompt }, capabilities);
|
|
392
251
|
const launch = await deps.run(command, { cwd: root, timeoutMs: 60_000 });
|
|
393
|
-
if (launch.exitCode !== 0)
|
|
394
|
-
return {
|
|
395
|
-
exitCode: launch.exitCode,
|
|
396
|
-
stdout: launch.stdout,
|
|
397
|
-
stderr: [fallbackReason, launch.stderr].filter(Boolean).join("\n"),
|
|
398
|
-
status: "failed",
|
|
399
|
-
transport: "cli"
|
|
400
|
-
};
|
|
401
|
-
}
|
|
252
|
+
if (launch.exitCode !== 0)
|
|
253
|
+
return { exitCode: launch.exitCode, stdout: launch.stdout, stderr: [fallbackReason, launch.stderr].filter(Boolean).join("\n"), status: "failed", transport: "cli" };
|
|
402
254
|
const id = extractPaseoAgentId(launch.stdout);
|
|
403
|
-
if (!id)
|
|
404
|
-
return {
|
|
405
|
-
|
|
406
|
-
stdout: launch.stdout,
|
|
407
|
-
stderr: [fallbackReason, "Paseo returned no parseable agent id."].join("\n"),
|
|
408
|
-
status: "failed",
|
|
409
|
-
transport: "cli"
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
const launched = {
|
|
413
|
-
id,
|
|
414
|
-
exitCode: 0,
|
|
415
|
-
stdout: launch.stdout,
|
|
416
|
-
stderr: launch.stderr,
|
|
417
|
-
status: "working",
|
|
418
|
-
workspaceId: options.workspaceId,
|
|
419
|
-
transport: "cli"
|
|
420
|
-
};
|
|
255
|
+
if (!id)
|
|
256
|
+
return { exitCode: 1, stdout: launch.stdout, stderr: [fallbackReason, "Paseo returned no parseable agent id."].join("\n"), status: "failed", transport: "cli" };
|
|
257
|
+
const launched = { id, exitCode: 0, stdout: launch.stdout, stderr: launch.stderr, status: "working", workspaceId: options.workspaceId, transport: "cli" };
|
|
421
258
|
await registerManagedAgent(root, options, launched);
|
|
422
259
|
if (options.waitForFinish === false)
|
|
423
260
|
return launched;
|
|
424
261
|
const waited = await waitManagedPaseoAgent(root, id, timeout, deps);
|
|
425
|
-
return {
|
|
426
|
-
...waited,
|
|
427
|
-
stderr: [fallbackReason, launch.stderr, waited.stderr].filter(Boolean).join("\n")
|
|
428
|
-
};
|
|
262
|
+
return { ...waited, stderr: [fallbackReason, launch.stderr, waited.stderr].filter(Boolean).join("\n") };
|
|
429
263
|
}
|
|
430
264
|
async function registerManagedAgent(root, options, result) {
|
|
431
265
|
if (!result.id)
|
|
432
266
|
return;
|
|
433
|
-
await registerCurrentOperationAgent(root, {
|
|
434
|
-
id: result.id,
|
|
435
|
-
role: options.labels?.["aeh.role"],
|
|
436
|
-
phase: options.labels?.["aeh.operation.phase"],
|
|
437
|
-
workspaceId: result.workspaceId ?? options.workspaceId,
|
|
438
|
-
transport: result.transport
|
|
439
|
-
});
|
|
267
|
+
await registerCurrentOperationAgent(root, { id: result.id, role: options.labels?.["aeh.role"], phase: options.labels?.["aeh.operation.phase"], workspaceId: result.workspaceId ?? options.workspaceId, transport: result.transport });
|
|
440
268
|
}
|
|
441
269
|
async function listCliAgents(root, deps) {
|
|
442
|
-
const result = await deps.run("paseo ls -a -g --json", {
|
|
443
|
-
cwd: root,
|
|
444
|
-
timeoutMs: 30_000
|
|
445
|
-
});
|
|
270
|
+
const result = await deps.run("paseo ls -a -g --json", { cwd: root, timeoutMs: 30_000 });
|
|
446
271
|
if (result.exitCode !== 0 || !result.stdout.trim())
|
|
447
272
|
return [];
|
|
448
273
|
try {
|
|
@@ -464,95 +289,31 @@ function collectCliAgents(value, out) {
|
|
|
464
289
|
return;
|
|
465
290
|
const record = value;
|
|
466
291
|
const id = firstString(record, ["id", "agentId", "agent_id"]);
|
|
467
|
-
if (id && ("status" in record || "title" in record || "labels" in record))
|
|
468
|
-
out.set(id, {
|
|
469
|
-
id,
|
|
470
|
-
title: firstString(record, ["title", "name"]),
|
|
471
|
-
status: statusText(record.status),
|
|
472
|
-
workspaceId: firstString(record, ["workspaceId", "workspace_id"]),
|
|
473
|
-
labels: stringRecord(record.labels),
|
|
474
|
-
raw: record
|
|
475
|
-
});
|
|
476
|
-
}
|
|
292
|
+
if (id && ("status" in record || "title" in record || "labels" in record))
|
|
293
|
+
out.set(id, { id, title: firstString(record, ["title", "name"]), status: statusText(record.status), workspaceId: firstString(record, ["workspaceId", "workspace_id"]), labels: stringRecord(record.labels), raw: record });
|
|
477
294
|
for (const child of Object.values(record))
|
|
478
295
|
collectCliAgents(child, out);
|
|
479
296
|
}
|
|
480
|
-
function forceCli() {
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
function
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return (
|
|
489
|
-
}
|
|
490
|
-
function
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
function
|
|
494
|
-
return {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
function fromNativeWait(result) {
|
|
505
|
-
return {
|
|
506
|
-
id: result.id,
|
|
507
|
-
exitCode: sdkExitCode(result.status, result.error),
|
|
508
|
-
stdout: result.lastMessage ?? "",
|
|
509
|
-
stderr: result.error ?? "",
|
|
510
|
-
status: result.status,
|
|
511
|
-
workspaceId: result.workspaceId,
|
|
512
|
-
transport: "sdk",
|
|
513
|
-
observation: "subscription"
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
function sdkExitCode(status, error) {
|
|
517
|
-
if (status === "timeout")
|
|
518
|
-
return 124;
|
|
519
|
-
if (error)
|
|
520
|
-
return 1;
|
|
521
|
-
if (status === "failed" || status === "error" || status === "cancelled")
|
|
522
|
-
return 1;
|
|
523
|
-
return 0;
|
|
524
|
-
}
|
|
525
|
-
function firstString(record, keys) {
|
|
526
|
-
for (const key of keys) {
|
|
527
|
-
if (typeof record[key] === "string" && record[key])
|
|
528
|
-
return record[key];
|
|
529
|
-
}
|
|
530
|
-
return undefined;
|
|
531
|
-
}
|
|
532
|
-
function stringRecord(value) {
|
|
533
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
534
|
-
return undefined;
|
|
535
|
-
const result = {};
|
|
536
|
-
for (const [key, item] of Object.entries(value)) {
|
|
537
|
-
if (typeof item === "string")
|
|
538
|
-
result[key] = item;
|
|
539
|
-
}
|
|
540
|
-
return Object.keys(result).length ? result : undefined;
|
|
541
|
-
}
|
|
542
|
-
function statusText(value) {
|
|
543
|
-
if (typeof value === "string")
|
|
544
|
-
return value;
|
|
545
|
-
if (value &&
|
|
546
|
-
typeof value === "object" &&
|
|
547
|
-
typeof value.status === "string") {
|
|
548
|
-
return value.status;
|
|
549
|
-
}
|
|
550
|
-
return undefined;
|
|
551
|
-
}
|
|
552
|
-
function errorMessage(error) {
|
|
553
|
-
return error instanceof Error ? error.message : String(error);
|
|
554
|
-
}
|
|
555
|
-
function quote(value) {
|
|
556
|
-
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
557
|
-
}
|
|
297
|
+
function forceCli() { return process.env.AEH_PASEO_FORCE_CLI === "1"; }
|
|
298
|
+
function sdkCanFallback(error) { return error instanceof PaseoSdkUnavailableError || (error instanceof Error && error.name === "PaseoSdkUnavailableError"); }
|
|
299
|
+
function timeoutMs(seconds) { return (seconds ?? 1800) * 1000; }
|
|
300
|
+
function secondsFromMs(ms) { return ms === undefined ? undefined : Math.max(1, Math.ceil(ms / 1000)); }
|
|
301
|
+
function fromSdk(result) { return { id: result.id, exitCode: sdkExitCode(result.status, result.error), stdout: result.lastMessage ?? "", stderr: result.error ?? "", status: result.status, workspaceId: result.workspaceId, transport: "sdk" }; }
|
|
302
|
+
function fromNativeWait(result) { return { id: result.id, exitCode: sdkExitCode(result.status, result.error), stdout: result.lastMessage ?? "", stderr: result.error ?? "", status: result.status, workspaceId: result.workspaceId, transport: "sdk", observation: "subscription" }; }
|
|
303
|
+
function sdkExitCode(status, error) { if (status === "timeout")
|
|
304
|
+
return 124; if (error)
|
|
305
|
+
return 1; if (status === "failed" || status === "error" || status === "cancelled")
|
|
306
|
+
return 1; return 0; }
|
|
307
|
+
function firstString(record, keys) { for (const key of keys)
|
|
308
|
+
if (typeof record[key] === "string" && record[key])
|
|
309
|
+
return record[key]; return undefined; }
|
|
310
|
+
function stringRecord(value) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
311
|
+
return undefined; const result = {}; for (const [key, item] of Object.entries(value))
|
|
312
|
+
if (typeof item === "string")
|
|
313
|
+
result[key] = item; return Object.keys(result).length ? result : undefined; }
|
|
314
|
+
function statusText(value) { if (typeof value === "string")
|
|
315
|
+
return value; if (value && typeof value === "object" && typeof value.status === "string")
|
|
316
|
+
return value.status; return undefined; }
|
|
317
|
+
function errorMessage(error) { return error instanceof Error ? error.message : String(error); }
|
|
318
|
+
function quote(value) { return `'${value.replaceAll("'", "'\\''")}'`; }
|
|
558
319
|
//# sourceMappingURL=runtime.js.map
|