@interactive-inc/claude-funnel 0.59.1 → 0.60.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 (85) hide show
  1. package/README.md +9 -3
  2. package/dist/bin.js +549 -487
  3. package/dist/channels-2g_BU1N0.d.ts +174 -0
  4. package/dist/claude.d.ts +9 -5
  5. package/dist/claude.js +54 -17
  6. package/dist/{diagnostic-log-Cb3v8P7p.d.ts → connector-descriptor-6SXJoszo.d.ts} +158 -2
  7. package/dist/connectors/discord.d.ts +30 -4
  8. package/dist/connectors/discord.js +2 -2
  9. package/dist/connectors/gh.d.ts +21 -5
  10. package/dist/connectors/gh.js +3 -3
  11. package/dist/connectors/schedule.d.ts +124 -2
  12. package/dist/connectors/schedule.js +3 -3
  13. package/dist/connectors/slack.d.ts +149 -5
  14. package/dist/connectors/slack.js +2 -2
  15. package/dist/{diagnostic-sql-reader-CzYgZpq2.js → diagnostic-sql-reader-C9zR-Csp.js} +5 -5
  16. package/dist/diagnostics.d.ts +1 -1
  17. package/dist/diagnostics.js +1 -1
  18. package/dist/{discord-listener-CKsZGTnH.js → discord-connector-BL36yvbL.js} +60 -37
  19. package/dist/docs.d.ts +1 -1
  20. package/dist/docs.js +1 -1
  21. package/dist/doctor.d.ts +1 -1
  22. package/dist/doctor.js +1 -1
  23. package/dist/error-message-of-Byi4y0Uf.js +9 -0
  24. package/dist/{file-process-guard-JhFpmHYo.d.ts → file-process-guard-DOlCr4GF.d.ts} +4 -5
  25. package/dist/{funnel-diagnostics-BpKYrMSu.js → funnel-diagnostics-CSiJmPlZ.js} +19 -2
  26. package/dist/{funnel-diagnostics-K-wON25Y.d.ts → funnel-diagnostics-DpXOsCty.d.ts} +3 -3
  27. package/dist/{funnel-docs-ng5K8w4j.js → funnel-docs-BxXZ9Ksx.js} +76 -3
  28. package/dist/{funnel-docs-DYBs1-H_.d.ts → funnel-docs-CNklHvbt.d.ts} +1 -1
  29. package/dist/{funnel-doctor-vxO96TCA.d.ts → funnel-doctor-CZf_0Luq.d.ts} +2 -2
  30. package/dist/{funnel-recovery-COExL9MD.d.ts → funnel-recovery-DnLrdWO9.d.ts} +1 -1
  31. package/dist/gateway/daemon.js +326 -266
  32. package/dist/gateway-base-url-Dy4Ykuoh.js +14 -0
  33. package/dist/gateway.d.ts +2 -2
  34. package/dist/gateway.js +2 -2
  35. package/dist/{gh-listener-B2I4s8qh.js → gh-connector-DpiixfQZ.js} +53 -5
  36. package/dist/gh-connector-schema-Rzwc1c1N.js +12 -0
  37. package/dist/http-client-oICicjuO.d.ts +18 -0
  38. package/dist/index-CgY8NdMz.d.ts +1057 -0
  39. package/dist/index.d.ts +1558 -17
  40. package/dist/index.js +374 -342
  41. package/dist/{local-config-json-schema-DE1zkMcb.js → local-config-json-schema-JyLqOQNX.js} +9 -5
  42. package/dist/local-config-sync-Dh1Croqe.d.ts +169 -0
  43. package/dist/local-config.d.ts +2 -2
  44. package/dist/local-config.js +2 -2
  45. package/dist/logger.js +1 -1
  46. package/dist/{memory-diagnostic-log-B9Us7X05.js → memory-diagnostic-log-CI60kNfB.js} +33 -18
  47. package/dist/{memory-token-prompter-CcShtF8B.d.ts → memory-token-prompter-B4sjyaAq.d.ts} +2 -2
  48. package/dist/{memory-token-prompter-C7vREzCL.js → memory-token-prompter-CZde7e6y.js} +1 -1
  49. package/dist/{node-file-system-BcrmWN9I.js → node-file-system-Blr8pAir.js} +1 -1
  50. package/dist/node-http-client-lowp60Oa.js +25 -0
  51. package/dist/{gh-connector-schema-ClPLSYD9.js → node-process-runner-DxTvycoK.js} +1 -12
  52. package/dist/{profiles-g2qGVOWv.d.ts → profiles-Cy5wXQ0L.d.ts} +3 -3
  53. package/dist/{profiles-MnXvYfZF.js → profiles-DSzTeKQw.js} +1 -1
  54. package/dist/profiles.d.ts +1 -1
  55. package/dist/profiles.js +1 -1
  56. package/dist/recovery.d.ts +1 -1
  57. package/dist/recovery.js +1 -1
  58. package/dist/{schedule-listener-DP9Jhc6U.js → schedule-connector-L4uzg5M8.js} +109 -9
  59. package/dist/{settings-reader-DPwqOVUm.d.ts → settings-reader-BIFB_j2f.d.ts} +1 -1
  60. package/dist/settings-schema-D1xcOqRu.d.ts +78 -0
  61. package/dist/{gateway-base-url-DxVjjDoW.js → settings-store-CUKSeTXC.js} +27 -29
  62. package/dist/{slack-listener-C4wlZaOq.js → slack-connector-DQIFPdBF.js} +67 -12
  63. package/dist/slot-fields-CMoRpwuy.js +45 -0
  64. package/dist/{yaml-render-cZu6CxkE.js → yaml-render-qW34NlYz.js} +4 -4
  65. package/package.json +1 -1
  66. package/dist/connector-adapter-DGacCppE.d.ts +0 -25
  67. package/dist/discord-connector-schema-CQyfDkLD.d.ts +0 -39
  68. package/dist/gh-connector-schema-CZzwzvqY.d.ts +0 -14
  69. package/dist/index-D7mjirUL.d.ts +0 -3602
  70. package/dist/local-config-sync-BGPAS9Be.d.ts +0 -401
  71. package/dist/process-runner-DIm1cy95.d.ts +0 -52
  72. package/dist/resolve-connector-token-CczqG_Ig.js +0 -22
  73. package/dist/schedule-listener-DoMPjHZj.d.ts +0 -112
  74. package/dist/settings-schema-1hh11jnN.d.ts +0 -152
  75. package/dist/slack-listener-Dj9NFbAJ.d.ts +0 -136
  76. /package/dist/{connector-adapter-qwXLjQId.js → connector-adapter-DU9Rvyec.js} +0 -0
  77. /package/dist/{connector-listener-CpHBecCj.js → connector-listener-DR3aKOuK.js} +0 -0
  78. /package/dist/{file-system-PWKKU7lA.js → file-system-Wvzc2ePY.js} +0 -0
  79. /package/dist/{file-system-DxpnnUVb.d.ts → file-system-o51IsM0W.d.ts} +0 -0
  80. /package/dist/{funnel-doctor-CApCezTq.js → funnel-doctor-DiJCjHsg.js} +0 -0
  81. /package/dist/{funnel-log-sqlite-sink-B_5_4ybn.js → funnel-log-sqlite-sink-kqJbx2H7.js} +0 -0
  82. /package/dist/{funnel-recovery-D9CxD5Zs.js → funnel-recovery-BFdPjL6Z.js} +0 -0
  83. /package/dist/{logger-BP6SisKt.js → logger-B6iyNbxM.js} +0 -0
  84. /package/dist/{schedule-connector-schema-B_xO5z5B.js → schedule-connector-schema-CfyuMCMh.js} +0 -0
  85. /package/dist/{settings-reader-DPqrpV7s.js → settings-reader-CtQ-Ix8_.js} +0 -0
