@interactive-inc/claude-funnel 0.8.0 → 0.8.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 (127) hide show
  1. package/dist/bin.js +583 -656
  2. package/dist/cli/factory.d.ts +7 -0
  3. package/dist/cli/router/query-to-cli-args.d.ts +1 -0
  4. package/dist/cli/router/to-request.d.ts +5 -0
  5. package/dist/cli/router/validator.d.ts +5 -0
  6. package/dist/cli/routes/channels.$channel.connectors.$connector.d.ts +42 -0
  7. package/dist/cli/routes/channels.$channel.connectors.$connector.rename.$newName.d.ts +46 -0
  8. package/dist/cli/routes/channels.$channel.connectors.$connector.request.d.ts +54 -0
  9. package/dist/cli/routes/channels.$channel.connectors.$connector.schedules.add.$id.d.ts +66 -0
  10. package/dist/cli/routes/channels.$channel.connectors.$connector.schedules.d.ts +42 -0
  11. package/dist/cli/routes/channels.$channel.connectors.$connector.schedules.remove.$id.d.ts +46 -0
  12. package/dist/cli/routes/channels.$channel.connectors.add.$connector.d.ts +90 -0
  13. package/dist/cli/routes/channels.$channel.connectors.d.ts +38 -0
  14. package/dist/cli/routes/channels.$channel.connectors.remove.$connector.d.ts +42 -0
  15. package/dist/cli/routes/channels.$channel.connectors.set.$connector.d.ts +62 -0
  16. package/dist/cli/routes/channels.$channel.d.ts +38 -0
  17. package/dist/cli/routes/channels.$channel.rename.$newName.d.ts +42 -0
  18. package/dist/cli/routes/channels.$channel.set.delivery.$mode.d.ts +28 -0
  19. package/dist/cli/routes/channels.add.$channel.d.ts +46 -0
  20. package/dist/cli/routes/channels.d.ts +16 -0
  21. package/dist/cli/routes/channels.remove.$channel.d.ts +38 -0
  22. package/dist/cli/routes/claude.d.ts +32 -0
  23. package/dist/cli/routes/gateway.d.ts +20 -0
  24. package/dist/cli/routes/gateway.listeners.d.ts +17 -0
  25. package/dist/cli/routes/gateway.logs.d.ts +24 -0
  26. package/dist/cli/routes/gateway.restart.d.ts +24 -0
  27. package/dist/cli/routes/gateway.run.d.ts +24 -0
  28. package/dist/cli/routes/gateway.start.d.ts +24 -0
  29. package/dist/cli/routes/gateway.status.d.ts +13 -0
  30. package/dist/cli/routes/gateway.stop.d.ts +16 -0
  31. package/dist/cli/routes/index.d.ts +1222 -0
  32. package/dist/cli/routes/profiles.$profile.as-default.d.ts +38 -0
  33. package/dist/cli/routes/profiles.$profile.rename.$newName.d.ts +42 -0
  34. package/dist/cli/routes/profiles.$profile.run.d.ts +46 -0
  35. package/dist/cli/routes/profiles.add.$profile.d.ts +54 -0
  36. package/dist/cli/routes/profiles.d.ts +16 -0
  37. package/dist/cli/routes/profiles.remove.$profile.d.ts +38 -0
  38. package/dist/cli/routes/profiles.set.$profile.d.ts +54 -0
  39. package/dist/cli/routes/status.d.ts +16 -0
  40. package/dist/cli/routes/update.d.ts +16 -0
  41. package/dist/connectors/connector-adapter.d.ts +8 -0
  42. package/dist/connectors/connector-config-schema.d.ts +43 -0
  43. package/dist/connectors/connector-factory.d.ts +32 -0
  44. package/dist/connectors/connector-listener.d.ts +17 -0
  45. package/dist/connectors/discord-adapter.d.ts +14 -0
  46. package/dist/connectors/discord-connector-schema.d.ts +10 -0
  47. package/dist/connectors/discord-event-processor.d.ts +26 -0
  48. package/dist/connectors/discord-listener.d.ts +17 -0
  49. package/dist/connectors/gh-adapter.d.ts +11 -0
  50. package/dist/connectors/gh-connector-schema.d.ts +10 -0
  51. package/dist/connectors/gh-listener.d.ts +26 -0
  52. package/dist/connectors/match-cron.d.ts +1 -0
  53. package/dist/connectors/schedule-connector-schema.d.ts +45 -0
  54. package/dist/connectors/schedule-listener.d.ts +30 -0
  55. package/dist/connectors/schedule-state-store.d.ts +19 -0
  56. package/dist/connectors/slack-adapter.d.ts +15 -0
  57. package/dist/connectors/slack-connector-schema.d.ts +11 -0
  58. package/dist/connectors/slack-event-processor.d.ts +27 -0
  59. package/dist/connectors/slack-listener.d.ts +17 -0
  60. package/dist/engine/channels/channels.d.ts +106 -0
  61. package/dist/engine/claude/claude.d.ts +49 -0
  62. package/dist/engine/claude/gateway-controller.d.ts +6 -0
  63. package/dist/engine/fs/file-system.d.ts +24 -0
  64. package/dist/engine/fs/memory-file-system.d.ts +31 -0
  65. package/dist/engine/fs/node-file-system.d.ts +15 -0
  66. package/dist/engine/http/http-client.d.ts +15 -0
  67. package/dist/engine/http/memory-http-client.d.ts +12 -0
  68. package/dist/engine/http/node-http-client.d.ts +5 -0
  69. package/dist/engine/id/id-generator.d.ts +7 -0
  70. package/dist/engine/id/memory-id-generator.d.ts +11 -0
  71. package/dist/engine/id/node-id-generator.d.ts +4 -0
  72. package/dist/engine/logger/logger.d.ts +11 -0
  73. package/dist/engine/logger/memory-logger.d.ts +14 -0
  74. package/dist/engine/logger/node-logger.d.ts +15 -0
  75. package/dist/engine/logger/noop-logger.d.ts +7 -0
  76. package/dist/engine/mcp/channel-server.d.ts +1 -0
  77. package/dist/engine/mcp/mcp.d.ts +22 -0
  78. package/dist/engine/process/memory-process-runner.d.ts +43 -0
  79. package/dist/engine/process/node-process-runner.d.ts +9 -0
  80. package/dist/engine/process/process-runner.d.ts +29 -0
  81. package/dist/engine/profiles/profile-channel-checker.d.ts +7 -0
  82. package/dist/engine/profiles/profiles.d.ts +31 -0
  83. package/dist/engine/settings/mock-settings-reader.d.ts +9 -0
  84. package/dist/engine/settings/settings-reader.d.ts +5 -0
  85. package/dist/engine/settings/settings-schema.d.ts +132 -0
  86. package/dist/engine/settings/settings-store.d.ts +18 -0
  87. package/dist/engine/time/clock.d.ts +9 -0
  88. package/dist/engine/time/memory-clock.d.ts +12 -0
  89. package/dist/engine/time/node-clock.d.ts +4 -0
  90. package/dist/funnel.d.ts +95 -0
  91. package/dist/gateway/auth-middleware.d.ts +14 -0
  92. package/dist/gateway/broadcaster.d.ts +122 -0
  93. package/dist/gateway/daemon.d.ts +2 -0
  94. package/dist/gateway/daemon.js +192 -220
  95. package/dist/gateway/factory.d.ts +7 -0
  96. package/dist/gateway/funnel-event-store.d.ts +81 -0
  97. package/dist/gateway/gateway-server.d.ts +94 -0
  98. package/dist/gateway/gateway-token.d.ts +33 -0
  99. package/dist/gateway/gateway.d.ts +58 -0
  100. package/dist/gateway/kill-competing-slack-gateways.d.ts +9 -0
  101. package/dist/gateway/listener-supervisor.d.ts +85 -0
  102. package/dist/gateway/listeners-client.d.ts +53 -0
  103. package/dist/gateway/resolve-daemon-script.d.ts +11 -0
  104. package/dist/gateway/routes/channels.connectors.call.d.ts +41 -0
  105. package/dist/gateway/routes/health.d.ts +17 -0
  106. package/dist/gateway/routes/index.d.ts +209 -0
  107. package/dist/gateway/routes/listeners.list.d.ts +14 -0
  108. package/dist/gateway/routes/listeners.restart.d.ts +34 -0
  109. package/dist/gateway/routes/listeners.start.d.ts +34 -0
  110. package/dist/gateway/routes/listeners.stop.d.ts +34 -0
  111. package/dist/gateway/routes/route-deps.d.ts +10 -0
  112. package/dist/gateway/routes/status.d.ts +30 -0
  113. package/dist/gateway/routes/validator.d.ts +19 -0
  114. package/dist/index.d.ts +36 -0
  115. package/dist/index.js +3575 -0
  116. package/dist/logger/leuco-human-file-writer.d.ts +33 -0
  117. package/dist/logger/leuco-human-logger.d.ts +46 -0
  118. package/dist/logger/leuco-human-record.d.ts +15 -0
  119. package/dist/logger/leuco-human-stdout-writer.d.ts +20 -0
  120. package/dist/logger/leuco-human-writer.d.ts +13 -0
  121. package/dist/logger/leuco-logger-memory-sink.d.ts +33 -0
  122. package/dist/logger/leuco-logger-record.d.ts +13 -0
  123. package/dist/logger/leuco-logger-sink.d.ts +34 -0
  124. package/dist/logger/leuco-logger-sqlite-sink.d.ts +102 -0
  125. package/dist/logger/leuco-logger.d.ts +56 -0
  126. package/lib/index.ts +2 -0
  127. package/package.json +14 -9
