agent.libx.js 0.94.19 → 0.94.21

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/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
@@ -1833,7 +1833,8 @@ var askUserQuestionTool = {
1833
1833
  const fallback = args.options?.[0]?.label ?? "";
1834
1834
  return `No interactive user is available \u2014 proceed using your best judgment.${fallback ? ` (Closest default: "${fallback}")` : ""}`;
1835
1835
  }
1836
- return ctx.host.ask(args);
1836
+ const answer = ctx.host.ask(args);
1837
+ return ctx.parkHuman ? ctx.parkHuman(answer) : answer;
1837
1838
  }
1838
1839
  };
1839
1840
  var ScriptedHostBridge = class {
@@ -1980,7 +1981,7 @@ function parseFrontmatter(md) {
1980
1981
  const b = block || md.slice(0, 600);
1981
1982
  return { name: grabField(b, "name"), description: grabField(b, "description") };
1982
1983
  }
1983
- async function loadSkills(fs, dir, opts = {}) {
1984
+ async function scanSkills(fs, dir) {
1984
1985
  const skills = [];
1985
1986
  const seen = /* @__PURE__ */ new Set();
1986
1987
  for (const d of Array.isArray(dir) ? dir : [dir]) {
@@ -1995,6 +1996,10 @@ async function loadSkills(fs, dir, opts = {}) {
1995
1996
  }
1996
1997
  }
1997
1998
  }
1999
+ return skills;
2000
+ }
2001
+ async function loadSkills(fs, dir, opts = {}) {
2002
+ const skills = await scanSkills(fs, dir);
1998
2003
  if (skills.length === 0) return { skills, catalog: "" };
1999
2004
  const { kept, rest } = topByRelevance(skills, opts.relevanceHint ?? "", (s) => `${s.name} ${s.description}`, opts.max ?? MAX_CATALOG);
2000
2005
  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 +2009,13 @@ async function loadSkills(fs, dir, opts = {}) {
2004
2009
  description: "Load a skill by name \u2014 returns its full instructions (SKILL.md). Use when a task matches a listed skill.",
2005
2010
  parameters: { type: "object", required: ["name"], properties: { name: { type: "string" } } },
2006
2011
  async run({ name }, ctx) {
2007
- const s = skills.find((x) => x.name === name);
2008
- if (!s) return `Error: no skill named '${name}'. Available: ${skills.map((x) => x.name).join(", ")}`;
2012
+ let s = skills.find((x) => x.name === name);
2013
+ if (!s) {
2014
+ const fresh = await scanSkills(ctx.fs, dir);
2015
+ s = fresh.find((x) => x.name === name);
2016
+ if (!s) return `Error: no skill named '${name}'. Available: ${fresh.map((x) => x.name).join(", ")}`;
2017
+ skills.push(s);
2018
+ }
2009
2019
  return ctx.fs.readFile(s.path);
2010
2020
  }
2011
2021
  };
@@ -2046,7 +2056,7 @@ async function expandCommand(fs, cmd, args) {
2046
2056
  const { body } = parseFrontmatter2(await fs.readFile(cmd.path));
2047
2057
  return embedFiles(expandTemplate(body, args), fs);
2048
2058
  }
2049
- async function loadCommands(fs, dir, opts = {}) {
2059
+ async function scanCommands(fs, dir) {
2050
2060
  const commands = [];
2051
2061
  const seen = /* @__PURE__ */ new Set();
2052
2062
  for (const d of Array.isArray(dir) ? dir : [dir]) {
@@ -2061,6 +2071,10 @@ async function loadCommands(fs, dir, opts = {}) {
2061
2071
  commands.push({ name, description: fm.description || "", path });
2062
2072
  }
2063
2073
  }
2074
+ return commands;
2075
+ }
2076
+ async function loadCommands(fs, dir, opts = {}) {
2077
+ const commands = await scanCommands(fs, dir);
2064
2078
  if (commands.length === 0) return { commands, catalog: "" };
2065
2079
  const { kept, rest } = topByRelevance(commands, opts.relevanceHint ?? "", (c) => `${c.name} ${c.description}`, opts.max ?? MAX_CATALOG2);
2066
2080
  const catalog = "## Slash commands (reusable prompt templates)\n" + kept.map((c) => `- **/${c.name}** \u2014 ${c.description} (\`${c.path}\`)`).join("\n") + (rest.length ? `
@@ -2075,8 +2089,13 @@ async function loadCommands(fs, dir, opts = {}) {
2075
2089
  },
2076
2090
  async run({ name, args }, ctx) {
2077
2091
  const slug2 = String(name ?? "").replace(/^\//, "");
2078
- const c = commands.find((x) => x.name === slug2);
2079
- if (!c) return `Error: no command named '${slug2}'. Available: ${commands.map((x) => x.name).join(", ")}`;
2092
+ let c = commands.find((x) => x.name === slug2);
2093
+ if (!c) {
2094
+ const fresh = await scanCommands(ctx.fs, dir);
2095
+ c = fresh.find((x) => x.name === slug2);
2096
+ if (!c) return `Error: no command named '${slug2}'. Available: ${fresh.map((x) => x.name).join(", ")}`;
2097
+ commands.push(c);
2098
+ }
2080
2099
  return expandCommand(ctx.fs, c, String(args ?? ""));
2081
2100
  }
2082
2101
  };
@@ -5840,6 +5859,8 @@ export {
5840
5859
  resolveAuth,
5841
5860
  rollbackTool,
5842
5861
  sandboxAgentOptions,
5862
+ scanCommands,
5863
+ scanSkills,
5843
5864
  slugify,
5844
5865
  toWireTools,
5845
5866
  todoWriteTool,