@cargo-ai/cli 1.0.94 → 1.0.96

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 (123) hide show
  1. package/build/commands/ai/chat.d.ts.map +1 -1
  2. package/build/commands/ai/chat.js +2 -1
  3. package/build/commands/ai/message.d.ts.map +1 -1
  4. package/build/commands/ai/message.js +2 -1
  5. package/build/commands/ai/release.d.ts.map +1 -1
  6. package/build/commands/ai/release.js +7 -6
  7. package/build/commands/ask/harness/approvals.d.ts +7 -0
  8. package/build/commands/ask/harness/approvals.d.ts.map +1 -0
  9. package/build/commands/ask/harness/approvals.js +81 -0
  10. package/build/commands/ask/harness/artifacts.d.ts.map +1 -0
  11. package/build/commands/ask/harness/askUserQuestion.d.ts +69 -0
  12. package/build/commands/ask/harness/askUserQuestion.d.ts.map +1 -0
  13. package/build/commands/ask/harness/askUserQuestion.js +218 -0
  14. package/build/commands/ask/harness/claudeConfig.d.ts.map +1 -0
  15. package/build/commands/ask/{claudeConfig.js → harness/claudeConfig.js} +28 -13
  16. package/build/commands/ask/harness/create.d.ts +59 -0
  17. package/build/commands/ask/harness/create.d.ts.map +1 -0
  18. package/build/commands/ask/harness/create.js +314 -0
  19. package/build/commands/ask/harness/index.d.ts +9 -0
  20. package/build/commands/ask/harness/index.d.ts.map +1 -0
  21. package/build/commands/ask/harness/index.js +8 -0
  22. package/build/commands/ask/harness/ingest.d.ts +25 -0
  23. package/build/commands/ask/harness/ingest.d.ts.map +1 -0
  24. package/build/commands/ask/harness/ingest.js +35 -0
  25. package/build/commands/ask/harness/instructions.d.ts +13 -0
  26. package/build/commands/ask/harness/instructions.d.ts.map +1 -0
  27. package/build/commands/ask/harness/instructions.js +43 -0
  28. package/build/commands/ask/harness/layout.d.ts +23 -0
  29. package/build/commands/ask/harness/layout.d.ts.map +1 -0
  30. package/build/commands/ask/harness/layout.js +32 -0
  31. package/build/commands/ask/harness/mcp.d.ts +25 -0
  32. package/build/commands/ask/harness/mcp.d.ts.map +1 -0
  33. package/build/commands/ask/harness/mcp.js +72 -0
  34. package/build/commands/ask/harness/pnpmShim.d.ts.map +1 -0
  35. package/build/commands/ask/harness/release.d.ts +18 -0
  36. package/build/commands/ask/harness/release.d.ts.map +1 -0
  37. package/build/commands/ask/harness/release.js +117 -0
  38. package/build/commands/ask/harness/sandbox.d.ts +9 -0
  39. package/build/commands/ask/harness/sandbox.d.ts.map +1 -0
  40. package/build/commands/ask/harness/sandbox.js +27 -0
  41. package/build/commands/ask/harness/timing.d.ts +16 -0
  42. package/build/commands/ask/harness/timing.d.ts.map +1 -0
  43. package/build/commands/ask/harness/timing.js +72 -0
  44. package/build/commands/ask/harness/turn.d.ts +152 -0
  45. package/build/commands/ask/harness/turn.d.ts.map +1 -0
  46. package/build/commands/ask/harness/turn.js +676 -0
  47. package/build/commands/ask/harness/usage.d.ts +50 -0
  48. package/build/commands/ask/harness/usage.d.ts.map +1 -0
  49. package/build/commands/ask/harness/usage.js +87 -0
  50. package/build/commands/ask/index.d.ts +9 -0
  51. package/build/commands/ask/index.d.ts.map +1 -1
  52. package/build/commands/ask/index.js +7 -7
  53. package/build/commands/ask/input/completer.d.ts.map +1 -0
  54. package/build/commands/ask/input/index.d.ts +5 -0
  55. package/build/commands/ask/input/index.d.ts.map +1 -0
  56. package/build/commands/ask/input/index.js +4 -0
  57. package/build/commands/ask/input/prompt.d.ts.map +1 -0
  58. package/build/commands/ask/{prompt.js → input/prompt.js} +1 -1
  59. package/build/commands/ask/input/slash.d.ts.map +1 -0
  60. package/build/commands/ask/{slash.js → input/slash.js} +1 -1
  61. package/build/commands/ask/input/typeAhead.d.ts.map +1 -0
  62. package/build/commands/ask/{history.d.ts → persist/history.d.ts} +1 -1
  63. package/build/commands/ask/persist/history.d.ts.map +1 -0
  64. package/build/commands/ask/persist/index.d.ts +4 -0
  65. package/build/commands/ask/persist/index.d.ts.map +1 -0
  66. package/build/commands/ask/persist/index.js +3 -0
  67. package/build/commands/ask/persist/persist.d.ts.map +1 -0
  68. package/build/commands/ask/persist/state.d.ts.map +1 -0
  69. package/build/commands/ask/session/claim.d.ts +56 -0
  70. package/build/commands/ask/session/claim.d.ts.map +1 -0
  71. package/build/commands/ask/session/claim.js +76 -0
  72. package/build/commands/ask/session/index.d.ts +5 -0
  73. package/build/commands/ask/session/index.d.ts.map +1 -0
  74. package/build/commands/ask/session/index.js +4 -0
  75. package/build/commands/ask/session/run.d.ts +36 -0
  76. package/build/commands/ask/session/run.d.ts.map +1 -0
  77. package/build/commands/ask/session/run.js +846 -0
  78. package/build/commands/ask/session/thinking.d.ts.map +1 -0
  79. package/build/commands/ask/session/tree.d.ts +99 -0
  80. package/build/commands/ask/session/tree.d.ts.map +1 -0
  81. package/build/commands/ask/session/tree.js +356 -0
  82. package/package.json +6 -5
  83. package/build/commands/ask/artifacts.d.ts.map +0 -1
  84. package/build/commands/ask/binding.d.ts +0 -13
  85. package/build/commands/ask/binding.d.ts.map +0 -1
  86. package/build/commands/ask/binding.js +0 -19
  87. package/build/commands/ask/claudeConfig.d.ts.map +0 -1
  88. package/build/commands/ask/completer.d.ts.map +0 -1
  89. package/build/commands/ask/history.d.ts.map +0 -1
  90. package/build/commands/ask/localHarness.d.ts +0 -278
  91. package/build/commands/ask/localHarness.d.ts.map +0 -1
  92. package/build/commands/ask/localHarness.js +0 -1300
  93. package/build/commands/ask/messageStream.d.ts +0 -33
  94. package/build/commands/ask/messageStream.d.ts.map +0 -1
  95. package/build/commands/ask/messageStream.js +0 -114
  96. package/build/commands/ask/persist.d.ts.map +0 -1
  97. package/build/commands/ask/pnpmShim.d.ts.map +0 -1
  98. package/build/commands/ask/prompt.d.ts.map +0 -1
  99. package/build/commands/ask/session.d.ts +0 -101
  100. package/build/commands/ask/session.d.ts.map +0 -1
  101. package/build/commands/ask/session.js +0 -1328
  102. package/build/commands/ask/slash.d.ts.map +0 -1
  103. package/build/commands/ask/state.d.ts.map +0 -1
  104. package/build/commands/ask/thinking.d.ts.map +0 -1
  105. package/build/commands/ask/typeAhead.d.ts.map +0 -1
  106. /package/build/commands/ask/{artifacts.d.ts → harness/artifacts.d.ts} +0 -0
  107. /package/build/commands/ask/{artifacts.js → harness/artifacts.js} +0 -0
  108. /package/build/commands/ask/{claudeConfig.d.ts → harness/claudeConfig.d.ts} +0 -0
  109. /package/build/commands/ask/{pnpmShim.d.ts → harness/pnpmShim.d.ts} +0 -0
  110. /package/build/commands/ask/{pnpmShim.js → harness/pnpmShim.js} +0 -0
  111. /package/build/commands/ask/{completer.d.ts → input/completer.d.ts} +0 -0
  112. /package/build/commands/ask/{completer.js → input/completer.js} +0 -0
  113. /package/build/commands/ask/{prompt.d.ts → input/prompt.d.ts} +0 -0
  114. /package/build/commands/ask/{slash.d.ts → input/slash.d.ts} +0 -0
  115. /package/build/commands/ask/{typeAhead.d.ts → input/typeAhead.d.ts} +0 -0
  116. /package/build/commands/ask/{typeAhead.js → input/typeAhead.js} +0 -0
  117. /package/build/commands/ask/{history.js → persist/history.js} +0 -0
  118. /package/build/commands/ask/{persist.d.ts → persist/persist.d.ts} +0 -0
  119. /package/build/commands/ask/{persist.js → persist/persist.js} +0 -0
  120. /package/build/commands/ask/{state.d.ts → persist/state.d.ts} +0 -0
  121. /package/build/commands/ask/{state.js → persist/state.js} +0 -0
  122. /package/build/commands/ask/{thinking.d.ts → session/thinking.d.ts} +0 -0
  123. /package/build/commands/ask/{thinking.js → session/thinking.js} +0 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * What one turn spent upstream, summed over the streams a suspended turn is
