@interactive-inc/claude-funnel 0.67.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +24 -3
  2. package/dist/bin.js +276 -270
  3. package/dist/{channels-BBA3GTAa.d.ts → channels-B0cifCfw.d.ts} +2 -1
  4. package/dist/claude.d.ts +2 -2
  5. package/dist/claude.js +5 -5
  6. package/dist/connector-descriptor-D4XtEsH8.d.ts +215 -0
  7. package/dist/connectors/discord.d.ts +3 -2
  8. package/dist/connectors/discord.js +1 -1
  9. package/dist/connectors/gh.d.ts +3 -2
  10. package/dist/connectors/gh.js +1 -1
  11. package/dist/connectors/schedule.d.ts +13 -11
  12. package/dist/connectors/schedule.js +3 -3
  13. package/dist/connectors/slack.d.ts +3 -2
  14. package/dist/connectors/slack.js +1 -1
  15. package/dist/diagnostic-event-CxMM5Bl2.js +78 -0
  16. package/dist/diagnostic-log-BsAg5qZK.d.ts +186 -0
  17. package/dist/diagnostics.d.ts +2 -2
  18. package/dist/diagnostics.js +3 -2
  19. package/dist/{discord-connector-CdjwPoty.js → discord-connector-CAcWifJn.js} +1 -1
  20. package/dist/docs.js +1 -1
  21. package/dist/doctor.d.ts +1 -1
  22. package/dist/event-log.d.ts +2 -0
  23. package/dist/event-log.js +3 -0
  24. package/dist/{file-process-guard-DAYe9Ndt.d.ts → file-process-guard-D-QatrwL.d.ts} +1 -1
  25. package/dist/{flume-source-listener-CLtsdcT2.d.ts → flume-source-listener-Ba8_1Mg-.d.ts} +2 -1
  26. package/dist/{funnel-diagnostics-B-PCuv_E.js → funnel-diagnostics-CAG7hJP0.js} +82 -139
  27. package/dist/{funnel-diagnostics-CnKus3Jg.d.ts → funnel-diagnostics-CDrZznTB.d.ts} +10 -13
  28. package/dist/{funnel-docs-BFcqITFA.js → funnel-docs-CI4hMkhq.js} +8 -3
  29. package/dist/{funnel-doctor-CviUTINw.d.ts → funnel-doctor-CY4S5cnz.d.ts} +1 -1
  30. package/dist/gateway/daemon.js +59 -79
  31. package/dist/gateway.d.ts +2 -2
  32. package/dist/gateway.js +1 -1
  33. package/dist/{gh-connector-D-iyjl-d.js → gh-connector-DMwI6zJA.js} +1 -1
  34. package/dist/{index-B4RvEaW-.d.ts → index-fHrKn4jm.d.ts} +7 -2
  35. package/dist/index.d.ts +18 -14
  36. package/dist/index.js +124 -30
  37. package/dist/local-config.d.ts +1 -1
  38. package/dist/logger.d.ts +6 -270
  39. package/dist/logger.js +6 -141
  40. package/dist/memory-event-log-BY8XjFzi.js +147 -0
  41. package/dist/{memory-token-prompter-D3R_kgM_.d.ts → memory-token-prompter-B20tl_aU.d.ts} +1 -1
  42. package/dist/{schedule-connector-teeDMHUe.js → schedule-connector-BXUOYgwZ.js} +59 -95
  43. package/dist/schedule-connector-schema-CNV8PgWX.js +137 -0
  44. package/dist/schedule-connector-schema-Tq5kJul-.d.ts +127 -0
  45. package/dist/{slack-connector-BE0KAjCs.js → slack-connector-CC3V2VXQ.js} +1 -1
  46. package/dist/{slot-fields-5ERhytIA.js → slot-fields-eCWizJqS.js} +1 -1
  47. package/dist/{sqlite-diagnostic-log-BDxfXGZy.js → sqlite-diagnostic-log-Qs4cf9I_.js} +53 -84
  48. package/dist/sqlite-event-log-BYgCFMxC.d.ts +284 -0
  49. package/dist/{funnel-log-sqlite-sink-CXbs3qQp.js → sqlite-event-log-eZuXKszJ.js} +52 -11
  50. package/package.json +16 -1
  51. package/dist/connector-descriptor-F75ZI8Fh.d.ts +0 -391
  52. package/dist/diagnostic-sql-reader-CoBk_EFF.js +0 -83
  53. package/dist/schedule-connector-schema-C2AChpwX.js +0 -31
  54. package/dist/schedule-connector-schema-DBko_Bf7.d.ts +0 -48
@@ -2,7 +2,8 @@ import { n as FunnelClock, t as FunnelLogger } from "./logger-mMZvblTx.js";
2
2
  import { n as FunnelFileSystem } from "./file-system-BNtl997T.js";
3
3
  import { n as ChannelDeliveryMode, t as ChannelConfig } from "./settings-schema-B-CKLuST.js";
4
4
  import { n as FunnelIdGenerator, t as FunnelSettingsReader } from "./settings-reader-CyTpbAre.js";
5
- import { A as FunnelConnectorListener, F as BaseConnectorConfig, M as CallInput, N as FunnelConnectorAdapter, c as FunnelHttpClient, g as ConnectorDiagnosticLog, n as ConnectorBuildContext, o as ConnectorOperationContext, r as ConnectorDescriptor, s as ConnectorUpdateContext, z as FunnelProcessRunner } from "./connector-descriptor-F75ZI8Fh.js";
5
+ import { b as FunnelProcessRunner, c as FunnelHttpClient, d as FunnelConnectorListener, g as BaseConnectorConfig, m as FunnelConnectorAdapter, n as ConnectorBuildContext, o as ConnectorOperationContext, p as CallInput, r as ConnectorDescriptor, s as ConnectorUpdateContext } from "./connector-descriptor-D4XtEsH8.js";
6
+ import { o as ConnectorDiagnosticLog } from "./diagnostic-log-BsAg5qZK.js";
6
7
  //#region lib/engine/connectors/connector-registry.d.ts
