saarthiclaw 0.2.1 → 0.2.3

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 (34) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +2 -0
  3. package/dist/chunks/{chunk-QFVMJJQY.js → chunk-44LLGJXH.js} +7 -7
  4. package/dist/chunks/{chunk-GSBUJPPF.js → chunk-BBQ26JQA.js} +5 -5
  5. package/dist/chunks/{chunk-OS5GVLKA.js → chunk-CGJ4VEUD.js} +1 -1
  6. package/dist/chunks/{chunk-4CNBITFA.js → chunk-CGTA77EE.js} +27 -7
  7. package/dist/chunks/{chunk-ZXVP7JFV.js → chunk-CUC6MUW7.js} +11 -13
  8. package/dist/chunks/{chunk-E4DRW4AW.js → chunk-H2FAKNUI.js} +10 -2
  9. package/dist/chunks/{chunk-OICPXSO2.js → chunk-HFMRQTXE.js} +1 -1
  10. package/dist/chunks/{chunk-4YYY2YOT.js → chunk-KAWTUWO2.js} +25 -7
  11. package/dist/chunks/{chunk-EG5A2Q6X.js → chunk-OJCC4JH2.js} +1 -1
  12. package/dist/chunks/{chunk-SKYTL7AH.js → chunk-OLL2WJVK.js} +17 -8
  13. package/dist/chunks/chunk-R4PMMMD5.js +407 -0
  14. package/dist/chunks/{chunk-VAP6FVF5.js → chunk-XNIFO3FV.js} +6 -6
  15. package/dist/chunks/{client-5WRI2PBK.js → client-O4UP5DCM.js} +3 -5
  16. package/dist/chunks/{context-AP3U34DQ.js → context-OL7JU4XA.js} +5 -7
  17. package/dist/chunks/{doctor-O3R2YTRO.js → doctor-OBO4MCDY.js} +11 -6
  18. package/dist/chunks/{errors-ZXTAHCZI.js → errors-OJZTUG74.js} +2 -4
  19. package/dist/chunks/orchestrator-HUHXYUUM.js +23 -0
  20. package/dist/chunks/{orchestrator-CYIGQH74.js → orchestrator-IKYROOM5.js} +10 -12
  21. package/dist/chunks/orchestrator-QAFNDXD2.js +22 -0
  22. package/dist/chunks/{session-FPFJMS7Y.js → session-ZC5D2O77.js} +6 -3
  23. package/dist/chunks/{store-KW257WIV.js → store-JG5OKLEO.js} +5 -5
  24. package/dist/chunks/{sync-S2A65FIE.js → sync-LTPGXMRU.js} +7 -9
  25. package/dist/chunks/{team-OFNBRXVP.js → team-AOMHCEDT.js} +25 -20
  26. package/dist/chunks/{telegram-LPSIQBQX.js → telegram-KO7VH46G.js} +14 -16
  27. package/dist/chunks/{wakeup-M5EIP54K.js → wakeup-YZNEVSVH.js} +16 -18
  28. package/dist/index.js +20 -19
  29. package/package.json +1 -1
  30. package/dist/chunks/chunk-BTFIQWAE.js +0 -185
  31. package/dist/chunks/chunk-G6GCAEKE.js +0 -64
  32. package/dist/chunks/chunk-XTVJWMUH.js +0 -143
  33. package/dist/chunks/orchestrator-4SMA442I.js +0 -24
  34. package/dist/chunks/orchestrator-L4TOOHXY.js +0 -23
@@ -11,16 +11,15 @@ import {
11
11
  saveKey,
12
12
  sha256Hex,
13
13
  syncStateFile,
14
+ teamAiFor,
14
15
  teamFile,
15
16
  writeSyncState,
16
17
  writeTeamLink
17
- } from "./chunk-E4DRW4AW.js";
18
- import "./chunk-G6GCAEKE.js";
19
- import "./chunk-IT46XDPQ.js";
20
- import "./chunk-XTVJWMUH.js";
21
- import "./chunk-BTFIQWAE.js";
18
+ } from "./chunk-H2FAKNUI.js";
19
+ import "./chunk-R4PMMMD5.js";
22
20
  import "./chunk-2GDAWRT7.js";
23
21
  import "./chunk-MMIJKDOU.js";