@@ -0,0 +1,33 @@
1
+ import type { LeucoHumanRecord } from "./leuco-human-record";
2
+ import type { LeucoHumanWriter } from "./leuco-human-writer";
3
+ type Props = {
4
+ /** Filesystem path. Parent directory is created on construct. */
5
+ path: string;
6
+ /**
7
+ * Optional size cap in bytes. When the next write would push the file
8
+ * over the cap, the existing file becomes `<path>.1` (replacing any
9
+ * prior `.1`) and a fresh file takes its place. Single-keep rotation —
10
+ * a second cycle drops the previous `.1`.
11
+ */
12
+ maxBytes?: number;
13
+ };
14
+ /**
15
+ * Appends one JSON line per record to a file. Optional one-keep size
16
+ * rotation. Designed for diagnostic logs a human tails (`tail -f file |
17
+ * jq`); not for replay or queries — use `LeucoLoggerSqliteSink` if you
18
+ * need indexed lookups.
19
+ *
20
+ * Writes are synchronous (`appendFileSync`), so each line is durable
21
+ * before `write` returns. Throughput matches the OS file cache; for
22
+ * high-volume logging consider buffering at the call site or using a
23
+ * different writer.
24
+ */
25
+ export declare class LeucoHumanFileWriter implements LeucoHumanWriter {
26
+ private readonly path;
27
+ private readonly maxBytes;
28
+ constructor(props: Props);
29
+ write(record: LeucoHumanRecord): void | Error;
30
+ private ensureDir;
31
+ private rotateIfNeeded;
32
+ }
33
+ export {};
@@ -0,0 +1,46 @@
1
+ import type { LeucoHumanLevel, LeucoHumanRecord } from "./leuco-human-record";
2
+ import type { LeucoHumanWriter } from "./leuco-human-writer";
3
+ type WriteErrorHandler = (error: Error, record: LeucoHumanRecord) => void;
4
+ type Props = {
5
+ /** Where records go. Use `LeucoHumanStdoutWriter`, `LeucoHumanFileWriter`, or your own. */
6
+ writer: LeucoHumanWriter;
7
+ /** Minimum level to emit. Lower-rank records are dropped. Default: "info". */
8
+ level?: LeucoHumanLevel;
9
+ /** Override for tests. Defaults to `Date.now`. */
10
+ now?: () => number;
11
+ /** Observer for writer failures. Default: silently swallow. */
12
+ onWriteError?: WriteErrorHandler;
13
+ };
14
+ /**
15
+ * Human-facing diagnostic logger. The companion to `LeucoLogger`: where
16
+ * `LeucoLogger` is for schema-validated, replayable domain events,
17
+ * `LeucoHumanLogger` is for free-form info/warn/error messages destined
18
+ * for a human tailing a log or skimming during incident response.
19
+ *
20
+ * Keeping the two separate matters operationally:
21
+ * - Diagnostics typically out-volume domain events 10–1000x; mixing
22
+ * them in the same store would push events out under retention.
23
+ * - Diagnostics are unstructured by design; mixing them in would defeat
24
+ * the schema-first guarantee that makes domain events replayable.
25
+ * - Different audiences and queries (humans grep `tail -f` vs. tools
26
+ * query `WHERE seq > ?`).
27
+ *
28
+ * The writer is a port. Level gating happens here so writers receive only
29
+ * what is worth persisting. Failure isolation matches `LeucoLogger`: a
30
+ * writer that throws or returns Error is contained, surfaced via
31
+ * `onWriteError`, and never blocks the caller.
32
+ */
33
+ export declare class LeucoHumanLogger {
34
+ private readonly writer;
35
+ private readonly minRank;
36
+ private readonly now;
37
+ private readonly onWriteError;
38
+ constructor(props: Props);
39
+ info(message: string, meta?: Record<string, unknown>): void;
40
+ warn(message: string, meta?: Record<string, unknown>): void;
41
+ error(message: string, meta?: Record<string, unknown>): void;
42
+ close(): void;
43
+ private emit;
44
+ private callWriter;
45
+ }
46
+ export {};
@@ -0,0 +1,15 @@
1
+ export type LeucoHumanLevel = "info" | "warn" | "error";
2
+ /**
3
+ * One human-facing diagnostic log entry. Distinct from `LeucoLoggerRecord`
4
+ * (which wraps a schema-validated domain event) — this is the free-form,
5
+ * for-humans-tailing-a-log shape: a level, a message, and optional meta.
6
+ *
7
+ * `meta` is `null` rather than `undefined` when absent so writers can
8
+ * persist a uniform shape (no missing-key ambiguity in JSON Lines).
9
+ */
10
+ export type LeucoHumanRecord = {
11
+ ts: number;
12
+ level: LeucoHumanLevel;
13
+ message: string;
14
+ meta: Record<string, unknown> | null;
15
+ };
@@ -0,0 +1,20 @@
1
+ import type { LeucoHumanRecord } from "./leuco-human-record";
2
+ import type { LeucoHumanWriter } from "./leuco-human-writer";
3
+ type Stream = {
4
+ write(s: string): void;
5
+ };
6
+ type Props = {
7
+ /** Override for tests. Defaults to `process.stdout`. */
8
+ out?: Stream;
9
+ };
10
+ /**
11
+ * Writes one JSON line per record to stdout. Useful as the default writer
12
+ * for foreground daemons, dev runs, and short-lived processes where a
13
+ * file-backed log would be overkill.
14
+ */
15
+ export declare class LeucoHumanStdoutWriter implements LeucoHumanWriter {
16
+ private readonly out;
17
+ constructor(props?: Props);
18
+ write(record: LeucoHumanRecord): void;
19
+ }
20
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { LeucoHumanRecord } from "./leuco-human-record";
2
+ /**
3
+ * Plugin port for `LeucoHumanLogger`. Writers decide where diagnostic
4
+ * records land — stdout, JSONL file, syslog, network, etc. — without the
5
+ * logger having to know about persistence shape.
6
+ *
7
+ * `write` returns `void` on success or an `Error` the logger surfaces via
8
+ * `onWriteError`. Throwing is also tolerated; the logger catches.
9
+ */
10
+ export type LeucoHumanWriter = {
11
+ write(record: LeucoHumanRecord): void | Error;
12
+ close?(): void;
13
+ };
@@ -0,0 +1,33 @@
1
+ import type { LeucoLoggerRecord } from "./leuco-logger-record";
2
+ import type { LeucoLoggerPrimarySink, LeucoLoggerSink } from "./leuco-logger-sink";
3
+ type Props = {
4
+ /** Hard cap on retained records. The oldest is evicted on overflow. 0 disables retention. */
5
+ capacity?: number;
6
+ };
7
+ /**
8
+ * In-memory ring buffer that doubles as primary or relay. As primary it
9
+ * owns its own seq counter (single-process only — for multi-process
10
+ * safety, use `LeucoLoggerSqliteSink` as primary and place this as a
11
+ * relay). As relay it accepts whatever seq the primary assigned and
12
+ * advances its own counter to match, so `getMaxSeq` stays meaningful.
13
+ *
14
+ * Useful as a test double, as a short-window replay buffer paired with a
15
+ * persistent primary (covering reconnects without round-tripping disk),
16
+ * or as a backing store for live subscribers.
17
+ */
18
+ export declare class LeucoLoggerMemorySink<E> implements LeucoLoggerPrimarySink<E>, LeucoLoggerSink<E> {
19
+ private readonly capacity;
20
+ private readonly buffer;
21
+ private seq;
22
+ constructor(props?: Props);
23
+ insert(input: {
24
+ ts: number;
25
+ event: E;
26
+ }): LeucoLoggerRecord<E>;
27
+ write(record: LeucoLoggerRecord<E>): void;
28
+ getMaxSeq(): number;
29
+ getRecords(): ReadonlyArray<LeucoLoggerRecord<E>>;
30
+ clear(): void;
31
+ private append;
32
+ }
33
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Wrapper that `LeucoLogger.emit` puts around every event before handing it
3
+ * to a sink. `seq` is monotonic across the lifetime of the underlying store —
4
+ * sinks persist it as the primary key so replay (and broadcaster seeding
5
+ * after restart) is an indexed range scan, not a full table walk. `ts` is
6
+ * epoch milliseconds. `event` is the caller-defined payload validated by the
7
+ * Zod schema passed to the bus.
8
+ */
9
+ export type LeucoLoggerRecord<E> = {
10
+ seq: number;
11
+ ts: number;
12
+ event: E;
13
+ };
@@ -0,0 +1,34 @@
1
+ import type { LeucoLoggerRecord } from "./leuco-logger-record";
2
+ /**
3
+ * Relay sink. Receives records that already have a `seq` assigned by the
4
+ * primary and stores or forwards them — memory ring, stdout, network push,
5
+ * a second SQLite mirror, etc. Does not generate seq itself, so any number
6
+ * can be attached and they all observe the same monotonic stream.
7
+ *
8
+ * `write` returns `void` on success or an `Error` the bus surfaces via
9
+ * `onSinkError`. Throwing is also tolerated (the bus catches), but
10
+ * returning is preferred so the failure path is part of the type.
11
+ */
12
+ export type LeucoLoggerSink<E> = {
13
+ write(record: LeucoLoggerRecord<E>): void | Error;
14
+ close?(): void;
15
+ };
16
+ /**
17
+ * Primary sink. Owns the canonical seq sequence for the bus. `insert` is
18
+ * the atomic boundary — it assigns a seq strictly greater than every
19
+ * previously assigned one, persists the record, and returns it. SQLite
20
+ * implementations get atomicity for free by delegating to `INTEGER PRIMARY
21
+ * KEY` so two processes sharing one database file see one monotonic
22
+ * stream without bus-level coordination.
23
+ *
24
+ * `getMaxSeq` is the highest seq currently in the sink — used for
25
+ * observability and for replay seeding by clients reading the store.
26
+ */
27
+ export type LeucoLoggerPrimarySink<E> = {
28
+ insert(input: {
29
+ ts: number;
30
+ event: E;
31
+ }): LeucoLoggerRecord<E> | Error;
32
+ getMaxSeq(): number;
33
+ close?(): void;
34
+ };
@@ -0,0 +1,102 @@
1
+ import type { LeucoLoggerRecord } from "./leuco-logger-record";
2
+ import type { LeucoLoggerPrimarySink, LeucoLoggerSink } from "./leuco-logger-sink";
3
+ type IndexValues<I extends ReadonlyArray<string>> = Record<I[number], string | null>;
4
+ /**
5
+ * Constructor props. The shape narrows on `I`: when no indexes are
6
+ * declared (the default), `extractIndexes` is forbidden; when indexes
7
+ * are declared, both `indexes` and `extractIndexes` are required and
8
+ * `extractIndexes` is type-checked against the index keys.
9
+ */
10
+ type Props<E, I extends ReadonlyArray<string>> = I extends readonly [] ? {
11
+ path: string;
12
+ maxRows?: number;
13
+ maxAgeMs?: number;
14
+ now?: () => number;
15
+ indexes?: I;
16
+ extractIndexes?: never;
17
+ } : {
18
+ path: string;
19
+ maxRows?: number;
20
+ maxAgeMs?: number;
21
+ now?: () => number;
22
+ indexes: I;
23
+ extractIndexes: (event: E) => IndexValues<I>;
24
+ };
25
+ type GetRecordsProps<I extends ReadonlyArray<string>> = {
26
+ /** Return only records with seq strictly greater than this. */
27
+ sinceSeq?: number;
28
+ /** Filter by the top-level `event.type` discriminator. */
29
+ type?: string;
30
+ /** Filter by indexed columns. Keys are constrained to the declared `indexes`. */
31
+ where?: Partial<IndexValues<I>>;
32
+ /** Maximum rows returned. Default 1000. */
33
+ limit?: number;
34
+ };
35
+ /**
36
+ * SQLite-backed sink built on `bun:sqlite`. Implements both primary and
37
+ * relay roles so the same instance can own seq generation for one bus and
38
+ * mirror records from another (e.g. cross-process replication, restore
39
+ * from a backup stream).
40
+ *
41
+ * Concurrency model: seq is `INTEGER PRIMARY KEY`, so SQLite assigns it
42
+ * atomically via `lastInsertRowid`. Two `LeucoLogger` instances pointed
43
+ * at the same database file therefore see one monotonically increasing
44
+ * seq stream without any bus-level coordination — the database itself is
45
+ * the synchronization point.
46
+ *
47
+ * Schema is version-managed via `PRAGMA user_version`. Migrations are
48
+ * append-only and run in a transaction on every construct so a partial
49
+ * upgrade rolls back cleanly. Caller-defined `indexes` are layered on top
50
+ * via `ALTER TABLE ADD COLUMN` + `CREATE INDEX IF NOT EXISTS`, so adding
51
+ * a new index to an existing database is a no-downtime operation.
52
+ *
53
+ * Type safety: the second generic parameter `I` is the literal tuple of
54
+ * index column names. `extractIndexes` and `getRecords({ where })` are
55
+ * both type-checked against this tuple, so a typo at the call site is a
56
+ * compile-time error rather than a silent miss at runtime.
57
+ *
58
+ * Retention is bounded by `maxRows` and/or `maxAgeMs`. Both run on every
59
+ * insert as a single indexed DELETE that no-ops below the cap.
60
+ *
61
+ * Bulk inserts use `insertMany`, which wraps the batch in one transaction
62
+ * for ~10–100x throughput at the cost of one fsync per batch instead of
63
+ * one per row.
64
+ */
65
+ export declare class LeucoLoggerSqliteSink<E, const I extends ReadonlyArray<string> = readonly []> implements LeucoLoggerPrimarySink<E>, LeucoLoggerSink<E> {
66
+ private readonly db;
67
+ private readonly maxRows;
68
+ private readonly maxAgeMs;
69
+ private readonly now;
70
+ private readonly indexes;
71
+ private readonly extractIndexes;
72
+ private readonly insertStmt;
73
+ private readonly insertWithSeqStmt;
74
+ private readonly maxSeqStmt;
75
+ private readonly countStmt;
76
+ private readonly trimRowsStmt;
77
+ private readonly trimAgeStmt;
78
+ constructor(props: Props<E, I>);
79
+ insert(input: {
80
+ ts: number;
81
+ event: E;
82
+ }): LeucoLoggerRecord<E> | Error;
83
+ insertMany(inputs: ReadonlyArray<{
84
+ ts: number;
85
+ event: E;
86
+ }>): LeucoLoggerRecord<E>[] | Error;
87
+ write(record: LeucoLoggerRecord<E>): void | Error;
88
+ getMaxSeq(): number;
89
+ getRecords(props?: GetRecordsProps<I>): LeucoLoggerRecord<E>[];
90
+ /**
91
+ * Current schema version. Useful for diagnostics and for tests that want
92
+ * to verify migrations ran. Reads `PRAGMA user_version` once per call.
93
+ */
94
+ getSchemaVersion(): number;
95
+ close(): void;
96
+ private buildInsertParams;
97
+ private appendWhereConditions;
98
+ private trim;
99
+ private syncIndexColumns;
100
+ private migrate;
101
+ }
102
+ export {};
@@ -0,0 +1,56 @@
1
+ import type { ZodType } from "zod";
2
+ import type { LeucoLoggerRecord } from "./leuco-logger-record";
3
+ import type { LeucoLoggerPrimarySink, LeucoLoggerSink } from "./leuco-logger-sink";
4
+ type Listener<E> = (record: LeucoLoggerRecord<E>) => void;
5
+ type SinkErrorHandler<E> = (error: Error, record: LeucoLoggerRecord<E>, sink: LeucoLoggerSink<E>) => void;
6
+ type Props<E> = {
7
+ /** Zod schema for the event union. Validated on every `emit`. */
8
+ schema: ZodType<E>;
9
+ /** Owns seq assignment + durability. Use `LeucoLoggerSqliteSink` for multi-process safety. */
10
+ primary: LeucoLoggerPrimarySink<E>;
11
+ /** Optional fanout for already-sequenced records (memory ring, stdout, network mirror). */
12
+ relays?: ReadonlyArray<LeucoLoggerSink<E>>;
13
+ /** Override for tests. Defaults to `Date.now`. */
14
+ now?: () => number;
15
+ /** Observer for relay failures. Default: silently swallow. */
16
+ onSinkError?: SinkErrorHandler<E>;
17
+ };
18
+ /**
19
+ * Schema-validated event log bus. Three responsibilities and nothing else:
20
+ * validate the event, delegate seq + persistence to the primary sink, and
21
+ * fan the resulting record out to relays and live subscribers.
22
+ *
23
+ * Splitting "primary" from "relays" makes the seq invariant honest: there
24
+ * is exactly one source of truth (the primary's atomic insert). Two
25
+ * `LeucoLogger` instances pointed at the same SQLite file therefore see
26
+ * one monotonic stream without bus-level coordination. Relays mirror
27
+ * already-sequenced records, so they can be added or removed without
28
+ * affecting correctness.
29
+ *
30
+ * Failure isolation:
31
+ * - Primary failure short-circuits emit and is returned to the caller.
32
+ * - Relay failures never block the primary path — they surface via the
33
+ * optional `onSinkError` callback so the caller can observe without
34
+ * being interrupted.
35
+ * - A subscriber that throws is contained; the rest of the fanout
36
+ * completes normally.
37
+ */
38
+ export declare class LeucoLogger<E> {
39
+ private readonly schema;
40
+ private readonly primary;
41
+ private readonly relays;
42
+ private readonly now;
43
+ private readonly onSinkError;
44
+ private readonly listeners;
45
+ constructor(props: Props<E>);
46
+ emit(event: E): LeucoLoggerRecord<E> | Error;
47
+ subscribe(listener: Listener<E>): () => void;
48
+ getMaxSeq(): number;
49
+ close(): void;
50
+ private callPrimary;
51
+ private fanOutToRelays;
52
+ private callRelay;
53
+ private fanOutToListeners;
54
+ private callClose;
55
+ }
56
+ export {};
package/lib/index.ts CHANGED
@@ -39,7 +39,9 @@ export * from "@/engine/id/memory-id-generator"
39
39
  // Connectors