7
8
  type Deps$1 = {
8
9
  /** Connector types this funnel handles. Each is a self-describing descriptor;
package/dist/claude.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as FunnelFileSystem } from "./file-system-BNtl997T.js";
2
- import { a as ProcessGuard, c as ChannelResolver, i as SessionStore, n as FunnelClaude, o as McpInstaller, r as LaunchOptions, s as GatewayController, t as FunnelFileProcessGuard } from "./file-process-guard-DAYe9Ndt.js";
3
- import { r as ConnectorDescriptor } from "./connector-descriptor-F75ZI8Fh.js";
2
+ import { a as ProcessGuard, c as ChannelResolver, i as SessionStore, n as FunnelClaude, o as McpInstaller, r as LaunchOptions, s as GatewayController, t as FunnelFileProcessGuard } from "./file-process-guard-D-QatrwL.js";
3
+ import { r as ConnectorDescriptor } from "./connector-descriptor-D4XtEsH8.js";
4
4
  import { t as FunnelProfiles } from "./profiles-CePRnv3F.js";
5
5
  //#region lib/engine/mcp/mcp.d.ts
6
6
  declare const FUNNEL_MCP_COMMAND = "bun";
package/dist/claude.js CHANGED
@@ -3,11 +3,11 @@ import { f as settingsSchema, s as resolveFunnelPort } from "./settings-store-ZF
3
3
  import { a as FunnelMcp, i as FUNNEL_MCP_NAME, n as FUNNEL_MCP_ARGS, o as FunnelFileProcessGuard, r as FUNNEL_MCP_COMMAND, s as FunnelClaude, t as renderYaml } from "./yaml-render-DxxRQT-V.js";
4
4
  import { t as FunnelProfiles } from "./profiles-KpN7_gBw.js";
5
5
  import { t as errorMessageOf } from "./error-message-of-BG4ezZ_s.js";
6
- import { t as FunnelDocs } from "./funnel-docs-BFcqITFA.js";
7
- import { t as discordConnector } from "./discord-connector-CdjwPoty.js";
8
- import { t as ghConnector } from "./gh-connector-D-iyjl-d.js";
9
- import { t as scheduleConnector } from "./schedule-connector-teeDMHUe.js";
10
- import { t as slackConnector } from "./slack-connector-BE0KAjCs.js";
6
+ import { t as FunnelDocs } from "./funnel-docs-CI4hMkhq.js";
7
+ import { t as discordConnector } from "./discord-connector-CAcWifJn.js";
8
+ import { t as ghConnector } from "./gh-connector-DMwI6zJA.js";
9
+ import { t as scheduleConnector } from "./schedule-connector-BXUOYgwZ.js";
10
+ import { t as slackConnector } from "./slack-connector-CC3V2VXQ.js";
11
11
  import { join } from "node:path";
12
12
  import { existsSync, readFileSync } from "node:fs";
13
13
  import { homedir } from "node:os";
@@ -0,0 +1,215 @@
1
+ import { n as FunnelClock, t as FunnelLogger } from "./logger-mMZvblTx.js";
2
+ import { n as FunnelFileSystem } from "./file-system-BNtl997T.js";
3
+ import { o as ConnectorDiagnosticLog } from "./diagnostic-log-BsAg5qZK.js";
4
+ import { z } from "zod";
5
+ //#region lib/engine/process/process-runner.d.ts
6
+ type RunOptions = {
7
+ cwd?: string;
8
+ env?: Record<string, string>;
9
+ input?: string;
10
+ };
11
+ type RunResult = {
12
+ exitCode: number;
13
+ stdout: string;
14
+ stderr: string;
15
+ };
16
+ type AttachOptions = {
17
+ cwd?: string;
18
+ env?: Record<string, string>;
19
+ /** Invoked synchronously after the child process has been spawned, with its PID.
20
+ * Useful for hosts that need to register the spawned process before it exits. */
21
+ onSpawned?: (pid: number) => void;
22
+ };
23
+ type DetachOptions = {
24
+ env?: Record<string, string>;
25
+ /** Append stdout to this file. Parent dir is the caller's responsibility. */
26
+ stdoutFile?: string;
27
+ /** Append stderr to this file. Parent dir is the caller's responsibility. */
28
+ stderrFile?: string;
29
+ };
30
+ type ProcessSnapshot = {
31
+ pid: number;
32
+ command: string;
33
+ };
34
+ /**
35
+ * Process boundary covering one-shot runs, sync runs, foreground attach, and
36
+ * detached background spawns. Default is NodeFunnelProcessRunner (Bun.spawn);
37
+ * MemoryFunnelProcessRunner records calls and lets tests stub responses.
38
+ *
39
+ * Liveness and process-listing helpers absorb POSIX/Windows differences so
40
+ * callers do not branch on `process.platform`. `isAlive` checks whether a PID
41
+ * names a live (non-zombie) process; `listProcessesContaining` enumerates
42
+ * processes whose command line includes `marker`, used for funnel-gateway tag
43
+ * matching across daemons that share a home dir. `getStartTime` returns a
44
+ * stable string identifying when a PID was started, used to detect PID reuse
45
+ * after the original process died abnormally (no exit hook fired).
46
+ */
47
+ declare abstract class FunnelProcessRunner {
48
+ abstract run(command: string[], options?: RunOptions): Promise<RunResult>;
49
+ abstract runSync(command: string[]): RunResult;
50
+ abstract attach(command: string[], options?: AttachOptions): Promise<number>;
51
+ abstract detach(command: string[], options?: DetachOptions): void;
52
+ abstract kill(pid: number, signal?: string): void;
53
+ abstract isAlive(pid: number): boolean;
54
+ abstract listProcessesContaining(marker: string): ProcessSnapshot[];
55
+ abstract getStartTime(pid: number): string | null;
56
+ }
57
+ //#endregion
58
+ //#region lib/engine/connectors/base-connector-config.d.ts
59
+ /**
60
+ * Fields every connector config carries, regardless of type. The discriminated
61
+ * union of concrete connector configs no longer lives in core: each connector
62
+ * type owns its full schema inside its descriptor, and core handles connectors
63
+ * through this base shape plus the injected registry. `type` is an open string
64
+ * here on purpose — core does not enumerate the known connector types.
65
+ */
66
+ declare const baseConnectorConfigSchema: z.ZodObject<{
67
+ id: z.ZodString;
68
+ name: z.ZodString;
69
+ type: z.ZodString;
70
+ createdAt: z.ZodOptional<z.ZodString>;
71
+ updatedAt: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strip>;
73
+ type BaseConnectorConfig = z.infer<typeof baseConnectorConfigSchema>;
74
+ //#endregion
75
+ //#region lib/engine/connectors/connector-adapter.d.ts
76
+ /**
77
+ * A JSON-serializable value. Connector call bodies are sent to external APIs as
78
+ * JSON, so the body must be representable as JSON — `JsonValue` says exactly
79
+ * that, replacing a bare `unknown` that let non-serializable values (functions,
80
+ * symbols, class instances) slip through to `JSON.stringify`.
81
+ */
82
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
83
+ [key: string]: JsonValue;
84
+ };
85
+ type CallInput = {
86
+ method: string;
87
+ path: string;
88
+ /** JSON request body. Omit for GET-like calls. */
89
+ body?: JsonValue;
90
+ };
91
+ declare abstract class FunnelConnectorAdapter {
92
+ /**
93
+ * Dispatches one Claude → external call. The response is the external API's
94
+ * raw payload, typed `unknown` because its shape is the provider's concern —
95
+ * the caller (Claude, via MCP) interprets it.
96
+ */
97
+ abstract call(input: CallInput): Promise<unknown>;
98
+ }
99
+ //#endregion
100
+ //#region lib/engine/connectors/connector-listener.d.ts
101
+ type NotifyFn = (content: string, meta?: Record<string, string>) => Promise<void>;
102
+ /**
103
+ * Long-lived event source for one connector.
104
+ *
105
+ * `start()` opens the underlying connection (Slack Socket Mode, Discord
106
+ * Gateway, GH polling, schedule tick) and pushes events through `notify`.
107
+ * `stop()` releases the resources so the supervisor can recreate the listener
108
+ * with new config without restarting the whole gateway. `isAlive()` lets the
109
+ * supervisor periodically health-check and auto-restart dead listeners; the
110
+ * default optimistic implementation is fine for poll/tick-based listeners
111
+ * that self-heal.
112
+ */
113
+ declare abstract class FunnelConnectorListener {
114
+ abstract start(notify: NotifyFn): Promise<void>;
115
+ abstract stop(): Promise<void>;
116
+ isAlive(): boolean;
117
+ }
118
+ //#endregion
119
+ //#region lib/engine/http/http-client.d.ts
120
+ type HttpRequest = {
121
+ method: string;
122
+ url: string;
123
+ headers?: Record<string, string>;
124
+ body?: string;
125
+ };
126
+ type HttpResponse = {
127
+ status: number;
128
+ ok: boolean;
129
+ text(): Promise<string>;
130
+ json(): Promise<unknown>;
131
+ };
132
+ declare abstract class FunnelHttpClient {
133
+ abstract fetch(request: HttpRequest): Promise<HttpResponse>;
134
+ }
135
+ //#endregion
136
+ //#region lib/engine/connectors/connector-descriptor.d.ts
137
+ /** Boundaries a listener needs, supplied by the registry at build time. */
138
+ type ConnectorListenerDeps = {
139
+ channelId: string;
140
+ fs: FunnelFileSystem;
141
+ process: FunnelProcessRunner;
142
+ /** HTTP client for self-detection (Slack auth.test), reactions, and other listener-side REST calls. */
143
+ http: FunnelHttpClient;
144
+ /** Wall clock — listeners that own a timer (schedule) read it from here so tests can inject a fake. */
145
+ clock: FunnelClock;
146
+ logger?: FunnelLogger;
147
+ diagnosticLog?: ConnectorDiagnosticLog;
148
+ /**
149
+ * Optional shutdown signal forwarded to flume-backed listeners. When the
150
+ * host aborts the signal, the listener's Flume tears down its WebSocket /
151
+ * fetch loop without waiting for the supervisor's `stop()`. Hosts that want
152
+ * a clean SIGTERM story wire `controller.signal` here and call
153
+ * `controller.abort()` in their shutdown handler.
154
+ */
155
+ signal?: AbortSignal;
156
+ /** Resolves the per-connector state directory (`<dir>/channels/<id>/connectors/<id>`). */
157
+ connectorDir: (channelId: string, connectorId: string) => string;
158
+ };
159
+ /** Boundaries an adapter needs. Adapters are channel-agnostic. */
160
+ type ConnectorAdapterDeps = {
161
+ fs: FunnelFileSystem;
162
+ process: FunnelProcessRunner;
163
+ /** HTTP client for outbound calls. Used by the Slack adapter, future REST adapters. */
164
+ http: FunnelHttpClient;
165
+ logger?: FunnelLogger;
166
+ };
167
+ type ConnectorBuildContext = {
168
+ id: string;
169
+ now: string;
170
+ };
171
+ type ConnectorUpdateContext = {
172
+ now: string;
173
+ };
174
+ type ConnectorOperationContext = {
175
+ generateId: () => string;
176
+ now: string;
177
+ };
178
+ /**
179
+ * One named operation a connector type exposes beyond plain CRUD (e.g. schedule
180
+ * entry add/remove/list). Returns the next config and an arbitrary result; when
181
+ * the returned config is reference-equal to the input, the channels layer treats
182
+ * the call as a read and skips persistence.
183
+ */
184
+ type ConnectorOperation = (props: {
185
+ config: BaseConnectorConfig;
186
+ args: unknown;
187
+ context: ConnectorOperationContext;
188
+ }) => {
189
+ config: BaseConnectorConfig;
190
+ result: unknown;
191
+ };
192
+ /**
193
+ * Everything core needs to handle one connector type, without importing it. A
194
+ * descriptor accepts/returns `BaseConnectorConfig` at every boundary and parses
195
+ * to its concrete config internally (via `schema`), so the registry can hold a
196
+ * homogeneous `ConnectorDescriptor[]` with no variance gymnastics. Type-specific
197
+ * launch hooks (e.g. Schedule `onFired`) are closed over by the descriptor
198
+ * factory, not threaded through here. Each descriptor parses configs to its
199
+ * concrete shape internally (it owns its zod schema), so no schema is exposed
200
+ * here — that also sidesteps the variance trap of a `ZodType<Slack>` field
201
+ * declared as `ZodType<BaseConnectorConfig>`.
202
+ */
203
+ type ConnectorDescriptor = {
204
+ type: string;
205
+ createListener: (config: BaseConnectorConfig, deps: ConnectorListenerDeps) => FunnelConnectorListener;
206
+ createAdapter: ((config: BaseConnectorConfig, deps: ConnectorAdapterDeps) => FunnelConnectorAdapter) | null;
207
+ /** Whether the MCP channel server exposes this type as a callable tool. */
208
+ toolExposed: boolean;
209
+ secretTokens: (config: BaseConnectorConfig) => string[];
210
+ buildConfig: (input: Record<string, unknown>, context: ConnectorBuildContext) => BaseConnectorConfig;
211
+ applyUpdate: (config: BaseConnectorConfig, fields: Record<string, unknown>, context: ConnectorUpdateContext) => BaseConnectorConfig;
212
+ operations: Record<string, ConnectorOperation>;
213
+ };
214
+ //#endregion
215
+ export { RunResult as C, RunOptions as S, baseConnectorConfigSchema as _, ConnectorOperation as a, FunnelProcessRunner as b, FunnelHttpClient as c, FunnelConnectorListener as d, NotifyFn as f, BaseConnectorConfig as g, JsonValue as h, ConnectorListenerDeps as i, HttpRequest as l, FunnelConnectorAdapter as m, ConnectorBuildContext as n, ConnectorOperationContext as o, CallInput as p, ConnectorDescriptor as r, ConnectorUpdateContext as s, ConnectorAdapterDeps as t, HttpResponse as u, AttachOptions as v, ProcessSnapshot as x, DetachOptions as y };
@@ -1,7 +1,8 @@
1
1
  import { t as FunnelLogger } from "../logger-mMZvblTx.js";
