@clagentic/console 1.10.0-beta.4 → 1.11.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/bin/cli.js +15 -3
- package/lib/agents.js +1 -55
- package/lib/bash-auto-approve.js +133 -0
- package/lib/build-identity.js +23 -5
- package/lib/build-sha.json +2 -2
- package/lib/build-update-check.js +0 -62
- package/lib/build-update-offer.js +23 -13
- package/lib/build-update-restart.js +59 -43
- package/lib/cli/schedule-input-subcommands.js +327 -0
- package/lib/cli/session-subcommands.js +100 -17
- package/lib/client-build-id.js +56 -0
- package/lib/daemon.js +20 -5
- package/lib/injected-sender.js +225 -0
- package/lib/message-sender-record.js +133 -0
- package/lib/pending-prompts.js +55 -0
- package/lib/permission-mode-policy.js +63 -0
- package/lib/permission-summary.js +67 -0
- package/lib/project-connection.js +2 -1
- package/lib/project-external-trigger.js +9 -1
- package/lib/project-loop.js +26 -20
- package/lib/project-prompt-responses.js +20 -14
- package/lib/project-sessions.js +73 -21
- package/lib/project-user-message.js +18 -47
- package/lib/project.js +36 -62
- package/lib/public/app.js +3 -5
- package/lib/public/css/channel-layout.css +20 -0
- package/lib/public/css/diagnostics.css +7 -0
- package/lib/public/css/input.css +78 -0
- package/lib/public/css/menus.css +17 -0
- package/lib/public/modules/app-connection.js +18 -1
- package/lib/public/modules/app-messages.js +19 -17
- package/lib/public/modules/app-panels.js +9 -2
- package/lib/public/modules/app-rate-limit.js +63 -87
- package/lib/public/modules/app-rendering.js +37 -6
- package/lib/public/modules/at-agents.js +8 -0
- package/lib/public/modules/build-guard.js +61 -0
- package/lib/public/modules/build-update-detail.js +1 -4
- package/lib/public/modules/diagnostics.js +98 -9
- package/lib/public/modules/injected-identity.js +78 -0
- package/lib/public/modules/injected-label.js +62 -0
- package/lib/public/modules/input.js +64 -114
- package/lib/public/modules/mode-options.js +19 -16
- package/lib/public/modules/rate-limit-state.js +47 -22
- package/lib/public/modules/schedule-panel.js +234 -0
- package/lib/public/modules/schedule-time.js +193 -0
- package/lib/public/modules/scheduled-input-actions.js +19 -0
- package/lib/runtime-env.js +4 -0
- package/lib/scheduled-input/ipc.js +92 -0
- package/lib/scheduled-input/rate-limit-resume.js +53 -0
- package/lib/scheduled-input/records.js +350 -0
- package/lib/scheduled-input/service.js +743 -0
- package/lib/scheduled-input/store.js +132 -0
- package/lib/scheduled-input/ws.js +194 -0
- package/lib/sdk-bridge.js +137 -152
- package/lib/sdk-message-processor.js +13 -5
- package/lib/sdk-skill-discovery.js +17 -0
- package/lib/sender-ref.js +109 -0
- package/lib/server.js +28 -8
- package/lib/session-directory.js +224 -0
- package/lib/session-file-scan.js +55 -0
- package/lib/session-input-ipc.js +20 -0
- package/lib/session-input.js +355 -19
- package/lib/session-name-holder.js +82 -0
- package/lib/session-resume.js +1 -0
- package/lib/sessions.js +44 -0
- package/lib/turn-initiator.js +6 -2
- package/lib/ws-schema.js +15 -7
- package/lib/yoke/adapters/claude-worker.js +3 -1
- package/lib/yoke/adapters/claude.js +13 -7
- package/lib/yoke/adapters/codex.js +18 -5
- package/lib/yoke/adapters/permission-relay.js +9 -0
- package/lib/yoke/interface.js +7 -1
- package/package.json +1 -1
- package/scripts/check-test-count.js +1 -1
- package/scripts/install-local-test.js +45 -1
- package/scripts/postinstall.js +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Maps the recorded sender of an injected message onto the existing
|
|
2
|
+
// name and avatar helpers. A sender only gains identity here when it matches a
|
|
3
|
+
// known mate or agent; the match changes the display name and avatar and
|
|
4
|
+
// nothing else, so an injected entry never reads as the operator.
|
|
5
|
+
|
|
6
|
+
import { mateAvatarUrl } from "./avatar.js";
|
|
7
|
+
import { injectedSenderName } from "./injected-label.js";
|
|
8
|
+
|
|
9
|
+
// Fixed seeds keep the avatar of anonymous senders stable across renders.
|
|
10
|
+
var UNDECLARED_SEED = "undeclared-sender";
|
|
11
|
+
var UNRECORDED_SEED = "unrecorded-sender";
|
|
12
|
+
var AUTOMATION_SEED_PREFIX = "console-automation:";
|
|
13
|
+
|
|
14
|
+
function norm(value) {
|
|
15
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function findKnownIdentity(known, fromId, fromName) {
|
|
19
|
+
var keys = [norm(fromId), norm(fromName)].filter(Boolean);
|
|
20
|
+
if (!keys.length || !Array.isArray(known)) return null;
|
|
21
|
+
for (var i = 0; i < known.length; i++) {
|
|
22
|
+
var entry = known[i];
|
|
23
|
+
if (!entry) continue;
|
|
24
|
+
var names = [entry.id, entry.agentName, entry.name, entry.slug].map(norm);
|
|
25
|
+
for (var k = 0; k < keys.length; k++) {
|
|
26
|
+
if (names.indexOf(keys[k]) !== -1) return entry;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// injected: { senderKind, fromName, ... }; fromId: the recorded `from`;
|
|
33
|
+
// known: mates and agents as { id, name, agentName?, slug?, avatar fields }.
|
|
34
|
+
// Returns { name, avatarUrl, matched }.
|
|
35
|
+
export function resolveInjectedIdentity(injected, fromId, known, size) {
|
|
36
|
+
var extracted = injected.senderKind === "extracted";
|
|
37
|
+
var declared = injected.senderKind === "declared" || extracted;
|
|
38
|
+
if (declared) {
|
|
39
|
+
// An extracted sender is matched on its agent name; its fromName is the
|
|
40
|
+
// "<agent>@<project>" label, which names no agent by itself.
|
|
41
|
+
var hit = extracted
|
|
42
|
+
? findKnownIdentity(known, undefined, injected.senderAgent)
|
|
43
|
+
: findKnownIdentity(known, fromId, injected.fromName);
|
|
44
|
+
if (hit) {
|
|
45
|
+
return {
|
|
46
|
+
name: extracted ? injectedSenderName(injected) : (hit.name || hit.agentName || injectedSenderName(injected)),
|
|
47
|
+
avatarUrl: mateAvatarUrl(hit, size),
|
|
48
|
+
matched: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// An extracted agent keeps its own avatar when the receiving project does not
|
|
53
|
+
// list it: same id the list would give it.
|
|
54
|
+
if (extracted && injected.senderAgentSlug) {
|
|
55
|
+
return {
|
|
56
|
+
name: injectedSenderName(injected),
|
|
57
|
+
avatarUrl: mateAvatarUrl({ id: injected.senderAgentSlug }, size),
|
|
58
|
+
matched: false,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// The console's own automations keep one avatar each, whichever session or
|
|
62
|
+
// project they run in, and never match a mate or agent by name.
|
|
63
|
+
if (injected.senderKind === "automation") {
|
|
64
|
+
return {
|
|
65
|
+
name: injectedSenderName(injected),
|
|
66
|
+
avatarUrl: mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: AUTOMATION_SEED_PREFIX + (injected.fromName || "console") }, size),
|
|
67
|
+
matched: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var seed = declared
|
|
71
|
+
? (injected.fromName || fromId || UNDECLARED_SEED)
|
|
72
|
+
: (injected.senderKind === "undeclared" ? UNDECLARED_SEED : UNRECORDED_SEED);
|
|
73
|
+
return {
|
|
74
|
+
name: injectedSenderName(injected),
|
|
75
|
+
avatarUrl: mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: seed }, size),
|
|
76
|
+
matched: false,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Text shown for a message that another process injected into the session.
|
|
2
|
+
// senderKind is extracted (derived from the console's own records; fromName is
|
|
3
|
+
// "<agent or vendor>@<project>", always, even within the same project), declared
|
|
4
|
+
// (the caller named itself), undeclared (it named nobody) or unrecorded (a
|
|
5
|
+
// legacy entry). Never the operator's name.
|
|
6
|
+
|
|
7
|
+
export function injectedSenderName(injected) {
|
|
8
|
+
if ((injected.senderKind === "declared" || injected.senderKind === "extracted" || injected.senderKind === "automation") && injected.fromName) return injected.fromName;
|
|
9
|
+
if (injected.senderKind === "undeclared") return "Undeclared sender";
|
|
10
|
+
return "injected (sender not recorded)";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// A run-now is the same schedule fired early; the label says so.
|
|
14
|
+
var INITIATOR_TEXT = { "scheduled-now": "scheduled · sent now" };
|
|
15
|
+
|
|
16
|
+
// "trigger · note · declared": who injected, why, and how far the name can be trusted.
|
|
17
|
+
// "loop · job-hunter · iteration 3": a turn the console composed itself.
|
|
18
|
+
export function injectedLabel(injected) {
|
|
19
|
+
var parts = [];
|
|
20
|
+
if (injected.initiator) parts.push(INITIATOR_TEXT[injected.initiator] || injected.initiator);
|
|
21
|
+
if (injected.contextNote) parts.push(injected.contextNote);
|
|
22
|
+
if (injected.senderKind === "declared" || injected.senderKind === "undeclared" || injected.senderKind === "extracted") {
|
|
23
|
+
parts.push(injected.senderKind);
|
|
24
|
+
}
|
|
25
|
+
// A --from that names someone else is shown beside the extracted identity.
|
|
26
|
+
if (injected.senderKind === "extracted" && injected.declaredName) parts.push("declared as " + injected.declaredName);
|
|
27
|
+
return parts.join(" · ");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// The full sender session id, for hover or tap: it tells apart two sessions with
|
|
31
|
+
// the same agent and project, which the label does not. "" when not recorded.
|
|
32
|
+
export function injectedSessionNote(injected) {
|
|
33
|
+
if (injected.senderKind !== "extracted" || !injected.senderSessionId) return "";
|
|
34
|
+
return "session " + injected.senderSessionId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The record-format marker lib/injected-sender.js stamps on every new entry.
|
|
38
|
+
// A marked entry always names its initiator, so one that does not fails closed:
|
|
39
|
+
// it is not the operator's. An unmarked entry is legacy and renders as before,
|
|
40
|
+
// the operator's unless the server completed a sender onto it.
|
|
41
|
+
function isMarked(msg) {
|
|
42
|
+
return typeof msg.entryFormat === "number" && msg.entryFormat >= 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The injected descriptor for a user_message, or null for one the operator typed.
|
|
46
|
+
export function injectedFromMessage(msg) {
|
|
47
|
+
if (isMarked(msg)) {
|
|
48
|
+
if (msg.initiator === "human" && !msg.senderKind) return null;
|
|
49
|
+
} else if (!msg.senderKind) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
senderKind: msg.senderKind || "unrecorded",
|
|
54
|
+
fromName: msg.fromName,
|
|
55
|
+
initiator: msg.initiator,
|
|
56
|
+
contextNote: msg.contextNote,
|
|
57
|
+
senderAgent: msg.senderAgent,
|
|
58
|
+
senderAgentSlug: msg.senderAgentSlug,
|
|
59
|
+
senderSessionId: msg.senderSessionId,
|
|
60
|
+
declaredName: msg.declaredName,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -5,7 +5,10 @@ import { checkForMention, showMentionMenu, hideMentionMenu, isMentionMenuVisible
|
|
|
5
5
|
import { initAtAgents, showAgentMenu, hideAgentMenu, isAgentMenuActive, agentMenuKeydown, requestProjectAgents } from './at-agents.js';
|
|
6
6
|
import { store } from './store.js';
|
|
7
7
|
import { sendWsQuiet } from './ws-ref.js';
|
|
8
|
-
import { getScheduleDelayMs,
|
|
8
|
+
import { getScheduleDelayMs, getArmedSchedule, setArmedSchedule, canArmScheduledInput, getScheduledInputs } from './rate-limit-state.js';
|
|
9
|
+
import { createSchedulePanel } from './schedule-panel.js';
|
|
10
|
+
import { scheduleMessageFor, specLabel, specTitle } from './schedule-time.js';
|
|
11
|
+
import { sendScheduledNow, cancelScheduledInput } from './scheduled-input-actions.js';
|
|
9
12
|
|
|
10
13
|
var ctx;
|
|
11
14
|
|
|
@@ -23,7 +26,8 @@ var isRemoteInput = false;
|
|
|
23
26
|
// module-scoped variable — that was the root cause of arming in one project
|
|
24
27
|
// silently overwriting another project's armed state, since the SPA never
|
|
25
28
|
// reloads the page on project switch).
|
|
26
|
-
var
|
|
29
|
+
var _showArmedScheduleFn = null; // set by initInput: paints the clock button
|
|
30
|
+
var _schedulePanel = null; // set by initInput
|
|
27
31
|
var slashMenuBound = false;
|
|
28
32
|
|
|
29
33
|
function currentSessionId() {
|
|
@@ -46,14 +50,20 @@ export function getScheduleDelay(sessionId) {
|
|
|
46
50
|
return getScheduleDelayMs(sessionId === undefined ? currentSessionId() : sessionId);
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
// Arms (or disarms, with
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
53
|
+
// Arms (or disarms, with null) what the next typed message of a session is
|
|
54
|
+
// scheduled as: { kind: "once", delayMs | atMs } or { kind: "recurring",
|
|
55
|
+
// everyMs, untilMs | count }. Only touches the visible schedule button when
|
|
56
|
+
// sessionId is the currently focused session — arming a background session
|
|
57
|
+
// (e.g. a rate-limit hit in a project the user isn't looking at) must not
|
|
58
|
+
// repaint the UI for whatever session IS focused (lr-0827ba).
|
|
59
|
+
export function setArmedScheduleForSession(sessionId, spec) {
|
|
60
|
+
setArmedSchedule(sessionId, spec);
|
|
61
|
+
if (sessionId === currentSessionId() && _showArmedScheduleFn) _showArmedScheduleFn(spec);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Arms (or disarms, with ms=0) an "in N minutes" delay for a specific session.
|
|
54
65
|
export function setScheduleDelayForSession(sessionId, ms) {
|
|
55
|
-
|
|
56
|
-
if (sessionId === currentSessionId() && _setScheduleDelayFn) _setScheduleDelayFn(ms);
|
|
66
|
+
setArmedScheduleForSession(sessionId, ms > 0 ? { kind: "once", delayMs: ms } : null);
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
// Arms (or disarms, with ms=0) the schedule delay for the currently active
|
|
@@ -66,19 +76,18 @@ export function setScheduleDelayMs(ms) {
|
|
|
66
76
|
// without re-triggering any arm/disarm side effects — used when switching
|
|
67
77
|
// back into a session that has a background-armed schedule (lr-0827ba).
|
|
68
78
|
export function restoreScheduleDelayUi() {
|
|
69
|
-
if (
|
|
79
|
+
if (_showArmedScheduleFn) _showArmedScheduleFn(getArmedSchedule(currentSessionId()));
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
export function clearScheduleDelayForSession(sessionId) {
|
|
73
|
-
|
|
83
|
+
setArmedSchedule(sessionId, null);
|
|
74
84
|
if (sessionId !== currentSessionId()) return;
|
|
85
|
+
if (_showArmedScheduleFn) { _showArmedScheduleFn(null); return; }
|
|
75
86
|
var btn = document.getElementById("schedule-btn");
|
|
76
87
|
if (btn) {
|
|
77
88
|
btn.classList.remove("schedule-active", "schedule-expanded");
|
|
78
89
|
var lbl = btn.querySelector(".schedule-delay-label");
|
|
79
90
|
if (lbl) lbl.remove();
|
|
80
|
-
var inp = btn.querySelector(".schedule-inline-input");
|
|
81
|
-
if (inp) inp.remove();
|
|
82
91
|
btn.title = "Schedule message";
|
|
83
92
|
}
|
|
84
93
|
}
|
|
@@ -87,17 +96,20 @@ export function clearScheduleDelay() {
|
|
|
87
96
|
clearScheduleDelayForSession(currentSessionId());
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
|
|
99
|
+
// Recomputes the button from the on-screen session's own list of scheduled
|
|
100
|
+
// inputs. The button always opens the panel, also at the cap, because the
|
|
101
|
+
// panel is where a queued input is cancelled or sent now; at the cap only the
|
|
102
|
+
// panel's Schedule control is off (see schedule-panel.js). The button just says
|
|
103
|
+
// so in its tooltip.
|
|
104
|
+
export function refreshScheduleControls() {
|
|
91
105
|
var btn = document.getElementById("schedule-btn");
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
if (disabled) {
|
|
95
|
-
btn.style.opacity = "0.3";
|
|
96
|
-
btn.style.pointerEvents = "none";
|
|
97
|
-
} else {
|
|
106
|
+
if (btn) {
|
|
107
|
+
btn.disabled = false;
|
|
98
108
|
btn.style.opacity = "";
|
|
99
109
|
btn.style.pointerEvents = "";
|
|
110
|
+
if (btn.classList) btn.classList.toggle("schedule-at-cap", !canArmScheduledInput(currentSessionId()));
|
|
100
111
|
}
|
|
112
|
+
if (_schedulePanel) _schedulePanel.refresh();
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
export var builtinCommands = [
|
|
@@ -257,11 +269,10 @@ export function sendMessage() {
|
|
|
257
269
|
return;
|
|
258
270
|
}
|
|
259
271
|
|
|
260
|
-
// Scheduled
|
|
261
|
-
var
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
ctx.ws.send(JSON.stringify({ type: "schedule_message", text: text || "", resetsAt: resetsAt }));
|
|
272
|
+
// Scheduled input: the armed schedule (once or a repeat) takes this message.
|
|
273
|
+
var _armedSchedule = getArmedSchedule(currentSessionId());
|
|
274
|
+
if (_armedSchedule) {
|
|
275
|
+
ctx.ws.send(JSON.stringify(scheduleMessageFor(_armedSchedule, text || "", Date.now())));
|
|
265
276
|
clearScheduleDelay();
|
|
266
277
|
ctx.inputEl.value = "";
|
|
267
278
|
sendInputSync();
|
|
@@ -879,109 +890,48 @@ export function initInput(_ctx) {
|
|
|
879
890
|
});
|
|
880
891
|
}
|
|
881
892
|
|
|
882
|
-
// Schedule button —
|
|
893
|
+
// Schedule button — opens the schedule panel (once or repeat, and the
|
|
894
|
+
// session's armed scheduled inputs). Armed, it shows what the next typed
|
|
895
|
+
// message is scheduled as; clicking it then clears that.
|
|
883
896
|
var scheduleBtn = document.getElementById("schedule-btn");
|
|
884
|
-
var
|
|
885
|
-
var scheduleInlineLabel = null;
|
|
886
|
-
var scheduleOutsideHandler = null;
|
|
887
|
-
|
|
888
|
-
function formatDelayLabel(ms) {
|
|
889
|
-
var mins = Math.round(ms / 60000);
|
|
890
|
-
if (mins < 60) return mins + "m";
|
|
891
|
-
var hrs = Math.floor(mins / 60);
|
|
892
|
-
var rem = mins % 60;
|
|
893
|
-
return rem > 0 ? hrs + "h " + rem + "m" : hrs + "h";
|
|
894
|
-
}
|
|
897
|
+
var scheduleLabelEl = null;
|
|
895
898
|
|
|
896
|
-
|
|
899
|
+
// Paints the clock button for an armed schedule, or none.
|
|
900
|
+
function showArmedSchedule(spec) {
|
|
897
901
|
if (!scheduleBtn) return;
|
|
898
|
-
|
|
899
|
-
if (
|
|
900
|
-
if (scheduleInlineLabel) { scheduleInlineLabel.remove(); scheduleInlineLabel = null; }
|
|
901
|
-
if (scheduleOutsideHandler) {
|
|
902
|
-
document.removeEventListener("mousedown", scheduleOutsideHandler);
|
|
903
|
-
scheduleOutsideHandler = null;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
function setScheduleDelay(ms) {
|
|
908
|
-
setSessionScheduleDelayMs(currentSessionId(), ms);
|
|
909
|
-
if (!scheduleBtn) return;
|
|
910
|
-
collapseScheduleBtn();
|
|
911
|
-
if (ms > 0) {
|
|
912
|
-
scheduleBtn.classList.add("schedule-active", "schedule-expanded");
|
|
913
|
-
scheduleBtn.title = "Scheduled: " + formatDelayLabel(ms) + " (click to clear)";
|
|
914
|
-
scheduleInlineLabel = document.createElement("span");
|
|
915
|
-
scheduleInlineLabel.className = "schedule-delay-label";
|
|
916
|
-
scheduleInlineLabel.textContent = formatDelayLabel(ms);
|
|
917
|
-
scheduleBtn.appendChild(scheduleInlineLabel);
|
|
918
|
-
} else {
|
|
902
|
+
if (scheduleLabelEl) { scheduleLabelEl.remove(); scheduleLabelEl = null; }
|
|
903
|
+
if (!spec) {
|
|
919
904
|
scheduleBtn.classList.remove("schedule-active", "schedule-expanded");
|
|
920
905
|
scheduleBtn.title = "Schedule message";
|
|
906
|
+
return;
|
|
921
907
|
}
|
|
908
|
+
scheduleBtn.classList.add("schedule-active", "schedule-expanded");
|
|
909
|
+
scheduleBtn.title = "Scheduled: " + specTitle(spec, Date.now()) + " (click to clear)";
|
|
910
|
+
scheduleLabelEl = document.createElement("span");
|
|
911
|
+
scheduleLabelEl.className = "schedule-delay-label";
|
|
912
|
+
scheduleLabelEl.textContent = specLabel(spec);
|
|
913
|
+
scheduleBtn.appendChild(scheduleLabelEl);
|
|
922
914
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
function expandScheduleInput() {
|
|
926
|
-
if (!scheduleBtn) return;
|
|
927
|
-
scheduleBtn.classList.add("schedule-expanded");
|
|
928
|
-
scheduleInlineInput = document.createElement("input");
|
|
929
|
-
scheduleInlineInput.type = "number";
|
|
930
|
-
scheduleInlineInput.min = "1";
|
|
931
|
-
scheduleInlineInput.max = "1440";
|
|
932
|
-
scheduleInlineInput.placeholder = "min";
|
|
933
|
-
scheduleInlineInput.className = "schedule-inline-input";
|
|
934
|
-
scheduleBtn.appendChild(scheduleInlineInput);
|
|
935
|
-
|
|
936
|
-
setTimeout(function () { scheduleInlineInput.focus(); }, 0);
|
|
937
|
-
|
|
938
|
-
scheduleInlineInput.addEventListener("click", function (e) { e.stopPropagation(); });
|
|
939
|
-
scheduleInlineInput.addEventListener("keydown", function (e) {
|
|
940
|
-
if (e.key === "Enter") {
|
|
941
|
-
e.preventDefault();
|
|
942
|
-
var val = parseInt(scheduleInlineInput.value, 10);
|
|
943
|
-
if (val >= 1 && val <= 1440) {
|
|
944
|
-
setScheduleDelay(val * 60000);
|
|
945
|
-
} else {
|
|
946
|
-
collapseScheduleBtn();
|
|
947
|
-
}
|
|
948
|
-
} else if (e.key === "Escape") {
|
|
949
|
-
collapseScheduleBtn();
|
|
950
|
-
}
|
|
951
|
-
});
|
|
915
|
+
_showArmedScheduleFn = showArmedSchedule;
|
|
952
916
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
} else {
|
|
962
|
-
collapseScheduleBtn();
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
document.removeEventListener("mousedown", scheduleOutsideHandler);
|
|
966
|
-
scheduleOutsideHandler = null;
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
document.addEventListener("mousedown", scheduleOutsideHandler);
|
|
970
|
-
}, 0);
|
|
971
|
-
}
|
|
917
|
+
_schedulePanel = scheduleBtn ? createSchedulePanel({
|
|
918
|
+
anchorEl: scheduleBtn,
|
|
919
|
+
getInputs: function () { return getScheduledInputs(currentSessionId()); },
|
|
920
|
+
canArm: function () { return canArmScheduledInput(currentSessionId()); },
|
|
921
|
+
onArm: function (spec) { setArmedScheduleForSession(currentSessionId(), spec); },
|
|
922
|
+
onSendNow: sendScheduledNow,
|
|
923
|
+
onCancel: cancelScheduledInput,
|
|
924
|
+
}) : null;
|
|
972
925
|
|
|
973
926
|
if (scheduleBtn) {
|
|
974
927
|
scheduleBtn.addEventListener("click", function (e) {
|
|
975
928
|
e.stopPropagation();
|
|
976
|
-
if (
|
|
977
|
-
|
|
929
|
+
if (getArmedSchedule(currentSessionId())) {
|
|
930
|
+
_schedulePanel.close();
|
|
931
|
+
setArmedScheduleForSession(currentSessionId(), null);
|
|
978
932
|
return;
|
|
979
933
|
}
|
|
980
|
-
|
|
981
|
-
collapseScheduleBtn();
|
|
982
|
-
} else {
|
|
983
|
-
expandScheduleInput();
|
|
984
|
-
}
|
|
934
|
+
_schedulePanel.toggle();
|
|
985
935
|
});
|
|
986
936
|
}
|
|
987
937
|
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
// mode-options.js - the permission modes the config chip offers,
|
|
2
|
-
// labels. Import-free so it can be exercised without the
|
|
3
|
-
// graph.
|
|
1
|
+
// mode-options.js - the permission modes the config chip offers, with their
|
|
2
|
+
// labels and one-line hints. Import-free so it can be exercised without the
|
|
3
|
+
// frontend module graph.
|
|
4
4
|
//
|
|
5
|
-
// Default, Plan and
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
5
|
+
// Default, Plan and Accept edits are offered whenever the session's agent
|
|
6
|
+
// declares permission modes at all (the caller gates on that capability); an
|
|
7
|
+
// agent that declares none is shown no mode list. Don't ask and Auto exist only
|
|
8
|
+
// in Claude Code: they are offered for a session whose vendor declares them in
|
|
9
|
+
// capabilities.permissionModes, so a vendor that does not (Codex, or one whose
|
|
10
|
+
// capabilities are not known yet) never shows them. Bypass permissions is
|
|
11
|
+
// offered when the daemon allows it. Labels and hints follow the Claude Agent
|
|
12
|
+
// SDK's PermissionMode definitions; only one label contains the word "auto",
|
|
13
|
+
// so the picker never shows two kinds of auto.
|
|
11
14
|
|
|
12
15
|
var BASE_MODES = [
|
|
13
|
-
{ value: "default", label: "Default" },
|
|
14
|
-
{ value: "plan", label: "Plan" },
|
|
15
|
-
{ value: "acceptEdits", label: "
|
|
16
|
+
{ value: "default", label: "Default", hint: "Asks before each action that needs permission." },
|
|
17
|
+
{ value: "plan", label: "Plan", hint: "Plans only and makes no changes until you approve the plan." },
|
|
18
|
+
{ value: "acceptEdits", label: "Accept edits", hint: "Approves file edits automatically and asks for everything else." },
|
|
16
19
|
];
|
|
17
20
|
|
|
18
21
|
var CAPABILITY_MODES = [
|
|
19
|
-
{ value: "dontAsk", label: "Don’t ask" },
|
|
20
|
-
{ value: "auto", label: "Auto" },
|
|
22
|
+
{ value: "dontAsk", label: "Don’t ask (deny)", hint: "Never asks. Denies any action that is not already approved." },
|
|
23
|
+
{ value: "auto", label: "Auto (model decides)", hint: "A model approves or denies each action and asks you only when it cannot decide." },
|
|
21
24
|
];
|
|
22
25
|
|
|
23
|
-
var FULL_AUTO = { value: "bypassPermissions", label: "
|
|
26
|
+
var FULL_AUTO = { value: "bypassPermissions", label: "Bypass permissions", hint: "Skips permission checks and approves every action." };
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* @param {?object} capabilities - the session vendor's capabilities.
|
|
27
30
|
* @param {boolean} fullAutoEnabled
|
|
28
|
-
* @returns {{value: string, label: string}[]}
|
|
31
|
+
* @returns {{value: string, label: string, hint: string}[]}
|
|
29
32
|
*/
|
|
30
33
|
export function modeOptions(capabilities, fullAutoEnabled) {
|
|
31
34
|
var declared = capabilities && Array.isArray(capabilities.permissionModes) ? capabilities.permissionModes : [];
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
// existing sessionDrafts precedent in app-messages.js/app.js. Each session's
|
|
15
15
|
// entry keeps running in the background (including its reset setTimeout)
|
|
16
16
|
// even while a different session is focused, mirroring server-side behavior
|
|
17
|
-
// (
|
|
18
|
-
// per-session).
|
|
17
|
+
// (the server's scheduled inputs are bound to one session each).
|
|
19
18
|
//
|
|
20
19
|
// DOM-free by design so it can be imported and unit-tested directly under
|
|
21
20
|
// plain Node (see test/rate-limit-state.test.js), following the same
|
|
@@ -23,17 +22,25 @@
|
|
|
23
22
|
|
|
24
23
|
var _bySession = Object.create(null);
|
|
25
24
|
|
|
25
|
+
// How many armed scheduled inputs a session may hold until the server says
|
|
26
|
+
// otherwise (it sends its own limit with every list).
|
|
27
|
+
var DEFAULT_SCHEDULED_INPUT_LIMIT = 5;
|
|
28
|
+
|
|
26
29
|
function emptyEntry() {
|
|
27
30
|
return {
|
|
28
|
-
//
|
|
29
|
-
|
|
31
|
+
// What the composer will schedule the next typed message as, or null:
|
|
32
|
+
// { kind: "once", delayMs } | { kind: "once", atMs } |
|
|
33
|
+
// { kind: "recurring", everyMs, untilMs | count } (input.js sendMessage()
|
|
34
|
+
// consumes this).
|
|
35
|
+
armedSchedule: null,
|
|
30
36
|
// Rate-limit-driven auto-schedule bookkeeping (app-rate-limit.js).
|
|
31
37
|
rateLimitResetsAt: null,
|
|
32
38
|
rateLimitResetTimer: null,
|
|
33
39
|
rateLimitResetState: {},
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
// The session's armed scheduled inputs, exactly as the server last listed
|
|
41
|
+
// them: the only source for the bubbles, the panel list and the button.
|
|
42
|
+
scheduledInputs: [],
|
|
43
|
+
scheduledInputLimit: DEFAULT_SCHEDULED_INPUT_LIMIT,
|
|
37
44
|
};
|
|
38
45
|
}
|
|
39
46
|
|
|
@@ -43,15 +50,27 @@ function getEntry(sessionId) {
|
|
|
43
50
|
return _bySession[sessionId];
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
// ---
|
|
53
|
+
// --- Armed schedule (what the next typed message is scheduled as) ---
|
|
54
|
+
|
|
55
|
+
export function getArmedSchedule(sessionId) {
|
|
56
|
+
return getEntry(sessionId).armedSchedule;
|
|
57
|
+
}
|
|
47
58
|
|
|
59
|
+
export function setArmedSchedule(sessionId, spec) {
|
|
60
|
+
if (sessionId == null) return;
|
|
61
|
+
getEntry(sessionId).armedSchedule = spec || null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The armed "in N minutes" delay, 0 when none is armed or the armed schedule
|
|
65
|
+
// is of another shape. The rate-limit auto-schedule arms through this.
|
|
48
66
|
export function getScheduleDelayMs(sessionId) {
|
|
49
|
-
|
|
67
|
+
var spec = getEntry(sessionId).armedSchedule;
|
|
68
|
+
return spec && spec.kind === "once" && spec.delayMs > 0 ? spec.delayMs : 0;
|
|
50
69
|
}
|
|
51
70
|
|
|
52
71
|
export function setScheduleDelayMs(sessionId, ms) {
|
|
53
72
|
if (sessionId == null) return;
|
|
54
|
-
getEntry(sessionId).
|
|
73
|
+
getEntry(sessionId).armedSchedule = ms > 0 ? { kind: "once", delayMs: ms } : null;
|
|
55
74
|
}
|
|
56
75
|
|
|
57
76
|
// --- Rate-limit reset bookkeeping ---
|
|
@@ -78,26 +97,32 @@ export function getRateLimitResetState(sessionId) {
|
|
|
78
97
|
return getEntry(sessionId).rateLimitResetState;
|
|
79
98
|
}
|
|
80
99
|
|
|
81
|
-
// --- Scheduled
|
|
100
|
+
// --- Scheduled inputs (the server's list for the session) ---
|
|
82
101
|
|
|
83
|
-
export function
|
|
84
|
-
|
|
85
|
-
if (e.scheduledMsgText == null) return null;
|
|
86
|
-
return { text: e.scheduledMsgText, resetsAt: e.scheduledMsgResetsAt };
|
|
102
|
+
export function getScheduledInputs(sessionId) {
|
|
103
|
+
return getEntry(sessionId).scheduledInputs.slice();
|
|
87
104
|
}
|
|
88
105
|
|
|
89
|
-
|
|
106
|
+
// Replaces the session's list with the one the server sent. limit is the
|
|
107
|
+
// server's per-session cap, when it sent one.
|
|
108
|
+
export function setScheduledInputs(sessionId, inputs, limit) {
|
|
90
109
|
if (sessionId == null) return;
|
|
91
110
|
var e = getEntry(sessionId);
|
|
92
|
-
e.
|
|
93
|
-
e.
|
|
111
|
+
e.scheduledInputs = Array.isArray(inputs) ? inputs.slice() : [];
|
|
112
|
+
if (typeof limit === "number" && isFinite(limit) && limit >= 0) e.scheduledInputLimit = limit;
|
|
94
113
|
}
|
|
95
114
|
|
|
96
|
-
export function
|
|
115
|
+
export function clearScheduledInputs(sessionId) {
|
|
97
116
|
if (sessionId == null) return;
|
|
117
|
+
getEntry(sessionId).scheduledInputs = [];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// A session can take another scheduled input exactly while its list is below
|
|
121
|
+
// the cap. The schedule panel derives whether its Schedule control is enabled
|
|
122
|
+
// from this for the session on screen; it is never stored separately.
|
|
123
|
+
export function canArmScheduledInput(sessionId) {
|
|
98
124
|
var e = getEntry(sessionId);
|
|
99
|
-
e.
|
|
100
|
-
e.scheduledMsgResetsAt = null;
|
|
125
|
+
return e.scheduledInputs.length < e.scheduledInputLimit;
|
|
101
126
|
}
|
|
102
127
|
|
|
103
128
|
// --- Whole-session lifecycle ---
|
|
@@ -108,7 +133,7 @@ export function hasArmedState(sessionId) {
|
|
|
108
133
|
if (sessionId == null) return false;
|
|
109
134
|
var e = _bySession[sessionId];
|
|
110
135
|
if (!e) return false;
|
|
111
|
-
return e.
|
|
136
|
+
return e.armedSchedule != null || e.scheduledInputs.length > 0;
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
// Clears a single session's state entirely, including canceling its
|