@@ -0,0 +1,174 @@
1
+ import { n as ChannelDeliveryMode, t as ChannelConfig } from "./settings-schema-D1xcOqRu.js";
2
+ import { n as FunnelIdGenerator, t as FunnelSettingsReader } from "./settings-reader-BIFB_j2f.js";
3
+ import { A as FunnelConnectorAdapter, B as FunnelLogger, D as FunnelConnectorListener, I as FunnelProcessRunner, M as BaseConnectorConfig, k as CallInput, n as ConnectorBuildContext, o as ConnectorOperationContext, p as ConnectorDiagnosticLog, r as ConnectorDescriptor, s as ConnectorUpdateContext } from "./connector-descriptor-6SXJoszo.js";
4
+ import { n as FunnelFileSystem } from "./file-system-o51IsM0W.js";
5
+
6
+ //#region lib/engine/connectors/connector-registry.d.ts
7
+ type Deps$1 = {
8
+ /** Connector types this funnel handles. Each is a self-describing descriptor;
9
+ * importing it is what pulls its (heavy) listener/adapter code into the bundle,
10
+ * so omitting a type keeps it out entirely. */
11
+ descriptors: ConnectorDescriptor[];
12
+ fs?: FunnelFileSystem;
13
+ process?: FunnelProcessRunner;
14
+ logger?: FunnelLogger;
15
+ diagnosticLog?: ConnectorDiagnosticLog;
16
+ dir?: string;
17
+ };
18
+ /**
19
+ * Dispatches connector work to injected descriptors by `type`. Replaces the old
20
+ * hard-coded factory: core never imports a concrete connector, so listener and
21
+ * adapter code (and their SDKs) is bundled only when the host passes that type's
22
+ * descriptor to `new Funnel({ connectors: [...] })`.
23
+ *
24
+ * `dir` is the funnel home; per-connector state files land at
25
+ * `<dir>/channels/<channel-id>/connectors/<connector-id>/`.
26
+ */
27
+ declare class FunnelConnectorRegistry {
28
+ private readonly descriptors;
29
+ private readonly fs;
30
+ private readonly process;
31
+ private readonly logger;
32
+ private readonly diagnosticLog;
33
+ private readonly dir;
34
+ constructor(deps: Deps$1);
35
+ has(type: string): boolean;
36
+ types(): string[];
37
+ createListener(channelId: string, config: BaseConnectorConfig): FunnelConnectorListener;
38
+ createAdapter(config: BaseConnectorConfig): FunnelConnectorAdapter | null;
39
+ secretTokens(config: BaseConnectorConfig): string[];
40
+ buildConfig(input: Record<string, unknown>, context: ConnectorBuildContext): BaseConnectorConfig;
41
+ applyUpdate(config: BaseConnectorConfig, fields: Record<string, unknown>, context: ConnectorUpdateContext): BaseConnectorConfig;
42
+ runOperation(config: BaseConnectorConfig, name: string, args: unknown, context: ConnectorOperationContext): {
43
+ config: BaseConnectorConfig;
44
+ result: unknown;
45
+ };
46
+ connectorDir(channelId: string, connectorId: string): string;
47
+ channelDir(channelId: string): string;
48
+ private require;
49
+ private listenerDeps;
50
+ private adapterDeps;
51
+ }
52
+ //#endregion
53
+ //#region lib/engine/profiles/profile-channel-checker.d.ts
54
+ /**
55
+ * Read-side dependency that lets FunnelChannels ask whether a profile
56
+ * references a given channel id, without depending on FunnelProfiles directly.
57
+ */
58
+ type ProfileChannelChecker = {
59
+ hasChannelRef(channelId: string): boolean;
60
+ };
61
+ //#endregion
62
+ //#region lib/engine/time/clock.d.ts
63
+ /**
64
+ * Time boundary. Default NodeFunnelClock returns `new Date()`; MemoryFunnelClock
65
+ * is settable and `advance(ms)`-able for deterministic schedule / timeout tests.
66
+ */
67
+ declare abstract class FunnelClock {
68
+ abstract now(): Date;
69
+ millis(): number;
70
+ iso(): string;
71
+ }
72
+ //#endregion
73
+ //#region lib/engine/channels/channels.d.ts
74
+ type Deps = {
75
+ store: FunnelSettingsReader;
76
+ registry: FunnelConnectorRegistry;
77
+ profileChecker?: ProfileChannelChecker;
78
+ clock?: FunnelClock;
79
+ idGenerator?: FunnelIdGenerator;
80
+ };
81
+ type ChannelConnectorView = BaseConnectorConfig & {
82
+ channelId: string;
83
+ channelName: string;
84
+ };
85
+ /**
86
+ * Add-connector input. Core does not enumerate connector types, so the shape is
87
+ * the common pair plus arbitrary type-specific fields — the connector's
88
+ * descriptor (via the registry) builds and validates the concrete config.
89
+ */
90
+ type AddConnectorInput = {
91
+ type: string;
92
+ name: string;
93
+ } & Record<string, unknown>;
94
+ /**
95
+ * Channels own their connectors. Each channel has a stable id (UUID); the
96
+ * `name` is the human-facing label used by the CLI. Connectors live nested
97
+ * inside `channel.connectors[]`, so add/remove/rename are channel-scoped — no
98
+ * global connector namespace exists. Token uniqueness is enforced across all
99
+ * channels at add/update time so the same Slack/Discord credentials cannot
100
+ * be registered twice.
101
+ *
102
+ * Connector type knowledge lives entirely in the injected registry (descriptors):
103
+ * this class builds, updates, and runs operations on connectors generically and
104
+ * never imports a concrete connector type.
105
+ */
106
+ declare class FunnelChannels {
107
+ private readonly store;
108
+ private readonly registry;
109
+ private readonly profileChecker;
110
+ private readonly clock;
111
+ private readonly idGenerator;
112
+ constructor(deps: Deps);
113
+ list(): ChannelConfig[];
114
+ get(name: string): ChannelConfig | null;
115
+ getById(id: string): ChannelConfig | null;
116
+ add(input: {
117
+ name: string;
118
+ delivery?: ChannelDeliveryMode;
119
+ }): ChannelConfig;
120
+ setDelivery(name: string, delivery: ChannelDeliveryMode): void;
121
+ remove(name: string): void;
122
+ rename(oldName: string, newName: string): void;
123
+ listConnectors(channelName: string): BaseConnectorConfig[];
124
+ getConnector(channelName: string, connectorName: string): BaseConnectorConfig | null;
125
+ listAllConnectors(): ChannelConnectorView[];
126
+ addConnector(channelName: string, input: AddConnectorInput): BaseConnectorConfig;
127
+ removeConnector(channelName: string, connectorName: string): void;
128
+ renameConnector(channelName: string, oldName: string, newName: string): void;
129
+ /**
130
+ * Update a connector's mutable fields generically. The connector's descriptor
131
+ * rebuilds the config from `fields` (e.g. Slack/Discord token slots are rebuilt
132
+ * so a slot can move between a literal and an env reference cleanly).
133
+ */
134
+ updateConnector(channelName: string, connectorName: string, fields: Record<string, unknown>): void;
135
+ /** Back-compat wrapper for `updateConnector` on a slack connector. */
136
+ updateSlackConnector(channelName: string, connectorName: string, fields: {
137
+ botToken?: string;
138
+ appToken?: string;
139
+ botTokenEnv?: string;
140
+ appTokenEnv?: string;
141
+ }): void;
142
+ /** Back-compat wrapper for `updateConnector` on a gh connector. */
143
+ updateGhConnector(channelName: string, connectorName: string, fields: {
144
+ pollInterval?: number;
145
+ }): void;
146
+ /** Back-compat wrapper for `updateConnector` on a discord connector. */
147
+ updateDiscordConnector(channelName: string, connectorName: string, fields: {
148
+ botToken?: string;
149
+ botTokenEnv?: string;
150
+ }): void;
151
+ /**
152
+ * Run a connector-type-specific operation (e.g. schedule `addEntry` /
153
+ * `removeEntry` / `listEntries`). The descriptor returns the next config and a
154
+ * result; the config is persisted only when the operation actually mutated it.
155
+ */
156
+ connectorOp(channelName: string, connectorName: string, operation: string, args: unknown): unknown;
157
+ call(channelName: string, connectorName: string, input: CallInput): Promise<unknown>;
158
+ createListener(channelName: string, connectorName: string): {
159
+ config: BaseConnectorConfig;
160
+ channelId: string;
161
+ listener: FunnelConnectorListener;
162
+ } | null;
163
+ createAllListeners(): {
164
+ config: BaseConnectorConfig;
165
+ channelId: string;
166
+ channelName: string;
167
+ listener: FunnelConnectorListener;
168
+ }[];
169
+ private requireChannel;
170
+ private replaceConnector;
171
+ private assertNoTokenCollision;
172
+ }
173
+ //#endregion
174
+ export { FunnelConnectorRegistry as a, FunnelClock as i, ChannelConnectorView as n, FunnelChannels as r, AddConnectorInput as t };
package/dist/claude.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { a as ProcessGuard, c as ChannelResolver, i as SessionStore, n as FunnelClaude, o as McpInstaller, r as LaunchOptions, s as GatewayController, t as FileProcessGuard } from "./file-process-guard-JhFpmHYo.js";
2
- import { n as FunnelFileSystem } from "./file-system-DxpnnUVb.js";
3
- import { t as FunnelProfiles } from "./profiles-g2qGVOWv.js";
4
- import { C as profileSpecSchema, S as localConfigSchema, _ as LOCAL_CONFIG_FILENAME, b as channelSpecSchema, g as ConnectorSpec, h as ChannelSpec, i as FunnelTokenPrompter, m as FunnelLocalConfig, n as FunnelLocalConfigSync, r as LocalConfigSyncResult, t as ConnectorSyncOutcome, v as LocalConfig, x as connectorSpecSchema, y as ProfileSpec } from "./local-config-sync-BGPAS9Be.js";
5
- import { i as funnelJsonSchema, n as NodeFunnelTokenPrompter, r as FunnelLocalConfigWriter, t as MemoryFunnelTokenPrompter } from "./memory-token-prompter-CcShtF8B.js";
1
+ import { a as ProcessGuard, c as ChannelResolver, i as SessionStore, n as FunnelClaude, o as McpInstaller, r as LaunchOptions, s as GatewayController, t as FileProcessGuard } from "./file-process-guard-DOlCr4GF.js";
2
+ import { r as ConnectorDescriptor } from "./connector-descriptor-6SXJoszo.js";
3
+ import { n as FunnelFileSystem } from "./file-system-o51IsM0W.js";
4
+ import { t as FunnelProfiles } from "./profiles-Cy5wXQ0L.js";
5
+ import { a as FunnelLocalConfig, c as LOCAL_CONFIG_FILENAME, d as channelSpecSchema, f as connectorSpecSchema, i as FunnelTokenPrompter, l as LocalConfig, m as profileSpecSchema, n as FunnelLocalConfigSync, o as ChannelSpec, p as localConfigSchema, r as LocalConfigSyncResult, s as ConnectorSpec, t as ConnectorSyncOutcome, u as ProfileSpec } from "./local-config-sync-Dh1Croqe.js";
6
+ import { i as funnelJsonSchema, n as NodeFunnelTokenPrompter, r as FunnelLocalConfigWriter, t as MemoryFunnelTokenPrompter } from "./memory-token-prompter-B4sjyaAq.js";
6
7
 
