@0xmaxma/claude-gateway 1.2.32 → 1.3.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.
Files changed (49) hide show
  1. package/README.md +23 -4
  2. package/config.template.json +5 -5
  3. package/dist/api/router.d.ts.map +1 -1
  4. package/dist/api/router.js +2 -4
  5. package/dist/api/router.js.map +1 -1
  6. package/dist/apps/agent-manager.d.ts.map +1 -1
  7. package/dist/apps/agent-manager.js +0 -1
  8. package/dist/apps/agent-manager.js.map +1 -1
  9. package/dist/config/watcher.d.ts.map +1 -1
  10. package/dist/config/watcher.js +21 -4
  11. package/dist/config/watcher.js.map +1 -1
  12. package/dist/index.js +8 -3
  13. package/dist/index.js.map +1 -1
  14. package/dist/session/process.d.ts.map +1 -1
  15. package/dist/session/process.js +33 -7
  16. package/dist/session/process.js.map +1 -1
  17. package/dist/shell/args.d.ts +22 -0
  18. package/dist/shell/args.d.ts.map +1 -0
  19. package/dist/shell/args.js +105 -0
  20. package/dist/shell/args.js.map +1 -0
  21. package/dist/shell/claude-pty-shell.d.ts +3 -0
  22. package/dist/shell/claude-pty-shell.d.ts.map +1 -0
  23. package/dist/shell/claude-pty-shell.js +403 -0
  24. package/dist/shell/claude-pty-shell.js.map +1 -0
  25. package/dist/shell/emitter.d.ts +36 -0
  26. package/dist/shell/emitter.d.ts.map +1 -0
  27. package/dist/shell/emitter.js +85 -0
  28. package/dist/shell/emitter.js.map +1 -0
  29. package/dist/shell/pty-host.d.ts +21 -0
  30. package/dist/shell/pty-host.d.ts.map +1 -0
  31. package/dist/shell/pty-host.js +102 -0
  32. package/dist/shell/pty-host.js.map +1 -0
  33. package/dist/shell/screen.d.ts +39 -0
  34. package/dist/shell/screen.d.ts.map +1 -0
  35. package/dist/shell/screen.js +77 -0
  36. package/dist/shell/screen.js.map +1 -0
  37. package/dist/shell/tailer.d.ts +64 -0
  38. package/dist/shell/tailer.d.ts.map +1 -0
  39. package/dist/shell/tailer.js +181 -0
  40. package/dist/shell/tailer.js.map +1 -0
  41. package/dist/shell/trust.d.ts +28 -0
  42. package/dist/shell/trust.d.ts.map +1 -0
  43. package/dist/shell/trust.js +121 -0
  44. package/dist/shell/trust.js.map +1 -0
  45. package/dist/types.d.ts +7 -1
  46. package/dist/types.d.ts.map +1 -1
  47. package/mcp/tools/telegram/dedup.ts +46 -0
  48. package/mcp/tools/telegram/receiver-server.ts +25 -0
  49. package/package.json +3 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/shell/emitter.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,MAAa,eAAe;IAC1B,YAA6B,MAA6B,OAAO,CAAC,MAAM;QAA3C,QAAG,GAAH,GAAG,CAAwC;IAAG,CAAC;IAEpE,SAAS,CAAC,GAA4B;QAC5C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,SAAiB,EAAE,KAAa,EAAE,GAAW;QACpD,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,SAAS;YACrB,KAAK;YACL,GAAG;YACH,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,KAAgB,EAAE,SAAiB;QACtD,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,cAAc;YACpB,UAAU,EAAE,SAAS;YACrB,KAAK,EAAE;gBACL,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE;oBACP,KAAK,EAAE;wBACL,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC;wBACrC,uBAAuB,EAAE,KAAK,CAAC,uBAAuB,IAAI,CAAC;wBAC3D,2BAA2B,EAAE,KAAK,CAAC,2BAA2B,IAAI,CAAC;qBAC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C,EAAE;SACzD,CAAC,CAAC;IACL,CAAC;CAEF;AArFD,0CAqFC"}