2
- import { M as CallInput, N as FunnelConnectorAdapter, c as FunnelHttpClient, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-F75ZI8Fh.js";
2
+ import { c as FunnelHttpClient, f as NotifyFn, m as FunnelConnectorAdapter, p as CallInput, r as ConnectorDescriptor } from "../connector-descriptor-D4XtEsH8.js";
3
+ import { o as ConnectorDiagnosticLog } from "../diagnostic-log-BsAg5qZK.js";
3
4
  import { n as discordConnectorSchema, t as DiscordConnectorConfig } from "../discord-connector-schema-BaBZYHxK.js";
4
- import { t as FunnelFlumeSourceListener } from "../flume-source-listener-CLtsdcT2.js";
5
+ import { t as FunnelFlumeSourceListener } from "../flume-source-listener-Ba8_1Mg-.js";
5
6
  import { FlumeRuntimeDeps } from "@interactive-inc/flume";
6
7
  //#region lib/engine/connectors/discord-adapter.d.ts
7
8
  type Deps$1 = {
@@ -1,3 +1,3 @@
1
1
  import { t as discordConnectorSchema } from "../discord-connector-schema-saAGuPmJ.js";
2
- import { i as FunnelDiscordAdapter, n as FunnelFlumeDiscordListener, r as FunnelDiscordEventProcessor, t as discordConnector } from "../discord-connector-CdjwPoty.js";
2
+ import { i as FunnelDiscordAdapter, n as FunnelFlumeDiscordListener, r as FunnelDiscordEventProcessor, t as discordConnector } from "../discord-connector-CAcWifJn.js";
3
3
  export { FunnelDiscordAdapter, FunnelDiscordEventProcessor, FunnelFlumeDiscordListener, discordConnector, discordConnectorSchema };
@@ -1,6 +1,7 @@
1
1
  import { t as FunnelLogger } from "../logger-mMZvblTx.js";
2
- import { M as CallInput, N as FunnelConnectorAdapter, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor, z as FunnelProcessRunner } from "../connector-descriptor-F75ZI8Fh.js";
3
- import { t as FunnelFlumeSourceListener } from "../flume-source-listener-CLtsdcT2.js";
2
+ import { b as FunnelProcessRunner, f as NotifyFn, m as FunnelConnectorAdapter, p as CallInput, r as ConnectorDescriptor } from "../connector-descriptor-D4XtEsH8.js";
3
+ import { o as ConnectorDiagnosticLog } from "../diagnostic-log-BsAg5qZK.js";
4
+ import { t as FunnelFlumeSourceListener } from "../flume-source-listener-Ba8_1Mg-.js";
4
5
  import { n as ghConnectorSchema, t as GhConnectorConfig } from "../gh-connector-schema-BrNsCl1T.js";
5
6
  import { FlumeRuntimeDeps } from "@interactive-inc/flume";
6
7
  //#region lib/engine/connectors/gh-adapter.d.ts
@@ -1,3 +1,3 @@
1
1
  import { t as ghConnectorSchema } from "../gh-connector-schema-DmZTrzUu.js";
2
- import { n as FunnelFlumeGhListener, r as FunnelGhAdapter, t as ghConnector } from "../gh-connector-D-iyjl-d.js";
2
+ import { n as FunnelFlumeGhListener, r as FunnelGhAdapter, t as ghConnector } from "../gh-connector-DMwI6zJA.js";
3
3
  export { FunnelFlumeGhListener, FunnelGhAdapter, ghConnector, ghConnectorSchema };
@@ -1,17 +1,15 @@
1
1
  import { t as FunnelLogger } from "../logger-mMZvblTx.js";
2
2
  import { n as FunnelFileSystem } from "../file-system-BNtl997T.js";
3
- import { A as FunnelConnectorListener, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-F75ZI8Fh.js";
4
- import { a as scheduleConnectorSchema, i as scheduleCatchupPolicySchema, n as ScheduleConnectorConfig, o as scheduleEntrySchema, r as ScheduleEntry, t as ScheduleCatchupPolicy } from "../schedule-connector-schema-DBko_Bf7.js";
3
+ import { d as FunnelConnectorListener, f as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-D4XtEsH8.js";
4
+ import { o as ConnectorDiagnosticLog } from "../diagnostic-log-BsAg5qZK.js";
5
+ import { a as ScheduleEntry, c as cronScheduleEntrySchema, d as scheduleConnectorSchema, f as scheduleEntryInputSchema, i as ScheduleConnectorConfig, l as onceScheduleEntrySchema, n as OnceScheduleEntry, o as ScheduleEntryInput, p as scheduleEntrySchema, r as ScheduleCatchupPolicy, s as cronExpressionSchema, t as CronScheduleEntry, u as scheduleCatchupPolicySchema } from "../schedule-connector-schema-Tq5kJul-.js";
5
6
  //#region lib/engine/connectors/match-cron.d.ts
7
+ /** Throws with a user-facing reason when `expr` is not a supported cron expression. */
8
+ declare const validateCronExpression: (expr: string) => void;
6
9
  /**
7
- * Returns true when `date` (local time) satisfies a 5-field cron expression.
8
- *
9
- * Two deliberate deviations from Vixie cron, called out so schedules are not
10
- * written expecting the other behavior:
11
- * - Day-of-month and day-of-week are ANDed, not ORed. Vixie cron fires when
12
- * EITHER matches once both are restricted; here every field must match.
13
- * - Day-of-week is 0-6 (Sunday=0). `7` for Sunday is NOT accepted (it throws
14
- * as out-of-range); use `0`.
10
+ * Returns true when `date` (local time) satisfies a standard 5-field cron
11
+ * expression. Sunday accepts both 0 and 7. When day-of-month and day-of-week
12
+ * are both restricted, either field matching is sufficient (Vixie cron).
15
13
  */
16
14
  declare const matchCron: (expr: string, date: Date) => boolean;
17
15
  //#endregion
@@ -69,11 +67,15 @@ declare class FunnelScheduleListener extends FunnelConnectorListener {
69
67
  isAlive(): boolean;
70
68
  tick(notify: NotifyFn): Promise<void>;
71
69
  private fireEntry;
70
+ private fireOnceEntry;
71
+ private fireCronEntry;
72
+ private seedSearchWatermark;
72
73
  private notifyOne;
73
74
  private findMostRecentMatch;
74
75
  private findAllMatches;
75
76
  private logInvalidCron;
76
77
  private truncateToMinute;
78
+ private pruneRemovedEntries;
77
79
  }
78
80
  //#endregion
79
81
  //#region lib/engine/connectors/schedule-connector.d.ts
@@ -90,4 +92,4 @@ type ScheduleConnectorOptions = {
90
92
  */
91
93
  declare const scheduleConnector: (options?: ScheduleConnectorOptions) => ConnectorDescriptor;
92
94
  //#endregion
93
- export { FunnelScheduleListener, FunnelScheduleStateStore, ScheduleCatchupPolicy, ScheduleConnectorConfig, ScheduleConnectorOptions, ScheduleEntry, ScheduleOnFired, matchCron, scheduleCatchupPolicySchema, scheduleConnector, scheduleConnectorSchema, scheduleEntrySchema };
95
+ export { CronScheduleEntry, FunnelScheduleListener, FunnelScheduleStateStore, OnceScheduleEntry, ScheduleCatchupPolicy, ScheduleConnectorConfig, ScheduleConnectorOptions, ScheduleEntry, ScheduleEntryInput, ScheduleOnFired, cronExpressionSchema, cronScheduleEntrySchema, matchCron, onceScheduleEntrySchema, scheduleCatchupPolicySchema, scheduleConnector, scheduleConnectorSchema, scheduleEntryInputSchema, scheduleEntrySchema, validateCronExpression };
@@ -1,3 +1,3 @@
1
- import { n as scheduleConnectorSchema, r as scheduleEntrySchema, t as scheduleCatchupPolicySchema } from "../schedule-connector-schema-C2AChpwX.js";
2
- import { i as matchCron, n as FunnelScheduleListener, r as FunnelScheduleStateStore, t as scheduleConnector } from "../schedule-connector-teeDMHUe.js";
3
- export { FunnelScheduleListener, FunnelScheduleStateStore, matchCron, scheduleCatchupPolicySchema, scheduleConnector, scheduleConnectorSchema, scheduleEntrySchema };
1
+ import { a as scheduleConnectorSchema, c as matchCron, i as scheduleCatchupPolicySchema, l as validateCronExpression, n as cronScheduleEntrySchema, o as scheduleEntryInputSchema, r as onceScheduleEntrySchema, s as scheduleEntrySchema, t as cronExpressionSchema } from "../schedule-connector-schema-CNV8PgWX.js";
2
+ import { n as FunnelScheduleListener, r as FunnelScheduleStateStore, t as scheduleConnector } from "../schedule-connector-BXUOYgwZ.js";
3
+ export { FunnelScheduleListener, FunnelScheduleStateStore, cronExpressionSchema, cronScheduleEntrySchema, matchCron, onceScheduleEntrySchema, scheduleCatchupPolicySchema, scheduleConnector, scheduleConnectorSchema, scheduleEntryInputSchema, scheduleEntrySchema, validateCronExpression };
@@ -1,6 +1,7 @@
1
1
  import { t as FunnelLogger } from "../logger-mMZvblTx.js";
2
- import { M as CallInput, N as FunnelConnectorAdapter, c as FunnelHttpClient, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-F75ZI8Fh.js";
3
- import { t as FunnelFlumeSourceListener } from "../flume-source-listener-CLtsdcT2.js";
2
+ import { c as FunnelHttpClient, f as NotifyFn, m as FunnelConnectorAdapter, p as CallInput, r as ConnectorDescriptor } from "../connector-descriptor-D4XtEsH8.js";
3
+ import { o as ConnectorDiagnosticLog } from "../diagnostic-log-BsAg5qZK.js";
4
+ import { t as FunnelFlumeSourceListener } from "../flume-source-listener-Ba8_1Mg-.js";
4
5
  import { a as SlackRawEvent, c as SlackMessageEvent, d as slackConnectorSchema, i as SlackProcessedSkip, l as SlackReactionEvent, n as SlackProcessed, o as SlackSkipReason, r as SlackProcessedEmit, s as SlackEvent, t as FunnelSlackEventProcessor, u as SlackConnectorConfig } from "../slack-event-processor-DmAlq4cV.js";
5
6
  import { FlumeRuntimeDeps } from "@interactive-inc/flume";
6
7
  //#region lib/engine/connectors/slack-adapter.d.ts
@@ -1,4 +1,4 @@
1
1
  import { t as slackConnectorSchema } from "../slack-connector-schema-EGVuuqSX.js";
2
2
  import { t as FunnelSlackEventProcessor } from "../slack-event-processor-Cs_YuI3w.js";
3
- import { n as FunnelFlumeSlackListener, r as FunnelSlackAdapter, t as slackConnector } from "../slack-connector-BE0KAjCs.js";
3
+ import { n as FunnelFlumeSlackListener, r as FunnelSlackAdapter, t as slackConnector } from "../slack-connector-CC3V2VXQ.js";
4
4
  export { FunnelFlumeSlackListener, FunnelSlackAdapter, FunnelSlackEventProcessor, slackConnector, slackConnectorSchema };
@@ -0,0 +1,78 @@
1
+ //#region lib/services/diagnostics/diagnostic-event.ts
2
+ const stringOrNull = (value) => typeof value === "string" && value.length > 0 ? value : null;
3
+ const numberOrNull = (value) => typeof value === "number" ? value : null;
4
+ const stringOr = (value, fallback) => typeof value === "string" ? value : fallback;
5
+ const isStringKeyedObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
6
+ const parsePayloadObject = (payload) => {
7
+ if (payload === null) return null;
8
+ try {
9
+ const parsed = JSON.parse(payload);
10
+ if (isStringKeyedObject(parsed)) return parsed;
11
+ } catch {
12
+ return null;
13
+ }
14
+ return null;
15
+ };
16
+ const truncate = (text, max) => text.length <= max ? text : `${text.slice(0, max)}…`;
17
+ const previewOf = (payload) => {
18
+ if (typeof payload !== "string" || payload.length === 0) return null;
19
+ const parsed = parsePayloadObject(payload);
20
+ if (parsed !== null && "text" in parsed) return truncate(String(parsed.text), 60);
21
+ return truncate(payload, 60);
22
+ };
23
+ const toDiagnosticEvent = (row) => {
24
+ const payload = stringOrNull(row.payload);
25
+ return {
26
+ seq: numberOrNull(row.seq),
27
+ ts: numberOrNull(row.ts),
28
+ type: stringOr(row.type, "?"),
29
+ outcome: stringOr(row.outcome, "?"),
30
+ eventId: stringOrNull(row.event_id),
31
+ payload,
32
+ payloadParsed: parsePayloadObject(payload),
33
+ preview: previewOf(row.payload)
34
+ };
35
+ };
36
+ const toDiagnosticConnectionError = (row) => ({
37
+ seq: numberOrNull(row.seq),
38
+ ts: numberOrNull(row.ts),
39
+ type: stringOr(row.type, "?"),
40
+ status: stringOr(row.status, "?"),
41
+ detail: stringOrNull(row.detail)
42
+ });
43
+ const diagnosticEventOfProcessed = (event) => ({
44
+ seq: event.seq,
45
+ ts: event.ts,
46
+ type: event.type,
47
+ outcome: event.outcome,
48
+ eventId: event.eventId,
49
+ payload: stringOrNull(event.payload),
50
+ payloadParsed: parsePayloadObject(stringOrNull(event.payload)),
51
+ preview: previewOf(event.payload)
52
+ });
53
+ const diagnosticEventOfRaw = (event) => ({
54
+ seq: event.seq,
55
+ ts: event.ts,
56
+ type: event.type,
57
+ outcome: "",
58
+ eventId: event.eventId,
59
+ payload: stringOrNull(event.payload),
60
+ payloadParsed: parsePayloadObject(stringOrNull(event.payload)),
61
+ preview: previewOf(event.payload)
62
+ });
63
+ const diagnosticConnectionEventOf = (event) => ({
64
+ seq: event.seq,
65
+ ts: event.ts,
66
+ type: event.type,
67
+ status: event.status,
68
+ detail: stringOrNull(event.detail)
69
+ });
70
+ const queryRows = (reader, sql, params) => {
71
+ try {
72
+ return reader.query(sql, params);
73
+ } finally {
74
+ reader.close();
75
+ }
76
+ };
77
+ //#endregion
78
+ export { queryRows as a, previewOf as i, diagnosticEventOfProcessed as n, toDiagnosticConnectionError as o, diagnosticEventOfRaw as r, toDiagnosticEvent as s, diagnosticConnectionEventOf as t };
@@ -0,0 +1,186 @@
1
+ import { z } from "zod";
2
+ //#region lib/engine/diagnostic-log/diagnostic-log.d.ts
3
+ /**
4
+ * Points in the listener's connection lifecycle. The single source of truth
5
+ * for the value set: the `status` column schema, the `ConnectorConnectionStatus`
6
+ * union, and the runtime Set used to narrow on read-back all derive from this
7
+ * array, so adding a status is a one-line change that cannot drift out of sync.
8
+ *
9
+ * started start() was called
10
+ * connected the socket opened and events can flow
11
+ * disconnected the socket was closed by a stop() call (a clean teardown)
12
+ * auth-failed the token was rejected before the socket opened
13
+ * stopped the listener was fully torn down (always follows a stop(),
14
+ * paired with the disconnected/error that preceded it)
15
+ * error start/stop threw, or Bolt surfaced an error frame — this is
16
+ * also where an unsolicited socket drop shows up when Bolt
17
+ * reports it (an `error` with no following `stopped` means the
18
+ * supervisor recycled the listener, not a clean stop)
19
+ *
20
+ * A connection row is independent of any single inbound event, so it carries
21
+ * no `eventId`. This is how "no notification arrived because the listener
22
+ * never connected (or dropped, or failed auth)" becomes visible: the
23
+ * raw/processed tables only hold events that *did* arrive.
24
+ */
25
+ declare const CONNECTOR_CONNECTION_STATUSES: readonly ["started", "connected", "disconnected", "auth-failed", "stopped", "error"];
26
+ type ConnectorConnectionStatus = (typeof CONNECTOR_CONNECTION_STATUSES)[number];
27
+ /**
28
+ * Rows stored in the diagnostic tables. Connector-agnostic on purpose: `type`
29
+ * carries the listener kind ("slack" | "discord" | "gh" | "schedule") so new
30
+ * connectors land in the same tables without a schema change. `event_id` is
31
+ * the correlation key the listener mints once per inbound event and stamps
32
+ * onto both the raw and processed rows, so the two are joinable even though
33
+ * they live in separate tables with independent `seq` counters.
34
+ *
35
+ * These schemas mirror the stored shape (snake_case columns) the way
36
+ * `FunnelEvent` does for the replay log; they exist for `z.infer` and to
37
+ * document the column set, not as a parse boundary.
38
+ */
39
+ declare const connectorRawEventSchema: z.ZodObject<{
40
+ event_id: z.ZodString;
41
+ type: z.ZodString;
42
+ connector_id: z.ZodNullable<z.ZodString>;
43
+ channel_id: z.ZodNullable<z.ZodString>;
44
+ payload: z.ZodString;
45
+ }, z.core.$strip>;
46
+ type ConnectorRawEvent = z.infer<typeof connectorRawEventSchema>;
47
+ declare const connectorProcessedEventSchema: z.ZodObject<{
48
+ event_id: z.ZodString;
49
+ type: z.ZodString;
50
+ connector_id: z.ZodNullable<z.ZodString>;
51
+ channel_id: z.ZodNullable<z.ZodString>;
52
+ outcome: z.ZodString;
53
+ payload: z.ZodString;
54
+ }, z.core.$strip>;
55
+ type ConnectorProcessedEvent = z.infer<typeof connectorProcessedEventSchema>;
56
+ declare const connectorConnectionEventSchema: z.ZodObject<{
57
+ type: z.ZodString;
58
+ connector_id: z.ZodNullable<z.ZodString>;
59
+ channel_id: z.ZodNullable<z.ZodString>;
60
+ status: z.ZodEnum<{
61
+ error: "error";
62
+ started: "started";
63
+ connected: "connected";
64
+ disconnected: "disconnected";
65
+ "auth-failed": "auth-failed";
66
+ stopped: "stopped";
67
+ }>;
68
+ detail: z.ZodString;
69
+ }, z.core.$strip>;
70
+ type ConnectorConnectionEvent = z.infer<typeof connectorConnectionEventSchema>;
71
+ /** The connector a row belongs to — the axis every diagnostic table shares. */
72
+ type ConnectorRef = {
73
+ type: string;
74
+ connectorId: string | null;
75
+ channelId: string | null;
76
+ };
77
+ /** A row tied to one inbound event, joinable to its twin by `eventId`. */
78
+ type ConnectorEventKeys = ConnectorRef & {
79
+ /** Correlation id shared by the raw and processed rows of the same inbound event. */
80
+ eventId: string;
81
+ };
82
+ /** One untouched inbound event to persist, before any processing. */
83
+ type ConnectorRawRecord = ConnectorEventKeys & {
84
+ /** The listener's untouched payload, already JSON-stringified by the caller. */
85
+ payload: string;
86
+ };
87
+ /** The processor's verdict for one inbound event. */
88
+ type ConnectorProcessedRecord = ConnectorEventKeys & {
89
+ /**
90
+ * "emitted" on successful delivery, "emitted:delivery-failed" when the
91
+ * downstream notify threw, or "skip:<reason>" when the processor dropped it.
92
+ */
93
+ outcome: string;
94
+ /**
95
+ * The delivered body (content + meta) for an emitted event. For a skipped
96
+ * event there is no body, so the listener records the event JSON here
97
+ * instead — keeping a skipped row self-describing rather than blank.
98
+ */
99
+ payload: string;
100
+ };
101
+ type ConnectorConnectionRecord = ConnectorRef & {
102
+ status: ConnectorConnectionStatus;
103
+ /** Free-form context (an error message, a reason) or "" when none. */
104
+ detail: string;
105
+ };
106
+ /**
107
+ * Filters every table query accepts — the read-side mirror of `ConnectorRef`.
108
+ * Each per-table query extends this with its own table's column, the same way
109
+ * each record extends `ConnectorRef`, so neither half of the file treats one
110
+ * table's shape as the base for the others.
111
+ */
112
+ type ConnectorQuery = {
113
+ type?: string;
114
+ connectorId?: string | null;
115
+ channelId?: string | null;
116
+ /** Match one table-local sequence number exactly. */
117
+ seq?: number;
118
+ /** Cap on returned rows. The most recent matching rows are returned, oldest first. */
119
+ limit?: number;
120
+ };
121
+ type ConnectorRawQuery = ConnectorQuery & {
122
+ eventId?: string;
123
+ };
124
+ type ConnectorProcessedQuery = ConnectorQuery & {
125
+ eventId?: string;
126
+ outcome?: string;
127
+ outcomePrefix?: string;
128
+ };
129
+ type ConnectorConnectionQuery = ConnectorQuery & {
130
+ status?: ConnectorConnectionStatus;
131
+ statuses?: ReadonlyArray<ConnectorConnectionStatus>;
132
+ };
133
+ /**
134
+ * A stored row, ascending by `seq`. `seq` is per-table (each table counts
135
+ * independently) and is for ordering within one table, not for correlating
136
+ * across them — use `eventId` to join raw and processed.
137
+ */
138
+ type StoredRawEvent = ConnectorRawRecord & {
139
+ seq: number;
140
+ ts: number;
141
+ };
142
+ type StoredProcessedEvent = ConnectorProcessedRecord & {
143
+ seq: number;
144
+ ts: number;
145
+ };
146
+ type StoredConnectionEvent = ConnectorConnectionRecord & {
147
+ seq: number;
148
+ ts: number;
149
+ };
150
+ /**
151
+ * Three-table diagnostic log of everything a connector listener does, so
152
+ * "why was there no notification?" is answerable whichever way it failed:
153
+ * - `raw` — every inbound event, before any filtering, with the listener's
154
+ * untouched payload (the Slack Bolt event, the GH webhook, …)
155
+ * - `processed` — the verdict for that event: `outcome` (emitted, or the
156
+ * reason it was dropped) and, when emitted, the body that was delivered.
157
+ * Shares an `eventId` with its raw row, so the two join into one story.
158
+ * - `connection` — the listener's lifecycle (started, connected, dropped,
159
+ * auth-failed, stopped, errored). This is the half the event tables can't
160
+ * show: an event that never arrived leaves no raw row, but a listener that
161
+ * never connected leaves a `connection` trail that says so.
162
+ *
163
+ * The three are physically separate (independent retention and payload-size
164
+ * policy) so a query never crosses them by accident and a huge raw payload
165
+ * never bloats the verdict or lifecycle trails. None flow to WS clients or the
166
+ * MCP channel — this is a separate store from `FunnelEventLog` (replay) and
167
+ * exists solely for debugging.
168
+ *
169
+ * Implementations:
170
+ * - `SqliteConnectorDiagnosticLog` — the default; survives daemon restarts,
171
+ * bounded by per-table row/age caps.
172
+ * - `MemoryConnectorDiagnosticLog` — an in-process double for tests.
173
+ */
174
+ declare abstract class ConnectorDiagnosticLog {
175
+ abstract recordRaw(record: ConnectorRawRecord): void;
176
+ abstract recordProcessed(record: ConnectorProcessedRecord): void;
177
+ abstract recordConnection(record: ConnectorConnectionRecord): void;
178
+ abstract queryRaw(query: ConnectorRawQuery): StoredRawEvent[];
179
+ abstract queryProcessed(query: ConnectorProcessedQuery): StoredProcessedEvent[];
180
+ abstract queryConnection(query: ConnectorConnectionQuery): StoredConnectionEvent[];
181
+ /** Drop every diagnostic row across all three tables and reclaim the files. */
182
+ abstract clear(): void;
183
+ abstract close(): void;
184
+ }
185
+ //#endregion
186
+ export { connectorConnectionEventSchema as _, ConnectorConnectionStatus as a, ConnectorProcessedQuery as c, ConnectorRawEvent as d, ConnectorRawQuery as f, StoredRawEvent as g, StoredProcessedEvent as h, ConnectorConnectionRecord as i, ConnectorProcessedRecord as l, StoredConnectionEvent as m, ConnectorConnectionEvent as n, ConnectorDiagnosticLog as o, ConnectorRawRecord as p, ConnectorConnectionQuery as r, ConnectorProcessedEvent as s, CONNECTOR_CONNECTION_STATUSES as t, ConnectorQuery as u, connectorProcessedEventSchema as v, connectorRawEventSchema as y };
@@ -1,2 +1,2 @@
1
- import { a as DiagnosticsGatewayProbe, c as FunnelDiagnostics, d as DiagnosticEvent, f as previewOf, h as toDiagnosticEvent, i as DiagnosticsChannelSource, l as ReplayResult, m as toDiagnosticConnectionError, n as DiagnoseAllReport, o as DiagnosticsPublisher, p as queryRows, r as DiagnosisStatus, s as DiagnosticsTokenReader, t as ChannelDiagnosis, u as DiagnosticConnectionError } from "./funnel-diagnostics-CnKus3Jg.js";
2
- export { ChannelDiagnosis, DiagnoseAllReport, DiagnosisStatus, DiagnosticConnectionError, DiagnosticEvent, DiagnosticsChannelSource, DiagnosticsGatewayProbe, DiagnosticsPublisher, DiagnosticsTokenReader, FunnelDiagnostics, ReplayResult, previewOf, queryRows, toDiagnosticConnectionError, toDiagnosticEvent };
1
+ import { _ as toDiagnosticConnectionError, a as DiagnosticsGatewayProbe, c as FunnelDiagnostics, d as DiagnosticEvent, f as diagnosticConnectionEventOf, g as queryRows, h as previewOf, i as DiagnosticsChannelSource, l as ReplayResult, m as diagnosticEventOfRaw, n as DiagnoseAllReport, o as DiagnosticsPublisher, p as diagnosticEventOfProcessed, r as DiagnosisStatus, s as DiagnosticsTokenReader, t as ChannelDiagnosis, u as DiagnosticConnectionError, v as toDiagnosticEvent } from "./funnel-diagnostics-CDrZznTB.js";
2
+ export { ChannelDiagnosis, DiagnoseAllReport, DiagnosisStatus, DiagnosticConnectionError, DiagnosticEvent, DiagnosticsChannelSource, DiagnosticsGatewayProbe, DiagnosticsPublisher, DiagnosticsTokenReader, FunnelDiagnostics, ReplayResult, diagnosticConnectionEventOf, diagnosticEventOfProcessed, diagnosticEventOfRaw, previewOf, queryRows, toDiagnosticConnectionError, toDiagnosticEvent };
@@ -1,2 +1,3 @@
1
- import { a as toDiagnosticEvent, i as toDiagnosticConnectionError, n as previewOf, r as queryRows, t as FunnelDiagnostics } from "./funnel-diagnostics-B-PCuv_E.js";
2
- export { FunnelDiagnostics, previewOf, queryRows, toDiagnosticConnectionError, toDiagnosticEvent };
1
+ import { a as queryRows, i as previewOf, n as diagnosticEventOfProcessed, o as toDiagnosticConnectionError, r as diagnosticEventOfRaw, s as toDiagnosticEvent, t as diagnosticConnectionEventOf } from "./diagnostic-event-CxMM5Bl2.js";
2
+ import { t as FunnelDiagnostics } from "./funnel-diagnostics-CAG7hJP0.js";
3
+ export { FunnelDiagnostics, diagnosticConnectionEventOf, diagnosticEventOfProcessed, diagnosticEventOfRaw, previewOf, queryRows, toDiagnosticConnectionError, toDiagnosticEvent };