@clagentic/console 1.10.0 → 1.11.0-beta.2
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 -1
- package/bin/cli.js +38 -16
- 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/arg-validation.js +50 -0
- package/lib/cli/daemon-launch.js +5 -4
- package/lib/cli/menus.js +2 -2
- package/lib/cli/schedule-input-subcommands.js +327 -0
- package/lib/cli/session-subcommands.js +101 -17
- package/lib/client-build-id.js +56 -0
- package/lib/daemon.js +38 -6
- package/lib/identity/index.js +9 -4
- 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-settings.js +96 -0
- package/lib/permission-summary.js +67 -0
- package/lib/project-connection.js +10 -11
- package/lib/project-external-trigger.js +9 -1
- package/lib/project-loop.js +50 -23
- package/lib/project-permission-settings.js +59 -0
- package/lib/project-prompt-responses.js +25 -15
- package/lib/project-sessions.js +164 -60
- package/lib/project-user-message.js +18 -47
- package/lib/project.js +46 -74
- package/lib/public/app.js +4 -7
- 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/css/overlays.css +0 -3
- package/lib/public/css/scheduler-modal.css +5 -0
- package/lib/public/index.html +44 -8
- package/lib/public/modules/app-connection.js +18 -1
- package/lib/public/modules/app-loop-ui.js +11 -1
- package/lib/public/modules/app-messages.js +23 -30
- package/lib/public/modules/app-panels.js +10 -3
- package/lib/public/modules/app-rate-limit.js +64 -88
- package/lib/public/modules/app-rendering.js +37 -6
- package/lib/public/modules/approve-tools-toggle.js +33 -0
- 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/loop-hooks-warning.js +20 -0
- package/lib/public/modules/mode-options.js +35 -16
- package/lib/public/modules/permission-settings.js +56 -0
- package/lib/public/modules/project-settings.js +3 -0
- 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/public/modules/scheduler-config.js +12 -0
- package/lib/public/modules/scheduler.js +8 -0
- package/lib/public/modules/server-settings.js +5 -9
- package/lib/public/modules/settings-defaults.js +18 -4
- 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/scheduler.js +4 -0
- package/lib/sdk-bridge.js +194 -175
- 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 +37 -11
- package/lib/session-directory.js +224 -0
- package/lib/session-file-scan.js +55 -0
- package/lib/session-input-ipc.js +21 -0
- package/lib/session-input.js +396 -23
- package/lib/session-name-holder.js +82 -0
- package/lib/session-resume.js +3 -0
- package/lib/sessions.js +111 -2
- package/lib/turn-initiator.js +6 -2
- package/lib/updater.js +8 -2
- package/lib/ws-schema.js +20 -9
- package/lib/yoke/adapters/claude-worker.js +3 -1
- package/lib/yoke/adapters/claude.js +13 -17
- 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,193 @@
|
|
|
1
|
+
// schedule-time.js - the time arithmetic and wording of the schedule panel.
|
|
2
|
+
// DOM-free, so it can be tested under plain Node.
|
|
3
|
+
//
|
|
4
|
+
// resolveClockTime mirrors the CLI's (lib/cli/schedule-input-subcommands.js),
|
|
5
|
+
// which the browser cannot load; test/scheduled-input-client.test.js feeds both the
|
|
6
|
+
// same cases. Everything is the browser's local time zone.
|
|
7
|
+
|
|
8
|
+
var MIN_EVERY_MIN = 1;
|
|
9
|
+
var MAX_EVERY_MIN = 24 * 60;
|
|
10
|
+
var MAX_ONCE_MIN = 24 * 60;
|
|
11
|
+
var MAX_COUNT = 1000;
|
|
12
|
+
|
|
13
|
+
function pad2(n) {
|
|
14
|
+
return (n < 10 ? "0" : "") + n;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// A whole number of minutes from a field's text, or null.
|
|
18
|
+
export function parseMinutes(raw, max) {
|
|
19
|
+
var text = typeof raw === "string" ? raw.trim() : String(raw == null ? "" : raw);
|
|
20
|
+
if (!/^\d+$/.test(text)) return null;
|
|
21
|
+
var n = parseInt(text, 10);
|
|
22
|
+
return n >= 1 && n <= max ? n : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The next occurrence, strictly after `now`, of a local HH:MM. A time that has
|
|
26
|
+
// passed today means tomorrow. Returns { ms, tomorrow } or { error }.
|
|
27
|
+
export function resolveClockTime(raw, now) {
|
|
28
|
+
var m = /^(\d{1,2}):(\d{2})$/.exec(typeof raw === "string" ? raw.trim() : "");
|
|
29
|
+
if (!m) return { error: "Enter a time as HH:MM." };
|
|
30
|
+
var h = parseInt(m[1], 10);
|
|
31
|
+
var mi = parseInt(m[2], 10);
|
|
32
|
+
if (h > 23 || mi > 59) return { error: "Enter a time from 00:00 to 23:59." };
|
|
33
|
+
var d = new Date(now);
|
|
34
|
+
d.setHours(h, mi, 0, 0);
|
|
35
|
+
var tomorrow = false;
|
|
36
|
+
if (d.getTime() <= now) {
|
|
37
|
+
d.setDate(d.getDate() + 1);
|
|
38
|
+
tomorrow = true;
|
|
39
|
+
}
|
|
40
|
+
return { ms: d.getTime(), tomorrow: tomorrow };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function clockText(ms) {
|
|
44
|
+
var d = new Date(ms);
|
|
45
|
+
return pad2(d.getHours()) + ":" + pad2(d.getMinutes());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
49
|
+
|
|
50
|
+
// "today at 20:01", "tomorrow at 20:01", or "Mar 3 at 20:01" for a later day.
|
|
51
|
+
export function dayTimeText(ms, now) {
|
|
52
|
+
var d = new Date(ms);
|
|
53
|
+
var today = new Date(now);
|
|
54
|
+
today.setHours(0, 0, 0, 0);
|
|
55
|
+
var dayStart = new Date(ms);
|
|
56
|
+
dayStart.setHours(0, 0, 0, 0);
|
|
57
|
+
var days = Math.round((dayStart.getTime() - today.getTime()) / 86400000);
|
|
58
|
+
var when;
|
|
59
|
+
if (days === 0) when = "today";
|
|
60
|
+
else if (days === 1) when = "tomorrow";
|
|
61
|
+
else when = MONTHS[d.getMonth()] + " " + d.getDate();
|
|
62
|
+
return when + " at " + clockText(ms);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function durationText(ms) {
|
|
66
|
+
var mins = Math.round(ms / 60000);
|
|
67
|
+
if (mins < 60) return mins + " min";
|
|
68
|
+
var hrs = Math.floor(mins / 60);
|
|
69
|
+
var rem = mins % 60;
|
|
70
|
+
return rem ? hrs + " h " + rem + " min" : hrs + " h";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// form: { mode: "once" | "repeat",
|
|
74
|
+
// onceBy: "in" | "at", inMinutes, at,
|
|
75
|
+
// everyMinutes, endBy: "until" | "count", until, count }
|
|
76
|
+
// Returns { spec, summary } or { error }. spec is what the composer arms (see
|
|
77
|
+
// scheduleMessageFor); summary says, before anything is armed, when it will go,
|
|
78
|
+
// including "tomorrow".
|
|
79
|
+
export function buildSchedule(form, now) {
|
|
80
|
+
if (form.mode === "once") {
|
|
81
|
+
if (form.onceBy === "at") {
|
|
82
|
+
var at = resolveClockTime(form.at, now);
|
|
83
|
+
if (at.error) return { error: at.error };
|
|
84
|
+
return { spec: { kind: "once", atMs: at.ms }, summary: "Sends " + dayTimeText(at.ms, now) + "." };
|
|
85
|
+
}
|
|
86
|
+
var mins = parseMinutes(form.inMinutes, MAX_ONCE_MIN);
|
|
87
|
+
if (mins === null) return { error: "Enter a number of minutes from 1 to " + MAX_ONCE_MIN + "." };
|
|
88
|
+
return { spec: { kind: "once", delayMs: mins * 60000 }, summary: "Sends in " + durationText(mins * 60000) + ", at " + clockText(now + mins * 60000) + "." };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var every = parseMinutes(form.everyMinutes, MAX_EVERY_MIN);
|
|
92
|
+
if (every === null) return { error: "Repeat every a number of minutes from " + MIN_EVERY_MIN + " to " + MAX_EVERY_MIN + " (24 hours)." };
|
|
93
|
+
var everyMs = every * 60000;
|
|
94
|
+
var first = "first " + dayTimeText(now + everyMs, now);
|
|
95
|
+
if (form.endBy === "count") {
|
|
96
|
+
var count = parseMinutes(form.count, MAX_COUNT);
|
|
97
|
+
if (count === null) return { error: "Enter how many times, from 1 to " + MAX_COUNT + "." };
|
|
98
|
+
return {
|
|
99
|
+
spec: { kind: "recurring", everyMs: everyMs, count: count },
|
|
100
|
+
summary: "Sends every " + durationText(everyMs) + ", " + count + (count === 1 ? " time" : " times") + " (" + first + ").",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
var until = resolveClockTime(form.until, now);
|
|
104
|
+
if (until.error) return { error: until.error };
|
|
105
|
+
if (until.ms < now + everyMs) {
|
|
106
|
+
return { error: "That end time is before the first send (" + dayTimeText(now + everyMs, now) + "). Pick a later end or a shorter interval." };
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
spec: { kind: "recurring", everyMs: everyMs, untilMs: until.ms },
|
|
110
|
+
summary: "Sends every " + durationText(everyMs) + " until " + dayTimeText(until.ms, now) + " (" + first + ").",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// The websocket message the composer sends for an armed spec and the typed text.
|
|
115
|
+
export function scheduleMessageFor(spec, text, now) {
|
|
116
|
+
if (spec.kind === "once") {
|
|
117
|
+
return { type: "schedule_message", text: text, resetsAt: spec.atMs != null ? spec.atMs : now + spec.delayMs };
|
|
118
|
+
}
|
|
119
|
+
var msg = { type: "schedule_message", text: text, kind: "recurring", every: spec.everyMs };
|
|
120
|
+
if (spec.untilMs != null) msg.until = spec.untilMs;
|
|
121
|
+
else msg.count = spec.count;
|
|
122
|
+
return msg;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function shortDuration(ms) {
|
|
126
|
+
var mins = Math.round(ms / 60000);
|
|
127
|
+
if (mins < 60) return mins + "m";
|
|
128
|
+
var hrs = Math.floor(mins / 60);
|
|
129
|
+
var rem = mins % 60;
|
|
130
|
+
return rem > 0 ? hrs + "h " + rem + "m" : hrs + "h";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// The short text beside the clock button while a schedule is armed.
|
|
134
|
+
export function specLabel(spec) {
|
|
135
|
+
if (spec.kind === "once") return spec.atMs != null ? "at " + clockText(spec.atMs) : shortDuration(spec.delayMs);
|
|
136
|
+
return "every " + shortDuration(spec.everyMs);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// The longer wording of the same, for the button's tooltip.
|
|
140
|
+
export function specTitle(spec, now) {
|
|
141
|
+
if (spec.kind === "once") {
|
|
142
|
+
return spec.atMs != null ? dayTimeText(spec.atMs, now) : "in " + durationText(spec.delayMs);
|
|
143
|
+
}
|
|
144
|
+
var end = spec.untilMs != null ? "until " + dayTimeText(spec.untilMs, now) : spec.count + (spec.count === 1 ? " time" : " times");
|
|
145
|
+
return "every " + durationText(spec.everyMs) + ", " + end;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// What the chat and the lists call an input: plain words, and the automatic
|
|
149
|
+
// resume under its own name.
|
|
150
|
+
export function inputLabel(input) {
|
|
151
|
+
if (input.createdBy === "rate-limit") return "Automatic resume after rate limit";
|
|
152
|
+
return input.kind === "recurring" ? "Scheduled repeat" : "Scheduled message";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The line under a scheduled-message bubble, refreshed every second:
|
|
156
|
+
// "Sends at 08:30 PM (4m 12s)", and for a repeat the next time and its end.
|
|
157
|
+
export function countdownText(input, now) {
|
|
158
|
+
var lead = "";
|
|
159
|
+
if (input.createdBy === "rate-limit") lead = "Automatic resume after rate limit · ";
|
|
160
|
+
else if (input.kind === "recurring") lead = "Scheduled repeat · ";
|
|
161
|
+
var remaining = input.nextAt - now;
|
|
162
|
+
if (remaining <= 0) return lead + "Sending...";
|
|
163
|
+
var hrs = Math.floor(remaining / 3600000);
|
|
164
|
+
var mins = Math.floor((remaining % 3600000) / 60000);
|
|
165
|
+
var secs = Math.floor((remaining % 60000) / 1000);
|
|
166
|
+
var timeStr = "";
|
|
167
|
+
if (hrs > 0) timeStr += hrs + "h ";
|
|
168
|
+
if (mins > 0 || hrs > 0) timeStr += mins + "m ";
|
|
169
|
+
timeStr += secs + "s";
|
|
170
|
+
var abs = new Date(input.nextAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
171
|
+
var text = lead + (input.kind === "recurring" ? "Next at " : "Sends at ") + abs + " (" + timeStr + ")";
|
|
172
|
+
if (input.kind === "recurring") {
|
|
173
|
+
text += " · every " + durationText(input.every);
|
|
174
|
+
if (input.until != null) text += " until " + dayTimeText(input.until, now).replace(/^today at /, "");
|
|
175
|
+
else if (input.count != null) text += " · " + (input.count - input.firedCount) + " of " + input.count + " left";
|
|
176
|
+
}
|
|
177
|
+
return text;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// "Scheduled repeat · every 30 min · next 19:30 · until 21:00", for the panel
|
|
181
|
+
// list and the bubble.
|
|
182
|
+
export function inputSummary(input, now) {
|
|
183
|
+
var parts = [inputLabel(input)];
|
|
184
|
+
if (input.kind === "recurring") {
|
|
185
|
+
parts.push("every " + durationText(input.every));
|
|
186
|
+
parts.push("next " + dayTimeText(input.nextAt, now).replace(/^today at /, ""));
|
|
187
|
+
if (input.until != null) parts.push("until " + dayTimeText(input.until, now).replace(/^today at /, ""));
|
|
188
|
+
else if (input.count != null) parts.push((input.count - input.firedCount) + " of " + input.count + " left");
|
|
189
|
+
} else {
|
|
190
|
+
parts.push(dayTimeText(input.nextAt, now).replace(/^today at /, ""));
|
|
191
|
+
}
|
|
192
|
+
return parts.join(" · ");
|
|
193
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// scheduled-input-actions.js - the messages the schedule panel and the
|
|
2
|
+
// scheduled-message bubbles send to the server about a scheduled input. One
|
|
3
|
+
// place, so the two surfaces cannot drift apart.
|
|
4
|
+
|
|
5
|
+
import { sendWs } from './ws-ref.js';
|
|
6
|
+
|
|
7
|
+
export function sendScheduledNow(id) {
|
|
8
|
+
return sendWs({ type: "send_scheduled_now", id: id });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function cancelScheduledInput(id) {
|
|
12
|
+
return sendWs({ type: "cancel_scheduled_message", id: id });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Asks for the armed inputs of the session on screen; the answer arrives as
|
|
16
|
+
// scheduled_input_list.
|
|
17
|
+
export function requestScheduledInputList() {
|
|
18
|
+
return sendWs({ type: "scheduled_input_list_request" });
|
|
19
|
+
}
|
|
@@ -774,6 +774,10 @@ export function openCreateModalWithRecord(rec, anchorEl) {
|
|
|
774
774
|
var skipRunningEl = document.getElementById("sched-skip-running");
|
|
775
775
|
if (skipRunningEl) skipRunningEl.checked = rec.skipIfRunning !== false;
|
|
776
776
|
|
|
777
|
+
// A record that never had the setting approves tools, as it always did.
|
|
778
|
+
var approveToolsEl = document.getElementById("sched-approve-tools");
|
|
779
|
+
if (approveToolsEl) approveToolsEl.checked = rec.approveToolsAutomatically !== false;
|
|
780
|
+
|
|
777
781
|
// Set iterations + review checkbox
|
|
778
782
|
var hasReview = rec.maxIterations && rec.maxIterations > 1;
|
|
779
783
|
var iterInput = document.getElementById("sched-create-iterations");
|
|
@@ -945,6 +949,10 @@ export function openCreateModal(date, hour, anchorEl) {
|
|
|
945
949
|
if (reviewCheck) reviewCheck.checked = false;
|
|
946
950
|
var reviewCount = document.getElementById("sched-review-count");
|
|
947
951
|
if (reviewCount) reviewCount.classList.add("hidden");
|
|
952
|
+
// A new schedule approves tools automatically, as every loop did before the
|
|
953
|
+
// setting existed; openCreateModalWithRecord sets the record's value after.
|
|
954
|
+
var approveToolsReset = document.getElementById("sched-approve-tools");
|
|
955
|
+
if (approveToolsReset) approveToolsReset.checked = true;
|
|
948
956
|
// (task is always visible, no accordion reset needed)
|
|
949
957
|
|
|
950
958
|
// Reset color
|
|
@@ -1515,6 +1523,8 @@ function submitCreateSchedule() {
|
|
|
1515
1523
|
|
|
1516
1524
|
var skipRunningEl = document.getElementById("sched-skip-running");
|
|
1517
1525
|
var skipIfRunning = skipRunningEl ? skipRunningEl.checked : true;
|
|
1526
|
+
var approveToolsEl = document.getElementById("sched-approve-tools");
|
|
1527
|
+
var approveToolsAutomatically = approveToolsEl ? approveToolsEl.checked : true;
|
|
1518
1528
|
|
|
1519
1529
|
var reviewCheckSubmit = document.getElementById("sched-review-check");
|
|
1520
1530
|
var maxIterations = 1;
|
|
@@ -1542,6 +1552,7 @@ function submitCreateSchedule() {
|
|
|
1542
1552
|
intervalEnd: intervalEnd,
|
|
1543
1553
|
maxIterations: maxIterations,
|
|
1544
1554
|
skipIfRunning: skipIfRunning,
|
|
1555
|
+
approveToolsAutomatically: approveToolsAutomatically,
|
|
1545
1556
|
},
|
|
1546
1557
|
});
|
|
1547
1558
|
} else {
|
|
@@ -1561,6 +1572,7 @@ function submitCreateSchedule() {
|
|
|
1561
1572
|
intervalEnd: intervalEnd,
|
|
1562
1573
|
maxIterations: maxIterations,
|
|
1563
1574
|
skipIfRunning: skipIfRunning,
|
|
1575
|
+
approveToolsAutomatically: approveToolsAutomatically,
|
|
1564
1576
|
},
|
|
1565
1577
|
});
|
|
1566
1578
|
}
|
|
@@ -10,6 +10,8 @@ import { showToast } from './utils.js';
|
|
|
10
10
|
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
11
11
|
import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar } from './settings-defaults.js';
|
|
12
12
|
import { store } from './store.js';
|
|
13
|
+
import { approveToolsCardHtml, bindApproveToolsToggle } from './approve-tools-toggle.js';
|
|
14
|
+
import { loopHooksWarningHtml } from './loop-hooks-warning.js';
|
|
13
15
|
import { initSchedulerConfig, setupCreateModal, openCreateModal, openCreateModalWithRecord, closeCreateModal, removePreview, getPreviewEl, showPreviewOnCell, showPreviewOnSlot, showPreviewForCreate, applyDraggedTask, parseCronSimple } from './scheduler-config.js';
|
|
14
16
|
import { initSchedulerHistory, renderHistory, _lastFiles as lastLoopFiles } from './scheduler-history.js';
|
|
15
17
|
import { positionPopover } from './popover-position.js';
|
|
@@ -792,6 +794,8 @@ function renderModelTab(bodyEl, rec) {
|
|
|
792
794
|
'<input id="ls-thinking-budget" type="number" class="settings-budget-input" min="1024" max="128000" step="1024" value="10000">' +
|
|
793
795
|
'</div>' +
|
|
794
796
|
'</div></div>' +
|
|
797
|
+
approveToolsCardHtml("ls") +
|
|
798
|
+
loopHooksWarningHtml(settings) +
|
|
795
799
|
'</div>';
|
|
796
800
|
|
|
797
801
|
function saveLoopSetting(key, value) {
|
|
@@ -833,6 +837,10 @@ function renderModelTab(bodyEl, rec) {
|
|
|
833
837
|
renderModeList("ls", opts);
|
|
834
838
|
renderEffortBar("ls", opts);
|
|
835
839
|
renderThinkingBar("ls", opts);
|
|
840
|
+
// The choice lives on the loop's record, not in LOOP.json.
|
|
841
|
+
bindApproveToolsToggle("ls", rec.approveToolsAutomatically, function (approve) {
|
|
842
|
+
send({ type: "loop_registry_update", id: rec.id, data: { approveToolsAutomatically: approve } });
|
|
843
|
+
});
|
|
836
844
|
}
|
|
837
845
|
|
|
838
846
|
// --- Chat reparenting ---
|
|
@@ -6,6 +6,8 @@ import { parseEnvString, looksLikeEnv } from './project-settings.js';
|
|
|
6
6
|
import { checkAdminAccess, loadAdminSection } from './admin.js';
|
|
7
7
|
import { closeFileViewer } from './filebrowser.js';
|
|
8
8
|
import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard, isSonnetModel } from './settings-defaults.js';
|
|
9
|
+
import { capabilitiesFor, defaultVendorId } from './vendor-registry.js';
|
|
10
|
+
import { renderPermissionSettings } from './permission-settings.js';
|
|
9
11
|
import { initCustomIconsSettings, initCustomIconsUpload, loadCustomIcons } from './custom-icons-settings.js';
|
|
10
12
|
import { formatBytes } from './app-panels.js';
|
|
11
13
|
import { registerHandlers } from './app-messages.js';
|
|
@@ -595,7 +597,6 @@ function populateSettings() {
|
|
|
595
597
|
var versionEl = document.getElementById("settings-server-version");
|
|
596
598
|
var slugEl = document.getElementById("settings-project-slug");
|
|
597
599
|
var wsPathEl = document.getElementById("settings-ws-path");
|
|
598
|
-
var skipPermsEl = document.getElementById("settings-skip-perms");
|
|
599
600
|
|
|
600
601
|
// Nav header defaults to hostname (updated by updateDaemonConfig)
|
|
601
602
|
if (nameEl && !nameEl.textContent) nameEl.textContent = "Server";
|
|
@@ -606,14 +607,6 @@ function populateSettings() {
|
|
|
606
607
|
if (slugEl) slugEl.textContent = ctx.currentSlug || "(default)";
|
|
607
608
|
if (wsPathEl) wsPathEl.textContent = ctx.wsPath || "/ws";
|
|
608
609
|
|
|
609
|
-
// Skip permissions
|
|
610
|
-
var spBanner = document.getElementById("skip-perms-pill");
|
|
611
|
-
if (skipPermsEl) {
|
|
612
|
-
var isSkip = spBanner && !spBanner.classList.contains("hidden");
|
|
613
|
-
skipPermsEl.textContent = isSkip ? "Enabled" : "Disabled";
|
|
614
|
-
skipPermsEl.classList.toggle("settings-badge-on", isSkip);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
610
|
// Sync notification toggles
|
|
618
611
|
syncNotifToggles();
|
|
619
612
|
|
|
@@ -623,6 +616,7 @@ function populateSettings() {
|
|
|
623
616
|
updateEffortBar();
|
|
624
617
|
updateThinkingBar();
|
|
625
618
|
updateSsBetaCard();
|
|
619
|
+
renderPermissionSettings(ssSendMsg);
|
|
626
620
|
}
|
|
627
621
|
|
|
628
622
|
function syncNotifToggles() {
|
|
@@ -655,6 +649,8 @@ function ssDefaultsOpts() {
|
|
|
655
649
|
currentThinking: ctx.currentThinking || "adaptive",
|
|
656
650
|
currentThinkingBudget: ctx.currentThinkingBudget || 10000,
|
|
657
651
|
currentBetas: ctx.currentBetas || [],
|
|
652
|
+
capabilities: capabilitiesFor(defaultVendorId()),
|
|
653
|
+
applyToRunning: true,
|
|
658
654
|
sendMsg: ssSendMsg,
|
|
659
655
|
// lr-db0437: was "set_model" — the session-scoped message type, wrong for
|
|
660
656
|
// a server DEFAULT picker. Every sibling control on this same panel
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { refreshIcons } from './icons.js';
|
|
5
5
|
import { isSonnetModel } from './model-families.js';
|
|
6
|
+
import { capabilityModeOptions } from './mode-options.js';
|
|
6
7
|
|
|
7
8
|
export var MODE_OPTIONS = [
|
|
8
9
|
{ value: "default", label: "Default", desc: "Claude asks for permission before running tools and editing files." },
|
|
@@ -230,7 +231,13 @@ export function renderModelList(prefix, opts) {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
/**
|
|
233
|
-
* Render mode list into `${prefix}-mode-list
|
|
234
|
+
* Render mode list into `${prefix}-mode-list`.
|
|
235
|
+
*
|
|
236
|
+
* opts.capabilities (an agent's capabilities) adds Don't ask and Auto when that
|
|
237
|
+
* agent declares them; without it the list is the three base modes. A picker
|
|
238
|
+
* for a default also names `${prefix}-mode-apply` (opts.applyToRunning): the
|
|
239
|
+
* "Apply to running sessions" choice, sent with the pick and then cleared, so
|
|
240
|
+
* it is off again for the next change.
|
|
234
241
|
*/
|
|
235
242
|
export function renderModeList(prefix, opts) {
|
|
236
243
|
var listEl = document.getElementById(prefix + "-mode-list");
|
|
@@ -238,8 +245,9 @@ export function renderModeList(prefix, opts) {
|
|
|
238
245
|
|
|
239
246
|
var currentMode = opts.currentMode || "default";
|
|
240
247
|
listEl.innerHTML = "";
|
|
248
|
+
var modes = MODE_OPTIONS.concat(capabilityModeOptions(opts.capabilities));
|
|
241
249
|
|
|
242
|
-
for (var i = 0; i <
|
|
250
|
+
for (var i = 0; i < modes.length; i++) {
|
|
243
251
|
(function (opt) {
|
|
244
252
|
var item = document.createElement("div");
|
|
245
253
|
item.className = "settings-model-item" + (opt.value === currentMode ? " active" : "");
|
|
@@ -255,14 +263,20 @@ export function renderModeList(prefix, opts) {
|
|
|
255
263
|
item.appendChild(descSpan);
|
|
256
264
|
|
|
257
265
|
item.addEventListener("click", function () {
|
|
258
|
-
|
|
266
|
+
var data = { mode: opt.value };
|
|
267
|
+
var applyEl = opts.applyToRunning ? document.getElementById(prefix + "-mode-apply") : null;
|
|
268
|
+
if (applyEl && applyEl.checked) {
|
|
269
|
+
data.applyToRunning = true;
|
|
270
|
+
applyEl.checked = false;
|
|
271
|
+
}
|
|
272
|
+
opts.sendMsg(opts.modeMsgType, data);
|
|
259
273
|
var items = listEl.querySelectorAll(".settings-model-item");
|
|
260
274
|
for (var j = 0; j < items.length; j++) items[j].classList.remove("active");
|
|
261
275
|
item.classList.add("active");
|
|
262
276
|
});
|
|
263
277
|
|
|
264
278
|
listEl.appendChild(item);
|
|
265
|
-
})(
|
|
279
|
+
})(modes[i]);
|
|
266
280
|
}
|
|
267
281
|
}
|
|
268
282
|
|
package/lib/runtime-env.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
var crypto = require("crypto");
|
|
23
23
|
var protectedKeys = require("./runtime-env-keys");
|
|
24
|
+
var senderRef = require("./sender-ref");
|
|
24
25
|
|
|
25
26
|
var KEY_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
26
27
|
var SHELL_META_RE = /[`$\\;|&><(){}\n]/;
|
|
@@ -185,6 +186,9 @@ function composeRuntimeEnv(base, overlay, opts) {
|
|
|
185
186
|
}
|
|
186
187
|
env[name] = overlay[name];
|
|
187
188
|
}
|
|
189
|
+
// The session reference is the console's alone to set, per session; a value
|
|
190
|
+
// inherited from the daemon's own environment would name some other session.
|
|
191
|
+
senderRef.strip(env);
|
|
188
192
|
return env;
|
|
189
193
|
}
|
|
190
194
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// ipc.js - the daemon side of `clagentic-console schedule-input`: which fields
|
|
2
|
+
// of an IPC message reach the scheduled-input service, and what each verb
|
|
3
|
+
// answers. The CLI is the same primitive the clock button uses; both go through
|
|
4
|
+
// the one service, so a record made by either shows in the other's list.
|
|
5
|
+
//
|
|
6
|
+
// schedule_input_create { projectSlug, sessionId, prompt, at | every + until | count,
|
|
7
|
+
// senderProject?, senderSessionId? }
|
|
8
|
+
// schedule_input_list { projectSlug?, sessionId?, state? }
|
|
9
|
+
// schedule_input_delete { id, projectSlug? }
|
|
10
|
+
//
|
|
11
|
+
// Times arrive as absolute milliseconds: the CLI resolves "in 10m" and a local
|
|
12
|
+
// "20:01" in the caller's own time zone.
|
|
13
|
+
|
|
14
|
+
var senderRef = require("../sender-ref");
|
|
15
|
+
var { isMs } = require("./records");
|
|
16
|
+
|
|
17
|
+
function refused(reason) {
|
|
18
|
+
return { ok: false, result: "refused", reason: reason };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// What the record says made it: the calling console session ("<agent>@<project>"),
|
|
22
|
+
// as send-input records its sender, else the plain CLI.
|
|
23
|
+
function createdByFor(getProject, msg) {
|
|
24
|
+
var extracted = senderRef.resolve(getProject, { project: msg.senderProject, sessionId: msg.senderSessionId });
|
|
25
|
+
return extracted ? extracted.name : "cli";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function create(deps, msg) {
|
|
29
|
+
if (typeof msg.projectSlug !== "string" || !msg.projectSlug) return Promise.resolve(refused("a project is required"));
|
|
30
|
+
if (typeof msg.prompt !== "string" || !msg.prompt) return Promise.resolve(refused("prompt must be a non-empty string"));
|
|
31
|
+
var recurring = msg.every !== undefined;
|
|
32
|
+
if (recurring ? !isMs(msg.every) : !isMs(msg.at)) {
|
|
33
|
+
return Promise.resolve(refused(recurring ? "every must be a duration" : "a once input needs the time to send at"));
|
|
34
|
+
}
|
|
35
|
+
return deps.service.resolveTarget(msg.projectSlug, msg.sessionId).then(function (resolved) {
|
|
36
|
+
if (!resolved.ok) return resolved;
|
|
37
|
+
var out = deps.service.create(msg.projectSlug, {
|
|
38
|
+
target: resolved.target,
|
|
39
|
+
session: resolved.session || undefined,
|
|
40
|
+
kind: recurring ? "recurring" : "once",
|
|
41
|
+
text: msg.prompt,
|
|
42
|
+
note: recurring ? "scheduled repeat" : "scheduled message",
|
|
43
|
+
createdBy: createdByFor(deps.getProject, msg),
|
|
44
|
+
at: recurring ? undefined : msg.at,
|
|
45
|
+
every: recurring ? msg.every : undefined,
|
|
46
|
+
until: recurring && msg.until !== undefined ? msg.until : undefined,
|
|
47
|
+
count: recurring && msg.count !== undefined ? msg.count : undefined,
|
|
48
|
+
});
|
|
49
|
+
if (out.ok) out.project = msg.projectSlug;
|
|
50
|
+
return out;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function list(deps, msg) {
|
|
55
|
+
var slugs = typeof msg.projectSlug === "string" && msg.projectSlug ? [msg.projectSlug] : deps.service.projectSlugs();
|
|
56
|
+
var inputs = [];
|
|
57
|
+
// Projects whose list cannot be saved (nothing of theirs is delivered).
|
|
58
|
+
var storeErrors = [];
|
|
59
|
+
for (var i = 0; i < slugs.length; i++) {
|
|
60
|
+
var part = deps.service.list(slugs[i], { sessionId: msg.sessionId, state: msg.state });
|
|
61
|
+
if (!part.ok) return part;
|
|
62
|
+
part.inputs.forEach(function (r) { inputs.push(Object.assign({ project: slugs[i] }, r)); });
|
|
63
|
+
if (part.store) storeErrors.push(Object.assign({ project: slugs[i] }, part.store));
|
|
64
|
+
}
|
|
65
|
+
inputs.sort(function (a, b) { return (a.nextAt === null ? Infinity : a.nextAt) - (b.nextAt === null ? Infinity : b.nextAt); });
|
|
66
|
+
var listed = { ok: true, result: "listed", count: inputs.length, inputs: inputs };
|
|
67
|
+
if (storeErrors.length) listed.storeErrors = storeErrors;
|
|
68
|
+
return listed;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function remove(deps, msg) {
|
|
72
|
+
if (typeof msg.id !== "string" || !msg.id) return refused("an id is required");
|
|
73
|
+
var slugs = typeof msg.projectSlug === "string" && msg.projectSlug ? [msg.projectSlug] : deps.service.projectSlugs();
|
|
74
|
+
var last = { ok: false, result: "not-found", reason: "no scheduled input " + JSON.stringify(msg.id.slice(0, 64)) };
|
|
75
|
+
for (var i = 0; i < slugs.length; i++) {
|
|
76
|
+
var out = deps.service.remove(slugs[i], msg.id);
|
|
77
|
+
if (out.ok) { out.project = slugs[i]; return out; }
|
|
78
|
+
if (out.result !== "not-found") last = out;
|
|
79
|
+
}
|
|
80
|
+
return last;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// deps: { service, getProject(slug) }
|
|
84
|
+
// Returns the result, or a Promise of it; undefined when msg.cmd is not ours.
|
|
85
|
+
function handleScheduledInputCommand(deps, msg) {
|
|
86
|
+
if (msg.cmd === "schedule_input_create") return create(deps, msg);
|
|
87
|
+
if (msg.cmd === "schedule_input_list") return list(deps, msg);
|
|
88
|
+
if (msg.cmd === "schedule_input_delete") return remove(deps, msg);
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = { handleScheduledInputCommand: handleScheduledInputCommand };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// rate-limit-resume.js - the one scheduled input the console arms by itself: an
|
|
2
|
+
// automatic "continue" for a session that hit a rate limit.
|
|
3
|
+
//
|
|
4
|
+
// It is an ordinary once record with its own note. The one thing that is its
|
|
5
|
+
// own is its timing, which lives here and nowhere else, so a person's "in 10
|
|
6
|
+
// min" fires at 10 minutes.
|
|
7
|
+
|
|
8
|
+
// What the chat says an automatic "continue" after a rate limit is.
|
|
9
|
+
var RATE_LIMIT_RESUME_NOTE = "automatic resume after rate limit";
|
|
10
|
+
|
|
11
|
+
var RESUME_TEXT = "continue";
|
|
12
|
+
// After the limit resets, the vendor needs a moment before it accepts a turn.
|
|
13
|
+
var RESET_BUFFER_MS = 60 * 1000;
|
|
14
|
+
// With extra usage available (or a reset already past) there is nothing to wait
|
|
15
|
+
// for except the rejected query finishing.
|
|
16
|
+
var IMMEDIATE_DELAY_MS = 5 * 1000;
|
|
17
|
+
|
|
18
|
+
// When to send the resume for a limit that resets at `resetsAt` (ms).
|
|
19
|
+
function resumeAt(resetsAt, now) {
|
|
20
|
+
if (!resetsAt || resetsAt <= now) return now + IMMEDIATE_DELAY_MS;
|
|
21
|
+
return resetsAt + RESET_BUFFER_MS;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// The two calls the SDK bridge makes for a project: arm the resume for a
|
|
25
|
+
// session, and ask whether one is already armed (its guard). A project with no
|
|
26
|
+
// scheduled-input service arms nothing.
|
|
27
|
+
// deps: { service, slug, now? }
|
|
28
|
+
function createRateLimitResume(deps) {
|
|
29
|
+
var now = deps.now || Date.now;
|
|
30
|
+
return {
|
|
31
|
+
schedule: function (session, resetsAt) {
|
|
32
|
+
if (!deps.service || !session || session.destroying) return;
|
|
33
|
+
var armed = deps.service.armResume(deps.slug, session, {
|
|
34
|
+
at: resumeAt(resetsAt, now()),
|
|
35
|
+
text: RESUME_TEXT,
|
|
36
|
+
note: RATE_LIMIT_RESUME_NOTE,
|
|
37
|
+
});
|
|
38
|
+
if (armed && !armed.ok) console.error("[rate-limit-resume] could not arm the resume for session " + session.localId + ": " + armed.reason);
|
|
39
|
+
},
|
|
40
|
+
has: function (session) {
|
|
41
|
+
return !!deps.service && deps.service.hasArmedResume(deps.slug, session);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
createRateLimitResume: createRateLimitResume,
|
|
48
|
+
RATE_LIMIT_RESUME_NOTE: RATE_LIMIT_RESUME_NOTE,
|
|
49
|
+
RESUME_TEXT: RESUME_TEXT,
|
|
50
|
+
RESET_BUFFER_MS: RESET_BUFFER_MS,
|
|
51
|
+
IMMEDIATE_DELAY_MS: IMMEDIATE_DELAY_MS,
|
|
52
|
+
resumeAt: resumeAt,
|
|
53
|
+
};
|