22
+ import "./chunk-IT46XDPQ.js";
24
23
  export {
25
24
  KEY_PATTERN,
26
25
  credentialId,
@@ -34,6 +33,7 @@ export {
34
33
  saveKey,
35
34
  sha256Hex,
36
35
  syncStateFile,
36
+ teamAiFor,
37
37
  teamFile,
38
38
  writeSyncState,
39
39
  writeTeamLink
@@ -1,20 +1,18 @@
1
1
  import {
2
2
  applyRemoteAction,
3
3
  runTeamSync
4
- } from "./chunk-ZXVP7JFV.js";
5
- import "./chunk-OS5GVLKA.js";
4
+ } from "./chunk-CUC6MUW7.js";
5
+ import "./chunk-CGJ4VEUD.js";
6
6
  import "./chunk-QRAFFI5V.js";
7
- import "./chunk-SKYTL7AH.js";
8
- import "./chunk-E4DRW4AW.js";
7
+ import "./chunk-OLL2WJVK.js";
8
+ import "./chunk-OJCC4JH2.js";
9
9
  import "./chunk-HGBZ55ND.js";
10
10
  import "./chunk-5WH3FNFK.js";
11
- import "./chunk-EG5A2Q6X.js";
12
- import "./chunk-G6GCAEKE.js";
13
- import "./chunk-IT46XDPQ.js";
14
- import "./chunk-XTVJWMUH.js";
15
- import "./chunk-BTFIQWAE.js";
11
+ import "./chunk-H2FAKNUI.js";
12
+ import "./chunk-R4PMMMD5.js";
16
13
  import "./chunk-2GDAWRT7.js";
17
14
  import "./chunk-MMIJKDOU.js";
15
+ import "./chunk-IT46XDPQ.js";
18
16
  export {
19
17
  applyRemoteAction,
20
18
  runTeamSync
@@ -3,14 +3,21 @@ import {
3
3
  } from "./chunk-R7ID2QVW.js";
4
4
  import {
5
5
  runTeamSync
6
- } from "./chunk-ZXVP7JFV.js";
7
- import "./chunk-OS5GVLKA.js";
6
+ } from "./chunk-CUC6MUW7.js";
7
+ import "./chunk-CGJ4VEUD.js";
8
8
  import "./chunk-QRAFFI5V.js";
9
9
  import {
10
10
  describeTeamMode,
11
11
  getTeamContext,
12
12
  teamClientFor
13
- } from "./chunk-SKYTL7AH.js";
13
+ } from "./chunk-OLL2WJVK.js";
14
+ import {
15
+ LEVEL_LABEL,
16
+ TeamApiError,
17
+ TeamClient
18
+ } from "./chunk-OJCC4JH2.js";
19
+ import "./chunk-HGBZ55ND.js";
20
+ import "./chunk-5WH3FNFK.js";
14
21
  import {
15
22
  KEY_PATTERN,
16
23
  normalizeServer,
@@ -20,24 +27,14 @@ import {
20
27
  removeTeamLink,
21
28
  saveKey,
22
29
  writeTeamLink
23
- } from "./chunk-E4DRW4AW.js";
24
- import "./chunk-HGBZ55ND.js";
25
- import "./chunk-5WH3FNFK.js";
26
- import {
27
- LEVEL_LABEL,
28
- TeamApiError,
29
- TeamClient
30
- } from "./chunk-EG5A2Q6X.js";
31
- import {
32
- UserFacingError
33
- } from "./chunk-G6GCAEKE.js";
34
- import "./chunk-IT46XDPQ.js";
30
+ } from "./chunk-H2FAKNUI.js";
35
31
  import {
32
+ UserFacingError,
36
33
  isSecretPath
37
- } from "./chunk-XTVJWMUH.js";
38
- import "./chunk-BTFIQWAE.js";
34
+ } from "./chunk-R4PMMMD5.js";
39
35
  import "./chunk-2GDAWRT7.js";
40
36
  import "./chunk-MMIJKDOU.js";
37
+ import "./chunk-IT46XDPQ.js";
41
38
 
42
39
  // cli/team.ts
43
40
  import chalk from "chalk";
@@ -174,6 +171,7 @@ Nothing changed. This folder is still ${was}.
174
171
  role: me.role,
175
172
  permissionLevel: me.permissionLevel,
176
173
  projectName: me.project?.name,
174
+ teamAi: Boolean(me.policy?.teamAi),
177
175
  connectedAt: (/* @__PURE__ */ new Date()).toISOString()
178
176
  });
179
177
  const gitignoreChanged = ensureGitignore(session.root, [".saarthiclaw/"]);
@@ -185,8 +183,14 @@ Nothing changed. This folder is still ${was}.
185
183
  console.log(`
186
184
  ${explainLevel(me)}
187
185
  `);
