@andorra-labs/code 0.1.8 → 0.1.10

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 (187) hide show
  1. package/THIRD_PARTY_NOTICES.md +2 -1
  2. package/dist/src/account-presentation.d.ts +11 -0
  3. package/dist/src/account-presentation.js +29 -2
  4. package/dist/src/agent-execution.js +57 -4
  5. package/dist/src/agent-mcp.d.ts +12 -0
  6. package/dist/src/agent-mcp.js +81 -2
  7. package/dist/src/app-server/protocol.d.ts +120 -1
  8. package/dist/src/app-server/protocol.js +8 -1
  9. package/dist/src/app-server/reasoning.d.ts +0 -8
  10. package/dist/src/app-server/reasoning.js +15 -28
  11. package/dist/src/app-server.d.ts +32 -0
  12. package/dist/src/app-server.js +214 -21
  13. package/dist/src/auth/AuthManager.d.ts +15 -0
  14. package/dist/src/auth/AuthManager.js +66 -7
  15. package/dist/src/auth/index.d.ts +1 -1
  16. package/dist/src/auth/index.js +1 -1
  17. package/dist/src/auth/store.d.ts +17 -1
  18. package/dist/src/auth/store.js +25 -2
  19. package/dist/src/browser-runner.js +1 -2
  20. package/dist/src/browser-server.js +10 -2
  21. package/dist/src/browser-session.js +6 -2
  22. package/dist/src/browser-stealth.d.ts +29 -0
  23. package/dist/src/browser-stealth.js +166 -0
  24. package/dist/src/browser-ui/app.js +123 -28
  25. package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
  26. package/dist/src/browser-ui/index.html +8 -8
  27. package/dist/src/browser-ui/style.css +199 -171
  28. package/dist/src/browser-ui/tokens.css +198 -0
  29. package/dist/src/browser-view.d.ts +57 -9
  30. package/dist/src/browser-view.js +187 -36
  31. package/dist/src/cli.js +31 -9
  32. package/dist/src/coding-tools.js +9 -5
  33. package/dist/src/command-screens.js +4 -4
  34. package/dist/src/commands.d.ts +1 -1
  35. package/dist/src/commands.js +3 -2
  36. package/dist/src/completion-gates.d.ts +35 -0
  37. package/dist/src/completion-gates.js +25 -0
  38. package/dist/src/completion.d.ts +7 -1
  39. package/dist/src/completion.js +37 -4
  40. package/dist/src/config.d.ts +1 -1
  41. package/dist/src/config.js +2 -2
  42. package/dist/src/context-budget.d.ts +11 -0
  43. package/dist/src/context-budget.js +13 -0
  44. package/dist/src/decision/DecisionEngine.d.ts +5 -1
  45. package/dist/src/decision/DecisionManager.d.ts +1 -0
  46. package/dist/src/decision/DecisionManager.js +14 -3
  47. package/dist/src/decision/FactContinuations.d.ts +6 -0
  48. package/dist/src/decision/FactContinuations.js +9 -1
  49. package/dist/src/decision/FactServiceGate.js +1 -1
  50. package/dist/src/decision/checks.js +1 -1
  51. package/dist/src/decision/hostedSkills.d.ts +37 -0
  52. package/dist/src/decision/hostedSkills.js +64 -0
  53. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
  54. package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
  55. package/dist/src/default-graph.d.ts +11 -0
  56. package/dist/src/default-graph.js +20 -0
  57. package/dist/src/duration.d.ts +13 -2
  58. package/dist/src/duration.js +27 -3
  59. package/dist/src/file-diff.d.ts +105 -0
  60. package/dist/src/file-diff.js +244 -0
  61. package/dist/src/graph-manager-chat.d.ts +302 -0
  62. package/dist/src/graph-manager-chat.js +940 -0
  63. package/dist/src/graph-runner.js +6 -0
  64. package/dist/src/graph-server.d.ts +9 -0
  65. package/dist/src/graph-server.js +171 -20
  66. package/dist/src/graph-studio-features.js +2 -2
  67. package/dist/src/graph-sync.js +5 -2
  68. package/dist/src/graph-ui/app.js +369 -183
  69. package/dist/src/graph-ui/controls.css +55 -32
  70. package/dist/src/graph-ui/controls.js +85 -9
  71. package/dist/src/graph-ui/edge-router.js +114 -13
  72. package/dist/src/graph-ui/embed.js +32 -17
  73. package/dist/src/graph-ui/icons.js +1 -0
  74. package/dist/src/graph-ui/index.html +4 -4
  75. package/dist/src/graph-ui/library.css +4 -10
  76. package/dist/src/graph-ui/manager-markdown.js +155 -0
  77. package/dist/src/graph-ui/manager-state.js +191 -0
  78. package/dist/src/graph-ui/manager.css +161 -0
  79. package/dist/src/graph-ui/manager.js +700 -0
  80. package/dist/src/graph-ui/skill-picker.js +6 -6
  81. package/dist/src/graph-ui/studio-canvas.js +17 -15
  82. package/dist/src/graph-ui/studio.css +24 -23
  83. package/dist/src/graph-ui/studio.js +69 -48
  84. package/dist/src/graph-ui/style.css +128 -93
  85. package/dist/src/graph-ui/theme.js +2 -2
  86. package/dist/src/graph-ui/tokens.css +217 -151
  87. package/dist/src/graphs.d.ts +76 -2
  88. package/dist/src/graphs.js +172 -9
  89. package/dist/src/hardened-runtime.js +8 -2
  90. package/dist/src/mcp.d.ts +75 -0
  91. package/dist/src/mcp.js +240 -8
  92. package/dist/src/membership-errors.d.ts +14 -0
  93. package/dist/src/membership-errors.js +24 -1
  94. package/dist/src/membership.d.ts +20 -0
  95. package/dist/src/membership.js +45 -16
  96. package/dist/src/palette.d.ts +25 -8
  97. package/dist/src/palette.js +26 -8
  98. package/dist/src/provider-engine.d.ts +4 -4
  99. package/dist/src/provider-engine.js +39 -22
  100. package/dist/src/provider-keys.d.ts +5 -1
  101. package/dist/src/provider-keys.js +7 -3
  102. package/dist/src/provider-settings.d.ts +4 -1
  103. package/dist/src/provider-settings.js +46 -5
  104. package/dist/src/providers.d.ts +24 -0
  105. package/dist/src/providers.js +47 -2
  106. package/dist/src/qa/guidance.d.ts +26 -0
  107. package/dist/src/qa/guidance.js +46 -0
  108. package/dist/src/qa/index.d.ts +1 -8
  109. package/dist/src/qa/index.js +1 -16
  110. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  111. package/dist/src/qa/profile/QaProfile.js +6 -2
  112. package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
  113. package/dist/src/qa/runtime/ProcessManager.js +69 -13
  114. package/dist/src/qa/tools.d.ts +19 -1
  115. package/dist/src/qa/tools.js +20 -145
  116. package/dist/src/react-runtime.d.ts +11 -0
  117. package/dist/src/react-runtime.js +203 -53
  118. package/dist/src/remote/engine-pool.js +21 -6
  119. package/dist/src/run-progress.d.ts +6 -0
  120. package/dist/src/run-progress.js +7 -0
  121. package/dist/src/runtime.d.ts +8 -0
  122. package/dist/src/screen-selection.d.ts +38 -0
  123. package/dist/src/screen-selection.js +103 -0
  124. package/dist/src/session-changes.d.ts +117 -0
  125. package/dist/src/session-changes.js +796 -0
  126. package/dist/src/session-skills.d.ts +75 -0
  127. package/dist/src/session-skills.js +151 -0
  128. package/dist/src/side-panel.d.ts +1 -1
  129. package/dist/src/side-panel.js +6 -12
  130. package/dist/src/skill-commands.js +1 -1
  131. package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
  132. package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
  133. package/dist/src/skills/bundled/provenance.json +3 -3
  134. package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
  135. package/dist/src/stall-recovery.d.ts +33 -0
  136. package/dist/src/stall-recovery.js +83 -0
  137. package/dist/src/subagent-run.js +1 -2
  138. package/dist/src/telemetry/schema.d.ts +1 -1
  139. package/dist/src/telemetry/schema.js +1 -2
  140. package/dist/src/terminal-ui.d.ts +66 -22
  141. package/dist/src/terminal-ui.js +327 -92
  142. package/dist/src/tool-diff-stats.d.ts +9 -0
  143. package/dist/src/tool-diff-stats.js +20 -0
  144. package/dist/src/tool-names.d.ts +1 -1
  145. package/dist/src/tool-result-filter.js +1 -1
  146. package/dist/src/tools.js +26 -2
  147. package/dist/src/transcript.d.ts +11 -0
  148. package/dist/src/transcript.js +23 -3
  149. package/dist/src/types.d.ts +24 -4
  150. package/dist/src/usage-analytics.d.ts +7 -0
  151. package/dist/src/usage-analytics.js +55 -15
  152. package/docs/concepts/README.md +1 -1
  153. package/docs/concepts/limits.md +9 -0
  154. package/docs/guides/desktop-app.md +1 -1
  155. package/docs/guides/graph-builder.md +16 -1
  156. package/docs/guides/tui.md +9 -9
  157. package/docs/reference/slash-commands.md +2 -1
  158. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
  159. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
  160. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
  161. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
  162. package/package.json +1 -1
  163. package/tests/chat-side-panel-test-plan.md +1 -1
  164. package/dist/src/qa/api/http-runner.d.ts +0 -3
  165. package/dist/src/qa/api/http-runner.js +0 -47
  166. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  167. package/dist/src/qa/git/ChangeDetector.js +0 -177
  168. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  169. package/dist/src/qa/git/DiffReviewer.js +0 -115
  170. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  171. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  172. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  173. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  174. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  175. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  176. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  177. package/dist/src/qa/runners/CommandRunner.js +0 -96
  178. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  179. package/dist/src/qa/runners/TestRunner.js +0 -66
  180. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  181. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  182. package/dist/src/qa/runtime-detect.d.ts +0 -10
  183. package/dist/src/qa/runtime-detect.js +0 -72
  184. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  185. package/dist/src/qa/security/DependencyScanner.js +0 -167
  186. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  187. package/dist/src/qa/security/SecretScanner.js +0 -55
