chatroom-cli 1.58.4 → 1.58.6
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 +359 -274
- package/dist/index.js.map +23 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28962,6 +28962,23 @@ var init_commandcode = __esm(() => {
|
|
|
28962
28962
|
init_command_code_agent_service();
|
|
28963
28963
|
});
|
|
28964
28964
|
|
|
28965
|
+
// src/infrastructure/services/remote-agents/wire-native-stream-adapter.ts
|
|
28966
|
+
function wireNativeStreamAdapter(args2) {
|
|
28967
|
+
args2.adapter.setAssistantTextCapture((text) => {
|
|
28968
|
+
for (const cb of args2.assistantTextCallbacks)
|
|
28969
|
+
cb(text);
|
|
28970
|
+
});
|
|
28971
|
+
args2.adapter.onOutput(() => {
|
|
28972
|
+
args2.entry.lastOutputAt = Date.now();
|
|
28973
|
+
for (const cb of args2.outputCallbacks)
|
|
28974
|
+
cb();
|
|
28975
|
+
});
|
|
28976
|
+
args2.adapter.onAgentEnd(() => {
|
|
28977
|
+
for (const cb of args2.agentEndCallbacks)
|
|
28978
|
+
cb();
|
|
28979
|
+
});
|
|
28980
|
+
}
|
|
28981
|
+
|
|
28965
28982
|
// src/infrastructure/services/remote-agents/cursor-sdk/cursor-models.ts
|
|
28966
28983
|
function resolveCursorSdkModel(model) {
|
|
28967
28984
|
const prefix = `${CURSOR_PROVIDER2}/`;
|
|
@@ -29086,103 +29103,132 @@ function closeCursorAgentOnFailure(agent, session2, exitCode, force = false) {
|
|
|
29086
29103
|
} catch {}
|
|
29087
29104
|
}
|
|
29088
29105
|
|
|
29089
|
-
// src/infrastructure/services/remote-agents/
|
|
29090
|
-
|
|
29106
|
+
// src/infrastructure/services/remote-agents/assistant-text-capture.ts
|
|
29107
|
+
function createAssistantTextCapture() {
|
|
29108
|
+
let onAssistantText;
|
|
29109
|
+
return {
|
|
29110
|
+
setAssistantTextCapture(cb) {
|
|
29111
|
+
onAssistantText = cb;
|
|
29112
|
+
},
|
|
29113
|
+
captureAssistantText(text) {
|
|
29114
|
+
onAssistantText?.(text);
|
|
29115
|
+
}
|
|
29116
|
+
};
|
|
29117
|
+
}
|
|
29118
|
+
|
|
29119
|
+
// src/infrastructure/services/remote-agents/native-stream-adapter-base.ts
|
|
29120
|
+
class NativeStreamAdapterBase {
|
|
29091
29121
|
logPrefix;
|
|
29092
29122
|
emitLogLine;
|
|
29093
29123
|
agentEndCallbacks = [];
|
|
29094
29124
|
outputCallbacks = [];
|
|
29095
29125
|
agentEndEmitted = false;
|
|
29096
|
-
|
|
29126
|
+
assistantTextCapture = createAssistantTextCapture();
|
|
29097
29127
|
constructor(logPrefix, emitLogLine) {
|
|
29098
29128
|
this.logPrefix = logPrefix;
|
|
29099
29129
|
this.emitLogLine = emitLogLine;
|
|
29100
29130
|
}
|
|
29131
|
+
setAssistantTextCapture(cb) {
|
|
29132
|
+
this.assistantTextCapture.setAssistantTextCapture(cb);
|
|
29133
|
+
}
|
|
29101
29134
|
onAgentEnd(cb) {
|
|
29102
29135
|
this.agentEndCallbacks.push(cb);
|
|
29103
29136
|
}
|
|
29104
29137
|
onOutput(cb) {
|
|
29105
29138
|
this.outputCallbacks.push(cb);
|
|
29106
29139
|
}
|
|
29107
|
-
|
|
29108
|
-
this.
|
|
29109
|
-
|
|
29110
|
-
|
|
29111
|
-
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
|
|
29116
|
-
|
|
29117
|
-
|
|
29140
|
+
notifyOutput() {
|
|
29141
|
+
for (const cb of this.outputCallbacks)
|
|
29142
|
+
cb();
|
|
29143
|
+
}
|
|
29144
|
+
writeLine(line) {
|
|
29145
|
+
this.emitLogLine?.(line);
|
|
29146
|
+
}
|
|
29147
|
+
}
|
|
29148
|
+
var init_native_stream_adapter_base = () => {};
|
|
29149
|
+
|
|
29150
|
+
// src/infrastructure/services/remote-agents/cursor-sdk/cursor-sdk-stream-adapter.ts
|
|
29151
|
+
var CursorSdkStreamAdapter;
|
|
29152
|
+
var init_cursor_sdk_stream_adapter = __esm(() => {
|
|
29153
|
+
init_native_stream_adapter_base();
|
|
29154
|
+
CursorSdkStreamAdapter = class CursorSdkStreamAdapter extends NativeStreamAdapterBase {
|
|
29155
|
+
textBuffer = "";
|
|
29156
|
+
handleMessage(message) {
|
|
29157
|
+
this.notifyOutput();
|
|
29158
|
+
switch (message.type) {
|
|
29159
|
+
case "assistant":
|
|
29160
|
+
this.handleAssistant(message);
|
|
29161
|
+
break;
|
|
29162
|
+
case "tool_call": {
|
|
29163
|
+
this.flushText();
|
|
29164
|
+
const bashCmd = extractBashCommandFromToolInput(message.name, message.args);
|
|
29165
|
+
if (bashCmd !== null) {
|
|
29166
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, BASH_TOOL_KIND, formatBashRunningPayload(bashCmd)));
|
|
29167
|
+
break;
|
|
29168
|
+
}
|
|
29169
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, `tool: ${message.call_id} ${message.name} ${JSON.stringify({ status: message.status, args: message.args })}`));
|
|
29118
29170
|
break;
|
|
29119
29171
|
}
|
|
29120
|
-
|
|
29121
|
-
|
|
29172
|
+
case "status":
|
|
29173
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, `status: ${message.status}`));
|
|
29174
|
+
break;
|
|
29175
|
+
case "thinking":
|
|
29176
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "thinking", message.text));
|
|
29177
|
+
break;
|
|
29178
|
+
case "system":
|
|
29179
|
+
if (message.subtype === "init") {
|
|
29180
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "system: init"));
|
|
29181
|
+
}
|
|
29182
|
+
break;
|
|
29183
|
+
default:
|
|
29184
|
+
break;
|
|
29122
29185
|
}
|
|
29123
|
-
case "status":
|
|
29124
|
-
this.writeLine(formatAgentLogLine(this.logPrefix, `status: ${message.status}`));
|
|
29125
|
-
break;
|
|
29126
|
-
case "thinking":
|
|
29127
|
-
this.writeLine(formatAgentLogLine(this.logPrefix, "thinking", message.text));
|
|
29128
|
-
break;
|
|
29129
|
-
case "system":
|
|
29130
|
-
if (message.subtype === "init") {
|
|
29131
|
-
this.writeLine(formatAgentLogLine(this.logPrefix, "system: init"));
|
|
29132
|
-
}
|
|
29133
|
-
break;
|
|
29134
|
-
default:
|
|
29135
|
-
break;
|
|
29136
29186
|
}
|
|
29137
|
-
|
|
29138
|
-
|
|
29139
|
-
|
|
29140
|
-
|
|
29141
|
-
|
|
29142
|
-
|
|
29143
|
-
|
|
29144
|
-
|
|
29145
|
-
|
|
29146
|
-
|
|
29147
|
-
|
|
29148
|
-
|
|
29149
|
-
|
|
29187
|
+
flushPendingOutput() {
|
|
29188
|
+
this.flushText();
|
|
29189
|
+
}
|
|
29190
|
+
finish() {
|
|
29191
|
+
this.flushText();
|
|
29192
|
+
this.emitAgentEnd();
|
|
29193
|
+
}
|
|
29194
|
+
handleAssistant(message) {
|
|
29195
|
+
for (const block of message.message.content) {
|
|
29196
|
+
if (block.type === "text") {
|
|
29197
|
+
this.textBuffer += block.text;
|
|
29198
|
+
this.assistantTextCapture.captureAssistantText(block.text);
|
|
29199
|
+
if (this.textBuffer.includes(`
|
|
29150
29200
|
`)) {
|
|
29151
|
-
|
|
29201
|
+
this.flushText();
|
|
29202
|
+
}
|
|
29152
29203
|
}
|
|
29153
29204
|
}
|
|
29154
29205
|
}
|
|
29155
|
-
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
for (const line of this.textBuffer.split(`
|
|
29206
|
+
flushText() {
|
|
29207
|
+
if (!this.textBuffer)
|
|
29208
|
+
return;
|
|
29209
|
+
for (const line of this.textBuffer.split(`
|
|
29160
29210
|
`)) {
|
|
29161
|
-
|
|
29162
|
-
|
|
29211
|
+
if (line)
|
|
29212
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "text", line));
|
|
29213
|
+
}
|
|
29214
|
+
this.textBuffer = "";
|
|
29163
29215
|
}
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
|
|
29173
|
-
|
|
29174
|
-
|
|
29175
|
-
writeLine(formatted) {
|
|
29176
|
-
process.stdout.write(`${formatted}
|
|
29216
|
+
emitAgentEnd() {
|
|
29217
|
+
if (this.agentEndEmitted)
|
|
29218
|
+
return;
|
|
29219
|
+
this.agentEndEmitted = true;
|
|
29220
|
+
this.flushText();
|
|
29221
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "agent_end"));
|
|
29222
|
+
for (const cb of this.agentEndCallbacks)
|
|
29223
|
+
cb();
|
|
29224
|
+
}
|
|
29225
|
+
writeLine(formatted) {
|
|
29226
|
+
process.stdout.write(`${formatted}
|
|
29177
29227
|
`);
|
|
29178
|
-
|
|
29179
|
-
|
|
29180
|
-
|
|
29181
|
-
|
|
29182
|
-
cb();
|
|
29183
|
-
}
|
|
29184
|
-
}
|
|
29185
|
-
var init_cursor_sdk_stream_adapter = () => {};
|
|
29228
|
+
this.emitLogLine?.(formatted);
|
|
29229
|
+
}
|
|
29230
|
+
};
|
|
29231
|
+
});
|
|
29186
29232
|
|
|
29187
29233
|
// src/infrastructure/services/remote-agents/with-timeout.ts
|
|
29188
29234
|
async function withTimeout(p, ms, label) {
|
|
@@ -29453,6 +29499,7 @@ ${options.prompt}`;
|
|
|
29453
29499
|
const outputCallbacks = [];
|
|
29454
29500
|
const agentEndCallbacks = [];
|
|
29455
29501
|
const logLineCallbacks = [];
|
|
29502
|
+
const assistantTextCallbacks = [];
|
|
29456
29503
|
const emitLogLine = (line) => {
|
|
29457
29504
|
for (const cb of logLineCallbacks)
|
|
29458
29505
|
cb(line);
|
|
@@ -29477,6 +29524,7 @@ ${options.prompt}`;
|
|
|
29477
29524
|
finishExit,
|
|
29478
29525
|
outputCallbacks,
|
|
29479
29526
|
agentEndCallbacks,
|
|
29527
|
+
assistantTextCallbacks,
|
|
29480
29528
|
emitLogLine
|
|
29481
29529
|
});
|
|
29482
29530
|
return {
|
|
@@ -29497,6 +29545,9 @@ ${options.prompt}`;
|
|
|
29497
29545
|
},
|
|
29498
29546
|
onLogLine: (cb) => {
|
|
29499
29547
|
logLineCallbacks.push(cb);
|
|
29548
|
+
},
|
|
29549
|
+
onAssistantText: (cb) => {
|
|
29550
|
+
assistantTextCallbacks.push(cb);
|
|
29500
29551
|
}
|
|
29501
29552
|
};
|
|
29502
29553
|
}
|
|
@@ -29512,6 +29563,7 @@ ${options.prompt}`;
|
|
|
29512
29563
|
entry,
|
|
29513
29564
|
outputCallbacks,
|
|
29514
29565
|
agentEndCallbacks,
|
|
29566
|
+
assistantTextCallbacks,
|
|
29515
29567
|
emitLogLine
|
|
29516
29568
|
} = args2;
|
|
29517
29569
|
let exited = false;
|
|
@@ -29549,14 +29601,12 @@ ${deferredResume}` : deferredResume;
|
|
|
29549
29601
|
session2.run = run3;
|
|
29550
29602
|
isFirstTurn = false;
|
|
29551
29603
|
const adapter = new CursorSdkStreamAdapter(logPrefix, emitLogLine);
|
|
29552
|
-
|
|
29553
|
-
|
|
29554
|
-
|
|
29555
|
-
|
|
29556
|
-
|
|
29557
|
-
|
|
29558
|
-
for (const cb of agentEndCallbacks)
|
|
29559
|
-
cb();
|
|
29604
|
+
wireNativeStreamAdapter({
|
|
29605
|
+
adapter,
|
|
29606
|
+
assistantTextCallbacks,
|
|
29607
|
+
outputCallbacks,
|
|
29608
|
+
agentEndCallbacks,
|
|
29609
|
+
entry
|
|
29560
29610
|
});
|
|
29561
29611
|
try {
|
|
29562
29612
|
for await (const message of run3.stream()) {
|
|
@@ -31920,8 +31970,10 @@ function startSessionEventForwarder(client4, options) {
|
|
|
31920
31970
|
}
|
|
31921
31971
|
async function handleTextPartUpdate(props, part) {
|
|
31922
31972
|
const chunk2 = resolvePartContent(props?.delta, part.text);
|
|
31923
|
-
if (chunk2)
|
|
31973
|
+
if (chunk2) {
|
|
31974
|
+
options.onAssistantText?.(chunk2);
|
|
31924
31975
|
logLine(target, "text", chunk2);
|
|
31976
|
+
}
|
|
31925
31977
|
}
|
|
31926
31978
|
async function handleReasoningPartUpdate(props, part) {
|
|
31927
31979
|
const chunk2 = resolvePartContent(props?.delta, part.text);
|
|
@@ -32187,6 +32239,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32187
32239
|
init_terminal_provider_error();
|
|
32188
32240
|
OpenCodeSdkAgentService = class OpenCodeSdkAgentService extends OpenCodeBinaryAgentService {
|
|
32189
32241
|
agentEndCallbacksByPid = new Map;
|
|
32242
|
+
assistantTextCallbacksByPid = new Map;
|
|
32190
32243
|
id = "opencode-sdk";
|
|
32191
32244
|
displayName = "OpenCode (SDK)";
|
|
32192
32245
|
listModelsHarnessId = "opencode-sdk";
|
|
@@ -32312,6 +32365,9 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32312
32365
|
const entry = this.registerProcess(pid, context5);
|
|
32313
32366
|
if (forwarder)
|
|
32314
32367
|
this.forwarders.set(pid, forwarder);
|
|
32368
|
+
if (args2.assistantTextCallbacks) {
|
|
32369
|
+
this.assistantTextCallbacksByPid.set(pid, args2.assistantTextCallbacks);
|
|
32370
|
+
}
|
|
32315
32371
|
const outputCallbacks = args2.outputCallbacks ?? [];
|
|
32316
32372
|
this.wireChildOutput(childProcess, pid, entry, emitLogLine, outputCallbacks);
|
|
32317
32373
|
return {
|
|
@@ -32330,6 +32386,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32330
32386
|
}
|
|
32331
32387
|
this.sessionStore.remove(sessionId);
|
|
32332
32388
|
this.agentEndCallbacksByPid.delete(pid);
|
|
32389
|
+
this.assistantTextCallbacksByPid.delete(pid);
|
|
32333
32390
|
this.deleteProcess(pid);
|
|
32334
32391
|
cb({ code: code2, signal, context: context5 });
|
|
32335
32392
|
});
|
|
@@ -32345,6 +32402,11 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32345
32402
|
},
|
|
32346
32403
|
onLogLine: (cb) => {
|
|
32347
32404
|
logLineCallbacks.push(cb);
|
|
32405
|
+
},
|
|
32406
|
+
onAssistantText: (cb) => {
|
|
32407
|
+
const callbacks = this.assistantTextCallbacksByPid.get(pid) ?? args2.assistantTextCallbacks ?? [];
|
|
32408
|
+
callbacks.push(cb);
|
|
32409
|
+
this.assistantTextCallbacksByPid.set(pid, callbacks);
|
|
32348
32410
|
}
|
|
32349
32411
|
};
|
|
32350
32412
|
}
|
|
@@ -32358,6 +32420,16 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32358
32420
|
}
|
|
32359
32421
|
};
|
|
32360
32422
|
}
|
|
32423
|
+
createAssistantTextEmitter() {
|
|
32424
|
+
const assistantTextCallbacks = [];
|
|
32425
|
+
return {
|
|
32426
|
+
assistantTextCallbacks,
|
|
32427
|
+
emitAssistantText: (text) => {
|
|
32428
|
+
for (const cb of assistantTextCallbacks)
|
|
32429
|
+
cb(text);
|
|
32430
|
+
}
|
|
32431
|
+
};
|
|
32432
|
+
}
|
|
32361
32433
|
async startServeAndClient(workingDir, resolvedConvexUrl) {
|
|
32362
32434
|
const childProcess = this.spawnServeProcess(workingDir, resolvedConvexUrl);
|
|
32363
32435
|
const pid = childProcess.pid;
|
|
@@ -32406,7 +32478,12 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32406
32478
|
const newSessionId2 = sessionCreateResult.data.id;
|
|
32407
32479
|
const forwarder = startSessionEventForwarder(client4, {
|
|
32408
32480
|
sessionId: newSessionId2,
|
|
32409
|
-
role: args2.context.role
|
|
32481
|
+
role: args2.context.role,
|
|
32482
|
+
onAssistantText: (text) => {
|
|
32483
|
+
const callbacks2 = this.assistantTextCallbacksByPid.get(args2.pid) ?? [];
|
|
32484
|
+
for (const cb of callbacks2)
|
|
32485
|
+
cb(text);
|
|
32486
|
+
}
|
|
32410
32487
|
});
|
|
32411
32488
|
const callbacks = this.agentEndCallbacksByPid.get(args2.pid) ?? [];
|
|
32412
32489
|
for (const cb of callbacks) {
|
|
@@ -32442,6 +32519,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32442
32519
|
const { childProcess, pid, baseUrl, client: client4 } = await this.startServeAndClient(workingDir, options.resolvedConvexUrl);
|
|
32443
32520
|
let forwarder;
|
|
32444
32521
|
const { logLineCallbacks, emitLogLine } = this.createLogLineEmitter();
|
|
32522
|
+
const { assistantTextCallbacks, emitAssistantText } = this.createAssistantTextEmitter();
|
|
32445
32523
|
const outputCallbacks = [];
|
|
32446
32524
|
try {
|
|
32447
32525
|
const sessionInfo = await withTimeout(client4.session.get({ path: { id: sessionId } }), SESSION_GET_TIMEOUT_MS, "session.get");
|
|
@@ -32452,6 +32530,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32452
32530
|
sessionId,
|
|
32453
32531
|
role: context5.role,
|
|
32454
32532
|
onLogLine: emitLogLine,
|
|
32533
|
+
onAssistantText: emitAssistantText,
|
|
32455
32534
|
onActivity: () => {
|
|
32456
32535
|
for (const cb of outputCallbacks)
|
|
32457
32536
|
cb();
|
|
@@ -32483,6 +32562,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32483
32562
|
model: modelForSession,
|
|
32484
32563
|
workingDir,
|
|
32485
32564
|
logLineCallbacks,
|
|
32565
|
+
assistantTextCallbacks,
|
|
32486
32566
|
outputCallbacks
|
|
32487
32567
|
});
|
|
32488
32568
|
}
|
|
@@ -32495,6 +32575,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32495
32575
|
let agentName;
|
|
32496
32576
|
let deferredSystemPrompt;
|
|
32497
32577
|
const { logLineCallbacks, emitLogLine } = this.createLogLineEmitter();
|
|
32578
|
+
const { assistantTextCallbacks, emitAssistantText } = this.createAssistantTextEmitter();
|
|
32498
32579
|
const outputCallbacks = [];
|
|
32499
32580
|
try {
|
|
32500
32581
|
const sessionCreateResult = await withTimeout(client4.session.create({ body: {} }), SESSION_CREATE_TIMEOUT_MS, "session.create");
|
|
@@ -32506,6 +32587,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32506
32587
|
sessionId,
|
|
32507
32588
|
role: context5.role,
|
|
32508
32589
|
onLogLine: emitLogLine,
|
|
32590
|
+
onAssistantText: emitAssistantText,
|
|
32509
32591
|
onActivity: () => {
|
|
32510
32592
|
for (const cb of outputCallbacks)
|
|
32511
32593
|
cb();
|
|
@@ -32545,6 +32627,7 @@ var init_opencode_sdk_agent_service = __esm(() => {
|
|
|
32545
32627
|
model,
|
|
32546
32628
|
workingDir: options.workingDir,
|
|
32547
32629
|
logLineCallbacks,
|
|
32630
|
+
assistantTextCallbacks,
|
|
32548
32631
|
deferredSystemPrompt,
|
|
32549
32632
|
outputCallbacks
|
|
32550
32633
|
});
|
|
@@ -32704,126 +32787,111 @@ var init_pi_sdk_package = __esm(() => {
|
|
|
32704
32787
|
});
|
|
32705
32788
|
|
|
32706
32789
|
// src/infrastructure/services/remote-agents/pi-sdk/pi-sdk-stream-adapter.ts
|
|
32707
|
-
|
|
32708
|
-
|
|
32709
|
-
|
|
32710
|
-
|
|
32711
|
-
|
|
32712
|
-
|
|
32713
|
-
|
|
32714
|
-
|
|
32715
|
-
|
|
32716
|
-
|
|
32717
|
-
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
|
|
32721
|
-
|
|
32722
|
-
|
|
32723
|
-
|
|
32724
|
-
}
|
|
32725
|
-
handleEvent(event) {
|
|
32726
|
-
this.notifyOutput();
|
|
32727
|
-
switch (event.type) {
|
|
32728
|
-
case "message_update": {
|
|
32729
|
-
const assistantEvent = event.assistantMessageEvent;
|
|
32730
|
-
if (assistantEvent.type === "text_delta") {
|
|
32731
|
-
this.appendText(assistantEvent.delta);
|
|
32732
|
-
} else if (assistantEvent.type === "thinking_delta") {
|
|
32733
|
-
this.appendThinking(assistantEvent.delta);
|
|
32790
|
+
var PiSdkStreamAdapter;
|
|
32791
|
+
var init_pi_sdk_stream_adapter = __esm(() => {
|
|
32792
|
+
init_native_stream_adapter_base();
|
|
32793
|
+
PiSdkStreamAdapter = class PiSdkStreamAdapter extends NativeStreamAdapterBase {
|
|
32794
|
+
textBuffer = "";
|
|
32795
|
+
thinkingBuffer = "";
|
|
32796
|
+
handleEvent(event) {
|
|
32797
|
+
this.notifyOutput();
|
|
32798
|
+
switch (event.type) {
|
|
32799
|
+
case "message_update": {
|
|
32800
|
+
const assistantEvent = event.assistantMessageEvent;
|
|
32801
|
+
if (assistantEvent.type === "text_delta") {
|
|
32802
|
+
this.appendText(assistantEvent.delta);
|
|
32803
|
+
} else if (assistantEvent.type === "thinking_delta") {
|
|
32804
|
+
this.appendThinking(assistantEvent.delta);
|
|
32805
|
+
}
|
|
32806
|
+
break;
|
|
32734
32807
|
}
|
|
32735
|
-
|
|
32736
|
-
|
|
32737
|
-
|
|
32738
|
-
|
|
32739
|
-
|
|
32740
|
-
|
|
32741
|
-
|
|
32742
|
-
|
|
32808
|
+
case "tool_execution_start": {
|
|
32809
|
+
this.flushText();
|
|
32810
|
+
this.flushThinking();
|
|
32811
|
+
const bashCmd = resolveBashCommandForLog(event.toolName, event.args);
|
|
32812
|
+
if (bashCmd !== null) {
|
|
32813
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, BASH_TOOL_KIND, formatBashRunningPayload(bashCmd)));
|
|
32814
|
+
break;
|
|
32815
|
+
}
|
|
32816
|
+
const argsStr = event.args != null ? ` args: ${JSON.stringify(event.args)}` : "";
|
|
32817
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "tool", `${event.toolName}${argsStr}`));
|
|
32743
32818
|
break;
|
|
32744
32819
|
}
|
|
32745
|
-
|
|
32746
|
-
|
|
32747
|
-
|
|
32748
|
-
|
|
32749
|
-
|
|
32750
|
-
|
|
32751
|
-
|
|
32752
|
-
|
|
32820
|
+
case "tool_execution_end": {
|
|
32821
|
+
const resultStr = typeof event.result === "string" ? event.result : JSON.stringify(event.result);
|
|
32822
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "tool_result", `${event.toolName} result: ${resultStr}`));
|
|
32823
|
+
break;
|
|
32824
|
+
}
|
|
32825
|
+
case "agent_end":
|
|
32826
|
+
this.emitAgentEnd();
|
|
32827
|
+
break;
|
|
32828
|
+
default:
|
|
32829
|
+
break;
|
|
32753
32830
|
}
|
|
32754
|
-
case "agent_end":
|
|
32755
|
-
this.emitAgentEnd();
|
|
32756
|
-
break;
|
|
32757
|
-
default:
|
|
32758
|
-
break;
|
|
32759
32831
|
}
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
|
|
32764
|
-
|
|
32765
|
-
|
|
32766
|
-
|
|
32767
|
-
|
|
32768
|
-
|
|
32769
|
-
|
|
32770
|
-
|
|
32771
|
-
|
|
32772
|
-
|
|
32773
|
-
|
|
32774
|
-
|
|
32775
|
-
|
|
32776
|
-
|
|
32777
|
-
|
|
32832
|
+
finish() {
|
|
32833
|
+
this.flushText();
|
|
32834
|
+
this.flushThinking();
|
|
32835
|
+
this.emitAgentEnd();
|
|
32836
|
+
}
|
|
32837
|
+
emitAgentEnd() {
|
|
32838
|
+
if (this.agentEndEmitted)
|
|
32839
|
+
return;
|
|
32840
|
+
this.agentEndEmitted = true;
|
|
32841
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "agent_end"));
|
|
32842
|
+
for (const cb of this.agentEndCallbacks)
|
|
32843
|
+
cb();
|
|
32844
|
+
}
|
|
32845
|
+
appendText(delta) {
|
|
32846
|
+
this.flushThinking();
|
|
32847
|
+
this.textBuffer += delta;
|
|
32848
|
+
this.assistantTextCapture.captureAssistantText(delta);
|
|
32849
|
+
if (this.textBuffer.includes(`
|
|
32778
32850
|
`))
|
|
32851
|
+
this.flushText();
|
|
32852
|
+
}
|
|
32853
|
+
appendThinking(delta) {
|
|
32779
32854
|
this.flushText();
|
|
32780
|
-
|
|
32781
|
-
|
|
32782
|
-
this.flushText();
|
|
32783
|
-
this.thinkingBuffer += delta;
|
|
32784
|
-
if (this.thinkingBuffer.includes(`
|
|
32855
|
+
this.thinkingBuffer += delta;
|
|
32856
|
+
if (this.thinkingBuffer.includes(`
|
|
32785
32857
|
`))
|
|
32786
|
-
|
|
32787
|
-
|
|
32788
|
-
|
|
32789
|
-
|
|
32790
|
-
|
|
32791
|
-
|
|
32858
|
+
this.flushThinking();
|
|
32859
|
+
}
|
|
32860
|
+
flushText() {
|
|
32861
|
+
if (!this.textBuffer)
|
|
32862
|
+
return;
|
|
32863
|
+
const lines = this.textBuffer.split(`
|
|
32792
32864
|
`);
|
|
32793
|
-
|
|
32865
|
+
const remaining = this.textBuffer.endsWith(`
|
|
32794
32866
|
`) ? "" : lines.pop() ?? "";
|
|
32795
|
-
|
|
32796
|
-
|
|
32797
|
-
|
|
32867
|
+
for (const line of lines) {
|
|
32868
|
+
if (line.length > 0) {
|
|
32869
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "text", line));
|
|
32870
|
+
}
|
|
32798
32871
|
}
|
|
32872
|
+
this.textBuffer = remaining;
|
|
32799
32873
|
}
|
|
32800
|
-
|
|
32801
|
-
|
|
32802
|
-
|
|
32803
|
-
|
|
32804
|
-
return;
|
|
32805
|
-
const lines = this.thinkingBuffer.split(`
|
|
32874
|
+
flushThinking() {
|
|
32875
|
+
if (!this.thinkingBuffer)
|
|
32876
|
+
return;
|
|
32877
|
+
const lines = this.thinkingBuffer.split(`
|
|
32806
32878
|
`);
|
|
32807
|
-
|
|
32879
|
+
const remaining = this.thinkingBuffer.endsWith(`
|
|
32808
32880
|
`) ? "" : lines.pop() ?? "";
|
|
32809
|
-
|
|
32810
|
-
|
|
32811
|
-
|
|
32881
|
+
for (const line of lines) {
|
|
32882
|
+
if (line.length > 0) {
|
|
32883
|
+
this.writeLine(formatAgentLogLine(this.logPrefix, "thinking", line));
|
|
32884
|
+
}
|
|
32812
32885
|
}
|
|
32886
|
+
this.thinkingBuffer = remaining;
|
|
32813
32887
|
}
|
|
32814
|
-
|
|
32815
|
-
|
|
32816
|
-
notifyOutput() {
|
|
32817
|
-
for (const cb of this.outputCallbacks)
|
|
32818
|
-
cb();
|
|
32819
|
-
}
|
|
32820
|
-
writeLine(line) {
|
|
32821
|
-
process.stderr.write(`${line}
|
|
32888
|
+
writeLine(line) {
|
|
32889
|
+
process.stderr.write(`${line}
|
|
32822
32890
|
`);
|
|
32823
|
-
|
|
32824
|
-
|
|
32825
|
-
}
|
|
32826
|
-
|
|
32891
|
+
this.emitLogLine?.(line);
|
|
32892
|
+
}
|
|
32893
|
+
};
|
|
32894
|
+
});
|
|
32827
32895
|
|
|
32828
32896
|
// src/infrastructure/services/remote-agents/pi-sdk/pi-sdk-agent-service.ts
|
|
32829
32897
|
async function loadSdk2() {
|
|
@@ -33045,6 +33113,7 @@ var init_pi_sdk_agent_service = __esm(() => {
|
|
|
33045
33113
|
const outputCallbacks = [];
|
|
33046
33114
|
const agentEndCallbacks = [];
|
|
33047
33115
|
const logLineCallbacks = [];
|
|
33116
|
+
const assistantTextCallbacks = [];
|
|
33048
33117
|
const emitLogLine = (line) => {
|
|
33049
33118
|
for (const cb of logLineCallbacks)
|
|
33050
33119
|
cb(line);
|
|
@@ -33066,6 +33135,7 @@ var init_pi_sdk_agent_service = __esm(() => {
|
|
|
33066
33135
|
finishExit,
|
|
33067
33136
|
outputCallbacks,
|
|
33068
33137
|
agentEndCallbacks,
|
|
33138
|
+
assistantTextCallbacks,
|
|
33069
33139
|
emitLogLine
|
|
33070
33140
|
});
|
|
33071
33141
|
return {
|
|
@@ -33082,6 +33152,9 @@ var init_pi_sdk_agent_service = __esm(() => {
|
|
|
33082
33152
|
},
|
|
33083
33153
|
onLogLine: (cb) => {
|
|
33084
33154
|
logLineCallbacks.push(cb);
|
|
33155
|
+
},
|
|
33156
|
+
onAssistantText: (cb) => {
|
|
33157
|
+
assistantTextCallbacks.push(cb);
|
|
33085
33158
|
}
|
|
33086
33159
|
};
|
|
33087
33160
|
}
|
|
@@ -33095,6 +33168,7 @@ var init_pi_sdk_agent_service = __esm(() => {
|
|
|
33095
33168
|
entry,
|
|
33096
33169
|
outputCallbacks,
|
|
33097
33170
|
agentEndCallbacks,
|
|
33171
|
+
assistantTextCallbacks,
|
|
33098
33172
|
emitLogLine
|
|
33099
33173
|
} = args2;
|
|
33100
33174
|
let exited = false;
|
|
@@ -33122,14 +33196,12 @@ ${deferredResume}` : deferredResume;
|
|
|
33122
33196
|
prependSystemOnNextResume = false;
|
|
33123
33197
|
}
|
|
33124
33198
|
const adapter = new PiSdkStreamAdapter(logPrefix, emitLogLine);
|
|
33125
|
-
|
|
33126
|
-
|
|
33127
|
-
|
|
33128
|
-
|
|
33129
|
-
|
|
33130
|
-
|
|
33131
|
-
for (const cb of agentEndCallbacks)
|
|
33132
|
-
cb();
|
|
33199
|
+
wireNativeStreamAdapter({
|
|
33200
|
+
adapter,
|
|
33201
|
+
assistantTextCallbacks,
|
|
33202
|
+
outputCallbacks,
|
|
33203
|
+
agentEndCallbacks,
|
|
33204
|
+
entry
|
|
33133
33205
|
});
|
|
33134
33206
|
const onSessionEvent = (event) => {
|
|
33135
33207
|
if (sdkSession.aborted)
|
|
@@ -75581,10 +75653,7 @@ Put your **complete** deliverable in the handoff message — not in session text
|
|
|
75581
75653
|
}
|
|
75582
75654
|
|
|
75583
75655
|
// ../../services/backend/prompts/utils/code-change-verification.ts
|
|
75584
|
-
var
|
|
75585
|
-
var init_code_change_verification = __esm(() => {
|
|
75586
|
-
CODE_CHANGE_VERIFICATION_CONFIRMATION = `- [ ] I confirm that I have run \`${CODE_CHANGE_VERIFICATION_COMMAND}\` (only required if code changes were made)`;
|
|
75587
|
-
});
|
|
75656
|
+
var CODE_CHANGE_VERIFICATION_CONFIRMATION = "- [ ] I confirm that I have run typecheck and tests for the project (only required if code changes were made)";
|
|
75588
75657
|
|
|
75589
75658
|
// ../../services/backend/prompts/cli/context/read.ts
|
|
75590
75659
|
function contextReadCommand(params = {}) {
|
|
@@ -75663,7 +75732,6 @@ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
|
|
|
75663
75732
|
\`\`\``;
|
|
75664
75733
|
}
|
|
75665
75734
|
var init_builder_to_planner = __esm(() => {
|
|
75666
|
-
init_code_change_verification();
|
|
75667
75735
|
init_context_disclosure();
|
|
75668
75736
|
init_role_guidance_disclosure();
|
|
75669
75737
|
});
|
|
@@ -75820,7 +75888,6 @@ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
|
|
|
75820
75888
|
\`\`\``;
|
|
75821
75889
|
}
|
|
75822
75890
|
var init_planner_to_user = __esm(() => {
|
|
75823
|
-
init_code_change_verification();
|
|
75824
75891
|
init_context_disclosure();
|
|
75825
75892
|
init_role_guidance_disclosure();
|
|
75826
75893
|
});
|
|
@@ -75919,7 +75986,6 @@ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
|
|
|
75919
75986
|
\`\`\``;
|
|
75920
75987
|
}
|
|
75921
75988
|
var init_solo_to_user = __esm(() => {
|
|
75922
|
-
init_code_change_verification();
|
|
75923
75989
|
init_context_disclosure();
|
|
75924
75990
|
init_role_guidance_disclosure();
|
|
75925
75991
|
});
|
|
@@ -76155,8 +76221,6 @@ var init_commands_reference = __esm(() => {
|
|
|
76155
76221
|
init_command2();
|
|
76156
76222
|
init_utils3();
|
|
76157
76223
|
});
|
|
76158
|
-
// ../../services/backend/src/domain/usecase/skills/modules/attachments/index.ts
|
|
76159
|
-
var init_attachments = () => {};
|
|
76160
76224
|
|
|
76161
76225
|
// ../../services/backend/prompts/cli/backlog/command.ts
|
|
76162
76226
|
var init_command3 = __esm(() => {
|
|
@@ -76173,7 +76237,6 @@ var init_code_review = () => {};
|
|
|
76173
76237
|
|
|
76174
76238
|
// ../../services/backend/src/domain/usecase/skills/registry.ts
|
|
76175
76239
|
var init_registry3 = __esm(() => {
|
|
76176
|
-
init_attachments();
|
|
76177
76240
|
init_backlog();
|
|
76178
76241
|
init_code_review();
|
|
76179
76242
|
});
|
|
@@ -76203,8 +76266,7 @@ var init_glossary = __esm(() => {
|
|
|
76203
76266
|
},
|
|
76204
76267
|
{
|
|
76205
76268
|
term: "attachments",
|
|
76206
|
-
definition: "Message attachment types (task, backlog, message, snippet)
|
|
76207
|
-
linkedSkillId: "attachments"
|
|
76269
|
+
definition: "Message attachment types (task, backlog, message, snippet) delivered in agent prompts as XML when users attach context to messages."
|
|
76208
76270
|
},
|
|
76209
76271
|
{
|
|
76210
76272
|
term: "code-review",
|
|
@@ -76599,15 +76661,6 @@ function handleHandoffError(err) {
|
|
|
76599
76661
|
} else if (err._tag === "InvalidChatroomId") {
|
|
76600
76662
|
formatChatroomIdError(err.id);
|
|
76601
76663
|
process.exit(1);
|
|
76602
|
-
} else if (err._tag === "ArtifactsInvalid") {
|
|
76603
|
-
formatError("One or more artifacts not found", [
|
|
76604
|
-
"Please create artifacts first:",
|
|
76605
|
-
`chatroom artifact create <chatroom-id> --from-file=... --filename=...`
|
|
76606
|
-
]);
|
|
76607
|
-
process.exit(1);
|
|
76608
|
-
} else if (err._tag === "ArtifactValidationFailed") {
|
|
76609
|
-
formatError("Failed to validate artifacts", [String(err.cause)]);
|
|
76610
|
-
process.exit(1);
|
|
76611
76664
|
} else if (err._tag === "HandoffFailed") {
|
|
76612
76665
|
console.error(`
|
|
76613
76666
|
❌ ERROR: Handoff failed`);
|
|
@@ -76670,7 +76723,7 @@ async function handoff(chatroomId, options, deps) {
|
|
|
76670
76723
|
var handoffEffect = (chatroomId, options) => exports_Effect.gen(function* () {
|
|
76671
76724
|
const session2 = yield* SessionService;
|
|
76672
76725
|
const backend2 = yield* BackendService;
|
|
76673
|
-
const { role, message, nextRole
|
|
76726
|
+
const { role, message, nextRole } = options;
|
|
76674
76727
|
const sessionId = yield* requireSessionIdEffect((a) => ({
|
|
76675
76728
|
_tag: "NotAuthenticated",
|
|
76676
76729
|
convexUrl: a.convexUrl,
|
|
@@ -76680,24 +76733,12 @@ var handoffEffect = (chatroomId, options) => exports_Effect.gen(function* () {
|
|
|
76680
76733
|
_tag: "InvalidChatroomId",
|
|
76681
76734
|
id: id3
|
|
76682
76735
|
}));
|
|
76683
|
-
if (attachedArtifactIds.length > 0) {
|
|
76684
|
-
const areValid = yield* backend2.query(api.artifacts.validateArtifactIds, {
|
|
76685
|
-
sessionId,
|
|
76686
|
-
artifactIds: attachedArtifactIds
|
|
76687
|
-
}).pipe(exports_Effect.mapError((cause3) => ({ _tag: "ArtifactValidationFailed", cause: cause3 })));
|
|
76688
|
-
if (!areValid) {
|
|
76689
|
-
return yield* exports_Effect.fail({ _tag: "ArtifactsInvalid" });
|
|
76690
|
-
}
|
|
76691
|
-
}
|
|
76692
76736
|
const result = yield* backend2.mutation(api.messages.handoff, {
|
|
76693
76737
|
sessionId,
|
|
76694
76738
|
chatroomId,
|
|
76695
76739
|
senderRole: role,
|
|
76696
76740
|
content: message,
|
|
76697
|
-
targetRole: nextRole
|
|
76698
|
-
...attachedArtifactIds.length > 0 && {
|
|
76699
|
-
attachedArtifactIds
|
|
76700
|
-
}
|
|
76741
|
+
targetRole: nextRole
|
|
76701
76742
|
}).pipe(exports_Effect.mapError((cause3) => {
|
|
76702
76743
|
let errorData;
|
|
76703
76744
|
if (cause3 instanceof ConvexError) {
|
|
@@ -76720,12 +76761,6 @@ var handoffEffect = (chatroomId, options) => exports_Effect.gen(function* () {
|
|
|
76720
76761
|
convexUrl,
|
|
76721
76762
|
supportsNativeIntegration: result.supportsNativeIntegration
|
|
76722
76763
|
}));
|
|
76723
|
-
if (attachedArtifactIds.length > 0) {
|
|
76724
|
-
console.log(`\uD83D\uDCCE Attached artifacts: ${attachedArtifactIds.length}`);
|
|
76725
|
-
attachedArtifactIds.forEach((id3) => {
|
|
76726
|
-
console.log(` • ${id3}`);
|
|
76727
|
-
});
|
|
76728
|
-
}
|
|
76729
76764
|
});
|
|
76730
76765
|
});
|
|
76731
76766
|
var init_handoff = __esm(() => {
|
|
@@ -77541,13 +77576,28 @@ var init_backlog2 = __esm(() => {
|
|
|
77541
77576
|
STALENESS_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000;
|
|
77542
77577
|
});
|
|
77543
77578
|
|
|
77579
|
+
// ../../services/backend/prompts/attachments/xml.ts
|
|
77580
|
+
function escapeXmlText(value) {
|
|
77581
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
77582
|
+
}
|
|
77583
|
+
function escapeXmlAttribute(value) {
|
|
77584
|
+
return escapeXmlText(value).replace(/"/g, """);
|
|
77585
|
+
}
|
|
77586
|
+
function xmlTextElement(tag, content, indent = " ") {
|
|
77587
|
+
if (!content.includes(`
|
|
77588
|
+
`)) {
|
|
77589
|
+
return [`${indent}<${tag}>${escapeXmlText(content)}</${tag}>`];
|
|
77590
|
+
}
|
|
77591
|
+
return [`${indent}<${tag}>`, escapeXmlText(content), `${indent}</${tag}>`];
|
|
77592
|
+
}
|
|
77593
|
+
|
|
77544
77594
|
// ../../services/backend/prompts/attachments/render-delivery-attachments.ts
|
|
77545
77595
|
function renderSnippetAttachment(snippet) {
|
|
77546
77596
|
return [
|
|
77547
|
-
` <attachment reference="${snippet.reference}">`,
|
|
77548
|
-
` <snippet file-source="${snippet.fileSource}">`,
|
|
77597
|
+
` <attachment type="snippet" reference="${escapeXmlAttribute(snippet.reference)}">`,
|
|
77598
|
+
` <snippet file-source="${escapeXmlAttribute(snippet.fileSource)}">`,
|
|
77549
77599
|
` <user-selected-content>`,
|
|
77550
|
-
snippet.selectedContent,
|
|
77600
|
+
escapeXmlText(snippet.selectedContent),
|
|
77551
77601
|
` </user-selected-content>`,
|
|
77552
77602
|
` </snippet>`,
|
|
77553
77603
|
` </attachment>`
|
|
@@ -77556,10 +77606,9 @@ function renderSnippetAttachment(snippet) {
|
|
|
77556
77606
|
function renderBacklogAttachments(items, ctx) {
|
|
77557
77607
|
const lines = [];
|
|
77558
77608
|
for (const item of items) {
|
|
77559
|
-
lines.push(` <attachment type="backlog-item">`);
|
|
77560
|
-
lines.push(
|
|
77561
|
-
lines.push(`
|
|
77562
|
-
lines.push(` <hint>Work on this item. When done: chatroom backlog mark-for-review --chatroom-id="${ctx.chatroomId}" --role="${ctx.role}" --backlog-item-id=${item._id}</hint>`);
|
|
77609
|
+
lines.push(` <attachment type="backlog" backlog-item-id="${escapeXmlAttribute(item._id)}">`);
|
|
77610
|
+
lines.push(...xmlTextElement("content", item.content, " "));
|
|
77611
|
+
lines.push(` <hint>Work on this item. When done: chatroom backlog mark-for-review --chatroom-id="${escapeXmlAttribute(ctx.chatroomId)}" --role="${escapeXmlAttribute(ctx.role)}" --backlog-item-id=${item._id}</hint>`);
|
|
77563
77612
|
lines.push(` </attachment>`);
|
|
77564
77613
|
}
|
|
77565
77614
|
return lines;
|
|
@@ -77571,19 +77620,51 @@ function renderSnippetAttachments(snippets) {
|
|
|
77571
77620
|
}
|
|
77572
77621
|
return lines;
|
|
77573
77622
|
}
|
|
77623
|
+
function renderTaskAttachments(items, _ctx) {
|
|
77624
|
+
const lines = [];
|
|
77625
|
+
for (const item of items) {
|
|
77626
|
+
lines.push(` <attachment type="task" task-id="${escapeXmlAttribute(item._id)}">`);
|
|
77627
|
+
lines.push(...xmlTextElement("content", item.content, " "));
|
|
77628
|
+
lines.push(` <hint>Referenced task attached by user.</hint>`);
|
|
77629
|
+
lines.push(` </attachment>`);
|
|
77630
|
+
}
|
|
77631
|
+
return lines;
|
|
77632
|
+
}
|
|
77633
|
+
function renderMessageAttachments(items) {
|
|
77634
|
+
const lines = [];
|
|
77635
|
+
for (const item of items) {
|
|
77636
|
+
lines.push(` <attachment type="message" message-id="${escapeXmlAttribute(item._id)}">`);
|
|
77637
|
+
lines.push(...xmlTextElement("sender-role", item.senderRole, " "));
|
|
77638
|
+
lines.push(...xmlTextElement("content", item.content, " "));
|
|
77639
|
+
lines.push(` </attachment>`);
|
|
77640
|
+
}
|
|
77641
|
+
return lines;
|
|
77642
|
+
}
|
|
77574
77643
|
function renderDeliveryAttachmentsBlock(input, ctx) {
|
|
77575
77644
|
const backlogLines = input.attachedBacklogItems?.length ? DELIVERY_ATTACHMENT_RENDERERS.backlog(input.attachedBacklogItems, ctx) : [];
|
|
77645
|
+
const taskLines = input.attachedTasks?.length ? DELIVERY_ATTACHMENT_RENDERERS.task(input.attachedTasks, ctx) : [];
|
|
77646
|
+
const messageLines = input.attachedMessages?.length ? DELIVERY_ATTACHMENT_RENDERERS.message(input.attachedMessages, ctx) : [];
|
|
77576
77647
|
const snippetLines = input.attachedSnippets?.length ? DELIVERY_ATTACHMENT_RENDERERS.snippet(input.attachedSnippets, ctx) : [];
|
|
77577
|
-
if (backlogLines.length === 0 && snippetLines.length === 0)
|
|
77648
|
+
if (backlogLines.length === 0 && taskLines.length === 0 && messageLines.length === 0 && snippetLines.length === 0) {
|
|
77578
77649
|
return [];
|
|
77579
|
-
|
|
77650
|
+
}
|
|
77651
|
+
return [
|
|
77652
|
+
"",
|
|
77653
|
+
"<attachments>",
|
|
77654
|
+
...backlogLines,
|
|
77655
|
+
...taskLines,
|
|
77656
|
+
...messageLines,
|
|
77657
|
+
...snippetLines,
|
|
77658
|
+
"</attachments>"
|
|
77659
|
+
];
|
|
77580
77660
|
}
|
|
77581
77661
|
var DELIVERY_ATTACHMENT_RENDERERS;
|
|
77582
77662
|
var init_render_delivery_attachments = __esm(() => {
|
|
77583
77663
|
DELIVERY_ATTACHMENT_RENDERERS = {
|
|
77584
77664
|
backlog: renderBacklogAttachments,
|
|
77585
77665
|
snippet: renderSnippetAttachments,
|
|
77586
|
-
message:
|
|
77666
|
+
message: renderMessageAttachments,
|
|
77667
|
+
task: renderTaskAttachments
|
|
77587
77668
|
};
|
|
77588
77669
|
});
|
|
77589
77670
|
|
|
@@ -77597,7 +77678,9 @@ function detectBacklogDivergence(contextContent, attachedIds) {
|
|
|
77597
77678
|
function renderAttachments(input, chatroomId, role) {
|
|
77598
77679
|
return renderDeliveryAttachmentsBlock({
|
|
77599
77680
|
attachedBacklogItems: input.attachedBacklogItems,
|
|
77600
|
-
attachedSnippets: input.attachedSnippets
|
|
77681
|
+
attachedSnippets: input.attachedSnippets,
|
|
77682
|
+
attachedTasks: input.attachedTasks,
|
|
77683
|
+
attachedMessages: input.attachedMessages
|
|
77601
77684
|
}, { chatroomId, role, mode: "task-read" });
|
|
77602
77685
|
}
|
|
77603
77686
|
function renderDivergenceWarnings(input) {
|
|
@@ -77692,7 +77775,9 @@ function buildTaskPromptFromReadResult(result, chatroomId, role) {
|
|
|
77692
77775
|
role,
|
|
77693
77776
|
context: result.context && typeof result.context === "object" ? result.context : undefined,
|
|
77694
77777
|
attachedBacklogItems: Array.isArray(result.attachedBacklogItems) ? result.attachedBacklogItems : undefined,
|
|
77695
|
-
attachedSnippets: Array.isArray(result.attachedSnippets) ? result.attachedSnippets : undefined
|
|
77778
|
+
attachedSnippets: Array.isArray(result.attachedSnippets) ? result.attachedSnippets : undefined,
|
|
77779
|
+
attachedTasks: Array.isArray(result.attachedTasks) ? result.attachedTasks : undefined,
|
|
77780
|
+
attachedMessages: Array.isArray(result.attachedMessages) ? result.attachedMessages : undefined
|
|
77696
77781
|
});
|
|
77697
77782
|
}
|
|
77698
77783
|
function handleTaskReadError(err) {
|
|
@@ -85862,7 +85947,7 @@ var init_crash_loop_tracker = __esm(() => {
|
|
|
85862
85947
|
});
|
|
85863
85948
|
|
|
85864
85949
|
// ../../services/backend/src/domain/entities/participant.ts
|
|
85865
|
-
var NATIVE_WAITING_ACTION = "native:waiting", NATIVE_TASK_INJECTED_ACTION = "native:task-injected", ONLINE_OR_STARTING_STATUSES;
|
|
85950
|
+
var NATIVE_WAITING_ACTION = "native:waiting", NATIVE_TASK_INJECTED_ACTION = "native:task-injected", NATIVE_HANDOFF_REMINDER = "Reminder: Use the handoff command to send your response to the team.", ONLINE_OR_STARTING_STATUSES;
|
|
85866
85951
|
var init_participant = __esm(() => {
|
|
85867
85952
|
ONLINE_OR_STARTING_STATUSES = new Set([
|
|
85868
85953
|
"agent.waiting",
|
|
@@ -85967,9 +86052,6 @@ function isInjectableNativeAction(action) {
|
|
|
85967
86052
|
return true;
|
|
85968
86053
|
return action === NATIVE_WAITING_ACTION;
|
|
85969
86054
|
}
|
|
85970
|
-
function shouldEmitNativeWaitingOnTurnEnd(lastStatus) {
|
|
85971
|
-
return lastStatus !== "task.acknowledged" && lastStatus !== "task.inProgress";
|
|
85972
|
-
}
|
|
85973
86055
|
function isNativeIdleAfterTaskComplete(participant) {
|
|
85974
86056
|
return participant.lastSeenAction === NATIVE_TASK_INJECTED_ACTION && participant.lastStatus === "task.completed";
|
|
85975
86057
|
}
|
|
@@ -87087,6 +87169,16 @@ class AgentProcessManager {
|
|
|
87087
87169
|
}
|
|
87088
87170
|
await service3.resumeTurn(slot.pid, args2.prompt);
|
|
87089
87171
|
}
|
|
87172
|
+
async injectHarnessReminder(chatroomId, role, prompt) {
|
|
87173
|
+
const key = agentKey3(chatroomId, role);
|
|
87174
|
+
const slot = this.slots.get(key);
|
|
87175
|
+
if (!slot?.pid || !slot.harness)
|
|
87176
|
+
return;
|
|
87177
|
+
const service3 = this.deps.agentServices.get(slot.harness);
|
|
87178
|
+
if (!service3?.resumeTurn)
|
|
87179
|
+
return;
|
|
87180
|
+
await service3.resumeTurn(slot.pid, prompt);
|
|
87181
|
+
}
|
|
87090
87182
|
async stop(opts) {
|
|
87091
87183
|
const key = agentKey3(opts.chatroomId, opts.role);
|
|
87092
87184
|
const slot = this.slots.get(key);
|
|
@@ -87217,9 +87309,20 @@ class AgentProcessManager {
|
|
|
87217
87309
|
console.log(`[AgentProcessManager] ⛔ Terminal provider error for ${opts.role} — emitted agent.startFailed`);
|
|
87218
87310
|
return;
|
|
87219
87311
|
}
|
|
87220
|
-
|
|
87221
|
-
|
|
87222
|
-
|
|
87312
|
+
try {
|
|
87313
|
+
const result = await this.deps.backend.mutation(api.participants.handleNativeAgentEnd, {
|
|
87314
|
+
sessionId: this.deps.sessionId,
|
|
87315
|
+
chatroomId: opts.chatroomId,
|
|
87316
|
+
role: opts.role
|
|
87317
|
+
});
|
|
87318
|
+
if (result?.needsHandoffReminder) {
|
|
87319
|
+
await this.injectHarnessReminder(opts.chatroomId, opts.role, NATIVE_HANDOFF_REMINDER);
|
|
87320
|
+
console.log(`[AgentProcessManager] ⏩ Handoff reminder injected for ${opts.role}`);
|
|
87321
|
+
return;
|
|
87322
|
+
}
|
|
87323
|
+
console.log(`[AgentProcessManager] ✅ Native agent_end handled for ${opts.role}`);
|
|
87324
|
+
} catch (err) {
|
|
87325
|
+
console.log(` ⚠️ Failed native agent_end for ${opts.role}: ${err.message}`);
|
|
87223
87326
|
}
|
|
87224
87327
|
}
|
|
87225
87328
|
async handleExit(opts) {
|
|
@@ -87985,25 +88088,9 @@ class AgentProcessManager {
|
|
|
87985
88088
|
this.registerSpawnCallbacks(slot, opts, spawnResult, pid);
|
|
87986
88089
|
await this.emitNativeWaiting(opts.chatroomId, opts.role, opts.agentHarness);
|
|
87987
88090
|
}
|
|
87988
|
-
async emitNativeWaiting(chatroomId, role, harness
|
|
88091
|
+
async emitNativeWaiting(chatroomId, role, harness) {
|
|
87989
88092
|
if (!getHarnessCapabilities(harness).supportsNativeIntegration)
|
|
87990
88093
|
return false;
|
|
87991
|
-
if (reason === "turn-end") {
|
|
87992
|
-
try {
|
|
87993
|
-
const participant = await this.deps.backend.query(api.participants.getByRole, {
|
|
87994
|
-
sessionId: this.deps.sessionId,
|
|
87995
|
-
chatroomId,
|
|
87996
|
-
role
|
|
87997
|
-
});
|
|
87998
|
-
if (!shouldEmitNativeWaitingOnTurnEnd(participant?.lastStatus)) {
|
|
87999
|
-
console.log(`[AgentProcessManager] Skipping native:waiting for ${role} — active work (${participant?.lastStatus})`);
|
|
88000
|
-
return false;
|
|
88001
|
-
}
|
|
88002
|
-
} catch (err) {
|
|
88003
|
-
console.log(` ⚠️ Failed to check status before native:waiting for ${role}: ${err.message}`);
|
|
88004
|
-
return false;
|
|
88005
|
-
}
|
|
88006
|
-
}
|
|
88007
88094
|
try {
|
|
88008
88095
|
await this.deps.backend.mutation(api.participants.join, {
|
|
88009
88096
|
sessionId: this.deps.sessionId,
|
|
@@ -88174,7 +88261,6 @@ var init_agent_process_manager = __esm(() => {
|
|
|
88174
88261
|
init_classify_resume_storm_reason();
|
|
88175
88262
|
init_terminal_provider_error();
|
|
88176
88263
|
init_handle_turn_completed();
|
|
88177
|
-
init_predicates();
|
|
88178
88264
|
init_spawn_policy();
|
|
88179
88265
|
init_agent_lifecycle_runtime();
|
|
88180
88266
|
init_agent_lifecycle_types();
|
|
@@ -105809,7 +105895,7 @@ handoffCommandGroup.command("view-template").description("Print the handoff mess
|
|
|
105809
105895
|
process.exit(1);
|
|
105810
105896
|
}
|
|
105811
105897
|
});
|
|
105812
|
-
handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--next-role <nextRole>", "Role to hand off to").
|
|
105898
|
+
handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--next-role <nextRole>", "Role to hand off to").action(async (options) => {
|
|
105813
105899
|
await maybeRequireAuth();
|
|
105814
105900
|
const { decode: decode5 } = await Promise.resolve().then(() => exports_decode);
|
|
105815
105901
|
const stdinContent = await readStdin();
|
|
@@ -105831,8 +105917,7 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
|
|
|
105831
105917
|
await handoff2(options.chatroomId, {
|
|
105832
105918
|
role: options.role,
|
|
105833
105919
|
message,
|
|
105834
|
-
nextRole: options.nextRole
|
|
105835
|
-
attachedArtifactIds: options.attachArtifact || []
|
|
105920
|
+
nextRole: options.nextRole
|
|
105836
105921
|
});
|
|
105837
105922
|
});
|
|
105838
105923
|
var backlogCommand = program2.command("backlog").description("Manage task queue and backlog");
|
|
@@ -106119,4 +106204,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
106119
106204
|
});
|
|
106120
106205
|
program2.parse();
|
|
106121
106206
|
|
|
106122
|
-
//# debugId=
|
|
106207
|
+
//# debugId=2E6B4710975E536E64756E2164756E21
|