@andorra-labs/code 0.1.17 → 0.1.19

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 (313) hide show
  1. package/dist/src/account-jev-savings.d.ts +4 -0
  2. package/dist/src/account-jev-savings.js +92 -0
  3. package/dist/src/acp-agent.js +2 -2
  4. package/dist/src/agent-execution.js +441 -53
  5. package/dist/src/agent-mcp.js +7 -1
  6. package/dist/src/agent-modifiers.js +5 -7
  7. package/dist/src/analytics.d.ts +19 -1
  8. package/dist/src/analytics.js +9 -1
  9. package/dist/src/andorra/entry.js +15 -6
  10. package/dist/src/andorra/errors.js +3 -0
  11. package/dist/src/andorra/hosted.d.ts +8 -0
  12. package/dist/src/andorra/hosted.js +22 -3
  13. package/dist/src/andorra/streams.d.ts +49 -0
  14. package/dist/src/andorra/streams.js +98 -0
  15. package/dist/src/antigravity-acp.d.ts +28 -0
  16. package/dist/src/antigravity-acp.js +150 -0
  17. package/dist/src/antigravity-terminal.d.ts +2 -0
  18. package/dist/src/antigravity-terminal.js +214 -0
  19. package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
  20. package/dist/src/app-server/adaptive-routing-settings.js +69 -0
  21. package/dist/src/app-server/artifact.d.ts +14 -0
  22. package/dist/src/app-server/artifact.js +46 -0
  23. package/dist/src/app-server/legal-protocol.d.ts +33 -0
  24. package/dist/src/app-server/legal-protocol.js +16 -0
  25. package/dist/src/app-server/protocol.d.ts +34 -3
  26. package/dist/src/app-server/protocol.js +3 -1
  27. package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
  28. package/dist/src/app-server/telemetry-protocol.js +2 -0
  29. package/dist/src/app-server/telemetry.d.ts +38 -0
  30. package/dist/src/app-server/telemetry.js +163 -0
  31. package/dist/src/app-server/workspace.d.ts +21 -0
  32. package/dist/src/app-server/workspace.js +192 -10
  33. package/dist/src/app-server.d.ts +82 -26
  34. package/dist/src/app-server.js +1573 -417
  35. package/dist/src/attachments.d.ts +10 -0
  36. package/dist/src/attachments.js +102 -7
  37. package/dist/src/auth/AuthManager.d.ts +11 -2
  38. package/dist/src/auth/AuthManager.js +56 -13
  39. package/dist/src/auth/index.d.ts +5 -1
  40. package/dist/src/auth/index.js +8 -1
  41. package/dist/src/auth/lifecycle.d.ts +13 -0
  42. package/dist/src/auth/lifecycle.js +109 -0
  43. package/dist/src/auth/store.d.ts +1 -0
  44. package/dist/src/auth/store.js +12 -0
  45. package/dist/src/auth/types.d.ts +12 -0
  46. package/dist/src/automation-runner.js +2 -0
  47. package/dist/src/automation-service.js +7 -2
  48. package/dist/src/automation-tool.js +2 -1
  49. package/dist/src/benchmark-scores.d.ts +88 -0
  50. package/dist/src/benchmark-scores.js +302 -0
  51. package/dist/src/bridge/command.js +16 -1
  52. package/dist/src/bridge/control.d.ts +3 -1
  53. package/dist/src/bridge/control.js +9 -3
  54. package/dist/src/bridge/engines.d.ts +2 -0
  55. package/dist/src/bridge/engines.js +9 -0
  56. package/dist/src/bridge/github.d.ts +108 -0
  57. package/dist/src/bridge/github.js +378 -0
  58. package/dist/src/bridge/host-ops.d.ts +3 -3
  59. package/dist/src/bridge/host-ops.js +14 -2
  60. package/dist/src/bridge/host.d.ts +2 -0
  61. package/dist/src/bridge/host.js +70 -16
  62. package/dist/src/bridge/protocol.d.ts +1 -0
  63. package/dist/src/bridge/protocol.js +1 -0
  64. package/dist/src/browser-panel-tool.d.ts +12 -0
  65. package/dist/src/browser-panel-tool.js +30 -3
  66. package/dist/src/browser-runner.js +53 -62
  67. package/dist/src/browser-server.js +10 -4
  68. package/dist/src/browser-session.d.ts +14 -0
  69. package/dist/src/browser-session.js +57 -12
  70. package/dist/src/browser-view.d.ts +40 -1
  71. package/dist/src/browser-view.js +163 -9
  72. package/dist/src/browser-window-style.d.ts +27 -0
  73. package/dist/src/browser-window-style.js +244 -0
  74. package/dist/src/bug-report-attachments.d.ts +48 -0
  75. package/dist/src/bug-report-attachments.js +327 -0
  76. package/dist/src/bug-report.d.ts +23 -3
  77. package/dist/src/bug-report.js +72 -9
  78. package/dist/src/claude-provider.d.ts +1 -0
  79. package/dist/src/claude-provider.js +77 -36
  80. package/dist/src/cli.d.ts +1 -3
  81. package/dist/src/cli.js +245 -62
  82. package/dist/src/codex-provider.d.ts +1 -0
  83. package/dist/src/codex-provider.js +44 -8
  84. package/dist/src/coding-tools.d.ts +1 -0
  85. package/dist/src/coding-tools.js +28 -7
  86. package/dist/src/command-screens.d.ts +1 -1
  87. package/dist/src/command-screens.js +2 -2
  88. package/dist/src/commands.d.ts +9 -2
  89. package/dist/src/commands.js +69 -64
  90. package/dist/src/completion.js +13 -7
  91. package/dist/src/config.d.ts +14 -3
  92. package/dist/src/config.js +57 -17
  93. package/dist/src/context-budget.d.ts +11 -2
  94. package/dist/src/context-budget.js +38 -4
  95. package/dist/src/context-compaction.d.ts +10 -8
  96. package/dist/src/context-compaction.js +23 -24
  97. package/dist/src/deadline.js +1 -1
  98. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  99. package/dist/src/decision/DecisionManager.d.ts +16 -0
  100. package/dist/src/decision/DecisionManager.js +75 -2
  101. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  102. package/dist/src/decision/applyTaskKind.js +53 -0
  103. package/dist/src/decision/applyToolMenu.js +6 -2
  104. package/dist/src/decision/hostedPolicy.js +6 -3
  105. package/dist/src/decision/optimizationPolicy.d.ts +10 -0
  106. package/dist/src/decision/optimizationPolicy.js +23 -3
  107. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
  108. package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
  109. package/dist/src/decision/providers/index.js +1 -1
  110. package/dist/src/decision/taskKind.d.ts +52 -0
  111. package/dist/src/decision/taskKind.js +76 -0
  112. package/dist/src/decision/toolFamilies.js +1 -1
  113. package/dist/src/decision/types.d.ts +3 -1
  114. package/dist/src/default-graph.js +1 -1
  115. package/dist/src/efficiency.d.ts +80 -1
  116. package/dist/src/efficiency.js +119 -4
  117. package/dist/src/effort-routing.d.ts +27 -0
  118. package/dist/src/effort-routing.js +34 -0
  119. package/dist/src/evidence.d.ts +110 -0
  120. package/dist/src/evidence.js +195 -0
  121. package/dist/src/extensions.d.ts +2 -0
  122. package/dist/src/extensions.js +30 -20
  123. package/dist/src/github-app/agent-writes.d.ts +1 -1
  124. package/dist/src/github-app/agent-writes.js +1 -1
  125. package/dist/src/github-app/client.d.ts +19 -0
  126. package/dist/src/github-app/client.js +21 -1
  127. package/dist/src/github-app/event-source.d.ts +0 -5
  128. package/dist/src/github-app/event-source.js +1 -31
  129. package/dist/src/github-app/metrics.d.ts +2 -5
  130. package/dist/src/github-app/metrics.js +2 -14
  131. package/dist/src/github-app/review-loop.d.ts +5 -5
  132. package/dist/src/github-app/review-loop.js +1 -1
  133. package/dist/src/github-app/review-node.d.ts +2 -2
  134. package/dist/src/github-app/triggers.d.ts +3 -3
  135. package/dist/src/github-names.d.ts +7 -0
  136. package/dist/src/github-names.js +7 -0
  137. package/dist/src/glob-search.d.ts +1 -0
  138. package/dist/src/glob-search.js +3 -0
  139. package/dist/src/google-provider.d.ts +5 -28
  140. package/dist/src/google-provider.js +6 -141
  141. package/dist/src/graph-editor-session.d.ts +1 -0
  142. package/dist/src/graph-editor-session.js +2 -0
  143. package/dist/src/graph-health.js +3 -1
  144. package/dist/src/graph-preview.d.ts +2 -0
  145. package/dist/src/graph-preview.js +1 -0
  146. package/dist/src/graph-runner.js +20 -14
  147. package/dist/src/graph-selection.d.ts +3 -1
  148. package/dist/src/graph-selection.js +2 -2
  149. package/dist/src/graph-server.d.ts +8 -1
  150. package/dist/src/graph-server.js +49 -12
  151. package/dist/src/graph-sync.d.ts +2 -1
  152. package/dist/src/graph-sync.js +13 -0
  153. package/dist/src/graph-ui/app.js +49 -8
  154. package/dist/src/graph-ui/index.html +1 -1
  155. package/dist/src/graphs.d.ts +23 -1
  156. package/dist/src/graphs.js +58 -7
  157. package/dist/src/grok-provider.js +17 -14
  158. package/dist/src/hardened-runtime.js +39 -25
  159. package/dist/src/jev-savings.d.ts +4 -0
  160. package/dist/src/jev-savings.js +13 -0
  161. package/dist/src/legal/client.d.ts +25 -0
  162. package/dist/src/legal/client.js +47 -0
  163. package/dist/src/legal/command.d.ts +13 -0
  164. package/dist/src/legal/command.js +98 -0
  165. package/dist/src/legal/documents.d.ts +2 -0
  166. package/dist/src/legal/documents.js +14 -0
  167. package/dist/src/legal/gate.d.ts +13 -0
  168. package/dist/src/legal/gate.js +96 -0
  169. package/dist/src/legal/manifest.d.ts +21 -0
  170. package/dist/src/legal/manifest.js +23 -0
  171. package/dist/src/legal/receipt.d.ts +13 -0
  172. package/dist/src/legal/receipt.js +137 -0
  173. package/dist/src/legal/release.d.ts +27 -0
  174. package/dist/src/legal/release.js +28 -0
  175. package/dist/src/managed-sign-in.d.ts +0 -1
  176. package/dist/src/managed-sign-in.js +0 -13
  177. package/dist/src/membership.d.ts +27 -1
  178. package/dist/src/membership.js +139 -7
  179. package/dist/src/model-health-cache.js +1 -1
  180. package/dist/src/model-metadata.js +3 -7
  181. package/dist/src/model-override.d.ts +2 -1
  182. package/dist/src/model-override.js +9 -0
  183. package/dist/src/model-pool.d.ts +99 -0
  184. package/dist/src/model-pool.js +136 -0
  185. package/dist/src/model-relay/local.js +5 -0
  186. package/dist/src/model-relay/remote.d.ts +2 -0
  187. package/dist/src/model-relay/remote.js +4 -0
  188. package/dist/src/model-tiers.d.ts +16 -1
  189. package/dist/src/model-tiers.js +31 -7
  190. package/dist/src/opencode-cli-provider.js +59 -56
  191. package/dist/src/opencode-provider.js +16 -13
  192. package/dist/src/permissions.d.ts +5 -0
  193. package/dist/src/permissions.js +7 -0
  194. package/dist/src/plan-pass.js +2 -1
  195. package/dist/src/pool-scores.d.ts +45 -0
  196. package/dist/src/pool-scores.js +40 -0
  197. package/dist/src/provider-connection.js +3 -17
  198. package/dist/src/provider-engine.d.ts +13 -1
  199. package/dist/src/provider-engine.js +116 -12
  200. package/dist/src/provider-request-error.d.ts +8 -0
  201. package/dist/src/provider-request-error.js +12 -0
  202. package/dist/src/provider-settings.d.ts +1 -1
  203. package/dist/src/provider-settings.js +36 -18
  204. package/dist/src/provider-turn-deadline.d.ts +39 -0
  205. package/dist/src/provider-turn-deadline.js +139 -0
  206. package/dist/src/providers.d.ts +8 -9
  207. package/dist/src/providers.js +211 -150
  208. package/dist/src/pull-request-merge.d.ts +1 -8
  209. package/dist/src/pull-request-merge.js +0 -4
  210. package/dist/src/pull-requests.d.ts +83 -57
  211. package/dist/src/pull-requests.js +266 -225
  212. package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
  213. package/dist/src/qa/runtime/ProcessManager.js +9 -3
  214. package/dist/src/react-runtime.js +245 -71
  215. package/dist/src/reasoning-probe-cloud.d.ts +10 -0
  216. package/dist/src/reasoning-probe-cloud.js +209 -0
  217. package/dist/src/remote/engine-pool.d.ts +3 -0
  218. package/dist/src/remote/engine-pool.js +88 -21
  219. package/dist/src/remote/recovery.d.ts +6 -0
  220. package/dist/src/remote/recovery.js +37 -0
  221. package/dist/src/run-records.d.ts +13 -3
  222. package/dist/src/run-records.js +59 -34
  223. package/dist/src/runtime.d.ts +47 -2
  224. package/dist/src/runtime.js +33 -7
  225. package/dist/src/session-summary.d.ts +8 -0
  226. package/dist/src/session-summary.js +34 -0
  227. package/dist/src/sessions.d.ts +32 -0
  228. package/dist/src/sessions.js +65 -3
  229. package/dist/src/shell.js +6 -0
  230. package/dist/src/side-panel.js +36 -2
  231. package/dist/src/sign-in-detection.d.ts +1 -1
  232. package/dist/src/sign-in-detection.js +4 -10
  233. package/dist/src/sign-in-offer.js +1 -1
  234. package/dist/src/skill-commands.js +1 -1
  235. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  236. package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
  237. package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
  238. package/dist/src/skills/bundled/provenance.json +3 -3
  239. package/dist/src/subagent-run.js +50 -50
  240. package/dist/src/subscription-usage.d.ts +50 -0
  241. package/dist/src/subscription-usage.js +92 -0
  242. package/dist/src/task-checkout.d.ts +157 -0
  243. package/dist/src/task-checkout.js +628 -0
  244. package/dist/src/telemetry/access.d.ts +18 -0
  245. package/dist/src/telemetry/access.js +43 -0
  246. package/dist/src/telemetry/aggregate.d.ts +18 -2
  247. package/dist/src/telemetry/aggregate.js +22 -9
  248. package/dist/src/telemetry/capture-core.d.ts +33 -14
  249. package/dist/src/telemetry/capture-core.js +124 -25
  250. package/dist/src/telemetry/capture.d.ts +3 -2
  251. package/dist/src/telemetry/capture.js +21 -1
  252. package/dist/src/telemetry/decision-capture.js +4 -0
  253. package/dist/src/telemetry/emitter.d.ts +6 -7
  254. package/dist/src/telemetry/emitter.js +124 -29
  255. package/dist/src/telemetry/gate.d.ts +41 -2
  256. package/dist/src/telemetry/gate.js +89 -4
  257. package/dist/src/telemetry/home.d.ts +1 -0
  258. package/dist/src/telemetry/home.js +20 -0
  259. package/dist/src/telemetry/identity.d.ts +6 -3
  260. package/dist/src/telemetry/identity.js +19 -6
  261. package/dist/src/telemetry/lifecycle.d.ts +8 -0
  262. package/dist/src/telemetry/lifecycle.js +76 -0
  263. package/dist/src/telemetry/outbox.d.ts +13 -8
  264. package/dist/src/telemetry/outbox.js +68 -12
  265. package/dist/src/telemetry/permission-command.d.ts +38 -0
  266. package/dist/src/telemetry/permission-command.js +208 -0
  267. package/dist/src/telemetry/permission.d.ts +168 -0
  268. package/dist/src/telemetry/permission.js +662 -0
  269. package/dist/src/telemetry/record-installation.d.ts +1 -0
  270. package/dist/src/telemetry/record-installation.js +9 -0
  271. package/dist/src/telemetry/region-data.d.ts +12 -0
  272. package/dist/src/telemetry/region-data.js +1314 -0
  273. package/dist/src/telemetry/region.d.ts +34 -0
  274. package/dist/src/telemetry/region.js +87 -0
  275. package/dist/src/telemetry/run-privacy.d.ts +11 -0
  276. package/dist/src/telemetry/run-privacy.js +165 -0
  277. package/dist/src/telemetry/schema.d.ts +27 -6
  278. package/dist/src/telemetry/schema.js +109 -14
  279. package/dist/src/telemetry/state.d.ts +11 -7
  280. package/dist/src/telemetry/state.js +39 -6
  281. package/dist/src/telemetry/surface.d.ts +20 -3
  282. package/dist/src/telemetry/surface.js +71 -15
  283. package/dist/src/telemetry/uploader.d.ts +6 -11
  284. package/dist/src/telemetry/uploader.js +72 -46
  285. package/dist/src/telemetry/uploads.d.ts +5 -1
  286. package/dist/src/telemetry/uploads.js +25 -6
  287. package/dist/src/telemetry/version.d.ts +5 -0
  288. package/dist/src/telemetry/version.js +34 -0
  289. package/dist/src/telemetry/workspace.d.ts +4 -1
  290. package/dist/src/telemetry/workspace.js +18 -3
  291. package/dist/src/terminal-ui.d.ts +3 -0
  292. package/dist/src/terminal-ui.js +48 -6
  293. package/dist/src/test-edit-guard.d.ts +30 -0
  294. package/dist/src/test-edit-guard.js +167 -2
  295. package/dist/src/thinking-level-detect.d.ts +13 -0
  296. package/dist/src/thinking-level-detect.js +52 -0
  297. package/dist/src/thinking-levels.d.ts +30 -0
  298. package/dist/src/thinking-levels.js +131 -0
  299. package/dist/src/timers.d.ts +3 -0
  300. package/dist/src/todos.d.ts +2 -1
  301. package/dist/src/todos.js +24 -4
  302. package/dist/src/tool-argument-coercion.d.ts +7 -0
  303. package/dist/src/tool-argument-coercion.js +49 -0
  304. package/dist/src/tool-catalog.d.ts +2 -2
  305. package/dist/src/tool-catalog.js +1 -1
  306. package/dist/src/tools.js +67 -22
  307. package/dist/src/transcript.js +3 -2
  308. package/dist/src/types.d.ts +48 -1
  309. package/dist/src/update.js +4 -0
  310. package/dist/src/usage-analytics.d.ts +7 -0
  311. package/dist/src/usage-analytics.js +85 -13
  312. package/dist/telemetry-consent-v1 +1 -0
  313. package/package.json +97 -96
