wave-agent-sdk 0.15.0 → 0.15.1
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/agent.d.ts +4 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +10 -0
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +7 -6
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +16 -4
- package/dist/managers/subagentManager.d.ts +6 -1
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +17 -18
- package/dist/prompts/index.d.ts +1 -2
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +0 -2
- package/dist/services/jsonlHandler.d.ts +4 -4
- package/dist/services/jsonlHandler.d.ts.map +1 -1
- package/dist/services/jsonlHandler.js +4 -13
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +3 -12
- package/dist/tools/agentTool.d.ts.map +1 -1
- package/dist/tools/agentTool.js +16 -4
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +2 -5
- package/dist/tools/skillTool.d.ts.map +1 -1
- package/dist/tools/skillTool.js +16 -4
- package/dist/types/messaging.d.ts +1 -0
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/session.d.ts +0 -4
- package/dist/types/session.d.ts.map +1 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +5 -0
- package/package.json +1 -1
- package/src/agent.ts +12 -0
- package/src/managers/messageManager.ts +7 -8
- package/src/managers/slashCommandManager.ts +24 -5
- package/src/managers/subagentManager.ts +28 -23
- package/src/prompts/index.ts +0 -3
- package/src/services/jsonlHandler.ts +12 -24
- package/src/services/session.ts +3 -14
- package/src/tools/agentTool.ts +24 -5
- package/src/tools/bashTool.ts +2 -5
- package/src/tools/skillTool.ts +24 -4
- package/src/types/messaging.ts +1 -0
- package/src/types/session.ts +0 -8
- package/src/utils/messageOperations.ts +5 -0
package/dist/agent.d.ts
CHANGED
|
@@ -308,5 +308,9 @@ export declare class Agent {
|
|
|
308
308
|
* Get the current task list ID
|
|
309
309
|
*/
|
|
310
310
|
get taskListId(): string;
|
|
311
|
+
/**
|
|
312
|
+
* Check if there are any running background tasks or active subagents
|
|
313
|
+
*/
|
|
314
|
+
get hasRunningBackgroundWork(): boolean;
|
|
311
315
|
}
|
|
312
316
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAYA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAO9E,OAAO,EACL,YAAY,EACZ,kBAAkB,EAElB,YAAY,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,OAAO,EAEP,eAAe,EACf,aAAa,EACb,WAAW,EACX,KAAK,EACL,cAAc,EACd,cAAc,EACf,MAAM,kBAAkB,CAAC;AAe1B,qBAAa,KAAK;IAChB,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,SAAS,CAAY;IAE7B,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,qBAAqB,CAAwB;IACrD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OA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K,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1D;;OAEG;IACU,oBAAoB,IAAI,OAAO,CAAC;QAC3C,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,UAAU,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;IAIF;;OAEG;IACI,eAAe,IAAI,MAAM,GAAG,SAAS;IAI5C;;OAEG;IACI,eAAe,IAAI,MAAM,EAAE;IAOlC;;OAEG;IACI,mBAAmB,IAAI,MAAM,EAAE;IAItC;;OAEG;IACU,eAAe,CAC1B,OAAO,EAAE,OAAO,wBAAwB,EAAE,qBAAqB,GAC9D,OAAO,CAAC,OAAO,wBAAwB,EAAE,kBAAkB,CAAC;IAI/D;;;OAGG;IACU,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D;;;;OAIG;IACI,mBAAmB,CACxB,UAAU,EAAE,MAAM,GACjB,OAAO,+BAA+B,EAAE,gBAAgB,GAAG,IAAI;IAIlE;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;OAEG;IACH,IAAW,wBAAwB,IAAI,OAAO,CAO7C;CACF"}
|
package/dist/agent.js
CHANGED
|
@@ -674,4 +674,14 @@ export class Agent {
|
|
|
674
674
|
get taskListId() {
|
|
675
675
|
return this.taskManager.getTaskListId();
|
|
676
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* Check if there are any running background tasks or active subagents
|
|
679
|
+
*/
|
|
680
|
+
get hasRunningBackgroundWork() {
|
|
681
|
+
const runningTasks = this.backgroundTaskManager
|
|
682
|
+
.getAllTasks()
|
|
683
|
+
.some((t) => t.status === "running");
|
|
684
|
+
const activeSubagents = this.subagentManager.getActiveInstances().length > 0;
|
|
685
|
+
return runningTasks || activeSubagents;
|
|
686
|
+
}
|
|
677
687
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageManager.d.ts","sourceRoot":"","sources":["../../src/managers/messageManager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AC;QAC3C,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,UAAU,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;IAKF;;;;OAIG;IACU,eAAe,CAC1B,KAAK,EAAE,MAAM,EACb,gBAAgB,CAAC,EAAE,OAAO,uBAAuB,EAAE,gBAAgB,GAClE,OAAO,CAAC,IAAI,CAAC;IAkGhB;;OAEG;YACW,kBAAkB;IAkBhC,OAAO,CAAC,sBAAsB;IA6B9B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IA6BnC;;;;;OAKG;IACI,kBAAkB,CACvB,QAAQ,SAAI,EACZ,gBAAgB,SAAO,GACtB,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAgB3C;;OAEG;IACH,OAAO,CAAC,kCAAkC;IA2B1C;;;;OAIG;IACI,oBAAoB,CAAC,SAAS,SAAK,GAAG,MAAM,EAAE;IAQrD;;OAEG;IACI,kBAAkB,IAAI,IAAI;CAGlC"}
|
|
@@ -336,6 +336,7 @@ export class MessageManager {
|
|
|
336
336
|
sessionId: this.sessionId,
|
|
337
337
|
},
|
|
338
338
|
],
|
|
339
|
+
timestamp: new Date().toISOString(),
|
|
339
340
|
...(usage && { usage }),
|
|
340
341
|
};
|
|
341
342
|
// Build new message array: keep the compacted message and last 3 messages
|
|
@@ -669,12 +670,12 @@ export class MessageManager {
|
|
|
669
670
|
async rewriteSessionFile(messages) {
|
|
670
671
|
try {
|
|
671
672
|
const { writeFile } = await import("fs/promises");
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
timestamp
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
(
|
|
673
|
+
const content = messages
|
|
674
|
+
.map((m) => {
|
|
675
|
+
const { timestamp, ...rest } = m;
|
|
676
|
+
return JSON.stringify({ timestamp, ...rest });
|
|
677
|
+
})
|
|
678
|
+
.join("\n") + (messages.length > 0 ? "\n" : "");
|
|
678
679
|
await writeFile(this.transcriptPath, content, "utf8");
|
|
679
680
|
}
|
|
680
681
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashCommandManager.d.ts","sourceRoot":"","sources":["../../src/managers/slashCommandManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAWlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,mBAAmB;IAQ5B,OAAO,CAAC,SAAS;IAPnB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,6BAA6B,CAAgC;gBAG3D,SAAS,EAAE,SAAS,EAC5B,OAAO,EAAE,0BAA0B;IAK9B,UAAU,IAAI,IAAI;IAazB,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,KAAK,qBAAqB,GAEhC;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,YAAY,GAEvB;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,CAAC,yBAAyB;IAcjC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA2C1B;;OAEG;IACI,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"slashCommandManager.d.ts","sourceRoot":"","sources":["../../src/managers/slashCommandManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E,OAAO,EAAE,SAAS,EAAE,MAAM,uBA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AA4B,CAAC,KAAK,EAAE,MAAM,GAAG;QAClD,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAeD;;OAEG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI7C;;OAEG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI1E;;OAEG;IACI,iBAAiB,IAAI,kBAAkB,EAAE;IAIhD;;OAEG;YACW,+BAA+B;IAuD7C;;OAEG;IACI,mBAAmB,IAAI,IAAI;CAQnC"}
|
|
@@ -147,17 +147,29 @@ export class SlashCommandManager {
|
|
|
147
147
|
if (subagent) {
|
|
148
148
|
const messages = subagent.messages;
|
|
149
149
|
const tokens = subagent.messageManager.getLatestTotalTokens();
|
|
150
|
-
const
|
|
150
|
+
const usedTools = subagent.usedTools;
|
|
151
151
|
const toolCount = countToolBlocks(messages);
|
|
152
152
|
const summary = formatToolTokenSummary(toolCount, tokens);
|
|
153
|
+
const getDisplayParam = (t) => {
|
|
154
|
+
if ((t.stage === "end" || t.stage === "running") &&
|
|
155
|
+
t.compactParams) {
|
|
156
|
+
return t.compactParams;
|
|
157
|
+
}
|
|
158
|
+
const flat = t.parameters.replace(/\n/g, "\\n");
|
|
159
|
+
return flat.length > 30 ? `…${flat.slice(-30)}` : flat;
|
|
160
|
+
};
|
|
153
161
|
let shortResult = "";
|
|
154
162
|
if (toolCount > 2) {
|
|
155
163
|
shortResult += "... ";
|
|
156
164
|
}
|
|
157
|
-
if (lastTools.length > 0) {
|
|
158
|
-
shortResult += `${lastTools.join(", ")} `;
|
|
159
|
-
}
|
|
160
165
|
shortResult += summary;
|
|
166
|
+
if (usedTools.length > 0) {
|
|
167
|
+
shortResult +=
|
|
168
|
+
"\n" +
|
|
169
|
+
usedTools
|
|
170
|
+
.map((t) => `${t.name} ${getDisplayParam(t)}`)
|
|
171
|
+
.join("\n");
|
|
172
|
+
}
|
|
161
173
|
this.messageManager.updateToolBlock({
|
|
162
174
|
id: toolBlockId,
|
|
163
175
|
messageId,
|
|
@@ -31,7 +31,12 @@ export interface SubagentInstance {
|
|
|
31
31
|
toolManager: ToolManager;
|
|
32
32
|
status: "initializing" | "active" | "completed" | "error" | "aborted";
|
|
33
33
|
messages: Message[];
|
|
34
|
-
|
|
34
|
+
usedTools: {
|
|
35
|
+
name: string;
|
|
36
|
+
parameters: string;
|
|
37
|
+
compactParams?: string;
|
|
38
|
+
stage?: string;
|
|
39
|
+
}[];
|
|
35
40
|
subagentType: string;
|
|
36
41
|
description: string;
|
|
37
42
|
allowedTools?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagentManager.d.ts","sourceRoot":"","sources":["../../src/managers/subagentManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAS/C,OAAO,EACL,iBAAiB,EACjB,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,MAAM,WAAW,wBAAwB;IAEvC,gDAAgD;IAChD,0BAA0B,CAAC,EAAE,CAC3B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,iBAAiB,KACtB,IAAI,CAAC;IACV,wDAAwD;IACxD,+BAA+B,CAAC,EAAE,CAAC,UAAU,E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GACjC,IAAI;IAOP;;OAEG;IACH,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAOhE;;OAEG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAazC;;OAEG;IACH,kBAAkB,IAAI,gBAAgB,EAAE;IAOxC;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;;OAGG;IACH,OAAO,CAAC,uBAAuB;CA+FhC"}
|
|
@@ -225,7 +225,7 @@ export class SubagentManager {
|
|
|
225
225
|
toolManager,
|
|
226
226
|
status: "initializing",
|
|
227
227
|
messages: [],
|
|
228
|
-
|
|
228
|
+
usedTools: [], // Initialize usedTools
|
|
229
229
|
subagentType: parameters.subagent_type, // Store the subagent type
|
|
230
230
|
description: parameters.description, // Store the AI-generated description
|
|
231
231
|
allowedTools: parameters.allowedTools, // Store optional permission rules
|
|
@@ -548,23 +548,13 @@ export class SubagentManager {
|
|
|
548
548
|
}
|
|
549
549
|
},
|
|
550
550
|
onToolBlockUpdated: (params) => {
|
|
551
|
-
|
|
552
|
-
if (
|
|
553
|
-
|
|
554
|
-
if (instance) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
instance.
|
|
558
|
-
if (instance.lastTools.length > 2) {
|
|
559
|
-
instance.lastTools.shift();
|
|
560
|
-
}
|
|
561
|
-
instance.onUpdate?.();
|
|
562
|
-
// Log tool execution to file
|
|
563
|
-
if (instance.logStream) {
|
|
564
|
-
const displayParams = params.compactParams ||
|
|
565
|
-
(params.parameters || "{}").substring(0, 100);
|
|
566
|
-
instance.logStream.write(`[${new Date().toISOString()}] ${params.name}${displayParams ? ` ${displayParams}` : ""}\n`);
|
|
567
|
-
}
|
|
551
|
+
const instance = this.instances.get(subagentId);
|
|
552
|
+
if (instance) {
|
|
553
|
+
// Log tool execution to file only when finalized
|
|
554
|
+
if (instance.logStream && params.stage === "end") {
|
|
555
|
+
const displayParams = params.compactParams ||
|
|
556
|
+
(params.parameters || "").substring(0, 100);
|
|
557
|
+
instance.logStream.write(`[${new Date().toISOString()}] ${params.name}${displayParams ? ` ${displayParams}` : ""}\n`);
|
|
568
558
|
}
|
|
569
559
|
}
|
|
570
560
|
// Forward tool block updates to parent via SubagentManager callbacks
|
|
@@ -577,6 +567,15 @@ export class SubagentManager {
|
|
|
577
567
|
const instance = this.instances.get(subagentId);
|
|
578
568
|
if (instance) {
|
|
579
569
|
instance.messages = messages;
|
|
570
|
+
// Compute usedTools from messages (last 2 tool blocks)
|
|
571
|
+
const toolBlocks = messages.flatMap((m) => m.blocks?.filter((b) => b.type === "tool") ?? []);
|
|
572
|
+
const last2 = toolBlocks.slice(-2);
|
|
573
|
+
instance.usedTools = last2.map((tb) => ({
|
|
574
|
+
name: tb.name ?? "",
|
|
575
|
+
parameters: tb.parameters ?? "",
|
|
576
|
+
compactParams: tb.compactParams,
|
|
577
|
+
stage: tb.stage,
|
|
578
|
+
}));
|
|
580
579
|
// Trigger the onUpdate callback if provided
|
|
581
580
|
instance.onUpdate?.();
|
|
582
581
|
// Forward subagent message changes to parent via callbacks
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ToolPlugin } from "../tools/types.js";
|
|
2
2
|
import { PermissionMode } from "../types/permissions.js";
|
|
3
|
-
export declare const MAX_PARALLEL_TOOL_CALLS = 3;
|
|
4
3
|
export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.";
|
|
5
4
|
export declare const DOING_TASKS_PROMPT = "# Doing tasks\n- The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change \"methodName\" to snake case, do not reply with just \"method_name\", instead find the method in the code and modify the code.\n- You are highly capable and often allow users to complete ambitious tasks that would otherwise be too complex or take too long. You should defer to user judgement about whether a task is too large to attempt.\n- If you notice the user's request is based on a misconception, or spot a bug adjacent to what they asked about, say so. You're a collaborator, not just an executor\u2014users benefit from your judgment, not just your compliance.\n- In general, do not propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Do not create files unless they're absolutely necessary for achieving your goal. Generally prefer editing an existing file to creating a new one, as this prevents file bloat and builds on existing work more effectively.\n- If an approach fails, diagnose why before switching tactics\u2014read the error, check your assumptions, try a focused fix. Don't retry the identical action blindly, but don't abandon a viable approach after a single failure either. Escalate to the user with AskUserQuestion only when you're genuinely stuck after investigation, not as a first response to friction.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it. Prioritize writing safe, secure, and correct code.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is what the task actually requires\u2014no speculative abstractions, but no half-finished implementations either. Three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused _vars, re-exporting types, adding // removed comments for removed code, etc. If you are certain that something is unused, you can delete it completely.\n- Report outcomes faithfully: if tests fail, say so with the relevant output; if you did not run a verification step, say that rather than implying it succeeded. Never claim \"all tests pass\" when output shows failures, never suppress or simplify failing checks (tests, lints, type errors) to manufacture a green result, and never characterize incomplete or broken work as done. Equally, when a check did pass or a task is complete, state it plainly \u2014 do not hedge confirmed results with unnecessary disclaimers, downgrade finished work to \"partial,\" or re-verify things you already checked. The goal is an accurate report, not a defensive one.\n- Before reporting a task complete, verify it actually works: run the test, execute the script, check the output. Minimum complexity means no gold-plating, not skipping the finish line. If you can't verify (no test exists, can't run the code), say so explicitly rather than claiming success.";
|
|
6
5
|
export declare const EXECUTING_ACTIONS_PROMPT = "# Executing actions with care\n\nCarefully consider the reversibility and blast radius of actions. Generally you can freely take local, reversible actions like editing files or running tests. But for actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding. The cost of pausing to confirm is low, while the cost of an unwanted action (lost work, unintended messages sent, deleted branches) can be very high. For actions like these, consider the context, the action, and user instructions, and by default transparently communicate the action and ask for confirmation before proceeding.\n\nExamples of the kind of risky actions that warrant user confirmation:\n- Destructive operations: deleting files/branches, dropping database tables, killing processes, rm -rf, overwriting uncommitted changes\n- Hard-to-reverse operations: force-pushing (can also overwrite upstream), git reset --hard, amending published commits, removing or downgrading packages/dependencies, modifying CI/CD pipelines\n- Actions visible to others or that affect shared state: pushing code, creating/closing/commenting on PRs or issues, sending messages (Slack, email, GitHub), posting to external services\n\nWhen you encounter an obstacle, do not use destructive actions as a shortcut to simply make it go away. For instance, try to identify root causes and fix underlying issues rather than bypassing safety checks (e.g. --no-verify). If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting, as it may represent the user's in-progress work. For example, typically resolve merge conflicts rather than discarding changes. In short: only take risky actions carefully, and when in doubt, ask before acting. Follow both the spirit and letter of these instructions - measure twice, cut once.";
|
|
7
|
-
export declare const TOOL_POLICY = "# Using your tools\n\n- Do NOT use the Bash to run commands when a relevant dedicated tool is provided. Using dedicated tools allows the user to better understand and review your work. This is CRITICAL to assisting the user:\n - To read files use Read instead of cat, head, tail, or sed\n - To edit files use Edit instead of sed or awk\n - To create files use Write instead of cat with heredoc or echo redirection\n - To search for files use Glob instead of find or ls\n - To search the content of files, use Grep instead of grep or rg\n - Reserve using the Bash exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the Bash tool for these if it is absolutely necessary.\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n-
|
|
6
|
+
export declare const TOOL_POLICY = "# Using your tools\n\n- Do NOT use the Bash to run commands when a relevant dedicated tool is provided. Using dedicated tools allows the user to better understand and review your work. This is CRITICAL to assisting the user:\n - To read files use Read instead of cat, head, tail, or sed\n - To edit files use Edit instead of sed or awk\n - To create files use Write instead of cat with heredoc or echo redirection\n - To search for files use Glob instead of find or ls\n - To search the content of files, use Grep instead of grep or rg\n - Reserve using the Bash exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the Bash tool for these if it is absolutely necessary.\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
|
8
7
|
/**
|
|
9
8
|
* Reference: /home/liuyiqi/github/claude-code/src/constants/prompts.ts getOutputEfficiencySection
|
|
10
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAiBzD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CA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
|
|
3
3
|
import { buildAutoMemoryPrompt } from "./autoMemory.js";
|
|
4
4
|
import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
|
|
5
5
|
import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, BASH_TOOL_NAME, READ_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, } from "../constants/tools.js";
|
|
6
|
-
export const MAX_PARALLEL_TOOL_CALLS = 3;
|
|
7
6
|
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.`;
|
|
8
7
|
export const DOING_TASKS_PROMPT = `# Doing tasks
|
|
9
8
|
- The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change "methodName" to snake case, do not reply with just "method_name", instead find the method in the code and modify the code.
|
|
@@ -40,7 +39,6 @@ export const TOOL_POLICY = `# Using your tools
|
|
|
40
39
|
- To search the content of files, use ${GREP_TOOL_NAME} instead of grep or rg
|
|
41
40
|
- Reserve using the ${BASH_TOOL_NAME} exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the ${BASH_TOOL_NAME} tool for these if it is absolutely necessary.
|
|
42
41
|
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
|
|
43
|
-
- **Limit**: You MUST NOT call more than ${MAX_PARALLEL_TOOL_CALLS} tools in parallel in a single response.
|
|
44
42
|
- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
45
43
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
|
|
46
44
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Handles reading and writing JSONL (JSON Lines) session files for improved performance
|
|
4
4
|
*/
|
|
5
5
|
import type { Message } from "../types/index.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { SessionFilename } from "../types/session.js";
|
|
7
7
|
/**
|
|
8
8
|
* JSONL write options
|
|
9
9
|
*/
|
|
@@ -31,15 +31,15 @@ export declare class JsonlHandler {
|
|
|
31
31
|
/**
|
|
32
32
|
* Append messages to JSONL file
|
|
33
33
|
*/
|
|
34
|
-
append(filePath: string, messages:
|
|
34
|
+
append(filePath: string, messages: Message[], options?: JsonlWriteOptions): Promise<void>;
|
|
35
35
|
/**
|
|
36
36
|
* Read all messages from JSONL file (simplified - no metadata handling)
|
|
37
37
|
*/
|
|
38
|
-
read(filePath: string): Promise<
|
|
38
|
+
read(filePath: string): Promise<Message[]>;
|
|
39
39
|
/**
|
|
40
40
|
* Get the last message from JSONL file using efficient file reading (simplified)
|
|
41
41
|
*/
|
|
42
|
-
getLastMessage(filePath: string): Promise<
|
|
42
|
+
getLastMessage(filePath: string): Promise<Message | null>;
|
|
43
43
|
/**
|
|
44
44
|
* Validate messages before writing
|
|
45
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonlHandler.d.ts","sourceRoot":"","sources":["../../src/services/jsonlHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"jsonlHandler.d.ts","sourceRoot":"","sources":["../../src/services/jsonlHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,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
const sessionMessages = messages.map((message) => ({
|
|
41
|
-
...message,
|
|
42
|
-
timestamp: new Date().toISOString(),
|
|
43
|
-
}));
|
|
44
|
-
return this.append(filePath, sessionMessages);
|
|
39
|
+
return this.append(filePath, messages);
|
|
45
40
|
}
|
|
46
41
|
/**
|
|
47
42
|
* Append messages to JSONL file
|
|
@@ -55,14 +50,10 @@ export class JsonlHandler {
|
|
|
55
50
|
this.validateMessages(messages);
|
|
56
51
|
// Ensure directory exists
|
|
57
52
|
await this.ensureDirectory(dirname(filePath));
|
|
58
|
-
// Convert messages to JSONL lines (
|
|
53
|
+
// Convert messages to JSONL lines (compact JSON, timestamp first)
|
|
59
54
|
const lines = messages.map((message) => {
|
|
60
|
-
const { timestamp
|
|
61
|
-
|
|
62
|
-
timestamp: existingTimestamp || new Date().toISOString(),
|
|
63
|
-
...messageWithoutTimestamp,
|
|
64
|
-
};
|
|
65
|
-
return JSON.stringify(messageWithTimestamp);
|
|
55
|
+
const { timestamp, ...rest } = message;
|
|
56
|
+
return JSON.stringify({ timestamp, ...rest });
|
|
66
57
|
});
|
|
67
58
|
const content = lines.join("\n") + "\n";
|
|
68
59
|
if (opts.atomic) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/services/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/services/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAOjD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,EAAE,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,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAChC,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkCxB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAM,GAAG,UAAmB,GACxC,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAY,GACtB,MAAM,CAQR;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,gBAAgB,CAAC,EAAE,MAAM,EACzB,mBAAmB,CAAC,EAAE,OAAO,EAC7B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA+ClC;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAiCxD"}
|
package/dist/services/session.js
CHANGED
|
@@ -147,17 +147,13 @@ export async function appendMessages(sessionId, newMessages, workdir, sessionTyp
|
|
|
147
147
|
catch {
|
|
148
148
|
throw new Error(`Session file not found: ${sessionId}. Use createSession() to create a new session first.`);
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
timestamp: new Date().toISOString(),
|
|
152
|
-
...msg,
|
|
153
|
-
}));
|
|
154
|
-
await jsonlHandler.append(filePath, messagesWithTimestamp, {
|
|
150
|
+
await jsonlHandler.append(filePath, newMessages, {
|
|
155
151
|
atomic: false,
|
|
156
152
|
});
|
|
157
153
|
// Update index
|
|
158
154
|
const encoder = new PathEncoder();
|
|
159
155
|
const projectDir = await encoder.getProjectDirectory(workdir, SESSION_DIR);
|
|
160
|
-
const lastMessage =
|
|
156
|
+
const lastMessage = newMessages[newMessages.length - 1];
|
|
161
157
|
// Get first message content if it's a new session or we don't have it
|
|
162
158
|
let firstMessage;
|
|
163
159
|
try {
|
|
@@ -232,12 +228,7 @@ export async function loadSessionFromJsonl(sessionId, workdir, sessionType = "ma
|
|
|
232
228
|
id: sessionId,
|
|
233
229
|
rootSessionId: rootSessionId || sessionId,
|
|
234
230
|
parentSessionId,
|
|
235
|
-
messages
|
|
236
|
-
// Remove timestamp property for backward compatibility
|
|
237
|
-
const { timestamp: _ignored, ...messageWithoutTimestamp } = msg;
|
|
238
|
-
void _ignored; // Use the variable to avoid eslint error
|
|
239
|
-
return messageWithoutTimestamp;
|
|
240
|
-
}),
|
|
231
|
+
messages,
|
|
241
232
|
metadata: {
|
|
242
233
|
workdir,
|
|
243
234
|
lastActiveAt: lastMessage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../src/tools/agentTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAStE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../src/tools/agentTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAStE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UA+RvB,CAAC"}
|
package/dist/tools/agentTool.js
CHANGED
|
@@ -132,17 +132,29 @@ When using the Agent tool, you must specify a subagent_type parameter to select
|
|
|
132
132
|
return;
|
|
133
133
|
const messages = instance.messageManager.getMessages();
|
|
134
134
|
const tokens = instance.messageManager.getLatestTotalTokens();
|
|
135
|
-
const
|
|
135
|
+
const usedTools = instance.usedTools;
|
|
136
136
|
const toolCount = countToolBlocks(messages);
|
|
137
137
|
const summary = formatToolTokenSummary(toolCount, tokens);
|
|
138
|
+
const getDisplayParam = (t) => {
|
|
139
|
+
if ((t.stage === "end" || t.stage === "running") &&
|
|
140
|
+
t.compactParams) {
|
|
141
|
+
return t.compactParams;
|
|
142
|
+
}
|
|
143
|
+
const flat = t.parameters.replace(/\n/g, "\\n");
|
|
144
|
+
return flat.length > 30 ? `…${flat.slice(-30)}` : flat;
|
|
145
|
+
};
|
|
138
146
|
let shortResult = "";
|
|
139
147
|
if (toolCount > 2) {
|
|
140
148
|
shortResult += "... ";
|
|
141
149
|
}
|
|
142
|
-
if (lastTools.length > 0) {
|
|
143
|
-
shortResult += `${lastTools.join(", ")} `;
|
|
144
|
-
}
|
|
145
150
|
shortResult += summary;
|
|
151
|
+
if (usedTools.length > 0) {
|
|
152
|
+
shortResult +=
|
|
153
|
+
"\n" +
|
|
154
|
+
usedTools
|
|
155
|
+
.map((t) => `${t.name} ${getDisplayParam(t)}`)
|
|
156
|
+
.join("\n");
|
|
157
|
+
}
|
|
146
158
|
context.onShortResultUpdate?.(shortResult);
|
|
147
159
|
});
|
|
148
160
|
return new Promise((resolve) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAwCtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAwCtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAibtB,CAAC"}
|
package/dist/tools/bashTool.js
CHANGED
|
@@ -63,7 +63,7 @@ export const bashTool = {
|
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
65
|
prompt: () => `
|
|
66
|
-
Executes a given bash command
|
|
66
|
+
Executes a given bash command with optional timeout, ensuring proper handling and security measures. Each invocation runs in a fresh shell process starting from the project root.
|
|
67
67
|
|
|
68
68
|
IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.
|
|
69
69
|
|
|
@@ -122,10 +122,7 @@ Use the gh command via the Bash tool for GitHub-related tasks including working
|
|
|
122
122
|
- Do not retry failing commands in a sleep loop — diagnose the root cause.
|
|
123
123
|
- If waiting for a background task you started with \`run_in_background\`, you will be notified when it completes — do not poll.
|
|
124
124
|
- If you must poll an external process, use a check command (e.g. \`gh run view\`) rather than sleeping first.
|
|
125
|
-
- If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user
|
|
126
|
-
|
|
127
|
-
# CWD management
|
|
128
|
-
Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of \`cd\`. You may use \`cd\` if the User explicitly requests it. When you use \`cd\`, the shell working directory will be reset to the original working directory after the command completes.`,
|
|
125
|
+
- If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user.`,
|
|
129
126
|
execute: async (args, context) => {
|
|
130
127
|
const command = args.command;
|
|
131
128
|
const runInBackground = args.run_in_background;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillTool.d.ts","sourceRoot":"","sources":["../../src/tools/skillTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAgBtE,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"skillTool.d.ts","sourceRoot":"","sources":["../../src/tools/skillTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAgBtE,eAAO,MAAM,SAAS,EAAE,UAuOvB,CAAC"}
|
package/dist/tools/skillTool.js
CHANGED
|
@@ -109,17 +109,29 @@ export const skillTool = {
|
|
|
109
109
|
// Update shortResult
|
|
110
110
|
const messages = instance.messageManager.getMessages();
|
|
111
111
|
const tokens = instance.messageManager.getLatestTotalTokens();
|
|
112
|
-
const
|
|
112
|
+
const usedTools = instance.usedTools;
|
|
113
113
|
const toolCount = countToolBlocks(messages);
|
|
114
114
|
const summary = formatToolTokenSummary(toolCount, tokens);
|
|
115
|
+
const getDisplayParam = (t) => {
|
|
116
|
+
if ((t.stage === "end" || t.stage === "running") &&
|
|
117
|
+
t.compactParams) {
|
|
118
|
+
return t.compactParams;
|
|
119
|
+
}
|
|
120
|
+
const flat = t.parameters.replace(/\n/g, "\\n");
|
|
121
|
+
return flat.length > 30 ? `…${flat.slice(-30)}` : flat;
|
|
122
|
+
};
|
|
115
123
|
let shortResult = "";
|
|
116
124
|
if (toolCount > 2) {
|
|
117
125
|
shortResult += "... ";
|
|
118
126
|
}
|
|
119
|
-
if (lastTools.length > 0) {
|
|
120
|
-
shortResult += `${lastTools.join(", ")} `;
|
|
121
|
-
}
|
|
122
127
|
shortResult += summary;
|
|
128
|
+
if (usedTools.length > 0) {
|
|
129
|
+
shortResult +=
|
|
130
|
+
"\n" +
|
|
131
|
+
usedTools
|
|
132
|
+
.map((t) => `${t.name} ${getDisplayParam(t)}`)
|
|
133
|
+
.join("\n");
|
|
134
|
+
}
|
|
123
135
|
context.onShortResultUpdate?.(shortResult);
|
|
124
136
|
});
|
|
125
137
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/types/messaging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM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
package/dist/types/session.d.ts
CHANGED
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
*
|
|
5
5
|
* SIMPLIFIED: Removed unused interfaces to focus on core functionality
|
|
6
6
|
*/
|
|
7
|
-
import type { Message } from "./messaging.js";
|
|
8
|
-
export interface SessionMessage extends Message {
|
|
9
|
-
timestamp: string;
|
|
10
|
-
}
|
|
11
7
|
export interface SessionFilename {
|
|
12
8
|
sessionId: string;
|
|
13
9
|
sessionType: "main" | "subagent";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EAGN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAI5E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7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D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAkB1D;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,gCAAgC,GAAI,8DAO9C,4BAA4B,KAAG,OAAO,EAkBxC,CAAC"}
|
|
@@ -67,6 +67,7 @@ export const addUserMessageToMessages = ({ messages, content, customCommandConte
|
|
|
67
67
|
id: id || generateMessageId(),
|
|
68
68
|
role: "user",
|
|
69
69
|
blocks,
|
|
70
|
+
timestamp: new Date().toISOString(),
|
|
70
71
|
...(isMeta !== undefined && { isMeta }),
|
|
71
72
|
};
|
|
72
73
|
return [...messages, userMessage];
|
|
@@ -123,6 +124,7 @@ export const addAssistantMessageToMessages = (messages, content, toolCalls, usag
|
|
|
123
124
|
id: generateMessageId(),
|
|
124
125
|
role: "assistant",
|
|
125
126
|
blocks,
|
|
127
|
+
timestamp: new Date().toISOString(),
|
|
126
128
|
usage, // Include usage data if provided
|
|
127
129
|
...(additionalFields ? { additionalFields: { ...additionalFields } } : {}),
|
|
128
130
|
};
|
|
@@ -279,6 +281,7 @@ export const addErrorBlockToMessage = ({ messages, error, }) => {
|
|
|
279
281
|
content: error,
|
|
280
282
|
},
|
|
281
283
|
],
|
|
284
|
+
timestamp: new Date().toISOString(),
|
|
282
285
|
});
|
|
283
286
|
}
|
|
284
287
|
return newMessages;
|
|
@@ -297,6 +300,7 @@ export const addBangMessage = ({ messages, command, }) => {
|
|
|
297
300
|
exitCode: null,
|
|
298
301
|
},
|
|
299
302
|
],
|
|
303
|
+
timestamp: new Date().toISOString(),
|
|
300
304
|
};
|
|
301
305
|
return [...messages, outputMessage];
|
|
302
306
|
};
|
|
@@ -442,6 +446,7 @@ export const addNotificationMessageToMessages = ({ messages, taskId, taskType, s
|
|
|
442
446
|
id: generateMessageId(),
|
|
443
447
|
role: "user",
|
|
444
448
|
blocks: [block],
|
|
449
|
+
timestamp: new Date().toISOString(),
|
|
445
450
|
};
|
|
446
451
|
return [...messages, notificationMessage];
|
|
447
452
|
};
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -894,4 +894,16 @@ export class Agent {
|
|
|
894
894
|
public get taskListId(): string {
|
|
895
895
|
return this.taskManager.getTaskListId();
|
|
896
896
|
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Check if there are any running background tasks or active subagents
|
|
900
|
+
*/
|
|
901
|
+
public get hasRunningBackgroundWork(): boolean {
|
|
902
|
+
const runningTasks = this.backgroundTaskManager
|
|
903
|
+
.getAllTasks()
|
|
904
|
+
.some((t) => t.status === "running");
|
|
905
|
+
const activeSubagents =
|
|
906
|
+
this.subagentManager.getActiveInstances().length > 0;
|
|
907
|
+
return runningTasks || activeSubagents;
|
|
908
|
+
}
|
|
897
909
|
}
|
|
@@ -518,6 +518,7 @@ export class MessageManager {
|
|
|
518
518
|
sessionId: this.sessionId,
|
|
519
519
|
},
|
|
520
520
|
],
|
|
521
|
+
timestamp: new Date().toISOString(),
|
|
521
522
|
...(usage && { usage }),
|
|
522
523
|
};
|
|
523
524
|
|
|
@@ -959,15 +960,13 @@ export class MessageManager {
|
|
|
959
960
|
try {
|
|
960
961
|
const { writeFile } = await import("fs/promises");
|
|
961
962
|
|
|
962
|
-
const sessionMessages: import("../types/session.js").SessionMessage[] =
|
|
963
|
-
messages.map((message) => ({
|
|
964
|
-
...message,
|
|
965
|
-
timestamp: new Date().toISOString(),
|
|
966
|
-
}));
|
|
967
|
-
|
|
968
963
|
const content =
|
|
969
|
-
|
|
970
|
-
|
|
964
|
+
messages
|
|
965
|
+
.map((m) => {
|
|
966
|
+
const { timestamp, ...rest } = m;
|
|
967
|
+
return JSON.stringify({ timestamp, ...rest });
|
|
968
|
+
})
|
|
969
|
+
.join("\n") + (messages.length > 0 ? "\n" : "");
|
|
971
970
|
|
|
972
971
|
await writeFile(this.transcriptPath, content, "utf8");
|
|
973
972
|
} catch (error) {
|
|
@@ -224,20 +224,39 @@ export class SlashCommandManager {
|
|
|
224
224
|
const messages = subagent.messages;
|
|
225
225
|
const tokens =
|
|
226
226
|
subagent.messageManager.getLatestTotalTokens();
|
|
227
|
-
const
|
|
227
|
+
const usedTools = subagent.usedTools;
|
|
228
228
|
|
|
229
229
|
const toolCount = countToolBlocks(messages);
|
|
230
230
|
const summary = formatToolTokenSummary(toolCount, tokens);
|
|
231
231
|
|
|
232
|
+
const getDisplayParam = (t: {
|
|
233
|
+
name: string;
|
|
234
|
+
parameters: string;
|
|
235
|
+
compactParams?: string;
|
|
236
|
+
stage?: string;
|
|
237
|
+
}) => {
|
|
238
|
+
if (
|
|
239
|
+
(t.stage === "end" || t.stage === "running") &&
|
|
240
|
+
t.compactParams
|
|
241
|
+
) {
|
|
242
|
+
return t.compactParams;
|
|
243
|
+
}
|
|
244
|
+
const flat = t.parameters.replace(/\n/g, "\\n");
|
|
245
|
+
return flat.length > 30 ? `…${flat.slice(-30)}` : flat;
|
|
246
|
+
};
|
|
247
|
+
|
|
232
248
|
let shortResult = "";
|
|
233
249
|
if (toolCount > 2) {
|
|
234
250
|
shortResult += "... ";
|
|
235
251
|
}
|
|
236
|
-
if (lastTools.length > 0) {
|
|
237
|
-
shortResult += `${lastTools.join(", ")} `;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
252
|
shortResult += summary;
|
|
253
|
+
if (usedTools.length > 0) {
|
|
254
|
+
shortResult +=
|
|
255
|
+
"\n" +
|
|
256
|
+
usedTools
|
|
257
|
+
.map((t) => `${t.name} ${getDisplayParam(t)}`)
|
|
258
|
+
.join("\n");
|
|
259
|
+
}
|
|
241
260
|
|
|
242
261
|
this.messageManager.updateToolBlock({
|
|
243
262
|
id: toolBlockId,
|
|
@@ -68,7 +68,12 @@ export interface SubagentInstance {
|
|
|
68
68
|
toolManager: ToolManager;
|
|
69
69
|
status: "initializing" | "active" | "completed" | "error" | "aborted";
|
|
70
70
|
messages: Message[];
|
|
71
|
-
|
|
71
|
+
usedTools: {
|
|
72
|
+
name: string;
|
|
73
|
+
parameters: string;
|
|
74
|
+
compactParams?: string;
|
|
75
|
+
stage?: string;
|
|
76
|
+
}[]; // Track tools with display info
|
|
72
77
|
subagentType: string; // Store the subagent type for hook context
|
|
73
78
|
description: string; // Store the AI-generated description
|
|
74
79
|
allowedTools?: string[]; // Optional permission rules (e.g. git:*)
|
|
@@ -388,7 +393,7 @@ export class SubagentManager {
|
|
|
388
393
|
toolManager,
|
|
389
394
|
status: "initializing",
|
|
390
395
|
messages: [],
|
|
391
|
-
|
|
396
|
+
usedTools: [], // Initialize usedTools
|
|
392
397
|
subagentType: parameters.subagent_type, // Store the subagent type
|
|
393
398
|
description: parameters.description, // Store the AI-generated description
|
|
394
399
|
allowedTools: parameters.allowedTools, // Store optional permission rules
|
|
@@ -790,27 +795,16 @@ export class SubagentManager {
|
|
|
790
795
|
},
|
|
791
796
|
|
|
792
797
|
onToolBlockUpdated: (params: AgentToolBlockUpdateParams) => {
|
|
793
|
-
|
|
794
|
-
if (
|
|
795
|
-
|
|
796
|
-
if (instance) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
instance.onUpdate?.();
|
|
804
|
-
|
|
805
|
-
// Log tool execution to file
|
|
806
|
-
if (instance.logStream) {
|
|
807
|
-
const displayParams =
|
|
808
|
-
params.compactParams ||
|
|
809
|
-
(params.parameters || "{}").substring(0, 100);
|
|
810
|
-
instance.logStream.write(
|
|
811
|
-
`[${new Date().toISOString()}] ${params.name}${displayParams ? ` ${displayParams}` : ""}\n`,
|
|
812
|
-
);
|
|
813
|
-
}
|
|
798
|
+
const instance = this.instances.get(subagentId);
|
|
799
|
+
if (instance) {
|
|
800
|
+
// Log tool execution to file only when finalized
|
|
801
|
+
if (instance.logStream && params.stage === "end") {
|
|
802
|
+
const displayParams =
|
|
803
|
+
params.compactParams ||
|
|
804
|
+
(params.parameters || "").substring(0, 100);
|
|
805
|
+
instance.logStream.write(
|
|
806
|
+
`[${new Date().toISOString()}] ${params.name}${displayParams ? ` ${displayParams}` : ""}\n`,
|
|
807
|
+
);
|
|
814
808
|
}
|
|
815
809
|
}
|
|
816
810
|
|
|
@@ -825,6 +819,17 @@ export class SubagentManager {
|
|
|
825
819
|
const instance = this.instances.get(subagentId);
|
|
826
820
|
if (instance) {
|
|
827
821
|
instance.messages = messages;
|
|
822
|
+
// Compute usedTools from messages (last 2 tool blocks)
|
|
823
|
+
const toolBlocks = messages.flatMap(
|
|
824
|
+
(m) => m.blocks?.filter((b) => b.type === "tool") ?? [],
|
|
825
|
+
);
|
|
826
|
+
const last2 = toolBlocks.slice(-2);
|
|
827
|
+
instance.usedTools = last2.map((tb) => ({
|
|
828
|
+
name: tb.name ?? "",
|
|
829
|
+
parameters: tb.parameters ?? "",
|
|
830
|
+
compactParams: tb.compactParams,
|
|
831
|
+
stage: tb.stage,
|
|
832
|
+
}));
|
|
828
833
|
// Trigger the onUpdate callback if provided
|
|
829
834
|
instance.onUpdate?.();
|
|
830
835
|
// Forward subagent message changes to parent via callbacks
|
package/src/prompts/index.ts
CHANGED
|
@@ -19,8 +19,6 @@ import {
|
|
|
19
19
|
GREP_TOOL_NAME,
|
|
20
20
|
} from "../constants/tools.js";
|
|
21
21
|
|
|
22
|
-
export const MAX_PARALLEL_TOOL_CALLS = 3;
|
|
23
|
-
|
|
24
22
|
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.`;
|
|
25
23
|
|
|
26
24
|
export const DOING_TASKS_PROMPT = `# Doing tasks
|
|
@@ -60,7 +58,6 @@ export const TOOL_POLICY = `# Using your tools
|
|
|
60
58
|
- To search the content of files, use ${GREP_TOOL_NAME} instead of grep or rg
|
|
61
59
|
- Reserve using the ${BASH_TOOL_NAME} exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the ${BASH_TOOL_NAME} tool for these if it is absolutely necessary.
|
|
62
60
|
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
|
|
63
|
-
- **Limit**: You MUST NOT call more than ${MAX_PARALLEL_TOOL_CALLS} tools in parallel in a single response.
|
|
64
61
|
- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
65
62
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
|
|
66
63
|
|
|
@@ -8,7 +8,7 @@ import { dirname } from "path";
|
|
|
8
8
|
import { getLastLine } from "../utils/fileUtils.js";
|
|
9
9
|
|
|
10
10
|
import type { Message } from "../types/index.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { SessionFilename } from "../types/session.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* JSONL write options
|
|
@@ -56,13 +56,7 @@ export class JsonlHandler {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
const sessionMessages: SessionMessage[] = messages.map((message) => ({
|
|
61
|
-
...message,
|
|
62
|
-
timestamp: new Date().toISOString(),
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
return this.append(filePath, sessionMessages);
|
|
59
|
+
return this.append(filePath, messages);
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
/**
|
|
@@ -70,7 +64,7 @@ export class JsonlHandler {
|
|
|
70
64
|
*/
|
|
71
65
|
async append(
|
|
72
66
|
filePath: string,
|
|
73
|
-
messages:
|
|
67
|
+
messages: Message[],
|
|
74
68
|
options?: JsonlWriteOptions,
|
|
75
69
|
): Promise<void> {
|
|
76
70
|
if (messages.length === 0) {
|
|
@@ -85,16 +79,10 @@ export class JsonlHandler {
|
|
|
85
79
|
// Ensure directory exists
|
|
86
80
|
await this.ensureDirectory(dirname(filePath));
|
|
87
81
|
|
|
88
|
-
// Convert messages to JSONL lines (
|
|
82
|
+
// Convert messages to JSONL lines (compact JSON, timestamp first)
|
|
89
83
|
const lines = messages.map((message) => {
|
|
90
|
-
const { timestamp
|
|
91
|
-
|
|
92
|
-
const messageWithTimestamp = {
|
|
93
|
-
timestamp: existingTimestamp || new Date().toISOString(),
|
|
94
|
-
...messageWithoutTimestamp,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return JSON.stringify(messageWithTimestamp);
|
|
84
|
+
const { timestamp, ...rest } = message;
|
|
85
|
+
return JSON.stringify({ timestamp, ...rest });
|
|
98
86
|
});
|
|
99
87
|
|
|
100
88
|
const content = lines.join("\n") + "\n";
|
|
@@ -116,7 +104,7 @@ export class JsonlHandler {
|
|
|
116
104
|
/**
|
|
117
105
|
* Read all messages from JSONL file (simplified - no metadata handling)
|
|
118
106
|
*/
|
|
119
|
-
async read(filePath: string): Promise<
|
|
107
|
+
async read(filePath: string): Promise<Message[]> {
|
|
120
108
|
try {
|
|
121
109
|
const content = await readFile(filePath, "utf8");
|
|
122
110
|
const lines = content
|
|
@@ -128,14 +116,14 @@ export class JsonlHandler {
|
|
|
128
116
|
return [];
|
|
129
117
|
}
|
|
130
118
|
|
|
131
|
-
const allMessages:
|
|
119
|
+
const allMessages: Message[] = [];
|
|
132
120
|
|
|
133
121
|
// Parse all messages (no metadata line to skip)
|
|
134
122
|
for (let i = 0; i < lines.length; i++) {
|
|
135
123
|
const line = lines[i];
|
|
136
124
|
|
|
137
125
|
try {
|
|
138
|
-
const message = JSON.parse(line) as
|
|
126
|
+
const message = JSON.parse(line) as Message;
|
|
139
127
|
if (message.timestamp) allMessages.push(message);
|
|
140
128
|
} catch (error) {
|
|
141
129
|
// Throw error for invalid JSON lines with line number
|
|
@@ -155,7 +143,7 @@ export class JsonlHandler {
|
|
|
155
143
|
/**
|
|
156
144
|
* Get the last message from JSONL file using efficient file reading (simplified)
|
|
157
145
|
*/
|
|
158
|
-
async getLastMessage(filePath: string): Promise<
|
|
146
|
+
async getLastMessage(filePath: string): Promise<Message | null> {
|
|
159
147
|
try {
|
|
160
148
|
// First check if file exists
|
|
161
149
|
try {
|
|
@@ -176,7 +164,7 @@ export class JsonlHandler {
|
|
|
176
164
|
|
|
177
165
|
try {
|
|
178
166
|
const parsed = JSON.parse(lastLine);
|
|
179
|
-
return parsed as
|
|
167
|
+
return parsed as Message;
|
|
180
168
|
} catch (error) {
|
|
181
169
|
throw new Error(`Invalid JSON in last line of "${filePath}": ${error}`);
|
|
182
170
|
}
|
|
@@ -190,7 +178,7 @@ export class JsonlHandler {
|
|
|
190
178
|
/**
|
|
191
179
|
* Validate messages before writing
|
|
192
180
|
*/
|
|
193
|
-
private validateMessages(messages:
|
|
181
|
+
private validateMessages(messages: Message[]): void {
|
|
194
182
|
for (let i = 0; i < messages.length; i++) {
|
|
195
183
|
const message = messages[i];
|
|
196
184
|
|
package/src/services/session.ts
CHANGED
|
@@ -20,7 +20,6 @@ import { join } from "path";
|
|
|
20
20
|
import { homedir } from "os";
|
|
21
21
|
import { randomUUID } from "crypto";
|
|
22
22
|
import type { Message } from "../types/index.js";
|
|
23
|
-
import type { SessionMessage } from "../types/session.js";
|
|
24
23
|
import { PathEncoder } from "../utils/pathEncoder.js";
|
|
25
24
|
import { JsonlHandler } from "../services/jsonlHandler.js";
|
|
26
25
|
import { extractLatestTotalTokens } from "../utils/tokenCalculation.js";
|
|
@@ -228,19 +227,14 @@ export async function appendMessages(
|
|
|
228
227
|
);
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
|
|
232
|
-
timestamp: new Date().toISOString(),
|
|
233
|
-
...msg,
|
|
234
|
-
}));
|
|
235
|
-
|
|
236
|
-
await jsonlHandler.append(filePath, messagesWithTimestamp, {
|
|
230
|
+
await jsonlHandler.append(filePath, newMessages, {
|
|
237
231
|
atomic: false,
|
|
238
232
|
});
|
|
239
233
|
|
|
240
234
|
// Update index
|
|
241
235
|
const encoder = new PathEncoder();
|
|
242
236
|
const projectDir = await encoder.getProjectDirectory(workdir, SESSION_DIR);
|
|
243
|
-
const lastMessage =
|
|
237
|
+
const lastMessage = newMessages[newMessages.length - 1];
|
|
244
238
|
|
|
245
239
|
// Get first message content if it's a new session or we don't have it
|
|
246
240
|
let firstMessage: string | undefined;
|
|
@@ -333,12 +327,7 @@ export async function loadSessionFromJsonl(
|
|
|
333
327
|
id: sessionId,
|
|
334
328
|
rootSessionId: rootSessionId || sessionId,
|
|
335
329
|
parentSessionId,
|
|
336
|
-
messages
|
|
337
|
-
// Remove timestamp property for backward compatibility
|
|
338
|
-
const { timestamp: _ignored, ...messageWithoutTimestamp } = msg;
|
|
339
|
-
void _ignored; // Use the variable to avoid eslint error
|
|
340
|
-
return messageWithoutTimestamp;
|
|
341
|
-
}),
|
|
330
|
+
messages,
|
|
342
331
|
metadata: {
|
|
343
332
|
workdir,
|
|
344
333
|
lastActiveAt: lastMessage
|
package/src/tools/agentTool.ts
CHANGED
|
@@ -159,20 +159,39 @@ When using the Agent tool, you must specify a subagent_type parameter to select
|
|
|
159
159
|
|
|
160
160
|
const messages = instance.messageManager.getMessages();
|
|
161
161
|
const tokens = instance.messageManager.getLatestTotalTokens();
|
|
162
|
-
const
|
|
162
|
+
const usedTools = instance.usedTools;
|
|
163
163
|
|
|
164
164
|
const toolCount = countToolBlocks(messages);
|
|
165
165
|
const summary = formatToolTokenSummary(toolCount, tokens);
|
|
166
166
|
|
|
167
|
+
const getDisplayParam = (t: {
|
|
168
|
+
name: string;
|
|
169
|
+
parameters: string;
|
|
170
|
+
compactParams?: string;
|
|
171
|
+
stage?: string;
|
|
172
|
+
}) => {
|
|
173
|
+
if (
|
|
174
|
+
(t.stage === "end" || t.stage === "running") &&
|
|
175
|
+
t.compactParams
|
|
176
|
+
) {
|
|
177
|
+
return t.compactParams;
|
|
178
|
+
}
|
|
179
|
+
const flat = t.parameters.replace(/\n/g, "\\n");
|
|
180
|
+
return flat.length > 30 ? `…${flat.slice(-30)}` : flat;
|
|
181
|
+
};
|
|
182
|
+
|
|
167
183
|
let shortResult = "";
|
|
168
184
|
if (toolCount > 2) {
|
|
169
185
|
shortResult += "... ";
|
|
170
186
|
}
|
|
171
|
-
if (lastTools.length > 0) {
|
|
172
|
-
shortResult += `${lastTools.join(", ")} `;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
187
|
shortResult += summary;
|
|
188
|
+
if (usedTools.length > 0) {
|
|
189
|
+
shortResult +=
|
|
190
|
+
"\n" +
|
|
191
|
+
usedTools
|
|
192
|
+
.map((t) => `${t.name} ${getDisplayParam(t)}`)
|
|
193
|
+
.join("\n");
|
|
194
|
+
}
|
|
176
195
|
|
|
177
196
|
context.onShortResultUpdate?.(shortResult);
|
|
178
197
|
},
|
package/src/tools/bashTool.ts
CHANGED
|
@@ -80,7 +80,7 @@ export const bashTool: ToolPlugin = {
|
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
prompt: () => `
|
|
83
|
-
Executes a given bash command
|
|
83
|
+
Executes a given bash command with optional timeout, ensuring proper handling and security measures. Each invocation runs in a fresh shell process starting from the project root.
|
|
84
84
|
|
|
85
85
|
IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.
|
|
86
86
|
|
|
@@ -139,10 +139,7 @@ Use the gh command via the Bash tool for GitHub-related tasks including working
|
|
|
139
139
|
- Do not retry failing commands in a sleep loop — diagnose the root cause.
|
|
140
140
|
- If waiting for a background task you started with \`run_in_background\`, you will be notified when it completes — do not poll.
|
|
141
141
|
- If you must poll an external process, use a check command (e.g. \`gh run view\`) rather than sleeping first.
|
|
142
|
-
- If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user
|
|
143
|
-
|
|
144
|
-
# CWD management
|
|
145
|
-
Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of \`cd\`. You may use \`cd\` if the User explicitly requests it. When you use \`cd\`, the shell working directory will be reset to the original working directory after the command completes.`,
|
|
142
|
+
- If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user.`,
|
|
146
143
|
execute: async (
|
|
147
144
|
args: Record<string, unknown>,
|
|
148
145
|
context: ToolContext,
|
package/src/tools/skillTool.ts
CHANGED
|
@@ -148,19 +148,39 @@ export const skillTool: ToolPlugin = {
|
|
|
148
148
|
// Update shortResult
|
|
149
149
|
const messages = instance.messageManager.getMessages();
|
|
150
150
|
const tokens = instance.messageManager.getLatestTotalTokens();
|
|
151
|
-
const
|
|
151
|
+
const usedTools = instance.usedTools;
|
|
152
152
|
|
|
153
153
|
const toolCount = countToolBlocks(messages);
|
|
154
154
|
const summary = formatToolTokenSummary(toolCount, tokens);
|
|
155
155
|
|
|
156
|
+
const getDisplayParam = (t: {
|
|
157
|
+
name: string;
|
|
158
|
+
parameters: string;
|
|
159
|
+
compactParams?: string;
|
|
160
|
+
stage?: string;
|
|
161
|
+
}) => {
|
|
162
|
+
if (
|
|
163
|
+
(t.stage === "end" || t.stage === "running") &&
|
|
164
|
+
t.compactParams
|
|
165
|
+
) {
|
|
166
|
+
return t.compactParams;
|
|
167
|
+
}
|
|
168
|
+
const flat = t.parameters.replace(/\n/g, "\\n");
|
|
169
|
+
return flat.length > 30 ? `…${flat.slice(-30)}` : flat;
|
|
170
|
+
};
|
|
171
|
+
|
|
156
172
|
let shortResult = "";
|
|
157
173
|
if (toolCount > 2) {
|
|
158
174
|
shortResult += "... ";
|
|
159
175
|
}
|
|
160
|
-
if (lastTools.length > 0) {
|
|
161
|
-
shortResult += `${lastTools.join(", ")} `;
|
|
162
|
-
}
|
|
163
176
|
shortResult += summary;
|
|
177
|
+
if (usedTools.length > 0) {
|
|
178
|
+
shortResult +=
|
|
179
|
+
"\n" +
|
|
180
|
+
usedTools
|
|
181
|
+
.map((t) => `${t.name} ${getDisplayParam(t)}`)
|
|
182
|
+
.join("\n");
|
|
183
|
+
}
|
|
164
184
|
|
|
165
185
|
context.onShortResultUpdate?.(shortResult);
|
|
166
186
|
},
|
package/src/types/messaging.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface Message {
|
|
|
14
14
|
id: string; // Unique identifier for the message
|
|
15
15
|
role: "user" | "assistant";
|
|
16
16
|
blocks: MessageBlock[];
|
|
17
|
+
timestamp: string; // ISO 8601 timestamp, assigned at creation
|
|
17
18
|
usage?: Usage; // Usage data for this message's AI operation (assistant messages only)
|
|
18
19
|
additionalFields?: Record<string, unknown>; // Additional metadata from AI responses
|
|
19
20
|
isMeta?: boolean; // Whether the message is a meta message (hidden from UI)
|
package/src/types/session.ts
CHANGED
|
@@ -5,14 +5,6 @@
|
|
|
5
5
|
* SIMPLIFIED: Removed unused interfaces to focus on core functionality
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { Message } from "./messaging.js";
|
|
9
|
-
|
|
10
|
-
// Enhanced message interface for JSONL storage (extends existing Message)
|
|
11
|
-
export interface SessionMessage extends Message {
|
|
12
|
-
timestamp: string; // ISO 8601 - added for JSONL format
|
|
13
|
-
// Inherits: role: "user" | "assistant", blocks: MessageBlock[], usage?, additionalFields?
|
|
14
|
-
}
|
|
15
|
-
|
|
16
8
|
// Session filename structure for simple filename-based metadata
|
|
17
9
|
export interface SessionFilename {
|
|
18
10
|
sessionId: string;
|
|
@@ -160,6 +160,7 @@ export const addUserMessageToMessages = ({
|
|
|
160
160
|
id: id || generateMessageId(),
|
|
161
161
|
role: "user",
|
|
162
162
|
blocks,
|
|
163
|
+
timestamp: new Date().toISOString(),
|
|
163
164
|
...(isMeta !== undefined && { isMeta }),
|
|
164
165
|
};
|
|
165
166
|
return [...messages, userMessage];
|
|
@@ -231,6 +232,7 @@ export const addAssistantMessageToMessages = (
|
|
|
231
232
|
id: generateMessageId(),
|
|
232
233
|
role: "assistant",
|
|
233
234
|
blocks,
|
|
235
|
+
timestamp: new Date().toISOString(),
|
|
234
236
|
usage, // Include usage data if provided
|
|
235
237
|
...(additionalFields ? { additionalFields: { ...additionalFields } } : {}),
|
|
236
238
|
};
|
|
@@ -407,6 +409,7 @@ export const addErrorBlockToMessage = ({
|
|
|
407
409
|
content: error,
|
|
408
410
|
},
|
|
409
411
|
],
|
|
412
|
+
timestamp: new Date().toISOString(),
|
|
410
413
|
});
|
|
411
414
|
}
|
|
412
415
|
|
|
@@ -430,6 +433,7 @@ export const addBangMessage = ({
|
|
|
430
433
|
exitCode: null,
|
|
431
434
|
},
|
|
432
435
|
],
|
|
436
|
+
timestamp: new Date().toISOString(),
|
|
433
437
|
};
|
|
434
438
|
|
|
435
439
|
return [...messages, outputMessage];
|
|
@@ -620,6 +624,7 @@ export const addNotificationMessageToMessages = ({
|
|
|
620
624
|
id: generateMessageId(),
|
|
621
625
|
role: "user",
|
|
622
626
|
blocks: [block],
|
|
627
|
+
timestamp: new Date().toISOString(),
|
|
623
628
|
};
|
|
624
629
|
|
|
625
630
|
return [...messages, notificationMessage];
|