@qxbyte/muse 0.1.2 → 0.1.3
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/cli.js +1218 -186
- package/dist/cli.js.map +1 -1
- package/dist/index.js +85 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1255,6 +1255,61 @@ var MemoryReadTool = defineTool({
|
|
|
1255
1255
|
}
|
|
1256
1256
|
});
|
|
1257
1257
|
|
|
1258
|
+
// src/tools/builtin/ask-user-question.ts
|
|
1259
|
+
import { z as z10 } from "zod";
|
|
1260
|
+
var AskQuestionOptionSchema = z10.object({
|
|
1261
|
+
label: z10.string().min(1).describe("Option text shown to the user. Concise (1-5 words)."),
|
|
1262
|
+
description: z10.string().optional().describe("Optional one-line explanation of what this option means."),
|
|
1263
|
+
preview: z10.string().optional().describe(
|
|
1264
|
+
"Optional rich preview rendered in a right-side panel when this option is focused. Use for code/diagram/config snippets that help compare options visually. Multi-line text supported."
|
|
1265
|
+
)
|
|
1266
|
+
});
|
|
1267
|
+
var AskQuestionSchema = z10.object({
|
|
1268
|
+
question: z10.string().min(1).describe("Full question text (end with ?)."),
|
|
1269
|
+
header: z10.string().min(1).max(16).describe("Very short label (chip), max 12 chars. E.g. 'Auth method'."),
|
|
1270
|
+
options: z10.array(AskQuestionOptionSchema).min(2).max(4).describe("2-4 options. Mutually exclusive unless multiSelect=true."),
|
|
1271
|
+
multiSelect: z10.boolean().optional().describe("Allow multiple selections. Default false.")
|
|
1272
|
+
});
|
|
1273
|
+
var AskUserQuestionArgs = z10.object({
|
|
1274
|
+
questions: z10.array(AskQuestionSchema).min(1).max(4).describe("1-4 questions to ask the user sequentially.")
|
|
1275
|
+
});
|
|
1276
|
+
var AskUserQuestionTool = defineTool({
|
|
1277
|
+
name: "AskUserQuestion",
|
|
1278
|
+
description: "Ask the user one or more multiple-choice questions when their input is needed to proceed. Each question has 2-4 options. Use multiSelect=true for non-mutually-exclusive choices. Prefer this over plain-text questions when the answer space is bounded. If the user presses Esc, the entire batch is treated as cancelled.",
|
|
1279
|
+
parameters: AskUserQuestionArgs,
|
|
1280
|
+
permission: "read",
|
|
1281
|
+
summarize: (args) => `AskUserQuestion(${args.questions.length} question${args.questions.length === 1 ? "" : "s"})`,
|
|
1282
|
+
async execute(args, ctx) {
|
|
1283
|
+
if (!ctx.askQuestions) {
|
|
1284
|
+
return {
|
|
1285
|
+
content: "AskUserQuestion is unavailable: this agent run has no question handler. (Internal bug; tell the user.)",
|
|
1286
|
+
isError: true
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
const responses = await ctx.askQuestions(args.questions);
|
|
1290
|
+
if (responses.length > 0 && responses[0].cancelled) {
|
|
1291
|
+
return {
|
|
1292
|
+
content: "User cancelled (Esc). No answers were collected.",
|
|
1293
|
+
isError: false
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
const blocks = args.questions.map((q, qi) => {
|
|
1297
|
+
const r = responses[qi];
|
|
1298
|
+
const sel = r?.selections ?? [];
|
|
1299
|
+
const ans = sel.length === 0 ? "(no answer)" : sel.join(", ");
|
|
1300
|
+
const notes = r?.notes?.trim();
|
|
1301
|
+
return notes ? `Q: ${q.question}
|
|
1302
|
+
A: ${ans}
|
|
1303
|
+
Notes: ${notes}` : `Q: ${q.question}
|
|
1304
|
+
A: ${ans}`;
|
|
1305
|
+
});
|
|
1306
|
+
return {
|
|
1307
|
+
content: blocks.join("\n\n"),
|
|
1308
|
+
summary: `Asked ${args.questions.length} question${args.questions.length === 1 ? "" : "s"}`
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
|
|
1258
1313
|
// src/tools/builtin/index.ts
|
|
1259
1314
|
var BUILTIN_TOOLS = [
|
|
1260
1315
|
ReadTool,
|
|
@@ -1266,7 +1321,8 @@ var BUILTIN_TOOLS = [
|
|
|
1266
1321
|
TodoWriteTool,
|
|
1267
1322
|
WebFetchTool,
|
|
1268
1323
|
MemoryReadTool,
|
|
1269
|
-
MemoryWriteTool
|
|
1324
|
+
MemoryWriteTool,
|
|
1325
|
+
AskUserQuestionTool
|
|
1270
1326
|
];
|
|
1271
1327
|
|
|
1272
1328
|
// src/permission/index.ts
|
|
@@ -1592,6 +1648,7 @@ ${todoSection}` : this.ctx.systemPrompt;
|
|
|
1592
1648
|
this.ctx.events?.onTurnEnd?.();
|
|
1593
1649
|
return;
|
|
1594
1650
|
}
|
|
1651
|
+
this.ctx.events?.onAssistantTurn?.();
|
|
1595
1652
|
for (const call of toolCallsToRun) {
|
|
1596
1653
|
await this.runToolCall(call);
|
|
1597
1654
|
}
|
|
@@ -1672,7 +1729,8 @@ ${todoSection}` : this.ctx.systemPrompt;
|
|
|
1672
1729
|
abortSignal: this.ctx.abortSignal,
|
|
1673
1730
|
askPermission: async () => true,
|
|
1674
1731
|
// 已在外层处理
|
|
1675
|
-
todos: this.todos
|
|
1732
|
+
todos: this.todos,
|
|
1733
|
+
askQuestions: this.ctx.events?.onAskQuestions ? (qs) => this.ctx.events.onAskQuestions(qs) : void 0
|
|
1676
1734
|
};
|
|
1677
1735
|
const result = await this.ctx.tools.execute(call.name, call.args, toolCtx);
|
|
1678
1736
|
this.recordToolResult(call.id, call.name, result.content, result.isError ?? false, result.summary, result.diff, result.kind);
|
|
@@ -1752,38 +1810,38 @@ import { homedir as homedir6 } from "os";
|
|
|
1752
1810
|
import { join as join4, resolve as resolve5 } from "path";
|
|
1753
1811
|
|
|
1754
1812
|
// src/config/types.ts
|
|
1755
|
-
import { z as
|
|
1756
|
-
var ProviderConfigSchema =
|
|
1757
|
-
apiKey:
|
|
1758
|
-
baseUrl:
|
|
1759
|
-
extraHeaders:
|
|
1813
|
+
import { z as z11 } from "zod";
|
|
1814
|
+
var ProviderConfigSchema = z11.object({
|
|
1815
|
+
apiKey: z11.string().optional(),
|
|
1816
|
+
baseUrl: z11.string().optional(),
|
|
1817
|
+
extraHeaders: z11.record(z11.string()).optional()
|
|
1760
1818
|
}).passthrough();
|
|
1761
|
-
var LLMConfigSchema =
|
|
1762
|
-
provider:
|
|
1763
|
-
model:
|
|
1764
|
-
temperature:
|
|
1765
|
-
maxTokens:
|
|
1819
|
+
var LLMConfigSchema = z11.object({
|
|
1820
|
+
provider: z11.string().optional().describe("Fallback provider preset (only used when no models.local.json entry matches)."),
|
|
1821
|
+
model: z11.string().optional().describe("Active model id; should match an id in models.local.json."),
|
|
1822
|
+
temperature: z11.number().min(0).max(2).optional(),
|
|
1823
|
+
maxTokens: z11.number().int().positive().optional()
|
|
1766
1824
|
});
|
|
1767
|
-
var PermissionsSchema =
|
|
1768
|
-
allow:
|
|
1769
|
-
ask:
|
|
1770
|
-
deny:
|
|
1771
|
-
defaultMode:
|
|
1825
|
+
var PermissionsSchema = z11.object({
|
|
1826
|
+
allow: z11.array(z11.string()).optional(),
|
|
1827
|
+
ask: z11.array(z11.string()).optional(),
|
|
1828
|
+
deny: z11.array(z11.string()).optional(),
|
|
1829
|
+
defaultMode: z11.enum(["strict", "relaxed", "ask"]).optional()
|
|
1772
1830
|
});
|
|
1773
|
-
var UISchema =
|
|
1774
|
-
theme:
|
|
1775
|
-
lang:
|
|
1776
|
-
showBanner:
|
|
1831
|
+
var UISchema = z11.object({
|
|
1832
|
+
theme: z11.enum(["dark", "light"]).optional(),
|
|
1833
|
+
lang: z11.enum(["en", "zh-CN"]).optional(),
|
|
1834
|
+
showBanner: z11.boolean().optional()
|
|
1777
1835
|
});
|
|
1778
|
-
var SettingsSchema =
|
|
1836
|
+
var SettingsSchema = z11.object({
|
|
1779
1837
|
llm: LLMConfigSchema.optional(),
|
|
1780
|
-
providers:
|
|
1838
|
+
providers: z11.record(ProviderConfigSchema).optional(),
|
|
1781
1839
|
permissions: PermissionsSchema.optional(),
|
|
1782
1840
|
ui: UISchema.optional(),
|
|
1783
|
-
mcpServers:
|
|
1784
|
-
skills:
|
|
1785
|
-
enabled:
|
|
1786
|
-
disabled:
|
|
1841
|
+
mcpServers: z11.record(z11.unknown()).optional(),
|
|
1842
|
+
skills: z11.object({
|
|
1843
|
+
enabled: z11.boolean().optional(),
|
|
1844
|
+
disabled: z11.array(z11.string()).optional()
|
|
1787
1845
|
}).optional()
|
|
1788
1846
|
}).passthrough();
|
|
1789
1847
|
|