@clagentic/console 1.11.0 → 1.12.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 +1 -0
- package/bin/cli.js +14 -2
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +31 -7
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/duration.js +27 -0
- package/lib/cli/ipc-subcommands.js +26 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +38 -7
- package/lib/daemon.js +26 -0
- package/lib/notification-prefs.js +257 -0
- package/lib/notify/core.js +175 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +63 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +64 -0
- package/lib/notify/types.js +20 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +74 -0
- package/lib/outbound-entry.js +109 -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 +40 -1
- package/lib/project-filesystem.js +20 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +25 -13
- package/lib/project-notifications.js +206 -42
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +30 -1
- package/lib/project.js +15 -1
- package/lib/prompt-registry.js +92 -24
- package/lib/prompt-reminders.js +282 -0
- package/lib/prompt-source.js +43 -8
- package/lib/public/app.js +1 -0
- package/lib/public/css/diagnostics.css +28 -0
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +93 -0
- package/lib/public/css/menus.css +22 -0
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/server-settings.css +24 -0
- package/lib/public/css/sidebar.css +24 -0
- package/lib/public/index.html +6 -0
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/app-connection.js +22 -5
- package/lib/public/modules/app-header.js +2 -0
- package/lib/public/modules/app-messages.js +6 -2
- package/lib/public/modules/app-notifications.js +65 -40
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +12 -6
- package/lib/public/modules/app-rendering.js +26 -3
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +77 -0
- package/lib/public/modules/diagnostics.js +9 -2
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/keep-alive.js +66 -0
- package/lib/public/modules/notification-prefs.js +151 -0
- package/lib/public/modules/notify-client.js +153 -0
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-reminders-setting.js +13 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/server-settings.js +3 -0
- package/lib/public/modules/sidebar-mobile.js +8 -0
- package/lib/public/modules/sidebar-sessions.js +27 -0
- package/lib/public/modules/terminal-links.js +175 -0
- package/lib/public/modules/terminal.js +19 -103
- package/lib/public/notify-sw-logic.js +300 -0
- package/lib/public/notify-target.js +97 -0
- package/lib/public/sw.js +15 -62
- package/lib/push-audience.js +84 -0
- package/lib/push.js +87 -20
- package/lib/runtime-env.js +1 -0
- package/lib/sdk-bridge.js +83 -36
- package/lib/sdk-message-processor.js +148 -49
- package/lib/sender-ref.js +3 -0
- package/lib/server.js +80 -4
- package/lib/session-directory.js +6 -4
- package/lib/session-input-ipc.js +11 -1
- package/lib/session-input.js +95 -14
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/sessions.js +58 -4
- package/lib/usage-store.js +403 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +13 -2
- package/lib/yoke/adapters/claude-vendor.js +11 -1
- package/lib/yoke/adapters/claude.js +17 -0
- package/lib/yoke/adapters/codex.js +5 -1
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +8 -1
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// notification-prefs.js - the user's per-type notification preferences.
|
|
2
|
+
//
|
|
3
|
+
// The preferences live on the server, with the user's account, so the phone and
|
|
4
|
+
// the desktop agree and push is filtered where it is sent. This module holds the
|
|
5
|
+
// last copy the server sent, answers "may this type alert / sound here?" and
|
|
6
|
+
// draws the settings card (a preset picker and a surface-by-type grid).
|
|
7
|
+
//
|
|
8
|
+
// Muting a type never hides it: the notification still lands in the panel and
|
|
9
|
+
// on the session's prompt card; only the banner, the sound and the push are
|
|
10
|
+
// suppressed.
|
|
11
|
+
|
|
12
|
+
import { getWs } from './ws-ref.js';
|
|
13
|
+
|
|
14
|
+
var LEGACY_MIGRATED_KEY = "notif-prefs-migrated";
|
|
15
|
+
var SURFACE_LABELS = { banner: "Banner", sound: "Sound", push: "Push" };
|
|
16
|
+
var SURFACE_ORDER = ["banner", "sound", "push"];
|
|
17
|
+
|
|
18
|
+
var current = null;
|
|
19
|
+
|
|
20
|
+
/** True once the server has sent the user's preferences. */
|
|
21
|
+
export function hasNotificationPrefs() {
|
|
22
|
+
return current !== null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether a surface should alert for a category. Before the server has
|
|
27
|
+
* answered, and for a notification with no category, everything is wanted
|
|
28
|
+
* (today's behaviour).
|
|
29
|
+
*/
|
|
30
|
+
export function isSurfaceWanted(surface, category) {
|
|
31
|
+
if (!current || !category) return true;
|
|
32
|
+
var row = current.prefs && current.prefs[surface];
|
|
33
|
+
return !row || row[category] !== false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether a notification just created should chime. The turn-done chime has
|
|
38
|
+
* only ever played while the tab is hidden, so a notification chimes under that
|
|
39
|
+
* same rule AND when the user's sound preference for its type is on. The
|
|
40
|
+
* default preferences leave sound on for a finished turn only, so by default a
|
|
41
|
+
* reminder is silent. A finished turn's own handler plays its chime itself.
|
|
42
|
+
* @param {{type: string, category: ?string}} notif
|
|
43
|
+
* @param {boolean} soundSwitchOn the browser's global sound switch
|
|
44
|
+
*/
|
|
45
|
+
export function shouldChimeForNotification(notif, soundSwitchOn) {
|
|
46
|
+
if (!notif || notif.type === "response_done") return false;
|
|
47
|
+
if (typeof document === "undefined" || !document.hidden) return false;
|
|
48
|
+
if (!soundSwitchOn) return false;
|
|
49
|
+
// No category: only the "everything wanted" fallback would say yes, which
|
|
50
|
+
// would chime for types that never did. Require a known category.
|
|
51
|
+
return !!notif.category && !!current && isSurfaceWanted("sound", notif.category);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function send(msg) {
|
|
55
|
+
var ws = getWs();
|
|
56
|
+
if (ws && ws.readyState === 1) ws.send(JSON.stringify(msg));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The browser held global switches before the preferences moved to the server.
|
|
60
|
+
// The sound switch carries over, once; the alert and push switches describe
|
|
61
|
+
// this browser's permission and subscription and stay with it.
|
|
62
|
+
function migrateLegacyOnce(msg) {
|
|
63
|
+
if (msg.known) return;
|
|
64
|
+
var already = false;
|
|
65
|
+
try { already = localStorage.getItem(LEGACY_MIGRATED_KEY) === "1"; } catch (e) { already = false; }
|
|
66
|
+
if (already) return;
|
|
67
|
+
var sound = true;
|
|
68
|
+
try { sound = localStorage.getItem("notif-sound") !== "0"; } catch (e) { sound = true; }
|
|
69
|
+
send({ type: "notification_prefs_migrate", legacy: { sound: sound } });
|
|
70
|
+
try { localStorage.setItem(LEGACY_MIGRATED_KEY, "1"); } catch (e) { /* storage unavailable: the server default stands */ }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function handleNotificationPrefs(msg) {
|
|
74
|
+
current = msg;
|
|
75
|
+
migrateLegacyOnce(msg);
|
|
76
|
+
render();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function render() {
|
|
80
|
+
var card = document.getElementById("notif-prefs-card");
|
|
81
|
+
if (!card || !current) return;
|
|
82
|
+
card.innerHTML = "";
|
|
83
|
+
|
|
84
|
+
var presetRow = document.createElement("div");
|
|
85
|
+
presetRow.className = "settings-field";
|
|
86
|
+
var presetLabel = document.createElement("label");
|
|
87
|
+
presetLabel.className = "settings-label";
|
|
88
|
+
presetLabel.setAttribute("for", "notif-prefs-preset");
|
|
89
|
+
presetLabel.textContent = "Notify me for";
|
|
90
|
+
var select = document.createElement("select");
|
|
91
|
+
select.id = "notif-prefs-preset";
|
|
92
|
+
select.className = "us-text-input";
|
|
93
|
+
(current.presets || []).forEach(function (p) {
|
|
94
|
+
var opt = document.createElement("option");
|
|
95
|
+
opt.value = p.id;
|
|
96
|
+
opt.textContent = p.label;
|
|
97
|
+
select.appendChild(opt);
|
|
98
|
+
});
|
|
99
|
+
var custom = document.createElement("option");
|
|
100
|
+
custom.value = "";
|
|
101
|
+
custom.textContent = "Custom";
|
|
102
|
+
custom.disabled = true;
|
|
103
|
+
select.appendChild(custom);
|
|
104
|
+
select.value = current.preset || "";
|
|
105
|
+
select.addEventListener("change", function () {
|
|
106
|
+
if (select.value) send({ type: "notification_prefs_set", preset: select.value });
|
|
107
|
+
});
|
|
108
|
+
presetRow.appendChild(presetLabel);
|
|
109
|
+
presetRow.appendChild(select);
|
|
110
|
+
var hint = document.createElement("div");
|
|
111
|
+
hint.className = "settings-hint";
|
|
112
|
+
hint.textContent = "A muted type still appears in the notifications panel and on the session's prompt card; only the banner, the sound and the push are suppressed.";
|
|
113
|
+
presetRow.appendChild(hint);
|
|
114
|
+
card.appendChild(presetRow);
|
|
115
|
+
|
|
116
|
+
var table = document.createElement("table");
|
|
117
|
+
table.className = "notif-prefs-grid";
|
|
118
|
+
var head = document.createElement("tr");
|
|
119
|
+
head.appendChild(document.createElement("th"));
|
|
120
|
+
SURFACE_ORDER.forEach(function (surface) {
|
|
121
|
+
var th = document.createElement("th");
|
|
122
|
+
th.textContent = SURFACE_LABELS[surface];
|
|
123
|
+
head.appendChild(th);
|
|
124
|
+
});
|
|
125
|
+
table.appendChild(head);
|
|
126
|
+
(current.categories || []).forEach(function (cat) {
|
|
127
|
+
var tr = document.createElement("tr");
|
|
128
|
+
var name = document.createElement("td");
|
|
129
|
+
name.textContent = cat.label;
|
|
130
|
+
tr.appendChild(name);
|
|
131
|
+
SURFACE_ORDER.forEach(function (surface) {
|
|
132
|
+
var td = document.createElement("td");
|
|
133
|
+
var box = document.createElement("input");
|
|
134
|
+
box.type = "checkbox";
|
|
135
|
+
box.checked = isSurfaceWanted(surface, cat.id);
|
|
136
|
+
box.setAttribute("data-surface", surface);
|
|
137
|
+
box.setAttribute("data-category", cat.id);
|
|
138
|
+
box.setAttribute("aria-label", cat.label + ": " + SURFACE_LABELS[surface]);
|
|
139
|
+
box.addEventListener("change", function () {
|
|
140
|
+
var patch = {};
|
|
141
|
+
patch[surface] = {};
|
|
142
|
+
patch[surface][cat.id] = box.checked;
|
|
143
|
+
send({ type: "notification_prefs_set", surfaces: patch });
|
|
144
|
+
});
|
|
145
|
+
td.appendChild(box);
|
|
146
|
+
tr.appendChild(td);
|
|
147
|
+
});
|
|
148
|
+
table.appendChild(tr);
|
|
149
|
+
});
|
|
150
|
+
card.appendChild(table);
|
|
151
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// The page side of notification routing: the one router a tap, a deep link and
|
|
2
|
+
// the service worker's route message all use, plus the reconcile that closes a
|
|
3
|
+
// shown notification whose prompt has ended.
|
|
4
|
+
import '../notify-target.js';
|
|
5
|
+
import '../notify-sw-logic.js';
|
|
6
|
+
import { store } from './store.js';
|
|
7
|
+
import { getWs } from './ws-ref.js';
|
|
8
|
+
import { switchProject } from './app-projects.js';
|
|
9
|
+
|
|
10
|
+
var Target = globalThis.NotifyTarget;
|
|
11
|
+
var PENDING_KEY = 'pending-notif-session';
|
|
12
|
+
|
|
13
|
+
export var urlForTarget = Target.urlForTarget;
|
|
14
|
+
|
|
15
|
+
var lastState = null;
|
|
16
|
+
var lastLivePrompts = null;
|
|
17
|
+
|
|
18
|
+
// The session a route is waiting to open once the connection is up. Held in
|
|
19
|
+
// memory as well as in sessionStorage: sessionStorage can be unavailable
|
|
20
|
+
// (private mode, quota), and the target must not depend on it.
|
|
21
|
+
var pendingSession = null;
|
|
22
|
+
// True while the deep link's query is still on the URL as the only durable
|
|
23
|
+
// copy of the target (sessionStorage refused it).
|
|
24
|
+
var queryHoldsTarget = false;
|
|
25
|
+
|
|
26
|
+
// Returns whether sessionStorage took the target. The in-memory copy is always
|
|
27
|
+
// kept, so a caller that sees false still has the route.
|
|
28
|
+
function rememberPendingSession(id) {
|
|
29
|
+
pendingSession = String(id);
|
|
30
|
+
try {
|
|
31
|
+
sessionStorage.setItem(PENDING_KEY, pendingSession);
|
|
32
|
+
return true;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.debug('[notify] could not store the pending session:', e && e.message ? e.message : e);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readStoredSession() {
|
|
40
|
+
try {
|
|
41
|
+
return sessionStorage.getItem(PENDING_KEY);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.debug('[notify] could not read the pending session:', e && e.message ? e.message : e);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function clearStoredSession() {
|
|
49
|
+
try {
|
|
50
|
+
sessionStorage.removeItem(PENDING_KEY);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.debug('[notify] could not clear the pending session:', e && e.message ? e.message : e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function stripDeepLinkQuery() {
|
|
57
|
+
var params = new URLSearchParams(location.search);
|
|
58
|
+
params.delete('session');
|
|
59
|
+
params.delete('request');
|
|
60
|
+
var rest = params.toString();
|
|
61
|
+
history.replaceState(null, '', location.pathname + (rest ? '?' + rest : '') + location.hash);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The session a route is waiting to open, or null. Call it only once the
|
|
66
|
+
* connection can carry the switch: taking it ends the wait, and with it the
|
|
67
|
+
* deep link's query if that was the target's only copy.
|
|
68
|
+
* @returns {?number}
|
|
69
|
+
*/
|
|
70
|
+
export function takePendingSession() {
|
|
71
|
+
var raw = pendingSession !== null ? pendingSession : readStoredSession();
|
|
72
|
+
pendingSession = null;
|
|
73
|
+
clearStoredSession();
|
|
74
|
+
if (queryHoldsTarget) {
|
|
75
|
+
queryHoldsTarget = false;
|
|
76
|
+
stripDeepLinkQuery();
|
|
77
|
+
}
|
|
78
|
+
return raw === null ? null : parseId(raw);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseId(id) {
|
|
82
|
+
var n = parseInt(id, 10);
|
|
83
|
+
return isNaN(n) ? null : n;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Opens the target's project and session in this page. A different project is
|
|
87
|
+
// switched to first, and the session is picked up by handleNotificationsState
|
|
88
|
+
// through the pending key once that project's connection is up; the same
|
|
89
|
+
// project switches at once when its connection is open, else the same key
|
|
90
|
+
// carries it.
|
|
91
|
+
export function routeTo(target) {
|
|
92
|
+
var t = Target.makeTarget(target);
|
|
93
|
+
if (!t) return;
|
|
94
|
+
var current = store.get('currentSlug') || '';
|
|
95
|
+
var sessionId = parseId(t.sessionId);
|
|
96
|
+
if (t.slug && t.slug !== current) {
|
|
97
|
+
if (sessionId !== null) rememberPendingSession(sessionId);
|
|
98
|
+
switchProject(t.slug);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (sessionId === null) return;
|
|
102
|
+
var ws = getWs();
|
|
103
|
+
if (ws && ws.readyState === 1) {
|
|
104
|
+
ws.send(JSON.stringify({ type: 'switch_session', id: sessionId }));
|
|
105
|
+
} else {
|
|
106
|
+
rememberPendingSession(sessionId);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// The page was opened on a deep link (/p/<slug>/?session=<id>): route to the
|
|
111
|
+
// session once connected, then drop the query so a reload does not repeat it.
|
|
112
|
+
// When sessionStorage refused the target, the query stays until the route has
|
|
113
|
+
// been taken, so a reload still finds it.
|
|
114
|
+
function consumeDeepLink() {
|
|
115
|
+
var link = Target.parseDeepLink(location.search);
|
|
116
|
+
if (!link) return;
|
|
117
|
+
if (rememberPendingSession(link.sessionId)) stripDeepLinkQuery();
|
|
118
|
+
else queryHoldsTarget = true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Scoped to this page's own project: the live-prompt record names it, else
|
|
122
|
+
// the project the page is on.
|
|
123
|
+
function reconcile() {
|
|
124
|
+
if (lastState === null || document.visibilityState !== 'visible') return;
|
|
125
|
+
if (!navigator.serviceWorker || !globalThis.NotifySw) return;
|
|
126
|
+
var scope = {
|
|
127
|
+
slug: (lastLivePrompts && lastLivePrompts.slug) || store.get('currentSlug') || '',
|
|
128
|
+
livePrompts: lastLivePrompts,
|
|
129
|
+
};
|
|
130
|
+
navigator.serviceWorker.ready.then(function (reg) {
|
|
131
|
+
return globalThis.NotifySw.reconcileShown(reg, lastState, scope);
|
|
132
|
+
}).catch(function (e) {
|
|
133
|
+
console.debug('[notify] reconcile failed:', e && e.message ? e.message : e);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Called with each notifications_state; reconciling waits for the first one so
|
|
138
|
+
// an empty list at boot never reads as "nothing is live".
|
|
139
|
+
export function noteNotificationsState(list, livePrompts) {
|
|
140
|
+
lastState = Array.isArray(list) ? list : [];
|
|
141
|
+
lastLivePrompts = livePrompts || null;
|
|
142
|
+
reconcile();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function initNotifyClient() {
|
|
146
|
+
consumeDeepLink();
|
|
147
|
+
if (navigator.serviceWorker) {
|
|
148
|
+
navigator.serviceWorker.addEventListener('message', function (event) {
|
|
149
|
+
if (event.data && event.data.type === 'notify_route') routeTo(event.data.target);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
document.addEventListener('visibilitychange', reconcile);
|
|
153
|
+
}
|
|
@@ -8,6 +8,7 @@ import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
|
8
8
|
import { closeFileViewer } from './filebrowser.js';
|
|
9
9
|
import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard } from './settings-defaults.js';
|
|
10
10
|
import { capabilitiesFor, defaultVendorId } from './vendor-registry.js';
|
|
11
|
+
import { renderShadowNotice } from './env-shadow-notice.js';
|
|
11
12
|
|
|
12
13
|
var ctx = null;
|
|
13
14
|
var panelEl = null;
|
|
@@ -689,6 +690,7 @@ function loadEnvironment() {
|
|
|
689
690
|
export function handleProjectEnv(msg) {
|
|
690
691
|
var notice = document.getElementById("ps-env-override-notice");
|
|
691
692
|
if (notice) notice.classList.toggle("hidden", !msg.hasEnvrc);
|
|
693
|
+
renderShadowNotice("ps-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
692
694
|
|
|
693
695
|
// Say whom these variables reach: in multi-user mode only the project owner's
|
|
694
696
|
// sessions get them, so no one else's runtime can be changed from here.
|
|
@@ -858,6 +860,7 @@ function autoSaveEnv() {
|
|
|
858
860
|
}
|
|
859
861
|
|
|
860
862
|
export function handleProjectEnvSaved(msg) {
|
|
863
|
+
if (msg.ok) renderShadowNotice("ps-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
861
864
|
var saveStatus = document.getElementById("ps-env-save-status");
|
|
862
865
|
if (!saveStatus) return;
|
|
863
866
|
if (msg.ok) {
|
|
@@ -881,6 +884,7 @@ function loadSharedEnv() {
|
|
|
881
884
|
}
|
|
882
885
|
|
|
883
886
|
export function handleProjectSharedEnv(msg) {
|
|
887
|
+
renderShadowNotice("ps-shared-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
884
888
|
var list = document.getElementById("ps-shared-env-list");
|
|
885
889
|
if (!list) return;
|
|
886
890
|
list.innerHTML = "";
|
|
@@ -893,6 +897,7 @@ export function handleProjectSharedEnv(msg) {
|
|
|
893
897
|
}
|
|
894
898
|
|
|
895
899
|
export function handleProjectSharedEnvSaved(msg) {
|
|
900
|
+
if (msg.ok) renderShadowNotice("ps-shared-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
896
901
|
var saveStatus = document.getElementById("ps-shared-env-save-status");
|
|
897
902
|
if (!saveStatus) return;
|
|
898
903
|
if (msg.ok) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// prompt-reminders-setting.js - the per-session switch for reminders about
|
|
2
|
+
// unanswered prompts (the server side is lib/prompt-reminders.js).
|
|
3
|
+
|
|
4
|
+
import { store } from './store.js';
|
|
5
|
+
import { getWs } from './ws-ref.js';
|
|
6
|
+
|
|
7
|
+
/** Asks the server to turn a session's prompt reminders on or off. */
|
|
8
|
+
export function sendSessionPromptReminders(sessionId, enabled) {
|
|
9
|
+
var ws = getWs();
|
|
10
|
+
if (ws && store.get('connected')) {
|
|
11
|
+
ws.send(JSON.stringify({ type: "set_session_prompt_reminders", sessionId: sessionId, enabled: !!enabled }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -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);
|
|
@@ -10,6 +10,7 @@ import { capabilitiesFor, defaultVendorId } from './vendor-registry.js';
|
|
|
10
10
|
import { renderPermissionSettings } from './permission-settings.js';
|
|
11
11
|
import { initCustomIconsSettings, initCustomIconsUpload, loadCustomIcons } from './custom-icons-settings.js';
|
|
12
12
|
import { formatBytes } from './app-panels.js';
|
|
13
|
+
import { renderShadowNotice } from './env-shadow-notice.js';
|
|
13
14
|
import { registerHandlers } from './app-messages.js';
|
|
14
15
|
|
|
15
16
|
var ctx = null;
|
|
@@ -1225,6 +1226,7 @@ function loadSharedEnv() {
|
|
|
1225
1226
|
}
|
|
1226
1227
|
|
|
1227
1228
|
export function handleSharedEnv(msg) {
|
|
1229
|
+
renderShadowNotice("ss-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
1228
1230
|
var list = document.getElementById("ss-env-list");
|
|
1229
1231
|
if (!list) return;
|
|
1230
1232
|
list.innerHTML = "";
|
|
@@ -1237,6 +1239,7 @@ export function handleSharedEnv(msg) {
|
|
|
1237
1239
|
}
|
|
1238
1240
|
|
|
1239
1241
|
export function handleSharedEnvSaved(msg) {
|
|
1242
|
+
if (msg.ok) renderShadowNotice("ss-env-shadow-notice", msg.shadowedKeys, msg.shadowConfigDirNote);
|
|
1240
1243
|
var saveStatus = document.getElementById("ss-env-save-status");
|
|
1241
1244
|
if (!saveStatus) return;
|
|
1242
1245
|
if (msg.ok) {
|
|
@@ -499,6 +499,14 @@ function createMobileSessionItem(s) {
|
|
|
499
499
|
el.appendChild(agentBadge);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
+
if (s.keepAlive) {
|
|
503
|
+
var pinBadge = document.createElement("span");
|
|
504
|
+
pinBadge.className = "session-keepalive-badge";
|
|
505
|
+
pinBadge.title = "Kept alive: not ended when idle";
|
|
506
|
+
pinBadge.innerHTML = iconHtml("pin");
|
|
507
|
+
el.appendChild(pinBadge);
|
|
508
|
+
}
|
|
509
|
+
|
|
502
510
|
var titleSpan = document.createElement("span");
|
|
503
511
|
titleSpan.className = "mobile-session-title";
|
|
504
512
|
titleSpan.appendChild(document.createTextNode(s.title || "New Session"));
|
|
@@ -10,6 +10,8 @@ import { capabilityGate } from './vendor-registry.js';
|
|
|
10
10
|
import { getWs } from './ws-ref.js';
|
|
11
11
|
import { openSessionGrants } from './session-grants.js';
|
|
12
12
|
import { getSessionListEl } from './dom-refs.js';
|
|
13
|
+
import { keepAliveBadgeHtml, sendSessionKeepAlive } from './keep-alive.js';
|
|
14
|
+
import { sendSessionPromptReminders } from './prompt-reminders-setting.js';
|
|
13
15
|
import { dismissOverlayPanels, closeSidebar, updatePageTitle, spawnDustParticles } from './sidebar.js';
|
|
14
16
|
import { showConfirm } from './app-misc.js';
|
|
15
17
|
import { getUpcomingSchedules } from './scheduler.js';
|
|
@@ -668,6 +670,28 @@ function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
|
|
|
668
670
|
});
|
|
669
671
|
menu.appendChild(bookmarkItem);
|
|
670
672
|
|
|
673
|
+
var keepAliveItem = document.createElement("button");
|
|
674
|
+
keepAliveItem.className = "session-ctx-item";
|
|
675
|
+
var keepAliveOn = !!(sessionData && sessionData.keepAlive);
|
|
676
|
+
keepAliveItem.innerHTML = iconHtml("pin") + " <span>" + (keepAliveOn ? "Allow idle ending" : "Keep alive when idle") + "</span>";
|
|
677
|
+
keepAliveItem.addEventListener("click", function (e) {
|
|
678
|
+
e.stopPropagation();
|
|
679
|
+
closeSessionCtxMenu();
|
|
680
|
+
sendSessionKeepAlive(sessionId, !keepAliveOn);
|
|
681
|
+
});
|
|
682
|
+
menu.appendChild(keepAliveItem);
|
|
683
|
+
|
|
684
|
+
var remindersItem = document.createElement("button");
|
|
685
|
+
remindersItem.className = "session-ctx-item";
|
|
686
|
+
var remindersOff = !!(sessionData && sessionData.promptRemindersOff);
|
|
687
|
+
remindersItem.innerHTML = iconHtml("bell") + " <span>" + (remindersOff ? "Remind me of waiting prompts" : "Stop reminders for waiting prompts") + "</span>";
|
|
688
|
+
remindersItem.addEventListener("click", function (e) {
|
|
689
|
+
e.stopPropagation();
|
|
690
|
+
closeSessionCtxMenu();
|
|
691
|
+
sendSessionPromptReminders(sessionId, remindersOff);
|
|
692
|
+
});
|
|
693
|
+
menu.appendChild(remindersItem);
|
|
694
|
+
|
|
671
695
|
var renameItem = document.createElement("button");
|
|
672
696
|
renameItem.className = "session-ctx-item";
|
|
673
697
|
renameItem.innerHTML = iconHtml("pencil") + " <span>Rename</span>";
|
|
@@ -1282,6 +1306,7 @@ function renderSessionItem(s) {
|
|
|
1282
1306
|
textHtml += '<span class="session-agent-badge" title="Agent: ' + escapeHtml(s.agentName) + '">'
|
|
1283
1307
|
+ iconHtml("bot") + '</span>';
|
|
1284
1308
|
}
|
|
1309
|
+
textHtml += keepAliveBadgeHtml(s);
|
|
1285
1310
|
textHtml += highlightMatch(s.title || "New Session", searchQuery);
|
|
1286
1311
|
textSpan.innerHTML = textHtml;
|
|
1287
1312
|
el.appendChild(textSpan);
|
|
@@ -1343,6 +1368,8 @@ function _fingerprintSessions(list, expanded, expandedRuns) {
|
|
|
1343
1368
|
(s.active ? "1" : "0") + "," +
|
|
1344
1369
|
indicatorClass(sessionActivity(s, myUserId)) + "," +
|
|
1345
1370
|
(s.bookmarked ? "1" : "0") + "," +
|
|
1371
|
+
(s.keepAlive ? "1" : "0") + "," +
|
|
1372
|
+
(s.promptRemindersOff ? "1" : "0") + "," +
|
|
1346
1373
|
// favoriteOrder drives sort order within the favorites section
|
|
1347
1374
|
// (compareSessionListItems) and unread drives the badge — both must be
|
|
1348
1375
|
// in the fingerprint or a bookmark reorder / unread-count change with
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Link detection for the console terminal, kept free of DOM and app imports so
|
|
2
|
+
// it can be unit-tested against a fake xterm buffer.
|
|
3
|
+
//
|
|
4
|
+
// xterm's WebLinksAddon only sees one row. This provider rebuilds "logical
|
|
5
|
+
// lines" and detects URLs that span rows in two cases:
|
|
6
|
+
// 1. soft wrap: xterm marked the continuation row isWrapped.
|
|
7
|
+
// 2. hard wrap: a program printed the URL itself across rows, so xterm did
|
|
8
|
+
// not mark isWrapped. Joined only when the row is full to the last column
|
|
9
|
+
// and ends inside a URL, and the next row is nothing but URL text: one
|
|
10
|
+
// whitespace-free token, with only padding after it.
|
|
11
|
+
//
|
|
12
|
+
// Remaining ambiguity: a real newline right after a URL that ends exactly at
|
|
13
|
+
// the last column, followed by a single-token line (for example "Done"), looks
|
|
14
|
+
// the same as a hard wrap and is joined. A following line with more than one
|
|
15
|
+
// word is never joined.
|
|
16
|
+
|
|
17
|
+
var URL_CHAR_CLASS = "[^\\s'\"\\]>)}{]";
|
|
18
|
+
var URL_RE_SOURCE = "https?:\\/\\/" + URL_CHAR_CLASS + "+";
|
|
19
|
+
var URL_AT_ROW_END_RE = new RegExp(URL_RE_SOURCE + "$");
|
|
20
|
+
var URL_CONTINUATION_RE = new RegExp("^" + URL_CHAR_CLASS + "+$");
|
|
21
|
+
|
|
22
|
+
function rowText(buffer, y, trimRight) {
|
|
23
|
+
var line = buffer.getLine(y);
|
|
24
|
+
return line ? line.translateToString(trimRight) : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A URL longer than this many rows is cut here: joining stops and the row past
|
|
28
|
+
// the bound is treated as not continued. Far above any sign-in URL, and it
|
|
29
|
+
// keeps every lookup linear in a fixed window instead of in buffer length.
|
|
30
|
+
export var MAX_LINK_ROWS = 64;
|
|
31
|
+
|
|
32
|
+
// Row y fills to the last column and row y+1 is URL text alone, not marked as
|
|
33
|
+
// a soft-wrapped row. Looks at two rows only.
|
|
34
|
+
function hardWrapCandidate(buffer, y, cols) {
|
|
35
|
+
var next = buffer.getLine(y + 1);
|
|
36
|
+
if (!next || next.isWrapped) return false;
|
|
37
|
+
var text = rowText(buffer, y, false);
|
|
38
|
+
if (text === null || text.length < cols) return false;
|
|
39
|
+
var nextText = rowText(buffer, y + 1, true);
|
|
40
|
+
return nextText !== null && URL_CONTINUATION_RE.test(nextText);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// hard[i] is true when row lo+i continues onto the next row by a hard wrap.
|
|
44
|
+
// One forward pass: a row qualifies when it ends in a URL, or when it is one
|
|
45
|
+
// full-width token continuing a hard wrap from the row above. The row before
|
|
46
|
+
// lo is assumed not to continue, which is the cut at the bound.
|
|
47
|
+
function hardWrapFlags(buffer, lo, hi, cols) {
|
|
48
|
+
var flags = [];
|
|
49
|
+
var prev = false;
|
|
50
|
+
for (var y = lo; y <= hi; y++) {
|
|
51
|
+
var flag = false;
|
|
52
|
+
if (hardWrapCandidate(buffer, y, cols)) {
|
|
53
|
+
var text = rowText(buffer, y, false);
|
|
54
|
+
var token = text.match(/\S+$/);
|
|
55
|
+
flag = !!token && (URL_AT_ROW_END_RE.test(text) || (token[0].length === cols && prev));
|
|
56
|
+
}
|
|
57
|
+
flags.push(flag);
|
|
58
|
+
prev = flag;
|
|
59
|
+
}
|
|
60
|
+
return flags;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getLogicalLine(buffer, y, cols) {
|
|
64
|
+
var lo = Math.max(0, y - MAX_LINK_ROWS);
|
|
65
|
+
var hi = Math.min(buffer.length - 1, y + MAX_LINK_ROWS);
|
|
66
|
+
var hard = hardWrapFlags(buffer, lo, hi, cols);
|
|
67
|
+
|
|
68
|
+
var startY = y;
|
|
69
|
+
while (startY > lo && y - startY < MAX_LINK_ROWS - 1) {
|
|
70
|
+
var line = buffer.getLine(startY);
|
|
71
|
+
if (!line) break;
|
|
72
|
+
if (!line.isWrapped && !hard[startY - 1 - lo]) break;
|
|
73
|
+
startY--;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var endY = startY;
|
|
77
|
+
while (endY < hi && endY - startY < MAX_LINK_ROWS - 1) {
|
|
78
|
+
var next = buffer.getLine(endY + 1);
|
|
79
|
+
if (!next || !(next.isWrapped || hard[endY - lo])) break;
|
|
80
|
+
endY++;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var text = "";
|
|
84
|
+
var rowOffsets = []; // { y, startOffset, length }
|
|
85
|
+
for (var row = startY; row <= endY; row++) {
|
|
86
|
+
var t = rowText(buffer, row, row === endY); // trim trailing spaces on the last row only
|
|
87
|
+
if (t === null) break;
|
|
88
|
+
rowOffsets.push({ y: row, startOffset: text.length, length: t.length });
|
|
89
|
+
text += t;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { text: text, startY: startY, endY: endY, rowOffsets: rowOffsets };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function offsetToBufferPos(rowOffsets, offset) {
|
|
96
|
+
for (var i = 0; i < rowOffsets.length; i++) {
|
|
97
|
+
var ro = rowOffsets[i];
|
|
98
|
+
if (offset < ro.startOffset + ro.length) {
|
|
99
|
+
return { x: offset - ro.startOffset + 1, y: ro.y + 1 }; // 1-based
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var last = rowOffsets[rowOffsets.length - 1];
|
|
103
|
+
return { x: last.length + 1, y: last.y + 1 };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Every URL in the logical line that crosses a row boundary.
|
|
107
|
+
function findMultiRowUrls(logical) {
|
|
108
|
+
var re = new RegExp(URL_RE_SOURCE, "g");
|
|
109
|
+
var found = [];
|
|
110
|
+
var match;
|
|
111
|
+
while ((match = re.exec(logical.text)) !== null) {
|
|
112
|
+
var start = offsetToBufferPos(logical.rowOffsets, match.index);
|
|
113
|
+
var end = offsetToBufferPos(logical.rowOffsets, match.index + match[0].length - 1);
|
|
114
|
+
if (start.y !== end.y) found.push({ url: match[0], start: start, end: end });
|
|
115
|
+
}
|
|
116
|
+
return found;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// opts.onHover(url) / opts.onLeave() let the owner remember the link under
|
|
120
|
+
// the pointer, for a copy-link action.
|
|
121
|
+
export function createMultiLineLinkProvider(xterm, opts) {
|
|
122
|
+
opts = opts || {};
|
|
123
|
+
return {
|
|
124
|
+
provideLinks: function (y, callback) {
|
|
125
|
+
var buffer = xterm.buffer.active;
|
|
126
|
+
var bufferY = y - 1; // provideLinks is 1-based
|
|
127
|
+
var logical = getLogicalLine(buffer, bufferY, xterm.cols);
|
|
128
|
+
|
|
129
|
+
if (logical.startY === logical.endY || bufferY !== logical.startY) {
|
|
130
|
+
callback(undefined);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var links = findMultiRowUrls(logical).map(function (hit) {
|
|
135
|
+
return {
|
|
136
|
+
range: { start: hit.start, end: hit.end },
|
|
137
|
+
text: hit.url,
|
|
138
|
+
activate: function () {
|
|
139
|
+
window.open(hit.url, "_blank", "noopener");
|
|
140
|
+
},
|
|
141
|
+
hover: function () {
|
|
142
|
+
if (opts.onHover) opts.onHover(hit.url);
|
|
143
|
+
},
|
|
144
|
+
leave: function () {
|
|
145
|
+
if (opts.onLeave) opts.onLeave();
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
callback(links.length > 0 ? links : undefined);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// getSelection() joins rows with a newline. When the whole selection sits
|
|
156
|
+
// inside one multi-row URL, return the selected part of the URL with the row
|
|
157
|
+
// breaks removed; otherwise return the selection unchanged.
|
|
158
|
+
export function copyTextForSelection(xterm, selection) {
|
|
159
|
+
if (!selection || !/[\r\n]/.test(selection)) return selection;
|
|
160
|
+
var pos = xterm.getSelectionPosition && xterm.getSelectionPosition();
|
|
161
|
+
if (!pos) return selection;
|
|
162
|
+
var buffer = xterm.buffer.active;
|
|
163
|
+
var logical = getLogicalLine(buffer, pos.start.y, xterm.cols);
|
|
164
|
+
if (logical.endY < pos.end.y) return selection;
|
|
165
|
+
var joined = selection.replace(/[\r\n]+/g, "");
|
|
166
|
+
var urls = findMultiRowUrls(logical);
|
|
167
|
+
for (var i = 0; i < urls.length; i++) {
|
|
168
|
+
var hit = urls[i];
|
|
169
|
+
if (pos.start.y >= hit.start.y - 1 && pos.end.y <= hit.end.y - 1 &&
|
|
170
|
+
hit.url.indexOf(joined) !== -1) {
|
|
171
|
+
return joined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return selection;
|
|
175
|
+
}
|