@clagentic/console 1.9.0 → 1.10.0-beta.2

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 (172) hide show
  1. package/LICENSE +117 -12
  2. package/LICENSES/MIT-legacy.txt +22 -0
  3. package/LICENSES/README.md +15 -0
  4. package/README.md +9 -3
  5. package/bin/cli.js +40 -5
  6. package/deploy/clagentic-console.service +10 -6
  7. package/lib/agent-dispatch-tool.js +20 -0
  8. package/lib/audit.js +3 -2
  9. package/lib/build-changes.js +79 -0
  10. package/lib/build-identity.js +192 -0
  11. package/lib/build-monitor.js +125 -0
  12. package/lib/build-sha.json +2 -2
  13. package/lib/build-update-check.js +138 -0
  14. package/lib/build-update-offer.js +141 -0
  15. package/lib/build-update-restart.js +142 -0
  16. package/lib/build-update-standing.js +184 -0
  17. package/lib/cli/daemon-launch.js +25 -22
  18. package/lib/cli/ipc-subcommands.js +6 -0
  19. package/lib/cli/session-subcommands.js +122 -0
  20. package/lib/cli-sessions.js +8 -1
  21. package/lib/codex-defaults.js +8 -2
  22. package/lib/config.js +32 -20
  23. package/lib/daemon-env-settings.js +84 -0
  24. package/lib/daemon-projects.js +57 -0
  25. package/lib/daemon.js +288 -205
  26. package/lib/drain.js +74 -17
  27. package/lib/env-compat.js +61 -0
  28. package/lib/extension-commands.js +45 -0
  29. package/lib/history-visibility.js +4 -0
  30. package/lib/idle-adapter-reaper.js +71 -0
  31. package/lib/link-trap.js +78 -0
  32. package/lib/mcp-local.js +8 -6
  33. package/lib/mcp-tool-input.js +116 -0
  34. package/lib/mcp-tool-schema.js +179 -0
  35. package/lib/memory-limits.js +61 -5
  36. package/lib/memory-setting-validate.js +65 -0
  37. package/lib/memory-shed.js +13 -32
  38. package/lib/new-work-gate.js +47 -0
  39. package/lib/os-users.js +5 -3
  40. package/lib/project-access.js +139 -0
  41. package/lib/project-connection.js +37 -22
  42. package/lib/project-external-trigger.js +166 -105
  43. package/lib/project-file-scope.js +172 -0
  44. package/lib/project-file-watch.js +86 -61
  45. package/lib/project-filesystem.js +144 -128
  46. package/lib/project-git.js +119 -0
  47. package/lib/project-http.js +44 -28
  48. package/lib/project-loop.js +17 -9
  49. package/lib/project-mcp.js +53 -72
  50. package/lib/project-message-gate.js +70 -0
  51. package/lib/project-notifications.js +31 -4
  52. package/lib/project-prompt-responses.js +217 -0
  53. package/lib/project-sessions.js +192 -355
  54. package/lib/project-user-message.js +27 -15
  55. package/lib/project.js +212 -147
  56. package/lib/projects-dir.js +90 -0
  57. package/lib/prompt-access.js +22 -0
  58. package/lib/prompt-kinds/answer-limits.js +15 -0
  59. package/lib/prompt-kinds/ask-user.js +58 -0
  60. package/lib/prompt-kinds/codecs.js +97 -0
  61. package/lib/prompt-kinds/elicitation.js +77 -0
  62. package/lib/prompt-kinds/extension.js +39 -0
  63. package/lib/prompt-kinds/index.js +68 -0
  64. package/lib/prompt-kinds/permission.js +114 -0
  65. package/lib/prompt-kinds/plan.js +79 -0
  66. package/lib/prompt-kinds/tool-call.js +38 -0
  67. package/lib/prompt-registry.js +680 -0
  68. package/lib/public/app.js +1 -1
  69. package/lib/public/css/diagnostics.css +80 -0
  70. package/lib/public/css/input.css +17 -3
  71. package/lib/public/css/menus.css +10 -0
  72. package/lib/public/css/messages.css +5 -0
  73. package/lib/public/css/rewind.css +22 -0
  74. package/lib/public/index.html +4 -12
  75. package/lib/public/modules/agent-dispatch-tool.js +9 -0
  76. package/lib/public/modules/app-connection.js +7 -0
  77. package/lib/public/modules/app-cursors.js +7 -5
  78. package/lib/public/modules/app-messages.js +52 -47
  79. package/lib/public/modules/app-notifications.js +47 -71
  80. package/lib/public/modules/app-panels.js +61 -59
  81. package/lib/public/modules/app-projects.js +2 -1
  82. package/lib/public/modules/app-rendering.js +4 -10
  83. package/lib/public/modules/build-update-detail.js +54 -0
  84. package/lib/public/modules/diagnostics.js +170 -20
  85. package/lib/public/modules/filebrowser.js +18 -16
  86. package/lib/public/modules/history-visibility.js +4 -0
  87. package/lib/public/modules/mention.js +3 -2
  88. package/lib/public/modules/mode-options.js +38 -0
  89. package/lib/public/modules/project-settings.js +19 -8
  90. package/lib/public/modules/prompt-banner.js +78 -0
  91. package/lib/public/modules/prompt-card.js +201 -0
  92. package/lib/public/modules/prompt-kinds/ask-user-codec.js +131 -0
  93. package/lib/public/modules/prompt-kinds/ask-user.js +213 -0
  94. package/lib/public/modules/prompt-kinds/elicitation-codec.js +343 -0
  95. package/lib/public/modules/prompt-kinds/elicitation.js +176 -0
  96. package/lib/public/modules/prompt-kinds/index.js +18 -0
  97. package/lib/public/modules/prompt-kinds/own-key.js +29 -0
  98. package/lib/public/modules/prompt-kinds/package.json +3 -0
  99. package/lib/public/modules/prompt-kinds/permission-choices.js +31 -0
  100. package/lib/public/modules/prompt-kinds/permission.js +209 -0
  101. package/lib/public/modules/prompt-kinds/plan.js +102 -0
  102. package/lib/public/modules/prompt-state.js +142 -0
  103. package/lib/public/modules/prompts.js +134 -0
  104. package/lib/public/modules/rewind.js +4 -1
  105. package/lib/public/modules/server-settings.js +2 -4
  106. package/lib/public/modules/sidebar-mobile.js +19 -9
  107. package/lib/public/modules/sidebar-sessions.js +21 -14
  108. package/lib/public/modules/sticky-notes.js +3 -2
  109. package/lib/public/modules/team-panel.js +5 -4
  110. package/lib/public/modules/tools.js +81 -906
  111. package/lib/public/modules/vendor-picker.js +53 -0
  112. package/lib/public/modules/vendor-registry.js +142 -0
  113. package/lib/public/sw.js +3 -1
  114. package/lib/rc-migrate.js +44 -0
  115. package/lib/runtime-env-keys.js +109 -0
  116. package/lib/runtime-env.js +236 -0
  117. package/lib/sdk-bridge.js +348 -284
  118. package/lib/sdk-message-processor.js +117 -146
  119. package/lib/sdk-skill-discovery.js +65 -60
  120. package/lib/server-hub-sessions.js +13 -10
  121. package/lib/server-palette.js +28 -19
  122. package/lib/server.js +156 -115
  123. package/lib/service-install.js +96 -0
  124. package/lib/session-capabilities.js +76 -0
  125. package/lib/session-id.js +33 -0
  126. package/lib/session-input-ipc.js +32 -0
  127. package/lib/session-input.js +379 -0
  128. package/lib/session-reclaim.js +284 -0
  129. package/lib/session-resume.js +172 -0
  130. package/lib/sessions.js +61 -30
  131. package/lib/supervisor.js +39 -0
  132. package/lib/turn-initiator.js +108 -0
  133. package/lib/users-permissions.js +9 -6
  134. package/lib/users.js +9 -0
  135. package/lib/utils.js +4 -2
  136. package/lib/vendor-auth.js +22 -0
  137. package/lib/vendor-registry-message.js +66 -0
  138. package/lib/ws-origin.js +99 -0
  139. package/lib/ws-schema.js +36 -23
  140. package/lib/yoke/adapters/claude-capabilities.js +38 -0
  141. package/lib/yoke/adapters/claude-vendor.js +34 -0
  142. package/lib/yoke/adapters/claude-worker.js +57 -87
  143. package/lib/yoke/adapters/claude.js +182 -88
  144. package/lib/yoke/adapters/codex-capabilities.js +40 -0
  145. package/lib/yoke/adapters/codex-vendor.js +46 -0
  146. package/lib/yoke/adapters/codex.js +462 -211
  147. package/lib/yoke/adapters/effort-control.js +34 -0
  148. package/lib/yoke/adapters/permission-relay.js +58 -0
  149. package/lib/yoke/adapters/worker-mcp-servers.js +81 -0
  150. package/lib/yoke/auth-checks.js +91 -0
  151. package/lib/yoke/capabilities.js +49 -0
  152. package/lib/yoke/codex-app-server.js +30 -56
  153. package/lib/yoke/codex-binary.js +254 -0
  154. package/lib/yoke/codex-command.js +122 -0
  155. package/lib/yoke/codex-protocol.js +96 -0
  156. package/lib/yoke/codex-version.js +135 -0
  157. package/lib/yoke/env-ownership.js +40 -0
  158. package/lib/yoke/index.js +84 -174
  159. package/lib/yoke/install-probe.js +136 -0
  160. package/lib/yoke/instructions.js +7 -11
  161. package/lib/yoke/interface.js +206 -4
  162. package/lib/yoke/package.json +1 -1
  163. package/lib/yoke/provider-credentials.js +96 -0
  164. package/lib/yoke/registry.js +377 -0
  165. package/package.json +12 -9
  166. package/scripts/check-sdk-lock-drift.js +160 -0
  167. package/scripts/check-test-count.js +76 -1
  168. package/scripts/postinstall.js +218 -136
  169. package/scripts/prompt-harness-history.js +202 -0
  170. package/scripts/verify-installed-build.js +59 -17
  171. package/scripts/verify-installed.js +67 -0
  172. package/lib/sdk-permission-ownership.js +0 -136
