@chroxy/server 0.11.10 → 0.11.11
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/CONFIG.md +4 -2
- package/package.json +3 -3
- package/src/acp-session.js +5 -1
- package/src/agent-connections.js +12 -1
- package/src/agent-control/client.js +29 -0
- package/src/agent-control/events.js +8 -4
- package/src/agent-control/local-connection.js +34 -16
- package/src/agent-control/mcp-server.js +2 -0
- package/src/anthropic-compatible-config.js +1 -0
- package/src/anthropic-gemini-shim.js +444 -0
- package/src/anthropic-gemini-translate.js +1030 -0
- package/src/base-session.js +319 -2
- package/src/bound-client-policy.js +12 -0
- package/src/byok-mcp-config.js +9 -5
- package/src/byok-mcp-trust.js +34 -20
- package/src/byok-session.js +62 -9
- package/src/byok-tool-executor.js +81 -1
- package/src/claude-setting-sources.js +74 -0
- package/src/claude-tui/pty-driver.js +5 -1
- package/src/claude-tui/usage-limit.js +2 -2
- package/src/claude-tui-session.js +57 -4
- package/src/cli/agent-cmd.js +236 -0
- package/src/cli/connection-state.js +54 -0
- package/src/cli/freshness-cmd.js +53 -0
- package/src/cli/pages-cmd.js +6 -4
- package/src/cli/pair-code-cmd.js +7 -6
- package/src/cli/pair-discord-cmd.js +7 -6
- package/src/cli/schedule-cmd.js +25 -3
- package/src/cli/server-cmd.js +6 -0
- package/src/cli/shell-cmd.js +7 -4
- package/src/cli/status-cmd.js +19 -5
- package/src/cli-session.js +190 -11
- package/src/cli.js +4 -0
- package/src/codex-app-server-session.js +78 -17
- package/src/codex-error-text.js +114 -0
- package/src/config-dir-migration.js +11 -6
- package/src/config.js +23 -3
- package/src/connection-info.js +73 -14
- package/src/continuations.js +153 -40
- package/src/conversation-scanner.js +2 -21
- package/src/conversation-search.js +4 -17
- package/src/dev-preview.js +2 -1
- package/src/docker-session.js +10 -1
- package/src/doctor.js +14 -3
- package/src/durable-write.js +35 -0
- package/src/environments/authority.js +7 -1
- package/src/event-normalizer.js +35 -2
- package/src/folder-trust-wire.js +137 -0
- package/src/folder-trust-worker.js +17 -0
- package/src/folder-trust.js +1572 -0
- package/src/freshness/activity-meter.js +101 -0
- package/src/freshness/adapter.js +199 -0
- package/src/freshness/checks.js +239 -0
- package/src/freshness/config.js +98 -0
- package/src/freshness/core.js +185 -0
- package/src/freshness/derive.js +680 -0
- package/src/freshness/exchange.js +305 -0
- package/src/freshness/file-ledger.js +400 -0
- package/src/freshness/grade.js +81 -0
- package/src/freshness/hash.js +45 -0
- package/src/freshness/inbox.js +163 -0
- package/src/freshness/index.js +20 -0
- package/src/freshness/investigation.js +474 -0
- package/src/freshness/keys.js +177 -0
- package/src/freshness/ledger.js +122 -0
- package/src/freshness/outbox.js +131 -0
- package/src/freshness/policy.js +599 -0
- package/src/freshness/queue.js +843 -0
- package/src/freshness/read-errors.js +23 -0
- package/src/freshness/render.js +153 -0
- package/src/freshness/runtime.js +113 -0
- package/src/freshness/session-registry-adapter.js +161 -0
- package/src/freshness/state-file-adapter.js +167 -0
- package/src/freshness-runner/build-info.js +139 -0
- package/src/freshness-runner/cli.js +105 -0
- package/src/freshness-runner/run-tick.js +109 -0
- package/src/freshness-runner/stamp.js +57 -0
- package/src/freshness-sources/claude-transcript-adapter.js +211 -0
- package/src/freshness-sources/codex-transcript-adapter.js +33 -0
- package/src/freshness-sources/index.js +8 -0
- package/src/gemini-byok-session.js +292 -0
- package/src/gemini-credentials.js +67 -0
- package/src/gemini-key-safety.js +246 -0
- package/src/gemini-models.js +386 -0
- package/src/handler-utils.js +6 -13
- package/src/handlers/checkpoint-handlers.js +8 -0
- package/src/handlers/folder-trust-handlers.js +90 -0
- package/src/handlers/input-handlers.js +40 -11
- package/src/handlers/principal-admin-handlers.js +229 -0
- package/src/handlers/principal-handlers.js +262 -0
- package/src/handlers/scheduler-handlers.js +4 -4
- package/src/handlers/session-handlers.js +10 -1
- package/src/handlers/settings-handlers.js +42 -8
- package/src/handlers/skills-handlers.js +7 -0
- package/src/history-page.js +8 -0
- package/src/jsonl-reader.js +90 -10
- package/src/jsonl-subprocess-session.js +4 -1
- package/src/logger.js +105 -15
- package/src/mailbox-route.js +102 -0
- package/src/notification-prefs.js +15 -0
- package/src/orchestration/orchestration-manager.js +38 -9
- package/src/orchestration/permission-gate.js +4 -1
- package/src/orchestration/run-record.js +11 -0
- package/src/orchestration/turn-driver.js +151 -33
- package/src/orphan-reaper.js +77 -20
- package/src/outgoing-policy.js +10 -4
- package/src/permission-floor.js +54 -2
- package/src/permission-manager.js +32 -13
- package/src/permission-resolved-by.js +89 -0
- package/src/permission-resolver.js +7 -3
- package/src/platform.js +156 -4
- package/src/principal-audit.js +189 -0
- package/src/principal-binding.js +25 -0
- package/src/principal-brakes.js +21 -0
- package/src/principal-effect.js +101 -0
- package/src/principal-journal.js +905 -0
- package/src/principal-kill-switch.js +183 -0
- package/src/principal-label.js +5 -0
- package/src/principal-pending-permissions.js +177 -0
- package/src/principal-policy.js +1094 -0
- package/src/principal-sessions-snapshot.js +208 -0
- package/src/principal-store.js +488 -0
- package/src/principal-subscriptions.js +283 -0
- package/src/providers.js +2 -0
- package/src/redaction.js +181 -22
- package/src/scheduled-task-store.js +12 -0
- package/src/scheduler.js +304 -17
- package/src/sdk-session.js +60 -7
- package/src/server-cli/push-notification-handler.js +6 -1
- package/src/server-cli.js +30 -1
- package/src/session-ci-watcher.js +210 -37
- package/src/session-manager.js +590 -19
- package/src/session-message-history.js +121 -2
- package/src/session-name-allocator.js +685 -0
- package/src/statusline.js +78 -19
- package/src/summarize-session.js +2 -0
- package/src/turn-outcome.js +5 -2
- package/src/utils/argv-safety.js +29 -0
- package/src/utils/binary-package-manifest.js +57 -15
- package/src/utils/bounded-regex-worker.js +4 -0
- package/src/utils/bounded-regex.js +16 -7
- package/src/utils/pid-liveness.js +47 -0
- package/src/web-task-manager.js +45 -4
- package/src/worktree-gc.js +195 -4
- package/src/ws-auth.js +103 -19
- package/src/ws-broadcaster.js +39 -7
- package/src/ws-client-manager.js +8 -0
- package/src/ws-file-ops/browser.js +35 -3
- package/src/ws-forwarding.js +23 -3
- package/src/ws-handler-context.js +18 -0
- package/src/ws-history.js +79 -12
- package/src/ws-message-handlers.js +10 -2
- package/src/ws-server.js +253 -13
|
@@ -140,6 +140,10 @@ export function streamKindOf(entry) {
|
|
|
140
140
|
return undefined
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/** #9024: the most tool-call split points one reply entry records, and the longest tool id one may name (the protocol's `splits` schema mirrors both). */
|
|
144
|
+
export const MAX_REPLY_SPLITS = 64
|
|
145
|
+
export const MAX_SPLIT_TOOL_ID_LENGTH = 256
|
|
146
|
+
|
|
143
147
|
/** `{ input }` when there is one, else nothing: an absent input is an absent key. */
|
|
144
148
|
function inputField(input) {
|
|
145
149
|
return input === undefined ? {} : { input }
|
|
@@ -185,6 +189,12 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
185
189
|
this._maxToolInput = maxToolInput || null
|
|
186
190
|
this._maxPendingStreamSize = maxPendingStreamSize || MAX_PENDING_STREAM_SIZE
|
|
187
191
|
this._messageHistory = new Map() // sessionId -> Array<{ type, _seq, ...data }>
|
|
192
|
+
// #8415 -- entry object -> the last seq issued when its tool input was filled in
|
|
193
|
+
// after the entry was recorded (`backfillToolInput`). A WeakMap on purpose: the
|
|
194
|
+
// marker is no field of the entry, so it is never persisted, never copied by
|
|
195
|
+
// `truncateEntry`, and needs no seq of its own. A daemon restart (or `setHistory`)
|
|
196
|
+
// forgets it; that limitation is accepted.
|
|
197
|
+
this._toolInputFillSeqs = new WeakMap()
|
|
188
198
|
this._pendingStreams = new Map() // sessionId:messageId -> accumulated delta text
|
|
189
199
|
// #6431 — messageIds whose pending stream has already been truncated, so the
|
|
190
200
|
// truncation is signalled to the client ONCE per stream (every subsequent
|
|
@@ -204,6 +214,12 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
204
214
|
// a replay has no entry for it; this is where that text belongs in the replay
|
|
205
215
|
// (before every entry recorded after the stream began). Cleared with the stream.
|
|
206
216
|
this._streamStartSeqs = new Map()
|
|
217
|
+
// #9024 -- sessionId:messageId -> [{ at, toolUseId }]: where tool calls interrupted an
|
|
218
|
+
// open reply stream. `at` is how much of the stream's text existed when the call
|
|
219
|
+
// started. A reply is recorded as ONE entry at stream_end (after the tool cards), so
|
|
220
|
+
// a replay lost where each tool call fell in the text; the entry carries these as
|
|
221
|
+
// `splits` and the client lays the text out around the cards again. Cleared with the stream.
|
|
222
|
+
this._streamSplits = new Map()
|
|
207
223
|
this._historyTruncated = new Map() // sessionId -> boolean
|
|
208
224
|
// #5555.3 (lastSeq delta replay) — per-session monotonic history sequence.
|
|
209
225
|
// Every entry pushed into the ring buffer is stamped with a strictly
|
|
@@ -339,6 +355,7 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
339
355
|
this._streamKinds.delete(key)
|
|
340
356
|
this._streamPrecedes.delete(key)
|
|
341
357
|
this._streamStartSeqs.delete(key)
|
|
358
|
+
this._streamSplits.delete(key)
|
|
342
359
|
}
|
|
343
360
|
}
|
|
344
361
|
return closedMessageIds
|
|
@@ -357,9 +374,10 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
357
374
|
* capability), as is a stream that has produced no text yet.
|
|
358
375
|
*
|
|
359
376
|
* @param {string} sessionId
|
|
360
|
-
* @returns {Array<{ messageId: string, content: string, startSeq: number }>}
|
|
377
|
+
* @returns {Array<{ messageId: string, content: string, startSeq: number, splits: Array<{ at: number, toolUseId: string }> }>}
|
|
361
378
|
* `startSeq` is the seq the next recorded entry had when its first text arrived:
|
|
362
|
-
* the reply belongs before every entry with `_seq >= startSeq`.
|
|
379
|
+
* the reply belongs before every entry with `_seq >= startSeq`. `splits` are the
|
|
380
|
+
* tool calls that interrupted it so far (#9024), as the closing entry will carry.
|
|
363
381
|
*/
|
|
364
382
|
getPendingResponseStreams(sessionId) {
|
|
365
383
|
const prefix = sessionId + ':'
|
|
@@ -371,6 +389,7 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
371
389
|
messageId: key.slice(prefix.length),
|
|
372
390
|
content,
|
|
373
391
|
startSeq: this._streamStartSeqs.get(key) ?? Infinity,
|
|
392
|
+
splits: (this._streamSplits.get(key) ?? []).map((split) => ({ ...split })),
|
|
374
393
|
})
|
|
375
394
|
}
|
|
376
395
|
return out
|
|
@@ -779,6 +798,7 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
779
798
|
case 'stream_start': {
|
|
780
799
|
const key = `${sessionId}:${data.messageId}`
|
|
781
800
|
this._pendingStreams.set(key, '')
|
|
801
|
+
this._streamSplits.delete(key)
|
|
782
802
|
// #6630 / #8282: a reasoning stream must not be recorded as a reply.
|
|
783
803
|
if (data.thinking === true) {
|
|
784
804
|
this._streamKinds.set(key, 'thinking')
|
|
@@ -828,6 +848,8 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
828
848
|
this._streamPrecedes.delete(key)
|
|
829
849
|
const wasTruncated = this._truncatedStreams.has(key)
|
|
830
850
|
this._streamStartSeqs.delete(key)
|
|
851
|
+
const splits = this._streamSplits.get(key)
|
|
852
|
+
this._streamSplits.delete(key)
|
|
831
853
|
this._truncatedStreams.delete(key) // #6431 — release the once-per-stream guard
|
|
832
854
|
// A reasoning stream is recorded even with no text: current Claude models
|
|
833
855
|
// return the block with its signature only, so the SDK opens and closes a
|
|
@@ -860,6 +882,10 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
860
882
|
// belongs above keeps saying so, so a reload orders it the way the live
|
|
861
883
|
// client did. Absent for a block that arrived in order.
|
|
862
884
|
...(thinkingPrecedes ? { thinkingPrecedes } : {}),
|
|
885
|
+
// #9024: where tool calls interrupted this reply's text, so a reload lays it
|
|
886
|
+
// out around the tool cards as the live client did. Additive: a client that
|
|
887
|
+
// does not read it shows the one entry as before.
|
|
888
|
+
...(kind !== 'thinking' && splits?.length ? { splits } : {}),
|
|
863
889
|
timestamp: Date.now(),
|
|
864
890
|
}, sessionId)
|
|
865
891
|
}
|
|
@@ -897,6 +923,7 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
897
923
|
break
|
|
898
924
|
|
|
899
925
|
case 'tool_start':
|
|
926
|
+
this._noteReplySplit(sessionId, data.toolUseId)
|
|
900
927
|
this._pushHistory(history, {
|
|
901
928
|
type: 'tool_start',
|
|
902
929
|
messageId: data.messageId,
|
|
@@ -1029,6 +1056,43 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
1029
1056
|
return { persistNeeded, ...(assistantCompleted ? { assistantCompleted, completedAssistant } : {}) }
|
|
1030
1057
|
}
|
|
1031
1058
|
|
|
1059
|
+
/**
|
|
1060
|
+
* #9024 -- note where a tool call interrupted each open reply stream of the session.
|
|
1061
|
+
*
|
|
1062
|
+
* A `tool_start` carries no stream id, so it applies to EVERY open non-thinking reply
|
|
1063
|
+
* stream of the session (there is normally one). A reply that is not the tool's owner
|
|
1064
|
+
* then carries a split naming a tool row that is not its own, which is harmless: the
|
|
1065
|
+
* client lays a reply out only around tool rows it holds, in transcript order.
|
|
1066
|
+
*
|
|
1067
|
+
* A split is kept only when the stream has text since the previous one, so a run of
|
|
1068
|
+
* tool calls in a row keeps the first (the text sits above it, and no text sits
|
|
1069
|
+
* between them). The list is bounded in count and in the length of the id, and a
|
|
1070
|
+
* call with no usable id splits nothing: an unusable split must never become a
|
|
1071
|
+
* position on a client.
|
|
1072
|
+
*
|
|
1073
|
+
* @param {string} sessionId
|
|
1074
|
+
* @param {unknown} toolUseId
|
|
1075
|
+
*/
|
|
1076
|
+
_noteReplySplit(sessionId, toolUseId) {
|
|
1077
|
+
if (typeof toolUseId !== 'string' || toolUseId.length === 0 || toolUseId.length > MAX_SPLIT_TOOL_ID_LENGTH) return
|
|
1078
|
+
const prefix = sessionId + ':'
|
|
1079
|
+
for (const [key, content] of this._pendingStreams) {
|
|
1080
|
+
if (!key.startsWith(prefix) || !content) continue
|
|
1081
|
+
if (this._streamKinds.get(key) === 'thinking') continue
|
|
1082
|
+
const splits = this._streamSplits.get(key) ?? []
|
|
1083
|
+
if (splits.length >= MAX_REPLY_SPLITS) continue
|
|
1084
|
+
if (content.length <= (splits.at(-1)?.at ?? 0)) continue
|
|
1085
|
+
// Never between the two halves of a surrogate pair: the next delta carries the low
|
|
1086
|
+
// half, and a piece must not start with half a character.
|
|
1087
|
+
let at = content.length
|
|
1088
|
+
const lastUnit = content.charCodeAt(at - 1)
|
|
1089
|
+
if (lastUnit >= 0xd800 && lastUnit <= 0xdbff) at -= 1
|
|
1090
|
+
if (at <= (splits.at(-1)?.at ?? 0)) continue
|
|
1091
|
+
splits.push({ at, toolUseId })
|
|
1092
|
+
this._streamSplits.set(key, splits)
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1032
1096
|
/**
|
|
1033
1097
|
* Push an entry to the history array, trimming to max size.
|
|
1034
1098
|
* @param {Array} history
|
|
@@ -1079,6 +1143,14 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
1079
1143
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
1080
1144
|
const entry = history[i]
|
|
1081
1145
|
if (entry && entry.type === 'tool_start' && entry.toolUseId === toolUseId) {
|
|
1146
|
+
// #8415: a client whose cursor already covers this entry holds the card
|
|
1147
|
+
// without its input, and the fill takes no seq of its own. Record when it
|
|
1148
|
+
// happened so a delta replay can tell that client. Only a fill of an input
|
|
1149
|
+
// the entry did not have counts: an entry recorded with its input (the
|
|
1150
|
+
// claude-tui shape) was sent with it.
|
|
1151
|
+
if (!isPlainObject(entry.input) && isPlainObject(input)) {
|
|
1152
|
+
this._toolInputFillSeqs.set(entry, this.getLastIssuedSeq(sessionId))
|
|
1153
|
+
}
|
|
1082
1154
|
entry.input = input
|
|
1083
1155
|
return true
|
|
1084
1156
|
}
|
|
@@ -1086,6 +1158,41 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
1086
1158
|
return false
|
|
1087
1159
|
}
|
|
1088
1160
|
|
|
1161
|
+
/**
|
|
1162
|
+
* #8415 -- the tool inputs a client at `cursor` holds a card for but not the input
|
|
1163
|
+
* of: retained `tool_start` entries at or before the cursor whose input was filled
|
|
1164
|
+
* in at or after it. An entry past the cursor is in the delta slice already, with
|
|
1165
|
+
* its input. Stored values are returned as they are (already sanitised): the frame
|
|
1166
|
+
* inherits the `sanitizeToolInput` cap.
|
|
1167
|
+
*
|
|
1168
|
+
* With cursor == fillSeq the frame repeats on every reconnect until a newer entry is
|
|
1169
|
+
* recorded. That is idempotent (a client never overwrites a held input) and bounded
|
|
1170
|
+
* by the history ring.
|
|
1171
|
+
*
|
|
1172
|
+
* @param {string} sessionId
|
|
1173
|
+
* @param {number} cursor - the client's history cursor
|
|
1174
|
+
* @returns {Array<{messageId: string, toolUseId?: string, input: object}>}
|
|
1175
|
+
*/
|
|
1176
|
+
getToolInputBackfills(sessionId, cursor) {
|
|
1177
|
+
const history = this._messageHistory.get(sessionId)
|
|
1178
|
+
if (!Array.isArray(history)) return []
|
|
1179
|
+
const out = []
|
|
1180
|
+
for (const entry of history) {
|
|
1181
|
+
if (!entry || entry.type !== 'tool_start') continue
|
|
1182
|
+
const fillSeq = this._toolInputFillSeqs.get(entry)
|
|
1183
|
+
if (fillSeq === undefined) continue
|
|
1184
|
+
if (typeof entry._seq !== 'number' || !isPlainObject(entry.input)) continue
|
|
1185
|
+
if (typeof entry.messageId !== 'string' || !entry.messageId) continue
|
|
1186
|
+
if (!(entry._seq <= cursor && cursor <= fillSeq)) continue
|
|
1187
|
+
out.push({
|
|
1188
|
+
messageId: entry.messageId,
|
|
1189
|
+
...(typeof entry.toolUseId === 'string' ? { toolUseId: entry.toolUseId } : {}),
|
|
1190
|
+
input: entry.input,
|
|
1191
|
+
})
|
|
1192
|
+
}
|
|
1193
|
+
return out
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1089
1196
|
/**
|
|
1090
1197
|
* Shallow-clone and truncate a history entry for serialization.
|
|
1091
1198
|
* Content/input fields >50KB are truncated to avoid bloated state files.
|
|
@@ -1112,6 +1219,14 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
1112
1219
|
delete clone._seq
|
|
1113
1220
|
if (typeof clone.content === 'string' && clone.content.length > MAX) {
|
|
1114
1221
|
clone.content = clone.content.slice(0, MAX) + '[truncated]'
|
|
1222
|
+
// #9024: a split past the clipped text points into text that is gone (or into the
|
|
1223
|
+
// marker). One out-of-range point makes a client drop the whole list, so keep only
|
|
1224
|
+
// those strictly inside what was kept (one AT the clip would leave the marker alone as a tail).
|
|
1225
|
+
if (Array.isArray(clone.splits)) {
|
|
1226
|
+
const kept = clone.splits.filter((split) => split && typeof split.at === 'number' && split.at < MAX)
|
|
1227
|
+
if (kept.length > 0) clone.splits = kept
|
|
1228
|
+
else delete clone.splits
|
|
1229
|
+
}
|
|
1115
1230
|
}
|
|
1116
1231
|
if (typeof clone.input === 'string' && clone.input.length > MAX) {
|
|
1117
1232
|
clone.input = clone.input.slice(0, MAX) + '[truncated]'
|
|
@@ -1205,6 +1320,9 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
1205
1320
|
for (const key of this._streamStartSeqs.keys()) {
|
|
1206
1321
|
if (key.startsWith(prefix)) this._streamStartSeqs.delete(key)
|
|
1207
1322
|
}
|
|
1323
|
+
for (const key of this._streamSplits.keys()) {
|
|
1324
|
+
if (key.startsWith(prefix)) this._streamSplits.delete(key)
|
|
1325
|
+
}
|
|
1208
1326
|
}
|
|
1209
1327
|
|
|
1210
1328
|
/**
|
|
@@ -1217,6 +1335,7 @@ export class SessionMessageHistory extends EventEmitter {
|
|
|
1217
1335
|
this._streamKinds.clear()
|
|
1218
1336
|
this._streamPrecedes.clear()
|
|
1219
1337
|
this._streamStartSeqs.clear()
|
|
1338
|
+
this._streamSplits.clear()
|
|
1220
1339
|
this._seqCounters.clear()
|
|
1221
1340
|
this._seqReserved.clear()
|
|
1222
1341
|
}
|