@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
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
// registry.js - the YOKE vendor registry. Each adapter module registers one
|
|
2
|
+
// descriptor; everything that needs to know which agents exist (adapter
|
|
3
|
+
// creation, install detection, the binary allowlist, the login command, the
|
|
4
|
+
// agent picker, default selection, capability gating) reads it from here, so
|
|
5
|
+
// adding an agent is registering one more descriptor and nothing else.
|
|
6
|
+
|
|
7
|
+
var iface = require("./interface");
|
|
8
|
+
var envOwnership = require("./env-ownership");
|
|
9
|
+
|
|
10
|
+
var _vendors = new Map();
|
|
11
|
+
|
|
12
|
+
function UnknownVendorError(vendor) {
|
|
13
|
+
var err = new Error("[YOKE] Unknown adapter vendor: " + String(vendor));
|
|
14
|
+
err.code = "YOKE_UNKNOWN_VENDOR";
|
|
15
|
+
err.vendor = vendor;
|
|
16
|
+
return err;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function DisallowedBinaryError(name) {
|
|
20
|
+
var err = new Error("[YOKE] Disallowed binary name: " + String(name));
|
|
21
|
+
err.code = "YOKE_DISALLOWED_BINARY";
|
|
22
|
+
err.binary = name;
|
|
23
|
+
return err;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function requireString(descriptor, field) {
|
|
27
|
+
if (typeof descriptor[field] !== "string" || !descriptor[field]) {
|
|
28
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs a non-empty string '" + field + "'");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function requireFunction(descriptor, field) {
|
|
33
|
+
if (typeof descriptor[field] !== "function") {
|
|
34
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs a function '" + field + "'");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function requireBoolean(descriptor, field) {
|
|
39
|
+
if (typeof descriptor[field] !== "boolean") {
|
|
40
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs a boolean '" + field + "'");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function requireStringList(descriptor, field) {
|
|
45
|
+
var value = descriptor[field];
|
|
46
|
+
if (!Array.isArray(value) || value.some(function (v) { return typeof v !== "string" || !v; })) {
|
|
47
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs '" + field + "' as an array of non-empty strings");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Whether the descriptor owns a variable name, by exact name or by prefix. */
|
|
52
|
+
function descriptorOwns(descriptor, name) {
|
|
53
|
+
return envOwnership.owns({ names: descriptor.ownedEnvNames, prefixes: descriptor.ownedEnvPrefixes }, name);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A credential group is a set of variables that work together (an access key
|
|
58
|
+
* id and its secret). Owning part of one would let the rest leak from the
|
|
59
|
+
* daemon's environment, so every prefix and name of every declared group must
|
|
60
|
+
* be owned by the descriptor, by the same matcher that resolves ownership.
|
|
61
|
+
* @returns {Array<{id: string, prefixes: string[], envNames: string[]}>} a copy of the groups
|
|
62
|
+
*/
|
|
63
|
+
function validateCredentialGroups(descriptor) {
|
|
64
|
+
var groups = descriptor.credentialGroups === undefined ? [] : descriptor.credentialGroups;
|
|
65
|
+
if (!Array.isArray(groups)) {
|
|
66
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs 'credentialGroups' as an array");
|
|
67
|
+
}
|
|
68
|
+
return groups.map(function (group) {
|
|
69
|
+
if (!group || typeof group.id !== "string" || !group.id) {
|
|
70
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' has a credential group without an id");
|
|
71
|
+
}
|
|
72
|
+
var prefixes = group.prefixes === undefined ? [] : group.prefixes;
|
|
73
|
+
var names = group.envNames === undefined ? [] : group.envNames;
|
|
74
|
+
requireStringList({ id: descriptor.id, prefixes: prefixes }, "prefixes");
|
|
75
|
+
requireStringList({ id: descriptor.id, envNames: names }, "envNames");
|
|
76
|
+
prefixes.forEach(function (prefix) {
|
|
77
|
+
if (descriptor.ownedEnvPrefixes.indexOf(prefix) === -1) {
|
|
78
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' declares credential group '" + group.id
|
|
79
|
+
+ "' but does not own the " + prefix + " namespace; a credential set is owned whole");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
names.forEach(function (name) {
|
|
83
|
+
if (!descriptorOwns(descriptor, name)) {
|
|
84
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' declares credential group '" + group.id
|
|
85
|
+
+ "' but does not own " + name + "; a credential set is owned whole");
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return { id: group.id, prefixes: prefixes.slice(), envNames: names.slice() };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Registers a vendor.
|
|
94
|
+
*
|
|
95
|
+
* Descriptor:
|
|
96
|
+
* id string the vendor id sessions are bound to ("claude")
|
|
97
|
+
* displayName string name shown to the user ("Claude Code")
|
|
98
|
+
* icon string optional URL path of the avatar image
|
|
99
|
+
* priority number lower is preferred when choosing a default
|
|
100
|
+
* binaryNames string[] executables the install probe may look up; the
|
|
101
|
+
* allowlist for lookups is the union over vendors
|
|
102
|
+
* probeInstalled function(ctx) -> boolean | {installed, detail}; ctx.lookupBinary(name)
|
|
103
|
+
* -> boolean, ctx.linuxUser (the OS user asked about, or null).
|
|
104
|
+
* detail ({path, version, reason}) is shown beside the agent
|
|
105
|
+
* recheck optional function(): forget what the probe remembered, so
|
|
106
|
+
* the next probe looks again (a user installed or updated it)
|
|
107
|
+
* checkAuth function() -> boolean
|
|
108
|
+
* installHint string one line telling the user how to install it
|
|
109
|
+
* loginCommand string the one place the login command is written
|
|
110
|
+
* osUsersSupported boolean can run under per-user OS isolation; when false the
|
|
111
|
+
* agent is disabled, with a reason, in that mode
|
|
112
|
+
* needsRuntimeEnv boolean every entry point requires runtimeEnv
|
|
113
|
+
* perProjectRuntime, activityTokens
|
|
114
|
+
* optional booleans (false when absent): adapter traits, how
|
|
115
|
+
* the console drives the adapter (interface.js TRAITS). Never
|
|
116
|
+
* resolved or overridden; read with traitOf.
|
|
117
|
+
* ownedEnvNames string[] exact environment variable names this agent reads
|
|
118
|
+
* for its own endpoint and credentials
|
|
119
|
+
* ownedEnvPrefixes optional string[] namespaces of variables this agent owns
|
|
120
|
+
* whole ("AWS_"); every variable under one is owned
|
|
121
|
+
* credentialGroups optional {id, prefixes[], envNames[]}[] variables that work
|
|
122
|
+
* as one credential set; each prefix and name must
|
|
123
|
+
* be owned by the descriptor
|
|
124
|
+
* nativeInstructionFiles string[] project instruction files the agent reads
|
|
125
|
+
* itself, so the console does not inject them again
|
|
126
|
+
* interruptMessage string shown when the user stops a turn
|
|
127
|
+
* capabilityReasons optional object capability key -> the line shown beside a
|
|
128
|
+
* control this agent has disabled, in place of the
|
|
129
|
+
* ledger's general one
|
|
130
|
+
* capabilities object the declared capabilities (interface.js ledger)
|
|
131
|
+
* createAdapter function(opts) -> adapter
|
|
132
|
+
*
|
|
133
|
+
* @param {object} descriptor
|
|
134
|
+
* @returns {object} the registered (frozen) descriptor, capabilities completed
|
|
135
|
+
*/
|
|
136
|
+
function register(descriptor) {
|
|
137
|
+
if (!descriptor || typeof descriptor !== "object") {
|
|
138
|
+
throw new Error("[YOKE] A vendor descriptor must be an object");
|
|
139
|
+
}
|
|
140
|
+
requireString(descriptor, "id");
|
|
141
|
+
requireString(descriptor, "displayName");
|
|
142
|
+
requireString(descriptor, "installHint");
|
|
143
|
+
requireString(descriptor, "loginCommand");
|
|
144
|
+
requireString(descriptor, "interruptMessage");
|
|
145
|
+
requireStringList(descriptor, "binaryNames");
|
|
146
|
+
requireStringList(descriptor, "ownedEnvNames");
|
|
147
|
+
if (descriptor.ownedEnvPrefixes === undefined) descriptor = Object.assign({}, descriptor, { ownedEnvPrefixes: [] });
|
|
148
|
+
requireStringList(descriptor, "ownedEnvPrefixes");
|
|
149
|
+
requireStringList(descriptor, "nativeInstructionFiles");
|
|
150
|
+
requireFunction(descriptor, "probeInstalled");
|
|
151
|
+
requireFunction(descriptor, "checkAuth");
|
|
152
|
+
requireFunction(descriptor, "createAdapter");
|
|
153
|
+
if (descriptor.recheck !== undefined) requireFunction(descriptor, "recheck");
|
|
154
|
+
requireBoolean(descriptor, "osUsersSupported");
|
|
155
|
+
requireBoolean(descriptor, "needsRuntimeEnv");
|
|
156
|
+
if (descriptor.capabilityReasons === undefined) descriptor = Object.assign({}, descriptor, { capabilityReasons: {} });
|
|
157
|
+
Object.keys(descriptor.capabilityReasons).forEach(function (key) {
|
|
158
|
+
if (!iface.isCapabilityKey(key) || typeof descriptor.capabilityReasons[key] !== "string" || !descriptor.capabilityReasons[key]) {
|
|
159
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' capabilityReasons needs a ledger key with a non-empty string: " + key);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
var traitDefaults = {};
|
|
163
|
+
iface.TRAIT_KEYS.forEach(function (key) {
|
|
164
|
+
if (descriptor[key] === undefined) traitDefaults[key] = false;
|
|
165
|
+
else requireBoolean(descriptor, key);
|
|
166
|
+
});
|
|
167
|
+
if (Object.keys(traitDefaults).length) descriptor = Object.assign({}, descriptor, traitDefaults);
|
|
168
|
+
if (typeof descriptor.priority !== "number") {
|
|
169
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs a numeric 'priority'");
|
|
170
|
+
}
|
|
171
|
+
if (_vendors.has(descriptor.id)) {
|
|
172
|
+
throw new Error("[YOKE] Vendor already registered: " + descriptor.id);
|
|
173
|
+
}
|
|
174
|
+
var credentialGroups = validateCredentialGroups(descriptor);
|
|
175
|
+
iface.validateCapabilities(descriptor.capabilities, "vendor '" + descriptor.id + "'");
|
|
176
|
+
|
|
177
|
+
var entry = Object.assign({}, descriptor, {
|
|
178
|
+
credentialGroups: credentialGroups,
|
|
179
|
+
icon: descriptor.icon || "",
|
|
180
|
+
binaryNames: descriptor.binaryNames.slice(),
|
|
181
|
+
ownedEnvNames: descriptor.ownedEnvNames.slice(),
|
|
182
|
+
ownedEnvPrefixes: descriptor.ownedEnvPrefixes.slice(),
|
|
183
|
+
nativeInstructionFiles: descriptor.nativeInstructionFiles.slice(),
|
|
184
|
+
capabilities: iface.completeCapabilities(descriptor.capabilities),
|
|
185
|
+
capabilityReasons: Object.assign({}, descriptor.capabilityReasons),
|
|
186
|
+
});
|
|
187
|
+
_vendors.set(entry.id, entry);
|
|
188
|
+
return entry;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Removes a vendor. Returns whether it was registered. */
|
|
192
|
+
function unregister(id) {
|
|
193
|
+
return _vendors.delete(id);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function isKnown(id) {
|
|
197
|
+
return typeof id === "string" && _vendors.has(id);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The descriptor for an id, or throws the named unknown-vendor error. */
|
|
201
|
+
function getVendor(id) {
|
|
202
|
+
if (!isKnown(id)) throw UnknownVendorError(id);
|
|
203
|
+
return _vendors.get(id);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** All descriptors, preferred first. */
|
|
207
|
+
function list() {
|
|
208
|
+
return Array.from(_vendors.values()).sort(function (a, b) {
|
|
209
|
+
return a.priority - b.priority || (a.id < b.id ? -1 : 1);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function ids() {
|
|
214
|
+
return list().map(function (d) { return d.id; });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The declared capabilities of a registered vendor (a copy). A declaration is
|
|
219
|
+
* only the starting point: a session-facing decision reads the resolved set
|
|
220
|
+
* (lib/session-capabilities.js), never this.
|
|
221
|
+
*/
|
|
222
|
+
function declaredCapabilities(id) {
|
|
223
|
+
return iface.completeCapabilities(getVendor(id).capabilities);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* An adapter trait (interface.js TRAITS). A trait is a fact about the adapter,
|
|
228
|
+
* so it is read from the descriptor and never resolved against a session. A
|
|
229
|
+
* name that is not registered has no traits: false, never a throw, because the
|
|
230
|
+
* name may come from a session or a client.
|
|
231
|
+
*/
|
|
232
|
+
function traitOf(id, key) {
|
|
233
|
+
if (!iface.isTraitKey(key)) throw new Error("[YOKE] Unknown adapter trait: " + String(key));
|
|
234
|
+
return isKnown(id) ? _vendors.get(id)[key] === true : false;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function loginCommandFor(id) {
|
|
238
|
+
return getVendor(id).loginCommand;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function displayNameFor(id) {
|
|
242
|
+
return getVendor(id).displayName;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Whether a registered vendor owns the environment variable name. */
|
|
246
|
+
function ownsEnvName(id, name) {
|
|
247
|
+
return descriptorOwns(getVendor(id), name);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The id of the registered vendor that owns the variable name, or null. */
|
|
251
|
+
function ownerOfEnvName(name) {
|
|
252
|
+
var all = list();
|
|
253
|
+
for (var i = 0; i < all.length; i++) {
|
|
254
|
+
if (descriptorOwns(all[i], name)) return all[i].id;
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* A copy of env without the variables the vendor owns, so a session that is to
|
|
261
|
+
* use its own endpoint and credentials does not inherit the daemon's.
|
|
262
|
+
*/
|
|
263
|
+
function withoutOwnedEnv(id, env) {
|
|
264
|
+
var vendor = getVendor(id);
|
|
265
|
+
var out = {};
|
|
266
|
+
Object.keys(env || {}).forEach(function (name) {
|
|
267
|
+
if (!descriptorOwns(vendor, name)) out[name] = env[name];
|
|
268
|
+
});
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Executable names the install probe may look up. */
|
|
273
|
+
function binaryNames() {
|
|
274
|
+
var names = [];
|
|
275
|
+
list().forEach(function (d) {
|
|
276
|
+
d.binaryNames.forEach(function (n) { if (names.indexOf(n) === -1) names.push(n); });
|
|
277
|
+
});
|
|
278
|
+
return names;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Throws the named error unless the name belongs to a registered vendor. */
|
|
282
|
+
function assertAllowedBinary(name) {
|
|
283
|
+
if (binaryNames().indexOf(name) === -1) throw DisallowedBinaryError(name);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The vendor a project starts on: the most preferred of the available ones,
|
|
288
|
+
* or the most preferred registered vendor when none is available.
|
|
289
|
+
* @param {string[]} availableIds
|
|
290
|
+
*/
|
|
291
|
+
function defaultVendorId(availableIds) {
|
|
292
|
+
var all = ids();
|
|
293
|
+
var avail = Array.isArray(availableIds) ? availableIds : [];
|
|
294
|
+
for (var i = 0; i < all.length; i++) {
|
|
295
|
+
if (avail.indexOf(all[i]) !== -1) return all[i];
|
|
296
|
+
}
|
|
297
|
+
return all[0] || null;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The registry as the browser needs it: serializable, no functions.
|
|
302
|
+
* @param {{installed: string[], available: string[], capabilities: ?object, probeFailures: ?object, details: ?object}} state
|
|
303
|
+
* details maps a vendor id to what its probe found: {path, version, reason}.
|
|
304
|
+
* probeFailures maps a vendor id to the class of an install lookup that
|
|
305
|
+
* failed, so the picker says it could not check instead of "not installed".
|
|
306
|
+
* capabilities, when given, maps a vendor id to what a live session has
|
|
307
|
+
* resolved for it; a vendor without an entry shows its declaration.
|
|
308
|
+
*/
|
|
309
|
+
function describeForClient(state) {
|
|
310
|
+
var installed = (state && state.installed) || [];
|
|
311
|
+
var available = (state && state.available) || [];
|
|
312
|
+
var resolved = (state && state.capabilities) || {};
|
|
313
|
+
var failures = (state && state.probeFailures) || {};
|
|
314
|
+
var details = (state && state.details) || {};
|
|
315
|
+
return list().map(function (d) {
|
|
316
|
+
var live = Object.prototype.hasOwnProperty.call(resolved, d.id) ? resolved[d.id] : d.capabilities;
|
|
317
|
+
return {
|
|
318
|
+
installDetail: Object.prototype.hasOwnProperty.call(details, d.id) ? details[d.id] : null,
|
|
319
|
+
id: d.id,
|
|
320
|
+
displayName: d.displayName,
|
|
321
|
+
icon: d.icon,
|
|
322
|
+
installHint: d.installHint,
|
|
323
|
+
loginCommand: d.loginCommand,
|
|
324
|
+
osUsersSupported: d.osUsersSupported,
|
|
325
|
+
installed: installed.indexOf(d.id) !== -1,
|
|
326
|
+
probeFailure: Object.prototype.hasOwnProperty.call(failures, d.id) ? failures[d.id] : null,
|
|
327
|
+
available: available.indexOf(d.id) !== -1,
|
|
328
|
+
capabilities: iface.completeCapabilities(live),
|
|
329
|
+
capabilityReasons: Object.assign({}, d.capabilityReasons),
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Whether per-user OS isolation rules an agent out: it is on and the agent does
|
|
336
|
+
* not support it. Fail-closed callers never create or start such an agent.
|
|
337
|
+
* @param {string} id
|
|
338
|
+
* @param {boolean} osUsers
|
|
339
|
+
*/
|
|
340
|
+
function disabledByOsUsers(id, osUsers) {
|
|
341
|
+
return !!osUsers && getVendor(id).osUsersSupported !== true;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** The reason shown for an agent that per-user OS isolation rules out. */
|
|
345
|
+
function osUsersReasonFor(id) {
|
|
346
|
+
return getVendor(id).displayName + " is not yet isolated per OS user";
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** key -> the one line shown beside a control the agent cannot support. */
|
|
350
|
+
function capabilityReasons() {
|
|
351
|
+
var out = {};
|
|
352
|
+
iface.CAPABILITY_KEYS.forEach(function (key) { out[key] = iface.CAPABILITIES[key].reason; });
|
|
353
|
+
return out;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
module.exports = {
|
|
357
|
+
register: register,
|
|
358
|
+
unregister: unregister,
|
|
359
|
+
isKnown: isKnown,
|
|
360
|
+
get: getVendor,
|
|
361
|
+
list: list,
|
|
362
|
+
ids: ids,
|
|
363
|
+
declaredCapabilities: declaredCapabilities,
|
|
364
|
+
traitOf: traitOf,
|
|
365
|
+
loginCommandFor: loginCommandFor,
|
|
366
|
+
displayNameFor: displayNameFor,
|
|
367
|
+
binaryNames: binaryNames,
|
|
368
|
+
ownsEnvName: ownsEnvName,
|
|
369
|
+
ownerOfEnvName: ownerOfEnvName,
|
|
370
|
+
withoutOwnedEnv: withoutOwnedEnv,
|
|
371
|
+
assertAllowedBinary: assertAllowedBinary,
|
|
372
|
+
defaultVendorId: defaultVendorId,
|
|
373
|
+
describeForClient: describeForClient,
|
|
374
|
+
disabledByOsUsers: disabledByOsUsers,
|
|
375
|
+
osUsersReasonFor: osUsersReasonFor,
|
|
376
|
+
capabilityReasons: capabilityReasons,
|
|
377
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.10.0-beta.2",
|
|
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"
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
"postinstall": "node scripts/postinstall.js",
|
|
14
14
|
"prepack": "node scripts/write-build-sha.js",
|
|
15
15
|
"test": "node scripts/check-test-count.js test/*.test.js",
|
|
16
|
+
"test:prompt-history": "node scripts/prompt-harness-history.js",
|
|
16
17
|
"install:local-test": "node scripts/install-local-test.js",
|
|
17
|
-
"verify:installed-build": "node scripts/verify-installed
|
|
18
|
+
"verify:installed-build": "node scripts/verify-installed.js",
|
|
18
19
|
"semantic-release": "semantic-release"
|
|
19
20
|
},
|
|
20
21
|
"files": [
|
|
@@ -22,7 +23,9 @@
|
|
|
22
23
|
"lib/",
|
|
23
24
|
"scripts/",
|
|
24
25
|
"deploy/",
|
|
25
|
-
"CREDITS.md"
|
|
26
|
+
"CREDITS.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"LICENSES/"
|
|
26
29
|
],
|
|
27
30
|
"keywords": [
|
|
28
31
|
"claude",
|
|
@@ -57,16 +60,16 @@
|
|
|
57
60
|
"Chad (original Clay author)"
|
|
58
61
|
],
|
|
59
62
|
"dependencies": {
|
|
60
|
-
"@anthropic-ai/claude-agent-sdk": "
|
|
61
|
-
"@anthropic-ai/sdk": "
|
|
63
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.295",
|
|
64
|
+
"@anthropic-ai/sdk": "0.104.2",
|
|
62
65
|
"@lydell/node-pty": "^1.2.0-beta.3",
|
|
63
|
-
"
|
|
64
|
-
"nodemailer": "^
|
|
66
|
+
"ajv": "^8.20.0",
|
|
67
|
+
"nodemailer": "^10.1.0",
|
|
65
68
|
"qrcode-terminal": "^0.12.0",
|
|
66
69
|
"web-push": "^3.6.7",
|
|
67
|
-
"ws": "^8.
|
|
70
|
+
"ws": "^8.22.0"
|
|
68
71
|
},
|
|
69
|
-
"license": "MIT",
|
|
72
|
+
"license": "FSL-1.1-MIT",
|
|
70
73
|
"engines": {
|
|
71
74
|
"node": ">=20.0.0"
|
|
72
75
|
},
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// check-sdk-lock-drift.js — fail when the installed build ships a different
|
|
5
|
+
// Agent SDK than the one package-lock.json pins.
|
|
6
|
+
//
|
|
7
|
+
// WHY: `npm install -g <tarball>` ignores package-lock.json (the lock is not
|
|
8
|
+
// published and there is no npm-shrinkwrap.json), so a range in package.json
|
|
9
|
+
// resolves afresh at install time. `npm ci` / `npm test` in a checkout exercise
|
|
10
|
+
// the locked SDK while the running service executes whatever the registry
|
|
11
|
+
// resolved at install time. This check closes that gap after the fact: it
|
|
12
|
+
// compares the versions of the SDK packages inside the globally installed build
|
|
13
|
+
// against the versions recorded in this tree's lock and exits non-zero on any
|
|
14
|
+
// difference. It runs as part of `npm run verify:installed-build`, the
|
|
15
|
+
// post-merge step that is already configured on_failure: fail, so drift blocks
|
|
16
|
+
// the merge chain instead of being logged and ignored.
|
|
17
|
+
//
|
|
18
|
+
// The SDK pair is pinned to exact versions in package.json (no caret), so the
|
|
19
|
+
// install-time resolution cannot move on an upstream publish: this check fails
|
|
20
|
+
// only on a real mismatch between the installed build and the lock, never
|
|
21
|
+
// because the registry gained a newer release. A test asserts the pins stay
|
|
22
|
+
// exact.
|
|
23
|
+
//
|
|
24
|
+
// TOOL CONSIDERED: `npm ls -g --json`. It does not fit: it reports the whole
|
|
25
|
+
// global tree and exits non-zero on unrelated tree problems (extraneous,
|
|
26
|
+
// invalid or missing optional packages), which would turn an unrelated install
|
|
27
|
+
// quirk into a false drift failure, and the lock side still needs its own
|
|
28
|
+
// reader. Reading the two package.json files and the lock directly is smaller
|
|
29
|
+
// and fails only on the comparison that matters.
|
|
30
|
+
//
|
|
31
|
+
// WHY A CHECK AND NOT npm-shrinkwrap.json: a shrinkwrap would make this lock —
|
|
32
|
+
// a generated file maintained for CI — the install-time source of truth for
|
|
33
|
+
// every end user, and would freeze transitive security fixes into published
|
|
34
|
+
// releases until the next release is cut. A bad entry would then surface as a
|
|
35
|
+
// user-facing install failure rather than a red post-merge step. The check
|
|
36
|
+
// keeps the lock a development artifact and turns any divergence into a loud,
|
|
37
|
+
// attributable failure at the one moment both sides are known.
|
|
38
|
+
//
|
|
39
|
+
// Exit codes: 0 = installed SDK versions match the lock; 1 = drift, or the
|
|
40
|
+
// lock/installed versions could not be read (an unreadable side is never
|
|
41
|
+
// treated as a match).
|
|
42
|
+
|
|
43
|
+
const fs = require('fs');
|
|
44
|
+
const path = require('path');
|
|
45
|
+
const { execFileSync } = require('child_process');
|
|
46
|
+
|
|
47
|
+
const TRACKED_PACKAGES = ['@anthropic-ai/claude-agent-sdk', '@anthropic-ai/sdk'];
|
|
48
|
+
|
|
49
|
+
function readLockedVersions(lockPath, names) {
|
|
50
|
+
const lock = JSON.parse(fs.readFileSync(lockPath, 'utf8'));
|
|
51
|
+
const packages = lock && lock.packages;
|
|
52
|
+
if (!packages || typeof packages !== 'object') {
|
|
53
|
+
throw new Error(`${lockPath} has no "packages" map (lockfileVersion 2 or 3 expected)`);
|
|
54
|
+
}
|
|
55
|
+
const versions = {};
|
|
56
|
+
for (const name of names) {
|
|
57
|
+
const entry = packages[`node_modules/${name}`];
|
|
58
|
+
if (!entry || typeof entry.version !== 'string') {
|
|
59
|
+
throw new Error(`${lockPath} has no locked version for ${name}`);
|
|
60
|
+
}
|
|
61
|
+
versions[name] = entry.version;
|
|
62
|
+
}
|
|
63
|
+
return versions;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// A package that is absent from the installed tree is reported as null so the
|
|
67
|
+
// caller can tell "missing" from "different"; any other read failure throws.
|
|
68
|
+
function readInstalledVersions(installedRoot, names) {
|
|
69
|
+
const versions = {};
|
|
70
|
+
for (const name of names) {
|
|
71
|
+
const pkgJson = path.join(installedRoot, 'node_modules', ...name.split('/'), 'package.json');
|
|
72
|
+
let raw;
|
|
73
|
+
try {
|
|
74
|
+
raw = fs.readFileSync(pkgJson, 'utf8');
|
|
75
|
+
} catch (err) {
|
|
76
|
+
if (err.code === 'ENOENT') {
|
|
77
|
+
versions[name] = null;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
const parsed = JSON.parse(raw);
|
|
83
|
+
if (!parsed || typeof parsed.version !== 'string') {
|
|
84
|
+
throw new Error(`${pkgJson} has no "version" field`);
|
|
85
|
+
}
|
|
86
|
+
versions[name] = parsed.version;
|
|
87
|
+
}
|
|
88
|
+
return versions;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function findDrift(locked, installed) {
|
|
92
|
+
return Object.keys(locked)
|
|
93
|
+
.filter((name) => installed[name] !== locked[name])
|
|
94
|
+
.map((name) => ({ name, locked: locked[name], installed: installed[name] }));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function formatDrift(drift, installedRoot) {
|
|
98
|
+
const lines = drift.map((d) =>
|
|
99
|
+
` ${d.name}: lock pins ${d.locked}, installed build has ${d.installed === null ? '(not installed)' : d.installed}`
|
|
100
|
+
);
|
|
101
|
+
return (
|
|
102
|
+
`[check-sdk-lock-drift] SDK_LOCK_DRIFT: the installed build (${installedRoot}) does not match package-lock.json:\n` +
|
|
103
|
+
`${lines.join('\n')}\n` +
|
|
104
|
+
'The running service would execute a different SDK than the one `npm ci` / `npm test` exercised. ' +
|
|
105
|
+
'Bump the exact pins in package.json and package-lock.json together, then reinstall.'
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function parseArgs(argv) {
|
|
110
|
+
const opts = {};
|
|
111
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
112
|
+
const flag = argv[i];
|
|
113
|
+
const value = argv[i + 1];
|
|
114
|
+
if ((flag !== '--lock' && flag !== '--installed-root') || typeof value !== 'string') {
|
|
115
|
+
throw new Error('usage: check-sdk-lock-drift.js [--lock <package-lock.json>] [--installed-root <dir>]');
|
|
116
|
+
}
|
|
117
|
+
opts[flag === '--lock' ? 'lock' : 'installedRoot'] = value;
|
|
118
|
+
}
|
|
119
|
+
return opts;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function resolveInstalledRoot() {
|
|
123
|
+
const globalRoot = execFileSync('npm', ['root', '-g'], {
|
|
124
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
125
|
+
}).toString().trim();
|
|
126
|
+
return path.join(globalRoot, '@clagentic', 'console');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function main(argv) {
|
|
130
|
+
let opts;
|
|
131
|
+
let locked;
|
|
132
|
+
let installed;
|
|
133
|
+
let installedRoot;
|
|
134
|
+
try {
|
|
135
|
+
opts = parseArgs(argv);
|
|
136
|
+
const lockPath = opts.lock || path.join(__dirname, '..', 'package-lock.json');
|
|
137
|
+
installedRoot = opts.installedRoot || resolveInstalledRoot();
|
|
138
|
+
locked = readLockedVersions(lockPath, TRACKED_PACKAGES);
|
|
139
|
+
installed = readInstalledVersions(installedRoot, TRACKED_PACKAGES);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(`[check-sdk-lock-drift] ERROR: ${err.message}`);
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const drift = findDrift(locked, installed);
|
|
146
|
+
if (drift.length > 0) {
|
|
147
|
+
console.error(formatDrift(drift, installedRoot));
|
|
148
|
+
return 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const summary = TRACKED_PACKAGES.map((name) => `${name}@${locked[name]}`).join(', ');
|
|
152
|
+
console.log(`[check-sdk-lock-drift] installed build matches package-lock.json: ${summary}`);
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = { TRACKED_PACKAGES, readLockedVersions, readInstalledVersions, findDrift, formatDrift, main };
|
|
157
|
+
|
|
158
|
+
if (require.main === module) {
|
|
159
|
+
process.exitCode = main(process.argv.slice(2));
|
|
160
|
+
}
|