@garuda-agent/garuda 0.16.1 → 0.17.0

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 (54) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/README.md +56 -1074
  3. package/SECURITY.md +9 -2
  4. package/dist/{acpCommand-OTAYW7BS.js → acpCommand-7EY3NHPG.js} +18 -16
  5. package/dist/{anthropic-NQDBCHJU.js → anthropic-NQIZLD64.js} +12 -6
  6. package/dist/{chunk-TILFPYWO.js → chunk-2DYMJMRQ.js} +1880 -982
  7. package/dist/{chunk-YQTGMCU6.js → chunk-3MRQJKUO.js} +29 -5
  8. package/dist/{chunk-WMOLXTBU.js → chunk-4LFJFDCF.js} +2 -1
  9. package/dist/{chunk-44QN5SWZ.js → chunk-55CFEEIN.js} +22 -2
  10. package/dist/{chunk-USCUXCAU.js → chunk-5B5HDTUR.js} +3 -3
  11. package/dist/{chunk-TUUEBHG2.js → chunk-6XHON3Q6.js} +2 -2
  12. package/dist/chunk-735BKABA.js +472 -0
  13. package/dist/{chunk-B6FA4I7Q.js → chunk-7TH3NHCQ.js} +2 -2
  14. package/dist/{chunk-OUCV3FCT.js → chunk-AOGFYUKG.js} +3 -3
  15. package/dist/{chunk-GXZACJUI.js → chunk-B4SJY7KT.js} +322 -39
  16. package/dist/{chunk-3EQU2GUX.js → chunk-BHZ6G65V.js} +5 -1
  17. package/dist/chunk-BSK5T2ZG.js +9 -0
  18. package/dist/chunk-J4346IDH.js +156 -0
  19. package/dist/{chunk-NP6RIC25.js → chunk-JRVWH27M.js} +7 -7
  20. package/dist/{chunk-HUIK3WXO.js → chunk-P6XWWIEK.js} +20 -3
  21. package/dist/{chunk-HE2K657U.js → chunk-TJIWD7R7.js} +47 -16
  22. package/dist/chunk-U65DQZDB.js +143 -0
  23. package/dist/chunk-UIRJOQQS.js +118 -0
  24. package/dist/{chunk-KKB5W47S.js → chunk-VTMD5IHD.js} +26 -2
  25. package/dist/{chunk-BQTUOO4G.js → chunk-Z66BWTMD.js} +81 -32
  26. package/dist/cli/index.js +99 -41
  27. package/dist/{create-VXIH2GUZ.js → create-W6BV75QX.js} +18 -12
  28. package/dist/{deadline-F5RJJ2QW.js → deadline-TP7ZGLT2.js} +4 -2
  29. package/dist/{evalCommand-RGMZRYDR.js → evalCommand-YVQAWUZE.js} +50 -29
  30. package/dist/{export-HN3CT7AV.js → export-SJ3DUP6W.js} +2 -2
  31. package/dist/{inkChat-WEDGQMCY.js → inkChat-FNUBK43U.js} +14 -13
  32. package/dist/install-TKWN5AYH.js +19 -0
  33. package/dist/{job-3NYDMP2M.js → job-7JOI4YIQ.js} +6 -2
  34. package/dist/jobCommand-FE6XN3YD.js +33 -0
  35. package/dist/{launchd-SSX362VG.js → launchd-3A3ONEW5.js} +9 -8
  36. package/dist/{lspCommand-JRXKRSL7.js → lspCommand-ZZ6R4PA2.js} +7 -6
  37. package/dist/{manager-773PUDFE.js → manager-73MPYFTP.js} +7 -6
  38. package/dist/{nightCommand-65MUEV32.js → nightCommand-OODJNWDT.js} +26 -20
  39. package/dist/{openaiCompatible-CJWVJP5M.js → openaiCompatible-6TLDDW5U.js} +29 -15
  40. package/dist/{policy-EJPLEEXP.js → policy-ZJ7RMOFN.js} +10 -4
  41. package/dist/{remove-6GDSTAIO.js → remove-42WQNVPX.js} +8 -7
  42. package/dist/{server-NGKVIQEV.js → server-VEYIJHEU.js} +2 -2
  43. package/dist/{setupCommand-VA7D5MZK.js → setupCommand-GBQIVYJC.js} +45 -13
  44. package/dist/text-LS35WSRL.js +17 -0
  45. package/native/bin/garuda-reap +0 -0
  46. package/native/garuda-reap.c +113 -0
  47. package/package.json +39 -13
  48. package/dist/chunk-EIXUSVFX.js +0 -116
  49. package/dist/chunk-R7I2NBPX.js +0 -71
  50. package/dist/chunk-ULAJPMY7.js +0 -107
  51. package/dist/chunk-VBZCNMUD.js +0 -9
  52. package/dist/install-EWDSPFFZ.js +0 -18
  53. package/dist/jobCommand-ACSGSBQ4.js +0 -32
  54. package/dist/text-J2GD647J.js +0 -11
