@clagentic/console 1.10.0-beta.1 → 1.10.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/cli.js +10 -0
- package/lib/activity-clock.js +23 -0
- package/lib/agent-dispatch-tool.js +20 -0
- package/lib/build-changes.js +79 -0
- package/lib/build-identity.js +192 -0
- package/lib/build-monitor.js +125 -0
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +141 -0
- package/lib/build-update-restart.js +142 -0
- package/lib/build-update-standing.js +184 -0
- package/lib/cli/daemon-launch.js +8 -5
- package/lib/cli/ipc-subcommands.js +6 -0
- package/lib/cli/session-subcommands.js +122 -0
- package/lib/cli-sessions.js +8 -1
- package/lib/cli-transcript-title.js +131 -0
- package/lib/codex-defaults.js +8 -2
- package/lib/daemon-projects.js +19 -0
- package/lib/daemon.js +166 -127
- package/lib/debug-log.js +17 -0
- package/lib/exit-flush.js +44 -0
- package/lib/grant-keys.js +179 -0
- package/lib/log-field.js +34 -0
- package/lib/memory-shed.js +13 -32
- package/lib/project-connection.js +14 -0
- package/lib/project-external-trigger.js +91 -123
- package/lib/project-http.js +2 -0
- package/lib/project-loop.js +5 -4
- package/lib/project-notifications.js +4 -0
- package/lib/project-prompt-responses.js +7 -5
- package/lib/project-session-grants.js +73 -0
- package/lib/project-sessions.js +55 -68
- package/lib/project-user-message.js +13 -25
- package/lib/project.js +25 -5
- package/lib/prompt-kinds/permission.js +18 -0
- package/lib/prompt-label.js +60 -0
- package/lib/prompt-registry.js +123 -13
- package/lib/prompt-source.js +65 -0
- package/lib/public/css/diagnostics.css +30 -0
- package/lib/public/css/notifications-center.css +15 -0
- package/lib/public/css/overlays.css +18 -0
- package/lib/public/css/rewind.css +8 -0
- package/lib/public/modules/agent-dispatch-tool.js +9 -0
- package/lib/public/modules/app-messages.js +10 -2
- package/lib/public/modules/app-notifications.js +9 -1
- package/lib/public/modules/app-panels.js +0 -1
- package/lib/public/modules/build-update-detail.js +54 -0
- package/lib/public/modules/diagnostics.js +126 -20
- package/lib/public/modules/prompt-banner.js +12 -0
- package/lib/public/modules/prompt-kinds/permission-choices.js +6 -1
- package/lib/public/modules/prompt-kinds/permission.js +15 -0
- package/lib/public/modules/prompt-label.js +44 -0
- package/lib/public/modules/prompts.js +9 -0
- package/lib/public/modules/session-grants.js +131 -0
- package/lib/public/modules/sidebar-sessions.js +11 -0
- package/lib/public/modules/tools.js +14 -2
- package/lib/public/modules/vendor-picker.js +2 -2
- package/lib/public/modules/vendor-registry.js +11 -2
- package/lib/runtime-env.js +1 -1
- package/lib/sdk-bridge.js +114 -115
- package/lib/sdk-message-processor.js +25 -87
- package/lib/sdk-skill-discovery.js +65 -60
- package/lib/server.js +15 -2
- package/lib/session-ai-title.js +80 -0
- package/lib/session-id.js +33 -0
- package/lib/session-input-ipc.js +32 -0
- package/lib/session-input.js +409 -0
- package/lib/session-reclaim.js +284 -0
- package/lib/session-resume.js +172 -0
- package/lib/sessions.js +31 -21
- package/lib/supervisor.js +39 -0
- package/lib/turn-initiator.js +108 -0
- package/lib/utils.js +9 -47
- package/lib/vendor-registry-message.js +1 -0
- package/lib/ws-schema.js +9 -4
- package/lib/yoke/adapters/claude-vendor.js +0 -1
- package/lib/yoke/adapters/claude-worker.js +6 -4
- package/lib/yoke/adapters/claude.js +29 -86
- package/lib/yoke/adapters/codex-capabilities.js +9 -6
- package/lib/yoke/adapters/codex-vendor.js +15 -15
- package/lib/yoke/adapters/codex.js +125 -136
- package/lib/yoke/auth-checks.js +8 -21
- package/lib/yoke/codex-app-server.js +27 -71
- package/lib/yoke/codex-binary.js +254 -0
- package/lib/yoke/codex-command.js +122 -0
- package/lib/yoke/codex-protocol.js +96 -0
- package/lib/yoke/codex-version.js +135 -0
- package/lib/yoke/index.js +20 -4
- package/lib/yoke/install-probe.js +21 -6
- package/lib/yoke/interface.js +14 -12
- package/lib/yoke/registry.js +41 -4
- package/package.json +1 -2
- package/scripts/verify-installed-build.js +59 -17
- package/lib/lore-attestation.js +0 -73
package/lib/prompt-registry.js
CHANGED
|
@@ -45,6 +45,11 @@ var crypto = require("crypto");
|
|
|
45
45
|
var utils = require("./utils");
|
|
46
46
|
var promptKinds = require("./prompt-kinds");
|
|
47
47
|
var codecs = require("./prompt-kinds/codecs");
|
|
48
|
+
var grantKeys = require("./grant-keys");
|
|
49
|
+
var sessionReclaim = require("./session-reclaim");
|
|
50
|
+
var { promptLabel } = require("./prompt-label");
|
|
51
|
+
var promptSource = require("./prompt-source");
|
|
52
|
+
var { logField } = require("./log-field");
|
|
48
53
|
var { ownValue, putOwn, hasOwnKey } = codecs;
|
|
49
54
|
|
|
50
55
|
var KINDS = promptKinds.KINDS;
|
|
@@ -117,6 +122,11 @@ function openedBy(item) {
|
|
|
117
122
|
* @param {function(object)} deps.saveSessionFile - durable session meta write.
|
|
118
123
|
* @param {function(): ?object} [deps.getNotificationsModule]
|
|
119
124
|
* @param {function()} [deps.onProcessingChanged] - cross-project badge refresh.
|
|
125
|
+
* @param {function(): string} [deps.getProjectName] - the project's display
|
|
126
|
+
* name, read at each prompt so a rename shows on the next one.
|
|
127
|
+
* @param {function(): string} [deps.getProjectSlug] - the project's slug, which
|
|
128
|
+
* the lifecycle log lines carry because console session ids repeat across
|
|
129
|
+
* projects.
|
|
120
130
|
*/
|
|
121
131
|
function createPromptRegistry(deps) {
|
|
122
132
|
var index = deps.index;
|
|
@@ -125,6 +135,8 @@ function createPromptRegistry(deps) {
|
|
|
125
135
|
var saveSessionFile = deps.saveSessionFile;
|
|
126
136
|
var getNotificationsModule = deps.getNotificationsModule || function () { return null; };
|
|
127
137
|
var onProcessingChanged = deps.onProcessingChanged || function () {};
|
|
138
|
+
var getProjectName = deps.getProjectName || function () { return ""; };
|
|
139
|
+
var getProjectSlug = deps.getProjectSlug || function () { return ""; };
|
|
128
140
|
|
|
129
141
|
// Project-scope prompts (no session): requestId -> record.
|
|
130
142
|
var projectPrompts = Object.create(null);
|
|
@@ -222,7 +234,36 @@ function createPromptRegistry(deps) {
|
|
|
222
234
|
pruneToolOwners(session);
|
|
223
235
|
}
|
|
224
236
|
|
|
225
|
-
|
|
237
|
+
// One line each when an operator prompt opens and when it settles, so the
|
|
238
|
+
// journal shows that a prompt was pending, for whom, and how it ended. Only
|
|
239
|
+
// identifiers and the outcome: never the tool input, the question, the
|
|
240
|
+
// answer or any prompt text.
|
|
241
|
+
function lifecycleFields(session, requestId, record, kind) {
|
|
242
|
+
var taskId = session ? ownerTaskOf(session, record) : null;
|
|
243
|
+
return "project=" + logField(getProjectSlug())
|
|
244
|
+
+ " session=" + logField(session && session.localId)
|
|
245
|
+
+ " request=" + logField(requestId, 80)
|
|
246
|
+
+ " kind=" + logField(kind.name)
|
|
247
|
+
+ " tool=" + logField(record.toolName)
|
|
248
|
+
+ " agent=" + (taskId ? "task:" + logField(taskId, 80) : "none");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function logOpened(session, requestId, record, kind) {
|
|
252
|
+
if (!kind.journal) return;
|
|
253
|
+
console.log("[prompt-registry] prompt opened: " + lifecycleFields(session, requestId, record, kind));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// info: { status: "resolved"|"cancelled", source, reason?, decision?, granted? }
|
|
257
|
+
function logSettled(session, requestId, entry, info) {
|
|
258
|
+
if (!entry.kind.journal) return;
|
|
259
|
+
var line = "[prompt-registry] prompt " + info.status + ": " + lifecycleFields(session, requestId, entry.record, entry.kind);
|
|
260
|
+
if (info.decision) line += " decision=" + logField(info.decision);
|
|
261
|
+
if (info.status === "resolved") line += " grant=" + (info.granted ? "stored" : "none");
|
|
262
|
+
if (info.reason) line += " reason=" + logField(info.reason);
|
|
263
|
+
console.log(line + " " + promptSource.describe(info.source));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function settle(session, requestId, entry, value, event, info) {
|
|
226
267
|
var map = session ? session[entry.store] : projectPrompts;
|
|
227
268
|
if (!map || ownValue(map, requestId) !== entry.record) return false;
|
|
228
269
|
delete map[requestId];
|
|
@@ -233,6 +274,7 @@ function createPromptRegistry(deps) {
|
|
|
233
274
|
dismissNotification(requestId);
|
|
234
275
|
if (event) sendAndRecord(session, event);
|
|
235
276
|
onProcessingChanged();
|
|
277
|
+
if (info) logSettled(session, requestId, entry, info);
|
|
236
278
|
}
|
|
237
279
|
entry.record.resolve(value);
|
|
238
280
|
if (session) {
|
|
@@ -248,7 +290,11 @@ function createPromptRegistry(deps) {
|
|
|
248
290
|
var event = (entry.kind.journal && !(opts && opts.record === false))
|
|
249
291
|
? { type: "prompt_cancel", requestId: requestId, kind: entry.kind.name, reason: reason }
|
|
250
292
|
: null;
|
|
251
|
-
return settle(session, requestId, entry, entry.kind.cancelled(reason), event
|
|
293
|
+
return settle(session, requestId, entry, entry.kind.cancelled(reason), event, {
|
|
294
|
+
status: "cancelled",
|
|
295
|
+
reason: reason,
|
|
296
|
+
source: (opts && opts.source) || promptSource.fromCancel(reason),
|
|
297
|
+
});
|
|
252
298
|
}
|
|
253
299
|
|
|
254
300
|
function cancelWhere(session, reason, predicate, opts) {
|
|
@@ -311,6 +357,7 @@ function createPromptRegistry(deps) {
|
|
|
311
357
|
var owner = scoped ? session : null;
|
|
312
358
|
|
|
313
359
|
if (scoped) {
|
|
360
|
+
record.label = labelFor(session, record.toolUseId);
|
|
314
361
|
record.query = session.queryInstance || null;
|
|
315
362
|
putOwn(sessionMap(session, kind.store), requestId, record);
|
|
316
363
|
putOwn(index, requestId, session.localId);
|
|
@@ -323,8 +370,9 @@ function createPromptRegistry(deps) {
|
|
|
323
370
|
requestId: requestId,
|
|
324
371
|
kind: kind.name,
|
|
325
372
|
toolUseId: record.toolUseId,
|
|
326
|
-
}, kind.requestFields(record)));
|
|
373
|
+
}, labelFields(record), kind.requestFields(record)));
|
|
327
374
|
onProcessingChanged();
|
|
375
|
+
logOpened(owner, requestId, record, kind);
|
|
328
376
|
}
|
|
329
377
|
|
|
330
378
|
var cleanups = [];
|
|
@@ -337,7 +385,9 @@ function createPromptRegistry(deps) {
|
|
|
337
385
|
}
|
|
338
386
|
var timeoutMs = opts.timeoutMs != null ? opts.timeoutMs : kind.defaultTimeoutMs;
|
|
339
387
|
if (timeoutMs) {
|
|
340
|
-
var timer = setTimeout(function () {
|
|
388
|
+
var timer = setTimeout(function () {
|
|
389
|
+
cancelEntry(owner, requestId, entry, "expired", { source: promptSource.fromTimeout() });
|
|
390
|
+
}, timeoutMs);
|
|
341
391
|
cleanups.push(function () { clearTimeout(timer); });
|
|
342
392
|
}
|
|
343
393
|
if (cleanups.length) {
|
|
@@ -348,10 +398,10 @@ function createPromptRegistry(deps) {
|
|
|
348
398
|
var nm = getNotificationsModule();
|
|
349
399
|
if (nm && typeof nm.notify === "function") {
|
|
350
400
|
var kindFields = typeof kind.notificationFields === "function" ? kind.notificationFields(record) : {};
|
|
351
|
-
|
|
401
|
+
nm.notify("permission_request", Object.assign({}, opts.notification, kindFields, labelFields(record), { requestId: requestId, kind: kind.name }));
|
|
352
402
|
}
|
|
353
403
|
}
|
|
354
|
-
return { requestId: requestId, answer: answer, pending: true };
|
|
404
|
+
return { requestId: requestId, answer: answer, pending: true, label: record.label || null };
|
|
355
405
|
}
|
|
356
406
|
|
|
357
407
|
// The pending entry for requestId (its live record and kind adapter), or
|
|
@@ -413,6 +463,9 @@ function createPromptRegistry(deps) {
|
|
|
413
463
|
* @param {string} [opts.denyMessage] - override for a plain deny.
|
|
414
464
|
* @param {?object} [opts.responder] - the connection that answered, if
|
|
415
465
|
* any; handed to the resolution effects.
|
|
466
|
+
* @param {?object} [opts.source] - who answered (lib/prompt-source.js); it is
|
|
467
|
+
* logged and recorded on the prompt_resolved event. A caller that names none
|
|
468
|
+
* is logged as unspecified and its event carries no source.
|
|
416
469
|
*/
|
|
417
470
|
function respond(requestId, msg, opts) {
|
|
418
471
|
opts = opts || {};
|
|
@@ -427,12 +480,20 @@ function createPromptRegistry(deps) {
|
|
|
427
480
|
if (response.invalid) {
|
|
428
481
|
return { status: "invalid", reason: response.invalid, pending: kind.journal ? pendingMessage(requestId, found) : null };
|
|
429
482
|
}
|
|
430
|
-
|
|
483
|
+
var granted = kind.grantsSession(response) ? grant(found.session, found.record.toolName, found.record.toolInput) : false;
|
|
431
484
|
var event = kind.journal
|
|
432
485
|
? Object.assign({ type: "prompt_resolved", requestId: requestId, kind: kind.name }, kind.resolvedFields(response, found.record))
|
|
433
486
|
: null;
|
|
487
|
+
if (event && opts.source) event.source = opts.source;
|
|
434
488
|
var prompt = publicView(requestId, found);
|
|
435
|
-
|
|
489
|
+
// The decision word or action only; an answer's content stays out of the log.
|
|
490
|
+
var decision = event && (typeof event.decision === "string" ? event.decision : (typeof event.action === "string" ? event.action : null));
|
|
491
|
+
settle(found.session, requestId, found, kind.outcome(found.record, response, opts), event, {
|
|
492
|
+
status: "resolved",
|
|
493
|
+
decision: decision,
|
|
494
|
+
granted: granted,
|
|
495
|
+
source: opts.source || null,
|
|
496
|
+
});
|
|
436
497
|
var outcome = { status: "resolved", session: found.session, prompt: prompt, kind: kind.name, response: response };
|
|
437
498
|
if (resolutionEffects) resolutionEffects(outcome, opts.responder || null);
|
|
438
499
|
return outcome;
|
|
@@ -504,6 +565,12 @@ function createPromptRegistry(deps) {
|
|
|
504
565
|
});
|
|
505
566
|
}
|
|
506
567
|
|
|
568
|
+
/** The Task id owning a tool call raised by a sub-agent, or null. */
|
|
569
|
+
function ownerTaskOfTool(session, toolUseId) {
|
|
570
|
+
if (!toolUseId) return null;
|
|
571
|
+
return ownValue(toolOwners(session), toolUseId) || null;
|
|
572
|
+
}
|
|
573
|
+
|
|
507
574
|
function noteSubagentTool(session, toolUseId, taskId) {
|
|
508
575
|
if (toolUseId && taskId) putOwn(toolOwners(session), toolUseId, taskId);
|
|
509
576
|
}
|
|
@@ -538,16 +605,55 @@ function createPromptRegistry(deps) {
|
|
|
538
605
|
return out;
|
|
539
606
|
}
|
|
540
607
|
|
|
608
|
+
// Who the prompt is from; null for a prompt with no session.
|
|
609
|
+
function labelFor(session, toolUseId) {
|
|
610
|
+
if (!session) return null;
|
|
611
|
+
var agent = sessionReclaim.ownerLabelOfTool(session, { ownerTaskOfTool: ownerTaskOfTool }, toolUseId);
|
|
612
|
+
return promptLabel({ project: getProjectName(), sessionTitle: session.title, agent: agent });
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function labelFields(record) {
|
|
616
|
+
return record && record.label ? { label: record.label } : {};
|
|
617
|
+
}
|
|
618
|
+
|
|
541
619
|
function isGranted(session, toolName, input) {
|
|
542
|
-
return
|
|
620
|
+
return grantKeys.isGranted(session.allowedTools, toolName, input);
|
|
543
621
|
}
|
|
544
622
|
|
|
545
|
-
//
|
|
546
|
-
//
|
|
623
|
+
// Grants only what the call asked for (lib/grant-keys.js). Flushed
|
|
624
|
+
// immediately so the grant survives a daemon restart or a resume that
|
|
625
|
+
// rebuilds the session from disk. Returns whether a grant was stored: a call
|
|
626
|
+
// with no narrow key, or a grant map with no room left in the persisted
|
|
627
|
+
// record, is allowed this once and nothing wider.
|
|
547
628
|
function grant(session, toolName, input) {
|
|
629
|
+
var key = utils.permissionGrantKey(toolName, input);
|
|
630
|
+
if (key === null) return false;
|
|
548
631
|
if (!session.allowedTools) session.allowedTools = Object.create(null);
|
|
549
|
-
|
|
632
|
+
if (!grantKeys.fitsBudget(session.allowedTools, key)) {
|
|
633
|
+
console.warn("[prompt-registry] session grant not stored, the record has no room: " + key.slice(0, 40));
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
putOwn(session.allowedTools, key, true);
|
|
637
|
+
saveSessionFile(session);
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** The session's grants, each described for the operator. */
|
|
642
|
+
function listGrants(session) {
|
|
643
|
+
var map = session && session.allowedTools;
|
|
644
|
+
if (!map) return [];
|
|
645
|
+
return Object.keys(map).filter(function (k) { return grantKeys.isGrantValue(k, map[k]); }).sort().map(grantKeys.describeGrantKey);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Take one grant away; the next call it covered prompts. Persisted at once.
|
|
650
|
+
* @returns {boolean} whether the session held it.
|
|
651
|
+
*/
|
|
652
|
+
function revokeGrant(session, key) {
|
|
653
|
+
if (!session || typeof key !== "string" || !grantKeys.isGrantValue(key, ownValue(session.allowedTools, key))) return false;
|
|
654
|
+
delete session.allowedTools[key];
|
|
550
655
|
saveSessionFile(session);
|
|
656
|
+
return true;
|
|
551
657
|
}
|
|
552
658
|
|
|
553
659
|
// The wire message re-presenting one pending prompt.
|
|
@@ -557,7 +663,7 @@ function createPromptRegistry(deps) {
|
|
|
557
663
|
requestId: requestId,
|
|
558
664
|
kind: entry.kind.name,
|
|
559
665
|
toolUseId: entry.record.toolUseId,
|
|
560
|
-
}, entry.kind.requestFields(entry.record));
|
|
666
|
+
}, labelFields(entry.record), entry.kind.requestFields(entry.record));
|
|
561
667
|
}
|
|
562
668
|
|
|
563
669
|
/** Wire messages re-presenting every pending prompt of a session. */
|
|
@@ -625,13 +731,17 @@ function createPromptRegistry(deps) {
|
|
|
625
731
|
cancelSession: cancelSession,
|
|
626
732
|
shutdown: shutdown,
|
|
627
733
|
noteSubagentTool: noteSubagentTool,
|
|
734
|
+
ownerTaskOfTool: ownerTaskOfTool,
|
|
628
735
|
taskStarted: taskStarted,
|
|
629
736
|
taskEnded: taskEnded,
|
|
630
737
|
isTaskTracked: isTaskTracked,
|
|
631
738
|
taskOwnsPending: taskOwnsPending,
|
|
632
739
|
trackedTaskIds: trackedTaskIds,
|
|
740
|
+
labelFor: labelFor,
|
|
633
741
|
isGranted: isGranted,
|
|
634
742
|
grant: grant,
|
|
743
|
+
listGrants: listGrants,
|
|
744
|
+
revokeGrant: revokeGrant,
|
|
635
745
|
pendingMessages: pendingMessages,
|
|
636
746
|
pendingCount: pendingCount,
|
|
637
747
|
replayAnnotator: replayAnnotator,
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Who or what settled a prompt. The prompt registry (lib/prompt-registry.js)
|
|
4
|
+
// logs a source for every prompt it settles and records the one for an answer
|
|
5
|
+
// in the session history (the prompt_resolved event), so "who allowed this"
|
|
6
|
+
// can be answered after the fact.
|
|
7
|
+
//
|
|
8
|
+
// { kind: "ws", clientId, user } an answer from a browser connection
|
|
9
|
+
// { kind: "push", action, user } an answer from a push notification
|
|
10
|
+
// { kind: "timeout" } the prompt's own timer ran out
|
|
11
|
+
// { kind: "cancel", reason } the scope that owned the prompt ended
|
|
12
|
+
//
|
|
13
|
+
// clientId is a per-connection label made here, not a credential; user is the
|
|
14
|
+
// authenticated user's id, or null in single-user mode. Prompt content never
|
|
15
|
+
// appears in a source.
|
|
16
|
+
|
|
17
|
+
var crypto = require("crypto");
|
|
18
|
+
var { logField } = require("./log-field");
|
|
19
|
+
|
|
20
|
+
function clientIdOf(ws) {
|
|
21
|
+
if (!ws) return null;
|
|
22
|
+
if (!ws._clagenticClientId) ws._clagenticClientId = "c-" + crypto.randomBytes(4).toString("hex");
|
|
23
|
+
return ws._clagenticClientId;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function userIdOf(user) {
|
|
27
|
+
return user && user.id !== undefined && user.id !== null ? String(user.id) : null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function fromWs(ws) {
|
|
31
|
+
return { kind: "ws", clientId: clientIdOf(ws), user: userIdOf(ws && ws._clagenticUser) };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// req is the HTTP request the answer arrived on.
|
|
35
|
+
function fromPush(req, action) {
|
|
36
|
+
return { kind: "push", action: action, user: userIdOf(req && req._clagenticUser) };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fromTimeout() {
|
|
40
|
+
return { kind: "timeout" };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function fromCancel(reason) {
|
|
44
|
+
return { kind: "cancel", reason: reason };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The source as log fields, "source=ws client=c-1a2b user=u1". A cancel's
|
|
48
|
+
// reason is its own field on the settle line, not repeated here.
|
|
49
|
+
function describe(source) {
|
|
50
|
+
if (!source) return "source=unspecified";
|
|
51
|
+
var out = "source=" + logField(source.kind);
|
|
52
|
+
if (source.clientId) out += " client=" + logField(source.clientId);
|
|
53
|
+
if (source.action) out += " action=" + logField(source.action);
|
|
54
|
+
if (source.kind === "ws" || source.kind === "push") out += " user=" + logField(source.user);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
fromWs: fromWs,
|
|
60
|
+
fromPush: fromPush,
|
|
61
|
+
fromTimeout: fromTimeout,
|
|
62
|
+
fromCancel: fromCancel,
|
|
63
|
+
describe: describe,
|
|
64
|
+
clientIdOf: clientIdOf,
|
|
65
|
+
};
|
|
@@ -229,6 +229,36 @@
|
|
|
229
229
|
}
|
|
230
230
|
.diagnostics-actionable-btn .lucide { width: 12px; height: 12px; }
|
|
231
231
|
|
|
232
|
+
/* A diagnostic's message may be several lines (the sessions a restart would end). */
|
|
233
|
+
.diagnostic-multiline { white-space: pre-line; }
|
|
234
|
+
|
|
235
|
+
/* Body of a "newer build installed" offer: both builds and the commits between them. */
|
|
236
|
+
.build-update-detail {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
gap: 3px;
|
|
240
|
+
margin-top: 4px;
|
|
241
|
+
font-size: 11px;
|
|
242
|
+
color: var(--text-secondary);
|
|
243
|
+
overflow-wrap: anywhere;
|
|
244
|
+
}
|
|
245
|
+
.build-update-builds { font-family: var(--font-mono, monospace); }
|
|
246
|
+
.build-update-heading { font-weight: 600; }
|
|
247
|
+
.build-update-commits {
|
|
248
|
+
margin: 0;
|
|
249
|
+
padding-left: 16px;
|
|
250
|
+
max-height: 140px;
|
|
251
|
+
overflow-y: auto;
|
|
252
|
+
}
|
|
253
|
+
.build-update-note { color: var(--text-muted); }
|
|
254
|
+
.diagnostics-actionable-btn.build-update-decline,
|
|
255
|
+
.toast-diagnostic-action-btn.build-update-decline {
|
|
256
|
+
background: transparent;
|
|
257
|
+
color: var(--text-secondary);
|
|
258
|
+
border: 1px solid var(--border, rgba(128, 128, 128, 0.4));
|
|
259
|
+
margin-left: 6px;
|
|
260
|
+
}
|
|
261
|
+
|
|
232
262
|
/* Empty state */
|
|
233
263
|
.diagnostics-empty {
|
|
234
264
|
padding: 20px 14px;
|
|
@@ -136,6 +136,21 @@
|
|
|
136
136
|
letter-spacing: 0.12em;
|
|
137
137
|
margin-bottom: 3px;
|
|
138
138
|
}
|
|
139
|
+
/* Whose prompt this is and what Allow for session grants: wrapped, never
|
|
140
|
+
cut off, because a clipped label is the failure these lines exist to fix. */
|
|
141
|
+
.notif-banner-label {
|
|
142
|
+
font-family: var(--font-mono, monospace);
|
|
143
|
+
font-size: 10.5px;
|
|
144
|
+
color: var(--accent);
|
|
145
|
+
margin-bottom: 3px;
|
|
146
|
+
overflow-wrap: anywhere;
|
|
147
|
+
}
|
|
148
|
+
.notif-banner-scope {
|
|
149
|
+
font-size: 12px;
|
|
150
|
+
color: var(--text-secondary);
|
|
151
|
+
margin-top: 3px;
|
|
152
|
+
overflow-wrap: anywhere;
|
|
153
|
+
}
|
|
139
154
|
.notif-banner-title {
|
|
140
155
|
font-weight: 500;
|
|
141
156
|
font-size: 13px;
|
|
@@ -544,6 +544,24 @@ button.top-bar-pill.pill-accent:hover { background: color-mix(in srgb, var(--acc
|
|
|
544
544
|
|
|
545
545
|
#skill-install-modal.hidden { display: none; }
|
|
546
546
|
|
|
547
|
+
#session-grants-modal {
|
|
548
|
+
position: fixed;
|
|
549
|
+
inset: 0;
|
|
550
|
+
z-index: 300;
|
|
551
|
+
display: flex;
|
|
552
|
+
align-items: center;
|
|
553
|
+
justify-content: center;
|
|
554
|
+
}
|
|
555
|
+
.session-grants-dialog { max-width: 520px; }
|
|
556
|
+
.session-grants-title { font-weight: 600; font-size: 16px; margin-bottom: 12px; color: var(--text); }
|
|
557
|
+
.session-grants-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 50vh; overflow-y: auto; }
|
|
558
|
+
.session-grants-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; background: rgba(var(--overlay-rgb), 0.05); border: 1px solid var(--border); }
|
|
559
|
+
.session-grants-whole { border-color: var(--warning, #f39c12); }
|
|
560
|
+
.session-grants-text { flex: 1; min-width: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
|
|
561
|
+
.session-grants-revoke { flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text); cursor: pointer; padding: 4px 10px; font-size: 12px; }
|
|
562
|
+
.session-grants-revoke:disabled { opacity: 0.5; cursor: default; }
|
|
563
|
+
.session-grants-empty { font-size: 13px; color: var(--text-muted); }
|
|
564
|
+
|
|
547
565
|
.skill-install-dialog { max-width: 460px; padding: 28px 32px; }
|
|
548
566
|
.skill-install-title { font-weight: 600; font-size: 17px; margin-bottom: 8px; color: var(--text); }
|
|
549
567
|
.skill-install-reason { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin-bottom: 18px; }
|
|
@@ -618,6 +618,14 @@
|
|
|
618
618
|
|
|
619
619
|
/* The user's own ask rule that forced the prompt. */
|
|
620
620
|
.permission-rule { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
|
|
621
|
+
.permission-scope { font-size: 12px; color: var(--text-secondary); margin-top: 6px; overflow-wrap: anywhere; }
|
|
622
|
+
.prompt-label {
|
|
623
|
+
font-family: var(--font-mono, monospace);
|
|
624
|
+
font-size: 11px;
|
|
625
|
+
color: var(--accent);
|
|
626
|
+
margin-bottom: 4px;
|
|
627
|
+
overflow-wrap: anywhere;
|
|
628
|
+
}
|
|
621
629
|
|
|
622
630
|
/* An ask that must open on No: the approve choices lose their primary
|
|
623
631
|
styling and the decline choice leads. */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Browser-side copy of lib/agent-dispatch-tool.js (the backend is CJS and the
|
|
2
|
+
// frontend is ESM, so neither can import the other). The claude CLI names the
|
|
3
|
+
// sub-agent dispatch tool "Task" in older builds and "Agent" in current ones;
|
|
4
|
+
// a test asserts both copies accept the same names.
|
|
5
|
+
export var AGENT_DISPATCH_TOOL_NAMES = ["Task", "Agent"];
|
|
6
|
+
|
|
7
|
+
export function isAgentDispatchTool(name) {
|
|
8
|
+
return typeof name === "string" && AGENT_DISPATCH_TOOL_NAMES.indexOf(name) !== -1;
|
|
9
|
+
}
|
|
@@ -65,10 +65,11 @@ import { handleRateLimitEvent, updateRateLimitUsage, addScheduledMessageBubble,
|
|
|
65
65
|
import { handleRemoteCursorMove, handleRemoteCursorLeave, handleRemoteSelection, clearRemoteCursors } from './app-cursors.js';
|
|
66
66
|
import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, updateLoopPendingBanner, showRalphApprovalBar, updateRalphApprovalStatus, openRalphPreviewModal, showExecModal, updateExecModalStatus } from './app-loop-ui.js';
|
|
67
67
|
import { handleSkillInstallWs } from './app-skills-install.js';
|
|
68
|
+
import { handleSessionGrants } from './session-grants.js';
|
|
68
69
|
import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll, showUpdateBanner } from './app-notifications.js';
|
|
69
70
|
import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
|
|
70
71
|
import { handleTeamState, handleTeamMemberUpdate, handleTeamTaskUpdate, handleTeamMessage as handleTeamMsg, handleTeamGone } from './team-panel.js';
|
|
71
|
-
import { addDiagnostic } from './diagnostics.js';
|
|
72
|
+
import { addDiagnostic, refreshDiagnostic, retractDiagnostics } from './diagnostics.js';
|
|
72
73
|
import { handleHistoryMeta, handleHistoryDone } from './app-history-replay.js';
|
|
73
74
|
import { shouldApplyActivityEdge } from './activity-latch.js';
|
|
74
75
|
import { deriveSessionListProcessing } from './activity-state.js';
|
|
@@ -1297,7 +1298,12 @@ registerHandlers({
|
|
|
1297
1298
|
// Diagnostic events from CLI stderr (stage 4/5, lr-8294, epic lr-1a52).
|
|
1298
1299
|
// Future sources (e.g. settings preflight from stage 5/5 lr-1a26) will
|
|
1299
1300
|
// also arrive via this same type — the render path must not assume CLI origin.
|
|
1300
|
-
|
|
1301
|
+
if (msg.refresh === true) refreshDiagnostic(msg);
|
|
1302
|
+
else addDiagnostic(msg);
|
|
1303
|
+
},
|
|
1304
|
+
|
|
1305
|
+
diagnostic_retract: function (msg) {
|
|
1306
|
+
retractDiagnostics(msg.source);
|
|
1301
1307
|
},
|
|
1302
1308
|
|
|
1303
1309
|
daemon_config: function (msg) {
|
|
@@ -1472,6 +1478,8 @@ registerHandlers({
|
|
|
1472
1478
|
addSystemMessage("Error: " + msg.text, true);
|
|
1473
1479
|
},
|
|
1474
1480
|
|
|
1481
|
+
session_grants: handleSessionGrants,
|
|
1482
|
+
|
|
1475
1483
|
// --- Notifications ---
|
|
1476
1484
|
notifications_state: handleNotificationsState,
|
|
1477
1485
|
notification_created: handleNotificationCreated,
|
|
@@ -13,7 +13,8 @@ import { switchProject } from './app-projects.js';
|
|
|
13
13
|
import { userAvatarUrl } from './avatar.js';
|
|
14
14
|
import { openTerminal } from './terminal.js';
|
|
15
15
|
import { askWording } from './prompt-kinds/index.js';
|
|
16
|
-
import { wirePromptBanner, restoreUnconfirmedBanners, bannerActions } from './prompt-banner.js';
|
|
16
|
+
import { wirePromptBanner, restoreUnconfirmedBanners, bannerActions, bannerScope } from './prompt-banner.js';
|
|
17
|
+
import { promptLabelHtml } from './prompt-label.js';
|
|
17
18
|
|
|
18
19
|
// The server dismisses a prompt's banner once the prompt settles, however it
|
|
19
20
|
// was answered.
|
|
@@ -139,12 +140,19 @@ function showBanner(notif, autoDismissMs) {
|
|
|
139
140
|
'</div>';
|
|
140
141
|
}
|
|
141
142
|
|
|
143
|
+
// The server says whose prompt this is (project, session, agent) and what
|
|
144
|
+
// Allow for session would grant: a banner reaches every client whatever
|
|
145
|
+
// project it is viewing, and the tool request alone does not say.
|
|
146
|
+
var scopeText = isPermission ? bannerScope(promptKind, notif.meta) : "";
|
|
147
|
+
|
|
142
148
|
banner.innerHTML =
|
|
143
149
|
'<div class="notif-banner-icon">' + iconHtmlStr + '</div>' +
|
|
144
150
|
'<div class="notif-banner-body">' +
|
|
145
151
|
(projectName ? '<div class="notif-banner-project">' + escapeHtml(projectName) + '</div>' : '') +
|
|
152
|
+
(isPermission ? promptLabelHtml(notif.meta.label) : '') +
|
|
146
153
|
'<div class="notif-banner-title">' + escapeHtml(notif.title) + '</div>' +
|
|
147
154
|
(notif.body ? '<div class="notif-banner-text">' + escapeHtml(notif.body) + '</div>' : '') +
|
|
155
|
+
(scopeText ? '<div class="notif-banner-scope">' + escapeHtml(scopeText) + '</div>' : '') +
|
|
148
156
|
actionsHtml +
|
|
149
157
|
'</div>' +
|
|
150
158
|
(!isEmpty ? '<button class="notif-banner-close">' + iconHtml("x") + '</button>' : '');
|
|
@@ -92,7 +92,6 @@ var EFFORT_LEVELS_BY_VENDOR = {
|
|
|
92
92
|
var THINKING_OPTIONS = ["disabled", "adaptive", "budget"];
|
|
93
93
|
var CODEX_APPROVAL_OPTIONS = [
|
|
94
94
|
{ value: "never", label: "Auto" },
|
|
95
|
-
{ value: "on-failure", label: "On Fail" },
|
|
96
95
|
{ value: "on-request", label: "Ask" },
|
|
97
96
|
];
|
|
98
97
|
var CODEX_SANDBOX_OPTIONS = [
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// build-update-detail.js — the body of a "newer build installed" diagnostic:
|
|
2
|
+
// which build is running, which is installed, and the commits between them
|
|
3
|
+
// when git history was available. Every value is set with textContent: commit
|
|
4
|
+
// subjects are repository content, never markup.
|
|
5
|
+
|
|
6
|
+
var SHORT_SHA_LENGTH = 12;
|
|
7
|
+
|
|
8
|
+
export function shortSha(sha) {
|
|
9
|
+
return typeof sha === 'string' && sha ? sha.slice(0, SHORT_SHA_LENGTH) : '(unknown)';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function line(className, text) {
|
|
13
|
+
var el = document.createElement('div');
|
|
14
|
+
el.className = className;
|
|
15
|
+
el.textContent = text;
|
|
16
|
+
return el;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {{loadedBuildSha: ?string, installedBuildSha: ?string, reason: string,
|
|
21
|
+
* changes: {available: boolean, commits: Array<{sha: string, subject: string}>, truncated: boolean, reason: ?string}}} offer
|
|
22
|
+
* @returns {?HTMLElement} null when the diagnostic carries no offer
|
|
23
|
+
*/
|
|
24
|
+
export function buildUpdateDetailEl(offer) {
|
|
25
|
+
if (!offer || typeof offer !== 'object') return null;
|
|
26
|
+
var root = document.createElement('div');
|
|
27
|
+
root.className = 'build-update-detail';
|
|
28
|
+
|
|
29
|
+
root.appendChild(line('build-update-builds',
|
|
30
|
+
'Running: ' + shortSha(offer.loadedBuildSha) + ' Installed: ' + shortSha(offer.installedBuildSha)));
|
|
31
|
+
|
|
32
|
+
var changes = offer.changes || {};
|
|
33
|
+
if (offer.reason === 'content') {
|
|
34
|
+
root.appendChild(line('build-update-note',
|
|
35
|
+
'Both report the same build, but the installed files differ from the ones this process loaded.'));
|
|
36
|
+
} else if (changes.available && Array.isArray(changes.commits) && changes.commits.length > 0) {
|
|
37
|
+
root.appendChild(line('build-update-heading', 'Changes since the running build:'));
|
|
38
|
+
var list = document.createElement('ul');
|
|
39
|
+
list.className = 'build-update-commits';
|
|
40
|
+
changes.commits.forEach(function (c) {
|
|
41
|
+
var item = document.createElement('li');
|
|
42
|
+
item.textContent = shortSha(c.sha).slice(0, 8) + ' ' + c.subject;
|
|
43
|
+
list.appendChild(item);
|
|
44
|
+
});
|
|
45
|
+
root.appendChild(list);
|
|
46
|
+
if (changes.truncated) root.appendChild(line('build-update-note', 'More commits not shown.'));
|
|
47
|
+
} else if (changes.available) {
|
|
48
|
+
root.appendChild(line('build-update-note', 'No commits between these builds were found in the available history.'));
|
|
49
|
+
} else {
|
|
50
|
+
root.appendChild(line('build-update-note',
|
|
51
|
+
'Change list unavailable' + (changes.reason ? ': ' + changes.reason : '') + '.'));
|
|
52
|
+
}
|
|
53
|
+
return root;
|
|
54
|
+
}
|