thinyai 0.1.3 → 0.1.5

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 (3) hide show
  1. package/README.md +1 -0
  2. package/dist/bin.js +60 -7
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -36,6 +36,7 @@ thiny # first launch runs setup, then starts chatting
36
36
  | `thiny` | Start the interactive agent. Runs first-time setup if needed. |
37
37
  | `thiny init` | (Re)run base setup — pick a model + agent name + API key. |
38
38
  | `thiny sui init` | Add Sui on-chain capabilities — pick a network + wallet. |
39
+ | `thiny update` | Update to the latest published version (auto-detects bun/npm/pnpm). |
39
40
  | `thiny help` | Show all commands. |
40
41
  | `thiny --version` | Print the version. |
41
42
 
package/dist/bin.js CHANGED
@@ -1,10 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // src/bin.ts
4
+ import { spawnSync } from "child_process";
5
+ import { fileURLToPath as fileURLToPath2 } from "url";
6
+
3
7
  // src/main.ts
4
8
  import { createInterface } from "readline/promises";
5
9
  import { clearLine, cursorTo, emitKeypressEvents } from "readline";
6
10
  import { stdin, stdout } from "process";
7
- import { mkdirSync as mkdirSync2 } from "fs";
11
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
8
12
  import { homedir as homedir2 } from "os";
9
13
  import { join as join2 } from "path";
10
14
  import { z as z6 } from "zod";
@@ -1436,14 +1440,14 @@ function suiPlugin(opts) {
1436
1440
  });