@@ -6,7 +6,7 @@ import {
6
6
  fuzzyFiles,
7
7
  runChat,
8
8
  statusOf
9
- } from "./chunk-BQTUOO4G.js";
9
+ } from "./chunk-Z66BWTMD.js";
10
10
  import {
11
11
  retryText,
12
12
  serverToolOutput,
@@ -19,26 +19,27 @@ import {
19
19
  colorPreview,
20
20
  header
21
21
  } from "./chunk-4JSUUDFQ.js";
22
- import "./chunk-TILFPYWO.js";
22
+ import "./chunk-2DYMJMRQ.js";
23
23
  import "./chunk-G2AX7MGS.js";
24
24
  import "./chunk-A2QAIRQL.js";
25
- import "./chunk-ULAJPMY7.js";
26
- import "./chunk-EIXUSVFX.js";
27
- import "./chunk-R7I2NBPX.js";
25
+ import "./chunk-735BKABA.js";
26
+ import "./chunk-U65DQZDB.js";
27
+ import "./chunk-J4346IDH.js";
28
28
  import "./chunk-B25VL4RU.js";
29
29
  import "./chunk-23FXBNBB.js";
30
30
  import "./chunk-EU7PA45O.js";
31
- import "./chunk-VBZCNMUD.js";
31
+ import "./chunk-BSK5T2ZG.js";
32
32
  import "./chunk-5DEWP3YX.js";
33
33
  import "./chunk-ZAE25JM2.js";
34
34
  import "./chunk-ATW7BNIG.js";
35
35
  import "./chunk-PZS3V6P3.js";
36
- import "./chunk-OUCV3FCT.js";
37
- import "./chunk-GXZACJUI.js";
38
- import "./chunk-WMOLXTBU.js";
39
- import "./chunk-3EQU2GUX.js";
40
- import "./chunk-HUIK3WXO.js";
41
- import "./chunk-KKB5W47S.js";
36
+ import "./chunk-AOGFYUKG.js";
37
+ import "./chunk-B4SJY7KT.js";
38
+ import "./chunk-BHZ6G65V.js";
39
+ import "./chunk-P6XWWIEK.js";
40
+ import "./chunk-VTMD5IHD.js";
41
+ import "./chunk-UIRJOQQS.js";
42
+ import "./chunk-4LFJFDCF.js";
42
43
  import "./chunk-3NJNVZTK.js";
43
44
 
44
45
  // src/cli/chat/inkChat.ts
@@ -1193,4 +1194,4 @@ async function runInkChat(runtime, approver, setEventTarget, banner, sessionPath
1193
1194
  export {
1194
1195
  runInkChat
1195
1196
  };
1196
- //# sourceMappingURL=inkChat-WEDGQMCY.js.map
1197
+ //# sourceMappingURL=inkChat-FNUBK43U.js.map
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ INSTALL_TIMEOUT_MS,
4
+ installCommand,
5
+ installServer
6
+ } from "./chunk-7TH3NHCQ.js";
7
+ import "./chunk-EU7PA45O.js";
8
+ import "./chunk-B4SJY7KT.js";
9
+ import "./chunk-BHZ6G65V.js";
10
+ import "./chunk-P6XWWIEK.js";
11
+ import "./chunk-UIRJOQQS.js";
12
+ import "./chunk-4LFJFDCF.js";
13
+ import "./chunk-3NJNVZTK.js";
14
+ export {
15
+ INSTALL_TIMEOUT_MS,
16
+ installCommand,
17
+ installServer
18
+ };
19
+ //# sourceMappingURL=install-TKWN5AYH.js.map
@@ -8,11 +8,14 @@ import {
8
8
  listJobs,
9
9
  loadJob,
10
10
  newJobId,
11
+ parseJob,
11
12
  planPermissions,
12
13
  planTitle,
13
14
  saveJob,
14
15
  settleJob
15
- } from "./chunk-KKB5W47S.js";
16
+ } from "./chunk-VTMD5IHD.js";
17
+ import "./chunk-UIRJOQQS.js";
18
+ import "./chunk-4LFJFDCF.js";
16
19
  import "./chunk-3NJNVZTK.js";
