aicodeman 1.24.6 → 1.25.0
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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +17 -2
- package/dist/cli.js.map +1 -1
- package/dist/config/base-path.d.ts +55 -0
- package/dist/config/base-path.d.ts.map +1 -0
- package/dist/config/base-path.js +105 -0
- package/dist/config/base-path.js.map +1 -0
- package/dist/config/cli-registry/schema.d.ts +2 -0
- package/dist/config/cli-registry/schema.d.ts.map +1 -1
- package/dist/config/cli-registry/schema.js +1 -1
- package/dist/config/cli-registry/schema.js.map +1 -1
- package/dist/config/cli-registry/stock.d.ts.map +1 -1
- package/dist/config/cli-registry/stock.js +4 -1
- package/dist/config/cli-registry/stock.js.map +1 -1
- package/dist/config/cli-registry/types.d.ts +9 -0
- package/dist/config/cli-registry/types.d.ts.map +1 -1
- package/dist/daemon-control.d.ts +2 -0
- package/dist/daemon-control.d.ts.map +1 -1
- package/dist/daemon-control.js +2 -0
- package/dist/daemon-control.js.map +1 -1
- package/dist/docker-export.d.ts.map +1 -1
- package/dist/docker-export.js +8 -1
- package/dist/docker-export.js.map +1 -1
- package/dist/docker-hosts.d.ts +97 -3
- package/dist/docker-hosts.d.ts.map +1 -1
- package/dist/docker-hosts.js +260 -4
- package/dist/docker-hosts.js.map +1 -1
- package/dist/hooks-config.d.ts.map +1 -1
- package/dist/hooks-config.js +39 -3
- package/dist/hooks-config.js.map +1 -1
- package/dist/session.d.ts +31 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +101 -5
- package/dist/session.js.map +1 -1
- package/dist/tmux-manager.d.ts.map +1 -1
- package/dist/tmux-manager.js +54 -8
- package/dist/tmux-manager.js.map +1 -1
- package/dist/types/api.d.ts +19 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/api.js.map +1 -1
- package/dist/types/session.d.ts +49 -0
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js.map +1 -1
- package/dist/types/update.d.ts +51 -3
- package/dist/types/update.d.ts.map +1 -1
- package/dist/types/update.js +4 -0
- package/dist/types/update.js.map +1 -1
- package/dist/web/middleware/auth.d.ts +3 -3
- package/dist/web/middleware/auth.d.ts.map +1 -1
- package/dist/web/middleware/auth.js +13 -11
- package/dist/web/middleware/auth.js.map +1 -1
- package/dist/web/public/admin-ui.js.gz +0 -0
- package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
- package/dist/web/public/app.3a89ac57.js +38 -0
- package/dist/web/public/app.3a89ac57.js.br +0 -0
- package/dist/web/public/app.3a89ac57.js.gz +0 -0
- package/dist/web/public/approvals-ui.js.gz +0 -0
- package/dist/web/public/{constants.7bd482dc.js → constants.7a635e34.js} +58 -0
- package/dist/web/public/constants.7a635e34.js.br +0 -0
- package/dist/web/public/constants.7a635e34.js.gz +0 -0
- package/dist/web/public/cron-ui.js.gz +0 -0
- package/dist/web/public/entrance-animations.js.gz +0 -0
- package/dist/web/public/home-sessions.js.gz +0 -0
- package/dist/web/public/i18n.9db8c4e0.js +1 -0
- package/dist/web/public/i18n.9db8c4e0.js.br +0 -0
- package/dist/web/public/i18n.9db8c4e0.js.gz +0 -0
- package/dist/web/public/image-input.ee16ad88.js.gz +0 -0
- package/dist/web/public/index.html +46 -17
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.87f14251.js.gz +0 -0
- package/dist/web/public/{keyboard-accessory.0454a3e9.js → keyboard-accessory.daf18302.js} +8 -4
- package/dist/web/public/keyboard-accessory.daf18302.js.br +0 -0
- package/dist/web/public/keyboard-accessory.daf18302.js.gz +0 -0
- package/dist/web/public/manifest.json +2 -1
- package/dist/web/public/mobile-handlers.0f83a608.js.gz +0 -0
- package/dist/web/public/mobile-overview.js.gz +0 -0
- package/dist/web/public/{mobile.87674154.css → mobile.7112f27d.css} +1 -1
- package/dist/web/public/{mobile.87674154.css.br → mobile.7112f27d.css.br} +0 -0
- package/dist/web/public/mobile.7112f27d.css.gz +0 -0
- package/dist/web/public/{notification-manager.5d229063.js → notification-manager.36ea4624.js} +1 -1
- package/dist/web/public/notification-manager.36ea4624.js.br +0 -0
- package/dist/web/public/notification-manager.36ea4624.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/{panels-ui.e6e06034.js → panels-ui.db4785bf.js} +8 -8
- package/dist/web/public/panels-ui.db4785bf.js.br +0 -0
- package/dist/web/public/panels-ui.db4785bf.js.gz +0 -0
- package/dist/web/public/ralph-panel.6de2d0f8.js.gz +0 -0
- package/dist/web/public/ralph-wizard.13a1831e.js.gz +0 -0
- package/dist/web/public/readmymind-ui.js.gz +0 -0
- package/dist/web/public/respawn-ui.ff0dae4c.js.gz +0 -0
- package/dist/web/public/sanitize-html.bc7078d6.js.gz +0 -0
- package/dist/web/public/session-lineage.js.gz +0 -0
- package/dist/web/public/session-ui.58116fce.js +68 -0
- package/dist/web/public/session-ui.58116fce.js.br +0 -0
- package/dist/web/public/session-ui.58116fce.js.gz +0 -0
- package/dist/web/public/{settings-ui.95b333c6.js → settings-ui.554f9cdd.js} +1 -1
- package/dist/web/public/settings-ui.554f9cdd.js.br +0 -0
- package/dist/web/public/settings-ui.554f9cdd.js.gz +0 -0
- package/dist/web/public/{styles.421b36d4.css → styles.2a35729d.css} +1 -1
- package/dist/web/public/styles.2a35729d.css.br +0 -0
- package/dist/web/public/{styles.421b36d4.css.gz → styles.2a35729d.css.gz} +0 -0
- package/dist/web/public/subagent-windows.e6ca799f.js.gz +0 -0
- package/dist/web/public/sw.js +13 -6
- package/dist/web/public/sw.js.br +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/tab-rail-resize.42c24949.js.gz +0 -0
- package/dist/web/public/terminal-ui.70445f81.js.gz +0 -0
- package/dist/web/public/ultracode-panel.js.gz +0 -0
- package/dist/web/public/ultracode-windows.js.gz +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
- package/dist/web/public/vendor/marked.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-predictive-echo.bd6882b8.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.6fee72f2.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/public/{voice-input.4ec670b0.js → voice-input.c4b51eb6.js} +1 -1
- package/dist/web/public/voice-input.c4b51eb6.js.br +0 -0
- package/dist/web/public/voice-input.c4b51eb6.js.gz +0 -0
- package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
- package/dist/web/public/webview-tabs.js +3 -1
- package/dist/web/public/webview-tabs.js.br +0 -0
- package/dist/web/public/webview-tabs.js.gz +0 -0
- package/dist/web/route-helpers.d.ts.map +1 -1
- package/dist/web/route-helpers.js +5 -0
- package/dist/web/route-helpers.js.map +1 -1
- package/dist/web/routes/admin-routes.d.ts.map +1 -1
- package/dist/web/routes/admin-routes.js +6 -1
- package/dist/web/routes/admin-routes.js.map +1 -1
- package/dist/web/routes/case-routes.d.ts.map +1 -1
- package/dist/web/routes/case-routes.js +188 -4
- package/dist/web/routes/case-routes.js.map +1 -1
- package/dist/web/routes/file-routes.d.ts.map +1 -1
- package/dist/web/routes/file-routes.js +62 -4
- package/dist/web/routes/file-routes.js.map +1 -1
- package/dist/web/routes/hook-event-routes.d.ts.map +1 -1
- package/dist/web/routes/hook-event-routes.js +29 -3
- package/dist/web/routes/hook-event-routes.js.map +1 -1
- package/dist/web/routes/session-routes.d.ts.map +1 -1
- package/dist/web/routes/session-routes.js +121 -56
- package/dist/web/routes/session-routes.js.map +1 -1
- package/dist/web/routes/system-routes.d.ts.map +1 -1
- package/dist/web/routes/system-routes.js +3 -0
- package/dist/web/routes/system-routes.js.map +1 -1
- package/dist/web/routes/webview-routes.d.ts +2 -2
- package/dist/web/routes/webview-routes.d.ts.map +1 -1
- package/dist/web/routes/webview-routes.js +62 -27
- package/dist/web/routes/webview-routes.js.map +1 -1
- package/dist/web/schemas.d.ts +29 -0
- package/dist/web/schemas.d.ts.map +1 -1
- package/dist/web/schemas.js +75 -0
- package/dist/web/schemas.js.map +1 -1
- package/dist/web/self-update.d.ts +92 -2
- package/dist/web/self-update.d.ts.map +1 -1
- package/dist/web/self-update.js +275 -13
- package/dist/web/self-update.js.map +1 -1
- package/dist/web/server.d.ts +4 -2
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +55 -11
- package/dist/web/server.js.map +1 -1
- package/dist/web/sse-events.d.ts +4 -2
- package/dist/web/sse-events.d.ts.map +1 -1
- package/dist/web/sse-events.js +4 -2
- package/dist/web/sse-events.js.map +1 -1
- package/dist/web/webview-egress-policy.d.ts +35 -0
- package/dist/web/webview-egress-policy.d.ts.map +1 -0
- package/dist/web/webview-egress-policy.js +163 -0
- package/dist/web/webview-egress-policy.js.map +1 -0
- package/dist/web/webview-egress.d.ts +71 -0
- package/dist/web/webview-egress.d.ts.map +1 -0
- package/dist/web/webview-egress.js +127 -0
- package/dist/web/webview-egress.js.map +1 -0
- package/dist/web/webview-proxy.d.ts +16 -7
- package/dist/web/webview-proxy.d.ts.map +1 -1
- package/dist/web/webview-proxy.js +40 -15
- package/dist/web/webview-proxy.js.map +1 -1
- package/dist/webview-capabilities.d.ts +19 -3
- package/dist/webview-capabilities.d.ts.map +1 -1
- package/dist/webview-capabilities.js +21 -2
- package/dist/webview-capabilities.js.map +1 -1
- package/package.json +9 -7
- package/skills/codeman/reference/endpoints.md +1 -0
- package/skills/codeman/reference/verbs.md +11 -1
- package/dist/web/public/app.a5d2fc08.js +0 -38
- package/dist/web/public/app.a5d2fc08.js.br +0 -0
- package/dist/web/public/app.a5d2fc08.js.gz +0 -0
- package/dist/web/public/constants.7bd482dc.js.br +0 -0
- package/dist/web/public/constants.7bd482dc.js.gz +0 -0
- package/dist/web/public/i18n.9ae15b51.js +0 -1
- package/dist/web/public/i18n.9ae15b51.js.br +0 -0
- package/dist/web/public/i18n.9ae15b51.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.0454a3e9.js.br +0 -0
- package/dist/web/public/keyboard-accessory.0454a3e9.js.gz +0 -0
- package/dist/web/public/mobile.87674154.css.gz +0 -0
- package/dist/web/public/notification-manager.5d229063.js.br +0 -0
- package/dist/web/public/notification-manager.5d229063.js.gz +0 -0
- package/dist/web/public/panels-ui.e6e06034.js.br +0 -0
- package/dist/web/public/panels-ui.e6e06034.js.gz +0 -0
- package/dist/web/public/session-ui.c558f981.js +0 -68
- package/dist/web/public/session-ui.c558f981.js.br +0 -0
- package/dist/web/public/session-ui.c558f981.js.gz +0 -0
- package/dist/web/public/settings-ui.95b333c6.js.br +0 -0
- package/dist/web/public/settings-ui.95b333c6.js.gz +0 -0
- package/dist/web/public/styles.421b36d4.css.br +0 -0
- package/dist/web/public/voice-input.4ec670b0.js.br +0 -0
- package/dist/web/public/voice-input.4ec670b0.js.gz +0 -0
|
@@ -13,6 +13,7 @@ import { performance } from 'node:perf_hooks';
|
|
|
13
13
|
import { ApiErrorCode, createErrorResponse, getErrorMessage, } from '../../types.js';
|
|
14
14
|
import { Session, isAltScreenStripMode, isExternalCliMode, isMuxAltScreenOnlyStripMode } from '../../session.js';
|
|
15
15
|
import { SseEvent } from '../sse-events.js';
|
|
16
|
+
import { webviewCapabilities } from '../../webview-capabilities.js';
|
|
16
17
|
import { CreateSessionSchema, SessionNameSchema, SessionColorSchema, RunPromptSchema, SessionInputWithLimitSchema, ResizeSchema, AutoClearSchema, AutoCompactSchema, AutoResumeSchema, PinSessionSchema, ImageWatcherSchema, FlickerFilterSchema, QuickRunSchema, QuickStartSchema, InteractiveStartSchema, SessionOrderUpdateSchema, SessionWaitQuerySchema, SessionWaitOutputQuerySchema, } from '../schemas.js';
|
|
17
18
|
import { ownerLayoutKey } from '../../tab-layout-persistence.js';
|
|
18
19
|
import { TabLayoutValidationError } from '../../tab-layout.js';
|
|
@@ -37,7 +38,7 @@ import { MAX_INPUT_LENGTH, MAX_SESSION_NAME_LENGTH } from '../../config/terminal
|
|
|
37
38
|
import { MAX_PASTE_IMAGE_BYTES } from '../../config/buffer-limits.js';
|
|
38
39
|
import { dataPath, getDataDir } from '../../config/instance.js';
|
|
39
40
|
import { checkRemoteTmuxAvailable, readRemoteCases, readRemoteHosts, toAttachedSessionRemote, toSessionRemote, } from '../../remote-hosts.js';
|
|
40
|
-
import { checkDockerAvailable, checkDockerConfigDrift, checkDockerTmuxAvailable, ensureAgentBaseImage, DEFAULT_AGENT_IMAGE, persistDockerCaseClaudeSessionId, readDockerCases, readDockerHosts, toSessionDocker, } from '../../docker-hosts.js';
|
|
41
|
+
import { checkDockerAvailable, checkDockerConfigDrift, probeAdoptableContainer, checkDockerTmuxAvailable, ensureAgentBaseImage, DEFAULT_AGENT_IMAGE, persistDockerCaseClaudeSessionId, readDockerCases, readDockerHosts, toSessionDocker, } from '../../docker-hosts.js';
|
|
41
42
|
import { LRUMap } from '../../utils/lru-map.js';
|
|
42
43
|
import { findLatestOmpSessionId } from '../../utils/omp-session-resolver.js';
|
|
43
44
|
import { scanOmpSessionsHistory } from '../../omp-transcript.js';
|
|
@@ -658,6 +659,10 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
658
659
|
if (sessionToken) {
|
|
659
660
|
ctx.authSessions?.delete(sessionToken);
|
|
660
661
|
}
|
|
662
|
+
// The web-tab proxy authenticates on capabilities, not on this cookie, so a
|
|
663
|
+
// logout has to retire them too or every dashboard URL opened during this
|
|
664
|
+
// login keeps relaying without one (WebviewCapabilityStore.revokeOwner).
|
|
665
|
+
webviewCapabilities.revokeOwner(ownerFor(req));
|
|
661
666
|
reply.clearCookie(AUTH_COOKIE_NAME, { path: '/' });
|
|
662
667
|
return {};
|
|
663
668
|
});
|
|
@@ -1547,9 +1552,18 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
1547
1552
|
// turn behind beats a viewer showing someone else's conversation.
|
|
1548
1553
|
const claudeHistoryPinCache = new LRUMap({ maxSize: 1024 });
|
|
1549
1554
|
async function resolveActiveClaudeSessionIdFromHistory(session, projectsDir) {
|
|
1555
|
+
// A pane whose conversation id came from its OWN hook needs no correlation:
|
|
1556
|
+
// $CODEMAN_SESSION_ID (the pane's env) -> data.session_id (the CLI's own
|
|
1557
|
+
// stdin JSON) is a first-hand binding that never looks at cwd, so it cannot
|
|
1558
|
+
// be stolen by a sibling pane, a closed tab, or a bare `claude` in a
|
|
1559
|
+
// terminal. Guessing can only be worse than the fact. This is also what
|
|
1560
|
+
// closes the hole below for a pane driven straight from tmux: it never
|
|
1561
|
+
// reaches `if (!submitAt)`.
|
|
1562
|
+
if (session.claudeSessionIdIsFirstHand)
|
|
1563
|
+
return null;
|
|
1550
1564
|
const submitAt = session.lastSubmitAt;
|
|
1551
1565
|
if (!submitAt)
|
|
1552
|
-
return null; //
|
|
1566
|
+
return null; // no anchor at all — nothing to credit
|
|
1553
1567
|
const cached = claudeHistoryPinCache.get(session.id);
|
|
1554
1568
|
if (cached && cached.submitAt === submitAt)
|
|
1555
1569
|
return cached.claudeSessionId;
|
|
@@ -1647,17 +1661,40 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
1647
1661
|
return /^(?:<local-command|<command-name>|<task-notification>|<system-reminder>|<teammate-message\b|Another Claude session sent a message:|Base directory for this skill:)/i.test(text);
|
|
1648
1662
|
}
|
|
1649
1663
|
/**
|
|
1650
|
-
* Claude writes
|
|
1651
|
-
*
|
|
1652
|
-
*
|
|
1653
|
-
*
|
|
1664
|
+
* Claude writes an append-only event log: tool results arrive as user rows,
|
|
1665
|
+
* thinking/tool_use rows carry no text, and a prompt typed while the agent is
|
|
1666
|
+
* working is only ever recorded as an `attachment/queued_command` row. But one
|
|
1667
|
+
* assistant row IS one whole model message: measured across ~/.claude/projects
|
|
1668
|
+
* (CLI 2.1.220-2.1.251) no assistant row carries more than one content block
|
|
1669
|
+
* and no message id carries more than one text block, so there is nothing to
|
|
1670
|
+
* reassemble. Emit one card per row and group them with `turn` instead of
|
|
1671
|
+
* concatenating a human turn's replies into a single card (#169), which fused
|
|
1672
|
+
* up to 74 distinct model messages into one card. Splitting is safe for
|
|
1673
|
+
* markdown: no adjacent pair of assistant text rows in the corpus continues a
|
|
1674
|
+
* table, a list, or an open code fence.
|
|
1654
1675
|
*/
|
|
1655
1676
|
function parseClaudeResponseTranscript(content, full) {
|
|
1656
1677
|
let lastText = '';
|
|
1657
1678
|
let lastTimestamp = '';
|
|
1658
1679
|
const messages = [];
|
|
1659
|
-
|
|
1660
|
-
|
|
1680
|
+
// #169's replay guards, kept: they now SKIP a duplicated row instead of
|
|
1681
|
+
// concatenating it into the previous card.
|
|
1682
|
+
const currentUserFragments = new Set();
|
|
1683
|
+
const currentAssistantFragments = new Set();
|
|
1684
|
+
// Turn 0 is reserved for anything emitted before the first human prompt.
|
|
1685
|
+
let turn = 0;
|
|
1686
|
+
const pushUserMessage = (text, timestamp, queued) => {
|
|
1687
|
+
// A run of consecutive human inputs (a mid-turn queued burst) is ONE turn,
|
|
1688
|
+
// so the viewer renders it under one badge instead of one badge per line.
|
|
1689
|
+
if (messages.at(-1)?.role !== 'user')
|
|
1690
|
+
turn += 1;
|
|
1691
|
+
const message = { kind: 'prompt', label: 'Prompt', role: 'user', text, timestamp, turn };
|
|
1692
|
+
if (queued)
|
|
1693
|
+
message.queued = true;
|
|
1694
|
+
messages.push(message);
|
|
1695
|
+
currentUserFragments.add(text);
|
|
1696
|
+
currentAssistantFragments.clear();
|
|
1697
|
+
};
|
|
1661
1698
|
for (const line of content.split('\n')) {
|
|
1662
1699
|
if (!line)
|
|
1663
1700
|
continue;
|
|
@@ -1672,6 +1709,30 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
1672
1709
|
// rows include repeated image dimensions and other UI-generated context.
|
|
1673
1710
|
if (entry.isSidechain)
|
|
1674
1711
|
continue;
|
|
1712
|
+
// A prompt typed while Claude is working is absorbed mid-turn and lives
|
|
1713
|
+
// ONLY in an attachment row, so it was lost outright. `origin.kind` and
|
|
1714
|
+
// `commandMode` separate the human's queue entries from the CLI's own:
|
|
1715
|
+
// measured over 57 real transcripts on 2026-09-01, 322 queued_command rows
|
|
1716
|
+
// split 163 `prompt`/`human` and 159 `task-notification`, and not one of
|
|
1717
|
+
// those 159 carries an `origin` key. The 163 human rows become 162 user
|
|
1718
|
+
// cards here — one is a verbatim repeat inside a still-unanswered user run
|
|
1719
|
+
// and is collapsed by the dedup guard below — out of 353 user cards total.
|
|
1720
|
+
if (entry.type === 'attachment') {
|
|
1721
|
+
if (!full)
|
|
1722
|
+
continue;
|
|
1723
|
+
const queued = entry.attachment;
|
|
1724
|
+
if (!queued || queued.type !== 'queued_command')
|
|
1725
|
+
continue;
|
|
1726
|
+
if (queued.origin?.kind !== 'human' || queued.commandMode !== 'prompt')
|
|
1727
|
+
continue;
|
|
1728
|
+
const text = typeof queued.prompt === 'string' ? queued.prompt.trim() : '';
|
|
1729
|
+
if (!text || isClaudeSyntheticUserMessage(entry, text))
|
|
1730
|
+
continue;
|
|
1731
|
+
if (currentUserFragments.has(text))
|
|
1732
|
+
continue;
|
|
1733
|
+
pushUserMessage(text, queued.timestamp || entry.timestamp, true);
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1675
1736
|
if (entry.type === 'user') {
|
|
1676
1737
|
const text = extractClaudeText(entry.message?.content, '\n').trim();
|
|
1677
1738
|
// A tool_result block has no text block and naturally drops out here.
|
|
@@ -1679,21 +1740,13 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
1679
1740
|
continue;
|
|
1680
1741
|
if (!full)
|
|
1681
1742
|
continue;
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
previous.text += `\n\n${text}`;
|
|
1690
|
-
currentUserFragments.add(text);
|
|
1691
|
-
}
|
|
1692
|
-
else {
|
|
1693
|
-
messages.push({ role: 'user', text, timestamp: entry.timestamp });
|
|
1694
|
-
currentUserFragments = new Set([text]);
|
|
1695
|
-
}
|
|
1696
|
-
currentAssistantFragments.clear();
|
|
1743
|
+
// Claude replays the initial user row while restoring a transcript, and
|
|
1744
|
+
// a CLI that also wrote an absorbed prompt as a user row would double it.
|
|
1745
|
+
// Both collapse here. The same prompt sent again AFTER a reply is a
|
|
1746
|
+
// legitimate second turn, because that reply cleared the set.
|
|
1747
|
+
if (currentUserFragments.has(text))
|
|
1748
|
+
continue;
|
|
1749
|
+
pushUserMessage(text, entry.timestamp, false);
|
|
1697
1750
|
continue;
|
|
1698
1751
|
}
|
|
1699
1752
|
if (entry.type !== 'assistant')
|
|
@@ -1705,20 +1758,11 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
1705
1758
|
lastTimestamp = entry.timestamp || '';
|
|
1706
1759
|
if (!full)
|
|
1707
1760
|
continue;
|
|
1708
|
-
|
|
1709
|
-
if (
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
continue;
|
|
1714
|
-
previous.text += `\n\n${text}`;
|
|
1715
|
-
previous.timestamp = entry.timestamp || previous.timestamp;
|
|
1716
|
-
currentAssistantFragments.add(text);
|
|
1717
|
-
}
|
|
1718
|
-
else {
|
|
1719
|
-
messages.push({ role: 'assistant', text, timestamp: entry.timestamp });
|
|
1720
|
-
currentAssistantFragments = new Set([text]);
|
|
1721
|
-
}
|
|
1761
|
+
// Replayed snapshots repeat an identical text block inside one turn.
|
|
1762
|
+
if (currentAssistantFragments.has(text))
|
|
1763
|
+
continue;
|
|
1764
|
+
messages.push({ kind: 'response', label: 'Response', role: 'assistant', text, timestamp: entry.timestamp, turn });
|
|
1765
|
+
currentAssistantFragments.add(text);
|
|
1722
1766
|
currentUserFragments.clear();
|
|
1723
1767
|
}
|
|
1724
1768
|
return full ? { text: lastText, timestamp: lastTimestamp, messages } : { text: lastText, timestamp: lastTimestamp };
|
|
@@ -2601,25 +2645,46 @@ export function registerSessionRoutes(app, ctx) {
|
|
|
2601
2645
|
return createErrorResponse(ApiErrorCode.OPERATION_FAILED, availability.error || 'docker daemon is not available');
|
|
2602
2646
|
}
|
|
2603
2647
|
const sessionDocker = toSessionDocker(host, dockerCase);
|
|
2604
|
-
//
|
|
2605
|
-
//
|
|
2606
|
-
//
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2648
|
+
// An ADOPTED container skips every image-side gate: we never run `docker
|
|
2649
|
+
// create`, so the image is the user's business, and `ensureAgentBaseImage`
|
|
2650
|
+
// would build/require an image that has nothing to do with their container.
|
|
2651
|
+
// The prerequisite that DOES still hold is tmux inside it, so probe the live
|
|
2652
|
+
// container (not the image) and refuse before launch rather than dead-paning.
|
|
2653
|
+
if (sessionDocker.owned === false) {
|
|
2654
|
+
const probe = await probeAdoptableContainer(sessionDocker, [mode]);
|
|
2655
|
+
if (!probe.ok) {
|
|
2656
|
+
return createErrorResponse(ApiErrorCode.OPERATION_FAILED, probe.error || 'container is not usable');
|
|
2657
|
+
}
|
|
2658
|
+
// The probe already exec'd into the container; carry its facts onto the
|
|
2659
|
+
// live session so the launch chain does not have to re-ask.
|
|
2660
|
+
sessionDocker.runsAsRoot = probe.runsAsRoot;
|
|
2661
|
+
// No `mode !== 'shell'` arm: a mode with no binary of its own is reported
|
|
2662
|
+
// available by the probe unconditionally, so this reads the same answer for it.
|
|
2663
|
+
if (!probe.availableModes?.includes(mode)) {
|
|
2664
|
+
return createErrorResponse(ApiErrorCode.OPERATION_FAILED, `"${mode}" is not installed in container "${sessionDocker.containerName}". Adoption never modifies the container — install it inside, or pick another mode.`);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
else {
|
|
2668
|
+
// Ensure the base image exists, auto-building the default image on first use so
|
|
2669
|
+
// it is never a blocker. Dedup'd with any build kicked off at case-create, so
|
|
2670
|
+
// this awaits the SAME in-flight build rather than starting a second one.
|
|
2671
|
+
const ensured = await ensureAgentBaseImage(sessionDocker, sessionDocker.image, {
|
|
2672
|
+
onProgress: (line) => ctx.broadcast(SseEvent.DockerImageBuildProgress, { name: dockerCase.name, line }),
|
|
2673
|
+
});
|
|
2674
|
+
if (!ensured.ok) {
|
|
2675
|
+
return createErrorResponse(ApiErrorCode.OPERATION_FAILED, ensured.error || 'base image not available');
|
|
2676
|
+
}
|
|
2677
|
+
if (ensured.built) {
|
|
2678
|
+
ctx.broadcast(SseEvent.DockerImageBuildComplete, { name: dockerCase.name, image: sessionDocker.image });
|
|
2679
|
+
}
|
|
2680
|
+
// tmux is a hard prerequisite (the in-container tmux makes reconnect durable).
|
|
2681
|
+
// Skip the extra container-run probe for our OWN default image (the baked
|
|
2682
|
+
// Dockerfile always contains tmux); still verify a custom image.
|
|
2683
|
+
if (sessionDocker.image !== DEFAULT_AGENT_IMAGE) {
|
|
2684
|
+
const tmuxCheck = await checkDockerTmuxAvailable(sessionDocker);
|
|
2685
|
+
if (!tmuxCheck.ok) {
|
|
2686
|
+
return createErrorResponse(ApiErrorCode.OPERATION_FAILED, tmuxCheck.error || 'base image is missing tmux');
|
|
2687
|
+
}
|
|
2623
2688
|
}
|
|
2624
2689
|
}
|
|
2625
2690
|
// Config drift (docs/docker-cases-plan.md §4): the desired create-config no
|