@livx.cc/agentx 0.98.2 → 0.99.2

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
@@ -467,14 +467,27 @@ interface WebFetchOptions {
467
467
  declare function makeWebFetchTool(options?: WebFetchOptions): AgentTool;
468
468
  interface WebSearchOptions {
469
469
  fetch?: typeof globalThis.fetch;
470
- /** Provider: 'auto' (default) uses Tavily if an API key is present, else keyless DuckDuckGo. */
471
- provider?: 'auto' | 'tavily' | 'duckduckgo';
470
+ /** Provider: 'auto' (default) prefers Firecrawl, then Tavily (by key presence), else keyless DuckDuckGo.
471
+ * 'anthropic' delegates to a cheap model with Anthropic's native server-side web_search. */
472
+ provider?: 'auto' | 'tavily' | 'duckduckgo' | 'anthropic' | 'firecrawl';
472
473
  /** API key for Tavily (default: process.env.TAVILY_API_KEY). */
473
474
  apiKey?: string;
474
475
  /** Tavily endpoint override. */
475
476
  endpoint?: string;
477
+ /** API key for Firecrawl (default: process.env.FIRECRAWL_API_KEY). */
478
+ firecrawlApiKey?: string;
479
+ /** Firecrawl search endpoint override. */
480
+ firecrawlEndpoint?: string;
476
481
  maxResults?: number;
477
482
  timeoutMs?: number;
483
+ /** Tool name (default 'WebSearch'). Set to register a provider-pinned variant, e.g. 'WebSearchAnthropic'. */
484
+ name?: string;
485
+ /** Tool description override (default: the generic ranked-results blurb). */
486
+ description?: string;
487
+ /** Anthropic key for provider 'anthropic' (default: process.env.ANTHROPIC_API_KEY). */
488
+ anthropicApiKey?: string;
489
+ /** Model for provider 'anthropic' (default 'claude-haiku-4-5'). */
490
+ model?: string;
478
491
  }
479
492
  interface SearchHit {
480
493
  title: string;
@@ -486,13 +499,24 @@ declare function decodeDdgUrl(href: string): string;
486
499
  /** Parse DuckDuckGo's HTML results page into hits (title/url/snippet) — dependency-free, zips anchors to snippets in order. */
487
500
  declare function parseDdgHtml(html: string, max: number): SearchHit[];
488
501
  /**
489
- * Build a WebSearch tool. Keyless by default (DuckDuckGo HTML) so it works in any deployment with
490
- * no setup; auto-upgrades to Tavily (better, agent-oriented results) when TAVILY_API_KEY is present.
502
+ * Build a WebSearch tool. Keyless by default (DuckDuckGo HTML) so it works in any deployment with no
503
+ * setup; on provider 'auto' it upgrades to an agent-oriented API by key presence — Firecrawl
504
+ * (FIRECRAWL_API_KEY) preferred, then Tavily (TAVILY_API_KEY). Provider 'anthropic' is a separate path
505
+ * (native search via a cheap model) exposed as the WebSearchAnthropic tool.
491
506
  */
492
507
  declare function makeWebSearchTool(options?: WebSearchOptions): AgentTool;
493
508
  /** Default instances (registered in the tool registry; opt-in by name). */
494
509
  declare const webFetchTool: AgentTool;
495
510
  declare const webSearchTool: AgentTool;
511
+ /** Anthropic-native search as a provider-pinned WebSearch variant. The credential is API-key billing
512
+ * (x-api-key); pass `anthropicApiKey` to inject a resolved key, else it falls back to ANTHROPIC_API_KEY. */
513
+ declare function makeWebSearchAnthropicTool(opts?: {
514
+ anthropicApiKey?: string;
515
+ model?: string;
516
+ }): AgentTool;
517
+ /** Env-keyed singleton: registered in the tool registry so 'WebSearchAnthropic' resolves by name. The
518
+ * CLI default-on path builds its own instance with a config-resolved key (see cli/core.ts). */
519
+ declare const webSearchAnthropicTool: AgentTool;
496
520
 
497
521
  /**
498
522
  * Scratch — keep large tool/subagent outputs OUT of the main context, but queryable AS FILES.
@@ -1499,4 +1523,4 @@ declare function exitWorktree(): {
1499
1523
  reason?: string;
1500
1524
  } | null;
1501
1525
 
1502
- 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 SiblingResolver, 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, type WorktreeInfo, type WorktreeSession, applyEditsTool, askUserQuestionTool, checkpointTool, checkpointTools, cleanupWorktree, compileSynthesizedTool, cronMatches, decodeDdgUrl, diskAgentOptions, enterWorktree, exitWorktree, expandCommand, expandEntry, expandTemplate, findGitRoot, forComponent, fullAgentOptions, getOrCreateWorktree, getWorktreeSession, 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, validateWorktreeSlug, webFetchTool, webSearchTool, worktreeBranchName, writeFact, writeTool };
1526
+ 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 SiblingResolver, 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, type WorktreeInfo, type WorktreeSession, applyEditsTool, askUserQuestionTool, checkpointTool, checkpointTools, cleanupWorktree, compileSynthesizedTool, cronMatches, decodeDdgUrl, diskAgentOptions, enterWorktree, exitWorktree, expandCommand, expandEntry, expandTemplate, findGitRoot, forComponent, fullAgentOptions, getOrCreateWorktree, getWorktreeSession, globTool, grepTool, htmlToText, idfWeights, lessonCapture, loadAgents, loadCommands, loadInstructions, loadMemory, loadSkills, makeAskTool, makeScheduleTools, makeTaskBatchTool, makeTaskTool, makeWebFetchTool, makeWebSearchAnthropicTool, makeWebSearchTool, mkdirp, multiEditTool, nextCronAfter, parseCron, parseDdgHtml, raceAttempts, reflectOnRun, relevanceScore, repoIndex, repoMapTool, resolveAuth, rollbackTool, sandboxAgentOptions, scanCommands, scanSkills, slugify, tokenize, toolCall, topByRelevance, validateToolCode, validateWorktreeSlug, webFetchTool, webSearchAnthropicTool, webSearchTool, worktreeBranchName, writeFact, writeTool };
package/dist/index.js CHANGED
@@ -644,13 +644,48 @@ function formatHits(hits) {
644
644
  ${r.url}
645
645
  ${r.snippet.replace(/\s+/g, " ").slice(0, 240)}`).join("\n\n");
646
646
  }
647
+ async function firecrawlSearch(q, opts) {
648
+ const res = await opts.fetch(opts.endpoint, {
649
+ method: "POST",
650
+ signal: opts.signal,
651
+ headers: { authorization: `Bearer ${opts.key}`, "content-type": "application/json" },
652
+ body: JSON.stringify({ query: q, limit: opts.maxResults })
653
+ });
654
+ if (!res.ok) return `Error: Firecrawl search returned ${res.status} ${res.statusText}`;
655
+ const data = await res.json();
656
+ const results = Array.isArray(data?.data) ? data.data.slice(0, opts.maxResults) : [];
657
+ return formatHits(results.map((r) => ({ title: r.title ?? "(untitled)", url: r.url ?? "", snippet: String(r.description ?? r.markdown ?? "") })));
658
+ }
659
+ async function anthropicSearch(q, opts) {
660
+ const res = await opts.fetch("https://api.anthropic.com/v1/messages", {
661
+ method: "POST",
662
+ signal: opts.signal,
663
+ headers: { "x-api-key": opts.key, "anthropic-version": "2023-06-01", "content-type": "application/json" },
664
+ body: JSON.stringify({
665
+ model: opts.model,
666
+ max_tokens: 1024,
667
+ // Basic variant: Haiku-tier doesn't support the _20260209 dynamic-filtering variant (Opus 4.6+/Sonnet 4.6 only).
668
+ tools: [{ type: "web_search_20250305", name: "web_search", max_uses: 5 }],
669
+ messages: [{ role: "user", content: `Search the web for: ${q}
670
+
671
+ Return only the relevant findings as concise bullet points, each with its source URL in parentheses. Do not add a preamble, conclusion, opinion, or commentary. If sources conflict, list each claim with its source rather than resolving it.` }]
672
+ })
673
+ });
674
+ if (!res.ok) return `Error: Anthropic search returned ${res.status} ${res.statusText}`;
675
+ const data = await res.json();
676
+ if (data?.stop_reason === "refusal") return "Error: Anthropic search refused the query";
677
+ let text = "";
678
+ for (const block of data?.content ?? []) if (block?.type === "text") text += block.text;
679
+ return text.trim() || "(no results)";
680
+ }
647
681
  function makeWebSearchTool(options = {}) {
648
682
  const tavilyEndpoint = options.endpoint ?? "https://api.tavily.com/search";
683
+ const firecrawlEndpoint = options.firecrawlEndpoint ?? "https://api.firecrawl.dev/v1/search";
649
684
  const maxResults = options.maxResults ?? 5;
650
685
  const timeoutMs = options.timeoutMs ?? 15e3;
651
686
  return {
652
- name: "WebSearch",
653
- description: "Search the web by query; returns ranked results (title, URL, snippet). Use to look things up, find pages, or research a topic \u2014 then WebFetch a result URL to read it in full.",
687
+ name: options.name ?? "WebSearch",
688
+ description: options.description ?? "Search the web by query; returns ranked results (title, URL, snippet). Use to look things up, find pages, or research a topic \u2014 then WebFetch a result URL to read it in full.",
654
689
  parameters: { type: "object", required: ["query"], properties: { query: { type: "string" } } },
655
690
  async run({ query }) {
656
691
  const doFetch = options.fetch ?? globalThis.fetch;
@@ -658,11 +693,22 @@ function makeWebSearchTool(options = {}) {
658
693
  const q = String(query ?? "").trim();
659
694
  if (!q) return "Error: empty query";
660
695
  const key = options.apiKey ?? process.env.TAVILY_API_KEY;
696
+ const fcKey = options.firecrawlApiKey ?? process.env.FIRECRAWL_API_KEY;
661
697
  const provider = options.provider ?? "auto";
662
- const useTavily = provider === "tavily" || provider === "auto" && !!key;
698
+ const useFirecrawl = provider === "firecrawl" || provider === "auto" && !!fcKey;
699
+ const useTavily = provider === "tavily" || provider === "auto" && !useFirecrawl && !!key;
663
700
  const ctl = new AbortController();
664
701
  const timer = setTimeout(() => ctl.abort(), timeoutMs);
665
702
  try {
703
+ if (provider === "anthropic") {
704
+ const akey = options.anthropicApiKey ?? process.env.ANTHROPIC_API_KEY;
705
+ if (!akey) return "Error: WebSearchAnthropic requires ANTHROPIC_API_KEY (set in env)";
706
+ return await anthropicSearch(q, { key: akey, model: options.model ?? "claude-haiku-4-5", fetch: doFetch, signal: ctl.signal });
707
+ }
708
+ if (useFirecrawl) {
709
+ if (!fcKey) return "Error: Firecrawl provider selected but FIRECRAWL_API_KEY is not set";
710
+ return await firecrawlSearch(q, { key: fcKey, endpoint: firecrawlEndpoint, maxResults, fetch: doFetch, signal: ctl.signal });
711
+ }
666
712
  if (useTavily) {
667
713
  if (!key) return "Error: Tavily provider selected but TAVILY_API_KEY is not set";
668
714
  const res2 = await doFetch(tavilyEndpoint, {
@@ -691,7 +737,10 @@ function makeWebSearchTool(options = {}) {
691
737
  }
692
738
  };
693
739
  }
694
- var log2, _dnsLookup, webFetchTool, webSearchTool;
740
+ function makeWebSearchAnthropicTool(opts = {}) {
741
+ return makeWebSearchTool({ provider: "anthropic", name: "WebSearchAnthropic", description: ANTHROPIC_SEARCH_DESC, anthropicApiKey: opts.anthropicApiKey, model: opts.model });
742
+ }
743
+ var log2, _dnsLookup, webFetchTool, webSearchTool, ANTHROPIC_SEARCH_DESC, webSearchAnthropicTool;
695
744
  var init_tools_web = __esm({
696
745
  "src/tools.web.ts"() {
697
746
  "use strict";
@@ -699,6 +748,8 @@ var init_tools_web = __esm({
699
748
  log2 = forComponent("web");
700
749
  webFetchTool = makeWebFetchTool();
701
750
  webSearchTool = makeWebSearchTool();
751
+ ANTHROPIC_SEARCH_DESC = "High-quality web search via Anthropic's native search index. Returns concise, sourced findings \u2014 one claim per line, each with its source URL. Prefer this over WebSearch when accuracy and citations matter; it is slower (~3\u20138s) and bills the Anthropic API account per call (one cheap-model turn + search fee).";
752
+ webSearchAnthropicTool = makeWebSearchAnthropicTool();
702
753
  }
703
754
  });
704
755
 
@@ -924,7 +975,7 @@ function defaultTools() {
924
975
  return [bashTool, readTool, editTool];
925
976
  }
926
977
  function toolRegistry() {
927
- const all = [bashTool, readTool, editTool, grepTool, globTool, writeTool, multiEditTool, applyEditsTool, repoMapTool, reviewTool(), todoWriteTool, webFetchTool, webSearchTool];
978
+ const all = [bashTool, readTool, editTool, grepTool, globTool, writeTool, multiEditTool, applyEditsTool, repoMapTool, reviewTool(), todoWriteTool, webFetchTool, webSearchTool, webSearchAnthropicTool];
928
979
  return Object.fromEntries(all.map((t) => [t.name, t]));
929
980
  }
930
981
  function toolsByName(names) {
@@ -4691,7 +4742,21 @@ var EMOTIONS = [
4691
4742
  "confident",
4692
4743
  "skeptical",
4693
4744
  "contemplative",
4694
- "determined"
4745
+ "determined",
4746
+ // remaining sonic-3 vocabulary — without these a valid model tag would be DROPPED (flat delivery).
4747
+ "joking",
4748
+ "trust",
4749
+ "anticipation",
4750
+ "outraged",
4751
+ "threatened",
4752
+ "contempt",
4753
+ "envious",
4754
+ "dejected",
4755
+ "rejected",
4756
+ "wistful",
4757
+ "insecure",
4758
+ "resigned",
4759
+ "distant"
4695
4760
  ];
4696
4761
  var VALID = new Set(EMOTIONS);
4697
4762
  var ALIASES = {
@@ -4736,7 +4801,9 @@ var ALIASES = {
4736
4801
  peaceful: "calm",
4737
4802
  serene: "calm",
4738
4803
  relaxed: "calm",
4739
- sleepy: "tired"
4804
+ sleepy: "tired",
4805
+ comedic: "joking"
4806
+ // Cartesia lists "joking/comedic" as one — canonicalize to joking
4740
4807
  };
4741
4808
  var NONVERBAL = { laughter: "laughter", laughs: "laughter", laugh: "laughter", laughing: "laughter" };
4742
4809
  function normalizeEmotion(raw) {
@@ -6817,6 +6884,7 @@ export {
6817
6884
  makeTaskBatchTool,
6818
6885
  makeTaskTool,
6819
6886
  makeWebFetchTool,
6887
+ makeWebSearchAnthropicTool,
6820
6888
  makeWebSearchTool,
6821
6889
  mcpToolToAgentTool,
6822
6890
  mcpToolsToAgentTools,
@@ -6850,6 +6918,7 @@ export {
6850
6918
  validateToolCode,
6851
6919
  validateWorktreeSlug,
6852
6920
  webFetchTool,
6921
+ webSearchAnthropicTool,
6853
6922
  webSearchTool,
6854
6923
  worktreeBranchName,
6855
6924
  writeFact,