@@ -21,14 +21,13 @@ import { randomUUID } from 'node:crypto';
21
21
  * calls and their thinking must not collapse into one row. The invocation identity the runtime
22
22
  * stamps on its own events travels along, so a row is attributable to its node and subagent.
23
23
  */
24
- /**
25
- * Characters of one call's reasoning carried by the live stream.
26
- *
27
- * Reasoning may run far longer than the answer it precedes; the row shows a bounded head rather
28
- * than letting one call's thinking occupy the window's memory. The marker on the event says so, so
29
- * a truncated row is never presented as the whole thought.
24
+ /*
25
+ * 2026-11-14: the stream carries all of a call's reasoning. It used to stop at 12,000 characters,
26
+ * which a fast model reaches in seconds: the window's row froze mid-word while the model kept
27
+ * thinking for minutes, and nothing said why until the call settled. What a row draws is bounded by
28
+ * the window instead — it renders a sliding tail of the text and pages back on request (see
29
+ * desktop/src/engine/thoughtWindow.ts) — so the text no longer has to be cut at the source.
30
30
  */
31
- export const REASONING_TEXT_LIMIT = 12_000;
32
31
  /**
33
32
  * Longest gap between two delta events on the wire.
34
33
  *
@@ -46,7 +45,6 @@ export function withReasoningEvents(adapter, publish) {
46
45
  const reasoningId = randomUUID();
47
46
  let open = false;
48
47
  let text = '';
49
- let truncated = false;
50
48
  let openedAt = 0;
51
49
  let attempts = 0;
52
50
  let pendingDelta = '';
@@ -75,7 +73,6 @@ export function withReasoningEvents(adapter, publish) {
75
73
  if (!open)
76
74
  return;
77
75
  text = '';
78
- truncated = false;
79
76
  pendingDelta = '';
80
77
  if (deltaTimer) {
81
78
  clearTimeout(deltaTimer);
@@ -124,7 +121,7 @@ export function withReasoningEvents(adapter, publish) {
124
121
  publish({
125
122
  type: 'agent.reasoning.completed',
126
123
  time: stamp(),
127
- data: { ...identity, text, durationMs: Math.max(0, Date.now() - openedAt), ...(truncated ? { truncated: true } : {}) },
124
+ data: { ...identity, text, durationMs: Math.max(0, Date.now() - openedAt) },
128
125
  });
129
126
  };
130
127
  try {
@@ -136,25 +133,15 @@ export function withReasoningEvents(adapter, publish) {
136
133
  return;
137
134
  if (!open)
138
135
  openRow();
139
- // Only the characters the row keeps are streamed: past the display limit the event would
140
- // carry text the settled row drops, and the live preview would jump backwards on settle.
141
- const room = Math.max(0, REASONING_TEXT_LIMIT - text.length);
142
- if (room === 0)
143
- truncated = true;
136
+ text += delta;
137
+ pendingDelta += delta;
138
+ const now = Date.now();
139
+ if (now - lastDeltaAt >= REASONING_DELTA_MS) {
140
+ lastDeltaAt = now;
141
+ flushDelta();
142
+ }
144
143
  else {
145
- const kept = delta.length > room ? delta.slice(0, room) : delta;
146
- if (kept.length < delta.length)
147
- truncated = true;
148
- text += kept;
149
- pendingDelta += kept;
150
- const now = Date.now();
151
- if (now - lastDeltaAt >= REASONING_DELTA_MS) {
152
- lastDeltaAt = now;
153
- flushDelta();
154
- }
155
- else {
156
- scheduleDeltaFlush();
157
- }
144
+ scheduleDeltaFlush();
158
145
  }
159
146
  request.onReasoning?.(delta);
160
147
  },
@@ -144,6 +144,8 @@ export declare class AppServer {
144
144
  private readonly gh;
145
145
  /** Polls the PRs whose sessions asked for Auto-fix; one engine per home actually polls. */