1437
1441
  const executePtb = defineTool({
1438
1442
  name: "sui_execute_ptb",
1439
- description: "Sign and submit an unsigned Sui programmable transaction (PTB) that a builder/MCP produced. Re-simulates the PTB, applies the soft policy and approval gate, then signs + submits. Pass the builder's `unsignedPtb` (base64 of the serialized transaction) \u2014 built with NO sender and NO gas (the signer fills both). On-chain caps may still abort it.",
1443
+ description: "Sign and submit an unsigned Sui programmable transaction (PTB) produced by an external builder/MCP (e.g. Rill). Re-simulates \u2192 soft policy \u2192 approval gate \u2192 sign + submit. Pass the builder's `unsignedTx`: the JSON string from `Transaction.toJSON()`, built with NO sender and NO gas (the signer fills both). On-chain caps may still abort it. For your OWN transfers/calls use sui_transfer / sui_move_call instead.",
1440
1444
  sensitive: true,
1441
1445
  parameters: z4.object({
1442
- unsignedPtb: z4.string().min(1).describe("The builder's unsigned PTB \u2014 base64 of a serialized Sui transaction.")
1446
+ unsignedTx: z4.string().min(1).describe("Unsigned PTB \u2014 the JSON string from Transaction.toJSON() (no sender, no gas).")
1443
1447
  }),
1444
- execute: async ({ unsignedPtb }) => {
1445
- const tx = Transaction2.from(Buffer.from(unsignedPtb, "base64").toString("utf8"));
1446
- return await executeTx(tx, "sui_execute_ptb", { unsignedPtb }, "sign and submit a Sui PTB");
1448
+ execute: async ({ unsignedTx }) => {
1449
+ const tx = Transaction2.from(unsignedTx);
1450
+ return await executeTx(tx, "sui_execute_ptb", { unsignedTx }, "sign and submit a Sui PTB");
1447
1451
  }
1448
1452
  });
1449
1453
  const transfer = defineTool({
@@ -2234,6 +2238,28 @@ function parseSkillArgs() {
2234
2238
  return (args[idx + 1] ?? "").split(",").map((s) => s.trim()).filter(Boolean);
2235
2239
  }
2236
2240
  var currentSessionId = `cli-${(/* @__PURE__ */ new Date()).getTime().toString()}`;
2241
+ function isNewerVersion(latest, current) {
2242
+ const a = latest.split(".").map((n) => Number(n) || 0);
2243
+ const b = current.split(".").map((n) => Number(n) || 0);
2244
+ for (let i = 0; i < 3; i++) {
2245
+ if ((a[i] ?? 0) !== (b[i] ?? 0)) return (a[i] ?? 0) > (b[i] ?? 0);
2246
+ }
2247
+ return false;
2248
+ }
2249
+ function notifyIfUpdate(thinyDir) {
2250
+ const cur = version();
2251
+ const cacheFile = join2(thinyDir, "update-check.json");
2252
+ try {
2253
+ const cached = JSON.parse(readFileSync3(cacheFile, "utf8"));
2254
+ if (cached.latest && isNewerVersion(cached.latest, cur)) {
2255
+ renderInfo(`Update available: ${cur} \u2192 ${cached.latest} \u2014 run \`thiny update\``);
2256
+ }
2257
+ } catch {
2258
+ }
2259
+ void fetch("https://registry.npmjs.org/thinyai/latest").then((r) => r.json()).then((j) => {
2260
+ if (j.version) writeFileSync2(cacheFile, JSON.stringify({ latest: j.version, at: Date.now() }));
2261
+ }).catch(() => void 0);
2262
+ }
2237
2263
  async function runCli() {
2238
2264
  const thinyDir = join2(homedir2(), ".thiny");
2239
2265
  mkdirSync2(thinyDir, { recursive: true });
@@ -2345,7 +2371,7 @@ async function runCli() {
2345
2371
  model,
2346
2372
  logger: agentLogger,
2347
2373
  persona,
2348
- 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\nSUI: You can operate on the Sui blockchain. " + (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. ") + "Use sui_balance to read balances and sui_object to inspect objects. To SEND a transaction you need an UNSIGNED PTB built by a builder (e.g. a connected Rill MCP tool); pass it to sui_execute_ptb, which simulates, applies caps, and signs. Never claim you cannot use Sui \u2014 you can.",
2374
+ 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\nSUI: 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.",
2349
2375
  tools: [echoTool, suiSetupTool],
2350
2376
  plugins: [
2351
2377
  {
@@ -2404,6 +2430,7 @@ async function runCli() {
2404
2430
  `Sui: ${suiNetwork} \xB7 ${suiSignerRef.address ?? "?"}${process.env.MCP_URL ? " \xB7 Rill MCP connected" : ""}`
2405
2431
  );
2406
2432
  else renderInfo("Sui: no wallet \u2014 ask the agent to set one up, or run `thiny sui init`");
2433
+ notifyIfUpdate(thinyDir);
2407
2434
  const rl = createInterface({ input: stdin, output: stdout });
2408
2435
  emitKeypressEvents(stdin);
2409
2436
  const spinner = new Spinner();
@@ -2621,11 +2648,33 @@ Usage:
2621
2648
  thiny Start the interactive CLI agent (runs setup on first use)
2622
2649
  thiny init Re-run setup (model, agent name, key)
2623
2650
  thiny sui init Add Sui capabilities (network + wallet)
2651
+ thiny update Update thinyai to the latest version
2624
2652
  thiny --version Print version
2625
2653
  thiny help Show this help
2626
2654
 
2627
2655
  Config: ~/.thiny/config.json (no .env needed)`);
2628
2656
  }
2657
+ function detectPackageManager() {
2658
+ const here = fileURLToPath2(import.meta.url);
2659
+ if (here.includes("/.bun/") || here.includes("\\.bun\\")) return "bun";
2660
+ if (here.includes("pnpm")) return "pnpm";
2661
+ return "npm";
2662
+ }
2663
+ function update() {
2664
+ const pm = detectPackageManager();
2665
+ const args = pm === "npm" ? ["install", "-g", "thinyai@latest"] : ["add", "-g", "thinyai@latest"];
2666
+ console.log(`Updating thinyai via ${pm}\u2026 (${pm} ${args.join(" ")})`);
2667
+ const res = spawnSync(pm, args, { stdio: "inherit" });
2668
+ if (res.status !== 0) {
2669
+ console.error(
2670
+ `
2671
+ Update failed. Run it manually: ${pm} ${args.join(" ")}
2672
+ (or, if you used a different installer: npm i -g thinyai@latest)`
2673
+ );
2674
+ process.exit(res.status ?? 1);
2675
+ }
2676
+ console.log("\n\u2713 Updated. Run `thiny --version` to confirm.");
2677
+ }
2629
2678
  async function run() {
2630
2679
  const [sub, sub2] = process.argv.slice(2);
2631
2680
  switch (sub) {
@@ -2636,6 +2685,10 @@ async function run() {
2636
2685
  if (sub2 === "init") await suiInit();
2637
2686
  else console.log("Usage: thiny sui init");
2638
2687
  return;
2688
+ case "update":
2689
+ case "upgrade":
2690
+ update();
2691
+ return;
2639
2692
  case "--version":
2640
2693
  case "-v":
2641
2694
  console.log(version());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinyai",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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/mcp": "0.1.0",
42
40
  "@thiny/core": "0.1.0",
43
- "@thiny/model-aisdk": "0.1.0",
44
- "@thiny/walrus": "0.1.0",
41
+ "@thiny/mcp": "0.1.0",
45
42
  "@thiny/logger-pino": "0.1.0",
43
+ "@thiny/walrus": "0.1.0",
44
+ "@thiny/model-aisdk": "0.1.0",
46
45
  "@thiny/plugin-agents": "0.1.0",
47
- "@thiny/plugin-sui": "0.1.0",
46
+ "@thiny/memory-memwal": "0.1.0",
48
47
  "@thiny/signer-sui": "0.1.0",
48
+ "@thiny/plugin-sui": "0.1.0",
49
49
  "@thiny/skills": "0.1.0"
50
50
  },
51
51
  "author": "Thiny AI",