@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.
- package/LICENSE +117 -12
- package/LICENSES/MIT-legacy.txt +22 -0
- package/LICENSES/README.md +15 -0
- package/README.md +8 -2
- package/bin/cli.js +30 -5
- package/deploy/clagentic-console.service +10 -6
- package/lib/audit.js +3 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-check.js +138 -0
- package/lib/cli/daemon-launch.js +17 -17
- package/lib/config.js +32 -20
- package/lib/daemon-env-settings.js +84 -0
- package/lib/daemon-projects.js +38 -0
- package/lib/daemon.js +202 -158
- 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/lore-attestation.js +73 -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/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 +23 -22
- package/lib/project-external-trigger.js +103 -10
- 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 +12 -5
- 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 +216 -0
- package/lib/project-sessions.js +164 -302
- package/lib/project-user-message.js +36 -11
- package/lib/project.js +189 -142
- 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 +673 -0
- package/lib/public/app.js +1 -1
- package/lib/public/css/diagnostics.css +50 -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/app-connection.js +7 -0
- package/lib/public/modules/app-cursors.js +7 -5
- package/lib/public/modules/app-messages.js +45 -45
- package/lib/public/modules/app-notifications.js +47 -71
- package/lib/public/modules/app-panels.js +61 -58
- package/lib/public/modules/app-projects.js +2 -1
- package/lib/public/modules/app-rendering.js +4 -10
- package/lib/public/modules/diagnostics.js +60 -16
- 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 +67 -904
- package/lib/public/modules/vendor-picker.js +53 -0
- package/lib/public/modules/vendor-registry.js +133 -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 +290 -273
- package/lib/sdk-message-processor.js +125 -145
- package/lib/server-hub-sessions.js +13 -10
- package/lib/server-palette.js +28 -19
- package/lib/server.js +141 -113
- package/lib/service-install.js +96 -0
- package/lib/session-capabilities.js +76 -0
- package/lib/sessions.js +45 -28
- 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 +65 -0
- package/lib/ws-origin.js +99 -0
- package/lib/ws-schema.js +33 -22
- package/lib/yoke/adapters/claude-capabilities.js +38 -0
- package/lib/yoke/adapters/claude-vendor.js +35 -0
- package/lib/yoke/adapters/claude-worker.js +55 -87
- package/lib/yoke/adapters/claude.js +156 -62
- package/lib/yoke/adapters/codex-capabilities.js +37 -0
- package/lib/yoke/adapters/codex-vendor.js +46 -0
- package/lib/yoke/adapters/codex.js +347 -156
- 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 +104 -0
- package/lib/yoke/capabilities.js +49 -0
- package/lib/yoke/codex-app-server.js +23 -5
- package/lib/yoke/env-ownership.js +40 -0
- package/lib/yoke/index.js +67 -173
- package/lib/yoke/install-probe.js +121 -0
- package/lib/yoke/instructions.js +7 -11
- package/lib/yoke/interface.js +199 -3
- package/lib/yoke/package.json +1 -1
- package/lib/yoke/provider-credentials.js +96 -0
- package/lib/yoke/registry.js +340 -0
- package/package.json +12 -8
- 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.js +67 -0
- package/lib/sdk-permission-ownership.js +0 -136
|
@@ -0,0 +1,340 @@
|
|
|
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, ctx.lookupBinary(name) -> boolean
|
|
103
|
+
* checkAuth function() -> boolean
|
|
104
|
+
* installHint string one line telling the user how to install it
|
|
105
|
+
* loginCommand string the one place the login command is written
|
|
106
|
+
* osUsersSupported boolean can run under per-user OS isolation
|
|
107
|
+
* needsRuntimeEnv boolean every entry point requires runtimeEnv
|
|
108
|
+
* perProjectRuntime, activityTokens, attestsHumanSessions
|
|
109
|
+
* optional booleans (false when absent): adapter traits, how
|
|
110
|
+
* the console drives the adapter (interface.js TRAITS). Never
|
|
111
|
+
* resolved or overridden; read with traitOf.
|
|
112
|
+
* ownedEnvNames string[] exact environment variable names this agent reads
|
|
113
|
+
* for its own endpoint and credentials
|
|
114
|
+
* ownedEnvPrefixes optional string[] namespaces of variables this agent owns
|
|
115
|
+
* whole ("AWS_"); every variable under one is owned
|
|
116
|
+
* credentialGroups optional {id, prefixes[], envNames[]}[] variables that work
|
|
117
|
+
* as one credential set; each prefix and name must
|
|
118
|
+
* be owned by the descriptor
|
|
119
|
+
* nativeInstructionFiles string[] project instruction files the agent reads
|
|
120
|
+
* itself, so the console does not inject them again
|
|
121
|
+
* interruptMessage string shown when the user stops a turn
|
|
122
|
+
* capabilities object the declared capabilities (interface.js ledger)
|
|
123
|
+
* createAdapter function(opts) -> adapter
|
|
124
|
+
*
|
|
125
|
+
* @param {object} descriptor
|
|
126
|
+
* @returns {object} the registered (frozen) descriptor, capabilities completed
|
|
127
|
+
*/
|
|
128
|
+
function register(descriptor) {
|
|
129
|
+
if (!descriptor || typeof descriptor !== "object") {
|
|
130
|
+
throw new Error("[YOKE] A vendor descriptor must be an object");
|
|
131
|
+
}
|
|
132
|
+
requireString(descriptor, "id");
|
|
133
|
+
requireString(descriptor, "displayName");
|
|
134
|
+
requireString(descriptor, "installHint");
|
|
135
|
+
requireString(descriptor, "loginCommand");
|
|
136
|
+
requireString(descriptor, "interruptMessage");
|
|
137
|
+
requireStringList(descriptor, "binaryNames");
|
|
138
|
+
requireStringList(descriptor, "ownedEnvNames");
|
|
139
|
+
if (descriptor.ownedEnvPrefixes === undefined) descriptor = Object.assign({}, descriptor, { ownedEnvPrefixes: [] });
|
|
140
|
+
requireStringList(descriptor, "ownedEnvPrefixes");
|
|
141
|
+
requireStringList(descriptor, "nativeInstructionFiles");
|
|
142
|
+
requireFunction(descriptor, "probeInstalled");
|
|
143
|
+
requireFunction(descriptor, "checkAuth");
|
|
144
|
+
requireFunction(descriptor, "createAdapter");
|
|
145
|
+
requireBoolean(descriptor, "osUsersSupported");
|
|
146
|
+
requireBoolean(descriptor, "needsRuntimeEnv");
|
|
147
|
+
var traitDefaults = {};
|
|
148
|
+
iface.TRAIT_KEYS.forEach(function (key) {
|
|
149
|
+
if (descriptor[key] === undefined) traitDefaults[key] = false;
|
|
150
|
+
else requireBoolean(descriptor, key);
|
|
151
|
+
});
|
|
152
|
+
if (Object.keys(traitDefaults).length) descriptor = Object.assign({}, descriptor, traitDefaults);
|
|
153
|
+
if (typeof descriptor.priority !== "number") {
|
|
154
|
+
throw new Error("[YOKE] Vendor descriptor '" + descriptor.id + "' needs a numeric 'priority'");
|
|
155
|
+
}
|
|
156
|
+
if (_vendors.has(descriptor.id)) {
|
|
157
|
+
throw new Error("[YOKE] Vendor already registered: " + descriptor.id);
|
|
158
|
+
}
|
|
159
|
+
var credentialGroups = validateCredentialGroups(descriptor);
|
|
160
|
+
iface.validateCapabilities(descriptor.capabilities, "vendor '" + descriptor.id + "'");
|
|
161
|
+
|
|
162
|
+
var entry = Object.assign({}, descriptor, {
|
|
163
|
+
credentialGroups: credentialGroups,
|
|
164
|
+
icon: descriptor.icon || "",
|
|
165
|
+
binaryNames: descriptor.binaryNames.slice(),
|
|
166
|
+
ownedEnvNames: descriptor.ownedEnvNames.slice(),
|
|
167
|
+
ownedEnvPrefixes: descriptor.ownedEnvPrefixes.slice(),
|
|
168
|
+
nativeInstructionFiles: descriptor.nativeInstructionFiles.slice(),
|
|
169
|
+
capabilities: iface.completeCapabilities(descriptor.capabilities),
|
|
170
|
+
});
|
|
171
|
+
_vendors.set(entry.id, entry);
|
|
172
|
+
return entry;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Removes a vendor. Returns whether it was registered. */
|
|
176
|
+
function unregister(id) {
|
|
177
|
+
return _vendors.delete(id);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function isKnown(id) {
|
|
181
|
+
return typeof id === "string" && _vendors.has(id);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The descriptor for an id, or throws the named unknown-vendor error. */
|
|
185
|
+
function getVendor(id) {
|
|
186
|
+
if (!isKnown(id)) throw UnknownVendorError(id);
|
|
187
|
+
return _vendors.get(id);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** All descriptors, preferred first. */
|
|
191
|
+
function list() {
|
|
192
|
+
return Array.from(_vendors.values()).sort(function (a, b) {
|
|
193
|
+
return a.priority - b.priority || (a.id < b.id ? -1 : 1);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function ids() {
|
|
198
|
+
return list().map(function (d) { return d.id; });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The declared capabilities of a registered vendor (a copy). A declaration is
|
|
203
|
+
* only the starting point: a session-facing decision reads the resolved set
|
|
204
|
+
* (lib/session-capabilities.js), never this.
|
|
205
|
+
*/
|
|
206
|
+
function declaredCapabilities(id) {
|
|
207
|
+
return iface.completeCapabilities(getVendor(id).capabilities);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* An adapter trait (interface.js TRAITS). A trait is a fact about the adapter,
|
|
212
|
+
* so it is read from the descriptor and never resolved against a session. A
|
|
213
|
+
* name that is not registered has no traits: false, never a throw, because the
|
|
214
|
+
* name may come from a session or a client.
|
|
215
|
+
*/
|
|
216
|
+
function traitOf(id, key) {
|
|
217
|
+
if (!iface.isTraitKey(key)) throw new Error("[YOKE] Unknown adapter trait: " + String(key));
|
|
218
|
+
return isKnown(id) ? _vendors.get(id)[key] === true : false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function loginCommandFor(id) {
|
|
222
|
+
return getVendor(id).loginCommand;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function displayNameFor(id) {
|
|
226
|
+
return getVendor(id).displayName;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Whether a registered vendor owns the environment variable name. */
|
|
230
|
+
function ownsEnvName(id, name) {
|
|
231
|
+
return descriptorOwns(getVendor(id), name);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The id of the registered vendor that owns the variable name, or null. */
|
|
235
|
+
function ownerOfEnvName(name) {
|
|
236
|
+
var all = list();
|
|
237
|
+
for (var i = 0; i < all.length; i++) {
|
|
238
|
+
if (descriptorOwns(all[i], name)) return all[i].id;
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A copy of env without the variables the vendor owns, so a session that is to
|
|
245
|
+
* use its own endpoint and credentials does not inherit the daemon's.
|
|
246
|
+
*/
|
|
247
|
+
function withoutOwnedEnv(id, env) {
|
|
248
|
+
var vendor = getVendor(id);
|
|
249
|
+
var out = {};
|
|
250
|
+
Object.keys(env || {}).forEach(function (name) {
|
|
251
|
+
if (!descriptorOwns(vendor, name)) out[name] = env[name];
|
|
252
|
+
});
|
|
253
|
+
return out;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Executable names the install probe may look up. */
|
|
257
|
+
function binaryNames() {
|
|
258
|
+
var names = [];
|
|
259
|
+
list().forEach(function (d) {
|
|
260
|
+
d.binaryNames.forEach(function (n) { if (names.indexOf(n) === -1) names.push(n); });
|
|
261
|
+
});
|
|
262
|
+
return names;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Throws the named error unless the name belongs to a registered vendor. */
|
|
266
|
+
function assertAllowedBinary(name) {
|
|
267
|
+
if (binaryNames().indexOf(name) === -1) throw DisallowedBinaryError(name);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The vendor a project starts on: the most preferred of the available ones,
|
|
272
|
+
* or the most preferred registered vendor when none is available.
|
|
273
|
+
* @param {string[]} availableIds
|
|
274
|
+
*/
|
|
275
|
+
function defaultVendorId(availableIds) {
|
|
276
|
+
var all = ids();
|
|
277
|
+
var avail = Array.isArray(availableIds) ? availableIds : [];
|
|
278
|
+
for (var i = 0; i < all.length; i++) {
|
|
279
|
+
if (avail.indexOf(all[i]) !== -1) return all[i];
|
|
280
|
+
}
|
|
281
|
+
return all[0] || null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* The registry as the browser needs it: serializable, no functions.
|
|
286
|
+
* @param {{installed: string[], available: string[], capabilities: ?object, probeFailures: ?object}} state
|
|
287
|
+
* probeFailures maps a vendor id to the class of an install lookup that
|
|
288
|
+
* failed, so the picker says it could not check instead of "not installed".
|
|
289
|
+
* capabilities, when given, maps a vendor id to what a live session has
|
|
290
|
+
* resolved for it; a vendor without an entry shows its declaration.
|
|
291
|
+
*/
|
|
292
|
+
function describeForClient(state) {
|
|
293
|
+
var installed = (state && state.installed) || [];
|
|
294
|
+
var available = (state && state.available) || [];
|
|
295
|
+
var resolved = (state && state.capabilities) || {};
|
|
296
|
+
var failures = (state && state.probeFailures) || {};
|
|
297
|
+
return list().map(function (d) {
|
|
298
|
+
var live = Object.prototype.hasOwnProperty.call(resolved, d.id) ? resolved[d.id] : d.capabilities;
|
|
299
|
+
return {
|
|
300
|
+
id: d.id,
|
|
301
|
+
displayName: d.displayName,
|
|
302
|
+
icon: d.icon,
|
|
303
|
+
installHint: d.installHint,
|
|
304
|
+
loginCommand: d.loginCommand,
|
|
305
|
+
osUsersSupported: d.osUsersSupported,
|
|
306
|
+
installed: installed.indexOf(d.id) !== -1,
|
|
307
|
+
probeFailure: Object.prototype.hasOwnProperty.call(failures, d.id) ? failures[d.id] : null,
|
|
308
|
+
available: available.indexOf(d.id) !== -1,
|
|
309
|
+
capabilities: iface.completeCapabilities(live),
|
|
310
|
+
};
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** key -> the one line shown beside a control the agent cannot support. */
|
|
315
|
+
function capabilityReasons() {
|
|
316
|
+
var out = {};
|
|
317
|
+
iface.CAPABILITY_KEYS.forEach(function (key) { out[key] = iface.CAPABILITIES[key].reason; });
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
module.exports = {
|
|
322
|
+
register: register,
|
|
323
|
+
unregister: unregister,
|
|
324
|
+
isKnown: isKnown,
|
|
325
|
+
get: getVendor,
|
|
326
|
+
list: list,
|
|
327
|
+
ids: ids,
|
|
328
|
+
declaredCapabilities: declaredCapabilities,
|
|
329
|
+
traitOf: traitOf,
|
|
330
|
+
loginCommandFor: loginCommandFor,
|
|
331
|
+
displayNameFor: displayNameFor,
|
|
332
|
+
binaryNames: binaryNames,
|
|
333
|
+
ownsEnvName: ownsEnvName,
|
|
334
|
+
ownerOfEnvName: ownerOfEnvName,
|
|
335
|
+
withoutOwnedEnv: withoutOwnedEnv,
|
|
336
|
+
assertAllowedBinary: assertAllowedBinary,
|
|
337
|
+
defaultVendorId: defaultVendorId,
|
|
338
|
+
describeForClient: describeForClient,
|
|
339
|
+
capabilityReasons: capabilityReasons,
|
|
340
|
+
};
|
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.1",
|
|
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,17 @@
|
|
|
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
66
|
"@openai/codex": "^0.124.0",
|
|
64
|
-
"
|
|
67
|
+
"ajv": "^8.20.0",
|
|
68
|
+
"nodemailer": "^10.1.0",
|
|
65
69
|
"qrcode-terminal": "^0.12.0",
|
|
66
70
|
"web-push": "^3.6.7",
|
|
67
|
-
"ws": "^8.
|
|
71
|
+
"ws": "^8.22.0"
|
|
68
72
|
},
|
|
69
|
-
"license": "MIT",
|
|
73
|
+
"license": "FSL-1.1-MIT",
|
|
70
74
|
"engines": {
|
|
71
75
|
"node": ">=20.0.0"
|
|
72
76
|
},
|
|
@@ -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
|
+
}
|
|
@@ -185,6 +185,73 @@ function emitAnnotation(message) {
|
|
|
185
185
|
writeFullySync(1, "::error::" + escaped + "\n");
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
// Caps keep the annotation inside GitHub's message size limits and readable
|
|
189
|
+
// when a systemic failure (e.g. a broken fixture) fails hundreds of tests.
|
|
190
|
+
var MAX_NAMED_FAILURES = 25;
|
|
191
|
+
var MAX_FAILURE_NAME_LENGTH = 200;
|
|
192
|
+
|
|
193
|
+
// extractFailedTests(tap) — every `not ok` line of a TAP stream, in order,
|
|
194
|
+
// with nesting indentation dropped. Subtests and their enclosing suite both
|
|
195
|
+
// report `not ok`, so a leaf failure is listed alongside its parents; that is
|
|
196
|
+
// deliberate, the parent chain locates the leaf. A `# SKIP`/`# TODO` directive
|
|
197
|
+
// is not a failure and is ignored.
|
|
198
|
+
function extractFailedTests(tap) {
|
|
199
|
+
return extractFailures(tap).map(function (f) { return f.name; });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// extractFailures(tap) — like extractFailedTests but each entry also carries
|
|
203
|
+
// `detail`: the error/expected/actual lines from the YAML block node's TAP
|
|
204
|
+
// reporter prints under a failing test, so the annotation says WHY it failed
|
|
205
|
+
// and not only which test did. Multi-line values (`error: |-`) contribute
|
|
206
|
+
// their first content line.
|
|
207
|
+
var MAX_FAILURE_DETAIL_LENGTH = 600;
|
|
208
|
+
var DETAIL_KEY = /^\s+(error|expected|actual|failureType|code):\s*(.*)$/;
|
|
209
|
+
|
|
210
|
+
function extractFailures(tap) {
|
|
211
|
+
var failures = [];
|
|
212
|
+
var current = null;
|
|
213
|
+
var lines = String(tap || "").split("\n");
|
|
214
|
+
for (var i = 0; i < lines.length; i++) {
|
|
215
|
+
var line = lines[i];
|
|
216
|
+
var match = /^\s*not ok \d+(?: - (.*))?$/.exec(line);
|
|
217
|
+
if (match) {
|
|
218
|
+
var name = (match[1] || "(unnamed)").trim();
|
|
219
|
+
if (/#\s*(SKIP|TODO)\b/i.test(name)) { current = null; continue; }
|
|
220
|
+
current = { name: name, detail: "" };
|
|
221
|
+
failures.push(current);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (/^\s*(ok \d+|# Subtest:)/.test(line)) { current = null; continue; }
|
|
225
|
+
if (!current) continue;
|
|
226
|
+
var detailMatch = DETAIL_KEY.exec(line);
|
|
227
|
+
if (!detailMatch) continue;
|
|
228
|
+
var value = detailMatch[2].trim();
|
|
229
|
+
if ((value === "|-" || value === "|") && i + 1 < lines.length) {
|
|
230
|
+
value = lines[i + 1].trim();
|
|
231
|
+
}
|
|
232
|
+
if (current.detail.length < MAX_FAILURE_DETAIL_LENGTH) {
|
|
233
|
+
current.detail += (current.detail ? "; " : "") + detailMatch[1] + ": " + value;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return failures;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function clip(text, max) {
|
|
240
|
+
return text.length > max ? text.slice(0, max) + "..." : text;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function formatFailedTests(failures) {
|
|
244
|
+
var shown = [];
|
|
245
|
+
failures.slice(0, MAX_NAMED_FAILURES).forEach(function (f) {
|
|
246
|
+
shown.push(" not ok - " + clip(f.name, MAX_FAILURE_NAME_LENGTH));
|
|
247
|
+
if (f.detail) shown.push(" " + clip(f.detail, MAX_FAILURE_DETAIL_LENGTH));
|
|
248
|
+
});
|
|
249
|
+
if (failures.length > MAX_NAMED_FAILURES) {
|
|
250
|
+
shown.push(" ... and " + (failures.length - MAX_NAMED_FAILURES) + " more");
|
|
251
|
+
}
|
|
252
|
+
return shown.join("\n");
|
|
253
|
+
}
|
|
254
|
+
|
|
188
255
|
// classifyRun() is the pure decision core of this script: given the raw
|
|
189
256
|
// spawnSync() result plus the bucketed RESULT-line data, decide whether the
|
|
190
257
|
// run passes and, if not, exactly WHY. Pulled out of the top-level script
|
|
@@ -285,13 +352,19 @@ function classifyRun(result, files, resultsByFile, totalTests, floor) {
|
|
|
285
352
|
}
|
|
286
353
|
|
|
287
354
|
if (result.status !== 0) {
|
|
355
|
+
// Name the failing tests in the verdict itself: the annotation is the only
|
|
356
|
+
// channel a crew agent can read from CI, and "see the TAP above" points at
|
|
357
|
+
// a log it cannot fetch.
|
|
358
|
+
var failed = extractFailures(result.stdout);
|
|
359
|
+
var named = formatFailedTests(failed);
|
|
288
360
|
return {
|
|
289
361
|
ok: false,
|
|
290
362
|
exitCode: result.status,
|
|
291
363
|
kind: "test-failure",
|
|
292
364
|
reason: (
|
|
293
365
|
"node --test exited " + result.status + " with a named test failure above (see the TAP `not ok` " +
|
|
294
|
-
"line(s)) — this is an ordinary test failure, not a wrapper-level condition."
|
|
366
|
+
"line(s)) — this is an ordinary test failure, not a wrapper-level condition." +
|
|
367
|
+
(named ? "\nFailing tests (" + failed.length + "):\n" + named : "")
|
|
295
368
|
),
|
|
296
369
|
};
|
|
297
370
|
}
|
|
@@ -302,6 +375,8 @@ function classifyRun(result, files, resultsByFile, totalTests, floor) {
|
|
|
302
375
|
module.exports = {
|
|
303
376
|
classifyRun: classifyRun,
|
|
304
377
|
emitAnnotation: emitAnnotation,
|
|
378
|
+
extractFailedTests: extractFailedTests,
|
|
379
|
+
extractFailures: extractFailures,
|
|
305
380
|
writeFullySync: writeFullySync,
|
|
306
381
|
};
|
|
307
382
|
|