146
146
  private readonly pullRequestWatcher;
147
+ /** The files each session's agent changed since the person last reviewed them (Keep / Undo). */
148
+ private readonly sessionChanges;
147
149
  /** The wakes this engine armed for Auto-fix, checked against the PR record again before delivery. */
148
150
  private readonly autoFixWakes;
149
151
  /**
@@ -396,6 +398,27 @@ export declare class AppServer {
396
398
  private setExtensionEnabled;
397
399
  /** Preserve MCP credentials when toggling or deleting an existing entry. */
398
400
  private mutateMcp;
401
+ /**
402
+ * One configured MCP server as an edit form can show it: the command and its arguments, or the
403
+ * endpoint, and the *names* of its environment variables and headers. Their values are secrets
404
+ * the engine never returns; an edit keeps a saved value by naming it (see mergeMcpEdit). The
405
+ * endpoint is returned without its query string, which can hold a credential.
406
+ */
407
+ private mcpServerView;
408
+ /**
409
+ * Check one configured MCP server, on the person's explicit request ("Check Connection"): start
410
+ * it, ask for its tools, stop it, and record the answer beside the ones tasks record. A server that
411
+ * is turned off is reported off without being started. A stdio server starts in the workspace the
412
+ * caller names, as it would for a task there, or the home folder. A page never calls this on its
413
+ * own: a task asks before it connects a server, and opening Settings is not that consent.
414
+ */
415
+ private mcpStatus;
416
+ /**
417
+ * What each configured server last answered, without starting anything: the status a task's
418
+ * connection or an explicit check recorded, while it still describes the server's current
419
+ * definition. An edited server, and one never connected, has none ("Not checked").
420
+ */
421
+ private mcpStatuses;
399
422
  /**
400
423
  * Apply one provider change inside the serialized configuration transaction.
401
424
  *
@@ -1029,8 +1052,17 @@ export declare class AppServer {
1029
1052
  * task is still coming back.
1030
1053
  */
1031
1054
  private listTimers;
1055
+ /** Tell every window the session's active skill changed; `null` means it has none now. */
1056
+ private emitSessionSkill;
1057
+ /**
1058
+ * Pause, resume or remove the session's skill. It takes effect from the session's next message: a
1059
+ * run already working read the skill when it started.
1060
+ */
1061
+ private updateSessionSkill;
1032
1062
  /** Say what a session is waiting on. An empty list is a real answer: it is what ends a wait. */
1033
1063
  private emitPullRequest;