40
40
  export * from "@/connectors/connector-factory"
41
41
  export * from "@/connectors/connector-config-schema"
42
+ export * from "@/connectors/connector-listener"
42
43
  export * from "@/connectors/schedule-connector-schema"
44
+ export * from "@/connectors/slack-connector-schema"
43
45
 
44
46
  // Gateway
45
47
  export * from "@/gateway/gateway"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interactive-inc/claude-funnel",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Hub CLI that routes external events (Slack / GitHub / Discord) to Claude Code agents through subscription channels over MCP.",
5
5
  "keywords": [
6
6
  "bun",
@@ -37,20 +37,25 @@
37
37
  "LICENSE"
38
38
  ],
39
39
  "scripts": {
40
- "build": "bun build lib/bin.ts lib/gateway/daemon.ts --target=bun --outdir dist --minify",
40
+ "build": "bun run build:lib && bun run build:bin && bun run build:types && bun run build:resolve-aliases",
41
+ "build:lib": "bun scripts/build-lib.ts",
42
+ "build:bin": "bun build lib/bin.ts lib/gateway/daemon.ts --target=bun --outdir dist --minify",
43
+ "build:types": "tsc -p tsconfig.build.json",
44
+ "build:resolve-aliases": "bun scripts/resolve-d-ts-aliases.ts",
41
45
  "prepare": "bun run build"
42
46
  },
43
47
  "type": "module",
44
- "main": "./lib/index.ts",
45
- "module": "./lib/index.ts",
46
- "types": "./lib/index.ts",
48
+ "main": "./dist/index.js",
49
+ "module": "./dist/index.js",
50
+ "types": "./dist/index.d.ts",
47
51
  "exports": {
48
52
  ".": {
49
- "types": "./lib/index.ts",
50
- "bun": "./lib/index.ts",
51
- "default": "./lib/index.ts"
53
+ "types": "./dist/index.d.ts",
54
+ "bun": "./dist/index.js",
55
+ "import": "./dist/index.js",
56
+ "default": "./dist/index.js"
52
57
  },
53
- "./bin": "./lib/bin.ts",
58
+ "./bin": "./dist/bin.js",
54
59
  "./package.json": "./package.json"
55
60
  },
56
61
  "publishConfig": {