188
- if (!session.config.openrouterApiKey && me.permissionLevel !== "suggest_only") {
189
- console.log(chalk.yellow("One more thing: this folder has no AI key yet, so the agent can't run here.") + chalk.dim(" Add it with ") + chalk.bold("npx saarthiclaw init") + "\n");
186
+ if (me.policy?.teamAi) {
187
+ console.log(chalk.green("🤖 AI: this team uses the Admin's AI key through the dashboard — no AI key is needed on this computer.") + (me.policy.teamAiModel ? chalk.dim(` Model: ${me.policy.teamAiModel}`) : "") + "\n");
188
+ } else if (!session.config.openrouterApiKey && me.permissionLevel !== "suggest_only") {
189
+ if (me.role === "admin") {
190
+ console.log(chalk.yellow("Tip: add a Team AI key on the dashboard (Settings → Team AI) so nobody on the team needs their own AI key.") + "\n");
191
+ } else {
192
+ console.log(chalk.yellow("No AI is available here yet.") + chalk.dim(" Ask the Admin to add a Team AI key on the dashboard (Settings → Team AI), or add your own with ") + chalk.bold("npx saarthiclaw init") + "\n");
193
+ }
190
194
  }
191
195
  if (me.role === "admin") {
192
196
  const share = !session.prompter.interactive || await session.prompter.confirm({
@@ -234,6 +238,7 @@ async function teamStatus(session) {
234
238
  }
235
239
  rows.push(["Unread messages", me.unreadMessages ? chalk.cyan(String(me.unreadMessages)) + chalk.dim(" (open the dashboard → Messages)") : "0"]);
236
240
  rows.push(["File changes", me.policy.allowFileModification ? "allowed by the Admin" : chalk.yellow("turned off by the Admin")]);
241
+ rows.push(["AI", me.policy.teamAi ? `team key from the dashboard${me.policy.teamAiModel ? ` (${me.policy.teamAiModel})` : ""}` : session.config.openrouterApiKey ? "your own key" : chalk.yellow("none — ask the Admin for a Team AI key")]);
237
242
  const width = Math.max(...rows.map(([k]) => k.length));
238
243
  for (const [k, v] of rows) console.log(` ${chalk.dim(k.padEnd(width))} ${v}`);
239
244
  console.log(`
@@ -338,7 +343,7 @@ async function teamInbox(session) {
338
343
  });
339
344
  if (what === "back") continue;
340
345
  if (what === "run") {
341
- const { runAgentTask } = await import("./orchestrator-L4TOOHXY.js");
346
+ const { runAgentTask } = await import("./orchestrator-HUHXYUUM.js");
342
347
  const task = `${item.message}${item.adminNote ? `
343
348
 
344
349
  Admin note: ${item.adminNote}` : ""}
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  generatePlan,
3
3
  stepPrompt
4
- } from "./chunk-VAP6FVF5.js";
4
+ } from "./chunk-XNIFO3FV.js";
5
5
  import {
6
6
  createWebTools
7
- } from "./chunk-OICPXSO2.js";
7
+ } from "./chunk-HFMRQTXE.js";
8
8
  import {
9
9
  createAgentTools,
10
10
  createReadOnlyTools,
11
11
  dedupeReadOnlyTools,
12
12
  finishOnLastStep
13
- } from "./chunk-QFVMJJQY.js";
13
+ } from "./chunk-44LLGJXH.js";
14
14
  import {
15
15
  ToolExecutor
16
- } from "./chunk-OS5GVLKA.js";
16
+ } from "./chunk-CGJ4VEUD.js";
17
17
  import {
18
18
  groupPending
19
19
  } from "./chunk-QRAFFI5V.js";
20
- import "./chunk-SKYTL7AH.js";
21
- import "./chunk-E4DRW4AW.js";
20
+ import "./chunk-OLL2WJVK.js";
21
+ import "./chunk-OJCC4JH2.js";
22
22
  import {
23
23
  waitForInterrupt
24
24
  } from "./chunk-HGBZ55ND.js";
@@ -27,21 +27,18 @@ import {
27
27
  createTracker,
28
28
  instructionsFor,
29
29
  readOnlyAgentConfig
30
- } from "./chunk-4YYY2YOT.js";
30
+ } from "./chunk-KAWTUWO2.js";
31
31
  import "./chunk-5WH3FNFK.js";
32
- import "./chunk-EG5A2Q6X.js";
33
- import {
34
- UserFacingError
35
- } from "./chunk-G6GCAEKE.js";
36
- import "./chunk-IT46XDPQ.js";
37
- import "./chunk-XTVJWMUH.js";
32
+ import "./chunk-H2FAKNUI.js";
38
33
  import {
39
34
  AI_MAX_RETRIES,
40
35
  MissingApiKeyError,
36
+ UserFacingError,
41
37
  mapAiError
42
- } from "./chunk-BTFIQWAE.js";
38
+ } from "./chunk-R4PMMMD5.js";
43
39
  import "./chunk-2GDAWRT7.js";