1064
+ /** The pending set as a change left it, without diffs: a client reads those with `sessions.changes.list`. */
1065
+ private emitSessionChanges;
1034
1066
  /**
1035
1067
  * Start tracking `ref` for the session. A PR already tracked under the same URL keeps its settings, so a
1036
1068
  * repeated `gh pr create` (which reports the existing PR) never switches off what the user turned on.
@@ -5,7 +5,7 @@ import { ModelHealthCache } from './model-health-cache.js';
5
5
  import { mkdir, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
6
6
  import { homedir } from 'node:os';
7
7
  import { fileURLToPath } from 'node:url';
8
- import { join, resolve } from 'node:path';
8
+ import { isAbsolute, join, resolve } from 'node:path';
9
9
  import { changeConfigFile, configDirectory, ConfigConflictError, loadConfig, reconcileSubagentPair, resolveCodeIntelConfig, resolveConfiguredLimits, validateMcpServer, checkSearxngUrl, validateWebSearchConfig, WEB_SEARCH_FIELDS, WEB_SEARCH_KEY_FIELDS, WEB_SEARCH_PROVIDERS } from './config.js';
10
10
  import { isUnlimitedAlias } from './limits.js';
11
11
  import { isPermissionMode, workspacePermissionKey } from './permissions.js';
@@ -21,7 +21,7 @@ import { GROK_BASE_URL } from './grok-provider.js';
21
21
  import { anthropicAccountHome } from './anthropic-credentials.js';
22
22
  import { codexAccountHome } from './codex-rpc.js';
23
23
  import { configuredModelSnapshot, discoverModelMetadata, resolveModelContext } from './model-metadata.js';
24
- import { graphLeavesNodesToSession, isDeletedGraph, listGraphs, loadGraph, maxNodeVisitsOf, withoutDeletedGraphs } from './graphs.js';
24
+ import { graphLeavesNodesToSession, graphMcpServers, isDeletedGraph, listGraphs, loadGraph, maxNodeVisitsOf, withoutDeletedGraphs } from './graphs.js';
25
25
  import { exportAgentDefinition, readAgentDefinition } from './agent-definitions.js';
26
26
  import { blockingHealthFailures, checkGraphModelHealth, formatGraphHealthFailure, resumeModelNodes } from './graph-health.js';
27
27
  import { bindPortableGraphProviders, GraphProviderUnavailableError } from './graph-provider-portability.js';
@@ -61,10 +61,12 @@ import { readFavicon } from './favicons.js';
61
61
  import { attachmentReferenceBlock, loadResolvedImages, parsePendingAttachments, pruneAttachments, readSpooledImage, readSpooledText, resolveAttachments, attachmentReadRoots } from './attachments.js';
62
62
  import { extensionSnapshot, listBundles, installBundle, removeBundle, removeBundleTransactional, setBundleEnabled, listSkillResources, readSkillResource, writeSkillResource, resolveSkillInvocation } from './extensions.js';
63
63
  import { isBuiltinSlashCommand } from './skill-commands.js';
64
- import { connectMcpServers, mcpCatalogStore } from './mcp.js';
64
+ import { copySessionSkill, readSessionSkill, removeSessionSkill, setSessionSkillPaused, skillForRun } from './session-skills.js';
65
+ import { LIST_DIFF_LINES, MAX_DIFF_LINES, SessionChangeStore } from './session-changes.js';
66
+ import { connectMcpServers, mcpCatalogStore, mcpDefinitionKey, mcpStatusStore, mcpTaskStatusReporter, mergeMcpEdit, probeMcpServer } from './mcp.js';
65
67
  import { loadWorkspaceInstructions } from './workspace-instructions.js';
66
68
  import { DAY_MS, planAutoArchive } from './session-reaper.js';
67
- import { QA_SYSTEM_GUIDANCE, disposeAllQaProcesses, disposeAllQaPtys, onBackgroundChange } from './qa/index.js';
69
+ import { disposeAllQaProcesses, disposeAllQaPtys, onBackgroundChange } from './qa/index.js';
68
70
  import { BackgroundTasks } from './background-tasks.js';
69
71
  import { disposePooledPowerShell } from './powershell-pool.js';
70
72
  import { TodoStore } from './todos.js';
@@ -340,9 +342,50 @@ function identifier(value, name) {
340
342
  throw new AppServerError('invalid-params', `${name} must be an identifier of up to 128 word characters`);
341
343
  return value;
342
344
  }
345
+ /**
346
+ * An MCP server's id. It matches validateConfig: an existing id has no 100/128-character limit, and
347
+ * a narrower check here would make valid stored servers impossible to manage.
348
+ */
349
+ function mcpServerId(value) {
350
+ if (typeof value !== 'string' || !/^[A-Za-z0-9_-]+$/.test(value) || ['__proto__', 'constructor', 'prototype'].includes(value)) {
351
+ throw new AppServerError('invalid-params', 'MCP id must contain only letters, numbers, underscores or hyphens');
352
+ }
353
+ return value;
354
+ }
343
355
  function optionalIdentifier(value, name) {
344
356
  return value === undefined ? undefined : identifier(value, name);
345
357
  }
358
+ /** A session the review record may hold a file for: its ids are file stems, never paths. */
359
+ function changesSessionId(value) {
360
+ if (typeof value !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(value))
361
+ throw new AppServerError('invalid-params', 'id must be a session id');
362
+ return value;
363
+ }
364
+ /** One workspace-relative path of a pending change, as `sessions.changes.list` spells it. */
365
+ function changePath(value, name) {
366
+ if (typeof value !== 'string' || !value || value.length > 4096 || value.includes('\0'))
367
+ throw new AppServerError('invalid-params', `${name} must be a path the pending set lists`);
368
+ return value;
369
+ }
370
+ /** `path` names one file, `paths` several; neither means every pending file. */
371
+ function changePaths(params) {
372
+ if (params.path !== undefined && params.paths !== undefined)
373
+ throw new AppServerError('invalid-params', 'Name the files with path or paths, not both');
374
+ if (params.path !== undefined)
375
+ return [changePath(params.path, 'path')];
376
+ if (params.paths === undefined)
377
+ return undefined;
378
+ if (!Array.isArray(params.paths) || params.paths.length > 10_000)
379
+ throw new AppServerError('invalid-params', 'paths must be a list of paths the pending set lists');
380
+ return params.paths.map(entry => changePath(entry, 'paths'));
381
+ }
382
+ function diffLines(value, fallback) {
383
+ if (value === undefined)
384
+ return fallback;
385
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value > MAX_DIFF_LINES)
386
+ throw new AppServerError('invalid-params', `maxLines must be an integer from 0 to ${MAX_DIFF_LINES}`);
387
+ return value;
388
+ }
346
389
  /** A panel navigation target: HTTP(S) only, as the isolated browser will open it. */
