agentic-engineering-harness 0.6.15 → 0.6.17
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/agents/structuredOutput.d.ts +5 -0
- package/dist/agents/structuredOutput.js +25 -3
- package/dist/agents/structuredOutput.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 +73 -51
- package/dist/operations/supervisor.js.map +1 -1
- package/dist/paseo/runtime.d.ts +2 -2
- package/dist/paseo/runtime.js +99 -325
- package/dist/paseo/runtime.js.map +1 -1
- package/dist/paseo/sdk.d.ts +9 -1
- package/dist/paseo/sdk.js +46 -8
- package/dist/paseo/sdk.js.map +1 -1
- package/dist/workers/agentPrompt.d.ts +5 -0
- package/dist/workers/agentPrompt.js +63 -6
- package/dist/workers/agentPrompt.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,68 @@ 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
|
-
export async function continueManagedPaseoAgent(root, agentId, prompt, timeoutSeconds, deps = DEFAULT_DEPS) {
|
|
122
|
+
export async function continueManagedPaseoAgent(root, agentId, prompt, timeoutSeconds, deps = DEFAULT_DEPS, outputSchema) {
|
|
123
|
+
const trace = deps.trace ?? DEFAULT_DEPS.trace;
|
|
124
|
+
if (!forceCli()) {
|
|
125
|
+
try {
|
|
126
|
+
const result = {
|
|
127
|
+
...fromSdk(await deps.sdk.run(root, agentId, prompt, timeoutMs(timeoutSeconds), outputSchema)),
|
|
128
|
+
observation: "sdk-run"
|
|
129
|
+
};
|
|
130
|
+
await trace(root, "agent.turn.completed", {
|
|
131
|
+
transport: "sdk",
|
|
132
|
+
observation: "sdk-run",
|
|
133
|
+
agentId,
|
|
134
|
+
status: result.status ?? "unknown",
|
|
135
|
+
structured: Boolean(outputSchema),
|
|
136
|
+
payloadCaptured: Boolean(result.stdout)
|
|
137
|
+
});
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (!sdkCanFallback(error))
|
|
142
|
+
throw error;
|
|
143
|
+
await trace(root, "agent.turn.fallback", { agentId, from: "sdk-run", to: "subscription", reason: errorMessage(error), structured: Boolean(outputSchema) });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
221
146
|
let baseline;
|
|
222
147
|
if (!forceCli()) {
|
|
223
148
|
const native = deps.native ?? DEFAULT_DEPS.native;
|
|
224
149
|
if (typeof native.capture === "function") {
|
|
225
150
|
try {
|
|
226
151
|
baseline = await native.capture(root, agentId);
|
|
227
|
-
await
|
|
228
|
-
agentId,
|
|
229
|
-
assistantMessage: baseline.lastAssistantMessage ? "present" : "absent"
|
|
230
|
-
});
|
|
152
|
+
await trace(root, "agent.turn.baseline", { agentId, assistantMessage: baseline.lastAssistantMessage ? "present" : "absent" });
|
|
231
153
|
}
|
|
232
154
|
catch (error) {
|
|
233
155
|
if (!sdkCanFallback(error))
|
|
234
156
|
throw error;
|
|
235
|
-
await
|
|
236
|
-
agentId,
|
|
237
|
-
reason: errorMessage(error)
|
|
238
|
-
});
|
|
157
|
+
await trace(root, "agent.turn.baseline.skipped", { agentId, reason: errorMessage(error) });
|
|
239
158
|
}
|
|
240
159
|
}
|
|
241
160
|
}
|
|
@@ -254,10 +173,7 @@ export async function probeManagedPaseoAgent(root, agentId, deps = DEFAULT_DEPS)
|
|
|
254
173
|
return false;
|
|
255
174
|
}
|
|
256
175
|
}
|
|
257
|
-
const probe = await deps.run(`paseo logs ${quote(agentId)} --tail 1`, {
|
|
258
|
-
cwd: root,
|
|
259
|
-
timeoutMs: 30_000
|
|
260
|
-
});
|
|
176
|
+
const probe = await deps.run(`paseo logs ${quote(agentId)} --tail 1`, { cwd: root, timeoutMs: 30_000 });
|
|
261
177
|
return probe.exitCode === 0;
|
|
262
178
|
}
|
|
263
179
|
export async function inspectManagedPaseoAgent(root, agentId, deps = DEFAULT_DEPS) {
|
|
@@ -281,10 +197,7 @@ export async function listManagedPaseoAgents(root, labels = {}, deps = DEFAULT_D
|
|
|
281
197
|
catch (error) {
|
|
282
198
|
if (!sdkCanFallback(error))
|
|
283
199
|
throw error;
|
|
284
|
-
await trace(root, "agent.list.cli.required", {
|
|
285
|
-
reason: errorMessage(error),
|
|
286
|
-
labelCount: Object.keys(labels).length
|
|
287
|
-
});
|
|
200
|
+
await trace(root, "agent.list.cli.required", { reason: errorMessage(error), labelCount: Object.keys(labels).length });
|
|
288
201
|
}
|
|
289
202
|
}
|
|
290
203
|
return (await listCliAgents(root, deps)).filter((agent) => Object.entries(labels).every(([key, value]) => agent.labels?.[key] === value));
|
|
@@ -295,154 +208,79 @@ async function ensurePreflight(root, options, deps) {
|
|
|
295
208
|
try {
|
|
296
209
|
const result = await native.preflight(root, options.provider, options.model, options.cwd);
|
|
297
210
|
if (!result.ok) {
|
|
298
|
-
const available = result.availableModels?.length
|
|
299
|
-
? ` Available models: ${result.availableModels.join(", ")}.`
|
|
300
|
-
: "";
|
|
211
|
+
const available = result.availableModels?.length ? ` Available models: ${result.availableModels.join(", ")}.` : "";
|
|
301
212
|
throw new Error(`Paseo provider preflight failed: ${result.message}${available}`);
|
|
302
213
|
}
|
|
303
214
|
}
|
|
304
215
|
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 {
|
|
216
|
+
if (sdkCanFallback(error))
|
|
217
|
+
await trace(root, "provider.preflight.skipped", { provider: options.provider, model: options.model ?? "", reason: errorMessage(error) });
|
|
218
|
+
else
|
|
313
219
|
throw error;
|
|
314
|
-
}
|
|
315
220
|
}
|
|
316
221
|
if (!options.modeId)
|
|
317
222
|
return;
|
|
318
223
|
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
|
-
});
|
|
224
|
+
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
225
|
return;
|
|
327
226
|
}
|
|
328
227
|
const mode = await native.preflightMode(root, options.provider, options.modeId, options.cwd);
|
|
329
228
|
if (!mode.ok) {
|
|
330
|
-
const available = mode.availableModes.length
|
|
331
|
-
? ` Available modes: ${mode.availableModes.join(", ")}.`
|
|
332
|
-
: "";
|
|
229
|
+
const available = mode.availableModes.length ? ` Available modes: ${mode.availableModes.join(", ")}.` : "";
|
|
333
230
|
throw new Error(`Paseo mode preflight failed: ${mode.message}${available}`);
|
|
334
231
|
}
|
|
335
232
|
}
|
|
336
233
|
async function traceResolvedIdentity(root, options, trace) {
|
|
337
234
|
if (!options.modeId)
|
|
338
235
|
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
|
-
});
|
|
236
|
+
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
237
|
}
|
|
347
238
|
async function launchCli(root, options, deps, fallbackReason) {
|
|
348
|
-
if (options.prompt === undefined && options.systemPrompt !== undefined)
|
|
239
|
+
if (options.prompt === undefined && options.systemPrompt !== undefined)
|
|
349
240
|
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) {
|
|
241
|
+
if (options.env && Object.keys(options.env).length)
|
|
352
242
|
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
243
|
const capabilities = await deps.detectCapabilities(root, deps.run);
|
|
355
244
|
const prompt = options.prompt;
|
|
356
245
|
if (prompt === undefined)
|
|
357
246
|
throw new Error("Paseo CLI fallback requires a prompt.");
|
|
358
247
|
const timeout = options.timeoutSeconds ?? Math.max(1, Math.ceil((options.timeoutMs ?? 1_800_000) / 1000));
|
|
359
248
|
if (options.outputSchema) {
|
|
360
|
-
if (!capabilities.outputSchema)
|
|
249
|
+
if (!capabilities.outputSchema)
|
|
361
250
|
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
|
-
];
|
|
251
|
+
const parts = ["paseo run --quiet", `--title ${quote(options.title)}`, `--provider ${quote(options.provider)}`];
|
|
368
252
|
if (options.workspaceId)
|
|
369
253
|
parts.push(`--workspace ${quote(options.workspaceId)}`);
|
|
370
254
|
if (options.model)
|
|
371
255
|
parts.push(`--model ${quote(options.model)}`);
|
|
372
256
|
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
|
-
};
|
|
257
|
+
const result = await deps.run(parts.join(" "), { cwd: root, timeoutMs: timeout * 1000 });
|
|
258
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: [fallbackReason, result.stderr].filter(Boolean).join("\n"), status: result.exitCode === 0 ? "idle" : "failed", transport: "cli" };
|
|
384
259
|
}
|
|
385
|
-
const command = buildPaseoBackgroundRunCommand({
|
|
386
|
-
title: options.title,
|
|
387
|
-
provider: options.provider,
|
|
388
|
-
model: options.model,
|
|
389
|
-
workspaceId: options.workspaceId,
|
|
390
|
-
prompt
|
|
391
|
-
}, capabilities);
|
|
260
|
+
const command = buildPaseoBackgroundRunCommand({ title: options.title, provider: options.provider, model: options.model, workspaceId: options.workspaceId, prompt }, capabilities);
|
|
392
261
|
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
|
-
}
|
|
262
|
+
if (launch.exitCode !== 0)
|
|
263
|
+
return { exitCode: launch.exitCode, stdout: launch.stdout, stderr: [fallbackReason, launch.stderr].filter(Boolean).join("\n"), status: "failed", transport: "cli" };
|
|
402
264
|
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
|
-
};
|
|
265
|
+
if (!id)
|
|
266
|
+
return { exitCode: 1, stdout: launch.stdout, stderr: [fallbackReason, "Paseo returned no parseable agent id."].join("\n"), status: "failed", transport: "cli" };
|
|
267
|
+
const launched = { id, exitCode: 0, stdout: launch.stdout, stderr: launch.stderr, status: "working", workspaceId: options.workspaceId, transport: "cli" };
|
|
421
268
|
await registerManagedAgent(root, options, launched);
|
|
422
269
|
if (options.waitForFinish === false)
|
|
423
270
|
return launched;
|
|
424
271
|
const waited = await waitManagedPaseoAgent(root, id, timeout, deps);
|
|
425
|
-
return {
|
|
426
|
-
...waited,
|
|
427
|
-
stderr: [fallbackReason, launch.stderr, waited.stderr].filter(Boolean).join("\n")
|
|
428
|
-
};
|
|
272
|
+
return { ...waited, stderr: [fallbackReason, launch.stderr, waited.stderr].filter(Boolean).join("\n") };
|
|
429
273
|
}
|
|
430
274
|
async function registerManagedAgent(root, options, result) {
|
|
431
275
|
if (!result.id)
|
|
432
276
|
return;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
workspaceId: result.workspaceId ?? options.workspaceId,
|
|
438
|
-
transport: result.transport
|
|
439
|
-
});
|
|
277
|
+
const role = options.labels?.["aeh.role"];
|
|
278
|
+
if (!role)
|
|
279
|
+
return;
|
|
280
|
+
await registerCurrentOperationAgent(root, { id: result.id, role, phase: options.labels?.["aeh.operation.phase"], workspaceId: result.workspaceId ?? options.workspaceId, transport: result.transport });
|
|
440
281
|
}
|
|
441
282
|
async function listCliAgents(root, deps) {
|
|
442
|
-
const result = await deps.run("paseo ls -a -g --json", {
|
|
443
|
-
cwd: root,
|
|
444
|
-
timeoutMs: 30_000
|
|
445
|
-
});
|
|
283
|
+
const result = await deps.run("paseo ls -a -g --json", { cwd: root, timeoutMs: 30_000 });
|
|
446
284
|
if (result.exitCode !== 0 || !result.stdout.trim())
|
|
447
285
|
return [];
|
|
448
286
|
try {
|
|
@@ -464,95 +302,31 @@ function collectCliAgents(value, out) {
|
|
|
464
302
|
return;
|
|
465
303
|
const record = value;
|
|
466
304
|
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
|
-
}
|
|
305
|
+
if (id && ("status" in record || "title" in record || "labels" in record))
|
|
306
|
+
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
307
|
for (const child of Object.values(record))
|
|
478
308
|
collectCliAgents(child, out);
|
|
479
309
|
}
|
|
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
|
-
}
|
|
310
|
+
function forceCli() { return process.env.AEH_PASEO_FORCE_CLI === "1"; }
|
|
311
|
+
function sdkCanFallback(error) { return error instanceof PaseoSdkUnavailableError || (error instanceof Error && error.name === "PaseoSdkUnavailableError"); }
|
|
312
|
+
function timeoutMs(seconds) { return (seconds ?? 1800) * 1000; }
|
|
313
|
+
function secondsFromMs(ms) { return ms === undefined ? undefined : Math.max(1, Math.ceil(ms / 1000)); }
|
|
314
|
+
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" }; }
|
|
315
|
+
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" }; }
|
|
316
|
+
function sdkExitCode(status, error) { if (status === "timeout")
|
|
317
|
+
return 124; if (error)
|
|
318
|
+
return 1; if (status === "failed" || status === "error" || status === "cancelled")
|
|
319
|
+
return 1; return 0; }
|
|
320
|
+
function firstString(record, keys) { for (const key of keys)
|
|
321
|
+
if (typeof record[key] === "string" && record[key])
|
|
322
|
+
return record[key]; return undefined; }
|
|
323
|
+
function stringRecord(value) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
324
|
+
return undefined; const result = {}; for (const [key, item] of Object.entries(value))
|
|
325
|
+
if (typeof item === "string")
|
|
326
|
+
result[key] = item; return Object.keys(result).length ? result : undefined; }
|
|
327
|
+
function statusText(value) { if (typeof value === "string")
|
|
328
|
+
return value; if (value && typeof value === "object" && typeof value.status === "string")
|
|
329
|
+
return value.status; return undefined; }
|
|
330
|
+
function errorMessage(error) { return error instanceof Error ? error.message : String(error); }
|
|
331
|
+
function quote(value) { return `'${value.replaceAll("'", "'\\''")}'`; }
|
|
558
332
|
//# sourceMappingURL=runtime.js.map
|