@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,195 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { stripVTControlCharacters } from 'node:util';
3
+ import { excludedRoots, trustedGitEnv, trustedGitPath } from './git-summary.js';
4
+ import { redactSecrets } from './secret-redaction.js';
5
+ export const MAX_OUTCOMES = 20;
6
+ /** Commands are kept, and compared, up to this length. */
7
+ export const COMMAND_LIMIT = 8000;
8
+ export const OUTPUT_TAIL_BYTES = 4096;
9
+ const TEXT_LIMIT = 600;
10
+ const DIRTY_LISTED = 20;
11
+ export const OUTCOMES_DESCRIPTION = 'Optional. When the task asked for results that can be checked, list each requested outcome: outcome (plain language), status (passed, failed or not_checked), command (the exact command you ran that shows it, copied as you ran it), reading (your short reading of its result), and for not_checked: why, and how a person can check it. The runtime links each command to its own record of the run; an outcome with no recorded command shows as unverified.';
12
+ /** The JSON schema of `outcomes` in complete_agent. */
13
+ export const OUTCOMES_SCHEMA = {
14
+ type: 'array', maxItems: MAX_OUTCOMES, description: OUTCOMES_DESCRIPTION,
15
+ items: {
16
+ type: 'object',
17
+ properties: {
18
+ outcome: { type: 'string' }, status: { type: 'string', enum: ['passed', 'failed', 'not_checked'] },
19
+ command: { type: 'string' }, reading: { type: 'string' }, why: { type: 'string' }, how: { type: 'string' },
20
+ },
21
+ required: ['outcome', 'status'],
22
+ additionalProperties: false,
23
+ },
24
+ };
25
+ const text = (value, limit = TEXT_LIMIT) => typeof value === 'string' && value.trim() ? value.trim().slice(0, limit) : undefined;
26
+ /** The outcomes an agent sent, kept leniently: a malformed entry is dropped with a note, never a failed completion. */
27
+ export function parseOutcomes(value, notes) {
28
+ if (value === undefined)
29
+ return undefined;
30
+ // Some models send a list as JSON text.
31
+ if (typeof value === 'string') {
32
+ try {
33
+ value = JSON.parse(value);
34
+ notes?.push('outcomes arrived as JSON text and was decoded');
35
+ }
36
+ catch { /* not JSON */ }
37
+ }
38
+ if (!Array.isArray(value)) {
39
+ notes?.push('outcomes was not a list and was ignored');
40
+ return undefined;
41
+ }
42
+ const kept = [];
43
+ let dropped = 0;
44
+ for (const entry of value.slice(0, MAX_OUTCOMES)) {
45
+ const item = entry;
46
+ const outcome = text(item?.outcome, 300);
47
+ if (outcome === undefined) {
48
+ dropped++;
49
+ continue;
50
+ }
51
+ // A status the list does not know (skipped, blocked) is a gap the agent disclosed: kept as not checked.
52
+ const said = typeof item?.status === 'string' ? item.status : '';
53
+ const status = said === 'passed' || said === 'failed' || said === 'not_checked' ? said : 'not_checked';
54
+ const command = text(item?.command, COMMAND_LIMIT), reading = text(item?.reading), how = text(item?.how);
55
+ const why = text(item?.why) ?? (status !== said && said ? `Reported as ${said.slice(0, 40)}.` : undefined);
56
+ kept.push({ outcome, status, ...(command ? { command } : {}), ...(reading ? { reading } : {}), ...(why ? { why } : {}), ...(how ? { how } : {}) });
57
+ }
58
+ if (dropped)
59
+ notes?.push(`${dropped} outcome${dropped === 1 ? ' was' : 's were'} malformed and dropped`);
60
+ return kept.length ? kept : undefined;
61
+ }
62
+ /** Commands compare with their ends trimmed and runs of spaces or tabs between words collapsed; line breaks count. */
63
+ const normalized = (command) => command.slice(0, COMMAND_LIMIT).trim().replace(/[ \t]+/g, ' ').replace(/ ?\r?\n ?/g, '\n');
64
+ /** The last non-empty line of the output, as the row's result. */
65
+ function lastLine(output) {
66
+ const line = output?.split('\n').map(part => part.trim()).filter(Boolean).at(-1);
67
+ return line === undefined ? undefined : line.length > 120 ? `${line.slice(0, 119)}…` : line;
68
+ }
69
+ /**
70
+ * Each outcome against what ran: the newest recorded run of its exact command decides passed or failed by its exit
71
+ * code, whatever the agent claimed; an outcome whose command never ran is agent-reported; a not-checked one says why.
72
+ * `edits` are the times files were edited by the agent; a run followed by an edit, or by a run that saw other files,
73
+ * keeps its result with "Edited since".
74
+ */
75
+ export function resolveEvidence(outcomes, observations, edits = [], finalRevisions = new Map()) {
76
+ return outcomes.map(outcome => {
77
+ const agent = outcome.reading;
78
+ if (outcome.status === 'not_checked') {
79
+ return { criterion: outcome.outcome, state: 'unchecked', result: 'Not checked', ...(outcome.why ? { why: outcome.why } : {}), ...(outcome.how ? { how: outcome.how } : {}), ...(agent ? { agent } : {}) };
80
+ }
81
+ const wanted = outcome.command === undefined ? undefined : normalized(outcome.command);
82
+ const observed = wanted === undefined ? undefined : [...observations].reverse().find(item => normalized(item.command) === wanted && item.endedAt !== undefined);
83
+ if (observed === undefined) {
84
+ return {
85
+ criterion: outcome.outcome, state: 'reported',
86
+ result: outcome.command ? 'Agent-reported · the command it names was not recorded' : 'Agent-reported · no recorded run',
87
+ why: 'The agent reported this, but no run of the command it names was recorded in this turn.',
88
+ ...(agent ? { agent } : {}),
89
+ };
90
+ }
91
+ // A zero exit can hide failures (a pipe into tail, `|| true`): when the agent read a failure, it stays failed.
92
+ const passed = observed.exitCode === 0 && outcome.status !== 'failed';
93
+ const tail = lastLine(observed.output);
94
+ const after = Date.parse(observed.endedAt);
95
+ const known = (revision) => revision !== undefined && revision.inputsUnknown !== true;
96
+ const finalRevision = finalRevisions.get(observed.directory);
97
+ const editedLater = edits.some(at => Date.parse(at) > after)
98
+ // A later command in the same folder that saw other files means the shell changed them.
99
+ || observations.some(item => item.directory === observed.directory && Date.parse(item.startedAt) > after && known(item.revision) && known(observed.revision) && revisionKey(item) !== revisionKey(observed))
100
+ // So does the folder as the turn left it.
101
+ || (known(finalRevision) && known(observed.revision) && revisionKey({ ...observed, revision: finalRevision }) !== revisionKey(observed));
102
+ return {
103
+ criterion: outcome.outcome,
104
+ state: passed ? 'passed' : 'failed',
105
+ result: [tail, observed.exitCode === undefined ? 'did not finish' : `exit ${observed.exitCode}`, observed.exitCode === 0 && !passed ? 'agent read failures' : undefined].filter(Boolean).join(' · '),
106
+ observation: observed,
107
+ ...(agent ? { agent } : {}),
108
+ ...(editedLater ? { stale: 'Edited since' } : {}),
109
+ };
110
+ });
111
+ }
112
+ function revisionKey(item) {
113
+ return `${item.revision?.commit ?? ''}|${(item.revision?.dirty ?? []).join(',')}|${item.revision?.dirtyCount ?? 0}`;
114
+ }
115
+ /**
116
+ * What the ledger names about a turn (E7): each outcome it did not verify, said as it stands — not checked, only
117
+ * agent-reported, failed, or passed before later edits.
118
+ */
119
+ export function unverified(items) {
120
+ const phrase = { unchecked: 'not checked', reported: 'only agent-reported', failed: 'failed' };
121
+ // The most serious first: a failure, then a gap, then a claim, then a pass that edits may have overtaken.
122
+ const rank = (item) => item.state === 'failed' ? 0 : item.state === 'unchecked' ? 1 : item.state === 'reported' ? 2 : 3;
123
+ return [...(items ?? [])].sort((a, b) => rank(a) - rank(b)).flatMap(item => {
124
+ const said = phrase[item.state] ?? (item.stale ? 'edited since its check' : undefined);
125
+ return said === undefined ? [] : [`${item.criterion.replace(/[.\s]+$/, '')} ${said}`];
126
+ });
127
+ }
128
+ const GIT_FLAGS = ['--no-pager', '--no-optional-locks', '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=', '-c', 'core.quotePath=false', '-c', 'gc.auto=0'];
129
+ const REVISION_TIMEOUT_MS = 3000;
130
+ function run(binary, args, cwd, env, signal) {
131
+ return new Promise(resolve => {
132
+ execFile(binary, args, { cwd, env, windowsHide: true, timeout: REVISION_TIMEOUT_MS, maxBuffer: 4 << 20, ...(signal ? { signal } : {}) }, (error, stdout, stderr) => resolve({ code: error === null ? 0 : typeof error.code === 'number' ? error.code : 1, stdout: String(stdout), stderr: String(stderr) }));
133
+ });
134
+ }
135
+ /**
136
+ * The commit and uncommitted files of `directory`'s repository right now; undefined outside Git. Git runs as the
137
+ * app's other reads of a workspace do: found outside the workspace, with fsmonitor, hooks and the repository's
138
+ * filter drivers off, so reading the revision never runs anything the workspace configured.
139
+ */
140
+ export async function readRevision(directory, signal) {
141
+ const env = { ...trustedGitEnv(directory), GIT_TERMINAL_PROMPT: '0' };
142
+ const binary = trustedGitPath(env, excludedRoots(directory));
143
+ if (binary === undefined)
144
+ return undefined;
145
+ const drivers = await run(binary, [...GIT_FLAGS, 'config', '--null', '--get-regexp', '^filter\\.'], directory, env, signal);
146
+ const names = [...new Set(drivers.stdout.split('\0').map(entry => /^filter\.(.+)\.[^.\n]+\n/.exec(entry)?.[1]).filter((name) => !!name))];
147
+ const neutral = names.flatMap(name => ['-c', `filter.${name}.clean=`, '-c', `filter.${name}.smudge=`, '-c', `filter.${name}.process=`, '-c', `filter.${name}.required=false`]);
148
+ const status = await run(binary, [...GIT_FLAGS, ...neutral, 'status', '--porcelain=v2', '--branch', '-z', '--untracked-files=all'], directory, env, signal);
149
+ if (status.code !== 0) {
150
+ if (/not a git repository/i.test(status.stderr))
151
+ return undefined;
152
+ const head = await run(binary, [...GIT_FLAGS, 'rev-parse', '--verify', '--quiet', 'HEAD'], directory, env, signal);
153
+ if (head.code !== 0 && /not a git repository/i.test(head.stderr))
154
+ return undefined;
155
+ return { ...(head.code === 0 && head.stdout.trim() ? { commit: head.stdout.trim() } : {}), dirty: [], dirtyCount: 0, inputsUnknown: true };
156
+ }
157
+ let commit;
158
+ const files = [];
159
+ const records = status.stdout.split('\0');
160
+ for (let index = 0; index < records.length; index++) {
161
+ const record = records[index];
162
+ if (record.startsWith('# branch.oid ')) {
163
+ const oid = record.slice('# branch.oid '.length).trim();
164
+ if (/^[0-9a-f]{7,64}$/.test(oid))
165
+ commit = oid;
166
+ continue;
167
+ }
168
+ if (record.startsWith('#') || !record)
169
+ continue;
170
+ const fields = record.split(' ');
171
+ if (record[0] === '1')
172
+ files.push(fields.slice(8).join(' '));
173
+ else if (record[0] === '2') {
174
+ files.push(fields.slice(9).join(' '));
175
+ index++;
176
+ }
177
+ else if (record[0] === 'u')
178
+ files.push(fields.slice(10).join(' '));
179
+ else if (record[0] === '?')
180
+ files.push(record.slice(2));
181
+ }
182
+ return { ...(commit ? { commit } : {}), dirty: files.slice(0, DIRTY_LISTED), dirtyCount: files.length };
183
+ }
184
+ /** A command or its output as kept: terminal escapes stripped and known secret shapes redacted. */
185
+ export function cleanRecorded(text) {
186
+ return redactSecrets(stripVTControlCharacters(text));
187
+ }
188
+ /** The last 4 KB of a command's output, cut at a line where it can be. */
189
+ export function outputTail(output) {
190
+ if (output.length <= OUTPUT_TAIL_BYTES)
191
+ return output;
192
+ const tail = output.slice(-OUTPUT_TAIL_BYTES);
193
+ const at = tail.indexOf('\n');
194
+ return at >= 0 && at < 200 ? tail.slice(at + 1) : tail;
195
+ }
@@ -19,6 +19,8 @@ export interface BundleEntry {
19
19
  relativePath?: string;
20
20
  command?: string;
21
21
  }
