@clagentic/console 1.9.0-beta.3 → 1.10.0-beta.1

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 (146) 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 +8 -2
  5. package/bin/cli.js +30 -5
  6. package/deploy/clagentic-console.service +10 -6
  7. package/lib/audit.js +3 -2
  8. package/lib/build-sha.json +2 -2
  9. package/lib/build-update-check.js +138 -0
  10. package/lib/cli/daemon-launch.js +17 -17
  11. package/lib/config.js +32 -20
  12. package/lib/daemon-env-settings.js +84 -0
  13. package/lib/daemon-projects.js +38 -0
  14. package/lib/daemon.js +202 -158
  15. package/lib/drain.js +74 -17
  16. package/lib/env-compat.js +61 -0
  17. package/lib/extension-commands.js +45 -0
  18. package/lib/history-visibility.js +4 -0
  19. package/lib/idle-adapter-reaper.js +71 -0
  20. package/lib/link-trap.js +78 -0
  21. package/lib/lore-attestation.js +73 -0
  22. package/lib/mcp-local.js +8 -6
  23. package/lib/mcp-tool-input.js +116 -0
  24. package/lib/mcp-tool-schema.js +179 -0
  25. package/lib/memory-limits.js +61 -5
  26. package/lib/memory-setting-validate.js +65 -0
  27. package/lib/new-work-gate.js +47 -0
  28. package/lib/os-users.js +5 -3
  29. package/lib/project-access.js +139 -0
  30. package/lib/project-connection.js +23 -22
  31. package/lib/project-external-trigger.js +103 -10
  32. package/lib/project-file-scope.js +172 -0
  33. package/lib/project-file-watch.js +86 -61
  34. package/lib/project-filesystem.js +144 -128
  35. package/lib/project-git.js +119 -0
  36. package/lib/project-http.js +44 -28
  37. package/lib/project-loop.js +12 -5
  38. package/lib/project-mcp.js +53 -72
  39. package/lib/project-message-gate.js +70 -0
  40. package/lib/project-notifications.js +31 -4
  41. package/lib/project-prompt-responses.js +216 -0
  42. package/lib/project-sessions.js +164 -302
  43. package/lib/project-user-message.js +36 -11
  44. package/lib/project.js +189 -142
  45. package/lib/projects-dir.js +90 -0
  46. package/lib/prompt-access.js +22 -0
  47. package/lib/prompt-kinds/answer-limits.js +15 -0
  48. package/lib/prompt-kinds/ask-user.js +58 -0
  49. package/lib/prompt-kinds/codecs.js +97 -0
  50. package/lib/prompt-kinds/elicitation.js +77 -0
  51. package/lib/prompt-kinds/extension.js +39 -0
  52. package/lib/prompt-kinds/index.js +68 -0
  53. package/lib/prompt-kinds/permission.js +114 -0
  54. package/lib/prompt-kinds/plan.js +79 -0
  55. package/lib/prompt-kinds/tool-call.js +38 -0
  56. package/lib/prompt-registry.js +673 -0
  57. package/lib/public/app.js +1 -1
  58. package/lib/public/css/diagnostics.css +50 -0
  59. package/lib/public/css/input.css +17 -3
  60. package/lib/public/css/menus.css +10 -0
  61. package/lib/public/css/messages.css +5 -0
  62. package/lib/public/css/rewind.css +22 -0
  63. package/lib/public/index.html +4 -12
  64. package/lib/public/modules/app-connection.js +7 -0
  65. package/lib/public/modules/app-cursors.js +7 -5
  66. package/lib/public/modules/app-messages.js +45 -45
  67. package/lib/public/modules/app-notifications.js +47 -71
  68. package/lib/public/modules/app-panels.js +61 -58
  69. package/lib/public/modules/app-projects.js +2 -1
  70. package/lib/public/modules/app-rendering.js +4 -10
  71. package/lib/public/modules/diagnostics.js +60 -16
  72. package/lib/public/modules/filebrowser.js +18 -16
  73. package/lib/public/modules/history-visibility.js +4 -0
  74. package/lib/public/modules/mention.js +3 -2
  75. package/lib/public/modules/mode-options.js +38 -0
  76. package/lib/public/modules/project-settings.js +19 -8
  77. package/lib/public/modules/prompt-banner.js +78 -0
  78. package/lib/public/modules/prompt-card.js +201 -0
  79. package/lib/public/modules/prompt-kinds/ask-user-codec.js +131 -0
  80. package/lib/public/modules/prompt-kinds/ask-user.js +213 -0
  81. package/lib/public/modules/prompt-kinds/elicitation-codec.js +343 -0
  82. package/lib/public/modules/prompt-kinds/elicitation.js +176 -0
  83. package/lib/public/modules/prompt-kinds/index.js +18 -0
  84. package/lib/public/modules/prompt-kinds/own-key.js +29 -0
  85. package/lib/public/modules/prompt-kinds/package.json +3 -0
  86. package/lib/public/modules/prompt-kinds/permission-choices.js +31 -0
  87. package/lib/public/modules/prompt-kinds/permission.js +209 -0
  88. package/lib/public/modules/prompt-kinds/plan.js +102 -0
  89. package/lib/public/modules/prompt-state.js +142 -0
  90. package/lib/public/modules/prompts.js +134 -0
  91. package/lib/public/modules/rewind.js +4 -1
  92. package/lib/public/modules/server-settings.js +2 -4
  93. package/lib/public/modules/sidebar-mobile.js +19 -9
  94. package/lib/public/modules/sidebar-sessions.js +21 -14
  95. package/lib/public/modules/sticky-notes.js +3 -2
  96. package/lib/public/modules/team-panel.js +5 -4
  97. package/lib/public/modules/tools.js +67 -904
  98. package/lib/public/modules/vendor-picker.js +53 -0
  99. package/lib/public/modules/vendor-registry.js +133 -0
  100. package/lib/public/sw.js +3 -1
  101. package/lib/rc-migrate.js +44 -0
  102. package/lib/runtime-env-keys.js +109 -0
  103. package/lib/runtime-env.js +236 -0
  104. package/lib/sdk-bridge.js +290 -273
  105. package/lib/sdk-message-processor.js +125 -145
  106. package/lib/server-hub-sessions.js +13 -10
  107. package/lib/server-palette.js +28 -19
  108. package/lib/server.js +141 -113
  109. package/lib/service-install.js +96 -0
  110. package/lib/session-capabilities.js +76 -0
  111. package/lib/sessions.js +45 -28
  112. package/lib/users-permissions.js +9 -6
  113. package/lib/users.js +9 -0
  114. package/lib/utils.js +4 -2
  115. package/lib/vendor-auth.js +22 -0
  116. package/lib/vendor-registry-message.js +65 -0
  117. package/lib/ws-origin.js +99 -0
  118. package/lib/ws-schema.js +33 -22
  119. package/lib/yoke/adapters/claude-capabilities.js +38 -0
  120. package/lib/yoke/adapters/claude-vendor.js +35 -0
  121. package/lib/yoke/adapters/claude-worker.js +55 -87
  122. package/lib/yoke/adapters/claude.js +156 -62
  123. package/lib/yoke/adapters/codex-capabilities.js +37 -0
  124. package/lib/yoke/adapters/codex-vendor.js +46 -0
  125. package/lib/yoke/adapters/codex.js +347 -156
  126. package/lib/yoke/adapters/effort-control.js +34 -0
  127. package/lib/yoke/adapters/permission-relay.js +58 -0
  128. package/lib/yoke/adapters/worker-mcp-servers.js +81 -0
  129. package/lib/yoke/auth-checks.js +104 -0
  130. package/lib/yoke/capabilities.js +49 -0
  131. package/lib/yoke/codex-app-server.js +23 -5
  132. package/lib/yoke/env-ownership.js +40 -0
  133. package/lib/yoke/index.js +67 -173
  134. package/lib/yoke/install-probe.js +121 -0
  135. package/lib/yoke/instructions.js +7 -11
  136. package/lib/yoke/interface.js +199 -3
  137. package/lib/yoke/package.json +1 -1
  138. package/lib/yoke/provider-credentials.js +96 -0
  139. package/lib/yoke/registry.js +340 -0
  140. package/package.json +12 -8
  141. package/scripts/check-sdk-lock-drift.js +160 -0
  142. package/scripts/check-test-count.js +76 -1
  143. package/scripts/postinstall.js +218 -136
  144. package/scripts/prompt-harness-history.js +202 -0
  145. package/scripts/verify-installed.js +67 -0
  146. 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>
