@aiden-ade/sandbox-agent 0.1.6 → 0.1.8
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/aiden-system-prompt.d.ts +6 -0
- package/dist/aiden-system-prompt.d.ts.map +1 -0
- package/dist/aiden-system-prompt.js +6 -0
- package/dist/aiden-system-prompt.js.map +1 -0
- package/dist/core-agent.d.ts +33 -27
- package/dist/core-agent.d.ts.map +1 -1
- package/dist/core-agent.js +137 -216
- package/dist/core-agent.js.map +1 -1
- package/dist/index.cjs +566 -135
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-backends.d.ts +1 -19
- package/dist/runtime-backends.d.ts.map +1 -1
- package/dist/runtime-backends.js +1 -768
- package/dist/runtime-backends.js.map +1 -1
- package/dist/sandbox.d.ts +1 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +69 -53
- package/dist/sandbox.js.map +1 -1
- package/dist/types.d.ts +3 -207
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-presenter.d.ts +18 -2
- package/dist/web-presenter.d.ts.map +1 -1
- package/dist/web-presenter.js +53 -6
- package/dist/web-presenter.js.map +1 -1
- package/dist/ws-client.d.ts +11 -4
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +14 -9
- package/dist/ws-client.js.map +1 -1
- package/package.json +1 -1
- package/dist/updater.d.ts +0 -15
- package/dist/updater.d.ts.map +0 -1
- package/dist/updater.js +0 -50
- package/dist/updater.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiden-system-prompt.d.ts","sourceRoot":"","sources":["../src/aiden-system-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiden-system-prompt.js","sourceRoot":"","sources":["../src/aiden-system-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qBAAqB,CAAC"}
|
package/dist/core-agent.d.ts
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Sandbox CoreAgent — E2B-specific subclass of BaseMachineAgent.
|
|
3
|
+
*
|
|
4
|
+
* Platform responsibilities:
|
|
5
|
+
* - buildCliEnvironment: extend process.env + inject E2B node bin path
|
|
6
|
+
* - buildExtraSystemPromptParts: inject artifact IDs from AIDEN_* env vars
|
|
7
|
+
* - submitAnswer / submitPlanApproval: resolve interactive-tool prompts relayed via WS
|
|
8
|
+
*
|
|
9
|
+
* Everything else (retry loop, system-prompt assembly, backend selection) lives
|
|
10
|
+
* in BaseMachineAgent.
|
|
4
11
|
*/
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
import { BaseMachineAgent, type AgentRuntimeConfig } from "@aiden/agent-core";
|
|
13
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
14
|
+
import type { AgentConfig } from "./types.js";
|
|
15
|
+
export declare class CoreAgent extends BaseMachineAgent {
|
|
16
|
+
private childProcess;
|
|
17
|
+
constructor(presenter: ConstructorParameters<typeof BaseMachineAgent>[0], runtime: AgentRuntimeConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Send a new user message to the CLI's stdin (stream-json format).
|
|
20
|
+
* Used during continuation mode when the CLI process is still alive after
|
|
21
|
+
* completing a turn — the message is processed as the next conversation turn
|
|
22
|
+
* without spawning a new subprocess.
|
|
23
|
+
*/
|
|
24
|
+
sendUserMessage(text: string, images?: Array<{
|
|
25
|
+
data: string;
|
|
26
|
+
mimeType: string;
|
|
27
|
+
}>): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Send a tool_result to the CLI's stdin (stream-json format).
|
|
30
|
+
* Used for interactive tools like AskUserQuestion.
|
|
31
|
+
*/
|
|
32
|
+
sendToolResponse(toolId: string, response: string): boolean;
|
|
33
|
+
protected getOnProcessSpawned(): ((child: ChildProcessWithoutNullStreams) => void) | undefined;
|
|
34
|
+
protected buildCliEnvironment(): Promise<Record<string, string>>;
|
|
35
|
+
protected buildExtraSystemPromptParts(_config: AgentConfig): string[];
|
|
11
36
|
}
|
|
12
|
-
export declare class CoreAgent {
|
|
13
|
-
private presenter;
|
|
14
|
-
private abortController;
|
|
15
|
-
private runtime;
|
|
16
|
-
private pendingQuestionResolvers;
|
|
17
|
-
private pendingPlanApprovalResolvers;
|
|
18
|
-
constructor(presenter: AgentPresenter, runtime: AgentRuntimeConfig);
|
|
19
|
-
submitAnswer(questionId: string, answers: Record<string, string> | null): boolean;
|
|
20
|
-
submitPlanApproval(approvalId: string, approved: boolean): boolean;
|
|
21
|
-
abort(): void;
|
|
22
|
-
private isAbortError;
|
|
23
|
-
private resolveBackendKind;
|
|
24
|
-
private getDefaultSupportTier;
|
|
25
|
-
private buildCliEnvironment;
|
|
26
|
-
private buildRuntimeConfig;
|
|
27
|
-
private runCliBackend;
|
|
28
|
-
run(config: AgentConfig): Promise<AgentResult>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
37
|
//# sourceMappingURL=core-agent.d.ts.map
|
package/dist/core-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-agent.d.ts","sourceRoot":"","sources":["../src/core-agent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"core-agent.d.ts","sourceRoot":"","sources":["../src/core-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,qBAAa,SAAU,SAAQ,gBAAgB;IAC7C,OAAO,CAAC,YAAY,CAA+C;gBAEvD,SAAS,EAAE,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB;IAMrG;;;;;OAKG;IACI,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,OAAO;IAgCjG;;;OAGG;IACI,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAgClE,SAAS,CAAC,mBAAmB,IAAI,CAAC,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,CAAC,GAAG,SAAS;cAO9E,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IA0CtE,SAAS,CAAC,2BAA2B,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,EAAE;CActE"}
|
package/dist/core-agent.js
CHANGED
|
@@ -1,238 +1,159 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Sandbox CoreAgent — E2B-specific subclass of BaseMachineAgent.
|
|
3
|
+
*
|
|
4
|
+
* Platform responsibilities:
|
|
5
|
+
* - buildCliEnvironment: extend process.env + inject E2B node bin path
|
|
6
|
+
* - buildExtraSystemPromptParts: inject artifact IDs from AIDEN_* env vars
|
|
7
|
+
* - submitAnswer / submitPlanApproval: resolve interactive-tool prompts relayed via WS
|
|
8
|
+
*
|
|
9
|
+
* Everything else (retry loop, system-prompt assembly, backend selection) lives
|
|
10
|
+
* in BaseMachineAgent.
|
|
4
11
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const MODE_CONFIG = {
|
|
10
|
-
agent: {},
|
|
11
|
-
plan: {
|
|
12
|
-
systemPromptHint: "You are in plan mode. Focus on analysis, sequencing, and implementation planning rather than making edits.",
|
|
13
|
-
},
|
|
14
|
-
debug: {
|
|
15
|
-
systemPromptHint: "You are in debug mode. Prioritize reproducing the issue, isolating the cause, and validating the fix.",
|
|
16
|
-
},
|
|
17
|
-
ask: {
|
|
18
|
-
systemPromptHint: "You are in ask mode. Stay read-only and explain the code or architecture clearly without changing files.",
|
|
19
|
-
},
|
|
20
|
-
review: {
|
|
21
|
-
systemPromptHint: "You are in review mode. Inspect the changes, identify real issues, and summarize risks and regressions.",
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
const DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
25
|
-
function canonicalizePath(inputPath) {
|
|
26
|
-
try {
|
|
27
|
-
const resolved = resolve(inputPath);
|
|
28
|
-
return existsSync(resolved) ? realpathSync(resolved) : resolved;
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
console.warn("CoreAgent", "Failed to canonicalize path", { inputPath, error });
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function buildPromptWithFiles(task, files) {
|
|
36
|
-
if (!files || files.length === 0) {
|
|
37
|
-
return task;
|
|
38
|
-
}
|
|
39
|
-
const fileList = files.map((file) => `- ${file.filename} (${file.label}): ${file.tempPath}`).join("\n");
|
|
40
|
-
return `${task}
|
|
41
|
-
|
|
42
|
-
The user has attached the following files. You can read them using your available tools:
|
|
43
|
-
${fileList}`;
|
|
44
|
-
}
|
|
45
|
-
export class CoreAgent {
|
|
46
|
-
presenter;
|
|
47
|
-
abortController = null;
|
|
48
|
-
runtime;
|
|
49
|
-
pendingQuestionResolvers = new Map();
|
|
50
|
-
pendingPlanApprovalResolvers = new Map();
|
|
12
|
+
import { BaseMachineAgent } from "@aiden/agent-core";
|
|
13
|
+
import { accessSync, chmodSync, constants as fsConstants, statSync } from "node:fs";
|
|
14
|
+
export class CoreAgent extends BaseMachineAgent {
|
|
15
|
+
childProcess = null;
|
|
51
16
|
constructor(presenter, runtime) {
|
|
52
|
-
|
|
53
|
-
this.runtime = runtime;
|
|
17
|
+
super(presenter, runtime);
|
|
54
18
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
19
|
+
// ── Interactive tool response / continuation user message (WS relay → stdin) ──
|
|
20
|
+
/**
|
|
21
|
+
* Send a new user message to the CLI's stdin (stream-json format).
|
|
22
|
+
* Used during continuation mode when the CLI process is still alive after
|
|
23
|
+
* completing a turn — the message is processed as the next conversation turn
|
|
24
|
+
* without spawning a new subprocess.
|
|
25
|
+
*/
|
|
26
|
+
sendUserMessage(text, images) {
|
|
27
|
+
if (!this.childProcess)
|
|
58
28
|
return false;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
submitPlanApproval(approvalId, approved) {
|
|
64
|
-
const resolver = this.pendingPlanApprovalResolvers.get(approvalId);
|
|
65
|
-
if (!resolver)
|
|
29
|
+
const stdin = this.childProcess.stdin;
|
|
30
|
+
if (!stdin || stdin.destroyed)
|
|
66
31
|
return false;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
32
|
+
try {
|
|
33
|
+
const contentBlocks = [];
|
|
34
|
+
if (images && images.length > 0) {
|
|
35
|
+
for (const img of images) {
|
|
36
|
+
contentBlocks.push({
|
|
37
|
+
type: "image",
|
|
38
|
+
source: { type: "base64", media_type: img.mimeType, data: img.data },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
contentBlocks.push({ type: "text", text });
|
|
43
|
+
const message = JSON.stringify({
|
|
44
|
+
type: "user",
|
|
45
|
+
message: { role: "user", content: contentBlocks },
|
|
46
|
+
session_id: "default",
|
|
47
|
+
parent_tool_use_id: null,
|
|
48
|
+
});
|
|
49
|
+
stdin.write(message + "\n");
|
|
50
|
+
console.info("[CoreAgent] Sent user message to CLI stdin (continuation mode)");
|
|
76
51
|
return true;
|
|
77
52
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
message.includes("canceled"));
|
|
83
|
-
}
|
|
84
|
-
resolveBackendKind(config) {
|
|
85
|
-
return this.runtime.backendKind || config.backendKind || "claude_cli";
|
|
53
|
+
catch (err) {
|
|
54
|
+
console.error("[CoreAgent] Failed to write user message to stdin", err);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
86
57
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Send a tool_result to the CLI's stdin (stream-json format).
|
|
60
|
+
* Used for interactive tools like AskUserQuestion.
|
|
61
|
+
*/
|
|
62
|
+
sendToolResponse(toolId, response) {
|
|
63
|
+
if (!this.childProcess)
|
|
64
|
+
return false;
|
|
65
|
+
const stdin = this.childProcess.stdin;
|
|
66
|
+
if (!stdin || stdin.destroyed)
|
|
67
|
+
return false;
|
|
68
|
+
try {
|
|
69
|
+
const message = JSON.stringify({
|
|
70
|
+
type: "user",
|
|
71
|
+
message: {
|
|
72
|
+
role: "user",
|
|
73
|
+
content: [
|
|
74
|
+
{
|
|
75
|
+
type: "tool_result",
|
|
76
|
+
tool_use_id: toolId,
|
|
77
|
+
content: response,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
session_id: "default",
|
|
82
|
+
parent_tool_use_id: null,
|
|
83
|
+
});
|
|
84
|
+
stdin.write(message + "\n");
|
|
85
|
+
console.info(`[CoreAgent] Sent tool_response for tool ${toolId}`);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
console.error("[CoreAgent] Failed to write tool_response to stdin", err);
|
|
90
|
+
return false;
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
|
-
|
|
93
|
+
// ── BaseMachineAgent hooks ─────────────────────────────────────────────
|
|
94
|
+
getOnProcessSpawned() {
|
|
95
|
+
return (child) => {
|
|
96
|
+
this.childProcess = child;
|
|
97
|
+
child.on("exit", () => { this.childProcess = null; });
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async buildCliEnvironment() {
|
|
99
101
|
const loginEnv = process.env;
|
|
100
102
|
const env = {};
|
|
101
103
|
for (const [key, value] of Object.entries(loginEnv)) {
|
|
102
|
-
if (value !== undefined)
|
|
104
|
+
if (value !== undefined)
|
|
103
105
|
env[key] = value;
|
|
106
|
+
}
|
|
107
|
+
// Guarantee CLI runtime bin dirs are in PATH regardless of how the agent
|
|
108
|
+
// was launched. Uses HOME from the inherited env so this works for both
|
|
109
|
+
// E2B (/home/user) and Daytona (/home/daytona) without hardcoding.
|
|
110
|
+
const home = env.HOME ?? "/home/user";
|
|
111
|
+
const extraPaths = [`${home}/.local/node/bin`, `${home}/.local/bin`];
|
|
112
|
+
const basePath = env.PATH ?? "";
|
|
113
|
+
const existingSegments = new Set(basePath.split(":").filter(Boolean));
|
|
114
|
+
const missing = extraPaths.filter((p) => !existingSegments.has(p));
|
|
115
|
+
env.PATH = missing.length > 0 ? `${missing.join(":")}:${basePath}` : basePath;
|
|
116
|
+
// Guard: ensure the CLI runtime binary has its execute bit set.
|
|
117
|
+
// On long-lived sandboxes the file can lose +x (e.g. npm overwrote it
|
|
118
|
+
// without preserving permissions, or a stray chmod was run during setup).
|
|
119
|
+
// We attempt to fix it silently so the agent can always start.
|
|
120
|
+
for (const dir of extraPaths) {
|
|
121
|
+
for (const bin of ["claude", "codex", "gemini"]) {
|
|
122
|
+
const binPath = `${dir}/${bin}`;
|
|
123
|
+
try {
|
|
124
|
+
const stat = statSync(binPath);
|
|
125
|
+
// Check owner-execute bit (0o100). If missing, add +x for owner/group/other.
|
|
126
|
+
if (!(stat.mode & 0o100)) {
|
|
127
|
+
chmodSync(binPath, stat.mode | 0o111);
|
|
128
|
+
console.info(`[CoreAgent] Restored execute permission on ${binPath}`);
|
|
129
|
+
}
|
|
130
|
+
// Verify we can actually execute it now
|
|
131
|
+
accessSync(binPath, fsConstants.X_OK);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// File doesn't exist or chmod failed — not a fatal error, let the
|
|
135
|
+
// backend surface a clear message if this binary is actually needed.
|
|
136
|
+
}
|
|
104
137
|
}
|
|
105
138
|
}
|
|
106
|
-
env.PATH = `/home/user/.local/node/bin:${env.PATH ?? ""}`;
|
|
107
139
|
return env;
|
|
108
140
|
}
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
...config,
|
|
128
|
-
backendKind,
|
|
129
|
-
supportTier,
|
|
130
|
-
runtimeCommand: config.runtimeCommand || this.runtime.runtimeCommand,
|
|
131
|
-
runtimeArgs: config.runtimeArgs || this.runtime.runtimeArgs,
|
|
132
|
-
selectedModel: config.selectedModel || DEFAULT_MODEL,
|
|
133
|
-
systemPrompt: systemPromptParts.join("\n\n") || undefined,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
async runCliBackend(config, safeProjectPath) {
|
|
137
|
-
const backendKind = this.resolveBackendKind(config);
|
|
138
|
-
const defaultCwd = join(homedir(), "Documents", "aiden");
|
|
139
|
-
if (!existsSync(defaultCwd)) {
|
|
140
|
-
mkdirSync(defaultCwd, { recursive: true });
|
|
141
|
-
}
|
|
142
|
-
const runtimeConfig = await this.buildRuntimeConfig(config, safeProjectPath);
|
|
143
|
-
const cwd = runtimeConfig.worktreePath || safeProjectPath || runtimeConfig.cwd || defaultCwd;
|
|
144
|
-
const promptText = buildPromptWithFiles(runtimeConfig.task, runtimeConfig.files);
|
|
145
|
-
const env = this.buildCliEnvironment();
|
|
146
|
-
const runtimeCommand = runtimeConfig.runtimeCommand || this.runtime.runtimeCommand;
|
|
147
|
-
const runtimeArgs = runtimeConfig.runtimeArgs || this.runtime.runtimeArgs || [];
|
|
148
|
-
const backend = backendKind === "claude_cli"
|
|
149
|
-
? createClaudeCliBackend(runtimeCommand || "claude", runtimeArgs)
|
|
150
|
-
: backendKind === "codex_app_server"
|
|
151
|
-
? createCodexRuntimeBackend(runtimeCommand || "codex", runtimeArgs)
|
|
152
|
-
: backendKind === "gemini_cli"
|
|
153
|
-
? createGeminiCliBackend(runtimeCommand || "gemini", runtimeArgs)
|
|
154
|
-
: createGenericCliPassthroughBackend(runtimeCommand || "generic-cli", runtimeArgs);
|
|
155
|
-
const result = await backend.run({
|
|
156
|
-
presenter: this.presenter,
|
|
157
|
-
config: runtimeConfig,
|
|
158
|
-
abortController: this.abortController,
|
|
159
|
-
cwd,
|
|
160
|
-
env,
|
|
161
|
-
promptText,
|
|
162
|
-
});
|
|
163
|
-
const normalizedResult = {
|
|
164
|
-
...result,
|
|
165
|
-
backendKind: backend.kind,
|
|
166
|
-
supportTier: backend.supportTier,
|
|
167
|
-
runtimeSessionId: result.runtimeSessionId || result.providerSessionId,
|
|
168
|
-
providerSessionId: result.providerSessionId || result.runtimeSessionId,
|
|
169
|
-
};
|
|
170
|
-
this.presenter.onComplete(normalizedResult);
|
|
171
|
-
return normalizedResult;
|
|
172
|
-
}
|
|
173
|
-
async run(config) {
|
|
174
|
-
this.abortController = new AbortController();
|
|
175
|
-
const backendKind = this.resolveBackendKind(config);
|
|
176
|
-
const supportTier = config.supportTier || this.getDefaultSupportTier(backendKind);
|
|
177
|
-
const initialConfig = {
|
|
178
|
-
...config,
|
|
179
|
-
backendKind,
|
|
180
|
-
supportTier,
|
|
181
|
-
runtimeCommand: config.runtimeCommand || this.runtime.runtimeCommand,
|
|
182
|
-
runtimeArgs: config.runtimeArgs || this.runtime.runtimeArgs,
|
|
183
|
-
};
|
|
184
|
-
this.presenter.onStart(initialConfig);
|
|
185
|
-
let safeProjectPath = initialConfig.projectPath;
|
|
186
|
-
if (initialConfig.projectPath) {
|
|
187
|
-
const canonicalized = canonicalizePath(initialConfig.projectPath);
|
|
188
|
-
if (canonicalized) {
|
|
189
|
-
safeProjectPath = canonicalized;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (safeProjectPath && !existsSync(safeProjectPath)) {
|
|
193
|
-
const message = `Project path no longer exists: "${safeProjectPath}". ` +
|
|
194
|
-
"Please update the project's local path in project settings before running the agent.";
|
|
195
|
-
this.presenter.onError(message, true);
|
|
196
|
-
const result = {
|
|
197
|
-
success: false,
|
|
198
|
-
summary: message,
|
|
199
|
-
filesModified: [],
|
|
200
|
-
planFilesCreated: [],
|
|
201
|
-
iterations: 0,
|
|
202
|
-
error: message,
|
|
203
|
-
backendKind,
|
|
204
|
-
supportTier,
|
|
205
|
-
};
|
|
206
|
-
this.presenter.onComplete(result);
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
return await this.runCliBackend(initialConfig, safeProjectPath);
|
|
211
|
-
}
|
|
212
|
-
catch (error) {
|
|
213
|
-
const interrupted = this.isAbortError(error);
|
|
214
|
-
const message = interrupted
|
|
215
|
-
? "Interrupted by user"
|
|
216
|
-
: error instanceof Error
|
|
217
|
-
? error.message
|
|
218
|
-
: String(error);
|
|
219
|
-
if (!interrupted) {
|
|
220
|
-
console.error("CoreAgent", "CLI runtime failed", error);
|
|
221
|
-
this.presenter.onError(message, true);
|
|
222
|
-
}
|
|
223
|
-
const result = {
|
|
224
|
-
success: false,
|
|
225
|
-
summary: message,
|
|
226
|
-
filesModified: [],
|
|
227
|
-
planFilesCreated: [],
|
|
228
|
-
iterations: 0,
|
|
229
|
-
error: message,
|
|
230
|
-
backendKind,
|
|
231
|
-
supportTier,
|
|
232
|
-
};
|
|
233
|
-
this.presenter.onComplete(result);
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
141
|
+
buildExtraSystemPromptParts(_config) {
|
|
142
|
+
const artifactIds = [];
|
|
143
|
+
const envTaskId = process.env.AIDEN_TASK_ID;
|
|
144
|
+
const envSessionId = process.env.AIDEN_SESSION_ID;
|
|
145
|
+
if (envTaskId)
|
|
146
|
+
artifactIds.push(`- taskId: "${envTaskId}"`);
|
|
147
|
+
if (envSessionId)
|
|
148
|
+
artifactIds.push(`- conversationId: "${envSessionId}"`);
|
|
149
|
+
if (artifactIds.length === 0)
|
|
150
|
+
return [];
|
|
151
|
+
return [
|
|
152
|
+
[
|
|
153
|
+
"When creating artifacts using MCP tools (create_plan, create_document_artifact, create_test_report), always pass these IDs:",
|
|
154
|
+
...artifactIds,
|
|
155
|
+
].join("\n"),
|
|
156
|
+
];
|
|
236
157
|
}
|
|
237
158
|
}
|
|
238
159
|
//# sourceMappingURL=core-agent.js.map
|
package/dist/core-agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-agent.js","sourceRoot":"","sources":["../src/core-agent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"core-agent.js","sourceRoot":"","sources":["../src/core-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIpF,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IACrC,YAAY,GAA0C,IAAI,CAAC;IAEnE,YAAY,SAA4D,EAAE,OAA2B;QACnG,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,iFAAiF;IAEjF;;;;;O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