22
+ /** Default cap for installing a GitHub skill or plugin: the compressed archive download, its expanded size and the selected bundle's file content are all bounded by this byte budget. Raise it with `extensions.githubArchiveMaxBytes` in config.json. */
23
+ export declare const DEFAULT_GITHUB_ARCHIVE_MAX_BYTES: number;
22
24
  export declare const MAX_SKILL_DOCUMENT_BYTES: number;
23
25
  export declare function listBundles(kind: Kind, config: Config, options?: {
24
26
  notices?: string[];
@@ -6,19 +6,29 @@ import { gunzip } from 'node:zlib';
6
6
  import { promisify } from 'node:util';
7
7
  import { parseDocument } from 'yaml';
8
8
  import { acquireSaveLock, SaveLockBusyError } from './save-lock.js';
9
- import { configDirectory, validateMcpServer } from './config.js';
9
+ import { configDirectory, validateMcpServer, MIN_GITHUB_ARCHIVE_MAX_BYTES } from './config.js';
10
10
  export { validateMcpServer } from './config.js';
11
11
  import { resolveBuiltinSkill } from './skills/invocable-skills.js';
12
12
  import { bundledSkillCatalog, bundledSkillDirectory } from './skills/runtime-skills.js';
13
13
  import { isBuiltinSlashCommand } from './skill-commands.js';
14
14
  import { workspacePermissionKey } from './permissions.js';
15
15
  const unzip = promisify(gunzip);
16
- const MAX_ARCHIVE_BYTES = 64 * 1024 * 1024;
17
- const MAX_EXPANDED_ARCHIVE_BYTES = 80 * 1024 * 1024;
18
- async function githubArchive(url, stage, subtree, signal) {
16
+ /** Default cap for installing a GitHub skill or plugin: the compressed archive download, its expanded size and the selected bundle's file content are all bounded by this byte budget. Raise it with `extensions.githubArchiveMaxBytes` in config.json. */
17
+ export const DEFAULT_GITHUB_ARCHIVE_MAX_BYTES = 1024 * 1024 * 1024;
18
+ const mib = (bytes) => Math.ceil(bytes / (1024 * 1024));
19
+ function githubArchiveMaxBytes(config) {
20
+ const configured = config.extensions?.githubArchiveMaxBytes;
21
+ if (configured === undefined)
22
+ return DEFAULT_GITHUB_ARCHIVE_MAX_BYTES;
23
+ if (!Number.isSafeInteger(configured) || configured < MIN_GITHUB_ARCHIVE_MAX_BYTES)
24
+ throw new Error('extensions.githubArchiveMaxBytes must be a whole number of at least 1 MiB');
25
+ return configured;
26
+ }
27
+ async function githubArchive(url, stage, subtree, signal, maxBytes = DEFAULT_GITHUB_ARCHIVE_MAX_BYTES) {
19
28
  const controller = new AbortController();
20
29
  const timeout = setTimeout(() => controller.abort(new Error('GitHub installation timed out')), 120_000);
21
30
  const active = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
31
+ const expandedMax = Math.ceil(maxBytes * 5 / 4);
22
32
  try {
23
33
  const response = await fetch(url, { signal: active, redirect: 'error' });
24
34
  if (!response.ok || !response.body) {
@@ -30,16 +40,16 @@ async function githubArchive(url, stage, subtree, signal) {
30
40
  let received = 0;
31
41
  try {
32
42
  const declared = response.headers.get('content-length');
33
- if (declared !== null && Number(declared) > MAX_ARCHIVE_BYTES)
34
- throw new Error('GitHub archive exceeds 64 MiB download limit');
43
+ if (declared !== null && Number(declared) > maxBytes)
44
+ throw new Error(`GitHub archive exceeds the ${mib(maxBytes)} MiB download limit`);
35
45
  while (true) {
36
46
  active.throwIfAborted();
37
47
  const item = await reader.read();
38
48
  if (item.done)
39
49
  break;
40
50
  received += item.value.byteLength;
41
- if (received > MAX_ARCHIVE_BYTES)
42
- throw new Error('GitHub archive exceeds 64 MiB download limit');
51
+ if (received > maxBytes)
52
+ throw new Error(`GitHub archive exceeds the ${mib(maxBytes)} MiB download limit`);
43
53
  chunks.push(item.value);
44
54
  }
45
55
  }
@@ -50,11 +60,11 @@ async function githubArchive(url, stage, subtree, signal) {
50
60
  active.throwIfAborted();
51
61
  let archive;
52
62
  try {
53
- archive = await unzip(Buffer.concat(chunks), { maxOutputLength: MAX_EXPANDED_ARCHIVE_BYTES });
63
+ archive = await unzip(Buffer.concat(chunks), { maxOutputLength: expandedMax });
54
64
  }
55
65
  catch (error) {
56
66
  if (error.code === 'ERR_BUFFER_TOO_LARGE')
57
- throw new Error('GitHub archive exceeds 80 MiB expanded limit');
67
+ throw new Error(`GitHub archive exceeds the ${mib(expandedMax)} MiB expanded limit`);
58
68
  throw new Error('Invalid GitHub gzip archive');
59
69
  }
60
70
  const selected = subtree?.split('/');
@@ -153,8 +163,8 @@ async function githubArchive(url, stage, subtree, signal) {
153
163
  if (treePaths.size + 1 > 10_000)
154
164
  throw new Error('Extension exceeds 10,000 files or 64 MiB');
155
165
  }
156
- if (treePaths.size + 1 > 10_000 || (bytes += size) > MAX_ARCHIVE_BYTES)
157
- throw new Error('Extension exceeds 10,000 files or 64 MiB');
166
+ if (treePaths.size + 1 > 10_000 || (bytes += size) > maxBytes)
167
+ throw new Error(`Extension exceeds 10,000 files or ${mib(maxBytes)} MiB`);
158
168
  entries.push({ path: target, mode: number(header, 100, 8) & 0o777, ...(type !== '5' ? { data } : {}) });
159
169
  }
160
170
  if (!ended || nextPath || !prefix || !entries.length)
@@ -218,17 +228,17 @@ function skillIdValid(id) { const [group, ...rest] = id.split(':'); idValid(grou
218
228
  function disabled(kind, config) { return config.extensions?.[kind === 'skills' ? 'disabledSkills' : 'disabledPlugins'] ?? []; }
219
229
  function root(kind, directory = configDirectory()) { return resolve(directory, kind); }
220
230
  function contained(base, target) { const rel = relative(base, target); return !isAbsolute(rel) && rel !== '..' && !rel.startsWith('..\\') && !rel.startsWith('../'); }
221
- async function safeTree(path, signal, budget = { count: 0, bytes: 0 }) {
231
+ async function safeTree(path, signal, maxBytes = DEFAULT_GITHUB_ARCHIVE_MAX_BYTES, budget = { count: 0, bytes: 0 }) {
222
232
  signal?.throwIfAborted();
223
233
  const info = await lstat(path);
224
- if (++budget.count > 10_000 || (budget.bytes += info.size) > 64 * 1024 * 1024)
225
- throw new Error('Extension exceeds 10,000 files or 64 MiB');
234
+ if (++budget.count > 10_000 || (budget.bytes += info.size) > maxBytes)
235
+ throw new Error(`Extension exceeds 10,000 files or ${mib(maxBytes)} MiB`);
226
236
  if (info.isSymbolicLink() || (!info.isDirectory() && !info.isFile()))
227
237
  throw new Error('Extension links and special files are not supported');
228
238
  if (info.isDirectory())
229
239
  for (const item of await readdir(path))
230
240
  if (item !== '.git')
231
- await safeTree(join(path, item), signal, budget);
241
+ await safeTree(join(path, item), signal, maxBytes, budget);
232
242
  }
233
243
  async function checkedResourcePath(base, path, signal) {
234
244
  signal?.throwIfAborted();
@@ -360,7 +370,7 @@ async function discoverSkillPaths(base, signal) {
360
370
  async function walk(path) {
361
371
  signal?.throwIfAborted();
362
372
  if (++count > 10_000)
363
- throw new Error('Extension exceeds 10,000 files or 64 MiB');
373
+ throw new Error('Extension exceeds 10,000 files');
364
374
  const items = await readdir(path, { withFileTypes: true });
365
375
  if (items.some(item => item.name === 'SKILL.md' && item.isFile()))
366
376
  paths.push(relative(base, path).split(sep).join('/') || '.');
@@ -483,7 +493,7 @@ export async function installBundle(kind, source, config, signal, directory = co
483
493
  url.hash = '';
484
494
  url.pathname = `/${match[1]}/${match[2]}`;
485
495
  const archiveUrl = `https://codeload.github.com/${match[1]}/${match[2]}/tar.gz/${ref ? encodeURIComponent(ref) : 'HEAD'}`;
486
- await githubArchive(archiveUrl, stage, subtree, signal);
496
+ await githubArchive(archiveUrl, stage, subtree, signal, githubArchiveMaxBytes(config));
487
497
  }
488
498
  else {
489
499
  const path = await realpath(resolve(source));
@@ -491,11 +501,11 @@ export async function installBundle(kind, source, config, signal, directory = co
491
501
  idValid(id);
492
502
  if (contained(path, await realpath(root(kind, directory))))
493
503
  throw new Error('Cannot install an ancestor of the extension directory');
494
- await safeTree(path, signal);
504
+ await safeTree(path, signal, githubArchiveMaxBytes(config));
495
505
  await cp(path, stage, { recursive: true, dereference: false, filter: path => basename(path) !== '.git' });
496
506
  }
497
507
  idValid(id);
498
- await safeTree(stage, signal);
508
+ await safeTree(stage, signal, githubArchiveMaxBytes(config));
499
509
  if (kind === 'skills' && (repository || !await lstat(join(stage, 'SKILL.md')).then(() => true, (e) => { if (e.code !== 'ENOENT')
500
510
  throw e; return false; }))) {
501
511
  repository ??= { name: id, source, skills: [] };
@@ -90,7 +90,7 @@ export declare const CHANGED_WHILE_APPROVING = "The pull request or reply settin
90
90
  export declare function approvalDetail(write: AgentPullRequestWrite, pullRequest: SessionPullRequest, bot: boolean, botName?: string): string;
91
91
  /**
92
92
  * Whether an agent write goes to the service first: agent writes set to the bot, and the PR covered (or
93
- * `permissions-pending`, where the service decides per action). The Auto-fix prompt uses the same rule, so
93
+ * `permissions-pending`, where the service decides per action). The review prompt uses the same rule, so
94
94
  * the prompt and the tool agree on who the replies post as.
95
95
  */
96
96
  export declare const asksBot: (setting: AgentWritesSetting, coverage: GitHubCoverage) => boolean;
@@ -111,7 +111,7 @@ export function approvalDetail(write, pullRequest, bot, botName) {
111
111
  }
112
112
  /**
113
113
  * Whether an agent write goes to the service first: agent writes set to the bot, and the PR covered (or
114
- * `permissions-pending`, where the service decides per action). The Auto-fix prompt uses the same rule, so
114
+ * `permissions-pending`, where the service decides per action). The review prompt uses the same rule, so
115
115
  * the prompt and the tool agree on who the replies post as.
116
116
  */
117
117
  export const asksBot = (setting, coverage) => setting === 'bot' && (coverage === 'covered' || coverage === 'permissions-pending');
@@ -66,6 +66,21 @@ export interface GitHubAppStatus {
66
66
  connection: GitHubConnection | null;
67
67
  installations: GitHubInstallation[];
68
68
  }
69
+ /** A repository the App can reach for the linked GitHub user; `push` is whether that user can push to it. */
70
+ export interface GitHubRepository {
71
+ id: number;
72
+ owner: string;
73
+ name: string;
74
+ private: boolean;
75
+ push: boolean;
76
+ }
77
+ /** `more`: the service left some repositories out for now (a large installation); asking again later lists further. */
78
+ export interface GitHubRepositoriesAnswer {
79
+ enabled: boolean;
80
+ connected: boolean;
81
+ repositories: GitHubRepository[];
82
+ more: boolean;
83
+ }
69
84
  export interface SubscriptionRequest {
70
85
  owner: string;
71
86
  repo: string;
@@ -278,6 +293,8 @@ export interface GitHubAppClient {
278
293
  disconnect(signal?: AbortSignal): Promise<{
279
294
  enabled: boolean;
280
295
  }>;
296
+ /** The repositories a Cloud machine may clone for this account. */
297
+ repositories(signal?: AbortSignal): Promise<GitHubRepositoriesAnswer>;
281
298
  subscribe(engine: string, pullRequests: SubscriptionRequest[], signal?: AbortSignal): Promise<SubscriptionAnswer>;
282
299
  events(engine: string, after: string | undefined, signal?: AbortSignal): Promise<EventsAnswer>;
283
300
  /**
@@ -333,6 +350,8 @@ export declare function accountApiTarget(env?: NodeJS.ProcessEnv): {
333
350
  export declare function parseNotice(value: unknown): GitHubNotice | undefined;
334
351
  /** A notice `parseNotice` read as a `request`, with every field it requires. */
335
352
  export declare const isMentionNotice: (notice: GitHubNotice) => notice is MentionNotice;
353
+ /** The most repositories one list answer is read for (the service sends at most this many). */
354
+ export declare const MAX_REPOSITORIES = 1000;
336
355
  /** The service's own limit on a bot write's body. */
337
356
  export declare const BOT_BODY_BYTES = 16384;
338
357
  /** The first field of a bot write the service would refuse (`400 bad_request`), checked as it checks them; undefined when none. */
@@ -1,6 +1,6 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
2
  import { AUTH_DEPLOYMENT } from '../auth/deployment.js';
3
- import { GITHUB_OWNER, GITHUB_REPO } from '../github-names.js';
3
+ import { GITHUB_ACCOUNT, GITHUB_OWNER, GITHUB_REPO } from '../github-names.js';
4
4
  import { AuthError } from '../auth/types.js';
5
5
  /**
6
6
  * The engine's client for the account API's GitHub App routes (`design/specs/github-app.md`): the
@@ -224,6 +224,15 @@ function parseRequest(value, base) {
224
224
  commentId, commentKind: commentKind, commentUrl, ...(commentAt === undefined ? {} : { commentAt: commentAt }),
225
225
  };
226
226
  }
227
+ /** The most repositories one list answer is read for (the service sends at most this many). */
228
+ export const MAX_REPOSITORIES = 1000;
229
+ function parseRepository(value) {
230
+ // The owner is read as the service writes it (a managed user's underscore included), not as a pull request URL names one.
231
+ if (!isRecord(value) || !positive(value.id) || typeof value.owner !== 'string' || !GITHUB_ACCOUNT.test(value.owner) || typeof value.name !== 'string' || !REPO.test(value.name))
232
+ return undefined;
233
+ // Private unless the service says otherwise, so a malformed flag never shows a private repository as public.
234
+ return { id: value.id, owner: value.owner, name: value.name, private: value.private !== false, push: value.push === true };
235
+ }
227
236
  function parseStatus(value) {
228
237
  const enabled = value.enabled === true;
229
238
  const status = { enabled, allowed: enabled && value.allowed !== false, connection: null, installations: [] };
@@ -567,6 +576,17 @@ export function createGitHubAppClient(deps) {
567
576
  const answer = await call('DELETE', '/github/connection', undefined, signal, true);
568
577
  return { enabled: answer.enabled !== false };
569
578
  },
579
+ async repositories(signal) {
580
+ const answer = await call('GET', '/github/repositories', undefined, signal);
581
+ if (typeof answer.enabled !== 'boolean')
582
+ throw new GitHubAppError('invalid-answer', 'The repository list carried no enabled flag.');
583
+ if (!answer.enabled)
584
+ return { enabled: false, connected: false, repositories: [], more: false };
585
+ if (!Array.isArray(answer.repositories))
586
+ throw new GitHubAppError('invalid-answer', 'The repository list carried no repositories.');
587
+ const repositories = answer.repositories.slice(0, MAX_REPOSITORIES).map(parseRepository).filter((entry) => entry !== undefined);
588
+ return { enabled: true, connected: answer.connection === true, repositories, more: answer.more === true };
589
+ },
570
590
  async subscribe(engine, pullRequests, signal) {
571
591
  if (!isEngineId(engine))
572
592
  throw new GitHubAppError('invalid-request', 'The engine id is malformed.');
@@ -72,7 +72,6 @@ export interface GitHubEventSourceOptions {
72
72
  onSummary?(summary: GitHubWatchSummary): void | Promise<void>;
73
73
  log?(level: 'info' | 'warn', detail: string): void;
74
74
  now?(): number;
75
- isReviewer?(login: string | undefined): boolean;
76
75
  metrics?: GitHubWatchMetrics;
77
76
  /** The timers `start()` schedules runs with (tests pass a fake clock's). */
78
77
  timers?: {
@@ -97,7 +96,6 @@ export declare class GitHubEventSource {
97
96
  private readonly options;
98
97
  private readonly metrics;
99
98
  private readonly now;
100
- private readonly isReviewer;
101
99
  /** off: signed out, switched off here, or nothing learned yet. disabled: the service said `enabled: false` or not allowed. */
102
100
  private mode;
103
101
  private offReason;
@@ -125,7 +123,6 @@ export declare class GitHubEventSource {
125
123
  private readonly seenOrder;
126
124
  private watched;
127
125
  private holder;
128
- private readonly wakeNotices;
129
126
  private ticking?;
130
127
  private again;
131
128
  private timer?;
@@ -158,8 +155,6 @@ export declare class GitHubEventSource {
158
155
  covers(sessionId: string): boolean;
159
156
  /** For the measures: one gh call the watcher made for a session. Nothing is counted while the source is off. */
160
157
  countGhCall(sessionId: string): void;
161
- /** The watcher armed an Auto-fix wake: if a code-review notice caused it, its latency is recorded. */
162
- woke(sessionId: string): void;
163
158
  get eventMode(): EventMode;
164
159
  private get modeReason();
165
160
  /** What `github.status` reports: this process's view when it holds the lease, else the holder's saved view. */
@@ -1,4 +1,4 @@
1
- import { isCodeReviewer, listPullRequests, pullRequestNeedsWatch } from '../pull-requests.js';
1
+ import { listPullRequests, pullRequestNeedsWatch } from '../pull-requests.js';
2
2
  import { GitHubAppError, isMentionNotice } from './client.js';
3
3
  import { GitHubWatchMetrics } from './metrics.js';
4
4
  import { engineId, readCursor, readSharedCoverage, writeCursor, writeSharedCoverage } from './store.js';
@@ -25,7 +25,6 @@ export const BREAKER_MAX_BACKOFF_MS = 5 * 60_000;
25
25
  export const MAX_SUBSCRIBED = 50;
26
26
  export const SEEN_IDS = 1_000;
27
27
  const MAX_PAGES = 10;
28
- const WAKE_NOTICE_TTL_MS = 15 * 60_000;
29
28
  /** The shortest wait between two runs the source schedules itself, whatever is due: no due time in the past can spin it. */
30
29
  export const MIN_TICK_MS = 1_000;
31
30
  /** Renewals start this long before the service's `renewBy`, so one failed attempt does not lose coverage. */
@@ -47,7 +46,6 @@ export class GitHubEventSource {
47
46
  options;
48
47
  metrics;
49
48
  now;
50
- isReviewer;
51
49
  /** off: signed out, switched off here, or nothing learned yet. disabled: the service said `enabled: false` or not allowed. */
52
50
  mode = 'off';
53
51
  offReason = 'pending';
@@ -75,7 +73,6 @@ export class GitHubEventSource {
75
73
  seenOrder = [];
76
74
  watched = new Map();
77
75
  holder = false;
78
- wakeNotices = new Map();
79
76
  ticking;
80
77
  again = false;
81
78
  timer;
@@ -93,7 +90,6 @@ export class GitHubEventSource {
93
90
  this.options = options;
94
91
  this.metrics = options.metrics ?? new GitHubWatchMetrics();
95
92
  this.now = options.now ?? Date.now;
96
- this.isReviewer = options.isReviewer ?? (login => isCodeReviewer(login));
97
93
  this.timers = options.timers ?? {
98
94
  setTimeout: (callback, ms) => { const handle = setTimeout(callback, ms); handle.unref?.(); return handle; },
99
95
  clearTimeout: handle => clearTimeout(handle),
@@ -180,15 +176,6 @@ export class GitHubEventSource {
180
176
  return;
181
177
  this.metrics.call(sessionId, this.coverageOf(sessionId), this.now());
182
178
  }
183
- /** The watcher armed an Auto-fix wake: if a code-review notice caused it, its latency is recorded. */
184
- woke(sessionId) {
185
- const at = this.wakeNotices.get(sessionId);
186
- if (at === undefined)
187
- return;
188
- this.wakeNotices.delete(sessionId);
189
- const now = this.now();
190
- this.metrics.wake(now - at, now);
191
- }
192
179
  get eventMode() {
193
180
  if (this.mode === 'events' && !this.breakerOpen && [...this.watched.keys()].some(id => this.covers(id)))
194
181
  return 'events';
@@ -346,9 +333,6 @@ export class GitHubEventSource {
346
333
  if (this.holder && active)
347
334
  for (const entry of this.watched.values())
348
335
  this.metrics.watched(entry.sessionId, this.coverageOf(entry.sessionId), at);
349
- for (const [sessionId, noticeAt] of this.wakeNotices)
350
- if (at - noticeAt > WAKE_NOTICE_TTL_MS)
351
- this.wakeNotices.delete(sessionId);
352
336
  if (this.metrics.due(at) && !this.stopped) {
353
337
  const summary = this.metrics.take(at);
354
338
  if (summary)
@@ -641,20 +625,6 @@ export class GitHubEventSource {
641
625
  this.options.onStale?.(entry.sessionId);
642
626
  if (notice.kind === 'state' || notice.kind === 'head' || notice.kind === 'checks')
643
627
  void this.options.watcher.checkNow(entry.sessionId);
644
- else if ((notice.kind === 'review' || notice.kind === 'comment') && entry.pullRequest.autoFix && this.isReviewer(notice.actor)) {
645
- const sessionId = entry.sessionId;
646
- const at = notice.at === undefined ? this.now() : Date.parse(notice.at);
647
- const known = this.wakeNotices.get(sessionId);
648
- if (known === undefined || at < known)
649
- this.wakeNotices.set(sessionId, at);
650
- const noted = this.wakeNotices.get(sessionId);
651
- // The wake this notice is timed for is the one its own read arms: a read that arms none forgets the
652
- // notice, so a later wake with another cause is never counted as its latency.
653
- void Promise.resolve(this.options.watcher.checkNow(sessionId)).then(() => {
654
- if (this.wakeNotices.get(sessionId) === noted)
655
- this.wakeNotices.delete(sessionId);
656
- }, () => { });
657
- }
658
628
  }
659
629
  }
660
630
  }
@@ -8,24 +8,21 @@ export interface GitHubWatchSummary {
8
8
  prs: number;
9
9
  calls: number;
10
10
  }[];
11
- /** Seconds from a code-review notice's time to the Auto-fix wake it caused, whole seconds. */
11
+ /** Retained for consumers of the historical telemetry shape. */
12
12
  wakeLatencies: number[];
13
13
  }
14
14
  /**
15
- * Counts for product telemetry (ADR 0021, `github.watch`): gh calls per watched PR by coverage, and wake
16
- * latency. Only numbers and coverage states are kept: no PR, repository or session leaves this object.
15
+ * Counts for product telemetry (ADR 0021, `github.watch`): gh calls per watched PR by coverage. Only numbers and coverage states are kept: no PR, repository or session leaves this object.
17
16
  */
18
17
  export declare class GitHubWatchMetrics {
19
18
  private readonly windowMs;
20
19
  private started?;
21
20
  private readonly prs;
22
21
  private readonly calls;
23
- private latencies;
24
22
  constructor(windowMs?: number);
25
23
  private begin;
26
24
  watched(sessionId: string, coverage: GitHubCoverage, now: number): void;
27
25
  call(sessionId: string, coverage: GitHubCoverage, now: number): void;
28
- wake(latencyMs: number, now: number): void;
29
26
  due(now: number): boolean;
30
27
  /** The window so far, and a fresh one begun; undefined when no PR was watched in it. */
31
28
  take(now: number): GitHubWatchSummary | undefined;
@@ -1,16 +1,12 @@
1
1
  const WINDOW_MS = 60 * 60_000;
2
- const MAX_LATENCIES = 60;
3
- const MAX_LATENCY_SECONDS = 86_400;
4
2
  /**
5
- * Counts for product telemetry (ADR 0021, `github.watch`): gh calls per watched PR by coverage, and wake
6
- * latency. Only numbers and coverage states are kept: no PR, repository or session leaves this object.
3
+ * Counts for product telemetry (ADR 0021, `github.watch`): gh calls per watched PR by coverage. Only numbers and coverage states are kept: no PR, repository or session leaves this object.
7
4
  */
8
5
  export class GitHubWatchMetrics {
9
6
  windowMs;
10
7
  started;
11
8
  prs = new Map();
12
9
  calls = new Map();
13
- latencies = [];
14
10
  constructor(windowMs = WINDOW_MS) {
15
11
  this.windowMs = windowMs;
16
12
  }
@@ -25,25 +21,17 @@ export class GitHubWatchMetrics {
25
21
  this.watched(sessionId, coverage, now);
26
22
  this.calls.set(coverage, (this.calls.get(coverage) ?? 0) + 1);
27
23
  }
28
- wake(latencyMs, now) {
29
- this.begin(now);
30
- if (this.latencies.length >= MAX_LATENCIES || !Number.isFinite(latencyMs))
31
- return;
32
- this.latencies.push(Math.max(0, Math.min(MAX_LATENCY_SECONDS, Math.round(latencyMs / 1000))));
33
- }
34
24
  due(now) { return this.started !== undefined && now - this.started >= this.windowMs; }
35
25
  /** The window so far, and a fresh one begun; undefined when no PR was watched in it. */
36
26
  take(now) {
37
27
  const started = this.started;
38
28
  const coverage = [...this.prs.entries()].map(([state, sessions]) => ({ state, prs: Math.min(sessions.size, 10_000), calls: this.calls.get(state) ?? 0 }));
39
- const latencies = this.latencies;
40
29
  this.started = undefined;
41
30
  this.prs.clear();
42
31
  this.calls.clear();
43
- this.latencies = [];
44
32
  if (started === undefined || coverage.length === 0)
45
33
  return undefined;
46
34
  const minutes = Math.max(1, Math.min(60, Math.ceil((now - started) / 60_000)));
47
- return { minutes, coverage, wakeLatencies: latencies };
35
+ return { minutes, coverage, wakeLatencies: [] };
48
36
  }
49
37
  }