@@ -0,0 +1,21 @@
1
+ export interface PtyHostOptions {
2
+ cols: number;
3
+ rows: number;
4
+ cwd: string;
5
+ onData: (data: string) => void;
6
+ onExit: (exitCode: number) => void;
7
+ }
8
+ /** Hosts the real interactive `claude` inside a pseudo-terminal. */
9
+ export declare class PtyHost {
10
+ private child;
11
+ constructor(binary: string, args: string[], opts: PtyHostOptions);
12
+ /** Raw keystroke write (control sequences allowed — caller sanitizes user text). */
13
+ writeRaw(data: string): void;
14
+ /**
15
+ * Paste large text without overwhelming the PTY line discipline:
16
+ * chunked writes with small delays.
17
+ */
18
+ writeChunked(data: string): Promise<void>;
19
+ kill(signal?: string): void;
20
+ }
21
+ //# sourceMappingURL=pty-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pty-host.d.ts","sourceRoot":"","sources":["../../src/shell/pty-host.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,oEAAoE;AACpE,qBAAa,OAAO;IAClB,OAAO,CAAC,KAAK,CAAW;gBAEZ,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc;IAiBhE,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI5B;;;OAGG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/C,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;CAO5B"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PtyHost = void 0;
37
+ const path = __importStar(require("path"));
38
+ const pty = __importStar(require("node-pty"));
39
+ const WRITE_CHUNK_BYTES = 8 * 1024;
40
+ const WRITE_CHUNK_DELAY_MS = 10;
41
+ // Keys matching these prefixes are scrubbed before spawning the child PTY:
42
+ // CLAUDECODE/CLAUDE_CODE_ prevent nested-claude child-session behavior that
43
+ // silently stops transcript JSONL writes; CLAUDE_REAL_BIN is a wrapper-only
44
+ // variable and must not leak into the child.
45
+ const SCRUB_ENV_PREFIXES = ['CLAUDECODE', 'CLAUDE_CODE_', 'CLAUDE_REAL_BIN', 'PTY_SHELL_'];
46
+ // Auth vars that share the CLAUDE_CODE_ prefix but must be kept.
47
+ const SCRUB_ENV_KEEPLIST = new Set(['CLAUDE_CODE_OAUTH_TOKEN']);
48
+ function childEnv() {
49
+ const env = { ...process.env };
50
+ for (const key of Object.keys(env)) {
51
+ if (!SCRUB_ENV_KEEPLIST.has(key) &&
52
+ SCRUB_ENV_PREFIXES.some((p) => key.startsWith(p))) {
53
+ delete env[key];
54
+ }
55
+ }
56
+ return env;
57
+ }
58
+ /** Hosts the real interactive `claude` inside a pseudo-terminal. */
59
+ class PtyHost {
60
+ constructor(binary, args, opts) {
61
+ // Recursion guard: CLAUDE_BIN points at this wrapper; the wrapper must
62
+ // never resolve the "real" binary back to itself.
63
+ if (path.basename(binary).includes('claude-pty-shell')) {
64
+ throw new Error(`refusing to spawn self as claude binary: ${binary}`);
65
+ }
66
+ this.child = pty.spawn(binary, args, {
67
+ name: 'xterm-256color',
68
+ cols: opts.cols,
69
+ rows: opts.rows,
70
+ cwd: opts.cwd,
71
+ env: childEnv(),
72
+ });
73
+ this.child.onData(opts.onData);
74
+ this.child.onExit(({ exitCode }) => opts.onExit(exitCode));
75
+ }
76
+ /** Raw keystroke write (control sequences allowed — caller sanitizes user text). */
77
+ writeRaw(data) {
78
+ this.child.write(data);
79
+ }
80
+ /**
81
+ * Paste large text without overwhelming the PTY line discipline:
82
+ * chunked writes with small delays.
83
+ */
84
+ async writeChunked(data) {
85
+ for (let i = 0; i < data.length; i += WRITE_CHUNK_BYTES) {
86
+ this.child.write(data.slice(i, i + WRITE_CHUNK_BYTES));
87
+ if (i + WRITE_CHUNK_BYTES < data.length) {
88
+ await new Promise((r) => setTimeout(r, WRITE_CHUNK_DELAY_MS));
89
+ }
90
+ }
91
+ }
92
+ kill(signal) {
93
+ try {
94
+ this.child.kill(signal);
95
+ }
96
+ catch {
97
+ /* already dead */
98
+ }
99
+ }
100
+ }
101
+ exports.PtyHost = PtyHost;
102
+ //# sourceMappingURL=pty-host.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F;AA7CD,0BA6CC"}
@@ -0,0 +1,39 @@
1
+ export type DialogKind = 'bypass-permissions';
2
+ /**
3
+ * TUI string constants — verified against Claude Code v2.1.x.
4
+ * When upgrading Claude Code, re-check each constant against the new TUI output.
5
+ * All matchers live here so a UI change requires touching exactly one file.
6
+ *
7
+ * BUSY_MARKER status bar text during an active turn
8
+ * PROMPT_RE idle input caret pattern
9
+ * BYPASS_PERMS "Bypass Permissions" dialog markers
10
+ */
11
+ export declare const TUI_BUSY_MARKER = "esc to interrupt";
12
+ export declare const TUI_PROMPT_RE: RegExp;
13
+ export declare const TUI_BYPASS_PERMS: readonly ["Bypass Permissions mode", "Yes, I accept"];
14
+ /**
15
+ * Virtual terminal fed with raw PTY bytes. Used ONLY for liveness signals
16
+ * (busy / idle / dialog detection) — assistant text is never parsed from
17
+ * the screen; the transcript JSONL is the text source of truth.
18
+ */
19
+ export declare class ScreenModel {
20
+ readonly cols: number;
21
+ readonly rows: number;
22
+ private term;
23
+ private lastDataTs;
24
+ /** Set when a busy marker is seen in a raw chunk; survives fast busy→idle flips between polls. */
25
+ private busySeenInRaw;
26
+ constructor(cols?: number, rows?: number);
27
+ write(data: string): void;
28
+ /** Milliseconds since the PTY last produced output. */
29
+ quietMs(): number;
30
+ text(): string;
31
+ /** Claude is processing a turn (spinner area shows "esc to interrupt"). */
32
+ isBusy(): boolean;
33
+ /** Consume the raw-chunk busy flag (catches turns faster than the poll interval). */
34
+ consumeBusySeen(): boolean;
35
+ /** Idle input prompt is on screen. */
36
+ hasPrompt(): boolean;
37
+ detectDialog(): DialogKind | null;
38
+ }
39
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/shell/screen.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAO9C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,aAAa,QAAS,CAAC;AACpC,eAAO,MAAM,gBAAgB,uDAAwD,CAAC;AAEtF;;;;GAIG;AACH,qBAAa,WAAW;aAMM,IAAI;aAAwB,IAAI;IAL5D,OAAO,CAAC,IAAI,CAAW;IACvB,OAAO,CAAC,UAAU,CAAc;IAChC,kGAAkG;IAClG,OAAO,CAAC,aAAa,CAAS;gBAEF,IAAI,SAAM,EAAkB,IAAI,SAAK;IAIjE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMzB,uDAAuD;IACvD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;IAUd,2EAA2E;IAC3E,MAAM,IAAI,OAAO;IAIjB,qFAAqF;IACrF,eAAe,IAAI,OAAO;IAM1B,sCAAsC;IACtC,SAAS,IAAI,OAAO;IAIpB,YAAY,IAAI,UAAU,GAAG,IAAI;CAOlC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScreenModel = exports.TUI_BYPASS_PERMS = exports.TUI_PROMPT_RE = exports.TUI_BUSY_MARKER = void 0;
4
+ const headless_1 = require("@xterm/headless");
5
+ /** The TUI renders spaces as U+00A0 (non-breaking) — normalize before matching. */
6
+ function normalize(text) {
7
+ return text.replace(/ /g, ' ');
8
+ }
9
+ /**
10
+ * TUI string constants — verified against Claude Code v2.1.x.
11
+ * When upgrading Claude Code, re-check each constant against the new TUI output.
12
+ * All matchers live here so a UI change requires touching exactly one file.
13
+ *
14
+ * BUSY_MARKER status bar text during an active turn
15
+ * PROMPT_RE idle input caret pattern
16
+ * BYPASS_PERMS "Bypass Permissions" dialog markers
17
+ */
18
+ exports.TUI_BUSY_MARKER = 'esc to interrupt';
19
+ exports.TUI_PROMPT_RE = /^❯ /m;
20
+ exports.TUI_BYPASS_PERMS = ['Bypass Permissions mode', 'Yes, I accept'];
21
+ /**
22
+ * Virtual terminal fed with raw PTY bytes. Used ONLY for liveness signals
23
+ * (busy / idle / dialog detection) — assistant text is never parsed from
24
+ * the screen; the transcript JSONL is the text source of truth.
25
+ */
26
+ class ScreenModel {
27
+ constructor(cols = 200, rows = 50) {
28
+ this.cols = cols;
29
+ this.rows = rows;
30
+ this.lastDataTs = Date.now();
31
+ /** Set when a busy marker is seen in a raw chunk; survives fast busy→idle flips between polls. */
32
+ this.busySeenInRaw = false;
33
+ this.term = new headless_1.Terminal({ cols, rows, allowProposedApi: true });
34
+ }
35
+ write(data) {
36
+ this.lastDataTs = Date.now();
37
+ if (normalize(data).includes(exports.TUI_BUSY_MARKER))
38
+ this.busySeenInRaw = true;
39
+ this.term.write(data);
40
+ }
41
+ /** Milliseconds since the PTY last produced output. */
42
+ quietMs() {
43
+ return Date.now() - this.lastDataTs;
44
+ }
45
+ text() {
46
+ const buf = this.term.buffer.active;
47
+ const lines = [];
48
+ for (let i = 0; i < this.term.rows; i++) {
49
+ const line = buf.getLine(buf.viewportY + i);
50
+ lines.push(line ? line.translateToString(true) : '');
51
+ }
52
+ return normalize(lines.join('\n'));
53
+ }
54
+ /** Claude is processing a turn (spinner area shows "esc to interrupt"). */
55
+ isBusy() {
56
+ return this.text().includes(exports.TUI_BUSY_MARKER);
57
+ }
58
+ /** Consume the raw-chunk busy flag (catches turns faster than the poll interval). */
59
+ consumeBusySeen() {
60
+ const seen = this.busySeenInRaw;
61
+ this.busySeenInRaw = false;
62
+ return seen;
63
+ }
64
+ /** Idle input prompt is on screen. */
65
+ hasPrompt() {
66
+ return exports.TUI_PROMPT_RE.test(this.text());
67
+ }
68
+ detectDialog() {
69
+ const text = this.text();
70
+ if (exports.TUI_BYPASS_PERMS.every((s) => text.includes(s))) {
71
+ return 'bypass-permissions';
72
+ }
73
+ return null;
74
+ }
75
+ }
76
+ exports.ScreenModel = ScreenModel;
77
+ //# sourceMappingURL=screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.js","sourceRoot":"","sources":["../../src/shell/screen.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAI3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C,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;YAC5C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,2EAA2E;IAC3E,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,uBAAe,CAAC,CAAC;IAC/C,CAAC;IAED,qFAAqF;IACrF,eAAe;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;QAChC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sCAAsC;IACtC,SAAS;QACP,OAAO,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,YAAY;QACV,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACzB,IAAI,wBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACpD,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvDD,kCAuDC"}
@@ -0,0 +1,64 @@
1
+ export interface UsageInfo {
2
+ input_tokens?: number;
3
+ cache_read_input_tokens?: number;
4
+ cache_creation_input_tokens?: number;
5
+ output_tokens?: number;
6
+ }
7
+ export interface AssistantRecord {
8
+ type: 'assistant';
9
+ isSidechain?: boolean;
10
+ message: {
11
+ role: 'assistant';
12
+ content: Array<{
13
+ type: string;
14
+ [k: string]: unknown;
15
+ }>;
16
+ stop_reason?: string | null;
17
+ usage?: UsageInfo;
18
+ };
19
+ uuid?: string;
20
+ timestamp?: string;
21
+ }
22
+ export interface TailerEvents {
23
+ /** A new (non-sidechain) assistant record was appended. */
24
+ onAssistant: (record: AssistantRecord) => void;
25
+ /** Claude finished a turn (system/turn_duration record). */
26
+ onTurnEnd: (durationMs: number) => void;
27
+ onError: (err: Error) => void;
28
+ }
29
+ /**
30
+ * cwd → Claude Code project-dir slug (verified against v2.1.x: `/` and `.` both become `-`).
31
+ * If Claude Code ever changes this scheme, findFile()'s fallback UUID scan will still
32
+ * locate the transcript — the primary path is just an optimistic fast path.
33
+ */
34
+ export declare function projectSlug(cwd: string): string;
35
+ export declare function transcriptPath(cwd: string, sessionId: string): string;
36
+ /**
37
+ * Incrementally reads the session transcript JSONL that interactive Claude
38
+ * Code appends to *during* a turn. This is the text source of truth and the
39
+ * streaming source: records are surfaced the moment they hit the file.
40
+ */
41
+ export declare class TranscriptTailer {
42
+ private readonly cwd;
43
+ private readonly sessionId;
44
+ private readonly events;
45
+ private readonly pollMs;
46
+ private offset;
47
+ private partialLine;
48
+ private timer;
49
+ private resolvedPath;
50
+ /** Total records dispatched since start — non-zero means claude is writing output. */
51
+ seenRecords: number;
52
+ /** Timestamp of last fallback scan — caps expensive readdirSync to once per 2s. */
53
+ private lastFallbackScanMs;
54
+ private static readonly FALLBACK_SCAN_INTERVAL_MS;
55
+ constructor(cwd: string, sessionId: string, events: TailerEvents, pollMs?: number);
56
+ start(): void;
57
+ stop(): void;
58
+ /** Force one synchronous read (used right before emitting a result). */
59
+ flush(): void;
60
+ private findFile;
61
+ private poll;
62
+ private dispatch;
63
+ }
64
+ //# sourceMappingURL=tailer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailer.d.ts","sourceRoot":"","sources":["../../src/shell/tailer.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;I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,CAA+C;IAC5D,OAAO,CAAC,YAAY,CAAuB;IAC3C,sFAAsF;IACtF,WAAW,SAAK;IAChB,mFAAmF;IACnF,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAS;gBAGvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,EACpB,MAAM,SAAM;IAG/B,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI;IAKZ,wEAAwE;IACxE,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,QAAQ;IA0BhB,OAAO,CAAC,IAAI;IA2CZ,OAAO,CAAC,QAAQ;CAejB"}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.TranscriptTailer = void 0;
37
+ exports.projectSlug = projectSlug;
38
+ exports.transcriptPath = transcriptPath;
39
+ const fs = __importStar(require("fs"));
40
+ const os = __importStar(require("os"));
41
+ const path = __importStar(require("path"));
42
+ /**
43
+ * cwd → Claude Code project-dir slug (verified against v2.1.x: `/` and `.` both become `-`).
44
+ * If Claude Code ever changes this scheme, findFile()'s fallback UUID scan will still
45
+ * locate the transcript — the primary path is just an optimistic fast path.
46
+ */
47
+ function projectSlug(cwd) {
48
+ return cwd.replace(/[/.]/g, '-');
49
+ }
50
+ function transcriptPath(cwd, sessionId) {
51
+ return path.join(os.homedir(), '.claude', 'projects', projectSlug(cwd), `${sessionId}.jsonl`);
52
+ }
53
+ /**
54
+ * Incrementally reads the session transcript JSONL that interactive Claude
55
+ * Code appends to *during* a turn. This is the text source of truth and the
56
+ * streaming source: records are surfaced the moment they hit the file.
57
+ */
58
+ class TranscriptTailer {
59
+ constructor(cwd, sessionId, events, pollMs = 150) {
60
+ this.cwd = cwd;
61
+ this.sessionId = sessionId;
62
+ this.events = events;
63
+ this.pollMs = pollMs;
64
+ this.offset = 0;
65
+ this.partialLine = '';
66
+ this.timer = null;
67
+ this.resolvedPath = null;
68
+ /** Total records dispatched since start — non-zero means claude is writing output. */
69
+ this.seenRecords = 0;
70
+ /** Timestamp of last fallback scan — caps expensive readdirSync to once per 2s. */
71
+ this.lastFallbackScanMs = 0;
72
+ }
73
+ start() {
74
+ this.timer = setInterval(() => this.poll(), this.pollMs);
75
+ }
76
+ stop() {
77
+ if (this.timer)
78
+ clearInterval(this.timer);
79
+ this.timer = null;
80
+ }
81
+ /** Force one synchronous read (used right before emitting a result). */
82
+ flush() {
83
+ this.poll();
84
+ }
85
+ findFile() {
86
+ if (this.resolvedPath)
87
+ return this.resolvedPath;
88
+ const expected = transcriptPath(this.cwd, this.sessionId);
89
+ if (fs.existsSync(expected)) {
90
+ this.resolvedPath = expected;
91
+ return expected;
92
+ }
93
+ // Fallback if the slug scheme ever changes: scan project dirs for the uuid.
94
+ // Capped to once per 2s — readdirSync over hundreds of project dirs every 150ms poll
95
+ // is expensive before the transcript file has been created.
96
+ const now = Date.now();
97
+ if (now - this.lastFallbackScanMs < TranscriptTailer.FALLBACK_SCAN_INTERVAL_MS)
98
+ return null;
99
+ this.lastFallbackScanMs = now;
100
+ const projectsRoot = path.join(os.homedir(), '.claude', 'projects');
101
+ let dirs = [];
102
+ try {
103
+ dirs = fs.readdirSync(projectsRoot);
104
+ }
105
+ catch {
106
+ return null;
107
+ }
108
+ for (const dir of dirs) {
109
+ const candidate = path.join(projectsRoot, dir, `${this.sessionId}.jsonl`);
110
+ if (fs.existsSync(candidate)) {
111
+ this.resolvedPath = candidate;
112
+ return candidate;
113
+ }
114
+ }
115
+ return null;
116
+ }
117
+ poll() {
118
+ const file = this.findFile();
119
+ if (!file)
120
+ return;
121
+ let size;
122
+ try {
123
+ size = fs.statSync(file).size;
124
+ }
125
+ catch {
126
+ return; // transient: file rotated/removed
127
+ }
128
+ if (size <= this.offset)
129
+ return;
130
+ let chunk;
131
+ try {
132
+ const fd = fs.openSync(file, 'r');
133
+ const buf = Buffer.alloc(size - this.offset);
134
+ fs.readSync(fd, buf, 0, buf.length, this.offset);
135
+ fs.closeSync(fd);
136
+ chunk = buf.toString('utf8');
137
+ }
138
+ catch (err) {
139
+ this.events.onError(err instanceof Error ? err : new Error(String(err)));
140
+ return;
141
+ }
142
+ this.offset = size;
143
+ const data = this.partialLine + chunk;
144
+ const lines = data.split('\n');
145
+ this.partialLine = lines.pop() ?? '';
146
+ for (const line of lines) {
147
+ if (!line.trim())
148
+ continue;
149
+ let record;
150
+ try {
151
+ record = JSON.parse(line);
152
+ }
153
+ catch {
154
+ // Mid-write torn line should be impossible (we split on \n), so a bad
155
+ // line is real corruption — surface it, never swallow.
156
+ this.events.onError(new Error(`unparseable transcript line (${line.length} bytes)`));
157
+ continue;
158
+ }
159
+ this.dispatch(record);
160
+ }
161
+ }
162
+ dispatch(record) {
163
+ if (record.isSidechain === true)
164
+ return; // subagent-internal records
165
+ this.seenRecords++;
166
+ if (record.type === 'assistant') {
167
+ const message = record.message;
168
+ if (message && Array.isArray(message.content)) {
169
+ this.events.onAssistant(record);
170
+ }
171
+ return;
172
+ }
173
+ if (record.type === 'system' && record.subtype === 'turn_duration') {
174
+ const durationMs = typeof record.durationMs === 'number' ? record.durationMs : 0;
175
+ this.events.onTurnEnd(durationMs);
176
+ }
177
+ }
178
+ }
179
+ exports.TranscriptTailer = TranscriptTailer;
180
+ TranscriptTailer.FALLBACK_SCAN_INTERVAL_MS = 2000;
181
+ //# sourceMappingURL=tailer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailer.js","sourceRoot":"","sources":["../../src/shell/tailer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,kCAEC;AAED,wCAEC;AA3CD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AA8B7B;;;;GAIG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,SAAiB;IAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,QAAQ,CAAC,CAAC;AAChG,CAAC;AAED;;;;GAIG;AACH,MAAa,gBAAgB;IAW3B,YACmB,GAAW,EACX,SAAiB,EACjB,MAAoB,EACpB,SAAS,GAAG;QAHZ,QAAG,GAAH,GAAG,CAAQ;QACX,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAc;QAC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AAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAiD,CAAC;YACzE,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAoC,CAAC,CAAC;YAChE,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,KAAK,eAAe,EAAE,CAAC;YACnE,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;;AAnHH,4CAoHC;AA3GyB,0CAAyB,GAAG,IAAK,AAAR,CAAS"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Pre-write flags into ~/.claude.json before spawning Claude Code so no startup dialogs appear.
3
+ *
4
+ * All flags live in a single file (~/.claude.json), matching Claude Code's GlobalConfig:
5
+ *
6
+ * Top-level keys (read by getGlobalConfig()):
7
+ * hasCompletedOnboarding = true → skips the theme/style picker (showSetupScreens check)
8
+ *
9
+ * projects[cwd] entry:
10
+ * hasTrustDialogAccepted = true → suppresses the workspace trust dialog
11
+ * projectOnboardingSeenCount = 1 → suppresses the per-project onboarding flow
12
+ *
13
+ * Writes are atomic (tmp+rename) and skipped if all flags are already set.
14
+ * The configPath parameter is exposed for testing only.
15
+ */
16
+ export declare function preTrustWorkspace(cwd: string, claudeJsonPath?: string): void;
17
+ /**
18
+ * Check whether Claude Code is authenticated.
19
+ * Runs `claude auth status` and parses the JSON output.
20
+ * Returns { loggedIn: false } on any error (missing binary, parse failure, etc.).
21
+ *
22
+ * Uses spawnSync with an args array — avoids shell interpolation of claudeBin.
23
+ */
24
+ export declare function checkAuthStatus(claudeBin?: string): {
25
+ loggedIn: boolean;
26
+ authMethod?: string;
27
+ };
28
+ //# sourceMappingURL=trust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../../src/shell/trust.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE,MAAM,GACtB,IAAI,CAEN;AA2CD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,SAAS,SAAW,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAahG"}