7
8
  //#region lib/engine/mcp/mcp.d.ts
8
9
  declare const FUNNEL_MCP_COMMAND = "bun";
@@ -40,6 +41,9 @@ type ChannelServerOptions = {
40
41
  gatewayUrl?: string; /** Channel id to subscribe to. Defaults to `$FUNNEL_CHANNEL_ID`. */
41
42
  channelId?: string; /** Auth token. Defaults to `$FUNNEL_GATEWAY_TOKEN` then `<dir>/gateway.token`. */
42
43
  token?: string;
44
+ /** Connector descriptors whose tools this MCP server exposes. Defaults to the
45
+ * four built-in connectors; the tool-exposed subset is derived from them. */
46
+ connectors?: ConnectorDescriptor[];
43
47
  };
44
48
  /**
45
49
  * Start the funnel MCP server over stdio. Wires:
package/dist/claude.js CHANGED
@@ -1,9 +1,15 @@
1
- import { f as settingsSchema, s as resolveFunnelPort, t as gatewayLoopbackUrl } from "./gateway-base-url-DxVjjDoW.js";
2
- import { a as FunnelMcp, i as FUNNEL_MCP_NAME, n as FUNNEL_MCP_ARGS, o as FileProcessGuard, r as FUNNEL_MCP_COMMAND, s as FunnelClaude, t as renderYaml } from "./yaml-render-cZu6CxkE.js";
3
- import { t as FunnelDocs } from "./funnel-docs-ng5K8w4j.js";
4
- import { a as FunnelLocalConfig, c as connectorSpecSchema, i as FunnelTokenPrompter, l as localConfigSchema, n as NodeFunnelTokenPrompter, o as LOCAL_CONFIG_FILENAME, r as FunnelLocalConfigSync, s as channelSpecSchema, t as funnelJsonSchema, u as profileSpecSchema } from "./local-config-json-schema-DE1zkMcb.js";
5
- import { t as FunnelProfiles } from "./profiles-MnXvYfZF.js";
6
- import { n as FunnelLocalConfigWriter, t as MemoryFunnelTokenPrompter } from "./memory-token-prompter-C7vREzCL.js";
1
+ import { t as gatewayLoopbackUrl } from "./gateway-base-url-Dy4Ykuoh.js";
2
+ import { d as settingsSchema, o as resolveFunnelPort } from "./settings-store-CUKSeTXC.js";
3
+ import { a as FunnelMcp, i as FUNNEL_MCP_NAME, n as FUNNEL_MCP_ARGS, o as FileProcessGuard, r as FUNNEL_MCP_COMMAND, s as FunnelClaude, t as renderYaml } from "./yaml-render-qW34NlYz.js";
4
+ import { t as FunnelDocs } from "./funnel-docs-BxXZ9Ksx.js";
5
+ import { a as FunnelLocalConfig, c as connectorSpecSchema, i as FunnelTokenPrompter, l as localConfigSchema, n as NodeFunnelTokenPrompter, o as LOCAL_CONFIG_FILENAME, r as FunnelLocalConfigSync, s as channelSpecSchema, t as funnelJsonSchema, u as profileSpecSchema } from "./local-config-json-schema-JyLqOQNX.js";
6
+ import { t as FunnelProfiles } from "./profiles-DSzTeKQw.js";
7
+ import { t as errorMessageOf } from "./error-message-of-Byi4y0Uf.js";
8
+ import { t as discordConnector } from "./discord-connector-BL36yvbL.js";
9
+ import { t as ghConnector } from "./gh-connector-DpiixfQZ.js";
10
+ import { t as scheduleConnector } from "./schedule-connector-L4uzg5M8.js";
11
+ import { t as slackConnector } from "./slack-connector-DQIFPdBF.js";
12
+ import { n as FunnelLocalConfigWriter, t as MemoryFunnelTokenPrompter } from "./memory-token-prompter-CZde7e6y.js";
7
13
  import { join } from "node:path";
8
14
  import { existsSync, readFileSync } from "node:fs";
9
15
  import { homedir } from "node:os";
@@ -411,13 +417,17 @@ const MAX_RECONNECT_DELAY = 1e4;
411
417
  var FunnelChannelSubscriber = class {
412
418
  state = {
413
419
  reconnectDelay: RECONNECT_DELAY,
414
- lastOffset: 0
420
+ lastOffset: 0,
421
+ isStarted: false,
422
+ hasPendingReconnect: false
415
423
  };
416
424
  constructor(props) {
417
425
  this.props = props;
418
426
  Object.freeze(this);
419
427
  }
420
428
  start() {
429
+ if (this.state.isStarted) return;
430
+ this.state.isStarted = true;
421
431
  this.connect();
422
432
  }
423
433
  connect() {
@@ -430,8 +440,13 @@ var FunnelChannelSubscriber = class {
430
440
  });
431
441
  ws.addEventListener("message", (event) => this.handleMessage(event));
432
442
  ws.addEventListener("close", () => {
443
+ if (this.state.hasPendingReconnect) return;
444
+ this.state.hasPendingReconnect = true;
433
445
  process.stderr.write(`funnel: disconnected, reconnecting in ${this.state.reconnectDelay}ms\n`);
434
- setTimeout(() => this.connect(), this.state.reconnectDelay);
446
+ setTimeout(() => {
447
+ this.state.hasPendingReconnect = false;
448
+ this.connect();
449
+ }, this.state.reconnectDelay);
435
450
  this.state.reconnectDelay = Math.min(this.state.reconnectDelay * 2, MAX_RECONNECT_DELAY);
436
451
  });
437
452
  ws.addEventListener("error", () => {});
@@ -450,18 +465,34 @@ var FunnelChannelSubscriber = class {
450
465
  }
451
466
  });
452
467
  } catch (error) {
453
- process.stderr.write(`funnel: error: ${error instanceof Error ? error.message : String(error)}\n`);
468
+ process.stderr.write(`funnel: error: ${errorMessageOf(error)}\n`);
454
469
  }
455
470
  }
456
471
  };
457
472
  //#endregion
473
+ //#region lib/engine/connectors/builtin-connectors.ts
474
+ /**
475
+ * The four built-in connector descriptors. Importing this pulls every connector
476
+ * SDK (@slack/bolt, discord.js, …) into the bundle, so it is used ONLY by
477
+ * full-bundle entry points (the `fnl` CLI, the gateway daemon, the MCP server) —
478
+ * never by the library's public barrel. Programmatic hosts pass the descriptors
479
+ * they actually need to `new Funnel({ connectors: [...] })` instead.
480
+ */
481
+ const builtinConnectors = () => [
482
+ slackConnector(),
483
+ ghConnector(),
484
+ discordConnector(),
485
+ scheduleConnector()
486
+ ];
487
+ //#endregion
458
488
  //#region lib/engine/mcp/read-channel-connectors.ts
