agentic-engineering-harness 0.6.0 → 0.6.1
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/README.md +8 -3
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/assets.d.ts +13 -0
- package/dist/core/assets.js +115 -0
- package/dist/core/assets.js.map +1 -0
- package/dist/core/init.js +4 -10
- package/dist/core/init.js.map +1 -1
- package/dist/entry.js +33 -1
- package/dist/entry.js.map +1 -1
- package/dist/paseo/runtime.d.ts +31 -0
- package/dist/paseo/runtime.js +158 -0
- package/dist/paseo/runtime.js.map +1 -0
- package/dist/paseo/sdk.d.ts +79 -0
- package/dist/paseo/sdk.js +165 -0
- package/dist/paseo/sdk.js.map +1 -0
- package/dist/paseo/start.d.ts +7 -1
- package/dist/paseo/start.js +40 -42
- package/dist/paseo/start.js.map +1 -1
- package/dist/toolchain/setup.js +2 -0
- package/dist/toolchain/setup.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/workers/agentPrompt.js +24 -29
- package/dist/workers/agentPrompt.js.map +1 -1
- package/dist/workers/paseo.d.ts +0 -1
- package/dist/workers/paseo.js +39 -27
- package/dist/workers/paseo.js.map +1 -1
- package/docs/PASEO.md +51 -20
- package/docs/PUBLISHING.md +53 -44
- package/package.json +86 -11
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { buildPaseoBackgroundRunCommand, detectPaseoCapabilities, extractPaseoAgentId } from "./capabilities.js";
|
|
3
|
+
import { PaseoSdkUnavailableError, createPaseoSdkAgent, inspectPaseoSdkAgent, listPaseoSdkAgents, probePaseoSdkAgent, runPaseoSdkAgent } from "./sdk.js";
|
|
4
|
+
import { runProcess } from "../utils/process.js";
|
|
5
|
+
const DEFAULT_DEPS = {
|
|
6
|
+
run: runProcess,
|
|
7
|
+
detectCapabilities: detectPaseoCapabilities,
|
|
8
|
+
sdk: { create: createPaseoSdkAgent, run: runPaseoSdkAgent, probe: probePaseoSdkAgent, inspect: inspectPaseoSdkAgent, list: listPaseoSdkAgents }
|
|
9
|
+
};
|
|
10
|
+
export async function launchManagedPaseoAgent(root, options, deps = DEFAULT_DEPS) {
|
|
11
|
+
if (preferSdk(options)) {
|
|
12
|
+
try {
|
|
13
|
+
const result = await deps.sdk.create(root, { ...options, timeoutMs: options.timeoutMs ?? timeoutMs(options.timeoutSeconds) });
|
|
14
|
+
return fromSdk(result);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (!sdkCanFallback(error))
|
|
18
|
+
throw error;
|
|
19
|
+
return launchCli(root, options, deps, `SDK unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return launchCli(root, options, deps, "SDK skipped because no explicit provider/model was available or AEH_PASEO_FORCE_CLI=1.");
|
|
23
|
+
}
|
|
24
|
+
export async function continueManagedPaseoAgent(root, agentId, prompt, timeoutSeconds, deps = DEFAULT_DEPS) {
|
|
25
|
+
if (!forceCli()) {
|
|
26
|
+
try {
|
|
27
|
+
return fromSdk(await deps.sdk.run(root, agentId, prompt, timeoutMs(timeoutSeconds)));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (!sdkCanFallback(error))
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const timeout = timeoutSeconds ?? 1800;
|
|
35
|
+
const send = await deps.run(`paseo send ${quote(agentId)} --no-wait ${quote(prompt)}`, { cwd: root, timeoutMs: 60_000 });
|
|
36
|
+
if (send.exitCode !== 0)
|
|
37
|
+
return { id: agentId, exitCode: send.exitCode, stdout: send.stdout, stderr: send.stderr, transport: "cli" };
|
|
38
|
+
const wait = await deps.run(`paseo wait ${quote(agentId)} --timeout ${timeout}`, { cwd: root, timeoutMs: (timeout + 30) * 1000 });
|
|
39
|
+
const logs = await deps.run(`paseo logs ${quote(agentId)} --tail 200`, { cwd: root, timeoutMs: 60_000 });
|
|
40
|
+
return { id: agentId, exitCode: wait.exitCode, stdout: logs.stdout || wait.stdout, stderr: [send.stderr, wait.stderr, logs.stderr].filter(Boolean).join("\n"), transport: "cli" };
|
|
41
|
+
}
|
|
42
|
+
export async function probeManagedPaseoAgent(root, agentId, deps = DEFAULT_DEPS) {
|
|
43
|
+
if (!forceCli()) {
|
|
44
|
+
try {
|
|
45
|
+
return await deps.sdk.probe(root, agentId);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (!sdkCanFallback(error))
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const probe = await deps.run(`paseo logs ${quote(agentId)} --tail 1`, { cwd: root, timeoutMs: 30_000 });
|
|
53
|
+
return probe.exitCode === 0;
|
|
54
|
+
}
|
|
55
|
+
export async function inspectManagedPaseoAgent(root, agentId, deps = DEFAULT_DEPS) {
|
|
56
|
+
if (!forceCli()) {
|
|
57
|
+
try {
|
|
58
|
+
return await deps.sdk.inspect(root, agentId);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (!sdkCanFallback(error))
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return (await listCliAgents(root, deps)).find((agent) => agent.id === agentId);
|
|
66
|
+
}
|
|
67
|
+
export async function listManagedPaseoAgents(root, labels = {}, deps = DEFAULT_DEPS) {
|
|
68
|
+
if (!forceCli()) {
|
|
69
|
+
try {
|
|
70
|
+
return await deps.sdk.list(root, labels);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (!sdkCanFallback(error))
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return (await listCliAgents(root, deps)).filter((agent) => Object.entries(labels).every(([key, value]) => agent.labels?.[key] === value));
|
|
78
|
+
}
|
|
79
|
+
async function launchCli(root, options, deps, fallbackReason) {
|
|
80
|
+
if (options.prompt === undefined && options.systemPrompt !== undefined) {
|
|
81
|
+
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}`);
|
|
82
|
+
}
|
|
83
|
+
const capabilities = await deps.detectCapabilities(root, deps.run);
|
|
84
|
+
const prompt = options.prompt;
|
|
85
|
+
if (prompt === undefined)
|
|
86
|
+
throw new Error("Paseo CLI fallback requires a prompt.");
|
|
87
|
+
const timeout = options.timeoutSeconds ?? Math.max(1, Math.ceil((options.timeoutMs ?? 1_800_000) / 1000));
|
|
88
|
+
if (options.outputSchema) {
|
|
89
|
+
if (!capabilities.outputSchema)
|
|
90
|
+
throw new Error(`Installed Paseo${capabilities.version ? ` ${capabilities.version}` : ""} does not advertise --output-schema required by this agent.`);
|
|
91
|
+
const parts = ["paseo run --quiet", `--title ${quote(options.title)}`, `--provider ${quote(options.provider)}`];
|
|
92
|
+
if (options.workspaceId)
|
|
93
|
+
parts.push(`--workspace ${quote(options.workspaceId)}`);
|
|
94
|
+
if (options.model)
|
|
95
|
+
parts.push(`--model ${quote(options.model)}`);
|
|
96
|
+
parts.push(`--output-schema ${quote(JSON.stringify(options.outputSchema))}`, quote(prompt));
|
|
97
|
+
const result = await deps.run(parts.join(" "), { cwd: root, timeoutMs: timeout * 1000 });
|
|
98
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: [fallbackReason, result.stderr].filter(Boolean).join("\n"), transport: "cli" };
|
|
99
|
+
}
|
|
100
|
+
const command = buildPaseoBackgroundRunCommand({ title: options.title, provider: options.provider, model: options.model, workspaceId: options.workspaceId, prompt }, capabilities);
|
|
101
|
+
const launch = await deps.run(command, { cwd: root, timeoutMs: 60_000 });
|
|
102
|
+
if (launch.exitCode !== 0)
|
|
103
|
+
return { exitCode: launch.exitCode, stdout: launch.stdout, stderr: [fallbackReason, launch.stderr].filter(Boolean).join("\n"), transport: "cli" };
|
|
104
|
+
const id = extractPaseoAgentId(launch.stdout);
|
|
105
|
+
if (!id)
|
|
106
|
+
return { exitCode: 1, stdout: launch.stdout, stderr: [fallbackReason, "Paseo returned no parseable agent id."].join("\n"), transport: "cli" };
|
|
107
|
+
const wait = await deps.run(`paseo wait ${quote(id)} --timeout ${timeout}`, { cwd: root, timeoutMs: (timeout + 30) * 1000 });
|
|
108
|
+
const logs = await deps.run(`paseo logs ${quote(id)} --tail 200`, { cwd: root, timeoutMs: 60_000 });
|
|
109
|
+
return { id, exitCode: wait.exitCode, stdout: logs.stdout || wait.stdout || launch.stdout, stderr: [fallbackReason, launch.stderr, wait.stderr, logs.stderr].filter(Boolean).join("\n"), transport: "cli" };
|
|
110
|
+
}
|
|
111
|
+
async function listCliAgents(root, deps) {
|
|
112
|
+
const result = await deps.run("paseo ls -a -g --json", { cwd: root, timeoutMs: 30_000 });
|
|
113
|
+
if (result.exitCode !== 0 || !result.stdout.trim())
|
|
114
|
+
return [];
|
|
115
|
+
try {
|
|
116
|
+
const records = new Map();
|
|
117
|
+
collectCliAgents(JSON.parse(result.stdout), records);
|
|
118
|
+
return [...records.values()];
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function collectCliAgents(value, out) {
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
for (const child of value)
|
|
127
|
+
collectCliAgents(child, out);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!value || typeof value !== "object")
|
|
131
|
+
return;
|
|
132
|
+
const record = value;
|
|
133
|
+
const id = firstString(record, ["id", "agentId", "agent_id"]);
|
|
134
|
+
if (id && ("status" in record || "title" in record || "labels" in record)) {
|
|
135
|
+
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 });
|
|
136
|
+
}
|
|
137
|
+
for (const child of Object.values(record))
|
|
138
|
+
collectCliAgents(child, out);
|
|
139
|
+
}
|
|
140
|
+
function preferSdk(options) { return !forceCli() && (Boolean(options.model) || options.provider.includes("/")); }
|
|
141
|
+
function forceCli() { return process.env.AEH_PASEO_FORCE_CLI === "1"; }
|
|
142
|
+
function sdkCanFallback(error) { return error instanceof PaseoSdkUnavailableError || (error instanceof Error && error.name === "PaseoSdkUnavailableError"); }
|
|
143
|
+
function timeoutMs(seconds) { return (seconds ?? 1800) * 1000; }
|
|
144
|
+
function fromSdk(result) { return { id: result.id, exitCode: sdkExitCode(result.status, result.error), stdout: result.lastMessage ?? "", stderr: result.error ?? "", status: result.status, transport: "sdk" }; }
|
|
145
|
+
function sdkExitCode(status, error) { if (error)
|
|
146
|
+
return 1; return !status || status === "idle" ? 0 : status === "timeout" ? 124 : 1; }
|
|
147
|
+
function firstString(record, keys) { for (const key of keys)
|
|
148
|
+
if (typeof record[key] === "string" && record[key])
|
|
149
|
+
return record[key]; return undefined; }
|
|
150
|
+
function stringRecord(value) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
151
|
+
return undefined; const result = {}; for (const [key, item] of Object.entries(value))
|
|
152
|
+
if (typeof item === "string")
|
|
153
|
+
result[key] = item; return Object.keys(result).length ? result : undefined; }
|
|
154
|
+
function statusText(value) { if (typeof value === "string")
|
|
155
|
+
return value; if (value && typeof value === "object" && typeof value.status === "string")
|
|
156
|
+
return value.status; return undefined; }
|
|
157
|
+
function quote(value) { return `'${value.replaceAll("'", "'\\''")}'`; }
|
|
158
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/paseo/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,8BAA8B,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACjH,OAAO,EACL,wBAAwB,EACxB,mBAAmB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OAAO,MAAM,CAAC,GAAG,CAAW,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;AACzN,SAAS,YAAY,CAAC,KAAc,IAAwC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IAAE,OAAO,SAAS,CAAC,CAAC,MAAM,MAAM,GAA2B,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC;IAAE,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACjY,SAAS,UAAU,CAAC,KAAc,IAAwB,IAAI,OAAO,KAAK,KAAK,QAAQ;IAAE,OAAO,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAAiC,CAAC,MAAM,KAAK,QAAQ;IAAE,OAAQ,KAAiC,CAAC,MAAgB,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;AAC/R,SAAS,KAAK,CAAC,KAAa,IAAY,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface PaseoSdkAgentOptions {
|
|
2
|
+
cwd: string;
|
|
3
|
+
workspaceId?: string;
|
|
4
|
+
provider: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
title: string;
|
|
7
|
+
systemPrompt?: string;
|
|
8
|
+
prompt?: string;
|
|
9
|
+
outputSchema?: Record<string, unknown>;
|
|
10
|
+
labels?: Record<string, string>;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
waitForFinish?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PaseoSdkAgentResult {
|
|
15
|
+
id: string;
|
|
16
|
+
workspaceId?: string;
|
|
17
|
+
status?: string;
|
|
18
|
+
lastMessage?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PaseoSdkAgentRecord {
|
|
22
|
+
id: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
status?: string;
|
|
25
|
+
workspaceId?: string;
|
|
26
|
+
labels?: Record<string, string>;
|
|
27
|
+
raw: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
interface PaseoSdkTurnResult {
|
|
30
|
+
status: string;
|
|
31
|
+
lastMessage?: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
interface PaseoSdkAgentHandle {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly workspaceId: string | null;
|
|
37
|
+
readonly status: unknown;
|
|
38
|
+
refresh(requestId?: string): Promise<{
|
|
39
|
+
agent: Record<string, unknown>;
|
|
40
|
+
project: unknown;
|
|
41
|
+
} | null>;
|
|
42
|
+
run(text: string, options?: {
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
}): Promise<PaseoSdkTurnResult>;
|
|
45
|
+
waitForFinish(timeoutMs?: number): Promise<PaseoSdkTurnResult>;
|
|
46
|
+
}
|
|
47
|
+
interface PaseoSdkWorkspaceHandle {
|
|
48
|
+
readonly agents: {
|
|
49
|
+
create(options: Record<string, unknown>): Promise<PaseoSdkAgentHandle>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
interface PaseoSdkClient {
|
|
53
|
+
readonly agents: {
|
|
54
|
+
create(options: Record<string, unknown>): Promise<PaseoSdkAgentHandle>;
|
|
55
|
+
ref(agentId: string): PaseoSdkAgentHandle;
|
|
56
|
+
list(options?: Record<string, unknown>): Promise<{
|
|
57
|
+
entries: Array<{
|
|
58
|
+
agent: Record<string, unknown>;
|
|
59
|
+
}>;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
readonly workspaces: {
|
|
63
|
+
ref(workspaceId: string): PaseoSdkWorkspaceHandle;
|
|
64
|
+
};
|
|
65
|
+
connect(): Promise<void>;
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export declare class PaseoSdkUnavailableError extends Error {
|
|
69
|
+
constructor(message: string, options?: {
|
|
70
|
+
cause?: unknown;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export declare function createPaseoSdkAgent(root: string, options: PaseoSdkAgentOptions): Promise<PaseoSdkAgentResult>;
|
|
74
|
+
export declare function createPaseoSdkAgentWithClient(client: PaseoSdkClient, options: PaseoSdkAgentOptions): Promise<PaseoSdkAgentResult>;
|
|
75
|
+
export declare function runPaseoSdkAgent(root: string, agentId: string, prompt: string, timeoutMs?: number): Promise<PaseoSdkAgentResult>;
|
|
76
|
+
export declare function inspectPaseoSdkAgent(root: string, agentId: string): Promise<PaseoSdkAgentRecord | undefined>;
|
|
77
|
+
export declare function probePaseoSdkAgent(root: string, agentId: string): Promise<boolean>;
|
|
78
|
+
export declare function listPaseoSdkAgents(root: string, labels?: Record<string, string>): Promise<PaseoSdkAgentRecord[]>;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { runProcess } from "../utils/process.js";
|
|
7
|
+
export class PaseoSdkUnavailableError extends Error {
|
|
8
|
+
constructor(message, options) {
|
|
9
|
+
super(message, options);
|
|
10
|
+
this.name = "PaseoSdkUnavailableError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function createPaseoSdkAgent(root, options) {
|
|
14
|
+
return withPaseoClient(root, async (client) => createPaseoSdkAgentWithClient(client, options));
|
|
15
|
+
}
|
|
16
|
+
export async function createPaseoSdkAgentWithClient(client, options) {
|
|
17
|
+
const config = { provider: providerModel(options.provider, options.model) };
|
|
18
|
+
if (options.systemPrompt)
|
|
19
|
+
config.systemPrompt = options.systemPrompt;
|
|
20
|
+
const createOptions = { config, title: options.title };
|
|
21
|
+
if (options.prompt !== undefined)
|
|
22
|
+
createOptions.prompt = options.prompt;
|
|
23
|
+
if (options.outputSchema)
|
|
24
|
+
createOptions.outputSchema = options.outputSchema;
|
|
25
|
+
if (options.labels && Object.keys(options.labels).length)
|
|
26
|
+
createOptions.labels = options.labels;
|
|
27
|
+
// Intentionally omit `parent`: AEH run/task labels own lifecycle relationships.
|
|
28
|
+
// Workspace placement does not imply parentage in the Paseo SDK.
|
|
29
|
+
const handle = options.workspaceId
|
|
30
|
+
? await client.workspaces.ref(options.workspaceId).agents.create(createOptions)
|
|
31
|
+
: await client.agents.create({ ...createOptions, cwd: options.cwd });
|
|
32
|
+
if (options.prompt !== undefined && options.waitForFinish !== false) {
|
|
33
|
+
const turn = await handle.waitForFinish(options.timeoutMs);
|
|
34
|
+
return {
|
|
35
|
+
id: handle.id,
|
|
36
|
+
workspaceId: handle.workspaceId ?? undefined,
|
|
37
|
+
status: turn.status,
|
|
38
|
+
lastMessage: turn.lastMessage,
|
|
39
|
+
error: turn.error
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
id: handle.id,
|
|
44
|
+
workspaceId: handle.workspaceId ?? undefined,
|
|
45
|
+
status: statusText(handle.status)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export async function runPaseoSdkAgent(root, agentId, prompt, timeoutMs) {
|
|
49
|
+
return withPaseoClient(root, async (client) => {
|
|
50
|
+
const handle = client.agents.ref(agentId);
|
|
51
|
+
const turn = await handle.run(prompt, { timeoutMs });
|
|
52
|
+
return { id: agentId, workspaceId: handle.workspaceId ?? undefined, status: turn.status, lastMessage: turn.lastMessage, error: turn.error };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export async function inspectPaseoSdkAgent(root, agentId) {
|
|
56
|
+
return withPaseoClient(root, async (client) => {
|
|
57
|
+
const refreshed = await client.agents.ref(agentId).refresh();
|
|
58
|
+
return refreshed ? normalizeRecord(refreshed.agent) : undefined;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export async function probePaseoSdkAgent(root, agentId) {
|
|
62
|
+
return Boolean(await inspectPaseoSdkAgent(root, agentId));
|
|
63
|
+
}
|
|
64
|
+
export async function listPaseoSdkAgents(root, labels = {}) {
|
|
65
|
+
return withPaseoClient(root, async (client) => {
|
|
66
|
+
const filter = { includeArchived: false };
|
|
67
|
+
if (Object.keys(labels).length)
|
|
68
|
+
filter.labels = labels;
|
|
69
|
+
const page = await client.agents.list({ filter });
|
|
70
|
+
return page.entries.map((entry) => normalizeRecord(entry.agent)).filter((agent) => labelsMatch(agent.labels, labels));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function withPaseoClient(root, action) {
|
|
74
|
+
const sdk = await loadPaseoSdk(root);
|
|
75
|
+
const client = sdk.createPaseoClient({
|
|
76
|
+
url: process.env.PASEO_DAEMON_URL?.trim() || "ws://127.0.0.1:6767/ws",
|
|
77
|
+
clientId: `aeh-${process.pid}`,
|
|
78
|
+
password: process.env.PASEO_DAEMON_PASSWORD?.trim() || undefined
|
|
79
|
+
});
|
|
80
|
+
try {
|
|
81
|
+
try {
|
|
82
|
+
await client.connect();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw new PaseoSdkUnavailableError(`Unable to connect to the Paseo daemon through @getpaseo/client: ${String(error)}`, { cause: error });
|
|
86
|
+
}
|
|
87
|
+
return await action(client);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await client.close().catch(() => undefined);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function loadPaseoSdk(root) {
|
|
94
|
+
const packageName = "@getpaseo/client";
|
|
95
|
+
let directError;
|
|
96
|
+
try {
|
|
97
|
+
const direct = await import(packageName);
|
|
98
|
+
if (typeof direct.createPaseoClient === "function")
|
|
99
|
+
return direct;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
directError = error;
|
|
103
|
+
}
|
|
104
|
+
const located = await runProcess("command -v paseo", { cwd: root, timeoutMs: 15_000 });
|
|
105
|
+
const executable = located.exitCode === 0 ? located.stdout.trim().split(/\r?\n/).filter(Boolean).at(-1) : undefined;
|
|
106
|
+
if (executable) {
|
|
107
|
+
const real = await fs.realpath(executable).catch(() => executable);
|
|
108
|
+
for (const start of [...new Set([path.dirname(real), path.dirname(executable)])]) {
|
|
109
|
+
let current = start;
|
|
110
|
+
for (let depth = 0; depth < 10; depth += 1) {
|
|
111
|
+
try {
|
|
112
|
+
const resolver = createRequire(path.join(current, "__aeh_paseo_sdk_loader__.cjs"));
|
|
113
|
+
const resolved = resolver.resolve(packageName);
|
|
114
|
+
const bundled = await import(pathToFileURL(resolved).href);
|
|
115
|
+
if (typeof bundled.createPaseoClient === "function")
|
|
116
|
+
return bundled;
|
|
117
|
+
}
|
|
118
|
+
catch { /* walk toward the managed npm installation root */ }
|
|
119
|
+
const parent = path.dirname(current);
|
|
120
|
+
if (parent === current)
|
|
121
|
+
break;
|
|
122
|
+
current = parent;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
throw new PaseoSdkUnavailableError(`@getpaseo/client could not be resolved directly or from the managed Paseo CLI installation.${directError ? ` Direct import: ${String(directError)}` : ""}`, { cause: directError });
|
|
127
|
+
}
|
|
128
|
+
function providerModel(provider, model) {
|
|
129
|
+
if (provider.includes("/"))
|
|
130
|
+
return provider;
|
|
131
|
+
if (!model)
|
|
132
|
+
throw new Error(`Paseo SDK requires an explicit model for provider '${provider}'.`);
|
|
133
|
+
return `${provider}/${model}`;
|
|
134
|
+
}
|
|
135
|
+
function normalizeRecord(raw) {
|
|
136
|
+
const id = stringField(raw, ["id", "agentId", "agent_id"]);
|
|
137
|
+
if (!id)
|
|
138
|
+
throw new Error("Paseo SDK returned an agent without an id.");
|
|
139
|
+
const labels = recordOfStrings(raw.labels);
|
|
140
|
+
return {
|
|
141
|
+
id,
|
|
142
|
+
title: stringField(raw, ["title", "name"]),
|
|
143
|
+
status: statusText(raw.status),
|
|
144
|
+
workspaceId: stringField(raw, ["workspaceId", "workspace_id"]),
|
|
145
|
+
labels,
|
|
146
|
+
raw
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function labelsMatch(actual, expected) {
|
|
150
|
+
return Object.entries(expected).every(([key, value]) => actual?.[key] === value);
|
|
151
|
+
}
|
|
152
|
+
function stringField(record, keys) { for (const key of keys)
|
|
153
|
+
if (typeof record[key] === "string" && record[key])
|
|
154
|
+
return record[key]; return undefined; }
|
|
155
|
+
function recordOfStrings(value) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
156
|
+
return undefined; const result = {}; for (const [key, item] of Object.entries(value))
|
|
157
|
+
if (typeof item === "string")
|
|
158
|
+
result[key] = item; return Object.keys(result).length ? result : undefined; }
|
|
159
|
+
function statusText(value) { if (typeof value === "string")
|
|
160
|
+
return value; if (value && typeof value === "object") {
|
|
161
|
+
const nested = value.status;
|
|
162
|
+
if (typeof nested === "string")
|
|
163
|
+
return nested;
|
|
164
|
+
} return undefined; }
|
|
165
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/paseo/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE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AC,CAAC"}
|
package/dist/paseo/start.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ResolvedAgentTopology } from "../agents/types.js";
|
|
2
2
|
import { loadResolvedAgentTopology } from "../agents/config.js";
|
|
3
|
+
import { reconcileHarnessAssets } from "../core/assets.js";
|
|
3
4
|
import type { HarnessProjectConfig } from "../core/types.js";
|
|
4
5
|
import { setupToolchain } from "../toolchain/setup.js";
|
|
5
6
|
import { commandExists, runProcess } from "../utils/process.js";
|
|
6
7
|
import { detectPaseoCapabilities } from "./capabilities.js";
|
|
7
|
-
|
|
8
|
+
import { launchManagedPaseoAgent, probeManagedPaseoAgent } from "./runtime.js";
|
|
9
|
+
export declare const PASEO_BOOTSTRAP_VERSION = 4;
|
|
8
10
|
export type PaseoSessionPolicy = "fresh-on-start" | "reuse-compatible" | "resume-explicit";
|
|
9
11
|
export interface PaseoStartOptions {
|
|
10
12
|
autoSetup?: boolean;
|
|
@@ -41,6 +43,7 @@ export interface PaseoStartResult {
|
|
|
41
43
|
stateFile: string;
|
|
42
44
|
bootstrapFile: string;
|
|
43
45
|
paseoVersion?: string;
|
|
46
|
+
transport?: "sdk" | "cli";
|
|
44
47
|
}
|
|
45
48
|
interface PaseoStartDeps {
|
|
46
49
|
run: typeof runProcess;
|
|
@@ -48,6 +51,9 @@ interface PaseoStartDeps {
|
|
|
48
51
|
setupToolchain: typeof setupToolchain;
|
|
49
52
|
loadTopology: typeof loadResolvedAgentTopology;
|
|
50
53
|
detectCapabilities: typeof detectPaseoCapabilities;
|
|
54
|
+
launchAgent: typeof launchManagedPaseoAgent;
|
|
55
|
+
probeAgent: typeof probeManagedPaseoAgent;
|
|
56
|
+
reconcileAssets?: typeof reconcileHarnessAssets;
|
|
51
57
|
}
|
|
52
58
|
export declare function startPaseoHarness(root: string, config: HarnessProjectConfig, options?: PaseoStartOptions, deps?: PaseoStartDeps): Promise<PaseoStartResult>;
|
|
53
59
|
export declare function buildPaseoLeadBootstrap(projectName: string, projectRoot: string, aehCommand: string, preferPaseoTools?: boolean, handoffPath?: string): string;
|
package/dist/paseo/start.js
CHANGED
|
@@ -2,13 +2,16 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { loadResolvedAgentTopology } from "../agents/config.js";
|
|
4
4
|
import { executionSelectionForAgent } from "../agents/routing.js";
|
|
5
|
+
import { reconcileHarnessAssets } from "../core/assets.js";
|
|
5
6
|
import { setupToolchain } from "../toolchain/setup.js";
|
|
6
7
|
import { clearToolchainEnvCache, commandExists, runProcess } from "../utils/process.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
import { detectPaseoCapabilities, isRecoverableDaemonStatus } from "./capabilities.js";
|
|
9
|
+
import { launchManagedPaseoAgent, probeManagedPaseoAgent } from "./runtime.js";
|
|
10
|
+
export const PASEO_BOOTSTRAP_VERSION = 4;
|
|
11
|
+
const DEFAULT_DEPS = { run: runProcess, commandExists, setupToolchain, loadTopology: loadResolvedAgentTopology, detectCapabilities: detectPaseoCapabilities, launchAgent: launchManagedPaseoAgent, probeAgent: probeManagedPaseoAgent, reconcileAssets: reconcileHarnessAssets };
|
|
10
12
|
export async function startPaseoHarness(root, config, options = {}, deps = DEFAULT_DEPS) {
|
|
11
13
|
const projectRoot = path.resolve(root);
|
|
14
|
+
await (deps.reconcileAssets ?? reconcileHarnessAssets)(projectRoot);
|
|
12
15
|
const settings = config.orchestration?.interactive;
|
|
13
16
|
const autoSetup = options.autoSetup ?? settings?.autoSetup ?? true;
|
|
14
17
|
const webUi = options.webUi ?? settings?.webUi ?? true;
|
|
@@ -54,58 +57,54 @@ export async function startPaseoHarness(root, config, options = {}, deps = DEFAU
|
|
|
54
57
|
await fs.writeFile(bootstrapFile, `${bootstrap}\n`);
|
|
55
58
|
const previous = await loadState(stateFile);
|
|
56
59
|
if (!options.forceNew && reuseRequested && !options.handoffPath && previous && compatibleState(previous, { projectRoot, leadName, provider, model, title })) {
|
|
57
|
-
|
|
58
|
-
if (probe.exitCode === 0)
|
|
60
|
+
if (await deps.probeAgent(projectRoot, previous.agentId))
|
|
59
61
|
return { daemonStarted, session: "reused", agentId: previous.agentId, title: previous.title, leadAgent: previous.leadAgent, provider: previous.provider, model: previous.model, stateFile, bootstrapFile, paseoVersion: capabilities.version };
|
|
60
62
|
}
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const generation = (previous?.generation ?? 0) + 1;
|
|
64
|
+
const labels = {
|
|
65
|
+
"aeh.project": config.project.name,
|
|
66
|
+
"aeh.kind": "lead",
|
|
67
|
+
"aeh.role": leadName,
|
|
68
|
+
"aeh.generation": String(generation)
|
|
69
|
+
};
|
|
70
|
+
if (options.handoffPath)
|
|
71
|
+
labels["aeh.handoff"] = options.handoffPath;
|
|
72
|
+
const launch = await deps.launchAgent(projectRoot, {
|
|
73
|
+
cwd: projectRoot,
|
|
74
|
+
title,
|
|
75
|
+
provider,
|
|
76
|
+
model,
|
|
77
|
+
systemPrompt: bootstrap,
|
|
78
|
+
labels,
|
|
79
|
+
waitForFinish: false,
|
|
80
|
+
timeoutSeconds: 300
|
|
81
|
+
});
|
|
82
|
+
if (launch.exitCode !== 0 || !launch.id)
|
|
83
|
+
throw new Error(`Failed to create AEH lead in Paseo${capabilities.version ? ` ${capabilities.version}` : ""}: ${launch.stderr || launch.stdout || `exit code ${launch.exitCode}`}`);
|
|
84
|
+
const agentId = launch.id;
|
|
85
|
+
const state = { version: 1, bootstrapVersion: PASEO_BOOTSTRAP_VERSION, projectRoot, projectName: config.project.name, agentId, title, leadAgent: leadName, provider, model, createdAt: new Date().toISOString(), generation, handoffPath: options.handoffPath };
|
|
72
86
|
await fs.writeFile(stateFile, `${JSON.stringify(state, null, 2)}\n`);
|
|
73
|
-
return { daemonStarted, session: "created", agentId, title, leadAgent: leadName, provider, model, stateFile, bootstrapFile, paseoVersion: capabilities.version };
|
|
87
|
+
return { daemonStarted, session: "created", agentId, title, leadAgent: leadName, provider, model, stateFile, bootstrapFile, paseoVersion: capabilities.version, transport: launch.transport };
|
|
74
88
|
}
|
|
75
89
|
export function buildPaseoLeadBootstrap(projectName, projectRoot, aehCommand, preferPaseoTools = true, handoffPath) {
|
|
76
|
-
const handoff = handoffPath ? `\n\nThis lead was created by proactive context rotation. Before
|
|
90
|
+
const handoff = handoffPath ? `\n\nThis lead was created by proactive context rotation. Before the next engineering action, read the deterministic handoff artifact ${JSON.stringify(handoffPath)} and the sealed/run/audit/delivery artifacts it references. Durable artifacts are authoritative; do not ask the previous lead to replay its conversation.` : "";
|
|
77
91
|
return `AEH thin-lead Paseo bootstrap v${PASEO_BOOTSTRAP_VERSION}.
|
|
78
92
|
|
|
79
|
-
You are the top-level engineering lead for project ${JSON.stringify(projectName)} at ${JSON.stringify(projectRoot)}.
|
|
93
|
+
You are the top-level engineering lead for project ${JSON.stringify(projectName)} at ${JSON.stringify(projectRoot)}. A normal \`aeh start\` creates a fresh lead; explicit resume is opt-in.${handoff}
|
|
80
94
|
|
|
81
|
-
Before engineering work, read AGENTS.md and .harness/skills/engineering-workflow/SKILL.md when present.
|
|
95
|
+
Before engineering work, read AGENTS.md and .harness/skills/engineering-workflow/SKILL.md when present. Those instructions plus the resolved AEH agent topology are authoritative for available roles, charters, permissions, routing and delegation. Do not maintain or invent a separate role map in conversational context.
|
|
82
96
|
|
|
83
|
-
|
|
97
|
+
Every engineering operation must enter through AEH, including read-only audits. Only purely informational questions may bypass. Whenever the workflow says \`aeh\`, invoke exactly: \`${aehCommand}\`.
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
- repository discovery/evidence -> explorer;
|
|
87
|
-
- toolchain, doctor, agents-check or Paseo daemon/provider recovery -> environment-manager;
|
|
88
|
-
- non-trivial triage/decomposition -> planner;
|
|
89
|
-
- SPEC authoring -> spec-manager using OpenSpec, never write proposal/spec/design/tasks yourself;
|
|
90
|
-
- implementation, validation and reviews -> AEH/Harness-selected workers.
|
|
99
|
+
Remain a thin ORCHESTRATOR: preserve user intent, make semantic/risk decisions, delegate bounded operations through the authoritative topology, monitor deterministic state and perform final semantic acceptance. Follow engineering-workflow end-to-end for intent classification, AUDIT, QUICK/SPEC triage, OpenSpec authoring, sealed execution, recovery, validation and delivery rather than reproducing those procedures here.
|
|
91
100
|
|
|
92
|
-
${preferPaseoTools ? `
|
|
101
|
+
${preferPaseoTools ? `When running inside Paseo, use the paseo-orchestration skill and injected native/MCP tools for conversational delegation and /paseo-handoff for responsibility transfer. AEH's external controller may create independent top-level Paseo agents for Harness-owned work; AEH run/task labels, not Paseo parentage, define their workflow ownership.` : `Use AEH's configured Paseo adapter for delegation and lifecycle control.`}
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
1. check context pressure with Paseo status if exposed, or \`${aehCommand} context guard --agent "$PASEO_AGENT_ID"\`. At 70% stop exploratory work. At 80% AEH automatically creates a deterministic handoff artifact and, when possible, rotates the persisted lead to a fresh Paseo agent; if the command reports rotatedAgentId, tell the user to continue in that fresh lead and stop this lead. At 90% no further engineering work is allowed in the old lead. Do not compact-and-continue after HANDOFF_REQUIRED/HARD_HANDOFF;
|
|
96
|
-
2. classify INFORMATIONAL | AUDIT | CHANGE using \`${aehCommand} intent\` when not trivially informational;
|
|
97
|
-
3. for AUDIT, invoke \`${aehCommand} audit\`; do not perform an ad-hoc review;
|
|
98
|
-
4. for CHANGE, delegate discovery to explorer and planning/triage evidence to planner. Feed only their compact structured evidence into deterministic \`${aehCommand} triage\`;
|
|
99
|
-
5. QUICK: create/validate/run the bounded QuickContract. Do not broaden QUICK;
|
|
100
|
-
6. SPEC: delegate to spec-manager. spec-manager owns OpenSpec artifacts and returns a compiled/validated AEH SDD/TaskContract. The lead must not author those files. Then invoke the sealed AEH run;
|
|
101
|
-
7. if execution reports environment/tool failure, delegate recovery to environment-manager and retry the same sealed operation after deterministic readiness. Do not personally run sequences of npm/git/Paseo diagnostic shells;
|
|
102
|
-
8. surface only concise state transitions, true human-on-exception decisions, and final audit/acceptance/delivery state.
|
|
103
|
+
Before non-trivial work, inspect context pressure through Paseo status when exposed or run \`${aehCommand} context guard --agent "$PASEO_AGENT_ID"\`. Honor HANDOFF_REQUIRED/HARD_HANDOFF and stop the old lead when a replacement is created.
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
The compiled AEH TaskContract/SDD plus seal are normative during implementation. OpenSpec is authoring provenance before freeze, not a competing runtime authority. Do not perform broad repository operations directly when a bounded Harness operation or configured agent owns them.
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Initialize this role now by reading only the project entry instructions needed to understand these rules. Do not run doctor/setup or inspect the repository broadly during bootstrap. When initialization is complete, respond with exactly: AEH READY`;
|
|
107
|
+
This bootstrap is session configuration, not a user task. Do not emit an initialization handshake or synthetic readiness message; remain idle until the user's first real request.`;
|
|
109
108
|
}
|
|
110
109
|
export function resolveLeadAgent(topology, configured) {
|
|
111
110
|
if (configured) {
|
|
@@ -134,5 +133,4 @@ catch {
|
|
|
134
133
|
} }
|
|
135
134
|
function compatibleState(state, expected) { return state.version === 1 && state.bootstrapVersion === PASEO_BOOTSTRAP_VERSION && state.projectRoot === expected.projectRoot && state.leadAgent === expected.leadName && state.provider === expected.provider && state.model === expected.model && state.title === expected.title; }
|
|
136
135
|
function diagnostic(result) { return [result.stderr.trim(), result.stdout.trim()].filter(Boolean).join("\n") || `exit code ${result.exitCode}`; }
|
|
137
|
-
function quote(value) { return `'${value.replaceAll("'", "'\\''")}'`; }
|
|
138
136
|
//# sourceMappingURL=start.js.map
|