@@ -0,0 +1,327 @@
1
+ import { createReadStream } from 'node:fs';
2
+ import { readFile, readdir, stat } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { createInterface } from 'node:readline';
5
+ import { redactSecrets } from './memory/redaction.js';
6
+ import { hiddenSession, validSavedSession } from './sessions.js';
7
+ /** Byte limits the service enforces on the two attachments (infra/andorra-auth/bug_report.py). */
8
+ export const GRAPH_LIMIT = 8000;
9
+ export const TRAJECTORY_LIMIT = 12000;
10
+ const ID = /^[A-Za-z0-9_-]{1,64}$/;
11
+ const CONTROL = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F­؜​-‏‪-‮⁠-⁤⁦--]/g;
12
+ const fields = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : {};
13
+ const word = (value) => typeof value === 'string' && value.trim() ? value.trim() : undefined;
14
+ /** One line of attachment text: no line breaks or control characters, no credential, at most `limit` characters. */
15
+ function clip(value, limit) {
16
+ if (typeof value !== 'string')
17
+ return '';
18
+ const text = redactSecrets(value.replace(/\s+/g, ' ').replace(CONTROL, '').trim()).text;
19
+ return text.length <= limit ? text : `${text.slice(0, limit)}… [${text.length - limit} more characters]`;
20
+ }
21
+ /** Fit whole lines into a byte limit: the start and the end are kept, since the end is where a run went wrong. */
22
+ function fit(lines, limit) {
23
+ const size = (text) => Buffer.byteLength(text, 'utf8');
24
+ // A single line longer than the limit cannot be kept whole; every line here is already clipped far below it.
25
+ const kept = lines.filter(line => size(line) < limit / 4);
26
+ if (size(kept.join('\n')) <= limit)
27
+ return kept.join('\n');
28
+ const marker = (count) => `… ${count} lines left out to fit the limit …`;
29
+ const budget = limit - size(marker(kept.length)) - 2;
30
+ const head = [];
31
+ const tail = [];
32
+ let used = 0;
33
+ let first = 0;
34
+ let last = kept.length - 1;
35
+ while (first <= last && used + size(kept[first]) + 1 <= budget * 0.25) {
36
+ used += size(kept[first]) + 1;
37
+ head.push(kept[first++]);
38
+ }
39
+ while (last >= first && used + size(kept[last]) + 1 <= budget) {
40
+ used += size(kept[last]) + 1;
41
+ tail.unshift(kept[last--]);
42
+ }
43
+ return [...head, marker(last - first + 1), ...tail].join('\n');
44
+ }
45
+ /**
46
+ * The sessions a report can be about: the newest saved ones, with the one this run belongs to first. Only the
47
+ * newest files are opened, so a home with thousands of sessions costs a directory listing and a few reads.
48
+ */
49
+ export async function listReportSessions(home, currentId, limit = 8) {
50
+ const directory = join(home, 'sessions');
51
+ let names;
52
+ try {
53
+ names = (await readdir(directory)).filter(name => name.endsWith('.json') && ID.test(name.slice(0, -5)));
54
+ }
55
+ catch {
56
+ return [];
57
+ }
58
+ const dated = (await Promise.all(names.map(async (name) => {
59
+ try {
60
+ return { name, modified: (await stat(join(directory, name))).mtimeMs };
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ }))).filter((entry) => !!entry).sort((a, b) => b.modified - a.modified);
66
+ const wanted = currentId && ID.test(currentId) ? `${currentId}.json` : undefined;
67
+ const order = [...(wanted && dated.some(entry => entry.name === wanted) ? [wanted] : []), ...dated.map(entry => entry.name).filter(name => name !== wanted)];
68
+ const sessions = [];
69
+ for (const name of order) {
70
+ if (sessions.length >= limit)
71
+ break;
72
+ try {
73
+ const value = JSON.parse(await readFile(join(directory, name), 'utf8'));
74
+ if (!validSavedSession(value) || `${value.id}.json` !== name || hiddenSession(value))
75
+ continue;
76
+ sessions.push({ id: value.id, name: clip(value.name, 80) || 'Untitled', updatedAt: value.updatedAt, ...(name === wanted ? { current: true } : {}) });
77
+ }
78
+ catch { }
79
+ }
80
+ return sessions;
81
+ }
82
+ /**
83
+ * A graph as one line per node and edge. Settings are listed; the text of an instruction, prompt or command is
84
+ * replaced by its length, because a bug in routing or tools is visible without the user's wording.
85
+ */
86
+ export function graphOutline(value) {
87
+ const graph = fields(value);
88
+ const nodes = Object.values(fields(graph.nodes)).map(fields).filter(node => word(node.id));
89
+ if (!word(graph.id) || !nodes.length)
90
+ return undefined;
91
+ const lines = [`graph "${clip(graph.name, 80)}" (${clip(graph.id, 80)}) revision ${Number(graph.revision) || 0}, schema ${Number(graph.schemaVersion) || 0}, entry ${clip(graph.entry, 64)}`];
92
+ const limits = Object.entries(fields(graph.limits)).filter(([, amount]) => typeof amount === 'number').map(([name, amount]) => `${name}=${amount}`);
93
+ if (limits.length)
94
+ lines.push(`limits ${limits.join(' ')}`);
95
+ for (const node of nodes) {
96
+ const parts = [`node ${clip(node.id, 64)} "${clip(node.name, 60)}" ${clip(node.type, 16)}`];
97
+ for (const name of ['agentRole', 'executor', 'provider', 'model', 'maxIterations', 'maxSubagents', 'jevEnabled']) {
98
+ const setting = node[name];
99
+ if (typeof setting === 'string' || typeof setting === 'number' || typeof setting === 'boolean')
100
+ parts.push(`${name}=${clip(String(setting), 80)}`);
101
+ }
102
+ for (const name of ['instruction', 'systemPrompt', 'prompt']) {
103
+ if (typeof node[name] === 'string' && node[name])
104
+ parts.push(`${name}=[${node[name].length} characters]`);
105
+ }
106
+ if (Array.isArray(node.tools))
107
+ parts.push(`tools=${node.tools.filter(tool => typeof tool === 'string').map(tool => clip(tool, 48)).join(',') || 'none'}`);
108
+ const capabilities = Object.entries(fields(node.capabilities)).filter(([, level]) => typeof level === 'string').map(([name, level]) => `${name}:${clip(level, 24)}`);
109
+ if (capabilities.length)
110
+ parts.push(`capabilities=${capabilities.join(',')}`);
111
+ const completion = fields(node.completion);
112
+ if (completion.mode === 'single')
113
+ parts.push(`completion=single[${clip(completion.outcome, 48)}]`);
114
+ else if (Array.isArray(completion.outcomes))
115
+ parts.push(`completion=outcomes[${completion.outcomes.map(outcome => clip(outcome, 48)).join(',')}]`);
116
+ const nodeLimits = Object.entries(fields(node.limits)).filter(([, amount]) => typeof amount === 'number').map(([name, amount]) => `${name}=${amount}`);
117
+ if (nodeLimits.length)
118
+ parts.push(`limits=${nodeLimits.join(',')}`);
119
+ const retry = fields(node.retry);
120
+ if (typeof retry.maxAttempts === 'number')
121
+ parts.push(`retry=${retry.maxAttempts}${fields(retry.fallback).provider ? '+fallback' : ''}`);
122
+ const roles = fields(node.subagents).roles;
123
+ if (Array.isArray(roles))
124
+ parts.push(`subagentRoles=${roles.length}`);
125
+ if (fields(node.join).mode)
126
+ parts.push(`join=${clip(fields(node.join).mode, 8)}`);
127
+ if (typeof fields(node.loop).maxIterations === 'number')
128
+ parts.push(`loop=${fields(node.loop).maxIterations}`);
129
+ if (word(fields(node.condition).source))
130
+ parts.push(`condition=${clip(fields(node.condition).source, 64)}.${clip(fields(node.condition).path, 64)}`);
131
+ const action = fields(node.action);
132
+ if (word(action.kind))
133
+ parts.push(`action=${clip(action.kind, 16)}[${typeof action.command === 'string' ? action.command.length : 0} characters]`);
134
+ if (typeof fields(node.review).rounds === 'number')
135
+ parts.push(`review=${fields(node.review).rounds} rounds`);
136
+ lines.push(parts.join(' '));
137
+ }
138
+ for (const edge of Array.isArray(graph.edges) ? graph.edges.map(fields) : []) {
139
+ if (!word(edge.source) || !word(edge.target))
140
+ continue;
141
+ lines.push(`edge ${clip(edge.source, 64)} -> ${clip(edge.target, 64)}${word(edge.outcome) ? ` [${clip(edge.outcome, 48)}]` : ''}${word(edge.toInput) ? ` as ${clip(edge.toInput, 48)}` : ''}`);
142
+ }
143
+ return fit(lines, GRAPH_LIMIT);
144
+ }
145
+ const seconds = (ms) => typeof ms === 'number' && Number.isFinite(ms) ? `${(ms / 1000).toFixed(1)}s` : '';
146
+ const count = (value) => {
147
+ const amount = typeof value === 'number' && Number.isFinite(value) ? value : 0;
148
+ return amount >= 1e6 ? `${(amount / 1e6).toFixed(1)}M` : amount >= 1e3 ? `${Math.round(amount / 1e3)}k` : String(amount);
149
+ };
150
+ /**
151
+ * Reads a session's trajectory into the two attachments: the graph of the last run it reports, and each run as a short
152
+ * list of steps (nodes, tools, retries, refusals, how it stopped). It never copies a prompt, a model reply, tool
153
+ * arguments or a successful tool's output; a failed step keeps the first 200 characters of its error.
154
+ */
155
+ export class TrajectoryDigest {
156
+ runs = [];
157
+ /** One line of the trajectory file. Model requests and replies are the bulk of the file and are skipped unparsed. */
158
+ add(line) {
159
+ if (!line || line.startsWith('{"type":"model.'))
160
+ return;
161
+ let record;
162
+ try {
163
+ record = fields(JSON.parse(line));
164
+ }
165
+ catch {
166
+ return;
167
+ }
168
+ const time = Date.parse(String(record.time ?? ''));
169
+ if (record.type === 'run.started') {
170
+ const run = this.run(word(record.runId), time);
171
+ const graph = typeof record.graph === 'string' ? record.graph : fields(record.graph).id;
172
+ run.lines.push(`run started ${Number.isFinite(time) ? new Date(time).toISOString() : ''} graph=${clip(graph, 80) || 'default'} model=${clip(record.provider, 48)}/${clip(record.model, 64)}`.replace(/\s+/g, ' '));
173
+ }
174
+ else if (record.type === 'run.finished') {
175
+ const run = this.run(word(record.runId), time);
176
+ this.flush(run);
177
+ const usage = fields(record.usage);
178
+ // A run that fails before its graph starts (a model check, a graph that does not load) leaves its reason only here.
179
+ const error = clip(record.error, 200);
180
+ run.lines.push(`${this.at(run, time)} run finished: ${clip(record.status, 32)} · ${count(usage.requests)} requests, ${count(record.toolCalls)} tool calls, ${count(usage.inputTokens)} in / ${count(usage.outputTokens)} out${error ? ` — ${error}` : ''}`);
181
+ run.finished = true;
182
+ }
183
+ else if (record.type === 'runtime.event') {
184
+ const event = fields(record.event);
185
+ this.event(String(event.type ?? ''), fields(event.data), Date.parse(String(event.time ?? record.time ?? '')));
186
+ }
187
+ }
188
+ run(id, time) {
189
+ const found = id ? this.runs.find(run => run.id === id) : this.runs.at(-1);
190
+ if (found) {
191
+ if (found.started === undefined && Number.isFinite(time))
192
+ found.started = time;
193
+ return found;
194
+ }
195
+ const run = { id: id ?? `run-${this.runs.length + 1}`, ...(Number.isFinite(time) ? { started: time } : {}), finished: false, lines: [] };
196
+ this.runs.push(run);
197
+ return run;
198
+ }
199
+ at(run, time) {
200
+ if (run.started === undefined || !Number.isFinite(time))
201
+ return '+??:??';
202
+ const elapsed = Math.max(0, Math.round((time - run.started) / 1000));
203
+ return `+${String(Math.floor(elapsed / 60)).padStart(2, '0')}:${String(elapsed % 60).padStart(2, '0')}`;
204
+ }
205
+ flush(run) {
206
+ const tool = run.tool;
207
+ if (!tool)
208
+ return;
209
+ run.tool = undefined;
210
+ run.lines.push(`${tool.at} ${tool.node ? `[${tool.node}] ` : ''}${tool.name}${tool.count > 1 ? ` ×${tool.count}` : ''} ok ${seconds(tool.ms)}`.trimEnd());
211
+ }
212
+ event(type, data, time) {
213
+ if (!type)
214
+ return;
215
+ // Kept with its run: the graph of the run that is reporting the bug must not stand in for the one that had it.
216
+ if (type === 'graph.started') {
217
+ if (word(fields(data.graph).id))
218
+ this.run(word(data.runId), time).graph = data.graph;
219
+ return;
220
+ }
221
+ const quiet = type === 'node.tool.completed';
222
+ const telling = quiet || /^(?:graph\.(?:node\.(?:started|completed)|edge\.activated|stopped)|node\.tool\.failed|agent\.(?:model\.retry|completion\.(?:rejected|coerced)|turn\.continued|clarification\.requested))$/.test(type) || /(?:error|\.failed)$/.test(type);
223
+ if (!telling)
224
+ return;
225
+ const run = this.run(word(data.runId), time);
226
+ const at = this.at(run, time);
227
+ const node = clip(data.nodeName ?? data.nodeId, 48);
228
+ const name = clip(data.name, 64);
229
+ if (quiet) {
230
+ const ms = typeof data.durationMs === 'number' ? data.durationMs : 0;
231
+ if (run.tool && run.tool.name === name && run.tool.node === node) {
232
+ run.tool.count++;
233
+ run.tool.ms += ms;
234
+ }
235
+ else {
236
+ this.flush(run);
237
+ run.tool = { name, node, count: 1, ms, at };
238
+ }
239
+ return;
240
+ }
241
+ this.flush(run);
242
+ const where = node ? `[${node}] ` : '';
243
+ const line = (text) => run.lines.push(`${at} ${text}`.trimEnd());
244
+ switch (type) {
245
+ case 'graph.node.started':
246
+ line(`node ${node} (${clip(data.nodeType, 16)}) started, visit ${Number(data.visit) || 1}${word(data.model) ? `, model=${clip(data.provider, 48)}/${clip(data.model, 64)}` : ''}`);
247
+ break;
248
+ case 'graph.node.completed':
249
+ line(`node ${node} completed${word(fields(data.completion).outcome) ? `: ${clip(fields(data.completion).outcome, 48)}` : ''}`);
250
+ break;
251
+ case 'graph.edge.activated':
252
+ line(`edge ${clip(data.source, 64)} -> ${clip(data.target, 64)}${word(data.outcome) ? ` [${clip(data.outcome, 48)}]` : ''}`);
253
+ break;
254
+ case 'graph.stopped':
255
+ line(`${where}graph stopped: ${clip(data.status, 32)}${word(data.reason) ? `, ${clip(data.reason, 64)}` : ''}${word(data.reasonText) ? ` — ${clip(data.reasonText, 200)}` : ''}`);
256
+ break;
257
+ case 'node.tool.failed':
258
+ line(`${where}${name} failed ${seconds(data.durationMs)}: ${clip(data.output, 200)}`.replace(/\s+/g, ' '));
259
+ break;
260
+ case 'agent.model.retry':
261
+ line(`${where}model retry ${Number(data.retry) || 0}/${Number(data.maxRetries) || 0}: ${clip(data.reason, 200)}`);
262
+ break;
263
+ case 'agent.completion.rejected':
264
+ line(`${where}completion rejected: ${clip(data.reason, 200)}`);
265
+ break;
266
+ case 'agent.completion.coerced':
267
+ line(`${where}completion coerced`);
268
+ break;
269
+ case 'agent.turn.continued':
270
+ line(`${where}turn continued: ${clip(data.reason, 80)}`);
271
+ break;
272
+ case 'agent.clarification.requested':
273
+ line(`${where}asked the user a question`);
274
+ break;
275
+ default: line(`${where}${clip(type, 64)}: ${clip(data.message ?? data.reason ?? data.error ?? data.detail, 200)}`);
276
+ }
277
+ }
278
+ /** `skipOpenRun` leaves out a last run that has not finished: in the reporting session, that run is the report itself. */
279
+ result(options = {}) {
280
+ const runs = options.skipOpenRun && this.runs.at(-1)?.finished === false ? this.runs.slice(0, -1) : this.runs;
281
+ const lines = [];
282
+ runs.forEach((run, index) => {
283
+ this.flush(run);
284
+ if (!run.lines.length)
285
+ return;
286
+ if (!run.lines[0].startsWith('run started'))
287
+ lines.push(`run ${index + 1}`);
288
+ lines.push(...run.lines.map((line, at) => at === 0 && line.startsWith('run started') ? `run ${index + 1}: ${line.slice(4)}` : ` ${line}`));
289
+ });
290
+ const graph = graphOutline(runs.findLast(run => run.graph !== undefined)?.graph);
291
+ return { ...(graph ? { graph } : {}), ...(lines.length ? { trajectory: fit(lines, TRAJECTORY_LIMIT) } : {}) };
292
+ }
293
+ }
294
+ /** Whether this machine has a saved session or a trajectory under that id. */
295
+ export async function sessionExists(home, sessionId) {
296
+ if (!ID.test(sessionId))
297
+ return false;
298
+ const present = (path) => stat(path).then(entry => entry.isFile(), () => false);
299
+ return await present(join(home, 'sessions', `${sessionId}.json`)) || await present(join(home, 'trajectories', `${sessionId}.jsonl`));
300
+ }
301
+ /** The graph and compressed trajectory of one saved session, or nothing when the session left no trajectory. */
302
+ export async function sessionAttachments(home, sessionId, options = {}) {
303
+ if (!ID.test(sessionId))
304
+ return {};
305
+ let trajectoryId = sessionId;
306
+ try {
307
+ const saved = JSON.parse(await readFile(join(home, 'sessions', `${sessionId}.json`), 'utf8'));
308
+ if (validSavedSession(saved) && saved.id === sessionId && saved.trajectoryId && ID.test(saved.trajectoryId))
309
+ trajectoryId = saved.trajectoryId;
310
+ }
311
+ catch { }
312
+ const digest = new TrajectoryDigest();
313
+ const stream = createReadStream(join(home, 'trajectories', `${trajectoryId}.jsonl`), { encoding: 'utf8', ...(options.signal ? { signal: options.signal } : {}) });
314
+ try {
315
+ for await (const line of createInterface({ input: stream, crlfDelay: Infinity }))
316
+ digest.add(line);
317
+ }
318
+ catch (error) {
319
+ options.signal?.throwIfAborted();
320
+ if (error.code !== 'ENOENT')
321
+ throw error;
322
+ }
323
+ finally {
324
+ stream.destroy();
325
+ }
326
+ return digest.result({ skipOpenRun: options.current === true });
327
+ }
@@ -1,7 +1,13 @@
1
+ import { sessionAttachments, type SessionAttachments } from './bug-report-attachments.js';
1
2
  import type { Tool } from './types.js';
2
3
  /** The built-in skill that interviews the user; a run that carries it also gets the tool below. */
3
4
  export declare const BUG_REPORT_SKILL = "andorra:bug-report";
4
5
  export declare const BUG_REPORT_TOOL = "submit_bug_report";
6
+ /** Tells the interview which session this conversation is and which others exist, so it can ask where the bug was. */
7
+ export declare const BUG_REPORT_SESSIONS_TOOL = "list_bug_report_sessions";
8
+ /** The two `session` answers that are not a session id. */
9
+ export declare const CURRENT_SESSION = "current";
10
+ export declare const NO_SESSION = "none";
5
11
  export declare const SEND_CHOICE = "Send report";
6
12
  export declare const CANCEL_CHOICE = "Do not send";
7
13
  /** The report's text fields with the byte limits the service enforces (infra/andorra-auth/bug_report.py). */
@@ -32,10 +38,11 @@ declare const FIELDS: readonly [{
32
38
  readonly heading: "Actual";
33
39
  }];
34
40
  type FieldName = typeof FIELDS[number]['name'];
41
+ /** `graph` and `trajectory` are read from the session the user named; the model never writes them. */
35
42
  export type BugReport = {
36
43
  title: string;
37
44
  description: string;
38
- } & Partial<Record<Exclude<FieldName, 'title' | 'description'>, string>>;
45
+ } & Partial<Record<Exclude<FieldName, 'title' | 'description'>, string>> & SessionAttachments;
39
46
  export interface BugReportEnvironment {
40
47
  appVersion?: string;
41
48
  surface?: 'cli' | 'desktop';
@@ -49,8 +56,16 @@ export declare class BugReportError extends Error {
49
56
  }
50
57
  /** The report as it will be sent: trimmed, bounded, and with anything credential-shaped replaced. */
51
58
  export declare function normalizeBugReport(args: Record<string, unknown>): BugReport;
52
- /** Exactly what the user is asked to approve: every field that will be sent, and what is attached. */
53
- export declare function bugReportPreview(report: BugReport, environment: BugReportEnvironment): string;
59
+ /** Which session the report is about: this one, a named one, or none (a bug in the program, not in a session). */
60
+ export declare function reportSession(args: Record<string, unknown>): string;
61
+ /** What the closing line of the confirmation promises about the report. Shown every time, just above the choices. */
62
+ export declare const REPORT_USE = "is used only to debug the problem. It is kept in the Andorra team's private bug tracker and is never used to train models.";
63
+ /**
64
+ * Exactly what the user is asked to approve: every field that will be sent, the graph and trajectory in full
65
+ * when a session is attached, and how the report is used. `sessionNamed` is set when the user named a session,
66
+ * so a session that left nothing to attach is said rather than passed over.
67
+ */
68
+ export declare function bugReportPreview(report: BugReport, environment: BugReportEnvironment, sessionNamed?: boolean): string;
54
69
  export declare function bugReportEnvironment(env?: NodeJS.ProcessEnv, version?: () => Promise<string | undefined>): Promise<BugReportEnvironment>;
55
70
  export interface BugReportDependencies {
56
71
  accessToken(signal?: AbortSignal): Promise<string>;
@@ -69,10 +84,15 @@ export declare function createBugReportClient(deps: BugReportDependencies): BugR
69
84
  export declare const bugReports: BugReportClient;
70
85
  export interface BugReportToolOptions {
71
86
  client?: BugReportClient;
87
+ /** Where sessions and trajectories are kept. Defaults to the run's own home. */
88
+ home?: string;
89
+ attachments?: typeof sessionAttachments;
72
90
  environment?: () => Promise<BugReportEnvironment>;
73
91
  /** Tells the surface a question is open, the way ask_user does, so the tool clock pauses while it waits. */
74
92
  emit?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
75
93
  }
94
+ /** Lists the sessions a report can be about. It reads names and dates only, and nothing leaves the machine. */
95
+ export declare function bugReportSessionsTool(options?: Pick<BugReportToolOptions, 'home'>): Tool;
76
96
  /**
77
97
  * Files a bug report with the Andorra team. The report leaves the machine only after the user has read
78
98
  * exactly what will be sent and chosen to send it, so the tool refuses on a surface where nobody can answer.
@@ -2,10 +2,17 @@ import { readFile } from 'node:fs/promises';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { AUTH_DEPLOYMENT } from './auth/deployment.js';
4
4
  import { AuthError } from './auth/types.js';
5
+ import { configDirectory } from './config.js';
5
6
  import { redactSecrets } from './memory/redaction.js';
7
+ import { GRAPH_LIMIT, TRAJECTORY_LIMIT, listReportSessions, sessionAttachments, sessionExists } from './bug-report-attachments.js';
6
8
  /** The built-in skill that interviews the user; a run that carries it also gets the tool below. */
7
9
  export const BUG_REPORT_SKILL = 'andorra:bug-report';
8
10
  export const BUG_REPORT_TOOL = 'submit_bug_report';
11
+ /** Tells the interview which session this conversation is and which others exist, so it can ask where the bug was. */
12
+ export const BUG_REPORT_SESSIONS_TOOL = 'list_bug_report_sessions';
13
+ /** The two `session` answers that are not a session id. */
14
+ export const CURRENT_SESSION = 'current';
15
+ export const NO_SESSION = 'none';
9
16
  export const SEND_CHOICE = 'Send report';
10
17
  export const CANCEL_CHOICE = 'Do not send';
11
18
  /** The report's text fields with the byte limits the service enforces (infra/andorra-auth/bug_report.py). */
@@ -49,9 +56,9 @@ function fieldText(value, field) {
49
56
  }
50
57
  /** The report as it will be sent: trimmed, bounded, and with anything credential-shaped replaced. */
51
58
  export function normalizeBugReport(args) {
52
- const unknown = Object.keys(args).filter(key => !FIELDS.some(field => field.name === key));
59
+ const unknown = Object.keys(args).filter(key => key !== 'session' && !FIELDS.some(field => field.name === key));
53
60
  if (unknown.length)
54
- throw new BugReportError('invalid', `Unknown bug report field${unknown.length === 1 ? '' : 's'}: ${unknown.join(', ')}. Use title, description, steps, expected and actual.`);
61
+ throw new BugReportError('invalid', `Unknown bug report field${unknown.length === 1 ? '' : 's'}: ${unknown.join(', ')}. Use title, description, steps, expected, actual and session.`);
55
62
  const report = {};
56
63
  for (const field of FIELDS) {
57
64
  const text = fieldText(args[field.name], field);
@@ -60,13 +67,32 @@ export function normalizeBugReport(args) {
60
67
  }
61
68
  return report;
62
69
  }
63
- /** Exactly what the user is asked to approve: every field that will be sent, and what is attached. */
64
- export function bugReportPreview(report, environment) {
70
+ const SESSION_ID = /^[A-Za-z0-9_-]{1,64}$/;
71
+ /** Which session the report is about: this one, a named one, or none (a bug in the program, not in a session). */
72
+ export function reportSession(args) {
73
+ const value = typeof args.session === 'string' ? args.session.trim() : '';
74
+ if (value === CURRENT_SESSION || value === NO_SESSION || SESSION_ID.test(value))
75
+ return value;
76
+ throw new BugReportError('invalid', `A bug report needs session: "${CURRENT_SESSION}" when the problem is in this conversation's session, a session id from ${BUG_REPORT_SESSIONS_TOOL} when it is in another one, or "${NO_SESSION}" when it is not tied to a session. Ask the user which, and call again.`);
77
+ }
78
+ /** What the closing line of the confirmation promises about the report. Shown every time, just above the choices. */
79
+ export const REPORT_USE = 'is used only to debug the problem. It is kept in the Andorra team\'s private bug tracker and is never used to train models.';
80
+ /**
81
+ * Exactly what the user is asked to approve: every field that will be sent, the graph and trajectory in full
82
+ * when a session is attached, and how the report is used. `sessionNamed` is set when the user named a session,
83
+ * so a session that left nothing to attach is said rather than passed over.
84
+ */
85
+ export function bugReportPreview(report, environment, sessionNamed = false) {
65
86
  const attached = [environment.appVersion ? `Andorra Code ${environment.appVersion}` : undefined, environment.surface, environment.os, environment.arch].filter(Boolean).join(', ');
87
+ const session = report.graph !== undefined || report.trajectory !== undefined;
66
88
  return [
67
89
  'Send this bug report to the Andorra team?',
68
90
  ...FIELDS.filter(field => report[field.name] !== undefined).map(field => `${field.heading}:\n${report[field.name]}`),
69
- `Also sent: your account id and plan, and ${attached}. Nothing else: no files, prompts or conversation.`,
91
+ ...(report.graph === undefined ? [] : [`Affected graph (its settings and routes; the text of each instruction is left out):\n${report.graph}`]),
92
+ ...(report.trajectory === undefined ? [] : [`Compressed trajectory of the session (steps, tools, outcomes and error text):\n${report.trajectory}`]),
93
+ ...(sessionNamed && !session ? ['That session left no graph or trajectory on this machine, so none is attached.'] : []),
94
+ `Also sent: your account id and plan, and ${attached}. Nothing else: no files, prompts or ${session ? 'model replies' : 'conversation'}.`,
95
+ `This report${session ? ', with the graph and trajectory above,' : ''} ${REPORT_USE}`,
70
96
  ].join('\n\n');
71
97
  }
72
98
  async function packageVersion() {
@@ -173,6 +199,29 @@ export const bugReports = createBugReportClient({
173
199
  apiBaseUrl: () => AUTH_DEPLOYMENT.apiBaseUrl,
174
200
  fetch: (...args) => globalThis.fetch(...args),
175
201
  });
202
+ function attachment(name, value, limit) {
203
+ const text = value?.trim();
204
+ return text && Buffer.byteLength(text, 'utf8') <= limit ? { [name]: text } : {};
205
+ }
206
+ /** Lists the sessions a report can be about. It reads names and dates only, and nothing leaves the machine. */
207
+ export function bugReportSessionsTool(options = {}) {
208
+ return {
209
+ name: BUG_REPORT_SESSIONS_TOOL, executionMode: 'sequential',
210
+ description: 'List the sessions a bug report can be about: the one this conversation is in (marked current) and the most recent others, newest first. Call it once during the bug-report interview, before asking the user which session has the problem. It reads session names and dates on this machine and sends nothing.',
211
+ parameters: { type: 'object', properties: {}, additionalProperties: false },
212
+ eventOutput: () => 'Listed sessions.',
213
+ execute: async (_args, ctx) => {
214
+ ctx.signal.throwIfAborted();
215
+ const sessions = await listReportSessions(options.home ?? ctx.automationDirectory ?? configDirectory(), ctx.sessionId);
216
+ const current = sessions.find(session => session.current);
217
+ return JSON.stringify({
218
+ current: current ? { id: current.id, name: current.name } : null,
219
+ others: sessions.filter(session => !session.current).map(({ id, name, updatedAt }) => ({ id, name, updatedAt })),
220
+ note: `Ask the user whether the problem is in ${current ? `this session ("${current.name}")` : 'this conversation'}, in another session, or not tied to a session. Pass ${BUG_REPORT_TOOL} session "${CURRENT_SESSION}", the other session's id, or "${NO_SESSION}".${current ? '' : ' This conversation has not been saved as a session yet, so "current" has nothing to attach.'}`,
221
+ });
222
+ },
223
+ };
224
+ }
176
225
  /**
177
226
  * Files a bug report with the Andorra team. The report leaves the machine only after the user has read
178
227
  * exactly what will be sent and chosen to send it, so the tool refuses on a surface where nobody can answer.
@@ -183,14 +232,15 @@ export function bugReportTool(options = {}) {
183
232
  const text = { type: 'string', minLength: 1 };
184
233
  return {
185
234
  name: BUG_REPORT_TOOL, executionMode: 'sequential',
186
- description: 'Send a bug report about Andorra Code to the Andorra team. Call it only after the bug-report skill\'s interview, with the answers the user gave: never invent steps or details. The tool shows the user the exact report and sends it only if they choose to; a different answer comes back to you as their requested change. It needs a signed-in Andorra account (any plan). Never put credentials, private code or file contents in a report.',
235
+ description: 'Send a bug report about Andorra Code to the Andorra team. Call it only after the bug-report skill\'s interview, with the answers the user gave: never invent steps or details. Pass the session the user said has the problem; the tool reads that session\'s graph and a compressed trajectory itself and attaches them, so do not write either into the text. The tool shows the user the exact report and sends it only if they choose to; a different answer comes back to you as their requested change. It needs a signed-in Andorra account (any plan). Never put credentials, private code or file contents in a report.',
187
236
  parameters: { type: 'object', properties: {
188
237
  title: { ...text, maxLength: 120, description: 'One line naming the problem, for example "Send button does nothing after attaching a file".' },
189
238
  description: { ...text, maxLength: 4000, description: 'What happened, in the user\'s words, with any error text they saw.' },
190
239
  steps: { ...text, maxLength: 2000, description: 'Numbered steps that reproduce it, if the user knows them.' },
191
240
  expected: { ...text, maxLength: 1000, description: 'What the user expected to happen.' },
192
241
  actual: { ...text, maxLength: 2000, description: 'What happened instead.' },
193
- }, required: ['title', 'description'], additionalProperties: false },
242
+ session: { ...text, maxLength: 64, description: `Where the problem happened, as the user answered: "${CURRENT_SESSION}" for this conversation's session, the id of another session from ${BUG_REPORT_SESSIONS_TOOL}, or "${NO_SESSION}" for a bug in the program that is not tied to a session.` },
243
+ }, required: ['title', 'description', 'session'], additionalProperties: false },
194
244
  eventOutput: output => {
195
245
  try {
196
246
  const result = JSON.parse(output);
@@ -202,13 +252,26 @@ export function bugReportTool(options = {}) {
202
252
  },
203
253
  execute: async (args, ctx) => {
204
254
  ctx.signal.throwIfAborted();
205
- const report = normalizeBugReport(args);
255
+ const written = normalizeBugReport(args);
256
+ const session = reportSession(args);
206
257
  if (ctx.approvalMode === 'headless' || !ctx.askUser)
207
258
  throw new BugReportError('refused', 'A bug report is sent only after the user reads and confirms it, and nobody can answer on this surface. Nothing was sent. Tell the user to run /bug-report in an interactive session (the terminal app or the desktop app).');
208
259
  // Checked first so a signed-out user is never asked to confirm a report that cannot be sent.
209
260
  await client.token(ctx.signal);
210
261
  const environment = await environmentOf();
211
- const question = bugReportPreview(report, environment);
262
+ const home = options.home ?? ctx.automationDirectory ?? configDirectory();
263
+ let found = {};
264
+ if (session !== NO_SESSION) {
265
+ const id = session === CURRENT_SESSION ? ctx.sessionId : session;
266
+ if (!id)
267
+ throw new BugReportError('invalid', `This conversation has no saved session to attach. Nothing was sent. Ask the user whether another session has the problem (${BUG_REPORT_SESSIONS_TOOL} lists them) or pass session "${NO_SESSION}".`);
268
+ if (!options.attachments && !await sessionExists(home, id))
269
+ throw new BugReportError('invalid', `There is no session ${id} on this machine. Nothing was sent. Use an id from ${BUG_REPORT_SESSIONS_TOOL}, "${CURRENT_SESSION}" or "${NO_SESSION}".`);
270
+ found = await (options.attachments ?? sessionAttachments)(home, id, { current: id === ctx.sessionId, signal: ctx.signal });
271
+ }
272
+ // Bounded again here: the attachments are built on this machine, and the service refuses a report over its limits.
273
+ const report = { ...written, ...attachment('graph', found.graph, GRAPH_LIMIT), ...attachment('trajectory', found.trajectory, TRAJECTORY_LIMIT) };
274
+ const question = bugReportPreview(report, environment, session !== NO_SESSION);
212
275
  const choices = [SEND_CHOICE, CANCEL_CHOICE];
213
276
  await options.emit?.('agent.clarification.requested', { question, choices });
214
277
  let answer;
@@ -33,5 +33,6 @@ export declare function parseClaudeAuxiliaryResponse(output: string, maxTokens:
33
33
  export declare function claudeRequestBlocks(messages: GenerateRequest['messages'], tools: GenerateRequest['tools']): object[];
34
34
  export declare function createClaudeAdapter(_config: {
35
35
  model: string;
36
+ reasoningEffort?: string;
36
37
  }, dependencies?: ClaudeDependencies): ModelAdapter;
37
38
  export {};