@@ -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") {
@@ -96,7 +120,7 @@ for (var i = 0; i < args.length; i++) {
96
120
  } else if (args[i] === "--no-update" || args[i] === "--skip-update") {
97
121
  skipUpdate = true;
98
122
  } else if (args[i] === "--dev") {
99
- // Already handled above for CLAGENTIC_HOME, just skip
123
+ // Already handled above (sets CLAGENTIC_CONSOLE_DEV), just skip
100
124
  } else if (args[i] === "--watch" || args[i] === "-w") {
101
125
  watchMode = true;
102
126
  } else if (args[i] === "--debug") {
@@ -141,6 +165,7 @@ for (var i = 0; i < args.length; i++) {
141
165
  console.log(" clagentic-console --activity-diagnostics Print activity-divergence probe totals as JSON (agent-readable)");
142
166
  console.log(" clagentic-console --process-build-status Print the running process's loaded build SHA as JSON (agent-readable)");
143
167
  console.log(" clagentic-console release list-betas List promotable beta versions (maintainer/release-engineering)");
168
+ console.log(" clagentic-console daemon Run the daemon in the foreground (used by the systemd unit)");
144
169
  console.log("");
145
170
  console.log("Options:");
146
171
  console.log(" -p, --port <port> Port to listen on (default: 2633)");
@@ -435,7 +460,7 @@ var currentVersion = require("../package.json").version;
435
460
  if (autoRestorable.length > 0 && autoYes) {
436
461
  console.log(" " + sym.done + " Restoring " + autoRestorable.length + " previous project(s)");
437
462
  }
438
- // Add cwd if it has history in .clagentic-rc, or if there are no other projects to restore
463
+ // Add cwd if it has history in the recent-projects file, or if there are no other projects to restore
439
464
  var cwdInRc = (autoRc.recentProjects || []).some(function (p) {
440
465
  return p.path === cwd;
441
466
  });
@@ -448,7 +473,7 @@ var currentVersion = require("../package.json").version;
448
473
  // Keep the crash-watcher/getCliOpts() snapshot current now that the
449
474
  // wizard has chosen a port (see the analogous re-sync above).
450
475
  setDaemonWatcherOpts(currentCliOpts());
451
- // Check ~/.clagentic-rc for previous projects to restore
476
+ // Check the recent-projects file for previous projects to restore
452
477
  var rc = loadClayrc();
453
478
  var restorable = (rc.recentProjects || []).filter(function (p) {
454
479
  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
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);
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "15119b80509da03dc53f5b059127646df851109a",
3
- "writtenAt": "2026-09-04T15:36:46.197Z"
2
+ "sha": "60b156cfc4df1ac7c46a48c98bd3ba448c132c03",
3
+ "writtenAt": "2026-10-11T22:53:13.001Z"
4
4
  }
@@ -0,0 +1,138 @@
1
+ // build-update-check.js — lr-e85fec: detects that a newer build has been
2
+ // installed on disk than the one this running daemon process loaded at
3
+ // startup, so the daemon can OFFER the operator a restart instead of the
4
+ // condition sitting invisible until someone remembers to check.
5
+ //
6
+ // This is deliberately detection-only. It never restarts anything itself —
7
+ // see lib/daemon.js's onRestartForBuildUpdate for the operator-initiated
8
+ // actuator, and this module's own header note below for why that split is
9
+ // load-bearing, not incidental.
10
+ //
11
+ // Reuses existing signals rather than inventing new ones:
12
+ // - `loadedBuildSha` (lib/daemon.js): captured ONCE at process startup from
13
+ // lib/build-sha.json — never re-read, so it always reflects what THIS
14
+ // process actually has in its module cache (lr-dc9a3b).
15
+ // - the on-disk lib/build-sha.json file: re-read fresh on every poll here,
16
+ // so it reflects whatever `npm install -g` most recently wrote — the
17
+ // same file scripts/verify-installed-build.js compares against merged
18
+ // HEAD at merge time.
19
+ //
20
+ // A daemon process that started before lib/build-sha.json existed (a dev
21
+ // checkout that never ran `npm pack`) reports loadedBuildSha === null. That
22
+ // is a legitimate "no build-identity signal available" state (see
23
+ // lib/daemon.js's own comment on the same condition) — never surfaced as a
24
+ // staleness diagnostic, since there is nothing to compare against.
25
+
26
+ 'use strict';
27
+
28
+ var fs = require('fs');
29
+
30
+ /**
31
+ * Read the current on-disk build-sha.json's `sha` field.
32
+ *
33
+ * @param {string} buildShaPath — absolute path to lib/build-sha.json.
34
+ * @returns {string|null} the SHA, or null if the file is missing/malformed
35
+ * (a dev checkout that has never run `npm pack`, or a filesystem race with
36
+ * an in-progress install write — both are "unknown," not "stale").
37
+ */
38
+ function readInstalledBuildSha(buildShaPath) {
39
+ try {
40
+ var raw = fs.readFileSync(buildShaPath, 'utf8');
41
+ var parsed = JSON.parse(raw);
42
+ if (parsed && typeof parsed.sha === 'string') return parsed.sha;
43
+ } catch (_) {
44
+ // Missing/unreadable/malformed — treated as "unknown," not "stale."
45
+ }
46
+ return null;
47
+ }
48
+
49
+ /**
50
+ * Pure comparison: does the on-disk build differ from what this process
51
+ * loaded at startup?
52
+ *
53
+ * @param {object} opts
54
+ * @param {string|null} opts.loadedBuildSha — captured once at daemon startup.
55
+ * @param {string|null} opts.installedBuildSha — freshly read from disk.
56
+ * @returns {{stale: boolean, loadedBuildSha: string|null, installedBuildSha: string|null}}
57
+ * stale is true only when BOTH shas are known non-null strings and they
58
+ * differ — never true from an absent/unreadable signal on either side,
59
+ * matching lib/daemon.js's own "no signal" (never guess) discipline for
60
+ * loadedBuildSha above.
61
+ */
62
+ function checkForNewerInstalledBuild(opts) {
63
+ var o = opts || {};
64
+ var loaded = typeof o.loadedBuildSha === 'string' ? o.loadedBuildSha : null;
65
+ var installed = typeof o.installedBuildSha === 'string' ? o.installedBuildSha : null;
66
+ return {
67
+ stale: !!(loaded && installed && loaded !== installed),
68
+ loadedBuildSha: loaded,
69
+ installedBuildSha: installed,
70
+ };
71
+ }
72
+
73
+ /**
74
+ * Bounded wait for in-flight sessions to finish, then invoke `onIdle()`.
75
+ * Extracted out of lib/daemon.js's onRestartForBuildUpdate so this timing
76
+ * logic is unit-testable without spinning up a real daemon process (the
77
+ * daemon script itself has no other exported surface — see
78
+ * test/daemon-bootstrap-guard.test.js's subprocess-spawn approach for why
79
+ * that path is reserved for bootstrap-only cases, not routine logic).
80
+ *
81
+ * This is the ONLY thing standing between "operator clicked restart" and
82
+ * "daemon actually restarts" — it never fires without that click (see
83
+ * lib/project-sessions.js's restart_for_build_update handler, which is the
84
+ * sole caller of the onRestartForBuildUpdate that wraps this). It exists so
85
+ * that click does not also mean "drop whatever is running right now" when
86
+ * waiting a bounded amount of time can avoid that.
87
+ *
88
+ * @param {object} opts
89
+ * @param {function(): number} opts.getActiveCount — same shape as
90
+ * drain.js's opts.getActiveCount (lib/sdk-bridge.js's getActiveLiveCount).
91
+ * @param {function(): void} opts.onIdle — called exactly once, either when
92
+ * getActiveCount() reaches <= 0 or when the timeout elapses.
93
+ * @param {number} [opts.timeoutMs] — defaults to DEFAULT_RESTART_WAIT_MS.
94
+ * @param {number} [opts.pollIntervalMs] — defaults to 1000.
95
+ * @param {function(function(): void, number): void} [opts.setTimeoutFn] —
96
+ * injectable for tests (default: a thin wrapper over the global
97
+ * setTimeout). Called as setTimeoutFn(fn, delayMs); must invoke fn with no
98
+ * arguments after that delay, same contract as the global setTimeout.
99
+ * @param {function(): number} [opts.nowMs] — injectable for tests (default
100
+ * Date.now).
101
+ */
102
+ var DEFAULT_RESTART_WAIT_MS = 60 * 1000;
103
+
104
+ function waitForIdleThenAct(opts) {
105
+ var o = opts || {};
106
+ if (typeof o.getActiveCount !== 'function') {
107
+ throw new Error('waitForIdleThenAct: opts.getActiveCount must be a function');
108
+ }
109
+ if (typeof o.onIdle !== 'function') {
110
+ throw new Error('waitForIdleThenAct: opts.onIdle must be a function');
111
+ }
112
+ var timeoutMs = (typeof o.timeoutMs === 'number' && o.timeoutMs > 0) ? o.timeoutMs : DEFAULT_RESTART_WAIT_MS;
113
+ var pollIntervalMs = (typeof o.pollIntervalMs === 'number' && o.pollIntervalMs > 0) ? o.pollIntervalMs : 1000;
114
+ var now = typeof o.nowMs === 'function' ? o.nowMs : Date.now;
115
+ var scheduleFn = typeof o.setTimeoutFn === 'function' ? o.setTimeoutFn : function (fn, delay) { setTimeout(fn, delay); };
116
+
117
+ var deadline = now() + timeoutMs;
118
+ var acted = false;
119
+
120
+ function tick() {
121
+ if (acted) return; // idempotent — a stray extra tick must never double-fire
122
+ if (o.getActiveCount() <= 0 || now() >= deadline) {
123
+ acted = true;
124
+ o.onIdle();
125
+ return;
126
+ }
127
+ scheduleFn(tick, pollIntervalMs);
128
+ }
129
+
130
+ tick();
131
+ }
132
+
133
+ module.exports = {
134
+ readInstalledBuildSha: readInstalledBuildSha,
135
+ checkForNewerInstalledBuild: checkForNewerInstalledBuild,
136
+ waitForIdleThenAct: waitForIdleThenAct,
137
+ DEFAULT_RESTART_WAIT_MS: DEFAULT_RESTART_WAIT_MS,
138
+ };
@@ -190,8 +190,8 @@ async function restartDaemonFromConfig(opts) {
190
190
 
191
191
  // Debug mode: run in foreground with logs to stdout
192
192
  if (opts.debugMode) {
193
- process.env.CLAGENTIC_CONFIG = configPath();
194
- process.env.CLAGENTIC_HOME = CLAGENTIC_HOME;
193
+ process.env.CLAGENTIC_CONSOLE_CONFIG = configPath();
194
+ process.env.CLAGENTIC_CONSOLE_HOME = CLAGENTIC_HOME;
195
195
  newConfig.pid = process.pid;
196
196
  saveConfig(newConfig);
197
197
  require(daemonScript);
@@ -206,8 +206,8 @@ async function restartDaemonFromConfig(opts) {
206
206
  windowsHide: true,
207
207
  stdio: ["ignore", logFd, logFd],
208
208
  env: Object.assign({}, process.env, {
209
- CLAGENTIC_CONFIG: configPath(),
210
- CLAGENTIC_HOME: CLAGENTIC_HOME,
209
+ CLAGENTIC_CONSOLE_CONFIG: configPath(),
210
+ CLAGENTIC_CONSOLE_HOME: CLAGENTIC_HOME,
211
211
  }),
212
212
  });
213
213
  child.unref();
@@ -311,7 +311,7 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers, c
311
311
  if (addCwd) {
312
312
  var slug = generateSlug(cwd, []);
313
313
  var cwdEntry = { path: cwd, slug: slug, addedAt: Date.now() };
314
- // Restore title/icon from .clagentic-rc if available
314
+ // Restore title/icon from the recent-projects file if available
315
315
  var cwdRc = loadClayrc();
316
316
  var cwdRecent = cwdRc.recentProjects || [];
317
317
  for (var cr = 0; cr < cwdRecent.length; cr++) {
@@ -329,7 +329,7 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers, c
329
329
  usedSlugs.push(slug);
330
330
  }
331
331
 
332
- // Add restored projects (from ~/.clagentic-rc)
332
+ // Add restored projects (from the recent-projects file)
333
333
  if (extraProjects && extraProjects.length > 0) {
334
334
  for (var ep = 0; ep < extraProjects.length; ep++) {
335
335
  var rp = extraProjects[ep];
@@ -371,8 +371,8 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers, c
371
371
 
372
372
  // Debug mode: run in foreground with logs to stdout
373
373
  if (cliOpts.debugMode) {
374
- process.env.CLAGENTIC_CONFIG = configPath();
375
- process.env.CLAGENTIC_HOME = CLAGENTIC_HOME;
374
+ process.env.CLAGENTIC_CONSOLE_CONFIG = configPath();
375
+ process.env.CLAGENTIC_CONSOLE_HOME = CLAGENTIC_HOME;
376
376
  config.pid = process.pid;
377
377
  saveConfig(config);
378
378
  require(daemonScript);
@@ -387,8 +387,8 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers, c
387
387
  windowsHide: true,
388
388
  stdio: ["ignore", logFd, logFd],
389
389
  env: Object.assign({}, process.env, {
390
- CLAGENTIC_CONFIG: configPath(),
391
- CLAGENTIC_HOME: CLAGENTIC_HOME,
390
+ CLAGENTIC_CONSOLE_CONFIG: configPath(),
391
+ CLAGENTIC_CONSOLE_HOME: CLAGENTIC_HOME,
392
392
  }),
393
393
  });
394
394
  child.unref();
@@ -505,7 +505,7 @@ async function devMode(mode, keepAwake, existingPinHash, wantOsUsers, cliOpts) {
505
505
  var restorable = (rc.recentProjects || []).filter(function (p) {
506
506
  return p.path !== cwd && fs.existsSync(p.path);
507
507
  });
508
- // Restore title/icon for cwd from .clagentic-rc
508
+ // Restore title/icon for cwd from the recent-projects file
509
509
  var rcAll = rc.recentProjects || [];
510
510
  for (var ci = 0; ci < rcAll.length; ci++) {
511
511
  if (rcAll[ci].path === cwd) {
@@ -570,8 +570,8 @@ async function devMode(mode, keepAwake, existingPinHash, wantOsUsers, cliOpts) {
570
570
  child = spawn(process.execPath, [daemonScript], {
571
571
  stdio: ["ignore", "inherit", "inherit"],
572
572
  env: Object.assign({}, process.env, {
573
- CLAGENTIC_CONFIG: configPath(),
574
- CLAGENTIC_HOME: CLAGENTIC_HOME,
573
+ CLAGENTIC_CONSOLE_CONFIG: configPath(),
574
+ CLAGENTIC_CONSOLE_HOME: CLAGENTIC_HOME,
575
575
  }),
576
576
  });
577
577
 
@@ -735,8 +735,8 @@ async function _restartDaemonWithTLS(config, callback, cliOpts) {
735
735
  windowsHide: true,
736
736
  stdio: ["ignore", logFd, logFd],
737
737
  env: Object.assign({}, process.env, {
738
- CLAGENTIC_CONFIG: configPath(),
739
- CLAGENTIC_HOME: CLAGENTIC_HOME,
738
+ CLAGENTIC_CONSOLE_CONFIG: configPath(),
739
+ CLAGENTIC_CONSOLE_HOME: CLAGENTIC_HOME,
740
740
  }),
741
741
  });
742
742
  child.unref();
@@ -762,8 +762,8 @@ async function _restartDaemonWithTLS(config, callback, cliOpts) {
762
762
  windowsHide: true,
763
763
  stdio: ["ignore", logFd2, logFd2],
764
764
  env: Object.assign({}, process.env, {
765
- CLAGENTIC_CONFIG: configPath(),
766
- CLAGENTIC_HOME: CLAGENTIC_HOME,
765
+ CLAGENTIC_CONSOLE_CONFIG: configPath(),
766
+ CLAGENTIC_CONSOLE_HOME: CLAGENTIC_HOME,
767
767
  }),
768
768
  });
769
769
  child2.unref();