poe-code 3.0.202 → 3.0.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/braintrust.d.ts +3 -0
- package/dist/cli/commands/braintrust.js +77 -0
- package/dist/cli/commands/braintrust.js.map +1 -0
- package/dist/cli/commands/configure.d.ts +1 -0
- package/dist/cli/commands/configure.js +197 -0
- package/dist/cli/commands/configure.js.map +1 -1
- package/dist/cli/commands/experiment.js +51 -7
- package/dist/cli/commands/experiment.js.map +1 -1
- package/dist/cli/commands/harness.d.ts +3 -0
- package/dist/cli/commands/harness.js +260 -0
- package/dist/cli/commands/harness.js.map +1 -0
- package/dist/cli/commands/pipeline.js +58 -24
- package/dist/cli/commands/pipeline.js.map +1 -1
- package/dist/cli/commands/ralph.js +19 -7
- package/dist/cli/commands/ralph.js.map +1 -1
- package/dist/cli/commands/runtime/build.d.ts +7 -0
- package/dist/cli/commands/runtime/build.js +128 -0
- package/dist/cli/commands/runtime/build.js.map +1 -0
- package/dist/cli/commands/runtime/index.d.ts +3 -0
- package/dist/cli/commands/runtime/index.js +14 -0
- package/dist/cli/commands/runtime/index.js.map +1 -0
- package/dist/cli/commands/runtime/init.d.ts +7 -0
- package/dist/cli/commands/runtime/init.js +39 -0
- package/dist/cli/commands/runtime/init.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/attach.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/attach.js +35 -0
- package/dist/cli/commands/runtime/jobs/attach.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/index.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/index.js +16 -0
- package/dist/cli/commands/runtime/jobs/index.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/logs.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/logs.js +27 -0
- package/dist/cli/commands/runtime/jobs/logs.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/ls.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/ls.js +60 -0
- package/dist/cli/commands/runtime/jobs/ls.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/sandbox.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/sandbox.js +15 -0
- package/dist/cli/commands/runtime/jobs/sandbox.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/shared.d.ts +22 -0
- package/dist/cli/commands/runtime/jobs/shared.js +124 -0
- package/dist/cli/commands/runtime/jobs/shared.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/stop.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/stop.js +31 -0
- package/dist/cli/commands/runtime/jobs/stop.js.map +1 -0
- package/dist/cli/commands/runtime/jobs/sync.d.ts +3 -0
- package/dist/cli/commands/runtime/jobs/sync.js +25 -0
- package/dist/cli/commands/runtime/jobs/sync.js.map +1 -0
- package/dist/cli/commands/runtime/shared.d.ts +20 -0
- package/dist/cli/commands/runtime/shared.js +69 -0
- package/dist/cli/commands/runtime/shared.js.map +1 -0
- package/dist/cli/commands/runtime/templates/clear.d.ts +3 -0
- package/dist/cli/commands/runtime/templates/clear.js +53 -0
- package/dist/cli/commands/runtime/templates/clear.js.map +1 -0
- package/dist/cli/commands/runtime/templates/index.d.ts +3 -0
- package/dist/cli/commands/runtime/templates/index.js +10 -0
- package/dist/cli/commands/runtime/templates/index.js.map +1 -0
- package/dist/cli/commands/runtime/templates/ls.d.ts +3 -0
- package/dist/cli/commands/runtime/templates/ls.js +52 -0
- package/dist/cli/commands/runtime/templates/ls.js.map +1 -0
- package/dist/cli/commands/runtime-options.d.ts +11 -0
- package/dist/cli/commands/runtime-options.js +26 -0
- package/dist/cli/commands/runtime-options.js.map +1 -0
- package/dist/cli/commands/spawn.js +36 -7
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/program.js +17 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +70879 -47381
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +3486 -852
- package/dist/providers/claude-code.js.map +4 -4
- package/dist/providers/codex.js +3486 -852
- package/dist/providers/codex.js.map +4 -4
- package/dist/providers/goose.js +3432 -798
- package/dist/providers/goose.js.map +4 -4
- package/dist/providers/kimi.js +3486 -852
- package/dist/providers/kimi.js.map +4 -4
- package/dist/providers/opencode.js +3486 -852
- package/dist/providers/opencode.js.map +4 -4
- package/dist/providers/poe-agent.js +20641 -17147
- package/dist/providers/poe-agent.js.map +4 -4
- package/dist/providers/spawn-options.d.ts +10 -1
- package/dist/sdk/experiment.js +6 -0
- package/dist/sdk/experiment.js.map +1 -1
- package/dist/sdk/ralph.js +108 -11
- package/dist/sdk/ralph.js.map +1 -1
- package/dist/sdk/spawn.js +27 -4
- package/dist/sdk/spawn.js.map +1 -1
- package/dist/sdk/types.d.ts +23 -1
- package/dist/utils/command-checks.js +2 -29
- package/dist/utils/command-checks.js.map +1 -1
- package/package.json +12 -7
- package/packages/design-system/dist/components/help-formatter-plain.d.ts +4 -0
- package/packages/design-system/dist/components/help-formatter-plain.js +132 -0
- package/packages/design-system/dist/components/help-formatter.d.ts +13 -0
- package/packages/design-system/dist/components/help-formatter.js +116 -7
- package/packages/design-system/dist/components/index.d.ts +2 -2
- package/packages/design-system/dist/components/index.js +1 -1
- package/packages/design-system/dist/components/text.d.ts +1 -0
- package/packages/design-system/dist/components/text.js +8 -0
- package/packages/design-system/dist/index.d.ts +3 -2
- package/packages/design-system/dist/index.js +2 -1
- package/packages/memory/dist/index.js +3406 -387
- package/packages/memory/dist/index.js.map +4 -4
- package/packages/superintendent/dist/commands/run.d.ts +45 -0
- package/packages/superintendent/dist/commands/run.js +133 -38
- package/packages/superintendent/dist/commands/superintendent-group.d.ts +36 -0
- package/packages/superintendent/dist/runtime/agent-runner.d.ts +31 -0
- package/packages/superintendent/dist/runtime/agent-runner.js +121 -0
- package/packages/superintendent/dist/runtime/loop.d.ts +7 -1
- package/packages/superintendent/dist/runtime/loop.js +3 -11
- package/packages/superintendent/dist/runtime/run-builder.d.ts +1 -0
- package/packages/superintendent/dist/runtime/run-builder.js +3 -25
- package/packages/superintendent/dist/runtime/run-inspector.d.ts +1 -0
- package/packages/superintendent/dist/runtime/run-inspector.js +3 -25
- package/packages/superintendent/dist/runtime/run-owner-review.d.ts +1 -0
- package/packages/superintendent/dist/runtime/run-owner-review.js +3 -25
- package/packages/superintendent/dist/runtime/run-superintendent.d.ts +1 -0
- package/packages/superintendent/dist/runtime/run-superintendent.js +3 -25
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type RuntimeOverrideOptions } from "@poe-code/agent-harness-tools";
|
|
1
2
|
import { select, type Dashboard } from "@poe-code/design-system";
|
|
3
|
+
import { type Integrations } from "@poe-code/poe-code-config";
|
|
2
4
|
import { type AgentRunInput, type AgentRunResult, type RunLoopOptions, type SuperintendentFileSystem, type SuperintendentRunResult } from "../runtime/loop.js";
|
|
3
5
|
export type SuperintendentRunCommandResult = SuperintendentRunResult & {
|
|
4
6
|
docPath: string;
|
|
@@ -9,6 +11,12 @@ export type RunCommandOptions = {
|
|
|
9
11
|
homeDir: string;
|
|
10
12
|
docPath?: string;
|
|
11
13
|
builderAgent?: string;
|
|
14
|
+
runtime?: "host" | "docker" | "e2b";
|
|
15
|
+
runtimeImage?: string;
|
|
16
|
+
runtimeTemplate?: string;
|
|
17
|
+
detach?: boolean;
|
|
18
|
+
mountPoeCode?: boolean;
|
|
19
|
+
runnerSync?: RuntimeOverrideOptions["runnerSync"];
|
|
12
20
|
configuredDefaultAgent?: string | null;
|
|
13
21
|
planDirectory?: string;
|
|
14
22
|
assumeYes?: boolean;
|
|
@@ -40,17 +48,30 @@ export type RunCommandOptions = {
|
|
|
40
48
|
openInEditor?: (absolutePath: string, env: Record<string, string | undefined>) => void;
|
|
41
49
|
stderr?: NodeJS.WritableStream;
|
|
42
50
|
exit?: (code: number) => never;
|
|
51
|
+
integrations?: Integrations | null;
|
|
43
52
|
};
|
|
44
53
|
export declare const runCommand: import("toolcraft").Command<{
|
|
45
54
|
[x: string]: never;
|
|
46
55
|
}, import("toolcraft-schema").ObjectSchema<{
|
|
47
56
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
48
57
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
58
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
59
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
60
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
61
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
62
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
63
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
49
64
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
50
65
|
}>, undefined, SuperintendentRunCommandResult> & {
|
|
51
66
|
readonly __agentKitCommandTypeInfo: import("toolcraft").CommandTypeInfo<"run", import("toolcraft-schema").ObjectSchema<{
|
|
52
67
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
53
68
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
69
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
70
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
71
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
72
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
73
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
74
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
54
75
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
55
76
|
}>, SuperintendentRunCommandResult, ("cli" | "sdk")[], undefined>;
|
|
56
77
|
};
|
|
@@ -62,11 +83,23 @@ export declare function createRunMcpCommand(runners?: RunMcpCommandRunners): imp
|
|
|
62
83
|
}, import("toolcraft-schema").ObjectSchema<{
|
|
63
84
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
64
85
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
86
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
87
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
88
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
89
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
90
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
91
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
65
92
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
66
93
|
}>, undefined, SuperintendentRunCommandResult> & {
|
|
67
94
|
readonly __agentKitCommandTypeInfo: import("toolcraft").CommandTypeInfo<"run", import("toolcraft-schema").ObjectSchema<{
|
|
68
95
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
69
96
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
97
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
98
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
99
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
100
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
101
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
102
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
70
103
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
71
104
|
}>, SuperintendentRunCommandResult, "mcp"[], undefined>;
|
|
72
105
|
};
|
|
@@ -75,11 +108,23 @@ export declare const runMcpCommand: import("toolcraft").Command<{
|
|
|
75
108
|
}, import("toolcraft-schema").ObjectSchema<{
|
|
76
109
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
77
110
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
111
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
112
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
113
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
114
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
115
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
116
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
78
117
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
79
118
|
}>, undefined, SuperintendentRunCommandResult> & {
|
|
80
119
|
readonly __agentKitCommandTypeInfo: import("toolcraft").CommandTypeInfo<"run", import("toolcraft-schema").ObjectSchema<{
|
|
81
120
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
82
121
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
122
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
123
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
124
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
125
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
126
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
127
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
83
128
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
84
129
|
}>, SuperintendentRunCommandResult, "mcp"[], undefined>;
|
|
85
130
|
};
|
|
@@ -7,7 +7,7 @@ import { parseAgentSpecifier } from "@poe-code/agent-defs";
|
|
|
7
7
|
import { executePoeAgent } from "./poe-agent-runner.js";
|
|
8
8
|
import { S, UserError, defineCommand } from "toolcraft";
|
|
9
9
|
import { acp, cancel, createDashboard, isCancel, resolveOutputFormat, select, shouldUseInteractiveDashboard, text } from "@poe-code/design-system";
|
|
10
|
-
import { planConfigScope, readMergedDocument, resolveConfigPath, resolveProjectConfigPath, resolveScope } from "@poe-code/poe-code-config";
|
|
10
|
+
import { planConfigScope, loadIntegrations, mergeLoopCallbacks, readMergedDocument, resolveConfigPath, resolveProjectConfigPath, resolveScope } from "@poe-code/poe-code-config";
|
|
11
11
|
import { superintendentConfigScope } from "../config-scope.js";
|
|
12
12
|
import { parseSuperintendentDoc, readExplicitBuilderAgent } from "../document/parse.js";
|
|
13
13
|
import { runLoop } from "../runtime/loop.js";
|
|
@@ -25,6 +25,18 @@ const runParams = S.Object({
|
|
|
25
25
|
agent: S.Optional(S.String({
|
|
26
26
|
description: "Override the builder agent for this run. Precedence: --agent > plan frontmatter builder.agent."
|
|
27
27
|
})),
|
|
28
|
+
runtime: S.Optional(S.Enum(["host", "docker", "e2b"], {
|
|
29
|
+
description: "Override runtime backend: host, docker, or e2b"
|
|
30
|
+
})),
|
|
31
|
+
runtimeImage: S.Optional(S.String({ description: "Override Docker runtime image" })),
|
|
32
|
+
runtimeTemplate: S.Optional(S.String({ description: "Override E2B runtime template id" })),
|
|
33
|
+
detach: S.Optional(S.Boolean({ description: "Run as a detached runtime job" })),
|
|
34
|
+
mountPoeCode: S.Optional(S.Boolean({
|
|
35
|
+
description: "Mount the local poe-code checkout into the runtime"
|
|
36
|
+
})),
|
|
37
|
+
runnerSync: S.Optional(S.Enum(["both", "upload", "none"], {
|
|
38
|
+
description: "Override runner workspace sync: both, upload, or none"
|
|
39
|
+
})),
|
|
28
40
|
tui: S.Optional(S.Boolean({ description: "Show a live dashboard while Superintendent is running" }))
|
|
29
41
|
});
|
|
30
42
|
export const runCommand = defineCommand({
|
|
@@ -37,19 +49,35 @@ export const runCommand = defineCommand({
|
|
|
37
49
|
const cwd = process.cwd();
|
|
38
50
|
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? cwd;
|
|
39
51
|
const commandConfig = await resolveSuperintendentCommandConfig(cwd, homeDir, process.env);
|
|
52
|
+
const integrations = await loadIntegrations(commandConfig.configDoc);
|
|
40
53
|
const tuiEnabled = params.tui ?? commandConfig.tui;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
try {
|
|
55
|
+
const runOptions = {
|
|
56
|
+
cwd,
|
|
57
|
+
homeDir,
|
|
58
|
+
docPath: params.doc,
|
|
59
|
+
...(params.agent ? { builderAgent: params.agent } : {}),
|
|
60
|
+
...(params.runtime ? { runtime: params.runtime } : {}),
|
|
61
|
+
...(params.runtimeImage ? { runtimeImage: params.runtimeImage } : {}),
|
|
62
|
+
...(params.runtimeTemplate ? { runtimeTemplate: params.runtimeTemplate } : {}),
|
|
63
|
+
...(params.detach ? { detach: params.detach } : {}),
|
|
64
|
+
...(params.mountPoeCode ? { mountPoeCode: params.mountPoeCode } : {}),
|
|
65
|
+
...(params.runnerSync ? { runnerSync: params.runnerSync } : {}),
|
|
66
|
+
configuredDefaultAgent: commandConfig.configuredDefaultAgent,
|
|
67
|
+
assumeYes: process.argv.includes("--yes"),
|
|
68
|
+
interactive: Boolean(process.stdin.isTTY),
|
|
69
|
+
useDashboard: shouldUseInteractiveDashboard(tuiEnabled) && resolveOutputFormat() === "terminal",
|
|
70
|
+
env: process.env,
|
|
71
|
+
integrations,
|
|
72
|
+
...(commandConfig.planDirectory ? { planDirectory: commandConfig.planDirectory } : {})
|
|
73
|
+
};
|
|
74
|
+
return integrations
|
|
75
|
+
? await integrations.traceRun("superintendent", params.doc ?? "run", () => runSuperintendentCommand(runOptions))
|
|
76
|
+
: await runSuperintendentCommand(runOptions);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
await integrations?.shutdown();
|
|
80
|
+
}
|
|
53
81
|
},
|
|
54
82
|
render: {
|
|
55
83
|
rich: (result, { logger }) => {
|
|
@@ -90,19 +118,34 @@ export function createRunMcpCommand(runners) {
|
|
|
90
118
|
const cwd = process.cwd();
|
|
91
119
|
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? cwd;
|
|
92
120
|
const commandConfig = await resolveSuperintendentCommandConfig(cwd, homeDir, process.env);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
121
|
+
const integrations = await loadIntegrations(commandConfig.configDoc);
|
|
122
|
+
try {
|
|
123
|
+
const runOptions = {
|
|
124
|
+
cwd,
|
|
125
|
+
homeDir,
|
|
126
|
+
docPath: params.doc,
|
|
127
|
+
...(params.agent ? { builderAgent: params.agent } : {}),
|
|
128
|
+
...(params.runtime ? { runtime: params.runtime } : {}),
|
|
129
|
+
...(params.runtimeImage ? { runtimeImage: params.runtimeImage } : {}),
|
|
130
|
+
...(params.runtimeTemplate ? { runtimeTemplate: params.runtimeTemplate } : {}),
|
|
131
|
+
...(params.detach ? { detach: params.detach } : {}),
|
|
132
|
+
...(params.mountPoeCode ? { mountPoeCode: params.mountPoeCode } : {}),
|
|
133
|
+
configuredDefaultAgent: commandConfig.configuredDefaultAgent,
|
|
134
|
+
assumeYes: true,
|
|
135
|
+
interactive: false,
|
|
136
|
+
useDashboard: false,
|
|
137
|
+
env: process.env,
|
|
138
|
+
integrations,
|
|
139
|
+
...(commandConfig.planDirectory ? { planDirectory: commandConfig.planDirectory } : {}),
|
|
140
|
+
...(runners?.runLoop ? { runLoop: runners.runLoop } : {})
|
|
141
|
+
};
|
|
142
|
+
return integrations
|
|
143
|
+
? await integrations.traceRun("superintendent", params.doc ?? "run", () => runSuperintendentCommand(runOptions))
|
|
144
|
+
: await runSuperintendentCommand(runOptions);
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await integrations?.shutdown();
|
|
148
|
+
}
|
|
106
149
|
},
|
|
107
150
|
render: runCommand.render
|
|
108
151
|
});
|
|
@@ -117,13 +160,14 @@ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs) {
|
|
|
117
160
|
const superintendentResolved = resolveScope(superintendentConfigScope.schema, document[superintendentConfigScope.scope], env);
|
|
118
161
|
const coreResolved = resolveScope(coreDefaultAgentConfigSchema, document.core, env);
|
|
119
162
|
return {
|
|
163
|
+
configDoc: document,
|
|
120
164
|
configuredDefaultAgent: normalizeAgentSelection(coreResolved.defaultAgent) ?? null,
|
|
121
165
|
...(planDirectory ? { planDirectory } : {}),
|
|
122
166
|
tui: superintendentResolved.tui === true
|
|
123
167
|
};
|
|
124
168
|
}
|
|
125
169
|
catch {
|
|
126
|
-
return { configuredDefaultAgent: null, tui: false };
|
|
170
|
+
return { configDoc: {}, configuredDefaultAgent: null, tui: false };
|
|
127
171
|
}
|
|
128
172
|
}
|
|
129
173
|
async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs) {
|
|
@@ -176,6 +220,16 @@ export async function runSuperintendentCommand(options) {
|
|
|
176
220
|
const useDashboard = options.useDashboard ?? resolveOutputFormat() === "terminal";
|
|
177
221
|
const stderr = options.stderr ?? process.stderr;
|
|
178
222
|
const exitProcess = options.exit ?? ((code) => process.exit(code));
|
|
223
|
+
const integrations = options.integrations ?? null;
|
|
224
|
+
const shutdownAndExit = (code) => {
|
|
225
|
+
if (!integrations) {
|
|
226
|
+
exitProcess(code);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
void integrations.shutdown().finally(() => {
|
|
230
|
+
exitProcess(code);
|
|
231
|
+
});
|
|
232
|
+
};
|
|
179
233
|
const selectedDocPath = await resolveDocPath({
|
|
180
234
|
cwd: options.cwd,
|
|
181
235
|
homeDir: options.homeDir,
|
|
@@ -214,7 +268,7 @@ export async function runSuperintendentCommand(options) {
|
|
|
214
268
|
const headlessAbort = new AbortController();
|
|
215
269
|
const headlessSigint = () => {
|
|
216
270
|
headlessAbort.abort();
|
|
217
|
-
|
|
271
|
+
shutdownAndExit(130);
|
|
218
272
|
};
|
|
219
273
|
process.on("SIGINT", headlessSigint);
|
|
220
274
|
try {
|
|
@@ -225,7 +279,7 @@ export async function runSuperintendentCommand(options) {
|
|
|
225
279
|
...(options.fs ? { fs } : {}),
|
|
226
280
|
signal: headlessAbort.signal,
|
|
227
281
|
logDir: runLogDir,
|
|
228
|
-
callbacks: {
|
|
282
|
+
callbacks: mergeLoopCallbacks({
|
|
229
283
|
onBuilderStart: () => {
|
|
230
284
|
activeStage = "builder";
|
|
231
285
|
},
|
|
@@ -256,11 +310,20 @@ export async function runSuperintendentCommand(options) {
|
|
|
256
310
|
onOwnerComplete: () => {
|
|
257
311
|
activeStage = undefined;
|
|
258
312
|
}
|
|
259
|
-
},
|
|
313
|
+
}, integrations?.superintendentCallbacks),
|
|
260
314
|
runAgent: createAgentRunner({
|
|
261
315
|
session: undefined,
|
|
262
316
|
executeAgent: options.executeAgent,
|
|
263
317
|
selectedBuilderAgent,
|
|
318
|
+
integrations,
|
|
319
|
+
runtime: {
|
|
320
|
+
runtime: options.runtime,
|
|
321
|
+
runtimeImage: options.runtimeImage,
|
|
322
|
+
runtimeTemplate: options.runtimeTemplate,
|
|
323
|
+
detach: options.detach,
|
|
324
|
+
mountPoeCode: options.mountPoeCode,
|
|
325
|
+
runnerSync: options.runnerSync
|
|
326
|
+
},
|
|
264
327
|
activeStage: () => activeStage,
|
|
265
328
|
now,
|
|
266
329
|
stderr
|
|
@@ -426,7 +489,7 @@ export async function runSuperintendentCommand(options) {
|
|
|
426
489
|
abortController.abort();
|
|
427
490
|
session.dashboard.stop();
|
|
428
491
|
session.dashboard.destroy();
|
|
429
|
-
|
|
492
|
+
shutdownAndExit(130);
|
|
430
493
|
};
|
|
431
494
|
const handleDashboardCommand = (command) => {
|
|
432
495
|
if (command === "forceQuit") {
|
|
@@ -499,13 +562,22 @@ export async function runSuperintendentCommand(options) {
|
|
|
499
562
|
cwd: options.cwd,
|
|
500
563
|
homeDir: options.homeDir,
|
|
501
564
|
...(options.fs ? { fs } : {}),
|
|
502
|
-
callbacks,
|
|
565
|
+
callbacks: mergeLoopCallbacks(callbacks, integrations?.superintendentCallbacks),
|
|
503
566
|
signal: abortController.signal,
|
|
504
567
|
logDir: runLogDir,
|
|
505
568
|
runAgent: createAgentRunner({
|
|
506
569
|
session,
|
|
507
570
|
executeAgent: options.executeAgent,
|
|
508
571
|
selectedBuilderAgent,
|
|
572
|
+
integrations,
|
|
573
|
+
runtime: {
|
|
574
|
+
runtime: options.runtime,
|
|
575
|
+
runtimeImage: options.runtimeImage,
|
|
576
|
+
runtimeTemplate: options.runtimeTemplate,
|
|
577
|
+
detach: options.detach,
|
|
578
|
+
mountPoeCode: options.mountPoeCode,
|
|
579
|
+
runnerSync: options.runnerSync
|
|
580
|
+
},
|
|
509
581
|
activeStage: () => session.activeStage,
|
|
510
582
|
now,
|
|
511
583
|
stderr
|
|
@@ -650,7 +722,8 @@ function createAgentRunner(options) {
|
|
|
650
722
|
return async (input) => {
|
|
651
723
|
const activeStage = options.activeStage();
|
|
652
724
|
const agent = activeStage === "builder" ? options.selectedBuilderAgent : input.agent;
|
|
653
|
-
const executeAgent = options.executeAgent ??
|
|
725
|
+
const executeAgent = options.executeAgent ??
|
|
726
|
+
((nextAgent, nextInput) => executeSpawnAgent(nextAgent, nextInput, options.integrations));
|
|
654
727
|
const stageLabel = formatStageLabel(activeStage);
|
|
655
728
|
const emitLine = (kind, line) => {
|
|
656
729
|
if (line.length === 0) {
|
|
@@ -672,7 +745,12 @@ function createAgentRunner(options) {
|
|
|
672
745
|
const onStdout = (chunk) => stdoutBuffer.push(chunk);
|
|
673
746
|
const onStderr = (chunk) => stderrBuffer.push(chunk);
|
|
674
747
|
try {
|
|
675
|
-
const result = await executeAgent(agent, {
|
|
748
|
+
const result = await executeAgent(agent, {
|
|
749
|
+
...input,
|
|
750
|
+
...options.runtime,
|
|
751
|
+
onStdout,
|
|
752
|
+
onStderr
|
|
753
|
+
});
|
|
676
754
|
if (options.session && result.usage) {
|
|
677
755
|
options.session.tokensIn += result.usage.inputTokens;
|
|
678
756
|
options.session.tokensOut += result.usage.outputTokens;
|
|
@@ -717,12 +795,12 @@ function formatStageLabel(stage) {
|
|
|
717
795
|
}
|
|
718
796
|
return `inspector:${stage.inspector}`;
|
|
719
797
|
}
|
|
720
|
-
async function executeSpawnAgent(agent, input) {
|
|
798
|
+
async function executeSpawnAgent(agent, input, integrations) {
|
|
721
799
|
if (parseAgentSpecifier(agent).agent === "poe-agent") {
|
|
722
800
|
return executePoeAgent(agent, input);
|
|
723
801
|
}
|
|
724
802
|
if ((input.onStdout || input.onStderr) && supportsStreaming(agent)) {
|
|
725
|
-
return executeSpawnAgentStreaming(agent, input);
|
|
803
|
+
return executeSpawnAgentStreaming(agent, input, integrations);
|
|
726
804
|
}
|
|
727
805
|
const tee = input.onStdout || input.onStderr
|
|
728
806
|
? {
|
|
@@ -738,6 +816,12 @@ async function executeSpawnAgent(agent, input) {
|
|
|
738
816
|
...(input.mcpServers ? { mcpServers: input.mcpServers } : {}),
|
|
739
817
|
...(input.signal ? { signal: input.signal } : {}),
|
|
740
818
|
...(input.logPath ? { logPath: input.logPath } : {}),
|
|
819
|
+
...(input.runtime ? { runtime: input.runtime } : {}),
|
|
820
|
+
...(input.runtimeImage ? { runtimeImage: input.runtimeImage } : {}),
|
|
821
|
+
...(input.runtimeTemplate ? { runtimeTemplate: input.runtimeTemplate } : {}),
|
|
822
|
+
...(input.detach ? { detach: input.detach } : {}),
|
|
823
|
+
...(input.mountPoeCode ? { mountPoeCode: input.mountPoeCode } : {}),
|
|
824
|
+
...(input.runnerSync ? { runnerSync: input.runnerSync } : {}),
|
|
741
825
|
...(tee ? { tee } : {})
|
|
742
826
|
});
|
|
743
827
|
return {
|
|
@@ -752,7 +836,7 @@ function supportsStreaming(agent) {
|
|
|
752
836
|
const config = getSpawnConfig(agent);
|
|
753
837
|
return config?.kind === "cli";
|
|
754
838
|
}
|
|
755
|
-
async function executeSpawnAgentStreaming(agent, input) {
|
|
839
|
+
async function executeSpawnAgentStreaming(agent, input, integrations) {
|
|
756
840
|
const writer = (line) => {
|
|
757
841
|
input.onStdout?.(`${line}\n`);
|
|
758
842
|
};
|
|
@@ -764,6 +848,12 @@ async function executeSpawnAgentStreaming(agent, input) {
|
|
|
764
848
|
...(input.mode ? { mode: input.mode } : {}),
|
|
765
849
|
...(input.mcpServers ? { mcpServers: input.mcpServers } : {}),
|
|
766
850
|
...(input.signal ? { signal: input.signal } : {}),
|
|
851
|
+
...(input.runtime ? { runtime: input.runtime } : {}),
|
|
852
|
+
...(input.runtimeImage ? { runtimeImage: input.runtimeImage } : {}),
|
|
853
|
+
...(input.runtimeTemplate ? { runtimeTemplate: input.runtimeTemplate } : {}),
|
|
854
|
+
...(input.detach ? { detach: input.detach } : {}),
|
|
855
|
+
...(input.mountPoeCode ? { mountPoeCode: input.mountPoeCode } : {}),
|
|
856
|
+
...(input.runnerSync ? { runnerSync: input.runnerSync } : {}),
|
|
767
857
|
...(input.onStderr ? { tee: { stderr: { write: input.onStderr } } } : {})
|
|
768
858
|
});
|
|
769
859
|
const middlewareContext = {
|
|
@@ -778,7 +868,12 @@ async function executeSpawnAgentStreaming(agent, input) {
|
|
|
778
868
|
...(input.logPath ? { logPath: input.logPath } : {}),
|
|
779
869
|
...(input.mode ? { mode: input.mode } : {})
|
|
780
870
|
};
|
|
781
|
-
await applyMiddlewares([
|
|
871
|
+
await applyMiddlewares([
|
|
872
|
+
spawnLog,
|
|
873
|
+
usageCapture,
|
|
874
|
+
sessionCapture,
|
|
875
|
+
...(integrations?.spawnMiddleware ? [integrations.spawnMiddleware] : [])
|
|
876
|
+
], middlewareContext);
|
|
782
877
|
await acp.withAcpWriter(writer, () => renderAcpStream(middlewareContext.eventStream ?? rawEvents));
|
|
783
878
|
const final = await done;
|
|
784
879
|
const logFile = middlewareContext.logFile ?? final.logFile;
|
|
@@ -122,11 +122,23 @@ export declare const superintendentGroup: import("toolcraft").Group<{
|
|
|
122
122
|
}, import("toolcraft-schema").ObjectSchema<{
|
|
123
123
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
124
124
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
125
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
126
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
127
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
128
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
129
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
130
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
125
131
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
126
132
|
}>, undefined, import("./run.js").SuperintendentRunCommandResult> & {
|
|
127
133
|
readonly __agentKitCommandTypeInfo: import("toolcraft").CommandTypeInfo<"run", import("toolcraft-schema").ObjectSchema<{
|
|
128
134
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
129
135
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
136
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
137
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
138
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
139
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
140
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
141
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
130
142
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
131
143
|
}>, import("./run.js").SuperintendentRunCommandResult, ("cli" | "sdk")[], undefined>;
|
|
132
144
|
}) | (import("toolcraft").Command<{
|
|
@@ -214,11 +226,23 @@ export declare function createSuperintendentMcpGroup(runners?: SuperintendentMcp
|
|
|
214
226
|
}, import("toolcraft-schema").ObjectSchema<{
|
|
215
227
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
216
228
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
229
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
230
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
231
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
232
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
233
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
234
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
217
235
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
218
236
|
}>, undefined, import("./run.js").SuperintendentRunCommandResult> & {
|
|
219
237
|
readonly __agentKitCommandTypeInfo: import("toolcraft").CommandTypeInfo<"run", import("toolcraft-schema").ObjectSchema<{
|
|
220
238
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
221
239
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
240
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
241
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
242
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
243
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
244
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
245
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
222
246
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
223
247
|
}>, import("./run.js").SuperintendentRunCommandResult, "mcp"[], undefined>;
|
|
224
248
|
}) | (import("toolcraft").Command<{
|
|
@@ -305,11 +329,23 @@ export declare const superintendentMcpGroup: import("toolcraft").Group<{
|
|
|
305
329
|
}, import("toolcraft-schema").ObjectSchema<{
|
|
306
330
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
307
331
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
332
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
333
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
334
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
335
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
336
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
337
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
308
338
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
309
339
|
}>, undefined, import("./run.js").SuperintendentRunCommandResult> & {
|
|
310
340
|
readonly __agentKitCommandTypeInfo: import("toolcraft").CommandTypeInfo<"run", import("toolcraft-schema").ObjectSchema<{
|
|
311
341
|
readonly doc: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
312
342
|
readonly agent: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
343
|
+
readonly runtime: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["host", "docker", "e2b"]>>;
|
|
344
|
+
readonly runtimeImage: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
345
|
+
readonly runtimeTemplate: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
|
|
346
|
+
readonly detach: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
347
|
+
readonly mountPoeCode: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
348
|
+
readonly runnerSync: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").EnumSchema<readonly ["both", "upload", "none"]>>;
|
|
313
349
|
readonly tui: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").BooleanSchema>;
|
|
314
350
|
}>, import("./run.js").SuperintendentRunCommandResult, "mcp"[], undefined>;
|
|
315
351
|
}) | (import("toolcraft").Command<{
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "@poe-code/agent-spawn/register-factories";
|
|
2
|
+
import { type RuntimeOverrideOptions } from "@poe-code/agent-harness-tools";
|
|
3
|
+
import { type McpSpawnConfig, type SpawnMode } from "@poe-code/agent-spawn";
|
|
4
|
+
export type { McpSpawnConfig, SpawnMode };
|
|
5
|
+
export type AutonomousInput = {
|
|
6
|
+
agent: string;
|
|
7
|
+
mode?: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
mcpServers?: McpSpawnConfig;
|
|
11
|
+
logPath?: string;
|
|
12
|
+
runtime?: RuntimeOverrideOptions["runtime"];
|
|
13
|
+
runtimeImage?: string;
|
|
14
|
+
runtimeTemplate?: string;
|
|
15
|
+
detach?: boolean;
|
|
16
|
+
mountPoeCode?: boolean;
|
|
17
|
+
runnerSync?: RuntimeOverrideOptions["runnerSync"];
|
|
18
|
+
};
|
|
19
|
+
export type AutonomousOutput = string | {
|
|
20
|
+
summary?: unknown;
|
|
21
|
+
log?: unknown;
|
|
22
|
+
output?: unknown;
|
|
23
|
+
stdout?: unknown;
|
|
24
|
+
text?: unknown;
|
|
25
|
+
toolCalls?: unknown;
|
|
26
|
+
sessionResult?: unknown;
|
|
27
|
+
logFile?: unknown;
|
|
28
|
+
};
|
|
29
|
+
type AutonomousRunner = (agent: string, options: Omit<AutonomousInput, "agent">) => Promise<AutonomousOutput>;
|
|
30
|
+
export declare function withAutonomousAgentRunner<T>(runner: AutonomousRunner, operation: () => Promise<T>): Promise<T>;
|
|
31
|
+
export declare function runAutonomousAgent(input: AutonomousInput): Promise<AutonomousOutput>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import "@poe-code/agent-spawn/register-factories";
|
|
2
|
+
import { mkdirSync, openSync, writeSync, closeSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { resolvePoeCommandExecution, runPoeCommand } from "@poe-code/agent-harness-tools";
|
|
5
|
+
import { buildSpawnArgs } from "@poe-code/agent-spawn";
|
|
6
|
+
let injectedRunner;
|
|
7
|
+
export async function withAutonomousAgentRunner(runner, operation) {
|
|
8
|
+
const previous = injectedRunner;
|
|
9
|
+
injectedRunner = runner;
|
|
10
|
+
try {
|
|
11
|
+
return await operation();
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
injectedRunner = previous;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function runAutonomousAgent(input) {
|
|
18
|
+
if (injectedRunner) {
|
|
19
|
+
return injectedRunner(input.agent, {
|
|
20
|
+
cwd: input.cwd,
|
|
21
|
+
prompt: input.prompt,
|
|
22
|
+
mode: input.mode,
|
|
23
|
+
...(input.mcpServers ? { mcpServers: input.mcpServers } : {}),
|
|
24
|
+
...(input.logPath ? { logPath: input.logPath } : {}),
|
|
25
|
+
...(input.runtime ? { runtime: input.runtime } : {}),
|
|
26
|
+
...(input.runtimeImage ? { runtimeImage: input.runtimeImage } : {}),
|
|
27
|
+
...(input.runtimeTemplate ? { runtimeTemplate: input.runtimeTemplate } : {}),
|
|
28
|
+
...(input.detach ? { detach: input.detach } : {}),
|
|
29
|
+
...(input.mountPoeCode ? { mountPoeCode: input.mountPoeCode } : {}),
|
|
30
|
+
...(input.runnerSync ? { runnerSync: input.runnerSync } : {})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const spawnArgs = buildSpawnArgs(input.agent, {
|
|
34
|
+
prompt: input.prompt,
|
|
35
|
+
mode: input.mode,
|
|
36
|
+
...(input.mcpServers ? { mcpServers: input.mcpServers } : {})
|
|
37
|
+
});
|
|
38
|
+
const processEnv = spawnArgs.env ? { ...process.env, ...spawnArgs.env } : undefined;
|
|
39
|
+
const argv = [spawnArgs.binaryName, ...spawnArgs.args];
|
|
40
|
+
const logFd = input.logPath ? openSpawnLog(input.logPath) : undefined;
|
|
41
|
+
const execution = resolvePoeCommandExecution({
|
|
42
|
+
cwd: input.cwd ?? process.cwd(),
|
|
43
|
+
env: (processEnv ?? process.env),
|
|
44
|
+
argv,
|
|
45
|
+
tool: input.agent,
|
|
46
|
+
runtime: {
|
|
47
|
+
runtime: input.runtime,
|
|
48
|
+
runtimeImage: input.runtimeImage,
|
|
49
|
+
runtimeTemplate: input.runtimeTemplate,
|
|
50
|
+
detach: input.detach,
|
|
51
|
+
mountPoeCode: input.mountPoeCode,
|
|
52
|
+
runnerSync: input.runnerSync
|
|
53
|
+
},
|
|
54
|
+
openSpec: {
|
|
55
|
+
execution: {
|
|
56
|
+
wrapForLogTee: false,
|
|
57
|
+
stdin: "inherit",
|
|
58
|
+
stdout: "pipe",
|
|
59
|
+
stderr: "pipe",
|
|
60
|
+
env: processEnv,
|
|
61
|
+
captureOutput: true,
|
|
62
|
+
onStdout(chunk) {
|
|
63
|
+
appendSpawnLog(logFd, chunk);
|
|
64
|
+
},
|
|
65
|
+
onStderr(chunk) {
|
|
66
|
+
appendSpawnLog(logFd, chunk);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const result = await runPoeCommand({
|
|
73
|
+
factory: execution.factory,
|
|
74
|
+
openSpec: execution.openSpec,
|
|
75
|
+
detach: execution.detach,
|
|
76
|
+
state: execution.state
|
|
77
|
+
});
|
|
78
|
+
if (result.kind === "detached") {
|
|
79
|
+
return {
|
|
80
|
+
stdout: "",
|
|
81
|
+
...(input.logPath ? { logFile: input.logPath } : {})
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
stdout: result.stdout ?? "",
|
|
86
|
+
...(input.logPath ? { logFile: input.logPath } : {})
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
closeSpawnLog(logFd);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function openSpawnLog(filePath) {
|
|
94
|
+
try {
|
|
95
|
+
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
96
|
+
return openSync(filePath, "a");
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function appendSpawnLog(fd, chunk) {
|
|
103
|
+
if (fd === undefined)
|
|
104
|
+
return;
|
|
105
|
+
try {
|
|
106
|
+
writeSync(fd, chunk);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// logging is best-effort
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function closeSpawnLog(fd) {
|
|
113
|
+
if (fd === undefined)
|
|
114
|
+
return;
|
|
115
|
+
try {
|
|
116
|
+
closeSync(fd);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// logging is best-effort
|
|
120
|
+
}
|
|
121
|
+
}
|