@cortex-agent/server 2026.10.21 → 2026.10.25

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 (194) hide show
  1. package/README.md +10 -6
  2. package/defaults/context/projects/AGENTS.md +1 -1
  3. package/defaults/gitignore +3 -3
  4. package/defaults/hooks/new-session-hook.mjs +1 -1
  5. package/defaults/hooks/status-md-guard.mjs +6 -6
  6. package/defaults/plugins/cortex-system/plugin.json +1 -1
  7. package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +16 -9
  8. package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +2 -2
  9. package/defaults/rules/agents-md.md +1 -1
  10. package/defaults/rules/issues-md.md +1 -1
  11. package/defaults/rules/meta-conventions.md +3 -3
  12. package/defaults/rules/mission-md.md +1 -1
  13. package/defaults/rules/status-md.md +1 -1
  14. package/dist/agent-adapter/claude/bg-task-tracker.d.ts +3 -1
  15. package/dist/agent-adapter/claude/bg-task-tracker.js +6 -2
  16. package/dist/agent-adapter/claude/mcp-config.js +11 -0
  17. package/dist/agent-adapter/claude/turn-machine.d.ts +2 -1
  18. package/dist/agent-adapter/claude/turn-machine.js +8 -5
  19. package/dist/agent-adapter/continuation-phase.d.ts +6 -3
  20. package/dist/agent-adapter/continuation-phase.js +8 -3
  21. package/dist/agent-adapter/run-events.d.ts +4 -0
  22. package/dist/agent-adapter/types.d.ts +9 -2
  23. package/dist/build-info.json +1 -0
  24. package/dist/client-bundle/client.mjs +10 -5
  25. package/dist/client-bundle/manifest.json +2 -2
  26. package/dist/core/claude-credentials.d.ts +6 -0
  27. package/dist/core/claude-credentials.js +11 -0
  28. package/dist/core/gateway-generator.d.ts +17 -0
  29. package/dist/core/gateway-generator.js +42 -4
  30. package/dist/core/hook-bus.d.ts +1 -1
  31. package/dist/core/hook-bus.js +1 -8
  32. package/dist/core/locales/en.d.ts +1 -0
  33. package/dist/core/locales/slices/init.d.ts +1 -0
  34. package/dist/core/locales/slices/init.js +2 -0
  35. package/dist/core/log.d.ts +3 -0
  36. package/dist/core/log.js +18 -1
  37. package/dist/core/settings-spec.d.ts +5 -0
  38. package/dist/core/settings-spec.js +4 -0
  39. package/dist/core/types/agent-types.d.ts +3 -1
  40. package/dist/core/types/environment-types.d.ts +1 -6
  41. package/dist/domain/agents/environments/registry.js +3 -2
  42. package/dist/domain/agents/environments/schema.d.ts +3 -2
  43. package/dist/domain/agents/environments/schema.js +4 -3
  44. package/dist/domain/auth/auth-watch.js +48 -18
  45. package/dist/domain/mcp/tools/context.d.ts +0 -1
  46. package/dist/domain/mcp/tools/context.js +0 -1
  47. package/dist/domain/monitor/event-loop-monitor.d.ts +2 -0
  48. package/dist/domain/monitor/event-loop-monitor.js +5 -1
  49. package/dist/domain/plugins/authoring.d.ts +8 -1
  50. package/dist/domain/plugins/authoring.js +24 -9
  51. package/dist/domain/plugins/runtime-gc.d.ts +7 -0
  52. package/dist/domain/plugins/runtime-gc.js +52 -19
  53. package/dist/domain/plugins/runtime.js +2 -1
  54. package/dist/domain/remote/client-bootstrap.js +1 -1
  55. package/dist/domain/remote/client-manager.js +6 -1
  56. package/dist/domain/runs/retryable-errors.js +3 -1
  57. package/dist/domain/runs/service.d.ts +0 -9
  58. package/dist/domain/runs/service.js +29 -15
  59. package/dist/domain/scheduling/builtin-job-controller.d.ts +3 -1
  60. package/dist/domain/scheduling/builtin-job-controller.js +5 -2
  61. package/dist/domain/scheduling/builtin-jobs.js +7 -0
  62. package/dist/domain/scheduling/scheduler.js +14 -5
  63. package/dist/domain/system/server-update-check.js +2 -1
  64. package/dist/domain/telemetry/bus-collector.d.ts +3 -0
  65. package/dist/domain/telemetry/bus-collector.js +22 -0
  66. package/dist/domain/telemetry/child-exit.d.ts +11 -0
  67. package/dist/domain/telemetry/child-exit.js +36 -0
  68. package/dist/domain/telemetry/client-kind.d.ts +4 -0
  69. package/dist/domain/telemetry/client-kind.js +7 -0
  70. package/dist/domain/telemetry/crash-limits.d.ts +15 -0
  71. package/dist/domain/telemetry/crash-limits.js +50 -0
  72. package/dist/domain/telemetry/crash.d.ts +25 -0
  73. package/dist/domain/telemetry/crash.js +70 -0
  74. package/dist/domain/telemetry/daily-upload.d.ts +5 -0
  75. package/dist/domain/telemetry/daily-upload.js +20 -0
  76. package/dist/domain/telemetry/daily.d.ts +5 -0
  77. package/dist/domain/telemetry/daily.js +104 -0
  78. package/dist/domain/telemetry/endpoint.d.ts +7 -0
  79. package/dist/domain/telemetry/endpoint.js +40 -0
  80. package/dist/domain/telemetry/envelope.d.ts +6 -0
  81. package/dist/domain/telemetry/envelope.js +35 -0
  82. package/dist/domain/telemetry/error-digest.d.ts +7 -0
  83. package/dist/domain/telemetry/error-digest.js +43 -0
  84. package/dist/domain/telemetry/funnel.d.ts +6 -0
  85. package/dist/domain/telemetry/funnel.js +22 -0
  86. package/dist/domain/telemetry/gate.d.ts +19 -0
  87. package/dist/domain/telemetry/gate.js +67 -0
  88. package/dist/domain/telemetry/heartbeat.d.ts +17 -0
  89. package/dist/domain/telemetry/heartbeat.js +49 -0
  90. package/dist/domain/telemetry/info.d.ts +9 -0
  91. package/dist/domain/telemetry/info.js +12 -0
  92. package/dist/domain/telemetry/init-answer.d.ts +12 -0
  93. package/dist/domain/telemetry/init-answer.js +42 -0
  94. package/dist/domain/telemetry/install-id.d.ts +5 -0
  95. package/dist/domain/telemetry/install-id.js +42 -0
  96. package/dist/domain/telemetry/normalize.d.ts +33 -0
  97. package/dist/domain/telemetry/normalize.js +88 -0
  98. package/dist/domain/telemetry/outbox.d.ts +18 -0
  99. package/dist/domain/telemetry/outbox.js +93 -0
  100. package/dist/domain/telemetry/panic-group.d.ts +4 -0
  101. package/dist/domain/telemetry/panic-group.js +51 -0
  102. package/dist/domain/telemetry/paths.d.ts +7 -0
  103. package/dist/domain/telemetry/paths.js +11 -0
  104. package/dist/domain/telemetry/redact.d.ts +18 -0
  105. package/dist/domain/telemetry/redact.js +109 -0
  106. package/dist/domain/telemetry/rollup-types.d.ts +81 -0
  107. package/dist/domain/telemetry/rollup-types.js +31 -0
  108. package/dist/domain/telemetry/rollup.d.ts +16 -0
  109. package/dist/domain/telemetry/rollup.js +102 -0
  110. package/dist/domain/telemetry/schema.d.ts +931 -0
  111. package/dist/domain/telemetry/schema.js +275 -0
  112. package/dist/domain/telemetry/service.d.ts +34 -0
  113. package/dist/domain/telemetry/service.js +146 -0
  114. package/dist/domain/telemetry/state.d.ts +17 -0
  115. package/dist/domain/telemetry/state.js +29 -0
  116. package/dist/domain/telemetry/turns.d.ts +17 -0
  117. package/dist/domain/telemetry/turns.js +176 -0
  118. package/dist/domain/telemetry/upgrade.d.ts +14 -0
  119. package/dist/domain/telemetry/upgrade.js +87 -0
  120. package/dist/domain/telemetry/uploader.d.ts +21 -0
  121. package/dist/domain/telemetry/uploader.js +82 -0
  122. package/dist/domain/telemetry/usage.d.ts +25 -0
  123. package/dist/domain/telemetry/usage.js +153 -0
  124. package/dist/domain/telemetry/web-report.d.ts +8 -0
  125. package/dist/domain/telemetry/web-report.js +15 -0
  126. package/dist/domain/ui-service/app-router.d.ts +69 -25
  127. package/dist/domain/ui-service/app-router.js +9 -2
  128. package/dist/domain/ui-service/input-schemas.d.ts +68 -4
  129. package/dist/domain/ui-service/input-schemas.js +9 -1
  130. package/dist/domain/ui-service/mutate/approvals.d.ts +3 -2
  131. package/dist/domain/ui-service/mutate/approvals.js +3 -2
  132. package/dist/domain/ui-service/mutate/plugin-packages.js +1 -1
  133. package/dist/domain/ui-service/mutate/telemetry.d.ts +5 -0
  134. package/dist/domain/ui-service/mutate/telemetry.js +6 -0
  135. package/dist/domain/ui-service/query/approvals.js +4 -3
  136. package/dist/domain/ui-service/query/machine-probe.d.ts +1 -1
  137. package/dist/domain/ui-service/query/machine-probe.js +3 -2
  138. package/dist/domain/ui-service/query/models.d.ts +3 -0
  139. package/dist/domain/ui-service/query/models.js +47 -30
  140. package/dist/domain/ui-service/query/plugin-source.js +4 -3
  141. package/dist/domain/ui-service/query/sessions.js +1 -0
  142. package/dist/domain/ui-service/query/telemetry.d.ts +3 -0
  143. package/dist/domain/ui-service/query/telemetry.js +4 -0
  144. package/dist/domain/ui-service/trpc.d.ts +8 -3
  145. package/dist/domain/ui-service/trpc.js +1 -1
  146. package/dist/domain/ui-service/types.d.ts +20 -2
  147. package/dist/domain/ui-service/ui-service.d.ts +33 -4
  148. package/dist/domain/ui-service/ui-service.js +19 -18
  149. package/dist/entry/app.js +20 -2
  150. package/dist/entry/cli-help.js +27 -14
  151. package/dist/entry/daemon.d.ts +1 -1
  152. package/dist/entry/daemon.js +86 -72
  153. package/dist/entry/init.d.ts +3 -0
  154. package/dist/entry/init.js +50 -28
  155. package/dist/entry/shutdown.js +3 -0
  156. package/dist/entry/signal-cli.js +8 -11
  157. package/dist/entry/start-ui-http.js +40 -18
  158. package/dist/entry/telemetry-wiring.d.ts +12 -0
  159. package/dist/entry/telemetry-wiring.js +56 -0
  160. package/dist/entry/ui-cli.d.ts +0 -11
  161. package/dist/entry/ui-cli.js +42 -33
  162. package/dist/events/event-types.d.ts +1 -4
  163. package/dist/orchestration/routing/message-router.js +2 -0
  164. package/dist/orchestration/routing/webhook.js +2 -0
  165. package/dist/orchestration/transcript-sink.d.ts +6 -0
  166. package/dist/orchestration/transcript-sink.js +17 -0
  167. package/dist/orchestration/waitpoint-ingress.js +3 -0
  168. package/dist/platform/ui-http/ui-auth-routes.d.ts +2 -0
  169. package/dist/platform/ui-http/ui-auth-routes.js +9 -2
  170. package/dist/platform/ui-http/ui-device-routes.d.ts +13 -0
  171. package/dist/platform/ui-http/ui-device-routes.js +81 -0
  172. package/dist/platform/ui-http/ui-devices.d.ts +24 -0
  173. package/dist/platform/ui-http/ui-devices.js +107 -0
  174. package/dist/platform/ui-http/ui-http-server.d.ts +10 -3
  175. package/dist/platform/ui-http/ui-http-server.js +11 -7
  176. package/dist/platform/ui-http/ui-pairing.d.ts +25 -0
  177. package/dist/platform/ui-http/ui-pairing.js +98 -0
  178. package/dist/store/gitignore-migration.d.ts +2 -0
  179. package/dist/store/gitignore-migration.js +16 -0
  180. package/dist/store/hook-registry.d.ts +1 -1
  181. package/dist/store/hook-registry.js +11 -6
  182. package/dist/store/session-registry-journal.js +3 -0
  183. package/dist/store/version-migrations.d.ts +5 -0
  184. package/dist/store/version-migrations.js +117 -80
  185. package/dist/tui/components/Dashboard.js +4 -3
  186. package/dist/tui/hooks/useDashboardData.js +1 -1
  187. package/package.json +3 -3
  188. package/web/dist/assets/{board-math-css-CB4GJ6qO.js → board-math-css-spk7yR6n.js} +1 -1
  189. package/web/dist/assets/index-BQ69u-92.css +1 -0
  190. package/web/dist/assets/{index-cIGFv27z.js → index-CKNLatCd.js} +1 -1
  191. package/web/dist/assets/index-CkzWfC98.js +525 -0
  192. package/web/dist/index.html +2 -2
  193. package/web/dist/assets/index-CaSZPg_H.css +0 -1
  194. package/web/dist/assets/index-CzOR7Edh.js +0 -522
