@interactive-inc/claude-funnel 0.66.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 (97) hide show
  1. package/README.md +31 -6
  2. package/dist/bin.js +292 -383
  3. package/dist/channel.d.ts +76 -52
  4. package/dist/channel.js +82 -47
  5. package/dist/{channels-DR90RmUP.d.ts → channels-B0cifCfw.d.ts} +6 -6
  6. package/dist/claude.d.ts +11 -8
  7. package/dist/claude.js +31 -15
  8. package/dist/connector-descriptor-D4XtEsH8.d.ts +215 -0
  9. package/dist/{connector-diagnostics-recorder-COtNEmUp.js → connector-diagnostics-recorder-BmOijU1p.js} +1 -0
  10. package/dist/connectors/discord.d.ts +11 -8
  11. package/dist/connectors/discord.js +2 -2
  12. package/dist/connectors/gh.d.ts +7 -6
  13. package/dist/connectors/gh.js +2 -2
  14. package/dist/connectors/schedule.d.ts +21 -17
  15. package/dist/connectors/schedule.js +3 -3
  16. package/dist/connectors/slack.d.ts +15 -10
  17. package/dist/connectors/slack.js +3 -3
  18. package/dist/diagnostic-event-CxMM5Bl2.js +78 -0
  19. package/dist/diagnostic-log-BsAg5qZK.d.ts +186 -0
  20. package/dist/diagnostics.d.ts +2 -2
  21. package/dist/diagnostics.js +3 -2
  22. package/dist/{discord-connector-DXARcO6w.js → discord-connector-CAcWifJn.js} +6 -6
  23. package/dist/{discord-connector-schema-D1dyxhXk.d.ts → discord-connector-schema-BaBZYHxK.d.ts} +0 -1
  24. package/dist/docs.d.ts +1 -1
  25. package/dist/docs.js +1 -1
  26. package/dist/doctor.d.ts +1 -1
  27. package/dist/doctor.js +1 -1
  28. package/dist/event-log.d.ts +2 -0
  29. package/dist/event-log.js +3 -0
  30. package/dist/{file-process-guard-CiBwXjzm.d.ts → file-process-guard-D-QatrwL.d.ts} +22 -18
  31. package/dist/{file-system-DHgbuTFb.d.ts → file-system-BNtl997T.d.ts} +2 -1
  32. package/dist/{flume-source-listener-FzR5lGpL.d.ts → flume-source-listener-Ba8_1Mg-.d.ts} +9 -6
  33. package/dist/{funnel-diagnostics-Cvk6Sk4x.js → funnel-diagnostics-CAG7hJP0.js} +85 -141
  34. package/dist/{funnel-diagnostics-kbd27d7I.d.ts → funnel-diagnostics-CDrZznTB.d.ts} +18 -18
  35. package/dist/{funnel-docs-C-ge0MuB.js → funnel-docs-CI4hMkhq.js} +12 -3
  36. package/dist/{funnel-doctor-CVTNUtDn.d.ts → funnel-doctor-CY4S5cnz.d.ts} +20 -9
  37. package/dist/{funnel-doctor-XrI2GBH8.js → funnel-doctor-Csw5qjcH.js} +1 -0
  38. package/dist/{funnel-error-0t1MK1R6.js → funnel-error-DoSBCogD.js} +13 -0
  39. package/dist/{funnel-recovery-D8MkiTpk.d.ts → funnel-recovery-BwcSNNSN.d.ts} +1 -2
  40. package/dist/{funnel-recovery-DKnEutUS.js → funnel-recovery-DYbSYGWC.js} +1 -0
  41. package/dist/gateway/daemon.js +60 -139
  42. package/dist/gateway.d.ts +2 -3
  43. package/dist/gateway.js +2 -2
  44. package/dist/{gh-connector-BUGCOEWS.js → gh-connector-DMwI6zJA.js} +5 -5
  45. package/dist/{gh-connector-schema-BCHEqpUg.d.ts → gh-connector-schema-BrNsCl1T.d.ts} +0 -1
  46. package/dist/{index-BU1TtuFy.d.ts → index-fHrKn4jm.d.ts} +210 -40
  47. package/dist/index.d.ts +125 -115
  48. package/dist/index.js +242 -57
  49. package/dist/{local-config-json-schema-DexV8vX3.js → local-config-json-schema-_-YVHX4c.js} +4 -4
  50. package/dist/local-config.d.ts +2 -3
  51. package/dist/local-config.js +1 -1
  52. package/dist/logger.d.ts +17 -265
  53. package/dist/logger.js +6 -141
  54. package/dist/memory-event-log-BY8XjFzi.js +147 -0
  55. package/dist/{memory-token-prompter-D0kIdhar.d.ts → memory-token-prompter-B20tl_aU.d.ts} +2 -3
  56. package/dist/{node-file-system-BOXIHW_Q.js → node-file-system-xJx7dymE.js} +11 -3
  57. package/dist/{profiles-M24JrcOh.d.ts → profiles-CePRnv3F.d.ts} +3 -4
  58. package/dist/{profiles-ZHLONml4.js → profiles-KpN7_gBw.js} +19 -5
  59. package/dist/profiles.d.ts +1 -1
  60. package/dist/profiles.js +1 -1
  61. package/dist/recovery.d.ts +1 -1
  62. package/dist/recovery.js +1 -1
  63. package/dist/{schedule-connector-9k3gOIgl.js → schedule-connector-BXUOYgwZ.js} +63 -99
  64. package/dist/schedule-connector-schema-CNV8PgWX.js +137 -0
  65. package/dist/schedule-connector-schema-Tq5kJul-.d.ts +127 -0
  66. package/dist/{settings-reader-BnKIbmsD.d.ts → settings-reader-CyTpbAre.d.ts} +1 -2
  67. package/dist/{settings-schema-IShSMm5G.d.ts → settings-schema-B-CKLuST.d.ts} +0 -1
  68. package/dist/{settings-store-ccv291GV.js → settings-store-ZFWBhOnp.js} +12 -3
  69. package/dist/{slack-connector-CxpWagbT.js → slack-connector-CC3V2VXQ.js} +10 -9
  70. package/dist/{slack-event-processor-xFDG3US0.js → slack-event-processor-Cs_YuI3w.js} +2 -2
  71. package/dist/{slack-event-processor-BDTr62cN.d.ts → slack-event-processor-DmAlq4cV.d.ts} +0 -1
  72. package/dist/{slot-fields-D-pvMgTK.js → slot-fields-eCWizJqS.js} +4 -4
  73. package/dist/{sqlite-diagnostic-log-CwhXE9Qh.js → sqlite-diagnostic-log-Qs4cf9I_.js} +92 -100
  74. package/dist/sqlite-event-log-BYgCFMxC.d.ts +284 -0
  75. package/dist/{funnel-log-sqlite-sink-DLYkY0pZ.js → sqlite-event-log-eZuXKszJ.js} +53 -12
  76. package/dist/{yaml-render-DVEtYuF1.js → yaml-render-DxxRQT-V.js} +3 -3
  77. package/package.json +25 -10
  78. package/dist/broadcaster-DVNcw00K.d.ts +0 -138
  79. package/dist/connector-descriptor-CmyHlEiT.d.ts +0 -380
  80. package/dist/diagnostic-sql-reader-oXZnWFf_.js +0 -83
  81. package/dist/file-system-Wvzc2ePY.js +0 -9
  82. package/dist/logger-B6iyNbxM.js +0 -9
  83. package/dist/schedule-connector-schema-D7ZEKvit.d.ts +0 -49
  84. package/dist/schedule-connector-schema-DKEPZnVv.js +0 -31
  85. package/dist/settings-reader-9FcX3qS1.js +0 -11
  86. /package/dist/{connector-adapter-Dvs8N7ew.js → connector-adapter-BL2ehMej.js} +0 -0
  87. /package/dist/{connector-listener-mPGZYa8e.js → connector-listener-BcQMzY6Q.js} +0 -0
  88. /package/dist/{discord-connector-schema-B4YpWpR3.js → discord-connector-schema-saAGuPmJ.js} +0 -0
  89. /package/dist/{error-message-of-ColuYmAk.js → error-message-of-BG4ezZ_s.js} +0 -0
  90. /package/dist/{funnel-docs-Cd66sKyV.d.ts → funnel-docs-BJWawfWI.d.ts} +0 -0
  91. /package/dist/{gh-connector-schema-CAqIhzGr.js → gh-connector-schema-DmZTrzUu.js} +0 -0
  92. /package/dist/{logger-Bc_Ooypb.d.ts → logger-mMZvblTx.d.ts} +0 -0
  93. /package/dist/{loopback-fetch-CVNuN3YZ.js → loopback-fetch-HP-bo9Kv.js} +0 -0
  94. /package/dist/{node-http-client-u00atiKx.js → node-http-client-SX3xFh4h.js} +0 -0
  95. /package/dist/{node-process-runner-DxTvycoK.js → node-process-runner-D4rzPl8Q.js} +0 -0
  96. /package/dist/{resolve-connector-token-DxDG9mhf.js → resolve-connector-token-BwiJCu82.js} +0 -0
  97. /package/dist/{slack-connector-schema-Dem8to4P.js → slack-connector-schema-EGVuuqSX.js} +0 -0