44
40
  import "./chunk-MMIJKDOU.js";
41
+ import "./chunk-IT46XDPQ.js";
45
42
 
46
43
  // modes/telegram/index.ts
47
44
  import chalk from "chalk";
@@ -414,7 +411,7 @@ ${list}`);
414
411
 
415
412
  // modes/telegram/index.ts
416
413
  async function runTelegramMode(session) {
417
- const { getTeamContext } = await import("./context-AP3U34DQ.js");
414
+ const { getTeamContext } = await import("./context-OL7JU4XA.js");
418
415
  const team = await getTeamContext(session);
419
416
  if (team.mode === "needs_approval" || team.mode === "suggest_only") {
420
417
  throw new UserFacingError(
@@ -436,7 +433,8 @@ async function runTelegramMode(session) {
436
433
  "Message @userinfobot on Telegram to find it."
437
434
  );
438
435
  }
439
- if (!session.config.openrouterApiKey) throw new MissingApiKeyError();
436
+ const { hasAiAccess } = await import("./session-ZC5D2O77.js");
437
+ if (!hasAiAccess(session)) throw new MissingApiKeyError();
440
438
  console.log(chalk.bold("\n📱 Telegram Mode\n"));
441
439
  const { Telegraf } = await import("telegraf");
442
440
  const bot = new Telegraf(token);
@@ -1,34 +1,32 @@
1
1
  import {
2
2
  runAgentMode
3
- } from "./chunk-4CNBITFA.js";
3
+ } from "./chunk-CGTA77EE.js";
4
4
  import {
5
5
  runAskMode
6
- } from "./chunk-GSBUJPPF.js";
6
+ } from "./chunk-BBQ26JQA.js";
7
7
  import {
8
8
  runPlanMode
9
- } from "./chunk-VAP6FVF5.js";
10
- import "./chunk-OICPXSO2.js";
11
- import "./chunk-QFVMJJQY.js";
12
- import "./chunk-OS5GVLKA.js";
9
+ } from "./chunk-XNIFO3FV.js";
10
+ import "./chunk-HFMRQTXE.js";
11
+ import "./chunk-44LLGJXH.js";
12
+ import "./chunk-CGJ4VEUD.js";
13
13
  import "./chunk-QRAFFI5V.js";
14
- import "./chunk-SKYTL7AH.js";
15
- import "./chunk-E4DRW4AW.js";
14
+ import "./chunk-OLL2WJVK.js";
15
+ import "./chunk-OJCC4JH2.js";
16
16
  import {
17
17
  RunCancelledError
18
18
  } from "./chunk-HGBZ55ND.js";
19
- import "./chunk-4YYY2YOT.js";
19
+ import "./chunk-KAWTUWO2.js";
20
20
  import "./chunk-5WH3FNFK.js";
21
- import "./chunk-EG5A2Q6X.js";
21
+ import "./chunk-H2FAKNUI.js";
22
22
  import {
23
23
  reportError
24
- } from "./chunk-G6GCAEKE.js";
24
+ } from "./chunk-R4PMMMD5.js";
25
+ import "./chunk-2GDAWRT7.js";
26
+ import "./chunk-MMIJKDOU.js";
25
27
  import {
26
28
  UserCancelledError
27
29
  } from "./chunk-IT46XDPQ.js";
28
- import "./chunk-XTVJWMUH.js";
29
- import "./chunk-BTFIQWAE.js";
30
- import "./chunk-2GDAWRT7.js";
31
- import "./chunk-MMIJKDOU.js";
32
30
 
33
31
  // tui/wakeup.ts
34
32
  import chalk2 from "chalk";
@@ -124,15 +122,15 @@ async function runWakeup(session) {
124
122
  }
125
123
  if (choice === MainMenu.Telegram) {
126
124
  await runModeSafely(session, async () => {
127
- const { runTelegramMode } = await import("./telegram-LPSIQBQX.js");
125
+ const { runTelegramMode } = await import("./telegram-KO7VH46G.js");
128
126
  await runTelegramMode(session);
129
127
  });
130
128
  }
131
129
  }
132
130
  }
133
131
  async function runTeamMenu(session) {
134
- const team = await import("./team-OFNBRXVP.js");
135
- const { readTeamLink } = await import("./store-KW257WIV.js");
132
+ const team = await import("./team-AOMHCEDT.js");
133
+ const { readTeamLink } = await import("./store-JG5OKLEO.js");
136
134
  while (true) {
137
135
  const link = readTeamLink(session.root, session.env ?? process.env);
138
136
  const options = link ? [
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ async function bootstrap(cmd, opts = {}) {
17
17
  import("./chunks/workspace-PFJUEHAB.js"),
18
18
  import("./chunks/config-PA5NJ37O.js"),
19
19
  import("./chunks/prompter-AAH4A3BG.js"),
20
- import("./chunks/session-FPFJMS7Y.js")
20
+ import("./chunks/session-ZC5D2O77.js")
21
21
  ]);
22
22
  if (opts.needsTty && !prompterMod.isInteractiveTerminal()) {
23
23
  throw new prompterMod.NonInteractiveError(opts.needsTty);
@@ -37,10 +37,11 @@ async function bootstrap(cmd, opts = {}) {
37
37
  async function startWakeup(cmd) {
38
38
  const session = await bootstrap(cmd, { needsTty: "`saarthiclaw wakeup`" });
39
39
  const g = cmd.optsWithGlobals();
40
- const { renderBanner, runWakeup } = await import("./chunks/wakeup-M5EIP54K.js");
40
+ const { renderBanner, runWakeup } = await import("./chunks/wakeup-YZNEVSVH.js");
41
41
  if (g.banner !== false) console.log(renderBanner(getVersion()) + "\n");
42
- if (!session.config.openrouterApiKey) {
43
- console.log(chalk.yellow("⚠ No OpenRouter API key found. Run `saarthiclaw init` first (Ask/Plan/Agent need it).\n"));
42
+ const { hasAiAccess } = await import("./chunks/session-ZC5D2O77.js");
43
+ if (!hasAiAccess(session)) {
44
+ console.log(chalk.yellow("⚠ No AI key found. Run `saarthiclaw init` first, or ask your team Admin to add a Team AI key (Ask/Plan/Agent need one).\n"));
44
45
  }
45
46
  await runWakeup(session);
46
47
  goodbye();
@@ -70,31 +71,31 @@ function buildProgram() {
70
71
  });
71
72
  program.command("doctor").description("check your setup (Node, config, API key, a live test call)").option("--offline", "skip the live model call").action(async (opts, cmd) => {
72
73
  const session = await bootstrap(cmd);
73
- const { runDoctor } = await import("./chunks/doctor-O3R2YTRO.js");
74
+ const { runDoctor } = await import("./chunks/doctor-OBO4MCDY.js");
74
75
  const code = await runDoctor(session, { live: !opts.offline });
75
76
  if (code !== 0) throw new CommanderError(code, "saarthiclaw.doctorFailed", "");
76
77
  });
77
78
  program.command("ask").argument("[question...]", "question about the codebase (omit for the interactive prompt)").option("--save <file.md>", "save the answer as Markdown (goes through the approval flow)").description("ask a question about this codebase (read-only)").action(async (words, opts, cmd) => {
78
79
  const question = joinWords(words);
79
80
  const session = await bootstrap(cmd, { needsTty: question && !opts.save ? void 0 : "`saarthiclaw ask` without a question or with --save" });
80
- const ask = await import("./chunks/orchestrator-CYIGQH74.js");
81
+ const ask = await import("./chunks/orchestrator-IKYROOM5.js");
81
82
  if (question) await ask.runAskOnce(session, question, opts.save);
82
83
  else await ask.runAskMode(session);
83
84
  });
84
85
  program.command("plan").argument("[goal...]", "what you want to achieve").description("generate a step-by-step plan, pick steps, execute them with approval").action(async (words, _opts, cmd) => {
85
86
  const session = await bootstrap(cmd, { needsTty: "`saarthiclaw plan`" });
86
- const { runPlanMode } = await import("./chunks/orchestrator-4SMA442I.js");
87
+ const { runPlanMode } = await import("./chunks/orchestrator-QAFNDXD2.js");
87
88
  await runPlanMode(session, joinWords(words));
88
89
  });
89
90
  program.command("agent").argument("[task...]", "task for the agent").description("let the agent stage changes; you review and approve every diff").option("--send", "team (Needs approval): send the changes to the Admin without asking; no shell commands").action(async (words, opts, cmd) => {
90
91
  const task = joinWords(words);
91
92
  const session = await bootstrap(cmd, { needsTty: opts.send && task ? void 0 : "`saarthiclaw agent`" });
92
- const { runAgentMode } = await import("./chunks/orchestrator-L4TOOHXY.js");
93
+ const { runAgentMode } = await import("./chunks/orchestrator-HUHXYUUM.js");
93
94
  await runAgentMode(session, task, { send: opts.send });
94
95
  });
95
96
  program.command("telegram").description("run the Telegram remote-control bot (owner only) until Ctrl+C").action(async (_opts, cmd) => {
96
97
  const session = await bootstrap(cmd);
97
- const { runTelegramMode } = await import("./chunks/telegram-LPSIQBQX.js");
98
+ const { runTelegramMode } = await import("./chunks/telegram-KO7VH46G.js");
98
99
  await runTelegramMode(session);
99
100
  });
100
101
  program.command("history").description("show the audit trail of staged / approved / applied actions").option("--last <n>", "number of events to show", "20").action(async (opts, cmd) => {
@@ -106,44 +107,44 @@ function buildProgram() {
106
107
  });
107
108
  const team = program.command("team").description("work with a team dashboard: connect, sync approved changes, suggest, invite").action(async (_opts, cmd) => {
108
109
  const session = await bootstrap(cmd);
109
- const { teamStatus } = await import("./chunks/team-OFNBRXVP.js");
110
+ const { teamStatus } = await import("./chunks/team-AOMHCEDT.js");
110
111
  await teamStatus(session);
111
112
  });
112
113
  team.command("connect").alias("join").argument("[url]", "dashboard address, e.g. http://127.0.0.1:3000").description("link this project to a dashboard with your access key (Admin or member)").action(async (url, _opts, cmd) => {
113
114
  const session = await bootstrap(cmd, { needsTty: process.env.SAARTHICLAW_TEAM_KEY ? void 0 : "`saarthiclaw team connect` (or set SAARTHICLAW_TEAM_KEY)" });
114
- const { teamConnect } = await import("./chunks/team-OFNBRXVP.js");
115
+ const { teamConnect } = await import("./chunks/team-AOMHCEDT.js");
115
116
  await teamConnect(session, url);
116
117
  });
117
118
  team.command("status").description("who you are, your level, and what is waiting").action(async (_opts, cmd) => {
118
119
  const session = await bootstrap(cmd);
119
- const { teamStatus } = await import("./chunks/team-OFNBRXVP.js");
120
+ const { teamStatus } = await import("./chunks/team-AOMHCEDT.js");
120
121
  await teamStatus(session);
121
122
  });
122
123
  team.command("sync").description("apply your changes the Admin approved; show rejections").option("-y, --yes", "apply approved changes without asking").option("-w, --wait", "keep waiting until the Admin has decided on everything").action(async (opts, cmd) => {
123
124
  const session = await bootstrap(cmd);
124
125
  const g = cmd.optsWithGlobals();
125
- const { teamSync } = await import("./chunks/team-OFNBRXVP.js");
126
+ const { teamSync } = await import("./chunks/team-AOMHCEDT.js");
126
127
  await teamSync(session, { yes: opts.yes, wait: opts.wait, allowShell: g.allowShell });
127
128
  });
128
129
  team.command("suggest").argument("[idea...]", "your idea for the Admin").description("send an idea to the Admin (any level, including Suggest only)").action(async (words, _opts, cmd) => {
129
130
  const idea = joinWords(words);
130
131
  const session = await bootstrap(cmd, { needsTty: idea ? void 0 : "`saarthiclaw team suggest` without text" });
131
- const { teamSuggest } = await import("./chunks/team-OFNBRXVP.js");
132
+ const { teamSuggest } = await import("./chunks/team-AOMHCEDT.js");
132
133
  await teamSuggest(session, idea);
133
134
  });
134
135
  team.command("invite").argument("[name]", "developer's name").option("--level <level>", "trusted | needs-approval | suggest-only").description("(Admin) add a developer and print their one-time access key").action(async (name, opts, cmd) => {
135
136
  const session = await bootstrap(cmd, { needsTty: name ? void 0 : "`saarthiclaw team invite` without a name" });
136
- const { teamInvite } = await import("./chunks/team-OFNBRXVP.js");
137
+ const { teamInvite } = await import("./chunks/team-AOMHCEDT.js");
137
138
  await teamInvite(session, name ?? "", opts.level);
138
139
  });
139
140
  team.command("inbox").description("(Admin) suggestions you forwarded to the agent; run the agent on one").action(async (_opts, cmd) => {
140
141
  const session = await bootstrap(cmd);
141
- const { teamInbox } = await import("./chunks/team-OFNBRXVP.js");
142
+ const { teamInbox } = await import("./chunks/team-AOMHCEDT.js");
142
143
  await teamInbox(session);
143
144
  });
144
145
  team.command("disconnect").alias("leave").description("unlink this project from the dashboard (back to solo mode)").action(async (_opts, cmd) => {
145
146
  const session = await bootstrap(cmd, { needsTty: "`saarthiclaw team disconnect`" });
146
- const { teamDisconnect } = await import("./chunks/team-OFNBRXVP.js");
147
+ const { teamDisconnect } = await import("./chunks/team-AOMHCEDT.js");
147
148
  await teamDisconnect(session);
148
149
  });
149
150
  program.addHelpText(
@@ -174,7 +175,7 @@ async function main(argv = process.argv) {
174
175
  });
175
176
  }
176
177
  process.on("unhandledRejection", async (reason) => {
177
- const { reportError } = await import("./chunks/errors-ZXTAHCZI.js");
178
+ const { reportError } = await import("./chunks/errors-OJZTUG74.js");
178
179
  reportError(reason, debug);
179
180
  process.exit(1);
180
181
  });
@@ -196,7 +197,7 @@ async function main(argv = process.argv) {
196
197
  console.log(chalk.yellow("\nRun cancelled. Staged changes were discarded — nothing was written."));
197
198
  return 0;
198
199
  }
199
- const { reportError } = await import("./chunks/errors-ZXTAHCZI.js");
200
+ const { reportError } = await import("./chunks/errors-OJZTUG74.js");
200
201
  reportError(e, debug);
201
202
  return 1;
202
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saarthiclaw",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "An AI developer assistant that lives in your project's terminal. Ask, Plan and Agent modes — the AI proposes, you approve every change.",
5
5
  "keywords": [
6
6
  "ai",
@@ -1,185 +0,0 @@
1
- import {
2
- DEFAULT_MODEL,
3
- loadConfig
4
- } from "./chunk-2GDAWRT7.js";
5
- import {
6
- findWorkspaceRoot
7
- } from "./chunk-MMIJKDOU.js";
8
-
9
- // ai/errors.ts
10
- var MissingApiKeyError = class extends Error {
11
- constructor() {
12
- super("OPENROUTER_API_KEY is not set");
13
- this.name = "MissingApiKeyError";
14
- }
15
- };
16
- var FREE_TIER_NOTE = "Free OpenRouter models allow roughly 20 requests/minute and about 200 requests/day. Wait a minute, switch model with `--model <id>`, or add credits on openrouter.ai.";
17
- function asErrorLike(e) {
18
- return e && typeof e === "object" ? e : { message: String(e) };
19
- }
20
- function unwrap(e) {
21
- let cur = asErrorLike(e);
22
- for (let i = 0; i < 6; i++) {
23
- if (cur.name === "AI_RetryError" && cur.lastError) {
24
- cur = asErrorLike(cur.lastError);
25
- continue;
26
- }
27
- if (cur.statusCode === void 0 && cur.status === void 0 && cur.cause) {
28
- const c = asErrorLike(cur.cause);
29
- if (c.statusCode !== void 0 || c.status !== void 0 || c.name === "AI_RetryError") {
30
- cur = c;
31
- continue;
32
- }
33
- }
34
- break;
35
- }
36
- return cur;
37
- }
38
- var NETWORK_CODES = /* @__PURE__ */ new Set([
39
- "ECONNREFUSED",
40
- "ECONNRESET",
41
- "ENOTFOUND",
42
- "EAI_AGAIN",
43
- "ETIMEDOUT",
44
- "ENETUNREACH",
45
- "EHOSTUNREACH",
46
- "UND_ERR_CONNECT_TIMEOUT",
47
- "UND_ERR_SOCKET"
48
- ]);
49
- function findCode(e) {
50
- let cur = e;
51
- for (let i = 0; i < 6 && cur && typeof cur === "object"; i++) {
52
- const c = cur.code;
53
- if (typeof c === "string") return c;
54
- cur = cur.cause;
55
- }
56
- return void 0;
57
- }
58
- function mapAiError(error) {
59
- const outer = asErrorLike(error);
60
- if (error instanceof MissingApiKeyError || outer.name === "MissingApiKeyError" || outer.name === "AI_LoadAPIKeyError") {
61
- return {
62
- kind: "missing_key",
63
- title: "No OpenRouter API key configured.",
64
- hint: "Run `saarthiclaw init` (or set OPENROUTER_API_KEY in your project .env). Get a key at https://openrouter.ai/keys"
65
- };
66
- }
67
- if (outer.name === "AI_NoOutputGeneratedError") {
68
- return {
69
- kind: "no_output",
70
- title: "The model finished without giving an answer.",
71
- hint: "This happens when a model keeps calling tools until it runs out of steps. Try again, ask a more specific question, or use a stronger model with `--model <id>`."
72
- };
73
- }
74
- if (outer.name === "AI_NoObjectGeneratedError") {
75
- return {
76
- kind: "no_output",
77
- title: "The model did not return a valid plan.",
78
- hint: "Try again, or use a model that is better at structured output (e.g. `--model openai/gpt-4o-mini`)."
79
- };
80
- }
81
- if (outer.name === "AbortError" || outer.name === "RunCancelledError") {
82
- return { kind: "cancelled", title: "Cancelled.", hint: "Nothing was written." };
83
- }
84
- const e = unwrap(error);
85
- const status = e.statusCode ?? e.status;
86
- const body = `${e.message ?? ""} ${e.responseBody ?? ""}`.toLowerCase();
87
- if (e.name === "TimeoutError" || /timed? ?out/.test(body) && status === void 0) {
88
- return {
89
- kind: "timeout",
90
- title: "The AI request timed out.",
91
- hint: "The model may be overloaded. Try again, or pick a faster model with `--model <id>`."
92
- };
93
- }
94
- if (status === 401) {
95
- return {
96
- kind: "invalid_key",
97
- title: "OpenRouter rejected the API key (401).",
98
- hint: "Check OPENROUTER_API_KEY or run `saarthiclaw init` to replace it. Keys: https://openrouter.ai/keys",
99
- status
100
- };
101
- }
102
- if (status === 402) {
103
- return {
104
- kind: "payment",
105
- title: "OpenRouter says this request needs credits (402).",
106
- hint: "Use a `:free` model (e.g. qwen/qwen3-coder:free) or add credits at https://openrouter.ai/credits",
107
- status
108
- };
109
- }
110
- if (status === 403) {
111
- return {
112
- kind: "forbidden",
113
- title: "OpenRouter refused the request (403).",
114
- hint: "Your key may lack permission for this model, or the input was flagged by moderation. Try another model.",
115
- status
116
- };
117
- }
118
- if (status === 429) {
119
- return {
120
- kind: "rate_limit",
121
- title: "Rate limited by OpenRouter (429), even after retrying with backoff.",
122
- hint: FREE_TIER_NOTE,
123
- status
124
- };
125
- }
126
- if (status === 404 || status === 400 && /(not a valid model|no endpoints found|model .*not (found|exist)|unknown model)/.test(body)) {
127
- return {
128
- kind: "model_not_found",
129
- title: "That model is not available on OpenRouter.",
130
- hint: "Free model lineups rotate. Pick another with `saarthiclaw init` or `--model <id>` (see https://openrouter.ai/models?q=free).",
131
- status
132
- };
133
- }
134
- const code = findCode(error);
135
- if (code && NETWORK_CODES.has(code) || /fetch failed|network|socket hang up|getaddrinfo/.test(body)) {
136
- return {
137
- kind: "network",
138
- title: "Could not reach OpenRouter (network error).",
139
- hint: "Check your internet connection, proxy or firewall, then try again."
140
- };
141
- }
142
- if (status !== void 0 && status >= 500) {
143
- return {
144
- kind: "unknown",
145
- title: `OpenRouter had a server error (${status}).`,
146
- hint: "This is usually temporary — try again in a moment or switch model.",
147
- status
148
- };
149
- }
150
- return {
151
- kind: "unknown",
152
- title: e.message?.split("\n")[0] || "Unexpected AI error.",
153
- hint: "Run with --debug for details, or `saarthiclaw doctor` to check your setup.",
154
- status
155
- };
156
- }
157
- var AI_MAX_RETRIES = 3;
158
-
159
- // ai/ai.config.ts
160
- import { createOpenRouter } from "@openrouter/ai-sdk-provider";
161
- function getAgentModel(options = {}) {
162
- let apiKey = options.apiKey?.trim();
163
- let modelId = options.model?.trim();
164
- if (!apiKey || !modelId) {
165
- const cfg = loadConfig({ root: findWorkspaceRoot() });
166
- apiKey ||= cfg.openrouterApiKey;
167
- modelId ||= cfg.model;
168
- }
169
- if (!apiKey) throw new MissingApiKeyError();
170
- const provider = createOpenRouter({
171
- apiKey,
172
- headers: {
173
- "HTTP-Referer": "https://github.com/hritik0447/SaarthiClaw",
174
- "X-Title": "SaarthiClaw"
175
- }
176
- });
177
- return provider(modelId || DEFAULT_MODEL);
178
- }
179
-
180
- export {
181
- MissingApiKeyError,
182
- mapAiError,
183
- AI_MAX_RETRIES,
184
- getAgentModel
185
- };