package/README.md CHANGED
@@ -25,11 +25,11 @@ keeps every result in plain files that outlast any session, and asks you only wh
25
25
 
26
26
  | Platform | Installer |
27
27
  |---|---|
28
- | macOS · Apple Silicon | [Cortex-2026.10.21-macOS-aarch64.dmg](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-macOS-aarch64.dmg) |
29
- | macOS · Intel | [Cortex-2026.10.21-macOS-x86_64.dmg](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-macOS-x86_64.dmg) |
30
- | Windows · x64 | [Cortex-2026.10.21-Windows-x86_64-setup.exe](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-Windows-x86_64-setup.exe) |
31
- | Linux · x86_64 | [AppImage](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-Linux-x86_64.AppImage) · [deb](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-Linux-amd64.deb) · [rpm](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-Linux-x86_64.rpm) |
32
- | Android · arm64 | [Cortex-2026.10.21-Android-arm64.apk](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.21/Cortex-2026.10.21-Android-arm64.apk) |
28
+ | macOS · Apple Silicon | [Cortex-2026.10.25-macOS-aarch64.dmg](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-macOS-aarch64.dmg) |
29
+ | macOS · Intel | [Cortex-2026.10.25-macOS-x86_64.dmg](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-macOS-x86_64.dmg) |
30
+ | Windows · x64 | [Cortex-2026.10.25-Windows-x86_64-setup.exe](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-Windows-x86_64-setup.exe) |
31
+ | Linux · x86_64 | [AppImage](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-Linux-x86_64.AppImage) · [deb](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-Linux-amd64.deb) · [rpm](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-Linux-x86_64.rpm) |
32
+ | Android · arm64 | [Cortex-2026.10.25-Android-arm64.apk](https://github.com/fangxm233/cortex-agent/releases/download/server-v2026.10.25/Cortex-2026.10.25-Android-arm64.apk) |
33
33
 
34
34
  The desktop app installs and starts a Cortex server on the same computer in one click, with no
35
35
  terminal and no Node.js to set up, or connects to a server you already run. The Android app connects
@@ -174,7 +174,11 @@ cortex daemon # start the server in the background
174
174
  ```
175
175
 
176
176
  Open `http://127.0.0.1:3004` on the server, or connect the desktop or Android app with the
177
- server's address and client token. [Quickstart →](https://fangxm233.github.io/cortex-agent/quickstart/)
177
+ server's address and a one-time pairing code from `cortex ui pair`. [Quickstart →](https://fangxm233.github.io/cortex-agent/quickstart/)
178
+
179
+ Cortex sends anonymous crash reports and usage statistics, never conversations, files or names.
180
+ `cortex init` and the desktop setup offer the choice, and **Settings → Privacy** turns it off.
181
+ [Telemetry →](https://fangxm233.github.io/cortex-agent/telemetry/)
178
182
 
179
183
  ### Other ways in
180
184
 
@@ -12,7 +12,7 @@ One subdirectory per active project.
12
12
 
13
13
  | File | Type | Purpose |
14
14
  |------|------|---------|
15
- | `STATUS.md` | Overwrite | Present-tense state register: overwritten when the project situation changes (hard cap 80 lines AND 6KB; see rules/status-md.md) |
15
+ | `STATUS.md` | Overwrite | Present-tense state register: overwritten when the project situation changes (hard caps <=80 lines and <=6KB, exceeding either is rejected; see rules/status-md.md) |
16
16
  | `ISSUES.md` | Append | Record issues affecting work efficiency |
17
17
  | `experiments/` | Atomic file | One `.md` file per experiment (YAML frontmatter + body), `index.md` auto-generated |
18
18
  | `knowledge/` | Atomic file | One `.md` file per knowledge entry, `index.md` auto-generated |
@@ -38,9 +38,9 @@ __pycache__/
38
38
  .venv/
39
39
 
40
40
  # Generated: memory index files (auto-rebuilt by memory-watcher / memory-index-regen)
41
- projects/*/experiments/index.md
42
- projects/*/knowledge/index.md
43
- projects/*/patterns/index.md
41
+ context/projects/*/experiments/index.md
42
+ context/projects/*/knowledge/index.md
43
+ context/projects/*/patterns/index.md
44
44
 
45
45
  # Local worktrees
46
46
  .claude/worktrees/
@@ -40,7 +40,7 @@ Examples of what to record:
40
40
  - A new project dependency or constraint was discovered → update STATUS.md
41
41
 
42
42
  File update rules you MUST respect:
43
- - **STATUS.md** — state register (hard cap 80 lines AND 6KB): replace stale lines with the latest state, never append; one line + pointer per change, details live in EXP/K entries; adding a line requires checking which old lines expired
43
+ - **STATUS.md** — state register (hard caps <=80 lines and <=6KB; exceeding either is rejected): replace stale lines with the latest state, never append; one line + pointer per change, details live in EXP/K entries; adding a line requires checking which old lines expired
44
44
  - **ISSUES.md** — append mode: add new entries at the end, keep history
45
45
  - **knowledge/K-NNN.md** — atomic: one file per knowledge entry, with YAML frontmatter
46
46
  - **knowledge/index.md, experiments/index.md, patterns/index.md** — AUTO-GENERATED, do NOT edit manually
@@ -24,7 +24,7 @@ const LIMIT_RULES = [
24
24
  maxBytes: 6 * 1024,
25
25
  warnLines: 60,
26
26
  warnBytes: 4 * 1024,
27
- capLabel: '80 lines AND 6KB',
27
+ capLabel: '<=80 lines and <=6KB',
28
28
  trimAdvice: [
29
29
  'STATUS is a state register, not a changelog. Trim before writing:',
30
30
  '- delete entries that no longer affect decisions (their content already lives in git / EXP records),',
@@ -40,7 +40,7 @@ const LIMIT_RULES = [
40
40
  maxBytes: 6 * 1024,
41
41
  warnLines: 60,
42
42
  warnBytes: 4 * 1024,
43
- capLabel: '80 lines AND 6KB',
43
+ capLabel: '<=80 lines and <=6KB',
44
44
  trimAdvice: [
45
45
  'ISSUES.md is a friction log with <=4-line entries. Trim before writing:',
46
46
  '- delete resolved entries outright (no changelog),',
@@ -56,7 +56,7 @@ const LIMIT_RULES = [
56
56
  maxBytes: 8 * 1024,
57
57
  warnLines: 90,
58
58
  warnBytes: 6656,
59
- capLabel: '120 lines AND 8KB',
59
+ capLabel: '<=120 lines and <=8KB',
60
60
  trimAdvice: [
61
61
  'AGENTS.md is a directory index loaded into every agent that works here: it answers "what is here, where to look", not the content itself. Trim before writing:',
62
62
  '- collapse atomic directories (experiments/ knowledge/ patterns/ decisions/) to one line each pointing at their index.md,',
@@ -89,7 +89,7 @@ function proposedContent(toolName, toolInput, currentContent) {
89
89
 
90
90
  function denyReason(rule, lineCount, byteCount) {
91
91
  return [
92
- `${rule.name} write rejected: the result would be ${lineCount} lines / ${byteCount} bytes — the hard cap is ${rule.capLabel} (${rule.ruleFile}).`,
92
+ `${rule.name} write rejected: the result would be ${lineCount} lines / ${byteCount} bytes — the hard cap is ${rule.capLabel}, and exceeding either limit is rejected (${rule.ruleFile}).`,
93
93
  '',
94
94
  ...rule.trimAdvice,
95
95
  '',
@@ -150,9 +150,9 @@ function main() {
150
150
  hookSpecificOutput: {
151
151
  hookEventName: 'PreToolUse',
152
152
  permissionDecision: 'allow',
153
- permissionDecisionReason: `Still over the ${rule.name} cap (${lineCount} lines / ${byteCount} bytes > ${rule.capLabel}) but shrinking — keep trimming to within the limit.`,
153
+ permissionDecisionReason: `Still over the ${rule.name} cap (${lineCount} lines / ${byteCount} bytes; cap ${rule.capLabel}) but shrinking — keep trimming until both limits are met.`,
154
154
  },
155
- systemMessage: `${rule.name} is still over the ${rule.capLabel} cap (${lineCount} lines / ${byteCount} bytes). This write shrinks it and is allowed — keep trimming.`,
155
+ systemMessage: `${rule.name} is still over its cap of ${rule.capLabel} (${lineCount} lines / ${byteCount} bytes). This write shrinks it and is allowed — keep trimming.`,
156
156
  }));
157
157
  return;
158
158
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "cortex-system",
4
- "version": "0.7.0",
4
+ "version": "0.7.1",
5
5
  "description": "Cortex system skill bundle — approval / browser / client-manage / project-init / schedule / user-learn."
6
6
  }
@@ -4,8 +4,8 @@ description: "Use when creating, deploying, updating, or troubleshooting cortex-
4
4
  allowed-tools: Read, Write, Edit, Bash, mcp__cortex-core__remote_bash, mcp__cortex-core__remote_read, mcp__cortex-core__remote_write, mcp__cortex-core__remote_edit, mcp__cortex-core__remote_glob, mcp__cortex-core__remote_grep
5
5
  metadata:
6
6
  author: "Cortex"
7
- version: "1.4.0"
8
- date: "2026-05-03"
7
+ version: "1.4.1"
8
+ date: "2026-10-22"
9
9
  ---
10
10
 
11
11
  # Client Manage
@@ -52,7 +52,13 @@ The client resolves its server URL by precedence (`server-url.ts`): `CORTEX_SERV
52
52
  - `clientToken` — The server's `CORTEX_CLIENT_TOKEN` (see Authentication). Required unless injected via the `CORTEX_CLIENT_TOKEN` env at launch.
53
53
  - `deviceName` — Must match the name in `machines.json` on the server.
54
54
 
55
- **This config file is managed by you (LLM).** The server never writes it. Server only starts/kills the client process.
55
+ Who writes this file:
56
+
57
+ - The bootstrap script (step 2 below) writes `serverHost`, `serverPort` and `deviceName`, replacing the whole file. Re-running bootstrap drops any `serverUrl` or `clientToken` you added.
58
+ - `cortex init` writes it for a local desktop client it prepares, and server startup finishes an interrupted preparation. It records ownership in `client/local-install.json` and refuses to overwrite a config that was edited afterwards.
59
+ - `cortex client remove` deletes it together with the client install.
60
+
61
+ Any other edit, such as switching a device to `serverUrl`, is yours to make on the device.
56
62
 
57
63
  ## Connectivity — The Most Important Part
58
64
 
@@ -97,7 +103,7 @@ Test each candidate from the remote device. Use the first one that works.
97
103
  Read `machines.json` on the server for the current device list. Key fields per device:
98
104
 
99
105
  - `ssh` — How the server reaches this device (empty = local)
100
- - `cortexPath` — Path to user's workspace on the device
106
+ - `cortexPath` — The user's home directory on the device (`/home/<user>`, `C:\Users\<user>` on Windows). It must exist: the Machines panel reports disk space for the filesystem holding it, and relative `!sendfile` paths resolve against it
101
107
  - `gpuCount` — Number of GPUs
102
108
  - `win` — `true` for Windows
103
109
  - `clientCommand` — (optional) command the server runs over SSH to launch the client; defaults to `node "$HOME/.cortex/client/current/client.mjs"` (`%USERPROFILE%` on Windows). Override on machines where `node` isn't on the **non-login** SSH PATH — e.g. nvm installs: set an absolute node path like `"/home/u/.nvm/versions/node/v20.19.5/bin/node /home/u/.cortex/client/current/client.mjs"`. See Troubleshooting.
@@ -106,7 +112,7 @@ Read `machines.json` on the server for the current device list. Key fields per d
106
112
 
107
113
  ### 1. Register in machines.json
108
114
 
109
- Edit `machines.json` on the server to add the device entry.
115
+ Edit `machines.json` on the server to add the device entry. Set `cortexPath` to the user's home directory on the device and confirm it exists (`ssh user@host 'echo $HOME'`).
110
116
 
111
117
  ### 2. Deploy the client bundle
112
118
 
@@ -180,13 +186,14 @@ To force a refresh, kill the client — the server relaunches it and the reconne
180
186
  ssh user@host "pkill -f client.mjs"
181
187
  ```
182
188
 
183
- If a bad bundle leaves the client unable to start, roll back or redeploy:
189
+ If a bad bundle leaves the client unable to start, switch back to the prior version in `previous/` or re-run the bootstrap deployment (step 2 above). `current/` and `previous/` are real directories, not symlinks. Move the failing version aside into an unused name rather than deleting it; the command checks that `previous/` exists and `broken/` is free before moving anything:
184
190
 
185
191
  ```bash
186
- ssh user@host "rm -rf ~/.cortex/client/current && mv ~/.cortex/client/previous ~/.cortex/client/current"
187
- # or re-run the bootstrap deployment (step 2 above)
192
+ ssh user@host 'cd ~/.cortex/client && test -d previous && test ! -e broken && mv current broken && mv previous current'
188
193
  ```
189
194
 
195
+ On Windows devices, run the PowerShell form from `docs/cross-machine.md`. The server relaunches the client from `current/`. On reconnect it pushes its own bundle again whenever the hashes differ, so a rollback holds only until the server's bundle is fixed; setting `clientHotReloadEnabled` to `false` in the server's `settings.json` turns update pushes off meanwhile. Remove `broken/` once the device is healthy.
196
+
190
197
  ### Edit the config
191
198
 
192
199
  ```
@@ -201,7 +208,7 @@ mcp__cortex-core__remote_edit({
201
208
  After editing, kill the client — server will restart it:
202
209
 
203
210
  ```bash
204
- ssh user@host "pkill -f 'node.*cortex-client'"
211
+ ssh user@host "pkill -f client.mjs"
205
212
  ```
206
213
 
207
214
  ## Troubleshooting
@@ -51,7 +51,7 @@ This is the entry point for future sessions. Must include:
51
51
 
52
52
  | File | Type | Purpose |
53
53
  |------|------|---------|
54
- | STATUS.md | Overwrite | Present-tense state register (hard cap 80 lines AND 6KB) |
54
+ | STATUS.md | Overwrite | Present-tense state register (hard caps <=80 lines and <=6KB; exceeding either is rejected) |
55
55
  | experiments/ | Atomic file | One EXP-NNN.md per experiment (YAML frontmatter + body), index.md auto-generated |
56
56
  | knowledge/ | Atomic file | One K-NNN.md per knowledge entry, index.md auto-generated |
57
57
  | patterns/ | Atomic file | Cross-experiment patterns, index.md auto-generated |
@@ -80,7 +80,7 @@ This is the entry point for future sessions. Must include:
80
80
 
81
81
  ### STATUS.md (required) — Current state snapshot
82
82
 
83
- Format is governed by `rules/status-md.md` (overwrite-style state register, hard cap 80 lines AND 6KB, each bullet <=2 lines, facts with a durable home appear as pointers only):
83
+ Format is governed by `rules/status-md.md` (overwrite-style state register, hard caps <=80 lines and <=6KB with either one rejecting the write, each bullet <=2 lines, facts with a durable home appear as pointers only):
84
84
 
85
85
  ```markdown
86
86
  # [Project Name] Status
@@ -9,7 +9,7 @@ Directory index + entry map. Loaded into the context of every agent that works i
9
9
 
10
10
  ## Hard Constraints
11
11
 
12
- - **Hard cap: 120 lines AND 8KB** (enforced by guard hook). The hook path truncates at 9,500 characters, so content past that line is never injected at all — pure waste.
12
+ - **Hard cap: at most 120 lines and at most 8KB** (enforced by guard hook, which rejects a write that exceeds either limit). The hook path truncates at 9,500 characters, so content past that line is never injected at all — pure waste.
13
13
  - **Each index line <=200 characters**: one sentence of purpose + pointer.
14
14
  - **One line per atomic directory**: experiments/, knowledge/, patterns/, decisions/ each take a single line in the index, pointing at their auto-generated index.md (or the directory itself). **Never enumerate per-entry summaries** — summaries already live in the atomic files' frontmatter and index.md; copies in the index are pure redundancy.
15
15
 
@@ -9,7 +9,7 @@ Records execution friction affecting work efficiency: misleading requirements, c
9
9
 
10
10
  ## Hard Constraints
11
11
 
12
- - **Length limit: 80 lines AND 6KB** (enforced by guard hook; the dual limit prevents gaming the line cap with mega-lines). Exceeding means unresolved issues are accumulating, triggering cleanup.
12
+ - **Length limit: at most 80 lines and at most 6KB** (enforced by guard hook, which rejects a write that exceeds either limit; the byte limit keeps mega-lines from gaming the line cap). Exceeding means unresolved issues are accumulating, triggering cleanup.
13
13
  - **Each entry <=4 lines**. Investigation detail not fitting is a signal to pointer-ize, not to lengthen the line.
14
14
  - **Append mode**: New issues are appended to the end.
15
15
  - **Resolved entries are deleted directly**: No archiving, no history retained. Delete the corresponding entry from the file immediately after fixing.
@@ -31,9 +31,9 @@ PostToolUse hook automatically records Read/Grep access to atomic files (EXP/K/P
31
31
 
32
32
  | File | Dedicated rule | Update mode |
33
33
  |------|----------------|-------------|
34
- | `STATUS.md` | status-md.md | Overwrite snapshot (state register), hard limit 80 lines AND 6KB, each bullet <=2 lines |
35
- | `ISSUES.md` | issues-md.md | Append, resolved entries deleted directly, hard limit 80 lines AND 6KB, each entry <=4 lines |
36
- | `AGENTS.md` (directory index) | agents-md.md | Pointer-style index, hard limit 120 lines AND 8KB, one line per atomic directory |
34
+ | `STATUS.md` | status-md.md | Overwrite snapshot (state register), hard limits <=80 lines and <=6KB (exceeding either is rejected), each bullet <=2 lines |
35
+ | `ISSUES.md` | issues-md.md | Append, resolved entries deleted directly, hard limits <=80 lines and <=6KB (exceeding either is rejected), each entry <=4 lines |
36
+ | `AGENTS.md` (directory index) | agents-md.md | Pointer-style index, hard limits <=120 lines and <=8KB (exceeding either is rejected), one line per atomic directory |
37
37
  | `mission.md` | mission-md.md | Modify after user confirmation |
38
38
  | `roadmap.md` | roadmap-md.md | Stable, milestones must contain testable checklist |
39
39
  | `OVERVIEW.md` | overview-md.md | Synchronous update, hard limit 60 lines |
@@ -11,7 +11,7 @@ The project's "constitution": defines goals and success conditions. It is the ba
11
11
 
12
12
  - **Stable file**: Can only be modified after user confirmation. Cortex must not rewrite or expand scope on its own.
13
13
  - **Modification trigger condition**: User explicitly directs a re-orientation, pivot, or scope change. Do not touch in any other case.
14
- - **Limit: 100 lines AND 8KB**. Too long means content that belongs in roadmap/STATUS or a project-pitch document has been mixed in; trimming also requires user confirmation.
14
+ - **Limit: at most 100 lines and at most 8KB**. Exceeding either means content that belongs in roadmap/STATUS or a project-pitch document has been mixed in; trimming also requires user confirmation.
15
15
 
16
16
  ## Required Sections
17
17
 
@@ -17,7 +17,7 @@ It answers exactly four questions: where are we, what is in flight, what is in t
17
17
  ## Hard Constraints
18
18
 
19
19
  - **Update mode: overwrite-rewrite the snapshot**. Every "add a line" must be paired with a check for which existing lines it makes stale — delete those.
20
- - **Length limit: 80 lines AND 6KB, both hard**. Scan before writing: at >=60 lines or >=4KB, warn and trim proactively; over the limit, trim below it before the write is allowed.
20
+ - **Length limit: at most 80 lines and at most 6KB, both hard**: exceeding either one blocks the write. Scan before writing: at >=60 lines or >=4KB, warn and trim proactively; over either limit, trim below both before the write is allowed.
21
21
  - **Each bullet <= 2 lines**. If it doesn't fit, the detail belongs elsewhere — keep one sentence + a pointer.
22
22
  - **Facts with a durable home appear only as pointers**: EXP-NNN / K-NNN / DR-NNNN / commit SHA / file path. The only content unique to STATUS is the one-sentence synthesis of the current situation.
23
23
 
@@ -47,6 +47,7 @@ export declare class BgTaskTracker {
47
47
  private readonly running;
48
48
  private readonly undelivered;
49
49
  private readonly foreground;
50
+ /** task_id → the notification's `summary` ('' when it carried none). */
50
51
  private readonly armed;
51
52
  /** task_id → the `Agent`/`Task` tool call that spawned it. Populated from `task_started`, which
52
53
  * is the only event carrying BOTH ids: `task_updated` reports terminal status with `task_id`
@@ -67,7 +68,8 @@ export declare class BgTaskTracker {
67
68
  * opened yet; the next assistant line with no active turn is that turn. Cleared by
68
69
  * disarmContinuation(). */
69
70
  get continuationArmed(): boolean;
70
- disarmContinuation(): void;
71
+ /** Clear the armed notifications and return their non-empty summaries: what woke the model. */
72
+ disarmContinuation(): string[];
71
73
  /**
72
74
  * The authoritative "this subagent is over" signal, read off the same line `observe` consumes.
73
75
  *
@@ -3,7 +3,8 @@ export class BgTaskTracker {
3
3
  running = new Set();
4
4
  undelivered = new Set();
5
5
  foreground = new Set();
6
- armed = new Set();
6
+ /** task_id → the notification's `summary` ('' when it carried none). */
7
+ armed = new Map();
7
8
  /** task_id → the `Agent`/`Task` tool call that spawned it. Populated from `task_started`, which
8
9
  * is the only event carrying BOTH ids: `task_updated` reports terminal status with `task_id`
9
10
  * alone, so without this map a completion cannot be attributed to a UI subagent block. */
@@ -62,7 +63,7 @@ export class BgTaskTracker {
62
63
  if (!known && data.status === 'stopped')
63
64
  break;
64
65
  // The authoritative completion-delivery signal: the model is being re-invoked.
65
- this.armed.add(id);
66
+ this.armed.set(id, typeof data.summary === 'string' ? data.summary.trim() : '');
66
67
  break;
67
68
  }
68
69
  default:
@@ -103,8 +104,11 @@ export class BgTaskTracker {
103
104
  get continuationArmed() {
104
105
  return this.armed.size > 0;
105
106
  }
107
+ /** Clear the armed notifications and return their non-empty summaries: what woke the model. */
106
108
  disarmContinuation() {
109
+ const summaries = [...this.armed.values()].filter(Boolean);
107
110
  this.armed.clear();
111
+ return summaries;
108
112
  }
109
113
  /**
110
114
  * The authoritative "this subagent is over" signal, read off the same line `observe` consumes.
@@ -78,11 +78,22 @@ function writePrivateAtomic(filePath, text) {
78
78
  fs.renameSync(tmp, filePath);
79
79
  fs.chmodSync(filePath, 0o600);
80
80
  }
81
+ /** Reuse refreshes the mtime: the plugin-runtime sweep removes only files untouched for a week. */
82
+ function markLive(filePath) {
83
+ try {
84
+ const now = new Date();
85
+ fs.utimesSync(filePath, now, now);
86
+ }
87
+ catch {
88
+ // A failed touch only makes the file eligible for a sweep; the next spawn writes it again.
89
+ }
90
+ }
81
91
  function privateContentFile(directory, text, label) {
82
92
  ensurePrivateDirectory(directory, label);
83
93
  const filePath = path.join(directory, `${sha256(text)}.json`);
84
94
  if (fs.existsSync(filePath)) {
85
95
  validateExistingFile(filePath, text);
96
+ markLive(filePath);
86
97
  return filePath;
87
98
  }
88
99
  try {
@@ -172,7 +172,8 @@ export declare class ClaudeTurnMachine {
172
172
  private handleReplayEcho;
173
173
  private continuationCallbacks;
174
174
  /** Open a synthetic turn to capture the spontaneous continuation the CLI emits after a
175
- * background task finishes. Its output is delivered or buffered for backgroundTurnSink. */
175
+ * background task finishes (or after an injected message it consumed with no turn in flight).
176
+ * Its output is delivered or buffered for backgroundTurnSink. */
176
177
  private openContinuationTurn;
177
178
  compactUsage(result: AgentResult): AgentCompactUsage | null;
178
179
  /** Start a fresh process's cost cursor at the total the CLI restored on `--resume` (0 for a new
@@ -313,13 +313,16 @@ export class ClaudeTurnMachine {
313
313
  };
314
314
  }
315
315
  /** Open a synthetic turn to capture the spontaneous continuation the CLI emits after a
316
- * background task finishes. Its output is delivered or buffered for backgroundTurnSink. */
317
- openContinuationTurn(label = '[background-task continuation]') {
318
- this.bgTracker.disarmContinuation();
316
+ * background task finishes (or after an injected message it consumed with no turn in flight).
317
+ * Its output is delivered or buffered for backgroundTurnSink. */
318
+ openContinuationTurn(fromInjection) {
319
+ const summaries = this.bgTracker.disarmContinuation();
320
+ const label = fromInjection ? '[injected-message continuation]' : '[background-task continuation]';
319
321
  const streams = this.createTurnStreams(label);
320
322
  // The hold's watchdogs bound the WAIT for this turn, not the turn itself: a continuation
321
323
  // that runs longer than the grace/max-wait window must not be sealed idle mid-stream.
322
- this.deliverContinuation(sink => sink.onTurnOpen?.());
324
+ const wake = fromInjection ? undefined : { summaries };
325
+ this.deliverContinuation(sink => sink.onTurnOpen?.(wake));
323
326
  this.currentTurn = {
324
327
  ...this.continuationCallbacks(),
325
328
  resultData: null, planFilePath: null,
@@ -640,7 +643,7 @@ export class ClaudeTurnMachine {
640
643
  && (this.injectionContinuationArmed || routeLine(this.bgTracker, data) === 'open-continuation')) {
641
644
  const fromInjection = this.injectionContinuationArmed;
642
645
  this.injectionContinuationArmed = false;
643
- this.openContinuationTurn(fromInjection ? '[injected-message continuation]' : '[background-task continuation]');
646
+ this.openContinuationTurn(fromInjection);
644
647
  }
645
648
  if (data.type === 'result' && this.currentTurn) {
646
649
  // A task-notification turn's result can only settle a spontaneous turn. When it lands on
@@ -1,5 +1,5 @@
1
1
  import type { AgentResult } from '../core/types/agent-types.js';
2
- import type { BackgroundTurnSink } from './types.js';
2
+ import type { BackgroundTurnSink, BackgroundWake } from './types.js';
3
3
  import type { RunEvent } from './run-events.js';
4
4
  /** What the caller asked the engine to do about a run's background work. */
5
5
  export type AwaitBackground = 'none' | 'hold';
@@ -96,8 +96,11 @@ export declare class ContinuationPhase {
96
96
  * result decides what happens next. Releasing it on the ack instead would close the stream
97
97
  * before the reply it is owed could land; never releasing it (as was the case) left a run whose
98
98
  * foreground turn ended with one injected message pending open forever — the max-wait watchdog
99
- * bounds a WAIT, it does not finish a run. */
100
- onTurnOpen(): void;
99
+ * bounds a WAIT, it does not finish a run.
100
+ *
101
+ * A turn that finished background work opened carries its `wake`, reported ahead of anything
102
+ * the turn says. */
103
+ onTurnOpen(wake?: BackgroundWake): void;
101
104
  private enterBackground;
102
105
  /** Everything that reaches this run's stream passes through here, so the phase can react to the
103
106
  * couple of events that change what the run still owes (injection acks, a turn opening). */
@@ -104,7 +104,7 @@ export class ContinuationPhase {
104
104
  const emit = sinkToRunEvents((event) => this.ingest(event));
105
105
  return {
106
106
  ...emit,
107
- onTurnOpen: () => this.onTurnOpen(),
107
+ onTurnOpen: (wake) => this.onTurnOpen(wake),
108
108
  onResult: (result) => this.onResult(result),
109
109
  };
110
110
  }
@@ -165,14 +165,19 @@ export class ContinuationPhase {
165
165
  * result decides what happens next. Releasing it on the ack instead would close the stream
166
166
  * before the reply it is owed could land; never releasing it (as was the case) left a run whose
167
167
  * foreground turn ended with one injected message pending open forever — the max-wait watchdog
168
- * bounds a WAIT, it does not finish a run. */
169
- onTurnOpen() {
168
+ * bounds a WAIT, it does not finish a run.
169
+ *
170
+ * A turn that finished background work opened carries its `wake`, reported ahead of anything
171
+ * the turn says. */
172
+ onTurnOpen(wake) {
170
173
  if (this.settled || !this.started)
171
174
  return;
172
175
  this.backgroundTurnOpen = true;
173
176
  this.outstandingInjections = 0;
174
177
  this.pause();
175
178
  this.enterBackground();
179
+ if (wake)
180
+ this.port.push({ type: 'background_wake', summaries: wake.summaries, phase: 'background' });
176
181
  }
177
182
  enterBackground() {
178
183
  if (!this.acc)
@@ -63,6 +63,10 @@ export type RunEvent = {
63
63
  toolUseId: string;
64
64
  snapshot: TodoSnapshot;
65
65
  phase: RunPhase;
66
+ } | {
67
+ type: 'background_wake';
68
+ summaries: string[];
69
+ phase: RunPhase;
66
70
  } | ({
67
71
  type: 'context_usage';
68
72
  phase: RunPhase;
@@ -175,6 +175,11 @@ export interface SpawnedAgentProcess {
175
175
  supervision?: AgentProcessSupervision;
176
176
  }
177
177
  export type AgentProcessSpawner = (command: string, args: string[], options: SpawnOptionsWithoutStdio) => SpawnedAgentProcess;
178
+ /** What re-invoked the model when a background turn was opened by finished background work:
179
+ * the summaries of the task notifications the CLI delivered. */
180
+ export interface BackgroundWake {
181
+ summaries: string[];
182
+ }
178
183
  /**
179
184
  * Where a BACKGROUND TURN reports itself: a turn the backend opened on its own, with no caller
180
185
  * awaiting it — a finished `run_in_background` task making the CLI re-invoke the model, or an
@@ -188,8 +193,10 @@ export type AgentProcessSpawner = (command: string, args: string[], options: Spa
188
193
  */
189
194
  export interface BackgroundTurnSink {
190
195
  /** Optional: the continuation turn has opened (first assistant line arrived). The wait is over;
191
- * holders pause their grace/max-wait watchdogs until `onResult` reports what remains. */
192
- onTurnOpen?: () => void;
196
+ * holders pause their grace/max-wait watchdogs until `onResult` reports what remains. `wake` is
197
+ * set when finished background tasks opened the turn, and absent when an injected message did
198
+ * (that message already has its own transcript row). */
199
+ onTurnOpen?: (wake?: BackgroundWake) => void;
193
200
  /** Assistant text from the continuation turn (append to the original reply). `subagent` is set
194
201
  * only when a native subagent produced it (see ToolUseSubagent). */
195
202
  onAssistantText: (text: string, model?: string | null, subagent?: ToolUseSubagent) => void;
@@ -0,0 +1 @@
1
+ {"telemetryEndpoint":"https://telemetry.fangxm.me/v1/batch"}
@@ -4294,20 +4294,25 @@ function getClientHelp() {
4294
4294
  "",
4295
4295
  "Usage: cortex-client",
4296
4296
  "",
4297
- "cortex-client is a daemon-style worker. Configuration is read from",
4297
+ "cortex-client is a daemon-style worker that the agent-server starts.",
4298
+ "Configuration is read from",
4298
4299
  ` ${path5.join(CONFIG_DIR, "cortex-client.json")}`,
4299
- "which the agent-server writes during `cortex client-deploy`. There are",
4300
- "no command-line flags beyond --help.",
4300
+ "which is written by the server's bootstrap script (from agent-server/ in a",
4301
+ "source checkout: node --import tsx src/domain/remote/client-bootstrap.ts),",
4302
+ "by `cortex init` for a local desktop install, or by hand. There are no",
4303
+ "command-line flags beyond --help.",
4301
4304
  "",
4302
4305
  "Config schema (JSON):",
4303
4306
  " {",
4304
4307
  ' "serverHost": "<agent-server host or LAN IP>",',
4305
4308
  ' "serverPort": 3002,',
4306
- ' "deviceName": "<short device name>"',
4309
+ ' "serverUrl": "<optional wss:// or ws:// URL; replaces serverHost/serverPort>",',
4310
+ ' "deviceName": "<short device name>",',
4311
+ ' "clientToken": "<server CORTEX_CLIENT_TOKEN; env CORTEX_CLIENT_TOKEN overrides>"',
4307
4312
  " }",
4308
4313
  "",
4309
4314
  "Behavior:",
4310
- " \u2022 Opens a WebSocket to ws://<serverHost>:<serverPort> on start.",
4315
+ " \u2022 Opens a WebSocket to CORTEX_SERVER_URL, else serverUrl, else ws://<serverHost>:<serverPort>.",
4311
4316
  " \u2022 Receives bash/read/write/edit/glob/grep commands.",
4312
4317
  " \u2022 Exits if the server rejects the handshake (e.g. device already connected).",
4313
4318
  " \u2022 Reconnects automatically on transient disconnects.",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "version": "2026.10.15",
3
- "hash": "8427e6d35fd14a8701b97c5d80cca778f5fc0340d0c938a485e25b666757cfcd",
4
- "source": "3d9dd5c4e1df1c572d6146f72b8dca90ee53e0f5"
3
+ "hash": "905214a46c7dbf67fc247e63168c0f687e4af7aed67df5c017317635139c3a8a",
4
+ "source": "d7f13e9b4fdb417bc24fd7cc06dac6c16118b33a"
5
5
  }
@@ -83,3 +83,9 @@ export declare function claudeKeychainService(deps?: ClaudeCredentialDeps): stri
83
83
  * shadow a live credential there.
84
84
  */
85
85
  export declare function claudeOwnsOAuthCredential(deps?: ClaudeCredentialDeps): boolean;
86
+ /**
87
+ * Can a Claude spawn on this host authenticate at all? Any store counts, unlike
88
+ * resolveClaudeCredential: an expired login still refreshes inside Claude Code, a macOS keychain
89
+ * login is never readable here, and ANTHROPIC_AUTH_TOKEN reaches a child only through the env.
90
+ */
91
+ export declare function hasClaudeCredential(deps?: ClaudeCredentialDeps): boolean;
@@ -229,3 +229,14 @@ export function claudeOwnsOAuthCredential(deps = {}) {
229
229
  const probe = deps.probeKeychain ?? probeKeychainItem;
230
230
  return probe(claudeKeychainService(deps));
231
231
  }
232
+ /**
233
+ * Can a Claude spawn on this host authenticate at all? Any store counts, unlike
234
+ * resolveClaudeCredential: an expired login still refreshes inside Claude Code, a macOS keychain
235
+ * login is never readable here, and ANTHROPIC_AUTH_TOKEN reaches a child only through the env.
236
+ */
237
+ export function hasClaudeCredential(deps = {}) {
238
+ const env = deps.env ?? process.env;
239
+ if (credentialValue(env.ANTHROPIC_AUTH_TOKEN))
240
+ return true;
241
+ return resolveClaudeCredential(deps) !== null || claudeOwnsOAuthCredential(deps);
242
+ }
@@ -46,6 +46,23 @@ export interface DiscoveredEndpoint {
46
46
  * newest Claude flagship. Always one of `models`; absent when the endpoint has no preference. */
47
47
  defaultModel?: string;
48
48
  }
49
+ /**
50
+ * Map a PI built-in provider name to its real upstream URL. Used by `generateGatewayYaml` so PI
51
+ * traffic can be routed through the gateway. Entries are sourced from PI source / docs.
52
+ *
53
+ * Providers absent from this table are still surfaced as models, but no gateway endpoint
54
+ * is generated for them (gatewayManaged=false). PI will then either fail (if the cortex spawn path
55
+ * forces gateway routing) or direct-call the upstream (if the spawn path leaves models.json
56
+ * untouched for that provider). Full provider plumbing remains future work.
57
+ */
58
+ export declare const PI_PROVIDER_UPSTREAM: Record<string, {
59
+ url: string;
60
+ auth_style: string;
61
+ }>;
62
+ /** Point every stored route still on a retired PI upstream at the current one; returns how many moved. */
63
+ export declare function refreshRetiredPiUpstreams(endpoints: EndpointMap): number;
64
+ /** Rewrite gateway.yaml (backing it up first) when a stored route is on a retired PI upstream. */
65
+ export declare function migrateRetiredPiUpstreams(configPath?: string): number;
49
66
  export interface PiDiscoveredModel {
50
67
  provider: string;
51
68
  model: string;