wave-agent-sdk 0.9.6 → 0.9.7
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/managers/messageManager.d.ts +5 -1
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +11 -1
- package/dist/managers/pluginManager.js +1 -1
- package/dist/managers/skillManager.d.ts +17 -3
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +51 -25
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +28 -10
- package/dist/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +4 -0
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +15 -2
- package/dist/types/marketplace.d.ts +1 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/skills.d.ts +1 -0
- package/dist/types/skills.d.ts.map +1 -1
- package/dist/utils/fileSearch.js +1 -1
- package/dist/utils/markdownParser.js +1 -1
- package/dist/utils/messageOperations.d.ts +6 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +26 -2
- package/package.json +1 -1
- package/scripts/install_ripgrep.js +7 -5
- package/scripts/postinstall.js +10 -7
- package/src/managers/messageManager.ts +16 -1
- package/src/managers/pluginManager.ts +1 -1
- package/src/managers/skillManager.ts +65 -34
- package/src/managers/slashCommandManager.ts +33 -10
- package/src/services/MarketplaceService.ts +6 -0
- package/src/services/hook.ts +16 -2
- package/src/types/marketplace.ts +1 -0
- package/src/types/skills.ts +1 -0
- package/src/utils/fileSearch.ts +1 -1
- package/src/utils/markdownParser.ts +1 -1
- package/src/utils/messageOperations.ts +32 -1
|
@@ -96,7 +96,11 @@ export declare class MessageManager {
|
|
|
96
96
|
*/
|
|
97
97
|
triggerSlashCommandsChange(commands: SlashCommand[]): void;
|
|
98
98
|
initializeFromSession(sessionData: SessionData): void;
|
|
99
|
-
addUserMessage(params: UserMessageParams):
|
|
99
|
+
addUserMessage(params: UserMessageParams): string;
|
|
100
|
+
/**
|
|
101
|
+
* Update an existing user message by its ID.
|
|
102
|
+
*/
|
|
103
|
+
updateUserMessage(id: string, params: Partial<UserMessageParams>): void;
|
|
100
104
|
addAssistantMessage(content?: string, toolCalls?: ChatCompletionMessageFunctionToolCall[], usage?: Usage, additionalFields?: Record<string, unknown>): void;
|
|
101
105
|
mergeAssistantAdditionalFields(additionalFields: Record<string, unknown>): void;
|
|
102
106
|
updateToolBlock(params: AgentToolBlockUpdateParams): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageManager.d.ts","sourceRoot":"","sources":["../../src/managers/messageManager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"messageManager.d.ts","sourceRoot":"","sources":["../../src/managers/messageManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,iBAAiB,EACjB,KAAK,0BAA0B,EAEhC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EAIL,WAAW,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAK5E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACjD,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,yBAAyB,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IAE3C,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,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,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAUxD,mBAAmB,CACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,IAAI;IAWP;;;OAGG;IACI,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAW1D;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAKnC;;OAEG;IACI,kBAAkB,IAAI,IAAI;IAIjC;;;;OAIG;IACI,2BAA2B,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI;IA6CvE;;;OAGG;IACI,6BAA6B,CAAC,uBAAuB,EAAE,MAAM,GAAG,IAAI;IA8C3E;;;OAGG;IACI,qBAAqB,IAAI,IAAI;IAKvB,oBAAoB,IAAI,OAAO,CAAC;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;IAoBhC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAyB5B,OAAO,CAAC,sBAAsB;CA4B/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addAssistantMessageToMessages, updateToolBlockInMessage, addErrorBlockToMessage, addUserMessageToMessages, addBangMessage, updateBangInMessage, completeBangInMessage, removeLastUserMessage, generateMessageId, } from "../utils/messageOperations.js";
|
|
1
|
+
import { addAssistantMessageToMessages, updateToolBlockInMessage, addErrorBlockToMessage, addUserMessageToMessages, updateUserMessageInMessages, addBangMessage, updateBangInMessage, completeBangInMessage, removeLastUserMessage, generateMessageId, } from "../utils/messageOperations.js";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { appendMessages, createSession, generateSessionId, SESSION_DIR, } from "../services/session.js";
|
|
4
4
|
import { pathEncoder } from "../utils/pathEncoder.js";
|
|
@@ -191,13 +191,23 @@ export class MessageManager {
|
|
|
191
191
|
}
|
|
192
192
|
// Encapsulated message operation functions
|
|
193
193
|
addUserMessage(params) {
|
|
194
|
+
const id = generateMessageId();
|
|
194
195
|
const newMessages = addUserMessageToMessages({
|
|
195
196
|
messages: this.messages,
|
|
196
197
|
...params,
|
|
198
|
+
id,
|
|
197
199
|
});
|
|
198
200
|
this.setMessages(newMessages);
|
|
199
201
|
this.callbacks.onUserMessageAdded?.(params);
|
|
200
202
|
// Note: Subagent-specific callbacks are now handled by SubagentManager
|
|
203
|
+
return id;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Update an existing user message by its ID.
|
|
207
|
+
*/
|
|
208
|
+
updateUserMessage(id, params) {
|
|
209
|
+
const newMessages = updateUserMessageInMessages(this.messages, id, params);
|
|
210
|
+
this.setMessages(newMessages);
|
|
201
211
|
}
|
|
202
212
|
addAssistantMessage(content, toolCalls, usage, additionalFields) {
|
|
203
213
|
const additionalFieldsRecord = additionalFields
|
|
@@ -113,7 +113,7 @@ export class PluginManager {
|
|
|
113
113
|
this.slashCommandManager.registerPluginCommands(plugin.name, plugin.commands);
|
|
114
114
|
}
|
|
115
115
|
if (this.skillManager && plugin.skills.length > 0) {
|
|
116
|
-
this.skillManager.registerPluginSkills(plugin.skills);
|
|
116
|
+
this.skillManager.registerPluginSkills(plugin.name, plugin.skills);
|
|
117
117
|
}
|
|
118
118
|
if (this.lspManager && plugin.lspConfig) {
|
|
119
119
|
for (const [language, config] of Object.entries(plugin.lspConfig)) {
|
|
@@ -54,9 +54,23 @@ export declare class SkillManager {
|
|
|
54
54
|
allowedTools?: string[];
|
|
55
55
|
}>;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Prepare a skill by name without executing bash commands
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
prepareSkill(args: SkillToolArgs): Promise<{
|
|
60
|
+
content: string;
|
|
61
|
+
skill: Skill;
|
|
62
|
+
} | {
|
|
63
|
+
content: string;
|
|
64
|
+
skill?: undefined;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Prepare skill content with arguments but without bash execution
|
|
68
|
+
*/
|
|
69
|
+
private prepareSkillContent;
|
|
70
|
+
/**
|
|
71
|
+
* Execute bash commands in prepared skill content
|
|
72
|
+
*/
|
|
73
|
+
private executeBashInSkillContent;
|
|
60
74
|
/**
|
|
61
75
|
* Format available skills list for error messages
|
|
62
76
|
*/
|
|
@@ -64,6 +78,6 @@ export declare class SkillManager {
|
|
|
64
78
|
/**
|
|
65
79
|
* Register skills provided by a plugin
|
|
66
80
|
*/
|
|
67
|
-
registerPluginSkills(skills: Skill[]): void;
|
|
81
|
+
registerPluginSkills(pluginName: string, skills: Skill[]): void;
|
|
68
82
|
}
|
|
69
83
|
//# sourceMappingURL=skillManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillManager.d.ts","sourceRoot":"","sources":["../../src/managers/skillManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,KAAK,EAGL,aAAa,EACb,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD;;GAEG;AACH,qBAAa,YAAY;IAUrB,OAAO,CAAC,SAAS;IATnB,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,WAAW,CAAS;gBAGlB,SAAS,EAAE,SAAS,EAC5B,OAAO,GAAE,mBAAwB;IAQnC;;OAEG;IACG,UAAU,IAAI,OAA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AQrC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAQzD;;;OAGG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAgBzD;;OAEG;YACW,cAAc;IAkB5B;;OAEG;YACW,uBAAuB;IA8ErC;;OAEG;YACW,oBAAoB;IAkBlC;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC;QAC/C,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,sBAAsB,CAAC;QACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IA8BF;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAC5C;QACE,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,KAAK,CAAC;KACd,GACD;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,SAAS,CAAA;KAAE,CACzC;IA6BD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;YACW,yBAAyB;IASvC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;OAEG;IACH,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;CA0BhE"}
|
|
@@ -193,10 +193,35 @@ export class SkillManager {
|
|
|
193
193
|
* Execute a skill by name
|
|
194
194
|
*/
|
|
195
195
|
async executeSkill(args) {
|
|
196
|
+
const { skill_name } = args;
|
|
197
|
+
logger?.debug(`Invoking skill: ${skill_name}`);
|
|
198
|
+
const prepared = await this.prepareSkill(args);
|
|
199
|
+
if (!prepared.skill) {
|
|
200
|
+
return { content: prepared.content };
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const finalContent = await this.executeBashInSkillContent(prepared.content);
|
|
204
|
+
return {
|
|
205
|
+
content: finalContent,
|
|
206
|
+
context: {
|
|
207
|
+
skillName: skill_name,
|
|
208
|
+
},
|
|
209
|
+
allowedTools: prepared.skill.allowedTools,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
logger?.error(`Failed to execute skill '${skill_name}':`, error);
|
|
214
|
+
return {
|
|
215
|
+
content: `❌ **Error executing skill**: ${error instanceof Error ? error.message : String(error)}`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Prepare a skill by name without executing bash commands
|
|
221
|
+
*/
|
|
222
|
+
async prepareSkill(args) {
|
|
196
223
|
const { skill_name, args: skillArgs } = args;
|
|
197
|
-
logger?.debug(`Invoking skill: ${skill_name} with args: ${skillArgs}`);
|
|
198
224
|
try {
|
|
199
|
-
// Load the skill
|
|
200
225
|
const skill = await this.loadSkill(skill_name);
|
|
201
226
|
if (!skill) {
|
|
202
227
|
return {
|
|
@@ -209,28 +234,20 @@ export class SkillManager {
|
|
|
209
234
|
content: `❌ **Skill validation failed**:\n\n\`\`\`\n${errorMsg}\n\`\`\``,
|
|
210
235
|
};
|
|
211
236
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
// Return skill content with context
|
|
215
|
-
return {
|
|
216
|
-
content: processedContent,
|
|
217
|
-
context: {
|
|
218
|
-
skillName: skill_name,
|
|
219
|
-
},
|
|
220
|
-
allowedTools: skill.allowedTools,
|
|
221
|
-
};
|
|
237
|
+
const preparedContent = this.prepareSkillContent(skill, skillArgs || "");
|
|
238
|
+
return { content: preparedContent, skill };
|
|
222
239
|
}
|
|
223
240
|
catch (error) {
|
|
224
|
-
logger?.error(`Failed to
|
|
241
|
+
logger?.error(`Failed to prepare skill '${skill_name}':`, error);
|
|
225
242
|
return {
|
|
226
|
-
content: `❌ **Error
|
|
243
|
+
content: `❌ **Error preparing skill**: ${error instanceof Error ? error.message : String(error)}`,
|
|
227
244
|
};
|
|
228
245
|
}
|
|
229
246
|
}
|
|
230
247
|
/**
|
|
231
|
-
*
|
|
248
|
+
* Prepare skill content with arguments but without bash execution
|
|
232
249
|
*/
|
|
233
|
-
|
|
250
|
+
prepareSkillContent(skill, argsString) {
|
|
234
251
|
const header = `🧠 **${skill.name}** (${skill.type} skill)\n\n`;
|
|
235
252
|
const description = `*${skill.description}*\n\n`;
|
|
236
253
|
const skillPath = `📁 Skill location: \`${skill.skillPath}\`\n\n`;
|
|
@@ -241,13 +258,18 @@ export class SkillManager {
|
|
|
241
258
|
mainContent = substituteCommandParameters(mainContent, argsString);
|
|
242
259
|
// 2. Substitute ${WAVE_SKILL_DIR} with the skill's directory path
|
|
243
260
|
mainContent = mainContent.replace(/\$\{WAVE_SKILL_DIR\}/g, skill.skillPath);
|
|
244
|
-
|
|
245
|
-
|
|
261
|
+
return header + description + skillPath + mainContent;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Execute bash commands in prepared skill content
|
|
265
|
+
*/
|
|
266
|
+
async executeBashInSkillContent(content) {
|
|
267
|
+
const { commands } = parseBashCommands(content);
|
|
246
268
|
if (commands.length > 0) {
|
|
247
269
|
const results = await executeBashCommands(commands, this.workdir);
|
|
248
|
-
|
|
270
|
+
return replaceBashCommandsWithOutput(content, results);
|
|
249
271
|
}
|
|
250
|
-
return
|
|
272
|
+
return content;
|
|
251
273
|
}
|
|
252
274
|
/**
|
|
253
275
|
* Format available skills list for error messages
|
|
@@ -264,10 +286,11 @@ export class SkillManager {
|
|
|
264
286
|
/**
|
|
265
287
|
* Register skills provided by a plugin
|
|
266
288
|
*/
|
|
267
|
-
registerPluginSkills(skills) {
|
|
289
|
+
registerPluginSkills(pluginName, skills) {
|
|
268
290
|
for (const skill of skills) {
|
|
291
|
+
const namespacedName = `${pluginName}:${skill.name}`;
|
|
269
292
|
const metadata = {
|
|
270
|
-
name:
|
|
293
|
+
name: namespacedName,
|
|
271
294
|
description: skill.description,
|
|
272
295
|
type: skill.type,
|
|
273
296
|
skillPath: skill.skillPath,
|
|
@@ -277,10 +300,13 @@ export class SkillManager {
|
|
|
277
300
|
model: skill.model,
|
|
278
301
|
disableModelInvocation: skill.disableModelInvocation,
|
|
279
302
|
userInvocable: skill.userInvocable,
|
|
303
|
+
pluginName,
|
|
280
304
|
};
|
|
281
|
-
|
|
282
|
-
|
|
305
|
+
// Update the skill object itself to have the namespaced name
|
|
306
|
+
skill.name = namespacedName;
|
|
307
|
+
this.skillMetadata.set(namespacedName, metadata);
|
|
308
|
+
this.skillContent.set(namespacedName, skill);
|
|
283
309
|
}
|
|
284
|
-
logger?.debug(`Registered ${skills.length} plugin skills. Total skills: ${this.skillMetadata.size}`);
|
|
310
|
+
logger?.debug(`Registered ${skills.length} plugin skills from ${pluginName}. Total skills: ${this.skillMetadata.size}`);
|
|
285
311
|
}
|
|
286
312
|
}
|
|
@@ -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;AAQlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,SAAS;IANnB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,OAAO,CAAS;gBAGd,SAAS,EAAE,SAAS,EAC5B,OAAO,EAAE,0BAA0B;IAK9B,UAAU,IAAI,IAAI;IAKzB,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,KAAK,qBAAqB,GAEhC;IAED,OA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eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAKnD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACI,WAAW,IAAI,YAAY,EAAE;IAIpC;;OAEG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI9D;;OAEG;IACU,cAAc,CACzB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC;IAenB;;;OAGG;IACI,4BAA4B,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;IAsD7C;;OAEG;IACI,mBAAmB,IAAI,IAAI;CAInC"}
|
|
@@ -100,19 +100,33 @@ export class SlashCommandManager {
|
|
|
100
100
|
description: `Skill: ${skill.description}`,
|
|
101
101
|
handler: async (args) => {
|
|
102
102
|
try {
|
|
103
|
-
|
|
103
|
+
// 1. Prepare skill content immediately
|
|
104
|
+
const prepared = await this.skillManager.prepareSkill({
|
|
104
105
|
skill_name: skill.name,
|
|
105
106
|
args,
|
|
106
107
|
});
|
|
107
|
-
// Add user message with skill content
|
|
108
108
|
const originalInput = args
|
|
109
109
|
? `/${skill.name} ${args}`
|
|
110
110
|
: `/${skill.name}`;
|
|
111
|
-
|
|
111
|
+
// 2. Add user message immediately
|
|
112
|
+
const messageId = this.messageManager.addUserMessage({
|
|
112
113
|
content: originalInput,
|
|
114
|
+
customCommandContent: prepared.content,
|
|
115
|
+
});
|
|
116
|
+
if (!prepared.skill) {
|
|
117
|
+
// If skill not found or invalid, we're done (error message already in prepared.content)
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// 3. Execute bash commands asynchronously
|
|
121
|
+
const result = await this.skillManager.executeSkill({
|
|
122
|
+
skill_name: skill.name,
|
|
123
|
+
args,
|
|
124
|
+
});
|
|
125
|
+
// 4. Update the message with final content
|
|
126
|
+
this.messageManager.updateUserMessage(messageId, {
|
|
113
127
|
customCommandContent: result.content,
|
|
114
128
|
});
|
|
115
|
-
// Trigger AI response
|
|
129
|
+
// 5. Trigger AI response
|
|
116
130
|
await this.aiManager.sendAIMessage({
|
|
117
131
|
model: skill.model,
|
|
118
132
|
allowedRules: result.allowedTools,
|
|
@@ -251,6 +265,14 @@ export class SlashCommandManager {
|
|
|
251
265
|
*/
|
|
252
266
|
async executeCustomCommandInMainAgent(commandName, content, config, args) {
|
|
253
267
|
try {
|
|
268
|
+
// Add custom command message immediately to show the command being executed
|
|
269
|
+
const originalInput = args
|
|
270
|
+
? `/${commandName} ${args}`
|
|
271
|
+
: `/${commandName}`;
|
|
272
|
+
const messageId = this.messageManager.addUserMessage({
|
|
273
|
+
content: originalInput,
|
|
274
|
+
customCommandContent: content, // Initial content with bash placeholders
|
|
275
|
+
});
|
|
254
276
|
// Parse bash commands from the content
|
|
255
277
|
const { commands, processedContent } = parseBashCommands(content);
|
|
256
278
|
// Execute bash commands if any
|
|
@@ -259,12 +281,8 @@ export class SlashCommandManager {
|
|
|
259
281
|
const bashResults = await executeBashCommands(commands, this.workdir);
|
|
260
282
|
finalContent = replaceBashCommandsWithOutput(processedContent, bashResults);
|
|
261
283
|
}
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
? `/${commandName} ${args}`
|
|
265
|
-
: `/${commandName}`;
|
|
266
|
-
this.messageManager.addUserMessage({
|
|
267
|
-
content: originalInput,
|
|
284
|
+
// Update the message with final content
|
|
285
|
+
this.messageManager.updateUserMessage(messageId, {
|
|
268
286
|
customCommandContent: finalContent,
|
|
269
287
|
});
|
|
270
288
|
// Execute the AI conversation with custom configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarketplaceService.d.ts","sourceRoot":"","sources":["../../src/services/MarketplaceService.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAGjC;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAOzC;;IAoBF;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IA8BhE;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAgB9D;;OAEG;IACG,qBAAqB,CACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,oBAAoB,CACxB,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,uBAAuB,CAC3B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAwB/B;;OAEG;IACI,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM;IAehE;;OAEG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"MarketplaceService.d.ts","sourceRoot":"","sources":["../../src/services/M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AO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GACpC,OAAO,CAAC,IAAI,CAAC;IAuGhB;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBpC;;OAEG;IACG,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrE;;OAEG;IACG,aAAa,CACjB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IA0H3B;;OAEG;IACG,eAAe,CACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAqChB;;OAEG;IACG,YAAY,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAI1E"}
|
|
@@ -173,6 +173,7 @@ export class MarketplaceService {
|
|
|
173
173
|
? { source: "git", url: urlOrRepo, ref }
|
|
174
174
|
: { source: "github", repo: urlOrRepo, ref },
|
|
175
175
|
autoUpdate: false,
|
|
176
|
+
lastUpdated: new Date().toISOString(),
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
179
|
else {
|
|
@@ -189,6 +190,7 @@ export class MarketplaceService {
|
|
|
189
190
|
name: manifest.name,
|
|
190
191
|
source: { source: "directory", path: absolutePath },
|
|
191
192
|
autoUpdate: false,
|
|
193
|
+
lastUpdated: new Date().toISOString(),
|
|
192
194
|
};
|
|
193
195
|
}
|
|
194
196
|
const registry = await this.getKnownMarketplaces();
|
|
@@ -266,6 +268,7 @@ export class MarketplaceService {
|
|
|
266
268
|
}
|
|
267
269
|
// For directory source, we just re-validate the manifest
|
|
268
270
|
const manifest = await this.loadMarketplaceManifest(this.getMarketplacePath(marketplace));
|
|
271
|
+
marketplace.lastUpdated = new Date().toISOString();
|
|
269
272
|
if (options?.updatePlugins) {
|
|
270
273
|
const installedRegistry = await this.getInstalledPlugins();
|
|
271
274
|
const pluginsToUpdate = installedRegistry.plugins.filter((p) => p.marketplace === marketplace.name);
|
|
@@ -299,6 +302,7 @@ export class MarketplaceService {
|
|
|
299
302
|
if (errors.length > 0) {
|
|
300
303
|
throw new Error(`Some marketplaces failed to update:\n${errors.join("\n")}`);
|
|
301
304
|
}
|
|
305
|
+
await this.saveKnownMarketplaces(registry);
|
|
302
306
|
}
|
|
303
307
|
/**
|
|
304
308
|
* Automatically updates all marketplaces that have auto-update enabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/services/hook.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAElC,MAAM,mBAAmB,CAAC;AAgF3B;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,EAC5D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/services/hook.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAElC,MAAM,mBAAmB,CAAC;AAgF3B;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,EAC5D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CA0I9B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,EAC5D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAchC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAsBtD"}
|
package/dist/services/hook.js
CHANGED
|
@@ -118,6 +118,13 @@ export async function executeCommand(command, context, options) {
|
|
|
118
118
|
WAVE_PROJECT_DIR: context.projectDir,
|
|
119
119
|
},
|
|
120
120
|
});
|
|
121
|
+
// Handle stdin errors (e.g. EPIPE if the process closes stdin early)
|
|
122
|
+
if (childProcess.stdin) {
|
|
123
|
+
childProcess.stdin.on("error", () => {
|
|
124
|
+
// Ignore stdin errors as they just mean the process closed stdin early
|
|
125
|
+
// or doesn't want to read from it.
|
|
126
|
+
});
|
|
127
|
+
}
|
|
121
128
|
// Set up timeout
|
|
122
129
|
const timeoutHandle = setTimeout(() => {
|
|
123
130
|
timedOut = true;
|
|
@@ -134,15 +141,21 @@ export async function executeCommand(command, context, options) {
|
|
|
134
141
|
childProcess.stdout.on("data", (data) => {
|
|
135
142
|
stdout += data.toString();
|
|
136
143
|
});
|
|
144
|
+
childProcess.stdout.on("error", () => {
|
|
145
|
+
// Ignore stdout errors
|
|
146
|
+
});
|
|
137
147
|
}
|
|
138
148
|
// Handle stderr
|
|
139
149
|
if (childProcess.stderr) {
|
|
140
150
|
childProcess.stderr.on("data", (data) => {
|
|
141
151
|
stderr += data.toString();
|
|
142
152
|
});
|
|
153
|
+
childProcess.stderr.on("error", () => {
|
|
154
|
+
// Ignore stderr errors
|
|
155
|
+
});
|
|
143
156
|
}
|
|
144
157
|
// Send JSON input to stdin if we have prepared it
|
|
145
|
-
if (childProcess.stdin && jsonInput) {
|
|
158
|
+
if (childProcess.stdin && childProcess.stdin.writable && jsonInput) {
|
|
146
159
|
try {
|
|
147
160
|
childProcess.stdin.write(jsonInput);
|
|
148
161
|
childProcess.stdin.end();
|
|
@@ -151,7 +164,7 @@ export async function executeCommand(command, context, options) {
|
|
|
151
164
|
// Continue execution even if JSON input fails
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
|
-
else if (childProcess.stdin) {
|
|
167
|
+
else if (childProcess.stdin && childProcess.stdin.writable) {
|
|
155
168
|
childProcess.stdin.end();
|
|
156
169
|
}
|
|
157
170
|
// Handle process completion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace.d.ts","sourceRoot":"","sources":["../../src/types/marketplace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,sBAAsB,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACD;IACE,MAAM,EAAE,KAAK,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,M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B,CAAC;IACxB,OAAO,EAAE,sBAAsB,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACD;IACE,MAAM,EAAE,KAAK,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
|
package/dist/types/skills.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/types/skills.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,Y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,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;CAYjB,CAAC"}
|
package/dist/utils/fileSearch.js
CHANGED
|
@@ -64,7 +64,7 @@ function deriveDirectories(files) {
|
|
|
64
64
|
* Search files and directories using fuzzy matching
|
|
65
65
|
*/
|
|
66
66
|
export const searchFiles = async (query, options) => {
|
|
67
|
-
const { maxResults =
|
|
67
|
+
const { maxResults = 100, workingDirectory = process.cwd() } = options || {};
|
|
68
68
|
try {
|
|
69
69
|
const files = await getAllFiles(workingDirectory);
|
|
70
70
|
if (!query.trim()) {
|
|
@@ -122,7 +122,7 @@ export function replaceBashCommandsWithOutput(content, results) {
|
|
|
122
122
|
processedContent = processedContent.replace(bashCommandRegex, (match) => {
|
|
123
123
|
if (commandIndex < results.length) {
|
|
124
124
|
const result = results[commandIndex++];
|
|
125
|
-
return
|
|
125
|
+
return result.output;
|
|
126
126
|
}
|
|
127
127
|
return match;
|
|
128
128
|
});
|
|
@@ -12,6 +12,7 @@ export interface UserMessageParams {
|
|
|
12
12
|
}
|
|
13
13
|
export interface AddUserMessageParams extends UserMessageParams {
|
|
14
14
|
messages: Message[];
|
|
15
|
+
id?: string;
|
|
15
16
|
}
|
|
16
17
|
export interface UpdateToolBlockParams {
|
|
17
18
|
messages: Message[];
|
|
@@ -66,7 +67,11 @@ export interface CompleteBangParams {
|
|
|
66
67
|
*/
|
|
67
68
|
export declare const convertImageToBase64: (imagePath: string) => string;
|
|
68
69
|
export declare const generateMessageId: () => string;
|
|
69
|
-
export declare const addUserMessageToMessages: ({ messages, content, images, customCommandContent, source, }: AddUserMessageParams) => Message[];
|
|
70
|
+
export declare const addUserMessageToMessages: ({ messages, content, images, customCommandContent, source, id, }: AddUserMessageParams) => Message[];
|
|
71
|
+
/**
|
|
72
|
+
* Update a user message's content or customCommandContent by its ID.
|
|
73
|
+
*/
|
|
74
|
+
export declare const updateUserMessageInMessages: (messages: Message[], id: string, params: Partial<UserMessageParams>) => Message[];
|
|
70
75
|
export declare const addAssistantMessageToMessages: (messages: Message[], content?: string, toolCalls?: ChatCompletionMessageFunctionToolCall[], usage?: Usage, additionalFields?: Record<string, unknown>) => Message[];
|
|
71
76
|
export declare const updateToolBlockInMessage: ({ messages, id, parameters, result, success, error, stage, name, shortResult, startLineNumber, images, compactParams, parametersChunk, isManuallyBackgrounded, }: UpdateToolBlockParams) => Message[];
|
|
72
77
|
export declare const addErrorBlockToMessage: ({ messages, error, }: AddErrorBlockParams) => Message[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,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,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAGD,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,QAAQ,EAAE,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAI5E,MAAM,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C,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;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAUR"}
|
|
@@ -44,7 +44,7 @@ export const convertImageToBase64 = (imagePath) => {
|
|
|
44
44
|
};
|
|
45
45
|
export const generateMessageId = () => `msg-${randomUUID()}`;
|
|
46
46
|
// Add user message
|
|
47
|
-
export const addUserMessageToMessages = ({ messages, content, images, customCommandContent, source, }) => {
|
|
47
|
+
export const addUserMessageToMessages = ({ messages, content, images, customCommandContent, source, id, }) => {
|
|
48
48
|
const blocks = [];
|
|
49
49
|
// Create text block with optional customCommandContent and source
|
|
50
50
|
const textBlock = {
|
|
@@ -63,12 +63,36 @@ export const addUserMessageToMessages = ({ messages, content, images, customComm
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
const userMessage = {
|
|
66
|
-
id: generateMessageId(),
|
|
66
|
+
id: id || generateMessageId(),
|
|
67
67
|
role: "user",
|
|
68
68
|
blocks,
|
|
69
69
|
};
|
|
70
70
|
return [...messages, userMessage];
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Update a user message's content or customCommandContent by its ID.
|
|
74
|
+
*/
|
|
75
|
+
export const updateUserMessageInMessages = (messages, id, params) => {
|
|
76
|
+
return messages.map((msg) => {
|
|
77
|
+
if (msg.id === id && msg.role === "user") {
|
|
78
|
+
const newBlocks = msg.blocks.map((block) => {
|
|
79
|
+
if (block.type === "text") {
|
|
80
|
+
return {
|
|
81
|
+
...block,
|
|
82
|
+
...(params.content !== undefined && { content: params.content }),
|
|
83
|
+
...(params.customCommandContent !== undefined && {
|
|
84
|
+
customCommandContent: params.customCommandContent,
|
|
85
|
+
}),
|
|
86
|
+
...(params.source !== undefined && { source: params.source }),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return block;
|
|
90
|
+
});
|
|
91
|
+
return { ...msg, blocks: newBlocks };
|
|
92
|
+
}
|
|
93
|
+
return msg;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
72
96
|
// Add assistant message (support one-time addition of answer and tool calls)
|
|
73
97
|
export const addAssistantMessageToMessages = (messages, content, toolCalls, usage, additionalFields) => {
|
|
74
98
|
const blocks = [];
|
package/package.json
CHANGED
|
@@ -31,12 +31,14 @@ async function main() {
|
|
|
31
31
|
const binaryPath = path.join(platformDir, binaryName);
|
|
32
32
|
|
|
33
33
|
if (fs.existsSync(binaryPath)) {
|
|
34
|
-
console.log(`Binary for ${platform} already exists at ${binaryPath}`);
|
|
35
34
|
if (!isWindows) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const stats = fs.statSync(binaryPath);
|
|
36
|
+
if ((stats.mode & 0o777) !== 0o755) {
|
|
37
|
+
try {
|
|
38
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.warn(`Failed to set permissions for ${binaryPath}: ${e}`);
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
continue;
|
package/scripts/postinstall.js
CHANGED
|
@@ -19,13 +19,16 @@ function chmodRecursive(dir) {
|
|
|
19
19
|
chmodRecursive(fullPath);
|
|
20
20
|
} else if (file === "rg" || file === "rg.exe") {
|
|
21
21
|
if (process.platform !== "win32") {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const currentMode = stats.mode & 0o777;
|
|
23
|
+
if (currentMode !== 0o755) {
|
|
24
|
+
try {
|
|
25
|
+
fs.chmodSync(fullPath, 0o755);
|
|
26
|
+
console.log(`Set execution permission for ${fullPath}`);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.warn(
|
|
29
|
+
`Failed to set execution permission for ${fullPath}: ${e.message}`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
updateToolBlockInMessage,
|
|
4
4
|
addErrorBlockToMessage,
|
|
5
5
|
addUserMessageToMessages,
|
|
6
|
+
updateUserMessageInMessages,
|
|
6
7
|
addBangMessage,
|
|
7
8
|
updateBangInMessage,
|
|
8
9
|
completeBangInMessage,
|
|
@@ -318,15 +319,29 @@ export class MessageManager {
|
|
|
318
319
|
}
|
|
319
320
|
|
|
320
321
|
// Encapsulated message operation functions
|
|
321
|
-
public addUserMessage(params: UserMessageParams):
|
|
322
|
+
public addUserMessage(params: UserMessageParams): string {
|
|
323
|
+
const id = generateMessageId();
|
|
322
324
|
const newMessages = addUserMessageToMessages({
|
|
323
325
|
messages: this.messages,
|
|
324
326
|
...params,
|
|
327
|
+
id,
|
|
325
328
|
});
|
|
326
329
|
this.setMessages(newMessages);
|
|
327
330
|
this.callbacks.onUserMessageAdded?.(params);
|
|
328
331
|
|
|
329
332
|
// Note: Subagent-specific callbacks are now handled by SubagentManager
|
|
333
|
+
return id;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Update an existing user message by its ID.
|
|
338
|
+
*/
|
|
339
|
+
public updateUserMessage(
|
|
340
|
+
id: string,
|
|
341
|
+
params: Partial<UserMessageParams>,
|
|
342
|
+
): void {
|
|
343
|
+
const newMessages = updateUserMessageInMessages(this.messages, id, params);
|
|
344
|
+
this.setMessages(newMessages);
|
|
330
345
|
}
|
|
331
346
|
|
|
332
347
|
public addAssistantMessage(
|
|
@@ -164,7 +164,7 @@ export class PluginManager {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
if (this.skillManager && plugin.skills.length > 0) {
|
|
167
|
-
this.skillManager.registerPluginSkills(plugin.skills);
|
|
167
|
+
this.skillManager.registerPluginSkills(plugin.name, plugin.skills);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
if (this.lspManager && plugin.lspConfig) {
|
|
@@ -262,12 +262,48 @@ export class SkillManager {
|
|
|
262
262
|
context?: SkillInvocationContext;
|
|
263
263
|
allowedTools?: string[];
|
|
264
264
|
}> {
|
|
265
|
-
const { skill_name
|
|
265
|
+
const { skill_name } = args;
|
|
266
|
+
|
|
267
|
+
logger?.debug(`Invoking skill: ${skill_name}`);
|
|
268
|
+
|
|
269
|
+
const prepared = await this.prepareSkill(args);
|
|
270
|
+
if (!prepared.skill) {
|
|
271
|
+
return { content: prepared.content };
|
|
272
|
+
}
|
|
266
273
|
|
|
267
|
-
|
|
274
|
+
try {
|
|
275
|
+
const finalContent = await this.executeBashInSkillContent(
|
|
276
|
+
prepared.content,
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
content: finalContent,
|
|
281
|
+
context: {
|
|
282
|
+
skillName: skill_name,
|
|
283
|
+
},
|
|
284
|
+
allowedTools: prepared.skill.allowedTools,
|
|
285
|
+
};
|
|
286
|
+
} catch (error) {
|
|
287
|
+
logger?.error(`Failed to execute skill '${skill_name}':`, error);
|
|
288
|
+
return {
|
|
289
|
+
content: `❌ **Error executing skill**: ${error instanceof Error ? error.message : String(error)}`,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Prepare a skill by name without executing bash commands
|
|
296
|
+
*/
|
|
297
|
+
async prepareSkill(args: SkillToolArgs): Promise<
|
|
298
|
+
| {
|
|
299
|
+
content: string;
|
|
300
|
+
skill: Skill;
|
|
301
|
+
}
|
|
302
|
+
| { content: string; skill?: undefined }
|
|
303
|
+
> {
|
|
304
|
+
const { skill_name, args: skillArgs } = args;
|
|
268
305
|
|
|
269
306
|
try {
|
|
270
|
-
// Load the skill
|
|
271
307
|
const skill = await this.loadSkill(skill_name);
|
|
272
308
|
|
|
273
309
|
if (!skill) {
|
|
@@ -283,35 +319,20 @@ export class SkillManager {
|
|
|
283
319
|
};
|
|
284
320
|
}
|
|
285
321
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
skill,
|
|
289
|
-
skillArgs || "",
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
// Return skill content with context
|
|
293
|
-
return {
|
|
294
|
-
content: processedContent,
|
|
295
|
-
context: {
|
|
296
|
-
skillName: skill_name,
|
|
297
|
-
},
|
|
298
|
-
allowedTools: skill.allowedTools,
|
|
299
|
-
};
|
|
322
|
+
const preparedContent = this.prepareSkillContent(skill, skillArgs || "");
|
|
323
|
+
return { content: preparedContent, skill };
|
|
300
324
|
} catch (error) {
|
|
301
|
-
logger?.error(`Failed to
|
|
325
|
+
logger?.error(`Failed to prepare skill '${skill_name}':`, error);
|
|
302
326
|
return {
|
|
303
|
-
content: `❌ **Error
|
|
327
|
+
content: `❌ **Error preparing skill**: ${error instanceof Error ? error.message : String(error)}`,
|
|
304
328
|
};
|
|
305
329
|
}
|
|
306
330
|
}
|
|
307
331
|
|
|
308
332
|
/**
|
|
309
|
-
*
|
|
333
|
+
* Prepare skill content with arguments but without bash execution
|
|
310
334
|
*/
|
|
311
|
-
private
|
|
312
|
-
skill: Skill,
|
|
313
|
-
argsString: string,
|
|
314
|
-
): Promise<string> {
|
|
335
|
+
private prepareSkillContent(skill: Skill, argsString: string): string {
|
|
315
336
|
const header = `🧠 **${skill.name}** (${skill.type} skill)\n\n`;
|
|
316
337
|
const description = `*${skill.description}*\n\n`;
|
|
317
338
|
const skillPath = `📁 Skill location: \`${skill.skillPath}\`\n\n`;
|
|
@@ -326,14 +347,19 @@ export class SkillManager {
|
|
|
326
347
|
// 2. Substitute ${WAVE_SKILL_DIR} with the skill's directory path
|
|
327
348
|
mainContent = mainContent.replace(/\$\{WAVE_SKILL_DIR\}/g, skill.skillPath);
|
|
328
349
|
|
|
329
|
-
|
|
330
|
-
|
|
350
|
+
return header + description + skillPath + mainContent;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Execute bash commands in prepared skill content
|
|
355
|
+
*/
|
|
356
|
+
private async executeBashInSkillContent(content: string): Promise<string> {
|
|
357
|
+
const { commands } = parseBashCommands(content);
|
|
331
358
|
if (commands.length > 0) {
|
|
332
359
|
const results = await executeBashCommands(commands, this.workdir);
|
|
333
|
-
|
|
360
|
+
return replaceBashCommandsWithOutput(content, results);
|
|
334
361
|
}
|
|
335
|
-
|
|
336
|
-
return header + description + skillPath + mainContent;
|
|
362
|
+
return content;
|
|
337
363
|
}
|
|
338
364
|
|
|
339
365
|
/**
|
|
@@ -356,10 +382,11 @@ export class SkillManager {
|
|
|
356
382
|
/**
|
|
357
383
|
* Register skills provided by a plugin
|
|
358
384
|
*/
|
|
359
|
-
registerPluginSkills(skills: Skill[]): void {
|
|
385
|
+
registerPluginSkills(pluginName: string, skills: Skill[]): void {
|
|
360
386
|
for (const skill of skills) {
|
|
387
|
+
const namespacedName = `${pluginName}:${skill.name}`;
|
|
361
388
|
const metadata: SkillMetadata = {
|
|
362
|
-
name:
|
|
389
|
+
name: namespacedName,
|
|
363
390
|
description: skill.description,
|
|
364
391
|
type: skill.type,
|
|
365
392
|
skillPath: skill.skillPath,
|
|
@@ -369,12 +396,16 @@ export class SkillManager {
|
|
|
369
396
|
model: skill.model,
|
|
370
397
|
disableModelInvocation: skill.disableModelInvocation,
|
|
371
398
|
userInvocable: skill.userInvocable,
|
|
399
|
+
pluginName,
|
|
372
400
|
};
|
|
373
|
-
|
|
374
|
-
|
|
401
|
+
// Update the skill object itself to have the namespaced name
|
|
402
|
+
skill.name = namespacedName;
|
|
403
|
+
|
|
404
|
+
this.skillMetadata.set(namespacedName, metadata);
|
|
405
|
+
this.skillContent.set(namespacedName, skill);
|
|
375
406
|
}
|
|
376
407
|
logger?.debug(
|
|
377
|
-
`Registered ${skills.length} plugin skills. Total skills: ${this.skillMetadata.size}`,
|
|
408
|
+
`Registered ${skills.length} plugin skills from ${pluginName}. Total skills: ${this.skillMetadata.size}`,
|
|
378
409
|
);
|
|
379
410
|
}
|
|
380
411
|
}
|
|
@@ -154,21 +154,39 @@ export class SlashCommandManager {
|
|
|
154
154
|
description: `Skill: ${skill.description}`,
|
|
155
155
|
handler: async (args?: string) => {
|
|
156
156
|
try {
|
|
157
|
-
|
|
157
|
+
// 1. Prepare skill content immediately
|
|
158
|
+
const prepared = await this.skillManager.prepareSkill({
|
|
158
159
|
skill_name: skill.name,
|
|
159
160
|
args,
|
|
160
161
|
});
|
|
161
162
|
|
|
162
|
-
// Add user message with skill content
|
|
163
163
|
const originalInput = args
|
|
164
164
|
? `/${skill.name} ${args}`
|
|
165
165
|
: `/${skill.name}`;
|
|
166
|
-
|
|
166
|
+
|
|
167
|
+
// 2. Add user message immediately
|
|
168
|
+
const messageId = this.messageManager.addUserMessage({
|
|
167
169
|
content: originalInput,
|
|
170
|
+
customCommandContent: prepared.content,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (!prepared.skill) {
|
|
174
|
+
// If skill not found or invalid, we're done (error message already in prepared.content)
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 3. Execute bash commands asynchronously
|
|
179
|
+
const result = await this.skillManager.executeSkill({
|
|
180
|
+
skill_name: skill.name,
|
|
181
|
+
args,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// 4. Update the message with final content
|
|
185
|
+
this.messageManager.updateUserMessage(messageId, {
|
|
168
186
|
customCommandContent: result.content,
|
|
169
187
|
});
|
|
170
188
|
|
|
171
|
-
// Trigger AI response
|
|
189
|
+
// 5. Trigger AI response
|
|
172
190
|
await this.aiManager.sendAIMessage({
|
|
173
191
|
model: skill.model,
|
|
174
192
|
allowedRules: result.allowedTools,
|
|
@@ -358,6 +376,15 @@ export class SlashCommandManager {
|
|
|
358
376
|
args?: string,
|
|
359
377
|
): Promise<void> {
|
|
360
378
|
try {
|
|
379
|
+
// Add custom command message immediately to show the command being executed
|
|
380
|
+
const originalInput = args
|
|
381
|
+
? `/${commandName} ${args}`
|
|
382
|
+
: `/${commandName}`;
|
|
383
|
+
const messageId = this.messageManager.addUserMessage({
|
|
384
|
+
content: originalInput,
|
|
385
|
+
customCommandContent: content, // Initial content with bash placeholders
|
|
386
|
+
});
|
|
387
|
+
|
|
361
388
|
// Parse bash commands from the content
|
|
362
389
|
const { commands, processedContent } = parseBashCommands(content);
|
|
363
390
|
|
|
@@ -371,12 +398,8 @@ export class SlashCommandManager {
|
|
|
371
398
|
);
|
|
372
399
|
}
|
|
373
400
|
|
|
374
|
-
//
|
|
375
|
-
|
|
376
|
-
? `/${commandName} ${args}`
|
|
377
|
-
: `/${commandName}`;
|
|
378
|
-
this.messageManager.addUserMessage({
|
|
379
|
-
content: originalInput,
|
|
401
|
+
// Update the message with final content
|
|
402
|
+
this.messageManager.updateUserMessage(messageId, {
|
|
380
403
|
customCommandContent: finalContent,
|
|
381
404
|
});
|
|
382
405
|
|
|
@@ -243,6 +243,7 @@ export class MarketplaceService {
|
|
|
243
243
|
? { source: "git", url: urlOrRepo, ref }
|
|
244
244
|
: { source: "github", repo: urlOrRepo, ref },
|
|
245
245
|
autoUpdate: false,
|
|
246
|
+
lastUpdated: new Date().toISOString(),
|
|
246
247
|
};
|
|
247
248
|
} else {
|
|
248
249
|
// Local directory format
|
|
@@ -260,6 +261,7 @@ export class MarketplaceService {
|
|
|
260
261
|
name: manifest.name,
|
|
261
262
|
source: { source: "directory", path: absolutePath },
|
|
262
263
|
autoUpdate: false,
|
|
264
|
+
lastUpdated: new Date().toISOString(),
|
|
263
265
|
};
|
|
264
266
|
}
|
|
265
267
|
|
|
@@ -363,6 +365,8 @@ export class MarketplaceService {
|
|
|
363
365
|
this.getMarketplacePath(marketplace),
|
|
364
366
|
);
|
|
365
367
|
|
|
368
|
+
marketplace.lastUpdated = new Date().toISOString();
|
|
369
|
+
|
|
366
370
|
if (options?.updatePlugins) {
|
|
367
371
|
const installedRegistry = await this.getInstalledPlugins();
|
|
368
372
|
const pluginsToUpdate = installedRegistry.plugins.filter(
|
|
@@ -414,6 +418,8 @@ export class MarketplaceService {
|
|
|
414
418
|
`Some marketplaces failed to update:\n${errors.join("\n")}`,
|
|
415
419
|
);
|
|
416
420
|
}
|
|
421
|
+
|
|
422
|
+
await this.saveKnownMarketplaces(registry);
|
|
417
423
|
}
|
|
418
424
|
|
|
419
425
|
/**
|
package/src/services/hook.ts
CHANGED
|
@@ -155,6 +155,14 @@ export async function executeCommand(
|
|
|
155
155
|
},
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
// Handle stdin errors (e.g. EPIPE if the process closes stdin early)
|
|
159
|
+
if (childProcess.stdin) {
|
|
160
|
+
childProcess.stdin.on("error", () => {
|
|
161
|
+
// Ignore stdin errors as they just mean the process closed stdin early
|
|
162
|
+
// or doesn't want to read from it.
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
158
166
|
// Set up timeout
|
|
159
167
|
const timeoutHandle = setTimeout(() => {
|
|
160
168
|
timedOut = true;
|
|
@@ -173,6 +181,9 @@ export async function executeCommand(
|
|
|
173
181
|
childProcess.stdout.on("data", (data: Buffer) => {
|
|
174
182
|
stdout += data.toString();
|
|
175
183
|
});
|
|
184
|
+
childProcess.stdout.on("error", () => {
|
|
185
|
+
// Ignore stdout errors
|
|
186
|
+
});
|
|
176
187
|
}
|
|
177
188
|
|
|
178
189
|
// Handle stderr
|
|
@@ -180,17 +191,20 @@ export async function executeCommand(
|
|
|
180
191
|
childProcess.stderr.on("data", (data: Buffer) => {
|
|
181
192
|
stderr += data.toString();
|
|
182
193
|
});
|
|
194
|
+
childProcess.stderr.on("error", () => {
|
|
195
|
+
// Ignore stderr errors
|
|
196
|
+
});
|
|
183
197
|
}
|
|
184
198
|
|
|
185
199
|
// Send JSON input to stdin if we have prepared it
|
|
186
|
-
if (childProcess.stdin && jsonInput) {
|
|
200
|
+
if (childProcess.stdin && childProcess.stdin.writable && jsonInput) {
|
|
187
201
|
try {
|
|
188
202
|
childProcess.stdin.write(jsonInput);
|
|
189
203
|
childProcess.stdin.end();
|
|
190
204
|
} catch {
|
|
191
205
|
// Continue execution even if JSON input fails
|
|
192
206
|
}
|
|
193
|
-
} else if (childProcess.stdin) {
|
|
207
|
+
} else if (childProcess.stdin && childProcess.stdin.writable) {
|
|
194
208
|
childProcess.stdin.end();
|
|
195
209
|
}
|
|
196
210
|
|
package/src/types/marketplace.ts
CHANGED
package/src/types/skills.ts
CHANGED
package/src/utils/fileSearch.ts
CHANGED
|
@@ -81,7 +81,7 @@ export const searchFiles = async (
|
|
|
81
81
|
workingDirectory?: string;
|
|
82
82
|
},
|
|
83
83
|
): Promise<FileItem[]> => {
|
|
84
|
-
const { maxResults =
|
|
84
|
+
const { maxResults = 100, workingDirectory = process.cwd() } = options || {};
|
|
85
85
|
|
|
86
86
|
try {
|
|
87
87
|
const files = await getAllFiles(workingDirectory);
|
|
@@ -173,7 +173,7 @@ export function replaceBashCommandsWithOutput(
|
|
|
173
173
|
processedContent = processedContent.replace(bashCommandRegex, (match) => {
|
|
174
174
|
if (commandIndex < results.length) {
|
|
175
175
|
const result = results[commandIndex++];
|
|
176
|
-
return
|
|
176
|
+
return result.output;
|
|
177
177
|
}
|
|
178
178
|
return match;
|
|
179
179
|
});
|
|
@@ -17,6 +17,7 @@ export interface UserMessageParams {
|
|
|
17
17
|
// Parameter interfaces for message operations
|
|
18
18
|
export interface AddUserMessageParams extends UserMessageParams {
|
|
19
19
|
messages: Message[];
|
|
20
|
+
id?: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export interface UpdateToolBlockParams {
|
|
@@ -123,6 +124,7 @@ export const addUserMessageToMessages = ({
|
|
|
123
124
|
images,
|
|
124
125
|
customCommandContent,
|
|
125
126
|
source,
|
|
127
|
+
id,
|
|
126
128
|
}: AddUserMessageParams): Message[] => {
|
|
127
129
|
const blocks: Message["blocks"] = [];
|
|
128
130
|
|
|
@@ -145,13 +147,42 @@ export const addUserMessageToMessages = ({
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
const userMessage: Message = {
|
|
148
|
-
id: generateMessageId(),
|
|
150
|
+
id: id || generateMessageId(),
|
|
149
151
|
role: "user",
|
|
150
152
|
blocks,
|
|
151
153
|
};
|
|
152
154
|
return [...messages, userMessage];
|
|
153
155
|
};
|
|
154
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Update a user message's content or customCommandContent by its ID.
|
|
159
|
+
*/
|
|
160
|
+
export const updateUserMessageInMessages = (
|
|
161
|
+
messages: Message[],
|
|
162
|
+
id: string,
|
|
163
|
+
params: Partial<UserMessageParams>,
|
|
164
|
+
): Message[] => {
|
|
165
|
+
return messages.map((msg) => {
|
|
166
|
+
if (msg.id === id && msg.role === "user") {
|
|
167
|
+
const newBlocks = msg.blocks.map((block) => {
|
|
168
|
+
if (block.type === "text") {
|
|
169
|
+
return {
|
|
170
|
+
...block,
|
|
171
|
+
...(params.content !== undefined && { content: params.content }),
|
|
172
|
+
...(params.customCommandContent !== undefined && {
|
|
173
|
+
customCommandContent: params.customCommandContent,
|
|
174
|
+
}),
|
|
175
|
+
...(params.source !== undefined && { source: params.source }),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return block;
|
|
179
|
+
});
|
|
180
|
+
return { ...msg, blocks: newBlocks };
|
|
181
|
+
}
|
|
182
|
+
return msg;
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
155
186
|
// Add assistant message (support one-time addition of answer and tool calls)
|
|
156
187
|
export const addAssistantMessageToMessages = (
|
|
157
188
|
messages: Message[],
|