@clagentic/console 1.12.0-beta.3 → 1.13.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 +7 -1
- package/bin/cli.js +18 -15
- package/lib/agent-roster-ws.js +38 -13
- package/lib/agent-roster.js +111 -12
- package/lib/agents.js +68 -33
- package/lib/atomic-install.js +334 -0
- package/lib/build-changes.js +33 -4
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +12 -0
- package/lib/chat-width.js +31 -0
- package/lib/cli/agent-usage.js +126 -0
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/compact-output.js +69 -0
- package/lib/cli/ipc-subcommands.js +92 -67
- package/lib/cli/output.js +28 -0
- package/lib/cli/restart-verb.js +132 -0
- package/lib/cli/schedule-input-subcommands.js +45 -8
- package/lib/cli/session-subcommands.js +37 -11
- package/lib/cli/settings-subcommands.js +74 -0
- package/lib/cli-transcript-title.js +56 -3
- package/lib/client-files.js +79 -0
- package/lib/daemon.js +100 -28
- package/lib/default-avatar-color.js +4 -0
- package/lib/drain.js +58 -10
- package/lib/mcp-tool-input.js +2 -2
- package/lib/model-families.js +49 -1
- package/lib/notify/type-registry.js +4 -0
- package/lib/notify/types.js +7 -4
- package/lib/pages.js +13 -63
- package/lib/permission-summary.js +12 -16
- package/lib/plan-usage-reader.js +70 -0
- package/lib/project-connection.js +4 -2
- package/lib/project-filesystem.js +6 -7
- package/lib/project-notifications.js +55 -8
- package/lib/project-prompt-expiry-settings.js +42 -0
- package/lib/project-sessions.js +52 -0
- package/lib/project-settings-gate.js +98 -0
- package/lib/project-user-mention.js +3 -2
- package/lib/project.js +1 -1
- package/lib/prompt-expiry-settings.js +49 -0
- package/lib/prompt-expiry.js +24 -3
- package/lib/prompt-kinds/codecs.js +6 -2
- package/lib/public/app.js +36 -36
- package/lib/public/css/admin.css +156 -170
- package/lib/public/css/agent-messages.css +24 -24
- package/lib/public/css/agent-picker.css +90 -38
- package/lib/public/css/agent-roster.css +61 -27
- package/lib/public/css/at-agents.css +10 -10
- package/lib/public/css/base.css +207 -184
- package/lib/public/css/chat-layout.css +228 -0
- package/lib/public/css/command-palette.css +86 -88
- package/lib/public/css/diagnostics.css +78 -204
- package/lib/public/css/diff.css +10 -10
- package/lib/public/css/filebrowser.css +32 -60
- package/lib/public/css/home-hub.css +100 -100
- package/lib/public/css/icon-strip.css +195 -238
- package/lib/public/css/input.css +191 -212
- package/lib/public/css/login-panel.css +16 -16
- package/lib/public/css/loop.css +96 -187
- package/lib/public/css/mention.css +49 -110
- package/lib/public/css/menus.css +162 -169
- package/lib/public/css/messages.css +49 -123
- package/lib/public/css/mobile-nav.css +207 -264
- package/lib/public/css/notifications-center.css +45 -124
- package/lib/public/css/overlay.css +269 -0
- package/lib/public/css/overlays.css +134 -156
- package/lib/public/css/playbook.css +41 -41
- package/lib/public/css/profile.css +43 -112
- package/lib/public/css/rewind.css +112 -112
- package/lib/public/css/scheduler-modal.css +27 -135
- package/lib/public/css/scheduler.css +204 -210
- package/lib/public/css/server-settings.css +173 -239
- package/lib/public/css/session-search.css +20 -20
- package/lib/public/css/settings-nav.css +197 -0
- package/lib/public/css/sidebar.css +213 -304
- package/lib/public/css/skills.css +121 -135
- package/lib/public/css/sticky-notes.css +114 -200
- package/lib/public/css/stt.css +17 -26
- package/lib/public/css/team-panel.css +36 -36
- package/lib/public/css/team-view.css +9 -9
- package/lib/public/css/title-bar.css +83 -100
- package/lib/public/css/tooltip.css +10 -10
- package/lib/public/css/user-settings.css +78 -131
- package/lib/public/css/user-shell.css +125 -29
- package/lib/public/index.html +178 -177
- package/lib/public/manifest.json +0 -2
- package/lib/public/modules/admin.js +54 -92
- package/lib/public/modules/agent-avatar.js +134 -3
- package/lib/public/modules/agent-messages.js +2 -1
- package/lib/public/modules/agent-picker.js +23 -21
- package/lib/public/modules/agent-roster-groups.js +128 -0
- package/lib/public/modules/agent-roster.js +40 -11
- package/lib/public/modules/app-connection.js +13 -1
- package/lib/public/modules/app-cursors.js +9 -9
- package/lib/public/modules/app-favicon.js +8 -16
- package/lib/public/modules/app-header.js +28 -19
- package/lib/public/modules/app-history-replay.js +67 -4
- package/lib/public/modules/app-home-hub.js +15 -0
- package/lib/public/modules/app-loop-ui.js +41 -47
- package/lib/public/modules/app-loop-wizard.js +9 -10
- package/lib/public/modules/app-messages.js +32 -36
- package/lib/public/modules/app-misc.js +22 -92
- package/lib/public/modules/app-modals.js +98 -0
- package/lib/public/modules/app-notifications.js +124 -135
- package/lib/public/modules/app-panels.js +28 -32
- package/lib/public/modules/app-projects.js +30 -40
- package/lib/public/modules/app-rate-limit.js +26 -9
- package/lib/public/modules/app-rendering.js +128 -110
- package/lib/public/modules/app-skills-install.js +6 -4
- package/lib/public/modules/assistant-identity.js +55 -0
- package/lib/public/modules/at-agents.js +3 -0
- package/lib/public/modules/build-guard.js +25 -11
- package/lib/public/modules/chat-width-choice.js +75 -0
- package/lib/public/modules/chat-width-prefs.js +52 -0
- package/lib/public/modules/chat-width.js +102 -0
- package/lib/public/modules/collapsible-text.js +36 -4
- package/lib/public/modules/command-palette.js +28 -34
- package/lib/public/modules/context-sources.js +3 -5
- package/lib/public/modules/diagnostics.js +130 -129
- package/lib/public/modules/info-panel.js +31 -0
- package/lib/public/modules/injected-identity.js +8 -8
- package/lib/public/modules/input-list-menu.js +39 -0
- package/lib/public/modules/input.js +22 -21
- package/lib/public/modules/markdown.js +10 -11
- package/lib/public/modules/mcp-ui.js +4 -14
- package/lib/public/modules/mention.js +100 -229
- package/lib/public/modules/message-header.js +80 -0
- package/lib/public/modules/message-participants.js +39 -0
- package/lib/public/modules/mobile-action-sheet.js +46 -0
- package/lib/public/modules/mobile-nav-sheet.js +104 -0
- package/lib/public/modules/model-families.js +41 -4
- package/lib/public/modules/note-order.js +39 -0
- package/lib/public/modules/notifications.js +35 -52
- package/lib/public/modules/overlay-history.js +73 -19
- package/lib/public/modules/overlay-menu.js +123 -0
- package/lib/public/modules/overlay-modal.js +186 -0
- package/lib/public/modules/overlay-registry.js +392 -0
- package/lib/public/modules/overlay-stack.js +110 -0
- package/lib/public/modules/overlay.js +117 -0
- package/lib/public/modules/popover-position.js +18 -2
- package/lib/public/modules/preference-sync.js +28 -0
- package/lib/public/modules/profile.js +24 -49
- package/lib/public/modules/project-settings.js +27 -172
- package/lib/public/modules/prompt-expiry-controls.js +46 -0
- package/lib/public/modules/prompt-kinds/command-summary.js +149 -0
- package/lib/public/modules/prompt-kinds/permission.js +70 -92
- package/lib/public/modules/prompts.js +1 -2
- package/lib/public/modules/qrcode.js +6 -21
- package/lib/public/modules/queued-button.js +15 -2
- package/lib/public/modules/rewind.js +9 -3
- package/lib/public/modules/schedule-time.js +32 -7
- package/lib/public/modules/scheduled-outbox.js +51 -18
- package/lib/public/modules/scheduler-config.js +87 -127
- package/lib/public/modules/scheduler.js +29 -26
- package/lib/public/modules/serialized-save.js +79 -0
- package/lib/public/modules/server-settings.js +75 -65
- package/lib/public/modules/session-grants.js +16 -19
- package/lib/public/modules/session-list-avatars.js +98 -0
- package/lib/public/modules/session-vendor-state.js +86 -0
- package/lib/public/modules/settings-access.js +35 -0
- package/lib/public/modules/settings-hub.js +125 -0
- package/lib/public/modules/settings-nav.js +182 -0
- package/lib/public/modules/shell-line.js +24 -0
- package/lib/public/modules/sidebar-mobile.js +151 -195
- package/lib/public/modules/sidebar-projects.js +88 -129
- package/lib/public/modules/sidebar-sessions.js +66 -34
- package/lib/public/modules/sidebar.js +2 -2
- package/lib/public/modules/skills.js +11 -26
- package/lib/public/modules/sticky-notes.js +19 -16
- package/lib/public/modules/stt.js +9 -23
- package/lib/public/modules/terminal.js +86 -90
- package/lib/public/modules/theme-choice.js +126 -0
- package/lib/public/modules/theme-colors.js +19 -0
- package/lib/public/modules/theme-prefs.js +121 -0
- package/lib/public/modules/theme.js +227 -605
- package/lib/public/modules/tool-palette.js +7 -17
- package/lib/public/modules/tools.js +8 -10
- package/lib/public/modules/user-settings.js +59 -115
- package/lib/public/modules/user-shell.js +9 -2
- package/lib/public/modules/utils.js +10 -12
- package/lib/public/modules/vendor-picker.js +4 -2
- package/lib/public/modules/vendor-registry.js +1 -2
- package/lib/public/style.css +3 -1
- package/lib/public/sw.js +9 -2
- package/lib/public/theme-core.js +411 -0
- package/lib/request-body.js +70 -0
- package/lib/sdk-bridge.js +227 -88
- package/lib/sdk-message-processor.js +44 -16
- package/lib/server-admin.js +198 -200
- package/lib/server-auth.js +16 -13
- package/lib/server-dm.js +4 -3
- package/lib/server-settings.js +177 -130
- package/lib/server.js +87 -36
- package/lib/session-background-tasks.js +79 -0
- package/lib/session-directory.js +138 -13
- package/lib/session-input-ipc.js +2 -0
- package/lib/session-input.js +39 -5
- package/lib/session-list-avatars.js +16 -0
- package/lib/session-reclaim.js +37 -25
- package/lib/session-vendor.js +37 -0
- package/lib/sessions.js +99 -34
- package/lib/settings-ipc.js +60 -0
- package/lib/settings-registry.js +86 -0
- package/lib/terminal-manager.js +17 -5
- package/lib/theme-files.js +132 -0
- package/lib/theme-seed.js +136 -0
- package/lib/themes/clagentic-dark.json +13 -6
- package/lib/themes/clagentic-light.json +12 -5
- package/lib/updater.js +6 -4
- package/lib/usage-store.js +97 -10
- package/lib/users-preferences.js +118 -19
- package/lib/users.js +19 -10
- package/lib/vendor-catalog.js +130 -0
- package/lib/ws-schema.js +4 -2
- package/lib/yoke/adapters/claude.js +81 -1
- package/lib/yoke/adapters/codex-user-shell.js +87 -23
- package/lib/yoke/adapters/codex.js +89 -5
- package/lib/yoke/codex-binary.js +59 -0
- package/package.json +1 -1
- package/scripts/check-test-count.js +5 -0
- package/scripts/install-local-test.js +50 -9
- package/scripts/write-build-sha.js +18 -2
- package/lib/public/css/channel-layout.css +0 -329
- package/lib/themes/ayu-light.json +0 -9
- package/lib/themes/catppuccin-latte.json +0 -9
- package/lib/themes/catppuccin-mocha.json +0 -9
- package/lib/themes/dracula.json +0 -9
- package/lib/themes/everforest-light.json +0 -9
- package/lib/themes/everforest.json +0 -9
- package/lib/themes/github-light.json +0 -9
- package/lib/themes/gruvbox-dark.json +0 -9
- package/lib/themes/gruvbox-light.json +0 -9
- package/lib/themes/monokai.json +0 -9
- package/lib/themes/nord-light.json +0 -9
- package/lib/themes/nord.json +0 -9
- package/lib/themes/one-dark.json +0 -9
- package/lib/themes/one-light.json +0 -9
- package/lib/themes/rose-pine-dawn.json +0 -9
- package/lib/themes/rose-pine.json +0 -9
- package/lib/themes/solarized-dark.json +0 -9
- package/lib/themes/solarized-light.json +0 -9
- package/lib/themes/tokyo-night-light.json +0 -9
- package/lib/themes/tokyo-night.json +0 -9
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// How a shell command is named to the operator in a permission ask, a banner
|
|
2
|
+
// and a summary. One source for the browser and the server (the server loads
|
|
3
|
+
// this file through lib/prompt-kinds/codecs.js), so no surface names a call
|
|
4
|
+
// differently from another.
|
|
5
|
+
//
|
|
6
|
+
// A command that opens with environment assignments ("export NAME=value; cmd",
|
|
7
|
+
// "NAME=value cmd") would fill a short bound with the assignments and hide the
|
|
8
|
+
// command they prefix. commandHead() shortens those assignments to their names
|
|
9
|
+
// and keeps the rest verbatim. It never hides code: only a plain literal value
|
|
10
|
+
// (letters, digits, - _ . / : , @ % + =) is shortened; any other value leaves
|
|
11
|
+
// the whole command as it is.
|
|
12
|
+
|
|
13
|
+
var NAME = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
14
|
+
var MAX_NAMES_SHOWN = 3;
|
|
15
|
+
var MAX_PREFIX = 40;
|
|
16
|
+
|
|
17
|
+
// What a line break reads as on a one-line surface: a mark, set off by spaces,
|
|
18
|
+
// that no command text is mistaken for.
|
|
19
|
+
export var LINE_BREAK = " ⏎ ";
|
|
20
|
+
|
|
21
|
+
// Bidirectional controls and marks, which reorder how text reads.
|
|
22
|
+
function isBidi(code) {
|
|
23
|
+
return (code >= 0x202a && code <= 0x202e) || (code >= 0x2066 && code <= 0x2069) ||
|
|
24
|
+
code === 0x200e || code === 0x200f || code === 0x061c;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isControl(code) {
|
|
28
|
+
return code <= 0x1f || (code >= 0x7f && code <= 0x9f) || code === 0x2028 || code === 0x2029;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function escapeCode(code) {
|
|
32
|
+
var hex = code.toString(16).toUpperCase();
|
|
33
|
+
return code <= 0xff ? "\\x" + hex.padStart(2, "0") : "\\u" + hex.padStart(4, "0");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The text with every control and bidirectional-override character written
|
|
38
|
+
* out as an escape (\x1B, ) so it is seen and not interpreted.
|
|
39
|
+
* keepLayout keep newline and tab as they are (a block that shows lines);
|
|
40
|
+
* otherwise a tab becomes a space and each line break (LF, CR,
|
|
41
|
+
* CRLF, the Unicode line and paragraph separators) becomes a
|
|
42
|
+
* visible LINE_BREAK mark (a one-line ask). A line break is never
|
|
43
|
+
* a space: "echo ok # note" then "rm -rf data" on the next line
|
|
44
|
+
* must not read as one commented-out line.
|
|
45
|
+
*/
|
|
46
|
+
export function visibleChars(text, keepLayout) {
|
|
47
|
+
var s = typeof text === "string" ? text : "";
|
|
48
|
+
var out = "";
|
|
49
|
+
for (var i = 0; i < s.length; i++) {
|
|
50
|
+
var code = s.charCodeAt(i);
|
|
51
|
+
if ((code === 10 || code === 9) && keepLayout) out += s.charAt(i);
|
|
52
|
+
else if (!keepLayout && (code === 10 || code === 13 || code === 0x2028 || code === 0x2029)) {
|
|
53
|
+
out += LINE_BREAK;
|
|
54
|
+
if (code === 13 && s.charCodeAt(i + 1) === 10) i++;
|
|
55
|
+
} else if (code === 10 || code === 9 || code === 13) out += " ";
|
|
56
|
+
else if (isControl(code) || isBidi(code)) out += escapeCode(code);
|
|
57
|
+
else out += s.charAt(i);
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The text as one printable line: visibleChars' one-line form (each line break
|
|
64
|
+
* a LINE_BREAK mark, every other control or bidirectional character written
|
|
65
|
+
* out as an escape), runs of spaces collapsed, the ends trimmed. It calls
|
|
66
|
+
* visibleChars so the two can never differ on which characters are shown.
|
|
67
|
+
*/
|
|
68
|
+
export function oneLine(text) {
|
|
69
|
+
return visibleChars(text, false).replace(/ {2,}/g, " ").trim();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isSpace(ch) {
|
|
73
|
+
return ch === " " || ch === "\t";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Characters a shortened value may hold. Anything else (a quote, $, a backtick,
|
|
77
|
+
// a brace, a parenthesis, a backslash, & | < >) can hide or run code, so it
|
|
78
|
+
// is never read past: an allowlist, because a denylist misses the next shape.
|
|
79
|
+
var PLAIN_VALUE_CHAR = /[A-Za-z0-9_.\/:,@%+=-]/;
|
|
80
|
+
|
|
81
|
+
// End index of the value that starts at i: the first space, tab, ; or line
|
|
82
|
+
// break after a fully plain literal. -1 when the value is anything else.
|
|
83
|
+
function valueEnd(s, i) {
|
|
84
|
+
for (; i < s.length; i++) {
|
|
85
|
+
var ch = s.charAt(i);
|
|
86
|
+
if (isSpace(ch) || ch === ";" || ch === "\n") break;
|
|
87
|
+
if (!PLAIN_VALUE_CHAR.test(ch)) return -1;
|
|
88
|
+
}
|
|
89
|
+
return i;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The leading assignments of a command and the rest. names is empty (and rest
|
|
94
|
+
* is the whole command) when the command does not open with assignments that
|
|
95
|
+
* can be shortened safely, or is nothing but assignments.
|
|
96
|
+
* @returns {{names: string[], rest: string}}
|
|
97
|
+
*/
|
|
98
|
+
export function splitAssignments(command) {
|
|
99
|
+
var s = typeof command === "string" ? command : "";
|
|
100
|
+
var whole = { names: [], rest: s };
|
|
101
|
+
var names = [];
|
|
102
|
+
var i = 0;
|
|
103
|
+
for (;;) {
|
|
104
|
+
while (i < s.length && (isSpace(s.charAt(i)) || s.charAt(i) === "\n")) i++;
|
|
105
|
+
var exported = /^export[ \t]+/.exec(s.slice(i));
|
|
106
|
+
var at = exported ? i + exported[0].length : i;
|
|
107
|
+
var count = 0;
|
|
108
|
+
for (;;) {
|
|
109
|
+
var m = NAME.exec(s.slice(at));
|
|
110
|
+
if (!m) break;
|
|
111
|
+
var end = valueEnd(s, at + m[0].length);
|
|
112
|
+
if (end < 0) return whole;
|
|
113
|
+
names.push(m[0].slice(0, -1));
|
|
114
|
+
count++;
|
|
115
|
+
at = end;
|
|
116
|
+
while (at < s.length && isSpace(s.charAt(at))) at++;
|
|
117
|
+
}
|
|
118
|
+
if (!count) break;
|
|
119
|
+
i = at;
|
|
120
|
+
var next = s.charAt(i);
|
|
121
|
+
if (next === ";" || next === "\n") {
|
|
122
|
+
i++;
|
|
123
|
+
} else if (s.slice(i, i + 2) === "&&") {
|
|
124
|
+
i += 2;
|
|
125
|
+
} else if (exported || i >= s.length || next === "&" || next === "|" || next === "<" || next === ">" || next === ")") {
|
|
126
|
+
return whole;
|
|
127
|
+
} else {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var rest = s.slice(i).trim();
|
|
132
|
+
return names.length && rest ? { names: names, rest: rest } : whole;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function prefixFor(names) {
|
|
136
|
+
var shown = names.length > MAX_NAMES_SHOWN ? names.slice(0, MAX_NAMES_SHOWN).join(", ") + " +" + (names.length - MAX_NAMES_SHOWN) : names.join(", ");
|
|
137
|
+
var prefix = "(sets " + shown + ")";
|
|
138
|
+
return prefix.length > MAX_PREFIX ? "(sets " + names.length + " variables)" : prefix;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The command as a short ask names it: leading assignments shortened to their
|
|
143
|
+
* names ("(sets A, B) cmd args"), the command they prefix kept verbatim.
|
|
144
|
+
* A command with no such assignments is returned unchanged.
|
|
145
|
+
*/
|
|
146
|
+
export function commandHead(command) {
|
|
147
|
+
var parts = splitAssignments(command);
|
|
148
|
+
return parts.names.length ? prefixFor(parts.names) + " " + parts.rest : (typeof command === "string" ? command : "");
|
|
149
|
+
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
// Tool-call approval card:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { escapeHtml } from '../utils.js';
|
|
8
|
-
import { iconHtml } from '../icons.js';
|
|
1
|
+
// Tool-call approval card: a conversational "Can I ...?" from the assistant,
|
|
2
|
+
// with Allow / Allow for session / No. The same card for every layout and width.
|
|
3
|
+
// The shell (prompts.js, prompt-card.js) owns its state. Which answers it
|
|
4
|
+
// offers, and which leads, follows the ask's SDK hints (permission-choices.js).
|
|
5
|
+
|
|
9
6
|
import { permissionChoices, opensOnNo } from './permission-choices.js';
|
|
7
|
+
import { buildMessageHeader } from '../message-header.js';
|
|
8
|
+
import { commandHead, visibleChars } from './command-summary.js';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
deny: { className: "permission-btn permission-deny", label: "Deny" },
|
|
15
|
-
};
|
|
10
|
+
// Characters of a command the ask line shows, assignment prefix included.
|
|
11
|
+
var ASK_COMMAND_MAX = 80;
|
|
12
|
+
var DESCRIPTION_MAX = 200;
|
|
16
13
|
|
|
17
|
-
var
|
|
14
|
+
var CHOICES = {
|
|
18
15
|
allow: { className: "perm-reply perm-allow", label: "Sure" },
|
|
19
16
|
allow_always: { className: "perm-reply perm-always", label: "Allow for session" },
|
|
20
17
|
deny: { className: "perm-reply perm-deny", label: "No" },
|
|
@@ -23,10 +20,10 @@ var CONVERSATIONAL_CHOICES = {
|
|
|
23
20
|
// The buttons for an ask's answers, in the order the ask allows. An ask that
|
|
24
21
|
// must open on No leads with its decline button and marks it the default;
|
|
25
22
|
// no approve button is ever marked.
|
|
26
|
-
function choiceButtons(fields,
|
|
23
|
+
function choiceButtons(fields, container, host) {
|
|
27
24
|
var leadsWithNo = opensOnNo(fields);
|
|
28
25
|
return permissionChoices(fields).map(function (decision, i) {
|
|
29
|
-
var spec =
|
|
26
|
+
var spec = CHOICES[decision];
|
|
30
27
|
var btn = button(spec.className, spec.label, function () {
|
|
31
28
|
host.respond(container, { decision: decision });
|
|
32
29
|
});
|
|
@@ -52,17 +49,13 @@ function shortPath(p) {
|
|
|
52
49
|
return parts.length > 3 ? ".../" + parts.slice(-3).join("/") : p;
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
case "Glob": return input.pattern || "";
|
|
63
|
-
case "Grep": return (input.pattern || "") + (input.path ? " in " + shortPath(input.path) : "");
|
|
64
|
-
default: return host.toolSummary(toolName, input);
|
|
65
|
-
}
|
|
52
|
+
// The command, never the agent's own description of it, which is free text
|
|
53
|
+
// the calling model chose. Leading environment assignments are shortened so
|
|
54
|
+
// the command they prefix shows within the bound.
|
|
55
|
+
function bashTarget(command) {
|
|
56
|
+
if (typeof command !== "string" || !command.trim()) return "a Bash call that gave no command";
|
|
57
|
+
var line = visibleChars(commandHead(command), false);
|
|
58
|
+
return line.length > ASK_COMMAND_MAX ? line.substring(0, ASK_COMMAND_MAX) + "..." : line;
|
|
66
59
|
}
|
|
67
60
|
|
|
68
61
|
/** "Can I <verb> <target>?" wording for a tool call. */
|
|
@@ -74,7 +67,7 @@ export function askWording(toolName, toolInput) {
|
|
|
74
67
|
case "Write": verb = "write to"; target = shortPath(input.file_path); break;
|
|
75
68
|
case "Edit": verb = "edit"; target = shortPath(input.file_path); break;
|
|
76
69
|
case "Read": verb = "read"; target = shortPath(input.file_path); break;
|
|
77
|
-
case "Bash": verb = "run"; target =
|
|
70
|
+
case "Bash": verb = "run"; target = bashTarget(input.command); break;
|
|
78
71
|
case "Grep": verb = "search"; target = input.pattern || ""; break;
|
|
79
72
|
case "Glob": verb = "search for files in"; target = input.pattern || ""; break;
|
|
80
73
|
case "WebFetch": verb = "fetch"; target = input.url || ""; break;
|
|
@@ -95,6 +88,29 @@ function detailsElement(className, toolInput) {
|
|
|
95
88
|
return details;
|
|
96
89
|
}
|
|
97
90
|
|
|
91
|
+
// For a Bash call: the agent's description as secondary text, marked as the
|
|
92
|
+
// agent's own, and the full command verbatim in a monospace block. Neither
|
|
93
|
+
// needs Details to be opened.
|
|
94
|
+
function bashEvidence(fields) {
|
|
95
|
+
if (fields.toolName !== "Bash") return [];
|
|
96
|
+
var input = fields.toolInput && typeof fields.toolInput === "object" ? fields.toolInput : {};
|
|
97
|
+
var els = [];
|
|
98
|
+
if (typeof input.description === "string" && input.description.trim()) {
|
|
99
|
+
var note = document.createElement("div");
|
|
100
|
+
note.className = "perm-description";
|
|
101
|
+
var text = visibleChars(input.description, false).trim();
|
|
102
|
+
note.textContent = "Agent's description: " + (text.length > DESCRIPTION_MAX ? text.substring(0, DESCRIPTION_MAX) + "..." : text);
|
|
103
|
+
els.push(note);
|
|
104
|
+
}
|
|
105
|
+
if (typeof input.command === "string" && input.command.trim()) {
|
|
106
|
+
var block = document.createElement("pre");
|
|
107
|
+
block.className = "perm-command";
|
|
108
|
+
block.textContent = visibleChars(input.command, true);
|
|
109
|
+
els.push(block);
|
|
110
|
+
}
|
|
111
|
+
return els;
|
|
112
|
+
}
|
|
113
|
+
|
|
98
114
|
function button(className, label, onClick) {
|
|
99
115
|
var btn = document.createElement("button");
|
|
100
116
|
btn.className = className;
|
|
@@ -103,89 +119,55 @@ function button(className, label, onClick) {
|
|
|
103
119
|
return btn;
|
|
104
120
|
}
|
|
105
121
|
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
container.className = "permission-container";
|
|
109
|
-
container.dataset.requestId = requestId;
|
|
110
|
-
|
|
111
|
-
var header = document.createElement("div");
|
|
112
|
-
header.className = "permission-header";
|
|
113
|
-
header.innerHTML =
|
|
114
|
-
'<span class="permission-icon">' + iconHtml("shield") + '</span>' +
|
|
115
|
-
'<span class="permission-title">Permission Required</span>';
|
|
116
|
-
|
|
117
|
-
var body = document.createElement("div");
|
|
118
|
-
body.className = "permission-body";
|
|
119
|
-
var summary = document.createElement("div");
|
|
120
|
-
summary.className = "permission-summary";
|
|
121
|
-
var toolNameEl = document.createElement("span");
|
|
122
|
-
toolNameEl.className = "permission-tool-name";
|
|
123
|
-
toolNameEl.textContent = fields.toolName;
|
|
124
|
-
summary.appendChild(toolNameEl);
|
|
125
|
-
var summaryText = inputSummary(fields.toolName, fields.toolInput, host);
|
|
126
|
-
if (summaryText) {
|
|
127
|
-
var descEl = document.createElement("span");
|
|
128
|
-
descEl.className = "permission-tool-desc";
|
|
129
|
-
descEl.textContent = summaryText;
|
|
130
|
-
summary.appendChild(descEl);
|
|
131
|
-
}
|
|
132
|
-
body.appendChild(summary);
|
|
133
|
-
if (fields.decisionReason) {
|
|
134
|
-
var reason = document.createElement("div");
|
|
135
|
-
reason.className = "permission-reason";
|
|
136
|
-
reason.textContent = fields.decisionReason;
|
|
137
|
-
body.appendChild(reason);
|
|
138
|
-
}
|
|
139
|
-
var rule = ruleNote(fields);
|
|
140
|
-
if (rule) body.appendChild(rule);
|
|
141
|
-
body.appendChild(detailsElement("permission-details", fields.toolInput));
|
|
142
|
-
|
|
143
|
-
var actions = document.createElement("div");
|
|
144
|
-
actions.className = "permission-actions";
|
|
145
|
-
choiceButtons(fields, FORMAL_CHOICES, container, host).forEach(function (btn) { actions.appendChild(btn); });
|
|
146
|
-
if (opensOnNo(fields)) container.dataset.defaultToNo = "true";
|
|
147
|
-
|
|
148
|
-
container.appendChild(header);
|
|
149
|
-
container.appendChild(body);
|
|
150
|
-
container.appendChild(actions);
|
|
151
|
-
return container;
|
|
122
|
+
function pad2(n) {
|
|
123
|
+
return String(n).padStart(2, "0");
|
|
152
124
|
}
|
|
153
125
|
|
|
154
|
-
function
|
|
126
|
+
function draw(fields, requestId, host) {
|
|
155
127
|
var identity = host.vendorIdentity(fields.vendor);
|
|
156
128
|
var wording = askWording(fields.toolName, fields.toolInput);
|
|
157
129
|
|
|
158
130
|
var container = document.createElement("div");
|
|
159
|
-
container.className = "permission-container";
|
|
131
|
+
container.className = "permission-container perm-conversational";
|
|
160
132
|
container.dataset.requestId = requestId;
|
|
161
133
|
|
|
162
|
-
|
|
134
|
+
// No vendor known: a blank avatar, never another vendor's picture.
|
|
135
|
+
var avi = document.createElement(identity.avatar ? "img" : "span");
|
|
163
136
|
avi.className = "dm-bubble-avatar dm-bubble-avatar-agent";
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
137
|
+
if (identity.avatar) {
|
|
138
|
+
avi.src = identity.avatar;
|
|
139
|
+
avi.alt = "";
|
|
140
|
+
}
|
|
167
141
|
|
|
168
142
|
var content = document.createElement("div");
|
|
169
143
|
content.className = "dm-bubble-content";
|
|
170
144
|
var now = new Date();
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
145
|
+
var head = buildMessageHeader({
|
|
146
|
+
side: "other",
|
|
147
|
+
avatarEl: avi,
|
|
148
|
+
name: identity.name,
|
|
149
|
+
time: pad2(now.getHours()) + ":" + pad2(now.getMinutes()),
|
|
150
|
+
});
|
|
151
|
+
content.appendChild(head.el);
|
|
177
152
|
|
|
178
153
|
var askEl = document.createElement("div");
|
|
179
154
|
askEl.className = "perm-ask";
|
|
180
155
|
askEl.textContent = "Can I " + wording.verb + (wording.target ? " " + wording.target : "") + "?";
|
|
181
156
|
content.appendChild(askEl);
|
|
157
|
+
bashEvidence(fields).forEach(function (el) { content.appendChild(el); });
|
|
158
|
+
if (fields.decisionReason) {
|
|
159
|
+
var reason = document.createElement("div");
|
|
160
|
+
reason.className = "permission-reason";
|
|
161
|
+
reason.textContent = fields.decisionReason;
|
|
162
|
+
content.appendChild(reason);
|
|
163
|
+
}
|
|
182
164
|
var rule = ruleNote(fields);
|
|
183
165
|
if (rule) content.appendChild(rule);
|
|
184
166
|
content.appendChild(detailsElement("perm-details", fields.toolInput));
|
|
185
167
|
|
|
186
168
|
var actions = document.createElement("div");
|
|
187
169
|
actions.className = "permission-actions";
|
|
188
|
-
choiceButtons(fields,
|
|
170
|
+
choiceButtons(fields, container, host).forEach(function (btn) { actions.appendChild(btn); });
|
|
189
171
|
if (opensOnNo(fields)) container.dataset.defaultToNo = "true";
|
|
190
172
|
content.appendChild(actions);
|
|
191
173
|
container.appendChild(content);
|
|
@@ -195,11 +177,7 @@ function drawConversational(fields, requestId, host) {
|
|
|
195
177
|
export default {
|
|
196
178
|
kind: "permission",
|
|
197
179
|
|
|
198
|
-
draw:
|
|
199
|
-
return host.layout() === "channel"
|
|
200
|
-
? drawConversational(fields, requestId, host)
|
|
201
|
-
: drawFormal(fields, requestId, host);
|
|
202
|
-
},
|
|
180
|
+
draw: draw,
|
|
203
181
|
|
|
204
182
|
outcome: function (state) {
|
|
205
183
|
if (state.decision === "deny") return { text: "Denied", tone: "denied" };
|
|
@@ -24,9 +24,8 @@ import { promptLabelElement } from './prompt-label.js';
|
|
|
24
24
|
* the transcript, focusing the element matching the selector if given.
|
|
25
25
|
* @param {function(object): boolean} host.send - send a WS message; false
|
|
26
26
|
* when the socket is unusable.
|
|
27
|
-
* @param {function(): string} host.layout - "channel" or "bubble".
|
|
28
27
|
* @param {function(string, object): string} host.toolSummary
|
|
29
|
-
* @param {function(?string): {name: string, avatar: string}} host.vendorIdentity
|
|
28
|
+
* @param {function(?string): {name: string, avatar: ?string}} host.vendorIdentity
|
|
30
29
|
* @param {function(): number} host.getContextPercent
|
|
31
30
|
* @param {function(): ?string} host.getPlanContent
|
|
32
31
|
* @param {function(boolean)} host.setMainInputDisabled
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { copyToClipboard } from './utils.js';
|
|
1
|
+
import { copyToClipboard, escapeHtml } from './utils.js';
|
|
2
|
+
import { showOverlay } from './overlay.js';
|
|
2
3
|
|
|
3
4
|
function getShareUrl() {
|
|
4
5
|
var url = window.location.href;
|
|
@@ -29,7 +30,7 @@ export function triggerShare() {
|
|
|
29
30
|
qr.addData(url);
|
|
30
31
|
qr.make();
|
|
31
32
|
qrCanvas.innerHTML = qr.createSvgTag(5, 0);
|
|
32
|
-
qrUrl.innerHTML = url + '<span class="qr-hint">click to copy</span>';
|
|
33
|
+
qrUrl.innerHTML = escapeHtml(url) + '<span class="qr-hint">click to copy</span>';
|
|
33
34
|
|
|
34
35
|
// Show browser share button if Web Share API is available
|
|
35
36
|
if (qrShareBtn) {
|
|
@@ -40,11 +41,11 @@ export function triggerShare() {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
// Escape, the scrim and the shared close control close it.
|
|
45
|
+
showOverlay({ kind: "modal", el: qrOverlay });
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export function initQrCode() {
|
|
47
|
-
var qrOverlay = document.getElementById("qr-overlay");
|
|
48
49
|
var qrUrl = document.getElementById("qr-url");
|
|
49
50
|
|
|
50
51
|
// click URL to copy
|
|
@@ -54,21 +55,12 @@ export function initQrCode() {
|
|
|
54
55
|
qrUrl.innerHTML = "Copied!";
|
|
55
56
|
qrUrl.classList.add("copied");
|
|
56
57
|
setTimeout(function () {
|
|
57
|
-
qrUrl.innerHTML = url + '<span class="qr-hint">click to copy</span>';
|
|
58
|
+
qrUrl.innerHTML = escapeHtml(url) + '<span class="qr-hint">click to copy</span>';
|
|
58
59
|
qrUrl.classList.remove("copied");
|
|
59
60
|
}, 1500);
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
qrOverlay.addEventListener("click", function () {
|
|
64
|
-
qrOverlay.classList.add("hidden");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// prevent closing when clicking the inner card
|
|
68
|
-
document.getElementById("qr-overlay-inner").addEventListener("click", function (e) {
|
|
69
|
-
e.stopPropagation();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
64
|
// Browser share button
|
|
73
65
|
var qrShareBtn = document.getElementById("qr-share-btn");
|
|
74
66
|
if (qrShareBtn) {
|
|
@@ -77,11 +69,4 @@ export function initQrCode() {
|
|
|
77
69
|
navigator.share({ title: document.title || "Clagentic: Console", url: url }).catch(function () {});
|
|
78
70
|
});
|
|
79
71
|
}
|
|
80
|
-
|
|
81
|
-
// ESC to close
|
|
82
|
-
document.addEventListener("keydown", function (e) {
|
|
83
|
-
if (e.key === "Escape" && !qrOverlay.classList.contains("hidden")) {
|
|
84
|
-
qrOverlay.classList.add("hidden");
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
72
|
}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
// queued-button.js - the control on a queued outbox item. Labelled in words and
|
|
2
2
|
// sized like the send button (the styling is on .shell-queued-btn). One place,
|
|
3
3
|
// so every kind of outbox item draws its controls the same way.
|
|
4
|
+
//
|
|
5
|
+
// opts.icon: a lucide icon name; the button then shows the icon alone and `label`
|
|
6
|
+
// is its accessible name and tooltip. The icon is a placeholder the page's icon
|
|
7
|
+
// pass resolves: the caller runs refreshIcons over the row once it is placed.
|
|
8
|
+
// Without opts the button is the word button it always was.
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
import { iconHtml } from './icons.js';
|
|
11
|
+
|
|
12
|
+
export function queuedButton(label, cls, opts) {
|
|
6
13
|
var b = document.createElement("button");
|
|
7
14
|
b.className = "shell-queued-btn " + cls;
|
|
8
|
-
|
|
15
|
+
if (opts && opts.icon) {
|
|
16
|
+
b.classList.add("shell-queued-icon-btn");
|
|
17
|
+
b.title = label;
|
|
18
|
+
b.innerHTML = iconHtml(opts.icon);
|
|
19
|
+
} else {
|
|
20
|
+
b.textContent = label;
|
|
21
|
+
}
|
|
9
22
|
b.setAttribute("aria-label", label);
|
|
10
23
|
return b;
|
|
11
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { escapeHtml } from './utils.js';
|
|
2
2
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
3
3
|
import { capabilityGate } from './vendor-registry.js';
|
|
4
|
+
import { showOverlay } from './overlay.js';
|
|
4
5
|
|
|
5
6
|
var ctx;
|
|
6
7
|
var rewindMode = false;
|
|
@@ -9,6 +10,7 @@ var rewindPreviewInFlight = false;
|
|
|
9
10
|
var rewindExecuting = false;
|
|
10
11
|
var rewindBannerEl = null;
|
|
11
12
|
var rewindScrollHandler = null;
|
|
13
|
+
var rewindHandle = null;
|
|
12
14
|
var rewindModal, rewindSummary, rewindFilesList, rewindConfirmBtn, rewindCancelBtn, rewindModeOptions;
|
|
13
15
|
var cachedPreview = null;
|
|
14
16
|
|
|
@@ -199,11 +201,16 @@ export function showRewindModal(data) {
|
|
|
199
201
|
rewindFilesList.style.display = "none";
|
|
200
202
|
}
|
|
201
203
|
|
|
202
|
-
|
|
204
|
+
rewindHandle = showOverlay({ kind: "modal", el: rewindModal, onRemove: resetRewindState });
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
export function hideRewindModal() {
|
|
206
|
-
|
|
208
|
+
if (rewindHandle && rewindHandle.isOpen()) rewindHandle.close();
|
|
209
|
+
else resetRewindState();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Runs when the modal closes, however (a button, Escape, the scrim or the close control).
|
|
213
|
+
function resetRewindState() {
|
|
207
214
|
pendingRewindUuid = null;
|
|
208
215
|
rewindPreviewInFlight = false;
|
|
209
216
|
}
|
|
@@ -380,5 +387,4 @@ export function initRewind(_ctx) {
|
|
|
380
387
|
});
|
|
381
388
|
|
|
382
389
|
rewindCancelBtn.addEventListener("click", hideRewindModal);
|
|
383
|
-
rewindModal.querySelector(".confirm-backdrop").addEventListener("click", hideRewindModal);
|
|
384
390
|
}
|
|
@@ -152,6 +152,37 @@ export function inputLabel(input) {
|
|
|
152
152
|
return input.kind === "recurring" ? "Scheduled repeat" : "Scheduled message";
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
// Time left as "1h 5m 3s", "4m 12s" or "12s". compact drops the seconds once an
|
|
156
|
+
// hour or more is left, for the one-line pending card.
|
|
157
|
+
export function remainingText(remaining, compact) {
|
|
158
|
+
var hrs = Math.floor(remaining / 3600000);
|
|
159
|
+
var mins = Math.floor((remaining % 3600000) / 60000);
|
|
160
|
+
var secs = Math.floor((remaining % 60000) / 1000);
|
|
161
|
+
var timeStr = "";
|
|
162
|
+
if (hrs > 0) timeStr += hrs + "h ";
|
|
163
|
+
if (mins > 0 || hrs > 0) timeStr += mins + "m";
|
|
164
|
+
if (hrs > 0 && compact) return timeStr;
|
|
165
|
+
if (mins > 0 || hrs > 0) timeStr += " ";
|
|
166
|
+
return timeStr + secs + "s";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// The fire time of the pending card's collapsed line: time remaining for a one-shot,
|
|
170
|
+
// the next firing's time remaining for a repeat. Returns { text, title, label }:
|
|
171
|
+
// the visible text, the absolute time for the tooltip, and the accessible name
|
|
172
|
+
// (absolute and remaining, since the name replaces the visible text).
|
|
173
|
+
export function fireTimeParts(input, now) {
|
|
174
|
+
var recurring = input.kind === "recurring";
|
|
175
|
+
var abs = (recurring ? "Next " : "Sends ") + dayTimeText(input.nextAt, now);
|
|
176
|
+
var remaining = input.nextAt - now;
|
|
177
|
+
if (remaining <= 0) return { text: "Sending...", title: abs, label: abs + ", sending now" };
|
|
178
|
+
var left = remainingText(remaining, true);
|
|
179
|
+
return {
|
|
180
|
+
text: (recurring ? "next in " : "in ") + left,
|
|
181
|
+
title: abs,
|
|
182
|
+
label: abs + ", in " + left,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
155
186
|
// The line under a scheduled-message bubble, refreshed every second:
|
|
156
187
|
// "Sends at 08:30 PM (4m 12s)", and for a repeat the next time and its end.
|
|
157
188
|
export function countdownText(input, now) {
|
|
@@ -160,13 +191,7 @@ export function countdownText(input, now) {
|
|
|
160
191
|
else if (input.kind === "recurring") lead = "Scheduled repeat · ";
|
|
161
192
|
var remaining = input.nextAt - now;
|
|
162
193
|
if (remaining <= 0) return lead + "Sending...";
|
|
163
|
-
var
|
|
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";
|
|
194
|
+
var timeStr = remainingText(remaining);
|
|
170
195
|
var abs = new Date(input.nextAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
171
196
|
var text = lead + (input.kind === "recurring" ? "Next at " : "Sends at ") + abs + " (" + timeStr + ")";
|
|
172
197
|
if (input.kind === "recurring") {
|