17
20
  export {
18
21
  DEFAULT_JOB_MAX_STEPS,
@@ -23,9 +26,10 @@ export {
23
26
  listJobs,
24
27
  loadJob,
25
28
  newJobId,
29
+ parseJob,
26
30
  planPermissions,
27
31
  planTitle,
28
32
  saveJob,
29
33
  settleJob
30
34
  };
31
- //# sourceMappingURL=job-3NYDMP2M.js.map
35
+ //# sourceMappingURL=job-7JOI4YIQ.js.map
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ JOB_TEST_TIMEOUT_MS,
4
+ finishJob,
5
+ msUntil,
6
+ prepareJob,
7
+ testsBefore
8
+ } from "./chunk-TJIWD7R7.js";
9
+ import "./chunk-N4I6YS3E.js";
10
+ import "./chunk-735BKABA.js";
11
+ import "./chunk-J4346IDH.js";
12
+ import "./chunk-5DEWP3YX.js";
13
+ import "./chunk-PZS3V6P3.js";
14
+ import "./chunk-55CFEEIN.js";
15
+ import "./chunk-5B5HDTUR.js";
16
+ import "./chunk-3MRQJKUO.js";
17
+ import "./chunk-AOGFYUKG.js";
18
+ import "./chunk-6XHON3Q6.js";
19
+ import "./chunk-B4SJY7KT.js";
20
+ import "./chunk-BHZ6G65V.js";
21
+ import "./chunk-P6XWWIEK.js";
22
+ import "./chunk-VTMD5IHD.js";
23
+ import "./chunk-UIRJOQQS.js";
24
+ import "./chunk-4LFJFDCF.js";
25
+ import "./chunk-3NJNVZTK.js";
26
+ export {
27
+ JOB_TEST_TIMEOUT_MS,
28
+ finishJob,
29
+ msUntil,
30
+ prepareJob,
31
+ testsBefore
32
+ };
33
+ //# sourceMappingURL=jobCommand-FE6XN3YD.js.map
@@ -14,13 +14,14 @@ import {
14
14
  removeSpec,
15
15
  specPath,
16
16
  specPlist
17
- } from "./chunk-USCUXCAU.js";
18
- import "./chunk-TUUEBHG2.js";
19
- import "./chunk-GXZACJUI.js";
20
- import "./chunk-WMOLXTBU.js";
21
- import "./chunk-3EQU2GUX.js";
22
- import "./chunk-HUIK3WXO.js";
23
- import "./chunk-KKB5W47S.js";
17
+ } from "./chunk-5B5HDTUR.js";
18
+ import "./chunk-6XHON3Q6.js";
19
+ import "./chunk-B4SJY7KT.js";
20
+ import "./chunk-BHZ6G65V.js";
21
+ import "./chunk-P6XWWIEK.js";
22
+ import "./chunk-VTMD5IHD.js";
23
+ import "./chunk-UIRJOQQS.js";
24
+ import "./chunk-4LFJFDCF.js";
24
25
  import "./chunk-3NJNVZTK.js";
25
26
  export {
26
27
  agentLabel,
@@ -38,4 +39,4 @@ export {
38
39
  specPath,
39
40
  specPlist
40
41
  };
41
- //# sourceMappingURL=launchd-SSX362VG.js.map
42
+ //# sourceMappingURL=launchd-3A3ONEW5.js.map
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-36GQIVGT.js";
6
6
  import {
7
7
  installServer
8
- } from "./chunk-B6FA4I7Q.js";
8
+ } from "./chunk-7TH3NHCQ.js";
9
9
  import {
10
10
  LSP_CONFIG_FILE,
11
11
  loadLspConfig
@@ -18,10 +18,11 @@ import {
18
18
  HostExecutor,
19
19
  createExecutor,
20
20
  loadSettings
21
- } from "./chunk-GXZACJUI.js";
22
- import "./chunk-WMOLXTBU.js";
23
- import "./chunk-3EQU2GUX.js";
24
- import "./chunk-HUIK3WXO.js";
21
+ } from "./chunk-B4SJY7KT.js";
22
+ import "./chunk-BHZ6G65V.js";
23
+ import "./chunk-P6XWWIEK.js";
24
+ import "./chunk-UIRJOQQS.js";
25
+ import "./chunk-4LFJFDCF.js";
25
26
  import "./chunk-3NJNVZTK.js";
