@clagentic/console 1.9.0 → 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
package/lib/yoke/interface.js
CHANGED
|
@@ -14,6 +14,22 @@
|
|
|
14
14
|
// Added: 'diagnostic' event type (DIAGNOSTIC_SEVERITIES, DIAGNOSTIC_SOURCES,
|
|
15
15
|
// validateDiagnosticEvent). Existing consumers are unaffected — no existing
|
|
16
16
|
// shape was narrowed or removed.
|
|
17
|
+
//
|
|
18
|
+
// 0.2.0 → 0.3.0 (2026-10, additive plus one tightening)
|
|
19
|
+
// Added: the capability ledger (CAPABILITIES, resolveCapabilities), the
|
|
20
|
+
// vendor registry that carries each adapter's declaration (registry.js), and
|
|
21
|
+
// the optional adapter / query-handle surface the console already consumed
|
|
22
|
+
// off-contract (ADAPTER_OPTIONAL_METHODS, QUERY_HANDLE_OPTIONAL_METHODS).
|
|
23
|
+
// Removed from the contract: nothing.
|
|
24
|
+
// Tightened: endInput joins QUERY_HANDLE_METHODS, since the console ends the
|
|
25
|
+
// input of every query it finishes and both shipped adapters implement it.
|
|
26
|
+
//
|
|
27
|
+
// 0.3.0 → 0.4.0 (2026-10, breaking for descriptors)
|
|
28
|
+
// Moved: perProjectRuntime, activityTokens and attestsHumanSessions leave the
|
|
29
|
+
// capability ledger and become descriptor traits (TRAITS). They describe how
|
|
30
|
+
// the console drives an adapter, not what a session negotiates, so they are
|
|
31
|
+
// never resolved, narrowed or overridden. A descriptor that still declares
|
|
32
|
+
// one as a capability is refused with a named error.
|
|
17
33
|
|
|
18
34
|
/**
|
|
19
35
|
* YOKE contract version. Bumped on every additive or breaking change.
|
|
@@ -24,8 +40,10 @@
|
|
|
24
40
|
* History:
|
|
25
41
|
* 0.1.0 — initial contract (Adapter + QueryHandle shapes)
|
|
26
42
|
* 0.2.0 — added 'diagnostic' event type (lr-8c43)
|
|
43
|
+
* 0.3.0 — capability ledger, vendor registry, reconciled method lists
|
|
44
|
+
* 0.4.0 — adapter traits split out of the capability ledger
|
|
27
45
|
*/
|
|
28
|
-
var INTERFACE_VERSION = "0.
|
|
46
|
+
var INTERFACE_VERSION = "0.4.0";
|
|
29
47
|
|
|
30
48
|
var TOOL_POLICIES = ["ask", "allow-all"];
|
|
31
49
|
|
|
@@ -36,7 +54,9 @@ var TOOL_POLICIES = ["ask", "allow-all"];
|
|
|
36
54
|
* Adapter shape:
|
|
37
55
|
* .vendor : string - e.g. "claude", "opencode", "codex"
|
|
38
56
|
* .init(opts) : Promise<InitResult>
|
|
39
|
-
* .supportedModels(): Promise<string[]>
|
|
57
|
+
* .supportedModels(opts): Promise<string[]> - opts.runtimeEnv (the Settings
|
|
58
|
+
* overlay, or null for none) is required by an adapter that keeps a server
|
|
59
|
+
* per environment (Codex); the list is that server's own
|
|
40
60
|
* .createToolServer(def): ToolServer (opaque)
|
|
41
61
|
* .createQuery(opts): QueryHandle
|
|
42
62
|
*
|
|
@@ -56,12 +76,24 @@ var TOOL_POLICIES = ["ask", "allow-all"];
|
|
|
56
76
|
* [Symbol.asyncIterator]() - yields SDK events (raw in Phase 3, normalized later)
|
|
57
77
|
* .pushMessage(text, images)
|
|
58
78
|
* .setModel(model)
|
|
59
|
-
* .setEffort(effort)
|
|
79
|
+
* .setEffort(effort) - Promise; settles once the running query has
|
|
80
|
+
* taken the change and rejects (with a message
|
|
81
|
+
* fit to show the operator) when it did not. The
|
|
82
|
+
* Claude SDK's Query has no setEffort: the Claude
|
|
83
|
+
* adapter applies it through applyFlagSettings
|
|
84
|
+
* ({effortLevel}); Codex reads it on the next turn.
|
|
60
85
|
* .setToolPolicy(policy) - "ask" | "allow-all"
|
|
61
86
|
* .stopTask(taskId)
|
|
62
87
|
* .getContextUsage() - Promise<object|null>
|
|
63
88
|
* .abort()
|
|
64
89
|
* .close()
|
|
90
|
+
* .endInput() - no more messages will be pushed to this query
|
|
91
|
+
*
|
|
92
|
+
* Each adapter also registers a vendor descriptor with registry.js (from a
|
|
93
|
+
* small adapters/<name>-vendor.js module, so listing the agents does not load
|
|
94
|
+
* the adapter): its id, display metadata, install probe, login command, environment needs
|
|
95
|
+
* and its declared capabilities (CAPABILITIES below). The adapter factory is
|
|
96
|
+
* part of that descriptor; nothing else in the console names a vendor.
|
|
65
97
|
*/
|
|
66
98
|
|
|
67
99
|
var ADAPTER_METHODS = [
|
|
@@ -80,8 +112,163 @@ var QUERY_HANDLE_METHODS = [
|
|
|
80
112
|
"getContextUsage",
|
|
81
113
|
"abort",
|
|
82
114
|
"close",
|
|
115
|
+
"endInput",
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Methods the console calls on a query handle only when the adapter's
|
|
120
|
+
* declared capabilities say it can use them. A caller checks the capability
|
|
121
|
+
* (or the method) first; absence is not an error.
|
|
122
|
+
* .setPermissionMode(mode) - capability permissionModes
|
|
123
|
+
* .rewindFiles(uuid, opts) - capability rewind
|
|
124
|
+
*/
|
|
125
|
+
var QUERY_HANDLE_OPTIONAL_METHODS = [
|
|
126
|
+
"setPermissionMode",
|
|
127
|
+
"rewindFiles",
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Adapter methods and properties the console uses beyond ADAPTER_METHODS.
|
|
132
|
+
* Optional: the console feature behind each is gated by a capability.
|
|
133
|
+
* .generateTitle(messages, opts) - session titles
|
|
134
|
+
* .getSessionInfo / .listSessions / .renameSession - capabilities
|
|
135
|
+
* sessionList, sessionRename
|
|
136
|
+
* .forkSession(sessionId, opts) - capability fork
|
|
137
|
+
* .rollbackThread(threadId, n, opts) - capability rollback
|
|
138
|
+
* .shutdown() - trait perProjectRuntime
|
|
139
|
+
* .shutdownIfIdle(idleMs) - idle runtime reclaim
|
|
140
|
+
* .workerScriptPath - OS-user isolation worker (string)
|
|
141
|
+
* .interfaceVersion - the INTERFACE_VERSION it was built for
|
|
142
|
+
* init() resolves with { models, defaultModel, skills, slashCommands,
|
|
143
|
+
* capabilities }; the capabilities member is the live session's advertised
|
|
144
|
+
* capabilities, which can only narrow the declaration (resolveCapabilities).
|
|
145
|
+
*/
|
|
146
|
+
var ADAPTER_OPTIONAL_METHODS = [
|
|
147
|
+
"generateTitle",
|
|
148
|
+
"getSessionInfo",
|
|
149
|
+
"listSessions",
|
|
150
|
+
"renameSession",
|
|
151
|
+
"forkSession",
|
|
152
|
+
"rollbackThread",
|
|
153
|
+
"shutdown",
|
|
154
|
+
"shutdownIfIdle",
|
|
83
155
|
];
|
|
84
156
|
|
|
157
|
+
/**
|
|
158
|
+
* The capability ledger: the one list of what an agent can do, and so the one
|
|
159
|
+
* list the UI gates on. A control is shown, disabled or hidden from these keys,
|
|
160
|
+
* never from a vendor name. Every key is declared by every adapter (an absent
|
|
161
|
+
* flag is false, an absent list is empty).
|
|
162
|
+
*
|
|
163
|
+
* kind "flag" - boolean
|
|
164
|
+
* kind "list" - array of strings; narrowing intersects, overriding replaces
|
|
165
|
+
* reason - the one line shown beside a control that is disabled
|
|
166
|
+
* because the agent lacks the capability
|
|
167
|
+
*/
|
|
168
|
+
var CAPABILITIES = {
|
|
169
|
+
thinking: { kind: "flag", reason: "This agent has no extended thinking control." },
|
|
170
|
+
betas: { kind: "flag", reason: "This agent has no beta feature switches." },
|
|
171
|
+
effort: { kind: "flag", reason: "This agent does not take a reasoning effort setting." },
|
|
172
|
+
rewind: { kind: "flag", reason: "This agent cannot rewind file changes to an earlier message." },
|
|
173
|
+
fork: { kind: "flag", reason: "This agent cannot fork a conversation at a message." },
|
|
174
|
+
rollback: { kind: "flag", reason: "This agent cannot roll a conversation back." },
|
|
175
|
+
sessionResume: { kind: "flag", reason: "This agent cannot resume a previous session." },
|
|
176
|
+
sessionList: { kind: "flag", reason: "This agent cannot list its own sessions." },
|
|
177
|
+
sessionRename: { kind: "flag", reason: "This agent cannot rename its own sessions." },
|
|
178
|
+
sessionArchive: { kind: "flag", reason: "This agent cannot archive its own sessions." },
|
|
179
|
+
promptSuggestions: { kind: "flag", reason: "This agent does not suggest follow-up prompts." },
|
|
180
|
+
elicitation: { kind: "flag", reason: "This agent cannot ask for structured input mid-turn." },
|
|
181
|
+
fileCheckpointing: { kind: "flag", reason: "This agent does not checkpoint file changes." },
|
|
182
|
+
contextCompacting: { kind: "flag", reason: "This agent cannot compact its context." },
|
|
183
|
+
mcpPanel: { kind: "flag", reason: "This agent does not use the MCP servers managed here." },
|
|
184
|
+
backgroundTasks: { kind: "flag", reason: "This agent has no background tasks." },
|
|
185
|
+
steering: { kind: "flag", reason: "This agent cannot take a message while it is working." },
|
|
186
|
+
agentInjection: { kind: "flag", reason: "This agent cannot take on a named agent identity." },
|
|
187
|
+
executionPolicy: { kind: "flag", reason: "This agent has no approval, sandbox or web search settings." },
|
|
188
|
+
toolPolicy: { kind: "list", reason: "This agent has no tool approval policy." },
|
|
189
|
+
permissionModes: { kind: "list", reason: "This agent has no permission modes." },
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var CAPABILITY_KEYS = Object.keys(CAPABILITIES);
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Adapter traits: booleans on the vendor descriptor describing how the console
|
|
196
|
+
* drives the adapter. Unlike a capability, a trait is a fact about the adapter
|
|
197
|
+
* itself, read where no session exists yet (adapter creation) or where the
|
|
198
|
+
* answer must not change with a connection (shutdown, activity bookkeeping).
|
|
199
|
+
* A trait is never resolved, narrowed or overridden. An absent trait is false.
|
|
200
|
+
*
|
|
201
|
+
* perProjectRuntime - the adapter's runtime belongs to one project and is
|
|
202
|
+
* created and shut down with it
|
|
203
|
+
* activityTokens - the adapter's tool and thinking blocks are tracked as
|
|
204
|
+
* activity tokens by the console
|
|
205
|
+
* attestsHumanSessions - the adapter's sessions are attested as human-driven
|
|
206
|
+
* by the console rather than by the adapter
|
|
207
|
+
*/
|
|
208
|
+
var TRAITS = {
|
|
209
|
+
perProjectRuntime: true,
|
|
210
|
+
activityTokens: true,
|
|
211
|
+
attestsHumanSessions: true,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
var TRAIT_KEYS = Object.keys(TRAITS);
|
|
215
|
+
|
|
216
|
+
function isTraitKey(key) {
|
|
217
|
+
return Object.prototype.hasOwnProperty.call(TRAITS, key);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function isCapabilityKey(key) {
|
|
221
|
+
return Object.prototype.hasOwnProperty.call(CAPABILITIES, key);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Checks a capability object (a declaration, an override or an advertisement)
|
|
226
|
+
* and throws a named error for a key outside the ledger or a value of the
|
|
227
|
+
* wrong kind. Keys it does not carry are simply absent.
|
|
228
|
+
*
|
|
229
|
+
* @param {object} caps
|
|
230
|
+
* @param {string} where what is being checked, for the message
|
|
231
|
+
* @param {{ignoreUnknown: boolean}} [options] skip keys outside the ledger
|
|
232
|
+
* (a live session may advertise more than the ledger names)
|
|
233
|
+
*/
|
|
234
|
+
function validateCapabilities(caps, where, options) {
|
|
235
|
+
if (!caps || typeof caps !== "object" || Array.isArray(caps)) {
|
|
236
|
+
throw new Error("[YOKE] " + where + " capabilities must be an object");
|
|
237
|
+
}
|
|
238
|
+
var ignoreUnknown = !!(options && options.ignoreUnknown);
|
|
239
|
+
Object.keys(caps).forEach(function (key) {
|
|
240
|
+
if (!isCapabilityKey(key)) {
|
|
241
|
+
if (ignoreUnknown) return;
|
|
242
|
+
if (isTraitKey(key)) {
|
|
243
|
+
throw new Error("[YOKE] " + where + " names '" + key + "' as a capability; it is an adapter trait set on the descriptor");
|
|
244
|
+
}
|
|
245
|
+
throw new Error("[YOKE] " + where + " names an unknown capability: " + key);
|
|
246
|
+
}
|
|
247
|
+
var kind = CAPABILITIES[key].kind;
|
|
248
|
+
var value = caps[key];
|
|
249
|
+
if (kind === "flag" && typeof value !== "boolean") {
|
|
250
|
+
throw new Error("[YOKE] " + where + " capability '" + key + "' must be a boolean");
|
|
251
|
+
}
|
|
252
|
+
if (kind === "list" && (!Array.isArray(value) || value.some(function (v) { return typeof v !== "string"; }))) {
|
|
253
|
+
throw new Error("[YOKE] " + where + " capability '" + key + "' must be an array of strings");
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* A declaration with every ledger key present: absent flags are false, absent
|
|
260
|
+
* lists are empty. The result is a copy.
|
|
261
|
+
*/
|
|
262
|
+
function completeCapabilities(caps) {
|
|
263
|
+
var out = {};
|
|
264
|
+
CAPABILITY_KEYS.forEach(function (key) {
|
|
265
|
+
var has = caps && Object.prototype.hasOwnProperty.call(caps, key);
|
|
266
|
+
if (CAPABILITIES[key].kind === "list") out[key] = has ? caps[key].slice() : [];
|
|
267
|
+
else out[key] = has ? !!caps[key] : false;
|
|
268
|
+
});
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
|
|
85
272
|
/**
|
|
86
273
|
* 'diagnostic' event type — vendor-agnostic signal for CLI-surfaced warnings,
|
|
87
274
|
* validation failures, deprecations, and load errors that adapters capture
|
|
@@ -189,6 +376,15 @@ module.exports = {
|
|
|
189
376
|
TOOL_POLICIES: TOOL_POLICIES,
|
|
190
377
|
ADAPTER_METHODS: ADAPTER_METHODS,
|
|
191
378
|
QUERY_HANDLE_METHODS: QUERY_HANDLE_METHODS,
|
|
379
|
+
QUERY_HANDLE_OPTIONAL_METHODS: QUERY_HANDLE_OPTIONAL_METHODS,
|
|
380
|
+
ADAPTER_OPTIONAL_METHODS: ADAPTER_OPTIONAL_METHODS,
|
|
381
|
+
CAPABILITIES: CAPABILITIES,
|
|
382
|
+
CAPABILITY_KEYS: CAPABILITY_KEYS,
|
|
383
|
+
isCapabilityKey: isCapabilityKey,
|
|
384
|
+
TRAIT_KEYS: TRAIT_KEYS,
|
|
385
|
+
isTraitKey: isTraitKey,
|
|
386
|
+
validateCapabilities: validateCapabilities,
|
|
387
|
+
completeCapabilities: completeCapabilities,
|
|
192
388
|
DIAGNOSTIC_SEVERITIES: DIAGNOSTIC_SEVERITIES,
|
|
193
389
|
DIAGNOSTIC_SOURCES: DIAGNOSTIC_SOURCES,
|
|
194
390
|
validateAdapter: validateAdapter,
|
package/lib/yoke/package.json
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// provider-credentials.js - the cloud providers Claude Code can reach
|
|
2
|
+
// (Bedrock, Vertex, Foundry): the namespaces of environment variables each one
|
|
3
|
+
// reads, and the rule for when a provider counts as configured. The namespaces
|
|
4
|
+
// feed the vendor descriptor's owned prefixes, so a credential set is owned
|
|
5
|
+
// whole by namespace and an unlisted variable (AWS_ROLE_ARN, AWS_CA_BUNDLE,
|
|
6
|
+
// GOOGLE_CLOUD_PROJECT) is owned the same as a listed one.
|
|
7
|
+
|
|
8
|
+
var envOwnership = require("./env-ownership");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Credential sets that must each be owned whole (see registry.register). A
|
|
12
|
+
* group owns every variable under its prefixes plus its exact names.
|
|
13
|
+
*/
|
|
14
|
+
var CREDENTIAL_GROUPS = [
|
|
15
|
+
{ id: "bedrock", prefixes: ["AWS_"], envNames: ["CLAUDE_CODE_USE_BEDROCK"] },
|
|
16
|
+
{
|
|
17
|
+
id: "vertex",
|
|
18
|
+
prefixes: ["GOOGLE_", "GCLOUD_", "CLOUDSDK_", "CLOUD_ML_", "ANTHROPIC_VERTEX_"],
|
|
19
|
+
envNames: ["CLAUDE_CODE_USE_VERTEX"],
|
|
20
|
+
},
|
|
21
|
+
{ id: "foundry", prefixes: ["ANTHROPIC_FOUNDRY_"], envNames: ["CLAUDE_CODE_USE_FOUNDRY"] },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The one matcher: which credential group owns a variable name, or null.
|
|
26
|
+
* Owned-name resolution, the registry's whole-group check and every env cleanup
|
|
27
|
+
* go through this or through env-ownership.owns, never a name list.
|
|
28
|
+
* @param {string} name
|
|
29
|
+
* @returns {?string} the group id
|
|
30
|
+
*/
|
|
31
|
+
function groupOf(name) {
|
|
32
|
+
for (var i = 0; i < CREDENTIAL_GROUPS.length; i++) {
|
|
33
|
+
var group = CREDENTIAL_GROUPS[i];
|
|
34
|
+
if (envOwnership.owns({ names: group.envNames, prefixes: group.prefixes }, name)) return group.id;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Every namespace prefix of every group, without repeats. */
|
|
40
|
+
function allCredentialPrefixes() {
|
|
41
|
+
var out = [];
|
|
42
|
+
CREDENTIAL_GROUPS.forEach(function (group) {
|
|
43
|
+
group.prefixes.forEach(function (p) { if (out.indexOf(p) === -1) out.push(p); });
|
|
44
|
+
});
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Every exact name of every group, without repeats. */
|
|
49
|
+
function allCredentialNames() {
|
|
50
|
+
var out = [];
|
|
51
|
+
CREDENTIAL_GROUPS.forEach(function (group) {
|
|
52
|
+
group.envNames.forEach(function (n) { if (out.indexOf(n) === -1) out.push(n); });
|
|
53
|
+
});
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function has(env, name) {
|
|
58
|
+
return typeof env[name] === "string" && env[name] !== "";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Which cloud provider is selected AND carries a complete credential source,
|
|
63
|
+
* or null. A provider switched on with an incomplete set (an access key id
|
|
64
|
+
* without its secret, a project without credentials) is not authenticated: the
|
|
65
|
+
* caller falls through to the normal login probe.
|
|
66
|
+
* @param {object} env process.env-shaped
|
|
67
|
+
* @returns {?string} "bedrock" | "vertex" | "foundry" | null
|
|
68
|
+
*/
|
|
69
|
+
function completeProvider(env) {
|
|
70
|
+
if (env.CLAUDE_CODE_USE_BEDROCK === "1"
|
|
71
|
+
&& (has(env, "AWS_BEARER_TOKEN_BEDROCK")
|
|
72
|
+
|| has(env, "AWS_PROFILE")
|
|
73
|
+
|| (has(env, "AWS_ACCESS_KEY_ID") && has(env, "AWS_SECRET_ACCESS_KEY"))
|
|
74
|
+
|| (has(env, "AWS_ROLE_ARN") && has(env, "AWS_WEB_IDENTITY_TOKEN_FILE")))) {
|
|
75
|
+
return "bedrock";
|
|
76
|
+
}
|
|
77
|
+
if (env.CLAUDE_CODE_USE_VERTEX === "1"
|
|
78
|
+
&& has(env, "ANTHROPIC_VERTEX_PROJECT_ID")
|
|
79
|
+
&& has(env, "GOOGLE_APPLICATION_CREDENTIALS")) {
|
|
80
|
+
return "vertex";
|
|
81
|
+
}
|
|
82
|
+
if (env.CLAUDE_CODE_USE_FOUNDRY === "1"
|
|
83
|
+
&& has(env, "ANTHROPIC_FOUNDRY_API_KEY")
|
|
84
|
+
&& (has(env, "ANTHROPIC_FOUNDRY_RESOURCE") || has(env, "ANTHROPIC_FOUNDRY_BASE_URL"))) {
|
|
85
|
+
return "foundry";
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
CREDENTIAL_GROUPS: CREDENTIAL_GROUPS,
|
|
92
|
+
groupOf: groupOf,
|
|
93
|
+
completeProvider: completeProvider,
|
|
94
|
+
allCredentialPrefixes: allCredentialPrefixes,
|
|
95
|
+
allCredentialNames: allCredentialNames,
|
|
96
|
+
};
|