@clagentic/console 1.12.0-beta.1 → 1.12.0-beta.3
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/LICENSES/README.md +5 -0
- package/README.md +1 -0
- package/bin/cli.js +5 -2
- package/lib/agent-roster-ws.js +84 -0
- package/lib/agent-roster.js +312 -0
- package/lib/auth-required-notify.js +42 -0
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +34 -11
- package/lib/build-update-standing.js +34 -14
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/duration.js +27 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +60 -11
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +31 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +18 -22
- package/lib/notify/core.js +210 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +62 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +81 -0
- package/lib/notify/types.js +57 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +85 -0
- package/lib/outbound-entry.js +116 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +48 -8
- package/lib/project-filesystem.js +43 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +38 -26
- package/lib/project-notifications.js +122 -39
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +11 -1
- package/lib/project-user-mention.js +22 -34
- package/lib/project-user-message.js +208 -4
- package/lib/project-user-shell.js +298 -0
- package/lib/project.js +41 -5
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +98 -25
- package/lib/prompt-reminders.js +38 -33
- package/lib/prompt-source.js +59 -8
- package/lib/public/app.js +32 -2
- package/lib/public/css/agent-messages.css +96 -0
- package/lib/public/css/agent-roster.css +93 -0
- package/lib/public/css/diagnostics.css +29 -1
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +20 -141
- package/lib/public/css/login-panel.css +73 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/sidebar.css +18 -0
- package/lib/public/css/team-panel.css +1 -6
- package/lib/public/css/team-view.css +101 -0
- package/lib/public/css/title-bar.css +10 -0
- package/lib/public/css/user-shell.css +144 -0
- package/lib/public/index.html +44 -7
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/agent-avatar-picker.js +162 -0
- package/lib/public/modules/agent-avatar.js +153 -0
- package/lib/public/modules/agent-messages.js +285 -0
- package/lib/public/modules/agent-roster.js +157 -0
- package/lib/public/modules/app-connection.js +34 -5
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +104 -75
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +32 -7
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +33 -18
- package/lib/public/modules/compaction-state.js +34 -0
- package/lib/public/modules/custom-icons.js +23 -5
- package/lib/public/modules/diagnostics.js +61 -57
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/injected-identity.js +24 -21
- package/lib/public/modules/input.js +176 -15
- package/lib/public/modules/login-panel.js +136 -0
- package/lib/public/modules/login-parser.js +73 -0
- package/lib/public/modules/login-tab.js +66 -0
- package/lib/public/modules/notifications.js +9 -1
- package/lib/public/modules/notify-client.js +246 -0
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/queued-button.js +11 -0
- package/lib/public/modules/scheduled-input-actions.js +12 -4
- package/lib/public/modules/scheduled-outbox.js +230 -0
- package/lib/public/modules/send-now.js +200 -0
- package/lib/public/modules/server-settings.js +50 -1
- package/lib/public/modules/shell-card.js +76 -0
- package/lib/public/modules/shell-line.js +49 -0
- package/lib/public/modules/shell-queue.js +253 -0
- package/lib/public/modules/shell-settings-controls.js +76 -0
- package/lib/public/modules/sidebar-mobile.js +3 -3
- package/lib/public/modules/sidebar-sessions.js +8 -0
- package/lib/public/modules/sidebar-users.js +5 -7
- package/lib/public/modules/team-panel.js +30 -88
- package/lib/public/modules/team-view.js +211 -0
- package/lib/public/modules/terminal-links.js +193 -0
- package/lib/public/modules/terminal.js +84 -107
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +252 -0
- package/lib/public/notify-target.js +157 -0
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +20 -69
- package/lib/push.js +63 -19
- package/lib/queued-chat.js +392 -0
- package/lib/runtime-env.js +1 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +184 -73
- package/lib/sdk-message-processor.js +124 -76
- package/lib/server-auth.js +6 -4
- package/lib/server-dm.js +11 -20
- package/lib/server-settings.js +39 -1
- package/lib/server.js +112 -16
- package/lib/session-directory.js +39 -12
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +37 -1
- package/lib/session-input.js +263 -21
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +80 -9
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +36 -7
- package/lib/user-shell-settings.js +105 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +33 -5
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +17 -1
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +225 -6
- package/lib/yoke/adapters/codex-capabilities.js +6 -1
- package/lib/yoke/adapters/codex-user-shell.js +265 -0
- package/lib/yoke/adapters/codex-vendor.js +7 -0
- package/lib/yoke/adapters/codex.js +186 -52
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +40 -1
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -87,7 +87,31 @@ function completeProvider(env) {
|
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
var PROVIDER_LABELS = {
|
|
91
|
+
bedrock: "Amazon Bedrock",
|
|
92
|
+
vertex: "Google Vertex AI",
|
|
93
|
+
foundry: "Microsoft Foundry",
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Which cloud provider the environment SELECTS, whether or not its credential
|
|
98
|
+
* set is complete. completeProvider answers "can it authenticate"; this answers
|
|
99
|
+
* "is it the provider the session talks to", which is what an auth-like error
|
|
100
|
+
* must be attributed to.
|
|
101
|
+
* @param {object} env process.env-shaped
|
|
102
|
+
* @returns {?string} "bedrock" | "vertex" | "foundry" | null
|
|
103
|
+
*/
|
|
104
|
+
function configuredProvider(env) {
|
|
105
|
+
if (!env) return null;
|
|
106
|
+
if (env.CLAUDE_CODE_USE_BEDROCK === "1") return "bedrock";
|
|
107
|
+
if (env.CLAUDE_CODE_USE_VERTEX === "1") return "vertex";
|
|
108
|
+
if (env.CLAUDE_CODE_USE_FOUNDRY === "1") return "foundry";
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
90
112
|
module.exports = {
|
|
113
|
+
PROVIDER_LABELS: PROVIDER_LABELS,
|
|
114
|
+
configuredProvider: configuredProvider,
|
|
91
115
|
CREDENTIAL_GROUPS: CREDENTIAL_GROUPS,
|
|
92
116
|
groupOf: groupOf,
|
|
93
117
|
completeProvider: completeProvider,
|
package/lib/yoke/registry.js
CHANGED
|
@@ -48,6 +48,28 @@ function requireStringList(descriptor, field) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
var LOGIN_PATTERN_KEYS = ["url", "codePrompt", "userCode"];
|
|
52
|
+
|
|
53
|
+
// Each pattern must compile, because the browser compiles it and a bad one
|
|
54
|
+
// would otherwise only show as a panel that never appears.
|
|
55
|
+
function requireLoginPatterns(descriptor) {
|
|
56
|
+
var patterns = descriptor.loginPatterns;
|
|
57
|
+
var fail = function (why) {
|
|
58
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' loginPatterns " + why);
|
|
59
|
+
};
|
|
60
|
+
if (!patterns || typeof patterns !== "object") fail("must be an object");
|
|
61
|
+
if (typeof patterns.url !== "string" || !patterns.url) fail("needs a non-empty 'url' pattern");
|
|
62
|
+
Object.keys(patterns).forEach(function (key) {
|
|
63
|
+
if (LOGIN_PATTERN_KEYS.indexOf(key) === -1) fail("has an unknown key: " + key);
|
|
64
|
+
if (typeof patterns[key] !== "string" || !patterns[key]) fail("'" + key + "' must be a non-empty string");
|
|
65
|
+
try {
|
|
66
|
+
new RegExp(patterns[key]);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
fail("'" + key + "' is not a valid regular expression");
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
51
73
|
/** Whether the descriptor owns a variable name, by exact name or by prefix. */
|
|
52
74
|
function descriptorOwns(descriptor, name) {
|
|
53
75
|
return envOwnership.owns({ names: descriptor.ownedEnvNames, prefixes: descriptor.ownedEnvPrefixes }, name);
|
|
@@ -104,9 +126,19 @@ function validateCredentialGroups(descriptor) {
|
|
|
104
126
|
* detail ({path, version, reason}) is shown beside the agent
|
|
105
127
|
* recheck optional function(): forget what the probe remembered, so
|
|
106
128
|
* the next probe looks again (a user installed or updated it)
|
|
107
|
-
* checkAuth function() -> boolean
|
|
129
|
+
* checkAuth function(runtimeEnvOverlay, osUsers) -> boolean; the overlay is the
|
|
130
|
+
* Settings variables of the runtime asked about, or null;
|
|
131
|
+
* osUsers is true under os-users mode
|
|
108
132
|
* installHint string one line telling the user how to install it
|
|
109
133
|
* loginCommand string the one place the login command is written
|
|
134
|
+
* loginPatterns optional {url, codePrompt?, userCode?} regular expression
|
|
135
|
+
* sources (no flags) the browser applies to the login
|
|
136
|
+
* terminal's own output, so it can offer the sign-in link and
|
|
137
|
+
* code entry. url matches the sign-in URL; codePrompt matches
|
|
138
|
+
* the line asking the user to paste a code; userCode has one
|
|
139
|
+
* capture group, the code the agent displays for the user to
|
|
140
|
+
* enter on the sign-in page. Lines are joined with a newline
|
|
141
|
+
* after hard-wrapped URLs are rejoined. Absent: no sign-in panel
|
|
110
142
|
* osUsersSupported boolean can run under per-user OS isolation; when false the
|
|
111
143
|
* agent is disabled, with a reason, in that mode
|
|
112
144
|
* needsRuntimeEnv boolean every entry point requires runtimeEnv
|
|
@@ -123,6 +155,10 @@ function validateCredentialGroups(descriptor) {
|
|
|
123
155
|
* be owned by the descriptor
|
|
124
156
|
* nativeInstructionFiles string[] project instruction files the agent reads
|
|
125
157
|
* itself, so the console does not inject them again
|
|
158
|
+
* effectiveRuntimeEnv optional function(env, osUsers) -> env; the environment this
|
|
159
|
+
* agent's CLI actually sees, given the composed one
|
|
160
|
+
* (a file the CLI applies over it). Read only to
|
|
161
|
+
* classify, never handed on
|
|
126
162
|
* interruptMessage string shown when the user stops a turn
|
|
127
163
|
* capabilityReasons optional object capability key -> the line shown beside a
|
|
128
164
|
* control this agent has disabled, in place of the
|
|
@@ -151,8 +187,10 @@ function register(descriptor) {
|
|
|
151
187
|
requireFunction(descriptor, "checkAuth");
|
|
152
188
|
requireFunction(descriptor, "createAdapter");
|
|
153
189
|
if (descriptor.recheck !== undefined) requireFunction(descriptor, "recheck");
|
|
190
|
+
if (descriptor.effectiveRuntimeEnv !== undefined) requireFunction(descriptor, "effectiveRuntimeEnv");
|
|
154
191
|
requireBoolean(descriptor, "osUsersSupported");
|
|
155
192
|
requireBoolean(descriptor, "needsRuntimeEnv");
|
|
193
|
+
if (descriptor.loginPatterns !== undefined) requireLoginPatterns(descriptor);
|
|
156
194
|
if (descriptor.capabilityReasons === undefined) descriptor = Object.assign({}, descriptor, { capabilityReasons: {} });
|
|
157
195
|
Object.keys(descriptor.capabilityReasons).forEach(function (key) {
|
|
158
196
|
if (!iface.isCapabilityKey(key) || typeof descriptor.capabilityReasons[key] !== "string" || !descriptor.capabilityReasons[key]) {
|
|
@@ -321,6 +359,7 @@ function describeForClient(state) {
|
|
|
321
359
|
icon: d.icon,
|
|
322
360
|
installHint: d.installHint,
|
|
323
361
|
loginCommand: d.loginCommand,
|
|
362
|
+
loginPatterns: d.loginPatterns ? Object.assign({}, d.loginPatterns) : null,
|
|
324
363
|
osUsersSupported: d.osUsersSupported,
|
|
325
364
|
installed: installed.indexOf(d.id) !== -1,
|
|
326
365
|
probeFailure: Object.prototype.hasOwnProperty.call(failures, d.id) ? failures[d.id] : null,
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// One shell command the person typed for themselves, run by the console for an
|
|
4
|
+
// agent that has no call of its own for it, and the text that records it in the
|
|
5
|
+
// agent's transcript. Adapters call this; the callers above the adapter go
|
|
6
|
+
// through QueryHandle.runUserShellCommand and never reach this module.
|
|
7
|
+
//
|
|
8
|
+
// The command runs through the platform shell, in the given directory, with the
|
|
9
|
+
// environment the caller hands over, under the identity of the console process:
|
|
10
|
+
// this module never changes uid.
|
|
11
|
+
|
|
12
|
+
var { spawn } = require("child_process");
|
|
13
|
+
|
|
14
|
+
// After the shell exits, how long to wait for its output pipes to close before
|
|
15
|
+
// settling anyway: a background process the command left behind can hold them.
|
|
16
|
+
var PIPE_DRAIN_GRACE_MS = 250;
|
|
17
|
+
|
|
18
|
+
function warnUnlessGone(err) {
|
|
19
|
+
if (err && err.code !== "ESRCH") console.warn("[yoke/user-shell] could not stop the command:", err.message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function truncationMarker(maxBytes) {
|
|
23
|
+
return "\n[output truncated at " + maxBytes + " bytes]";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// A buffer cut at an arbitrary byte can end inside a multibyte character, which
|
|
27
|
+
// would decode to U+FFFD. Drops that partial character from the end, so what is
|
|
28
|
+
// kept is whole characters and never more than was kept before.
|
|
29
|
+
function dropPartialChar(buf) {
|
|
30
|
+
var lead = buf.length - 1;
|
|
31
|
+
var back = 0;
|
|
32
|
+
while (lead >= 0 && back < 3 && (buf[lead] & 0xC0) === 0x80) { lead--; back++; }
|
|
33
|
+
if (lead < 0) return buf;
|
|
34
|
+
var b = buf[lead];
|
|
35
|
+
var width = b >= 0xF0 ? 4 : b >= 0xE0 ? 3 : b >= 0xC0 ? 2 : 1;
|
|
36
|
+
return width > buf.length - lead ? buf.subarray(0, lead) : buf;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The one place the cap is applied. Text that fits is returned whole; text that
|
|
40
|
+
// does not is cut and followed by the truncation marker, and the marker's bytes
|
|
41
|
+
// are reserved before the cut so the result, marker included, is never longer
|
|
42
|
+
// than maxBytes. forceCut is for a buffer that already lost bytes while being
|
|
43
|
+
// read. When maxBytes cannot hold the marker, the marker itself is cut to fit
|
|
44
|
+
// (it is ASCII, so any byte count is a whole-character count).
|
|
45
|
+
function capBuffer(buf, maxBytes, forceCut) {
|
|
46
|
+
if (!forceCut && buf.length <= maxBytes) return { output: buf.toString("utf8"), truncated: false };
|
|
47
|
+
var marker = truncationMarker(maxBytes);
|
|
48
|
+
var room = maxBytes - Buffer.byteLength(marker, "utf8");
|
|
49
|
+
if (room <= 0) return { output: marker.slice(0, Math.max(0, maxBytes)), truncated: true };
|
|
50
|
+
return { output: dropPartialChar(buf.subarray(0, room)).toString("utf8") + marker, truncated: true };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Cuts text so the result, truncation marker included, is at most maxBytes of
|
|
55
|
+
* UTF-8. The cut backs off to a character boundary.
|
|
56
|
+
* @param {string} text
|
|
57
|
+
* @param {number} maxBytes
|
|
58
|
+
* @returns {{output: string, truncated: boolean}}
|
|
59
|
+
*/
|
|
60
|
+
function capText(text, maxBytes) {
|
|
61
|
+
return capBuffer(Buffer.from(String(text == null ? "" : text), "utf8"), maxBytes, false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Runs a command to its end, its timeout, or an interrupt.
|
|
66
|
+
*
|
|
67
|
+
* @param {object} opts
|
|
68
|
+
* @param {string} opts.command
|
|
69
|
+
* @param {string} opts.cwd
|
|
70
|
+
* @param {number} opts.timeoutMs the command's process group is killed when it runs longer
|
|
71
|
+
* @param {number} opts.maxOutputBytes output kept; the rest is read and dropped
|
|
72
|
+
* @param {object} [opts.env] default: the console process's own
|
|
73
|
+
* @param {AbortSignal} [opts.signal] aborting kills the command's process group
|
|
74
|
+
* @returns {Promise<{exitCode: ?number, durationMs: number, output: string,
|
|
75
|
+
* truncated: boolean, timedOut: boolean, interrupted: boolean}>}
|
|
76
|
+
*/
|
|
77
|
+
function runShellCommand(opts) {
|
|
78
|
+
var started = Date.now();
|
|
79
|
+
var maxBytes = opts.maxOutputBytes;
|
|
80
|
+
var signal = opts.signal || null;
|
|
81
|
+
|
|
82
|
+
return new Promise(function (resolve) {
|
|
83
|
+
var chunks = [];
|
|
84
|
+
var kept = 0;
|
|
85
|
+
var readTruncated = false;
|
|
86
|
+
var timedOut = false;
|
|
87
|
+
var interrupted = false;
|
|
88
|
+
var settled = false;
|
|
89
|
+
var exited = false;
|
|
90
|
+
var drainTimer = null;
|
|
91
|
+
var timeoutTimer = null;
|
|
92
|
+
var child = null;
|
|
93
|
+
|
|
94
|
+
function finish(exitCode, extraOutput) {
|
|
95
|
+
if (settled) return;
|
|
96
|
+
settled = true;
|
|
97
|
+
clearTimeout(timeoutTimer);
|
|
98
|
+
clearTimeout(drainTimer);
|
|
99
|
+
if (signal) signal.removeEventListener("abort", onAbort);
|
|
100
|
+
// The cap is applied to everything the person is shown, the failure text
|
|
101
|
+
// included, so no text added here can push the output past it.
|
|
102
|
+
var buf = Buffer.concat(chunks);
|
|
103
|
+
if (extraOutput) buf = Buffer.concat([buf, Buffer.from((buf.length ? "\n" : "") + extraOutput, "utf8")]);
|
|
104
|
+
// Bytes dropped while reading mean the kept ones may end inside a character.
|
|
105
|
+
var capped = capBuffer(buf, maxBytes, readTruncated);
|
|
106
|
+
resolve({
|
|
107
|
+
exitCode: typeof exitCode === "number" ? exitCode : null,
|
|
108
|
+
durationMs: Date.now() - started,
|
|
109
|
+
output: capped.output,
|
|
110
|
+
truncated: capped.truncated,
|
|
111
|
+
timedOut: timedOut,
|
|
112
|
+
interrupted: interrupted,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function killTree() {
|
|
117
|
+
if (!child || !child.pid) return;
|
|
118
|
+
try {
|
|
119
|
+
// The command's own process group, so what it started dies with it.
|
|
120
|
+
if (process.platform === "win32") child.kill();
|
|
121
|
+
else process.kill(-child.pid, "SIGKILL");
|
|
122
|
+
} catch (err) {
|
|
123
|
+
warnUnlessGone(err);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function onAbort() {
|
|
128
|
+
// An abort that arrives after the shell exited (while the pipes drain)
|
|
129
|
+
// stopped nothing the command was doing, so it does not relabel the result.
|
|
130
|
+
if (!exited) interrupted = true;
|
|
131
|
+
killTree();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function collect(chunk) {
|
|
135
|
+
var room = maxBytes - kept;
|
|
136
|
+
if (room <= 0) { readTruncated = true; return; }
|
|
137
|
+
if (chunk.length > room) {
|
|
138
|
+
chunks.push(chunk.subarray(0, room));
|
|
139
|
+
kept += room;
|
|
140
|
+
readTruncated = true;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
chunks.push(chunk);
|
|
144
|
+
kept += chunk.length;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (signal && signal.aborted) {
|
|
148
|
+
interrupted = true;
|
|
149
|
+
finish(null, null);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
child = spawn(opts.command, {
|
|
155
|
+
shell: true,
|
|
156
|
+
cwd: opts.cwd,
|
|
157
|
+
env: opts.env || process.env,
|
|
158
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
159
|
+
detached: process.platform !== "win32",
|
|
160
|
+
windowsHide: true,
|
|
161
|
+
});
|
|
162
|
+
} catch (err) {
|
|
163
|
+
finish(null, "Could not start the command: " + err.message);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
child.stdout.on("data", collect);
|
|
168
|
+
child.stderr.on("data", collect);
|
|
169
|
+
child.on("error", function (err) {
|
|
170
|
+
finish(null, "Could not run the command: " + err.message);
|
|
171
|
+
});
|
|
172
|
+
child.on("exit", function (code) {
|
|
173
|
+
exited = true;
|
|
174
|
+
// The command is over: a timeout that fires during the drain must not mark
|
|
175
|
+
// it as timed out.
|
|
176
|
+
clearTimeout(timeoutTimer);
|
|
177
|
+
drainTimer = setTimeout(function () { finish(code, null); }, PIPE_DRAIN_GRACE_MS);
|
|
178
|
+
});
|
|
179
|
+
child.on("close", function (code) {
|
|
180
|
+
finish(code, null);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
timeoutTimer = setTimeout(function () {
|
|
184
|
+
timedOut = true;
|
|
185
|
+
killTree();
|
|
186
|
+
}, opts.timeoutMs);
|
|
187
|
+
if (signal) signal.addEventListener("abort", onAbort, { once: true });
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function escapeAngles(text) {
|
|
192
|
+
return String(text).replace(/</g, "<").replace(/>/g, ">");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The text that records a finished command in an agent's conversation. The
|
|
197
|
+
* command and its output are data a program (or a hostile file) can shape, so
|
|
198
|
+
* angle brackets in them are escaped: the wrapper's own tags are then the only
|
|
199
|
+
* tags in the block, and output cannot close it early and pose as what follows.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} command
|
|
202
|
+
* @param {{exitCode: ?number, durationMs: number, output: string, truncated: boolean,
|
|
203
|
+
* timedOut: boolean, interrupted?: boolean}} result
|
|
204
|
+
* @returns {string}
|
|
205
|
+
*/
|
|
206
|
+
function formatTranscriptText(command, result) {
|
|
207
|
+
var lines = [
|
|
208
|
+
"<user_shell_command>",
|
|
209
|
+
"<command>" + escapeAngles(command) + "</command>",
|
|
210
|
+
"<exit_code>" + (result.exitCode === null || result.exitCode === undefined ? "none" : result.exitCode) + "</exit_code>",
|
|
211
|
+
"<duration_ms>" + Math.round(result.durationMs || 0) + "</duration_ms>",
|
|
212
|
+
];
|
|
213
|
+
if (result.timedOut) lines.push("<timed_out>true</timed_out>");
|
|
214
|
+
if (result.interrupted) lines.push("<interrupted>true</interrupted>");
|
|
215
|
+
if (result.truncated) lines.push("<truncated>true</truncated>");
|
|
216
|
+
lines.push("<output>", escapeAngles(result.output || ""), "</output>", "</user_shell_command>");
|
|
217
|
+
return lines.join("\n");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = {
|
|
221
|
+
runShellCommand: runShellCommand,
|
|
222
|
+
formatTranscriptText: formatTranscriptText,
|
|
223
|
+
capText: capText,
|
|
224
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.12.0-beta.
|
|
6
|
+
"version": "1.12.0-beta.3",
|
|
7
7
|
"description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
|
|
8
8
|
"bin": {
|
|
9
9
|
"clagentic-console": "./bin/cli.js"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"Chad (original Clay author)"
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
64
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.318",
|
|
65
65
|
"@anthropic-ai/sdk": "0.104.2",
|
|
66
66
|
"@lydell/node-pty": "^1.2.0-beta.3",
|
|
67
67
|
"ajv": "^8.20.0",
|
|
@@ -392,8 +392,22 @@ if (require.main === module) {
|
|
|
392
392
|
|
|
393
393
|
var REPORTER_PATH = path.join(__dirname, "test-file-completion-reporter.js");
|
|
394
394
|
|
|
395
|
+
// --test-timeout bounds each test and also each file as a whole (measured on
|
|
396
|
+
// Node 22: a file of four 1 s tests is cancelled at --test-timeout=2500, as
|
|
397
|
+
// a file, though no test in it ran past 1 s). There is no separate per-file
|
|
398
|
+
// flag, so this one value is the per-file bound: a file that hangs (an open
|
|
399
|
+
// handle, a child that never connects) fails by name instead of stalling the
|
|
400
|
+
// buffered run, and a file whose tests legitimately add up to more than it
|
|
401
|
+
// is cancelled too. A slow file is therefore split, not given a higher
|
|
402
|
+
// bound (prompt-invariants was one file of 10 slow parts, about 12 minutes
|
|
403
|
+
// alone; split into one file per slice each takes about 15 s). 300 s is
|
|
404
|
+
// about 20 times the slowest file measured on a loaded host. A test that
|
|
405
|
+
// needs its own tighter bound sets the `timeout` option on itself.
|
|
406
|
+
var testTimeoutMs = Number(process.env.CHECK_TEST_COUNT_TEST_TIMEOUT_MS) || 300000;
|
|
407
|
+
|
|
395
408
|
var result = spawnSync(process.execPath, [
|
|
396
409
|
"--test",
|
|
410
|
+
"--test-timeout=" + testTimeoutMs,
|
|
397
411
|
"--test-reporter=tap", "--test-reporter-destination=stdout",
|
|
398
412
|
"--test-reporter=" + REPORTER_PATH, "--test-reporter-destination=stderr",
|
|
399
413
|
].concat(files), {
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// build-notice-gate.js — decides what the diagnostics list does with the
|
|
2
|
-
// "newer build installed" notice, which the daemon replays to every client that
|
|
3
|
-
// connects (once per project connection) and refreshes while the build is stale.
|
|
4
|
-
//
|
|
5
|
-
// Pure state and rules, no DOM: lib/public/modules/diagnostics.js asks it what
|
|
6
|
-
// to do and does it. The rules:
|
|
7
|
-
// - one notice per running/installed build pair; an identical one never stacks;
|
|
8
|
-
// - a different pair replaces the held one, or retracts it when the incoming
|
|
9
|
-
// pair is itself quiet (nothing new is shown until the cooldown passes);
|
|
10
|
-
// - once the operator has closed the notice (the toast, or the panel entry),
|
|
11
|
-
// the same pair stays quiet until the cooldown has passed.
|
|
12
|
-
|
|
13
|
-
export var BUILD_NOTICE_SOURCE = 'build-update';
|
|
14
|
-
export var BUILD_NOTICE_ACTION = 'restart_for_build_update';
|
|
15
|
-
export var DEFAULT_COOLDOWN_MS = 60 * 60 * 1000;
|
|
16
|
-
|
|
17
|
-
/** The pair a standing notice is about, or null when `msg` is not that notice. */
|
|
18
|
-
export function noticeKeyOf(msg) {
|
|
19
|
-
if (!msg || msg.source !== BUILD_NOTICE_SOURCE) return null;
|
|
20
|
-
if (!msg.actionable || msg.actionable.action !== BUILD_NOTICE_ACTION) return null;
|
|
21
|
-
var b = msg.buildUpdate;
|
|
22
|
-
if (!b || !b.loadedBuildSha || !b.installedBuildSha) return null;
|
|
23
|
-
return b.loadedBuildSha + ':' + b.installedBuildSha;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** The daemon-configured cooldown carried on the notice, else the default. */
|
|
27
|
-
export function cooldownOf(msg) {
|
|
28
|
-
var ms = msg && msg.noticeCooldownMs;
|
|
29
|
-
return typeof ms === 'number' && isFinite(ms) && ms >= 0 ? ms : DEFAULT_COOLDOWN_MS;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function createNoticeGate() {
|
|
33
|
-
// key -> {at, entryGone}. entryGone: the operator removed the panel entry too,
|
|
34
|
-
// so the notice must not come back at all, not just without a toast.
|
|
35
|
-
var closed = Object.create(null);
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
/**
|
|
39
|
-
* @param {object} s
|
|
40
|
-
* @param {string} s.key — noticeKeyOf(msg)
|
|
41
|
-
* @param {?string} s.heldKey — key of the notice already in the list, or null
|
|
42
|
-
* @param {boolean} s.toastOnScreen — a toast for the held notice is showing
|
|
43
|
-
* @param {number} s.now
|
|
44
|
-
* @param {number} s.cooldownMs
|
|
45
|
-
* @returns {{action: 'add'|'replace'|'retract'|'skip'|'retoast', toast: boolean}}
|
|
46
|
-
*/
|
|
47
|
-
decide: function (s) {
|
|
48
|
-
var rec = closed[s.key];
|
|
49
|
-
var quiet = rec !== undefined && s.now - rec.at < s.cooldownMs;
|
|
50
|
-
if (rec !== undefined && !quiet) delete closed[s.key];
|
|
51
|
-
|
|
52
|
-
if (s.heldKey === s.key) {
|
|
53
|
-
// Identical notice: never a second entry. After the cooldown the toast
|
|
54
|
-
// may come back if the operator had closed it.
|
|
55
|
-
if (rec !== undefined && !quiet && !s.toastOnScreen) return { action: 'retoast', toast: true };
|
|
56
|
-
return { action: 'skip', toast: false };
|
|
57
|
-
}
|
|
58
|
-
// A quiet current pair shows nothing, so a different held pair is stale
|
|
59
|
-
// and must go too: one current notice, never an obsolete one left visible.
|
|
60
|
-
if (quiet && s.heldKey) return { action: 'retract', toast: false };
|
|
61
|
-
if (quiet && rec.entryGone) return { action: 'skip', toast: false };
|
|
62
|
-
return { action: s.heldKey ? 'replace' : 'add', toast: !quiet };
|
|
63
|
-
},
|
|
64
|
-
toastClosed: function (key, now) {
|
|
65
|
-
if (!key) return;
|
|
66
|
-
var rec = closed[key];
|
|
67
|
-
closed[key] = { at: now, entryGone: rec ? rec.entryGone : false };
|
|
68
|
-
},
|
|
69
|
-
entryDismissed: function (key, now) {
|
|
70
|
-
if (key) closed[key] = { at: now, entryGone: true };
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|