@clagentic/console 1.10.0 → 1.11.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/bin/cli.js +38 -16
- package/lib/agents.js +1 -55
- package/lib/bash-auto-approve.js +133 -0
- package/lib/build-identity.js +23 -5
- package/lib/build-sha.json +2 -2
- package/lib/build-update-check.js +0 -62
- package/lib/build-update-offer.js +23 -13
- package/lib/build-update-restart.js +59 -43
- package/lib/cli/arg-validation.js +50 -0
- package/lib/cli/daemon-launch.js +5 -4
- package/lib/cli/menus.js +2 -2
- package/lib/cli/schedule-input-subcommands.js +327 -0
- package/lib/cli/session-subcommands.js +101 -17
- package/lib/client-build-id.js +56 -0
- package/lib/daemon.js +38 -6
- package/lib/identity/index.js +9 -4
- package/lib/injected-sender.js +225 -0
- package/lib/message-sender-record.js +133 -0
- package/lib/pending-prompts.js +55 -0
- package/lib/permission-mode-policy.js +63 -0
- package/lib/permission-settings.js +96 -0
- package/lib/permission-summary.js +67 -0
- package/lib/project-connection.js +10 -11
- package/lib/project-external-trigger.js +9 -1
- package/lib/project-loop.js +50 -23
- package/lib/project-permission-settings.js +59 -0
- package/lib/project-prompt-responses.js +25 -15
- package/lib/project-sessions.js +164 -60
- package/lib/project-user-message.js +18 -47
- package/lib/project.js +46 -74
- package/lib/public/app.js +4 -7
- package/lib/public/css/channel-layout.css +20 -0
- package/lib/public/css/diagnostics.css +7 -0
- package/lib/public/css/input.css +78 -0
- package/lib/public/css/menus.css +17 -0
- package/lib/public/css/overlays.css +0 -3
- package/lib/public/css/scheduler-modal.css +5 -0
- package/lib/public/index.html +44 -8
- package/lib/public/modules/app-connection.js +18 -1
- package/lib/public/modules/app-loop-ui.js +11 -1
- package/lib/public/modules/app-messages.js +23 -30
- package/lib/public/modules/app-panels.js +10 -3
- package/lib/public/modules/app-rate-limit.js +64 -88
- package/lib/public/modules/app-rendering.js +37 -6
- package/lib/public/modules/approve-tools-toggle.js +33 -0
- package/lib/public/modules/at-agents.js +8 -0
- package/lib/public/modules/build-guard.js +61 -0
- package/lib/public/modules/build-update-detail.js +1 -4
- package/lib/public/modules/diagnostics.js +98 -9
- package/lib/public/modules/injected-identity.js +78 -0
- package/lib/public/modules/injected-label.js +62 -0
- package/lib/public/modules/input.js +64 -114
- package/lib/public/modules/loop-hooks-warning.js +20 -0
- package/lib/public/modules/mode-options.js +35 -16
- package/lib/public/modules/permission-settings.js +56 -0
- package/lib/public/modules/project-settings.js +3 -0
- package/lib/public/modules/rate-limit-state.js +47 -22
- package/lib/public/modules/schedule-panel.js +234 -0
- package/lib/public/modules/schedule-time.js +193 -0
- package/lib/public/modules/scheduled-input-actions.js +19 -0
- package/lib/public/modules/scheduler-config.js +12 -0
- package/lib/public/modules/scheduler.js +8 -0
- package/lib/public/modules/server-settings.js +5 -9
- package/lib/public/modules/settings-defaults.js +18 -4
- package/lib/runtime-env.js +4 -0
- package/lib/scheduled-input/ipc.js +92 -0
- package/lib/scheduled-input/rate-limit-resume.js +53 -0
- package/lib/scheduled-input/records.js +350 -0
- package/lib/scheduled-input/service.js +743 -0
- package/lib/scheduled-input/store.js +132 -0
- package/lib/scheduled-input/ws.js +194 -0
- package/lib/scheduler.js +4 -0
- package/lib/sdk-bridge.js +194 -175
- package/lib/sdk-message-processor.js +13 -5
- package/lib/sdk-skill-discovery.js +17 -0
- package/lib/sender-ref.js +109 -0
- package/lib/server.js +37 -11
- package/lib/session-directory.js +224 -0
- package/lib/session-file-scan.js +55 -0
- package/lib/session-input-ipc.js +21 -0
- package/lib/session-input.js +396 -23
- package/lib/session-name-holder.js +82 -0
- package/lib/session-resume.js +3 -0
- package/lib/sessions.js +111 -2
- package/lib/turn-initiator.js +6 -2
- package/lib/updater.js +8 -2
- package/lib/ws-schema.js +20 -9
- package/lib/yoke/adapters/claude-worker.js +3 -1
- package/lib/yoke/adapters/claude.js +13 -17
- package/lib/yoke/adapters/codex.js +18 -5
- package/lib/yoke/adapters/permission-relay.js +9 -0
- package/lib/yoke/interface.js +7 -1
- package/package.json +1 -1
- package/scripts/check-test-count.js +1 -1
- package/scripts/install-local-test.js +45 -1
- package/scripts/postinstall.js +1 -0
package/lib/session-resume.js
CHANGED
|
@@ -124,8 +124,11 @@ function resumeStoredSession(deps, cliSessionId, opts) {
|
|
|
124
124
|
if (meta) {
|
|
125
125
|
if (meta.vendor) resumeOpts.vendor = meta.vendor;
|
|
126
126
|
if (meta.agentName) resumeOpts.agentName = meta.agentName;
|
|
127
|
+
if (meta.sessionName) resumeOpts.sessionName = meta.sessionName;
|
|
127
128
|
if (meta.ownerId) resumeOpts.ownerId = meta.ownerId;
|
|
128
129
|
if (meta.sessionVisibility) resumeOpts.sessionVisibility = meta.sessionVisibility;
|
|
130
|
+
// The mode the session had; the session manager checks it before use.
|
|
131
|
+
if (typeof meta.permissionMode === "string" && meta.permissionMode) resumeOpts.permissionMode = meta.permissionMode;
|
|
129
132
|
// Sanitized so a crafted meta record cannot auto-approve a tool.
|
|
130
133
|
if (meta.allowedTools) resumeOpts.allowedTools = utils.sanitizeAllowedTools(meta.allowedTools);
|
|
131
134
|
}
|
package/lib/sessions.js
CHANGED
|
@@ -9,6 +9,11 @@ var { isVisibleHistoryEvent } = require("./history-visibility");
|
|
|
9
9
|
var { createPromptRegistry } = require("./prompt-registry");
|
|
10
10
|
var { registerExitFlush } = require("./exit-flush");
|
|
11
11
|
var sessionReclaim = require("./session-reclaim");
|
|
12
|
+
var sessionFileScan = require("./session-file-scan");
|
|
13
|
+
var { findNameHolder } = require("./session-name-holder");
|
|
14
|
+
var { createSenderRecorder } = require("./message-sender-record");
|
|
15
|
+
var { checkPermissionMode, savedModeOrDefault } = require("./permission-mode-policy");
|
|
16
|
+
var { logField } = require("./log-field");
|
|
12
17
|
|
|
13
18
|
// lr-2ea2a7: hard cap on how many history entries a session may hold in the
|
|
14
19
|
// heap array, regardless of isProcessing state. On-disk JSONL remains the
|
|
@@ -39,6 +44,16 @@ function effectiveSessionModel(session, sm) {
|
|
|
39
44
|
return (sm && sm.currentModel) || "";
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
// The permission mode THIS session's clients should see: the session's own
|
|
48
|
+
// (saved with it), falling back to the project default only for a session that
|
|
49
|
+
// has none. Every client-facing push of a session's mode reads it here, never
|
|
50
|
+
// the shared sm.currentPermissionMode, which is the project default and not any
|
|
51
|
+
// one session's mode (the same split as effectiveSessionModel above).
|
|
52
|
+
function effectiveSessionMode(session, sm) {
|
|
53
|
+
if (session && session.permissionMode) return session.permissionMode;
|
|
54
|
+
return (sm && sm.currentPermissionMode) || "default";
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
// Message types whose client-side handler writes the global client-local
|
|
43
58
|
// 'processing'/'sessionIsProcessing' edge latch (app-messages.js's status/
|
|
44
59
|
// done/auth_required handlers). Stamping localId at the shared send choke
|
|
@@ -74,6 +89,10 @@ function createSessionManager(opts) {
|
|
|
74
89
|
// wire cross-project unread tracking (e.g. tests constructing a bare
|
|
75
90
|
// SessionManager).
|
|
76
91
|
var onSessionDeleted = opts.onSessionDeleted || function () {};
|
|
92
|
+
// Called with the session object as it was, after it left the manager, for a
|
|
93
|
+
// listener that needs more than the id: scheduled input ends the records
|
|
94
|
+
// bound to the session's vendor session id.
|
|
95
|
+
var onSessionRemoved = opts.onSessionRemoved || function () {};
|
|
77
96
|
|
|
78
97
|
// daemon.json knob `historyInMemMax` (lr-2ea2a7): operators may override the
|
|
79
98
|
// in-heap tail cap. TRIM_TO is derived as 80% of the configured max so the
|
|
@@ -116,6 +135,8 @@ function createSessionManager(opts) {
|
|
|
116
135
|
});
|
|
117
136
|
var capabilitiesByVendor = null; // set by sdk-bridge after adapter init
|
|
118
137
|
var defaultVendor = null; // set by sdk-bridge
|
|
138
|
+
// Publishes who sent each user message (lib/message-sender-record.js).
|
|
139
|
+
var senderRecorder = createSenderRecorder({ getBaseDir: function () { return opts.senderRecordDir || config.CONFIG_DIR; } });
|
|
119
140
|
var codexApproval = CODEX_DEFAULTS.approval;
|
|
120
141
|
var codexSandbox = CODEX_DEFAULTS.sandbox;
|
|
121
142
|
var codexWebSearch = CODEX_DEFAULTS.webSearch;
|
|
@@ -145,6 +166,7 @@ function createSessionManager(opts) {
|
|
|
145
166
|
if (typeof session.favoriteOrder === "number") metaObj.favoriteOrder = session.favoriteOrder;
|
|
146
167
|
if (session.lastRewindUuid) metaObj.lastRewindUuid = session.lastRewindUuid;
|
|
147
168
|
if (session.agentName) metaObj.agentName = session.agentName;
|
|
169
|
+
if (session.sessionName) metaObj.sessionName = session.sessionName;
|
|
148
170
|
if (session.loop) metaObj.loop = session.loop;
|
|
149
171
|
// lr-db0437: persist the session's own model choice so it survives a
|
|
150
172
|
// daemon restart / resume. Without this, session.model only ever lived
|
|
@@ -152,6 +174,9 @@ function createSessionManager(opts) {
|
|
|
152
174
|
// the project/global default happened to be, indistinguishable from the
|
|
153
175
|
// user never having picked a model at all.
|
|
154
176
|
if (session.model) metaObj.model = session.model;
|
|
177
|
+
// The session's own permission mode, so a resume or a restart keeps it
|
|
178
|
+
// instead of taking whatever the project default is by then.
|
|
179
|
+
if (session.permissionMode) metaObj.permissionMode = session.permissionMode;
|
|
155
180
|
// Persist per-session "allow for session" tool grants (lr-8b2e) so they
|
|
156
181
|
// survive daemon restart / resume-by-cliSessionId rehydration instead of
|
|
157
182
|
// silently re-prompting. Only written when non-empty — grants that were
|
|
@@ -291,6 +316,10 @@ function createSessionManager(opts) {
|
|
|
291
316
|
// pre-existing lr-f940 contract where such a push is detected via the
|
|
292
317
|
// historyMatchesDisk() length mismatch, not counted as already-durable.
|
|
293
318
|
function recordHistoryEntry(session, obj, persisted) {
|
|
319
|
+
// Every user message the console sends passes here, whichever writer built
|
|
320
|
+
// it, so the published per-message sender record covers all of them. Before
|
|
321
|
+
// the history-loaded check: the record does not depend on the heap window.
|
|
322
|
+
if (obj && obj.type === "user_message") senderRecorder.note(session, obj, defaultVendor);
|
|
294
323
|
if (!session._historyLoaded) return;
|
|
295
324
|
session.history.push(obj);
|
|
296
325
|
if (persisted !== false) {
|
|
@@ -763,11 +792,25 @@ function createSessionManager(opts) {
|
|
|
763
792
|
};
|
|
764
793
|
if (m.vendor) session.vendor = m.vendor;
|
|
765
794
|
if (m.agentName) session.agentName = m.agentName;
|
|
795
|
+
if (m.sessionName) session.sessionName = m.sessionName;
|
|
766
796
|
if (m.loop) session.loop = m.loop;
|
|
767
797
|
// lr-db0437: restore the session's own model choice across a daemon
|
|
768
798
|
// restart — see buildMetaLine's write side above for why this must
|
|
769
799
|
// persist (session.model, not the project/global default).
|
|
770
800
|
if (m.model) session.model = m.model;
|
|
801
|
+
// The saved permission mode, through the same check as any mode entering
|
|
802
|
+
// the server. One that fails it (a bypass written while the server
|
|
803
|
+
// allowed it, or by hand) loads as "default" and says so. The vendor
|
|
804
|
+
// check waits for query start, when the vendor's capabilities are known.
|
|
805
|
+
// A session saved before modes were kept has none and takes the project
|
|
806
|
+
// default when the project finishes starting (lib/project.js).
|
|
807
|
+
if (m.permissionMode) {
|
|
808
|
+
var savedMode = savedModeOrDefault(m.permissionMode);
|
|
809
|
+
if (savedMode.error) {
|
|
810
|
+
console.warn("[sessions] saved permission mode " + logField(m.permissionMode) + " of session " + logField(m.cliSessionId) + " refused (" + savedMode.error + "); using default");
|
|
811
|
+
}
|
|
812
|
+
session.permissionMode = savedMode.mode;
|
|
813
|
+
}
|
|
771
814
|
if (m.ownerId) session.ownerId = m.ownerId;
|
|
772
815
|
session.sessionVisibility = m.sessionVisibility || "shared";
|
|
773
816
|
session.bookmarked = !!m.bookmarked;
|
|
@@ -879,6 +922,31 @@ function createSessionManager(opts) {
|
|
|
879
922
|
}
|
|
880
923
|
}
|
|
881
924
|
|
|
925
|
+
// A new session takes its mode at creation and keeps it (it is saved with the
|
|
926
|
+
// session): the mode the creator names, else the project's default. Before the
|
|
927
|
+
// project has loaded its default (the session made while this manager is
|
|
928
|
+
// built) there is none to give; lib/project.js gives it once it does.
|
|
929
|
+
function giveStartingMode(session, sessionOpts) {
|
|
930
|
+
var mode;
|
|
931
|
+
if (sessionOpts && sessionOpts.permissionMode) {
|
|
932
|
+
// Named by the creator, or read from a stored record on resume: checked
|
|
933
|
+
// like any mode that enters the server, with the session's vendor once
|
|
934
|
+
// that vendor has reported what it can run.
|
|
935
|
+
var vendorCaps = capabilitiesByVendor && (sessionOpts.vendor || defaultVendor)
|
|
936
|
+
? capabilitiesByVendor[sessionOpts.vendor || defaultVendor] : null;
|
|
937
|
+
var verdict = checkPermissionMode(sessionOpts.permissionMode, {
|
|
938
|
+
supportedModes: vendorCaps && Array.isArray(vendorCaps.permissionModes) ? vendorCaps.permissionModes : null,
|
|
939
|
+
});
|
|
940
|
+
if (!verdict.ok) {
|
|
941
|
+
console.warn("[sessions] permission mode " + logField(sessionOpts.permissionMode) + " refused for a new session (" + verdict.error + "); using default");
|
|
942
|
+
}
|
|
943
|
+
mode = verdict.ok ? sessionOpts.permissionMode : "default";
|
|
944
|
+
} else {
|
|
945
|
+
mode = _instance && _instance._savedDefaultMode;
|
|
946
|
+
}
|
|
947
|
+
if (mode) session.permissionMode = mode;
|
|
948
|
+
}
|
|
949
|
+
|
|
882
950
|
function createSession(sessionOpts, targetWs) {
|
|
883
951
|
var localId = nextLocalId++;
|
|
884
952
|
var session = {
|
|
@@ -907,7 +975,9 @@ function createSessionManager(opts) {
|
|
|
907
975
|
favoriteOrder: null,
|
|
908
976
|
vendor: (sessionOpts && sessionOpts.vendor) || null,
|
|
909
977
|
agentName: (sessionOpts && sessionOpts.agentName) || null,
|
|
978
|
+
sessionName: (sessionOpts && sessionOpts.sessionName) || null,
|
|
910
979
|
};
|
|
980
|
+
giveStartingMode(session, sessionOpts);
|
|
911
981
|
sessions.set(localId, session);
|
|
912
982
|
switchSession(localId, targetWs);
|
|
913
983
|
return session;
|
|
@@ -943,6 +1013,7 @@ function createSessionManager(opts) {
|
|
|
943
1013
|
vendor: (sessionOpts && sessionOpts.vendor) || null,
|
|
944
1014
|
agentName: (sessionOpts && sessionOpts.agentName) || null,
|
|
945
1015
|
};
|
|
1016
|
+
giveStartingMode(session, sessionOpts);
|
|
946
1017
|
sessions.set(localId, session);
|
|
947
1018
|
return session;
|
|
948
1019
|
}
|
|
@@ -1145,7 +1216,7 @@ function createSessionManager(opts) {
|
|
|
1145
1216
|
// client hydrating from session_switched alone (no separate config_state
|
|
1146
1217
|
// round-trip needed) never has to fall back to guessing the shared
|
|
1147
1218
|
// project/global default — see effectiveSessionModel() above.
|
|
1148
|
-
_send({ type: "session_switched", id: localId, cliSessionId: session.cliSessionId || null, loop: session.loop || null, vendor: session.vendor || null, model: effectiveSessionModel(session, _instance), hasHistory: (session._historyLoaded ? session.history.length > 0 : !!session.cliSessionId), capabilities: _vendorCaps, isProcessing: !!session.isProcessing, agentName: session.agentName || null });
|
|
1219
|
+
_send({ type: "session_switched", id: localId, cliSessionId: session.cliSessionId || null, loop: session.loop || null, vendor: session.vendor || null, model: effectiveSessionModel(session, _instance), mode: effectiveSessionMode(session, _instance), hasHistory: (session._historyLoaded ? session.history.length > 0 : !!session.cliSessionId), capabilities: _vendorCaps, isProcessing: !!session.isProcessing, agentName: session.agentName || null });
|
|
1149
1220
|
// Send vendor-specific slash commands
|
|
1150
1221
|
var _vendorCmds = slashCommandsByVendor[_sessionVendor] || slashCommands || [];
|
|
1151
1222
|
_send({ type: "slash_commands", commands: _vendorCmds, vendor: _sessionVendor });
|
|
@@ -1224,6 +1295,7 @@ function createSessionManager(opts) {
|
|
|
1224
1295
|
sessions.delete(localId);
|
|
1225
1296
|
broadcastSessionDeleted(localId);
|
|
1226
1297
|
onSessionDeleted(localId);
|
|
1298
|
+
onSessionRemoved(session);
|
|
1227
1299
|
|
|
1228
1300
|
if (activeSessionId === localId) {
|
|
1229
1301
|
var remaining = [...sessions.keys()];
|
|
@@ -1268,6 +1340,7 @@ function createSessionManager(opts) {
|
|
|
1268
1340
|
}
|
|
1269
1341
|
sessions.delete(localId);
|
|
1270
1342
|
onSessionDeleted(localId);
|
|
1343
|
+
onSessionRemoved(session);
|
|
1271
1344
|
}
|
|
1272
1345
|
|
|
1273
1346
|
function deleteSessionsBulk(localIds, targetWs) {
|
|
@@ -1424,6 +1497,19 @@ function createSessionManager(opts) {
|
|
|
1424
1497
|
};
|
|
1425
1498
|
if (opts && opts.vendor) session.vendor = opts.vendor;
|
|
1426
1499
|
if (opts && opts.agentName) session.agentName = opts.agentName;
|
|
1500
|
+
// A session resumed from its stored record keeps the mode saved with it.
|
|
1501
|
+
giveStartingMode(session, opts);
|
|
1502
|
+
if (opts && opts.sessionName) {
|
|
1503
|
+
// The resume is never refused over a name: when another session holds it,
|
|
1504
|
+
// this one comes back unnamed and saveSessionFile below clears the meta.
|
|
1505
|
+
var nameHolder = findNameHolder(sessions, opts.sessionName, localId);
|
|
1506
|
+
if (nameHolder) {
|
|
1507
|
+
console.warn("[sessions] resume of " + cliSessionId + ": name " + JSON.stringify(opts.sessionName) +
|
|
1508
|
+
" is held by session " + nameHolder.localId + "; resumed unnamed");
|
|
1509
|
+
} else {
|
|
1510
|
+
session.sessionName = opts.sessionName;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1427
1513
|
if (opts && opts.sessionVisibility) session.sessionVisibility = opts.sessionVisibility;
|
|
1428
1514
|
if (opts && opts.ownerId) session.ownerId = opts.ownerId;
|
|
1429
1515
|
sessions.set(localId, session);
|
|
@@ -1465,6 +1551,15 @@ function createSessionManager(opts) {
|
|
|
1465
1551
|
return _parseSessionFileLines(session).lines;
|
|
1466
1552
|
}
|
|
1467
1553
|
|
|
1554
|
+
// The newest stored history entry `accept` takes, or null. A bounded reverse
|
|
1555
|
+
// read of the session file: memory is the chunk, not the history, and no
|
|
1556
|
+
// session state is touched. Throws when the file cannot be read.
|
|
1557
|
+
function findNewestHistoryEntry(session, accept) {
|
|
1558
|
+
if (!session.cliSessionId) return null;
|
|
1559
|
+
flushSessionBuffer(session);
|
|
1560
|
+
return sessionFileScan.findNewestEntry(sessionFilePath(session.cliSessionId), accept);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1468
1563
|
// canSee (optional): predicate over a session; a session it rejects is
|
|
1469
1564
|
// skipped before its title or any of its content is examined.
|
|
1470
1565
|
function searchSessions(query, canSee) {
|
|
@@ -1682,6 +1777,13 @@ function createSessionManager(opts) {
|
|
|
1682
1777
|
set codexWebSearch(v) { codexWebSearch = v; },
|
|
1683
1778
|
sessions: sessions,
|
|
1684
1779
|
sessionsDir: sessionsDir,
|
|
1780
|
+
// Once the project has loaded its default mode: a session saved before
|
|
1781
|
+
// sessions kept their own mode (or made before the default was known) takes
|
|
1782
|
+
// that default now and keeps it, so a later change of the default does not
|
|
1783
|
+
// move it. In memory only; it is saved with the session's next write.
|
|
1784
|
+
adoptDefaultMode: function (mode) {
|
|
1785
|
+
sessions.forEach(function (s) { if (!s.permissionMode) s.permissionMode = mode; });
|
|
1786
|
+
},
|
|
1685
1787
|
HISTORY_PAGE_SIZE: HISTORY_PAGE_SIZE,
|
|
1686
1788
|
getActiveSession: getActiveSession,
|
|
1687
1789
|
createSession: createSession,
|
|
@@ -1714,6 +1816,11 @@ function createSessionManager(opts) {
|
|
|
1714
1816
|
// lr-2ea2a7: the single choke point every session.history.push() site
|
|
1715
1817
|
// must route through — see the grep-guard test.
|
|
1716
1818
|
recordHistoryEntry: recordHistoryEntry,
|
|
1819
|
+
// Per-message sender record (lib/message-sender-record.js): the processor
|
|
1820
|
+
// flushes a session's held records once its vendor session id is known and
|
|
1821
|
+
// binds a vendor turn id to the message that started it.
|
|
1822
|
+
flushSenderRecords: function (session) { senderRecorder.flush(session, defaultVendor); },
|
|
1823
|
+
bindSenderTurn: function (session, messageId, turnId) { senderRecorder.bindTurn(session, messageId, turnId, defaultVendor); },
|
|
1717
1824
|
HISTORY_INMEM_MAX: HISTORY_INMEM_MAX,
|
|
1718
1825
|
HISTORY_INMEM_TRIM_TO: HISTORY_INMEM_TRIM_TO,
|
|
1719
1826
|
LRU_HISTORY_LIMIT: LRU_HISTORY_LIMIT,
|
|
@@ -1735,6 +1842,7 @@ function createSessionManager(opts) {
|
|
|
1735
1842
|
// (project-filesystem.js's fs_file_history) so they don't have to call
|
|
1736
1843
|
// loadSessionHistory()/mutate session state just to scan for a match.
|
|
1737
1844
|
readSessionHistoryFromDisk: readSessionHistoryFromDisk,
|
|
1845
|
+
findNewestHistoryEntry: findNewestHistoryEntry,
|
|
1738
1846
|
// lr-2ea2a7 observability: per-session heap footprint + top-5 by
|
|
1739
1847
|
// heapEntries, consumed by project-sessions.js's process_stats handler
|
|
1740
1848
|
// so a future incident is diagnosable without a heap snapshot.
|
|
@@ -1836,6 +1944,7 @@ function createSessionManager(opts) {
|
|
|
1836
1944
|
// `sm.effectiveSessionModel(session)` without importing this module
|
|
1837
1945
|
// separately.
|
|
1838
1946
|
effectiveSessionModel: function (session) { return effectiveSessionModel(session, _instance); },
|
|
1947
|
+
effectiveSessionMode: function (session) { return effectiveSessionMode(session, _instance); },
|
|
1839
1948
|
// Called when the project owning this session manager is torn down. No
|
|
1840
1949
|
// prompt resolver outlives it, so every pending prompt ends here and its
|
|
1841
1950
|
// outcome is flushed to disk; then the exit flusher registered above is
|
|
@@ -1850,4 +1959,4 @@ function createSessionManager(opts) {
|
|
|
1850
1959
|
return _instance;
|
|
1851
1960
|
}
|
|
1852
1961
|
|
|
1853
|
-
module.exports = { createSessionManager, effectiveSessionModel, stampActivityLocalId };
|
|
1962
|
+
module.exports = { createSessionManager, effectiveSessionModel, effectiveSessionMode, stampActivityLocalId };
|
package/lib/turn-initiator.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
var pkg = require("../package.json");
|
|
16
16
|
var runtimeEnv = require("./runtime-env");
|
|
17
|
+
var senderRef = require("./sender-ref");
|
|
17
18
|
// Required for its constant only: nothing of the identity surface runs from here.
|
|
18
19
|
var IDENTITY_DIR_ENV = require("./identity/contract").IDENTITY_DIR_ENV;
|
|
19
20
|
|
|
@@ -94,8 +95,11 @@ function claudeHostEnv() {
|
|
|
94
95
|
// console never issued for this process, and a consumer would trust it. It is
|
|
95
96
|
// removed always; `identity` ({ dir: <delivery directory> | null }, present only
|
|
96
97
|
// when an identity provider is configured) is the only way it comes back.
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
//
|
|
99
|
+
// `sessionRef` ({ project, sessionId }) is the console's reference to the session
|
|
100
|
+
// this process belongs to (lib/sender-ref.js), set whatever the provider is.
|
|
101
|
+
function claudeProcessEnv(base, overlay, identity, sessionRef) {
|
|
102
|
+
var env = Object.assign(runtimeEnv.composeRuntimeEnv(base, overlay), claudeHostEnv(), senderRef.envFor(sessionRef));
|
|
99
103
|
delete env[IDENTITY_DIR_ENV];
|
|
100
104
|
if (identity && typeof identity === "object" && typeof identity.dir === "string" && identity.dir) {
|
|
101
105
|
env[IDENTITY_DIR_ENV] = identity.dir;
|
package/lib/updater.js
CHANGED
|
@@ -96,8 +96,14 @@ function performUpdate(version) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
// Argument vector handed to node on re-exec: the script path and the original
|
|
100
|
+
// arguments, plus --no-update. Split out so a test can read the real argv shape.
|
|
101
|
+
function reExecArgs(argv) {
|
|
102
|
+
return argv.slice(1).concat("--no-update");
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
function reExec() {
|
|
100
|
-
var args = process.argv
|
|
106
|
+
var args = reExecArgs(process.argv);
|
|
101
107
|
var child = spawn(process.execPath, args, { stdio: "inherit" });
|
|
102
108
|
child.on("exit", function (code) {
|
|
103
109
|
process.exit(code);
|
|
@@ -144,4 +150,4 @@ async function checkAndUpdate(currentVersion, skipUpdate, channel) {
|
|
|
144
150
|
return false;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
module.exports = { checkAndUpdate, fetchLatestVersion, fetchVersion, isNewer };
|
|
153
|
+
module.exports = { checkAndUpdate, fetchLatestVersion, fetchVersion, isNewer, reExecArgs };
|
package/lib/ws-schema.js
CHANGED
|
@@ -78,10 +78,13 @@ var schema = {
|
|
|
78
78
|
// were live, sent types with no documentation entry.
|
|
79
79
|
"plan_content": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Plan-mode content for the plan card" },
|
|
80
80
|
"sdk_notification": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Informational notification surfaced from the vendor SDK" },
|
|
81
|
-
"diagnostic": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Session-scoped diagnostic toast (settings preflight, memory shedding, adapter warnings). A message with refresh:true updates the entry the client already holds for the same source and action, and is ignored when the client holds none" },
|
|
81
|
+
"diagnostic": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Session-scoped diagnostic toast (settings preflight, memory shedding, adapter warnings). A message with refresh:true updates the entry the client already holds for the same source and action, and is ignored when the client holds none. A message with persistent:true is a state, not a notice: its toast has no timer and a repeat replaces the earlier card of the same source" },
|
|
82
82
|
|
|
83
83
|
"diagnostic_retract": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Withdraws every diagnostic of one source (source) because its condition no longer holds; sent when the installed build is adopted while an update offer is shown, and to a client that connects while no offer stands" },
|
|
84
84
|
|
|
85
|
+
"restart_for_build_update": { direction: "c2s", handler: "lib/project-sessions.js", description: "Admin request to adopt the installed build. Without confirmToken it asks for the offer (what a restart would end) and restarts nothing; with the token of an offer the daemon issued it schedules the restart. The client sets requestId (a string of at most 64 characters) on every request so it can match the answer to the pending click" },
|
|
86
|
+
"restart_for_build_update_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Answer to restart_for_build_update. ok:true means the restart is scheduled or already was (any request while one waits gets ok:true and the pending-restart diagnostic, never another offer); otherwise the request was refused (unknown or expired token) and a fresh offer may follow as a diagnostic; a changed session set is never a refusal, and the client gives its action buttons back. requestId is echoed unchanged from the request (absent if the request carried none or an over-long one); a client settles only the pending slot with the matching requestId and ignores any other answer" },
|
|
87
|
+
|
|
85
88
|
// -----------------------------------------------------------------------
|
|
86
89
|
// Thinking
|
|
87
90
|
// -----------------------------------------------------------------------
|
|
@@ -174,12 +177,17 @@ var schema = {
|
|
|
174
177
|
// -----------------------------------------------------------------------
|
|
175
178
|
"rate_limit": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Rate limit hit, includes wait time" },
|
|
176
179
|
"rate_limit_usage": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Current rate limit usage stats" },
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
180
|
+
// Scheduled input (lib/scheduled-input/): a once message or a recurring
|
|
181
|
+
// input with an end. The scheduled_message_* names are the original ones, kept;
|
|
182
|
+
// a current client takes its state from scheduled_input_list alone.
|
|
183
|
+
"schedule_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Schedule input for the session on screen: once ({ text, resetsAt }) or recurring ({ text, kind, every, until | count })" },
|
|
184
|
+
"send_scheduled_now": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Send a scheduled input immediately ({ id? }), into a running turn if need be" },
|
|
185
|
+
"cancel_scheduled_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Cancel a scheduled input ({ id? })" },
|
|
186
|
+
"scheduled_input_list_request": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Ask for the armed scheduled inputs of the session on screen" },
|
|
187
|
+
"scheduled_input_list": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The armed scheduled inputs of a session, in full, after every change" },
|
|
188
|
+
"scheduled_message_queued": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was queued (older clients draw their bubble from it; also carries id, kind, every, until, count)" },
|
|
189
|
+
"scheduled_message_sent": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was sent (carries id, kind and final)" },
|
|
190
|
+
"scheduled_message_cancelled": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was cancelled or ended (carries id and reason)" },
|
|
183
191
|
"auto_continue_scheduled": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Auto-continue was scheduled after rate limit" },
|
|
184
192
|
"auto_continue_fired": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Auto-continue timer fired" },
|
|
185
193
|
|
|
@@ -190,7 +198,8 @@ var schema = {
|
|
|
190
198
|
"set_server_default_model": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set the server-wide default model" },
|
|
191
199
|
"set_project_default_model": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set the project default model" },
|
|
192
200
|
"set_permission_mode": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set permission mode for the current session" },
|
|
193
|
-
"set_server_default_mode": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set the server-wide default permission mode" },
|
|
201
|
+
"set_server_default_mode": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set the server-wide default permission mode; applyToRunning: true also re-modes this project's sessions" },
|
|
202
|
+
"set_permission_settings": { direction: "c2s", handler: "lib/project-permission-settings.js", description: "Change the server-wide permission settings (admin only): autoApproveReadOnly, openedSessionMode" },
|
|
194
203
|
"set_project_default_mode": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set the project default permission mode" },
|
|
195
204
|
"set_effort": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set effort level for the current session" },
|
|
196
205
|
"set_server_default_effort": { direction: "c2s", handler: "lib/project-sessions.js", description: "Set the server-wide default effort level" },
|
|
@@ -202,7 +211,9 @@ var schema = {
|
|
|
202
211
|
"model_info": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Current model and available models list" },
|
|
203
212
|
"vendor_registry": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Every registered agent with display data, install state, login command and capabilities; the agent picker and capability-gated controls render from it" },
|
|
204
213
|
"recheck_vendors": { direction: "c2s", handler: "lib/project-sessions.js", description: "Look again for installed agents and broadcast the vendor registry" },
|
|
205
|
-
"config_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "
|
|
214
|
+
"config_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Config state: model, effort, betas, thinking, and the viewed session's mode (absent when the push is not about a mode)" },
|
|
215
|
+
"permission_settings": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The server-wide permission settings: autoApproveReadOnly, openedSessionMode" },
|
|
216
|
+
"permission_mode_applied": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Result of applying a new default mode to the running sessions: applied count and skipped sessions with reasons" },
|
|
206
217
|
"slash_commands": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Available slash commands list" },
|
|
207
218
|
"fast_mode_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Fast mode toggle state" },
|
|
208
219
|
"client_count": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Number of connected clients" },
|
|
@@ -108,9 +108,11 @@ function applyRuntimeEnv(options) {
|
|
|
108
108
|
delete options.runtimeEnv;
|
|
109
109
|
var identity = options.identity;
|
|
110
110
|
delete options.identity;
|
|
111
|
+
var sessionRef = options.sessionRef;
|
|
112
|
+
delete options.sessionRef;
|
|
111
113
|
// Always built: the product identity and host declaration are part of every
|
|
112
114
|
// Claude process's environment.
|
|
113
|
-
options.env = turnInitiator.claudeProcessEnv(process.env, overlay, identity);
|
|
115
|
+
options.env = turnInitiator.claudeProcessEnv(process.env, overlay, identity, sessionRef);
|
|
114
116
|
return options;
|
|
115
117
|
}
|
|
116
118
|
|
|
@@ -345,7 +345,9 @@ function flattenEvent(raw) {
|
|
|
345
345
|
|
|
346
346
|
// The streamed user message for one turn, stamped with who initiated it. Shared
|
|
347
347
|
// by the in-process and worker handles so both deliver the same provenance.
|
|
348
|
-
|
|
348
|
+
// `messageId`, when given, is the message's own id (the SDK's uuid field), so the
|
|
349
|
+
// vendor transcript line for this message carries the id the console recorded.
|
|
350
|
+
function buildUserMessage(text, images, initiator, messageId) {
|
|
349
351
|
var content = [];
|
|
350
352
|
if (images && images.length > 0) {
|
|
351
353
|
for (var i = 0; i < images.length; i++) {
|
|
@@ -356,7 +358,9 @@ function buildUserMessage(text, images, initiator) {
|
|
|
356
358
|
}
|
|
357
359
|
}
|
|
358
360
|
if (text) content.push({ type: "text", text: text });
|
|
359
|
-
|
|
361
|
+
var message = turnInitiator.stampClaudeUserMessage({ type: "user", message: { role: "user", content: content } }, initiator);
|
|
362
|
+
if (typeof messageId === "string" && messageId) message.uuid = messageId;
|
|
363
|
+
return message;
|
|
360
364
|
}
|
|
361
365
|
|
|
362
366
|
// --- QueryHandle ---
|
|
@@ -380,8 +384,8 @@ function createQueryHandle(rawQuery, messageQueue, abortController) {
|
|
|
380
384
|
};
|
|
381
385
|
},
|
|
382
386
|
|
|
383
|
-
pushMessage: function(text, images, initiator) {
|
|
384
|
-
messageQueue.push(buildUserMessage(text, images, initiator));
|
|
387
|
+
pushMessage: function(text, images, initiator, messageId) {
|
|
388
|
+
messageQueue.push(buildUserMessage(text, images, initiator, messageId));
|
|
385
389
|
},
|
|
386
390
|
|
|
387
391
|
setModel: function(model) {
|
|
@@ -1104,8 +1108,8 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
1104
1108
|
};
|
|
1105
1109
|
},
|
|
1106
1110
|
|
|
1107
|
-
pushMessage: function(text, images, initiator) {
|
|
1108
|
-
worker.send({ type: "push_message", content: buildUserMessage(text, images, initiator) });
|
|
1111
|
+
pushMessage: function(text, images, initiator, messageId) {
|
|
1112
|
+
worker.send({ type: "push_message", content: buildUserMessage(text, images, initiator, messageId) });
|
|
1109
1113
|
},
|
|
1110
1114
|
|
|
1111
1115
|
// lr-f22787: correlated by requestId (mirrors rewindFiles below) so the
|
|
@@ -1643,14 +1647,13 @@ function createClaudeAdapter(opts) {
|
|
|
1643
1647
|
if (co.thinking) sdkOptions.thinking = co.thinking;
|
|
1644
1648
|
if (co.betas && co.betas.length > 0) sdkOptions.betas = co.betas;
|
|
1645
1649
|
if (co.permissionMode) sdkOptions.permissionMode = co.permissionMode;
|
|
1646
|
-
if (co.allowDangerouslySkipPermissions) sdkOptions.allowDangerouslySkipPermissions = true;
|
|
1647
1650
|
if (co.resumeSessionAt) sdkOptions.resumeSessionAt = co.resumeSessionAt;
|
|
1648
1651
|
if (co.settings) sdkOptions.settings = co.settings;
|
|
1649
1652
|
|
|
1650
1653
|
// options.env REPLACES the subprocess environment, so the query is handed
|
|
1651
1654
|
// the whole environment (the process's own, the Settings variables, and
|
|
1652
1655
|
// the product identity and host declaration), not the additions.
|
|
1653
|
-
sdkOptions.env = turnInitiator.claudeProcessEnv(process.env, queryOpts.runtimeEnv, queryOpts.identity);
|
|
1656
|
+
sdkOptions.env = turnInitiator.claudeProcessEnv(process.env, queryOpts.runtimeEnv, queryOpts.identity, queryOpts.sessionRef);
|
|
1654
1657
|
|
|
1655
1658
|
var rawQuery = sdk.query({ prompt: mq, options: sdkOptions });
|
|
1656
1659
|
return createQueryHandle(rawQuery, mq, ac);
|
|
@@ -1762,7 +1765,6 @@ function createClaudeAdapter(opts) {
|
|
|
1762
1765
|
if (claudeOpts.thinking) queryOptions.thinking = claudeOpts.thinking;
|
|
1763
1766
|
if (claudeOpts.betas && claudeOpts.betas.length > 0) queryOptions.betas = claudeOpts.betas;
|
|
1764
1767
|
if (claudeOpts.permissionMode) queryOptions.permissionMode = claudeOpts.permissionMode;
|
|
1765
|
-
if (claudeOpts.allowDangerouslySkipPermissions) queryOptions.allowDangerouslySkipPermissions = true;
|
|
1766
1768
|
if (claudeOpts.settings) queryOptions.settings = claudeOpts.settings;
|
|
1767
1769
|
// The worker lays these over its own environment (the OS user's), then
|
|
1768
1770
|
// hands the SDK the complete result.
|
|
@@ -1770,6 +1772,8 @@ function createClaudeAdapter(opts) {
|
|
|
1770
1772
|
// Present only when an identity provider is configured; the worker adds the
|
|
1771
1773
|
// delivery directory to the Claude process's environment.
|
|
1772
1774
|
if (queryOpts.identity) queryOptions.identity = queryOpts.identity;
|
|
1775
|
+
// The console's reference to this session; the worker adds it to the environment.
|
|
1776
|
+
if (queryOpts.sessionRef) queryOptions.sessionRef = queryOpts.sessionRef;
|
|
1773
1777
|
|
|
1774
1778
|
if (queryOpts.toolServerDescriptors) queryOptions.mcpServerDescriptors = queryOpts.toolServerDescriptors;
|
|
1775
1779
|
if (queryOpts.model) queryOptions.model = queryOpts.model;
|
|
@@ -1814,10 +1818,6 @@ function createClaudeAdapter(opts) {
|
|
|
1814
1818
|
};
|
|
1815
1819
|
if (_claudeBinaryPath) warmupOptions.pathToClaudeCodeExecutable = _claudeBinaryPath;
|
|
1816
1820
|
|
|
1817
|
-
if (initOpts && initOpts.dangerouslySkipPermissions) {
|
|
1818
|
-
warmupOptions.permissionMode = "bypassPermissions";
|
|
1819
|
-
warmupOptions.allowDangerouslySkipPermissions = true;
|
|
1820
|
-
}
|
|
1821
1821
|
// The warmup starts the same CLI a query does, so it gets the same environment.
|
|
1822
1822
|
warmupOptions.env = turnInitiator.claudeProcessEnv(process.env, initOpts && initOpts.runtimeEnv);
|
|
1823
1823
|
|
|
@@ -1887,10 +1887,6 @@ function createClaudeAdapter(opts) {
|
|
|
1887
1887
|
|
|
1888
1888
|
var warmupOptions = { cwd: workerCwd, settingSources: ["user", "project", "local"], settings: { disableAllHooks: true } };
|
|
1889
1889
|
if (_claudeBinaryPath) warmupOptions.pathToClaudeCodeExecutable = _claudeBinaryPath;
|
|
1890
|
-
if (initOpts && initOpts.dangerouslySkipPermissions) {
|
|
1891
|
-
warmupOptions.permissionMode = "bypassPermissions";
|
|
1892
|
-
warmupOptions.allowDangerouslySkipPermissions = true;
|
|
1893
|
-
}
|
|
1894
1890
|
if (initOpts && runtimeEnv.hasOverlay(initOpts.runtimeEnv)) warmupOptions.runtimeEnv = initOpts.runtimeEnv;
|
|
1895
1891
|
|
|
1896
1892
|
return new Promise(function(resolve, reject) {
|
|
@@ -195,7 +195,15 @@ function flattenEvent(notification, state) {
|
|
|
195
195
|
if (method === "turn/started") {
|
|
196
196
|
state.turnStarted = true;
|
|
197
197
|
var userUuid = generateUuid();
|
|
198
|
-
|
|
198
|
+
var turnStart = { yokeType: "turn_start", uuid: userUuid, messageType: "user" };
|
|
199
|
+
// The app-server's own id for the turn, and the console's id for the message
|
|
200
|
+
// that started it: together they join a message to the Codex rollout.
|
|
201
|
+
var startedTurn = params.turn && params.turn.id ? params.turn.id : params.turnId;
|
|
202
|
+
if (startedTurn && state.currentMessageId) {
|
|
203
|
+
turnStart.turnId = String(startedTurn);
|
|
204
|
+
turnStart.messageId = state.currentMessageId;
|
|
205
|
+
}
|
|
206
|
+
events.push(turnStart);
|
|
199
207
|
return events;
|
|
200
208
|
}
|
|
201
209
|
|
|
@@ -963,9 +971,10 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
963
971
|
}
|
|
964
972
|
|
|
965
973
|
// --- Main query loop ---
|
|
966
|
-
async function runQueryLoop(initialMessage, initialInitiator) {
|
|
974
|
+
async function runQueryLoop(initialMessage, initialInitiator, initialMessageId) {
|
|
967
975
|
// Who started the turn being sent, per turn (turn-initiator.js).
|
|
968
976
|
var currentInitiator = initialInitiator;
|
|
977
|
+
var currentMessageId = initialMessageId;
|
|
969
978
|
// Prepend system prompt (project instructions from YOKE layer) to first message.
|
|
970
979
|
// initialMessage may be a string (text-only) or an array of content items
|
|
971
980
|
// (e.g. [{ type: "text", text: "..." }, ...] when images/attachments are present).
|
|
@@ -1043,6 +1052,9 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1043
1052
|
while (!isCancelled()) {
|
|
1044
1053
|
// Reset per-turn state
|
|
1045
1054
|
state.turnStarted = false;
|
|
1055
|
+
// Named on the turn_start event so the console can publish which turn
|
|
1056
|
+
// this message started.
|
|
1057
|
+
state.currentMessageId = currentMessageId || null;
|
|
1046
1058
|
state.textBlocks = {};
|
|
1047
1059
|
state.textLengths = {};
|
|
1048
1060
|
state.thinkingBlocks = {};
|
|
@@ -1159,6 +1171,7 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1159
1171
|
if (nextMsg === null) break;
|
|
1160
1172
|
currentMessage = nextMsg.input;
|
|
1161
1173
|
currentInitiator = nextMsg.initiator;
|
|
1174
|
+
currentMessageId = nextMsg.messageId;
|
|
1162
1175
|
}
|
|
1163
1176
|
} catch (e) {
|
|
1164
1177
|
// Suppress AbortError when the user stopped the query.
|
|
@@ -1201,7 +1214,7 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1201
1214
|
};
|
|
1202
1215
|
},
|
|
1203
1216
|
|
|
1204
|
-
pushMessage: function(text, images, initiator) {
|
|
1217
|
+
pushMessage: function(text, images, initiator, messageId) {
|
|
1205
1218
|
var input;
|
|
1206
1219
|
if (images && images.length > 0) {
|
|
1207
1220
|
input = [];
|
|
@@ -1234,9 +1247,9 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1234
1247
|
|
|
1235
1248
|
if (!state.loopStarted) {
|
|
1236
1249
|
state.loopStarted = true;
|
|
1237
|
-
runQueryLoop(input, initiator);
|
|
1250
|
+
runQueryLoop(input, initiator, messageId);
|
|
1238
1251
|
} else {
|
|
1239
|
-
pushMessageToQueue({ input: input, initiator: initiator });
|
|
1252
|
+
pushMessageToQueue({ input: input, initiator: initiator, messageId: messageId });
|
|
1240
1253
|
}
|
|
1241
1254
|
},
|
|
1242
1255
|
|
|
@@ -32,6 +32,11 @@ function toRequestMessage(requestId, toolName, input, opts) {
|
|
|
32
32
|
if (opts.suppressAlwaysAllowRule === true) msg.suppressAlwaysAllowRule = true;
|
|
33
33
|
if (opts.defaultToNo === true) msg.defaultToNo = true;
|
|
34
34
|
if (opts.matchedAskRule) msg.matchedAskRule = opts.matchedAskRule;
|
|
35
|
+
// Which MCP server serves the tool and where its definition came from: the
|
|
36
|
+
// daemon keys MCP auto-approval on it, so it must cross the process boundary.
|
|
37
|
+
if (opts.mcpServer && typeof opts.mcpServer === "object") {
|
|
38
|
+
msg.mcpServer = { name: String(opts.mcpServer.name), source: String(opts.mcpServer.source) };
|
|
39
|
+
}
|
|
35
40
|
return msg;
|
|
36
41
|
}
|
|
37
42
|
|
|
@@ -49,6 +54,10 @@ function toCanUseToolOptions(msg, signal) {
|
|
|
49
54
|
if (msg.suppressAlwaysAllowRule === true) opts.suppressAlwaysAllowRule = true;
|
|
50
55
|
if (msg.defaultToNo === true) opts.defaultToNo = true;
|
|
51
56
|
if (msg.matchedAskRule) opts.matchedAskRule = typeof msg.matchedAskRule === "object" ? msg.matchedAskRule : {};
|
|
57
|
+
if (msg.mcpServer && typeof msg.mcpServer === "object"
|
|
58
|
+
&& typeof msg.mcpServer.name === "string" && typeof msg.mcpServer.source === "string") {
|
|
59
|
+
opts.mcpServer = { name: msg.mcpServer.name, source: msg.mcpServer.source };
|
|
60
|
+
}
|
|
52
61
|
return opts;
|
|
53
62
|
}
|
|
54
63
|
|
package/lib/yoke/interface.js
CHANGED
|
@@ -81,7 +81,13 @@ var TOOL_POLICIES = ["ask", "allow-all"];
|
|
|
81
81
|
*
|
|
82
82
|
* QueryHandle shape:
|
|
83
83
|
* [Symbol.asyncIterator]() - yields SDK events (raw in Phase 3, normalized later)
|
|
84
|
-
* .pushMessage(text, images, initiator) - initiator optional, per
|
|
84
|
+
* .pushMessage(text, images, initiator, messageId) - initiator optional, per
|
|
85
|
+
* turn; messageId optional: the id the console
|
|
86
|
+
* recorded for the message, which an adapter
|
|
87
|
+
* carries to its vendor where the vendor lets a
|
|
88
|
+
* client name a message (the Claude adapter sets
|
|
89
|
+
* the SDK message uuid) and otherwise reports back
|
|
90
|
+
* on the turn_start event (turnId, messageId)
|
|
85
91
|
* .setModel(model)
|
|
86
92
|
* .setEffort(effort) - Promise; settles once the running query has
|
|
87
93
|
* taken the change and rejects (with a message
|
package/package.json
CHANGED
|
@@ -297,7 +297,7 @@ function classifyRun(result, files, resultsByFile, totalTests, floor) {
|
|
|
297
297
|
reason: (
|
|
298
298
|
missingFiles.length + " test file(s) reported ZERO test results — " +
|
|
299
299
|
"treated as a truncated/incomplete run, not a pass, regardless of the overall exit code. This is " +
|
|
300
|
-
"exactly the failure class lr-795882 fixed (
|
|
300
|
+
"exactly the failure class lr-795882 fixed (lr-a7b03e): a file whose tests silently vanish " +
|
|
301
301
|
"while the overall run still exits 0.\n " + missingFiles.join("\n ")
|
|
302
302
|
),
|
|
303
303
|
};
|