@ycodium-ai/agent-acp 0.2.3598 → 0.2.3608
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.js +616 -33
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -504,13 +504,14 @@ function extractToolCallCommand(rawInput, title) {
|
|
|
504
504
|
}
|
|
505
505
|
var TOOL_CALL_CONTENT_MAX_CHARS = 8e3;
|
|
506
506
|
var TOOL_CALL_CONTENT_TRUNCATION_MARKER = "[Earlier output truncated]\n\n";
|
|
507
|
-
function
|
|
508
|
-
if (text.length <=
|
|
507
|
+
function boundTailText(text, limit = TOOL_CALL_CONTENT_MAX_CHARS) {
|
|
508
|
+
if (text.length <= limit) {
|
|
509
509
|
return text;
|
|
510
510
|
}
|
|
511
|
-
const tail = text.slice(text.length -
|
|
511
|
+
const tail = text.slice(text.length - limit);
|
|
512
512
|
return `${TOOL_CALL_CONTENT_TRUNCATION_MARKER}${tail}`;
|
|
513
513
|
}
|
|
514
|
+
var boundToolCallOutputText = (text) => boundTailText(text);
|
|
514
515
|
var RAW_OUTPUT_TEXT_FIELDS = ["content", "stdout", "stderr", "output"];
|
|
515
516
|
function boundToolCallRawOutput(rawOutput) {
|
|
516
517
|
if (!isRecord(rawOutput)) {
|
|
@@ -622,6 +623,7 @@ function makeToolCallState(input2, options) {
|
|
|
622
623
|
...status ? { status } : {},
|
|
623
624
|
...command ? { command } : {},
|
|
624
625
|
...presentation?.detail ? { detail: presentation.detail } : {},
|
|
626
|
+
...textContent ? { contentText: textContent } : {},
|
|
625
627
|
data
|
|
626
628
|
};
|
|
627
629
|
}
|
|
@@ -632,6 +634,7 @@ function mergeToolCallState(previous, next) {
|
|
|
632
634
|
const status = next.status ?? previous?.status;
|
|
633
635
|
const command = next.command ?? previous?.command;
|
|
634
636
|
const detail = next.detail ?? previous?.detail;
|
|
637
|
+
const contentText = "content" in next.data ? next.contentText : previous?.contentText;
|
|
635
638
|
return {
|
|
636
639
|
toolCallId: next.toolCallId,
|
|
637
640
|
...kind ? { kind } : {},
|
|
@@ -639,6 +642,7 @@ function mergeToolCallState(previous, next) {
|
|
|
639
642
|
...status ? { status } : {},
|
|
640
643
|
...command ? { command } : {},
|
|
641
644
|
...detail ? { detail } : {},
|
|
645
|
+
...contentText ? { contentText } : {},
|
|
642
646
|
data: {
|
|
643
647
|
...previous?.data,
|
|
644
648
|
...next.data
|
|
@@ -1185,6 +1189,54 @@ function retainToolCallUpdate(toolCalls, next, seen) {
|
|
|
1185
1189
|
return { nextToolCall, decision };
|
|
1186
1190
|
}
|
|
1187
1191
|
|
|
1192
|
+
// ../../packages/ycodium-acp-executor/src/executor/child-sessions.ts
|
|
1193
|
+
var CHILD_LIMIT = 256;
|
|
1194
|
+
var active = (status) => status === "running" || status === "waiting";
|
|
1195
|
+
function createChildSessionRegistry(limit = CHILD_LIMIT) {
|
|
1196
|
+
const records = /* @__PURE__ */ new Map();
|
|
1197
|
+
const evictOne = (keep) => {
|
|
1198
|
+
const protectedIds = /* @__PURE__ */ new Set();
|
|
1199
|
+
for (const [id, record2] of records) {
|
|
1200
|
+
if (!active(record2.observed)) continue;
|
|
1201
|
+
protectedIds.add(id);
|
|
1202
|
+
let parent = record2.parentAgentId;
|
|
1203
|
+
while (parent !== void 0 && !protectedIds.has(parent)) {
|
|
1204
|
+
protectedIds.add(parent);
|
|
1205
|
+
parent = records.get(parent)?.parentAgentId;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
for (const id of records.keys()) {
|
|
1209
|
+
if (id === keep || protectedIds.has(id)) continue;
|
|
1210
|
+
records.delete(id);
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
const add = (sessionId, record2) => {
|
|
1215
|
+
records.set(sessionId, record2);
|
|
1216
|
+
if (records.size > limit) evictOne(sessionId);
|
|
1217
|
+
};
|
|
1218
|
+
return {
|
|
1219
|
+
has: (sessionId) => records.has(sessionId),
|
|
1220
|
+
get: (sessionId) => records.get(sessionId),
|
|
1221
|
+
mark: (sessionId) => {
|
|
1222
|
+
if (records.has(sessionId)) return;
|
|
1223
|
+
add(sessionId, {
|
|
1224
|
+
turnId: void 0,
|
|
1225
|
+
title: void 0,
|
|
1226
|
+
description: void 0,
|
|
1227
|
+
parentAgentId: void 0,
|
|
1228
|
+
observed: void 0,
|
|
1229
|
+
reported: void 0,
|
|
1230
|
+
reportedError: void 0,
|
|
1231
|
+
announced: false,
|
|
1232
|
+
pendingMetadata: false
|
|
1233
|
+
});
|
|
1234
|
+
},
|
|
1235
|
+
add,
|
|
1236
|
+
entries: () => records.entries()
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1188
1240
|
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.4.0_zod@4.6.5/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
1189
1241
|
var AGENT_METHODS = {
|
|
1190
1242
|
initialize: "initialize",
|
|
@@ -25167,7 +25219,9 @@ function createExecutorLifecycle({
|
|
|
25167
25219
|
eventStream,
|
|
25168
25220
|
onInputDead,
|
|
25169
25221
|
shared,
|
|
25170
|
-
promptResults
|
|
25222
|
+
promptResults,
|
|
25223
|
+
settleToolSubagents,
|
|
25224
|
+
settleSessionEnded
|
|
25171
25225
|
}) {
|
|
25172
25226
|
const cancel = async (turnId) => {
|
|
25173
25227
|
failIfDisposed();
|
|
@@ -25198,6 +25252,7 @@ function createExecutorLifecycle({
|
|
|
25198
25252
|
shared.promptsInFlight = 0;
|
|
25199
25253
|
shared.activeTurnId = void 0;
|
|
25200
25254
|
shared.status = "ready";
|
|
25255
|
+
settleToolSubagents("turn-interrupted", targetTurnId);
|
|
25201
25256
|
emit({
|
|
25202
25257
|
type: "turn.completed",
|
|
25203
25258
|
...stamp(),
|
|
@@ -25309,6 +25364,7 @@ function createExecutorLifecycle({
|
|
|
25309
25364
|
shared.abortLocalPrompt?.();
|
|
25310
25365
|
promptResults.finishUnreceived();
|
|
25311
25366
|
await promptResults.wait();
|
|
25367
|
+
settleSessionEnded();
|
|
25312
25368
|
emit({
|
|
25313
25369
|
type: "session.exited",
|
|
25314
25370
|
...stamp(),
|
|
@@ -25412,6 +25468,304 @@ var acpPromptFailureCategory = (error62, input2) => {
|
|
|
25412
25468
|
return error62 instanceof AcpConnectionClosedError ? acpTransportIfEstablished(input2.sessionEstablished, input2.disposed) : void 0;
|
|
25413
25469
|
};
|
|
25414
25470
|
|
|
25471
|
+
// ../../packages/ycodium-acp-executor/src/tool-subagents.ts
|
|
25472
|
+
var EXCLUDED = /* @__PURE__ */ Symbol("excluded");
|
|
25473
|
+
var sealedHidden = (entry) => ({
|
|
25474
|
+
sealed: true,
|
|
25475
|
+
keepToolRow: false,
|
|
25476
|
+
turnId: entry.turnId,
|
|
25477
|
+
kind: entry.kind,
|
|
25478
|
+
taskId: entry.taskId,
|
|
25479
|
+
facts: entry.facts
|
|
25480
|
+
});
|
|
25481
|
+
function toolSubagentSettlementOfTurn(state, failureCategory) {
|
|
25482
|
+
if (state === "cancelled") return "turn-interrupted";
|
|
25483
|
+
return state === "failed" && failureCategory === "transport" ? "session-ended" : "turn-ended";
|
|
25484
|
+
}
|
|
25485
|
+
var sameFacts = (a, b) => a.title === b.title && a.description === b.description && a.summary === b.summary && a.role === b.role && a.model === b.model && a.effort === b.effort && a.rosterKind === b.rosterKind;
|
|
25486
|
+
function linkage(taskId, toolCallId, facts) {
|
|
25487
|
+
return {
|
|
25488
|
+
taskId,
|
|
25489
|
+
taskType: "subagent",
|
|
25490
|
+
toolUseId: toolCallId,
|
|
25491
|
+
title: facts.title,
|
|
25492
|
+
...facts.role === void 0 ? {} : { role: facts.role },
|
|
25493
|
+
...facts.model === void 0 ? {} : { model: facts.model },
|
|
25494
|
+
...facts.effort === void 0 ? {} : { effort: facts.effort },
|
|
25495
|
+
...facts.rosterKind === void 0 ? {} : { rosterKind: facts.rosterKind }
|
|
25496
|
+
};
|
|
25497
|
+
}
|
|
25498
|
+
var isEntry = (value) => value !== EXCLUDED && !("sealed" in value);
|
|
25499
|
+
function createToolSubagentTracker(spec) {
|
|
25500
|
+
const calls = /* @__PURE__ */ new Map();
|
|
25501
|
+
const agentTasks = /* @__PURE__ */ new Map();
|
|
25502
|
+
const rememberAgent = (ref, taskId, facts) => {
|
|
25503
|
+
agentTasks.set(ref, { taskId, facts });
|
|
25504
|
+
};
|
|
25505
|
+
const turnOf = (turnId) => turnId === void 0 ? {} : { turnId };
|
|
25506
|
+
const onToolCallUpdated = (call) => {
|
|
25507
|
+
const tracked = calls.get(call.toolCallId);
|
|
25508
|
+
if (tracked === EXCLUDED) return void 0;
|
|
25509
|
+
if (tracked !== void 0 && !isEntry(tracked)) {
|
|
25510
|
+
const late = spec.resolve?.(call, tracked.kind, { known: true, background: false });
|
|
25511
|
+
if (late !== void 0 && late.type !== "hold" && late.agentRef !== void 0) {
|
|
25512
|
+
rememberAgent(late.agentRef, tracked.taskId, tracked.facts);
|
|
25513
|
+
}
|
|
25514
|
+
const repeatedTerminal = call.status === "completed" || call.status === "failed";
|
|
25515
|
+
const events2 = [];
|
|
25516
|
+
const final = tracked.final;
|
|
25517
|
+
if (repeatedTerminal && final !== void 0 && final.summary === void 0 && late?.type === "final" && late.status === final.status && late.summary !== void 0) {
|
|
25518
|
+
final.summary = late.summary;
|
|
25519
|
+
events2.push({
|
|
25520
|
+
type: "task.completed",
|
|
25521
|
+
...turnOf(tracked.turnId),
|
|
25522
|
+
payload: {
|
|
25523
|
+
...linkage(tracked.taskId, call.toolCallId, tracked.facts),
|
|
25524
|
+
status: final.status,
|
|
25525
|
+
summary: late.summary
|
|
25526
|
+
}
|
|
25527
|
+
});
|
|
25528
|
+
}
|
|
25529
|
+
return {
|
|
25530
|
+
events: events2,
|
|
25531
|
+
handled: !tracked.keepToolRow || repeatedTerminal,
|
|
25532
|
+
...turnOf(tracked.turnId)
|
|
25533
|
+
};
|
|
25534
|
+
}
|
|
25535
|
+
let known = tracked;
|
|
25536
|
+
let kind;
|
|
25537
|
+
if (known === void 0) {
|
|
25538
|
+
const recognized = spec.recognize(call);
|
|
25539
|
+
if (recognized === void 0) return void 0;
|
|
25540
|
+
if (recognized === "exclude") {
|
|
25541
|
+
calls.set(call.toolCallId, EXCLUDED);
|
|
25542
|
+
return void 0;
|
|
25543
|
+
}
|
|
25544
|
+
kind = recognized;
|
|
25545
|
+
} else {
|
|
25546
|
+
kind = known.kind;
|
|
25547
|
+
}
|
|
25548
|
+
const resolution = spec.resolve?.(call, kind, {
|
|
25549
|
+
known: known?.announced === true,
|
|
25550
|
+
background: known?.background ?? false
|
|
25551
|
+
});
|
|
25552
|
+
if (known?.phase === "idle" && resolution?.type !== "final") {
|
|
25553
|
+
if (resolution?.type === "background" && resolution.agentRef !== void 0) {
|
|
25554
|
+
rememberAgent(resolution.agentRef, known.taskId, known.facts);
|
|
25555
|
+
}
|
|
25556
|
+
return { events: [], handled: true };
|
|
25557
|
+
}
|
|
25558
|
+
let carriedTurn;
|
|
25559
|
+
if (known === void 0 || !known.announced) {
|
|
25560
|
+
if (resolution === void 0 && !(spec.ready?.(call, kind) ?? true)) {
|
|
25561
|
+
if (known === void 0) {
|
|
25562
|
+
calls.set(call.toolCallId, {
|
|
25563
|
+
kind,
|
|
25564
|
+
taskId: call.toolCallId,
|
|
25565
|
+
turnId: call.turnId,
|
|
25566
|
+
facts: spec.facts(call, kind, void 0),
|
|
25567
|
+
phase: "open",
|
|
25568
|
+
status: void 0,
|
|
25569
|
+
background: false,
|
|
25570
|
+
announced: false
|
|
25571
|
+
});
|
|
25572
|
+
}
|
|
25573
|
+
return { events: [], handled: true };
|
|
25574
|
+
}
|
|
25575
|
+
carriedTurn = known?.turnId;
|
|
25576
|
+
calls.delete(call.toolCallId);
|
|
25577
|
+
known = void 0;
|
|
25578
|
+
}
|
|
25579
|
+
const events = [];
|
|
25580
|
+
const ref = known === void 0 ? spec.resumes?.(call, kind) : void 0;
|
|
25581
|
+
const prior = ref === void 0 ? void 0 : agentTasks.get(ref);
|
|
25582
|
+
const facts = spec.facts(call, kind, prior?.facts ?? known?.facts);
|
|
25583
|
+
const turnId = known?.turnId ?? carriedTurn ?? call.turnId;
|
|
25584
|
+
const turn = turnOf(turnId);
|
|
25585
|
+
let entry;
|
|
25586
|
+
if (known !== void 0) {
|
|
25587
|
+
entry = known;
|
|
25588
|
+
} else if (prior !== void 0) {
|
|
25589
|
+
for (const [id, other] of calls) {
|
|
25590
|
+
if (other === EXCLUDED || other.taskId !== prior.taskId) continue;
|
|
25591
|
+
if (isEntry(other)) calls.set(id, sealedHidden(other));
|
|
25592
|
+
else if (other.final !== void 0) {
|
|
25593
|
+
const { final: _superseded, ...rest } = other;
|
|
25594
|
+
calls.set(id, rest);
|
|
25595
|
+
}
|
|
25596
|
+
}
|
|
25597
|
+
entry = {
|
|
25598
|
+
kind,
|
|
25599
|
+
taskId: prior.taskId,
|
|
25600
|
+
turnId,
|
|
25601
|
+
facts,
|
|
25602
|
+
phase: "open",
|
|
25603
|
+
status: "running",
|
|
25604
|
+
background: false,
|
|
25605
|
+
announced: true
|
|
25606
|
+
};
|
|
25607
|
+
calls.set(call.toolCallId, entry);
|
|
25608
|
+
events.push({
|
|
25609
|
+
type: "task.updated",
|
|
25610
|
+
...turn,
|
|
25611
|
+
payload: {
|
|
25612
|
+
...linkage(entry.taskId, call.toolCallId, facts),
|
|
25613
|
+
description: facts.description,
|
|
25614
|
+
status: "running"
|
|
25615
|
+
}
|
|
25616
|
+
});
|
|
25617
|
+
} else {
|
|
25618
|
+
entry = {
|
|
25619
|
+
kind,
|
|
25620
|
+
taskId: call.toolCallId,
|
|
25621
|
+
turnId,
|
|
25622
|
+
facts,
|
|
25623
|
+
phase: "open",
|
|
25624
|
+
status: void 0,
|
|
25625
|
+
background: false,
|
|
25626
|
+
announced: true
|
|
25627
|
+
};
|
|
25628
|
+
calls.set(call.toolCallId, entry);
|
|
25629
|
+
if (spec.announce === "started") {
|
|
25630
|
+
events.push({
|
|
25631
|
+
type: "task.started",
|
|
25632
|
+
...turn,
|
|
25633
|
+
payload: {
|
|
25634
|
+
...linkage(entry.taskId, call.toolCallId, facts),
|
|
25635
|
+
description: facts.description
|
|
25636
|
+
}
|
|
25637
|
+
});
|
|
25638
|
+
}
|
|
25639
|
+
}
|
|
25640
|
+
const seen = known !== void 0 || prior !== void 0;
|
|
25641
|
+
const wasStatus = entry.status;
|
|
25642
|
+
entry.turnId = turnId;
|
|
25643
|
+
if (resolution?.type === "hold") {
|
|
25644
|
+
entry.facts = facts;
|
|
25645
|
+
return { events, handled: true };
|
|
25646
|
+
}
|
|
25647
|
+
if (resolution?.type === "background") {
|
|
25648
|
+
entry.facts = resolution.role === void 0 ? facts : { ...facts, role: resolution.role };
|
|
25649
|
+
if (!entry.background) {
|
|
25650
|
+
events.push({
|
|
25651
|
+
type: "task.updated",
|
|
25652
|
+
...turn,
|
|
25653
|
+
payload: {
|
|
25654
|
+
...linkage(entry.taskId, call.toolCallId, entry.facts),
|
|
25655
|
+
status: "running",
|
|
25656
|
+
isBackgrounded: true
|
|
25657
|
+
}
|
|
25658
|
+
});
|
|
25659
|
+
}
|
|
25660
|
+
entry.background = true;
|
|
25661
|
+
entry.status = "running";
|
|
25662
|
+
if (resolution.agentRef !== void 0)
|
|
25663
|
+
rememberAgent(resolution.agentRef, entry.taskId, entry.facts);
|
|
25664
|
+
return { events, handled: true };
|
|
25665
|
+
}
|
|
25666
|
+
if (resolution?.type === "final") {
|
|
25667
|
+
const finalFacts = resolution.role === void 0 ? facts : { ...facts, role: resolution.role };
|
|
25668
|
+
const keepToolRow = resolution.keepToolRow === true;
|
|
25669
|
+
const base = linkage(entry.taskId, call.toolCallId, finalFacts);
|
|
25670
|
+
if (resolution.agentRef !== void 0)
|
|
25671
|
+
rememberAgent(resolution.agentRef, entry.taskId, finalFacts);
|
|
25672
|
+
calls.set(call.toolCallId, {
|
|
25673
|
+
sealed: true,
|
|
25674
|
+
keepToolRow,
|
|
25675
|
+
...keepToolRow && (resolution.status === "completed" || resolution.status === "failed") ? { final: { status: resolution.status, summary: resolution.summary } } : {},
|
|
25676
|
+
turnId,
|
|
25677
|
+
kind,
|
|
25678
|
+
taskId: entry.taskId,
|
|
25679
|
+
facts: finalFacts
|
|
25680
|
+
});
|
|
25681
|
+
if (resolution.status === "completed" || resolution.status === "failed") {
|
|
25682
|
+
events.push({
|
|
25683
|
+
type: "task.completed",
|
|
25684
|
+
...turn,
|
|
25685
|
+
payload: {
|
|
25686
|
+
...base,
|
|
25687
|
+
status: resolution.status,
|
|
25688
|
+
...resolution.summary === void 0 ? {} : { summary: resolution.summary }
|
|
25689
|
+
}
|
|
25690
|
+
});
|
|
25691
|
+
} else {
|
|
25692
|
+
events.push({
|
|
25693
|
+
type: "task.updated",
|
|
25694
|
+
...turn,
|
|
25695
|
+
payload: {
|
|
25696
|
+
...base,
|
|
25697
|
+
status: resolution.status,
|
|
25698
|
+
...resolution.status === "idle" ? { outcomeUnknown: true } : {},
|
|
25699
|
+
...resolution.description === void 0 ? {} : { description: resolution.description },
|
|
25700
|
+
...resolution.timelineBypass === true ? { timelineBypass: true } : {}
|
|
25701
|
+
}
|
|
25702
|
+
});
|
|
25703
|
+
}
|
|
25704
|
+
return { events, handled: !keepToolRow, ...turn };
|
|
25705
|
+
}
|
|
25706
|
+
const status = call.status === "pending" && wasStatus !== "running" ? "pending" : "running";
|
|
25707
|
+
const changed = !seen && spec.announce === "progress" ? true : seen && (wasStatus !== status || !sameFacts(entry.facts, facts));
|
|
25708
|
+
entry.facts = facts;
|
|
25709
|
+
entry.status = status;
|
|
25710
|
+
if (changed) {
|
|
25711
|
+
events.push({
|
|
25712
|
+
type: "task.progress",
|
|
25713
|
+
...turn,
|
|
25714
|
+
payload: {
|
|
25715
|
+
...linkage(entry.taskId, call.toolCallId, facts),
|
|
25716
|
+
description: facts.description,
|
|
25717
|
+
...facts.summary === void 0 ? {} : { summary: facts.summary },
|
|
25718
|
+
status
|
|
25719
|
+
}
|
|
25720
|
+
});
|
|
25721
|
+
}
|
|
25722
|
+
return { events, handled: true };
|
|
25723
|
+
};
|
|
25724
|
+
const settle2 = (settlement, turnId) => {
|
|
25725
|
+
const events = [];
|
|
25726
|
+
for (const [toolCallId, entry] of calls) {
|
|
25727
|
+
if (!isEntry(entry)) continue;
|
|
25728
|
+
if (settlement !== "session-ended" && turnId !== void 0 && entry.turnId !== void 0 && entry.turnId !== turnId) {
|
|
25729
|
+
continue;
|
|
25730
|
+
}
|
|
25731
|
+
const interrupted = settlement === "turn-interrupted";
|
|
25732
|
+
const ended = settlement === "session-ended" || interrupted && spec.interruptedMayStillRun !== true;
|
|
25733
|
+
if (!entry.announced) {
|
|
25734
|
+
if (ended) calls.set(toolCallId, sealedHidden(entry));
|
|
25735
|
+
else entry.phase = "idle";
|
|
25736
|
+
continue;
|
|
25737
|
+
}
|
|
25738
|
+
const base = linkage(entry.taskId, toolCallId, entry.facts);
|
|
25739
|
+
const turn = turnOf(entry.turnId);
|
|
25740
|
+
if (ended) {
|
|
25741
|
+
events.push({ type: "task.updated", ...turn, payload: { ...base, status: "cancelled" } });
|
|
25742
|
+
calls.set(toolCallId, sealedHidden(entry));
|
|
25743
|
+
continue;
|
|
25744
|
+
}
|
|
25745
|
+
if (entry.phase === "idle") continue;
|
|
25746
|
+
const note = spec.endNote({ interrupted, background: entry.background });
|
|
25747
|
+
events.push({
|
|
25748
|
+
type: "task.updated",
|
|
25749
|
+
...turn,
|
|
25750
|
+
payload: {
|
|
25751
|
+
...base,
|
|
25752
|
+
status: "idle",
|
|
25753
|
+
outcomeUnknown: true,
|
|
25754
|
+
description: note.description,
|
|
25755
|
+
...note.timelineBypass === true ? { timelineBypass: true } : {}
|
|
25756
|
+
}
|
|
25757
|
+
});
|
|
25758
|
+
entry.phase = "idle";
|
|
25759
|
+
}
|
|
25760
|
+
return events;
|
|
25761
|
+
};
|
|
25762
|
+
const mayStillRun = () => {
|
|
25763
|
+
for (const entry of calls.values()) if (isEntry(entry)) return true;
|
|
25764
|
+
return false;
|
|
25765
|
+
};
|
|
25766
|
+
return { onToolCallUpdated, settle: settle2, mayStillRun };
|
|
25767
|
+
}
|
|
25768
|
+
|
|
25415
25769
|
// ../../packages/ycodium-acp-executor/src/executor/prompt.ts
|
|
25416
25770
|
function createExecutorPrompt({
|
|
25417
25771
|
isLive,
|
|
@@ -25431,7 +25785,8 @@ function createExecutorPrompt({
|
|
|
25431
25785
|
applyRequestedModel,
|
|
25432
25786
|
notifyPromptSettled,
|
|
25433
25787
|
shared,
|
|
25434
|
-
promptResults
|
|
25788
|
+
promptResults,
|
|
25789
|
+
settleToolSubagents
|
|
25435
25790
|
}) {
|
|
25436
25791
|
const settleTurn = (input2) => {
|
|
25437
25792
|
if (!isLive(input2.expectedGeneration) || input2.record.finished) {
|
|
@@ -25455,6 +25810,10 @@ function createExecutorPrompt({
|
|
|
25455
25810
|
shared.status = "ready";
|
|
25456
25811
|
}
|
|
25457
25812
|
const interrupted = promptResults.hasInterrupted(input2.turnId);
|
|
25813
|
+
settleToolSubagents(
|
|
25814
|
+
toolSubagentSettlementOfTurn(interrupted ? "cancelled" : input2.state, input2.failureCategory),
|
|
25815
|
+
input2.turnId
|
|
25816
|
+
);
|
|
25458
25817
|
emit({
|
|
25459
25818
|
type: "turn.completed",
|
|
25460
25819
|
...stamp(),
|
|
@@ -26375,11 +26734,19 @@ function acpInitializePayload(clientInfo, overrides) {
|
|
|
26375
26734
|
writeTextFile: false,
|
|
26376
26735
|
...overrides?.fs
|
|
26377
26736
|
},
|
|
26378
|
-
terminal: overrides?.terminal ?? false
|
|
26737
|
+
terminal: overrides?.terminal ?? false,
|
|
26738
|
+
...overrides?.subagents === true ? { subagents: {} } : {}
|
|
26379
26739
|
},
|
|
26380
26740
|
clientInfo
|
|
26381
26741
|
};
|
|
26382
26742
|
}
|
|
26743
|
+
function acpCapabilityOverrides(input2) {
|
|
26744
|
+
const rest = {
|
|
26745
|
+
...input2.clientCapabilities
|
|
26746
|
+
};
|
|
26747
|
+
delete rest.subagents;
|
|
26748
|
+
return input2.subagentSessions === true ? { ...rest, subagents: true } : rest;
|
|
26749
|
+
}
|
|
26383
26750
|
|
|
26384
26751
|
// ../../packages/ycodium-acp-executor/src/refreshDeadline.ts
|
|
26385
26752
|
var MODEL_CATALOG_REFRESH_TIMEOUT_MS = 9e4;
|
|
@@ -26514,6 +26881,20 @@ function createExecutorSession({
|
|
|
26514
26881
|
failIfDisposed,
|
|
26515
26882
|
shared
|
|
26516
26883
|
}) {
|
|
26884
|
+
const requestSession = async (method, params) => {
|
|
26885
|
+
const knownSessionId = params["sessionId"];
|
|
26886
|
+
if (typeof knownSessionId === "string") shared.ownSessionIds.add(knownSessionId);
|
|
26887
|
+
shared.sessionOpensInFlight += 1;
|
|
26888
|
+
try {
|
|
26889
|
+
const result = await connection.request(method, params);
|
|
26890
|
+
const sessionId = result?.sessionId;
|
|
26891
|
+
if (typeof sessionId === "string" && sessionId.length > 0)
|
|
26892
|
+
shared.ownSessionIds.add(sessionId);
|
|
26893
|
+
return result;
|
|
26894
|
+
} finally {
|
|
26895
|
+
shared.sessionOpensInFlight -= 1;
|
|
26896
|
+
}
|
|
26897
|
+
};
|
|
26517
26898
|
const openFreshSession = async (expectedGeneration) => {
|
|
26518
26899
|
const initialized = shared.initializeResult;
|
|
26519
26900
|
if (initialized === void 0) {
|
|
@@ -26524,7 +26905,7 @@ function createExecutorSession({
|
|
|
26524
26905
|
initialized.agentCapabilities
|
|
26525
26906
|
);
|
|
26526
26907
|
const additionalDirectories = options.additionalDirectories !== void 0 && options.additionalDirectories.length > 0 ? { additionalDirectories: options.additionalDirectories } : {};
|
|
26527
|
-
const created = await
|
|
26908
|
+
const created = await requestSession("session/new", {
|
|
26528
26909
|
cwd: options.cwd,
|
|
26529
26910
|
mcpServers,
|
|
26530
26911
|
...additionalDirectories
|
|
@@ -26641,7 +27022,13 @@ function createExecutorSession({
|
|
|
26641
27022
|
return applyOnce(input2.state, input2.acpSessionId, input2.setup, false);
|
|
26642
27023
|
};
|
|
26643
27024
|
const startOnce = async (expectedGeneration) => {
|
|
26644
|
-
const initializePayload = acpInitializePayload(
|
|
27025
|
+
const initializePayload = acpInitializePayload(
|
|
27026
|
+
options.clientInfo,
|
|
27027
|
+
acpCapabilityOverrides({
|
|
27028
|
+
clientCapabilities: options.clientCapabilities,
|
|
27029
|
+
subagentSessions: options.subagentSessions
|
|
27030
|
+
})
|
|
27031
|
+
);
|
|
26645
27032
|
const initialized = await connection.request(
|
|
26646
27033
|
"initialize",
|
|
26647
27034
|
initializePayload
|
|
@@ -26665,7 +27052,7 @@ function createExecutorSession({
|
|
|
26665
27052
|
let setup;
|
|
26666
27053
|
let nextSessionId;
|
|
26667
27054
|
if (options.resumeSessionId && options.resumeMethod === "session/resume") {
|
|
26668
|
-
setup = await
|
|
27055
|
+
setup = await requestSession("session/resume", {
|
|
26669
27056
|
sessionId: options.resumeSessionId,
|
|
26670
27057
|
cwd: options.cwd,
|
|
26671
27058
|
mcpServers,
|
|
@@ -26675,7 +27062,7 @@ function createExecutorSession({
|
|
|
26675
27062
|
} else if (options.resumeSessionId) {
|
|
26676
27063
|
shared.sessionLoadInFlight = true;
|
|
26677
27064
|
try {
|
|
26678
|
-
setup = await
|
|
27065
|
+
setup = await requestSession("session/load", {
|
|
26679
27066
|
sessionId: options.resumeSessionId,
|
|
26680
27067
|
cwd: options.cwd,
|
|
26681
27068
|
mcpServers,
|
|
@@ -26690,7 +27077,7 @@ function createExecutorSession({
|
|
|
26690
27077
|
});
|
|
26691
27078
|
nextSessionId = options.resumeSessionId;
|
|
26692
27079
|
} else {
|
|
26693
|
-
const created = await
|
|
27080
|
+
const created = await requestSession("session/new", {
|
|
26694
27081
|
cwd: options.cwd,
|
|
26695
27082
|
mcpServers,
|
|
26696
27083
|
...additionalDirectories
|
|
@@ -26875,6 +27262,127 @@ function createExecutorSettlement({
|
|
|
26875
27262
|
return { rememberSettledPromptKey, abortPendingSettlement, settleFromNotification };
|
|
26876
27263
|
}
|
|
26877
27264
|
|
|
27265
|
+
// ../../packages/ycodium-acp-executor/src/executor/subagent-sessions.ts
|
|
27266
|
+
function parseState(raw) {
|
|
27267
|
+
if (!isRecord(raw)) return { status: void 0, error: void 0 };
|
|
27268
|
+
const state = raw["state"];
|
|
27269
|
+
if (state === "running") return { status: "running", error: void 0 };
|
|
27270
|
+
if (state === "requires_action") return { status: "waiting", error: void 0 };
|
|
27271
|
+
if (state !== "idle") return { status: void 0, error: void 0 };
|
|
27272
|
+
const stopReason = raw["stopReason"];
|
|
27273
|
+
const error62 = isRecord(raw["error"]) ? asTrimmedString(raw["error"]["message"]) : void 0;
|
|
27274
|
+
if (stopReason === "error" || isRecord(raw["error"])) return { status: "failed", error: error62 };
|
|
27275
|
+
if (stopReason === "cancelled") return { status: "cancelled", error: void 0 };
|
|
27276
|
+
return { status: "idle", error: void 0 };
|
|
27277
|
+
}
|
|
27278
|
+
function childLinkage(childId, record2) {
|
|
27279
|
+
return {
|
|
27280
|
+
taskType: "subagent",
|
|
27281
|
+
rosterKind: "subagent",
|
|
27282
|
+
nativeSessionId: childId,
|
|
27283
|
+
timelineBypass: true,
|
|
27284
|
+
...record2.title === void 0 ? {} : { title: record2.title }
|
|
27285
|
+
};
|
|
27286
|
+
}
|
|
27287
|
+
function createSubagentSessionTracker(registry2) {
|
|
27288
|
+
const observe = (notification, ctx) => {
|
|
27289
|
+
const update = notification.update;
|
|
27290
|
+
if (!isRecord(update) || update["sessionUpdate"] !== "subagent_update") return [];
|
|
27291
|
+
const childId = asTrimmedString(update["sessionId"]);
|
|
27292
|
+
if (childId === void 0 || ctx.ownSessionIds.has(childId)) return [];
|
|
27293
|
+
const outerId = notification.sessionId;
|
|
27294
|
+
const nested = registry2.has(outerId);
|
|
27295
|
+
if (ctx.foreign && !nested) return [];
|
|
27296
|
+
if (outerId === childId) return [];
|
|
27297
|
+
const title = asTrimmedString(update["title"]);
|
|
27298
|
+
const description = asTrimmedString(update["description"]);
|
|
27299
|
+
const state = parseState(update["state"]);
|
|
27300
|
+
let record2 = registry2.get(childId);
|
|
27301
|
+
if (record2 === void 0) {
|
|
27302
|
+
record2 = {
|
|
27303
|
+
turnId: ctx.turnId,
|
|
27304
|
+
title,
|
|
27305
|
+
description,
|
|
27306
|
+
parentAgentId: nested ? outerId : void 0,
|
|
27307
|
+
observed: state.status,
|
|
27308
|
+
reported: void 0,
|
|
27309
|
+
reportedError: void 0,
|
|
27310
|
+
// 重放里恢复的身份:宿主早有这一行,不再发 started。
|
|
27311
|
+
announced: ctx.silent,
|
|
27312
|
+
pendingMetadata: false
|
|
27313
|
+
};
|
|
27314
|
+
registry2.add(childId, record2);
|
|
27315
|
+
}
|
|
27316
|
+
record2.turnId ??= ctx.turnId;
|
|
27317
|
+
if (!ctx.silent) {
|
|
27318
|
+
if (title !== void 0 && title !== record2.title || description !== void 0 && description !== record2.description) {
|
|
27319
|
+
record2.pendingMetadata = true;
|
|
27320
|
+
}
|
|
27321
|
+
}
|
|
27322
|
+
if (title !== void 0) record2.title = title;
|
|
27323
|
+
if (description !== void 0) record2.description = description;
|
|
27324
|
+
if (state.status !== void 0) record2.observed = state.status;
|
|
27325
|
+
if (ctx.silent) return [];
|
|
27326
|
+
const linkage2 = childLinkage(childId, record2);
|
|
27327
|
+
const turn = record2.turnId === void 0 ? {} : { turnId: record2.turnId };
|
|
27328
|
+
const events = [];
|
|
27329
|
+
if (!record2.announced && state.status === void 0) return events;
|
|
27330
|
+
if (!record2.announced) {
|
|
27331
|
+
record2.announced = true;
|
|
27332
|
+
record2.pendingMetadata = false;
|
|
27333
|
+
events.push({
|
|
27334
|
+
type: "task.started",
|
|
27335
|
+
...turn,
|
|
27336
|
+
payload: {
|
|
27337
|
+
taskId: childId,
|
|
27338
|
+
...linkage2,
|
|
27339
|
+
...record2.description === void 0 ? {} : { description: record2.description }
|
|
27340
|
+
}
|
|
27341
|
+
});
|
|
27342
|
+
}
|
|
27343
|
+
const statusChanged = state.status !== void 0 && (state.status !== record2.reported || record2.pendingMetadata || state.error !== void 0 && state.error !== record2.reportedError);
|
|
27344
|
+
if (statusChanged) {
|
|
27345
|
+
record2.pendingMetadata = false;
|
|
27346
|
+
record2.reported = state.status;
|
|
27347
|
+
record2.reportedError = state.status === "failed" ? state.error ?? record2.reportedError : void 0;
|
|
27348
|
+
events.push({
|
|
27349
|
+
type: "task.updated",
|
|
27350
|
+
...turn,
|
|
27351
|
+
payload: {
|
|
27352
|
+
taskId: childId,
|
|
27353
|
+
status: state.status,
|
|
27354
|
+
...state.error === void 0 ? {} : { error: state.error },
|
|
27355
|
+
...record2.description === void 0 ? {} : { description: record2.description },
|
|
27356
|
+
...linkage2
|
|
27357
|
+
}
|
|
27358
|
+
});
|
|
27359
|
+
}
|
|
27360
|
+
return events;
|
|
27361
|
+
};
|
|
27362
|
+
const settleSessionEnded = () => {
|
|
27363
|
+
const events = [];
|
|
27364
|
+
for (const [childId, record2] of registry2.entries()) {
|
|
27365
|
+
const last = record2.reported ?? record2.observed;
|
|
27366
|
+
if (!record2.announced || last !== "running" && last !== "waiting") continue;
|
|
27367
|
+
record2.reported = "idle";
|
|
27368
|
+
record2.observed = "idle";
|
|
27369
|
+
events.push({
|
|
27370
|
+
type: "task.updated",
|
|
27371
|
+
...record2.turnId === void 0 ? {} : { turnId: record2.turnId },
|
|
27372
|
+
payload: {
|
|
27373
|
+
taskId: childId,
|
|
27374
|
+
status: "idle",
|
|
27375
|
+
outcomeUnknown: true,
|
|
27376
|
+
...record2.description === void 0 ? {} : { description: record2.description },
|
|
27377
|
+
...childLinkage(childId, record2)
|
|
27378
|
+
}
|
|
27379
|
+
});
|
|
27380
|
+
}
|
|
27381
|
+
return events;
|
|
27382
|
+
};
|
|
27383
|
+
return { observe, settleSessionEnded };
|
|
27384
|
+
}
|
|
27385
|
+
|
|
26878
27386
|
// ../../packages/ycodium-acp-executor/src/executor/updates.ts
|
|
26879
27387
|
var COMPACTION_SUMMARY_MAX_CHARS = 8e3;
|
|
26880
27388
|
var SHOWN_TOOL_CALL_LIMIT = 256;
|
|
@@ -26893,6 +27401,8 @@ function createExecutorUpdates({
|
|
|
26893
27401
|
shared
|
|
26894
27402
|
}) {
|
|
26895
27403
|
const shownToolCallIds = /* @__PURE__ */ new Set();
|
|
27404
|
+
const markChildSession = shared.childSessions.mark;
|
|
27405
|
+
const subagentSessions = options.subagentSessions === true ? createSubagentSessionTracker(shared.childSessions) : void 0;
|
|
26896
27406
|
const emitCompactionState = (record2, state) => {
|
|
26897
27407
|
const summary = record2.summary?.trim() ?? "";
|
|
26898
27408
|
const truncated = summary.length > COMPACTION_SUMMARY_MAX_CHARS;
|
|
@@ -26978,6 +27488,30 @@ function createExecutorUpdates({
|
|
|
26978
27488
|
return;
|
|
26979
27489
|
}
|
|
26980
27490
|
};
|
|
27491
|
+
const emitTaskEvents = (taskEvents) => {
|
|
27492
|
+
for (const taskEvent of taskEvents ?? []) {
|
|
27493
|
+
emit({
|
|
27494
|
+
type: taskEvent.type,
|
|
27495
|
+
...stamp(),
|
|
27496
|
+
provider: options.provider,
|
|
27497
|
+
threadId: options.threadId,
|
|
27498
|
+
...taskEvent.turnId !== void 0 ? { turnId: taskEvent.turnId } : {},
|
|
27499
|
+
payload: taskEvent.payload
|
|
27500
|
+
});
|
|
27501
|
+
}
|
|
27502
|
+
};
|
|
27503
|
+
const toolSubagents = hooks.toolSubagents === void 0 ? void 0 : createToolSubagentTracker(hooks.toolSubagents);
|
|
27504
|
+
const settleToolSubagents = (settlement, turnId) => emitTaskEvents(toolSubagents?.settle(settlement, turnId));
|
|
27505
|
+
const settleSessionEnded = () => {
|
|
27506
|
+
settleToolSubagents("session-ended");
|
|
27507
|
+
emitTaskEvents(subagentSessions?.settleSessionEnded());
|
|
27508
|
+
emitTaskEvents(hooks.onSessionEnded?.());
|
|
27509
|
+
};
|
|
27510
|
+
const observeContext = () => ({
|
|
27511
|
+
turnId: shared.activeTurnId,
|
|
27512
|
+
sessionId: shared.sessionId,
|
|
27513
|
+
markChildSession
|
|
27514
|
+
});
|
|
26981
27515
|
const handleSessionUpdate = (params) => {
|
|
26982
27516
|
const parsed = parseSessionUpdateEvent(params);
|
|
26983
27517
|
if (parsed.modeId && shared.modeState) {
|
|
@@ -27004,43 +27538,39 @@ function createExecutorUpdates({
|
|
|
27004
27538
|
rawTitle: params.update.title,
|
|
27005
27539
|
nowMs
|
|
27006
27540
|
});
|
|
27007
|
-
const
|
|
27541
|
+
const hasToolHooks = toolSubagents !== void 0 || hooks.onToolCallUpdated !== void 0;
|
|
27542
|
+
const call = !hasToolHooks ? void 0 : {
|
|
27008
27543
|
toolCallId: nextToolCall.toolCallId,
|
|
27009
27544
|
status: nextToolCall.status,
|
|
27010
27545
|
title: nextToolCall.title,
|
|
27011
27546
|
kind: nextToolCall.kind,
|
|
27012
27547
|
rawInput: nextToolCall.data["rawInput"],
|
|
27013
27548
|
rawOutput: nextToolCall.data["rawOutput"],
|
|
27549
|
+
contentText: nextToolCall.contentText,
|
|
27014
27550
|
meta: params.update._meta,
|
|
27015
27551
|
turnId: shared.activeTurnId
|
|
27016
|
-
}
|
|
27017
|
-
const
|
|
27552
|
+
};
|
|
27553
|
+
const hookResult = call === void 0 ? void 0 : toolSubagents?.onToolCallUpdated(call) ?? hooks.onToolCallUpdated?.(call);
|
|
27018
27554
|
const handledByHook = hookResult !== void 0 && "events" in hookResult && hookResult.handled === true;
|
|
27019
|
-
|
|
27020
|
-
|
|
27021
|
-
|
|
27022
|
-
...stamp(),
|
|
27023
|
-
provider: options.provider,
|
|
27024
|
-
threadId: options.threadId,
|
|
27025
|
-
...taskEvent.turnId !== void 0 ? { turnId: taskEvent.turnId } : {},
|
|
27026
|
-
payload: taskEvent.payload
|
|
27027
|
-
});
|
|
27028
|
-
}
|
|
27555
|
+
emitTaskEvents(
|
|
27556
|
+
hookResult === void 0 ? [] : "events" in hookResult ? hookResult.events : hookResult
|
|
27557
|
+
);
|
|
27029
27558
|
if (nextToolCall.status === "completed" && hookResult && "artifacts" in hookResult)
|
|
27030
27559
|
emitArtifacts(hookResult.artifacts ?? [], nextToolCall.toolCallId);
|
|
27031
27560
|
if (handledByHook || !decision.emit) {
|
|
27032
27561
|
continue;
|
|
27033
27562
|
}
|
|
27563
|
+
const toolTurnId = (hookResult !== void 0 && "events" in hookResult ? hookResult.turnId : void 0) ?? shared.activeTurnId;
|
|
27034
27564
|
if (!shownToolCallIds.has(nextToolCall.toolCallId)) {
|
|
27035
27565
|
rememberShownToolCall(nextToolCall.toolCallId);
|
|
27036
|
-
closeActiveAssistantSegment(shared.activeTurnId);
|
|
27566
|
+
if (toolTurnId === shared.activeTurnId) closeActiveAssistantSegment(shared.activeTurnId);
|
|
27037
27567
|
}
|
|
27038
27568
|
emit(
|
|
27039
27569
|
makeAcpToolCallEvent({
|
|
27040
27570
|
stamp: stamp(),
|
|
27041
27571
|
provider: options.provider,
|
|
27042
27572
|
threadId: options.threadId,
|
|
27043
|
-
turnId:
|
|
27573
|
+
turnId: toolTurnId,
|
|
27044
27574
|
toolCall: nextToolCall,
|
|
27045
27575
|
rawPayload: event.rawPayload
|
|
27046
27576
|
})
|
|
@@ -27117,7 +27647,36 @@ function createExecutorUpdates({
|
|
|
27117
27647
|
}
|
|
27118
27648
|
}
|
|
27119
27649
|
};
|
|
27120
|
-
|
|
27650
|
+
const receiveSessionUpdate = (params) => {
|
|
27651
|
+
const foreign = !shared.ownSessionIds.has(params.sessionId) && (shared.childSessions.has(params.sessionId) || shared.sessionOpensInFlight === 0 && shared.ownSessionIds.size > 0);
|
|
27652
|
+
emitTaskEvents(
|
|
27653
|
+
subagentSessions?.observe(params, {
|
|
27654
|
+
turnId: shared.activeTurnId,
|
|
27655
|
+
foreign,
|
|
27656
|
+
ownSessionIds: shared.ownSessionIds,
|
|
27657
|
+
silent: shared.sessionLoadInFlight
|
|
27658
|
+
})
|
|
27659
|
+
);
|
|
27660
|
+
if (!shared.sessionLoadInFlight) {
|
|
27661
|
+
if (hooks.onSessionUpdate) {
|
|
27662
|
+
emitTaskEvents(hooks.onSessionUpdate(params, { ...observeContext(), foreign }));
|
|
27663
|
+
}
|
|
27664
|
+
}
|
|
27665
|
+
if (!foreign) handleSessionUpdate(params);
|
|
27666
|
+
};
|
|
27667
|
+
const receiveExtensionNotification = (method, params) => {
|
|
27668
|
+
if (shared.sessionLoadInFlight || !hooks.onExtensionNotification) return;
|
|
27669
|
+
const result = hooks.onExtensionNotification(method, params, observeContext());
|
|
27670
|
+
if (Array.isArray(result)) emitTaskEvents(result);
|
|
27671
|
+
};
|
|
27672
|
+
return {
|
|
27673
|
+
emitCompactionState,
|
|
27674
|
+
receiveSessionUpdate,
|
|
27675
|
+
receiveExtensionNotification,
|
|
27676
|
+
settleToolSubagents,
|
|
27677
|
+
settleSessionEnded,
|
|
27678
|
+
toolSubagentsMayRun: () => toolSubagents?.mayStillRun() ?? false
|
|
27679
|
+
};
|
|
27121
27680
|
}
|
|
27122
27681
|
|
|
27123
27682
|
// ../../packages/ycodium-acp-executor/src/openCommands.ts
|
|
@@ -27266,7 +27825,10 @@ function createAcpExecutor(options) {
|
|
|
27266
27825
|
abortLocalPrompt: void 0,
|
|
27267
27826
|
connectionClosed: false,
|
|
27268
27827
|
sessionLoadInFlight: false,
|
|
27269
|
-
droppedReplayUpdates: 0
|
|
27828
|
+
droppedReplayUpdates: 0,
|
|
27829
|
+
ownSessionIds: /* @__PURE__ */ new Set(),
|
|
27830
|
+
childSessions: createChildSessionRegistry(),
|
|
27831
|
+
sessionOpensInFlight: 0
|
|
27270
27832
|
};
|
|
27271
27833
|
const interruptedTurnIds = /* @__PURE__ */ new Set();
|
|
27272
27834
|
const approvals = createApprovalGate({
|
|
@@ -27296,7 +27858,14 @@ function createAcpExecutor(options) {
|
|
|
27296
27858
|
promptMutex,
|
|
27297
27859
|
shared
|
|
27298
27860
|
});
|
|
27299
|
-
const {
|
|
27861
|
+
const {
|
|
27862
|
+
emitCompactionState,
|
|
27863
|
+
receiveSessionUpdate,
|
|
27864
|
+
receiveExtensionNotification,
|
|
27865
|
+
settleToolSubagents,
|
|
27866
|
+
settleSessionEnded,
|
|
27867
|
+
toolSubagentsMayRun
|
|
27868
|
+
} = createExecutorUpdates({
|
|
27300
27869
|
emit,
|
|
27301
27870
|
stamp,
|
|
27302
27871
|
options,
|
|
@@ -27359,11 +27928,11 @@ function createAcpExecutor(options) {
|
|
|
27359
27928
|
if (notification.method === "session/update") {
|
|
27360
27929
|
const params = notification.params;
|
|
27361
27930
|
const transformed = hooks.transformSessionUpdate ? hooks.transformSessionUpdate(params) : params;
|
|
27362
|
-
if (transformed !== void 0)
|
|
27931
|
+
if (transformed !== void 0) receiveSessionUpdate(transformed);
|
|
27363
27932
|
return;
|
|
27364
27933
|
}
|
|
27365
27934
|
if (settleFromNotification(notification.method, notification.params)) return;
|
|
27366
|
-
|
|
27935
|
+
receiveExtensionNotification(notification.method, notification.params);
|
|
27367
27936
|
},
|
|
27368
27937
|
onRequest: async (method, params) => {
|
|
27369
27938
|
if (method === CLIENT_METHODS.session_request_permission) {
|
|
@@ -27419,6 +27988,7 @@ function createAcpExecutor(options) {
|
|
|
27419
27988
|
});
|
|
27420
27989
|
const { sendPromptRpc, prompt } = createExecutorPrompt({
|
|
27421
27990
|
promptResults,
|
|
27991
|
+
settleToolSubagents,
|
|
27422
27992
|
isLive,
|
|
27423
27993
|
closeActiveAssistantSegment,
|
|
27424
27994
|
emit,
|
|
@@ -27443,6 +28013,8 @@ function createAcpExecutor(options) {
|
|
|
27443
28013
|
dispose: disposeLifecycle
|
|
27444
28014
|
} = createExecutorLifecycle({
|
|
27445
28015
|
promptResults,
|
|
28016
|
+
settleToolSubagents,
|
|
28017
|
+
settleSessionEnded,
|
|
27446
28018
|
failIfDisposed,
|
|
27447
28019
|
requireStarted,
|
|
27448
28020
|
interruptedTurnIds,
|
|
@@ -27491,6 +28063,7 @@ function createAcpExecutor(options) {
|
|
|
27491
28063
|
setNativeMode,
|
|
27492
28064
|
compact,
|
|
27493
28065
|
openToolCalls: () => readOpenToolCalls(toolCalls, shared.activeTurnId),
|
|
28066
|
+
toolSubagentsMayRun,
|
|
27494
28067
|
dispose: (exitCode) => {
|
|
27495
28068
|
disposeOnce ??= (async () => {
|
|
27496
28069
|
try {
|
|
@@ -27693,7 +28266,13 @@ async function openAcpProbeHandshake(input2) {
|
|
|
27693
28266
|
});
|
|
27694
28267
|
try {
|
|
27695
28268
|
const initializeResult = await withProbeTimeout(
|
|
27696
|
-
connection.request(
|
|
28269
|
+
connection.request(
|
|
28270
|
+
"initialize",
|
|
28271
|
+
acpInitializePayload(
|
|
28272
|
+
input2.clientInfo,
|
|
28273
|
+
acpCapabilityOverrides({ subagentSessions: input2.subagentSessions })
|
|
28274
|
+
)
|
|
28275
|
+
),
|
|
27697
28276
|
input2.requestTimeoutMs,
|
|
27698
28277
|
"ACP probe request 'initialize'",
|
|
27699
28278
|
input2.signal
|
|
@@ -28024,6 +28603,7 @@ async function probeAcpModelsViaSession(input2) {
|
|
|
28024
28603
|
readable,
|
|
28025
28604
|
writable,
|
|
28026
28605
|
clientInfo: CLIENT_INFO,
|
|
28606
|
+
subagentSessions: true,
|
|
28027
28607
|
requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS
|
|
28028
28608
|
}),
|
|
28029
28609
|
input2.signal
|
|
@@ -28081,6 +28661,7 @@ async function probeAcpAgentVersion(input2) {
|
|
|
28081
28661
|
readable,
|
|
28082
28662
|
writable,
|
|
28083
28663
|
clientInfo: CLIENT_INFO,
|
|
28664
|
+
subagentSessions: true,
|
|
28084
28665
|
requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS,
|
|
28085
28666
|
signal: operation.signal
|
|
28086
28667
|
});
|
|
@@ -28313,6 +28894,8 @@ var createAcpInstance = (config2, host) => {
|
|
|
28313
28894
|
provider: ACP_DRIVER_KIND,
|
|
28314
28895
|
providerInstanceId: host.instanceId,
|
|
28315
28896
|
clientInfo: CLIENT_INFO2,
|
|
28897
|
+
// 背后的 agent 支持 ACP 子会话就把派出的子 agent 报进 agent 列表;不支持的 agent 按协议不会发。
|
|
28898
|
+
subagentSessions: true,
|
|
28316
28899
|
log: host.log,
|
|
28317
28900
|
// agent 自己宣告的斜杠命令按会话报给宿主,输入区的 / 菜单才有它们。
|
|
28318
28901
|
onAvailableCommands: (commands) => host.reportSessionInventory?.({
|
|
@@ -28481,7 +29064,7 @@ var executors = [
|
|
|
28481
29064
|
];
|
|
28482
29065
|
var index_default = definePlugin({
|
|
28483
29066
|
id: "agent-acp",
|
|
28484
|
-
apiVersion:
|
|
29067
|
+
apiVersion: 49,
|
|
28485
29068
|
executors,
|
|
28486
29069
|
activate(ctx) {
|
|
28487
29070
|
ctx.log.info("generic ACP executor ready");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-acp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3608",
|
|
4
4
|
"description": "Generic ACP executor: user-supplied CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
25
|
-
"ycodium-
|
|
26
|
-
"ycodium-executor
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.3608",
|
|
25
|
+
"ycodium-executor-testing": "0.0.0",
|
|
26
|
+
"ycodium-acp-executor": "0.2.3608"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|
|
29
29
|
"plugin": "./dist/index.js",
|