@clagentic/console 1.10.0-beta.2 → 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/lib/activity-clock.js +23 -0
- package/lib/build-sha.json +2 -2
- package/lib/cli-transcript-title.js +131 -0
- 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/project-http.js +2 -0
- package/lib/project-notifications.js +4 -0
- package/lib/project-prompt-responses.js +2 -1
- package/lib/project-session-grants.js +73 -0
- package/lib/project-sessions.js +12 -0
- package/lib/project-user-message.js +6 -5
- package/lib/project.js +2 -0
- package/lib/prompt-kinds/permission.js +18 -0
- package/lib/prompt-label.js +60 -0
- package/lib/prompt-registry.js +116 -13
- package/lib/prompt-source.js +65 -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/app-messages.js +3 -0
- package/lib/public/modules/app-notifications.js +9 -1
- 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/runtime-env.js +1 -1
- package/lib/sdk-bridge.js +53 -101
- package/lib/sdk-message-processor.js +14 -67
- package/lib/session-ai-title.js +80 -0
- package/lib/session-input.js +32 -2
- package/lib/sessions.js +14 -18
- package/lib/utils.js +9 -47
- package/lib/ws-schema.js +6 -3
- package/lib/yoke/adapters/claude.js +0 -57
- package/lib/yoke/adapters/codex.js +4 -75
- package/lib/yoke/interface.js +3 -7
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// session-ai-title.js - gives a session the title its vendor CLI wrote for it.
|
|
2
|
+
//
|
|
3
|
+
// The console never asks a model for a title. The Claude Code CLI titles each
|
|
4
|
+
// session itself and records it in the session's transcript
|
|
5
|
+
// (cli-transcript-title.js); this module copies the latest such title onto the
|
|
6
|
+
// console session, which is the one place every surface (the picker, prompt
|
|
7
|
+
// cards, banners and push, the restart interrupt list, CLI listings) reads a
|
|
8
|
+
// title from.
|
|
9
|
+
//
|
|
10
|
+
// Precedence: a title the operator set by rename always wins; otherwise the
|
|
11
|
+
// CLI's title replaces whatever the first-line fallback put there; a session
|
|
12
|
+
// whose transcript holds no title keeps the first-line title.
|
|
13
|
+
|
|
14
|
+
var path = require("path");
|
|
15
|
+
var transcriptTitle = require("./cli-transcript-title");
|
|
16
|
+
var runtimeEnv = require("./runtime-env");
|
|
17
|
+
|
|
18
|
+
// Vendors whose sessions have a Claude Code transcript. Another vendor's
|
|
19
|
+
// thread id names no transcript here, so it is never looked up.
|
|
20
|
+
function hasCliTranscript(session) {
|
|
21
|
+
return !session.vendor || session.vendor === "claude";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// deps: {
|
|
25
|
+
// sm session manager (saveSessionFile, broadcastSessionList)
|
|
26
|
+
// cwd the project directory
|
|
27
|
+
// resolveHome(session) the session owner's home, or null for the daemon's own
|
|
28
|
+
// daemonHome the daemon user's home
|
|
29
|
+
// getRuntimeEnvOverlay?(session) the Settings variables the session's Claude
|
|
30
|
+
// process was started with, or null
|
|
31
|
+
// claudeDir? overrides the transcript root (tests)
|
|
32
|
+
// }
|
|
33
|
+
// Returns refresh(session): Promise<boolean>, true when the title changed.
|
|
34
|
+
function createAiTitleRefresher(deps) {
|
|
35
|
+
var sm = deps.sm;
|
|
36
|
+
|
|
37
|
+
// The CLAUDE_CONFIG_DIR the session's process was given by Settings. Read
|
|
38
|
+
// through composeRuntimeEnv so a name the runtime drops is dropped here too.
|
|
39
|
+
function overlayConfigDir(session) {
|
|
40
|
+
var overlay = deps.getRuntimeEnvOverlay ? deps.getRuntimeEnvOverlay(session) : null;
|
|
41
|
+
if (!overlay) return null;
|
|
42
|
+
var dir = runtimeEnv.composeRuntimeEnv({}, overlay).CLAUDE_CONFIG_DIR;
|
|
43
|
+
return dir || null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Same order the session's process resolves its config: Settings overlay,
|
|
47
|
+
// then the owner's home, then the daemon's own variable and home.
|
|
48
|
+
function claudeDirFor(session) {
|
|
49
|
+
if (deps.claudeDir) return deps.claudeDir;
|
|
50
|
+
var overlayDir = overlayConfigDir(session);
|
|
51
|
+
if (overlayDir) return overlayDir;
|
|
52
|
+
var ownerHome = deps.resolveHome ? deps.resolveHome(session) : null;
|
|
53
|
+
if (ownerHome) return path.join(ownerHome, ".claude");
|
|
54
|
+
return process.env.CLAUDE_CONFIG_DIR || path.join(deps.daemonHome, ".claude");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return function refresh(session) {
|
|
58
|
+
if (!session || !session.cliSessionId || session.titleManuallySet) return Promise.resolve(false);
|
|
59
|
+
if (!hasCliTranscript(session)) return Promise.resolve(false);
|
|
60
|
+
var sessionId = session.cliSessionId;
|
|
61
|
+
return transcriptTitle.findTranscript(claudeDirFor(session), [session.cwd, deps.cwd], sessionId)
|
|
62
|
+
.then(function (file) { return file ? transcriptTitle.readLatestAiTitle(file, sessionId) : null; })
|
|
63
|
+
.then(function (title) {
|
|
64
|
+
// Re-checked after the read: a rename can land while the file is read.
|
|
65
|
+
if (!title || session.titleManuallySet || session.title === title) return false;
|
|
66
|
+
session.title = title;
|
|
67
|
+
session.titleAutoGenerated = true;
|
|
68
|
+
session.titleProvisional = false;
|
|
69
|
+
sm.saveSessionFile(session);
|
|
70
|
+
sm.broadcastSessionList();
|
|
71
|
+
return true;
|
|
72
|
+
})
|
|
73
|
+
.catch(function (e) {
|
|
74
|
+
console.error("[ai-title] could not read the session title:", e && e.message ? e.message : e);
|
|
75
|
+
return false;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = { createAiTitleRefresher: createAiTitleRefresher };
|
package/lib/session-input.js
CHANGED
|
@@ -17,6 +17,7 @@ var { isKnownVendor } = require("./yoke");
|
|
|
17
17
|
var { getNewWorkRefusal } = require("./new-work-gate");
|
|
18
18
|
var agentsModule = require("./agents");
|
|
19
19
|
var sessionResume = require("./session-resume");
|
|
20
|
+
var { logField, logText } = require("./log-field");
|
|
20
21
|
|
|
21
22
|
// The result vocabulary reported to the caller. "error" is not a verdict on
|
|
22
23
|
// the request: delivery was attempted and failed, so a caller may retry.
|
|
@@ -128,6 +129,33 @@ function neverThrows(fn) {
|
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
// One line per request, whichever caller made it (IPC verb or file drop): the
|
|
133
|
+
// project, the console session and the result, with the reason when the
|
|
134
|
+
// request was refused or failed. The prompt, the context note and the request
|
|
135
|
+
// body are never part of it; a reason only quotes a bounded identifier.
|
|
136
|
+
function logResult(verb, req, out) {
|
|
137
|
+
req = req || {};
|
|
138
|
+
out = out || {};
|
|
139
|
+
var line = "[session-input] " + verb + ": project=" + logField(req.projectSlug)
|
|
140
|
+
+ " session=" + logField(out.consoleSessionId || req.sessionId)
|
|
141
|
+
+ " result=" + logField(out.result);
|
|
142
|
+
if (out.retryable === true) line += " retryable=true";
|
|
143
|
+
// Last, because it is free text.
|
|
144
|
+
if (out.reason) line += " reason=" + logText(out.reason);
|
|
145
|
+
console.log(line);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function logged(verb, fn) {
|
|
149
|
+
return function (req) {
|
|
150
|
+
var out = fn(req);
|
|
151
|
+
if (out && typeof out.then === "function") {
|
|
152
|
+
return out.then(function (result) { logResult(verb, req, result); return result; });
|
|
153
|
+
}
|
|
154
|
+
logResult(verb, req, out);
|
|
155
|
+
return out;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
131
159
|
// deps:
|
|
132
160
|
// getProject(slug) -> project context | null
|
|
133
161
|
// agentCatalog(project) -> [{ name }] named agents on offer (default: the picker's catalog)
|
|
@@ -354,12 +382,14 @@ function createSessionInput(deps) {
|
|
|
354
382
|
// Recorded once, only now that the query has started: a rejected start
|
|
355
383
|
// leaves no history entry for a prompt that never ran.
|
|
356
384
|
recordInjected(project, sess, req, init.initiator);
|
|
357
|
-
console.log("[session-input] session opened: project=" + req.projectSlug + " session=" + sess.localId);
|
|
358
385
|
return opened();
|
|
359
386
|
}, openStartFailure);
|
|
360
387
|
}
|
|
361
388
|
|
|
362
|
-
return {
|
|
389
|
+
return {
|
|
390
|
+
openSession: logged("open_session", neverThrows(openSession)),
|
|
391
|
+
sendInput: logged("send_session_input", neverThrows(sendInput)),
|
|
392
|
+
};
|
|
363
393
|
}
|
|
364
394
|
|
|
365
395
|
// sendInput and openSession answer synchronously when nothing has to wait and
|
package/lib/sessions.js
CHANGED
|
@@ -7,6 +7,7 @@ var users = require("./users");
|
|
|
7
7
|
var { CODEX_DEFAULTS } = require("./codex-defaults");
|
|
8
8
|
var { isVisibleHistoryEvent } = require("./history-visibility");
|
|
9
9
|
var { createPromptRegistry } = require("./prompt-registry");
|
|
10
|
+
var { registerExitFlush } = require("./exit-flush");
|
|
10
11
|
var sessionReclaim = require("./session-reclaim");
|
|
11
12
|
|
|
12
13
|
// lr-2ea2a7: hard cap on how many history entries a session may hold in the
|
|
@@ -110,6 +111,8 @@ function createSessionManager(opts) {
|
|
|
110
111
|
saveSessionFile: function (session) { return saveSessionFile(session); },
|
|
111
112
|
getNotificationsModule: opts.getNotificationsModule,
|
|
112
113
|
onProcessingChanged: opts.onProcessingChanged,
|
|
114
|
+
getProjectName: opts.getProjectName,
|
|
115
|
+
getProjectSlug: opts.getProjectSlug,
|
|
113
116
|
});
|
|
114
117
|
var capabilitiesByVendor = null; // set by sdk-bridge after adapter init
|
|
115
118
|
var defaultVendor = null; // set by sdk-bridge
|
|
@@ -170,18 +173,11 @@ function createSessionManager(opts) {
|
|
|
170
173
|
var resumeAgents = sessionReclaim.sanitizeAgentLabels(session.pendingAutoResumeAgents);
|
|
171
174
|
if (resumeAgents) metaObj.pendingAutoResumeAgents = resumeAgents;
|
|
172
175
|
}
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
// at sdk-message-processor.js and sdk-bridge.js were guarding against
|
|
177
|
-
// state that could never actually be true after a restart. turnCount is
|
|
178
|
-
// persisted alongside them because the turn-threshold gate (see the
|
|
179
|
-
// '>=' fix at sdk-message-processor.js) depends on it surviving too —
|
|
180
|
-
// a restarted session that lost its turn count would silently miss the
|
|
181
|
-
// auto-title window forever instead of catching up on a later turn.
|
|
176
|
+
// Durable title state: titleManuallySet (the operator renamed the session,
|
|
177
|
+
// which always wins) and titleAutoGenerated (the title is the CLI's own,
|
|
178
|
+
// see session-ai-title.js) must survive a daemon restart.
|
|
182
179
|
// titleProvisional marks a title set from the raw first-message
|
|
183
|
-
// truncation (project-user-message.js)
|
|
184
|
-
// safe to overwrite even though the flags above look "not yet set".
|
|
180
|
+
// truncation (project-user-message.js).
|
|
185
181
|
if (session.titleAutoGenerated) metaObj.titleAutoGenerated = true;
|
|
186
182
|
if (session.titleManuallySet) metaObj.titleManuallySet = true;
|
|
187
183
|
if (session.titleProvisional) metaObj.titleProvisional = true;
|
|
@@ -797,14 +793,15 @@ function createSessionManager(opts) {
|
|
|
797
793
|
|
|
798
794
|
// Drain all write buffers synchronously on process exit to prevent trailing
|
|
799
795
|
// event loss when the daemon shuts down cleanly.
|
|
800
|
-
//
|
|
801
|
-
//
|
|
796
|
+
// Registered with the shared exit flusher, not as a listener of its own:
|
|
797
|
+
// one process listener per project tripped the MaxListeners warning at
|
|
798
|
+
// startup. sm.destroy() unregisters it when the project is torn down.
|
|
802
799
|
function _onProcessExit() {
|
|
803
800
|
sessions.forEach(function(session) {
|
|
804
801
|
flushSessionBuffer(session);
|
|
805
802
|
});
|
|
806
803
|
}
|
|
807
|
-
|
|
804
|
+
var unregisterExitFlush = registerExitFlush(_onProcessExit);
|
|
808
805
|
|
|
809
806
|
function getActiveSession() {
|
|
810
807
|
return sessions.get(activeSessionId) || null;
|
|
@@ -1834,13 +1831,12 @@ function createSessionManager(opts) {
|
|
|
1834
1831
|
effectiveSessionModel: function (session) { return effectiveSessionModel(session, _instance); },
|
|
1835
1832
|
// Called when the project owning this session manager is torn down. No
|
|
1836
1833
|
// prompt resolver outlives it, so every pending prompt ends here and its
|
|
1837
|
-
// outcome is flushed to disk; then the
|
|
1838
|
-
//
|
|
1839
|
-
// project open/close cycles.
|
|
1834
|
+
// outcome is flushed to disk; then the exit flusher registered above is
|
|
1835
|
+
// unregistered so nothing accumulates across project open/close cycles.
|
|
1840
1836
|
destroy: function() {
|
|
1841
1837
|
prompts.shutdown();
|
|
1842
1838
|
_onProcessExit();
|
|
1843
|
-
|
|
1839
|
+
unregisterExitFlush();
|
|
1844
1840
|
},
|
|
1845
1841
|
};
|
|
1846
1842
|
_instance.prompts = prompts;
|
package/lib/utils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var fs = require("fs");
|
|
6
|
+
var grantKeys = require("./grant-keys");
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Encode a cwd path into a filesystem-safe directory/file name.
|
|
@@ -66,64 +67,25 @@ function resolveEncodedFile(baseDir, cwd, ext) {
|
|
|
66
67
|
* handleCanUseTool check (lib/sdk-bridge.js:691).
|
|
67
68
|
*
|
|
68
69
|
* Keeps only entries whose key is a string and whose value is strictly
|
|
69
|
-
* boolean `true
|
|
70
|
+
* boolean `true` and not scoped to a file (a persisted Write:<path> key is
|
|
71
|
+
* dropped: file tools never hold a session grant); drops everything else. A non-object input (including
|
|
70
72
|
* null/undefined/arrays) yields an empty map rather than throwing. The map
|
|
71
73
|
* has no prototype: its keys are tool names, and a name like "constructor"
|
|
72
|
-
* must not be found as an inherited entry.
|
|
74
|
+
* must not be found as an inherited entry. A key longer than a grant can be,
|
|
75
|
+
* or beyond the number a session record has room for, is dropped: grants are
|
|
76
|
+
* persisted in a bounded part of the meta record (lib/grant-keys.js).
|
|
73
77
|
*/
|
|
74
78
|
function sanitizeAllowedTools(value) {
|
|
75
79
|
var out = Object.create(null);
|
|
76
80
|
if (!value || typeof value !== "object" || Array.isArray(value)) return out;
|
|
77
81
|
for (var key in value) {
|
|
78
82
|
if (!Object.prototype.hasOwnProperty.call(value, key)) continue;
|
|
79
|
-
if (typeof key === "string" &&
|
|
83
|
+
if (typeof key === "string" && key.length <= grantKeys.MAX_KEY_LENGTH && grantKeys.isGrantValue(key, value[key])
|
|
84
|
+
&& Object.keys(out).length < grantKeys.MAX_GRANTS) out[key] = value[key];
|
|
80
85
|
}
|
|
81
86
|
return out;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
/**
|
|
85
|
-
* Compute the key used to index a session's "allow for session" grant map
|
|
86
|
-
* (session.allowedTools) for a given tool call (lr-f969dc).
|
|
87
|
-
*
|
|
88
|
-
* Most tools are correctly discriminated by bare tool name alone — MCP tools
|
|
89
|
-
* already fold server + tool identity into the name itself (e.g.
|
|
90
|
-
* "mcp__browser__navigate" vs "mcp__browser__screenshot" are already
|
|
91
|
-
* distinct keys), so approving one MCP tool must not silently approve a
|
|
92
|
-
* different one, and bare-name keying already gives that.
|
|
93
|
-
*
|
|
94
|
-
* The Claude `Skill` tool is the one exception found so far: every distinct
|
|
95
|
-
* skill invocation arrives as the SAME toolName "Skill" with a different
|
|
96
|
-
* `input.skill` discriminator. Keying on bare "Skill" means granting one
|
|
97
|
-
* skill silently authorizes every other skill for the rest of the session —
|
|
98
|
-
* a security regression, not the "doesn't stick" fix the grant was meant to
|
|
99
|
-
* provide. Fold the discriminator into the key so a grant is scoped to the
|
|
100
|
-
* specific skill that was actually approved.
|
|
101
|
-
*
|
|
102
|
-
* This repo is vendor-agnostic via the YOKE adapter layer (lib/yoke/), so a
|
|
103
|
-
* bare "Skill" literal here is a deliberate, checked exception, not a
|
|
104
|
-
* default pattern for future tools. Verified (lr-f969dc): Codex's approval
|
|
105
|
-
* RPCs (exec/file/MCP, lib/yoke/adapters/codex.js) route through this same
|
|
106
|
-
* function via the identical vendor-neutral canUseTool wiring, and all of
|
|
107
|
-
* them already send correctly-flat tool names — Codex has no tool today
|
|
108
|
-
* whose identity fans out under one shared name the way Skill does, so no
|
|
109
|
-
* generalization is needed for vendor parity right now. If a second vendor
|
|
110
|
-
* or a renamed/restructured tool introduces another input-discriminated
|
|
111
|
-
* tool, extend this with another explicit branch (or a small declarative
|
|
112
|
-
* toolName -> discriminator-field table if a third case appears) rather
|
|
113
|
-
* than reaching for a config knob nobody would otherwise set.
|
|
114
|
-
*
|
|
115
|
-
* Falls back to the bare tool name when the expected discriminator is
|
|
116
|
-
* missing or not a string (fails closed to the pre-existing per-tool grant
|
|
117
|
-
* rather than throwing or producing an unstable key). Never hardcodes an
|
|
118
|
-
* individual skill name — only the shared "Skill" tool identifier.
|
|
119
|
-
*/
|
|
120
|
-
function permissionGrantKey(toolName, input) {
|
|
121
|
-
if (toolName === "Skill" && input && typeof input.skill === "string" && input.skill) {
|
|
122
|
-
return "Skill:" + input.skill;
|
|
123
|
-
}
|
|
124
|
-
return toolName;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
89
|
/**
|
|
128
90
|
* Default hard cap for readCappedBody() call sites that don't pass their own
|
|
129
91
|
* maxBytes: these are small JSON-only pre-auth endpoints (login, PIN
|
|
@@ -183,7 +145,7 @@ module.exports = {
|
|
|
183
145
|
resolveEncodedDir: resolveEncodedDir,
|
|
184
146
|
resolveEncodedFile: resolveEncodedFile,
|
|
185
147
|
sanitizeAllowedTools: sanitizeAllowedTools,
|
|
186
|
-
permissionGrantKey: permissionGrantKey,
|
|
148
|
+
permissionGrantKey: grantKeys.permissionGrantKey,
|
|
187
149
|
readCappedBody: readCappedBody,
|
|
188
150
|
DEFAULT_BODY_CAP_BYTES: DEFAULT_BODY_CAP_BYTES,
|
|
189
151
|
};
|
package/lib/ws-schema.js
CHANGED
|
@@ -122,10 +122,10 @@ var schema = {
|
|
|
122
122
|
// suppressAlwaysAllowRule, defaultToNo, matchedAskRule; ask_user: input; elicitation: serverName,
|
|
123
123
|
// message, mode, url, elicitationId, requestedSchema).
|
|
124
124
|
// -----------------------------------------------------------------------
|
|
125
|
-
"prompt_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt awaits the operator: {requestId, kind, toolUseId, ...kind fields}. On history replay it carries promptState {state: pending|resolved|cancelled, decision|answers|skipped|action, reason}, the server's authoritative state for the prompt at replay time" },
|
|
125
|
+
"prompt_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt awaits the operator: {requestId, kind, toolUseId, label: {project, session, agent}, ...kind fields} (label names whose prompt it is; agent is empty unless a background agent raised it; a permission prompt also carries grantScope, the sentence saying what Allow for Session would grant, or null when it cannot be granted). On history replay it carries promptState {state: pending|resolved|cancelled, decision|answers|skipped|action, reason}, the server's authoritative state for the prompt at replay time" },
|
|
126
126
|
"prompt_pending": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt still awaiting the operator, re-presented on connect and session switch; same fields as prompt_request" },
|
|
127
|
-
"prompt_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "The operator's answer: {requestId, kind, ...} with decision (+ feedback, planContent) for permission/plan, answers or decision:\"skip\" for ask_user (answers keyed by question index; each a label or text, or for a multi-select question the list of chosen labels), action (+ content, held to the requested schema) for elicitation. The kind is required and must match the prompt's. Decision allow_always to a permission prompt that carries suppressAlwaysAllowRule settles nothing: the prompt is sent again as prompt_pending. A prompt of the extension kind is never answered this way" },
|
|
128
|
-
"prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action}; a permission prompt forced by a user ask rule also carries matchedAskRule" },
|
|
127
|
+
"prompt_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "The operator's answer: {requestId, kind, ...} with decision (+ feedback, planContent) for permission/plan, answers or decision:\"skip\" for ask_user (answers keyed by question index; each a label or text, or for a multi-select question the list of chosen labels), action (+ content, held to the requested schema) for elicitation. The kind is required and must match the prompt's. Decision allow_always grants only what the prompt's grantScope says, and to a permission prompt that carries suppressAlwaysAllowRule, or whose grantScope is null (nothing narrow enough to grant), settles nothing: the prompt is sent again as prompt_pending. A prompt of the extension kind is never answered this way" },
|
|
128
|
+
"prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action, source?}; a permission prompt forced by a user ask rule also carries matchedAskRule. source says who answered, as {kind:\"ws\", clientId, user} for a browser connection (clientId is a per-connection label, user the user id or null) or {kind:\"push\", action, user} for a push notification answer; it is absent when the answering path named none. The same source is written to the journal line the settle logs. Prompt content is never part of a source" },
|
|
129
129
|
"prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown. Reason \"stale\" is sent only to a client whose prompt_response named a prompt the server no longer holds, and is not recorded in history" },
|
|
130
130
|
|
|
131
131
|
// Aliases kept for compatibility: the s2c types appear in history recorded
|
|
@@ -134,6 +134,9 @@ var schema = {
|
|
|
134
134
|
// before an upgrade. Nothing records or sends the s2c aliases any more,
|
|
135
135
|
// except permission_cancel {reason: "stale"} in reply to a
|
|
136
136
|
// permission_response.
|
|
137
|
+
"list_session_grants": { direction: "c2s", handler: "lib/project-session-grants.js", description: "Ask for a session's Allow for Session grants: {sessionId?} (the connection's own session when absent). Answered with session_grants to the asker; refused silently for a session the user may not see" },
|
|
138
|
+
"revoke_session_grant": { direction: "c2s", handler: "lib/project-session-grants.js", description: "Revoke one Allow for Session grant: {sessionId?, key}. Persisted at once and in force on the session's next tool call; every client viewing the session gets the resulting session_grants. Authorized by mayAnswerPrompt (lib/prompt-access.js), the rule that lets a user answer the session's prompts. For a session that rule refuses, the asker alone gets session_grants with an error string and no grants" },
|
|
139
|
+
"session_grants": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A session's grants as {sessionId, grants: [{key, tool, wholeTool, text}]}; wholeTool marks a grant that covers every call of the tool (older sessions). A refused revoke is {sessionId, error} with no grants" },
|
|
137
140
|
"permission_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_request (kind permission or plan); history carries permissionState or promptState" },
|
|
138
141
|
"permission_request_pending": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Alias of prompt_pending (kind permission or plan)" },
|
|
139
142
|
"permission_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "Alias of prompt_response for kinds permission and plan: {requestId, decision, feedback, planContent}" },
|
|
@@ -1657,63 +1657,6 @@ function createClaudeAdapter(opts) {
|
|
|
1657
1657
|
return createQueryHandle(rawQuery, mq, ac);
|
|
1658
1658
|
},
|
|
1659
1659
|
|
|
1660
|
-
// --- Title generation ---
|
|
1661
|
-
generateTitle: async function(messages, opts) {
|
|
1662
|
-
console.log("[auto-title/claude] generateTitle called with " + messages.length + " messages");
|
|
1663
|
-
var systemPrompt = "You are a title generator. Output only a short title (3-8 words). No quotes, no punctuation at the end, no explanation.";
|
|
1664
|
-
var prompt = "Below is a conversation between a user and an AI assistant. Generate a short, descriptive title (3-8 words) that captures the main topic. Reply with ONLY the title, nothing else.\n\n";
|
|
1665
|
-
for (var i = 0; i < messages.length; i++) {
|
|
1666
|
-
prompt += "User message " + (i + 1) + ": " + messages[i] + "\n";
|
|
1667
|
-
}
|
|
1668
|
-
var ac = new AbortController();
|
|
1669
|
-
console.log("[auto-title/claude] Creating query with model=haiku...");
|
|
1670
|
-
var handle = await adapter.createQuery({
|
|
1671
|
-
cwd: (opts && opts.cwd) || _cwd,
|
|
1672
|
-
systemPrompt: systemPrompt,
|
|
1673
|
-
model: "haiku",
|
|
1674
|
-
adapterOptions: {
|
|
1675
|
-
CLAUDE: {
|
|
1676
|
-
settingSources: ["user"],
|
|
1677
|
-
// A title needs no tool. bypassPermissions makes the SDK pass
|
|
1678
|
-
// --dangerously-skip-permissions, which the CLI refuses under
|
|
1679
|
-
// root, so every title failed there; dontAsk denies anything
|
|
1680
|
-
// not pre-approved and starts the same under any uid.
|
|
1681
|
-
permissionMode: "dontAsk",
|
|
1682
|
-
}
|
|
1683
|
-
},
|
|
1684
|
-
abortController: ac,
|
|
1685
|
-
runtimeEnv: opts && opts.runtimeEnv,
|
|
1686
|
-
});
|
|
1687
|
-
console.log("[auto-title/claude] Query created, pushing message...");
|
|
1688
|
-
handle.pushMessage(prompt);
|
|
1689
|
-
var title = "";
|
|
1690
|
-
var streamed = false;
|
|
1691
|
-
try {
|
|
1692
|
-
for await (var msg of handle) {
|
|
1693
|
-
if (msg.yokeType === "text_delta" && msg.text) {
|
|
1694
|
-
streamed = true;
|
|
1695
|
-
title += msg.text;
|
|
1696
|
-
} else if (msg.yokeType === "message" && msg.messageRole === "assistant" && !streamed && msg.content) {
|
|
1697
|
-
// Fallback: extract text from non-streamed message content
|
|
1698
|
-
var content = msg.content;
|
|
1699
|
-
if (Array.isArray(content)) {
|
|
1700
|
-
for (var ci = 0; ci < content.length; ci++) {
|
|
1701
|
-
if (content[ci].type === "text" && content[ci].text) {
|
|
1702
|
-
title += content[ci].text;
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
} else if (msg.yokeType === "result") {
|
|
1707
|
-
break;
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
} finally {
|
|
1711
|
-
handle.close();
|
|
1712
|
-
}
|
|
1713
|
-
console.log("[auto-title/claude] Generated: " + title.substring(0, 80));
|
|
1714
|
-
return title.replace(/[\r\n]+/g, " ").replace(/^["'\s]+|["'\s.]+$/g, "").trim();
|
|
1715
|
-
},
|
|
1716
|
-
|
|
1717
1660
|
// --- Session management ---
|
|
1718
1661
|
// These delegate to SDK module-level functions.
|
|
1719
1662
|
|
|
@@ -633,27 +633,6 @@ function _test_resolveModel(queryOpts) {
|
|
|
633
633
|
return queryOpts.model || queryOpts.defaultModel || "gpt-5.5";
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
-
// Selects the model used for background title generation.
|
|
637
|
-
//
|
|
638
|
-
// The live "model/list" RPC's Model objects (see the model/list handler
|
|
639
|
-
// below, and the shape of an instance's models) carry no cost-tier field — only
|
|
640
|
-
// value/displayName/supportedEffortLevels/isLatest ("isLatest" means "not
|
|
641
|
-
// superseded by an upgrade", not "cheap"). There is no robust signal in the
|
|
642
|
-
// live catalog to identify a mini/small-tier model, and this codebase does
|
|
643
|
-
// not substring-match displayName/value for a tier (that class of fragile
|
|
644
|
-
// string matching was deliberately removed elsewhere — see the Context
|
|
645
|
-
// meter section of docs/guides/architecture.md).
|
|
646
|
-
//
|
|
647
|
-
// So titling — a trivial 3-8 word job — falls back to the server's default
|
|
648
|
-
// model, the adapter's only non-staling model identifier (refreshed from the live
|
|
649
|
-
// model/list response). This is a deliberate cost/staleness tradeoff: every
|
|
650
|
-
// auto-title now runs on the user's main model instead of a cheaper
|
|
651
|
-
// mini-tier one, in exchange for auto-titling never breaking silently when
|
|
652
|
-
// OpenAI retires a pinned mini snapshot. See PR body for the reasoning.
|
|
653
|
-
function resolveTitleModel(defaultModel) {
|
|
654
|
-
return defaultModel || "gpt-5.5";
|
|
655
|
-
}
|
|
656
|
-
|
|
657
636
|
function createCodexQueryHandle(appServer, queryOpts) {
|
|
658
637
|
var abortController = queryOpts.abortController;
|
|
659
638
|
var systemPrompt = queryOpts.systemPrompt || "";
|
|
@@ -886,9 +865,10 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
886
865
|
if (isAllowAll()) {
|
|
887
866
|
appServer.respond(msg.id, { decision: "accept" });
|
|
888
867
|
} else if (canUseTool) {
|
|
889
|
-
var
|
|
868
|
+
var fcChanges = Array.isArray(fcParams.changes) ? fcParams.changes : [];
|
|
869
|
+
var changeInfo = fcChanges.map(function(c) { return c.kind + " " + c.path; }).join(", ");
|
|
890
870
|
awaitApproval(msg.id, function (signal) {
|
|
891
|
-
return canUseTool("Edit", { changes: changeInfo
|
|
871
|
+
return canUseTool("Edit", { changes: changeInfo }, { signal: signal });
|
|
892
872
|
}, function (decision) {
|
|
893
873
|
appServer.respond(msg.id, { decision: isApproved(decision) ? "accept" : "decline" });
|
|
894
874
|
}, function (err) {
|
|
@@ -1056,7 +1036,7 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1056
1036
|
if (threadResult && threadResult.thread) {
|
|
1057
1037
|
state.threadId = threadResult.thread.id;
|
|
1058
1038
|
// Narrow the handler to only receive events for this thread so other
|
|
1059
|
-
// concurrent queries
|
|
1039
|
+
// concurrent queries are not routed to us.
|
|
1060
1040
|
appServer.updateHandlerThreadId(_handlerEntry, state.threadId);
|
|
1061
1041
|
}
|
|
1062
1042
|
|
|
@@ -2138,53 +2118,6 @@ function createCodexAdapter(opts) {
|
|
|
2138
2118
|
return handle;
|
|
2139
2119
|
},
|
|
2140
2120
|
|
|
2141
|
-
// --- Title generation ---
|
|
2142
|
-
generateTitle: async function(messages, opts) {
|
|
2143
|
-
var systemPrompt = "You are a title generator. Output only a short title (3-8 words). No quotes, no punctuation at the end, no explanation.";
|
|
2144
|
-
var prompt = "Below is a conversation between a user and an AI assistant. Generate a short, descriptive title (3-8 words) that captures the main topic. Reply with ONLY the title, nothing else.\n\n";
|
|
2145
|
-
for (var i = 0; i < messages.length; i++) {
|
|
2146
|
-
prompt += "User message " + (i + 1) + ": " + messages[i] + "\n";
|
|
2147
|
-
}
|
|
2148
|
-
var ac = new AbortController();
|
|
2149
|
-
// The title is generated on the server of the caller's environment, and
|
|
2150
|
-
// with that server's own default model.
|
|
2151
|
-
var envOpts = { runtimeEnv: opts && opts.runtimeEnv };
|
|
2152
|
-
var titleInst = await acquireInstance(envOpts, fingerprintFor(envOpts, "generateTitle"));
|
|
2153
|
-
var handle = await adapter.createQuery({
|
|
2154
|
-
cwd: (opts && opts.cwd) || _cwd,
|
|
2155
|
-
systemPrompt: systemPrompt,
|
|
2156
|
-
model: resolveTitleModel(titleInst.defaultModel),
|
|
2157
|
-
abortController: ac,
|
|
2158
|
-
canUseTool: function() { return Promise.resolve({ behavior: "deny", message: "No tools." }); },
|
|
2159
|
-
runtimeEnv: envOpts.runtimeEnv,
|
|
2160
|
-
});
|
|
2161
|
-
handle.pushMessage(prompt);
|
|
2162
|
-
var title = "";
|
|
2163
|
-
var streamed = false;
|
|
2164
|
-
try {
|
|
2165
|
-
for await (var msg of handle) {
|
|
2166
|
-
if (msg.yokeType === "text_delta" && msg.text) {
|
|
2167
|
-
streamed = true;
|
|
2168
|
-
title += msg.text;
|
|
2169
|
-
} else if (msg.yokeType === "message" && msg.messageRole === "assistant" && !streamed && msg.content) {
|
|
2170
|
-
var content = msg.content;
|
|
2171
|
-
if (Array.isArray(content)) {
|
|
2172
|
-
for (var ci = 0; ci < content.length; ci++) {
|
|
2173
|
-
if (content[ci].type === "text" && content[ci].text) {
|
|
2174
|
-
title += content[ci].text;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
} else if (msg.yokeType === "result") {
|
|
2179
|
-
break;
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
} finally {
|
|
2183
|
-
handle.close();
|
|
2184
|
-
}
|
|
2185
|
-
return title.replace(/[\r\n]+/g, " ").replace(/^["'\s]+|["'\s.]+$/g, "").trim();
|
|
2186
|
-
},
|
|
2187
|
-
|
|
2188
2121
|
// Codex has session persistence via thread IDs
|
|
2189
2122
|
getSessionInfo: function(sessionId) {
|
|
2190
2123
|
return Promise.resolve(null);
|
|
@@ -2240,10 +2173,6 @@ function createCodexAdapter(opts) {
|
|
|
2240
2173
|
module.exports = {
|
|
2241
2174
|
createCodexAdapter: createCodexAdapter,
|
|
2242
2175
|
_test_resolveModel: _test_resolveModel,
|
|
2243
|
-
// Exported so tests exercise the real title-generation model selection
|
|
2244
|
-
// (including the catalog-unavailable fallback) rather than reimplementing
|
|
2245
|
-
// a copy of it.
|
|
2246
|
-
_test_resolveTitleModel: resolveTitleModel,
|
|
2247
2176
|
// lr-f7a4 — exported so tests can drive the real approval-routing and
|
|
2248
2177
|
// setToolPolicy logic against a fake appServer, rather than reimplementing
|
|
2249
2178
|
// a copy of handleServerEvent's approval branches inline.
|
package/lib/yoke/interface.js
CHANGED
|
@@ -69,11 +69,9 @@ var TOOL_POLICIES = ["ask", "allow-all"];
|
|
|
69
69
|
* .createToolServer(def): ToolServer (opaque)
|
|
70
70
|
* .createQuery(opts): QueryHandle
|
|
71
71
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* opts: { cwd }
|
|
76
|
-
* Returns a short (3-8 word) title string.
|
|
72
|
+
* There is no title-generation method: an adapter never starts a query to
|
|
73
|
+
* title a session. A session's title is the vendor CLI's own (see
|
|
74
|
+
* lib/session-ai-title.js) or the first-line title.
|
|
77
75
|
*
|
|
78
76
|
* Additional session management (Claude SDK specific, may vary per adapter):
|
|
79
77
|
* .getSessionInfo(sessionId, opts): Promise<object|null>
|
|
@@ -139,7 +137,6 @@ var QUERY_HANDLE_OPTIONAL_METHODS = [
|
|
|
139
137
|
/**
|
|
140
138
|
* Adapter methods and properties the console uses beyond ADAPTER_METHODS.
|
|
141
139
|
* Optional: the console feature behind each is gated by a capability.
|
|
142
|
-
* .generateTitle(messages, opts) - session titles
|
|
143
140
|
* .getSessionInfo / .listSessions / .renameSession - capabilities
|
|
144
141
|
* sessionList, sessionRename
|
|
145
142
|
* .forkSession(sessionId, opts) - capability fork
|
|
@@ -153,7 +150,6 @@ var QUERY_HANDLE_OPTIONAL_METHODS = [
|
|
|
153
150
|
* capabilities, which can only narrow the declaration (resolveCapabilities).
|
|
154
151
|
*/
|
|
155
152
|
var ADAPTER_OPTIONAL_METHODS = [
|
|
156
|
-
"generateTitle",
|
|
157
153
|
"getSessionInfo",
|
|
158
154
|
"listSessions",
|
|
159
155
|
"renameSession",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.10.0-beta.
|
|
6
|
+
"version": "1.10.0-beta.3",
|
|
7
7
|
"description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
|
|
8
8
|
"bin": {
|
|
9
9
|
"clagentic-console": "./bin/cli.js"
|