botmux 2.9.0 → 2.9.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.en.md +140 -76
- package/README.md +134 -75
- 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 +10 -0
- package/dist/adapters/backend/pty-backend.js.map +1 -1
- package/dist/adapters/backend/session-backend-selector.d.ts +11 -0
- package/dist/adapters/backend/session-backend-selector.d.ts.map +1 -0
- package/dist/adapters/backend/session-backend-selector.js +26 -0
- package/dist/adapters/backend/session-backend-selector.js.map +1 -0
- package/dist/adapters/backend/tmux-backend.d.ts +80 -3
- package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-backend.js +301 -49
- package/dist/adapters/backend/tmux-backend.js.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.d.ts +100 -0
- package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -0
- package/dist/adapters/backend/tmux-pipe-backend.js +473 -0
- package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -0
- package/dist/adapters/cli/aiden.d.ts.map +1 -1
- package/dist/adapters/cli/aiden.js +5 -0
- package/dist/adapters/cli/aiden.js.map +1 -1
- package/dist/adapters/cli/claude-code.d.ts +40 -1
- package/dist/adapters/cli/claude-code.d.ts.map +1 -1
- package/dist/adapters/cli/claude-code.js +470 -49
- package/dist/adapters/cli/claude-code.js.map +1 -1
- package/dist/adapters/cli/coco.d.ts.map +1 -1
- package/dist/adapters/cli/coco.js +191 -9
- package/dist/adapters/cli/coco.js.map +1 -1
- package/dist/adapters/cli/codex.d.ts.map +1 -1
- package/dist/adapters/cli/codex.js +94 -17
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/shared-hints.d.ts +2 -2
- package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
- package/dist/adapters/cli/shared-hints.js +7 -5
- package/dist/adapters/cli/shared-hints.js.map +1 -1
- package/dist/adapters/cli/types.d.ts +38 -1
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/autostart.d.ts +14 -0
- package/dist/autostart.d.ts.map +1 -0
- package/dist/autostart.js +357 -0
- package/dist/autostart.js.map +1 -0
- package/dist/bot-registry.d.ts +29 -3
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +91 -12
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli/arg-utils.d.ts +11 -0
- package/dist/cli/arg-utils.d.ts.map +1 -0
- package/dist/cli/arg-utils.js +25 -0
- package/dist/cli/arg-utils.js.map +1 -0
- package/dist/cli/create-group-resolver.d.ts +32 -0
- package/dist/cli/create-group-resolver.d.ts.map +1 -0
- package/dist/cli/create-group-resolver.js +70 -0
- package/dist/cli/create-group-resolver.js.map +1 -0
- package/dist/cli/quoted-render.d.ts +30 -0
- package/dist/cli/quoted-render.d.ts.map +1 -0
- package/dist/cli/quoted-render.js +29 -0
- package/dist/cli/quoted-render.js.map +1 -0
- package/dist/cli.js +916 -272
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -8
- package/dist/config.js.map +1 -1
- package/dist/core/command-handler.d.ts +43 -0
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +167 -64
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/dashboard-events.d.ts +57 -0
- package/dist/core/dashboard-events.d.ts.map +1 -0
- package/dist/core/dashboard-events.js +23 -0
- package/dist/core/dashboard-events.js.map +1 -0
- package/dist/core/dashboard-ipc-server.d.ts +43 -0
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -0
- package/dist/core/dashboard-ipc-server.js +481 -0
- package/dist/core/dashboard-ipc-server.js.map +1 -0
- package/dist/core/dashboard-locate.d.ts +20 -0
- package/dist/core/dashboard-locate.d.ts.map +1 -0
- package/dist/core/dashboard-locate.js +26 -0
- package/dist/core/dashboard-locate.js.map +1 -0
- package/dist/core/dashboard-rows.d.ts +31 -0
- package/dist/core/dashboard-rows.d.ts.map +1 -0
- package/dist/core/dashboard-rows.js +65 -0
- package/dist/core/dashboard-rows.js.map +1 -0
- package/dist/core/inherit-peer.d.ts +14 -0
- package/dist/core/inherit-peer.d.ts.map +1 -0
- package/dist/core/inherit-peer.js +32 -0
- package/dist/core/inherit-peer.js.map +1 -0
- package/dist/core/scheduler.d.ts +24 -0
- package/dist/core/scheduler.d.ts.map +1 -1
- package/dist/core/scheduler.js +93 -2
- package/dist/core/scheduler.js.map +1 -1
- package/dist/core/session-activity.d.ts +3 -0
- package/dist/core/session-activity.d.ts.map +1 -0
- package/dist/core/session-activity.js +20 -0
- package/dist/core/session-activity.js.map +1 -0
- package/dist/core/session-discovery.d.ts +39 -0
- package/dist/core/session-discovery.d.ts.map +1 -1
- package/dist/core/session-discovery.js +114 -21
- package/dist/core/session-discovery.js.map +1 -1
- package/dist/core/session-manager.d.ts +72 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +396 -106
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/types.d.ts +27 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +14 -3
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +72 -3
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +459 -38
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +601 -309
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/aggregator.d.ts +41 -0
- package/dist/dashboard/aggregator.d.ts.map +1 -0
- package/dist/dashboard/aggregator.js +125 -0
- package/dist/dashboard/aggregator.js.map +1 -0
- package/dist/dashboard/auth.d.ts +23 -0
- package/dist/dashboard/auth.d.ts.map +1 -0
- package/dist/dashboard/auth.js +66 -0
- package/dist/dashboard/auth.js.map +1 -0
- package/dist/dashboard/operator-selector.d.ts +20 -0
- package/dist/dashboard/operator-selector.d.ts.map +1 -0
- package/dist/dashboard/operator-selector.js +39 -0
- package/dist/dashboard/operator-selector.js.map +1 -0
- package/dist/dashboard/registry.d.ts +35 -0
- package/dist/dashboard/registry.d.ts.map +1 -0
- package/dist/dashboard/registry.js +74 -0
- package/dist/dashboard/registry.js.map +1 -0
- package/dist/dashboard/web/app.d.ts +2 -0
- package/dist/dashboard/web/app.d.ts.map +1 -0
- package/dist/dashboard/web/app.js +45 -0
- package/dist/dashboard/web/app.js.map +1 -0
- package/dist/dashboard/web/bot-defaults.d.ts +2 -0
- package/dist/dashboard/web/bot-defaults.d.ts.map +1 -0
- package/dist/dashboard/web/bot-defaults.js +201 -0
- package/dist/dashboard/web/bot-defaults.js.map +1 -0
- package/dist/dashboard/web/groups.d.ts +16 -0
- package/dist/dashboard/web/groups.d.ts.map +1 -0
- package/dist/dashboard/web/groups.js +584 -0
- package/dist/dashboard/web/groups.js.map +1 -0
- package/dist/dashboard/web/schedules.d.ts +2 -0
- package/dist/dashboard/web/schedules.d.ts.map +1 -0
- package/dist/dashboard/web/schedules.js +105 -0
- package/dist/dashboard/web/schedules.js.map +1 -0
- package/dist/dashboard/web/sessions.d.ts +2 -0
- package/dist/dashboard/web/sessions.d.ts.map +1 -0
- package/dist/dashboard/web/sessions.js +374 -0
- package/dist/dashboard/web/sessions.js.map +1 -0
- package/dist/dashboard/web/store.d.ts +23 -0
- package/dist/dashboard/web/store.d.ts.map +1 -0
- package/dist/dashboard/web/store.js +82 -0
- package/dist/dashboard/web/store.js.map +1 -0
- package/dist/dashboard-web/app.js +263 -0
- package/dist/dashboard-web/index.html +23 -0
- package/dist/dashboard-web/style.css +93 -0
- package/dist/dashboard.d.ts +2 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +639 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/im/lark/card-builder.d.ts +18 -1
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +70 -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 +123 -109
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts +36 -0
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +119 -13
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts +92 -8
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +410 -89
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/im/lark/forwarded-renderer.d.ts +23 -0
- package/dist/im/lark/forwarded-renderer.d.ts.map +1 -0
- package/dist/im/lark/forwarded-renderer.js +105 -0
- package/dist/im/lark/forwarded-renderer.js.map +1 -0
- package/dist/im/lark/md-card.d.ts +73 -0
- package/dist/im/lark/md-card.d.ts.map +1 -0
- package/dist/im/lark/md-card.js +332 -0
- package/dist/im/lark/md-card.js.map +1 -0
- 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 +110 -0
- package/dist/im/lark/merge-forward.js.map +1 -0
- package/dist/im/lark/message-parser.d.ts +9 -3
- package/dist/im/lark/message-parser.d.ts.map +1 -1
- package/dist/im/lark/message-parser.js +48 -13
- package/dist/im/lark/message-parser.js.map +1 -1
- package/dist/im/lark/quote-hint.d.ts +18 -0
- package/dist/im/lark/quote-hint.d.ts.map +1 -0
- package/dist/im/lark/quote-hint.js +23 -0
- package/dist/im/lark/quote-hint.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-rotation-policy.d.ts +139 -0
- package/dist/services/bridge-rotation-policy.d.ts.map +1 -0
- package/dist/services/bridge-rotation-policy.js +125 -0
- package/dist/services/bridge-rotation-policy.js.map +1 -0
- package/dist/services/bridge-turn-queue.d.ts +154 -0
- package/dist/services/bridge-turn-queue.d.ts.map +1 -0
- package/dist/services/bridge-turn-queue.js +316 -0
- package/dist/services/bridge-turn-queue.js.map +1 -0
- package/dist/services/chat-first-seen-store.d.ts +27 -0
- package/dist/services/chat-first-seen-store.d.ts.map +1 -0
- package/dist/services/chat-first-seen-store.js +114 -0
- package/dist/services/chat-first-seen-store.js.map +1 -0
- package/dist/services/claude-transcript.d.ts +268 -0
- package/dist/services/claude-transcript.d.ts.map +1 -0
- package/dist/services/claude-transcript.js +798 -0
- package/dist/services/claude-transcript.js.map +1 -0
- package/dist/services/coco-transcript.d.ts +35 -0
- package/dist/services/coco-transcript.d.ts.map +1 -0
- package/dist/services/coco-transcript.js +192 -0
- package/dist/services/coco-transcript.js.map +1 -0
- package/dist/services/codex-bridge-queue.d.ts +56 -0
- package/dist/services/codex-bridge-queue.d.ts.map +1 -0
- package/dist/services/codex-bridge-queue.js +150 -0
- package/dist/services/codex-bridge-queue.js.map +1 -0
- package/dist/services/codex-transcript.d.ts +84 -0
- package/dist/services/codex-transcript.d.ts.map +1 -0
- package/dist/services/codex-transcript.js +298 -0
- package/dist/services/codex-transcript.js.map +1 -0
- package/dist/services/group-creator.d.ts +23 -0
- package/dist/services/group-creator.d.ts.map +1 -0
- package/dist/services/group-creator.js +75 -0
- package/dist/services/group-creator.js.map +1 -0
- package/dist/services/groups-store.d.ts +98 -0
- package/dist/services/groups-store.d.ts.map +1 -0
- package/dist/services/groups-store.js +213 -0
- package/dist/services/groups-store.js.map +1 -0
- package/dist/services/oncall-store.d.ts +80 -8
- package/dist/services/oncall-store.d.ts.map +1 -1
- package/dist/services/oncall-store.js +265 -55
- package/dist/services/oncall-store.js.map +1 -1
- package/dist/services/project-scanner.d.ts +1 -2
- package/dist/services/project-scanner.d.ts.map +1 -1
- package/dist/services/project-scanner.js +118 -68
- package/dist/services/project-scanner.js.map +1 -1
- package/dist/services/schedule-store.d.ts +5 -0
- package/dist/services/schedule-store.d.ts.map +1 -1
- package/dist/services/schedule-store.js +77 -1
- package/dist/services/schedule-store.js.map +1 -1
- package/dist/services/session-store.d.ts +22 -0
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +62 -4
- package/dist/services/session-store.js.map +1 -1
- package/dist/setup/bots-store.d.ts +3 -0
- package/dist/setup/bots-store.d.ts.map +1 -0
- package/dist/setup/bots-store.js +24 -0
- package/dist/setup/bots-store.js.map +1 -0
- package/dist/setup/detect-platform.d.ts +14 -0
- package/dist/setup/detect-platform.d.ts.map +1 -0
- package/dist/setup/detect-platform.js +139 -0
- package/dist/setup/detect-platform.js.map +1 -0
- package/dist/setup/ensure-fonts.d.ts +13 -0
- package/dist/setup/ensure-fonts.d.ts.map +1 -0
- package/dist/setup/ensure-fonts.js +225 -0
- package/dist/setup/ensure-fonts.js.map +1 -0
- package/dist/setup/ensure-tmux.d.ts +60 -0
- package/dist/setup/ensure-tmux.d.ts.map +1 -0
- package/dist/setup/ensure-tmux.js +236 -0
- package/dist/setup/ensure-tmux.js.map +1 -0
- package/dist/setup/index.d.ts +9 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +46 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/lark-scopes.json +301 -0
- package/dist/setup/register-app.d.ts +52 -0
- package/dist/setup/register-app.d.ts.map +1 -0
- package/dist/setup/register-app.js +91 -0
- package/dist/setup/register-app.js.map +1 -0
- package/dist/setup/verify-permissions.d.ts +115 -0
- package/dist/setup/verify-permissions.d.ts.map +1 -0
- package/dist/setup/verify-permissions.js +207 -0
- package/dist/setup/verify-permissions.js.map +1 -0
- package/dist/skills/definitions.d.ts +4 -0
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +133 -19
- package/dist/skills/definitions.js.map +1 -1
- package/dist/skills/installer.d.ts +3 -1
- package/dist/skills/installer.d.ts.map +1 -1
- package/dist/skills/installer.js +18 -3
- package/dist/skills/installer.js.map +1 -1
- package/dist/types.d.ts +44 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/bot-routing.d.ts +6 -0
- package/dist/utils/bot-routing.d.ts.map +1 -0
- package/dist/utils/bot-routing.js +50 -0
- package/dist/utils/bot-routing.js.map +1 -0
- package/dist/utils/file-lock.d.ts +2 -0
- package/dist/utils/file-lock.d.ts.map +1 -0
- package/dist/utils/file-lock.js +114 -0
- package/dist/utils/file-lock.js.map +1 -0
- package/dist/utils/font-installer.js +1 -1
- package/dist/utils/font-installer.js.map +1 -1
- package/dist/utils/idle-detector.d.ts +6 -0
- package/dist/utils/idle-detector.d.ts.map +1 -1
- package/dist/utils/idle-detector.js +25 -4
- package/dist/utils/idle-detector.js.map +1 -1
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +60 -8
- package/dist/utils/logger.js.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/screen-analyzer.d.ts.map +1 -1
- package/dist/utils/screen-analyzer.js +24 -0
- package/dist/utils/screen-analyzer.js.map +1 -1
- package/dist/utils/screenshot-renderer.d.ts.map +1 -1
- package/dist/utils/screenshot-renderer.js +67 -23
- package/dist/utils/screenshot-renderer.js.map +1 -1
- package/dist/utils/terminal-renderer.d.ts +16 -0
- package/dist/utils/terminal-renderer.d.ts.map +1 -1
- package/dist/utils/terminal-renderer.js +40 -23
- package/dist/utils/terminal-renderer.js.map +1 -1
- package/dist/utils/transient-snapshot.d.ts +28 -0
- package/dist/utils/transient-snapshot.d.ts.map +1 -0
- package/dist/utils/transient-snapshot.js +96 -0
- package/dist/utils/transient-snapshot.js.map +1 -0
- package/dist/worker.js +2220 -83
- package/dist/worker.js.map +1 -1
- package/package.json +12 -5
|
@@ -0,0 +1,268 @@
|
|
|
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
|
+
/** Present on `type:"attachment"` lines. The bridge attribution queue
|
|
12
|
+
* treats `attachment.type === "queued_command"` as a turn-start signal —
|
|
13
|
+
* Claude writes one of these the moment it dequeues a type-ahead
|
|
14
|
+
* submission, immediately before the assistant's reply for that turn
|
|
15
|
+
* starts streaming. `prompt` carries the same content the user typed;
|
|
16
|
+
* shape is usually `string` but we tolerate the message-style array form
|
|
17
|
+
* via stringifyUserContent. */
|
|
18
|
+
attachment?: {
|
|
19
|
+
type?: string;
|
|
20
|
+
prompt?: unknown;
|
|
21
|
+
commandMode?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Extract the user-typed prompt text for a "turn start" event — works for
|
|
25
|
+
* both legacy `role:user` events (text in `message.content`) and the
|
|
26
|
+
* type-ahead `attachment(queued_command)` form (text in `attachment.prompt`).
|
|
27
|
+
* Returns '' when neither shape carries usable content. Used at three
|
|
28
|
+
* layers: BridgeTurnQueue.ingest (fingerprint-match the right pending Lark
|
|
29
|
+
* turn), worker emit (local-turn user-text resolution), and tests. */
|
|
30
|
+
export declare function extractTurnStartText(ev: TranscriptEvent | null | undefined): string;
|
|
31
|
+
export interface DrainResult {
|
|
32
|
+
events: TranscriptEvent[];
|
|
33
|
+
/** Byte offset to pass back on the next drain. */
|
|
34
|
+
newOffset: number;
|
|
35
|
+
/** Trailing partial line (no newline yet) — kept so the next drain can
|
|
36
|
+
* prepend it. Internal helper for chained drains; callers usually only
|
|
37
|
+
* need to remember `newOffset`. */
|
|
38
|
+
pendingTail: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Read everything from `path` starting at `fromOffset` and return parsed
|
|
42
|
+
* JSONL events plus the new file offset.
|
|
43
|
+
*
|
|
44
|
+
* - Returns `{ events: [], newOffset: 0, pendingTail: '' }` if the file
|
|
45
|
+
* doesn't exist (caller treats this as "nothing yet").
|
|
46
|
+
* - Detects truncation (size < fromOffset): resets to 0 and re-drains so a
|
|
47
|
+
* rotated/cleared transcript doesn't silently swallow new lines.
|
|
48
|
+
* - Skips malformed JSON lines (logs nothing — robustness over noise).
|
|
49
|
+
* - The trailing partial line (no `\n` yet) is *not* parsed and *not*
|
|
50
|
+
* counted toward `newOffset`, so the next drain re-reads it.
|
|
51
|
+
*/
|
|
52
|
+
export declare function drainTranscript(path: string, fromOffset: number): DrainResult;
|
|
53
|
+
/**
|
|
54
|
+
* Filter to assistant text events. Returns only events where:
|
|
55
|
+
* - type === 'assistant' OR message.role === 'assistant'
|
|
56
|
+
* - content has at least one text block
|
|
57
|
+
* - uuid is present
|
|
58
|
+
*
|
|
59
|
+
* Sub-agent / sidechain events (isSidechain === true) are excluded so that
|
|
60
|
+
* spawn-internal Task agent chatter doesn't leak to Lark.
|
|
61
|
+
*/
|
|
62
|
+
export declare function pickAssistantTextEvents(events: TranscriptEvent[]): TranscriptEvent[];
|
|
63
|
+
/**
|
|
64
|
+
* Extract the visible text from one assistant event. Walks all `type:'text'`
|
|
65
|
+
* blocks in `message.content` (or the bare string) and joins them with
|
|
66
|
+
* blank lines. Returns '' if no text blocks.
|
|
67
|
+
*/
|
|
68
|
+
export declare function extractAssistantText(event: TranscriptEvent): string;
|
|
69
|
+
/** Convenience: filter+extract a list of events into a single concatenated string. */
|
|
70
|
+
export declare function joinAssistantText(events: TranscriptEvent[]): string;
|
|
71
|
+
/** True when a `type:'user'` (or `message.role:'user'`) event represents a
|
|
72
|
+
* *real* prompt the human typed — not Claude Code's internal machinery
|
|
73
|
+
* (tool_result, slash-command wrappers, isMeta/isCompactSummary markers,
|
|
74
|
+
* sidechain spawn events). The bridge attribution queue and the adopt
|
|
75
|
+
* preamble extractor share this predicate to ensure they're seeing the
|
|
76
|
+
* same notion of "user input". */
|
|
77
|
+
export declare function isMeaningfulUserEvent(ev: TranscriptEvent | null | undefined): boolean;
|
|
78
|
+
/** True when a `type:'attachment'` line carries a queued-command payload
|
|
79
|
+
* representing a real submitted prompt. Claude writes one of these when it
|
|
80
|
+
* dequeues a type-ahead submission (right before the assistant's reply for
|
|
81
|
+
* that turn starts streaming) — the bridge attribution queue treats it
|
|
82
|
+
* exactly like a `role:user` event for turn-start purposes. Filters mirror
|
|
83
|
+
* isMeaningfulUserEvent's defenses (sidechain, empty / synthetic-prefix
|
|
84
|
+
* prompts) so a queued slash command can't false-start a Lark turn. */
|
|
85
|
+
export declare function isMeaningfulQueuedCommand(ev: TranscriptEvent | null | undefined): boolean;
|
|
86
|
+
export interface AdoptPreamble {
|
|
87
|
+
/** The most recent meaningful user prompt's text (post-stringify, no
|
|
88
|
+
* whitespace collapse — preserves the prompt's actual formatting). */
|
|
89
|
+
userText: string;
|
|
90
|
+
/** All assistant visible-text emitted between that user prompt and the
|
|
91
|
+
* end of the events list, joined with blank lines. tool_use blocks are
|
|
92
|
+
* excluded; sidechain assistant events are excluded. */
|
|
93
|
+
assistantText: string;
|
|
94
|
+
}
|
|
95
|
+
/** Walk the events forward and return the last *completed* user/assistant
|
|
96
|
+
* exchange. "Completed" here means: a meaningful user prompt followed by
|
|
97
|
+
* at least one assistant event with visible text. tool_use / tool_result
|
|
98
|
+
* events do NOT reset the turn — they're intra-turn machinery, so a
|
|
99
|
+
* prompt → tool_use → tool_result → assistant text sequence still counts
|
|
100
|
+
* as a single turn. Returns null when there's no meaningful user yet, or
|
|
101
|
+
* the last user wasn't followed by any visible assistant text (Claude is
|
|
102
|
+
* mid-tool-use when /adopt fired).
|
|
103
|
+
*
|
|
104
|
+
* Used by adopt-bridge to surface "the previous round" to the Lark thread
|
|
105
|
+
* so the user has context for continuing the conversation. */
|
|
106
|
+
export declare function extractLastAssistantTurn(events: TranscriptEvent[]): AdoptPreamble | null;
|
|
107
|
+
/**
|
|
108
|
+
* True when a user-role event carries ONLY tool_result blocks — Claude
|
|
109
|
+
* Code's representation of "tool returned this output" between an
|
|
110
|
+
* assistant tool_use and the assistant's continuation. Both the bridge
|
|
111
|
+
* attribution queue and the on-disk fingerprint search must skip these:
|
|
112
|
+
*
|
|
113
|
+
* - the queue would treat tool output as fresh local input and disable
|
|
114
|
+
* collection mid-turn,
|
|
115
|
+
* - the fingerprint search would false-positive on log content that
|
|
116
|
+
* happens to contain the Lark fingerprint substring (e.g. a short
|
|
117
|
+
* "hello" message hijacked by an unrelated jsonl whose tool_result
|
|
118
|
+
* dumped a log line containing "hello"). Re-exported by
|
|
119
|
+
* bridge-turn-queue.ts so both consumers share the same predicate
|
|
120
|
+
* and never drift apart.
|
|
121
|
+
*/
|
|
122
|
+
export declare function isPureToolResultUserEvent(content: unknown): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Stringify a transcript user event's content to a flat string. Handles
|
|
125
|
+
* both legacy bare-string content and the array-of-blocks form.
|
|
126
|
+
*
|
|
127
|
+
* Lives here (not in bridge-turn-queue.ts) so the in-process attribution
|
|
128
|
+
* state machine and the on-disk fingerprint search use *exactly* the
|
|
129
|
+
* same text — otherwise multi-line / array-content Lark messages stop
|
|
130
|
+
* matching one path or the other and bridges silently break.
|
|
131
|
+
*/
|
|
132
|
+
export declare function stringifyUserContent(content: unknown): string;
|
|
133
|
+
/**
|
|
134
|
+
* Collapse whitespace + trim. Same normalisation applied on both sides
|
|
135
|
+
* of the fingerprint compare (the Lark message that produces the
|
|
136
|
+
* fingerprint, and the transcript user content we search through),
|
|
137
|
+
* so newlines / tabs / double-spaces don't break the match.
|
|
138
|
+
*/
|
|
139
|
+
export declare function normaliseForFingerprint(s: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* Find the most recently-modified `.jsonl` file in a Claude Code project
|
|
142
|
+
* directory.
|
|
143
|
+
*
|
|
144
|
+
* `acceptCandidate` lets callers narrow the candidate set — the bridge's
|
|
145
|
+
* quiet-mtime fallback passes a trust-set predicate so a sibling Claude
|
|
146
|
+
* pane writing in the same project dir cannot hijack the watcher.
|
|
147
|
+
* Without it any actively-written sibling jsonl wins the mtime race and
|
|
148
|
+
* the bridge enters a flap loop with the pid resolver pulling it back.
|
|
149
|
+
*
|
|
150
|
+
* Returns null when the directory doesn't exist, has no jsonl files, or
|
|
151
|
+
* every candidate was rejected by `acceptCandidate`.
|
|
152
|
+
*/
|
|
153
|
+
export declare function findLatestJsonl(dir: string, opts?: {
|
|
154
|
+
acceptCandidate?: (path: string) => boolean;
|
|
155
|
+
}): string | null;
|
|
156
|
+
/**
|
|
157
|
+
* Search every `.jsonl` file in `dir` for one whose contents include the
|
|
158
|
+
* given fingerprint. Used by the bridge watcher to detect a session
|
|
159
|
+
* switch (`/clear` / `/resume`) caused by the user's pane: when a Lark
|
|
160
|
+
* message is pending and its content fingerprint shows up in a NEW jsonl
|
|
161
|
+
* file, that file is the user's current session and we should switch.
|
|
162
|
+
*
|
|
163
|
+
* Pinning the switch decision to fingerprint match (rather than mtime)
|
|
164
|
+
* avoids hijacking by sibling Claude Code panes in the same project
|
|
165
|
+
* directory — they'll write busy jsonls but won't ever contain our Lark
|
|
166
|
+
* fingerprint.
|
|
167
|
+
*
|
|
168
|
+
* Optional `excludePath` skips the file we're already watching so the
|
|
169
|
+
* caller's "did it change?" comparison is cheap.
|
|
170
|
+
*
|
|
171
|
+
* Reads only the trailing 1 MB of each candidate (fingerprints land near
|
|
172
|
+
* the end of the jsonl when Claude has just written them) — long-lived
|
|
173
|
+
* sessions can grow to tens of MB so a full read would be wasteful.
|
|
174
|
+
* Callers should still gate on "an unstarted pending turn exists" rather
|
|
175
|
+
* than calling this on every poll tick.
|
|
176
|
+
*/
|
|
177
|
+
export interface JsonlFingerprintSearchOptions {
|
|
178
|
+
/** Skip the file the caller is already watching/checking. */
|
|
179
|
+
excludePath?: string;
|
|
180
|
+
/** Ignore older files when the caller is looking for a just-written submit. */
|
|
181
|
+
minMtimeMs?: number;
|
|
182
|
+
/** Drop events whose `timestamp` field is older than this (millis since
|
|
183
|
+
* epoch). Defends against short fingerprints ("hello", "test") matching
|
|
184
|
+
* old user lines in unrelated sibling jsonls — file mtime alone isn't
|
|
185
|
+
* enough since a sibling Claude pane could be actively writing. */
|
|
186
|
+
minEventTimestampMs?: number;
|
|
187
|
+
/** Also match Claude Code type-ahead enqueue events, whose content is not role:user. */
|
|
188
|
+
includeQueueOperations?: boolean;
|
|
189
|
+
/** Called on each candidate that already passed the fingerprint match.
|
|
190
|
+
* Returning `false` skips the candidate and continues searching older
|
|
191
|
+
* files in the directory (mtime-descending walk). Used by the bridge
|
|
192
|
+
* watcher to reject sibling-pane jsonls whose sessionId we don't trust,
|
|
193
|
+
* without losing the chance to find a legitimate /clear rotation buried
|
|
194
|
+
* under a busier sibling. Default (no callback): accept the first
|
|
195
|
+
* fingerprint match like the original behaviour. */
|
|
196
|
+
acceptCandidate?: (path: string) => boolean;
|
|
197
|
+
}
|
|
198
|
+
/** Scan a single jsonl file's tail for a Lark message fingerprint. Same
|
|
199
|
+
* parsing rules as `findJsonlContainingFingerprint` (decode role:user content,
|
|
200
|
+
* optionally also queue-operation/enqueue, normalise whitespace, then
|
|
201
|
+
* substring-match the fingerprint). Used by the claude-code adapter when
|
|
202
|
+
* the pid resolver has just switched to a rotated jsonl that may already
|
|
203
|
+
* contain the just-submitted user event. */
|
|
204
|
+
export declare function jsonlContainsFingerprint(path: string, fingerprint: string, opts?: {
|
|
205
|
+
includeQueueOperations?: boolean;
|
|
206
|
+
minEventTimestampMs?: number;
|
|
207
|
+
}): boolean;
|
|
208
|
+
export declare function findJsonlContainingFingerprint(dir: string, fingerprint: string, excludePathOrOptions?: string | JsonlFingerprintSearchOptions): string | null;
|
|
209
|
+
/**
|
|
210
|
+
* Stronger sibling-pane recovery anchor than the substring fingerprint
|
|
211
|
+
* search. Walks every `.jsonl` in `dir` and returns the paths whose
|
|
212
|
+
* trailing 1MB contains a user/queue event whose normalised text is
|
|
213
|
+
* EXACTLY equal to `normalisedContent` (not a substring), respecting
|
|
214
|
+
* `excludePath`, `minMtimeMs`, `minEventTimestampMs`,
|
|
215
|
+
* `includeQueueOperations`, and `acceptCandidate` the same way as
|
|
216
|
+
* `findJsonlContainingFingerprint`.
|
|
217
|
+
*
|
|
218
|
+
* Returns *all* matches in mtime-descending order — callers must
|
|
219
|
+
* abstain when the result has length > 1, since multiple files containing
|
|
220
|
+
* the same exact normalised content cannot be disambiguated without
|
|
221
|
+
* stronger evidence (and forcing a switch would risk picking the wrong
|
|
222
|
+
* pane). The caller's typical pattern is:
|
|
223
|
+
*
|
|
224
|
+
* - 1 match → switch to it (legitimate post-/clear recovery)
|
|
225
|
+
* - 0 matches → no recovery this tick; wait for stronger signal
|
|
226
|
+
* - >1 match → log and abstain; surface a diagnostic to the user
|
|
227
|
+
*
|
|
228
|
+
* Used by the bridge fingerprint fallback's recovery path for in-pane
|
|
229
|
+
* `/clear`: substring matches risk hijacking on short fingerprints (the
|
|
230
|
+
* literal text "test" matches "run tests" / "test bridge"), but full
|
|
231
|
+
* equality on a Lark message we just wrote is a much stronger anchor.
|
|
232
|
+
*/
|
|
233
|
+
export declare function findJsonlsContainingExactContent(dir: string, normalisedContent: string, options?: JsonlFingerprintSearchOptions): string[];
|
|
234
|
+
/**
|
|
235
|
+
* Partition transcript events into history (timestamp ≤ cutoff) and live
|
|
236
|
+
* (timestamp > cutoff, or no parseable timestamp). Used by the bridge
|
|
237
|
+
* watcher when it switches to a new jsonl that may contain pre-existing
|
|
238
|
+
* conversation: anything older than the cutoff (e.g. iTerm-typed turns
|
|
239
|
+
* the user produced before the Lark mark fired) belongs in the seen-set
|
|
240
|
+
* via `BridgeTurnQueue.absorb` so the worker doesn't replay them as
|
|
241
|
+
* "🖥️ 终端本地对话" cards. Anything newer is fed through `ingest()` so
|
|
242
|
+
* the freshly-written Lark user event can match its pending fingerprint.
|
|
243
|
+
*
|
|
244
|
+
* Events with malformed / missing timestamps fall into `live`: better
|
|
245
|
+
* to forward an unattributable event once than to silently drop a real
|
|
246
|
+
* reply because Claude omitted a timestamp.
|
|
247
|
+
*/
|
|
248
|
+
export declare function splitTranscriptEventsByCutoff(events: TranscriptEvent[], cutoffMs: number): {
|
|
249
|
+
history: TranscriptEvent[];
|
|
250
|
+
live: TranscriptEvent[];
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Read the first event timestamp out of a jsonl. Reads only the leading
|
|
254
|
+
* 4 KB — Claude's `file-history-snapshot` and `SessionStart` events both
|
|
255
|
+
* land in the first few hundred bytes. Returns the parsed millis, or
|
|
256
|
+
* undefined when no parseable timestamp is found in the leading chunk
|
|
257
|
+
* (corrupted file, partial first line, format change).
|
|
258
|
+
*
|
|
259
|
+
* NOTE: not currently wired into the bridge rotation flow. The bridge
|
|
260
|
+
* fingerprint fallback (`decideFingerprintSwitch` in
|
|
261
|
+
* `bridge-rotation-policy.ts`) deliberately rejects candidates outside
|
|
262
|
+
* the pid-derived trust set rather than relying on freshness heuristics
|
|
263
|
+
* — file-creation timestamps cannot prove ownership across panes in
|
|
264
|
+
* the same project dir. Kept here as a reusable primitive for
|
|
265
|
+
* diagnostics and future /clear-recovery work.
|
|
266
|
+
*/
|
|
267
|
+
export declare function readFirstEventTimestamp(path: string): number | undefined;
|
|
268
|
+
//# 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,O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