@clagentic/console 1.12.0-beta.2 → 1.12.0
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/LICENSES/README.md +5 -0
- package/bin/cli.js +4 -2
- package/lib/agent-roster-ws.js +84 -0
- package/lib/agent-roster.js +312 -0
- package/lib/auth-required-notify.js +42 -0
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +3 -4
- package/lib/build-update-standing.js +34 -14
- package/lib/cli/session-subcommands.js +26 -8
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +25 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +16 -22
- package/lib/notify/core.js +53 -18
- package/lib/notify/payload.js +2 -3
- package/lib/notify/type-registry.js +17 -0
- package/lib/notify/types.js +38 -1
- package/lib/outbound-access.js +12 -1
- package/lib/outbound-entry.js +8 -1
- package/lib/project-connection.js +9 -8
- package/lib/project-filesystem.js +23 -0
- package/lib/project-loop.js +16 -19
- package/lib/project-notifications.js +68 -7
- package/lib/project-sessions.js +9 -0
- package/lib/project-user-mention.js +22 -34
- package/lib/project-user-message.js +208 -4
- package/lib/project-user-shell.js +298 -0
- package/lib/project.js +26 -4
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +24 -1
- package/lib/prompt-source.js +16 -0
- package/lib/public/app.js +31 -2
- package/lib/public/css/agent-messages.css +96 -0
- package/lib/public/css/agent-roster.css +93 -0
- package/lib/public/css/diagnostics.css +1 -1
- package/lib/public/css/input.css +20 -141
- package/lib/public/css/login-panel.css +73 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/sidebar.css +11 -0
- package/lib/public/css/team-panel.css +1 -6
- package/lib/public/css/team-view.css +101 -0
- package/lib/public/css/title-bar.css +10 -0
- package/lib/public/css/user-shell.css +144 -0
- package/lib/public/index.html +41 -7
- package/lib/public/modules/agent-avatar-picker.js +162 -0
- package/lib/public/modules/agent-avatar.js +153 -0
- package/lib/public/modules/agent-messages.js +285 -0
- package/lib/public/modules/agent-roster.js +157 -0
- package/lib/public/modules/app-connection.js +12 -0
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +59 -29
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +22 -7
- package/lib/public/modules/collapsible-text.js +33 -18
- package/lib/public/modules/compaction-state.js +34 -0
- package/lib/public/modules/custom-icons.js +23 -5
- package/lib/public/modules/diagnostics.js +52 -55
- package/lib/public/modules/injected-identity.js +24 -21
- package/lib/public/modules/input.js +176 -15
- package/lib/public/modules/login-panel.js +136 -0
- package/lib/public/modules/login-parser.js +73 -0
- package/lib/public/modules/login-tab.js +66 -0
- package/lib/public/modules/notifications.js +9 -1
- package/lib/public/modules/notify-client.js +114 -21
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/queued-button.js +11 -0
- package/lib/public/modules/scheduled-input-actions.js +12 -4
- package/lib/public/modules/scheduled-outbox.js +230 -0
- package/lib/public/modules/send-now.js +200 -0
- package/lib/public/modules/server-settings.js +47 -1
- package/lib/public/modules/shell-card.js +76 -0
- package/lib/public/modules/shell-line.js +49 -0
- package/lib/public/modules/shell-queue.js +253 -0
- package/lib/public/modules/shell-settings-controls.js +76 -0
- package/lib/public/modules/sidebar-mobile.js +3 -3
- package/lib/public/modules/sidebar-sessions.js +8 -0
- package/lib/public/modules/sidebar-users.js +5 -7
- package/lib/public/modules/team-panel.js +30 -88
- package/lib/public/modules/team-view.js +211 -0
- package/lib/public/modules/terminal-links.js +18 -0
- package/lib/public/modules/terminal.js +65 -4
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +35 -83
- package/lib/public/notify-target.js +70 -10
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +7 -3
- package/lib/queued-chat.js +392 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +122 -43
- package/lib/sdk-message-processor.js +46 -39
- package/lib/server-auth.js +6 -4
- package/lib/server-dm.js +11 -20
- package/lib/server-settings.js +39 -1
- package/lib/server.js +83 -19
- package/lib/session-directory.js +33 -8
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +26 -0
- package/lib/session-input.js +176 -9
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +49 -5
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +7 -0
- package/lib/user-shell-settings.js +105 -0
- package/lib/ws-schema.js +27 -4
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +6 -0
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +218 -6
- package/lib/yoke/adapters/codex-capabilities.js +6 -1
- package/lib/yoke/adapters/codex-user-shell.js +265 -0
- package/lib/yoke/adapters/codex-vendor.js +7 -0
- package/lib/yoke/adapters/codex.js +186 -52
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/registry.js +32 -0
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +1 -1
- package/lib/public/modules/build-notice-gate.js +0 -73
package/lib/notify/core.js
CHANGED
|
@@ -34,9 +34,28 @@ function createNotifyCore(deps) {
|
|
|
34
34
|
ownerId: audience && audience.ownerId || null,
|
|
35
35
|
isMultiUser: audience && audience.isMultiUser,
|
|
36
36
|
listAdmins: audience && audience.listAdmins,
|
|
37
|
+
isOnline: audience && typeof audience.isOnline === "function" ? audience.isOnline : null,
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
function isOnline(aud) {
|
|
42
|
+
if (!aud.isOnline || !aud.ownerId) return false;
|
|
43
|
+
try {
|
|
44
|
+
return aud.isOnline(aud.ownerId) === true;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
// A presence reader that fails counts as offline: a push too many beats
|
|
47
|
+
// a message nobody sees.
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// A type with a fixed audience ignores the owner the emitter names: the
|
|
53
|
+
// admins (or the one person of a single-user install) are the recipients.
|
|
54
|
+
function audienceForType(type, aud) {
|
|
55
|
+
if (type.audience !== "admins") return aud;
|
|
56
|
+
return Object.assign({}, aud, { ownerId: null });
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
function perSurface(content) {
|
|
41
60
|
var c = content || {};
|
|
42
61
|
if (c.push || c.banner) return { push: c.push || null, banner: c.banner || null };
|
|
@@ -53,14 +72,17 @@ function createNotifyCore(deps) {
|
|
|
53
72
|
var aud = audienceFor(audience.ownerId, audience.isMultiUser, audience.listAdmins);
|
|
54
73
|
// The audience and the target are applied last: emitter content cannot
|
|
55
74
|
// widen or redirect who reads the banner, or where it points.
|
|
56
|
-
|
|
75
|
+
var fixed = {
|
|
57
76
|
ownerId: audience.ownerId,
|
|
58
77
|
targetUserId: aud.kind === "owner" ? aud.userIds[0] : null,
|
|
59
78
|
targetUserIds: aud.kind === "admins" ? aud.userIds : null,
|
|
60
79
|
slug: norm.slug,
|
|
61
80
|
sessionId: raw.sessionId,
|
|
62
81
|
requestId: norm.requestId,
|
|
63
|
-
}
|
|
82
|
+
};
|
|
83
|
+
// A direct message's target names the other person, not a project.
|
|
84
|
+
fixed.peerId = norm.peerId || null;
|
|
85
|
+
return Object.assign({}, data, fixed);
|
|
64
86
|
}
|
|
65
87
|
|
|
66
88
|
/**
|
|
@@ -74,10 +96,12 @@ function createNotifyCore(deps) {
|
|
|
74
96
|
* fields are added here). A surface without content is not delivered to;
|
|
75
97
|
* the core picks the surfaces from the type's registration, never the
|
|
76
98
|
* emitter. A content naming neither key is the push content itself.
|
|
77
|
-
* @param {{ownerId: ?string, isMultiUser: ?function, listAdmins: ?function}} [audience]
|
|
78
|
-
* who the
|
|
79
|
-
*
|
|
80
|
-
*
|
|
99
|
+
* @param {{ownerId: ?string, isMultiUser: ?function, listAdmins: ?function, isOnline: ?function}} [audience]
|
|
100
|
+
* who the notification belongs to (the session's owner; for a message, its
|
|
101
|
+
* recipient); the push audience rules (lib/push-audience.js) decide the
|
|
102
|
+
* recipients from it, for the push and the banner alike. The mode, admin
|
|
103
|
+
* and presence readers are optional; the presence reader (userId ->
|
|
104
|
+
* boolean) is used only by types that skip the push for an online person.
|
|
81
105
|
* @returns {?object} the payload built, or null when nothing was delivered.
|
|
82
106
|
*/
|
|
83
107
|
function notify(typeName, t, content, audience) {
|
|
@@ -89,10 +113,11 @@ function createNotifyCore(deps) {
|
|
|
89
113
|
throw new Error("notification type " + typeName + " needs a requestId");
|
|
90
114
|
}
|
|
91
115
|
var bySurface = perSurface(content);
|
|
92
|
-
var aud = audienceOf(audience);
|
|
116
|
+
var aud = audienceForType(type, audienceOf(audience));
|
|
93
117
|
var payload = payloads.buildPayload(type, norm, bySurface.push || bySurface.banner);
|
|
94
118
|
var delivered = false;
|
|
95
|
-
|
|
119
|
+
var skipPush = type.pushUnlessOnline && isOnline(aud);
|
|
120
|
+
if (push && bySurface.push && !skipPush) {
|
|
96
121
|
deliver(aud, payload);
|
|
97
122
|
delivered = true;
|
|
98
123
|
}
|
|
@@ -112,17 +137,21 @@ function createNotifyCore(deps) {
|
|
|
112
137
|
// notification category: a close push follows the preference of the
|
|
113
138
|
// notification it closes, and types of one category share a preference, so
|
|
114
139
|
// one push per category carries all its tags.
|
|
115
|
-
function closeGroups(norms) {
|
|
140
|
+
function closeGroups(norms, onlyType) {
|
|
116
141
|
var groups = Object.create(null);
|
|
117
142
|
var order = [];
|
|
118
143
|
var bannerKeys = [];
|
|
119
144
|
norms.forEach(function (norm) {
|
|
120
145
|
registry.names().forEach(function (name) {
|
|
121
146
|
var type = registry.get(name);
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
if (onlyType) {
|
|
148
|
+
if (name !== onlyType) return;
|
|
149
|
+
} else {
|
|
150
|
+
if (!type.closeOnResolve) return;
|
|
151
|
+
// With a request named, that prompt's request-level notifications;
|
|
152
|
+
// without one, the session-level ones.
|
|
153
|
+
if ((type.collapse === "request") !== !!norm.requestId) return;
|
|
154
|
+
}
|
|
126
155
|
var key = type.category || name;
|
|
127
156
|
if (!groups[key]) {
|
|
128
157
|
groups[key] = { type: type, tags: [] };
|
|
@@ -147,16 +176,22 @@ function createNotifyCore(deps) {
|
|
|
147
176
|
* banners of that request).
|
|
148
177
|
* @param {{ownerId: ?string, isMultiUser: ?function, listAdmins: ?function}} [audience]
|
|
149
178
|
* the same audience the notification was sent to.
|
|
179
|
+
* @param {{type: ?string}} [opts] type: close only that registered type's
|
|
180
|
+
* notification at the target, whether or not the type closes with a
|
|
181
|
+
* prompt. This is how a system notification (no session, no prompt) is
|
|
182
|
+
* closed: its target is the console itself.
|
|
150
183
|
* @returns {number} how many close pushes were sent.
|
|
151
184
|
*/
|
|
152
|
-
function resolve(what, audience) {
|
|
185
|
+
function resolve(what, audience, opts) {
|
|
186
|
+
var onlyType = opts && opts.type ? opts.type : null;
|
|
187
|
+
if (onlyType && !registry.get(onlyType)) throw new Error("unregistered notification type: " + onlyType);
|
|
153
188
|
var all = [].concat(what).map(target.makeTarget).filter(Boolean);
|
|
154
|
-
var norms = all.filter(function (n) { return n.sessionId; });
|
|
155
|
-
var closing = closeGroups(norms);
|
|
189
|
+
var norms = onlyType ? all : all.filter(function (n) { return n.sessionId; });
|
|
190
|
+
var closing = closeGroups(norms, onlyType);
|
|
156
191
|
if (inApp && closing.bannerKeys.length) inApp.dismissKeys(closing.bannerKeys);
|
|
157
192
|
// An answer that arrives for a prompt no session claims (a stale one) names
|
|
158
193
|
// only its request: the banners of that request are retired, in its project.
|
|
159
|
-
if (inApp && typeof inApp.dismissRequest === "function") {
|
|
194
|
+
if (inApp && !onlyType && typeof inApp.dismissRequest === "function") {
|
|
160
195
|
all.filter(function (n) { return !n.sessionId && n.requestId; }).forEach(function (n) {
|
|
161
196
|
inApp.dismissRequest(n.slug, n.requestId);
|
|
162
197
|
});
|
|
@@ -164,7 +199,7 @@ function createNotifyCore(deps) {
|
|
|
164
199
|
if (!push) return 0;
|
|
165
200
|
var aud = audienceOf(audience);
|
|
166
201
|
closing.groups.forEach(function (g) {
|
|
167
|
-
deliver(aud, payloads.buildClose(g.type, g.tags));
|
|
202
|
+
deliver(audienceForType(g.type, aud), payloads.buildClose(g.type, g.tags));
|
|
168
203
|
});
|
|
169
204
|
return closing.groups.length;
|
|
170
205
|
}
|
package/lib/notify/payload.js
CHANGED
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
var target = require("./target");
|
|
9
9
|
|
|
10
10
|
// Marks a payload the generic service worker handles from its own fields. A
|
|
11
|
-
// payload without it is
|
|
11
|
+
// payload without it is not shown.
|
|
12
12
|
var CORE_MARK = 1;
|
|
13
13
|
var CLOSE_TYPE = "notify_close";
|
|
14
14
|
|
|
15
15
|
function tagFor(type, t) {
|
|
16
|
-
|
|
17
|
-
return "n:" + type.name + ":" + key;
|
|
16
|
+
return target.tagFor(type.name, type.collapse, t);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
// here, so no emitter carries any of it.
|
|
6
6
|
|
|
7
7
|
var COLLAPSE = ["request", "session"];
|
|
8
|
+
// Who a type's notification reaches: "target" follows the owner the emitter
|
|
9
|
+
// names (the session's owner, a message's recipient); "admins" is fixed by the
|
|
10
|
+
// type, whatever the emitter passes.
|
|
11
|
+
var AUDIENCE = ["target", "admins"];
|
|
8
12
|
|
|
9
13
|
function defaultFormat(content) {
|
|
10
14
|
return { title: content.title, body: content.body };
|
|
@@ -28,6 +32,13 @@ function createTypeRegistry() {
|
|
|
28
32
|
* closed with the notification (default false).
|
|
29
33
|
* @param {boolean} [def.liveInState] the page can verify the notification
|
|
30
34
|
* against notifications_state (default false).
|
|
35
|
+
* @param {boolean} [def.pushUnlessOnline] no push to a person who is online
|
|
36
|
+
* in the app: their banner already reaches them (default false).
|
|
37
|
+
* @param {"target"|"admins"} [def.audience] who receives it (default
|
|
38
|
+
* "target"). "admins": the admins in a multi-user install, the one person
|
|
39
|
+
* otherwise; the emitter cannot widen it.
|
|
40
|
+
* @param {boolean} [def.ephemeral] its banner does not outlive a daemon
|
|
41
|
+
* restart: what it announces is rebuilt from live state (default false).
|
|
31
42
|
* @param {function(object): {title: string, body: string}} [def.format]
|
|
32
43
|
*/
|
|
33
44
|
function register(name, def) {
|
|
@@ -36,6 +47,9 @@ function createTypeRegistry() {
|
|
|
36
47
|
if (!def || COLLAPSE.indexOf(def.collapse) === -1) {
|
|
37
48
|
throw new Error("notification type " + name + " needs collapse: request|session");
|
|
38
49
|
}
|
|
50
|
+
if (def.audience !== undefined && AUDIENCE.indexOf(def.audience) === -1) {
|
|
51
|
+
throw new Error("notification type " + name + " needs audience: target|admins");
|
|
52
|
+
}
|
|
39
53
|
types[name] = Object.freeze({
|
|
40
54
|
name: name,
|
|
41
55
|
category: def.category || null,
|
|
@@ -45,6 +59,9 @@ function createTypeRegistry() {
|
|
|
45
59
|
closeOnResolve: def.closeOnResolve !== false,
|
|
46
60
|
banner: def.banner === true,
|
|
47
61
|
liveInState: def.liveInState === true,
|
|
62
|
+
pushUnlessOnline: def.pushUnlessOnline === true,
|
|
63
|
+
audience: def.audience || "target",
|
|
64
|
+
ephemeral: def.ephemeral === true,
|
|
48
65
|
format: typeof def.format === "function" ? def.format : defaultFormat,
|
|
49
66
|
});
|
|
50
67
|
return types[name];
|
package/lib/notify/types.js
CHANGED
|
@@ -10,11 +10,48 @@ var PROMPT_TYPES = {
|
|
|
10
10
|
elicitation: { category: "approval", collapse: "request", persistent: true, liveInState: true },
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// What happened in a session, a loop or a conversation. Nothing waits on the
|
|
14
|
+
// person, so none is closed when a prompt resolves; a repeat for the same
|
|
15
|
+
// session replaces the earlier one.
|
|
16
|
+
var ACTIVITY_TYPES = {
|
|
17
|
+
response_done: { category: "turn_done", collapse: "session", renotify: true, banner: true, closeOnResolve: false },
|
|
18
|
+
loop_complete: { category: "loop", collapse: "session", renotify: true, banner: true, closeOnResolve: false },
|
|
19
|
+
loop_error: { category: "loop", collapse: "session", renotify: true, banner: true, closeOnResolve: false },
|
|
20
|
+
mate_dm: { category: "messages", collapse: "session", renotify: true, banner: true, closeOnResolve: false },
|
|
21
|
+
user_mention: { category: "messages", collapse: "session", renotify: true, banner: true, closeOnResolve: false, pushUnlessOnline: true },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// What the console itself needs the operator for. None is tied to a prompt, so
|
|
25
|
+
// a prompt resolving never closes one: each closes only by its own resolve
|
|
26
|
+
// (resolve(target, audience, { type })), whose tag derives from the target
|
|
27
|
+
// alone and so works from any process.
|
|
28
|
+
//
|
|
29
|
+
// The page does not reconcile these against its notification list (liveInState
|
|
30
|
+
// is off): the reconcile is scoped to the page's own project (see
|
|
31
|
+
// notify-client.js), and a system target has no project (slug null).
|
|
32
|
+
var SYSTEM_TYPES = {
|
|
33
|
+
// A sign-in is missing for a session's agent. Target: that session; owner only.
|
|
34
|
+
auth_required: { category: "system", collapse: "session", persistent: true, renotify: true, banner: true, closeOnResolve: false, audience: "target" },
|
|
35
|
+
// The installed build is newer than the running one. Target: the console
|
|
36
|
+
// itself (slug and session null). Only an admin can restart, so only admins
|
|
37
|
+
// are told. Closed when the build is adopted or the offer is declined.
|
|
38
|
+
build_update_offer: { category: "system", collapse: "session", persistent: true, banner: true, closeOnResolve: false, audience: "admins", ephemeral: true },
|
|
39
|
+
// A newer release exists. Target: the console itself; admins only. Ephemeral:
|
|
40
|
+
// after the update the banner would announce the version already running.
|
|
41
|
+
update_available: { category: "system", collapse: "session", banner: true, closeOnResolve: false, audience: "admins", ephemeral: true },
|
|
42
|
+
};
|
|
43
|
+
|
|
13
44
|
function registerBuiltins(registry) {
|
|
14
45
|
Object.keys(PROMPT_TYPES).forEach(function (name) {
|
|
15
46
|
registry.register(name, PROMPT_TYPES[name]);
|
|
16
47
|
});
|
|
48
|
+
Object.keys(ACTIVITY_TYPES).forEach(function (name) {
|
|
49
|
+
registry.register(name, ACTIVITY_TYPES[name]);
|
|
50
|
+
});
|
|
51
|
+
Object.keys(SYSTEM_TYPES).forEach(function (name) {
|
|
52
|
+
registry.register(name, SYSTEM_TYPES[name]);
|
|
53
|
+
});
|
|
17
54
|
return registry;
|
|
18
55
|
}
|
|
19
56
|
|
|
20
|
-
module.exports = { registerBuiltins: registerBuiltins, PROMPT_TYPES: PROMPT_TYPES };
|
|
57
|
+
module.exports = { registerBuiltins: registerBuiltins, PROMPT_TYPES: PROMPT_TYPES, ACTIVITY_TYPES: ACTIVITY_TYPES, SYSTEM_TYPES: SYSTEM_TYPES };
|
package/lib/outbound-access.js
CHANGED
|
@@ -68,7 +68,18 @@ function createOutboundAccess(deps) {
|
|
|
68
68
|
return { allowed: true };
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
// May this caller see that something happened in `project`? The project-level
|
|
72
|
+
// half of canReadPrompt, for readers (the agent roster) that record where an
|
|
73
|
+
// identity was seen and not a session's text.
|
|
74
|
+
function canReadProject(project, caller) {
|
|
75
|
+
caller = caller || {};
|
|
76
|
+
var principal = projectAccess.principalFor(caller.user || null, { authenticated: caller.authenticated === true });
|
|
77
|
+
if (!principal) return false;
|
|
78
|
+
if (principal.implicit) return true;
|
|
79
|
+
return !!project && projectAccess.canAccess(principal.id, project, { authenticated: true });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { canReadPrompt: canReadPrompt, canReadProject: canReadProject };
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
module.exports = { createOutboundAccess: createOutboundAccess };
|
package/lib/outbound-entry.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var { SENDER_KIND } = require("./injected-sender");
|
|
9
9
|
|
|
10
|
-
var VERB = Object.freeze({ SEND_INPUT: "send_input", OPEN_SESSION: "open_session" });
|
|
10
|
+
var VERB = Object.freeze({ SEND_INPUT: "send_input", OPEN_SESSION: "open_session", END_SESSION: "end_session", ANSWER_PROMPT: "answer_prompt" });
|
|
11
11
|
|
|
12
12
|
// target.runsAs for a session that runs as the daemon's own OS user; any other
|
|
13
13
|
// value is the name of the OS user it runs as.
|
|
@@ -66,7 +66,14 @@ function buildEntry(args) {
|
|
|
66
66
|
result: out.result || (args.verb === VERB.OPEN_SESSION ? "opened" : "delivered"),
|
|
67
67
|
};
|
|
68
68
|
put(entry, "reason", out.reason);
|
|
69
|
+
// An answer-prompt names the request and its kind, never the decision, which
|
|
70
|
+
// can be the text of an answer.
|
|
71
|
+
if (args.verb === VERB.ANSWER_PROMPT) {
|
|
72
|
+
put(entry, "requestId", out.requestId);
|
|
73
|
+
put(entry, "promptKind", out.kind);
|
|
74
|
+
}
|
|
69
75
|
if (out.retryable === true) entry.retryable = true;
|
|
76
|
+
if (Array.isArray(out.failures) && out.failures.length) entry.failures = out.failures;
|
|
70
77
|
put(entry, "messageId", args.messageId);
|
|
71
78
|
put(entry, "initiator", args.initiator);
|
|
72
79
|
entry.sender = senderOf(args.sender || {});
|
|
@@ -7,6 +7,8 @@ var { getCodexConfig } = require("./codex-defaults");
|
|
|
7
7
|
var { promptsFor } = require("./prompt-registry");
|
|
8
8
|
var { snapshotLivePrompts } = require("./notify/live-prompts");
|
|
9
9
|
var { settingsMessage } = require("./permission-settings");
|
|
10
|
+
var userShellSettings = require("./user-shell-settings");
|
|
11
|
+
var { rosterMessage, callerOf } = require("./agent-roster-ws");
|
|
10
12
|
var { effectiveSessionMode } = require("./sessions");
|
|
11
13
|
var sessionReclaim = require("./session-reclaim");
|
|
12
14
|
var clientBuildId = require("./client-build-id");
|
|
@@ -179,6 +181,13 @@ function attachConnection(ctx) {
|
|
|
179
181
|
if (typeof opts.onGetPermissionSettings === "function") {
|
|
180
182
|
sendTo(ws, settingsMessage(opts.onGetPermissionSettings()));
|
|
181
183
|
}
|
|
184
|
+
if (typeof opts.onGetUserShellSettings === "function") {
|
|
185
|
+
sendTo(ws, userShellSettings.settingsMessage(opts.onGetUserShellSettings()));
|
|
186
|
+
}
|
|
187
|
+
// Every client holds the roster's avatar choices from the start: a transcript
|
|
188
|
+
// draws agents before the Team view is ever opened.
|
|
189
|
+
// The roster is filtered to what this connection may read, as on request.
|
|
190
|
+
if (opts.agentRoster) sendTo(ws, rosterMessage(opts.agentRoster, callerOf(ws)));
|
|
182
191
|
sendTo(ws, { type: "term_list", terminals: tm.list(ws) });
|
|
183
192
|
// Context sources sent after session is resolved (per-session storage)
|
|
184
193
|
sendTo(ws, { type: "notes_list", notes: nm.list() });
|
|
@@ -193,14 +202,6 @@ function attachConnection(ctx) {
|
|
|
193
202
|
viewerId: wsUser ? wsUser.id : null,
|
|
194
203
|
}));
|
|
195
204
|
}
|
|
196
|
-
// A client that connects is told the current offer state: the held offer, or
|
|
197
|
-
// an explicit retraction when none stands, so a missed retraction cannot
|
|
198
|
-
// leave a dead restart action on screen.
|
|
199
|
-
if (typeof opts.onGetBuildUpdateDiagnostic === "function") {
|
|
200
|
-
var _buildUpdateDiag = opts.onGetBuildUpdateDiagnostic();
|
|
201
|
-
if (_buildUpdateDiag) sendTo(ws, _buildUpdateDiag);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
205
|
// Session list (filtered for access control)
|
|
205
206
|
// Use the canonical mapper from sessions.js
|
|
206
207
|
var activeId = restoredActive ? restoredActive.localId : sm.activeSessionId;
|
|
@@ -3,6 +3,7 @@ var path = require("path");
|
|
|
3
3
|
var fileScope = require("./project-file-scope");
|
|
4
4
|
var projectGit = require("./project-git");
|
|
5
5
|
var claudeSettingsEnv = require("./claude-settings-env");
|
|
6
|
+
var idleCompaction = require("./idle-compaction-setting");
|
|
6
7
|
var runtimeEnv = require("./runtime-env");
|
|
7
8
|
var { REAL_HOME } = require("./config");
|
|
8
9
|
|
|
@@ -288,6 +289,28 @@ function attachFilesystem(ctx) {
|
|
|
288
289
|
return true;
|
|
289
290
|
}
|
|
290
291
|
|
|
292
|
+
// --- Claude idleCompaction user setting ---
|
|
293
|
+
// Acts on the requesting account's own settings file. Without OS-level
|
|
294
|
+
// isolation every user shares the daemon account's one file, so changing it
|
|
295
|
+
// is an administrator action there; reading is open.
|
|
296
|
+
if (msg.type === "get_idle_compaction" || msg.type === "set_idle_compaction") {
|
|
297
|
+
var isSet = msg.type === "set_idle_compaction";
|
|
298
|
+
var resultType = isSet ? "set_idle_compaction_result" : "idle_compaction_result";
|
|
299
|
+
var icMultiUser = typeof projectAccess.isMultiUser === "function" ? projectAccess.isMultiUser() : true;
|
|
300
|
+
if (isSet && icMultiUser && !osUsers && !projectAccess.isAdmin(ws._clagenticUser, projectAccess.authOf(ws))) {
|
|
301
|
+
sendTo(ws, { type: resultType, ok: false, error: "Only an administrator can change the shared Claude settings file" });
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
var icOpts = { osUsers: !!osUsers, osUserInfo: getOsUserInfoForWs(ws), homeDir: REAL_HOME };
|
|
305
|
+
var icPending = isSet
|
|
306
|
+
? idleCompaction.applyForOwner("write", msg.value, icOpts)
|
|
307
|
+
: idleCompaction.applyForOwner("read", null, icOpts);
|
|
308
|
+
icPending.then(function (icResult) {
|
|
309
|
+
sendTo(ws, { type: resultType, ok: icResult.ok, value: icResult.value, error: icResult.error });
|
|
310
|
+
});
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
|
|
291
314
|
// --- Global CLAUDE.md ---
|
|
292
315
|
if (msg.type === "read_global_claude_md") {
|
|
293
316
|
var globalMdPath = path.join(require("./config").REAL_HOME, ".claude", "CLAUDE.md");
|
package/lib/project-loop.js
CHANGED
|
@@ -6,7 +6,7 @@ var { createLoopRegistry } = require("./scheduler");
|
|
|
6
6
|
var sessionLiveness = require("./session-liveness");
|
|
7
7
|
var store = require("./store");
|
|
8
8
|
var usersModule = require("./users");
|
|
9
|
-
var {
|
|
9
|
+
var { notifyFor } = require("./notify");
|
|
10
10
|
var { writeHandoff, buildHandoffPreamble } = require("./loop-handoff");
|
|
11
11
|
var { authOf } = require("./project-access");
|
|
12
12
|
var { INITIATORS } = require("./turn-initiator");
|
|
@@ -868,28 +868,25 @@ function attachLoop(ctx) {
|
|
|
868
868
|
activeRegistryId = null;
|
|
869
869
|
}
|
|
870
870
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (notificationsModule) {
|
|
885
|
-
notificationsModule.notify("loop_complete", {
|
|
871
|
+
var _finishBody = reason === "pass" || reason === "complete"
|
|
872
|
+
? "Completed after " + loopState.iteration + " iteration(s)"
|
|
873
|
+
: reason === "max_iterations"
|
|
874
|
+
? "Reached max iterations (" + loopState.maxIterations + ")"
|
|
875
|
+
: reason === "stopped" ? "Stopped by user" : "Ended due to error";
|
|
876
|
+
// One notify() per loop end, to the loop's owner alone (the push body
|
|
877
|
+
// carries iteration status), landing on the loop's last session.
|
|
878
|
+
notifyFor(pushModule, notificationsModule).notify(reason === "error" ? "loop_error" : "loop_complete", {
|
|
879
|
+
slug: slug,
|
|
880
|
+
sessionId: _lastSessionId,
|
|
881
|
+
}, {
|
|
882
|
+
push: { title: "Loop Complete", body: _finishBody },
|
|
883
|
+
banner: {
|
|
886
884
|
reason: reason,
|
|
887
885
|
name: loopState.name,
|
|
888
886
|
iterations: loopState.iteration,
|
|
889
887
|
maxIterations: loopState.maxIterations,
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
888
|
+
},
|
|
889
|
+
}, { ownerId: _loopOwnerUserId });
|
|
893
890
|
|
|
894
891
|
// Process next queued trigger if any
|
|
895
892
|
if (pendingTriggers.length > 0) {
|
|
@@ -8,6 +8,7 @@ var config = require("./config");
|
|
|
8
8
|
var yokeRegistry = require("./yoke").registry;
|
|
9
9
|
var notificationPrefs = require("./notification-prefs");
|
|
10
10
|
var audienceFor = require("./push-audience").audienceFor;
|
|
11
|
+
var notifyCore = require("./notify");
|
|
11
12
|
|
|
12
13
|
var NOTIF_FILE = path.join(config.CONFIG_DIR, "notifications.json");
|
|
13
14
|
|
|
@@ -40,6 +41,31 @@ var formatters = {
|
|
|
40
41
|
};
|
|
41
42
|
},
|
|
42
43
|
|
|
44
|
+
// The installed build is newer than the running one. The page builds the
|
|
45
|
+
// diagnostics entry (the place its restart action lives) from the offer in
|
|
46
|
+
// meta; the offer carries no restart token, which is issued per requester.
|
|
47
|
+
build_update_offer: function (data) {
|
|
48
|
+
return {
|
|
49
|
+
type: "build_update_offer",
|
|
50
|
+
title: data.title || "A newer build is installed",
|
|
51
|
+
body: data.body || "",
|
|
52
|
+
meta: {
|
|
53
|
+
message: data.message || "",
|
|
54
|
+
buildUpdate: data.buildUpdate || null,
|
|
55
|
+
actionable: data.actionable || null,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
update_available: function (data) {
|
|
61
|
+
return {
|
|
62
|
+
type: "update_available",
|
|
63
|
+
title: data.title || "Update available",
|
|
64
|
+
body: data.body || "",
|
|
65
|
+
meta: { version: data.version || "", current: data.current || "" },
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
|
|
43
69
|
loop_complete: function (data) {
|
|
44
70
|
var reason = data.reason || "complete";
|
|
45
71
|
var body = (reason === "pass" || reason === "complete")
|
|
@@ -138,6 +164,10 @@ var formatters = {
|
|
|
138
164
|
},
|
|
139
165
|
};
|
|
140
166
|
|
|
167
|
+
// A loop that ended in error is its own type, so it is registered and filtered
|
|
168
|
+
// as one; the formatter reads the reason either way.
|
|
169
|
+
formatters.loop_error = formatters.loop_complete;
|
|
170
|
+
|
|
141
171
|
// ========================================================
|
|
142
172
|
// Module (global singleton)
|
|
143
173
|
// ========================================================
|
|
@@ -155,16 +185,21 @@ function attachNotifications(ctx) {
|
|
|
155
185
|
var isMultiUser = ctx.isMultiUser || null;
|
|
156
186
|
var listAdmins = ctx.listAdmins || null;
|
|
157
187
|
|
|
188
|
+
var onResolvedByOperator = typeof ctx.onResolvedByOperator === "function" ? ctx.onResolvedByOperator : null;
|
|
189
|
+
|
|
158
190
|
// A prompt notification (and the reminder about it) is actionable only while
|
|
159
191
|
// its prompt's resolver lives in this process; none survives a restart, so a
|
|
160
|
-
// persisted one would offer buttons for a prompt nothing can answer.
|
|
192
|
+
// persisted one would offer buttons for a prompt nothing can answer. A type
|
|
193
|
+
// registered ephemeral (the build-update offer) is rebuilt from live state.
|
|
161
194
|
function loadNotifications() {
|
|
162
195
|
try {
|
|
163
196
|
var raw = fs.readFileSync(NOTIF_FILE, "utf8");
|
|
164
197
|
var parsed = JSON.parse(raw);
|
|
165
198
|
if (Array.isArray(parsed)) {
|
|
166
199
|
return parsed.filter(function (n) {
|
|
167
|
-
|
|
200
|
+
if (!n) return false;
|
|
201
|
+
var registered = notifyCore.getType(n.type);
|
|
202
|
+
return !(n.type === "permission_request" || n.type === "permission_reminder" || (registered && registered.ephemeral));
|
|
168
203
|
});
|
|
169
204
|
}
|
|
170
205
|
} catch (e) {}
|
|
@@ -242,6 +277,7 @@ function attachNotifications(ctx) {
|
|
|
242
277
|
slug: data.slug || "",
|
|
243
278
|
sessionId: data.sessionId || null,
|
|
244
279
|
mateId: data.mateId || null,
|
|
280
|
+
peerId: data.peerId || null,
|
|
245
281
|
ownerId: data.ownerId || null,
|
|
246
282
|
targetUserId: data.targetUserId || null,
|
|
247
283
|
targetUserIds: Array.isArray(data.targetUserIds) ? data.targetUserIds : null,
|
|
@@ -321,11 +357,32 @@ function attachNotifications(ctx) {
|
|
|
321
357
|
if (ids.length) dismiss(ids);
|
|
322
358
|
}
|
|
323
359
|
|
|
360
|
+
// The operator closed these banners. A notification of a type that is also
|
|
361
|
+
// shown on the phone (push) is closed there too, and the type's owner is told
|
|
362
|
+
// it was declined, so a close in one window is a close on every device.
|
|
363
|
+
function resolveDismissed(list) {
|
|
364
|
+
if (!pushModule && !onResolvedByOperator) return;
|
|
365
|
+
var core = notifyCore.notifyFor(pushModule, api);
|
|
366
|
+
var seen = Object.create(null);
|
|
367
|
+
list.forEach(function (n) {
|
|
368
|
+
var type = notifyCore.getType(n.type);
|
|
369
|
+
if (!type || type.category !== "system" || type.closeOnResolve || seen[n.type]) return;
|
|
370
|
+
// Only a system type about the console itself (no project, no session)
|
|
371
|
+
// is closed this way; a sign-in notice belongs to its session.
|
|
372
|
+
if (n.sessionId || n.slug) return;
|
|
373
|
+
seen[n.type] = true;
|
|
374
|
+
core.resolve({ slug: null, sessionId: null }, { ownerId: null, isMultiUser: isMultiUser, listAdmins: listAdmins }, { type: n.type });
|
|
375
|
+
if (onResolvedByOperator) onResolvedByOperator(n.type);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
324
379
|
function dismissAll() {
|
|
325
380
|
if (notifications.length > 0) {
|
|
381
|
+
var closing = notifications;
|
|
326
382
|
notifications = [];
|
|
327
383
|
saveNotifications();
|
|
328
384
|
broadcastAll({ type: "notification_dismissed_all", unreadCount: 0 });
|
|
385
|
+
resolveDismissed(closing);
|
|
329
386
|
}
|
|
330
387
|
}
|
|
331
388
|
|
|
@@ -347,11 +404,11 @@ function attachNotifications(ctx) {
|
|
|
347
404
|
}
|
|
348
405
|
}
|
|
349
406
|
|
|
350
|
-
|
|
351
|
-
|
|
407
|
+
// A notification aimed at users is shown to them alone, whatever its type:
|
|
408
|
+
// the live delivery and the list a connecting client is handed agree.
|
|
352
409
|
function visibleTo(n, viewer) {
|
|
353
410
|
if (Array.isArray(n.targetUserIds)) return n.targetUserIds.indexOf(viewer) !== -1;
|
|
354
|
-
if (
|
|
411
|
+
if (n.targetUserId) return n.targetUserId === viewer;
|
|
355
412
|
return true;
|
|
356
413
|
}
|
|
357
414
|
|
|
@@ -407,7 +464,10 @@ function attachNotifications(ctx) {
|
|
|
407
464
|
|
|
408
465
|
function handleNotificationMessage(ws, msg) {
|
|
409
466
|
if (msg.type === "notification_dismiss") {
|
|
410
|
-
|
|
467
|
+
var ids = Array.isArray(msg.ids) ? msg.ids : [];
|
|
468
|
+
var closing = notifications.filter(function (n) { return ids.indexOf(n.id) !== -1; });
|
|
469
|
+
dismiss(ids);
|
|
470
|
+
resolveDismissed(closing);
|
|
411
471
|
return true;
|
|
412
472
|
}
|
|
413
473
|
if (msg.type === "notification_dismiss_all") {
|
|
@@ -430,7 +490,7 @@ function attachNotifications(ctx) {
|
|
|
430
490
|
return false;
|
|
431
491
|
}
|
|
432
492
|
|
|
433
|
-
|
|
493
|
+
var api = {
|
|
434
494
|
notify: notify,
|
|
435
495
|
show: show,
|
|
436
496
|
dismissKeys: dismissKeys,
|
|
@@ -441,6 +501,7 @@ function attachNotifications(ctx) {
|
|
|
441
501
|
sendConnectionState: sendConnectionState,
|
|
442
502
|
handleNotificationMessage: handleNotificationMessage,
|
|
443
503
|
};
|
|
504
|
+
return api;
|
|
444
505
|
}
|
|
445
506
|
|
|
446
507
|
module.exports = { attachNotifications: attachNotifications };
|
package/lib/project-sessions.js
CHANGED
|
@@ -21,6 +21,7 @@ var { checkPermissionMode } = require("./permission-mode-policy");
|
|
|
21
21
|
var { attachPermissionSettings, isServerAdmin } = require("./project-permission-settings");
|
|
22
22
|
var { effectiveSessionMode } = require("./sessions");
|
|
23
23
|
var { composeRestartingNotice } = require("./build-update-offer");
|
|
24
|
+
var { notifyFor } = require("./notify");
|
|
24
25
|
// Kick off SDK agent discovery in the background at module load.
|
|
25
26
|
// Errors are swallowed inside refresh(); the cache starts empty and fills
|
|
26
27
|
// when the SDK subprocess completes initialization (~9s on this box).
|
|
@@ -801,7 +802,15 @@ function attachSessions(ctx) {
|
|
|
801
802
|
fetchVersion(updateChannel).then(function (latest) {
|
|
802
803
|
if (latest && isNewer(latest, currentVersion)) {
|
|
803
804
|
setLatestVersion(latest);
|
|
805
|
+
// The asking client's settings button reads the reply; the banner and
|
|
806
|
+
// the push for every admin come from the core, which collapses the
|
|
807
|
+
// repeat from each client's hourly check into one.
|
|
804
808
|
sendTo(ws, { type: "update_available", version: latest, current: currentVersion });
|
|
809
|
+
var updateText = { title: "Update available", body: "Clagentic: Console v" + latest + " is available" };
|
|
810
|
+
notifyFor(pushModule, getNotificationsModule()).notify("update_available", { slug: null, sessionId: null }, {
|
|
811
|
+
push: updateText,
|
|
812
|
+
banner: Object.assign({ version: latest, current: currentVersion }, updateText),
|
|
813
|
+
}, {});
|
|
805
814
|
} else {
|
|
806
815
|
sendTo(ws, { type: "up_to_date", version: currentVersion });
|
|
807
816
|
}
|