@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
package/lib/sessions.js
CHANGED
|
@@ -5,6 +5,7 @@ var utils = require("./utils");
|
|
|
5
5
|
var users = require("./users");
|
|
6
6
|
var { CODEX_DEFAULTS } = require("./codex-defaults");
|
|
7
7
|
var { isVisibleHistoryEvent } = require("./history-visibility");
|
|
8
|
+
var { createPromptRegistry } = require("./prompt-registry");
|
|
8
9
|
|
|
9
10
|
// lr-2ea2a7: hard cap on how many history entries a session may hold in the
|
|
10
11
|
// heap array, regardless of isProcessing state. On-disk JSONL remains the
|
|
@@ -94,7 +95,20 @@ function createSessionManager(opts) {
|
|
|
94
95
|
var slashCommands = null; // shared across sessions (deprecated, use slashCommandsByVendor)
|
|
95
96
|
var slashCommandsByVendor = {}; // vendor -> array of slash commands
|
|
96
97
|
var skillNames = null; // Claude-only skills to filter from slash menu
|
|
97
|
-
|
|
98
|
+
// requestId -> sessionLocalId (O(1) lookup). Keyed by ids that arrive from
|
|
99
|
+
// clients, so it has no prototype to answer for "constructor" or "__proto__".
|
|
100
|
+
var permissionRequestIndex = Object.create(null);
|
|
101
|
+
// Sole writer of every session's operator-prompt state; see
|
|
102
|
+
// lib/prompt-registry.js. Built before any session exists because
|
|
103
|
+
// construction itself may create and switch to one.
|
|
104
|
+
var prompts = createPromptRegistry({
|
|
105
|
+
index: permissionRequestIndex,
|
|
106
|
+
getSession: function (localId) { return sessions.get(localId) || null; },
|
|
107
|
+
sendAndRecord: function (session, obj) { return doSendAndRecord(session, obj); },
|
|
108
|
+
saveSessionFile: function (session) { return saveSessionFile(session); },
|
|
109
|
+
getNotificationsModule: opts.getNotificationsModule,
|
|
110
|
+
onProcessingChanged: opts.onProcessingChanged,
|
|
111
|
+
});
|
|
98
112
|
var capabilitiesByVendor = null; // set by sdk-bridge after adapter init
|
|
99
113
|
var defaultVendor = null; // set by sdk-bridge
|
|
100
114
|
var codexApproval = CODEX_DEFAULTS.approval;
|
|
@@ -717,8 +731,8 @@ function createSessionManager(opts) {
|
|
|
717
731
|
cliSessionId: m.cliSessionId,
|
|
718
732
|
blocks: {},
|
|
719
733
|
sentToolResults: {},
|
|
720
|
-
pendingPermissions:
|
|
721
|
-
pendingAskUser:
|
|
734
|
+
pendingPermissions: Object.create(null),
|
|
735
|
+
pendingAskUser: Object.create(null),
|
|
722
736
|
// Hydrate previously-granted "allow for session" tool decisions from
|
|
723
737
|
// durable state (lr-8b2e); default to {} only when none was saved so
|
|
724
738
|
// grants that were never given remain empty, not re-prompted.
|
|
@@ -863,9 +877,9 @@ function createSessionManager(opts) {
|
|
|
863
877
|
cliSessionId: null,
|
|
864
878
|
blocks: {},
|
|
865
879
|
sentToolResults: {},
|
|
866
|
-
pendingPermissions:
|
|
867
|
-
pendingAskUser:
|
|
868
|
-
allowedTools:
|
|
880
|
+
pendingPermissions: Object.create(null),
|
|
881
|
+
pendingAskUser: Object.create(null),
|
|
882
|
+
allowedTools: Object.create(null),
|
|
869
883
|
isProcessing: false,
|
|
870
884
|
title: "",
|
|
871
885
|
titleAutoGenerated: false,
|
|
@@ -898,9 +912,9 @@ function createSessionManager(opts) {
|
|
|
898
912
|
cliSessionId: null,
|
|
899
913
|
blocks: {},
|
|
900
914
|
sentToolResults: {},
|
|
901
|
-
pendingPermissions:
|
|
902
|
-
pendingAskUser:
|
|
903
|
-
allowedTools:
|
|
915
|
+
pendingPermissions: Object.create(null),
|
|
916
|
+
pendingAskUser: Object.create(null),
|
|
917
|
+
allowedTools: Object.create(null),
|
|
904
918
|
isProcessing: false,
|
|
905
919
|
title: "",
|
|
906
920
|
titleAutoGenerated: false,
|
|
@@ -1031,10 +1045,12 @@ function createSessionManager(opts) {
|
|
|
1031
1045
|
|
|
1032
1046
|
_send({ type: "history_meta", total: total, from: baseIndex + heapFrom });
|
|
1033
1047
|
|
|
1048
|
+
var annotatePrompt = prompts.replayAnnotator(session, session.history, heapFrom);
|
|
1034
1049
|
for (var i = heapFrom; i < heapLen; i++) {
|
|
1035
1050
|
var _item = session.history[i];
|
|
1036
1051
|
// Skip internal bookkeeping entries not meant for the UI
|
|
1037
1052
|
if (_item && _item.type === "digest_checkpoint") continue;
|
|
1053
|
+
_item = annotatePrompt(_item);
|
|
1038
1054
|
_send(transform ? transform(_item) : _item);
|
|
1039
1055
|
}
|
|
1040
1056
|
|
|
@@ -1129,19 +1145,8 @@ function createSessionManager(opts) {
|
|
|
1129
1145
|
_send({ type: "status", status: "processing" });
|
|
1130
1146
|
}
|
|
1131
1147
|
|
|
1132
|
-
// Re-
|
|
1133
|
-
|
|
1134
|
-
for (var i = 0; i < pendingIds.length; i++) {
|
|
1135
|
-
var p = session.pendingPermissions[pendingIds[i]];
|
|
1136
|
-
_send({
|
|
1137
|
-
type: "permission_request_pending",
|
|
1138
|
-
requestId: p.requestId,
|
|
1139
|
-
toolName: p.toolName,
|
|
1140
|
-
toolInput: p.toolInput,
|
|
1141
|
-
toolUseId: p.toolUseId,
|
|
1142
|
-
decisionReason: p.decisionReason,
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1148
|
+
// Re-present every prompt still awaiting the operator.
|
|
1149
|
+
prompts.pendingMessages(session).forEach(_send);
|
|
1145
1150
|
|
|
1146
1151
|
// Re-send active mention indicator so returning clients restore the mate avatar state
|
|
1147
1152
|
if (session._mentionInProgress && session._mentionActiveMateId) {
|
|
@@ -1181,6 +1186,9 @@ function createSessionManager(opts) {
|
|
|
1181
1186
|
_lruRemove(localId);
|
|
1182
1187
|
|
|
1183
1188
|
cleanupMentionSessions(session);
|
|
1189
|
+
// Settled before the abort below so no abort listener records an event
|
|
1190
|
+
// into a history that is about to be deleted.
|
|
1191
|
+
prompts.cancelSession(session, "session_deleted", { record: false });
|
|
1184
1192
|
|
|
1185
1193
|
if (session.abortController) {
|
|
1186
1194
|
try { session.abortController.abort(); } catch(e) {}
|
|
@@ -1228,6 +1236,7 @@ function createSessionManager(opts) {
|
|
|
1228
1236
|
_lruRemove(localId);
|
|
1229
1237
|
|
|
1230
1238
|
cleanupMentionSessions(session);
|
|
1239
|
+
prompts.cancelSession(session, "session_deleted", { record: false });
|
|
1231
1240
|
if (session.abortController) {
|
|
1232
1241
|
try { session.abortController.abort(); } catch(e) {}
|
|
1233
1242
|
}
|
|
@@ -1378,8 +1387,8 @@ function createSessionManager(opts) {
|
|
|
1378
1387
|
cliSessionId: cliSessionId,
|
|
1379
1388
|
blocks: {},
|
|
1380
1389
|
sentToolResults: {},
|
|
1381
|
-
pendingPermissions:
|
|
1382
|
-
pendingAskUser:
|
|
1390
|
+
pendingPermissions: Object.create(null),
|
|
1391
|
+
pendingAskUser: Object.create(null),
|
|
1383
1392
|
// Hydrate previously-granted "allow for session" tool decisions from
|
|
1384
1393
|
// durable state (lr-8b2e); default to {} only when none was saved.
|
|
1385
1394
|
// Sanitized (lr-8b2e hardening) so a malformed/injected persisted
|
|
@@ -1438,11 +1447,14 @@ function createSessionManager(opts) {
|
|
|
1438
1447
|
return _parseSessionFileLines(session).lines;
|
|
1439
1448
|
}
|
|
1440
1449
|
|
|
1441
|
-
|
|
1450
|
+
// canSee (optional): predicate over a session; a session it rejects is
|
|
1451
|
+
// skipped before its title or any of its content is examined.
|
|
1452
|
+
function searchSessions(query, canSee) {
|
|
1442
1453
|
if (!query) return [];
|
|
1443
1454
|
var q = query.toLowerCase();
|
|
1444
1455
|
var results = [];
|
|
1445
1456
|
sessions.forEach(function (session) {
|
|
1457
|
+
if (canSee && !canSee(session)) return;
|
|
1446
1458
|
var titleMatch = (session.title || "New Session").toLowerCase().indexOf(q) !== -1;
|
|
1447
1459
|
var contentMatch = false;
|
|
1448
1460
|
if (titleMatch) {
|
|
@@ -1806,13 +1818,18 @@ function createSessionManager(opts) {
|
|
|
1806
1818
|
// `sm.effectiveSessionModel(session)` without importing this module
|
|
1807
1819
|
// separately.
|
|
1808
1820
|
effectiveSessionModel: function (session) { return effectiveSessionModel(session, _instance); },
|
|
1809
|
-
//
|
|
1810
|
-
//
|
|
1811
|
-
//
|
|
1821
|
+
// Called when the project owning this session manager is torn down. No
|
|
1822
|
+
// prompt resolver outlives it, so every pending prompt ends here and its
|
|
1823
|
+
// outcome is flushed to disk; then the process-level exit listener
|
|
1824
|
+
// registered above is removed so listeners do not accumulate across
|
|
1825
|
+
// project open/close cycles.
|
|
1812
1826
|
destroy: function() {
|
|
1827
|
+
prompts.shutdown();
|
|
1828
|
+
_onProcessExit();
|
|
1813
1829
|
process.removeListener("exit", _onProcessExit);
|
|
1814
1830
|
},
|
|
1815
1831
|
};
|
|
1832
|
+
_instance.prompts = prompts;
|
|
1816
1833
|
return _instance;
|
|
1817
1834
|
}
|
|
1818
1835
|
|
package/lib/users-permissions.js
CHANGED
|
@@ -65,16 +65,19 @@ function attachPermissions(deps) {
|
|
|
65
65
|
|
|
66
66
|
function canAccessProject(userId, project) {
|
|
67
67
|
if (!project) return false;
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
if (user && user.role === "admin") return true;
|
|
68
|
+
// Only an explicit "public" opens a project to every authenticated user.
|
|
69
|
+
// A record with no (or an unrecognised) visibility is treated as private
|
|
70
|
+
// so a missing field can never widen access.
|
|
71
|
+
if (project.visibility === "public") return true;
|
|
73
72
|
// Owner always has access to their own project
|
|
74
73
|
if (project.ownerId && project.ownerId === userId) return true;
|
|
75
74
|
// Private project -- check allowedUsers
|
|
76
75
|
var allowed = project.allowedUsers || [];
|
|
77
|
-
|
|
76
|
+
if (allowed.indexOf(userId) >= 0) return true;
|
|
77
|
+
// Admin always has access. Checked last: it reads the user store, and
|
|
78
|
+
// this runs for every message a connection sends.
|
|
79
|
+
var user = findUserById(userId);
|
|
80
|
+
return !!(user && user.role === "admin");
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
function getAccessibleProjects(userId, projects) {
|
package/lib/users.js
CHANGED
|
@@ -140,6 +140,14 @@ function hasAdmin() {
|
|
|
140
140
|
return !!findAdmin();
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
// The daemon's mode, as stored with the users. An install that predates the
|
|
144
|
+
// flag, or whose file is absent, is multi-user (see loadUsers); only an
|
|
145
|
+
// explicit false marks a single-user install. A read error propagates so the
|
|
146
|
+
// caller can treat "mode unknown" as the stricter mode.
|
|
147
|
+
function isMultiUser() {
|
|
148
|
+
return loadUsers().multiUser !== false;
|
|
149
|
+
}
|
|
150
|
+
|
|
143
151
|
function findUserById(id) {
|
|
144
152
|
var data = loadUsers();
|
|
145
153
|
for (var i = 0; i < data.users.length; i++) {
|
|
@@ -438,6 +446,7 @@ module.exports = {
|
|
|
438
446
|
createAdmin: createAdmin,
|
|
439
447
|
findAdmin: findAdmin,
|
|
440
448
|
hasAdmin: hasAdmin,
|
|
449
|
+
isMultiUser: isMultiUser,
|
|
441
450
|
findUserById: findUserById,
|
|
442
451
|
findUserByEmail: findUserByEmail,
|
|
443
452
|
authenticateUser: authenticateUser,
|
package/lib/utils.js
CHANGED
|
@@ -67,10 +67,12 @@ function resolveEncodedFile(baseDir, cwd, ext) {
|
|
|
67
67
|
*
|
|
68
68
|
* Keeps only entries whose key is a string and whose value is strictly
|
|
69
69
|
* boolean `true`; drops everything else. A non-object input (including
|
|
70
|
-
* null/undefined/arrays) yields
|
|
70
|
+
* null/undefined/arrays) yields an empty map rather than throwing. The map
|
|
71
|
+
* has no prototype: its keys are tool names, and a name like "constructor"
|
|
72
|
+
* must not be found as an inherited entry.
|
|
71
73
|
*/
|
|
72
74
|
function sanitizeAllowedTools(value) {
|
|
73
|
-
var out =
|
|
75
|
+
var out = Object.create(null);
|
|
74
76
|
if (!value || typeof value !== "object" || Array.isArray(value)) return out;
|
|
75
77
|
for (var key in value) {
|
|
76
78
|
if (!Object.prototype.hasOwnProperty.call(value, key)) continue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// vendor-auth.js - the "not logged in" facts for one agent, read from the YOKE
|
|
2
|
+
// registry so the title and the login command are written once and every
|
|
3
|
+
// surface (chat message, notification, terminal launcher) agrees.
|
|
4
|
+
|
|
5
|
+
var registry = require("./yoke").registry;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} vendor a registered vendor id
|
|
9
|
+
* @returns {{vendor: string, displayName: string, title: string, loginCommand: string}}
|
|
10
|
+
* @throws {Error} code YOKE_UNKNOWN_VENDOR when the vendor is not registered
|
|
11
|
+
*/
|
|
12
|
+
function authRequiredFacts(vendor) {
|
|
13
|
+
var descriptor = registry.get(vendor);
|
|
14
|
+
return {
|
|
15
|
+
vendor: descriptor.id,
|
|
16
|
+
displayName: descriptor.displayName,
|
|
17
|
+
title: descriptor.displayName + " is not logged in.",
|
|
18
|
+
loginCommand: descriptor.loginCommand,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { authRequiredFacts: authRequiredFacts };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// vendor-registry-message.js - the agent registry as the browser receives it:
|
|
2
|
+
// every registered agent with its display data, whether it is installed, the
|
|
3
|
+
// login command and the capabilities its controls are gated on. The agent
|
|
4
|
+
// picker and every capability-gated control render from this message, so a
|
|
5
|
+
// newly registered agent appears without a front-end change.
|
|
6
|
+
//
|
|
7
|
+
// Install state belongs to an OS identity: what is on one user's PATH says
|
|
8
|
+
// nothing about another's. The session manager keeps it per identity
|
|
9
|
+
// (installStateByUser, keyed by Linux user name, "" for the daemon account).
|
|
10
|
+
|
|
11
|
+
var registry = require("./yoke").registry;
|
|
12
|
+
|
|
13
|
+
var DAEMON_IDENTITY_KEY = "";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Records what an install lookup found for one OS identity.
|
|
17
|
+
* @param {object} sm
|
|
18
|
+
* @param {?string} linuxUser null for the daemon's own account
|
|
19
|
+
* @param {{installed: string[], failures: object}} state
|
|
20
|
+
*/
|
|
21
|
+
function recordInstallState(sm, linuxUser, state) {
|
|
22
|
+
sm.installStateByUser = sm.installStateByUser || {};
|
|
23
|
+
sm.installStateByUser[linuxUser || DAEMON_IDENTITY_KEY] = state;
|
|
24
|
+
if (!linuxUser) sm.installedVendors = state.installed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* What is known about installed agents for an OS identity. An identity not
|
|
29
|
+
* looked up yet gets the project-wide list from the last warm-up.
|
|
30
|
+
* @param {object} sm
|
|
31
|
+
* @param {?string} linuxUser
|
|
32
|
+
* @returns {{installed: string[], failures: object}}
|
|
33
|
+
*/
|
|
34
|
+
function installStateFor(sm, linuxUser) {
|
|
35
|
+
var byUser = sm.installStateByUser || {};
|
|
36
|
+
var key = linuxUser || DAEMON_IDENTITY_KEY;
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(byUser, key)) return byUser[key];
|
|
38
|
+
return { installed: sm.installedVendors || [], failures: {} };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {object} sm the session manager (installedVendors, availableVendors,
|
|
43
|
+
* capabilitiesByVendor, installStateByUser)
|
|
44
|
+
* @param {?string} [linuxUser] the OS identity the message is for
|
|
45
|
+
* @returns {{type: string, vendors: object[], reasons: object}}
|
|
46
|
+
*/
|
|
47
|
+
function buildVendorRegistryMessage(sm, linuxUser) {
|
|
48
|
+
var state = installStateFor(sm, linuxUser);
|
|
49
|
+
return {
|
|
50
|
+
type: "vendor_registry",
|
|
51
|
+
vendors: registry.describeForClient({
|
|
52
|
+
installed: state.installed,
|
|
53
|
+
probeFailures: state.failures,
|
|
54
|
+
available: sm.availableVendors || [],
|
|
55
|
+
capabilities: sm.capabilitiesByVendor || {},
|
|
56
|
+
}),
|
|
57
|
+
reasons: registry.capabilityReasons(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
buildVendorRegistryMessage: buildVendorRegistryMessage,
|
|
63
|
+
recordInstallState: recordInstallState,
|
|
64
|
+
installStateFor: installStateFor,
|
|
65
|
+
};
|
package/lib/ws-origin.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// WebSocket upgrade origin check (defence in depth against cross-site
|
|
2
|
+
// WebSocket hijacking; every upgrade must also carry a valid login).
|
|
3
|
+
//
|
|
4
|
+
// Rules:
|
|
5
|
+
// - No Origin header: a non-browser client (CLI, relay, MCP bridge). Allowed;
|
|
6
|
+
// the login still applies.
|
|
7
|
+
// - An Origin on the operator's allowedOrigins list: allowed.
|
|
8
|
+
// - Otherwise the Origin's host AND port must equal those of the request's
|
|
9
|
+
// Host header (or, only when the operator declared a trusted proxy, of its
|
|
10
|
+
// X-Forwarded-Host). A bare port match is not enough: a sibling
|
|
11
|
+
// subdomain that is served on the same port is a different origin.
|
|
12
|
+
// - Scheme is compared only where the daemon knows it: it terminates TLS
|
|
13
|
+
// itself (https required), or a trusted proxy reported it
|
|
14
|
+
// (X-Forwarded-Proto). Behind an unconfigured TLS-terminating proxy the
|
|
15
|
+
// scheme the daemon sees is not the browser's, so it is not compared; the
|
|
16
|
+
// origin's own scheme only supplies the default port.
|
|
17
|
+
// - Any Origin that is not a parsable http(s) origin (including "null" and
|
|
18
|
+
// extension origins such as chrome-extension://...) is refused unless it
|
|
19
|
+
// is on the allowed list.
|
|
20
|
+
|
|
21
|
+
function parseOrigin(value) {
|
|
22
|
+
try {
|
|
23
|
+
var url = new URL(value);
|
|
24
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
25
|
+
return url;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function defaultPort(protocol) {
|
|
32
|
+
return protocol === "https:" ? "443" : "80";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// "scheme://host:port" with the default port made explicit and the host
|
|
36
|
+
// lower-cased, or null when value is not an http(s) origin.
|
|
37
|
+
function normalizeOrigin(value) {
|
|
38
|
+
var url = parseOrigin(value);
|
|
39
|
+
if (!url) return null;
|
|
40
|
+
return url.protocol + "//" + url.hostname + ":" + (url.port || defaultPort(url.protocol));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function hostMatches(originUrl, hostHeader) {
|
|
44
|
+
if (!hostHeader) return false;
|
|
45
|
+
var hostUrl;
|
|
46
|
+
try {
|
|
47
|
+
hostUrl = new URL(originUrl.protocol + "//" + hostHeader);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
var originPort = originUrl.port || defaultPort(originUrl.protocol);
|
|
52
|
+
var hostPort = hostUrl.port || defaultPort(originUrl.protocol);
|
|
53
|
+
return originUrl.hostname === hostUrl.hostname && originPort === hostPort;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function firstValue(header) {
|
|
57
|
+
if (typeof header !== "string") return "";
|
|
58
|
+
return header.split(",")[0].trim();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// o: { headers, tls, trustedProxy, allowedOrigins }
|
|
62
|
+
// Returns { ok: boolean, reason?: string }.
|
|
63
|
+
function checkWsOrigin(o) {
|
|
64
|
+
var headers = o.headers || {};
|
|
65
|
+
var origin = headers.origin;
|
|
66
|
+
if (origin === undefined || origin === "") return { ok: true };
|
|
67
|
+
if (typeof origin !== "string") return { ok: false, reason: "malformed origin" };
|
|
68
|
+
|
|
69
|
+
var allowed = Array.isArray(o.allowedOrigins) ? o.allowedOrigins : [];
|
|
70
|
+
var normalized = normalizeOrigin(origin);
|
|
71
|
+
for (var i = 0; i < allowed.length; i++) {
|
|
72
|
+
if (typeof allowed[i] !== "string") continue;
|
|
73
|
+
// Non-http(s) entries (extension origins) are compared as written.
|
|
74
|
+
if (allowed[i] === origin) return { ok: true };
|
|
75
|
+
if (normalized && normalizeOrigin(allowed[i]) === normalized) return { ok: true };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var originUrl = parseOrigin(origin);
|
|
79
|
+
if (!originUrl) return { ok: false, reason: "origin is not an http(s) origin" };
|
|
80
|
+
|
|
81
|
+
var hostOk = hostMatches(originUrl, headers.host);
|
|
82
|
+
if (!hostOk && o.trustedProxy) {
|
|
83
|
+
hostOk = hostMatches(originUrl, firstValue(headers["x-forwarded-host"]));
|
|
84
|
+
}
|
|
85
|
+
if (!hostOk) return { ok: false, reason: "origin host does not match the request host" };
|
|
86
|
+
|
|
87
|
+
var knownScheme = null;
|
|
88
|
+
if (o.tls) knownScheme = "https:";
|
|
89
|
+
else if (o.trustedProxy) {
|
|
90
|
+
var forwardedProto = firstValue(headers["x-forwarded-proto"]).toLowerCase();
|
|
91
|
+
if (forwardedProto === "https" || forwardedProto === "http") knownScheme = forwardedProto + ":";
|
|
92
|
+
}
|
|
93
|
+
if (knownScheme && originUrl.protocol !== knownScheme) {
|
|
94
|
+
return { ok: false, reason: "origin scheme does not match the connection" };
|
|
95
|
+
}
|
|
96
|
+
return { ok: true };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { checkWsOrigin: checkWsOrigin };
|
package/lib/ws-schema.js
CHANGED
|
@@ -113,27 +113,36 @@ var schema = {
|
|
|
113
113
|
"task_updated": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Background task status/description patch" },
|
|
114
114
|
|
|
115
115
|
// -----------------------------------------------------------------------
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
// Operator prompts: one shape for every kind (lib/prompt-registry.js).
|
|
117
|
+
// kind is permission, plan, ask_user or elicitation; the kind's own fields
|
|
118
|
+
// ride flat on the message (permission/plan: toolName, toolInput,
|
|
119
|
+
// decisionReason, vendor, and for permission the SDK's hints when set:
|
|
120
|
+
// suppressAlwaysAllowRule, defaultToNo, matchedAskRule; ask_user: input; elicitation: serverName,
|
|
121
|
+
// message, mode, url, elicitationId, requestedSchema).
|
|
122
|
+
// -----------------------------------------------------------------------
|
|
123
|
+
"prompt_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt awaits the operator: {requestId, kind, toolUseId, ...kind fields}. On history replay it carries promptState {state: pending|resolved|cancelled, decision|answers|skipped|action, reason}, the server's authoritative state for the prompt at replay time" },
|
|
124
|
+
"prompt_pending": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt still awaiting the operator, re-presented on connect and session switch; same fields as prompt_request" },
|
|
125
|
+
"prompt_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "The operator's answer: {requestId, kind, ...} with decision (+ feedback, planContent) for permission/plan, answers or decision:\"skip\" for ask_user (answers keyed by question index; each a label or text, or for a multi-select question the list of chosen labels), action (+ content, held to the requested schema) for elicitation. The kind is required and must match the prompt's. Decision allow_always to a permission prompt that carries suppressAlwaysAllowRule settles nothing: the prompt is sent again as prompt_pending. A prompt of the extension kind is never answered this way" },
|
|
126
|
+
"prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action}; a permission prompt forced by a user ask rule also carries matchedAskRule" },
|
|
127
|
+
"prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown. Reason \"stale\" is sent only to a client whose prompt_response named a prompt the server no longer holds, and is not recorded in history" },
|
|
128
|
+
|
|
129
|
+
// Aliases kept for compatibility: the s2c types appear in history recorded
|
|
130
|
+
// before prompts had one shape (the client maps them onto the prompt_*
|
|
131
|
+
// handlers), and the c2s types are still accepted from a page loaded
|
|
132
|
+
// before an upgrade. Nothing records or sends the s2c aliases any more,
|
|
133
|
+
// except permission_cancel {reason: "stale"} in reply to a
|
|
134
|
+
// permission_response.
|
|
135
|
+
"permission_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_request (kind permission or plan); history carries permissionState or promptState" },
|
|
136
|
+
"permission_request_pending": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_pending (kind permission or plan)" },
|
|
137
|
+
"permission_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "Alias of prompt_response for kinds permission and plan: {requestId, decision, feedback, planContent}" },
|
|
138
|
+
"permission_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_resolved (kind permission or plan)" },
|
|
139
|
+
"permission_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_cancel (kind permission or plan); the stale reply to a permission_response" },
|
|
127
140
|
"ask_user": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Assistant is requesting user input via ask_user tool" },
|
|
128
|
-
"ask_user_response": { direction: "c2s", handler: "lib/project-
|
|
129
|
-
"ask_user_answered": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// -----------------------------------------------------------------------
|
|
134
|
-
"elicitation_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Structured form elicitation request from assistant" },
|
|
135
|
-
"elicitation_response": { direction: "c2s", handler: "lib/project-sessions.js", description: "User response to an elicitation form" },
|
|
136
|
-
"elicitation_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Elicitation request resolved" },
|
|
141
|
+
"ask_user_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "Alias of prompt_response for kind ask_user: {toolId, answers}; toolId is the prompt's requestId" },
|
|
142
|
+
"ask_user_answered": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_resolved (kind ask_user) keyed by toolId; without answers, the question ended unanswered" },
|
|
143
|
+
"elicitation_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_request (kind elicitation)" },
|
|
144
|
+
"elicitation_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "Alias of prompt_response for kind elicitation: {requestId, action, content}" },
|
|
145
|
+
"elicitation_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_resolved (kind elicitation)" },
|
|
137
146
|
|
|
138
147
|
// -----------------------------------------------------------------------
|
|
139
148
|
// Stop / control
|
|
@@ -186,6 +195,8 @@ var schema = {
|
|
|
186
195
|
"set_project_default_betas": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set and persist the project default beta flags" },
|
|
187
196
|
"set_thinking": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set thinking mode and budget" },
|
|
188
197
|
"model_info": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Current model and available models list" },
|
|
198
|
+
"vendor_registry": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Every registered agent with display data, install state, login command and capabilities; the agent picker and capability-gated controls render from it" },
|
|
199
|
+
"recheck_vendors": { direction: "c2s", handler: "lib/project-sessions.js", description: "Look again for installed agents and broadcast the vendor registry" },
|
|
189
200
|
"config_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Full config state: model, mode, effort, betas, thinking" },
|
|
190
201
|
"slash_commands": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Available slash commands list" },
|
|
191
202
|
"fast_mode_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Fast mode toggle state" },
|
|
@@ -375,8 +386,8 @@ var schema = {
|
|
|
375
386
|
// Browser extension
|
|
376
387
|
// -----------------------------------------------------------------------
|
|
377
388
|
"browser_tab_list": { direction: "c2s", handler: "lib/project-user-message.js", description: "Provide browser tab list from the extension" },
|
|
378
|
-
"extension_result": { direction: "c2s", handler: "lib/project-user-message.js", description: "Result from a browser extension command" },
|
|
379
|
-
"extension_command": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Command for the browser extension to execute" },
|
|
389
|
+
"extension_result": { direction: "c2s", handler: "lib/project-user-message.js", description: "Result from a browser extension command; answers the extension-kind prompt named by requestId (lib/prompt-registry.js)" },
|
|
390
|
+
"extension_command": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Command for the browser extension to execute; an unanswered command resolves to null after its timeout" },
|
|
380
391
|
"clay_ext_tab_list": { direction: "s2c", handler: "lib/public/modules/app-misc.js", description: "Browser tab list from the extension (broadcast)" },
|
|
381
392
|
"clay_ext_result": { direction: "s2c", handler: "lib/public/modules/app-misc.js", description: "Browser extension command result (broadcast)" },
|
|
382
393
|
"clay_ext_command": { direction: "c2s", handler: "lib/public/modules/app-misc.js", description: "Send a command to the browser extension" },
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// What a Claude session can do, as the client sees it (sent with
|
|
4
|
+
// session_switched), and the declaration the Claude adapter registers. Every
|
|
5
|
+
// key is one of the YOKE capability ledger (lib/yoke/interface.js).
|
|
6
|
+
// permissionModes names the SDK permission modes the session accepts through
|
|
7
|
+
// setPermissionMode: the mode picker offers dontAsk and auto only for a vendor
|
|
8
|
+
// that lists them, so a vendor that cannot run one never shows it.
|
|
9
|
+
|
|
10
|
+
var PERMISSION_MODES = ["default", "plan", "acceptEdits", "dontAsk", "auto"];
|
|
11
|
+
|
|
12
|
+
function claudeCapabilities() {
|
|
13
|
+
return {
|
|
14
|
+
thinking: true,
|
|
15
|
+
betas: true,
|
|
16
|
+
effort: true,
|
|
17
|
+
rewind: true,
|
|
18
|
+
fork: true,
|
|
19
|
+
rollback: false,
|
|
20
|
+
sessionResume: true,
|
|
21
|
+
sessionList: true,
|
|
22
|
+
sessionRename: true,
|
|
23
|
+
sessionArchive: false,
|
|
24
|
+
promptSuggestions: true,
|
|
25
|
+
elicitation: true,
|
|
26
|
+
fileCheckpointing: true,
|
|
27
|
+
contextCompacting: true,
|
|
28
|
+
mcpPanel: true,
|
|
29
|
+
backgroundTasks: true,
|
|
30
|
+
steering: true,
|
|
31
|
+
agentInjection: true,
|
|
32
|
+
executionPolicy: false,
|
|
33
|
+
toolPolicy: ["ask", "allow-all"],
|
|
34
|
+
permissionModes: PERMISSION_MODES.slice(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = { claudeCapabilities: claudeCapabilities, PERMISSION_MODES: PERMISSION_MODES };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Registers the Claude Code vendor with the YOKE registry.
|
|
2
|
+
//
|
|
3
|
+
// Kept apart from claude.js on purpose: that module does work when it is first
|
|
4
|
+
// loaded (it opens up the package directory for OS-user workers), so merely
|
|
5
|
+
// asking the registry which agents exist must not load it. The adapter module is
|
|
6
|
+
// required only when an adapter is actually created.
|
|
7
|
+
|
|
8
|
+
var registry = require("../registry");
|
|
9
|
+
var authChecks = require("../auth-checks");
|
|
10
|
+
var providerCredentials = require("../provider-credentials");
|
|
11
|
+
var claudeCapabilities = require("./claude-capabilities").claudeCapabilities;
|
|
12
|
+
|
|
13
|
+
registry.register({
|
|
14
|
+
id: "claude",
|
|
15
|
+
displayName: "Claude Code",
|
|
16
|
+
icon: "/claude-code-avatar.png",
|
|
17
|
+
priority: 10,
|
|
18
|
+
binaryNames: ["claude"],
|
|
19
|
+
probeInstalled: function(ctx) { return ctx.lookupBinary("claude"); },
|
|
20
|
+
checkAuth: authChecks.checkClaudeAuth,
|
|
21
|
+
installHint: "Install Claude Code (npm install -g @anthropic-ai/claude-code), then sign in.",
|
|
22
|
+
loginCommand: "claude login",
|
|
23
|
+
osUsersSupported: true,
|
|
24
|
+
needsRuntimeEnv: false,
|
|
25
|
+
perProjectRuntime: false,
|
|
26
|
+
activityTokens: false,
|
|
27
|
+
attestsHumanSessions: false,
|
|
28
|
+
ownedEnvNames: ["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"].concat(providerCredentials.allCredentialNames()),
|
|
29
|
+
ownedEnvPrefixes: providerCredentials.allCredentialPrefixes(),
|
|
30
|
+
credentialGroups: providerCredentials.CREDENTIAL_GROUPS,
|
|
31
|
+
nativeInstructionFiles: ["CLAUDE.md"],
|
|
32
|
+
interruptMessage: "Interrupted · What should Claude do instead?",
|
|
33
|
+
capabilities: claudeCapabilities(),
|
|
34
|
+
createAdapter: function(opts) { return require("./claude").createClaudeAdapter(opts); },
|
|
35
|
+
});
|