@clagentic/console 1.12.0-beta.1 → 1.12.0-beta.3
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/README.md +1 -0
- package/bin/cli.js +5 -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-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +34 -11
- package/lib/build-update-standing.js +34 -14
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/duration.js +27 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +60 -11
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +31 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +18 -22
- package/lib/notify/core.js +210 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +62 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +81 -0
- package/lib/notify/types.js +57 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +85 -0
- package/lib/outbound-entry.js +116 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +48 -8
- package/lib/project-filesystem.js +43 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +38 -26
- package/lib/project-notifications.js +122 -39
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +11 -1
- 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 +41 -5
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +98 -25
- package/lib/prompt-reminders.js +38 -33
- package/lib/prompt-source.js +59 -8
- package/lib/public/app.js +32 -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 +29 -1
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- 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/mobile-nav.css +11 -0
- package/lib/public/css/sidebar.css +18 -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 +44 -7
- package/lib/public/modules/activity-state.js +20 -4
- 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 +34 -5
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +104 -75
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +32 -7
- package/lib/public/modules/build-update-sessions.js +81 -0
- 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 +61 -57
- package/lib/public/modules/env-shadow-notice.js +34 -0
- 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 +246 -0
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- 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 +50 -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 +193 -0
- package/lib/public/modules/terminal.js +84 -107
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +252 -0
- package/lib/public/notify-target.js +157 -0
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +20 -69
- package/lib/push.js +63 -19
- package/lib/queued-chat.js +392 -0
- package/lib/runtime-env.js +1 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +184 -73
- package/lib/sdk-message-processor.js +124 -76
- 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 +112 -16
- package/lib/session-directory.js +39 -12
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +37 -1
- package/lib/session-input.js +263 -21
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +80 -9
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +36 -7
- package/lib/user-shell-settings.js +105 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +33 -5
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +17 -1
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +225 -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/auth-checks.js +17 -2
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +40 -1
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
/**
|
|
16
16
|
* @typedef {{state: "pending"|"resolved"|"cancelled", decision?: ?string,
|
|
17
17
|
* answers?: ?object, skipped?: boolean, action?: ?string,
|
|
18
|
-
* reason?: ?string}} PromptState
|
|
18
|
+
* reason?: ?string, source?: ?string}} PromptState
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
var OUTCOME_FIELDS = ["decision", "answers", "skipped", "action"];
|
|
@@ -25,7 +25,7 @@ export function isTerminal(st) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function normalizeState(next) {
|
|
28
|
-
var out = { state: next.state, reason: next.reason || null };
|
|
28
|
+
var out = { state: next.state, reason: next.reason || null, source: next.source || null };
|
|
29
29
|
OUTCOME_FIELDS.forEach(function (k) { out[k] = next[k] === undefined ? null : next[k]; });
|
|
30
30
|
return out;
|
|
31
31
|
}
|
|
@@ -135,7 +135,7 @@ export function normalizePromptMessage(msg) {
|
|
|
135
135
|
return { phase: "cancel", requestId: msg.toolId, kind: "ask_user", fields: { reason: null }, serverState: null };
|
|
136
136
|
case "prompt_cancel":
|
|
137
137
|
case "permission_cancel":
|
|
138
|
-
return { phase: "cancel", requestId: msg.requestId, kind: msg.kind || null, fields: { reason: msg.reason || null }, serverState: null };
|
|
138
|
+
return { phase: "cancel", requestId: msg.requestId, kind: msg.kind || null, fields: { reason: msg.reason || null, source: msg.source || null }, serverState: null };
|
|
139
139
|
default:
|
|
140
140
|
return null;
|
|
141
141
|
}
|
|
@@ -115,7 +115,7 @@ export function createPromptController(host) {
|
|
|
115
115
|
states.apply(n.requestId, Object.assign({ state: "resolved" }, n.fields));
|
|
116
116
|
sync(n.requestId);
|
|
117
117
|
} else {
|
|
118
|
-
states.apply(n.requestId, { state: "cancelled", reason: n.fields.reason });
|
|
118
|
+
states.apply(n.requestId, { state: "cancelled", reason: n.fields.reason, source: n.fields.source });
|
|
119
119
|
sync(n.requestId);
|
|
120
120
|
}
|
|
121
121
|
return states.get(n.requestId);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// queued-button.js - the control on a queued outbox item. Labelled in words and
|
|
2
|
+
// sized like the send button (the styling is on .shell-queued-btn). One place,
|
|
3
|
+
// so every kind of outbox item draws its controls the same way.
|
|
4
|
+
|
|
5
|
+
export function queuedButton(label, cls) {
|
|
6
|
+
var b = document.createElement("button");
|
|
7
|
+
b.className = "shell-queued-btn " + cls;
|
|
8
|
+
b.textContent = label;
|
|
9
|
+
b.setAttribute("aria-label", label);
|
|
10
|
+
return b;
|
|
11
|
+
}
|
|
@@ -4,12 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import { sendWs } from './ws-ref.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// requestId is optional: the server echoes it on its answer to the request, so
|
|
8
|
+
// a caller that waits for the answer (the composer's outbox) can tell which of
|
|
9
|
+
// its requests an answer or an error is for. The schedule panel sends none.
|
|
10
|
+
function withRequestId(msg, requestId) {
|
|
11
|
+
if (requestId) msg.requestId = requestId;
|
|
12
|
+
return msg;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export function
|
|
12
|
-
return sendWs({ type: "
|
|
15
|
+
export function sendScheduledNow(id, requestId) {
|
|
16
|
+
return sendWs(withRequestId({ type: "send_scheduled_now", id: id }, requestId));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function cancelScheduledInput(id, requestId) {
|
|
20
|
+
return sendWs(withRequestId({ type: "cancel_scheduled_message", id: id }, requestId));
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
// Asks for the armed inputs of the session on screen; the answer arrives as
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// scheduled-outbox.js - the session's armed scheduled inputs, drawn in the
|
|
2
|
+
// composer's outbox beside the queued chat and ! items. The scheduled-input
|
|
3
|
+
// service is the store and the scheduler: the page draws the list the server
|
|
4
|
+
// sends (scheduled_input_list) and sends Fire now and Cancel back. Nothing here
|
|
5
|
+
// is kept or timed by the page except the countdown text.
|
|
6
|
+
//
|
|
7
|
+
// One rendering per schedule: this row is the only one in the composer (the
|
|
8
|
+
// schedule panel's list is a separate surface). The rows share one container,
|
|
9
|
+
// which addToMessages keeps at the end of the message list, after the queued
|
|
10
|
+
// items.
|
|
11
|
+
|
|
12
|
+
import { addToMessages, scrollToBottom } from './app-rendering.js';
|
|
13
|
+
import { sendScheduledNow, cancelScheduledInput } from './scheduled-input-actions.js';
|
|
14
|
+
import { countdownText } from './schedule-time.js';
|
|
15
|
+
import { currentSendNowState, sendNowLabel } from './send-now.js';
|
|
16
|
+
import { queuedButton } from './queued-button.js';
|
|
17
|
+
import { buildCollapsibleText, needsCollapse, isNonTypedInput } from './collapsible-text.js';
|
|
18
|
+
|
|
19
|
+
var containerEl = null;
|
|
20
|
+
var countdowns = [];
|
|
21
|
+
var countdownTimer = null;
|
|
22
|
+
// Rows with a Fire now or Cancel request sent and not yet answered: schedule id
|
|
23
|
+
// -> the request id sent. The server already refuses a second send; this only
|
|
24
|
+
// keeps a second click from being made. A row is freed by the server's answer
|
|
25
|
+
// to that request (scheduled_request_result, or an error carrying the same
|
|
26
|
+
// request id), by the list no longer having it, or by a reconnect.
|
|
27
|
+
var inFlight = {};
|
|
28
|
+
var failures = {};
|
|
29
|
+
var requestSeq = 0;
|
|
30
|
+
|
|
31
|
+
function tickCountdowns() {
|
|
32
|
+
var now = Date.now();
|
|
33
|
+
countdowns.forEach(function (c) { c.el.textContent = countdownText(c.input, now); });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Fire now follows the capability table like Send now of the other kinds; a
|
|
37
|
+
// disabled state is aria-disabled so a tap can still say why.
|
|
38
|
+
function paintFireNow(btn) {
|
|
39
|
+
var st = currentSendNowState("scheduled");
|
|
40
|
+
var off = st.mode === "disabled";
|
|
41
|
+
btn.classList.toggle("unavailable", off);
|
|
42
|
+
btn.setAttribute("aria-disabled", off ? "true" : "false");
|
|
43
|
+
btn.title = off
|
|
44
|
+
? sendNowLabel("scheduled") + " (unavailable): " + st.reason
|
|
45
|
+
: sendNowLabel("scheduled") + ": deliver this schedule now";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function paintBusy(row, id) {
|
|
49
|
+
var busy = !!inFlight[id];
|
|
50
|
+
row.fireBtn.disabled = busy;
|
|
51
|
+
row.cancelBtn.disabled = busy;
|
|
52
|
+
row.fireBtn.setAttribute("aria-busy", busy ? "true" : "false");
|
|
53
|
+
row.cancelBtn.setAttribute("aria-busy", busy ? "true" : "false");
|
|
54
|
+
row.errorEl.textContent = failures[id] || "";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function repaintRow(id) {
|
|
58
|
+
if (!containerEl) return;
|
|
59
|
+
rows.forEach(function (r) { if (r.id === id) paintBusy(r, id); });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var rows = [];
|
|
63
|
+
|
|
64
|
+
// Sends one request for the row; a refused send frees the row at once, the
|
|
65
|
+
// server's answer frees it through completeScheduledRequest or
|
|
66
|
+
// failScheduledRequests, matched on the request id.
|
|
67
|
+
function request(id, send) {
|
|
68
|
+
if (inFlight[id]) return;
|
|
69
|
+
var requestId = "sr_" + (++requestSeq);
|
|
70
|
+
inFlight[id] = requestId;
|
|
71
|
+
delete failures[id];
|
|
72
|
+
repaintRow(id);
|
|
73
|
+
if (send(id, requestId) === false) {
|
|
74
|
+
delete inFlight[id];
|
|
75
|
+
failures[id] = "Could not send the request: the connection is not open.";
|
|
76
|
+
repaintRow(id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function buildRow(input) {
|
|
81
|
+
var el = document.createElement("div");
|
|
82
|
+
el.className = "shell-queued scheduled-queued";
|
|
83
|
+
el.setAttribute("data-id", input.id);
|
|
84
|
+
|
|
85
|
+
var tag = document.createElement("span");
|
|
86
|
+
tag.className = "shell-queued-tag";
|
|
87
|
+
tag.textContent = "Scheduled";
|
|
88
|
+
|
|
89
|
+
var when = document.createElement("span");
|
|
90
|
+
when.className = "scheduled-queued-time";
|
|
91
|
+
|
|
92
|
+
var body = document.createElement("span");
|
|
93
|
+
body.className = "shell-queued-text";
|
|
94
|
+
var toggle = null;
|
|
95
|
+
// A schedule is input the console pushes in later: the same rule as its delivery.
|
|
96
|
+
if (isNonTypedInput({ initiator: "scheduled", senderKind: "automation" }) && needsCollapse(input.text)) {
|
|
97
|
+
var collapsible = buildCollapsibleText(input.text);
|
|
98
|
+
body.appendChild(collapsible.el);
|
|
99
|
+
toggle = collapsible.button;
|
|
100
|
+
} else {
|
|
101
|
+
body.textContent = input.text;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var actions = document.createElement("span");
|
|
105
|
+
actions.className = "shell-queued-actions";
|
|
106
|
+
var fireBtn = queuedButton(sendNowLabel("scheduled"), "shell-queued-send-now scheduled-queued-fire");
|
|
107
|
+
fireBtn.addEventListener("click", function () {
|
|
108
|
+
var st = currentSendNowState("scheduled");
|
|
109
|
+
if (st.mode === "disabled") return;
|
|
110
|
+
request(input.id, sendScheduledNow);
|
|
111
|
+
});
|
|
112
|
+
var cancelBtn = queuedButton("Cancel", "shell-queued-cancel scheduled-queued-cancel");
|
|
113
|
+
cancelBtn.addEventListener("click", function () { request(input.id, cancelScheduledInput); });
|
|
114
|
+
actions.appendChild(fireBtn);
|
|
115
|
+
actions.appendChild(cancelBtn);
|
|
116
|
+
if (toggle) {
|
|
117
|
+
toggle.classList.add("shell-queued-btn");
|
|
118
|
+
actions.appendChild(toggle);
|
|
119
|
+
}
|
|
120
|
+
paintFireNow(fireBtn);
|
|
121
|
+
|
|
122
|
+
var errorEl = document.createElement("span");
|
|
123
|
+
errorEl.className = "scheduled-queued-error";
|
|
124
|
+
errorEl.setAttribute("role", "alert");
|
|
125
|
+
|
|
126
|
+
el.appendChild(tag);
|
|
127
|
+
el.appendChild(when);
|
|
128
|
+
el.appendChild(body);
|
|
129
|
+
el.appendChild(actions);
|
|
130
|
+
el.appendChild(errorEl);
|
|
131
|
+
var row = { id: input.id, el: el, when: when, fireBtn: fireBtn, cancelBtn: cancelBtn, errorEl: errorEl };
|
|
132
|
+
paintBusy(row, input.id);
|
|
133
|
+
return row;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function rowsOfRequest(requestId) {
|
|
137
|
+
if (!requestId) return [];
|
|
138
|
+
return Object.keys(inFlight).filter(function (id) { return inFlight[id] === requestId; });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The server answered a Fire now or Cancel with an error that names the request
|
|
143
|
+
* (requestId): only the row that sent it is freed and shows the failure. An
|
|
144
|
+
* error without a request id, or with one this page is not waiting on, is not
|
|
145
|
+
* about any row and frees none.
|
|
146
|
+
* @param {string} text the server's error text
|
|
147
|
+
* @param {string} [requestId] the request id the error carries
|
|
148
|
+
*/
|
|
149
|
+
export function failScheduledRequests(text, requestId) {
|
|
150
|
+
rowsOfRequest(requestId).forEach(function (id) {
|
|
151
|
+
delete inFlight[id];
|
|
152
|
+
failures[id] = text || "The request failed.";
|
|
153
|
+
repaintRow(id);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The server answered a Fire now or Cancel as done (scheduled_request_result):
|
|
159
|
+
* the row that sent it is freed. A recurring schedule stays listed after Fire
|
|
160
|
+
* now, so its controls are enabled again here, not by the list.
|
|
161
|
+
* @param {string} requestId the request id the answer carries
|
|
162
|
+
*/
|
|
163
|
+
export function completeScheduledRequest(requestId) {
|
|
164
|
+
rowsOfRequest(requestId).forEach(function (id) {
|
|
165
|
+
delete inFlight[id];
|
|
166
|
+
repaintRow(id);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The connection came back: an answer lost with the old connection will never
|
|
172
|
+
* arrive, so nothing stays waiting, and the rows are repainted enabled. The
|
|
173
|
+
* server's list, requested on reconnect, redraws what is armed.
|
|
174
|
+
*/
|
|
175
|
+
export function clearScheduledOutboxOnReconnect() {
|
|
176
|
+
inFlight = {};
|
|
177
|
+
failures = {};
|
|
178
|
+
rows.forEach(function (r) { paintBusy(r, r.id); });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Redraws the outbox rows of the session on screen from the server's list:
|
|
183
|
+
* one row per armed input, in the list's order. Replaces what was drawn.
|
|
184
|
+
* @param {Array<object>} inputs the service's armed inputs for the session
|
|
185
|
+
*/
|
|
186
|
+
export function renderScheduledOutbox(inputs) {
|
|
187
|
+
removeScheduledOutbox();
|
|
188
|
+
// A schedule the server no longer lists has left: nothing of it stays waiting.
|
|
189
|
+
var listed = {};
|
|
190
|
+
(inputs || []).forEach(function (i) { listed[i.id] = true; });
|
|
191
|
+
Object.keys(inFlight).forEach(function (id) { if (!listed[id]) delete inFlight[id]; });
|
|
192
|
+
Object.keys(failures).forEach(function (id) { if (!listed[id]) delete failures[id]; });
|
|
193
|
+
if (!inputs || inputs.length === 0) return;
|
|
194
|
+
var container = document.createElement("div");
|
|
195
|
+
container.className = "scheduled-msgs";
|
|
196
|
+
inputs.forEach(function (input) {
|
|
197
|
+
var row = buildRow(input);
|
|
198
|
+
container.appendChild(row.el);
|
|
199
|
+
rows.push(row);
|
|
200
|
+
countdowns.push({ el: row.when, input: input });
|
|
201
|
+
});
|
|
202
|
+
addToMessages(container);
|
|
203
|
+
containerEl = container;
|
|
204
|
+
scrollToBottom();
|
|
205
|
+
tickCountdowns();
|
|
206
|
+
countdownTimer = setInterval(tickCountdowns, 1000);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Forgets the requests in flight and their failures (the view left the session). */
|
|
210
|
+
export function resetScheduledOutboxRequests() {
|
|
211
|
+
inFlight = {};
|
|
212
|
+
failures = {};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Removes the drawn rows and their countdown; the session's list is untouched. */
|
|
216
|
+
export function removeScheduledOutbox() {
|
|
217
|
+
if (containerEl) {
|
|
218
|
+
containerEl.remove();
|
|
219
|
+
containerEl = null;
|
|
220
|
+
}
|
|
221
|
+
countdowns = [];
|
|
222
|
+
rows = [];
|
|
223
|
+
if (countdownTimer) {
|
|
224
|
+
clearInterval(countdownTimer);
|
|
225
|
+
countdownTimer = null;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** The container of the drawn rows, or null when the session has none. */
|
|
230
|
+
export function getScheduledOutboxEl() { return containerEl; }
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// send-now.js - deliver a typed message into the running turn instead of
|
|
2
|
+
// queueing it for the next one. The decision is pure (state in, mode out) so
|
|
3
|
+
// the shortcut, the queued items' controls, the touch long press and the tests share one rule, and nothing here
|
|
4
|
+
// names an agent: whether a turn can be steered is the `steering` capability.
|
|
5
|
+
|
|
6
|
+
import { store } from './store.js';
|
|
7
|
+
import { capabilityGate } from './vendor-registry.js';
|
|
8
|
+
|
|
9
|
+
// What Send now means for each kind of queued or typed item, in one place.
|
|
10
|
+
// - chat: into the running turn when the agent has the steering capability
|
|
11
|
+
// (gate "steering"); a normal send when no turn runs.
|
|
12
|
+
// - shell: a ! command never goes into a turn (no two writers on the session):
|
|
13
|
+
// unavailable while a turn runs, and run next when the session is idle.
|
|
14
|
+
// - scheduled: an armed schedule is fired at once through the scheduled-input
|
|
15
|
+
// service's run-now path, which joins a running turn like a person's
|
|
16
|
+
// message; the service, not the page, owns when and how it is delivered.
|
|
17
|
+
// `label` is what the control says.
|
|
18
|
+
export var SEND_NOW_BY_KIND = {
|
|
19
|
+
chat: {
|
|
20
|
+
label: "Send now",
|
|
21
|
+
gate: "steering",
|
|
22
|
+
running: "steer",
|
|
23
|
+
idle: "send",
|
|
24
|
+
unavailableReason: "This agent cannot take a message while it is working.",
|
|
25
|
+
},
|
|
26
|
+
shell: {
|
|
27
|
+
label: "Send now",
|
|
28
|
+
gate: null,
|
|
29
|
+
running: "disabled",
|
|
30
|
+
idle: "run-next",
|
|
31
|
+
unavailableReason: "a command runs after the turn",
|
|
32
|
+
},
|
|
33
|
+
scheduled: {
|
|
34
|
+
label: "Fire now",
|
|
35
|
+
gate: null,
|
|
36
|
+
running: "fire",
|
|
37
|
+
idle: "fire",
|
|
38
|
+
unavailableReason: "",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// What Cancel and Edit mean for each kind of queued item, in one place, beside
|
|
43
|
+
// Send now.
|
|
44
|
+
// - chat: a message is pushed to the agent at once and waits there until the
|
|
45
|
+
// agent takes it into a turn; withdrawing it is the agent's
|
|
46
|
+
// `queuedMessageCancel` capability. Without it the message is not
|
|
47
|
+
// drawn as queued at all: it is shown as sent, as it always was.
|
|
48
|
+
// - shell: a ! entry is held on this page, so the page can always withdraw it.
|
|
49
|
+
// - scheduled: the scheduled-input service holds it; Cancel deletes it there.
|
|
50
|
+
// It has no Edit here (a schedule is changed from the schedule panel).
|
|
51
|
+
export var QUEUED_CONTROLS_BY_KIND = {
|
|
52
|
+
chat: {
|
|
53
|
+
gate: "queuedMessageCancel",
|
|
54
|
+
unavailableReason: "This agent cannot withdraw a message that is waiting to be delivered.",
|
|
55
|
+
},
|
|
56
|
+
shell: {
|
|
57
|
+
gate: null,
|
|
58
|
+
unavailableReason: "",
|
|
59
|
+
},
|
|
60
|
+
scheduled: {
|
|
61
|
+
gate: null,
|
|
62
|
+
unavailableReason: "",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether Cancel and Edit work on one kind of queued item.
|
|
68
|
+
* @param {string} kind a key of QUEUED_CONTROLS_BY_KIND
|
|
69
|
+
* @param {?{enabled: boolean, reason: string}} gate the capability gate the kind names, if any
|
|
70
|
+
* @returns {{cancel: {enabled: boolean, reason: string}, edit: {enabled: boolean, reason: string}}}
|
|
71
|
+
*/
|
|
72
|
+
export function queuedControlsForKind(kind, gate) {
|
|
73
|
+
var rule = QUEUED_CONTROLS_BY_KIND[kind];
|
|
74
|
+
if (!rule) {
|
|
75
|
+
var unknown = { enabled: false, reason: "Unknown kind of item." };
|
|
76
|
+
return { cancel: unknown, edit: unknown };
|
|
77
|
+
}
|
|
78
|
+
var on = !rule.gate || !!(gate && gate.enabled);
|
|
79
|
+
var state = on
|
|
80
|
+
? { enabled: true, reason: "" }
|
|
81
|
+
: { enabled: false, reason: (gate && gate.reason) || rule.unavailableReason };
|
|
82
|
+
return { cancel: state, edit: state };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The Cancel and Edit state for one kind, for the live store and the current agent. */
|
|
86
|
+
export function currentQueuedControls(kind) {
|
|
87
|
+
var rule = QUEUED_CONTROLS_BY_KIND[kind];
|
|
88
|
+
return queuedControlsForKind(kind, rule && rule.gate ? capabilityGate(rule.gate) : null);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* What send-now does for one kind right now.
|
|
93
|
+
* - "send": chat, no turn running: a normal send.
|
|
94
|
+
* - "steer": chat, a turn is running and the agent can take a message into it.
|
|
95
|
+
* - "run-next": ! command, idle: it runs next.
|
|
96
|
+
* - "fire": scheduled input: the service delivers it now, running turn or not.
|
|
97
|
+
* - "disabled": it cannot be sent now; `reason` says why.
|
|
98
|
+
* @param {string} kind a key of SEND_NOW_BY_KIND
|
|
99
|
+
* @param {boolean} processing a turn is running
|
|
100
|
+
* @param {?{enabled: boolean, reason: string}} gate the capability gate the kind names, if any
|
|
101
|
+
* @returns {{mode: string, reason: string}}
|
|
102
|
+
*/
|
|
103
|
+
export function sendNowForKind(kind, processing, gate) {
|
|
104
|
+
var rule = SEND_NOW_BY_KIND[kind];
|
|
105
|
+
if (!rule) return { mode: "disabled", reason: "Unknown kind of item." };
|
|
106
|
+
if (!processing) return { mode: rule.idle, reason: "" };
|
|
107
|
+
if (rule.running === "disabled") return { mode: "disabled", reason: rule.unavailableReason };
|
|
108
|
+
if (!rule.gate || (gate && gate.enabled)) return { mode: rule.running, reason: "" };
|
|
109
|
+
return { mode: "disabled", reason: (gate && gate.reason) || rule.unavailableReason };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** What the Send now control of one kind is called ("Fire now" for a schedule). */
|
|
113
|
+
export function sendNowLabel(kind) {
|
|
114
|
+
var rule = SEND_NOW_BY_KIND[kind];
|
|
115
|
+
return rule ? rule.label : "Send now";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The chat rule: what send-now does to a typed message right now. */
|
|
119
|
+
export function sendNowState(processing, gate) {
|
|
120
|
+
return sendNowForKind("chat", processing, gate);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Whether a keydown is the send-now shortcut: Ctrl+Enter anywhere, and
|
|
125
|
+
* Cmd+Enter on macOS. Shift and Alt variants are left to the composer.
|
|
126
|
+
* @param {{key: string, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean, altKey: boolean}} e
|
|
127
|
+
* @param {boolean} isMac
|
|
128
|
+
*/
|
|
129
|
+
export function isSendNowKey(e, isMac) {
|
|
130
|
+
if (e.key !== "Enter" || e.shiftKey || e.altKey) return false;
|
|
131
|
+
return !!e.ctrlKey || (!!isMac && !!e.metaKey);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function isMacPlatform() {
|
|
135
|
+
var platform = (typeof navigator !== "undefined" && (navigator.platform || "")) || "";
|
|
136
|
+
return /^Mac/i.test(platform);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The state for one kind, for the live store and the current agent. */
|
|
140
|
+
export function currentSendNowState(kind) {
|
|
141
|
+
var k = kind || "chat";
|
|
142
|
+
var rule = SEND_NOW_BY_KIND[k];
|
|
143
|
+
return sendNowForKind(k, !!store.get("processing"), rule && rule.gate ? capabilityGate(rule.gate) : null);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// How long after a long press ends its click can still arrive.
|
|
147
|
+
var SWALLOW_WINDOW_MS = 400;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Send now for a touch screen, where there is no Ctrl key and no button of its
|
|
151
|
+
* own: a long press on the send button, while a message is ready to go, sends
|
|
152
|
+
* it now. The click that ends the press is swallowed so it does not also send.
|
|
153
|
+
* Register this before the button's own click handler.
|
|
154
|
+
* @param {HTMLElement} btn
|
|
155
|
+
* @param {function(): boolean} canArm a press may start send-now (a turn runs and a draft is ready)
|
|
156
|
+
* @param {function(): void} onSendNow
|
|
157
|
+
* @param {number} [ms] how long a press counts as long
|
|
158
|
+
*/
|
|
159
|
+
export function initSendLongPress(btn, canArm, onSendNow, ms) {
|
|
160
|
+
if (!btn) return;
|
|
161
|
+
var delay = ms || 500;
|
|
162
|
+
var timer = null;
|
|
163
|
+
var fired = false;
|
|
164
|
+
var settle = null;
|
|
165
|
+
function clear() { if (timer !== null) { clearTimeout(timer); timer = null; } }
|
|
166
|
+
function clearSettle() { if (settle !== null) { clearTimeout(settle); settle = null; } }
|
|
167
|
+
// `fired` only exists to swallow the click that ends the press that fired. That click
|
|
168
|
+
// follows pointerup at once, so a press that ends otherwise (pointerleave, pointercancel,
|
|
169
|
+
// or a click that never comes) must not leave it set to swallow a later, unrelated click.
|
|
170
|
+
function endPress(swallowClickFollows) {
|
|
171
|
+
clear();
|
|
172
|
+
clearSettle();
|
|
173
|
+
if (!fired) return;
|
|
174
|
+
if (!swallowClickFollows) { fired = false; return; }
|
|
175
|
+
settle = setTimeout(function () { settle = null; fired = false; }, SWALLOW_WINDOW_MS);
|
|
176
|
+
}
|
|
177
|
+
btn.addEventListener("pointerdown", function (e) {
|
|
178
|
+
fired = false;
|
|
179
|
+
clear();
|
|
180
|
+
clearSettle();
|
|
181
|
+
if (e && e.pointerType === "mouse") return;
|
|
182
|
+
if (!canArm()) return;
|
|
183
|
+
timer = setTimeout(function () {
|
|
184
|
+
timer = null;
|
|
185
|
+
fired = true;
|
|
186
|
+
onSendNow();
|
|
187
|
+
}, delay);
|
|
188
|
+
});
|
|
189
|
+
btn.addEventListener("pointerup", function () { endPress(true); });
|
|
190
|
+
btn.addEventListener("pointerleave", function () { endPress(true); });
|
|
191
|
+
btn.addEventListener("pointercancel", function () { endPress(false); });
|
|
192
|
+
btn.addEventListener("contextmenu", function (e) { if (fired || timer !== null) e.preventDefault(); });
|
|
193
|
+
btn.addEventListener("click", function (e) {
|
|
194
|
+
if (!fired) return;
|
|
195
|
+
fired = false;
|
|
196
|
+
clearSettle();
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
e.stopImmediatePropagation();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
@@ -8,9 +8,12 @@ import { closeFileViewer } from './filebrowser.js';
|
|
|
8
8
|
import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard, isSonnetModel } from './settings-defaults.js';
|
|
9
9
|
import { capabilitiesFor, defaultVendorId } from './vendor-registry.js';
|
|
10
10
|
import { renderPermissionSettings } from './permission-settings.js';
|
|
11
|
+
import { renderUserShellSettings } from './shell-settings-controls.js';
|
|
11
12
|
import { initCustomIconsSettings, initCustomIconsUpload, loadCustomIcons } from './custom-icons-settings.js';
|
|
12
13
|
import { formatBytes } from './app-panels.js';
|
|
14
|
+
import { renderShadowNotice } from './env-shadow-notice.js';
|
|
13
15
|
import { registerHandlers } from './app-messages.js';
|
|
16
|
+
import { registerPlace } from './notify-client.js';
|
|
14
17
|
|
|
15
18
|
var ctx = null;
|
|
16
19
|
var settingsEl = null;
|
|
@@ -63,6 +66,8 @@ export function initServerSettings(appCtx) {
|
|
|
63
66
|
settingsBtn.addEventListener("click", function () {
|
|
64
67
|
openSettings();
|
|
65
68
|
});
|
|
69
|
+
// The update button lives here: a tap on an update notice opens it.
|
|
70
|
+
registerPlace("update_available", openSettings);
|
|
66
71
|
|
|
67
72
|
// Close settings
|
|
68
73
|
closeBtn.addEventListener("click", function () {
|
|
@@ -284,6 +289,12 @@ export function initServerSettings(appCtx) {
|
|
|
284
289
|
ssClaudeMdSave.addEventListener("click", function () { saveGlobalClaudeMd(); });
|
|
285
290
|
}
|
|
286
291
|
|
|
292
|
+
// Idle compaction (Claude user setting)
|
|
293
|
+
var ssIdleOff = document.getElementById("ss-idle-compaction-off");
|
|
294
|
+
if (ssIdleOff) ssIdleOff.addEventListener("click", function () { setIdleCompaction("off"); });
|
|
295
|
+
var ssIdleDefault = document.getElementById("ss-idle-compaction-default");
|
|
296
|
+
if (ssIdleDefault) ssIdleDefault.addEventListener("click", function () { setIdleCompaction("default"); });
|
|
297
|
+
|
|
287
298
|
// Shared environment: add button
|
|
288
299
|
var ssEnvAddBtn = document.getElementById("ss-env-add-btn");
|
|
289
300
|
if (ssEnvAddBtn) {
|
|
@@ -521,7 +532,7 @@ function switchSection(sectionName) {
|
|
|
521
532
|
}
|
|
522
533
|
|
|
523
534
|
// Lazy-load section data
|
|
524
|
-
if (sectionName === "claudemd") loadGlobalClaudeMd();
|
|
535
|
+
if (sectionName === "claudemd") { loadGlobalClaudeMd(); loadIdleCompaction(); }
|
|
525
536
|
if (sectionName === "environment") loadSharedEnv();
|
|
526
537
|
if (sectionName === "custom-icons") loadCustomIcons();
|
|
527
538
|
if (sectionName === "admin-users" || sectionName === "admin-invites" || sectionName === "admin-projects" || sectionName === "admin-smtp") {
|
|
@@ -617,6 +628,7 @@ function populateSettings() {
|
|
|
617
628
|
updateThinkingBar();
|
|
618
629
|
updateSsBetaCard();
|
|
619
630
|
renderPermissionSettings(ssSendMsg);
|
|
631
|
+
renderUserShellSettings(ssSendMsg);
|
|
620
632
|
}
|
|
621
633
|
|
|
622
634
|
function syncNotifToggles() {
|
|
@@ -1211,6 +1223,39 @@ export function handleGlobalClaudeMdWrite(msg) {
|
|
|
1211
1223
|
}
|
|
1212
1224
|
}
|
|
1213
1225
|
|
|
1226
|
+
// ===== Idle compaction (Claude user setting) =====
|
|
1227
|
+
var IDLE_COMPACTION_LABELS = {
|
|
1228
|
+
off: "Off. Claude Code will not compact an idle session.",
|
|
1229
|
+
on: "On (set outside the console).",
|
|
1230
|
+
"default": "Claude Code default (the setting is not set).",
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
function setIdleCompactionStatus(text) {
|
|
1234
|
+
var el = document.getElementById("ss-idle-compaction-status");
|
|
1235
|
+
if (el) el.textContent = text;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function loadIdleCompaction() {
|
|
1239
|
+
setIdleCompactionStatus("Loading...");
|
|
1240
|
+
var ws = ctx.ws;
|
|
1241
|
+
if (ws && ws.readyState === 1) ws.send(JSON.stringify({ type: "get_idle_compaction" }));
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
function setIdleCompaction(value) {
|
|
1245
|
+
var ws = ctx.ws;
|
|
1246
|
+
if (!ws || ws.readyState !== 1) return;
|
|
1247
|
+
setIdleCompactionStatus("Saving...");
|
|
1248
|
+
ws.send(JSON.stringify({ type: "set_idle_compaction", value: value }));
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
export function handleIdleCompactionResult(msg) {
|
|
1252
|
+
if (!msg.ok) {
|
|
1253
|
+
setIdleCompactionStatus("Error: " + (msg.error || "Could not read the setting"));
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
setIdleCompactionStatus(IDLE_COMPACTION_LABELS[msg.value] || IDLE_COMPACTION_LABELS["default"]);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1214
1259
|
// ===== Shared Environment Variables =====
|
|
1215
1260
|
var sharedEnvSaveTimer = null;
|
|
1216
1261
|
|
|
@@ -1225,6 +1270,7 @@ function loadSharedEnv() {
|
|
|
1225
1270
|
}
|
|
1226
1271
|
|
|
1227
1272
|
export function handleSharedEnv(msg) {
|
|
1273
|
+
renderShadowNotice("ss-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
1228
1274
|
var list = document.getElementById("ss-env-list");
|
|
1229
1275
|
if (!list) return;
|
|
1230
1276
|
list.innerHTML = "";
|
|
@@ -1237,6 +1283,7 @@ export function handleSharedEnv(msg) {
|
|
|
1237
1283
|
}
|
|
1238
1284
|
|
|
1239
1285
|
export function handleSharedEnvSaved(msg) {
|
|
1286
|
+
if (msg.ok) renderShadowNotice("ss-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
1240
1287
|
var saveStatus = document.getElementById("ss-env-save-status");
|
|
1241
1288
|
if (!saveStatus) return;
|
|
1242
1289
|
if (msg.ok) {
|
|
@@ -1401,6 +1448,8 @@ export function initSsLiteToggle() {
|
|
|
1401
1448
|
// only place both consumers are already imported together.
|
|
1402
1449
|
registerHandlers({
|
|
1403
1450
|
global_claude_md_result: handleGlobalClaudeMdRead,
|
|
1451
|
+
idle_compaction_result: handleIdleCompactionResult,
|
|
1452
|
+
set_idle_compaction_result: handleIdleCompactionResult,
|
|
1404
1453
|
write_global_claude_md_result: handleGlobalClaudeMdWrite,
|
|
1405
1454
|
set_pin_result: handleSetPinResult,
|
|
1406
1455
|
set_keep_awake_result: handleKeepAwakeChanged,
|