package/LICENSE CHANGED
@@ -1,22 +1,127 @@
1
- MIT License
1
+ # Functional Source License, Version 1.1, MIT Future License
2
2
 
3
- Copyright (c) 2026 Chad
4
- Copyright (c) 2026 Andy Kuehner, Clagentic:Console contributors
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Andy Kuehner
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publish, and redistribute the
28
+ Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing
33
+ Use means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives
65
+ of the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND,
74
+ INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
75
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO
78
+ THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
79
+ DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin
84
+ of the Software, you have no right under these Terms and Conditions to use
85
+ our trademarks, trade names, service marks, or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software
90
+ under the MIT license that is effective on the second anniversary of the
91
+ date we make the Software available. On or after that date, you may use the
92
+ Software under the MIT license, in which case the following will apply:
5
93
 
6
94
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
95
+ of this software and associated documentation files (the "Software"), to
96
+ deal in the Software without restriction, including without limitation the
97
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
98
+ sell copies of the Software, and to permit persons to whom the Software is
11
99
  furnished to do so, subject to the following conditions:
12
100
 
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
101
+ The above copyright notice and this permission notice shall be included in
102
+ all copies or substantial portions of the Software.
15
103
 
16
104
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
105
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
106
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
107
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
109
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
110
+ DEALINGS IN THE SOFTWARE.
111
+
112
+ ---
113
+
114
+ ## Plain-English summary (non-binding)
115
+
116
+ Clagentic: Console is **free for personal and internal-business use**. You can
117
+ read it, run it, modify it, redistribute it, and use it inside your company
118
+ without paying anyone.
119
+
120
+ You **may not** offer Clagentic: Console (or a substantial fork of it) as a
121
+ competing commercial hosted agent console or service. If that's what you want
122
+ to do, contact us for a commercial license.
123
+
124
+ Two years after each release, that release auto-converts to the **MIT
125
+ license** — fully open source, no restrictions.
126
+
127
+ **Commercial licensing inquiries:** https://clagentic.ai
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chad
4
+ Copyright (c) 2026 Andy Kuehner, Clagentic:Console contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ # Licenses
2
+
3
+ The project as a whole is licensed under FSL-1.1-MIT (the Functional Source
4
+ License 1.1 with MIT as the Change License), see the root `LICENSE`, from the
5
+ first release that contains this change.
6
+
7
+ Portions of the project that existed before that release remain available under
8
+ the MIT terms in `MIT-legacy.txt` (a verbatim copy of the previous `LICENSE`).
9
+ This notice does not narrow or revoke those grants. Releases published before
10
+ this change remain under MIT.
11
+
12
+ The FSL-1.1-MIT license applies from commit db3c533 (PR #434) onward; the first
13
+ release cut after that commit is the first FSL release.
14
+
15
+ Third-party components keep their own licenses.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  <p align="center">
8
8
  <a href="https://clagentic.ai"><img src="https://img.shields.io/badge/-clagentic.ai-00CFFF?style=flat&logoColor=white" alt="clagentic.ai" /></a>
9
- <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow?style=flat" alt="License: MIT" /></a>
9
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-FSL--1.1--MIT-blue?style=flat" alt="License: FSL-1.1-MIT" /></a>
10
10
  <a href="https://github.com/clagentic/clagentic-console/actions/workflows/pr-checks.yml"><img src="https://github.com/clagentic/clagentic-console/actions/workflows/pr-checks.yml/badge.svg?branch=main" alt="CI" /></a>
11
11
  <img src="https://img.shields.io/badge/Node.js-20+-339933?style=flat&logo=node.js&logoColor=white" alt="Node.js 20+" />
12
12
  <a href="https://www.npmjs.com/package/@clagentic/console"><img src="https://img.shields.io/npm/v/@clagentic/console?style=flat&label=npm" alt="npm version" /></a>
@@ -34,7 +34,7 @@ Or try without installing:
34
34
  npx @clagentic/console
35
35
  ```
36
36
 
37
- **Requirements:** Node.js 20+. Authenticated Claude Code CLI, Codex CLI, or both.
37
+ **Requirements:** Node.js 20+. Authenticated Claude Code CLI, Codex CLI, or both. Codex is not bundled: install it yourself (`npm install -g @openai/codex`, version 0.148.0 or newer). The console runs the one it finds from `CLAGENTIC_CONSOLE_CODEX_PATH` (an absolute path), then `codex` on `PATH`, then the usual install locations, and shows the path and version in the agent picker.
38
38
 
39
39
  ### Postinstall / systemd
40
40
 
@@ -250,4 +250,10 @@ Not affiliated with Anthropic or OpenAI. Claude is a trademark of Anthropic. Cod
250
250
 
251
251
  ## License
252
252
 
253
- [MIT](LICENSE)
253
+ [FSL-1.1-MIT](LICENSE) — Functional Source License 1.1, with MIT as the Change License.
254
+
255
+ Free for personal, internal-business, evaluation, research, and non-commercial use.
256
+ Not free for offering this tool (or a substantial fork) as a competing commercial product.
257
+ Each release auto-converts to MIT on its second anniversary.
258
+
259
+ Code from releases before this change remains available under MIT ([LICENSES/MIT-legacy.txt](LICENSES/MIT-legacy.txt)).
package/bin/cli.js CHANGED
@@ -16,9 +16,9 @@ var fs = require("fs");
16
16
  var path = require("path");
17
17
 
18
18
  // Detect dev mode — dev and prod use separate daemon files so they can run simultaneously
19
- var _isDev = (process.argv[1] && path.basename(process.argv[1]) === "clagentic-dev") || process.argv.includes("--dev");
19
+ var _isDev = (process.argv[1] && path.basename(process.argv[1]) === "clagentic-console-dev") || process.argv.includes("--dev");
20
20
  if (_isDev) {
21
- process.env.CLAGENTIC_DEV = "1";
21
+ process.env.CLAGENTIC_CONSOLE_DEV = "1";
22
22
  }
23
23
 
24
24
  // Preserve console output in dev/debug mode so logs remain readable
@@ -37,6 +37,30 @@ var { handleShutdown, handleRestart, handleAdd, handleRemove, handleList, handle
37
37
 
38
38
  var args = process.argv.slice(2);
39
39
 
40
+ // --- `daemon` subcommand: run the daemon in the foreground, in this process ---
41
+ // This is what the systemd unit's ExecStart invokes (Type=simple needs the
42
+ // supervised PID to be the daemon itself, so no fork/detach here). A refused
43
+ // start exits 78 (EX_CONFIG), which the unit lists in RestartPreventExitStatus
44
+ // so a mis-installed package is not restart-looped.
45
+ if (args[0] === "daemon") {
46
+ var { findLinkTrap, linkTrapMessage, LinkTrapProbeError } = require("../lib/link-trap");
47
+ var linkTrap = null;
48
+ try {
49
+ linkTrap = findLinkTrap(path.resolve(__dirname, ".."), { binPath: process.argv[1] });
50
+ } catch (probeErr) {
51
+ // An uninspectable path is treated as a trap: fail closed, same exit code.
52
+ if (!(probeErr instanceof LinkTrapProbeError)) throw probeErr;
53
+ console.error("ERROR: " + probeErr.message + "; refusing to start (path: " + probeErr.path + ", errno: " + probeErr.errno + ")");
54
+ process.exit(78);
55
+ }
56
+ if (linkTrap) {
57
+ console.error(linkTrapMessage(linkTrap));
58
+ process.exit(78);
59
+ }
60
+ require("../lib/daemon");
61
+ return;
62
+ }
63
+
40
64
  // --- `release` subcommand group (release-engineering helpers, lr-01c6) ---
41
65
  // Positional subcommand, handled before flag parsing: `clagentic-console release list-betas`.
42
66
  if (args[0] === "release") {
@@ -56,6 +80,14 @@ if (args[0] === "release") {
56
80
  }
57
81
  }
58
82
 
83
+ // --- `open-session` / `send-input`: drive a session through the running daemon ---
84
+ // Positional verbs, handled before flag parsing: `clagentic-console send-input --project <slug> ...`.
85
+ var { SESSION_VERBS, runSessionVerb } = require("../lib/cli/session-subcommands");
86
+ if (SESSION_VERBS.indexOf(args[0]) !== -1) {
87
+ runSessionVerb(args[0], args.slice(1));
88
+ return;
89
+ }
90
+
59
91
  var port = _isDev ? 2635 : 2633;
60
92
  var useHttps = true;
61
93
  var forceMkcert = false;
@@ -96,7 +128,7 @@ for (var i = 0; i < args.length; i++) {
96
128
  } else if (args[i] === "--no-update" || args[i] === "--skip-update") {
97
129
  skipUpdate = true;
98
130
  } else if (args[i] === "--dev") {
99
- // Already handled above for CLAGENTIC_HOME, just skip
131
+ // Already handled above (sets CLAGENTIC_CONSOLE_DEV), just skip
100
132
  } else if (args[i] === "--watch" || args[i] === "-w") {
101
133
  watchMode = true;
102
134
  } else if (args[i] === "--debug") {
@@ -140,7 +172,10 @@ for (var i = 0; i < args.length; i++) {
140
172
  console.log(" clagentic-console --list List registered projects");
141
173
  console.log(" clagentic-console --activity-diagnostics Print activity-divergence probe totals as JSON (agent-readable)");
142
174
  console.log(" clagentic-console --process-build-status Print the running process's loaded build SHA as JSON (agent-readable)");
175
+ console.log(" clagentic-console open-session --project <slug> --prompt <text|-> [--vendor <id>] [--agent <name>] Open a session and run a first prompt (prints JSON)");
176
+ console.log(" clagentic-console send-input --project <slug> --session <id> --prompt <text|-> Send input to a session, resuming it if needed (prints JSON)");
143
177
  console.log(" clagentic-console release list-betas List promotable beta versions (maintainer/release-engineering)");
178
+ console.log(" clagentic-console daemon Run the daemon in the foreground (used by the systemd unit)");
144
179
  console.log("");
145
180
  console.log("Options:");
146
181
  console.log(" -p, --port <port> Port to listen on (default: 2633)");
@@ -435,7 +470,7 @@ var currentVersion = require("../package.json").version;
435
470
  if (autoRestorable.length > 0 && autoYes) {
436
471
  console.log(" " + sym.done + " Restoring " + autoRestorable.length + " previous project(s)");
437
472
  }
438
- // Add cwd if it has history in .clagentic-rc, or if there are no other projects to restore
473
+ // Add cwd if it has history in the recent-projects file, or if there are no other projects to restore
439
474
  var cwdInRc = (autoRc.recentProjects || []).some(function (p) {
440
475
  return p.path === cwd;
441
476
  });
@@ -448,7 +483,7 @@ var currentVersion = require("../package.json").version;
448
483
  // Keep the crash-watcher/getCliOpts() snapshot current now that the
449
484
  // wizard has chosen a port (see the analogous re-sync above).
450
485
  setDaemonWatcherOpts(currentCliOpts());
451
- // Check ~/.clagentic-rc for previous projects to restore
486
+ // Check the recent-projects file for previous projects to restore
452
487
  var rc = loadClayrc();
453
488
  var restorable = (rc.recentProjects || []).filter(function (p) {
454
489
  return p.path !== cwd && fs.existsSync(p.path);
@@ -1,13 +1,17 @@
1
1
  [Unit]
2
- Description=Clagentic Console daemon
2
+ Description=Clagentic: Console daemon
3
3
  After=network.target
4
4
 
5
5
  [Service]
6
6
  Type=simple
7
- ExecStart=/usr/local/bin/clagentic-daemon.sh
7
+ # Template: scripts/postinstall.js fills the BIN placeholders in this file with the
8
+ # absolute path of the globally installed clagentic-console bin at install time.
9
+ # Do not copy this file into /etc/systemd/system by hand.
10
+ ExecStart=@CLAGENTIC_CONSOLE_BIN@ daemon
8
11
  Restart=always
9
12
  RestartSec=5
10
- # EX_CONFIG (78) is a fatal configuration error (mis-set CLAGENTIC_HOME, unsupported Node) — do not restart-loop
13
+ # EX_CONFIG (78) is a fatal configuration error (mis-set CLAGENTIC_CONSOLE_HOME, unsupported Node,
14
+ # npm-link symlink trap) — do not restart-loop
11
15
  RestartPreventExitStatus=78
12
16
  KillMode=mixed
13
17
  TimeoutStopSec=20
@@ -31,9 +35,9 @@ StandardOutput=journal
31
35
  StandardError=journal
32
36
  SyslogIdentifier=clagentic-console
33
37
  Environment=SHELL=/bin/bash
34
- Environment=PATH=/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
35
- # TODO(lr-9452): rename to CLAGENTIC_CONSOLE_MAX_CONCURRENT_SESSIONS once sdk-bridge.js is updated
36
- Environment=CLAGENTIC_MAX_CONCURRENT_SESSIONS=50
38
+ # The bin dir leads PATH so `#!/usr/bin/env node` finds the node that installed the package.
39
+ Environment=PATH=@CLAGENTIC_CONSOLE_BIN_DIR@:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
40
+ Environment=CLAGENTIC_CONSOLE_MAX_CONCURRENT_SESSIONS=50
37
41
 
38
42
  [Install]
39
43
  WantedBy=multi-user.target
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ // The claude CLI has named the tool that dispatches a sub-agent both "Task"
4
+ // (older builds) and "Agent" (current builds). Every place that recognises a
5
+ // dispatch by tool name asks this predicate, so a rename cannot silently turn
6
+ // background-agent tracking off again.
7
+ //
8
+ // lib/public/modules/tools.js keeps a browser-side copy of this name set (the
9
+ // frontend is ESM and cannot require this file); a test asserts both accept
10
+ // the same names.
11
+ var AGENT_DISPATCH_TOOL_NAMES = ["Task", "Agent"];
12
+
13
+ function isAgentDispatchTool(name) {
14
+ return typeof name === "string" && AGENT_DISPATCH_TOOL_NAMES.indexOf(name) !== -1;
15
+ }
16
+
17
+ module.exports = {
18
+ AGENT_DISPATCH_TOOL_NAMES: AGENT_DISPATCH_TOOL_NAMES,
19
+ isAgentDispatchTool: isAgentDispatchTool,
20
+ };
package/lib/audit.js CHANGED
@@ -5,16 +5,17 @@
5
5
  var fs = require("fs");
6
6
  var path = require("path");
7
7
  var config = require("./config");
8
+ var { readConsoleEnv } = require("./env-compat");
8
9
 
9
10
  var AUDIT_LOG_PATH = path.join(config.CONFIG_DIR, "audit.log");
10
11
  var OLD_AUDIT_LOG_PATH = path.join(config.CONFIG_DIR, "..", "audit.log");
11
12
 
12
13
  // One-time migration: copy old audit.log to new location if new is absent.
13
14
  // Copy-not-rename so rollback still finds the old file.
14
- // Only runs if CLAGENTIC_HOME is not explicitly set (default layout).
15
+ // Only runs if CLAGENTIC_CONSOLE_HOME is not explicitly set (default layout).
15
16
  // Note: this runs at module load time, potentially before ensureConfigDir() creates
16
17
  // console/ — so we ensure the parent dir exists ourselves before copying.
17
- if (!process.env.CLAGENTIC_HOME && !fs.existsSync(AUDIT_LOG_PATH) && fs.existsSync(OLD_AUDIT_LOG_PATH)) {
18
+ if (!readConsoleEnv("CLAGENTIC_CONSOLE_HOME") &&!fs.existsSync(AUDIT_LOG_PATH) && fs.existsSync(OLD_AUDIT_LOG_PATH)) {
18
19
  try {
19
20
  fs.mkdirSync(path.dirname(AUDIT_LOG_PATH), { recursive: true });
20
21
  fs.copyFileSync(OLD_AUDIT_LOG_PATH, AUDIT_LOG_PATH);
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ // build-changes.js — the commits between the build a daemon is running and the
4
+ // build installed over it, for the operator deciding whether to restart.
5
+ //
6
+ // Git history is optional: an npm install carries none, a checkout or an
7
+ // operator-named source repository (daemon.json `buildSourceRepo`) does. When
8
+ // it cannot be read the answer says so; it never invents a list.
9
+
10
+ var fs = require('fs');
11
+ var path = require('path');
12
+ var { execFile } = require('child_process');
13
+
14
+ var SHA_RE = /^[0-9a-f]{7,40}$/i;
15
+ var DEFAULT_LIMIT = 30;
16
+ var SUBJECT_MAX = 200;
17
+ var GIT_TIMEOUT_MS = 5000;
18
+
19
+ /** The repository to read history from, or null when there is none to try. */
20
+ function resolveHistoryRepo(configured, packageRoot) {
21
+ if (typeof configured === 'string' && path.isAbsolute(configured)) return configured;
22
+ try {
23
+ if (fs.existsSync(path.join(packageRoot, '.git'))) return packageRoot;
24
+ } catch (_) {
25
+ // unreadable package root: no history to offer
26
+ }
27
+ return null;
28
+ }
29
+
30
+ function oneLine(text) {
31
+ var line = String(text).replace(/\s+/g, ' ').trim();
32
+ return line.length > SUBJECT_MAX ? line.slice(0, SUBJECT_MAX - 3) + '...' : line;
33
+ }
34
+
35
+ /**
36
+ * @param {object} o
37
+ * @param {?string} o.repo — result of resolveHistoryRepo
38
+ * @param {string} o.fromSha — the build the process loaded
39
+ * @param {string} o.toSha — the build installed over it
40
+ * @param {number} [o.limit]
41
+ * @param {function} [o.execFileFn] — injectable for tests
42
+ * @returns {Promise<{available: boolean, commits: Array<{sha: string, subject: string}>, truncated: boolean, reason: ?string}>}
43
+ */
44
+ function listBuildChanges(o) {
45
+ var limit = o.limit > 0 ? o.limit : DEFAULT_LIMIT;
46
+ var run = o.execFileFn || execFile;
47
+ function unavailable(reason) {
48
+ return { available: false, commits: [], truncated: false, reason: reason };
49
+ }
50
+ if (!o.repo) return Promise.resolve(unavailable('no git history is available for this install'));
51
+ // Only hex revisions reach git, so a value can never be read as an option.
52
+ if (!SHA_RE.test(String(o.fromSha)) || !SHA_RE.test(String(o.toSha))) {
53
+ return Promise.resolve(unavailable('a build sha is not a git revision'));
54
+ }
55
+ var args = [
56
+ '-C', o.repo,
57
+ '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null',
58
+ 'log', '--no-ext-diff', '--no-textconv',
59
+ '--format=%h%x09%s', '-n', String(limit + 1),
60
+ o.fromSha + '..' + o.toSha,
61
+ ];
62
+ return new Promise(function (resolve) {
63
+ run('git', args, { timeout: GIT_TIMEOUT_MS, maxBuffer: 1024 * 1024, encoding: 'utf8' }, function (err, stdout) {
64
+ if (err) {
65
+ resolve(unavailable('git could not list the commits between these builds'));
66
+ return;
67
+ }
68
+ var lines = String(stdout).split('\n').filter(function (l) { return l.length > 0; });
69
+ var truncated = lines.length > limit;
70
+ var commits = lines.slice(0, limit).map(function (l) {
71
+ var tab = l.indexOf('\t');
72
+ return { sha: l.slice(0, tab), subject: oneLine(l.slice(tab + 1)) };
73
+ });
74
+ resolve({ available: true, commits: commits, truncated: truncated, reason: null });
75
+ });
76
+ });
77
+ }
78
+
79
+ module.exports = { listBuildChanges: listBuildChanges, resolveHistoryRepo: resolveHistoryRepo, DEFAULT_LIMIT: DEFAULT_LIMIT };
@@ -0,0 +1,192 @@
1
+ 'use strict';
2
+
3
+ // build-identity.js — what build is this process running, and is it still the
4
+ // build installed on disk?
5
+ //
6
+ // An install replaces the package's files. A running Node process keeps what
7
+ // it already loaded, so "adopted" means two things must both hold: the sha the
8
+ // process recorded at startup equals the sha of the installed build, and the
9
+ // installed files are byte-for-byte what the process started from. The second
10
+ // half is what tells an identical reinstall (same sha, same bytes, new inodes)
11
+ // apart from a genuinely different build with an unchanged sha.
12
+ //
13
+ // The kernel's "(deleted)" mapping marker is NOT part of this decision: an
14
+ // identical reinstall unlinks the native module the daemon keeps mapped, so
15
+ // that marker appears and never clears, although nothing the daemon runs
16
+ // differs from what is installed.
17
+
18
+ var crypto = require('crypto');
19
+ var fs = require('fs');
20
+ var path = require('path');
21
+
22
+ // This module must not require another lib/ module: the daemon loads it first
23
+ // so the loaded identity is captured before any other lib code is read from
24
+ // disk. An install landing between those reads would otherwise label old
25
+ // cached code with the new tree's identity.
26
+
27
+ // A file absent or half-written during an install is expected and means
28
+ // "unknown, not stale". Anything else (permissions, I/O, a bug) is not, so it is
29
+ // journaled with the path and surfaced to the verdict instead of vanishing.
30
+ function isExpectedReadFailure(err, allowParse) {
31
+ return !!err && (err.code === 'ENOENT' || (allowParse && err instanceof SyntaxError));
32
+ }
33
+
34
+ function describeFailure(what, target, err) {
35
+ var message = what + ' ' + target + ': ' + (err && err.message ? err.message : String(err));
36
+ try { console.error('[build-identity] ' + message); } catch (_) { /* a closed stdio must not mask the verdict */ }
37
+ return message;
38
+ }
39
+
40
+ /** @returns {{sha: ?string, error: ?string}} error is set only for an unexpected failure */
41
+ function readInstalledBuildSha(buildShaPath) {
42
+ try {
43
+ var parsed = JSON.parse(fs.readFileSync(buildShaPath, 'utf8'));
44
+ return { sha: parsed && typeof parsed.sha === 'string' ? parsed.sha : null, error: null };
45
+ } catch (err) {
46
+ if (isExpectedReadFailure(err, true)) return { sha: null, error: null };
47
+ return { sha: null, error: describeFailure('could not read the build identity at', buildShaPath, err) };
48
+ }
49
+ }
50
+
51
+ var STATES = { ADOPTED: 'adopted', STALE: 'stale', INCONCLUSIVE: 'inconclusive' };
52
+
53
+ /**
54
+ * Walks `dir` and calls fn(absPath, relPath) for every regular file, in a
55
+ * stable order. Symlinks and special files are not content of the build.
56
+ */
57
+ function walkFiles(dir, relBase, fn) {
58
+ var entries = fs.readdirSync(dir, { withFileTypes: true });
59
+ entries.sort(function (a, b) { return a.name < b.name ? -1 : a.name > b.name ? 1 : 0; });
60
+ for (var i = 0; i < entries.length; i++) {
61
+ var entry = entries[i];
62
+ var abs = path.join(dir, entry.name);
63
+ var rel = relBase ? relBase + '/' + entry.name : entry.name;
64
+ if (entry.isDirectory()) walkFiles(abs, rel, fn);
65
+ else if (entry.isFile()) fn(abs, rel);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * A hasher over one package root (the directory holding lib/ and
71
+ * package.json). `hash()` returns a hex digest of every file under lib/ plus
72
+ * package.json, or null when the tree cannot be read right now (an install in
73
+ * progress removes files mid-walk). Per-file digests are remembered by
74
+ * (inode, size, mtime), so a poll re-reads only files an install replaced.
75
+ */
76
+ function createTreeHasher(packageRoot) {
77
+ var known = new Map(); // abs path -> { key, digest }
78
+ var lastError = null; // set only when the last hash() failed for a reason an install does not explain
79
+
80
+ function fileDigest(abs) {
81
+ var st = fs.statSync(abs);
82
+ // ctime moves on any in-place rewrite even when mtime is restored with
83
+ // utimes, so a same-size rewrite cannot reuse the old digest.
84
+ var key = st.dev + ':' + st.ino + ':' + st.size + ':' + st.mtimeMs + ':' + st.ctimeMs;
85
+ var cached = known.get(abs);
86
+ if (cached && cached.key === key) return cached.digest;
87
+ var digest = crypto.createHash('sha256').update(fs.readFileSync(abs)).digest('hex');
88
+ known.set(abs, { key: key, digest: digest });
89
+ return digest;
90
+ }
91
+
92
+ function hash() {
93
+ lastError = null;
94
+ try {
95
+ var outer = crypto.createHash('sha256');
96
+ var seen = new Set();
97
+ var add = function (abs, rel) {
98
+ seen.add(abs);
99
+ outer.update(rel + '\0' + fileDigest(abs) + '\n');
100
+ };
101
+ walkFiles(path.join(packageRoot, 'lib'), 'lib', add);
102
+ add(path.join(packageRoot, 'package.json'), 'package.json');
103
+ // Files that left the tree must not keep their remembered digest.
104
+ known.forEach(function (_v, abs) { if (!seen.has(abs)) known.delete(abs); });
105
+ return outer.digest('hex');
106
+ } catch (err) {
107
+ if (!isExpectedReadFailure(err, false)) {
108
+ lastError = describeFailure('could not hash the installed tree under', packageRoot, err);
109
+ }
110
+ return null;
111
+ }
112
+ }
113
+
114
+ return { hash: hash, lastError: function () { return lastError; } };
115
+ }
116
+
117
+ /**
118
+ * Pure comparison of what the process loaded against what is installed.
119
+ * Exactly one of adopted / stale / inconclusive, never a guess: a missing
120
+ * piece on either side is inconclusive with the reason, not stale.
121
+ *
122
+ * @param {{sha: ?string, contentHash: ?string}} loaded
123
+ * @param {{sha: ?string, contentHash: ?string}} installed
124
+ */
125
+ function assessBuild(loaded, installed) {
126
+ var l = loaded || {};
127
+ var i = installed || {};
128
+ var base = {
129
+ loadedBuildSha: l.sha || null,
130
+ installedBuildSha: i.sha || null,
131
+ loadedContentHash: l.contentHash || null,
132
+ installedContentHash: i.contentHash || null,
133
+ };
134
+ function result(state, reason, detail) {
135
+ return Object.assign({ state: state, reason: reason, detail: detail }, base);
136
+ }
137
+ if (!l.sha) {
138
+ return result(STATES.INCONCLUSIVE, 'no-loaded-sha',
139
+ l.shaError || 'this process has no embedded build sha (a checkout that never ran npm pack)');
140
+ }
141
+ if (!i.sha) {
142
+ return result(STATES.INCONCLUSIVE, 'no-installed-sha',
143
+ i.shaError || 'the installed build-sha.json is missing or unreadable');
144
+ }
145
+ // A partial install can change build-sha.json before the files are whole, so
146
+ // an unreadable tree is inconclusive whatever the shas say.
147
+ if (!l.contentHash || !i.contentHash) {
148
+ return result(STATES.INCONCLUSIVE, 'hash-unavailable',
149
+ l.hashError || i.hashError || 'the installed files could not be read to compare their content');
150
+ }
151
+ if (l.sha !== i.sha) {
152
+ return result(STATES.STALE, 'sha', 'the installed build (' + i.sha + ') is not the one this process loaded (' + l.sha + ')');
153
+ }
154
+ if (l.contentHash !== i.contentHash) {
155
+ return result(STATES.STALE, 'content',
156
+ 'the installed files differ from the ones this process loaded, although both report build ' + l.sha);
157
+ }
158
+ return result(STATES.ADOPTED, 'identical', 'the installed build is the one this process loaded');
159
+ }
160
+
161
+ /**
162
+ * Captures the running build once, at startup, and reads the installed one on
163
+ * demand. `libDir` is the lib/ directory this process was loaded from.
164
+ */
165
+ function createBuildIdentity(libDir) {
166
+ var packageRoot = path.resolve(libDir, '..');
167
+ var buildShaPath = path.join(libDir, 'build-sha.json');
168
+ var hasher = createTreeHasher(packageRoot);
169
+ function snapshot() {
170
+ var s = readInstalledBuildSha(buildShaPath);
171
+ var contentHash = hasher.hash();
172
+ return { sha: s.sha, shaError: s.error, contentHash: contentHash, hashError: contentHash ? null : hasher.lastError() };
173
+ }
174
+ var loaded = snapshot();
175
+
176
+ function readInstalled() {
177
+ return snapshot();
178
+ }
179
+
180
+ return {
181
+ loaded: loaded,
182
+ readInstalled: readInstalled,
183
+ assess: function () { return assessBuild(loaded, readInstalled()); },
184
+ };
185
+ }
186
+
187
+ module.exports = {
188
+ STATES: STATES,
189
+ assessBuild: assessBuild,
190
+ createBuildIdentity: createBuildIdentity,
191
+ createTreeHasher: createTreeHasher,
192
+ };