26
27
 
27
28
  // src/cli/lspCommand.ts
@@ -97,4 +98,4 @@ export {
97
98
  lspInstallCommand,
98
99
  lspStatusCommand
99
100
  };
100
- //# sourceMappingURL=lspCommand-JRXKRSL7.js.map
101
+ //# sourceMappingURL=lspCommand-ZZ6R4PA2.js.map
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-4P26OKTP.js";
12
12
  import {
13
13
  VERSION
14
- } from "./chunk-VBZCNMUD.js";
14
+ } from "./chunk-BSK5T2ZG.js";
15
15
  import {
16
16
  USER_SCOPE
17
17
  } from "./chunk-5DEWP3YX.js";
@@ -34,10 +34,11 @@ import {
34
34
  import {
35
35
  DEFAULT_ENV_ALLOWLIST,
36
36
  sandboxPaths
37
- } from "./chunk-GXZACJUI.js";
38
- import "./chunk-WMOLXTBU.js";
39
- import "./chunk-3EQU2GUX.js";
40
- import "./chunk-HUIK3WXO.js";
37
+ } from "./chunk-B4SJY7KT.js";
38
+ import "./chunk-BHZ6G65V.js";
39
+ import "./chunk-P6XWWIEK.js";
40
+ import "./chunk-UIRJOQQS.js";
41
+ import "./chunk-4LFJFDCF.js";
41
42
  import "./chunk-3NJNVZTK.js";
42
43
 
43
44
  // src/mcp/manager.ts
@@ -845,4 +846,4 @@ export {
845
846
  changeLines,
846
847
  warnings
847
848
  };
848
- //# sourceMappingURL=manager-773PUDFE.js.map
849
+ //# sourceMappingURL=manager-73MPYFTP.js.map
@@ -1,41 +1,46 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  msUntil
4
- } from "./chunk-HE2K657U.js";
4
+ } from "./chunk-TJIWD7R7.js";
5
5
  import {
6
6
  notificationBytes,
7
7
  pickChannel
8
8
  } from "./chunk-N4I6YS3E.js";
9
- import "./chunk-ULAJPMY7.js";
10
- import "./chunk-R7I2NBPX.js";
9
+ import "./chunk-735BKABA.js";
10
+ import "./chunk-J4346IDH.js";
11
11
  import "./chunk-5DEWP3YX.js";
12
12
  import "./chunk-PZS3V6P3.js";
13
- import "./chunk-44QN5SWZ.js";
13
+ import "./chunk-55CFEEIN.js";
14
14
  import {
15
15
  defaultAgentEnv,
16
16
  nightSpec,
17
17
  removeSpec
18
- } from "./chunk-USCUXCAU.js";
19
- import "./chunk-YQTGMCU6.js";
18
+ } from "./chunk-5B5HDTUR.js";
19
+ import {
20
+ formatCost,
21
+ jobCost,
22
+ sumCosts
23
+ } from "./chunk-3MRQJKUO.js";
20
24
  import {
21
25
  testSummary
22
- } from "./chunk-OUCV3FCT.js";
26
+ } from "./chunk-AOGFYUKG.js";
23
27
  import {
24
28
  hostCommand,
25
29
  shellWord
26
- } from "./chunk-TUUEBHG2.js";
30
+ } from "./chunk-6XHON3Q6.js";
27
31
  import {
28
32
  createExecutor
29
- } from "./chunk-GXZACJUI.js";
30
- import "./chunk-WMOLXTBU.js";
31
- import "./chunk-3EQU2GUX.js";
32
- import "./chunk-HUIK3WXO.js";
33
+ } from "./chunk-B4SJY7KT.js";
34
+ import "./chunk-BHZ6G65V.js";
35
+ import "./chunk-P6XWWIEK.js";
33
36
  import {
34
37
  JOBS_DIR,
35
38
  listJobs,
36
39
  loadJob,
37
40
  settleJob
38
- } from "./chunk-KKB5W47S.js";
41
+ } from "./chunk-VTMD5IHD.js";
42
+ import "./chunk-UIRJOQQS.js";
43
+ import "./chunk-4LFJFDCF.js";
39
44
  import "./chunk-3NJNVZTK.js";