@@ -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 };
@@ -5,6 +5,7 @@
5
5
  * fields. When no log is wired every call is a silent no-op.
6
6
  */
7
7
  var FunnelConnectorDiagnosticsRecorder = class {
8
+ props;
8
9
  constructor(props) {
9
10
  this.props = props;
10
11
  Object.freeze(this);
@@ -1,12 +1,13 @@
1
- import { t as FunnelLogger } from "../logger-Bc_Ooypb.js";
2
- import { M as CallInput, N as FunnelConnectorAdapter, c as FunnelHttpClient, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-CmyHlEiT.js";
3
- import { n as discordConnectorSchema, t as DiscordConnectorConfig } from "../discord-connector-schema-D1dyxhXk.js";
4
- import { t as FunnelFlumeSourceListener } from "../flume-source-listener-FzR5lGpL.js";
1
+ import { t as FunnelLogger } from "../logger-mMZvblTx.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 { n as discordConnectorSchema, t as DiscordConnectorConfig } from "../discord-connector-schema-BaBZYHxK.js";
5
+ import { t as FunnelFlumeSourceListener } from "../flume-source-listener-Ba8_1Mg-.js";
5
6
  import { FlumeRuntimeDeps } from "@interactive-inc/flume";
6
-
7
7
  //#region lib/engine/connectors/discord-adapter.d.ts
8
8
  type Deps$1 = {
9
- config: DiscordConnectorConfig; /** Environment used to resolve a `botTokenEnv` reference. Defaults to process.env. */
9
+ config: DiscordConnectorConfig;
10
+ /** Environment used to resolve a `botTokenEnv` reference. Defaults to process.env. */
10
11
  env?: NodeJS.ProcessEnv;
11
12
  http?: FunnelHttpClient;
12
13
  };
@@ -79,8 +80,10 @@ type Deps = {
79
80
  env?: NodeJS.ProcessEnv;
80
81
  logger?: FunnelLogger;
81
82
  diagnosticLog?: ConnectorDiagnosticLog;
82
- flumeDeps?: Partial<FlumeRuntimeDeps>; /** Shutdown signal forwarded to the underlying Flume. */
83
- signal?: AbortSignal; /** See `DiscordConnectorOptions.eventTypes`. */
83
+ flumeDeps?: Partial<FlumeRuntimeDeps>;
84
+ /** Shutdown signal forwarded to the underlying Flume. */
85
+ signal?: AbortSignal;
86
+ /** See `DiscordConnectorOptions.eventTypes`. */
84
87
  eventTypes?: ReadonlyArray<string> | "all";
85
88
  };
86
89
  /**
@@ -1,3 +1,3 @@
1
- import { t as discordConnectorSchema } from "../discord-connector-schema-B4YpWpR3.js";
2
- import { i as FunnelDiscordAdapter, n as FunnelFlumeDiscordListener, r as FunnelDiscordEventProcessor, t as discordConnector } from "../discord-connector-DXARcO6w.js";
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-CAcWifJn.js";
3
3
  export { FunnelDiscordAdapter, FunnelDiscordEventProcessor, FunnelFlumeDiscordListener, discordConnector, discordConnectorSchema };
@@ -1,9 +1,9 @@
1
- import { t as FunnelLogger } from "../logger-Bc_Ooypb.js";
2
- import { M as CallInput, N as FunnelConnectorAdapter, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor, z as FunnelProcessRunner } from "../connector-descriptor-CmyHlEiT.js";
3
- import { t as FunnelFlumeSourceListener } from "../flume-source-listener-FzR5lGpL.js";
4
- import { n as ghConnectorSchema, t as GhConnectorConfig } from "../gh-connector-schema-BCHEqpUg.js";
1
+ import { t as FunnelLogger } from "../logger-mMZvblTx.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";
5
+ import { n as ghConnectorSchema, t as GhConnectorConfig } from "../gh-connector-schema-BrNsCl1T.js";
5
6
  import { FlumeRuntimeDeps } from "@interactive-inc/flume";
6
-
7
7
  //#region lib/engine/connectors/gh-adapter.d.ts
8
8
  type Deps$1 = {
9
9
  process?: FunnelProcessRunner;
@@ -34,7 +34,8 @@ type Deps = {
34
34
  process?: FunnelProcessRunner;
35
35
  logger?: FunnelLogger;
36
36
  diagnosticLog?: ConnectorDiagnosticLog;
37
- flumeDeps?: Partial<FlumeRuntimeDeps>; /** Shutdown signal forwarded to the underlying Flume. */
37
+ flumeDeps?: Partial<FlumeRuntimeDeps>;
38
+ /** Shutdown signal forwarded to the underlying Flume. */
38
39
  signal?: AbortSignal;
39
40
  };
40
41
  /**
@@ -1,3 +1,3 @@
1
- import { t as ghConnectorSchema } from "../gh-connector-schema-CAqIhzGr.js";
2
- import { n as FunnelFlumeGhListener, r as FunnelGhAdapter, t as ghConnector } from "../gh-connector-BUGCOEWS.js";
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-DMwI6zJA.js";
3
3
  export { FunnelFlumeGhListener, FunnelGhAdapter, ghConnector, ghConnectorSchema };
@@ -1,18 +1,15 @@
1
- import { t as FunnelLogger } from "../logger-Bc_Ooypb.js";
2
- import { n as FunnelFileSystem } from "../file-system-DHgbuTFb.js";
3
- import { A as FunnelConnectorListener, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-CmyHlEiT.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-D7ZEKvit.js";
5
-
1
+ import { t as FunnelLogger } from "../logger-mMZvblTx.js";
2
+ import { n as FunnelFileSystem } from "../file-system-BNtl997T.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";
6
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;
7
9
  /**
8
- * Returns true when `date` (local time) satisfies a 5-field cron expression.
9
- *
10
- * Two deliberate deviations from Vixie cron, called out so schedules are not
11
- * written expecting the other behavior:
12
- * - Day-of-month and day-of-week are ANDed, not ORed. Vixie cron fires when
13
- * EITHER matches once both are restricted; here every field must match.
14
- * - Day-of-week is 0-6 (Sunday=0). `7` for Sunday is NOT accepted (it throws
15
- * 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).
16
13
  */
17
14
  declare const matchCron: (expr: string, date: Date) => boolean;
18
15
  //#endregion
@@ -39,9 +36,11 @@ declare class FunnelScheduleStateStore {
39
36
  type ScheduleOnFired = (entry: ScheduleEntry, firedAt: Date) => void | Promise<void>;
40
37
  type Deps = {
41
38
  config: ScheduleConnectorConfig;
42
- lastFiredStore: FunnelScheduleStateStore; /** Funnel channel uuid this connector lives under; stamped onto diagnostic-log rows. */
39
+ lastFiredStore: FunnelScheduleStateStore;
40
+ /** Funnel channel uuid this connector lives under; stamped onto diagnostic-log rows. */
43
41
  channelId?: string;
44
- logger?: FunnelLogger; /** Diagnostic log of fired entries and lifecycle. No-op when absent. */
42
+ logger?: FunnelLogger;
43
+ /** Diagnostic log of fired entries and lifecycle. No-op when absent. */
45
44
  diagnosticLog?: ConnectorDiagnosticLog;
46
45
  now?: () => Date;
47
46
  /**
@@ -68,16 +67,21 @@ declare class FunnelScheduleListener extends FunnelConnectorListener {
68
67
  isAlive(): boolean;
69
68
  tick(notify: NotifyFn): Promise<void>;
70
69
  private fireEntry;
70
+ private fireOnceEntry;
71
+ private fireCronEntry;
72
+ private seedSearchWatermark;
71
73
  private notifyOne;
72
74
  private findMostRecentMatch;
73
75
  private findAllMatches;
74
76
  private logInvalidCron;
75
77
  private truncateToMinute;
78
+ private pruneRemovedEntries;
76
79
  }
77
80
  //#endregion
78
81
  //#region lib/engine/connectors/schedule-connector.d.ts
79
82
  type ScheduleConnectorOptions = {
80
- /** Invoked after a schedule entry fires successfully — e.g. to drop one-shot entries. */onFired?: ScheduleOnFired;
83
+ /** Invoked after a schedule entry fires successfully — e.g. to drop one-shot entries. */
84
+ onFired?: ScheduleOnFired;
81
85
  };
82
86
  /**
83
87
  * Schedule connector descriptor. Pass `scheduleConnector()` to
@@ -88,4 +92,4 @@ type ScheduleConnectorOptions = {
88
92
  */
89
93
  declare const scheduleConnector: (options?: ScheduleConnectorOptions) => ConnectorDescriptor;
90
94
  //#endregion
91
- 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-DKEPZnVv.js";
2
- import { i as matchCron, n as FunnelScheduleListener, r as FunnelScheduleStateStore, t as scheduleConnector } from "../schedule-connector-9k3gOIgl.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,13 +1,14 @@
1
- import { t as FunnelLogger } from "../logger-Bc_Ooypb.js";
2
- import { M as CallInput, N as FunnelConnectorAdapter, c as FunnelHttpClient, g as ConnectorDiagnosticLog, j as NotifyFn, r as ConnectorDescriptor } from "../connector-descriptor-CmyHlEiT.js";
3
- import { t as FunnelFlumeSourceListener } from "../flume-source-listener-FzR5lGpL.js";
4
- 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-BDTr62cN.js";
1
+ import { t as FunnelLogger } from "../logger-mMZvblTx.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";
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
7
  //#region lib/engine/connectors/slack-adapter.d.ts
8
8
  type Deps$1 = {
9
9
  config: SlackConnectorConfig;
10
- env?: NodeJS.ProcessEnv; /** HTTP client injection — defaults to `NodeFunnelHttpClient`. Tests inject `MemoryFunnelHttpClient`. */
10
+ env?: NodeJS.ProcessEnv;
11
+ /** HTTP client injection — defaults to `NodeFunnelHttpClient`. Tests inject `MemoryFunnelHttpClient`. */
11
12
  http?: FunnelHttpClient;
12
13
  };
13
14
  /**
@@ -73,10 +74,14 @@ type Deps = {
73
74
  env?: NodeJS.ProcessEnv;
74
75
  logger?: FunnelLogger;
75
76
  diagnosticLog?: ConnectorDiagnosticLog;
76
- flumeDeps?: Partial<FlumeRuntimeDeps>; /** HTTP client for `auth.test` and `reactions.add`. Defaults to NodeFunnelHttpClient. */
77
- http?: FunnelHttpClient; /** Shutdown signal forwarded to the underlying Flume. */
78
- signal?: AbortSignal; /** See `SlackPreprocessEvent`. Default: identity (no preprocessing). */
79
- preprocessEvent?: SlackPreprocessEvent; /** See `SlackInteractiveHandler`. Default: drop interactive envelopes silently. */
77
+ flumeDeps?: Partial<FlumeRuntimeDeps>;
78
+ /** HTTP client for `auth.test` and `reactions.add`. Defaults to NodeFunnelHttpClient. */
79
+ http?: FunnelHttpClient;
80
+ /** Shutdown signal forwarded to the underlying Flume. */
81
+ signal?: AbortSignal;
82
+ /** See `SlackPreprocessEvent`. Default: identity (no preprocessing). */
83
+ preprocessEvent?: SlackPreprocessEvent;
84
+ /** See `SlackInteractiveHandler`. Default: drop interactive envelopes silently. */
80
85
  onInteractive?: SlackInteractiveHandler;
81
86
  };
82
87
  /**
@@ -1,4 +1,4 @@
1
- import { t as slackConnectorSchema } from "../slack-connector-schema-Dem8to4P.js";
2
- import { t as FunnelSlackEventProcessor } from "../slack-event-processor-xFDG3US0.js";
3
- import { n as FunnelFlumeSlackListener, r as FunnelSlackAdapter, t as slackConnector } from "../slack-connector-CxpWagbT.js";
1
+ import { t as slackConnectorSchema } from "../slack-connector-schema-EGVuuqSX.js";
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-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 };