agent.libx.js 0.94.19 → 0.94.20
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/README.md +1 -1
- package/dist/cli.js +62 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -590,6 +590,8 @@ interface SkillInfo {
|
|
|
590
590
|
* adds the catalog + a convenience tool. (Executable skills can be `bash`-exec'd: wcli
|
|
591
591
|
* runs JS files from the VFS as commands.)
|
|
592
592
|
*/
|
|
593
|
+
/** Scan `dir`(s) for `<dir>/<id>/SKILL.md` entries (first dir wins on duplicate ids). */
|
|
594
|
+
declare function scanSkills(fs: IFilesystem, dir: string | string[]): Promise<SkillInfo[]>;
|
|
593
595
|
declare function loadSkills(fs: IFilesystem, dir: string | string[], opts?: {
|
|
594
596
|
relevanceHint?: string;
|
|
595
597
|
max?: number;
|
|
@@ -644,6 +646,8 @@ declare function expandCommand(fs: IFilesystem, cmd: CommandInfo, args: string):
|
|
|
644
646
|
* VFS files. The template body is returned (user args appended, and `$ARGUMENTS`
|
|
645
647
|
* substituted if present) so the model can act on it. Mirrors loadSkills.
|
|
646
648
|
*/
|
|
649
|
+
/** Scan `dir`(s) for `<dir>/<name>.md` command templates (first dir wins on duplicate names). */
|
|
650
|
+
declare function scanCommands(fs: IFilesystem, dir: string | string[]): Promise<CommandInfo[]>;
|
|
647
651
|
declare function loadCommands(fs: IFilesystem, dir: string | string[], opts?: {
|
|
648
652
|
relevanceHint?: string;
|
|
649
653
|
max?: number;
|
|
@@ -1261,4 +1265,4 @@ declare class CartesiaTTS {
|
|
|
1261
1265
|
close(): void;
|
|
1262
1266
|
}
|
|
1263
1267
|
|
|
1264
|
-
export { Agent, type AgentDef, AgentOptions, AgentTool, type AskOptions, type Attempt, type AudioSink, type AudioSource, type AuthProvider, BodDbFilesystem, CartesiaTTS, CartesiaTTSOptions, ChatLike, ChatOptions, ChatResponse, type CommandInfo, ConsoleHostBridge, DEFAULT_DENY, DuplexAgent, DuplexAgentOptions, type DuplexTaskStatus, FakeAIClient, Hooks, HostBridge, JailOptions, JailedFilesystem, type LessonOptions, LessonOptionsDefaults, type LoadMemoryOpts, MEMORY_PROMPT, MessageContent, type Mount, MountFilesystem, NodeDiskFilesystem, OverlayFilesystem, type ReflectOptions, RunResult, SCRATCH_DIR, STT_SAMPLE_RATE, type ScheduledJob, type ScheduledJobSnapshot, Scheduler, type SchedulerOptions, Scratch, type ScratchOptions, ScriptedHostBridge, type SkillInfo, SonioxSTT, SonioxSTTOptions, type SttLike, TTS_SAMPLE_RATE, type TaskRecord, type TaskToolOptions, ToolCall, type ToolSpec, type Trigger, type TriggerCron, type TriggerInterval, type TriggerOneOff, type TtsLike, UserQuestion, VOICE_MEMORY_PROMPT, VOICE_SYSTEM_PROMPT, VoiceEngine, VoiceEngineOptions, type VoiceState, type WebFetchOptions, type WebSearchOptions, type WorkerTier, applyEditsTool, askUserQuestionTool, checkpointTool, checkpointTools, compileSynthesizedTool, cronMatches, decodeDdgUrl, diskAgentOptions, expandCommand, expandTemplate, forComponent, fullAgentOptions, globTool, grepTool, htmlToText, idfWeights, lessonCapture, loadAgents, loadCommands, loadInstructions, loadMemory, loadSkills, makeAskTool, makeScheduleTools, makeTaskBatchTool, makeTaskTool, makeWebFetchTool, makeWebSearchTool, mkdirp, multiEditTool, nextCronAfter, parseCron, parseDdgHtml, raceAttempts, reflectOnRun, relevanceScore, repoIndex, repoMapTool, resolveAuth, rollbackTool, sandboxAgentOptions, slugify, tokenize, toolCall, topByRelevance, validateToolCode, webFetchTool, webSearchTool, writeFact, writeTool };
|
|
1268
|
+
export { Agent, type AgentDef, AgentOptions, AgentTool, type AskOptions, type Attempt, type AudioSink, type AudioSource, type AuthProvider, BodDbFilesystem, CartesiaTTS, CartesiaTTSOptions, ChatLike, ChatOptions, ChatResponse, type CommandInfo, ConsoleHostBridge, DEFAULT_DENY, DuplexAgent, DuplexAgentOptions, type DuplexTaskStatus, FakeAIClient, Hooks, HostBridge, JailOptions, JailedFilesystem, type LessonOptions, LessonOptionsDefaults, type LoadMemoryOpts, MEMORY_PROMPT, MessageContent, type Mount, MountFilesystem, NodeDiskFilesystem, OverlayFilesystem, type ReflectOptions, RunResult, SCRATCH_DIR, STT_SAMPLE_RATE, type ScheduledJob, type ScheduledJobSnapshot, Scheduler, type SchedulerOptions, Scratch, type ScratchOptions, ScriptedHostBridge, type SkillInfo, SonioxSTT, SonioxSTTOptions, type SttLike, TTS_SAMPLE_RATE, type TaskRecord, type TaskToolOptions, ToolCall, type ToolSpec, type Trigger, type TriggerCron, type TriggerInterval, type TriggerOneOff, type TtsLike, UserQuestion, VOICE_MEMORY_PROMPT, VOICE_SYSTEM_PROMPT, VoiceEngine, VoiceEngineOptions, type VoiceState, type WebFetchOptions, type WebSearchOptions, type WorkerTier, applyEditsTool, askUserQuestionTool, checkpointTool, checkpointTools, compileSynthesizedTool, cronMatches, decodeDdgUrl, diskAgentOptions, expandCommand, expandTemplate, forComponent, fullAgentOptions, globTool, grepTool, htmlToText, idfWeights, lessonCapture, loadAgents, loadCommands, loadInstructions, loadMemory, loadSkills, makeAskTool, makeScheduleTools, makeTaskBatchTool, makeTaskTool, makeWebFetchTool, makeWebSearchTool, mkdirp, multiEditTool, nextCronAfter, parseCron, parseDdgHtml, raceAttempts, reflectOnRun, relevanceScore, repoIndex, repoMapTool, resolveAuth, rollbackTool, sandboxAgentOptions, scanCommands, scanSkills, slugify, tokenize, toolCall, topByRelevance, validateToolCode, webFetchTool, webSearchTool, writeFact, writeTool };
|
package/dist/index.js
CHANGED
|
@@ -1980,7 +1980,7 @@ function parseFrontmatter(md) {
|
|
|
1980
1980
|
const b = block || md.slice(0, 600);
|
|
1981
1981
|
return { name: grabField(b, "name"), description: grabField(b, "description") };
|
|
1982
1982
|
}
|
|
1983
|
-
async function
|
|
1983
|
+
async function scanSkills(fs, dir) {
|
|
1984
1984
|
const skills = [];
|
|
1985
1985
|
const seen = /* @__PURE__ */ new Set();
|
|
1986
1986
|
for (const d of Array.isArray(dir) ? dir : [dir]) {
|
|
@@ -1995,6 +1995,10 @@ async function loadSkills(fs, dir, opts = {}) {
|
|
|
1995
1995
|
}
|
|
1996
1996
|
}
|
|
1997
1997
|
}
|
|
1998
|
+
return skills;
|
|
1999
|
+
}
|
|
2000
|
+
async function loadSkills(fs, dir, opts = {}) {
|
|
2001
|
+
const skills = await scanSkills(fs, dir);
|
|
1998
2002
|
if (skills.length === 0) return { skills, catalog: "" };
|
|
1999
2003
|
const { kept, rest } = topByRelevance(skills, opts.relevanceHint ?? "", (s) => `${s.name} ${s.description}`, opts.max ?? MAX_CATALOG);
|
|
2000
2004
|
const catalog = "## Skills (load one before acting on a matching task)\n" + kept.map((s) => `- **${s.name}** \u2014 ${s.description} (\`${s.path}\`)`).join("\n") + (rest.length ? `
|
|
@@ -2004,8 +2008,13 @@ async function loadSkills(fs, dir, opts = {}) {
|
|
|
2004
2008
|
description: "Load a skill by name \u2014 returns its full instructions (SKILL.md). Use when a task matches a listed skill.",
|
|
2005
2009
|
parameters: { type: "object", required: ["name"], properties: { name: { type: "string" } } },
|
|
2006
2010
|
async run({ name }, ctx) {
|
|
2007
|
-
|
|
2008
|
-
if (!s)
|
|
2011
|
+
let s = skills.find((x) => x.name === name);
|
|
2012
|
+
if (!s) {
|
|
2013
|
+
const fresh = await scanSkills(ctx.fs, dir);
|
|
2014
|
+
s = fresh.find((x) => x.name === name);
|
|
2015
|
+
if (!s) return `Error: no skill named '${name}'. Available: ${fresh.map((x) => x.name).join(", ")}`;
|
|
2016
|
+
skills.push(s);
|
|
2017
|
+
}
|
|
2009
2018
|
return ctx.fs.readFile(s.path);
|
|
2010
2019
|
}
|
|
2011
2020
|
};
|
|
@@ -2046,7 +2055,7 @@ async function expandCommand(fs, cmd, args) {
|
|
|
2046
2055
|
const { body } = parseFrontmatter2(await fs.readFile(cmd.path));
|
|
2047
2056
|
return embedFiles(expandTemplate(body, args), fs);
|
|
2048
2057
|
}
|
|
2049
|
-
async function
|
|
2058
|
+
async function scanCommands(fs, dir) {
|
|
2050
2059
|
const commands = [];
|
|
2051
2060
|
const seen = /* @__PURE__ */ new Set();
|
|
2052
2061
|
for (const d of Array.isArray(dir) ? dir : [dir]) {
|
|
@@ -2061,6 +2070,10 @@ async function loadCommands(fs, dir, opts = {}) {
|
|
|
2061
2070
|
commands.push({ name, description: fm.description || "", path });
|
|
2062
2071
|
}
|
|
2063
2072
|
}
|
|
2073
|
+
return commands;
|
|
2074
|
+
}
|
|
2075
|
+
async function loadCommands(fs, dir, opts = {}) {
|
|
2076
|
+
const commands = await scanCommands(fs, dir);
|
|
2064
2077
|
if (commands.length === 0) return { commands, catalog: "" };
|
|
2065
2078
|
const { kept, rest } = topByRelevance(commands, opts.relevanceHint ?? "", (c) => `${c.name} ${c.description}`, opts.max ?? MAX_CATALOG2);
|
|
2066
2079
|
const catalog = "## Slash commands (reusable prompt templates)\n" + kept.map((c) => `- **/${c.name}** \u2014 ${c.description} (\`${c.path}\`)`).join("\n") + (rest.length ? `
|
|
@@ -2075,8 +2088,13 @@ async function loadCommands(fs, dir, opts = {}) {
|
|
|
2075
2088
|
},
|
|
2076
2089
|
async run({ name, args }, ctx) {
|
|
2077
2090
|
const slug2 = String(name ?? "").replace(/^\//, "");
|
|
2078
|
-
|
|
2079
|
-
if (!c)
|
|
2091
|
+
let c = commands.find((x) => x.name === slug2);
|
|
2092
|
+
if (!c) {
|
|
2093
|
+
const fresh = await scanCommands(ctx.fs, dir);
|
|
2094
|
+
c = fresh.find((x) => x.name === slug2);
|
|
2095
|
+
if (!c) return `Error: no command named '${slug2}'. Available: ${fresh.map((x) => x.name).join(", ")}`;
|
|
2096
|
+
commands.push(c);
|
|
2097
|
+
}
|
|
2080
2098
|
return expandCommand(ctx.fs, c, String(args ?? ""));
|
|
2081
2099
|
}
|
|
2082
2100
|
};
|
|
@@ -5840,6 +5858,8 @@ export {
|
|
|
5840
5858
|
resolveAuth,
|
|
5841
5859
|
rollbackTool,
|
|
5842
5860
|
sandboxAgentOptions,
|
|
5861
|
+
scanCommands,
|
|
5862
|
+
scanSkills,
|
|
5843
5863
|
slugify,
|
|
5844
5864
|
toWireTools,
|
|
5845
5865
|
todoWriteTool,
|