459
- const TOOL_CONNECTOR_TYPES = new Set([
460
- "slack",
461
- "gh",
462
- "discord"
463
- ]);
464
- const readChannelConnectors = (dir, channelId) => {
489
+ /**
490
+ * Reads the connectors of one channel from settings.json, keeping only the
491
+ * tool-exposed types. The exposed set is supplied by the caller (the MCP server
492
+ * builds it from the connector descriptors it imports) — core does not enumerate
493
+ * connector types here.
494
+ */
495
+ const readChannelConnectors = (dir, channelId, toolConnectorTypes) => {
465
496
  const settingsPath = join(dir, "settings.json");
466
497
  if (!existsSync(settingsPath)) return null;
467
498
  const raw = JSON.parse(readFileSync(settingsPath, "utf-8"));
@@ -469,7 +500,7 @@ const readChannelConnectors = (dir, channelId) => {
469
500
  if (!parsed.success) return null;
470
501
  const channel = parsed.data.channels.find((c) => c.id === channelId);
471
502
  if (!channel) return null;
472
- const connectors = channel.connectors.filter((c) => TOOL_CONNECTOR_TYPES.has(c.type)).map((c) => ({
503
+ const connectors = channel.connectors.filter((c) => toolConnectorTypes.has(c.type)).map((c) => ({
473
504
  name: c.name,
474
505
  type: c.type
475
506
  }));
@@ -491,6 +522,11 @@ const readGatewayToken = (dir) => {
491
522
  //#endregion
492
523
  //#region lib/engine/mcp/channel-server.ts
493
524
  const DEFAULT_FUNNEL_DIR = join(homedir(), ".funnel");
525
+ const toolConnectorTypesOf = (descriptors) => {
526
+ const out = /* @__PURE__ */ new Set();
527
+ for (const descriptor of descriptors) if (descriptor.toolExposed) out.add(descriptor.type);
528
+ return out;
529
+ };
494
530
  const readAllChannels = (dir) => {
495
531
  const settingsPath = join(dir, "settings.json");
496
532
  if (!existsSync(settingsPath)) return [];
@@ -522,7 +558,8 @@ const startChannelServer = async (options = {}) => {
522
558
  const gatewayBaseUrl = options.gatewayUrl ?? process.env.FUNNEL_GATEWAY_URL ?? gatewayLoopbackUrl(resolveFunnelPort());
523
559
  const gatewayWsUrl = `${gatewayBaseUrl.replace(/^http/, "ws")}/ws`;
524
560
  const channelId = options.channelId ?? process.env.FUNNEL_CHANNEL_ID;
525
- const channel = channelId ? readChannelConnectors(dir, channelId) : null;
561
+ const toolConnectorTypes = toolConnectorTypesOf(options.connectors ?? builtinConnectors());
562
+ const channel = channelId ? readChannelConnectors(dir, channelId, toolConnectorTypes) : null;
526
563
  const token = options.token ?? readGatewayToken(dir);
527
564
  const allChannels = readAllChannels(dir);
528
565
  const currentChannelName = channel?.channelName ?? null;
@@ -1,3 +1,4 @@
1
+ import { n as FunnelFileSystem } from "./file-system-o51IsM0W.js";
1
2
  import { z } from "zod";
2
3
 
3
4
  //#region lib/engine/logger/logger.d.ts
@@ -13,6 +14,98 @@ declare abstract class FunnelLogger {
13
14
  abstract readonly file: string | null;
14
15
  }
15
16
  //#endregion
17
+ //#region lib/engine/process/process-runner.d.ts
18
+ type RunOptions = {
19
+ cwd?: string;
20
+ env?: Record<string, string>;
21
+ input?: string;
22
+ };
23
+ type RunResult = {
24
+ exitCode: number;
25
+ stdout: string;
26
+ stderr: string;
27
+ };
28
+ type AttachOptions = {
29
+ cwd?: string;
30
+ env?: Record<string, string>;
31
+ /** Invoked synchronously after the child process has been spawned, with its PID.
32
+ * Useful for hosts that need to register the spawned process before it exits. */
33
+ onSpawned?: (pid: number) => void;
34
+ };
35
+ type DetachOptions = {
36
+ env?: Record<string, string>; /** Append stdout to this file. Parent dir is the caller's responsibility. */
37
+ stdoutFile?: string; /** Append stderr to this file. Parent dir is the caller's responsibility. */
38
+ stderrFile?: string;
39
+ };
40
+ type ProcessSnapshot = {
41
+ pid: number;
42
+ command: string;
43
+ };
44
+ /**
45
+ * Process boundary covering one-shot runs, sync runs, foreground attach, and
46
+ * detached background spawns. Default is NodeFunnelProcessRunner (Bun.spawn);
47
+ * MemoryFunnelProcessRunner records calls and lets tests stub responses.
48
+ *
49
+ * Liveness and process-listing helpers absorb POSIX/Windows differences so
50
+ * callers do not branch on `process.platform`. `isAlive` checks whether a PID
51
+ * names a live (non-zombie) process; `listProcessesContaining` enumerates
52
+ * processes whose command line includes `marker`, used for funnel-gateway tag
53
+ * matching across daemons that share a home dir. `getStartTime` returns a
54
+ * stable string identifying when a PID was started, used to detect PID reuse
55
+ * after the original process died abnormally (no exit hook fired).
56
+ */
57
+ declare abstract class FunnelProcessRunner {
58
+ abstract run(command: string[], options?: RunOptions): Promise<RunResult>;
59
+ abstract runSync(command: string[]): RunResult;
60
+ abstract attach(command: string[], options?: AttachOptions): Promise<number>;
61
+ abstract detach(command: string[], options?: DetachOptions): void;
62
+ abstract kill(pid: number, signal?: string): void;
63
+ abstract isAlive(pid: number): boolean;
64
+ abstract listProcessesContaining(marker: string): ProcessSnapshot[];
65
+ abstract getStartTime(pid: number): string | null;
66
+ }
67
+ //#endregion
68
+ //#region lib/engine/connectors/base-connector-config.d.ts
69
+ /**
70
+ * Fields every connector config carries, regardless of type. The discriminated
71
+ * union of concrete connector configs no longer lives in core: each connector
72
+ * type owns its full schema inside its descriptor, and core handles connectors
73
+ * through this base shape plus the injected registry. `type` is an open string
74
+ * here on purpose — core does not enumerate the known connector types.
75
+ */
76
+ declare const baseConnectorConfigSchema: z.ZodObject<{
77
+ id: z.ZodString;
78
+ name: z.ZodString;
79
+ type: z.ZodString;
80
+ createdAt: z.ZodOptional<z.ZodString>;
81
+ updatedAt: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>;
83
+ type BaseConnectorConfig = z.infer<typeof baseConnectorConfigSchema>;
84
+ //#endregion
85
+ //#region lib/engine/connectors/connector-adapter.d.ts
86
+ /**
87
+ * A JSON-serializable value. Connector call bodies are sent to external APIs as
88
+ * JSON, so the body must be representable as JSON — `JsonValue` says exactly
89
+ * that, replacing a bare `unknown` that let non-serializable values (functions,
90
+ * symbols, class instances) slip through to `JSON.stringify`.
91
+ */
92
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
93
+ [key: string]: JsonValue;
94
+ };
95
+ type CallInput = {
96
+ method: string;
97
+ path: string; /** JSON request body. Omit for GET-like calls. */
98
+ body?: JsonValue;
99
+ };
100
+ declare abstract class FunnelConnectorAdapter {
101
+ /**
102
+ * Dispatches one Claude → external call. The response is the external API's
103
+ * raw payload, typed `unknown` because its shape is the provider's concern —
104
+ * the caller (Claude, via MCP) interprets it.
105
+ */
106
+ abstract call(input: CallInput): Promise<unknown>;
107
+ }
108
+ //#endregion
16
109
  //#region lib/engine/connectors/connector-listener.d.ts
17
110
  type NotifyFn = (content: string, meta?: Record<string, string>) => Promise<void>;
18
111
  /**
@@ -32,7 +125,7 @@ declare abstract class FunnelConnectorListener {
32
125
  isAlive(): boolean;
33
126
  }
34
127
  //#endregion
35
- //#region lib/gateway/diagnostic-log/diagnostic-log.d.ts
128
+ //#region lib/engine/diagnostic-log/diagnostic-log.d.ts
36
129
  /**
37
130
  * Points in the listener's connection lifecycle. The single source of truth
38
131
  * for the value set: the `status` column schema, the `ConnectorConnectionStatus`
@@ -205,4 +298,67 @@ declare abstract class ConnectorDiagnosticLog {
205
298
  abstract close(): void;
206
299
  }
207
300
  //#endregion
208
- export { FunnelLogger as S, connectorConnectionEventSchema as _, ConnectorConnectionStatus as a, FunnelConnectorListener as b, 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, NotifyFn as x, connectorRawEventSchema as y };
301
+ //#region lib/engine/connectors/connector-descriptor.d.ts
302
+ /** Boundaries a listener needs, supplied by the registry at build time. */
303
+ type ConnectorListenerDeps = {
304
+ channelId: string;
305
+ fs: FunnelFileSystem;
306
+ process: FunnelProcessRunner;
307
+ logger?: FunnelLogger;
308
+ diagnosticLog?: ConnectorDiagnosticLog; /** Resolves the per-connector state directory (`<dir>/channels/<id>/connectors/<id>`). */
309
+ connectorDir: (channelId: string, connectorId: string) => string;
310
+ };
311
+ /** Boundaries an adapter needs. Adapters are channel-agnostic. */
312
+ type ConnectorAdapterDeps = {
313
+ fs: FunnelFileSystem;
314
+ process: FunnelProcessRunner;
315
+ logger?: FunnelLogger;
316
+ };
317
+ type ConnectorBuildContext = {
318
+ id: string;
319
+ now: string;
320
+ };
321
+ type ConnectorUpdateContext = {
322
+ now: string;
323
+ };
324
+ type ConnectorOperationContext = {
325
+ generateId: () => string;
326
+ now: string;
327
+ };
328
+ /**
329
+ * One named operation a connector type exposes beyond plain CRUD (e.g. schedule
330
+ * entry add/remove/list). Returns the next config and an arbitrary result; when
331
+ * the returned config is reference-equal to the input, the channels layer treats
332
+ * the call as a read and skips persistence.
333
+ */
334
+ type ConnectorOperation = (props: {
335
+ config: BaseConnectorConfig;
336
+ args: unknown;
337
+ context: ConnectorOperationContext;
338
+ }) => {
339
+ config: BaseConnectorConfig;
340
+ result: unknown;
341
+ };
342
+ /**
343
+ * Everything core needs to handle one connector type, without importing it. A
344
+ * descriptor accepts/returns `BaseConnectorConfig` at every boundary and parses
345
+ * to its concrete config internally (via `schema`), so the registry can hold a
346
+ * homogeneous `ConnectorDescriptor[]` with no variance gymnastics. Type-specific
347
+ * launch hooks (Slack `onAppCreated`, Schedule `onFired`) are closed over by the
348
+ * descriptor factory, not threaded through here. Each descriptor parses configs
349
+ * to its concrete shape internally (it owns its zod schema), so no schema is
350
+ * exposed here — that also sidesteps the variance trap of a `ZodType<Slack>`
351
+ * field declared as `ZodType<BaseConnectorConfig>`.
352
+ */
353
+ type ConnectorDescriptor = {
354
+ type: string;
355
+ createListener: (config: BaseConnectorConfig, deps: ConnectorListenerDeps) => FunnelConnectorListener;
356
+ createAdapter: ((config: BaseConnectorConfig, deps: ConnectorAdapterDeps) => FunnelConnectorAdapter) | null; /** Whether the MCP channel server exposes this type as a callable tool. */
357
+ toolExposed: boolean;
358
+ secretTokens: (config: BaseConnectorConfig) => string[];
359
+ buildConfig: (input: Record<string, unknown>, context: ConnectorBuildContext) => BaseConnectorConfig;
360
+ applyUpdate: (config: BaseConnectorConfig, fields: Record<string, unknown>, context: ConnectorUpdateContext) => BaseConnectorConfig;
361
+ operations: Record<string, ConnectorOperation>;
362
+ };
363
+ //#endregion
364
+ export { FunnelConnectorAdapter as A, FunnelLogger as B, StoredRawEvent as C, FunnelConnectorListener as D, connectorRawEventSchema as E, DetachOptions as F, FunnelProcessRunner as I, ProcessSnapshot as L, BaseConnectorConfig as M, baseConnectorConfigSchema as N, NotifyFn as O, AttachOptions as P, RunOptions as R, StoredProcessedEvent as S, connectorProcessedEventSchema as T, ConnectorQuery as _, ConnectorOperation as a, ConnectorRawRecord as b, CONNECTOR_CONNECTION_STATUSES as c, ConnectorConnectionRecord as d, ConnectorConnectionStatus as f, ConnectorProcessedRecord as g, ConnectorProcessedQuery as h, ConnectorListenerDeps as i, JsonValue as j, CallInput as k, ConnectorConnectionEvent as l, ConnectorProcessedEvent as m, ConnectorBuildContext as n, ConnectorOperationContext as o, ConnectorDiagnosticLog as p, ConnectorDescriptor as r, ConnectorUpdateContext as s, ConnectorAdapterDeps as t, ConnectorConnectionQuery as u, ConnectorRawEvent as v, connectorConnectionEventSchema as w, StoredConnectionEvent as x, ConnectorRawQuery as y, RunResult as z };
@@ -1,7 +1,26 @@
1
- import { S as FunnelLogger, b as FunnelConnectorListener, o as ConnectorDiagnosticLog, x as NotifyFn } from "../diagnostic-log-Cb3v8P7p.js";
2
- import { n as FunnelConnectorAdapter, t as CallInput } from "../connector-adapter-DGacCppE.js";
3
- import { n as discordConnectorSchema, r as FunnelHttpClient, t as DiscordConnectorConfig } from "../discord-connector-schema-CQyfDkLD.js";
1
+ import { A as FunnelConnectorAdapter, B as FunnelLogger, D as FunnelConnectorListener, O as NotifyFn, k as CallInput, p as ConnectorDiagnosticLog, r as ConnectorDescriptor } from "../connector-descriptor-6SXJoszo.js";
2
+ import { t as FunnelHttpClient } from "../http-client-oICicjuO.js";
3
+ import { z } from "zod";
4
4
 
5
+ //#region lib/engine/connectors/discord-connector-schema.d.ts
6
+ /**
7
+ * Like slack, a discord connector holds either a literal `botToken` or a
8
+ * `botTokenEnv` reference resolved from `process.env` at listener start. The
9
+ * reference form keeps the secret out of settings.json, but is only set through
10
+ * the engine API (`new Funnel(...)`); funnel.json and the `fnl` CLI produce
11
+ * literals.
12
+ */
13
+ declare const discordConnectorSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ name: z.ZodString;
16
+ type: z.ZodLiteral<"discord">;
17
+ botToken: z.ZodOptional<z.ZodString>;
18
+ botTokenEnv: z.ZodOptional<z.ZodString>;
19
+ createdAt: z.ZodOptional<z.ZodString>;
20
+ updatedAt: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>;
22
+ type DiscordConnectorConfig = z.infer<typeof discordConnectorSchema>;
23
+ //#endregion
5
24
  //#region lib/engine/connectors/discord-adapter.d.ts
6
25
  type Deps$1 = {
7
26
  config: DiscordConnectorConfig; /** Environment used to resolve a `botTokenEnv` reference. Defaults to process.env. */
@@ -15,6 +34,13 @@ declare class FunnelDiscordAdapter extends FunnelConnectorAdapter {
15
34
  call(input: CallInput): Promise<unknown>;
16
35
  }
17
36
  //#endregion
37
+ //#region lib/engine/connectors/discord-connector.d.ts
38
+ /**
39
+ * Discord connector descriptor. Pass `discordConnector()` to
40
+ * `new Funnel({ connectors: [...] })` to enable the type.
41
+ */
42
+ declare const discordConnector: () => ConnectorDescriptor;
43
+ //#endregion
18
44
  //#region lib/engine/connectors/discord-event-processor.d.ts
19
45
  type DiscordInboundMessage = {
20
46
  authorId: string;
@@ -66,4 +92,4 @@ declare class FunnelDiscordListener extends FunnelConnectorListener {
66
92
  private recordConnection;
67
93
  }
68
94
  //#endregion
69
- export { DiscordConnectorConfig, DiscordInboundMessage, DiscordProcessed, DiscordProcessedEmit, DiscordProcessedSkip, FunnelDiscordAdapter, FunnelDiscordEventProcessor, FunnelDiscordListener, discordConnectorSchema };
95
+ export { DiscordConnectorConfig, DiscordInboundMessage, DiscordProcessed, DiscordProcessedEmit, DiscordProcessedSkip, FunnelDiscordAdapter, FunnelDiscordEventProcessor, FunnelDiscordListener, discordConnector, discordConnectorSchema };
@@ -1,3 +1,3 @@
1
- import { n as FunnelDiscordEventProcessor, r as FunnelDiscordAdapter, t as FunnelDiscordListener } from "../discord-listener-CKsZGTnH.js";
2
1
  import { t as discordConnectorSchema } from "../discord-connector-schema-B_N6IXLz.js";
3
- export { FunnelDiscordAdapter, FunnelDiscordEventProcessor, FunnelDiscordListener, discordConnectorSchema };
2
+ import { i as FunnelDiscordAdapter, n as FunnelDiscordListener, r as FunnelDiscordEventProcessor, t as discordConnector } from "../discord-connector-BL36yvbL.js";
3
+ export { FunnelDiscordAdapter, FunnelDiscordEventProcessor, FunnelDiscordListener, discordConnector, discordConnectorSchema };
@@ -1,7 +1,5 @@
1
- import { S as FunnelLogger, b as FunnelConnectorListener, o as ConnectorDiagnosticLog, x as NotifyFn } from "../diagnostic-log-Cb3v8P7p.js";
2
- import { r as FunnelProcessRunner } from "../process-runner-DIm1cy95.js";
3
- import { n as FunnelConnectorAdapter, t as CallInput } from "../connector-adapter-DGacCppE.js";
4
- import { n as ghConnectorSchema, t as GhConnectorConfig } from "../gh-connector-schema-CZzwzvqY.js";
1
+ import { A as FunnelConnectorAdapter, B as FunnelLogger, D as FunnelConnectorListener, I as FunnelProcessRunner, O as NotifyFn, k as CallInput, p as ConnectorDiagnosticLog, r as ConnectorDescriptor } from "../connector-descriptor-6SXJoszo.js";
2
+ import { z } from "zod";
5
3
 
6
4
  //#region lib/engine/connectors/gh-adapter.d.ts
7
5
  type Deps$1 = {
@@ -13,6 +11,24 @@ declare class FunnelGhAdapter extends FunnelConnectorAdapter {
13
11
  call(input: CallInput): Promise<unknown>;
14
12
  }
15
13
  //#endregion
14
+ //#region lib/engine/connectors/gh-connector.d.ts
15
+ /**
16
+ * GitHub connector descriptor. Pass `ghConnector()` to
17
+ * `new Funnel({ connectors: [...] })` to enable the type.
18
+ */
19
+ declare const ghConnector: () => ConnectorDescriptor;
20
+ //#endregion
21
+ //#region lib/engine/connectors/gh-connector-schema.d.ts
22
+ declare const ghConnectorSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ name: z.ZodString;
25
+ type: z.ZodLiteral<"gh">;
26
+ pollInterval: z.ZodOptional<z.ZodNumber>;
27
+ createdAt: z.ZodOptional<z.ZodString>;
28
+ updatedAt: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strip>;
30
+ type GhConnectorConfig = z.infer<typeof ghConnectorSchema>;
31
+ //#endregion
16
32
  //#region lib/engine/connectors/gh-listener.d.ts
17
33
  type Deps = {
18
34
  config: GhConnectorConfig; /** Funnel channel uuid this connector lives under; stamped onto diagnostic-log rows. */
@@ -43,4 +59,4 @@ declare class FunnelGhListener extends FunnelConnectorListener {
43
59
  private recordConnection;
44
60
  }
45
61
  //#endregion
46
- export { FunnelGhAdapter, FunnelGhListener, GhConnectorConfig, ghConnectorSchema };
62
+ export { FunnelGhAdapter, FunnelGhListener, GhConnectorConfig, ghConnector, ghConnectorSchema };
@@ -1,3 +1,3 @@
1
- import { t as ghConnectorSchema } from "../gh-connector-schema-ClPLSYD9.js";
2
- import { n as FunnelGhAdapter, t as FunnelGhListener } from "../gh-listener-B2I4s8qh.js";
3
- export { FunnelGhAdapter, FunnelGhListener, ghConnectorSchema };
1
+ import { t as ghConnectorSchema } from "../gh-connector-schema-Rzwc1c1N.js";
2
+ import { n as FunnelGhListener, r as FunnelGhAdapter, t as ghConnector } from "../gh-connector-DpiixfQZ.js";
3
+ export { FunnelGhAdapter, FunnelGhListener, ghConnector, ghConnectorSchema };