@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
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// team-traffic.js - the read side of the Team view's agent-messages section:
|
|
2
|
+
// the agent-to-agent traffic that went through the console, grouped by
|
|
3
|
+
// counterpart pair, for one caller.
|
|
4
|
+
//
|
|
5
|
+
// Read-only. The outbound ledger (lib/outbound-ledger.js) is the primary source:
|
|
6
|
+
// every open-session and send-input leaves one entry there. Two routes never
|
|
7
|
+
// reach the ledger and are filled from the receiving session's own history, in
|
|
8
|
+
// the same aggregation (no second view):
|
|
9
|
+
// - a scheduled firing (fireScheduled in session-input.js records the turn the
|
|
10
|
+
// console composed, never a ledger entry)
|
|
11
|
+
// - a loop iteration (project-loop.js starts its sessions itself and does not
|
|
12
|
+
// call session-input.js)
|
|
13
|
+
// Both are recorded on the target as a user_message from the console's own
|
|
14
|
+
// automation (senderKind "automation"). The fill reads the sessions the console
|
|
15
|
+
// holds in memory, so it only reaches back as far as their loaded history.
|
|
16
|
+
// Armed scheduled inputs are listed as pending, read-only.
|
|
17
|
+
//
|
|
18
|
+
// The read rules are the ledger's (lib/outbound-access.js), unchanged. An entry
|
|
19
|
+
// is shown only when its text may be shown to this caller: one whose text the
|
|
20
|
+
// caller cannot read, or that was never stored because the target runs as
|
|
21
|
+
// another OS user, is counted and its reason reported, and is not listed.
|
|
22
|
+
|
|
23
|
+
var outboundEntry = require("./outbound-entry");
|
|
24
|
+
var injectedSender = require("./injected-sender");
|
|
25
|
+
var { INITIATORS } = require("./turn-initiator");
|
|
26
|
+
|
|
27
|
+
var MAX_MESSAGES = 1000;
|
|
28
|
+
var MAX_TEXT_CHARS = 4000;
|
|
29
|
+
var MAX_REASONS = 5;
|
|
30
|
+
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
31
|
+
var OTHER_OS_USER = "the target session runs as another OS user";
|
|
32
|
+
|
|
33
|
+
var KIND = Object.freeze({ OPEN: "open", INPUT: "input", SCHEDULED: "scheduled", REPLY: "reply", LOOP: "loop" });
|
|
34
|
+
|
|
35
|
+
var OUTBOUND_VERBS = new Set([outboundEntry.VERB.SEND_INPUT, outboundEntry.VERB.OPEN_SESSION]);
|
|
36
|
+
|
|
37
|
+
function clip(text) {
|
|
38
|
+
if (typeof text !== "string") return { text: null, truncated: false };
|
|
39
|
+
if (text.length <= MAX_TEXT_CHARS) return { text: text, truncated: false };
|
|
40
|
+
return { text: text.slice(0, MAX_TEXT_CHARS), truncated: true };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function kindOfEntry(entry) {
|
|
44
|
+
if (entry.target && entry.target.reply === true) return KIND.REPLY;
|
|
45
|
+
if (entry.initiator === INITIATORS.SCHEDULED || entry.initiator === INITIATORS.SCHEDULED_NOW) return KIND.SCHEDULED;
|
|
46
|
+
return entry.verb === outboundEntry.VERB.OPEN_SESSION ? KIND.OPEN : KIND.INPUT;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function kindOfAutomation(initiator) {
|
|
50
|
+
return initiator === INITIATORS.LOOP ? KIND.LOOP : KIND.SCHEDULED;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// A sender as the client's identity adapter takes it (injected-identity.js).
|
|
54
|
+
function identityOfLedgerSender(sender) {
|
|
55
|
+
sender = sender || {};
|
|
56
|
+
var out = { senderKind: sender.kind || injectedSender.SENDER_KIND.UNDECLARED, attribution: sender.attribution || "unverified" };
|
|
57
|
+
if (sender.name) out.fromName = sender.name;
|
|
58
|
+
if (sender.agent) out.senderAgent = sender.agent;
|
|
59
|
+
if (sender.project) out.senderProject = sender.project;
|
|
60
|
+
if (sender.sessionId) out.senderSessionId = sender.sessionId;
|
|
61
|
+
if (sender.declaredName) out.declaredName = sender.declaredName;
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function identityOfAutomation(entry) {
|
|
66
|
+
return {
|
|
67
|
+
senderKind: injectedSender.SENDER_KIND.AUTOMATION,
|
|
68
|
+
attribution: "console",
|
|
69
|
+
fromName: entry.fromName,
|
|
70
|
+
initiator: entry.initiator,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Stable text for "who": the pair is the same pair whichever entry names it.
|
|
75
|
+
function senderKey(sender) {
|
|
76
|
+
sender = sender || {};
|
|
77
|
+
if (sender.attribution === "extracted" && sender.project && (sender.cliSessionId || sender.sessionId)) {
|
|
78
|
+
return "s:" + sender.project + "/" + (sender.cliSessionId || "console-" + sender.sessionId);
|
|
79
|
+
}
|
|
80
|
+
if (sender.kind === "declared" && sender.name) return "d:" + sender.name + (sender.fromSession ? "/" + sender.fromSession : "");
|
|
81
|
+
return "u:";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function targetKey(target) {
|
|
85
|
+
target = target || {};
|
|
86
|
+
return (target.project || "") + "/" + (target.cliSessionId || (target.sessionId ? "console-" + target.sessionId : target.address || ""));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// deps:
|
|
90
|
+
// ledger lib/outbound-ledger.js createOutboundLedger() result
|
|
91
|
+
// access lib/outbound-access.js createOutboundAccess() result
|
|
92
|
+
// getProject(slug) -> project context | null
|
|
93
|
+
// listProjects() -> [{ slug, project }] every project held
|
|
94
|
+
// scheduledInput optional { armedForSession(slug, session) } (lib/scheduled-input/service.js)
|
|
95
|
+
// now() ms clock (default Date.now)
|
|
96
|
+
function createTeamTraffic(deps) {
|
|
97
|
+
var ledger = deps.ledger;
|
|
98
|
+
var access = deps.access;
|
|
99
|
+
var getProject = deps.getProject;
|
|
100
|
+
var listProjects = deps.listProjects || function () { return []; };
|
|
101
|
+
var scheduledInput = deps.scheduledInput || null;
|
|
102
|
+
var now = deps.now || Date.now;
|
|
103
|
+
|
|
104
|
+
// The caller's view of one session, by the same decision the ledger applies to
|
|
105
|
+
// its prompts. A session is named by project and vendor id only.
|
|
106
|
+
function mayRead(project, cliSessionId, caller) {
|
|
107
|
+
return access.canReadPrompt({ target: { project: project, cliSessionId: cliSessionId } }, caller);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// The live session behind a vendor id, as the sidebar addresses it now. A
|
|
111
|
+
// console id is renumbered by a restart, so it is looked up here at read time
|
|
112
|
+
// and never stored. null when the session is gone or the caller may not read it.
|
|
113
|
+
function linkFor(slug, cliSessionId, caller) {
|
|
114
|
+
if (!slug || !cliSessionId) return null;
|
|
115
|
+
var project = getProject(slug);
|
|
116
|
+
if (!project || !project.sm || !project.sm.sessions) return null;
|
|
117
|
+
var found = null;
|
|
118
|
+
project.sm.sessions.forEach(function (s) {
|
|
119
|
+
if (!found && s.cliSessionId === cliSessionId) found = s;
|
|
120
|
+
});
|
|
121
|
+
if (!found || !mayRead(slug, cliSessionId, caller).allowed) return null;
|
|
122
|
+
return { project: slug, id: found.localId };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function describeTarget(target) {
|
|
126
|
+
target = target || {};
|
|
127
|
+
var out = { project: target.project || null };
|
|
128
|
+
if (target.agent) out.agent = target.agent;
|
|
129
|
+
if (target.name) out.name = target.name;
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Collects what the caller may see into `state`; counts and explains the rest.
|
|
134
|
+
function collect(state, caller, cutoff) {
|
|
135
|
+
function withhold(reason) {
|
|
136
|
+
state.withheldCount++;
|
|
137
|
+
if (reason && state.reasons.indexOf(reason) === -1 && state.reasons.length < MAX_REASONS) state.reasons.push(reason);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
ledger.readAttributed({}).concat(ledger.readUnattributed({})).forEach(function (e) {
|
|
141
|
+
if (!OUTBOUND_VERBS.has(e.verb)) return;
|
|
142
|
+
var verdict = access.canReadPrompt(e, caller);
|
|
143
|
+
if (!verdict.allowed) return withhold(verdict.reason);
|
|
144
|
+
if (e.promptWithheld === true) return withhold(e.promptWithheldReason || OTHER_OS_USER);
|
|
145
|
+
var sender = e.sender || {};
|
|
146
|
+
var text = clip(e.prompt);
|
|
147
|
+
state.items.push({
|
|
148
|
+
ts: e.ts,
|
|
149
|
+
pairKey: senderKey(sender) + ">" + targetKey(e.target),
|
|
150
|
+
senderIdentity: identityOfLedgerSender(sender),
|
|
151
|
+
senderRef: { project: sender.project || null, cliSessionId: sender.cliSessionId || null },
|
|
152
|
+
target: describeTarget(e.target),
|
|
153
|
+
targetRef: { project: (e.target || {}).project || null, cliSessionId: (e.target || {}).cliSessionId || null },
|
|
154
|
+
message: {
|
|
155
|
+
ts: e.ts,
|
|
156
|
+
kind: kindOfEntry(e),
|
|
157
|
+
result: e.result,
|
|
158
|
+
reason: e.reason || null,
|
|
159
|
+
initiator: e.initiator || null,
|
|
160
|
+
messageId: e.messageId || null,
|
|
161
|
+
text: text.text,
|
|
162
|
+
truncated: text.truncated,
|
|
163
|
+
contextNote: typeof e.contextNote === "string" ? e.contextNote : null,
|
|
164
|
+
source: "ledger",
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
listProjects().forEach(function (held) {
|
|
170
|
+
var project = held.project;
|
|
171
|
+
if (!project || !project.sm || !project.sm.sessions) return;
|
|
172
|
+
project.sm.sessions.forEach(function (s) {
|
|
173
|
+
var history = Array.isArray(s.history) ? s.history : [];
|
|
174
|
+
var fromHistory = history.filter(function (h) {
|
|
175
|
+
return injectedSender.isInjected(h) && h.senderKind === injectedSender.SENDER_KIND.AUTOMATION
|
|
176
|
+
&& typeof h._ts === "number" && h._ts >= cutoff;
|
|
177
|
+
});
|
|
178
|
+
if (!fromHistory.length) return;
|
|
179
|
+
var linux = typeof project.getLinuxUserForSession === "function" ? project.getLinuxUserForSession(s) : null;
|
|
180
|
+
var verdict = mayRead(held.slug, s.cliSessionId, caller);
|
|
181
|
+
fromHistory.forEach(function (h) {
|
|
182
|
+
if (!verdict.allowed) return withhold(verdict.reason);
|
|
183
|
+
if (linux) return withhold(OTHER_OS_USER);
|
|
184
|
+
var text = clip(h.text);
|
|
185
|
+
var tRef = { project: held.slug, cliSessionId: s.cliSessionId || null };
|
|
186
|
+
state.items.push({
|
|
187
|
+
ts: new Date(h._ts).toISOString(),
|
|
188
|
+
pairKey: "a:" + h.fromName + ">" + targetKey({ project: held.slug, cliSessionId: s.cliSessionId, sessionId: String(s.localId) }),
|
|
189
|
+
senderIdentity: identityOfAutomation(h),
|
|
190
|
+
senderRef: { project: null, cliSessionId: null },
|
|
191
|
+
target: { project: held.slug, agent: s.agentName || undefined, name: s.sessionName || undefined },
|
|
192
|
+
targetRef: tRef,
|
|
193
|
+
message: {
|
|
194
|
+
ts: new Date(h._ts).toISOString(),
|
|
195
|
+
kind: kindOfAutomation(h.initiator),
|
|
196
|
+
result: "delivered",
|
|
197
|
+
reason: null,
|
|
198
|
+
initiator: h.initiator || null,
|
|
199
|
+
messageId: h.messageId || null,
|
|
200
|
+
text: text.text,
|
|
201
|
+
truncated: text.truncated,
|
|
202
|
+
contextNote: typeof h.contextNote === "string" ? h.contextNote : null,
|
|
203
|
+
source: "session",
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Armed scheduled inputs of the sessions the caller may read, as pending items.
|
|
212
|
+
function collectPending(state, caller) {
|
|
213
|
+
if (!scheduledInput || typeof scheduledInput.armedForSession !== "function") return;
|
|
214
|
+
listProjects().forEach(function (held) {
|
|
215
|
+
var project = held.project;
|
|
216
|
+
if (!project || !project.sm || !project.sm.sessions) return;
|
|
217
|
+
project.sm.sessions.forEach(function (s) {
|
|
218
|
+
var armed;
|
|
219
|
+
try { armed = scheduledInput.armedForSession(held.slug, s); } catch (e) {
|
|
220
|
+
console.error("[team-traffic] could not list the armed scheduled inputs of " + held.slug + ":", e && e.message ? e.message : e);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (!armed.length || !mayRead(held.slug, s.cliSessionId, caller).allowed) return;
|
|
224
|
+
if (typeof project.getLinuxUserForSession === "function" && project.getLinuxUserForSession(s)) return;
|
|
225
|
+
armed.forEach(function (r) {
|
|
226
|
+
var text = clip(r.text);
|
|
227
|
+
state.pending.push({
|
|
228
|
+
pairKey: "a:" + injectedSender.AUTOMATION_NAMES[INITIATORS.SCHEDULED] + ">" + targetKey({ project: held.slug, cliSessionId: s.cliSessionId, sessionId: String(s.localId) }),
|
|
229
|
+
senderIdentity: { senderKind: injectedSender.SENDER_KIND.AUTOMATION, attribution: "console", fromName: injectedSender.AUTOMATION_NAMES[INITIATORS.SCHEDULED], initiator: INITIATORS.SCHEDULED },
|
|
230
|
+
target: { project: held.slug, agent: s.agentName || undefined, name: s.sessionName || undefined },
|
|
231
|
+
targetRef: { project: held.slug, cliSessionId: s.cliSessionId || null },
|
|
232
|
+
pending: {
|
|
233
|
+
id: r.id,
|
|
234
|
+
kind: KIND.SCHEDULED,
|
|
235
|
+
nextAt: r.nextAt,
|
|
236
|
+
every: r.every,
|
|
237
|
+
createdBy: r.createdBy,
|
|
238
|
+
text: text.text,
|
|
239
|
+
truncated: text.truncated,
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// caller: { user, authenticated } as for lib/outbound-query.js.
|
|
248
|
+
// Returns { ok, result, retentionDays, pairs, messages, pending, withheld }
|
|
249
|
+
// or { ok: false, result: "error", reason } when the ledger cannot be read.
|
|
250
|
+
function snapshot(caller) {
|
|
251
|
+
var days = ledger.retentionDays();
|
|
252
|
+
var base = { ok: true, result: "listed", retentionDays: days };
|
|
253
|
+
if (days === 0) {
|
|
254
|
+
return Object.assign(base, {
|
|
255
|
+
pairs: [], messages: [], pending: [], withheld: { count: 0, reasons: [] },
|
|
256
|
+
note: "the outbound ledger is turned off (outboundRetentionDays is 0)",
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
var state = { items: [], pending: [], withheldCount: 0, reasons: [] };
|
|
260
|
+
try {
|
|
261
|
+
collect(state, caller, now() - days * DAY_MS);
|
|
262
|
+
} catch (e) {
|
|
263
|
+
// The detail (a message can carry a host path) stays in the server log; the
|
|
264
|
+
// client gets the same generic reason the ws handler uses.
|
|
265
|
+
console.error("[team-traffic] could not read the outbound ledger:", e && e.message ? e.message : e, e && e.code ? "(" + e.code + ")" : "");
|
|
266
|
+
return { ok: false, result: "error", reason: "the agent messages could not be read" };
|
|
267
|
+
}
|
|
268
|
+
collectPending(state, caller);
|
|
269
|
+
|
|
270
|
+
state.items.sort(function (a, b) { return Date.parse(a.ts) - Date.parse(b.ts); });
|
|
271
|
+
var pairs = new Map();
|
|
272
|
+
function pairOf(item) {
|
|
273
|
+
var p = pairs.get(item.pairKey);
|
|
274
|
+
if (!p) {
|
|
275
|
+
p = {
|
|
276
|
+
key: item.pairKey,
|
|
277
|
+
sender: Object.assign({}, item.senderIdentity, { link: item.senderRef ? linkFor(item.senderRef.project, item.senderRef.cliSessionId, caller) : null }),
|
|
278
|
+
target: Object.assign({}, item.target, { link: linkFor(item.targetRef.project, item.targetRef.cliSessionId, caller) }),
|
|
279
|
+
count: 0,
|
|
280
|
+
pendingCount: 0,
|
|
281
|
+
lastAt: null,
|
|
282
|
+
};
|
|
283
|
+
pairs.set(item.pairKey, p);
|
|
284
|
+
}
|
|
285
|
+
return p;
|
|
286
|
+
}
|
|
287
|
+
state.items.forEach(function (item) {
|
|
288
|
+
var p = pairOf(item);
|
|
289
|
+
p.count++;
|
|
290
|
+
p.lastAt = item.ts;
|
|
291
|
+
});
|
|
292
|
+
var pending = state.pending.map(function (item) {
|
|
293
|
+
pairOf(item).pendingCount++;
|
|
294
|
+
return Object.assign({ pairKey: item.pairKey }, item.pending);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
var shown = state.items;
|
|
298
|
+
var truncated = 0;
|
|
299
|
+
if (shown.length > MAX_MESSAGES) {
|
|
300
|
+
truncated = shown.length - MAX_MESSAGES;
|
|
301
|
+
shown = shown.slice(truncated);
|
|
302
|
+
}
|
|
303
|
+
var list = Array.from(pairs.values()).sort(function (a, b) {
|
|
304
|
+
return (b.lastAt ? Date.parse(b.lastAt) : 0) - (a.lastAt ? Date.parse(a.lastAt) : 0);
|
|
305
|
+
});
|
|
306
|
+
return Object.assign(base, {
|
|
307
|
+
pairs: list,
|
|
308
|
+
messages: shown.map(function (item) { return Object.assign({ pairKey: item.pairKey }, item.message); }),
|
|
309
|
+
messagesTruncated: truncated,
|
|
310
|
+
pending: pending,
|
|
311
|
+
withheld: { count: state.withheldCount, reasons: state.reasons },
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return { snapshot: snapshot };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
module.exports = { createTeamTraffic: createTeamTraffic, KIND: KIND, MAX_MESSAGES: MAX_MESSAGES, MAX_TEXT_CHARS: MAX_TEXT_CHARS };
|
package/lib/usage-store.js
CHANGED
|
@@ -195,6 +195,8 @@ function createUsageStore(opts) {
|
|
|
195
195
|
}
|
|
196
196
|
var loaded = newMap();
|
|
197
197
|
var dropped = 0;
|
|
198
|
+
var kept = 0;
|
|
199
|
+
var newest = null;
|
|
198
200
|
Object.keys(parsed.vendors).forEach(function (vendor) {
|
|
199
201
|
var buckets = parsed.vendors[vendor];
|
|
200
202
|
if (isUnsafeKey(vendor)) { dropped++; return; }
|
|
@@ -203,10 +205,15 @@ function createUsageStore(opts) {
|
|
|
203
205
|
var rec = isUnsafeKey(b) ? null : validRecord(buckets[b]);
|
|
204
206
|
if (!rec) { dropped++; return; }
|
|
205
207
|
(loaded[vendor] || (loaded[vendor] = newMap()))[b] = rec;
|
|
208
|
+
kept++;
|
|
209
|
+
var t = typeof rec.observedAt === "string" ? Date.parse(rec.observedAt) : NaN;
|
|
210
|
+
if (isFinite(t) && (newest === null || t > newest)) newest = t;
|
|
206
211
|
});
|
|
207
212
|
});
|
|
208
213
|
records = loaded;
|
|
209
214
|
if (dropped > 0) log("[usage-store] Clagentic: Console dropped " + dropped + " malformed usage record(s) from " + file);
|
|
215
|
+
// The restart journal's proof that persisted usage survived the restart.
|
|
216
|
+
log("[usage-store] Clagentic: Console loaded " + kept + " usage record(s) from " + file + ", newest observedAt " + (newest === null ? "none" : new Date(newest).toISOString()));
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
// info.resetsAt is epoch seconds, as the adapters report it.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// The settings of the composer's ! mode: whether it is on, how long a command
|
|
4
|
+
// may run, and how much of its output is kept. Stored in daemon.json beside the
|
|
5
|
+
// other server settings and read when a command is sent, so a change needs no
|
|
6
|
+
// restart. Each default is what runs until an administrator changes it.
|
|
7
|
+
|
|
8
|
+
var { ownValue } = require("./prompt-kinds/codecs");
|
|
9
|
+
|
|
10
|
+
var DEFAULT_TIMEOUT_MINUTES = 10;
|
|
11
|
+
var DEFAULT_MAX_OUTPUT_KIB = 256;
|
|
12
|
+
|
|
13
|
+
// A day is far past any command worth waiting on in a chat; 4 MiB is far past
|
|
14
|
+
// any output worth putting in a conversation.
|
|
15
|
+
var MAX_TIMEOUT_MINUTES = 24 * 60;
|
|
16
|
+
var MAX_OUTPUT_KIB = 4096;
|
|
17
|
+
|
|
18
|
+
function isCount(v, max) {
|
|
19
|
+
return typeof v === "number" && isFinite(v) && Math.floor(v) === v && v >= 1 && v <= max;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The setting names a client may send, each with its type check. Anything else
|
|
23
|
+
// in a request is refused rather than stored. A name is also its daemon.json key.
|
|
24
|
+
var SETTING_TYPES = {
|
|
25
|
+
userShellEnabled: function (v) { return typeof v === "boolean"; },
|
|
26
|
+
userShellTimeoutMinutes: function (v) { return isCount(v, MAX_TIMEOUT_MINUTES); },
|
|
27
|
+
userShellMaxOutputKiB: function (v) { return isCount(v, MAX_OUTPUT_KIB); },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {?object} config - the daemon configuration (daemon.json contents).
|
|
32
|
+
* @returns {{enabled: boolean, timeoutMinutes: number, maxOutputKiB: number,
|
|
33
|
+
* timeoutMs: number, maxOutputBytes: number}}
|
|
34
|
+
*/
|
|
35
|
+
function readUserShellSettings(config) {
|
|
36
|
+
var cfg = config || {};
|
|
37
|
+
var timeoutMinutes = isCount(cfg.userShellTimeoutMinutes, MAX_TIMEOUT_MINUTES)
|
|
38
|
+
? cfg.userShellTimeoutMinutes : DEFAULT_TIMEOUT_MINUTES;
|
|
39
|
+
var maxOutputKiB = isCount(cfg.userShellMaxOutputKiB, MAX_OUTPUT_KIB)
|
|
40
|
+
? cfg.userShellMaxOutputKiB : DEFAULT_MAX_OUTPUT_KIB;
|
|
41
|
+
return {
|
|
42
|
+
// Only an explicit false turns it off: an absent field is the default, on.
|
|
43
|
+
enabled: cfg.userShellEnabled !== false,
|
|
44
|
+
timeoutMinutes: timeoutMinutes,
|
|
45
|
+
maxOutputKiB: maxOutputKiB,
|
|
46
|
+
timeoutMs: timeoutMinutes * 60 * 1000,
|
|
47
|
+
maxOutputBytes: maxOutputKiB * 1024,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The fields of a change request that name a known setting with a value of the
|
|
53
|
+
* right type; nothing else passes. `rejected` lists the names that did not.
|
|
54
|
+
* @returns {{values: object, rejected: string[]}}
|
|
55
|
+
*/
|
|
56
|
+
function pickSettingChanges(request) {
|
|
57
|
+
var values = {};
|
|
58
|
+
var rejected = [];
|
|
59
|
+
Object.keys(request || {}).forEach(function (name) {
|
|
60
|
+
if (name === "type") return;
|
|
61
|
+
var check = ownValue(SETTING_TYPES, name);
|
|
62
|
+
if (typeof check === "function" && check(request[name])) values[name] = request[name];
|
|
63
|
+
else rejected.push(name);
|
|
64
|
+
});
|
|
65
|
+
return { values: values, rejected: rejected };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The wire message that tells a client the current settings. */
|
|
69
|
+
function settingsMessage(settings) {
|
|
70
|
+
return {
|
|
71
|
+
type: "user_shell_settings",
|
|
72
|
+
userShellEnabled: settings.enabled,
|
|
73
|
+
userShellTimeoutMinutes: settings.timeoutMinutes,
|
|
74
|
+
userShellMaxOutputKiB: settings.maxOutputKiB,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Applies accepted changes to a daemon configuration object; a value equal to
|
|
80
|
+
* its default is removed so daemon.json keeps showing only what was changed.
|
|
81
|
+
*/
|
|
82
|
+
function applySettingChanges(config, values) {
|
|
83
|
+
if (values.userShellEnabled !== undefined) {
|
|
84
|
+
if (values.userShellEnabled === false) config.userShellEnabled = false;
|
|
85
|
+
else delete config.userShellEnabled;
|
|
86
|
+
}
|
|
87
|
+
if (values.userShellTimeoutMinutes !== undefined) {
|
|
88
|
+
if (values.userShellTimeoutMinutes === DEFAULT_TIMEOUT_MINUTES) delete config.userShellTimeoutMinutes;
|
|
89
|
+
else config.userShellTimeoutMinutes = values.userShellTimeoutMinutes;
|
|
90
|
+
}
|
|
91
|
+
if (values.userShellMaxOutputKiB !== undefined) {
|
|
92
|
+
if (values.userShellMaxOutputKiB === DEFAULT_MAX_OUTPUT_KIB) delete config.userShellMaxOutputKiB;
|
|
93
|
+
else config.userShellMaxOutputKiB = values.userShellMaxOutputKiB;
|
|
94
|
+
}
|
|
95
|
+
return config;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
DEFAULT_TIMEOUT_MINUTES: DEFAULT_TIMEOUT_MINUTES,
|
|
100
|
+
DEFAULT_MAX_OUTPUT_KIB: DEFAULT_MAX_OUTPUT_KIB,
|
|
101
|
+
readUserShellSettings: readUserShellSettings,
|
|
102
|
+
pickSettingChanges: pickSettingChanges,
|
|
103
|
+
settingsMessage: settingsMessage,
|
|
104
|
+
applySettingChanges: applySettingChanges,
|
|
105
|
+
};
|
package/lib/ws-schema.js
CHANGED
|
@@ -60,8 +60,18 @@ var schema = {
|
|
|
60
60
|
// -----------------------------------------------------------------------
|
|
61
61
|
// Chat / streaming
|
|
62
62
|
// -----------------------------------------------------------------------
|
|
63
|
-
"message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Send a user chat message" },
|
|
63
|
+
"message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Send a user chat message. sendNow:true delivers it into the running turn when the agent can steer; otherwise it is queued as usual. messageId (a uuid minted by the page) is the message uuid at the agent and names it on message_delivered and cancel_queued_message" },
|
|
64
|
+
"message_delivered": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent took a chat message into the turn: {messageId}. The page turns the queued item it drew for that id into the normal user message, once. Also sent at once for a message that was not held as queued (the turn had ended, or the agent cannot withdraw a queued message)" },
|
|
65
|
+
"cancel_queued_message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Withdraw a chat message the page drew as queued: {messageId}. Answered with queued_message_cancelled" },
|
|
66
|
+
"queued_message_cancelled": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome for a queued chat message: {messageId, result}. cancelled: the agent dropped it and it is never delivered; the reply carries {text, pastes, imageCount} so the page can hand the message back even when it no longer holds its queued item. already_delivered: the server no longer tracks the message, because the agent took it in (message_delivered follows, or came first), it was cancelled before, or the id is unknown; no message_delivered follows in the last two cases. Nothing is handed back, so nothing is lost or doubled. pending: the agent did not drop it from its queue and cannot say whether it runs (a coalesced batch member, a held-back message); it stays queued and ends as message_delivered, or as dropped with its text when the agent never takes it. unsupported: the agent cannot withdraw it. error: the agent did not answer (message says why). dropped: the agent will not run the message: its query was closed before it took it, or a cancel answered pending and no turn took it in (a turn ending with a message merely waiting is not a drop: the agent runs it as its next turn); carries {text, pastes, imageCount, cause} (cause: closed, the query closed; send_now_missed, Send now interrupted the turn and the agent's receipt did not list the message as kept; not_taken, the idle grace timer settled it after a cancel the agent answered false to, with no turn running and no frame having named it; restart, the daemon restarted while it waited) and the page hands the text back. A dropped reply with nobody viewing the session is kept with the session and sent when a page next shows it. pending can also arrive unasked: a cancel of another message may have dropped this one too (it shares the dropped batch), and the page disables its controls. cancelled also goes, without text, to the other pages on the session when one page withdraws the message: a page that drew the item drops it, one that did not changes nothing" },
|
|
67
|
+
"queued_message_tracked": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A chat message the agent has not taken in yet, sent after a session is shown (a reload, a second tab): {messageId, text, pastes, imageCount, unconfirmed, sendNow?}. The page draws it as queued again with its controls, or, when sendNow is true (Send now was pressed on it), as sending with no controls and never as queued; message_delivered or queued_message_cancelled then ends it. A page that already holds an item for the id ignores it" },
|
|
68
|
+
"send_now_queued_message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Send now on a chat message the page drew as queued (already pushed to the agent): {messageId}. The server interrupts the running turn with the agent's queue kept, so the message runs as the next input at once; nothing is pushed again. Answered with queued_message_send_now" },
|
|
69
|
+
"queued_message_send_now": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of Send now on a queued chat message: {messageId, result}. requested: the turn was interrupted and the agent still holds the message (or sent no receipt to say otherwise); the page draws the item as sending, with no queued label or controls, and message_delivered ends it. Also sent, unasked, to the other pages on the session. already_delivered: the server no longer tracks the message (taken, cancelled, unknown); nothing was interrupted. no_turn: no turn runs, or the message was pushed into a query that is no longer the session's live one; nothing was interrupted and the item stays as it was. missed: the interrupt receipt did not list the message, so it was not kept; it is handed back through queued_message_cancelled (dropped, cause send_now_missed, with its text) and never pushed again. unsupported: the agent cannot interrupt. error: the agent did not answer (message says why); the item is drawn as queued again" },
|
|
64
70
|
"user_message": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Echo of the user message in the timeline" },
|
|
71
|
+
"shell": { direction: "c2s", handler: "lib/project-user-shell.js", description: "Run a command typed with !: {command, requestId?}. Only leading whitespace is dropped from the command. The server checks in order: the setting off, OS-user isolation, plan mode, a running turn or command, no live query, an adapter without runUserShellCommand, then the permission gate as a Bash tool call. Answered with shell_result. A stop request cancels a pending approval and aborts a running command" },
|
|
72
|
+
"shell_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of a shell request, sent to every client viewing the session and recorded in its history: {requestId, command, exitCode, durationMs, output, truncated, timedOut, interrupted}, plus refused:true with reason (disabled, empty, os_users, plan, no_terminal, busy, no_query, unsupported) and message, denied:true when the gate did not approve it, or error:true (output carries the message) when it could not run" },
|
|
73
|
+
"set_user_shell_settings": { direction: "c2s", handler: "lib/project-user-shell.js", description: "Change the ! settings (admin only): userShellEnabled, userShellTimeoutMinutes, userShellMaxOutputKiB" },
|
|
74
|
+
"user_shell_settings": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The ! settings, sent on connect and to every client after a change: userShellEnabled (default true), userShellTimeoutMinutes (default 10), userShellMaxOutputKiB (default 256)" },
|
|
65
75
|
"delta": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Incremental text delta from the assistant" },
|
|
66
76
|
"result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Final assistant result text" },
|
|
67
77
|
"status": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Processing status update (e.g. 'processing')" },
|
|
@@ -114,6 +124,14 @@ var schema = {
|
|
|
114
124
|
"team_message": { direction: "s2c", handler: "lib/public/modules/team-panel.js", description: "Teammate SendMessage event (peer DM)" },
|
|
115
125
|
"team_gone": { direction: "s2c", handler: "lib/public/modules/team-panel.js", description: "Team was deleted/cleaned up" },
|
|
116
126
|
"team_request_state": { direction: "c2s", handler: "lib/project-team.js", description: "Client requests current team snapshot" },
|
|
127
|
+
"team_traffic_request": { direction: "c2s", handler: "lib/team-traffic-ws.js", description: "Ask for the agent-to-agent traffic through the console that this connection may read" },
|
|
128
|
+
"team_traffic": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Agent messages (drawn by agent-messages.js): pairs (count, last seen), messages, pending scheduled inputs, withheld count and reasons" },
|
|
129
|
+
"team_traffic_changed": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "An open or send landed; ask again (carries no content)" },
|
|
130
|
+
"agent_roster_request": { direction: "c2s", handler: "lib/agent-roster-ws.js", description: "Ask for the agent roster" },
|
|
131
|
+
"agent_roster": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster (drawn by agent-roster.js): every agent identity the console has seen, each {key, firstSeen, lastSeen, places [{source, project, session, lastSeen}], avatar}; avatar is {style, seed}, {custom} (a custom-icon slug) or null. Sent to a connection on connect and on request, limited to the projects that connection may read (an agent with no readable place is omitted); the avatar map every agent label resolves from" },
|
|
132
|
+
"agent_roster_changed": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster changed; send agent_roster_request (carries no content)" },
|
|
133
|
+
"agent_avatar_set": { direction: "c2s", handler: "lib/agent-roster-ws.js", description: "Choose the avatar of a seen agent: {key, avatar}; avatar is {style, seed}, {custom} or null to clear" },
|
|
134
|
+
"agent_avatar_set_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of agent_avatar_set for the client that asked: {key, ok, error?}" },
|
|
117
135
|
"task_started": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Background task started" },
|
|
118
136
|
"task_progress": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Background task progress update" },
|
|
119
137
|
// lr-66c118 fold-in: see the plan_content/sdk_notification/diagnostic note above.
|
|
@@ -130,7 +148,7 @@ var schema = {
|
|
|
130
148
|
"prompt_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt awaits the operator: {requestId, kind, toolUseId, label: {project, session, agent}, ...kind fields} (label names whose prompt it is; agent is empty unless a background agent raised it). 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" },
|
|
131
149
|
"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" },
|
|
132
150
|
"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 grants the whole tool (Skill: the one skill) for the rest of the session, and 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" },
|
|
133
|
-
"prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action, source?}; a permission prompt forced by a user ask rule also carries matchedAskRule. source says who answered, as {kind:\"ws\", clientId, user} for a browser connection (clientId is a per-connection label, user the user id or null) or {kind:\"push\", action, user} for a push notification answer; it is absent when the answering path named none. The same source is written to the journal line the settle logs. Prompt content is never part of a source" },
|
|
151
|
+
"prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action, source?}; a permission prompt forced by a user ask rule also carries matchedAskRule. source says who answered, as {kind:\"ws\", clientId, user} for a browser connection (clientId is a per-connection label, user the user id or null) or {kind:\"push\", action, user} for a push notification answer, or the string user or caller:<name> for an answer from the answer-prompt CLI verb; it is absent when the answering path named none. The same source is written to the journal line the settle logs. Prompt content is never part of a source" },
|
|
134
152
|
"prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason, source}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown; source says who or what ended it: user, timeout, session_end, daemon_restart, worker, caller:<name> or unspecified (a replayed ending recorded before cancels carried a source). promptState on a replayed request carries the same source for a cancelled prompt. 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" },
|
|
135
153
|
|
|
136
154
|
// Aliases kept for compatibility: the s2c types appear in history recorded
|
|
@@ -183,10 +201,11 @@ var schema = {
|
|
|
183
201
|
// input with an end. The scheduled_message_* names are the original ones, kept;
|
|
184
202
|
// a current client takes its state from scheduled_input_list alone.
|
|
185
203
|
"schedule_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Schedule input for the session on screen: once ({ text, resetsAt }) or recurring ({ text, kind, every, until | count })" },
|
|
186
|
-
"send_scheduled_now": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Send a scheduled input immediately ({ id? }), into a running turn if need be" },
|
|
187
|
-
"cancel_scheduled_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Cancel a scheduled input ({ id? })" },
|
|
204
|
+
"send_scheduled_now": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Send a scheduled input immediately ({ id?, requestId? }), into a running turn if need be" },
|
|
205
|
+
"cancel_scheduled_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Cancel a scheduled input ({ id?, requestId? })" },
|
|
188
206
|
"scheduled_input_list_request": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Ask for the armed scheduled inputs of the session on screen" },
|
|
189
207
|
"scheduled_input_list": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The armed scheduled inputs of a session, in full, after every change" },
|
|
208
|
+
"scheduled_request_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The answer to a send_scheduled_now or cancel_scheduled_message that carried a requestId (carries requestId, id, ok)" },
|
|
190
209
|
"scheduled_message_queued": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was queued (older clients draw their bubble from it; also carries id, kind, every, until, count)" },
|
|
191
210
|
"scheduled_message_sent": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was sent (carries id, kind and final)" },
|
|
192
211
|
"scheduled_message_cancelled": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was cancelled or ended (carries id and reason)" },
|
|
@@ -363,6 +382,10 @@ var schema = {
|
|
|
363
382
|
"project_env_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Project .envrc content" },
|
|
364
383
|
"set_project_env": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Write the project .envrc" },
|
|
365
384
|
"set_project_env_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Project .envrc write result" },
|
|
385
|
+
"get_idle_compaction": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Read the Claude idleCompaction user setting" },
|
|
386
|
+
"idle_compaction_result": { direction: "s2c", handler: "lib/public/modules/server-settings.js", description: "Current idleCompaction value (off, default or on) or a read error" },
|
|
387
|
+
"set_idle_compaction": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Set idleCompaction off or remove it (default)" },
|
|
388
|
+
"set_idle_compaction_result": { direction: "s2c", handler: "lib/public/modules/server-settings.js", description: "idleCompaction write result" },
|
|
366
389
|
"read_global_claude_md": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Read the global CLAUDE.md" },
|
|
367
390
|
"global_claude_md_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Global CLAUDE.md content" },
|
|
368
391
|
"write_global_claude_md": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Write the global CLAUDE.md" },
|
|
@@ -29,9 +29,11 @@ function claudeCapabilities() {
|
|
|
29
29
|
backgroundTasks: true,
|
|
30
30
|
steering: true,
|
|
31
31
|
agentInjection: true,
|
|
32
|
+
queuedMessageCancel: true,
|
|
32
33
|
executionPolicy: false,
|
|
33
34
|
toolPolicy: ["ask", "allow-all"],
|
|
34
35
|
permissionModes: PERMISSION_MODES.slice(),
|
|
36
|
+
additiveSettings: true,
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -30,6 +30,12 @@ registry.register({
|
|
|
30
30
|
effectiveRuntimeEnv: effectiveRuntimeEnv,
|
|
31
31
|
installHint: "Install Claude Code (npm install -g @anthropic-ai/claude-code), then sign in.",
|
|
32
32
|
loginCommand: "claude auth login",
|
|
33
|
+
// The login prints a sign-in URL and then asks for the code the sign-in
|
|
34
|
+
// page shows.
|
|
35
|
+
loginPatterns: {
|
|
36
|
+
url: "https:\\/\\/[^\\s'\"\\]>)}{]+",
|
|
37
|
+
codePrompt: "[Pp]aste code here",
|
|
38
|
+
},
|
|
33
39
|
osUsersSupported: true,
|
|
34
40
|
needsRuntimeEnv: false,
|
|
35
41
|
perProjectRuntime: false,
|
|
@@ -220,6 +220,12 @@ function handleMessage(msg) {
|
|
|
220
220
|
case "push_message":
|
|
221
221
|
handlePushMessage(msg);
|
|
222
222
|
break;
|
|
223
|
+
case "cancel_message":
|
|
224
|
+
handleCancelMessage(msg);
|
|
225
|
+
break;
|
|
226
|
+
case "interrupt_query":
|
|
227
|
+
handleInterruptQuery(msg);
|
|
228
|
+
break;
|
|
223
229
|
case "end_messages":
|
|
224
230
|
if (messageQueue) messageQueue.end();
|
|
225
231
|
break;
|
|
@@ -269,23 +275,15 @@ function canUseTool(toolName, input, opts) {
|
|
|
269
275
|
var requestId = crypto.randomUUID();
|
|
270
276
|
sendToDaemon(permissionRelay.toRequestMessage(requestId, toolName, input, opts));
|
|
271
277
|
return new Promise(function(resolve) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
resolve({ behavior: "deny", message: "Permission request timed out after 30s" });
|
|
276
|
-
// The daemon still shows the request as answerable; tell it the
|
|
277
|
-
// decision can no longer take effect.
|
|
278
|
-
sendToDaemon({ type: "permission_expired", requestId: requestId });
|
|
279
|
-
}
|
|
280
|
-
}, 30000);
|
|
278
|
+
// No timer here: the daemon's prompt registry bounds an unanswered
|
|
279
|
+
// prompt (daemon.json promptExpiryMinutes) and answers deny through the
|
|
280
|
+
// relay.
|
|
281
281
|
pendingPermissions[requestId] = function(result) {
|
|
282
|
-
clearTimeout(timeoutId);
|
|
283
282
|
resolve(result);
|
|
284
283
|
};
|
|
285
284
|
if (opts.signal) {
|
|
286
285
|
opts.signal.addEventListener("abort", function() {
|
|
287
286
|
if (pendingPermissions[requestId]) {
|
|
288
|
-
clearTimeout(timeoutId);
|
|
289
287
|
delete pendingPermissions[requestId];
|
|
290
288
|
resolve({ behavior: "deny", message: "Cancelled" });
|
|
291
289
|
sendToDaemon({ type: "prompt_cancelled", kind: "permission", id: requestId });
|
|
@@ -585,6 +583,36 @@ function handlePushMessage(msg) {
|
|
|
585
583
|
messageQueue.push(msg.content);
|
|
586
584
|
}
|
|
587
585
|
|
|
586
|
+
// Bridges the daemon's cancelQueuedMessage to the SDK query held here. The
|
|
587
|
+
// answer is the SDK's own: true only when the message was still queued.
|
|
588
|
+
async function handleCancelMessage(msg) {
|
|
589
|
+
if (!queryInstance || typeof queryInstance.cancelAsyncMessage !== "function") {
|
|
590
|
+
sendToDaemon({ type: "cancel_message_response", requestId: msg.requestId, error: "The installed Claude SDK cannot cancel a queued message." });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
try {
|
|
594
|
+
var cancelled = await queryInstance.cancelAsyncMessage(msg.messageId);
|
|
595
|
+
sendToDaemon({ type: "cancel_message_response", requestId: msg.requestId, cancelled: cancelled === true });
|
|
596
|
+
} catch (e) {
|
|
597
|
+
sendToDaemon({ type: "cancel_message_response", requestId: msg.requestId, error: (e && e.message) ? e.message : String(e) });
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// Interrupts the running turn with the SDK's queue kept (Query.interrupt() with
|
|
602
|
+
// no cancelQueued), and answers with the interrupt receipt as the SDK returns it.
|
|
603
|
+
async function handleInterruptQuery(msg) {
|
|
604
|
+
if (!queryInstance || typeof queryInstance.interrupt !== "function") {
|
|
605
|
+
sendToDaemon({ type: "interrupt_response", requestId: msg.requestId, error: "The installed Claude SDK cannot interrupt a query." });
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
try {
|
|
609
|
+
var receipt = await queryInstance.interrupt();
|
|
610
|
+
sendToDaemon({ type: "interrupt_response", requestId: msg.requestId, receipt: receipt || null });
|
|
611
|
+
} catch (e) {
|
|
612
|
+
sendToDaemon({ type: "interrupt_response", requestId: msg.requestId, error: (e && e.message) ? e.message : String(e) });
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
588
616
|
async function handleSetModel(msg) {
|
|
589
617
|
if (!queryInstance) return;
|
|
590
618
|
try {
|