agentic-engineering-harness 0.6.9 → 0.6.11
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/permissions.d.ts +28 -1
- package/dist/agents/permissions.js +188 -29
- package/dist/agents/permissions.js.map +1 -1
- package/dist/paseo/launchSpec.d.ts +6 -0
- package/dist/paseo/launchSpec.js +33 -3
- package/dist/paseo/launchSpec.js.map +1 -1
- package/dist/paseo/modePreflight.d.ts +15 -0
- package/dist/paseo/modePreflight.js +118 -0
- package/dist/paseo/modePreflight.js.map +1 -0
- package/dist/paseo/runtime.d.ts +4 -0
- package/dist/paseo/runtime.js +48 -3
- package/dist/paseo/runtime.js.map +1 -1
- package/dist/paseo/sdk.d.ts +3 -0
- package/dist/paseo/sdk.js +122 -43
- package/dist/paseo/sdk.js.map +1 -1
- package/dist/workers/agentPrompt.js +232 -70
- package/dist/workers/agentPrompt.js.map +1 -1
- package/dist/workers/direct.js +85 -22
- package/dist/workers/direct.js.map +1 -1
- package/dist/workers/paseo.js +31 -7
- package/dist/workers/paseo.js.map +1 -1
- package/dist/workers/podman.js +97 -19
- package/dist/workers/podman.js.map +1 -1
- package/docs/PASEO_NATIVE.md +39 -0
- package/package.json +1 -1
- package/presets/agents/orchestration.jsonc +5 -0
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import type { HarnessProjectConfig } from "../core/types.js";
|
|
2
2
|
import type { AgentExecutionSelection } from "./types.js";
|
|
3
|
+
export type OpenCodeAgentBindingSource = "aeh-managed" | "explicit";
|
|
4
|
+
export interface OpenCodeAgentBinding {
|
|
5
|
+
agentId: string;
|
|
6
|
+
source: OpenCodeAgentBindingSource;
|
|
7
|
+
managed: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface OpenCodeRuntimeProjection {
|
|
10
|
+
binding: OpenCodeAgentBinding;
|
|
11
|
+
config: Record<string, unknown>;
|
|
12
|
+
env: Record<string, string>;
|
|
13
|
+
}
|
|
3
14
|
export declare function validateExecutionCapabilities(selection: AgentExecutionSelection, transport: string): string[];
|
|
4
15
|
export declare function permissionSummary(selection: AgentExecutionSelection): string;
|
|
5
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the concrete OpenCode execution identity for an AEH logical agent.
|
|
18
|
+
*
|
|
19
|
+
* Explicit nativeAgent is an externally-authored OpenCode primary/all agent and
|
|
20
|
+
* is preserved exactly. Otherwise AEH owns the native identity and injects a
|
|
21
|
+
* primary agent with a deterministic collision-resistant name into the
|
|
22
|
+
* session-local OpenCode config.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveOpenCodeAgentBinding(selection: AgentExecutionSelection): OpenCodeAgentBinding;
|
|
25
|
+
/**
|
|
26
|
+
* Compile the inline OpenCode configuration used by direct, Podman and Paseo
|
|
27
|
+
* transports. OPENCODE_CONFIG_CONTENT is loaded after ordinary user/project
|
|
28
|
+
* config, so the AEH-managed identity and policy are deterministic without
|
|
29
|
+
* mutating the user's global OpenCode configuration.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildOpenCodeRuntimeConfig(selection: AgentExecutionSelection, config?: HarnessProjectConfig, binding?: OpenCodeAgentBinding): Record<string, unknown>;
|
|
32
|
+
export declare function compileOpenCodeRuntimeProjection(selection: AgentExecutionSelection, config?: HarnessProjectConfig): OpenCodeRuntimeProjection;
|
|
@@ -1,30 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
issues
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function
|
|
28
|
-
return
|
|
29
|
-
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export function validateExecutionCapabilities(selection, transport) {
|
|
3
|
+
const issues = [];
|
|
4
|
+
if (selection.nativeAgent && selection.runtimeCapabilities.nativeAgent === false) {
|
|
5
|
+
issues.push(`Runtime ${selection.runtimeName} cannot select native agent ${selection.nativeAgent}.`);
|
|
6
|
+
}
|
|
7
|
+
const nativeAgentViaPaseo = selection.runtimeCapabilities.nativeAgentViaPaseo === true ||
|
|
8
|
+
(selection.runtimeAdapter === "opencode" && selection.paseoProvider === "opencode");
|
|
9
|
+
if (selection.nativeAgent && transport === "paseo" && !nativeAgentViaPaseo) {
|
|
10
|
+
issues.push(`Agent ${selection.logicalAgent} requires nativeAgent=${selection.nativeAgent}, but runtime ${selection.runtimeName} does not support that native agent through Paseo.`);
|
|
11
|
+
}
|
|
12
|
+
if (selection.variant && selection.runtimeCapabilities.variantSelection === false) {
|
|
13
|
+
issues.push(`Runtime ${selection.runtimeName} cannot select variant ${selection.variant}.`);
|
|
14
|
+
}
|
|
15
|
+
if (selection.role === "implementer" && selection.permissions.write === "deny") {
|
|
16
|
+
issues.push(`Implementer ${selection.logicalAgent} denies write permission.`);
|
|
17
|
+
}
|
|
18
|
+
if ((selection.role === "reviewer" || selection.role === "validator") &&
|
|
19
|
+
selection.permissions.write === "allow") {
|
|
20
|
+
issues.push(`${selection.role} ${selection.logicalAgent} explicitly allows writes; read-only roles should use write=deny unless intentionally mutating.`);
|
|
21
|
+
}
|
|
22
|
+
if (selection.role === "orchestrator" && selection.permissions.delegate === "deny") {
|
|
23
|
+
issues.push(`Orchestrator ${selection.logicalAgent} denies delegation.`);
|
|
24
|
+
}
|
|
25
|
+
return issues;
|
|
26
|
+
}
|
|
27
|
+
export function permissionSummary(selection) {
|
|
28
|
+
return (Object.entries(selection.permissions)
|
|
29
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
30
|
+
.join(", ") || "unspecified");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the concrete OpenCode execution identity for an AEH logical agent.
|
|
34
|
+
*
|
|
35
|
+
* Explicit nativeAgent is an externally-authored OpenCode primary/all agent and
|
|
36
|
+
* is preserved exactly. Otherwise AEH owns the native identity and injects a
|
|
37
|
+
* primary agent with a deterministic collision-resistant name into the
|
|
38
|
+
* session-local OpenCode config.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveOpenCodeAgentBinding(selection) {
|
|
41
|
+
const explicit = selection.nativeAgent?.trim();
|
|
42
|
+
if (explicit) {
|
|
43
|
+
return { agentId: explicit, source: "explicit", managed: false };
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
agentId: managedOpenCodeAgentId(selection.logicalAgent),
|
|
47
|
+
source: "aeh-managed",
|
|
48
|
+
managed: true
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Compile the inline OpenCode configuration used by direct, Podman and Paseo
|
|
53
|
+
* transports. OPENCODE_CONFIG_CONTENT is loaded after ordinary user/project
|
|
54
|
+
* config, so the AEH-managed identity and policy are deterministic without
|
|
55
|
+
* mutating the user's global OpenCode configuration.
|
|
56
|
+
*/
|
|
57
|
+
export function buildOpenCodeRuntimeConfig(selection, config, binding = resolveOpenCodeAgentBinding(selection)) {
|
|
58
|
+
const permission = buildOpenCodePermission(selection);
|
|
59
|
+
const mcp = {};
|
|
60
|
+
const tools = {};
|
|
61
|
+
const configured = config?.mcp?.servers ?? {};
|
|
62
|
+
for (const [name, server] of Object.entries(configured)) {
|
|
63
|
+
const selected = selection.mcps.includes(name) && server.enabled !== false;
|
|
64
|
+
tools[`${name}_*`] = selected;
|
|
65
|
+
if (selected)
|
|
66
|
+
mcp[name] = toOpenCodeMcp(server);
|
|
67
|
+
}
|
|
68
|
+
for (const name of selection.mcps) {
|
|
69
|
+
if (!configured[name])
|
|
70
|
+
tools[`${name}_*`] = true;
|
|
71
|
+
}
|
|
72
|
+
const managedAgent = binding.managed
|
|
73
|
+
? {
|
|
74
|
+
agent: {
|
|
75
|
+
[binding.agentId]: {
|
|
76
|
+
mode: "primary",
|
|
77
|
+
description: selection.description ??
|
|
78
|
+
`AEH-managed OpenCode execution identity for ${selection.logicalAgent}.`,
|
|
79
|
+
model: selection.modelId,
|
|
80
|
+
prompt: `AEH execution identity: ${selection.logicalAgent}. Follow the task-scoped AEH charter, frozen control-plane context, permissions and acceptance criteria supplied with each turn.`,
|
|
81
|
+
...(selection.variant ? { variant: selection.variant } : {}),
|
|
82
|
+
...(selection.temperature !== undefined
|
|
83
|
+
? { temperature: selection.temperature }
|
|
84
|
+
: {}),
|
|
85
|
+
...(Object.keys(permission).length ? { permission } : {})
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
default_agent: binding.agentId
|
|
89
|
+
}
|
|
90
|
+
: {};
|
|
91
|
+
return {
|
|
92
|
+
$schema: "https://opencode.ai/config.json",
|
|
93
|
+
permission,
|
|
94
|
+
...managedAgent,
|
|
95
|
+
...(Object.keys(mcp).length ? { mcp } : {}),
|
|
96
|
+
...(Object.keys(tools).length ? { tools } : {})
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function compileOpenCodeRuntimeProjection(selection, config) {
|
|
100
|
+
const binding = resolveOpenCodeAgentBinding(selection);
|
|
101
|
+
const runtimeConfig = buildOpenCodeRuntimeConfig(selection, config, binding);
|
|
102
|
+
return {
|
|
103
|
+
binding,
|
|
104
|
+
config: runtimeConfig,
|
|
105
|
+
env: {
|
|
106
|
+
OPENCODE_CONFIG_CONTENT: JSON.stringify(runtimeConfig)
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function buildOpenCodePermission(selection) {
|
|
111
|
+
const permission = {};
|
|
112
|
+
const p = selection.permissions;
|
|
113
|
+
if (p.read)
|
|
114
|
+
permission.read = p.read;
|
|
115
|
+
if (p.write)
|
|
116
|
+
permission.edit = p.write;
|
|
117
|
+
if (p.network) {
|
|
118
|
+
permission.webfetch = p.network;
|
|
119
|
+
permission.websearch = p.network;
|
|
120
|
+
}
|
|
121
|
+
if (p.delegate)
|
|
122
|
+
permission.task = p.delegate;
|
|
123
|
+
const bash = buildBashPermission(p.shell, p.gitWrite);
|
|
124
|
+
if (bash)
|
|
125
|
+
permission.bash = bash;
|
|
126
|
+
if (selection.skills.length && !selection.skills.includes("*")) {
|
|
127
|
+
permission.skill = Object.fromEntries([
|
|
128
|
+
["*", "deny"],
|
|
129
|
+
...selection.skills.map((skill) => [skill, "allow"])
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
return permission;
|
|
133
|
+
}
|
|
134
|
+
function managedOpenCodeAgentId(logicalAgent) {
|
|
135
|
+
const original = logicalAgent.trim();
|
|
136
|
+
if (!original)
|
|
137
|
+
throw new Error("AEH logical agent name is required for OpenCode identity.");
|
|
138
|
+
const slug = original
|
|
139
|
+
.toLowerCase()
|
|
140
|
+
.replace(/[^a-z0-9._-]+/g, "-")
|
|
141
|
+
.replace(/^-+|-+$/g, "") || "agent";
|
|
142
|
+
const normalizedOriginal = original.toLowerCase();
|
|
143
|
+
if (slug === normalizedOriginal)
|
|
144
|
+
return `aeh-${slug}`;
|
|
145
|
+
const digest = createHash("sha256").update(original).digest("hex").slice(0, 8);
|
|
146
|
+
return `aeh-${slug}-${digest}`;
|
|
147
|
+
}
|
|
148
|
+
function toOpenCodeMcp(server) {
|
|
149
|
+
if (server.type === "local") {
|
|
150
|
+
return {
|
|
151
|
+
type: "local",
|
|
152
|
+
command: server.command,
|
|
153
|
+
enabled: true,
|
|
154
|
+
...(server.environment ? { environment: server.environment } : {}),
|
|
155
|
+
...(server.timeoutMs ? { timeout: server.timeoutMs } : {})
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
type: "remote",
|
|
160
|
+
url: server.url,
|
|
161
|
+
enabled: true,
|
|
162
|
+
...(server.headers ? { headers: server.headers } : {}),
|
|
163
|
+
...(server.oauth !== undefined ? { oauth: server.oauth } : {}),
|
|
164
|
+
...(server.timeoutMs ? { timeout: server.timeoutMs } : {})
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function buildBashPermission(shell, gitWrite) {
|
|
168
|
+
if (!gitWrite)
|
|
169
|
+
return shell;
|
|
170
|
+
const result = { "*": shell ?? "ask" };
|
|
171
|
+
for (const pattern of [
|
|
172
|
+
"git add *",
|
|
173
|
+
"git commit *",
|
|
174
|
+
"git push *",
|
|
175
|
+
"git tag *",
|
|
176
|
+
"git checkout *",
|
|
177
|
+
"git switch *",
|
|
178
|
+
"git reset *",
|
|
179
|
+
"git clean *",
|
|
180
|
+
"git restore *",
|
|
181
|
+
"git merge *",
|
|
182
|
+
"git rebase *",
|
|
183
|
+
"git cherry-pick *"
|
|
184
|
+
]) {
|
|
185
|
+
result[pattern] = gitWrite;
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
30
189
|
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/agents/permissions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/agents/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkBzC,MAAM,UAAU,6BAA6B,CAC3C,SAAkC,EAClC,SAAiB;IAEjB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,mBAAmB,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;QACjF,MAAM,CAAC,IAAI,CACT,WAAW,SAAS,CAAC,WAAW,+BAA+B,SAAS,CAAC,WAAW,GAAG,CACxF,CAAC;IACJ,CAAC;IACD,MAAM,mBAAmB,GACvB,SAAS,CAAC,mBAAmB,CAAC,mBAAmB,KAAK,IAAI;QAC1D,CAAC,SAAS,CAAC,cAAc,KAAK,UAAU,IAAI,SAAS,CAAC,aAAa,KAAK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ource } from "../agents/permissions.js";
|
|
1
2
|
import type { AgentExecutionSelection } from "../agents/types.js";
|
|
2
3
|
import type { HarnessProjectConfig, TaskContract } from "../core/types.js";
|
|
3
4
|
export interface PaseoLaunchSpecOptions {
|
|
@@ -14,6 +15,11 @@ export interface PaseoAgentLaunchSpec {
|
|
|
14
15
|
title: string;
|
|
15
16
|
provider: string;
|
|
16
17
|
model?: string;
|
|
18
|
+
modeId?: string;
|
|
19
|
+
modeSource?: OpenCodeAgentBindingSource;
|
|
20
|
+
thinkingOptionId?: string;
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
nativeAgentId?: string;
|
|
17
23
|
workspaceId?: string;
|
|
18
24
|
labels: Record<string, string>;
|
|
19
25
|
timeoutSeconds: number;
|
package/dist/paseo/launchSpec.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compileOpenCodeRuntimeProjection } from "../agents/permissions.js";
|
|
1
2
|
import { deliveryWorkspaceId } from "../delivery/handoff.js";
|
|
2
3
|
import { currentOperationContext } from "../operations/state.js";
|
|
3
4
|
export async function compilePaseoAgentLaunchSpec(root, config, contract, options = {}) {
|
|
@@ -5,7 +6,12 @@ export async function compilePaseoAgentLaunchSpec(root, config, contract, option
|
|
|
5
6
|
const worker = config.orchestration?.worker;
|
|
6
7
|
const logicalAgent = options.logicalAgent ?? selection?.logicalAgent ?? "worker";
|
|
7
8
|
const provider = options.provider ?? selection?.paseoProvider ?? worker?.provider ?? "opencode";
|
|
8
|
-
const model = options.model ??
|
|
9
|
+
const model = options.model ??
|
|
10
|
+
(selection
|
|
11
|
+
? selection.runtimeAdapter === "codex"
|
|
12
|
+
? selection.modelName
|
|
13
|
+
: selection.modelId
|
|
14
|
+
: worker?.model);
|
|
9
15
|
const operation = currentOperationContext();
|
|
10
16
|
const operationId = operation.id ?? contract.task.id;
|
|
11
17
|
const operationKind = operation.kind ?? options.kind ?? inferOperationKind(contract);
|
|
@@ -13,6 +19,10 @@ export async function compilePaseoAgentLaunchSpec(root, config, contract, option
|
|
|
13
19
|
const deliveryId = await deliveryWorkspaceId(root, config, contract.task.id);
|
|
14
20
|
const workspaceId = deliveryId ?? operation.workspaceId;
|
|
15
21
|
const title = `${options.titlePrefix ?? worker?.titlePrefix ?? "aeh"}-${contract.task.id}-${logicalAgent}`;
|
|
22
|
+
const openCode = selection?.runtimeAdapter === "opencode" && provider === "opencode"
|
|
23
|
+
? compileOpenCodeRuntimeProjection(selection, config)
|
|
24
|
+
: undefined;
|
|
25
|
+
const explicitOpenCodeMode = openCode && !openCode.binding.managed ? openCode.binding.agentId : undefined;
|
|
16
26
|
const labels = {
|
|
17
27
|
"aeh.project": config.project.name,
|
|
18
28
|
"aeh.kind": "worker",
|
|
@@ -24,8 +34,13 @@ export async function compilePaseoAgentLaunchSpec(root, config, contract, option
|
|
|
24
34
|
};
|
|
25
35
|
if (selection?.profile)
|
|
26
36
|
labels["aeh.profile"] = selection.profile;
|
|
27
|
-
if (
|
|
37
|
+
if (openCode) {
|
|
38
|
+
labels["aeh.native-agent"] = openCode.binding.agentId;
|
|
39
|
+
labels["aeh.native-agent.source"] = openCode.binding.source;
|
|
40
|
+
}
|
|
41
|
+
if (workspaceId && workspaceId === operation.workspaceId && !deliveryId) {
|
|
28
42
|
labels["aeh.workspace.kind"] = "orchestration";
|
|
43
|
+
}
|
|
29
44
|
if (workspaceId && deliveryId)
|
|
30
45
|
labels["aeh.workspace.kind"] = "delivery";
|
|
31
46
|
return {
|
|
@@ -33,6 +48,18 @@ export async function compilePaseoAgentLaunchSpec(root, config, contract, option
|
|
|
33
48
|
title,
|
|
34
49
|
provider,
|
|
35
50
|
model,
|
|
51
|
+
// Paseo validates an explicit mode against the provider catalog before it
|
|
52
|
+
// launches the per-session OpenCode process. AEH-managed agents exist only
|
|
53
|
+
// in OPENCODE_CONFIG_CONTENT for that process, so exposing their generated
|
|
54
|
+
// id as modeId makes Paseo reject them before OpenCode can load the config.
|
|
55
|
+
// Leave modeId unset for managed identities: Paseo then omits the OpenCode
|
|
56
|
+
// prompt `agent` field and the injected default_agent selects the managed
|
|
57
|
+
// primary deterministically inside the session.
|
|
58
|
+
modeId: explicitOpenCodeMode,
|
|
59
|
+
modeSource: explicitOpenCodeMode ? openCode?.binding.source : undefined,
|
|
60
|
+
thinkingOptionId: openCode ? selection?.variant : undefined,
|
|
61
|
+
env: openCode?.env,
|
|
62
|
+
nativeAgentId: openCode?.binding.agentId,
|
|
36
63
|
workspaceId,
|
|
37
64
|
labels,
|
|
38
65
|
timeoutSeconds: worker?.timeoutSeconds ?? 1800,
|
|
@@ -54,8 +81,11 @@ export function inferAgentPhase(selection, logicalAgent) {
|
|
|
54
81
|
return "spec-authoring";
|
|
55
82
|
if (name.includes("environment-manager"))
|
|
56
83
|
return "environment-recovery";
|
|
57
|
-
if (role === "implementer" ||
|
|
84
|
+
if (role === "implementer" ||
|
|
85
|
+
name.includes("implementer") ||
|
|
86
|
+
name.includes("worker")) {
|
|
58
87
|
return "implementation";
|
|
88
|
+
}
|
|
59
89
|
return "work";
|
|
60
90
|
}
|
|
61
91
|
function inferOperationKind(contract) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launchSpec.js","sourceRoot":"","sources":["../../src/paseo/launchSpec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launchSpec.js","sourceRoot":"","sources":["../../src/paseo/launchSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAEjC,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AA8BjE,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,IAAY,EACZ,MAA4B,EAC5B,QAAsB,EACtB,UAAkC,EAAE;IAEpC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,E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,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAChD,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACvC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,OAAO,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PaseoProviderModePreflightResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
provider: string;
|
|
4
|
+
modeId: string;
|
|
5
|
+
availableModes: string[];
|
|
6
|
+
source: "paseo-provider-modes";
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate an externally-authored provider mode before AEH dispatches work.
|
|
11
|
+
* This is intentionally fail-closed: an explicit nativeAgent is part of the
|
|
12
|
+
* frozen execution contract, so silently falling back to an ambient default
|
|
13
|
+
* would execute a different agent than the one AEH selected.
|
|
14
|
+
*/
|
|
15
|
+
export declare function preflightPaseoProviderMode(root: string, provider: string, modeId: string, cwd?: string): Promise<PaseoProviderModePreflightResult>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { PaseoSdkUnavailableError } from "./sdk.js";
|
|
4
|
+
import { resolvePaseoSdkFromCli } from "./sdkResolve.js";
|
|
5
|
+
import { recordPaseoTrace } from "./trace.js";
|
|
6
|
+
/**
|
|
7
|
+
* Validate an externally-authored provider mode before AEH dispatches work.
|
|
8
|
+
* This is intentionally fail-closed: an explicit nativeAgent is part of the
|
|
9
|
+
* frozen execution contract, so silently falling back to an ambient default
|
|
10
|
+
* would execute a different agent than the one AEH selected.
|
|
11
|
+
*/
|
|
12
|
+
export async function preflightPaseoProviderMode(root, provider, modeId, cwd = root) {
|
|
13
|
+
const normalizedProvider = provider.trim();
|
|
14
|
+
const normalizedMode = modeId.trim();
|
|
15
|
+
if (!normalizedProvider)
|
|
16
|
+
throw new Error("Paseo provider is required for mode preflight.");
|
|
17
|
+
if (!normalizedMode)
|
|
18
|
+
throw new Error("Paseo modeId is required for mode preflight.");
|
|
19
|
+
const sdk = await loadSdk(root);
|
|
20
|
+
const client = sdk.createPaseoClient({
|
|
21
|
+
url: process.env.PASEO_DAEMON_URL?.trim() || "ws://127.0.0.1:6767/ws",
|
|
22
|
+
clientId: `aeh-mode-preflight-${process.pid}`,
|
|
23
|
+
password: process.env.PASEO_DAEMON_PASSWORD?.trim() || undefined
|
|
24
|
+
});
|
|
25
|
+
try {
|
|
26
|
+
await client.connect();
|
|
27
|
+
if (typeof client.providers?.listModes !== "function") {
|
|
28
|
+
throw new Error("The active Paseo SDK does not expose providers.listModes(), which AEH requires to validate an explicit native OpenCode agent before dispatch.");
|
|
29
|
+
}
|
|
30
|
+
const response = await client.providers.listModes(normalizedProvider, { cwd });
|
|
31
|
+
const availableModes = modeIds(response);
|
|
32
|
+
const ok = availableModes.includes(normalizedMode);
|
|
33
|
+
const result = {
|
|
34
|
+
ok,
|
|
35
|
+
provider: normalizedProvider,
|
|
36
|
+
modeId: normalizedMode,
|
|
37
|
+
availableModes,
|
|
38
|
+
source: "paseo-provider-modes",
|
|
39
|
+
message: ok
|
|
40
|
+
? `Paseo provider ${normalizedProvider} exposes mode ${normalizedMode}.`
|
|
41
|
+
: availableModes.length
|
|
42
|
+
? `Paseo provider ${normalizedProvider} does not expose requested mode ${normalizedMode}.`
|
|
43
|
+
: `Paseo provider ${normalizedProvider} reported no selectable modes for ${cwd}.`
|
|
44
|
+
};
|
|
45
|
+
await recordPaseoTrace(root, "provider.mode.preflight", {
|
|
46
|
+
ok,
|
|
47
|
+
provider: normalizedProvider,
|
|
48
|
+
modeId: normalizedMode,
|
|
49
|
+
availableModeCount: availableModes.length,
|
|
50
|
+
source: result.source,
|
|
51
|
+
message: result.message
|
|
52
|
+
});
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await client.close().catch(() => undefined);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function loadSdk(root) {
|
|
60
|
+
const bundled = await resolvePaseoSdkFromCli(root);
|
|
61
|
+
if (bundled.resolved) {
|
|
62
|
+
try {
|
|
63
|
+
const sdk = (await import(pathToFileURL(bundled.resolved).href));
|
|
64
|
+
if (typeof sdk.createPaseoClient === "function")
|
|
65
|
+
return sdk;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
bundled.diagnostics.push(`mode preflight bundled import: ${String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const packageName = "@getpaseo/client";
|
|
72
|
+
let directError;
|
|
73
|
+
try {
|
|
74
|
+
const direct = (await import(packageName));
|
|
75
|
+
if (typeof direct.createPaseoClient === "function")
|
|
76
|
+
return direct;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
directError = error;
|
|
80
|
+
}
|
|
81
|
+
const detail = bundled.diagnostics.length
|
|
82
|
+
? ` Resolution diagnostics: ${bundled.diagnostics.join("; ")}.`
|
|
83
|
+
: "";
|
|
84
|
+
throw new PaseoSdkUnavailableError(`Paseo SDK could not be resolved for explicit provider-mode preflight.${detail}${directError ? ` Direct import: ${String(directError)}` : ""}`, { cause: directError });
|
|
85
|
+
}
|
|
86
|
+
function modeIds(value) {
|
|
87
|
+
const result = new Set();
|
|
88
|
+
const visit = (item) => {
|
|
89
|
+
if (Array.isArray(item)) {
|
|
90
|
+
for (const child of item)
|
|
91
|
+
visit(child);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!item || typeof item !== "object")
|
|
95
|
+
return;
|
|
96
|
+
const record = item;
|
|
97
|
+
const id = stringField(record, ["id", "modeId", "mode_id"]);
|
|
98
|
+
if (id &&
|
|
99
|
+
("label" in record ||
|
|
100
|
+
"description" in record ||
|
|
101
|
+
"colorTier" in record ||
|
|
102
|
+
"isDefault" in record)) {
|
|
103
|
+
result.add(id);
|
|
104
|
+
}
|
|
105
|
+
for (const child of Object.values(record))
|
|
106
|
+
visit(child);
|
|
107
|
+
};
|
|
108
|
+
visit(value);
|
|
109
|
+
return [...result];
|
|
110
|
+
}
|
|
111
|
+
function stringField(record, keys) {
|
|
112
|
+
for (const key of keys) {
|
|
113
|
+
if (typeof record[key] === "string" && record[key])
|
|
114
|
+
return record[key];
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=modePreflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modePreflight.js","sourceRoot":"","sources":["../../src/paseo/modePreflight.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgC9C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,IAAY,EACZ,QAAgB,EAChB,MAAc,EACd,GAAG,GAAG,IAAI;IAEV,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,kBAAkB;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAC3F,IAAI,CAAC,cAAc;QAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAErF,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC;QACnC,GAAG,EAAE,OA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AAO,MAAM,CAAC,GAAG,CAAW,CAAC;IACnF,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/paseo/runtime.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { OpenCodeAgentBindingSource } from "../agents/permissions.js";
|
|
1
2
|
import { runProcess } from "../utils/process.js";
|
|
2
3
|
import { detectPaseoCapabilities } from "./capabilities.js";
|
|
4
|
+
import { preflightPaseoProviderMode } from "./modePreflight.js";
|
|
3
5
|
import { capturePaseoAgentTurnBaseline, preflightPaseoProviderModel, waitForPaseoAgentNative, type PaseoTurnBaseline } from "./native.js";
|
|
4
6
|
import { createPaseoSdkAgent, dispatchPaseoSdkAgent, inspectPaseoSdkAgent, listPaseoSdkAgents, materializePaseoSdkAgent, probePaseoSdkAgent, runPaseoSdkAgent, waitPaseoSdkAgent, type PaseoSdkAgentOptions, type PaseoSdkAgentRecord } from "./sdk.js";
|
|
5
7
|
import { recordPaseoTrace } from "./trace.js";
|
|
6
8
|
export interface ManagedPaseoAgentOptions extends PaseoSdkAgentOptions {
|
|
7
9
|
timeoutSeconds?: number;
|
|
10
|
+
modeSource?: OpenCodeAgentBindingSource;
|
|
8
11
|
}
|
|
9
12
|
export interface ManagedPaseoAgentResult {
|
|
10
13
|
id?: string;
|
|
@@ -22,6 +25,7 @@ interface PaseoRuntimeDeps {
|
|
|
22
25
|
trace?: typeof recordPaseoTrace;
|
|
23
26
|
native?: {
|
|
24
27
|
preflight: typeof preflightPaseoProviderModel;
|
|
28
|
+
preflightMode: typeof preflightPaseoProviderMode;
|
|
25
29
|
wait: typeof waitForPaseoAgentNative;
|
|
26
30
|
capture?: typeof capturePaseoAgentTurnBaseline;
|
|
27
31
|
};
|