@aiden-ade/sandbox-agent 0.1.16 → 0.1.18
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/index.cjs +520 -109
- package/dist/updater.d.ts.map +1 -1
- package/dist/updater.js +4 -0
- package/dist/updater.js.map +1 -1
- package/package.json +3 -3
- package/dist/aiden-system-prompt.d.ts +0 -6
- package/dist/aiden-system-prompt.d.ts.map +0 -1
- package/dist/aiden-system-prompt.js +0 -6
- package/dist/aiden-system-prompt.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3404,7 +3404,7 @@ var require_websocket = __commonJS({
|
|
|
3404
3404
|
var http2 = require("http");
|
|
3405
3405
|
var net = require("net");
|
|
3406
3406
|
var tls = require("tls");
|
|
3407
|
-
var { randomBytes: randomBytes2, createHash:
|
|
3407
|
+
var { randomBytes: randomBytes2, createHash: createHash3 } = require("crypto");
|
|
3408
3408
|
var { Duplex, Readable } = require("stream");
|
|
3409
3409
|
var { URL } = require("url");
|
|
3410
3410
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -4061,7 +4061,7 @@ var require_websocket = __commonJS({
|
|
|
4061
4061
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
4062
4062
|
return;
|
|
4063
4063
|
}
|
|
4064
|
-
const digest =
|
|
4064
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
4065
4065
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
4066
4066
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
4067
4067
|
return;
|
|
@@ -4428,7 +4428,7 @@ var require_websocket_server = __commonJS({
|
|
|
4428
4428
|
var EventEmitter = require("events");
|
|
4429
4429
|
var http2 = require("http");
|
|
4430
4430
|
var { Duplex } = require("stream");
|
|
4431
|
-
var { createHash:
|
|
4431
|
+
var { createHash: createHash3 } = require("crypto");
|
|
4432
4432
|
var extension = require_extension();
|
|
4433
4433
|
var PerMessageDeflate = require_permessage_deflate();
|
|
4434
4434
|
var subprotocol = require_subprotocol();
|
|
@@ -4725,7 +4725,7 @@ var require_websocket_server = __commonJS({
|
|
|
4725
4725
|
);
|
|
4726
4726
|
}
|
|
4727
4727
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
4728
|
-
const digest =
|
|
4728
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
4729
4729
|
const headers = [
|
|
4730
4730
|
"HTTP/1.1 101 Switching Protocols",
|
|
4731
4731
|
"Upgrade: websocket",
|
|
@@ -4814,32 +4814,25 @@ var require_websocket_server = __commonJS({
|
|
|
4814
4814
|
var import_child_process = require("child_process");
|
|
4815
4815
|
|
|
4816
4816
|
// ../shared/dist/agent/agent-definitions.js
|
|
4817
|
-
var COORDINATOR_PROMPT = `## You are the
|
|
4817
|
+
var COORDINATOR_PROMPT = `## You are the Orchestrator
|
|
4818
4818
|
|
|
4819
|
-
You are the **
|
|
4819
|
+
You are the **Orchestrator** for this task. When asked "who are you?", "what agent are you?", "are you the coordinator?", "are you the orchestrator?", or anything similar \u2014 identify yourself plainly as the Orchestrator for this task. Do not say "I'm Aiden" alone; say "I'm the Orchestrator (an Aiden agent profile) for this task."
|
|
4820
4820
|
|
|
4821
|
-
Your primary job is orchestration
|
|
4821
|
+
Your primary job is orchestration: understand the task, choose the next unit of work, keep context current, and decide whether to act directly or delegate to a specialist.
|
|
4822
4822
|
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
You MUST NOT call these tools:
|
|
4826
|
-
- \`Edit\`, \`Write\`, \`MultiEdit\`, \`NotebookEdit\` \u2014 any file modification
|
|
4827
|
-
- \`Bash\` for state-mutating commands (git commits, builds, installs, tests, file writes, deploys)
|
|
4828
|
-
|
|
4829
|
-
If the user asks for a code change, a build, a test run, a deploy, or anything that mutates state \u2014 STOP. **Delegate it** via \`start_task_session\` to the right specialist agent.
|
|
4830
|
-
|
|
4831
|
-
Read-only inspection is fine: \`Read\`, \`Glob\`, \`Grep\`, and \`Bash\` for read commands like \`ls\`, \`git status\`, \`git log\`, \`cat\`, \`pwd\`.
|
|
4823
|
+
You may inspect, edit, run commands, create artifacts, and use MCP tools when that is the smallest coherent way to move the task forward. Delegate via \`delegate_task_session\` when a specialist or parallel worker is genuinely useful, not because the coordinator profile is blocked from doing the work. Use \`start_task_session\` only as a force-new escape hatch when reuse is explicitly wrong.
|
|
4832
4824
|
|
|
4833
4825
|
## Your primary tools
|
|
4834
4826
|
|
|
4835
4827
|
Use these tools, in roughly this order of frequency:
|
|
4836
|
-
1. \`
|
|
4828
|
+
1. \`delegate_task_session\` \u2014 route work to a specialist, reusing active matching workers by default
|
|
4837
4829
|
2. \`get_task_memory\` / \`update_task_memory\` \u2014 keep the task-level working memory current
|
|
4838
4830
|
3. \`list_subtasks\` / \`create_subtask\` / \`update_subtask\` \u2014 keep task breakdown current
|
|
4839
4831
|
4. \`get_session_context\` \u2014 check what a worker accomplished
|
|
4840
4832
|
5. \`update_task\` \u2014 keep status, priority, labels current
|
|
4841
|
-
6. \`
|
|
4842
|
-
7. \`
|
|
4833
|
+
6. \`send_session_message\` / \`start_task_session\` \u2014 continue a specific session or force a new session only when needed
|
|
4834
|
+
7. \`list_sessions\` / \`search\` / \`Read\` / \`Glob\` / \`Grep\` \u2014 situational awareness
|
|
4835
|
+
8. \`add_task_comment\` / \`create_plan\` \u2014 document decisions and plans
|
|
4843
4836
|
|
|
4844
4837
|
## How to scale work
|
|
4845
4838
|
|
|
@@ -4857,9 +4850,11 @@ A two-line change does not need its own session. A well-scoped subtask can often
|
|
|
4857
4850
|
- **PM Agent** \u2014 product questions, requirements, scope definition, PRD creation
|
|
4858
4851
|
- **General Agent** \u2014 only when no specialist fits
|
|
4859
4852
|
|
|
4860
|
-
## How to
|
|
4853
|
+
## How to delegate
|
|
4861
4854
|
|
|
4862
|
-
|
|
4855
|
+
Before creating any worker, check task memory and active sessions for a matching agent/workstream. Reuse the owning worker with \`delegate_task_session\` unless \`force_new\` is explicit or the workstream is intentionally independent.
|
|
4856
|
+
|
|
4857
|
+
Every \`delegate_task_session\` message must include all four of these:
|
|
4863
4858
|
1. **Objective** \u2014 what to do, in one clear sentence
|
|
4864
4859
|
2. **Relevant context** \u2014 which files, APIs, or prior session results matter
|
|
4865
4860
|
3. **Constraints** \u2014 what not to change, patterns to match, things already tried
|
|
@@ -4871,10 +4866,10 @@ Write it like a senior engineer's handoff note, not a vague request.
|
|
|
4871
4866
|
|
|
4872
4867
|
1. Read the task, current subtasks, recent sessions \u2014 understand state before acting.
|
|
4873
4868
|
2. Decide the next concrete unit of work. Break it down when scope is wide; keep subtasks current.
|
|
4874
|
-
3. **Either** delegate via \`
|
|
4875
|
-
4. After delegation,
|
|
4869
|
+
3. **Either** delegate via \`delegate_task_session\`, **or** create/update a subtask, **or** ask the user a single targeted question if scope is ambiguous.
|
|
4870
|
+
4. After delegation, track results via \`get_session_context\`, persist summaries/outcomes via \`update_task_memory\`, integrate status, decide the next move.
|
|
4876
4871
|
|
|
4877
|
-
You are read-only
|
|
4872
|
+
You are coordination-first, not read-only. Use judgment: act directly for focused work, delegate when coordination creates leverage.`;
|
|
4878
4873
|
var PM_PROMPT = `## You are the PM Agent
|
|
4879
4874
|
|
|
4880
4875
|
You are the **PM Agent** (Product Manager) for this task. When identifying yourself, say "I'm the PM Agent (an Aiden agent profile)."
|
|
@@ -4913,7 +4908,7 @@ Use these tools, in roughly this order of frequency:
|
|
|
4913
4908
|
|
|
4914
4909
|
- **Implementor** \u2014 any code change: features, fixes, data, API, UI, tests
|
|
4915
4910
|
- **Designer** \u2014 interaction, layout, accessibility, visual design
|
|
4916
|
-
- **
|
|
4911
|
+
- **Orchestrator** \u2014 multi-agent orchestration where the work is complex enough to need coordination
|
|
4917
4912
|
- **General Agent** \u2014 research, investigation, or work that doesn't fit a specialist
|
|
4918
4913
|
|
|
4919
4914
|
## How to write a kickoff message
|
|
@@ -4947,6 +4942,25 @@ Non-trivial implementations include tests. Break and plan before building when s
|
|
|
4947
4942
|
- Files changed, if any
|
|
4948
4943
|
- How you validated the result
|
|
4949
4944
|
- Any residual risk or open question`;
|
|
4945
|
+
var REVIEW_PROMPT = `## You are the Review Agent
|
|
4946
|
+
|
|
4947
|
+
You are the **Review Agent** (an Aiden agent profile) for pull request review sessions. When identifying yourself, say "I'm the Review Agent."
|
|
4948
|
+
|
|
4949
|
+
Your job is to inspect the pull request context, reason about correctness and risk, and help the user review the change. Prefer concrete findings tied to files, lines, tests, and behavior. Do not send a review verdict until you have enough evidence.
|
|
4950
|
+
|
|
4951
|
+
## How to review
|
|
4952
|
+
|
|
4953
|
+
1. Understand the PR goal, linked task context, changed files, and current checks.
|
|
4954
|
+
2. Prioritize correctness, regressions, data loss, security, migration risk, and missing tests.
|
|
4955
|
+
3. Reuse available contextual comments, file diffs, task metadata, and session history before asking for more context.
|
|
4956
|
+
4. Report findings clearly, ordered by severity. If there are no blocking findings, say that and call out residual test gaps.
|
|
4957
|
+
|
|
4958
|
+
## Rules
|
|
4959
|
+
|
|
4960
|
+
- Do not invent changed files, test results, or PR metadata.
|
|
4961
|
+
- Keep feedback actionable and scoped to this PR.
|
|
4962
|
+
- Prefer short review comments over broad commentary.
|
|
4963
|
+
- Ask one targeted question only when evidence is missing and blocks a useful review.`;
|
|
4950
4964
|
var IMPLEMENTOR_PROMPT = `## You are the Implementor Agent
|
|
4951
4965
|
|
|
4952
4966
|
You are a senior implementation agent responsible for end-to-end code delivery. When identifying yourself, say "I'm the Implementor Agent (an Aiden agent profile)."
|
|
@@ -4983,6 +4997,10 @@ var DESIGNER_PROMPT = `## You are the Designer Agent
|
|
|
4983
4997
|
|
|
4984
4998
|
You are a product UI designer and frontend interaction specialist. When identifying yourself, say "I'm the Designer Agent (an Aiden agent profile)."
|
|
4985
4999
|
|
|
5000
|
+
## Taste Skill (premium frontends)
|
|
5001
|
+
|
|
5002
|
+
For landing pages, marketing sites, portfolios, or visual redesigns outside the core product shell, read and follow the \`design-taste-frontend\` skill in \`.agents/skills/\` before writing UI. Related vendored skills: \`redesign-existing-projects\` (existing codebases), \`minimalist-ui\`, \`high-end-visual-design\`, \`industrial-brutalist-ui\`. Sync from upstream with \`scripts/sync-taste-skills.sh\`.
|
|
5003
|
+
|
|
4986
5004
|
## How to approach the work
|
|
4987
5005
|
|
|
4988
5006
|
1. Think from the user's task flow before touching layout. What is the user trying to do?
|
|
@@ -5020,14 +5038,14 @@ You are a product UI designer and frontend interaction specialist. When identify
|
|
|
5020
5038
|
var BUILTIN_AGENT_DEFINITIONS = [
|
|
5021
5039
|
{
|
|
5022
5040
|
id: "coordinator",
|
|
5023
|
-
name: "
|
|
5024
|
-
description: "Plans work, breaks down tasks,
|
|
5041
|
+
name: "Orchestrator",
|
|
5042
|
+
description: "Plans work, breaks down tasks, orchestrates agents",
|
|
5025
5043
|
iconKey: "command",
|
|
5026
5044
|
defaultMode: "agent",
|
|
5027
5045
|
capabilities: {
|
|
5028
|
-
canEditFiles:
|
|
5029
|
-
canRunCommands:
|
|
5030
|
-
canCreateArtifacts:
|
|
5046
|
+
canEditFiles: true,
|
|
5047
|
+
canRunCommands: true,
|
|
5048
|
+
canCreateArtifacts: true,
|
|
5031
5049
|
canStartSessions: true,
|
|
5032
5050
|
canManageSubtasks: true
|
|
5033
5051
|
},
|
|
@@ -5048,6 +5066,21 @@ var BUILTIN_AGENT_DEFINITIONS = [
|
|
|
5048
5066
|
},
|
|
5049
5067
|
systemPrompt: GENERAL_PROMPT
|
|
5050
5068
|
},
|
|
5069
|
+
{
|
|
5070
|
+
id: "pr-reviewer",
|
|
5071
|
+
name: "Review Agent",
|
|
5072
|
+
description: "Reviews pull requests and surfaces risks",
|
|
5073
|
+
iconKey: "search-code",
|
|
5074
|
+
defaultMode: "review",
|
|
5075
|
+
capabilities: {
|
|
5076
|
+
canEditFiles: false,
|
|
5077
|
+
canRunCommands: true,
|
|
5078
|
+
canCreateArtifacts: true,
|
|
5079
|
+
canStartSessions: false,
|
|
5080
|
+
canManageSubtasks: false
|
|
5081
|
+
},
|
|
5082
|
+
systemPrompt: REVIEW_PROMPT
|
|
5083
|
+
},
|
|
5051
5084
|
{
|
|
5052
5085
|
id: "pm",
|
|
5053
5086
|
name: "PM Agent",
|
|
@@ -5100,7 +5133,6 @@ var LEGACY_AGENT_ID_ALIASES = {
|
|
|
5100
5133
|
developer: "implementor",
|
|
5101
5134
|
implementer: "implementor",
|
|
5102
5135
|
"ui-designer": "designer",
|
|
5103
|
-
"pr-reviewer": "general",
|
|
5104
5136
|
verifier: "general"
|
|
5105
5137
|
};
|
|
5106
5138
|
function normalizeBuiltinAgentId(agentId) {
|
|
@@ -5202,12 +5234,11 @@ function getAidenAgentPrompt(agentId) {
|
|
|
5202
5234
|
var SESSION_RESUME_FAILED_MESSAGE = "Session resume failed. The previous session may have expired or is no longer available. Please start a new session.";
|
|
5203
5235
|
|
|
5204
5236
|
// ../agent-core/dist/index.js
|
|
5237
|
+
var import_crypto = require("crypto");
|
|
5205
5238
|
var import_fs = require("fs");
|
|
5206
5239
|
var import_os = require("os");
|
|
5207
5240
|
var import_path = require("path");
|
|
5208
|
-
var import_crypto = require("crypto");
|
|
5209
5241
|
var import_fs2 = require("fs");
|
|
5210
|
-
var import_fs3 = require("fs");
|
|
5211
5242
|
var import_os2 = require("os");
|
|
5212
5243
|
var import_path2 = require("path");
|
|
5213
5244
|
var import_readline = require("readline");
|
|
@@ -5240,9 +5271,12 @@ var DEFAULT_TEAM_STATUSES = STATUS_OPTIONS.map((o) => ({
|
|
|
5240
5271
|
}));
|
|
5241
5272
|
|
|
5242
5273
|
// ../agent-core/dist/index.js
|
|
5243
|
-
var
|
|
5274
|
+
var import_fs3 = require("fs");
|
|
5244
5275
|
var import_os3 = require("os");
|
|
5245
5276
|
var import_path3 = require("path");
|
|
5277
|
+
var import_fs4 = require("fs");
|
|
5278
|
+
var import_os4 = require("os");
|
|
5279
|
+
var import_path4 = require("path");
|
|
5246
5280
|
function isLikelyProviderAuthError(stderr) {
|
|
5247
5281
|
const lower = stderr.toLowerCase();
|
|
5248
5282
|
return lower.includes("api key") || lower.includes("api_key") || lower.includes("invalid api key") || lower.includes("api key invalid") || lower.includes("unauthorized") || lower.includes("authentication failed") || lower.includes("authentication error") || lower.includes("provider settings") || lower.includes("invalid token") || lower.includes("token expired");
|
|
@@ -5376,6 +5410,7 @@ function normalizeCodexMcpToolResult(output) {
|
|
|
5376
5410
|
}
|
|
5377
5411
|
return raw;
|
|
5378
5412
|
}
|
|
5413
|
+
var MAX_INLINE_GENERATED_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
5379
5414
|
function findCodexSessionLog(runtimeSessionId, codexHome) {
|
|
5380
5415
|
if (!runtimeSessionId || !(0, import_fs.existsSync)(codexHome)) return null;
|
|
5381
5416
|
const root = (0, import_path.join)(codexHome, "sessions");
|
|
@@ -5406,14 +5441,106 @@ function findCodexSessionLog(runtimeSessionId, codexHome) {
|
|
|
5406
5441
|
matches.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
5407
5442
|
return matches[0]?.path ?? null;
|
|
5408
5443
|
}
|
|
5444
|
+
function inferImageMimeType(buffer) {
|
|
5445
|
+
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) {
|
|
5446
|
+
return "image/png";
|
|
5447
|
+
}
|
|
5448
|
+
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
|
|
5449
|
+
return "image/jpeg";
|
|
5450
|
+
}
|
|
5451
|
+
if (buffer.length >= 6 && (buffer.toString("ascii", 0, 6) === "GIF87a" || buffer.toString("ascii", 0, 6) === "GIF89a")) {
|
|
5452
|
+
return "image/gif";
|
|
5453
|
+
}
|
|
5454
|
+
if (buffer.length >= 12 && buffer.toString("ascii", 0, 4) === "RIFF" && buffer.toString("ascii", 8, 12) === "WEBP") {
|
|
5455
|
+
return "image/webp";
|
|
5456
|
+
}
|
|
5457
|
+
return null;
|
|
5458
|
+
}
|
|
5459
|
+
function extensionForMimeType(mimeType) {
|
|
5460
|
+
switch (mimeType) {
|
|
5461
|
+
case "image/jpeg":
|
|
5462
|
+
return "jpg";
|
|
5463
|
+
case "image/gif":
|
|
5464
|
+
return "gif";
|
|
5465
|
+
case "image/webp":
|
|
5466
|
+
return "webp";
|
|
5467
|
+
case "image/png":
|
|
5468
|
+
default:
|
|
5469
|
+
return "png";
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
function readImageDimensions(buffer, mimeType) {
|
|
5473
|
+
if (mimeType === "image/png" && buffer.length >= 24) {
|
|
5474
|
+
return { width: buffer.readUInt32BE(16), height: buffer.readUInt32BE(20) };
|
|
5475
|
+
}
|
|
5476
|
+
if (mimeType === "image/gif" && buffer.length >= 10) {
|
|
5477
|
+
return { width: buffer.readUInt16LE(6), height: buffer.readUInt16LE(8) };
|
|
5478
|
+
}
|
|
5479
|
+
if (mimeType === "image/jpeg" && buffer.length > 4) {
|
|
5480
|
+
let offset = 2;
|
|
5481
|
+
while (offset + 9 < buffer.length) {
|
|
5482
|
+
if (buffer[offset] !== 255) break;
|
|
5483
|
+
const marker = buffer[offset + 1];
|
|
5484
|
+
const length = buffer.readUInt16BE(offset + 2);
|
|
5485
|
+
if (length < 2) break;
|
|
5486
|
+
if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker)) {
|
|
5487
|
+
return {
|
|
5488
|
+
width: buffer.readUInt16BE(offset + 7),
|
|
5489
|
+
height: buffer.readUInt16BE(offset + 5)
|
|
5490
|
+
};
|
|
5491
|
+
}
|
|
5492
|
+
offset += 2 + length;
|
|
5493
|
+
}
|
|
5494
|
+
}
|
|
5495
|
+
return { width: null, height: null };
|
|
5496
|
+
}
|
|
5497
|
+
function buildGeneratedImageFromCodexPayload(payload) {
|
|
5498
|
+
const data = typeof payload.result === "string" ? payload.result : "";
|
|
5499
|
+
if (!data) return null;
|
|
5500
|
+
const buffer = Buffer.from(data, "base64");
|
|
5501
|
+
if (buffer.length <= 0 || buffer.length > MAX_INLINE_GENERATED_IMAGE_BYTES) return null;
|
|
5502
|
+
const mimeType = inferImageMimeType(buffer);
|
|
5503
|
+
if (!mimeType) return null;
|
|
5504
|
+
const callId = typeof payload.call_id === "string" && payload.call_id ? payload.call_id : void 0;
|
|
5505
|
+
const imageId = (0, import_crypto.randomUUID)();
|
|
5506
|
+
const { width, height } = readImageDimensions(buffer, mimeType);
|
|
5507
|
+
return {
|
|
5508
|
+
type: "generated_image",
|
|
5509
|
+
id: imageId,
|
|
5510
|
+
filename: `${callId ?? imageId}.${extensionForMimeType(mimeType)}`,
|
|
5511
|
+
mimeType,
|
|
5512
|
+
size: buffer.length,
|
|
5513
|
+
width,
|
|
5514
|
+
height,
|
|
5515
|
+
data: buffer.toString("base64"),
|
|
5516
|
+
sourceHash: (0, import_crypto.createHash)("sha256").update(buffer).digest("hex"),
|
|
5517
|
+
...callId ? { toolId: callId } : {},
|
|
5518
|
+
ts: Date.now()
|
|
5519
|
+
};
|
|
5520
|
+
}
|
|
5521
|
+
function latestUserMessageLineIndex(lines) {
|
|
5522
|
+
let latestIndex = -1;
|
|
5523
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
5524
|
+
const line = lines[index];
|
|
5525
|
+
if (!line) continue;
|
|
5526
|
+
const entry = parseJsonObject(line);
|
|
5527
|
+
const payload = entry && typeof entry.payload === "object" && entry.payload !== null ? entry.payload : null;
|
|
5528
|
+
if (payload?.type === "message" && payload.role === "user") {
|
|
5529
|
+
latestIndex = index;
|
|
5530
|
+
}
|
|
5531
|
+
}
|
|
5532
|
+
return latestIndex;
|
|
5533
|
+
}
|
|
5409
5534
|
async function replayCodexMcpToolEventsFromSessionLog(context, state) {
|
|
5410
5535
|
const runtimeSessionId = state.runtimeSessionId;
|
|
5411
5536
|
if (!runtimeSessionId) return;
|
|
5412
5537
|
const codexHome = context.env.CODEX_HOME || process.env.CODEX_HOME || (0, import_path.join)((0, import_os.homedir)(), ".codex");
|
|
5413
5538
|
const logPath = findCodexSessionLog(runtimeSessionId, codexHome);
|
|
5414
5539
|
if (!logPath) return;
|
|
5540
|
+
const allLines = (0, import_fs.readFileSync)(logPath, "utf8").split(/\r?\n/).filter(Boolean);
|
|
5541
|
+
const latestUserLineIndex = latestUserMessageLineIndex(allLines);
|
|
5542
|
+
const lines = latestUserLineIndex >= 0 ? allLines.slice(latestUserLineIndex + 1) : allLines;
|
|
5415
5543
|
const emittedToolIds = /* @__PURE__ */ new Set();
|
|
5416
|
-
const lines = (0, import_fs.readFileSync)(logPath, "utf8").split(/\r?\n/).filter(Boolean);
|
|
5417
5544
|
for (const line of lines) {
|
|
5418
5545
|
const entry = parseJsonObject(line);
|
|
5419
5546
|
const payload = entry && typeof entry.payload === "object" && entry.payload !== null ? entry.payload : null;
|
|
@@ -5433,36 +5560,39 @@ async function replayCodexMcpToolEventsFromSessionLog(context, state) {
|
|
|
5433
5560
|
if (!callId) continue;
|
|
5434
5561
|
context.presenter.onToolUse("tool_search", payload.arguments ?? {}, callId);
|
|
5435
5562
|
emittedToolIds.add(callId);
|
|
5563
|
+
continue;
|
|
5564
|
+
}
|
|
5565
|
+
if (payload.type === "image_generation_end") {
|
|
5566
|
+
const image = buildGeneratedImageFromCodexPayload(payload);
|
|
5567
|
+
if (image) await context.presenter.onGeneratedImage?.(image);
|
|
5436
5568
|
}
|
|
5437
5569
|
}
|
|
5438
|
-
if (emittedToolIds.size
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5570
|
+
if (emittedToolIds.size > 0) {
|
|
5571
|
+
for (const line of lines) {
|
|
5572
|
+
const entry = parseJsonObject(line);
|
|
5573
|
+
const payload = entry && typeof entry.payload === "object" && entry.payload !== null ? entry.payload : null;
|
|
5574
|
+
if (!payload || payload.type !== "function_call_output" && payload.type !== "tool_search_output")
|
|
5575
|
+
continue;
|
|
5576
|
+
const callId = typeof payload.call_id === "string" ? payload.call_id : "";
|
|
5577
|
+
if (!emittedToolIds.has(callId)) continue;
|
|
5578
|
+
try {
|
|
5579
|
+
const result = payload.type === "tool_search_output" ? JSON.stringify(payload.tools ?? [], null, 2) : normalizeCodexMcpToolResult(payload.output);
|
|
5580
|
+
context.presenter.onToolResult?.(callId, result);
|
|
5581
|
+
} catch {
|
|
5582
|
+
context.presenter.onToolResult?.(callId, String(payload.output ?? ""));
|
|
5583
|
+
}
|
|
5450
5584
|
}
|
|
5451
5585
|
}
|
|
5452
5586
|
}
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5587
|
+
var KIMI_RESUME_SESSION_RE = /To resume this session:\s*kimi(?:-cli)?\s+(?:-[rS]|--session|--resume)\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
5588
|
+
function parseKimiStderrLine(line, state) {
|
|
5589
|
+
const match = line.match(KIMI_RESUME_SESSION_RE);
|
|
5590
|
+
if (match?.[1]) {
|
|
5591
|
+
state.runtimeSessionId = match[1];
|
|
5458
5592
|
}
|
|
5459
|
-
return (0, import_crypto.createHash)("md5").update(resolved).digest("hex");
|
|
5460
5593
|
}
|
|
5461
5594
|
function parseKimiStructuredLine(line, context, state) {
|
|
5462
5595
|
const presenter = context.presenter;
|
|
5463
|
-
if (!state.runtimeSessionId) {
|
|
5464
|
-
state.runtimeSessionId = kimiSessionId(context.cwd);
|
|
5465
|
-
}
|
|
5466
5596
|
let parsed;
|
|
5467
5597
|
try {
|
|
5468
5598
|
parsed = JSON.parse(line);
|
|
@@ -5547,11 +5677,11 @@ function createImageTempDirectory(cwd) {
|
|
|
5547
5677
|
].filter((value2) => Boolean(value2));
|
|
5548
5678
|
for (const candidate of candidates) {
|
|
5549
5679
|
try {
|
|
5550
|
-
return (0,
|
|
5680
|
+
return (0, import_fs2.mkdtempSync)(candidate);
|
|
5551
5681
|
} catch {
|
|
5552
5682
|
}
|
|
5553
5683
|
}
|
|
5554
|
-
return (0,
|
|
5684
|
+
return (0, import_fs2.mkdtempSync)((0, import_path2.join)((0, import_os2.tmpdir)(), "aiden-images-"));
|
|
5555
5685
|
}
|
|
5556
5686
|
function writeImagesToTempFiles(images, cwd) {
|
|
5557
5687
|
if (!images?.length) return { paths: [], files: [], cleanup: () => {
|
|
@@ -5562,7 +5692,7 @@ function writeImagesToTempFiles(images, cwd) {
|
|
|
5562
5692
|
for (const img of images) {
|
|
5563
5693
|
const ext = imageFileExtension(img.mimeType);
|
|
5564
5694
|
const filePath = (0, import_path2.join)(directory, `aiden-img-${img.id}.${ext}`);
|
|
5565
|
-
(0,
|
|
5695
|
+
(0, import_fs2.writeFileSync)(filePath, Buffer.from(img.data, "base64"));
|
|
5566
5696
|
paths.push(filePath);
|
|
5567
5697
|
files.push({
|
|
5568
5698
|
filename: img.filename,
|
|
@@ -5577,7 +5707,7 @@ function writeImagesToTempFiles(images, cwd) {
|
|
|
5577
5707
|
files,
|
|
5578
5708
|
cleanup: () => {
|
|
5579
5709
|
try {
|
|
5580
|
-
(0,
|
|
5710
|
+
(0, import_fs2.rmSync)(directory, { recursive: true, force: true });
|
|
5581
5711
|
} catch {
|
|
5582
5712
|
}
|
|
5583
5713
|
}
|
|
@@ -5666,6 +5796,9 @@ function createGenericCliBackend(options) {
|
|
|
5666
5796
|
});
|
|
5667
5797
|
stderrRl.on("line", (line) => {
|
|
5668
5798
|
presenter.recordRawTranscript?.("stderr", line);
|
|
5799
|
+
if (options.parseStderrLine) {
|
|
5800
|
+
options.parseStderrLine(line, context, state);
|
|
5801
|
+
}
|
|
5669
5802
|
if (line.trim().length > 0) {
|
|
5670
5803
|
stderrLines.push(line);
|
|
5671
5804
|
void presenter.onLog(`[${options.kind}] ${line}`);
|
|
@@ -6138,7 +6271,7 @@ function resolveKimiCliModelArg(model) {
|
|
|
6138
6271
|
if (trimmed.startsWith("claude-")) return void 0;
|
|
6139
6272
|
return trimmed;
|
|
6140
6273
|
}
|
|
6141
|
-
function createKimiCliBackend(command = "kimi", defaultArgs = []) {
|
|
6274
|
+
function createKimiCliBackend(command = "kimi-cli", defaultArgs = []) {
|
|
6142
6275
|
return {
|
|
6143
6276
|
kind: "kimi_cli",
|
|
6144
6277
|
supportTier: "structured",
|
|
@@ -6168,7 +6301,8 @@ function createKimiCliBackend(command = "kimi", defaultArgs = []) {
|
|
|
6168
6301
|
return [...args, ...defaultArgs, "--prompt", prompt];
|
|
6169
6302
|
},
|
|
6170
6303
|
augmentPrompt: (ctx) => buildPromptWithImagePathReferences(ctx, imageFiles),
|
|
6171
|
-
parseStructuredLine: parseKimiStructuredLine
|
|
6304
|
+
parseStructuredLine: parseKimiStructuredLine,
|
|
6305
|
+
parseStderrLine: (line, _ctx, state) => parseKimiStderrLine(line, state)
|
|
6172
6306
|
}).run(context);
|
|
6173
6307
|
} finally {
|
|
6174
6308
|
cleanup();
|
|
@@ -6964,7 +7098,12 @@ function createCodexRuntimeBackend(command = "codex", defaultArgs = []) {
|
|
|
6964
7098
|
const resumeId = ctx.config.runtimeSessionId?.trim() || ctx.config.providerSessionId?.trim();
|
|
6965
7099
|
const modelArgs = ctx.config.selectedModel?.trim() ? ["--model", ctx.config.selectedModel.trim()] : [];
|
|
6966
7100
|
const effortArgs = buildCodexEffortArgs(ctx.config.selectedEffortLevel);
|
|
6967
|
-
const permissionArgs = [
|
|
7101
|
+
const permissionArgs = [
|
|
7102
|
+
"--ask-for-approval",
|
|
7103
|
+
"never",
|
|
7104
|
+
"--sandbox",
|
|
7105
|
+
"danger-full-access"
|
|
7106
|
+
];
|
|
6968
7107
|
const imageArgs = imagePaths.flatMap((p) => ["--image", p]);
|
|
6969
7108
|
const baseArgs = resumeId ? [...permissionArgs, "exec", "resume", "--json", "--skip-git-repo-check", ...modelArgs, ...effortArgs, ...imageArgs, resumeId, "-"] : [...permissionArgs, "exec", "--json", "--skip-git-repo-check", ...modelArgs, ...effortArgs, ...imageArgs, "-"];
|
|
6970
7109
|
return [...baseArgs, ...defaultArgs];
|
|
@@ -7099,6 +7238,85 @@ function createCopilotCliBackend(command = "copilot", defaultArgs = []) {
|
|
|
7099
7238
|
}
|
|
7100
7239
|
};
|
|
7101
7240
|
}
|
|
7241
|
+
var SKILL_COMMAND_RE = /^\s*\/([A-Za-z0-9][A-Za-z0-9._:-]*)(?:\s+([\s\S]*))?$/;
|
|
7242
|
+
function parseSkillInvocation(text) {
|
|
7243
|
+
const match = text.match(SKILL_COMMAND_RE);
|
|
7244
|
+
if (!match) return null;
|
|
7245
|
+
return {
|
|
7246
|
+
command: match[1],
|
|
7247
|
+
userRequest: match[2]?.trim() ?? ""
|
|
7248
|
+
};
|
|
7249
|
+
}
|
|
7250
|
+
function candidateRoots(cwd) {
|
|
7251
|
+
const roots = [];
|
|
7252
|
+
if (cwd) {
|
|
7253
|
+
roots.push((0, import_path4.join)(cwd, ".agents", "skills"));
|
|
7254
|
+
roots.push((0, import_path4.join)(cwd, ".claude", "skills"));
|
|
7255
|
+
roots.push((0, import_path4.join)(cwd, ".codex", "skills"));
|
|
7256
|
+
if ((0, import_fs4.existsSync)(cwd)) {
|
|
7257
|
+
let entries = [];
|
|
7258
|
+
try {
|
|
7259
|
+
entries = (0, import_fs4.readdirSync)(cwd, { withFileTypes: true });
|
|
7260
|
+
} catch {
|
|
7261
|
+
}
|
|
7262
|
+
for (const entry of entries) {
|
|
7263
|
+
if (!entry.isDirectory()) continue;
|
|
7264
|
+
if (entry.name.startsWith(".")) continue;
|
|
7265
|
+
const child = (0, import_path4.join)(cwd, entry.name);
|
|
7266
|
+
roots.push((0, import_path4.join)(child, ".agents", "skills"));
|
|
7267
|
+
roots.push((0, import_path4.join)(child, ".claude", "skills"));
|
|
7268
|
+
roots.push((0, import_path4.join)(child, ".codex", "skills"));
|
|
7269
|
+
}
|
|
7270
|
+
}
|
|
7271
|
+
}
|
|
7272
|
+
const home = (0, import_os4.homedir)();
|
|
7273
|
+
roots.push((0, import_path4.join)(home, ".agents", "skills"));
|
|
7274
|
+
roots.push((0, import_path4.join)(home, ".claude", "skills"));
|
|
7275
|
+
roots.push((0, import_path4.join)(home, ".codex", "skills"));
|
|
7276
|
+
return Array.from(new Set(roots));
|
|
7277
|
+
}
|
|
7278
|
+
function resolveSkillInvocation(text, cwd) {
|
|
7279
|
+
const parsed = parseSkillInvocation(text);
|
|
7280
|
+
if (!parsed) return null;
|
|
7281
|
+
for (const root of candidateRoots(cwd)) {
|
|
7282
|
+
const skillPath = (0, import_path4.join)(root, parsed.command, "SKILL.md");
|
|
7283
|
+
if (!(0, import_fs4.existsSync)(skillPath)) continue;
|
|
7284
|
+
let content;
|
|
7285
|
+
try {
|
|
7286
|
+
content = (0, import_fs4.readFileSync)(skillPath, "utf-8");
|
|
7287
|
+
} catch {
|
|
7288
|
+
continue;
|
|
7289
|
+
}
|
|
7290
|
+
return {
|
|
7291
|
+
command: parsed.command,
|
|
7292
|
+
skillPath,
|
|
7293
|
+
content,
|
|
7294
|
+
userRequest: parsed.userRequest
|
|
7295
|
+
};
|
|
7296
|
+
}
|
|
7297
|
+
return null;
|
|
7298
|
+
}
|
|
7299
|
+
function expandSkillInvocationPrompt(text, cwd) {
|
|
7300
|
+
const invocation = resolveSkillInvocation(text, cwd);
|
|
7301
|
+
if (!invocation) return { text, invocation: null };
|
|
7302
|
+
const request = invocation.userRequest || "(No additional request text was provided.)";
|
|
7303
|
+
return {
|
|
7304
|
+
invocation,
|
|
7305
|
+
text: [
|
|
7306
|
+
`The user invoked the \`/${invocation.command}\` skill.`,
|
|
7307
|
+
`Skill source: ${invocation.skillPath}`,
|
|
7308
|
+
"",
|
|
7309
|
+
"Follow the skill instructions below for this turn.",
|
|
7310
|
+
"",
|
|
7311
|
+
`<skill_instructions command="${invocation.command}">`,
|
|
7312
|
+
invocation.content.trim(),
|
|
7313
|
+
"</skill_instructions>",
|
|
7314
|
+
"",
|
|
7315
|
+
"User request after the slash command:",
|
|
7316
|
+
request
|
|
7317
|
+
].join("\n")
|
|
7318
|
+
};
|
|
7319
|
+
}
|
|
7102
7320
|
var DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
7103
7321
|
var DROID_DEFAULT_MODEL = "claude-opus-4-7";
|
|
7104
7322
|
function defaultSelectedModelForBackend(backendKind) {
|
|
@@ -7120,7 +7338,7 @@ function defaultSelectedModelForBackend(backendKind) {
|
|
|
7120
7338
|
function canonicalizePath(inputPath) {
|
|
7121
7339
|
try {
|
|
7122
7340
|
const resolved = (0, import_path3.resolve)(inputPath);
|
|
7123
|
-
return (0,
|
|
7341
|
+
return (0, import_fs3.existsSync)(resolved) ? (0, import_fs3.realpathSync)(resolved) : resolved;
|
|
7124
7342
|
} catch {
|
|
7125
7343
|
return null;
|
|
7126
7344
|
}
|
|
@@ -7278,16 +7496,21 @@ Prefer relative paths and keep your work scoped to this project.`
|
|
|
7278
7496
|
async runCliBackend(config, safeProjectPath) {
|
|
7279
7497
|
const backendKind = this.resolveBackendKind(config);
|
|
7280
7498
|
const defaultCwd = (0, import_path3.join)((0, import_os3.homedir)(), "Documents", "aiden");
|
|
7281
|
-
if (!(0,
|
|
7282
|
-
(0,
|
|
7499
|
+
if (!(0, import_fs3.existsSync)(defaultCwd)) {
|
|
7500
|
+
(0, import_fs3.mkdirSync)(defaultCwd, { recursive: true });
|
|
7283
7501
|
}
|
|
7284
7502
|
let runtimeConfig = this.buildRuntimeConfig(config, safeProjectPath);
|
|
7285
7503
|
const cwd = runtimeConfig.worktreePath || safeProjectPath || runtimeConfig.cwd || defaultCwd;
|
|
7504
|
+
const skillExpansion = expandSkillInvocationPrompt(runtimeConfig.task, cwd);
|
|
7505
|
+
if (skillExpansion.invocation) {
|
|
7506
|
+
runtimeConfig = { ...runtimeConfig, task: skillExpansion.text };
|
|
7507
|
+
void this.presenter.onLog(`Using /${skillExpansion.invocation.command} skill`);
|
|
7508
|
+
}
|
|
7286
7509
|
const env = await this.buildCliEnvironment();
|
|
7287
7510
|
const promptText = this.buildPromptText(runtimeConfig);
|
|
7288
7511
|
const runtimeCommand = runtimeConfig.runtimeCommand || this.runtime.runtimeCommand;
|
|
7289
7512
|
const runtimeArgs = runtimeConfig.runtimeArgs || this.runtime.runtimeArgs || [];
|
|
7290
|
-
const backend = backendKind === "claude_cli" ? createClaudeCliBackend(runtimeCommand || "claude", runtimeArgs) : backendKind === "codex_app_server" ? createCodexRuntimeBackend(runtimeCommand || "codex", runtimeArgs) : backendKind === "copilot_cli" ? createCopilotCliBackend(runtimeCommand || "copilot", runtimeArgs) : backendKind === "cursor_agent_cli" ? createCursorAgentCliBackend(runtimeCommand || "cursor-agent", runtimeArgs) : backendKind === "gemini_cli" ? createGeminiCliBackend(runtimeCommand || "gemini", runtimeArgs) : backendKind === "droid_cli" ? createDroidCliBackend(runtimeCommand || "droid", runtimeArgs) : backendKind === "opencode_cli" ? createOpencodeCliBackend(runtimeCommand || "opencode", runtimeArgs) : backendKind === "kimi_cli" ? createKimiCliBackend(runtimeCommand || "kimi", runtimeArgs) : backendKind === "supatest_cli" ? createSupatestCliBackend(runtimeCommand || "supatest", runtimeArgs) : createGenericCliPassthroughBackend(runtimeCommand || "generic-cli", runtimeArgs);
|
|
7513
|
+
const backend = backendKind === "claude_cli" ? createClaudeCliBackend(runtimeCommand || "claude", runtimeArgs) : backendKind === "codex_app_server" ? createCodexRuntimeBackend(runtimeCommand || "codex", runtimeArgs) : backendKind === "copilot_cli" ? createCopilotCliBackend(runtimeCommand || "copilot", runtimeArgs) : backendKind === "cursor_agent_cli" ? createCursorAgentCliBackend(runtimeCommand || "cursor-agent", runtimeArgs) : backendKind === "gemini_cli" ? createGeminiCliBackend(runtimeCommand || "gemini", runtimeArgs) : backendKind === "droid_cli" ? createDroidCliBackend(runtimeCommand || "droid", runtimeArgs) : backendKind === "opencode_cli" ? createOpencodeCliBackend(runtimeCommand || "opencode", runtimeArgs) : backendKind === "kimi_cli" ? createKimiCliBackend(runtimeCommand || "kimi-cli", runtimeArgs) : backendKind === "supatest_cli" ? createSupatestCliBackend(runtimeCommand || "supatest", runtimeArgs) : createGenericCliPassthroughBackend(runtimeCommand || "generic-cli", runtimeArgs);
|
|
7291
7514
|
let lastResult = null;
|
|
7292
7515
|
for (let attempt = 0; attempt <= _BaseMachineAgent.MAX_RETRIES; attempt++) {
|
|
7293
7516
|
if (this.abortController?.signal.aborted) break;
|
|
@@ -7383,7 +7606,7 @@ Prefer relative paths and keep your work scoped to this project.`
|
|
|
7383
7606
|
const canonicalized = canonicalizePath(initialConfig.teamPath);
|
|
7384
7607
|
if (canonicalized) safeProjectPath = canonicalized;
|
|
7385
7608
|
}
|
|
7386
|
-
if (safeProjectPath && !(0,
|
|
7609
|
+
if (safeProjectPath && !(0, import_fs3.existsSync)(safeProjectPath)) {
|
|
7387
7610
|
const message = `Local path no longer exists: "${safeProjectPath}". Please update the team's local path in team settings before running the agent.`;
|
|
7388
7611
|
this.presenter.onError(message, true);
|
|
7389
7612
|
const result = {
|
|
@@ -7439,7 +7662,7 @@ var PROVIDER_CLI_COMMANDS = {
|
|
|
7439
7662
|
copilot_cli: { provider: "copilot_cli", command: "copilot", envVar: "AIDEN_COPILOT_PATH" },
|
|
7440
7663
|
cursor_agent_cli: { provider: "cursor_agent_cli", command: "cursor-agent", envVar: "AIDEN_CURSOR_AGENT_PATH" },
|
|
7441
7664
|
gemini_cli: { provider: "gemini_cli", command: "gemini", envVar: "AIDEN_GEMINI_PATH" },
|
|
7442
|
-
kimi_cli: { provider: "kimi_cli", command: "kimi", envVar: "AIDEN_KIMI_PATH" },
|
|
7665
|
+
kimi_cli: { provider: "kimi_cli", command: "kimi-cli", envVar: "AIDEN_KIMI_PATH" },
|
|
7443
7666
|
opencode_cli: { provider: "opencode_cli", command: "opencode", envVar: "AIDEN_OPENCODE_PATH" },
|
|
7444
7667
|
droid_cli: { provider: "droid_cli", command: "droid", envVar: "AIDEN_DROID_PATH" },
|
|
7445
7668
|
supatest_cli: { provider: "supatest_cli", command: "supatest", envVar: "AIDEN_SUPATEST_PATH" }
|
|
@@ -7457,13 +7680,13 @@ var BACKEND_CLI_COMMANDS = {
|
|
|
7457
7680
|
cursor_agent_cli: "cursor-agent",
|
|
7458
7681
|
gemini_cli: "gemini",
|
|
7459
7682
|
gemini: "gemini",
|
|
7460
|
-
kimi_cli: "kimi",
|
|
7683
|
+
kimi_cli: "kimi-cli",
|
|
7461
7684
|
opencode_cli: "opencode",
|
|
7462
7685
|
droid_cli: "droid",
|
|
7463
7686
|
supatest_cli: "supatest"
|
|
7464
7687
|
};
|
|
7465
7688
|
var CLI_COMMAND_ALIASES = {
|
|
7466
|
-
kimi: ["kimi
|
|
7689
|
+
"kimi-cli": ["kimi"]
|
|
7467
7690
|
};
|
|
7468
7691
|
var resolvedCliCache = /* @__PURE__ */ new Map();
|
|
7469
7692
|
var cachedLoginShellEnv = null;
|
|
@@ -7864,6 +8087,46 @@ ${meta.description}`);
|
|
|
7864
8087
|
}
|
|
7865
8088
|
parts2.push(lines.join("\n"));
|
|
7866
8089
|
}
|
|
8090
|
+
if (config.prMeta) {
|
|
8091
|
+
const pr = config.prMeta;
|
|
8092
|
+
const lines = ["# Pull Request Context"];
|
|
8093
|
+
lines.push(`- **Repo**: ${pr.owner}/${pr.repo}`);
|
|
8094
|
+
lines.push(`- **PR**: #${pr.prNumber} \u2014 ${pr.title}`);
|
|
8095
|
+
lines.push(`- **State**: ${pr.state}`);
|
|
8096
|
+
if (pr.author) lines.push(`- **Author**: ${pr.author}`);
|
|
8097
|
+
const baseHead = `${pr.baseBranch || "?"} \u2190 ${pr.headBranch || "?"}`;
|
|
8098
|
+
lines.push(`- **Base \u2190 Head**: ${baseHead}`);
|
|
8099
|
+
if (pr.mergeable === false) {
|
|
8100
|
+
lines.push(`- **Mergeable**: no`);
|
|
8101
|
+
} else if (pr.mergeable === true) {
|
|
8102
|
+
lines.push(`- **Mergeable**: yes`);
|
|
8103
|
+
}
|
|
8104
|
+
if (pr.labels && pr.labels.length > 0) {
|
|
8105
|
+
lines.push(`- **Labels**: ${pr.labels.join(", ")}`);
|
|
8106
|
+
}
|
|
8107
|
+
const sizeBits = [];
|
|
8108
|
+
if (typeof pr.changedFilesCount === "number") sizeBits.push(`${pr.changedFilesCount} files`);
|
|
8109
|
+
if (typeof pr.additions === "number") sizeBits.push(`+${pr.additions}`);
|
|
8110
|
+
if (typeof pr.deletions === "number") sizeBits.push(`-${pr.deletions}`);
|
|
8111
|
+
if (sizeBits.length > 0) lines.push(`- **Size**: ${sizeBits.join(" / ")}`);
|
|
8112
|
+
if (pr.linkedTaskReadableId) {
|
|
8113
|
+
lines.push(`- **Linked task**: ${pr.linkedTaskReadableId}`);
|
|
8114
|
+
}
|
|
8115
|
+
if (pr.htmlUrl) lines.push(`- **URL**: ${pr.htmlUrl}`);
|
|
8116
|
+
if (pr.body) {
|
|
8117
|
+
lines.push("");
|
|
8118
|
+
lines.push("## PR Description");
|
|
8119
|
+
lines.push(pr.body);
|
|
8120
|
+
}
|
|
8121
|
+
if (pr.changedFiles && pr.changedFiles.length > 0) {
|
|
8122
|
+
lines.push("");
|
|
8123
|
+
lines.push("## Changed Files (first 50)");
|
|
8124
|
+
for (const file of pr.changedFiles) {
|
|
8125
|
+
lines.push(`- ${file.status}: \`${file.path}\` (+${file.additions} / -${file.deletions})`);
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
parts2.push(lines.join("\n"));
|
|
8129
|
+
}
|
|
7867
8130
|
const taskId = config.taskId ?? process.env.AIDEN_TASK_ID;
|
|
7868
8131
|
const conversationId = config.conversationId ?? process.env.AIDEN_SESSION_ID;
|
|
7869
8132
|
const teamId = config.teamId;
|
|
@@ -7898,15 +8161,128 @@ ${meta.description}`);
|
|
|
7898
8161
|
}
|
|
7899
8162
|
};
|
|
7900
8163
|
|
|
8164
|
+
// src/generated-images.ts
|
|
8165
|
+
var import_node_crypto = require("crypto");
|
|
8166
|
+
var import_node_fs2 = require("fs");
|
|
8167
|
+
var import_node_path2 = require("path");
|
|
8168
|
+
var IMAGE_MIME_BY_EXT = {
|
|
8169
|
+
".gif": "image/gif",
|
|
8170
|
+
".jpeg": "image/jpeg",
|
|
8171
|
+
".jpg": "image/jpeg",
|
|
8172
|
+
".png": "image/png",
|
|
8173
|
+
".webp": "image/webp"
|
|
8174
|
+
};
|
|
8175
|
+
var MAX_GENERATED_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
8176
|
+
function collectStringValues(value2, out) {
|
|
8177
|
+
if (typeof value2 === "string") {
|
|
8178
|
+
out.push(value2);
|
|
8179
|
+
return;
|
|
8180
|
+
}
|
|
8181
|
+
if (Array.isArray(value2)) {
|
|
8182
|
+
for (const item of value2) collectStringValues(item, out);
|
|
8183
|
+
return;
|
|
8184
|
+
}
|
|
8185
|
+
if (!value2 || typeof value2 !== "object") return;
|
|
8186
|
+
for (const entry of Object.values(value2)) {
|
|
8187
|
+
collectStringValues(entry, out);
|
|
8188
|
+
}
|
|
8189
|
+
}
|
|
8190
|
+
function candidateStrings(content) {
|
|
8191
|
+
const values = [content];
|
|
8192
|
+
try {
|
|
8193
|
+
collectStringValues(JSON.parse(content), values);
|
|
8194
|
+
} catch {
|
|
8195
|
+
}
|
|
8196
|
+
return values;
|
|
8197
|
+
}
|
|
8198
|
+
function extractPathCandidates(content) {
|
|
8199
|
+
const paths = /* @__PURE__ */ new Set();
|
|
8200
|
+
const imagePathPattern = /(?:file:\/\/)?(?:~|\.{1,2}|\/)?[^\s"'`)\]}<>]+?\.(?:png|jpe?g|gif|webp)\b/gi;
|
|
8201
|
+
for (const value2 of candidateStrings(content)) {
|
|
8202
|
+
for (const match of value2.matchAll(imagePathPattern)) {
|
|
8203
|
+
paths.add(match[0]);
|
|
8204
|
+
}
|
|
8205
|
+
}
|
|
8206
|
+
return [...paths];
|
|
8207
|
+
}
|
|
8208
|
+
function normalizePath(candidate, cwd) {
|
|
8209
|
+
let path = candidate.trim().replace(/^file:\/\//, "");
|
|
8210
|
+
try {
|
|
8211
|
+
path = decodeURI(path);
|
|
8212
|
+
} catch {
|
|
8213
|
+
}
|
|
8214
|
+
if (path.startsWith("~/")) return null;
|
|
8215
|
+
if ((0, import_node_path2.isAbsolute)(path)) return path;
|
|
8216
|
+
return cwd ? (0, import_node_path2.join)(cwd, path) : null;
|
|
8217
|
+
}
|
|
8218
|
+
function readImageDimensions2(buffer, mimeType) {
|
|
8219
|
+
if (mimeType === "image/png" && buffer.length >= 24 && buffer.toString("ascii", 1, 4) === "PNG") {
|
|
8220
|
+
return { width: buffer.readUInt32BE(16), height: buffer.readUInt32BE(20) };
|
|
8221
|
+
}
|
|
8222
|
+
if (mimeType === "image/gif" && buffer.length >= 10 && buffer.toString("ascii", 0, 3) === "GIF") {
|
|
8223
|
+
return { width: buffer.readUInt16LE(6), height: buffer.readUInt16LE(8) };
|
|
8224
|
+
}
|
|
8225
|
+
if (mimeType === "image/jpeg" && buffer.length > 4) {
|
|
8226
|
+
let offset = 2;
|
|
8227
|
+
while (offset + 9 < buffer.length) {
|
|
8228
|
+
if (buffer[offset] !== 255) break;
|
|
8229
|
+
const marker = buffer[offset + 1];
|
|
8230
|
+
const length = buffer.readUInt16BE(offset + 2);
|
|
8231
|
+
if (length < 2) break;
|
|
8232
|
+
if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker)) {
|
|
8233
|
+
return {
|
|
8234
|
+
width: buffer.readUInt16BE(offset + 7),
|
|
8235
|
+
height: buffer.readUInt16BE(offset + 5)
|
|
8236
|
+
};
|
|
8237
|
+
}
|
|
8238
|
+
offset += 2 + length;
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8241
|
+
return { width: null, height: null };
|
|
8242
|
+
}
|
|
8243
|
+
function extractGeneratedImagesFromToolResult(toolId, content, cwd) {
|
|
8244
|
+
const images = [];
|
|
8245
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8246
|
+
for (const candidate of extractPathCandidates(content)) {
|
|
8247
|
+
const path = normalizePath(candidate, cwd);
|
|
8248
|
+
if (!path || seen.has(path) || !(0, import_node_fs2.existsSync)(path)) continue;
|
|
8249
|
+
seen.add(path);
|
|
8250
|
+
const ext = (0, import_node_path2.extname)(path).toLowerCase();
|
|
8251
|
+
const mimeType = IMAGE_MIME_BY_EXT[ext];
|
|
8252
|
+
if (!mimeType) continue;
|
|
8253
|
+
const stat = (0, import_node_fs2.statSync)(path);
|
|
8254
|
+
if (!stat.isFile() || stat.size <= 0 || stat.size > MAX_GENERATED_IMAGE_BYTES) continue;
|
|
8255
|
+
const buffer = (0, import_node_fs2.readFileSync)(path);
|
|
8256
|
+
const { width, height } = readImageDimensions2(buffer, mimeType);
|
|
8257
|
+
images.push({
|
|
8258
|
+
type: "generated_image",
|
|
8259
|
+
id: (0, import_node_crypto.randomUUID)(),
|
|
8260
|
+
filename: (0, import_node_path2.basename)(path),
|
|
8261
|
+
mimeType,
|
|
8262
|
+
size: buffer.length,
|
|
8263
|
+
width,
|
|
8264
|
+
height,
|
|
8265
|
+
data: buffer.toString("base64"),
|
|
8266
|
+
sourcePath: path,
|
|
8267
|
+
sourceHash: (0, import_node_crypto.createHash)("sha256").update(buffer).digest("hex"),
|
|
8268
|
+
toolId,
|
|
8269
|
+
ts: Date.now()
|
|
8270
|
+
});
|
|
8271
|
+
}
|
|
8272
|
+
return images;
|
|
8273
|
+
}
|
|
8274
|
+
|
|
7901
8275
|
// src/web-presenter.ts
|
|
7902
8276
|
var WebPresenter = class {
|
|
7903
|
-
wsClient
|
|
7904
|
-
|
|
7905
|
-
suppressSessionLifecycle = false;
|
|
7906
|
-
constructor(wsClient, conversationId) {
|
|
8277
|
+
constructor(wsClient, conversationId, cwd) {
|
|
8278
|
+
this.cwd = cwd;
|
|
7907
8279
|
this.wsClient = wsClient;
|
|
7908
8280
|
this.conversationId = conversationId;
|
|
7909
8281
|
}
|
|
8282
|
+
wsClient;
|
|
8283
|
+
conversationId;
|
|
8284
|
+
emittedGeneratedImageKeys = /* @__PURE__ */ new Set();
|
|
8285
|
+
suppressSessionLifecycle = false;
|
|
7910
8286
|
setSuppressSessionLifecycle(suppress) {
|
|
7911
8287
|
this.suppressSessionLifecycle = suppress;
|
|
7912
8288
|
}
|
|
@@ -7933,6 +8309,19 @@ var WebPresenter = class {
|
|
|
7933
8309
|
ts: Date.now(),
|
|
7934
8310
|
...isError ? { is_error: true } : {}
|
|
7935
8311
|
});
|
|
8312
|
+
if (isError) return;
|
|
8313
|
+
for (const image of extractGeneratedImagesFromToolResult(toolId, content, this.cwd)) {
|
|
8314
|
+
this.emitGeneratedImage(image);
|
|
8315
|
+
}
|
|
8316
|
+
}
|
|
8317
|
+
onGeneratedImage(image) {
|
|
8318
|
+
this.emitGeneratedImage(image);
|
|
8319
|
+
}
|
|
8320
|
+
emitGeneratedImage(image) {
|
|
8321
|
+
const key = image.sourceHash ?? `${image.sourcePath ?? image.id}:${image.size}`;
|
|
8322
|
+
if (this.emittedGeneratedImageKeys.has(key)) return;
|
|
8323
|
+
this.emittedGeneratedImageKeys.add(key);
|
|
8324
|
+
this.wsClient.emitEvent(image);
|
|
7936
8325
|
}
|
|
7937
8326
|
onTurnComplete(content) {
|
|
7938
8327
|
this.wsClient.emitEvent({ type: "turn_complete", content, ts: Date.now() });
|
|
@@ -11610,6 +11999,7 @@ var WSClient = class {
|
|
|
11610
11999
|
selectedEffortLevel: data.selectedEffortLevel,
|
|
11611
12000
|
mode: data.mode,
|
|
11612
12001
|
taskMeta: data.taskMeta,
|
|
12002
|
+
prMeta: data.prMeta,
|
|
11613
12003
|
workflowTools: data.workflowTools,
|
|
11614
12004
|
runId: data.runId,
|
|
11615
12005
|
messageId: data.messageId,
|
|
@@ -11635,7 +12025,7 @@ var WSClient = class {
|
|
|
11635
12025
|
};
|
|
11636
12026
|
|
|
11637
12027
|
// src/version.ts
|
|
11638
|
-
var AGENT_VERSION = "0.1.
|
|
12028
|
+
var AGENT_VERSION = "0.1.18";
|
|
11639
12029
|
|
|
11640
12030
|
// src/sandbox.ts
|
|
11641
12031
|
async function runSandbox(config) {
|
|
@@ -11645,6 +12035,7 @@ async function runSandbox(config) {
|
|
|
11645
12035
|
let pendingMessageResolve = null;
|
|
11646
12036
|
let currentAgent = null;
|
|
11647
12037
|
let currentTaskMeta = void 0;
|
|
12038
|
+
let currentPrMeta = void 0;
|
|
11648
12039
|
let currentWorkflowTools = void 0;
|
|
11649
12040
|
let currentMaxIterations = config.maxIterations ?? 50;
|
|
11650
12041
|
let currentTaskId = config.taskId;
|
|
@@ -11697,7 +12088,7 @@ async function runSandbox(config) {
|
|
|
11697
12088
|
console.error("[sandbox] Failed to connect to WS server:", error.message);
|
|
11698
12089
|
process.exit(1);
|
|
11699
12090
|
}
|
|
11700
|
-
const presenter = new WebPresenter(wsClient, config.sessionId);
|
|
12091
|
+
const presenter = new WebPresenter(wsClient, config.sessionId, config.projectPath);
|
|
11701
12092
|
presenter.setSuppressSessionLifecycle(true);
|
|
11702
12093
|
let lastProviderSessionId = config.providerSessionId;
|
|
11703
12094
|
let activeBackendKind = config.backendKind || "claude_cli";
|
|
@@ -11729,6 +12120,7 @@ async function runSandbox(config) {
|
|
|
11729
12120
|
selectedEffortLevel: activeEffortLevel ?? null,
|
|
11730
12121
|
providerSessionId: lastProviderSessionId ?? void 0,
|
|
11731
12122
|
taskMeta: currentTaskMeta,
|
|
12123
|
+
prMeta: currentPrMeta,
|
|
11732
12124
|
taskId: currentTaskId,
|
|
11733
12125
|
conversationId: currentConversationId,
|
|
11734
12126
|
teamId: currentTeamId,
|
|
@@ -11791,6 +12183,9 @@ async function runSandbox(config) {
|
|
|
11791
12183
|
if (nextPayload.taskMeta !== void 0) {
|
|
11792
12184
|
currentTaskMeta = nextPayload.taskMeta;
|
|
11793
12185
|
}
|
|
12186
|
+
if (nextPayload.prMeta !== void 0) {
|
|
12187
|
+
currentPrMeta = nextPayload.prMeta;
|
|
12188
|
+
}
|
|
11794
12189
|
if (nextPayload.workflowTools !== void 0) {
|
|
11795
12190
|
currentWorkflowTools = nextPayload.workflowTools;
|
|
11796
12191
|
}
|
|
@@ -11821,17 +12216,17 @@ async function runSandbox(config) {
|
|
|
11821
12216
|
}
|
|
11822
12217
|
|
|
11823
12218
|
// src/daemon.ts
|
|
11824
|
-
var
|
|
12219
|
+
var import_node_fs4 = require("fs");
|
|
11825
12220
|
var import_node_http = __toESM(require("http"), 1);
|
|
11826
|
-
var
|
|
12221
|
+
var import_node_crypto2 = require("crypto");
|
|
11827
12222
|
var import_node_os4 = require("os");
|
|
11828
|
-
var
|
|
12223
|
+
var import_node_path4 = require("path");
|
|
11829
12224
|
|
|
11830
12225
|
// ../shared/dist/node/provider-limits.js
|
|
11831
12226
|
var import_node_child_process3 = require("child_process");
|
|
11832
|
-
var
|
|
12227
|
+
var import_node_fs3 = require("fs");
|
|
11833
12228
|
var import_node_os3 = require("os");
|
|
11834
|
-
var
|
|
12229
|
+
var import_node_path3 = require("path");
|
|
11835
12230
|
var CACHE_TTL_MS = 6e4;
|
|
11836
12231
|
var cachedLimits = null;
|
|
11837
12232
|
function numericValue(value2) {
|
|
@@ -11843,11 +12238,11 @@ function numericValue(value2) {
|
|
|
11843
12238
|
return null;
|
|
11844
12239
|
}
|
|
11845
12240
|
function splitPath2(value2) {
|
|
11846
|
-
return (value2 ?? "").split(
|
|
12241
|
+
return (value2 ?? "").split(import_node_path3.delimiter).filter(Boolean);
|
|
11847
12242
|
}
|
|
11848
12243
|
function isExecutableFile(path) {
|
|
11849
12244
|
try {
|
|
11850
|
-
(0,
|
|
12245
|
+
(0, import_node_fs3.accessSync)(path, import_node_fs3.constants.X_OK);
|
|
11851
12246
|
return true;
|
|
11852
12247
|
} catch {
|
|
11853
12248
|
return false;
|
|
@@ -11856,10 +12251,10 @@ function isExecutableFile(path) {
|
|
|
11856
12251
|
function augmentCliPath2(env) {
|
|
11857
12252
|
const home = env.HOME || (0, import_node_os3.homedir)();
|
|
11858
12253
|
const extraPaths = [
|
|
11859
|
-
(0,
|
|
11860
|
-
(0,
|
|
11861
|
-
(0,
|
|
11862
|
-
(0,
|
|
12254
|
+
(0, import_node_path3.join)(home, ".local", "bin"),
|
|
12255
|
+
(0, import_node_path3.join)(home, ".local", "node", "bin"),
|
|
12256
|
+
(0, import_node_path3.join)(home, ".bun", "bin"),
|
|
12257
|
+
(0, import_node_path3.join)(home, ".cargo", "bin"),
|
|
11863
12258
|
"/opt/homebrew/bin",
|
|
11864
12259
|
"/usr/local/bin"
|
|
11865
12260
|
];
|
|
@@ -11869,7 +12264,7 @@ function augmentCliPath2(env) {
|
|
|
11869
12264
|
return env;
|
|
11870
12265
|
return {
|
|
11871
12266
|
...env,
|
|
11872
|
-
PATH: `${missing.join(
|
|
12267
|
+
PATH: `${missing.join(import_node_path3.delimiter)}${import_node_path3.delimiter}${env.PATH ?? ""}`
|
|
11873
12268
|
};
|
|
11874
12269
|
}
|
|
11875
12270
|
function resolveExecutable(command, env, overrideEnvVar) {
|
|
@@ -11877,7 +12272,7 @@ function resolveExecutable(command, env, overrideEnvVar) {
|
|
|
11877
12272
|
if (override && isExecutableFile(override))
|
|
11878
12273
|
return override;
|
|
11879
12274
|
for (const dir of splitPath2(env.PATH)) {
|
|
11880
|
-
const candidate = (0,
|
|
12275
|
+
const candidate = (0, import_node_path3.join)(dir, command);
|
|
11881
12276
|
if (isExecutableFile(candidate))
|
|
11882
12277
|
return candidate;
|
|
11883
12278
|
}
|
|
@@ -12021,10 +12416,10 @@ async function collectCodexLimits(env) {
|
|
|
12021
12416
|
}), 4e3, []);
|
|
12022
12417
|
}
|
|
12023
12418
|
function readClaudeCredentialsPayload() {
|
|
12024
|
-
const path = (0,
|
|
12025
|
-
if ((0,
|
|
12419
|
+
const path = (0, import_node_path3.join)((0, import_node_os3.homedir)(), ".claude", ".credentials.json");
|
|
12420
|
+
if ((0, import_node_fs3.existsSync)(path)) {
|
|
12026
12421
|
try {
|
|
12027
|
-
return JSON.parse((0,
|
|
12422
|
+
return JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
12028
12423
|
} catch {
|
|
12029
12424
|
return null;
|
|
12030
12425
|
}
|
|
@@ -12125,33 +12520,33 @@ function describeOccupiedLocalDaemon(port) {
|
|
|
12125
12520
|
return `local daemon API port ${port} is already in use. If Aiden desktop is open, it manages the daemon automatically. Quit Aiden desktop or stop the existing daemon before starting another.`;
|
|
12126
12521
|
}
|
|
12127
12522
|
function getConfigPath() {
|
|
12128
|
-
return process.env.AIDEN_AGENT_CONFIG_PATH ?? (0,
|
|
12523
|
+
return process.env.AIDEN_AGENT_CONFIG_PATH ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".aiden", "agent", "config.json");
|
|
12129
12524
|
}
|
|
12130
12525
|
function getEndpointDefaultsPath() {
|
|
12131
|
-
return process.env.AIDEN_AGENT_ENDPOINTS_PATH ?? (0,
|
|
12526
|
+
return process.env.AIDEN_AGENT_ENDPOINTS_PATH ?? (0, import_node_path4.join)((0, import_node_path4.dirname)(getConfigPath()), "endpoints.json");
|
|
12132
12527
|
}
|
|
12133
12528
|
function readConfig() {
|
|
12134
12529
|
const configPath = getConfigPath();
|
|
12135
|
-
if (!(0,
|
|
12136
|
-
return JSON.parse((0,
|
|
12530
|
+
if (!(0, import_node_fs4.existsSync)(configPath)) return {};
|
|
12531
|
+
return JSON.parse((0, import_node_fs4.readFileSync)(configPath, "utf8"));
|
|
12137
12532
|
}
|
|
12138
12533
|
function readEndpointDefaults() {
|
|
12139
12534
|
const endpointsPath = getEndpointDefaultsPath();
|
|
12140
|
-
if (!(0,
|
|
12535
|
+
if (!(0, import_node_fs4.existsSync)(endpointsPath)) return {};
|
|
12141
12536
|
try {
|
|
12142
|
-
return JSON.parse((0,
|
|
12537
|
+
return JSON.parse((0, import_node_fs4.readFileSync)(endpointsPath, "utf8"));
|
|
12143
12538
|
} catch {
|
|
12144
12539
|
return {};
|
|
12145
12540
|
}
|
|
12146
12541
|
}
|
|
12147
12542
|
function writeConfig(config) {
|
|
12148
12543
|
const configPath = getConfigPath();
|
|
12149
|
-
(0,
|
|
12150
|
-
(0,
|
|
12544
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path4.dirname)(configPath), { recursive: true, mode: 448 });
|
|
12545
|
+
(0, import_node_fs4.writeFileSync)(configPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
12151
12546
|
}
|
|
12152
12547
|
function removeConfig() {
|
|
12153
12548
|
const configPath = getConfigPath();
|
|
12154
|
-
if ((0,
|
|
12549
|
+
if ((0, import_node_fs4.existsSync)(configPath)) (0, import_node_fs4.rmSync)(configPath, { force: true });
|
|
12155
12550
|
}
|
|
12156
12551
|
function argValue(args, name) {
|
|
12157
12552
|
const index = args.indexOf(name);
|
|
@@ -12238,7 +12633,7 @@ function collectRuntimeMetadata() {
|
|
|
12238
12633
|
metadata.cpuCores = cpuList.length;
|
|
12239
12634
|
}
|
|
12240
12635
|
try {
|
|
12241
|
-
const disk = (0,
|
|
12636
|
+
const disk = (0, import_node_fs4.statfsSync)((0, import_node_os4.homedir)());
|
|
12242
12637
|
metadata.diskFreeBytes = disk.bavail * disk.bsize;
|
|
12243
12638
|
metadata.diskTotalBytes = disk.blocks * disk.bsize;
|
|
12244
12639
|
} catch {
|
|
@@ -12257,11 +12652,13 @@ async function collectRuntimeMetadataWithProviderLimits() {
|
|
|
12257
12652
|
return metadata;
|
|
12258
12653
|
}
|
|
12259
12654
|
var RuntimePresenter = class {
|
|
12260
|
-
constructor(socket, conversationId, runId) {
|
|
12655
|
+
constructor(socket, conversationId, runId, cwd) {
|
|
12261
12656
|
this.socket = socket;
|
|
12262
12657
|
this.conversationId = conversationId;
|
|
12263
12658
|
this.runId = runId;
|
|
12659
|
+
this.cwd = cwd;
|
|
12264
12660
|
}
|
|
12661
|
+
emittedGeneratedImageKeys = /* @__PURE__ */ new Set();
|
|
12265
12662
|
emitEvent(event) {
|
|
12266
12663
|
this.socket.emit("agent.event", {
|
|
12267
12664
|
conversationId: this.conversationId,
|
|
@@ -12292,6 +12689,19 @@ var RuntimePresenter = class {
|
|
|
12292
12689
|
ts: Date.now(),
|
|
12293
12690
|
...isError ? { is_error: true } : {}
|
|
12294
12691
|
});
|
|
12692
|
+
if (isError) return;
|
|
12693
|
+
for (const image of extractGeneratedImagesFromToolResult(toolId, content, this.cwd)) {
|
|
12694
|
+
this.emitGeneratedImage(image);
|
|
12695
|
+
}
|
|
12696
|
+
}
|
|
12697
|
+
onGeneratedImage(image) {
|
|
12698
|
+
this.emitGeneratedImage(image);
|
|
12699
|
+
}
|
|
12700
|
+
emitGeneratedImage(image) {
|
|
12701
|
+
const key = image.sourceHash ?? `${image.sourcePath ?? image.id}:${image.size}`;
|
|
12702
|
+
if (this.emittedGeneratedImageKeys.has(key)) return;
|
|
12703
|
+
this.emittedGeneratedImageKeys.add(key);
|
|
12704
|
+
this.emitEvent(image);
|
|
12295
12705
|
}
|
|
12296
12706
|
onTurnComplete(content) {
|
|
12297
12707
|
this.emitEvent({ type: "turn_complete", content, ts: Date.now() });
|
|
@@ -12376,7 +12786,7 @@ async function setupDaemon(args) {
|
|
|
12376
12786
|
runtimeId: body.runtime.id,
|
|
12377
12787
|
runtimeToken: body.runtimeToken,
|
|
12378
12788
|
localApiPort: getLocalApiPort(args, {}),
|
|
12379
|
-
localApiToken: (0,
|
|
12789
|
+
localApiToken: (0, import_node_crypto2.randomBytes)(24).toString("hex"),
|
|
12380
12790
|
displayName: body.runtime.displayName ?? displayName
|
|
12381
12791
|
});
|
|
12382
12792
|
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath: getConfigPath() });
|
|
@@ -12422,7 +12832,7 @@ async function loginWithDeviceCode(args) {
|
|
|
12422
12832
|
runtimeId: body.runtime.id,
|
|
12423
12833
|
runtimeToken: body.runtimeToken,
|
|
12424
12834
|
localApiPort: getLocalApiPort(args, {}),
|
|
12425
|
-
localApiToken: (0,
|
|
12835
|
+
localApiToken: (0, import_node_crypto2.randomBytes)(24).toString("hex"),
|
|
12426
12836
|
displayName: body.runtime.displayName ?? displayName
|
|
12427
12837
|
});
|
|
12428
12838
|
console.info("[aiden-agent] Runtime registered", { runtimeId: body.runtime.id, configPath: getConfigPath() });
|
|
@@ -12436,7 +12846,7 @@ async function startDaemon(args) {
|
|
|
12436
12846
|
const runtimeToken = argValue(args, "--token") ?? process.env.AIDEN_RUNTIME_TOKEN ?? stored.runtimeToken;
|
|
12437
12847
|
const wsUrl = argValue(args, "--ws-url") ?? process.env.AIDEN_WS_URL ?? stored.wsUrl;
|
|
12438
12848
|
let localApiPort = getLocalApiPort(args, stored);
|
|
12439
|
-
const localApiToken = stored.localApiToken ?? (0,
|
|
12849
|
+
const localApiToken = stored.localApiToken ?? (0, import_node_crypto2.randomBytes)(24).toString("hex");
|
|
12440
12850
|
if (!runtimeId || !runtimeToken || !wsUrl) {
|
|
12441
12851
|
throw new Error("daemon requires runtimeId, runtime token, and wsUrl. Run setup first or pass --runtime-id/--token/--ws-url.");
|
|
12442
12852
|
}
|
|
@@ -12508,13 +12918,13 @@ async function startDaemon(args) {
|
|
|
12508
12918
|
}
|
|
12509
12919
|
socket.emit("agent.accepted", { runId: payload.runId });
|
|
12510
12920
|
pushLog(`accepted run=${payload.runId}`);
|
|
12511
|
-
const
|
|
12921
|
+
const cwd = payload.projectPath ?? process.cwd();
|
|
12922
|
+
const presenter = new RuntimePresenter(socket, payload.conversationId, payload.runId, cwd);
|
|
12512
12923
|
const agent = new CoreAgent(presenter, {
|
|
12513
12924
|
backendKind,
|
|
12514
12925
|
runtimeCommand,
|
|
12515
12926
|
providerApiKey: payload.providerApiKey
|
|
12516
12927
|
});
|
|
12517
|
-
const cwd = payload.projectPath ?? process.cwd();
|
|
12518
12928
|
activeAgents.set(payload.runId, { agent, presenter });
|
|
12519
12929
|
void agent.run({
|
|
12520
12930
|
task: payload.content,
|
|
@@ -12531,6 +12941,7 @@ async function startDaemon(args) {
|
|
|
12531
12941
|
selectedEffortLevel: payload.selectedEffortLevel ?? null,
|
|
12532
12942
|
providerSessionId: payload.providerSessionId,
|
|
12533
12943
|
taskMeta: payload.taskMeta,
|
|
12944
|
+
prMeta: payload.prMeta,
|
|
12534
12945
|
conversationId: payload.conversationId,
|
|
12535
12946
|
taskId: payload.taskMeta?.id,
|
|
12536
12947
|
teamId: payload.teamId,
|
package/dist/updater.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAmB5E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAmBjE"}
|
package/dist/updater.js
CHANGED
|
@@ -10,6 +10,10 @@ const DEFAULT_PATH = "/home/user/.local/node/bin:/home/user/.local/bin:/usr/loca
|
|
|
10
10
|
*/
|
|
11
11
|
export async function installUpdate(payload) {
|
|
12
12
|
const version = payload.version ?? "latest";
|
|
13
|
+
if (!/^[\w.\-+]+$/.test(version)) {
|
|
14
|
+
console.error(`[updater] Refusing to install: invalid version string "${version}"`);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
13
17
|
try {
|
|
14
18
|
console.info(`[updater] Installing @aiden-ade/sandbox-agent@${version} via npm`);
|
|
15
19
|
execSync(`npm install -g @aiden-ade/sandbox-agent@${version}`, {
|
package/dist/updater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater.js","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,YAAY,GAAG,+GAA+G,CAAC;AAOrI;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAsB;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,iDAAiD,OAAO,UAAU,CAAC,CAAC;QACjF,QAAQ,CAAC,2CAA2C,OAAO,EAAE,EAAE;YAC7D,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;YAC3C,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QACzE,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,qBAA8B;IACzD,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,qBAAqB,EAAE,CAAC;QAC1B,GAAG,CAAC,yBAAyB,GAAG,qBAAqB,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,EAAE,EAAE,EAAE;QACrC,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,QAAQ;QACf,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;KACpC,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;IAEd,wDAAwD;IACxD,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"updater.js","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,YAAY,GAAG,+GAA+G,CAAC;AAOrI;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAsB;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC;IAC5C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,0DAA0D,OAAO,GAAG,CAAC,CAAC;QACpF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,iDAAiD,OAAO,UAAU,CAAC,CAAC;QACjF,QAAQ,CAAC,2CAA2C,OAAO,EAAE,EAAE;YAC7D,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;YAC3C,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QACzE,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,qBAA8B;IACzD,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,qBAAqB,EAAE,CAAC;QAC1B,GAAG,CAAC,yBAAyB,GAAG,qBAAqB,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,EAAE,EAAE,EAAE;QACrC,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,QAAQ;QACf,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;KACpC,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;IAEd,wDAAwD;IACxD,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiden-ade/sandbox-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"aiden-agent": "./dist/index.cjs"
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"tsup": "^8.5.1",
|
|
20
20
|
"tsx": "^4.19.0",
|
|
21
21
|
"typescript": "~5.9.3",
|
|
22
|
-
"@aiden/
|
|
23
|
-
"@aiden/
|
|
22
|
+
"@aiden/shared": "0.1.0",
|
|
23
|
+
"@aiden/agent-core": "0.1.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsup",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aiden-system-prompt.d.ts","sourceRoot":"","sources":["../src/aiden-system-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aiden-system-prompt.js","sourceRoot":"","sources":["../src/aiden-system-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qBAAqB,CAAC"}
|