thinyai 0.1.6 → 0.1.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.
Files changed (2) hide show
  1. package/dist/bin.js +48 -3
  2. package/package.json +5 -5
package/dist/bin.js CHANGED
@@ -2444,14 +2444,56 @@ async function runCli() {
2444
2444
  };
2445
2445
  }
2446
2446
  });
2447
- const webPlugins = process.env.BRAVE_API_KEY ? [webSearchPlugin({ apiKey: process.env.BRAVE_API_KEY })] : [];
2447
+ const exaKey = process.env.EXA_API_KEY;
2448
+ const webPlugins = [];
2449
+ const webTools = [];
2450
+ if (exaKey) {
2451
+ webTools.push(
2452
+ defineTool({
2453
+ name: "web_search",
2454
+ description: "Search the WEB via Exa and get ranked results with text snippets. Use whenever you need current info, prices, docs, or to find a page \u2014 anything you don't already know. This is DIFFERENT from fetch_url: web_search finds pages by query; fetch_url reads one URL you have.",
2455
+ parameters: z7.object({
2456
+ query: z7.string().min(1).describe("The search query."),
2457
+ numResults: z7.number().int().positive().optional().describe("Results to return (default 5).")
2458
+ }),
2459
+ execute: async ({ query, numResults }) => {
2460
+ const res = await fetch("https://api.exa.ai/search", {
2461
+ method: "POST",
2462
+ headers: { "content-type": "application/json", "x-api-key": exaKey },
2463
+ body: JSON.stringify({
2464
+ query,
2465
+ numResults: numResults ?? 5,
2466
+ contents: { text: { maxCharacters: 1200 } }
2467
+ }),
2468
+ signal: AbortSignal.timeout(2e4)
2469
+ });
2470
+ if (!res.ok) throw new Error(`web_search: Exa HTTP ${String(res.status)} ${await res.text()}`);
2471
+ const data = await res.json();
2472
+ return {
2473
+ query,
2474
+ results: (data.results ?? []).map((r) => ({ title: r.title, url: r.url, text: r.text }))
2475
+ };
2476
+ }
2477
+ })
2478
+ );
2479
+ } else if (process.env.BRAVE_API_KEY) {
2480
+ webPlugins.push(webSearchPlugin({ apiKey: process.env.BRAVE_API_KEY }));
2481
+ }
2482
+ const webSearchOn = webTools.length > 0 || webPlugins.length > 0;
2448
2483
  const budget = budgetMiddleware({ maxCalls: 50, logger });