3
+ * made of. `costUsd` is Claude Code's own accounting; the API stores it on
4
+ * the message. Credits for the spend are billed on the sandbox proxy from
5
+ * the forwarded Anthropic response.
6
+ */
7
+ export type LocalTurnUsage = {
8
+ costUsd: number;
9
+ totalTokens: number;
10
+ inputTokens: number;
11
+ outputTokens: number;
12
+ cacheReadTokens: number;
13
+ cacheWriteTokens: number;
14
+ reasoningTokens: number;
15
+ };
16
+ /**
17
+ * Text and usage of a turn in progress, owned by the caller rather than by
18
+ * `runPromptTurn`: a cancelled or failed turn still spent those tokens, and
19
+ * they have to reach the API anyway.
20
+ */
21
+ export type LocalTurnAccumulator = {
22
+ chunks: string[];
23
+ usage: LocalTurnUsage;
24
+ };
25
+ /** Exported for tests. */
26
+ export declare function createTurnAccumulator(): LocalTurnAccumulator;
27
+ /**
28
+ * Whether the turn got as far as Anthropic. `costUsd` and `totalTokens` are
29
+ * reported independently by the harness, so either alone means it did.
30
+ */
31
+ export declare function didReachAnthropic(usage: LocalTurnUsage): boolean;
32
+ /**
33
+ * Add one stream's `finish` totals to the turn. `totalUsage` is the AI SDK
34
+ * shape; `costUsd` is what Claude Code reports for the same stream under
35
+ * `harnessMetadata`, and is stored on the ingested message.
36
+ */
37
+ export declare function addTurnUsage(usage: LocalTurnUsage, part: Record<string, unknown>): void;
38
+ /**
39
+ * What Claude Code says the turn cost, off the `finish` part.
40
+ *
41
+ * Two keys, because the value is renamed on its way here: the bridge emits
42
+ * `harnessMetadata`, and `HarnessAgent` republishes the same object as
43
+ * `providerMetadata` on the parts this code actually reads. Looking only for
44
+ * the bridge's name found nothing, so every local turn was ingested at a cost
45
+ * of zero and priced into no credits at all.
46
+ *
47
+ * Exported for tests.
48
+ */
49
+ export declare function readClaudeCodeCostUsd(part: Record<string, unknown>): number | undefined;
50
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/harness/usage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,0BAA0B;AAC1B,wBAAgB,qBAAqB,IAAI,oBAAoB,CAa5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,IAAI,CAmCN;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,GAAG,SAAS,CA0BpB"}
@@ -0,0 +1,87 @@
1
+ /** Exported for tests. */
2
+ export function createTurnAccumulator() {
3
+ return {
4
+ chunks: [],
5
+ usage: {
6
+ costUsd: 0,
7
+ totalTokens: 0,
8
+ inputTokens: 0,
9
+ outputTokens: 0,
10
+ cacheReadTokens: 0,
11
+ cacheWriteTokens: 0,
12
+ reasoningTokens: 0,
13
+ },
14
+ };
15
+ }
16
+ /**
17
+ * Whether the turn got as far as Anthropic. `costUsd` and `totalTokens` are
18
+ * reported independently by the harness, so either alone means it did.
19
+ */
20
+ export function didReachAnthropic(usage) {
21
+ return usage.costUsd > 0 || usage.totalTokens > 0;
22
+ }
23
+ /**
24
+ * Add one stream's `finish` totals to the turn. `totalUsage` is the AI SDK
25
+ * shape; `costUsd` is what Claude Code reports for the same stream under
26
+ * `harnessMetadata`, and is stored on the ingested message.
27
+ */
28
+ export function addTurnUsage(usage, part) {
29
+ const costUsd = readClaudeCodeCostUsd(part);
30
+ if (costUsd !== undefined) {
31
+ usage.costUsd += costUsd;
32
+ }
33
+ const totalUsage = part["totalUsage"];
34
+ if (typeof totalUsage !== "object" || totalUsage === null) {
35
+ return;
36
+ }
37
+ const totals = totalUsage;
38
+ usage.totalTokens += readCount(totals["totalTokens"]);
39
+ usage.inputTokens += readCount(totals["inputTokens"]);
40
+ usage.outputTokens += readCount(totals["outputTokens"]);
41
+ const inputDetails = totals["inputTokenDetails"];
42
+ if (typeof inputDetails === "object" && inputDetails !== null) {
43
+ const details = inputDetails;
44
+ usage.cacheReadTokens += readCount(details["cacheReadTokens"]);
45
+ usage.cacheWriteTokens += readCount(details["cacheWriteTokens"]);
46
+ }
47
+ const outputDetails = totals["outputTokenDetails"];
48
+ if (typeof outputDetails === "object" && outputDetails !== null) {
49
+ const details = outputDetails;
50
+ usage.reasoningTokens += readCount(details["reasoningTokens"]);
51
+ }
52
+ }
53
+ function readCount(value) {
54
+ return typeof value === "number" && Number.isFinite(value) && value > 0
55
+ ? value
56
+ : 0;
57
+ }
58
+ /**
59
+ * What Claude Code says the turn cost, off the `finish` part.
60
+ *
61
+ * Two keys, because the value is renamed on its way here: the bridge emits
62
+ * `harnessMetadata`, and `HarnessAgent` republishes the same object as
63
+ * `providerMetadata` on the parts this code actually reads. Looking only for
64
+ * the bridge's name found nothing, so every local turn was ingested at a cost
65
+ * of zero and priced into no credits at all.
66
+ *
67
+ * Exported for tests.
68
+ */
69
+ export function readClaudeCodeCostUsd(part) {
70
+ for (const key of ["providerMetadata", "harnessMetadata"]) {
71
+ const metadata = part[key];
72
+ if (typeof metadata !== "object" || metadata === null) {
73
+ continue;
74
+ }
75
+ const claudeCode = metadata["claude-code"];
76
+ if (typeof claudeCode !== "object" || claudeCode === null) {
77
+ continue;
78
+ }
79
+ const costUsd = claudeCode["costUsd"];
80
+ if (typeof costUsd === "number" &&
81
+ Number.isFinite(costUsd) &&
82
+ costUsd > 0) {
83
+ return costUsd;
84
+ }
85
+ }
86
+ return undefined;
87
+ }
@@ -1,5 +1,14 @@
1
1
  import type { Command } from "commander";
