botmux 2.11.1 → 2.12.1
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/adapters/backend/pty-backend.d.ts +6 -0
- package/dist/adapters/backend/pty-backend.d.ts.map +1 -1
- package/dist/adapters/backend/pty-backend.js +6 -0
- package/dist/adapters/backend/pty-backend.js.map +1 -1
- package/dist/adapters/backend/tmux-backend.d.ts +16 -2
- package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-backend.js +40 -10
- package/dist/adapters/backend/tmux-backend.js.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.d.ts +59 -0
- package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -0
- package/dist/adapters/backend/tmux-pipe-backend.js +288 -0
- package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -0
- package/dist/adapters/cli/claude-code.d.ts +15 -0
- package/dist/adapters/cli/claude-code.d.ts.map +1 -1
- package/dist/adapters/cli/claude-code.js +205 -24
- package/dist/adapters/cli/claude-code.js.map +1 -1
- package/dist/adapters/cli/codex.d.ts.map +1 -1
- package/dist/adapters/cli/codex.js +78 -16
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/types.d.ts +10 -0
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/cli.js +63 -8
- package/dist/cli.js.map +1 -1
- package/dist/core/command-handler.d.ts +10 -0
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +29 -1
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/scheduler.d.ts +3 -0
- package/dist/core/scheduler.d.ts.map +1 -1
- package/dist/core/scheduler.js +3 -0
- package/dist/core/scheduler.js.map +1 -1
- package/dist/core/session-manager.d.ts +17 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +51 -3
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/types.d.ts +4 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +13 -1
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +115 -4
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +59 -120
- package/dist/daemon.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts +2 -1
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +23 -9
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +26 -93
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/merge-forward.d.ts +32 -0
- package/dist/im/lark/merge-forward.d.ts.map +1 -0
- package/dist/im/lark/merge-forward.js +99 -0
- package/dist/im/lark/merge-forward.js.map +1 -0
- package/dist/services/bridge-fallback-gate.d.ts +42 -0
- package/dist/services/bridge-fallback-gate.d.ts.map +1 -0
- package/dist/services/bridge-fallback-gate.js +12 -0
- package/dist/services/bridge-fallback-gate.js.map +1 -0
- package/dist/services/bridge-turn-queue.d.ts +111 -0
- package/dist/services/bridge-turn-queue.d.ts.map +1 -0
- package/dist/services/bridge-turn-queue.js +213 -0
- package/dist/services/bridge-turn-queue.js.map +1 -0
- package/dist/services/claude-transcript.d.ts +168 -0
- package/dist/services/claude-transcript.d.ts.map +1 -0
- package/dist/services/claude-transcript.js +524 -0
- package/dist/services/claude-transcript.js.map +1 -0
- package/dist/services/codex-bridge-queue.d.ts +39 -0
- package/dist/services/codex-bridge-queue.d.ts.map +1 -0
- package/dist/services/codex-bridge-queue.js +116 -0
- package/dist/services/codex-bridge-queue.js.map +1 -0
- package/dist/services/codex-transcript.d.ts +35 -0
- package/dist/services/codex-transcript.d.ts.map +1 -0
- package/dist/services/codex-transcript.js +163 -0
- package/dist/services/codex-transcript.js.map +1 -0
- package/dist/services/schedule-store.d.ts +3 -0
- package/dist/services/schedule-store.d.ts.map +1 -1
- package/dist/services/schedule-store.js +6 -0
- package/dist/services/schedule-store.js.map +1 -1
- package/dist/services/session-store.d.ts +10 -0
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +40 -0
- package/dist/services/session-store.js.map +1 -1
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +2 -1
- package/dist/skills/definitions.js.map +1 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/render-dimensions.d.ts +48 -0
- package/dist/utils/render-dimensions.d.ts.map +1 -0
- package/dist/utils/render-dimensions.js +55 -0
- package/dist/utils/render-dimensions.js.map +1 -0
- package/dist/utils/terminal-renderer.d.ts.map +1 -1
- package/dist/utils/terminal-renderer.js +5 -2
- package/dist/utils/terminal-renderer.js.map +1 -1
- package/dist/worker.js +1317 -37
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** Subset of Claude Code's JSONL event shape we care about. */
|
|
2
|
+
export interface TranscriptEvent {
|
|
3
|
+
type?: string;
|
|
4
|
+
uuid?: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
timestamp?: string;
|
|
7
|
+
message?: {
|
|
8
|
+
role?: string;
|
|
9
|
+
content?: unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface DrainResult {
|
|
13
|
+
events: TranscriptEvent[];
|
|
14
|
+
/** Byte offset to pass back on the next drain. */
|
|
15
|
+
newOffset: number;
|
|
16
|
+
/** Trailing partial line (no newline yet) — kept so the next drain can
|
|
17
|
+
* prepend it. Internal helper for chained drains; callers usually only
|
|
18
|
+
* need to remember `newOffset`. */
|
|
19
|
+
pendingTail: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Read everything from `path` starting at `fromOffset` and return parsed
|
|
23
|
+
* JSONL events plus the new file offset.
|
|
24
|
+
*
|
|
25
|
+
* - Returns `{ events: [], newOffset: 0, pendingTail: '' }` if the file
|
|
26
|
+
* doesn't exist (caller treats this as "nothing yet").
|
|
27
|
+
* - Detects truncation (size < fromOffset): resets to 0 and re-drains so a
|
|
28
|
+
* rotated/cleared transcript doesn't silently swallow new lines.
|
|
29
|
+
* - Skips malformed JSON lines (logs nothing — robustness over noise).
|
|
30
|
+
* - The trailing partial line (no `\n` yet) is *not* parsed and *not*
|
|
31
|
+
* counted toward `newOffset`, so the next drain re-reads it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function drainTranscript(path: string, fromOffset: number): DrainResult;
|
|
34
|
+
/**
|
|
35
|
+
* Filter to assistant text events. Returns only events where:
|
|
36
|
+
* - type === 'assistant' OR message.role === 'assistant'
|
|
37
|
+
* - content has at least one text block
|
|
38
|
+
* - uuid is present
|
|
39
|
+
*
|
|
40
|
+
* Sub-agent / sidechain events (isSidechain === true) are excluded so that
|
|
41
|
+
* spawn-internal Task agent chatter doesn't leak to Lark.
|
|
42
|
+
*/
|
|
43
|
+
export declare function pickAssistantTextEvents(events: TranscriptEvent[]): TranscriptEvent[];
|
|
44
|
+
/**
|
|
45
|
+
* Extract the visible text from one assistant event. Walks all `type:'text'`
|
|
46
|
+
* blocks in `message.content` (or the bare string) and joins them with
|
|
47
|
+
* blank lines. Returns '' if no text blocks.
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractAssistantText(event: TranscriptEvent): string;
|
|
50
|
+
/** Convenience: filter+extract a list of events into a single concatenated string. */
|
|
51
|
+
export declare function joinAssistantText(events: TranscriptEvent[]): string;
|
|
52
|
+
/** True when a `type:'user'` (or `message.role:'user'`) event represents a
|
|
53
|
+
* *real* prompt the human typed — not Claude Code's internal machinery
|
|
54
|
+
* (tool_result, slash-command wrappers, isMeta/isCompactSummary markers,
|
|
55
|
+
* sidechain spawn events). The bridge attribution queue and the adopt
|
|
56
|
+
* preamble extractor share this predicate to ensure they're seeing the
|
|
57
|
+
* same notion of "user input". */
|
|
58
|
+
export declare function isMeaningfulUserEvent(ev: TranscriptEvent | null | undefined): boolean;
|
|
59
|
+
export interface AdoptPreamble {
|
|
60
|
+
/** The most recent meaningful user prompt's text (post-stringify, no
|
|
61
|
+
* whitespace collapse — preserves the prompt's actual formatting). */
|
|
62
|
+
userText: string;
|
|
63
|
+
/** All assistant visible-text emitted between that user prompt and the
|
|
64
|
+
* end of the events list, joined with blank lines. tool_use blocks are
|
|
65
|
+
* excluded; sidechain assistant events are excluded. */
|
|
66
|
+
assistantText: string;
|
|
67
|
+
}
|
|
68
|
+
/** Walk the events forward and return the last *completed* user/assistant
|
|
69
|
+
* exchange. "Completed" here means: a meaningful user prompt followed by
|
|
70
|
+
* at least one assistant event with visible text. tool_use / tool_result
|
|
71
|
+
* events do NOT reset the turn — they're intra-turn machinery, so a
|
|
72
|
+
* prompt → tool_use → tool_result → assistant text sequence still counts
|
|
73
|
+
* as a single turn. Returns null when there's no meaningful user yet, or
|
|
74
|
+
* the last user wasn't followed by any visible assistant text (Claude is
|
|
75
|
+
* mid-tool-use when /adopt fired).
|
|
76
|
+
*
|
|
77
|
+
* Used by adopt-bridge to surface "the previous round" to the Lark thread
|
|
78
|
+
* so the user has context for continuing the conversation. */
|
|
79
|
+
export declare function extractLastAssistantTurn(events: TranscriptEvent[]): AdoptPreamble | null;
|
|
80
|
+
/**
|
|
81
|
+
* True when a user-role event carries ONLY tool_result blocks — Claude
|
|
82
|
+
* Code's representation of "tool returned this output" between an
|
|
83
|
+
* assistant tool_use and the assistant's continuation. Both the bridge
|
|
84
|
+
* attribution queue and the on-disk fingerprint search must skip these:
|
|
85
|
+
*
|
|
86
|
+
* - the queue would treat tool output as fresh local input and disable
|
|
87
|
+
* collection mid-turn,
|
|
88
|
+
* - the fingerprint search would false-positive on log content that
|
|
89
|
+
* happens to contain the Lark fingerprint substring (e.g. a short
|
|
90
|
+
* "hello" message hijacked by an unrelated jsonl whose tool_result
|
|
91
|
+
* dumped a log line containing "hello"). Re-exported by
|
|
92
|
+
* bridge-turn-queue.ts so both consumers share the same predicate
|
|
93
|
+
* and never drift apart.
|
|
94
|
+
*/
|
|
95
|
+
export declare function isPureToolResultUserEvent(content: unknown): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Stringify a transcript user event's content to a flat string. Handles
|
|
98
|
+
* both legacy bare-string content and the array-of-blocks form.
|
|
99
|
+
*
|
|
100
|
+
* Lives here (not in bridge-turn-queue.ts) so the in-process attribution
|
|
101
|
+
* state machine and the on-disk fingerprint search use *exactly* the
|
|
102
|
+
* same text — otherwise multi-line / array-content Lark messages stop
|
|
103
|
+
* matching one path or the other and bridges silently break.
|
|
104
|
+
*/
|
|
105
|
+
export declare function stringifyUserContent(content: unknown): string;
|
|
106
|
+
/**
|
|
107
|
+
* Collapse whitespace + trim. Same normalisation applied on both sides
|
|
108
|
+
* of the fingerprint compare (the Lark message that produces the
|
|
109
|
+
* fingerprint, and the transcript user content we search through),
|
|
110
|
+
* so newlines / tabs / double-spaces don't break the match.
|
|
111
|
+
*/
|
|
112
|
+
export declare function normaliseForFingerprint(s: string): string;
|
|
113
|
+
/**
|
|
114
|
+
* Find the most recently-modified `.jsonl` file in a Claude Code project
|
|
115
|
+
* directory. Helper kept for diagnostics and tests. The adopt-bridge
|
|
116
|
+
* watcher does NOT use mtime to follow session switches — see
|
|
117
|
+
* `findJsonlContainingFingerprint` for the safer fingerprint-based variant
|
|
118
|
+
* that ignores unrelated panes writing in the same project directory.
|
|
119
|
+
*
|
|
120
|
+
* Returns null when the directory doesn't exist or has no jsonl files.
|
|
121
|
+
*/
|
|
122
|
+
export declare function findLatestJsonl(dir: string): string | null;
|
|
123
|
+
/**
|
|
124
|
+
* Search every `.jsonl` file in `dir` for one whose contents include the
|
|
125
|
+
* given fingerprint. Used by the bridge watcher to detect a session
|
|
126
|
+
* switch (`/clear` / `/resume`) caused by the user's pane: when a Lark
|
|
127
|
+
* message is pending and its content fingerprint shows up in a NEW jsonl
|
|
128
|
+
* file, that file is the user's current session and we should switch.
|
|
129
|
+
*
|
|
130
|
+
* Pinning the switch decision to fingerprint match (rather than mtime)
|
|
131
|
+
* avoids hijacking by sibling Claude Code panes in the same project
|
|
132
|
+
* directory — they'll write busy jsonls but won't ever contain our Lark
|
|
133
|
+
* fingerprint.
|
|
134
|
+
*
|
|
135
|
+
* Optional `excludePath` skips the file we're already watching so the
|
|
136
|
+
* caller's "did it change?" comparison is cheap.
|
|
137
|
+
*
|
|
138
|
+
* Reads only the trailing 1 MB of each candidate (fingerprints land near
|
|
139
|
+
* the end of the jsonl when Claude has just written them) — long-lived
|
|
140
|
+
* sessions can grow to tens of MB so a full read would be wasteful.
|
|
141
|
+
* Callers should still gate on "an unstarted pending turn exists" rather
|
|
142
|
+
* than calling this on every poll tick.
|
|
143
|
+
*/
|
|
144
|
+
export interface JsonlFingerprintSearchOptions {
|
|
145
|
+
/** Skip the file the caller is already watching/checking. */
|
|
146
|
+
excludePath?: string;
|
|
147
|
+
/** Ignore older files when the caller is looking for a just-written submit. */
|
|
148
|
+
minMtimeMs?: number;
|
|
149
|
+
/** Drop events whose `timestamp` field is older than this (millis since
|
|
150
|
+
* epoch). Defends against short fingerprints ("hello", "test") matching
|
|
151
|
+
* old user lines in unrelated sibling jsonls — file mtime alone isn't
|
|
152
|
+
* enough since a sibling Claude pane could be actively writing. */
|
|
153
|
+
minEventTimestampMs?: number;
|
|
154
|
+
/** Also match Claude Code type-ahead enqueue events, whose content is not role:user. */
|
|
155
|
+
includeQueueOperations?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** Scan a single jsonl file's tail for a Lark message fingerprint. Same
|
|
158
|
+
* parsing rules as `findJsonlContainingFingerprint` (decode role:user content,
|
|
159
|
+
* optionally also queue-operation/enqueue, normalise whitespace, then
|
|
160
|
+
* substring-match the fingerprint). Used by the claude-code adapter when
|
|
161
|
+
* the pid resolver has just switched to a rotated jsonl that may already
|
|
162
|
+
* contain the just-submitted user event. */
|
|
163
|
+
export declare function jsonlContainsFingerprint(path: string, fingerprint: string, opts?: {
|
|
164
|
+
includeQueueOperations?: boolean;
|
|
165
|
+
minEventTimestampMs?: number;
|
|
166
|
+
}): boolean;
|
|
167
|
+
export declare function findJsonlContainingFingerprint(dir: string, fingerprint: string, excludePathOrOptions?: string | JsonlFingerprintSearchOptions): string | null;
|
|
168
|
+
//# sourceMappingURL=claude-transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-transcript.d.ts","sourceRoot":"","sources":["../../src/services/claude-transcript.ts"],"names":[],"mappings":"AAgBA,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB;;wCAEoC;IACpC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,WAAW,CA8Db;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAapF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAYnE;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAKnE;AAeD;;;;;mCAKmC;AACnC,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI,GAAG,SA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