2449
2484
  const agent = await createAgent({
2450
2485
  model,
2451
2486
  logger: agentLogger,
2452
2487
  persona,
2453
- systemPrompt: "You are a helpful AI assistant. Use tools when they help you answer better. Be concise.\n\nMEMORY: You have persistent long-term memory across sessions, stored on Walrus. What you already know about the user is injected automatically at the start of each conversation under \u201C[User Memory \u2026]\u201D. When the user shares anything durable about themselves \u2014 their name, role, preferences, projects, or goals, even casually \u2014 immediately call remember_fact to save it. If asked what you remember, answer from the injected user memory (or call recall_memory). You DO remember across sessions \u2014 never say you lack memory or that each session starts fresh.\n\nFor multi-step work, call update_plan to track steps and delegate_task to hand focused sub-problems to a sub-agent.\n\nLINKS: When the user shares any URL (a skill.md, docs, an API or MCP endpoint, etc.), call fetch_url to read it \u2014 never say you can't open links" + (webPlugins.length > 0 ? ". Use web_search to look things up on the web.\n\n" : ".\n\n") + "SUI: You can operate on the Sui blockchain directly with your own tools \u2014 do NOT tell the user to install a browser wallet extension. " + (suiSignerRef ? `A wallet IS configured on ${suiNetwork} at ${suiSignerRef.address ?? "(unknown)"}. ` : "No wallet is set up yet \u2014 when the user wants Sui, call sui_setup (generate / import / rill) to create or connect one, then tell them to fund the returned address. ") + "Your Sui tools: sui_setup (create/import a wallet), sui_balance and sui_object (read), sui_transfer (send SUI or any coin to an address \u2014 amounts in MIST, 1 SUI = 1e9), sui_move_call (call ANY Move function on any package \u2014 the general way to run any on-chain action), and sui_execute_ptb (sign a PTB an external builder/Rill produced). Prefer sui_transfer for sends and sui_move_call for contract calls. Always confirm details and remind the user to fund the wallet. Never claim you cannot transact on Sui \u2014 you can, via these tools.",
2454
- tools: [echoTool, suiSetupTool, fetchUrlTool],
2488
+ systemPrompt: `You are ${persona?.name ?? "ThinyAI"}, a capable assistant with real tools. Be concise.
2489
+
2490
+ HOW TO ACT: When a request maps to one of your tools, CALL THE TOOL automatically \u2014 figure out the right tool yourself; do not ask the user which tool to run, do not ask permission for read-only actions, and never say you can't do something one of your tools covers. Chain tools when needed (e.g. web_search \u2192 fetch_url \u2192 act).
2491
+
2492
+ YOUR TOOLS:
2493
+ \u2022 Memory \u2014 remember_fact, recall_memory: durable memory across sessions (stored on Walrus). Known facts are injected each turn under \u201C[User Memory \u2026]\u201D. Immediately save anything durable the user shares (name, role, preferences, projects, goals). Answer \u201Cwhat do you remember\u201D from it. You DO remember across sessions \u2014 never say otherwise.
2494
+ \u2022 Links \u2014 fetch_url: read ANY URL the user shares (a skill.md, docs, JSON, an API/MCP endpoint). Always fetch shared links instead of saying you can't open URLs.
2495
+ ` + (webSearchOn ? "\u2022 Web search \u2014 web_search: search the web for anything you don't know (news, prices, docs). web_search FINDS pages by query; fetch_url READS a specific URL \u2014 use them together.\n" : "") + "\u2022 Planning \u2014 update_plan (track multi-step work), delegate_task (hand a focused subtask to a sub-agent).\n\u2022 Sui blockchain \u2014 you transact yourself; NEVER tell the user to install a browser wallet. " + (suiSignerRef ? `A wallet IS set up on ${suiNetwork} at ${suiSignerRef.address ?? "?"}. ` : "No wallet yet \u2014 call sui_setup (generate / import / rill) when the user wants Sui, then have them fund the address. ") + "sui_setup (create/import a wallet), sui_balance & sui_object (read), sui_transfer (send SUI or any coin \u2014 amounts in MIST, 1 SUI = 1e9), sui_move_call (call ANY Move function \u2014 any on-chain action), sui_execute_ptb (sign a PTB a builder/Rill produced). Prefer sui_transfer for sends and sui_move_call for contract calls; confirm details before signing.",
2496
+ tools: [echoTool, suiSetupTool, fetchUrlTool, ...webTools],
2455
2497
  plugins: [
2456
2498
  {
2457
2499
  name: "observability",
@@ -2511,6 +2553,9 @@ async function runCli() {
2511
2553
  `Sui: ${suiNetwork} \xB7 ${suiSignerRef.address ?? "?"}${process.env.MCP_URL ? " \xB7 Rill MCP connected" : ""}`
2512
2554
  );
2513
2555
  else renderInfo("Sui: no wallet \u2014 ask the agent to set one up, or run `thiny sui init`");
2556
+ renderInfo(
2557
+ `Web: fetch_url (any URL)${webSearchOn ? ` \xB7 web_search (${exaKey ? "Exa" : "Brave"})` : " \xB7 web_search off (set EXA_API_KEY)"}`
2558
+ );
2514
2559
  notifyIfUpdate(thinyDir);
2515
2560
  const rl = createInterface({ input: stdin, output: stdout });
2516
2561
  emitKeypressEvents(stdin);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinyai",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Thiny AI — a beautiful terminal agent: interactive chat, tools, Walrus memory, and Sui execution.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,15 +37,15 @@
37
37
  "devDependencies": {
38
38
  "tsup": "^8.5.1",
39
39
  "typescript": "^5.5.0",
40
- "@thiny/memory-memwal": "0.1.0",
41
- "@thiny/walrus": "0.1.0",
42
- "@thiny/plugin-agents": "0.1.0",
43
40
  "@thiny/core": "0.1.0",
44
- "@thiny/model-aisdk": "0.1.0",
45
41
  "@thiny/logger-pino": "0.1.0",
42
+ "@thiny/plugin-agents": "0.1.0",
43
+ "@thiny/memory-memwal": "0.1.0",
46
44
  "@thiny/mcp": "0.1.0",
45
+ "@thiny/walrus": "0.1.0",
47
46
  "@thiny/signer-sui": "0.1.0",
48
47
  "@thiny/plugin-web-search": "0.1.0",
48
+ "@thiny/model-aisdk": "0.1.0",
49
49
  "@thiny/plugin-sui": "0.1.0",
50
50
  "@thiny/skills": "0.1.0"
51
51
  },