347
390
  function viewUrl(value) {
348
391
  if (typeof value !== 'string' || !value)
@@ -884,6 +927,8 @@ export class AppServer {
884
927
  gh;
885
928
  /** Polls the PRs whose sessions asked for Auto-fix; one engine per home actually polls. */
886
929
  pullRequestWatcher;
930
+ /** The files each session's agent changed since the person last reviewed them (Keep / Undo). */
931
+ sessionChanges;
887
932
  /** The wakes this engine armed for Auto-fix, checked against the PR record again before delivery. */
888
933
  autoFixWakes = new Set();
889
934
  /**
@@ -1048,6 +1093,7 @@ export class AppServer {
1048
1093
  onStop;
1049
1094
  constructor(options) {
1050
1095
  this.directory = options.directory ?? configDirectory();
1096
+ this.sessionChanges = new SessionChangeStore(this.directory);
1051
1097
  this.output = options.output;
1052
1098
  this.error = options.error;
1053
1099
  this.checkGraphHealth = options.checkGraphHealth ?? checkGraphModelHealth;
@@ -1377,6 +1423,27 @@ export class AppServer {
1377
1423
  case 'sessions.pullRequest.dismiss':
1378
1424
  await this.dismissPullRequest(identifier(params.id, 'id'));
1379
1425
  return {};
1426
+ case 'sessions.changes.list': return this.sessionChanges.list(changesSessionId(params.id), diffLines(params.maxLines, LIST_DIFF_LINES));
1427
+ case 'sessions.changes.get': {
1428
+ const id = changesSessionId(params.id);
1429
+ return { sessionId: id, ...await this.sessionChanges.get(id, changePath(params.path, 'path'), diffLines(params.maxLines, MAX_DIFF_LINES)) };
1430
+ }
1431
+ case 'sessions.changes.keep': {
1432
+ const answer = await this.sessionChanges.keep(changesSessionId(params.id), changePaths(params));
1433
+ if (answer.kept.length)
1434
+ this.emitSessionChanges(answer);
1435
+ return answer;
1436
+ }
1437
+ case 'sessions.changes.undo': {
1438
+ if (params.force !== undefined && typeof params.force !== 'boolean')
1439
+ throw new AppServerError('invalid-params', 'force must be a boolean');
1440
+ const answer = await this.sessionChanges.undo(changesSessionId(params.id), changePaths(params), params.force === true);
1441
+ if (answer.reverted.length)
1442
+ this.emitSessionChanges(answer);
1443
+ return answer;
1444
+ }
1445
+ case 'sessions.skill.get': return { skill: (await readSessionSkill(this.directory, identifier(params.id, 'id'))) ?? null };
1446
+ case 'sessions.skill.update': return { skill: (await this.updateSessionSkill(identifier(params.id, 'id'), params)) ?? null };
1380
1447
  case 'timers.list': return this.listTimers();
1381
1448
  case 'run.start': return this.startRun(params);
1382
1449
  case 'workspace.warm': return this.warmWorkspace(params);
@@ -1471,7 +1538,7 @@ export class AppServer {
1471
1538
  if (params.mode !== undefined && params.mode !== 'desktop' && params.mode !== 'mobile')
1472
1539
  throw new AppServerError('invalid-params', 'mode must be desktop or mobile');
1473
1540
  await this.browserViews.configureStream(sessionId, {
1474
- enabled: params.enabled, viewportWidth: params.viewportWidth, viewportHeight: params.viewportHeight, quality: params.quality, mode: params.mode,
1541
+ enabled: params.enabled, viewportWidth: params.viewportWidth, viewportHeight: params.viewportHeight, quality: params.quality, mode: params.mode, scale: params.scale,
1475
1542
  });
1476
1543
  return { ok: true };
1477
1544
  }
@@ -1659,6 +1726,9 @@ export class AppServer {
1659
1726
  case 'extensions.remove': return this.removeExtension(params);
1660
1727
  case 'extensions.setEnabled': return this.setExtensionEnabled(params);
1661
1728
  case 'mcp.mutate': return this.mutateMcp(params);
1729
+ case 'mcp.get': return this.mcpServerView(params);
1730
+ case 'mcp.status': return this.mcpStatus(params);
1731
+ case 'mcp.statuses': return this.mcpStatuses();
1662
1732
  case 'projects.list': return { projects: await this.listProjects() };
1663
1733
  case 'projects.add': return this.addProject(params);
1664
1734
  case 'projects.remove': return this.removeProject(params);
@@ -2043,15 +2113,10 @@ export class AppServer {
2043
2113
  }
2044
2114
  /** Preserve MCP credentials when toggling or deleting an existing entry. */
2045
2115
  async mutateMcp(params) {
2046
- // Match validateConfig: existing MCP IDs have no 100/128-character limit.
2047
- // A narrower RPC check would make valid stored servers impossible to manage.
2048
- const id = params.id;
2049
- if (typeof id !== 'string' || !/^[A-Za-z0-9_-]+$/.test(id) || ['__proto__', 'constructor', 'prototype'].includes(id)) {
2050
- throw new AppServerError('invalid-params', 'MCP id must contain only letters, numbers, underscores or hyphens');
2051
- }
2116
+ const id = mcpServerId(params.id);
2052
2117
  const action = params.action;
2053
- if (action !== 'add' && action !== 'remove' && action !== 'setEnabled') {
2054
- throw new AppServerError('invalid-params', 'action must be add, remove or setEnabled');
2118
+ if (action !== 'add' && action !== 'update' && action !== 'remove' && action !== 'setEnabled') {
2119
+ throw new AppServerError('invalid-params', 'action must be add, update, remove or setEnabled');
2055
2120
  }
2056
2121
  if (action === 'setEnabled' && typeof params.enabled !== 'boolean') {
2057
2122
  throw new AppServerError('invalid-params', 'enabled must be a boolean');
@@ -2074,6 +2139,18 @@ export class AppServer {
2074
2139
  throw new AppServerError('busy', `MCP server ${id} already exists. Remove it before replacing it.`);
2075
2140
  servers[id] = server;
2076
2141
  }
2142
+ else if (action === 'update') {
2143
+ if (!exists)
2144
+ throw new AppServerError('not-found', `MCP server ${id} does not exist`);
2145
+ // Saved secrets never leave the engine, so an edit names the ones it keeps instead of
2146
+ // sending them back: see mergeMcpEdit.
2147
+ try {
2148
+ servers[id] = mergeMcpEdit(servers[id], params.server);
2149
+ }
2150
+ catch (error) {
2151
+ throw new AppServerError('invalid-params', message(error));
2152
+ }
2153
+ }
2077
2154
  else {
2078
2155
  if (!exists)
2079
2156
  throw new AppServerError('not-found', `MCP server ${id} does not exist`);
@@ -2089,6 +2166,68 @@ export class AppServer {
2089
2166
  return { id };
2090
2167
  });
2091
2168
  }
2169
+ /**
2170
+ * One configured MCP server as an edit form can show it: the command and its arguments, or the
2171
+ * endpoint, and the *names* of its environment variables and headers. Their values are secrets
2172
+ * the engine never returns; an edit keeps a saved value by naming it (see mergeMcpEdit). The
2173
+ * endpoint is returned without its query string, which can hold a credential.
2174
+ */
2175
+ async mcpServerView(params) {
2176
+ const id = mcpServerId(params.id);
2177
+ const servers = (await loadConfig(this.directory)).mcpServers ?? {};
2178
+ if (!Object.prototype.hasOwnProperty.call(servers, id))
2179
+ throw new AppServerError('not-found', `MCP server ${id} does not exist`);
2180
+ const server = servers[id];
2181
+ const enabled = server.enabled !== false;
2182
+ if (server.transport === 'stdio') {
2183
+ return { id, transport: 'stdio', enabled, command: server.command, args: server.args ?? [], envKeys: Object.keys(server.env ?? {}) };
2184
+ }
2185
+ const url = new URL(server.url);
2186
+ const query = url.search !== '';
2187
+ url.search = '';
2188
+ return { id, transport: 'http', enabled, url: url.href, ...(query ? { urlQuery: true } : {}), headerKeys: Object.keys(server.headers ?? {}) };
2189
+ }
2190
+ /**
2191
+ * Check one configured MCP server, on the person's explicit request ("Check Connection"): start
2192
+ * it, ask for its tools, stop it, and record the answer beside the ones tasks record. A server that
2193
+ * is turned off is reported off without being started. A stdio server starts in the workspace the
2194
+ * caller names, as it would for a task there, or the home folder. A page never calls this on its
2195
+ * own: a task asks before it connects a server, and opening Settings is not that consent.
2196
+ */
2197
+ async mcpStatus(params) {
2198
+ const id = mcpServerId(params.id);
2199
+ const servers = (await loadConfig(this.directory)).mcpServers ?? {};
2200
+ if (!Object.prototype.hasOwnProperty.call(servers, id))
2201
+ throw new AppServerError('not-found', `MCP server ${id} does not exist`);
2202
+ const server = servers[id];
2203
+ if (server.enabled === false)
2204
+ return { id, state: 'off' };
2205
+ const named = typeof params.workspace === 'string' && isAbsolute(params.workspace) ? params.workspace : undefined;
2206
+ const workspace = named !== undefined && await stat(named).then(entry => entry.isDirectory(), () => false) ? named : homedir();
2207
+ const result = await probeMcpServer(server, workspace);
2208
+ const checkedAt = new Date();
2209
+ await mcpStatusStore(this.directory).record(id, server, result, 'check', checkedAt).catch(() => undefined);
2210
+ return { id, ...result, checkedAt: checkedAt.toISOString(), source: 'check' };
2211
+ }
2212
+ /**
2213
+ * What each configured server last answered, without starting anything: the status a task's
2214
+ * connection or an explicit check recorded, while it still describes the server's current
2215
+ * definition. An edited server, and one never connected, has none ("Not checked").
2216
+ */
2217
+ async mcpStatuses() {
2218
+ const servers = (await loadConfig(this.directory)).mcpServers ?? {};
2219
+ const statuses = {};
2220
+ for (const record of await mcpStatusStore(this.directory).list()) {
2221
+ if (!Object.prototype.hasOwnProperty.call(servers, record.id))
2222
+ continue;
2223
+ const server = servers[record.id];
2224
+ if (mcpDefinitionKey(server) !== record.definition)
2225
+ continue;
2226
+ const { id: _id, definition: _definition, ...status } = record;
2227
+ statuses[record.id] = status;
2228
+ }
2229
+ return { statuses };
2230
+ }
2092
2231
  /**
2093
2232
  * Apply one provider change inside the serialized configuration transaction.
2094
2233
  *
@@ -2460,6 +2599,11 @@ export class AppServer {
2460
2599
  ...(access.dailyDecisionLimit === undefined ? {} : { dailyDecisionLimit: access.dailyDecisionLimit }),
2461
2600
  ...(access.dailyDecisionUsed === undefined ? {} : { dailyDecisionUsed: access.dailyDecisionUsed }),
2462
2601
  ...(access.decisionsSinceRollout === undefined ? {} : { decisionsSinceRollout: access.decisionsSinceRollout }),
2602
+ ...(access.fairUse === undefined ? {} : { fairUse: access.fairUse }),
2603
+ ...(access.windowDays === undefined ? {} : { windowDays: access.windowDays }),
2604
+ ...(access.windowDecisionLimit === undefined ? {} : { windowDecisionLimit: access.windowDecisionLimit }),
2605
+ ...(access.windowDecisionUsed === undefined ? {} : { windowDecisionUsed: access.windowDecisionUsed }),
2606
+ ...(access.windowDecisionResetsAt === undefined ? {} : { windowDecisionResetsAt: access.windowDecisionResetsAt }),
2463
2607
  ...(access.billingUrl === undefined ? {} : { billingUrl: access.billingUrl }),
2464
2608
  };
2465
2609
  return { account };
@@ -2816,6 +2960,10 @@ export class AppServer {
2816
2960
  await this.browserViews.release(id, 'That session was deleted.');
2817
2961
  // Its pull request stops being watched with it: an Auto-fix wake has no conversation left to land in.
2818
2962
  await removePullRequest(this.directory, id).catch(() => { });
2963
+ await removeSessionSkill(this.directory, id).catch(() => { });
2964
+ // The stored originals of its unreviewed changes go too: nothing can ask to undo them any more.
2965
+ if (/^[A-Za-z0-9_-]{1,128}$/.test(id))
2966
+ await this.sessionChanges.remove(id).catch(() => { });
2819
2967
  this.emit('session.removed', { id });
2820
2968
  return { removed: true };
2821
2969
  });
@@ -3459,6 +3607,8 @@ export class AppServer {
3459
3607
  record = { ...forked, id: randomUUID(), parentId: existing.id,
3460
3608
  ancestors: lineageThrough(existing.ancestors, existing.id), inheritedUsage: { ...existing.usage },
3461
3609
  inheritedTurns: existing.history.length, lineage: lineagePoints(existing, existing.usage, existing.history.length) };
3610
+ // The fork continues the parent's conversation, so it keeps following the skill the parent was.
3611
+ await copySessionSkill(this.directory, existing.id, record.id).catch(error => this.log('warn', `Could not carry the session's active skill to its continuation: ${message(error)}`));
3462
3612
  }
3463
3613
  record = { ...record, workspace: root, projectId: record.projectId ?? projectIdentity(root), updatedAt: new Date().toISOString() };
3464
3614
  const controller = new AbortController();
@@ -4240,7 +4390,13 @@ export class AppServer {
4240
4390
  // dispatched, so the naming request waits for a signal this run publishes.
4241
4391
  if (params.sessionId === undefined)
4242
4392
  this.titleSessionFromPrompt(record, task, provider, modelId, runId);
4243
- const runTask = this.executeRun({ runId, startedAt, telemetryRunId, ...(accountSubject ? { accountSubject } : {}), task, selection, providerId: provider.id, modelId, root, permissions: effective, liveSteers, ...(internal?.inheritedPermissions === undefined ? {} : { boundPermissions: internal.inheritedPermissions }), ...(effort === undefined ? {} : { reasoningEffort: effort }), ...(overrideAllNodes ? { overrideAllNodes: true } : {}), ...(modelPinned ? { modelPinned: true } : {}), ...(nodeModelOverrides === undefined ? {} : { nodeModelOverrides }), ...(panelRelay ? { panelBrowserRelay: true } : {}), ...(entryHistory ? { entryHistory: true } : {}), ...(runInput === undefined ? {} : { runInput }), ...(runState === undefined ? {} : { runState }), ...(automationContext === undefined ? {} : { automationContext }), ...(resumedDirection === undefined ? {} : { direction: resumedDirection }), ...(wake === undefined ? {} : { wake }), ...(directionNode === undefined ? {} : { directionNode }), ...(armedCarried.length === 0 ? {} : { carriedDirections: armedCarried, pendingDirections: armedCarried.map(entry => ({ runId: entry.runId, direction: entry.direction, ...(entry.id === undefined ? {} : { id: entry.id }), ...wakeProvenance(entry.wake, entry.node) })) }), ownDirectionId: `${runId}#own`, ...(seedExclusions.length === 0 ? {} : { armedRunIds: seedExclusions }), ...(openingAttachments === undefined ? {} : { openingAttachments }), record, controller, ...(attachments === undefined ? {} : { attachments }), ...(internal?.resumedFrom === undefined ? {} : { resumedFrom: internal.resumedFrom }), ...(resumeFrom === undefined ? {} : { resumeFrom }), lineage, ...(lineageArtifacts === undefined ? {} : { lineageArtifacts }), ...(resumedGraph === undefined ? {} : { prepared: resumedGraph }) })
4393
+ // The text that may invoke a skill is a message the user just sent: a new run's task, or the
4394
+ // direction sent with a resume. A resume otherwise replays the stopped attempt's own task, or
4395
+ // recovers its own direction, or delivers a wake — none of which is a new invocation, and reading
4396
+ // one as such would rewrite the session's skill and undo a pause or removal made since the stop.
4397
+ const invocationText = internal?.resumedFrom === undefined ? task
4398
+ : internal.recoveredDirection === true || internal.wake !== undefined ? undefined : internal.direction;
4399
+ const runTask = this.executeRun({ runId, startedAt, telemetryRunId, ...(accountSubject ? { accountSubject } : {}), ...(invocationText === undefined ? {} : { invocationText }), task, selection, providerId: provider.id, modelId, root, permissions: effective, liveSteers, ...(internal?.inheritedPermissions === undefined ? {} : { boundPermissions: internal.inheritedPermissions }), ...(effort === undefined ? {} : { reasoningEffort: effort }), ...(overrideAllNodes ? { overrideAllNodes: true } : {}), ...(modelPinned ? { modelPinned: true } : {}), ...(nodeModelOverrides === undefined ? {} : { nodeModelOverrides }), ...(panelRelay ? { panelBrowserRelay: true } : {}), ...(entryHistory ? { entryHistory: true } : {}), ...(runInput === undefined ? {} : { runInput }), ...(runState === undefined ? {} : { runState }), ...(automationContext === undefined ? {} : { automationContext }), ...(resumedDirection === undefined ? {} : { direction: resumedDirection }), ...(wake === undefined ? {} : { wake }), ...(directionNode === undefined ? {} : { directionNode }), ...(armedCarried.length === 0 ? {} : { carriedDirections: armedCarried, pendingDirections: armedCarried.map(entry => ({ runId: entry.runId, direction: entry.direction, ...(entry.id === undefined ? {} : { id: entry.id }), ...wakeProvenance(entry.wake, entry.node) })) }), ownDirectionId: `${runId}#own`, ...(seedExclusions.length === 0 ? {} : { armedRunIds: seedExclusions }), ...(openingAttachments === undefined ? {} : { openingAttachments }), record, controller, ...(attachments === undefined ? {} : { attachments }), ...(internal?.resumedFrom === undefined ? {} : { resumedFrom: internal.resumedFrom }), ...(resumeFrom === undefined ? {} : { resumeFrom }), lineage, ...(lineageArtifacts === undefined ? {} : { lineageArtifacts }), ...(resumedGraph === undefined ? {} : { prepared: resumedGraph }) })
4244
4400
  .catch(error => this.log('error', `Run ${runId} failed: ${message(error)}`));
4245
4401
  // The finally sits outside the awaited chain so the settle can name the exact promise this
4246
4402
  // attempt owns: the finalizer now releases the live-run slot before the terminal events, so a
@@ -4787,11 +4943,19 @@ export class AppServer {
4787
4943
  // may have a different window.
4788
4944
  contextWindow = snapshot.contextWindow;
4789
4945
  this.emit('run.context', { runId, provider: provider.id, model: snapshot.model, ...(snapshot.contextWindow === undefined ? {} : { contextWindow: snapshot.contextWindow }), ...(snapshot.reasoningEffort === undefined ? {} : { reasoningEffort: snapshot.reasoningEffort }) });
4790
- const invocationInput = direction ?? task;
4946
+ const invocationInput = input.invocationText;
4791
4947
  bootMark('run.exec.model-context.resolved');
4792
- const invocation = isBuiltinSlashCommand(invocationInput) ? undefined : await resolveSkillInvocation(invocationInput, config, signal, this.directory);
4948
+ const invocation = invocationInput === undefined || isBuiltinSlashCommand(invocationInput) ? undefined : await resolveSkillInvocation(invocationInput, config, signal, this.directory);
4949
+ // A slash invocation becomes the session's skill, and a later message without one inherits it
4950
+ // (see `src/session-skills.ts`): the skill's requirements apply to the whole conversation, not
4951
+ // only to the message that named it.
4952
+ const runSkill = await skillForRun({ invocation, home: this.directory, sessionId: input.record.id, config, signal });
4953
+ if (runSkill.recorded)
4954
+ this.emitSessionSkill(input.record.id, runSkill.recorded);
4955
+ if (runSkill.notice)
4956
+ this.emit('log', { level: 'warn', message: runSkill.notice });
4793
4957
  bootMark('run.exec.skill-invocation.resolved');
4794
- const extension = await extensionSnapshot(config, signal, this.directory, invocation?.id);
4958
+ const extension = await extensionSnapshot(config, signal, this.directory, runSkill.skill?.id);
4795
4959
  for (const notice of extension.notices)
4796
4960
  this.emit('log', { level: 'info', message: notice });
4797
4961
  bootMark('run.exec.extensions.loaded');
@@ -4856,6 +5020,8 @@ export class AppServer {
4856
5020
  timers: this.timers, sessionScope: input.record.id, wakesArmed, automationDirectory: this.directory,
4857
5021
  wakeCarry,
4858
5022
  pullRequests: this.pullRequestControl(input.record.id, wakeCarry),
5023
+ // Every write the run makes to a workspace file is kept for review under the session it belongs to.
5024
+ fileChanges: this.sessionChanges.recorder(input.record.id, root, changes => this.emitSessionChanges(changes), error => this.log('warn', `Could not record a file change for review: ${message(error)}`)),
4859
5025
  };
4860
5026
  bootMark('run.exec.mcp.connect.start');
4861
5027
  // The health verdict is watched while the servers connect, not after: a server can wait on the
@@ -4872,8 +5038,9 @@ export class AppServer {
4872
5038
  // process starts beside the first model request rather than in front of it: starting a stdio
4873
5039
  // server and listing its tools is seconds of work the first node does not need the result of
4874
5040
  // until a model calls one of those tools, and that call waits for the connection.
4875
- const connecting = Object.keys(extension.servers).length
4876
- ? connectMcpServers(extension.servers, { ...toolContext, signal: setupSignal, userSignal: setupSignal }, detail => this.emit('log', { level: 'info', message: detail }), setupSignal, { catalogs: mcpCatalogStore(this.directory) })
5041
+ const servers = graphMcpServers(graph.id, extension.servers);
5042
+ const connecting = Object.keys(servers).length
5043
+ ? connectMcpServers(servers, { ...toolContext, signal: setupSignal, userSignal: setupSignal }, detail => this.emit('log', { level: 'info', message: detail }), setupSignal, { catalogs: mcpCatalogStore(this.directory), status: mcpTaskStatusReporter(this.directory) })
4877
5044
  : Promise.resolve(undefined);
4878
5045
  try {
4879
5046
  mcp = await Promise.race([connecting, healthGate.then(() => connecting)]);
@@ -4913,8 +5080,8 @@ export class AppServer {
4913
5080
  // CLI builds its toolset without an app-server and never sees it.
4914
5081
  tools: [...createTools(), createBrowserPanelTool(this.browserViews, input.record.id, panelBrowserRelay ? this.panelBrowserRelayFor(input.record.id) : undefined),
4915
5082
  createBrowserIncognitoTool(this.browserViews, input.record.id, panelBrowserRelay ? this.panelBrowserRelayFor(input.record.id) : undefined), ...extension.tools, ...(mcp?.tools ?? [])], installedSkillClaims: extension.claimsSkillName, history: contextSeed,
4916
- ...(invocation ? { inheritedSkills: [invocation.id], skillInvocationInstruction: invocation.task } : {}),
4917
- instructions: `${await loadWorkspaceInstructions(root, signal, config.systemPromptOverride)}\n${QA_SYSTEM_GUIDANCE}${extension.instructions}`,
5083
+ ...(runSkill.skill ? { inheritedSkills: [runSkill.skill.id], skillInvocationInstruction: runSkill.skill.instruction } : {}),
5084
+ instructions: `${await loadWorkspaceInstructions(root, signal, config.systemPromptOverride)}${extension.instructions}`,
4918
5085
  codeIntel, todoStore: new TodoStore(), ...(commandMemory ? { commandMemory } : {}),
4919
5086
  limits: resolveConfiguredLimits(config),
4920
5087
  ...hostedDecisionPolicy(membership, config.jevEnabled !== false, config.decisions),
@@ -7206,10 +7373,36 @@ export class AppServer {
7206
7373
  }
7207
7374
  return { sessions: [...owners].map(sessionId => ({ sessionId, timers: this.timersFor(sessionId) })) };
7208
7375
  }
7376
+ /** Tell every window the session's active skill changed; `null` means it has none now. */
7377
+ emitSessionSkill(sessionId, skill) {
7378
+ this.emit('session.skill.updated', { sessionId, skill });
7379
+ }
7380
+ /**
7381
+ * Pause, resume or remove the session's skill. It takes effect from the session's next message: a
7382
+ * run already working read the skill when it started.
7383
+ */
7384
+ async updateSessionSkill(sessionId, params) {
7385
+ if (params.remove === true) {
7386
+ await removeSessionSkill(this.directory, sessionId);
7387
+ this.emitSessionSkill(sessionId, null);
7388
+ return undefined;
7389
+ }
7390
+ if (typeof params.paused !== 'boolean')
7391
+ throw new AppServerError('invalid-params', 'paused must be a boolean, or remove must be true');
7392
+ const skill = await setSessionSkillPaused(this.directory, sessionId, params.paused);
7393
+ if (!skill)
7394
+ throw new AppServerError('not-found', 'This session has no active skill.');
7395
+ this.emitSessionSkill(sessionId, skill);
7396
+ return skill;
7397
+ }
7209
7398
  /** Say what a session is waiting on. An empty list is a real answer: it is what ends a wait. */
7210
7399
  emitPullRequest(sessionId, pullRequest) {
7211
7400
  this.emit('session.pullRequest.updated', { sessionId, pullRequest: pullRequestForClients(pullRequest) });
7212
7401
  }
7402
+ /** The pending set as a change left it, without diffs: a client reads those with `sessions.changes.list`. */
7403
+ emitSessionChanges(changes) {
7404
+ this.emit('session.changes.updated', { sessionId: changes.sessionId, revision: changes.revision, changes: changes.changes });
7405
+ }
7213
7406
  /**
7214
7407
  * Start tracking `ref` for the session. A PR already tracked under the same URL keeps its settings, so a
7215
7408
  * repeated `gh pr create` (which reports the existing PR) never switches off what the user turned on.
@@ -38,6 +38,12 @@ export declare class AuthManager {
38
38
  private readonly store;
39
39
  private readonly fetch;
40
40
  private readonly keys;
41
+ /**
42
+ * A rotated session this process holds but could not save, and the stored refresh token it
43
+ * replaced. The server already retired that stored token, so until a save lands this copy is the
44
+ * only live credential (see `rotate`).
45
+ */
46
+ private unsaved?;
41
47
  constructor(options: {
42
48
  config: AuthConfiguration;
43
49
  store?: CredentialStore;
@@ -98,6 +104,15 @@ export declare class AuthManager {
98
104
  * for what they *observe* (`getAccessToken` checks the signal once the exchange has landed).
99
105
  */
100
106
  private rotate;
107
+ /**
108
+ * The envelope to work from: the store's, or the rotated session this process could not save.
109
+ *
110
+ * The kept session stands in only while the store still holds the exact token it replaced, under
111
+ * the same login generation. Anything else means another process signed in, signed out or saved
112
+ * its own rotation, and the store is the newer answer. A store left unreadable by a failed save
113
+ * cannot say either way, so the kept session is used until a save repairs it.
114
+ */
115
+ private current;
101
116
  /**
102
117
  * Request one rotation, repeating a lost response once inside the server's retry grace.
103
118
  *