wave-agent-sdk 0.12.8 → 0.12.10
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/builtin/skills/settings/ENV.md +1 -0
- package/builtin/skills/settings/PERMISSIONS.md +57 -0
- package/builtin/skills/settings/SKILL.md +12 -3
- package/dist/managers/messageManager.d.ts +1 -5
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +1 -28
- package/dist/managers/permissionManager.d.ts +6 -0
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +9 -0
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +31 -46
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +8 -0
- package/dist/services/aiService.js +4 -4
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +1 -0
- package/dist/services/initializationService.d.ts.map +1 -1
- package/dist/services/initializationService.js +2 -0
- package/dist/types/messaging.d.ts +1 -11
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/utils/cacheControlUtils.d.ts +8 -1
- package/dist/utils/cacheControlUtils.d.ts.map +1 -1
- package/dist/utils/cacheControlUtils.js +25 -8
- package/dist/utils/containerSetup.d.ts.map +1 -1
- package/dist/utils/containerSetup.js +2 -0
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
- package/dist/utils/convertMessagesForAPI.js +0 -15
- package/dist/utils/messageOperations.d.ts +0 -26
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +0 -80
- package/package.json +1 -1
- package/src/managers/messageManager.ts +0 -40
- package/src/managers/permissionManager.ts +12 -0
- package/src/managers/slashCommandManager.ts +33 -49
- package/src/managers/subagentManager.ts +15 -0
- package/src/services/aiService.ts +4 -4
- package/src/services/configurationService.ts +1 -0
- package/src/services/initializationService.ts +2 -0
- package/src/types/messaging.ts +0 -12
- package/src/utils/cacheControlUtils.ts +27 -8
- package/src/utils/containerSetup.ts +2 -0
- package/src/utils/convertMessagesForAPI.ts +0 -16
- package/src/utils/messageOperations.ts +0 -114
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheControlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/cacheControlUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,EAE1B,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAO1B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mCACf,SAAQ,6BAA6B;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,gCACf,SAAQ,0BAA0B;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAC;IACjD,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IAGrB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,cAAc,CAAC,EAAE;QACf,yBAAyB,EAAE,MAAM,CAAC;QAClC,yBAAyB,EAAE,MAAM,CAAC;KACnC,CAAC;CACH;AAUD;;;;GAIG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"cacheControlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/cacheControlUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OA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BAAyB,CACvC,KAAK,EAAE,0BAA0B,EAAE,GAClC,gCAAgC,EAAE,CAwCpC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,0BAA0B,EAAE,GACrC,MAAM,CAoBR;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,0BAA0B,EAAE,EACtC,SAAS,EAAE,MAAM,GAChB,0BAA0B,EAAE,CAgG9B;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,eAAe,EAC9B,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAClC,WAAW,CAkCb;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAyCvE"}
|
|
@@ -13,11 +13,11 @@ import { logger } from "./globalLogger.js";
|
|
|
13
13
|
// Utility Functions (Basic Structure - to be implemented)
|
|
14
14
|
// ============================================================================
|
|
15
15
|
/**
|
|
16
|
-
* Determines if a model supports
|
|
16
|
+
* Determines if a model supports prompt caching
|
|
17
17
|
* @param modelName - Model identifier
|
|
18
|
-
* @returns True if model name contains 'claude'
|
|
18
|
+
* @returns True if model name matches the cache pattern (default: contains 'claude')
|
|
19
19
|
*/
|
|
20
|
-
export function
|
|
20
|
+
export function supportsPromptCaching(modelName) {
|
|
21
21
|
// Handle null, undefined, and non-string inputs
|
|
22
22
|
if (!modelName || typeof modelName !== "string") {
|
|
23
23
|
return false;
|
|
@@ -27,8 +27,23 @@ export function isClaudeModel(modelName) {
|
|
|
27
27
|
if (trimmed.length === 0) {
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
const cachePattern = process.env.WAVE_PROMPT_CACHE_REGEX || "claude";
|
|
31
|
+
try {
|
|
32
|
+
const regex = new RegExp(cachePattern, "i");
|
|
33
|
+
return regex.test(trimmed);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// If regex is invalid, fall back to simple includes check with default
|
|
37
|
+
return trimmed.toLowerCase().includes("claude");
|
|
38
|
+
}
|
|
31
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Determines if a model supports cache control
|
|
42
|
+
* @param modelName - Model identifier
|
|
43
|
+
* @returns True if model name contains 'claude' (case-insensitive)
|
|
44
|
+
* @deprecated Use supportsPromptCaching instead
|
|
45
|
+
*/
|
|
46
|
+
export const isClaudeModel = supportsPromptCaching;
|
|
32
47
|
/**
|
|
33
48
|
* Validates cache control structure
|
|
34
49
|
* @param control - Object to validate
|
|
@@ -195,8 +210,8 @@ export function transformMessagesForClaudeCache(messages, modelName) {
|
|
|
195
210
|
if (messages.length === 0) {
|
|
196
211
|
return [];
|
|
197
212
|
}
|
|
198
|
-
// Only apply cache control for
|
|
199
|
-
if (!
|
|
213
|
+
// Only apply cache control for models that support prompt caching
|
|
214
|
+
if (!supportsPromptCaching(modelName)) {
|
|
200
215
|
return messages;
|
|
201
216
|
}
|
|
202
217
|
// Find the latest interval message index (20th, 40th, 60th, etc.)
|
|
@@ -228,11 +243,13 @@ export function transformMessagesForClaudeCache(messages, modelName) {
|
|
|
228
243
|
}
|
|
229
244
|
// Interval-based message caching: cache message at latest interval position (sliding window)
|
|
230
245
|
if (index === intervalMessageIndex) {
|
|
231
|
-
// If the message is a tool role, add cache control
|
|
246
|
+
// If the message is a tool role, add cache control to the content block
|
|
232
247
|
if (message.role === "tool") {
|
|
248
|
+
const content = typeof message.content === "string" ? message.content : "";
|
|
249
|
+
const transformedContent = addCacheControlToContent(content, true);
|
|
233
250
|
return {
|
|
234
251
|
...message,
|
|
235
|
-
|
|
252
|
+
content: transformedContent,
|
|
236
253
|
};
|
|
237
254
|
}
|
|
238
255
|
// If the message has tool calls, cache the last tool call instead of content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerSetup.d.ts","sourceRoot":"","sources":["../../src/utils/containerSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAqB3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"containerSetup.d.ts","sourceRoot":"","sources":["../../src/utils/containerSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAqB3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAM3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,IAAI,EACJ,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAGhB,uBAAuB,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACvC,sBAAsB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACvD,wBAAwB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACzD,iBAAiB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,0BAA0B,GACvC,SAAS,CA8PX"}
|
|
@@ -23,6 +23,7 @@ import { ReversionService } from "../services/reversionService.js";
|
|
|
23
23
|
import { MemoryService } from "../services/memory.js";
|
|
24
24
|
import { AutoMemoryService } from "../services/autoMemoryService.js";
|
|
25
25
|
import { getGitMainRepoRoot } from "./gitUtils.js";
|
|
26
|
+
import { USER_MEMORY_FILE } from "./constants.js";
|
|
26
27
|
import { logger } from "./globalLogger.js";
|
|
27
28
|
export function setupAgentContainer(setupOptions) {
|
|
28
29
|
const { options, workdir, configurationService, systemPrompt, stream, onBackgroundTasksChange, onTasksChange, onPermissionModeChange, handlePlanModeTransition, setPermissionMode, addPermissionRule, addUsage, } = setupOptions;
|
|
@@ -93,6 +94,7 @@ export function setupAgentContainer(setupOptions) {
|
|
|
93
94
|
if (configurationService.resolveAutoMemoryEnabled()) {
|
|
94
95
|
const autoMemoryDir = memoryService.getAutoMemoryDirectory(workdir);
|
|
95
96
|
permissionManager.addSystemAdditionalDirectory(autoMemoryDir);
|
|
97
|
+
permissionManager.addSystemAdditionalDirectory(USER_MEMORY_FILE);
|
|
96
98
|
}
|
|
97
99
|
container.register("PermissionManager", permissionManager);
|
|
98
100
|
permissionManager.setOnConfiguredPermissionModeChange((mode) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertMessagesForAPI.d.ts","sourceRoot":"","sources":["../../src/utils/convertMessagesForAPI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAEL,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AA0B7B;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EAAE,GAClB,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"convertMessagesForAPI.d.ts","sourceRoot":"","sources":["../../src/utils/convertMessagesForAPI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAEL,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AA0B7B;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EAAE,GAClB,0BAA0B,EAAE,CA8N9B"}
|
|
@@ -155,21 +155,6 @@ export function convertMessagesForAPI(messages) {
|
|
|
155
155
|
text: block.content,
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
// Handle SlashBlock
|
|
159
|
-
if (block.type === "slash") {
|
|
160
|
-
if (block.content && block.content.trim().length > 0) {
|
|
161
|
-
contentParts.push({
|
|
162
|
-
type: "text",
|
|
163
|
-
text: block.content,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
if (block.result && block.result.trim().length > 0) {
|
|
167
|
-
contentParts.push({
|
|
168
|
-
type: "text",
|
|
169
|
-
text: `<local-command-stdout>\n${stripAnsiColors(block.result)}\n</local-command-stdout>`,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
158
|
// If there is an image, add image content
|
|
174
159
|
if (block.type === "image" &&
|
|
175
160
|
block.imageUrls &&
|
|
@@ -14,24 +14,6 @@ export interface AddUserMessageParams extends UserMessageParams {
|
|
|
14
14
|
messages: Message[];
|
|
15
15
|
id?: string;
|
|
16
16
|
}
|
|
17
|
-
export interface AddSlashParams {
|
|
18
|
-
messages: Message[];
|
|
19
|
-
command: string;
|
|
20
|
-
args?: string;
|
|
21
|
-
content?: string;
|
|
22
|
-
id?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface UpdateSlashParams {
|
|
25
|
-
messages: Message[];
|
|
26
|
-
command: string;
|
|
27
|
-
messageId?: string;
|
|
28
|
-
args?: string;
|
|
29
|
-
content?: string;
|
|
30
|
-
result?: string;
|
|
31
|
-
stage?: "running" | "success" | "error" | "aborted";
|
|
32
|
-
error?: string;
|
|
33
|
-
shortResult?: string;
|
|
34
|
-
}
|
|
35
17
|
export interface UpdateToolBlockParams {
|
|
36
18
|
messages: Message[];
|
|
37
19
|
id: string;
|
|
@@ -87,14 +69,6 @@ export interface CompleteBangParams {
|
|
|
87
69
|
export declare const convertImageToBase64: (imagePath: string) => string;
|
|
88
70
|
export declare const generateMessageId: () => string;
|
|
89
71
|
export declare const addUserMessageToMessages: ({ messages, content, images, source, id, isMeta, }: AddUserMessageParams) => Message[];
|
|
90
|
-
/**
|
|
91
|
-
* Add a slash command message to the conversation.
|
|
92
|
-
*/
|
|
93
|
-
export declare const addSlashMessageToMessages: ({ messages, command, args, content, id, }: AddSlashParams) => Message[];
|
|
94
|
-
/**
|
|
95
|
-
* Update a slash block in a message.
|
|
96
|
-
*/
|
|
97
|
-
export declare const updateSlashBlockInMessage: ({ messages, command, messageId, args, content, result, stage, error, shortResult, }: UpdateSlashParams) => Message[];
|
|
98
72
|
/**
|
|
99
73
|
* Update a user message's content by its ID.
|
|
100
74
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAa,MAAM,mBAAmB,CAAC;AACnE,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,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;IAC7D,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mapp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BAA0B,EAAE,IAAI,CAAC,KAC7C;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAuB5C,CAAC;AAGF,eAAO,MAAM,wBAAwB,GAAI,6KAgBtC,qBAAqB,KAAG,OAAO,EAsFjC,CAAC;AAGF,eAAO,MAAM,sBAAsB,GAAI,sBAGpC,mBAAmB,KAAG,OAAO,EAgC/B,CAAC;AAGF,eAAO,MAAM,cAAc,GAAI,wBAG5B,aAAa,KAAG,OAAO,EAgBzB,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAI,gCAIjC,gBAAgB,KAAG,OAAO,EAiB5B,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAAI,0CAKnC,kBAAkB,KAAG,OAAO,EAqB9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAU3D;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,OAAO,EAAE,KAAG,OAAO,EASlE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAoBtD;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,CAoB1D"}
|
|
@@ -69,82 +69,6 @@ export const addUserMessageToMessages = ({ messages, content, images, source, id
|
|
|
69
69
|
};
|
|
70
70
|
return [...messages, userMessage];
|
|
71
71
|
};
|
|
72
|
-
/**
|
|
73
|
-
* Add a slash command message to the conversation.
|
|
74
|
-
*/
|
|
75
|
-
export const addSlashMessageToMessages = ({ messages, command, args, content, id, }) => {
|
|
76
|
-
const slashMessage = {
|
|
77
|
-
id: id || generateMessageId(),
|
|
78
|
-
role: "user",
|
|
79
|
-
blocks: [
|
|
80
|
-
{
|
|
81
|
-
type: "slash",
|
|
82
|
-
command,
|
|
83
|
-
args,
|
|
84
|
-
content,
|
|
85
|
-
stage: "running",
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
};
|
|
89
|
-
return [...messages, slashMessage];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Update a slash block in a message.
|
|
93
|
-
*/
|
|
94
|
-
export const updateSlashBlockInMessage = ({ messages, command, messageId, args, content, result, stage, error, shortResult, }) => {
|
|
95
|
-
const newMessages = [...messages];
|
|
96
|
-
// If messageId is provided, target that specific message
|
|
97
|
-
if (messageId) {
|
|
98
|
-
const messageIndex = newMessages.findIndex((msg) => msg.id === messageId);
|
|
99
|
-
if (messageIndex !== -1) {
|
|
100
|
-
const slashBlockIndex = newMessages[messageIndex].blocks.findIndex((block) => block.type === "slash" && block.command === command);
|
|
101
|
-
if (slashBlockIndex !== -1) {
|
|
102
|
-
const slashBlock = newMessages[messageIndex].blocks[slashBlockIndex];
|
|
103
|
-
if (slashBlock.type === "slash") {
|
|
104
|
-
if (args !== undefined)
|
|
105
|
-
slashBlock.args = args;
|
|
106
|
-
if (content !== undefined)
|
|
107
|
-
slashBlock.content = content;
|
|
108
|
-
if (result !== undefined)
|
|
109
|
-
slashBlock.result = result;
|
|
110
|
-
if (stage !== undefined)
|
|
111
|
-
slashBlock.stage = stage;
|
|
112
|
-
if (error !== undefined)
|
|
113
|
-
slashBlock.error = error;
|
|
114
|
-
if (shortResult !== undefined)
|
|
115
|
-
slashBlock.shortResult = shortResult;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return newMessages;
|
|
120
|
-
}
|
|
121
|
-
// Find the last user message with a slash block for this command
|
|
122
|
-
for (let i = newMessages.length - 1; i >= 0; i--) {
|
|
123
|
-
const msg = newMessages[i];
|
|
124
|
-
if (msg.role === "user") {
|
|
125
|
-
const slashBlockIndex = msg.blocks.findIndex((block) => block.type === "slash" && block.command === command);
|
|
126
|
-
if (slashBlockIndex !== -1) {
|
|
127
|
-
const slashBlock = msg.blocks[slashBlockIndex];
|
|
128
|
-
if (slashBlock.type === "slash") {
|
|
129
|
-
if (args !== undefined)
|
|
130
|
-
slashBlock.args = args;
|
|
131
|
-
if (content !== undefined)
|
|
132
|
-
slashBlock.content = content;
|
|
133
|
-
if (result !== undefined)
|
|
134
|
-
slashBlock.result = result;
|
|
135
|
-
if (stage !== undefined)
|
|
136
|
-
slashBlock.stage = stage;
|
|
137
|
-
if (error !== undefined)
|
|
138
|
-
slashBlock.error = error;
|
|
139
|
-
if (shortResult !== undefined)
|
|
140
|
-
slashBlock.shortResult = shortResult;
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return newMessages;
|
|
147
|
-
};
|
|
148
72
|
/**
|
|
149
73
|
* Update a user message's content by its ID.
|
|
150
74
|
*/
|
|
@@ -486,10 +410,6 @@ export function getMessageContent(message) {
|
|
|
486
410
|
if (textBlock && "content" in textBlock) {
|
|
487
411
|
return textBlock.content;
|
|
488
412
|
}
|
|
489
|
-
const slashBlock = message.blocks.find((block) => block.type === "slash");
|
|
490
|
-
if (slashBlock && "command" in slashBlock) {
|
|
491
|
-
return `/${slashBlock.command}${slashBlock.args ? ` ${slashBlock.args}` : ""}`;
|
|
492
|
-
}
|
|
493
413
|
const bangBlock = message.blocks.find((block) => block.type === "bang");
|
|
494
414
|
if (bangBlock && "command" in bangBlock) {
|
|
495
415
|
return `!${bangBlock.command}`;
|
package/package.json
CHANGED
|
@@ -7,13 +7,9 @@ import {
|
|
|
7
7
|
addBangMessage,
|
|
8
8
|
updateBangInMessage,
|
|
9
9
|
completeBangInMessage,
|
|
10
|
-
addSlashMessageToMessages,
|
|
11
|
-
updateSlashBlockInMessage,
|
|
12
10
|
removeLastUserMessage,
|
|
13
11
|
addToolBlockToMessageInMessages,
|
|
14
12
|
UserMessageParams,
|
|
15
|
-
AddSlashParams,
|
|
16
|
-
UpdateSlashParams,
|
|
17
13
|
type AgentToolBlockUpdateParams,
|
|
18
14
|
generateMessageId,
|
|
19
15
|
} from "../utils/messageOperations.js";
|
|
@@ -54,13 +50,6 @@ export interface MessageManagerCallbacks {
|
|
|
54
50
|
onAddBangMessage?: (command: string) => void;
|
|
55
51
|
onUpdateBangMessage?: (command: string, output: string) => void;
|
|
56
52
|
onCompleteBangMessage?: (command: string, exitCode: number) => void;
|
|
57
|
-
// Slash callback
|
|
58
|
-
onAddSlashMessage?: (
|
|
59
|
-
params: import("../utils/messageOperations.js").AddSlashParams,
|
|
60
|
-
) => void;
|
|
61
|
-
onUpdateSlashBlock?: (
|
|
62
|
-
params: import("../utils/messageOperations.js").UpdateSlashParams,
|
|
63
|
-
) => void;
|
|
64
53
|
onInfoBlockAdded?: (content: string) => void;
|
|
65
54
|
// Rewind callbacks
|
|
66
55
|
onShowRewind?: () => void;
|
|
@@ -594,35 +583,6 @@ export class MessageManager {
|
|
|
594
583
|
this.callbacks.onCompleteBangMessage?.(command, exitCode);
|
|
595
584
|
}
|
|
596
585
|
|
|
597
|
-
// Slash related message operations
|
|
598
|
-
public addSlashMessage(params: Omit<AddSlashParams, "messages">): string {
|
|
599
|
-
const id = params.id || generateMessageId();
|
|
600
|
-
const updatedMessages = addSlashMessageToMessages({
|
|
601
|
-
messages: this.messages,
|
|
602
|
-
...params,
|
|
603
|
-
id,
|
|
604
|
-
});
|
|
605
|
-
this.setMessages(updatedMessages);
|
|
606
|
-
this.callbacks.onAddSlashMessage?.({
|
|
607
|
-
messages: updatedMessages,
|
|
608
|
-
...params,
|
|
609
|
-
id,
|
|
610
|
-
});
|
|
611
|
-
return id;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
public updateSlashBlock(params: Omit<UpdateSlashParams, "messages">): void {
|
|
615
|
-
const updatedMessages = updateSlashBlockInMessage({
|
|
616
|
-
messages: this.messages,
|
|
617
|
-
...params,
|
|
618
|
-
});
|
|
619
|
-
this.setMessages(updatedMessages);
|
|
620
|
-
this.callbacks.onUpdateSlashBlock?.({
|
|
621
|
-
messages: updatedMessages,
|
|
622
|
-
...params,
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
|
|
626
586
|
/**
|
|
627
587
|
* Rebuild usage array from messages containing usage metadata
|
|
628
588
|
* Called during session restoration to reconstruct usage tracking
|
|
@@ -110,6 +110,8 @@ export interface PermissionManagerOptions {
|
|
|
110
110
|
instanceDeniedRules?: string[];
|
|
111
111
|
/** Additional directories considered part of the Safe Zone */
|
|
112
112
|
additionalDirectories?: string[];
|
|
113
|
+
/** System additional directories (persistent across reloads) */
|
|
114
|
+
systemAdditionalDirectories?: string[];
|
|
113
115
|
/** The main working directory */
|
|
114
116
|
workdir?: string;
|
|
115
117
|
/** Path to the current plan file */
|
|
@@ -147,6 +149,9 @@ export class PermissionManager {
|
|
|
147
149
|
this.planFilePath = options.planFilePath;
|
|
148
150
|
this._logger = options.logger;
|
|
149
151
|
this.updateAdditionalDirectories(options.additionalDirectories || []);
|
|
152
|
+
for (const dir of options.systemAdditionalDirectories || []) {
|
|
153
|
+
this.addSystemAdditionalDirectory(dir);
|
|
154
|
+
}
|
|
150
155
|
|
|
151
156
|
this.worktreeName = this.container.get<string>("WorktreeName");
|
|
152
157
|
this.mainRepoRoot = this.container.get<string>("MainRepoRoot");
|
|
@@ -220,6 +225,13 @@ export class PermissionManager {
|
|
|
220
225
|
return [...this.additionalDirectories];
|
|
221
226
|
}
|
|
222
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Get all system additional directories
|
|
230
|
+
*/
|
|
231
|
+
public getSystemAdditionalDirectories(): string[] {
|
|
232
|
+
return [...this.systemAdditionalDirectories];
|
|
233
|
+
}
|
|
234
|
+
|
|
223
235
|
/**
|
|
224
236
|
* Get all default allowed rules
|
|
225
237
|
*/
|
|
@@ -130,7 +130,6 @@ export class SlashCommandManager {
|
|
|
130
130
|
command.name,
|
|
131
131
|
processedContent,
|
|
132
132
|
command.config,
|
|
133
|
-
args,
|
|
134
133
|
);
|
|
135
134
|
},
|
|
136
135
|
});
|
|
@@ -171,25 +170,27 @@ export class SlashCommandManager {
|
|
|
171
170
|
args,
|
|
172
171
|
});
|
|
173
172
|
|
|
174
|
-
// 2. Add slash message immediately
|
|
175
|
-
const messageId = this.messageManager.addSlashMessage({
|
|
176
|
-
command: skill.name,
|
|
177
|
-
args,
|
|
178
|
-
content: prepared.content,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
173
|
if (!prepared.skill) {
|
|
182
|
-
// If skill not found or invalid,
|
|
183
|
-
this.messageManager.
|
|
184
|
-
command: skill.name,
|
|
185
|
-
messageId,
|
|
186
|
-
stage: "error",
|
|
187
|
-
error: prepared.content,
|
|
188
|
-
});
|
|
174
|
+
// If skill not found or invalid, add error
|
|
175
|
+
this.messageManager.addErrorBlock(prepared.content);
|
|
189
176
|
return;
|
|
190
177
|
}
|
|
191
178
|
|
|
192
179
|
if (skill.context === "fork") {
|
|
180
|
+
// Forked skill execution: add user message with text + tool block
|
|
181
|
+
const messageId = this.messageManager.addUserMessage({
|
|
182
|
+
content: `/${skill.name} ${args || ""}`,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const toolBlockId = this.messageManager.addToolBlockToMessage(
|
|
186
|
+
messageId,
|
|
187
|
+
{
|
|
188
|
+
name: skill.name,
|
|
189
|
+
parameters: prepared.content,
|
|
190
|
+
stage: "running",
|
|
191
|
+
},
|
|
192
|
+
);
|
|
193
|
+
|
|
193
194
|
// Forked skill execution
|
|
194
195
|
const subagentConfigs =
|
|
195
196
|
await this.subagentManager.loadConfigurations();
|
|
@@ -214,7 +215,7 @@ export class SlashCommandManager {
|
|
|
214
215
|
},
|
|
215
216
|
false,
|
|
216
217
|
() => {
|
|
217
|
-
// Update the
|
|
218
|
+
// Update the tool block with progress
|
|
218
219
|
const subagent = this.subagentManager.getInstance(
|
|
219
220
|
instance.subagentId,
|
|
220
221
|
);
|
|
@@ -237,8 +238,8 @@ export class SlashCommandManager {
|
|
|
237
238
|
|
|
238
239
|
shortResult += summary;
|
|
239
240
|
|
|
240
|
-
this.messageManager.
|
|
241
|
-
|
|
241
|
+
this.messageManager.updateToolBlock({
|
|
242
|
+
id: toolBlockId,
|
|
242
243
|
messageId,
|
|
243
244
|
shortResult,
|
|
244
245
|
});
|
|
@@ -253,24 +254,22 @@ export class SlashCommandManager {
|
|
|
253
254
|
signal,
|
|
254
255
|
);
|
|
255
256
|
|
|
256
|
-
// Update the
|
|
257
|
-
this.messageManager.
|
|
258
|
-
|
|
257
|
+
// Update the ToolBlock with final result
|
|
258
|
+
this.messageManager.updateToolBlock({
|
|
259
|
+
id: toolBlockId,
|
|
259
260
|
messageId,
|
|
260
261
|
result,
|
|
261
|
-
stage: "
|
|
262
|
+
stage: "end",
|
|
262
263
|
});
|
|
263
264
|
} finally {
|
|
264
265
|
this.subagentManager.cleanupInstance(instance.subagentId);
|
|
265
266
|
}
|
|
266
267
|
} catch (error) {
|
|
267
|
-
// Update the
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
this.messageManager.updateSlashBlock({
|
|
271
|
-
command: skill.name,
|
|
268
|
+
// Update the ToolBlock with error
|
|
269
|
+
this.messageManager.updateToolBlock({
|
|
270
|
+
id: toolBlockId,
|
|
272
271
|
messageId,
|
|
273
|
-
stage:
|
|
272
|
+
stage: "end",
|
|
274
273
|
error: error instanceof Error ? error.message : String(error),
|
|
275
274
|
});
|
|
276
275
|
throw error; // Re-throw to be caught by outer catch for logging/error block
|
|
@@ -278,21 +277,18 @@ export class SlashCommandManager {
|
|
|
278
277
|
return;
|
|
279
278
|
}
|
|
280
279
|
|
|
281
|
-
//
|
|
280
|
+
// Non-forked skill: execute and trigger AI response
|
|
282
281
|
const result = await this.skillManager.executeSkill({
|
|
283
282
|
skill_name: skill.name,
|
|
284
283
|
args,
|
|
285
284
|
});
|
|
286
285
|
|
|
287
|
-
//
|
|
288
|
-
this.messageManager.
|
|
289
|
-
command: skill.name,
|
|
290
|
-
messageId,
|
|
286
|
+
// Add user message with the processed content
|
|
287
|
+
this.messageManager.addUserMessage({
|
|
291
288
|
content: result.content,
|
|
292
|
-
stage: "success",
|
|
293
289
|
});
|
|
294
290
|
|
|
295
|
-
//
|
|
291
|
+
// Trigger AI response
|
|
296
292
|
await this.aiManager.sendAIMessage({
|
|
297
293
|
model: skill.model,
|
|
298
294
|
allowedRules: result.allowedTools,
|
|
@@ -352,7 +348,6 @@ export class SlashCommandManager {
|
|
|
352
348
|
namespacedName,
|
|
353
349
|
processedContent,
|
|
354
350
|
command.config,
|
|
355
|
-
args,
|
|
356
351
|
);
|
|
357
352
|
},
|
|
358
353
|
});
|
|
@@ -489,16 +484,8 @@ export class SlashCommandManager {
|
|
|
489
484
|
commandName: string,
|
|
490
485
|
content: string,
|
|
491
486
|
config?: { model?: string; allowedTools?: string[] },
|
|
492
|
-
args?: string,
|
|
493
487
|
): Promise<void> {
|
|
494
488
|
try {
|
|
495
|
-
// Add slash command message immediately to show the command being executed
|
|
496
|
-
const messageId = this.messageManager.addSlashMessage({
|
|
497
|
-
command: commandName,
|
|
498
|
-
args,
|
|
499
|
-
content, // Initial content with bash placeholders
|
|
500
|
-
});
|
|
501
|
-
|
|
502
489
|
// Parse bash commands from the content
|
|
503
490
|
const { commands, processedContent } = parseBashCommands(content);
|
|
504
491
|
|
|
@@ -512,12 +499,9 @@ export class SlashCommandManager {
|
|
|
512
499
|
);
|
|
513
500
|
}
|
|
514
501
|
|
|
515
|
-
//
|
|
516
|
-
this.messageManager.
|
|
517
|
-
command: commandName,
|
|
518
|
-
messageId,
|
|
502
|
+
// Add user message with the processed content
|
|
503
|
+
this.messageManager.addUserMessage({
|
|
519
504
|
content: finalContent,
|
|
520
|
-
stage: "success",
|
|
521
505
|
});
|
|
522
506
|
|
|
523
507
|
// Execute the AI conversation with custom configuration
|
|
@@ -194,6 +194,8 @@ export class SubagentManager {
|
|
|
194
194
|
],
|
|
195
195
|
additionalDirectories:
|
|
196
196
|
parentPermissionManager?.getAdditionalDirectories(),
|
|
197
|
+
systemAdditionalDirectories:
|
|
198
|
+
parentPermissionManager?.getSystemAdditionalDirectories(),
|
|
197
199
|
planFilePath: parentPermissionManager?.getPlanFilePath(),
|
|
198
200
|
});
|
|
199
201
|
subagentContainer.register("PermissionManager", subagentPermissionManager);
|
|
@@ -496,6 +498,15 @@ export class SubagentManager {
|
|
|
496
498
|
|
|
497
499
|
// If this was transitioned to background, update the background task
|
|
498
500
|
if (instance.backgroundTaskId && backgroundTaskManager) {
|
|
501
|
+
// Write final response and completion status to log before closing
|
|
502
|
+
if (instance.logStream && response) {
|
|
503
|
+
instance.logStream.write(
|
|
504
|
+
`[${new Date().toISOString()}] Final response:\n${response}\n`,
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
instance.logStream?.write(
|
|
508
|
+
`[${new Date().toISOString()}] Agent completed successfully\n`,
|
|
509
|
+
);
|
|
499
510
|
instance.logStream?.end();
|
|
500
511
|
const task = backgroundTaskManager.getTask(instance.backgroundTaskId);
|
|
501
512
|
if (task) {
|
|
@@ -516,6 +527,10 @@ export class SubagentManager {
|
|
|
516
527
|
|
|
517
528
|
// If this was transitioned to background, update the background task with error
|
|
518
529
|
if (instance.backgroundTaskId && backgroundTaskManager) {
|
|
530
|
+
// Write error to log before closing
|
|
531
|
+
instance.logStream?.write(
|
|
532
|
+
`[${new Date().toISOString()}] Agent failed: ${error instanceof Error ? error.message : String(error)}\n`,
|
|
533
|
+
);
|
|
519
534
|
instance.logStream?.end();
|
|
520
535
|
const task = backgroundTaskManager.getTask(instance.backgroundTaskId);
|
|
521
536
|
if (task) {
|
|
@@ -13,7 +13,7 @@ import type { GatewayConfig, ModelConfig } from "../types/index.js";
|
|
|
13
13
|
import {
|
|
14
14
|
transformMessagesForClaudeCache,
|
|
15
15
|
addCacheControlToLastTool,
|
|
16
|
-
|
|
16
|
+
supportsPromptCaching,
|
|
17
17
|
extendUsageWithCacheMetrics,
|
|
18
18
|
type ClaudeUsage,
|
|
19
19
|
} from "../utils/cacheControlUtils.js";
|
|
@@ -250,7 +250,7 @@ export async function callAgent(
|
|
|
250
250
|
|
|
251
251
|
processedTools = tools;
|
|
252
252
|
|
|
253
|
-
if (
|
|
253
|
+
if (supportsPromptCaching(currentModel)) {
|
|
254
254
|
openaiMessages = transformMessagesForClaudeCache(
|
|
255
255
|
openaiMessages,
|
|
256
256
|
currentModel,
|
|
@@ -351,7 +351,7 @@ export async function callAgent(
|
|
|
351
351
|
: undefined;
|
|
352
352
|
|
|
353
353
|
// Extend usage with cache metrics for Claude models
|
|
354
|
-
if (totalUsage &&
|
|
354
|
+
if (totalUsage && supportsPromptCaching(currentModel) && response.usage) {
|
|
355
355
|
totalUsage = extendUsageWithCacheMetrics(
|
|
356
356
|
totalUsage,
|
|
357
357
|
response.usage as Partial<ClaudeUsage>,
|
|
@@ -572,7 +572,7 @@ async function processStreamingResponse(
|
|
|
572
572
|
};
|
|
573
573
|
|
|
574
574
|
// Extend usage with cache metrics for Claude models
|
|
575
|
-
if (modelName &&
|
|
575
|
+
if (modelName && supportsPromptCaching(modelName)) {
|
|
576
576
|
chunkUsage = extendUsageWithCacheMetrics(
|
|
577
577
|
chunkUsage,
|
|
578
578
|
chunk.usage as Partial<ClaudeUsage>,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { handleSessionRestoration } from "./session.js";
|
|
2
2
|
import { setGlobalLogger } from "../utils/globalLogger.js";
|
|
3
3
|
import { LspManager } from "../managers/lspManager.js";
|
|
4
|
+
import { USER_MEMORY_FILE } from "../utils/constants.js";
|
|
4
5
|
import type {
|
|
5
6
|
Message,
|
|
6
7
|
Logger,
|
|
@@ -221,6 +222,7 @@ export class InitializationService {
|
|
|
221
222
|
if (permissionManager) {
|
|
222
223
|
const autoMemoryDir = memoryService.getAutoMemoryDirectory(workdir);
|
|
223
224
|
permissionManager.addSystemAdditionalDirectory(autoMemoryDir);
|
|
225
|
+
permissionManager.addSystemAdditionalDirectory(USER_MEMORY_FILE);
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
}
|