2
2
  import type { Api } from "../../api.js";
3
+ /**
4
+ * `cargo ask` layout:
5
+ *
6
+ * - `index.ts`, `argvFlags.ts`, `rewriteChatFlag.ts` — command and argv
7
+ * - `session/` — chat loop, tree, turn claim
8
+ * - `input/` — reading the user (prompt, slash, completion, type-ahead)
9
+ * - `persist/` — last chat on disk and history preamble
10
+ * - `harness/` — local Claude Code
11
+ */
3
12
  export type AskOptions = {
4
13
  continue?: boolean;
5
14
  print?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/ask/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOxC,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GAAG,EACjB,IAAI,EAAE,cAAc,GACnB,IAAI,CAwIN"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/ask/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOxC;;;;;;;;GAQG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GAAG,EACjB,IAAI,EAAE,cAAc,GACnB,IAAI,CAwIN"}
@@ -2,17 +2,17 @@ import { resolve } from "node:path";
2
2
  import { isInteractive } from "@cargo-ai/cdk/cli";
3
3
  import { parseBooleanOption } from "../../utils/booleanOption.js";
4
4
  import { ExitCodes, failWith } from "../runHandler.js";
5
- import { loadAskState } from "./persist.js";
6
- import { AskInterrupted } from "./prompt.js";
7
- import { doesChatExist, runAskPrint, runAskSession } from "./session.js";
5
+ import { AskInterrupted } from "./input/index.js";
6
+ import { loadAskState } from "./persist/index.js";
7
+ import { doesChatExist, runAskPrint, runAskSession } from "./session/index.js";
8
8
  export function registerAskCommand(program, getApi, deps) {
9
9
  program
10
10
  .command("ask")
11
- .description("Chat in the palette tree. Defaults to Claude Code on this machine; optional --agent-uuid streams as that agent.")
11
+ .description("Chat in the palette tree. Defaults to Claude Code on this machine; optional --agent-uuid attaches that agent to the same local session.")
12
12
  .argument("[message...]", "Question to send as the first message")
13
13
  .option("--continue [true|false]", "Reopen the last chat from this machine (defaults to true when passed bare; starts a new chat when there is none)", parseBooleanOption)
14
14
  .option("--print [true|false]", "One turn, JSON on stdout (defaults to true when passed bare)", parseBooleanOption)
15
- .option("--agent-uuid <uuid>", "Talk to this workspace agent instead of the local Claude Code default")
15
+ .option("--agent-uuid <uuid>", "Talk to this workspace agent in the local Claude Code session")
16
16
  .option("--chat-uuid <uuid>", "Existing chat to continue")
17
17
  .option("--dir <path>", "Working directory for the local Claude Code workspace (default: cwd)")
18
18
  .addHelpText("after", `
@@ -25,8 +25,8 @@ Examples:
25
25
 
26
26
  Default Ask is Claude Code on this machine (--dir, default cwd), with no
27
27
  agent. --continue reopens the last chat thread but does not reattach an
28
- agent. Workspace agents are optional via --agent-uuid or /agent (remote
29
- turns use POST /v1/ai/messages/stream, like the webapp chat).
28
+ agent. Workspace agents are optional via --agent-uuid or /agent; they stay
29
+ in the same local session and the same --dir.
30
30
 
31
31
  Ask continues the palette tree and streams the reply as it arrives:
32
32
  ◇ your message
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completer.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/input/completer.ts"],"names":[],"mappings":"AAYA,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,oEAOrB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;AAEhE,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAgBhE;AAED,sDAAsD;AACtD,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAU5D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CASnE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAYxE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,GAAG,SAAS,CAY1E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAwE1E"}
@@ -0,0 +1,5 @@
1
+ export { applyCompletion, ASK_COMPLETION_MENU_LIMIT, ASK_SLASH_COMMANDS, type AskCompleter, classifySlashToken, completePath, completeSlash, createAskCompleter, listCompletions, type SlashTokenKind, } from "./completer.js";
2
+ export { AskInterrupted, readAskLine } from "./prompt.js";
3
+ export { ChatSessionAction, parseSlash, type SlashAction, type SlashCard, type SlashResult, } from "./slash.js";
4
+ export { collectTypeAhead, EMPTY_TYPE_AHEAD, type TypeAhead, type TypeAheadCollector, } from "./typeAhead.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,YAAY,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { applyCompletion, ASK_COMPLETION_MENU_LIMIT, ASK_SLASH_COMMANDS, classifySlashToken, completePath, completeSlash, createAskCompleter, listCompletions, } from "./completer.js";
2
+ export { AskInterrupted, readAskLine } from "./prompt.js";
3
+ export { ChatSessionAction, parseSlash, } from "./slash.js";
4
+ export { collectTypeAhead, EMPTY_TYPE_AHEAD, } from "./typeAhead.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/input/prompt.ts"],"names":[],"mappings":";AAiBA;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;;CAKxC;AASD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,CAAC,cAAc,EAC5B,GAAG,EAAE,MAAM;AACX;;;;GAIG;AACH,WAAW,SAAK,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiQ7B"}
@@ -1,5 +1,5 @@
1
1
  import * as readline from "node:readline";
2
- import { colors } from "../runHandler.js";
2
+ import { colors } from "../../runHandler.js";
3
3
  import { applyCompletion, ASK_COMPLETION_MENU_LIMIT, listCompletions, } from "./completer.js";
4
4
  /**
5
5
  * Ctrl-C on the Ask line.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slash.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/input/slash.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAmBlD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAqDhE;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;gBAE3B,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC;CAK1C"}
@@ -5,7 +5,7 @@ const HELP_TEXT = [
5
5
  "/help List these commands",
6
6
  "/clear Start a fresh local session (no agent)",
7
7
  "/new Same as /clear",
8
- "/agent Pick a workspace agent, or Local workspace (default)",
8
+ "/agent Pick a workspace agent, or Local workspace (default). Stays on this machine.",
9
9
  "/cancel Explain how to stop a turn (press Ctrl-C while it runs)",
10
10
  "/exit Leave without asking (same as an empty line)",
11
11
  "",
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeAhead.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/input/typeAhead.ts"],"names":[],"mappings":";AAGA;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAG9B,CAAC;AA4BF,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;;;;;OAUG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,6CAA6C;IAC7C,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,MAAM,CAAC;IACtB,iDAAiD;IACjD,IAAI,EAAE,MAAM,SAAS,CAAC;CACvB,CAAC;AAgBF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,wEAAwE;IACxE,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,kBAAkB,CAqJrB"}
@@ -1,4 +1,4 @@
1
- import type { Api } from "../../api.js";
1
+ import type { Api } from "../../../api.js";
2
2
  /**
3
3
  * The earlier turns of a chat, rendered for a Claude Code session that has
4
4
  * never seen them.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/persist/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AA0B3C;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU9B;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,MAAM,GAAG,SAAS,CA6CpB"}
@@ -0,0 +1,4 @@
1
+ export { loadChatHistoryPreamble, renderHistoryPreamble } from "./history.js";
2
+ export { getAskStatePath, loadAskState, saveAskState } from "./persist.js";
3
+ export { asAskState, ASK_STATE_VERSION, type AskState } from "./state.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/persist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { loadChatHistoryPreamble, renderHistoryPreamble } from "./history.js";
2
+ export { getAskStatePath, loadAskState, saveAskState } from "./persist.js";
3
+ export { asAskState, ASK_STATE_VERSION } from "./state.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/persist/persist.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,YAAY,IAAI,QAAQ,GAAG,SAAS,CAYnD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAUrD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/persist/state.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,OAAO,iBAAiB,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CA0B/D"}
@@ -0,0 +1,56 @@
1
+ import type { Api } from "../../../api.js";
2
+ /**
3
+ * When the proxy token baked into the running harness stops being safe to
4
+ * reuse.
5
+ *
6
+ * The server re-arms the token on every proxy call, so the clock runs from
7
+ * the last turn that reached Anthropic rather than from when it was minted.
8
+ * Anchoring it to mint time instead would tear down a conversation that is
9
+ * still going — a cold start, a replayed history preamble and the loss of
10
+ * Claude Code's in-session memory, for a token that had not expired.
11
+ *
12
+ * Exported for tests.
13
+ */
14
+ export declare function proxyTokenDeadlineMs(input: {
15
+ mintedAtMs: number;
16
+ lastUsedAtMs: number | undefined;
17
+ ttlMs: number;
18
+ }): number;
19
+ /**
20
+ * The result of trying to take the chat for one local turn. `busy` is an
21
+ * answer rather than a failure — another session is mid-turn — so it does not
22
+ * end the session the way a transport error does.
23
+ */
24
+ export type ChatTurnClaim = {
25
+ outcome: "claimed";
26
+ } | {
27
+ outcome: "busy";
28
+ } | {
29
+ outcome: "unavailable";
30
+ error: unknown;
31
+ };
32
+ /**
33
+ * Take the chat for one local turn.
34
+ *
35
+ * Exported for tests.
36
+ */
37
+ export declare function claimChatTurn(api: Api, chatUuid: string, ownerId: string): Promise<ChatTurnClaim>;
38
+ /**
39
+ * Report an API failure the way every other call in the CLI does, and exit.
40
+ * Never returns: `handleApiCall` exits on a recognised API error, and anything
41
+ * else is rethrown for the top-level handler.
42
+ */
43
+ export declare function reportApiFailure(error: unknown): Promise<never>;
44
+ /**
45
+ * Hand the chat back after a turn.
46
+ *
47
+ * Recording the turn already does this, but a turn that spent nothing has
48
+ * nothing to record — a stall, an expired token, a workspace out of credits —
49
+ * and the claim would sit there until it expired, telling the next process the
50
+ * chat was busy.
51
+ *
52
+ * Best effort: the TTL is the backstop, and a reply the user has already read
53
+ * must not fail on the way out.
54
+ */
55
+ export declare function releaseChatTurn(api: Api, chatUuid: string, ownerId: string): Promise<void>;
56
+ //# sourceMappingURL=claim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/session/claim.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAU3C;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,CAKT;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,GACtB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACnB;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/C;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,CAAC,CAkBxB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CASrE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -0,0 +1,76 @@
1
+ import { determineIfIsFetcherError } from "@cargo-ai/api";
2
+ import { handleApiCall } from "../../runHandler.js";
3
+ /**
4
+ * How long before a proxy token's stated expiry to stop trusting it. Covers
5
+ * the gap between deciding to reuse the harness and the first proxy call the
6
+ * turn makes.
7
+ */
8
+ const TOKEN_REFRESH_MARGIN_MS = 5 * 60_000;
9
+ /**
10
+ * When the proxy token baked into the running harness stops being safe to
11
+ * reuse.
12
+ *
13
+ * The server re-arms the token on every proxy call, so the clock runs from
14
+ * the last turn that reached Anthropic rather than from when it was minted.
15
+ * Anchoring it to mint time instead would tear down a conversation that is
16
+ * still going — a cold start, a replayed history preamble and the loss of
17
+ * Claude Code's in-session memory, for a token that had not expired.
18
+ *
19
+ * Exported for tests.
20
+ */
21
+ export function proxyTokenDeadlineMs(input) {
22
+ const armedAtMs = input.lastUsedAtMs === undefined ? input.mintedAtMs : input.lastUsedAtMs;
23
+ return armedAtMs + input.ttlMs - TOKEN_REFRESH_MARGIN_MS;
24
+ }
25
+ /**
26
+ * Take the chat for one local turn.
27
+ *
28
+ * Exported for tests.
29
+ */
30
+ export async function claimChatTurn(api, chatUuid, ownerId) {
31
+ try {
32
+ await api.ai.chat.turn.claim(chatUuid, { ownerId });
33
+ return { outcome: "claimed" };
34
+ }
35
+ catch (error) {
36
+ if (determineIfIsFetcherError(error) === true &&
37
+ error.status === 409) {
38
+ return { outcome: "busy" };
39
+ }
40
+ // Handed back rather than reported from here. Reporting an API failure
41
+ // ends the process, and the interactive session has a Claude Code process
42
+ // to shut down first — `process.exit` does not run the `finally` that
43
+ // would have done it.
44
+ return { outcome: "unavailable", error };
45
+ }
46
+ }
47
+ /**
48
+ * Report an API failure the way every other call in the CLI does, and exit.
49
+ * Never returns: `handleApiCall` exits on a recognised API error, and anything
50
+ * else is rethrown for the top-level handler.
51
+ */
52
+ export async function reportApiFailure(error) {
53
+ await handleApiCall(async () => {
54
+ throw error;
55
+ }, { spinner: false });
56
+ throw error;
57
+ }
58
+ /**
59
+ * Hand the chat back after a turn.
60
+ *
61
+ * Recording the turn already does this, but a turn that spent nothing has
62
+ * nothing to record — a stall, an expired token, a workspace out of credits —
63
+ * and the claim would sit there until it expired, telling the next process the
64
+ * chat was busy.
65
+ *
66
+ * Best effort: the TTL is the backstop, and a reply the user has already read
67
+ * must not fail on the way out.
68
+ */
69
+ export async function releaseChatTurn(api, chatUuid, ownerId) {
70
+ try {
71
+ await api.ai.chat.turn.release(chatUuid, { ownerId });
72
+ }
73
+ catch {
74
+ // Nothing useful to say to the user about this one.
75
+ }
76
+ }
@@ -0,0 +1,5 @@
1
+ export { type ChatTurnClaim, claimChatTurn, proxyTokenDeadlineMs, } from "./claim.js";
2
+ export { type AskSessionOptions, doesChatExist, runAskPrint, runAskSession, } from "./run.js";
3
+ export { ASK_THINKING_WORDS, pickThinkingWord } from "./thinking.js";
4
+ export { displayPath, wrapLine } from "./tree.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,iBAAiB,EACtB,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { claimChatTurn, proxyTokenDeadlineMs, } from "./claim.js";
2
+ export { doesChatExist, runAskPrint, runAskSession, } from "./run.js";
3
+ export { ASK_THINKING_WORDS, pickThinkingWord } from "./thinking.js";
4
+ export { displayPath, wrapLine } from "./tree.js";
@@ -0,0 +1,36 @@
1
+ import type { Api } from "../../../api.js";
2
+ export type AskSessionOptions = {
3
+ api: Api;
4
+ message?: string;
5
+ continueChat: boolean;
6
+ agentUuid?: string;
7
+ chatUuid?: string;
8
+ dir: string;
9
+ };
10
+ /**
11
+ * True when the chat is already on the server. A saved `--continue` uuid can
12
+ * point at nothing (Esc before the first turn, wiped local DB, different API),
13
+ * and that must become a create — not chatNotFound on the first message.
14
+ *
15
+ * Careful with the false case: it means "not readable", which covers a chat
16
+ * that was deleted as well as one that never existed. Deletion is soft, so
17
+ * the row keeps the uuid and creating it again fails on the primary key —
18
+ * see where `--continue` resolves its uuid.
19
+ */
20
+ export declare function doesChatExist(api: Api, chatUuid: string): Promise<boolean>;
21
+ /**
22
+ * Same tree grammar as the palette:
23
+ * ◇ <your message>
24
+ * ■ reply…
25
+ * ◆
26
+ * Empty Enter or /exit leaves to the parent palette.
27
+ */
28
+ export declare function runAskSession(options: AskSessionOptions): Promise<"palette" | "exit">;
29
+ export declare function runAskPrint(input: {
30
+ api: Api;
31
+ message: string;
32
+ agentUuid?: string;
33
+ chatUuid?: string;
34
+ dir: string;
35
+ }): Promise<void>;
36
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../src/commands/ask/session/run.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAoD3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAkHF;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAqBlB;AAyND;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,CAsmB7B;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE;IACvC,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,IAAI,CAAC,CAqGhB"}