@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
package/lib/yoke/index.js
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
var iface = require("./interface");
|
|
5
5
|
var instructions = require("./instructions");
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var registry = require("./registry");
|
|
7
|
+
var installProbe = require("./install-probe");
|
|
8
|
+
var capabilities = require("./capabilities");
|
|
9
|
+
// Requiring the vendor modules registers the shipped agents. They are light on
|
|
10
|
+
// purpose: the adapters themselves are loaded when one is created.
|
|
11
|
+
require("./adapters/claude-vendor");
|
|
12
|
+
require("./adapters/codex-vendor");
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Wrap adapter.createQuery to inject cross-vendor project instructions.
|
|
@@ -34,25 +39,30 @@ function wrapCreateQuery(adapter, defaultCwd) {
|
|
|
34
39
|
};
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
// A vendor name that arrives from a client is checked here before it is used as
|
|
43
|
+
// a key or handed to a lookup.
|
|
44
|
+
function isKnownVendor(vendor) {
|
|
45
|
+
return registry.isKnown(vendor);
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
/**
|
|
38
|
-
* Create a YOKE adapter.
|
|
49
|
+
* Create a YOKE adapter for a registered vendor.
|
|
39
50
|
*
|
|
40
51
|
* @param {object} opts
|
|
41
|
-
* @param {string} [opts.vendor
|
|
52
|
+
* @param {string} [opts.vendor] - Registered vendor id (default: the most preferred)
|
|
42
53
|
* @param {string} opts.cwd - Project working directory
|
|
43
54
|
* @param {object} [opts.adapterOpts] - Vendor-specific adapter construction options
|
|
44
55
|
* @returns {Adapter}
|
|
56
|
+
* @throws {Error} code YOKE_UNKNOWN_VENDOR for a vendor that is not registered
|
|
45
57
|
*/
|
|
46
58
|
function createAdapter(opts) {
|
|
47
|
-
var vendor = (opts && opts.vendor) ||
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
adapter = createCodexAdapter(opts);
|
|
53
|
-
} else {
|
|
54
|
-
throw new Error("[YOKE] Unknown adapter vendor: " + vendor);
|
|
59
|
+
var vendor = (opts && opts.vendor) || registry.ids()[0];
|
|
60
|
+
if (registry.disabledByOsUsers(vendor, opts && opts.osUsers)) {
|
|
61
|
+
var refusal = new Error("[YOKE] " + registry.osUsersReasonFor(vendor));
|
|
62
|
+
refusal.code = "YOKE_OS_USERS_UNSUPPORTED";
|
|
63
|
+
throw refusal;
|
|
55
64
|
}
|
|
65
|
+
var adapter = registry.get(vendor).createAdapter(opts);
|
|
56
66
|
iface.validateAdapter(adapter);
|
|
57
67
|
wrapCreateQuery(adapter, opts && opts.cwd);
|
|
58
68
|
return adapter;
|
|
@@ -73,115 +83,17 @@ function logAuthCheck(auth) {
|
|
|
73
83
|
if (_lastAuthLogKey === key && now - _lastAuthLogAt < 30000) return;
|
|
74
84
|
_lastAuthLogKey = key;
|
|
75
85
|
_lastAuthLogAt = now;
|
|
76
|
-
console.log("[yoke] Auth check:
|
|
86
|
+
console.log("[yoke] Auth check: " + Object.keys(auth).map(function(id) { return id + "=" + auth[id]; }).join(" "));
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
function checkAuth() {
|
|
80
90
|
if (_authCache) return _authCache;
|
|
81
91
|
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (process.platform === "win32") {
|
|
88
|
-
return execFileSync("where", [name], { timeout: 3000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim().split(/\r?\n/)[0] || null;
|
|
89
|
-
}
|
|
90
|
-
return execFileSync("which", [name], { timeout: 3000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim().split(/\r?\n/)[0] || null;
|
|
91
|
-
} catch (e) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function parseClaudeAuthStatusJson(out) {
|
|
97
|
-
if (!out) return null;
|
|
98
|
-
try {
|
|
99
|
-
return JSON.parse(out);
|
|
100
|
-
} catch (e) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function isClaudeLoggedInText(out) {
|
|
106
|
-
if (!out) return false;
|
|
107
|
-
var text = String(out).toLowerCase();
|
|
108
|
-
if (text.indexOf("not logged in") !== -1) return false;
|
|
109
|
-
if (text.indexOf("login method:") !== -1) return true;
|
|
110
|
-
if (text.indexOf("logged in") !== -1) return true;
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function hasThirdPartyProviderAuth() {
|
|
115
|
-
// Claude Code supports third-party providers via env vars. When these are set,
|
|
116
|
-
// `claude auth status` reports "not logged in" because there is no OAuth session,
|
|
117
|
-
// but Claude Code itself authenticates directly through the provider.
|
|
118
|
-
var env = process.env;
|
|
119
|
-
if (env.CLAUDE_CODE_USE_BEDROCK === "1"
|
|
120
|
-
&& (env.AWS_BEARER_TOKEN_BEDROCK
|
|
121
|
-
|| env.AWS_ACCESS_KEY_ID
|
|
122
|
-
|| env.AWS_PROFILE
|
|
123
|
-
|| env.AWS_SESSION_TOKEN)) {
|
|
124
|
-
return "bedrock";
|
|
125
|
-
}
|
|
126
|
-
if (env.CLAUDE_CODE_USE_VERTEX === "1") return "vertex";
|
|
127
|
-
if (env.ANTHROPIC_API_KEY) return "api_key";
|
|
128
|
-
if (env.ANTHROPIC_AUTH_TOKEN) return "auth_token";
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function checkClaude() {
|
|
133
|
-
var provider = hasThirdPartyProviderAuth();
|
|
134
|
-
if (provider) {
|
|
135
|
-
console.log("[yoke] Claude auth via third-party provider: " + provider);
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
var out = execSync("claude auth status --json", { timeout: 5000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
141
|
-
var parsed = parseClaudeAuthStatusJson(out);
|
|
142
|
-
if (parsed) return !!parsed.loggedIn;
|
|
143
|
-
console.warn("[yoke] Claude auth status JSON parse failed; falling back to text output");
|
|
144
|
-
} catch (e) {
|
|
145
|
-
var stdout = e && e.stdout ? String(e.stdout) : "";
|
|
146
|
-
if (stdout) {
|
|
147
|
-
var parsedFallback = parseClaudeAuthStatusJson(stdout);
|
|
148
|
-
if (parsedFallback) return !!parsedFallback.loggedIn;
|
|
149
|
-
}
|
|
150
|
-
console.warn("[yoke] Claude auth status JSON check failed; falling back to text output:", e.message);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
try {
|
|
154
|
-
var textOut = execSync("claude auth status --text", { timeout: 5000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
155
|
-
return isClaudeLoggedInText(textOut);
|
|
156
|
-
} catch (e) {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function resolveCodexBinary() {
|
|
162
|
-
var fs = require("fs");
|
|
163
|
-
var findCodexPath = require("./codex-app-server").findCodexPath;
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
var codexBin = findCodexPath();
|
|
167
|
-
if (codexBin && fs.existsSync(codexBin)) return codexBin;
|
|
168
|
-
} catch (e) {}
|
|
169
|
-
|
|
170
|
-
return lookupBinary("codex");
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function checkCodex() {
|
|
174
|
-
try {
|
|
175
|
-
var codexBin = resolveCodexBinary();
|
|
176
|
-
if (!codexBin) return false;
|
|
177
|
-
execFileSync(codexBin, ["login", "status"], { timeout: 5000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
178
|
-
return true;
|
|
179
|
-
} catch (e) {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
_authCache = { claude: checkClaude(), codex: checkCodex() };
|
|
92
|
+
var result = {};
|
|
93
|
+
registry.list().forEach(function(vendor) {
|
|
94
|
+
result[vendor.id] = !!vendor.checkAuth();
|
|
95
|
+
});
|
|
96
|
+
_authCache = result;
|
|
185
97
|
logAuthCheck(_authCache);
|
|
186
98
|
return _authCache;
|
|
187
99
|
}
|
|
@@ -189,59 +101,49 @@ function checkAuth() {
|
|
|
189
101
|
/**
|
|
190
102
|
* Check which vendor binaries are installed (regardless of auth status).
|
|
191
103
|
*
|
|
192
|
-
* Result is cached at module scope because the check runs
|
|
193
|
-
*
|
|
194
|
-
* startup. With N projects
|
|
195
|
-
* caching collapses it to
|
|
196
|
-
* the auth cache (via invalidateAuthCache) since "just installed" is
|
|
197
|
-
* same situation as "just logged in" from the daemon's perspective.
|
|
104
|
+
* Result is cached at module scope because the check runs a subprocess per
|
|
105
|
+
* vendor per invocation and is triggered once per project context on daemon
|
|
106
|
+
* startup. With N projects that would cost N times the vendors synchronous
|
|
107
|
+
* subprocesses; caching collapses it to one pass. The cache is invalidated
|
|
108
|
+
* alongside the auth cache (via invalidateAuthCache) since "just installed" is
|
|
109
|
+
* the same situation as "just logged in" from the daemon's perspective.
|
|
198
110
|
*/
|
|
199
111
|
var _installedCache = null;
|
|
200
112
|
|
|
201
113
|
function checkInstalled() {
|
|
202
114
|
if (_installedCache) return _installedCache;
|
|
203
115
|
|
|
204
|
-
var
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
try {
|
|
208
|
-
if (process.platform === "win32") execFileSync("where", ["claude"], { timeout: 3000, stdio: ["pipe", "pipe", "pipe"] });
|
|
209
|
-
else execFileSync("which", ["claude"], { timeout: 3000, stdio: ["pipe", "pipe", "pipe"] });
|
|
210
|
-
result.claude = true;
|
|
211
|
-
} catch (e) {}
|
|
212
|
-
try {
|
|
213
|
-
var codexBin = null;
|
|
214
|
-
try {
|
|
215
|
-
var findCodexPath = require("./codex-app-server").findCodexPath;
|
|
216
|
-
codexBin = findCodexPath();
|
|
217
|
-
if (codexBin && fs.existsSync(codexBin)) {
|
|
218
|
-
result.codex = true;
|
|
219
|
-
_installedCache = result;
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
} catch (e) {}
|
|
223
|
-
|
|
224
|
-
var whichOut = process.platform === "win32"
|
|
225
|
-
? execFileSync("where", ["codex"], { timeout: 3000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] })
|
|
226
|
-
: execFileSync("which", ["codex"], { timeout: 3000, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
227
|
-
if (whichOut.trim()) result.codex = true;
|
|
228
|
-
} catch (e) {}
|
|
116
|
+
var installedIds = installProbe.detectInstalledVendors(null);
|
|
117
|
+
var result = {};
|
|
118
|
+
registry.ids().forEach(function(id) { result[id] = installedIds.indexOf(id) !== -1; });
|
|
229
119
|
_installedCache = result;
|
|
230
120
|
return result;
|
|
231
121
|
}
|
|
232
122
|
|
|
123
|
+
// Installed, and not ruled out by per-user OS isolation. An agent that does not
|
|
124
|
+
// support that mode is never created while it is on, whatever its install state:
|
|
125
|
+
// the cached install check above is not per mode.
|
|
126
|
+
function isUsable(installed, vendorId, osUsers) {
|
|
127
|
+
return !!installed[vendorId] && !registry.disabledByOsUsers(vendorId, osUsers);
|
|
128
|
+
}
|
|
129
|
+
|
|
233
130
|
function invalidateAuthCache() {
|
|
234
131
|
_authCache = null;
|
|
235
132
|
_installedCache = null;
|
|
133
|
+
// A probe may remember what it found (a resolved binary and its version).
|
|
134
|
+
registry.list().forEach(function(vendor) {
|
|
135
|
+
if (typeof vendor.recheck === "function") vendor.recheck();
|
|
136
|
+
});
|
|
236
137
|
}
|
|
237
138
|
|
|
238
139
|
/**
|
|
239
|
-
* Create adapters for all
|
|
240
|
-
*
|
|
241
|
-
*
|
|
140
|
+
* Create adapters for all installed vendors.
|
|
141
|
+
* A vendor whose runtime is per project (the perProjectRuntime trait: its
|
|
142
|
+
* app-server and bridge stay scoped to one project slug) is instantiated per
|
|
143
|
+
* project; the others are shared across projects.
|
|
242
144
|
* Returns { adapters: { vendor: Adapter }, auth: { vendor: boolean } }
|
|
243
145
|
*/
|
|
244
|
-
var
|
|
146
|
+
var _sharedAdapters = {};
|
|
245
147
|
|
|
246
148
|
function createAdapters(opts) {
|
|
247
149
|
opts = opts || {};
|
|
@@ -250,31 +152,27 @@ function createAdapters(opts) {
|
|
|
250
152
|
// that `claude auth status` does not always detect. Runtime auth failures are
|
|
251
153
|
// handled downstream via query-level error detection.
|
|
252
154
|
var installed = checkInstalled();
|
|
253
|
-
var auth = {
|
|
155
|
+
var auth = {};
|
|
254
156
|
var adapters = {};
|
|
255
157
|
|
|
256
|
-
|
|
158
|
+
registry.list().forEach(function(vendor) {
|
|
159
|
+
auth[vendor.id] = false;
|
|
160
|
+
if (!isUsable(installed, vendor.id, opts.osUsers)) return;
|
|
257
161
|
try {
|
|
258
|
-
if (
|
|
259
|
-
|
|
162
|
+
if (vendor.perProjectRuntime) {
|
|
163
|
+
adapters[vendor.id] = createAdapter({ vendor: vendor.id, cwd: opts.cwd, slug: opts.slug, osUsers: !!opts.osUsers });
|
|
164
|
+
} else {
|
|
165
|
+
if (!_sharedAdapters[vendor.id]) {
|
|
166
|
+
_sharedAdapters[vendor.id] = createAdapter({ vendor: vendor.id, cwd: opts.cwd });
|
|
167
|
+
}
|
|
168
|
+
adapters[vendor.id] = _sharedAdapters[vendor.id];
|
|
260
169
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
console.log("[yoke] Adapter created: claude");
|
|
170
|
+
auth[vendor.id] = true;
|
|
171
|
+
console.log("[yoke] Adapter created: " + vendor.id);
|
|
264
172
|
} catch (e) {
|
|
265
|
-
console.error("[yoke] Failed to create adapter for
|
|
173
|
+
console.error("[yoke] Failed to create adapter for " + vendor.id + ":", e.message);
|
|
266
174
|
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (installed.codex) {
|
|
270
|
-
try {
|
|
271
|
-
adapters.codex = createAdapter({ vendor: "codex", cwd: opts.cwd, slug: opts.slug });
|
|
272
|
-
auth.codex = true;
|
|
273
|
-
console.log("[yoke] Adapter created: codex");
|
|
274
|
-
} catch (e) {
|
|
275
|
-
console.error("[yoke] Failed to create adapter for codex:", e.message);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
175
|
+
});
|
|
278
176
|
|
|
279
177
|
return { adapters: adapters, auth: auth };
|
|
280
178
|
}
|
|
@@ -283,19 +181,24 @@ function createAdapters(opts) {
|
|
|
283
181
|
* Lazy-create an adapter for a vendor that wasn't available at startup.
|
|
284
182
|
* Re-checks auth, creates adapter if now logged in.
|
|
285
183
|
* Returns the adapter or null.
|
|
184
|
+
*
|
|
185
|
+
* onInit, when given, is called with what the adapter's init() resolved with
|
|
186
|
+
* (its models and the capabilities the live session advertises), so the caller
|
|
187
|
+
* records them: the init result is the only place those are reported.
|
|
286
188
|
*/
|
|
287
|
-
async function lazyCreateAdapter(adapters, vendor, opts) {
|
|
189
|
+
async function lazyCreateAdapter(adapters, vendor, opts, onInit) {
|
|
288
190
|
opts = opts || {};
|
|
289
191
|
|
|
290
192
|
// Force re-check since user may have logged in after server start
|
|
291
193
|
invalidateAuthCache();
|
|
292
194
|
var installed = checkInstalled();
|
|
293
|
-
if (!installed
|
|
195
|
+
if (!isUsable(installed, vendor, opts.osUsers)) return null;
|
|
294
196
|
|
|
295
197
|
try {
|
|
296
|
-
var ad = createAdapter({ vendor: vendor, cwd: opts.cwd, slug: opts.slug });
|
|
198
|
+
var ad = createAdapter({ vendor: vendor, cwd: opts.cwd, slug: opts.slug, osUsers: !!opts.osUsers });
|
|
297
199
|
if (typeof ad.init === "function") {
|
|
298
|
-
await ad.init(opts || {});
|
|
200
|
+
var initResult = await ad.init(opts || {});
|
|
201
|
+
if (typeof onInit === "function") onInit(initResult);
|
|
299
202
|
}
|
|
300
203
|
console.log("[yoke] Lazy adapter created: " + vendor);
|
|
301
204
|
adapters[vendor] = ad;
|
|
@@ -307,6 +210,12 @@ async function lazyCreateAdapter(adapters, vendor, opts) {
|
|
|
307
210
|
}
|
|
308
211
|
|
|
309
212
|
module.exports = {
|
|
213
|
+
isKnownVendor: isKnownVendor,
|
|
214
|
+
registry: registry,
|
|
215
|
+
resolveCapabilities: capabilities.resolveCapabilities,
|
|
216
|
+
completeCapabilities: iface.completeCapabilities,
|
|
217
|
+
detectInstalledVendors: installProbe.detectInstalledVendors,
|
|
218
|
+
detectVendorInstallState: installProbe.detectVendorInstallState,
|
|
310
219
|
createAdapter: createAdapter,
|
|
311
220
|
createAdapters: createAdapters,
|
|
312
221
|
lazyCreateAdapter: lazyCreateAdapter,
|
|
@@ -315,6 +224,7 @@ module.exports = {
|
|
|
315
224
|
invalidateAuthCache: invalidateAuthCache,
|
|
316
225
|
INTERFACE_VERSION: iface.INTERFACE_VERSION,
|
|
317
226
|
TOOL_POLICIES: iface.TOOL_POLICIES,
|
|
227
|
+
CAPABILITIES: iface.CAPABILITIES,
|
|
318
228
|
DIAGNOSTIC_SEVERITIES: iface.DIAGNOSTIC_SEVERITIES,
|
|
319
229
|
DIAGNOSTIC_SOURCES: iface.DIAGNOSTIC_SOURCES,
|
|
320
230
|
validateAdapter: iface.validateAdapter,
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// install-probe.js - finds out which registered agents are installed, for the
|
|
2
|
+
// daemon's own user or for a specific OS user. Every executable name looked up
|
|
3
|
+
// must belong to a registered vendor (registry.binaryNames): the name reaches
|
|
4
|
+
// a shell command for the OS-user case, so an unregistered name is refused with
|
|
5
|
+
// a named error instead of being passed on.
|
|
6
|
+
//
|
|
7
|
+
// A lookup has three outcomes, never two: found, not installed, or the lookup
|
|
8
|
+
// itself failed (timeout, permission, su or which unusable). A failed lookup
|
|
9
|
+
// is reported as such so the picker can say it could not check, instead of
|
|
10
|
+
// telling the user an installed agent is missing.
|
|
11
|
+
|
|
12
|
+
var execFileSync = require("child_process").execFileSync;
|
|
13
|
+
var registry = require("./registry");
|
|
14
|
+
|
|
15
|
+
var LOOKUP_TIMEOUT_MS = 3000;
|
|
16
|
+
var PROBE_FAILED_CODE = "YOKE_PROBE_FAILED";
|
|
17
|
+
|
|
18
|
+
function ProbeFailedError(probeClass, cause) {
|
|
19
|
+
var err = new Error("[YOKE] Install lookup failed: " + probeClass + (cause && cause.message ? " (" + cause.message + ")" : ""));
|
|
20
|
+
err.code = PROBE_FAILED_CODE;
|
|
21
|
+
err.probeClass = probeClass;
|
|
22
|
+
return err;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Names why a lookup command did not succeed.
|
|
27
|
+
* @param {Error} e what execFileSync threw
|
|
28
|
+
* @param {boolean} asUser the lookup ran through su
|
|
29
|
+
* @returns {?string} null when the command ran and found nothing, otherwise
|
|
30
|
+
* the failure class
|
|
31
|
+
*/
|
|
32
|
+
function classifyLookupFailure(e, asUser) {
|
|
33
|
+
if (e && (e.code === "ETIMEDOUT" || e.killed || e.signal)) return "timeout";
|
|
34
|
+
if (e && (e.code === "EACCES" || e.code === "EPERM")) return "permission-denied";
|
|
35
|
+
if (e && e.code === "ENOENT") return asUser ? "su-unavailable" : "lookup-tool-missing";
|
|
36
|
+
var stderr = e && e.stderr ? String(e.stderr).trim() : "";
|
|
37
|
+
// which exits 1 and prints nothing when the name is not on PATH. Output on
|
|
38
|
+
// stderr with that exit is su (or the shell) failing, not the name missing.
|
|
39
|
+
if (e && e.status === 1 && !stderr) return null;
|
|
40
|
+
return asUser ? "su-failed" : "lookup-failed";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Outcome of looking up one registered executable.
|
|
45
|
+
* @param {string} name must be a registered binary name
|
|
46
|
+
* @param {?string} linuxUser look it up as this OS user instead
|
|
47
|
+
* @returns {{state: "found", path: string}|{state: "missing"}|{state: "failed", probeClass: string}}
|
|
48
|
+
*/
|
|
49
|
+
function probeBinary(name, linuxUser) {
|
|
50
|
+
registry.assertAllowedBinary(name);
|
|
51
|
+
var options = { timeout: LOOKUP_TIMEOUT_MS, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] };
|
|
52
|
+
try {
|
|
53
|
+
var out;
|
|
54
|
+
if (linuxUser) {
|
|
55
|
+
out = execFileSync("su", ["-", linuxUser, "-c", "which " + name], options);
|
|
56
|
+
} else if (process.platform === "win32") {
|
|
57
|
+
out = execFileSync("where", [name], options);
|
|
58
|
+
} else {
|
|
59
|
+
out = execFileSync("which", [name], options);
|
|
60
|
+
}
|
|
61
|
+
return { state: "found", path: String(out).trim().split(/\r?\n/)[0] };
|
|
62
|
+
} catch (e) {
|
|
63
|
+
var probeClass = classifyLookupFailure(e, !!linuxUser);
|
|
64
|
+
return probeClass ? { state: "failed", probeClass: probeClass } : { state: "missing" };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Path of a registered executable on PATH, or null when it was not found or
|
|
70
|
+
* the lookup failed. Callers that must tell the two apart use probeBinary.
|
|
71
|
+
* @param {string} name must be a registered binary name
|
|
72
|
+
* @param {?string} linuxUser look it up as this OS user instead
|
|
73
|
+
*/
|
|
74
|
+
function findBinaryPath(name, linuxUser) {
|
|
75
|
+
var result = probeBinary(name, linuxUser);
|
|
76
|
+
return result.state === "found" ? result.path : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Which registered vendors are installed, and which could not be checked.
|
|
81
|
+
* @param {?string} linuxUser
|
|
82
|
+
* @param {{osUsers: ?boolean}} [options] osUsers: per-user OS isolation is on;
|
|
83
|
+
* an agent that does not support it is reported not installed, with the
|
|
84
|
+
* reason, and its probe is not run
|
|
85
|
+
* @returns {{installed: string[], failures: Object<string, string>, details: object}}
|
|
86
|
+
* failures maps a vendor id to the class of the lookup failure
|
|
87
|
+
*/
|
|
88
|
+
function detectVendorInstallState(linuxUser, options) {
|
|
89
|
+
var installed = [];
|
|
90
|
+
var failures = {};
|
|
91
|
+
var details = {};
|
|
92
|
+
var osUsers = !!(options && options.osUsers);
|
|
93
|
+
registry.list().forEach(function (vendor) {
|
|
94
|
+
if (registry.disabledByOsUsers(vendor.id, osUsers)) {
|
|
95
|
+
details[vendor.id] = { path: null, version: null, source: null, reason: registry.osUsersReasonFor(vendor.id) };
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
var outcome = vendor.probeInstalled({
|
|
100
|
+
linuxUser: linuxUser || null,
|
|
101
|
+
lookupBinary: function (name) {
|
|
102
|
+
var result = probeBinary(name, linuxUser);
|
|
103
|
+
if (result.state === "failed") throw ProbeFailedError(result.probeClass);
|
|
104
|
+
return result.state === "found";
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
// A probe answers with whether the agent is installed, or with that and
|
|
108
|
+
// what it found (path, version) or why it is not usable.
|
|
109
|
+
var found = outcome && typeof outcome === "object" ? outcome.installed : outcome;
|
|
110
|
+
if (outcome && typeof outcome === "object" && outcome.detail) details[vendor.id] = outcome.detail;
|
|
111
|
+
if (found) installed.push(vendor.id);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
if (!e || e.code !== PROBE_FAILED_CODE) throw e;
|
|
114
|
+
failures[vendor.id] = e.probeClass;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return { installed: installed, failures: failures, details: details };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Ids of the registered vendors that are installed.
|
|
122
|
+
* @param {?string} linuxUser
|
|
123
|
+
* @param {{osUsers: ?boolean}} [options]
|
|
124
|
+
* @returns {string[]}
|
|
125
|
+
*/
|
|
126
|
+
function detectInstalledVendors(linuxUser, options) {
|
|
127
|
+
return detectVendorInstallState(linuxUser, options).installed;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = {
|
|
131
|
+
classifyLookupFailure: classifyLookupFailure,
|
|
132
|
+
probeBinary: probeBinary,
|
|
133
|
+
findBinaryPath: findBinaryPath,
|
|
134
|
+
detectVendorInstallState: detectVendorInstallState,
|
|
135
|
+
detectInstalledVendors: detectInstalledVendors,
|
|
136
|
+
};
|
package/lib/yoke/instructions.js
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
// (CLAUDE.md, AGENTS.md, .cursorrules, etc.) and merges them into
|
|
5
5
|
// a single string that any adapter can inject as context.
|
|
6
6
|
//
|
|
7
|
-
// Each adapter declares which files its vendor
|
|
8
|
-
// those are excluded from the merged output (no
|
|
7
|
+
// Each adapter declares (in its registered descriptor) which files its vendor
|
|
8
|
+
// reads natively so those are excluded from the merged output (no
|
|
9
|
+
// double-injection).
|
|
9
10
|
|
|
10
11
|
var fs = require("fs");
|
|
11
12
|
var path = require("path");
|
|
13
|
+
var registry = require("./registry");
|
|
12
14
|
|
|
13
15
|
// Known instruction files in priority order.
|
|
14
16
|
// { file: relative path, label: human-readable label }
|
|
@@ -20,20 +22,15 @@ var KNOWN_FILES = [
|
|
|
20
22
|
{ file: "COPILOT.md", label: "COPILOT.md" },
|
|
21
23
|
];
|
|
22
24
|
|
|
23
|
-
// Files each vendor reads natively (skip these to avoid duplication).
|
|
24
|
-
var NATIVE_FILES = {
|
|
25
|
-
claude: ["CLAUDE.md"],
|
|
26
|
-
codex: ["AGENTS.md"],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
25
|
// Scan projectDir for instruction files and return merged text.
|
|
30
|
-
// Excludes files the given vendor
|
|
26
|
+
// Excludes the files the given vendor reads natively (its registered
|
|
27
|
+
// nativeInstructionFiles); a vendor that is not registered reads none.
|
|
31
28
|
//
|
|
32
29
|
// Returns "" if no files found (callers can skip injection).
|
|
33
30
|
function scanAndMerge(projectDir, vendor) {
|
|
34
31
|
if (!projectDir) return "";
|
|
35
32
|
|
|
36
|
-
var exclude =
|
|
33
|
+
var exclude = registry.isKnown(vendor) ? registry.get(vendor).nativeInstructionFiles : [];
|
|
37
34
|
var sections = [];
|
|
38
35
|
|
|
39
36
|
for (var i = 0; i < KNOWN_FILES.length; i++) {
|
|
@@ -57,5 +54,4 @@ function scanAndMerge(projectDir, vendor) {
|
|
|
57
54
|
module.exports = {
|
|
58
55
|
scanAndMerge: scanAndMerge,
|
|
59
56
|
KNOWN_FILES: KNOWN_FILES,
|
|
60
|
-
NATIVE_FILES: NATIVE_FILES,
|
|
61
57
|
};
|