@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/lib/config.js CHANGED
@@ -3,6 +3,8 @@ var path = require("path");
3
3
  var os = require("os");
4
4
  var net = require("net");
5
5
  var execFileSync = require("child_process").execFileSync;
6
+ var { readConsoleEnv } = require("./env-compat");
7
+ var { migrateRc, RC_FILENAME } = require("./rc-migrate");
6
8
  var _store = null; // lazy to avoid circular-require at module load time
7
9
 
8
10
  function isSafeSystemUserName(name) {
@@ -32,12 +34,12 @@ function getRealHome() {
32
34
  var REAL_HOME = getRealHome();
33
35
 
34
36
  // Data dir: ~/.clagentic/console/ (prev: ~/.clagentic/ root → moved to console/ subdir by lr-12d0; prev: ~/.clay/ — migrated on first run)
35
- // If CLAGENTIC_CONFIG is set (daemon mode), derive CLAGENTIC_HOME from it.
36
- // CLAY_HOME and CLAY_CONFIG accepted as fallbacks for one release.
37
- var CLAGENTIC_HOME = process.env.CLAGENTIC_HOME
38
- || process.env.CLAY_HOME
39
- || (process.env.CLAGENTIC_CONFIG ? path.dirname(process.env.CLAGENTIC_CONFIG) : null)
40
- || (process.env.CLAY_CONFIG ? path.dirname(process.env.CLAY_CONFIG) : null)
37
+ // If CLAGENTIC_CONSOLE_CONFIG is set (daemon mode), derive the home from it.
38
+ // The un-scoped names are accepted for one release (see env-compat.js).
39
+ var _envHome = readConsoleEnv("CLAGENTIC_CONSOLE_HOME");
40
+ var _envConfig = _envHome ? undefined : readConsoleEnv("CLAGENTIC_CONSOLE_CONFIG");
41
+ var CLAGENTIC_HOME = _envHome
42
+ || (_envConfig ? path.dirname(_envConfig) : null)
41
43
  || path.join(REAL_HOME, ".clagentic");
42
44
 
43
45
  // One-time migration: copy ~/.clay/ → ~/.clagentic/ if clagentic dir absent
@@ -92,16 +94,20 @@ var CONFIG_DIR = CONSOLE_DIR;
92
94
  var EXTERNAL_TRIGGERS_DIR = path.join(CONFIG_DIR, "external-triggers");
93
95
  var OLD_EXTERNAL_TRIGGERS_DIR = path.join(CLAGENTIC_HOME, "external-triggers");
94
96
  var OLD_CLAYRC = path.join(REAL_HOME, ".clayrc");
95
- var CLAGENTIC_RC_PATH = path.join(REAL_HOME, ".clagentic-rc");
96
- // One-time migration: copy .clayrc → .clagentic-rc if new file absent
97
- if (!fs.existsSync(CLAGENTIC_RC_PATH) && fs.existsSync(OLD_CLAYRC)) {
98
- try { fs.copyFileSync(OLD_CLAYRC, CLAGENTIC_RC_PATH); } catch (e) {}
99
- }
97
+ // Recent-projects file. Kept beside daemon.json under the console data dir
98
+ // (not ~/.config/clagentic/console/) so it follows CLAGENTIC_CONSOLE_HOME and
99
+ // lives with the rest of this product's state, which already sits in CONFIG_DIR.
100
+ var RC_PATH = path.join(CONFIG_DIR, RC_FILENAME);
101
+ // One-time COPY from the old home-directory dotfiles; the originals are never touched.
102
+ migrateRc({
103
+ rcPath: RC_PATH,
104
+ legacyPaths: [path.join(REAL_HOME, ".clagentic-rc"), OLD_CLAYRC],
105
+ });
100
106
  var CRASH_INFO_PATH = path.join(CONFIG_DIR, "crash.json");
101
107
  var OLD_CRASH_INFO_PATH = path.join(CLAGENTIC_HOME, "crash.json");
102
108
 
103
109
  // Dev mode uses separate daemon files so dev and prod can run simultaneously
104
- var _devMode = !!(process.env.CLAGENTIC_DEV || process.env.CLAY_DEV);
110
+ var _devMode = !!readConsoleEnv("CLAGENTIC_CONSOLE_DEV");
105
111
 
106
112
  function configPath() {
107
113
  return path.join(CONFIG_DIR, _devMode ? "daemon-dev.json" : "daemon.json");
@@ -112,10 +118,13 @@ function oldConfigPath() {
112
118
  return path.join(CLAGENTIC_HOME, _devMode ? "daemon-dev.json" : "daemon.json");
113
119
  }
114
120
 
121
+ function windowsPipePath(devMode) {
122
+ return "\\\\.\\pipe\\" + (devMode ? "clagentic-console-daemon-dev" : "clagentic-console-daemon");
123
+ }
124
+
115
125
  function socketPath() {
116
126
  if (process.platform === "win32") {
117
- var pipeName = _devMode ? "clagentic-daemon-dev" : "clagentic-daemon";
118
- return "\\\\.\\pipe\\" + pipeName;
127
+ return windowsPipePath(_devMode);
119
128
  }
120
129
  return path.join(CONFIG_DIR, _devMode ? "daemon-dev.sock" : "daemon.sock");
121
130
  }
@@ -147,7 +156,7 @@ function ensureConfigDir() {
147
156
  // One-time migrations: copy Console-owned runtime files to console/ subdir.
148
157
  // Rules: copy-not-rename (rollback safety), never overwrite newer dest,
149
158
  // non-fatal on permission errors, skip when CLAGENTIC_HOME is custom.
150
- if (!process.env.CLAGENTIC_HOME) {
159
+ if (!readConsoleEnv("CLAGENTIC_CONSOLE_HOME")) {
151
160
  // daemon.log / daemon-dev.log
152
161
  var oldLog = oldLogPath();
153
162
  var newLog = logPath();
@@ -455,11 +464,11 @@ function clearCrashInfo() {
455
464
  try { fs.unlinkSync(CRASH_INFO_PATH); } catch (e) {}
456
465
  }
457
466
 
458
- // --- ~/.clagentic-rc (recent projects persistence) ---
467
+ // --- recent projects persistence (RC_PATH) ---
459
468
 
460
469
  function loadClayrc() {
461
470
  try {
462
- var data = fs.readFileSync(CLAGENTIC_RC_PATH, "utf8");
471
+ var data = fs.readFileSync(RC_PATH, "utf8");
463
472
  return JSON.parse(data);
464
473
  } catch (e) {
465
474
  return { recentProjects: [] };
@@ -467,13 +476,14 @@ function loadClayrc() {
467
476
  }
468
477
 
469
478
  function saveClayrc(rc) {
470
- var tmpPath = CLAGENTIC_RC_PATH + ".tmp";
479
+ var tmpPath = RC_PATH + ".tmp";
480
+ fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
471
481
  fs.writeFileSync(tmpPath, JSON.stringify(rc, null, 2) + "\n");
472
- fs.renameSync(tmpPath, CLAGENTIC_RC_PATH);
482
+ fs.renameSync(tmpPath, RC_PATH);
473
483
  }
474
484
 
475
485
  /**
476
- * Update ~/.clagentic-rc with the current project list from daemon config.
486
+ * Update the recent-projects file with the current project list from daemon config.
477
487
  * Merges with existing entries (preserves addedAt, updates lastUsed).
478
488
  */
479
489
  function syncClayrc(projects) {
@@ -546,6 +556,8 @@ module.exports = {
546
556
  EXTERNAL_TRIGGERS_DIR: EXTERNAL_TRIGGERS_DIR,
547
557
  configPath: configPath,
548
558
  socketPath: socketPath,
559
+ windowsPipePath: windowsPipePath,
560
+ RC_PATH: RC_PATH,
549
561
  oldSocketPath: oldSocketPath,
550
562
  logPath: logPath,
551
563
  ensureConfigDir: ensureConfigDir,
@@ -0,0 +1,84 @@
1
+ // daemon-env-settings.js - where the shared and per-project environment texts
2
+ // are kept. The daemon holds the shared text on its config (sharedEnv) and each
3
+ // project's on its record (envrc); the Settings pages read and write them
4
+ // through the four callbacks this returns.
5
+ //
6
+ // A text is checked here as well as on the WebSocket handler that receives it,
7
+ // so a caller that reaches the store another way cannot save a protected
8
+ // variable.
9
+
10
+ var runtimeEnv = require("./runtime-env");
11
+
12
+ /**
13
+ * @param {object} deps
14
+ * @param {function(): object} deps.getConfig the daemon config (projects[], sharedEnv)
15
+ * @param {function(object): void} deps.saveConfig
16
+ * @returns {{onGetProjectEnv: function, onSetProjectEnv: function, onGetSharedEnv: function, onSetSharedEnv: function}}
17
+ */
18
+ function createEnvSettings(deps) {
19
+ var getConfig = deps.getConfig;
20
+ var saveConfig = deps.saveConfig;
21
+
22
+ function findProject(slug) {
23
+ var projects = getConfig().projects || [];
24
+ for (var i = 0; i < projects.length; i++) {
25
+ if (projects[i].slug === slug) return projects[i];
26
+ }
27
+ return null;
28
+ }
29
+
30
+ return {
31
+ onGetProjectEnv: function (slug) {
32
+ var project = findProject(slug);
33
+ return { envrc: (project && project.envrc) || "" };
34
+ },
35
+
36
+ onSetProjectEnv: function (slug, envrc) {
37
+ var project = findProject(slug);
38
+ if (!project) return { ok: false, error: "Project not found" };
39
+ var problem = runtimeEnv.validateEnvText(envrc);
40
+ if (problem) return { ok: false, error: problem };
41
+ if (envrc) {
42
+ project.envrc = envrc;
43
+ } else {
44
+ delete project.envrc;
45
+ }
46
+ saveConfig(getConfig());
47
+ return { ok: true };
48
+ },
49
+
50
+ onGetSharedEnv: function () {
51
+ return { envrc: getConfig().sharedEnv || "" };
52
+ },
53
+
54
+ onSetSharedEnv: function (envrc) {
55
+ var problem = runtimeEnv.validateEnvText(envrc);
56
+ if (problem) return { ok: false, error: problem };
57
+ var config = getConfig();
58
+ if (envrc) {
59
+ config.sharedEnv = envrc;
60
+ } else {
61
+ delete config.sharedEnv;
62
+ }
63
+ saveConfig(config);
64
+ return { ok: true };
65
+ },
66
+ };
67
+ }
68
+
69
+ /**
70
+ * A project's environment text was written by its owner and applies to the
71
+ * owner's sessions: when the owner changes, the new owner does not inherit it.
72
+ * @param {object} project the project record (mutated)
73
+ * @param {string|null} oldOwnerId
74
+ * @param {string|null} newOwnerId
75
+ * @returns {boolean} true when the text was removed
76
+ */
77
+ function removeEnvrcOnOwnerChange(project, oldOwnerId, newOwnerId) {
78
+ if ((oldOwnerId || null) === (newOwnerId || null)) return false;
79
+ if (!project || !("envrc" in project)) return false;
80
+ delete project.envrc;
81
+ return true;
82
+ }
83
+
84
+ module.exports = { createEnvSettings: createEnvSettings, removeEnvrcOnOwnerChange: removeEnvrcOnOwnerChange };
@@ -134,6 +134,42 @@ function getFilteredRemovedProjects(config, userId) {
134
134
  });
135
135
  }
136
136
 
137
+ /**
138
+ * The parent project's slug for a registered worktree slug, or null when the
139
+ * slug is not a registered worktree. Worktrees inherit their parent's access.
140
+ */
141
+ function getWorktreeParent(wtSlug) {
142
+ var parents = Object.keys(worktreeRegistry);
143
+ for (var i = 0; i < parents.length; i++) {
144
+ if (worktreeRegistry[parents[i]].indexOf(wtSlug) !== -1) return parents[i];
145
+ }
146
+ return null;
147
+ }
148
+
149
+ /**
150
+ * The access record for a project slug, as lib/server.js's access checks read
151
+ * it: { slug, visibility, allowedUsers, ownerId }, or { error } when no
152
+ * project has that slug. A worktree is not in config.projects, so it carries
153
+ * its parent's record (a registered worktree whose parent is gone has none).
154
+ * A project with no stored visibility is private in os-users mode and public
155
+ * otherwise; lib/users-permissions.js treats anything not "public" as private.
156
+ */
157
+ function getProjectAccessRecord(config, slug) {
158
+ var accessSlug = getWorktreeParent(slug) || slug;
159
+ var projects = config.projects || [];
160
+ for (var i = 0; i < projects.length; i++) {
161
+ if (projects[i].slug === accessSlug) {
162
+ return {
163
+ slug: slug,
164
+ visibility: projects[i].visibility || (config.osUsers ? "private" : "public"),
165
+ allowedUsers: projects[i].allowedUsers || [],
166
+ ownerId: projects[i].ownerId || null,
167
+ };
168
+ }
169
+ }
170
+ return { error: "Project not found" };
171
+ }
172
+
137
173
  /**
138
174
  * Register a worktree slug under a parent slug.
139
175
  * Used by daemon.js when creating worktrees directly.
@@ -161,4 +197,6 @@ module.exports = {
161
197
  getFilteredRemovedProjects: getFilteredRemovedProjects,
162
198
  registerWorktreeSlug: registerWorktreeSlug,
163
199
  unregisterWorktreeSlug: unregisterWorktreeSlug,
200
+ getWorktreeParent: getWorktreeParent,
201
+ getProjectAccessRecord: getProjectAccessRecord,
164
202
  };