@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.
- package/LICENSE +117 -12
- package/LICENSES/MIT-legacy.txt +22 -0
- package/LICENSES/README.md +15 -0
- package/README.md +9 -3
- package/bin/cli.js +40 -5
- package/deploy/clagentic-console.service +10 -6
- package/lib/agent-dispatch-tool.js +20 -0
- package/lib/audit.js +3 -2
- package/lib/build-changes.js +79 -0
- package/lib/build-identity.js +192 -0
- package/lib/build-monitor.js +125 -0
- package/lib/build-sha.json +2 -2
- package/lib/build-update-check.js +138 -0
- package/lib/build-update-offer.js +141 -0
- package/lib/build-update-restart.js +142 -0
- package/lib/build-update-standing.js +184 -0
- package/lib/cli/daemon-launch.js +25 -22
- package/lib/cli/ipc-subcommands.js +6 -0
- package/lib/cli/session-subcommands.js +122 -0
- package/lib/cli-sessions.js +8 -1
- package/lib/codex-defaults.js +8 -2
- package/lib/config.js +32 -20
- package/lib/daemon-env-settings.js +84 -0
- package/lib/daemon-projects.js +57 -0
- package/lib/daemon.js +288 -205
- package/lib/drain.js +74 -17
- package/lib/env-compat.js +61 -0
- package/lib/extension-commands.js +45 -0
- package/lib/history-visibility.js +4 -0
- package/lib/idle-adapter-reaper.js +71 -0
- package/lib/link-trap.js +78 -0
- package/lib/mcp-local.js +8 -6
- package/lib/mcp-tool-input.js +116 -0
- package/lib/mcp-tool-schema.js +179 -0
- package/lib/memory-limits.js +61 -5
- package/lib/memory-setting-validate.js +65 -0
- package/lib/memory-shed.js +13 -32
- package/lib/new-work-gate.js +47 -0
- package/lib/os-users.js +5 -3
- package/lib/project-access.js +139 -0
- package/lib/project-connection.js +37 -22
- package/lib/project-external-trigger.js +166 -105
- package/lib/project-file-scope.js +172 -0
- package/lib/project-file-watch.js +86 -61
- package/lib/project-filesystem.js +144 -128
- package/lib/project-git.js +119 -0
- package/lib/project-http.js +44 -28
- package/lib/project-loop.js +17 -9
- package/lib/project-mcp.js +53 -72
- package/lib/project-message-gate.js +70 -0
- package/lib/project-notifications.js +31 -4
- package/lib/project-prompt-responses.js +217 -0
- package/lib/project-sessions.js +192 -355
- package/lib/project-user-message.js +27 -15
- package/lib/project.js +212 -147
- package/lib/projects-dir.js +90 -0
- package/lib/prompt-access.js +22 -0
- package/lib/prompt-kinds/answer-limits.js +15 -0
- package/lib/prompt-kinds/ask-user.js +58 -0
- package/lib/prompt-kinds/codecs.js +97 -0
- package/lib/prompt-kinds/elicitation.js +77 -0
- package/lib/prompt-kinds/extension.js +39 -0
- package/lib/prompt-kinds/index.js +68 -0
- package/lib/prompt-kinds/permission.js +114 -0
- package/lib/prompt-kinds/plan.js +79 -0
- package/lib/prompt-kinds/tool-call.js +38 -0
- package/lib/prompt-registry.js +680 -0
- package/lib/public/app.js +1 -1
- package/lib/public/css/diagnostics.css +80 -0
- package/lib/public/css/input.css +17 -3
- package/lib/public/css/menus.css +10 -0
- package/lib/public/css/messages.css +5 -0
- package/lib/public/css/rewind.css +22 -0
- package/lib/public/index.html +4 -12
- package/lib/public/modules/agent-dispatch-tool.js +9 -0
- package/lib/public/modules/app-connection.js +7 -0
- package/lib/public/modules/app-cursors.js +7 -5
- package/lib/public/modules/app-messages.js +52 -47
- package/lib/public/modules/app-notifications.js +47 -71
- package/lib/public/modules/app-panels.js +61 -59
- package/lib/public/modules/app-projects.js +2 -1
- package/lib/public/modules/app-rendering.js +4 -10
- package/lib/public/modules/build-update-detail.js +54 -0
- package/lib/public/modules/diagnostics.js +170 -20
- package/lib/public/modules/filebrowser.js +18 -16
- package/lib/public/modules/history-visibility.js +4 -0
- package/lib/public/modules/mention.js +3 -2
- package/lib/public/modules/mode-options.js +38 -0
- package/lib/public/modules/project-settings.js +19 -8
- package/lib/public/modules/prompt-banner.js +78 -0
- package/lib/public/modules/prompt-card.js +201 -0
- package/lib/public/modules/prompt-kinds/ask-user-codec.js +131 -0
- package/lib/public/modules/prompt-kinds/ask-user.js +213 -0
- package/lib/public/modules/prompt-kinds/elicitation-codec.js +343 -0
- package/lib/public/modules/prompt-kinds/elicitation.js +176 -0
- package/lib/public/modules/prompt-kinds/index.js +18 -0
- package/lib/public/modules/prompt-kinds/own-key.js +29 -0
- package/lib/public/modules/prompt-kinds/package.json +3 -0
- package/lib/public/modules/prompt-kinds/permission-choices.js +31 -0
- package/lib/public/modules/prompt-kinds/permission.js +209 -0
- package/lib/public/modules/prompt-kinds/plan.js +102 -0
- package/lib/public/modules/prompt-state.js +142 -0
- package/lib/public/modules/prompts.js +134 -0
- package/lib/public/modules/rewind.js +4 -1
- package/lib/public/modules/server-settings.js +2 -4
- package/lib/public/modules/sidebar-mobile.js +19 -9
- package/lib/public/modules/sidebar-sessions.js +21 -14
- package/lib/public/modules/sticky-notes.js +3 -2
- package/lib/public/modules/team-panel.js +5 -4
- package/lib/public/modules/tools.js +81 -906
- package/lib/public/modules/vendor-picker.js +53 -0
- package/lib/public/modules/vendor-registry.js +142 -0
- package/lib/public/sw.js +3 -1
- package/lib/rc-migrate.js +44 -0
- package/lib/runtime-env-keys.js +109 -0
- package/lib/runtime-env.js +236 -0
- package/lib/sdk-bridge.js +348 -284
- package/lib/sdk-message-processor.js +117 -146
- package/lib/sdk-skill-discovery.js +65 -60
- package/lib/server-hub-sessions.js +13 -10
- package/lib/server-palette.js +28 -19
- package/lib/server.js +156 -115
- package/lib/service-install.js +96 -0
- package/lib/session-capabilities.js +76 -0
- package/lib/session-id.js +33 -0
- package/lib/session-input-ipc.js +32 -0
- package/lib/session-input.js +379 -0
- package/lib/session-reclaim.js +284 -0
- package/lib/session-resume.js +172 -0
- package/lib/sessions.js +61 -30
- package/lib/supervisor.js +39 -0
- package/lib/turn-initiator.js +108 -0
- package/lib/users-permissions.js +9 -6
- package/lib/users.js +9 -0
- package/lib/utils.js +4 -2
- package/lib/vendor-auth.js +22 -0
- package/lib/vendor-registry-message.js +66 -0
- package/lib/ws-origin.js +99 -0
- package/lib/ws-schema.js +36 -23
- package/lib/yoke/adapters/claude-capabilities.js +38 -0
- package/lib/yoke/adapters/claude-vendor.js +34 -0
- package/lib/yoke/adapters/claude-worker.js +57 -87
- package/lib/yoke/adapters/claude.js +182 -88
- package/lib/yoke/adapters/codex-capabilities.js +40 -0
- package/lib/yoke/adapters/codex-vendor.js +46 -0
- package/lib/yoke/adapters/codex.js +462 -211
- package/lib/yoke/adapters/effort-control.js +34 -0
- package/lib/yoke/adapters/permission-relay.js +58 -0
- package/lib/yoke/adapters/worker-mcp-servers.js +81 -0
- package/lib/yoke/auth-checks.js +91 -0
- package/lib/yoke/capabilities.js +49 -0
- package/lib/yoke/codex-app-server.js +30 -56
- package/lib/yoke/codex-binary.js +254 -0
- package/lib/yoke/codex-command.js +122 -0
- package/lib/yoke/codex-protocol.js +96 -0
- package/lib/yoke/codex-version.js +135 -0
- package/lib/yoke/env-ownership.js +40 -0
- package/lib/yoke/index.js +84 -174
- package/lib/yoke/install-probe.js +136 -0
- package/lib/yoke/instructions.js +7 -11
- package/lib/yoke/interface.js +206 -4
- package/lib/yoke/package.json +1 -1
- package/lib/yoke/provider-credentials.js +96 -0
- package/lib/yoke/registry.js +377 -0
- package/package.json +12 -9
- package/scripts/check-sdk-lock-drift.js +160 -0
- package/scripts/check-test-count.js +76 -1
- package/scripts/postinstall.js +218 -136
- package/scripts/prompt-harness-history.js +202 -0
- package/scripts/verify-installed-build.js +59 -17
- package/scripts/verify-installed.js +67 -0
- package/lib/sdk-permission-ownership.js +0 -136
|
@@ -19,6 +19,10 @@ var path = require("path");
|
|
|
19
19
|
var fs = require("fs");
|
|
20
20
|
var os = require("os");
|
|
21
21
|
var parseDiagnosticLine = require("./diagnostic-patterns").parseDiagnosticLine;
|
|
22
|
+
var permissionRelay = require("./permission-relay");
|
|
23
|
+
var effortControl = require("./effort-control");
|
|
24
|
+
var turnInitiator = require("../../turn-initiator");
|
|
25
|
+
var workerMcpServers = require("./worker-mcp-servers");
|
|
22
26
|
|
|
23
27
|
var socketPath = process.argv[2];
|
|
24
28
|
if (!socketPath) {
|
|
@@ -93,15 +97,34 @@ function applyWorkerClaudeBinary(options) {
|
|
|
93
97
|
return options;
|
|
94
98
|
}
|
|
95
99
|
|
|
100
|
+
// The variables Settings add arrive as an overlay. The SDK REPLACES the CLI
|
|
101
|
+
// subprocess environment with options.env, so they are laid over this
|
|
102
|
+
// worker's own environment (the OS user's, in multi-user mode) and the SDK is
|
|
103
|
+
// handed the complete result. The overlay is removed from the options so it
|
|
104
|
+
// goes no further than this function.
|
|
105
|
+
function applyRuntimeEnv(options) {
|
|
106
|
+
if (!options) return options;
|
|
107
|
+
var overlay = options.runtimeEnv;
|
|
108
|
+
var initiator = options.initiator;
|
|
109
|
+
delete options.runtimeEnv;
|
|
110
|
+
delete options.initiator;
|
|
111
|
+
// Always built: the product identity is part of every Claude process's
|
|
112
|
+
// environment, with the initiator of the turn that starts the query.
|
|
113
|
+
options.env = turnInitiator.claudeProcessEnv(process.env, overlay, initiator);
|
|
114
|
+
return options;
|
|
115
|
+
}
|
|
116
|
+
|
|
96
117
|
// --- State ---
|
|
97
118
|
var sdkModule = null;
|
|
98
119
|
var queryInstance = null;
|
|
99
120
|
var messageQueue = null;
|
|
100
121
|
var abortController = null;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var
|
|
104
|
-
var
|
|
122
|
+
// Keyed by ids that come in over the daemon socket: no prototype, so an id
|
|
123
|
+
// such as "constructor" finds nothing instead of an inherited function.
|
|
124
|
+
var pendingPermissions = Object.create(null); // requestId -> resolve
|
|
125
|
+
var pendingAskUser = Object.create(null); // toolUseId -> resolve
|
|
126
|
+
var pendingElicitations = Object.create(null); // requestId -> resolve
|
|
127
|
+
var pendingMcpToolCalls = Object.create(null); // requestId -> { resolve, reject }
|
|
105
128
|
var conn = null;
|
|
106
129
|
var buffer = "";
|
|
107
130
|
// Reference to the claude CLI child process spawned by spawnClaudeCodeProcess.
|
|
@@ -153,40 +176,6 @@ function getSDK() {
|
|
|
153
176
|
return sdkModule;
|
|
154
177
|
}
|
|
155
178
|
|
|
156
|
-
function buildZodShape(z, inputSchema) {
|
|
157
|
-
if (!inputSchema || !inputSchema.properties) return {};
|
|
158
|
-
var shape = {};
|
|
159
|
-
var props = inputSchema.properties;
|
|
160
|
-
var required = inputSchema.required || [];
|
|
161
|
-
var keys = Object.keys(props);
|
|
162
|
-
|
|
163
|
-
for (var i = 0; i < keys.length; i++) {
|
|
164
|
-
var key = keys[i];
|
|
165
|
-
var prop = props[key];
|
|
166
|
-
var field;
|
|
167
|
-
|
|
168
|
-
if (prop.type === "number" || prop.type === "integer") {
|
|
169
|
-
field = z.number();
|
|
170
|
-
} else if (prop.type === "boolean") {
|
|
171
|
-
field = z.boolean();
|
|
172
|
-
} else if (prop.type === "array") {
|
|
173
|
-
field = z.array(z.any());
|
|
174
|
-
} else if (prop.type === "object") {
|
|
175
|
-
field = z.record(z.any());
|
|
176
|
-
} else if (prop.enum) {
|
|
177
|
-
field = z.enum(prop.enum);
|
|
178
|
-
} else {
|
|
179
|
-
field = z.string();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (prop.description) field = field.describe(prop.description);
|
|
183
|
-
if (required.indexOf(key) === -1) field = field.optional();
|
|
184
|
-
shape[key] = field;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return shape;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
179
|
function createWorkerMcpToolHandler(serverName, toolName) {
|
|
191
180
|
return function(args) {
|
|
192
181
|
var requestId = crypto.randomUUID();
|
|
@@ -204,37 +193,10 @@ function createWorkerMcpToolHandler(serverName, toolName) {
|
|
|
204
193
|
}
|
|
205
194
|
|
|
206
195
|
function buildMcpServersFromDescriptors(descriptors, sdk) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
var servers = {};
|
|
214
|
-
for (var i = 0; i < descriptors.length; i++) {
|
|
215
|
-
var descriptor = descriptors[i];
|
|
216
|
-
if (!descriptor || !descriptor.serverName || !descriptor.tools || !descriptor.tools.length) continue;
|
|
217
|
-
var tools = [];
|
|
218
|
-
for (var j = 0; j < descriptor.tools.length; j++) {
|
|
219
|
-
var toolDescriptor = descriptor.tools[j];
|
|
220
|
-
if (!toolDescriptor || !toolDescriptor.name) continue;
|
|
221
|
-
tools.push(sdk.tool(
|
|
222
|
-
toolDescriptor.name,
|
|
223
|
-
toolDescriptor.description || toolDescriptor.name,
|
|
224
|
-
buildZodShape(z, toolDescriptor.inputSchema),
|
|
225
|
-
createWorkerMcpToolHandler(descriptor.serverName, toolDescriptor.name)
|
|
226
|
-
));
|
|
227
|
-
}
|
|
228
|
-
if (tools.length > 0) {
|
|
229
|
-
servers[descriptor.serverName] = sdk.createSdkMcpServer({
|
|
230
|
-
name: descriptor.serverName,
|
|
231
|
-
version: "1.0.0",
|
|
232
|
-
tools: tools,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return Object.keys(servers).length > 0 ? servers : null;
|
|
196
|
+
return workerMcpServers.buildMcpServersFromDescriptors(descriptors, sdk, {
|
|
197
|
+
createHandler: createWorkerMcpToolHandler,
|
|
198
|
+
onSkipped: function(diagnostic) { sendToDaemon({ type: "sdk_event", event: diagnostic }); },
|
|
199
|
+
});
|
|
238
200
|
}
|
|
239
201
|
|
|
240
202
|
// --- IPC helpers ---
|
|
@@ -303,19 +265,15 @@ function handleMessage(msg) {
|
|
|
303
265
|
// --- canUseTool: delegates to daemon via IPC ---
|
|
304
266
|
function canUseTool(toolName, input, opts) {
|
|
305
267
|
var requestId = crypto.randomUUID();
|
|
306
|
-
sendToDaemon(
|
|
307
|
-
type: "permission_request",
|
|
308
|
-
requestId: requestId,
|
|
309
|
-
toolName: toolName,
|
|
310
|
-
input: input,
|
|
311
|
-
toolUseId: opts.toolUseID || "",
|
|
312
|
-
decisionReason: opts.decisionReason || "",
|
|
313
|
-
});
|
|
268
|
+
sendToDaemon(permissionRelay.toRequestMessage(requestId, toolName, input, opts));
|
|
314
269
|
return new Promise(function(resolve) {
|
|
315
270
|
var timeoutId = setTimeout(function() {
|
|
316
271
|
if (pendingPermissions[requestId]) {
|
|
317
272
|
delete pendingPermissions[requestId];
|
|
318
273
|
resolve({ behavior: "deny", message: "Permission request timed out after 30s" });
|
|
274
|
+
// The daemon still shows the request as answerable; tell it the
|
|
275
|
+
// decision can no longer take effect.
|
|
276
|
+
sendToDaemon({ type: "permission_expired", requestId: requestId });
|
|
319
277
|
}
|
|
320
278
|
}, 30000);
|
|
321
279
|
pendingPermissions[requestId] = function(result) {
|
|
@@ -328,6 +286,7 @@ function canUseTool(toolName, input, opts) {
|
|
|
328
286
|
clearTimeout(timeoutId);
|
|
329
287
|
delete pendingPermissions[requestId];
|
|
330
288
|
resolve({ behavior: "deny", message: "Cancelled" });
|
|
289
|
+
sendToDaemon({ type: "prompt_cancelled", kind: "permission", id: requestId });
|
|
331
290
|
}
|
|
332
291
|
});
|
|
333
292
|
}
|
|
@@ -351,8 +310,10 @@ function onElicitation(request, opts) {
|
|
|
351
310
|
pendingElicitations[requestId] = resolve;
|
|
352
311
|
if (opts.signal) {
|
|
353
312
|
opts.signal.addEventListener("abort", function() {
|
|
313
|
+
if (!pendingElicitations[requestId]) return;
|
|
354
314
|
delete pendingElicitations[requestId];
|
|
355
315
|
resolve({ action: "reject" });
|
|
316
|
+
sendToDaemon({ type: "prompt_cancelled", kind: "elicitation", id: requestId });
|
|
356
317
|
});
|
|
357
318
|
}
|
|
358
319
|
});
|
|
@@ -421,8 +382,8 @@ async function handleQueryStart(msg) {
|
|
|
421
382
|
// Build query options (callbacks are local, everything else from daemon)
|
|
422
383
|
var options = msg.options || {};
|
|
423
384
|
options.abortController = abortController;
|
|
424
|
-
if (
|
|
425
|
-
var _logDir = path.join(os.homedir(), ".clagentic", "worker-logs");
|
|
385
|
+
if (require("../../env-compat").readConsoleEnv("CLAGENTIC_CONSOLE_DEBUG") === "1") {
|
|
386
|
+
var _logDir = path.join(os.homedir(), ".clagentic", "console", "worker-logs");
|
|
426
387
|
fs.mkdirSync(_logDir, { recursive: true, mode: 0o700 });
|
|
427
388
|
var _logFile = path.join(_logDir, process.pid + ".log");
|
|
428
389
|
// Create with 0o600 before passing to the SDK so the file is never world-readable
|
|
@@ -431,6 +392,7 @@ async function handleQueryStart(msg) {
|
|
|
431
392
|
options.debugFile = _logFile;
|
|
432
393
|
}
|
|
433
394
|
applyWorkerClaudeBinary(options);
|
|
395
|
+
applyRuntimeEnv(options);
|
|
434
396
|
if (options.mcpServerDescriptors && options.mcpServerDescriptors.length) {
|
|
435
397
|
try {
|
|
436
398
|
var mcpServers = buildMcpServersFromDescriptors(options.mcpServerDescriptors, sdk);
|
|
@@ -501,8 +463,10 @@ async function handleQueryStart(msg) {
|
|
|
501
463
|
pendingAskUser[toolUseId] = resolve;
|
|
502
464
|
if (toolOpts.signal) {
|
|
503
465
|
toolOpts.signal.addEventListener("abort", function() {
|
|
466
|
+
if (!pendingAskUser[toolUseId]) return;
|
|
504
467
|
delete pendingAskUser[toolUseId];
|
|
505
468
|
resolve({ behavior: "deny", message: "Cancelled" });
|
|
469
|
+
sendToDaemon({ type: "prompt_cancelled", kind: "ask_user", id: toolUseId });
|
|
506
470
|
});
|
|
507
471
|
}
|
|
508
472
|
});
|
|
@@ -607,10 +571,10 @@ async function handleQueryStart(msg) {
|
|
|
607
571
|
queryInstance = null;
|
|
608
572
|
messageQueue = null;
|
|
609
573
|
abortController = null;
|
|
610
|
-
pendingPermissions =
|
|
611
|
-
pendingAskUser =
|
|
612
|
-
pendingElicitations =
|
|
613
|
-
pendingMcpToolCalls =
|
|
574
|
+
pendingPermissions = Object.create(null);
|
|
575
|
+
pendingAskUser = Object.create(null);
|
|
576
|
+
pendingElicitations = Object.create(null);
|
|
577
|
+
pendingMcpToolCalls = Object.create(null);
|
|
614
578
|
}
|
|
615
579
|
}
|
|
616
580
|
|
|
@@ -633,13 +597,18 @@ async function handleSetModel(msg) {
|
|
|
633
597
|
}
|
|
634
598
|
}
|
|
635
599
|
|
|
600
|
+
// requestId is echoed on both outcomes so the daemon's pending setEffort()
|
|
601
|
+
// resolves or rejects on the real result.
|
|
636
602
|
async function handleSetEffort(msg) {
|
|
637
|
-
if (!queryInstance)
|
|
603
|
+
if (!queryInstance) {
|
|
604
|
+
sendToDaemon({ type: "worker_error", error: "Failed to set effort: no running query", requestId: msg.requestId });
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
638
607
|
try {
|
|
639
|
-
await
|
|
640
|
-
sendToDaemon({ type: "effort_changed", effort: msg.effort });
|
|
608
|
+
await effortControl.applyEffort(queryInstance, msg.effort);
|
|
609
|
+
sendToDaemon({ type: "effort_changed", effort: msg.effort, requestId: msg.requestId });
|
|
641
610
|
} catch (e) {
|
|
642
|
-
sendToDaemon({ type: "worker_error", error: "Failed to set effort: " + (e.message || e) });
|
|
611
|
+
sendToDaemon({ type: "worker_error", error: "Failed to set effort: " + (e.message || e), requestId: msg.requestId });
|
|
643
612
|
}
|
|
644
613
|
}
|
|
645
614
|
|
|
@@ -700,6 +669,7 @@ async function handleWarmup(msg) {
|
|
|
700
669
|
var warmupOptions = msg.options || {};
|
|
701
670
|
warmupOptions.abortController = ac;
|
|
702
671
|
applyWorkerClaudeBinary(warmupOptions);
|
|
672
|
+
applyRuntimeEnv(warmupOptions);
|
|
703
673
|
|
|
704
674
|
try {
|
|
705
675
|
var stream = sdk.query({
|