40
45
 
41
46
  // src/cli/nightCommand.ts
@@ -100,14 +105,15 @@ async function runQueue(jobs, run, parallel, report = {}) {
100
105
  }
101
106
  function nightDigest(jobs, started, ended) {
102
107
  const ready = jobs.filter((j) => j.result?.proof?.verdict === "ready");
103
- const cost = jobs.reduce(
104
- (sum, j) => sum + (j.result?.costUsd ?? 0) + (j.result?.proof?.review?.costUsd ?? 0),
105
- 0
108
+ const cost = sumCosts(
109
+ jobs.map(
110
+ (j) => j.result !== void 0 ? jobCost(j.result) : { usd: 0, incomplete: j.status !== "scheduled" }
111
+ )
106
112
  );
107
113
  const lines = [
108
114
  `# Garuda night shift: ${local(started)}`,
109
115
  "",
110
- `${jobs.length} job(s): ${ready.length} ready to merge, ${jobs.length - ready.length} need a look. Time ${Math.round((ended.getTime() - started.getTime()) / 6e4)} min \xB7 cost $${cost.toFixed(4)}.`,
116
+ `${jobs.length} job(s): ${ready.length} ready to merge, ${jobs.length - ready.length} need a look. Time ${Math.round((ended.getTime() - started.getTime()) / 6e4)} min \xB7 cost ${formatCost(cost)}.`,
111
117
  "",
112
118
  "| Job | Verdict | Tests after | Files | Cost | Branch |",
113
119
  "| --- | --- | --- | --- | --- | --- |"
@@ -115,9 +121,9 @@ function nightDigest(jobs, started, ended) {
115
121
  for (const j of jobs) {
116
122
  const r = j.result;
117
123
  const verdict = r?.proof === void 0 ? j.status : r.proof.verdict === "ready" ? "ready to merge" : "needs a look";
118
- const jobCost = r === void 0 ? "\u2013" : `$${((r.costUsd ?? 0) + (r.proof?.review?.costUsd ?? 0)).toFixed(4)}`;
124
+ const costText = r === void 0 ? "\u2013" : formatCost(jobCost(r));
119
125
  lines.push(
120
- `| ${j.id}: ${cell(j.title)} | ${verdict} | ${j.test === void 0 ? "no tests" : testSummary(r?.proof?.after)} | ${r?.files.length ?? 0} | ${jobCost} | ${j.branch} |`
126
+ `| ${j.id}: ${cell(j.title)} | ${verdict} | ${j.test === void 0 ? "no tests" : testSummary(r?.proof?.after)} | ${r?.files.length ?? 0} | ${costText} | ${j.branch} |`
121
127
  );
122
128
  }
123
129
  const looks = jobs.filter((j) => j.result?.proof?.verdict !== "ready");
@@ -246,4 +252,4 @@ Digest: ${file}`);
246
252
  export {
247
253
  nightCommand
248
254
  };
249
- //# sourceMappingURL=nightCommand-65MUEV32.js.map
255
+ //# sourceMappingURL=nightCommand-OODJNWDT.js.map
@@ -215,7 +215,11 @@ var OpenAICompatibleClient = class {
215
215
  fetch;
216
216
  delays;
217
217
  async *stream(request, options) {
218
- const http = await this.post(toWireBody(this.options.model, request), options?.signal);
218
+ const http = await this.post(
219
+ toWireBody(this.options.model, request),
220
+ options?.signal,
221
+ options?.meter
222
+ );
219
223
  const mode = request.tools.length === 0 ? "off" : this.options.textToolCalls ?? "whole";
220
224
  const state = newStreamState();
221
225
  const hold = new StreamHold(mode);
@@ -241,7 +245,7 @@ var OpenAICompatibleClient = class {
241
245
  }
242
246
  yield { type: "response", response };
243
247
  }
244
- async post(body, signal) {
248
+ async post(body, signal, meter) {
245
249
  const url = `${this.options.baseUrl.replace(/\/+$/, "")}/chat/completions`;
246
250
  const headers = {
247
251
  "content-type": "application/json",
@@ -262,6 +266,7 @@ var OpenAICompatibleClient = class {
262
266
  const cause = causeCode(error);
263
267
  if (attempt < this.delays.length && cause !== "ECONNREFUSED") {
264
268
  await sleep(this.delays[attempt] ?? 1e3, signal);
269
+ meter?.retry();
265
270
  continue;
266
271
  }
267
272
  throw new Error(
@@ -274,6 +279,7 @@ var OpenAICompatibleClient = class {
274
279
  const retryAfter = Number(response.headers.get("retry-after")) * 1e3;
275
280
  const wait = Number.isFinite(retryAfter) && retryAfter > 0 ? Math.min(retryAfter, MAX_RETRY_AFTER_MS) : this.delays[attempt] ?? 1e3;
276
281
  await sleep(wait, signal);
282
+ meter?.retry();
277
283
  continue;
278
284
  }
279
285
  throw new Error(
@@ -378,10 +384,12 @@ function finishResponse(state, request, mode = "whole") {
378
384
  input: parseArguments(call.args)
379
385
  });
380
386
  }
387
+ const reported = providerUsage(state.usage);
381
388
  return {
382
389
  content,
383
390
  stopReason: stopReason(state, content),
384
- usage: usageOf(state, request, content)
391
+ usage: reported ?? estimatedUsage(request, content),
392
+ ...reported === void 0 ? { usageReported: false } : {}
385
393
  };
386
394
  }
387
395
  function toolNames(request) {
@@ -403,17 +411,23 @@ function stopReason(state, content) {
403
411
  return "end_turn";
404
412
  return "other";
405
413
  }
406
- function usageOf(state, request, content) {
407
- const u = state.usage;
408
- if (u?.prompt_tokens !== void 0) {
409
- const cached = u.prompt_tokens_details?.cached_tokens ?? 0;
410
- return {
411
- inputTokens: Math.max(0, u.prompt_tokens - cached),
412
- outputTokens: u.completion_tokens ?? 0,
413
- cacheReadTokens: cached,
414
- cacheWriteTokens: 0
415
- };
416
- }
414
+ function providerUsage(u) {
415
+ const input = u?.prompt_tokens;
416
+ const output = u?.completion_tokens;
417
+ const cached = u?.prompt_tokens_details?.cached_tokens ?? 0;
418
+ if (!tokenCount(input) || !tokenCount(output) || !tokenCount(cached) || cached > input)
419
+ return void 0;
420
+ return {
421
+ inputTokens: input - cached,
422
+ outputTokens: output,
423
+ cacheReadTokens: cached,
424
+ cacheWriteTokens: 0
425
+ };
426
+ }
427
+ function tokenCount(value) {
428
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
429
+ }
430
+ function estimatedUsage(request, content) {
417
431
  const chars = (value) => JSON.stringify(value).length;
418
432
  return {
419
433
  inputTokens: Math.ceil(
@@ -498,4 +512,4 @@ export {
498
512
  toWireMessages,
499
513
  toWireTools
500
514
  };
501
- //# sourceMappingURL=openaiCompatible-CJWVJP5M.js.map
515
+ //# sourceMappingURL=openaiCompatible-6TLDDW5U.js.map
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  POLICY_FILE,
4
+ PROFILES,
4
5
  assertModelAllowedByPolicy,
5
6
  ignoredProjectPolicy,
6
7
  isCommandDisallowedByPolicy,
@@ -8,14 +9,17 @@ import {
8
9
  isModelAllowedByPolicy,
9
10
  isPathDeniedByPolicy,
10
11
  isSandboxRequiredByPolicy,
12
+ isStrict,
11
13
  loadTeamPolicy,
12
14
  managedPolicyPath,
13
15
  mergePolicies,
14
- parsePolicy
15
- } from "./chunk-HUIK3WXO.js";
16
+ parsePolicy,
17
+ withProfile
18
+ } from "./chunk-P6XWWIEK.js";
16
19
  import "./chunk-3NJNVZTK.js";
17
20
  export {
18
21
  POLICY_FILE,
22
+ PROFILES,
19
23
  assertModelAllowedByPolicy,
20
24
  ignoredProjectPolicy,
21
25
  isCommandDisallowedByPolicy,
@@ -23,9 +27,11 @@ export {
23
27
  isModelAllowedByPolicy,
24
28
  isPathDeniedByPolicy,
25
29
  isSandboxRequiredByPolicy,
30
+ isStrict,
26
31
  loadTeamPolicy,
27
32
  managedPolicyPath,
28
33
  mergePolicies,
29
- parsePolicy
34
+ parsePolicy,
35
+ withProfile
30
36
  };
31
- //# sourceMappingURL=policy-EJPLEEXP.js.map
37
+ //# sourceMappingURL=policy-ZJ7RMOFN.js.map
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  git
4
- } from "./chunk-TUUEBHG2.js";
5
- import "./chunk-GXZACJUI.js";
6
- import "./chunk-WMOLXTBU.js";
7
- import "./chunk-3EQU2GUX.js";
8
- import "./chunk-HUIK3WXO.js";
4
+ } from "./chunk-6XHON3Q6.js";
5
+ import "./chunk-B4SJY7KT.js";
6
+ import "./chunk-BHZ6G65V.js";
7
+ import "./chunk-P6XWWIEK.js";
9
8
  import {
10
9
  JOBS_DIR,
11
10
  jobPath
12
- } from "./chunk-KKB5W47S.js";
11
+ } from "./chunk-VTMD5IHD.js";
12
+ import "./chunk-UIRJOQQS.js";
13
+ import "./chunk-4LFJFDCF.js";
13
14
  import "./chunk-3NJNVZTK.js";
14
15
 
15
16
  // src/jobs/remove.ts
@@ -57,4 +58,4 @@ export {
57
58
  jobLeftovers,
58
59
  removeJob
59
60
  };
60
- //# sourceMappingURL=remove-6GDSTAIO.js.map
61
+ //# sourceMappingURL=remove-42WQNVPX.js.map
@@ -467,7 +467,7 @@ function setupNeeded(message) {
467
467
  return Object.assign(new Error(message), { authRequired: true });
468
468
  }
469
469
  var MODES = {
470
- build: { name: "Build", description: "Edits and commands, each one asks first." },
470
+ build: { name: "Build", description: "Edits ask first; commands run in the sandbox." },
471
471
  plan: {
472
472
  name: "Plan",
473
473
  description: "Reads and plans. No edits; commands cannot write the project."
@@ -695,4 +695,4 @@ export {
695
695
  canRunTerminalAuth,
696
696
  setupNeeded
697
697
  };
698
- //# sourceMappingURL=server-NGKVIQEV.js.map
698
+ //# sourceMappingURL=server-VEYIJHEU.js.map
@@ -11,13 +11,16 @@ import {
11
11
  resolveModel,
12
12
  setDefaultModel,
13
13
  writeCredentials
14
- } from "./chunk-NP6RIC25.js";
15
- import "./chunk-EIXUSVFX.js";
14
+ } from "./chunk-JRVWH27M.js";
16
15
  import {
17
- knownModels
18
- } from "./chunk-R7I2NBPX.js";
16
+ fetchCatalog,
17
+ loadCatalog,
18
+ mergedModels,
19
+ saveCatalog
20
+ } from "./chunk-U65DQZDB.js";
21
+ import "./chunk-J4346IDH.js";
19
22
  import "./chunk-ATW7BNIG.js";
20
- import "./chunk-3EQU2GUX.js";
23
+ import "./chunk-BHZ6G65V.js";
21
24
 
22
25
  // src/cli/setupCommand.ts
23
26
  import { homedir } from "os";
@@ -85,7 +88,9 @@ async function setup(io, config, home, env, fetcher) {
85
88
  }))
86
89
  );
87
90
  const def = providers[provider];
88
- const model = await pickModel(io, provider, def, fetcher);
91
+ const anthropicKey = def.type === "anthropic" ? def.apiKeyEnv ?? "ANTHROPIC_API_KEY" : void 0;
92
+ const knownKey = anthropicKey === void 0 ? void 0 : (env[anthropicKey] ?? "") !== "" ? env[anthropicKey] : stored.keys[anthropicKey];
93
+ const model = await pickModel(io, provider, def, fetcher, { home, env, key: knownKey });
89
94
  const spec = provider === "anthropic" ? model : `${provider}/${model}`;
90
95
  try {
91
96
  resolveModel(spec, config);
@@ -111,7 +116,12 @@ async function setup(io, config, home, env, fetcher) {
111
116
  const key = fromEnv !== "" ? fromEnv : newKey ?? old;
112
117
  const result = await checkKey(provider, def, key, env, fetcher);
113
118
  io.print(result.message);
114
- if (result.ok) break;
119
+ if (result.ok) {
120
+ if (def.type === "anthropic" && knownKey === void 0) {
121
+ await refreshCatalog(io, { home, env, key }, fetcher);
122
+ }
123
+ break;
124
+ }
115
125
  const next = await io.select("What now?", [
116
126
  ...fromEnv === "" ? [{ name: "Enter the key again", value: "again" }] : [],
117
127
  { name: "Store it anyway", value: "store" },
@@ -146,15 +156,17 @@ async function setup(io, config, home, env, fetcher) {
146
156
  io.print("Done. Start Garuda with: garuda");
147
157
  return 0;
148
158
  }
149
- async function pickModel(io, provider, def, fetcher) {
159
+ async function pickModel(io, provider, def, fetcher, account) {
150
160
  let listed = [];
151
161
  const notes = /* @__PURE__ */ new Map();
152
162
  if (def.type === "anthropic") {
153
- for (const { id, info } of knownModels()) {
163
+ let catalog = await loadCatalog(account.home);
164
+ if (account.key !== void 0) {
165
+ catalog = await refreshCatalog(io, account, fetcher) ?? catalog;
166
+ }
167
+ for (const { id, info, known } of mergedModels(catalog)) {
154
168
  listed.push(id);
155
- if (info.price !== void 0) {
156
- notes.set(id, `$${info.price.input} in, $${info.price.output} out per million tokens`);
157
- }
169
+ notes.set(id, known && info.price !== void 0 ? priceNote(info.price) : UNKNOWN_PRICE);
158
170
  }
159
171
  } else if (def.local === true && def.baseUrl !== void 0) {
160
172
  listed = await localModels(def.baseUrl, fetcher);
@@ -177,6 +189,26 @@ async function pickModel(io, provider, def, fetcher) {
177
189
  io.print("Type a model name with no spaces.");
178
190
  }
179
191
  }
192
+ var UNKNOWN_PRICE = "price unknown to this Garuda version: costs show as unknown (set model.price, or update Garuda)";
193
+ function priceNote(price) {
194
+ const more = price.over === void 0 ? "" : ` (more for prompts over ${price.over.tokens / 1e3}k tokens)`;
195
+ return `$${price.input} in, $${price.output} out per million tokens${more}`;
196
+ }
197
+ async function refreshCatalog(io, account, fetcher) {
198
+ const base = account.env.ANTHROPIC_BASE_URL ?? "";
199
+ const result = await fetchCatalog({
200
+ key: account.key,
201
+ ...base === "" ? {} : { baseUrl: base },
202
+ fetcher
203
+ });
204
+ if ("problem" in result) {
205
+ io.print(`The list shows Garuda's own table: ${result.problem}.`);
206
+ return void 0;
207
+ }
208
+ await saveCatalog(result.catalog, account.home);
209
+ io.print(`Models of your account: ${result.catalog.models.length}.`);
210
+ return result.catalog;
211
+ }
180
212
  async function localModels(baseUrl, fetcher) {
181
213
  try {
182
214
  const response = await fetcher(`${baseUrl.replace(/\/+$/, "")}/models`, {
@@ -300,4 +332,4 @@ export {
300
332
  setupCommand,
301
333
  terminalIO
302
334
  };
303
- //# sourceMappingURL=setupCommand-VA7D5MZK.js.map
335
+ //# sourceMappingURL=setupCommand-GBQIVYJC.js.map
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatCost,
4
+ jobCost,
5
+ jobPrompt,
6
+ jobReport,
7
+ sumCosts
8
+ } from "./chunk-3MRQJKUO.js";
9
+ import "./chunk-AOGFYUKG.js";
10
+ export {
11
+ formatCost,
12
+ jobCost,
13
+ jobPrompt,
14
+ jobReport,
15
+ sumCosts
16
+ };
17
+ //# sourceMappingURL=text-LS35WSRL.js.map
Binary file