@interactive-inc/claude-funnel 0.18.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -63,7 +63,7 @@ type SlackListenerOptions = {
63
63
  type ScheduleListenerOptions = {
64
64
  onFired?: ScheduleOnFired;
65
65
  };
66
- type Deps$15 = {
66
+ type Deps$16 = {
67
67
  fs?: FunnelFileSystem;
68
68
  process?: FunnelProcessRunner;
69
69
  logger?: FunnelLogger;
@@ -90,7 +90,7 @@ declare class FunnelConnectorFactory {
90
90
  private readonly dir;
91
91
  private readonly slackListenerOptions;
92
92
  private readonly scheduleListenerOptions;
93
- constructor(deps?: Deps$15);
93
+ constructor(deps?: Deps$16);
94
94
  createListener(channelId: string, config: ConnectorConfig): FunnelConnectorListener;
95
95
  createAdapter(config: ConnectorConfig): FunnelConnectorAdapter | null;
96
96
  connectorDir(channelId: string, connectorId: string): string;
@@ -152,6 +152,7 @@ declare const channelConfigSchema: z.ZodObject<{
152
152
  }>>;
153
153
  options: z.ZodDefault<z.ZodArray<z.ZodString>>;
154
154
  env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
155
+ resume: z.ZodDefault<z.ZodBoolean>;
155
156
  connectors: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
156
157
  id: z.ZodString;
157
158
  name: z.ZodString;
@@ -212,6 +213,7 @@ declare const settingsSchema: z.ZodObject<{
212
213
  }>>;
213
214
  options: z.ZodDefault<z.ZodArray<z.ZodString>>;
214
215
  env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
216
+ resume: z.ZodDefault<z.ZodBoolean>;
215
217
  connectors: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
216
218
  id: z.ZodString;
217
219
  name: z.ZodString;
@@ -268,7 +270,7 @@ declare abstract class FunnelSettingsReader {
268
270
  }
269
271
  //#endregion
270
272
  //#region lib/engine/channels/channels.d.ts
271
- type Deps$14 = {
273
+ type Deps$15 = {
272
274
  store: FunnelSettingsReader;
273
275
  factory: FunnelConnectorFactory;
274
276
  profileChecker: ProfileChannelChecker;
@@ -311,7 +313,7 @@ declare class FunnelChannels {
311
313
  private readonly profileChecker;
312
314
  private readonly clock;
313
315
  private readonly idGenerator;
314
- constructor(deps: Deps$14);
316
+ constructor(deps: Deps$15);
315
317
  list(): ChannelConfig[];
316
318
  get(name: string): ChannelConfig | null;
317
319
  getById(id: string): ChannelConfig | null;
@@ -320,8 +322,10 @@ declare class FunnelChannels {
320
322
  delivery?: ChannelDeliveryMode;
321
323
  options?: string[];
322
324
  env?: Record<string, string>;
325
+ resume?: boolean;
323
326
  }): ChannelConfig;
324
327
  setDelivery(name: string, delivery: ChannelDeliveryMode): void;
328
+ setResume(name: string, resume: boolean): void;
325
329
  setOptions(name: string, options: string[]): void;
326
330
  setEnv(name: string, env: Record<string, string>): void;
327
331
  remove(name: string): void;
@@ -373,7 +377,7 @@ type GatewayController = {
373
377
  //#region lib/engine/mcp/mcp.d.ts
374
378
  declare const FUNNEL_MCP_COMMAND = "funnel";
375
379
  declare const FUNNEL_MCP_NAME = "funnel";
376
- type Deps$13 = {
380
+ type Deps$14 = {
377
381
  fs?: FunnelFileSystem;
378
382
  };
379
383
  /**
@@ -383,7 +387,7 @@ type Deps$13 = {
383
387
  */
384
388
  declare class FunnelMcp {
385
389
  private readonly fs;
386
- constructor(deps?: Deps$13);
390
+ constructor(deps?: Deps$14);
387
391
  install(repoPath: string): void;
388
392
  uninstall(repoPath: string): void;
389
393
  findInstalledName(cwd: string): string | null;
@@ -392,6 +396,43 @@ declare class FunnelMcp {
392
396
  private writeConfig;
393
397
  }
394
398
  //#endregion
399
+ //#region lib/engine/sessions/sessions.d.ts
400
+ type Deps$13 = {
401
+ fs: FunnelFileSystem;
402
+ idGenerator: FunnelIdGenerator;
403
+ dir: string;
404
+ };
405
+ /**
406
+ * Per-channel persistent Claude Code session IDs, keyed by the cwd the
407
+ * channel was launched from. The whole point is to give each (channel, cwd)
408
+ * its own stable conversation: relaunching from the same path picks up the
409
+ * previous claude session via `--session-id <uuid>`, while a different cwd
410
+ * (or a different channel) gets an independent one — so sessions never
411
+ * silently bleed across workspaces the way claude's `-c` does.
412
+ *
413
+ * Storage lives under `<dir>/channels/<channel-id>/sessions.json` (channel
414
+ * id, not name, so renames don't lose history). The file is a flat
415
+ * `{ cwd: uuid }` map; the channel directory itself is created lazily.
416
+ */
417
+ declare class FunnelSessions {
418
+ private readonly fs;
419
+ private readonly idGenerator;
420
+ private readonly dir;
421
+ constructor(deps: Deps$13);
422
+ /** Returns the existing session id for (channelId, cwd) or generates and persists a new one. */
423
+ getOrCreate(channelId: string, cwd: string): string;
424
+ /** Returns the existing session id for (channelId, cwd) or null. */
425
+ get(channelId: string, cwd: string): string | null;
426
+ /** Drops the recorded session id for (channelId, cwd). No-op if absent. */
427
+ clear(channelId: string, cwd: string): void;
428
+ /** Drops the whole session map for the channel (e.g. when the channel is deleted). */
429
+ clearAll(channelId: string): void;
430
+ private readMap;
431
+ private writeMap;
432
+ private channelDir;
433
+ private pathFor;
434
+ }
435
+ //#endregion
395
436
  //#region lib/engine/claude/claude.d.ts
396
437
  type LaunchOptions = {
397
438
  channel: string;
@@ -402,11 +443,16 @@ type LaunchOptions = {
402
443
  * Useful for hosts that need to register the spawned process before it exits
403
444
  * (e.g. multi-session registries that track per-claude liveness). */
404
445
  onSpawned?: (pid: number) => void;
446
+ /** Whether to install the funnel MCP entry into `.mcp.json` (default: true).
447
+ * Set to false when the host already provides its own MCP server entry and
448
+ * does not need the funnel binary as an MCP endpoint. */
449
+ installMcp?: boolean;
405
450
  };
406
451
  type Deps$12 = {
407
452
  channels: FunnelChannels;
408
453
  mcp: FunnelMcp;
409
454
  gateway: GatewayController;
455
+ sessions: FunnelSessions;
410
456
  process?: FunnelProcessRunner;
411
457
  fs?: FunnelFileSystem;
412
458
  logger?: FunnelLogger;
@@ -422,6 +468,7 @@ declare class FunnelClaude {
422
468
  private readonly channels;
423
469
  private readonly mcp;
424
470
  private readonly gateway;
471
+ private readonly sessions;
425
472
  private readonly process;
426
473
  private readonly fs;
427
474
  private readonly logger;
@@ -436,6 +483,12 @@ declare class FunnelClaude {
436
483
  private installCleanup;
437
484
  private isProcessAlive;
438
485
  private buildArgs;
486
+ /**
487
+ * Decides whether funnel should inject `--session-id`. We back off when
488
+ * the user already passed a session-shaping flag, since combining them
489
+ * would either confuse claude or override the explicit user intent.
490
+ */
491
+ private resolveSessionId;
439
492
  private buildEnv;
440
493
  }
441
494
  //#endregion
@@ -485,6 +538,7 @@ declare const channelSpecSchema: z.ZodObject<{
485
538
  name: z.ZodString;
486
539
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
487
540
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
541
+ resume: z.ZodOptional<z.ZodBoolean>;
488
542
  connectors: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
489
543
  type: z.ZodLiteral<"slack">;
490
544
  name: z.ZodString;
@@ -517,6 +571,7 @@ declare const localConfigSchema: z.ZodObject<{
517
571
  name: z.ZodString;
518
572
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
519
573
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
574
+ resume: z.ZodOptional<z.ZodBoolean>;
520
575
  connectors: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
521
576
  type: z.ZodLiteral<"slack">;
522
577
  name: z.ZodString;
@@ -581,6 +636,14 @@ type Deps$9 = {
581
636
  prompter: FunnelTokenPrompter;
582
637
  env?: NodeJS.ProcessEnv;
583
638
  };
639
+ type ConnectorSyncOutcome = {
640
+ name: string;
641
+ changed: boolean;
642
+ };
643
+ type LocalConfigSyncResult = {
644
+ touched: ConnectorSyncOutcome[];
645
+ removed: string[];
646
+ };
584
647
  /**
585
648
  * Reconciles a single funnel.json channel spec with `~/.funnel/settings.json`.
586
649
  * The spec is the source of truth for the channel it declares:
@@ -596,6 +659,9 @@ type Deps$9 = {
596
659
  * absent field means "do not manage connectors from here" and leaves
597
660
  * everything in `~/.funnel` alone. Other channels in funnel.json (not
598
661
  * passed to this call) are untouched.
662
+ *
663
+ * Returns the per-connector change set so callers (e.g. the claude launcher)
664
+ * can drive listener hot-reload on the gateway after settings are written.
599
665
  */
600
666
  declare class FunnelLocalConfigSync {
601
667
  private readonly channels;
@@ -603,7 +669,7 @@ declare class FunnelLocalConfigSync {
603
669
  private readonly prompter;
604
670
  private readonly env;
605
671
  constructor(deps: Deps$9);
606
- ensure(channel: ChannelSpec, cwd: string): Promise<void>;
672
+ ensure(channel: ChannelSpec, cwd: string): Promise<LocalConfigSyncResult>;
607
673
  private ensureConnector;
608
674
  private ensureSlack;
609
675
  private ensureDiscord;
@@ -1311,6 +1377,8 @@ declare class Funnel {
1311
1377
  get channels(): FunnelChannels;
1312
1378
  /** Launch profiles (named presets for `fnl claude`: path + sub-agent + channel id). */
1313
1379
  get profiles(): FunnelProfiles;
1380
+ /** Per-(channel, cwd) claude session-id store. Backs `--session-id` injection on launch. */
1381
+ get sessions(): FunnelSessions;
1314
1382
  /** Reads `funnel.json` from a cwd. `fnl claude` consults it before falling back to the default profile. */
1315
1383
  get localConfig(): FunnelLocalConfig;
1316
1384
  /** Parses `.env.local` from a cwd (used by sync to back $VAR references). */
@@ -4195,4 +4263,4 @@ ${string}`;
4195
4263
  //#region lib/tui/tui.d.ts
4196
4264
  declare function launchTui(funnel: Funnel): Promise<void>;
4197
4265
  //#endregion
4198
- export { AttachOptions, BroadcastEvent, BroadcastSubscriber, ChannelConfig, ChannelConnectorView, ChannelDeliveryMode, ChannelServerOptions, ChannelSpec, ConnectorConfig, ConnectorSpec, ConnectorType, DEFAULT_GATEWAY_TOKEN_PATH, DetachOptions, DiscordConnectorConfig, Env, FUNNEL_DIR, FUNNEL_MCP_COMMAND, FUNNEL_MCP_NAME, FileStat, Funnel, FunnelBroadcaster, FunnelChannelPublisher, FunnelChannels, FunnelClaude, FunnelClock, FunnelConnectorFactory, FunnelConnectorListener, FunnelDotenvReader, FunnelEvent, FunnelEventStore, FunnelFileSystem, FunnelGateway, FunnelGatewayServer, FunnelGatewayToken, FunnelIdGenerator, FunnelListenerSupervisor, FunnelListenersClient, FunnelLocalConfig, FunnelLocalConfigSync, FunnelLogger, FunnelMcp, FunnelProcessRunner, FunnelProfiles, FunnelSettingsReader, FunnelSettingsStore, FunnelSlackEventProcessor, FunnelTokenPrompter, type GatewayEmitInput, type GatewayRouteDeps, type Env$1 as GatewayServerEnv, GhConnectorConfig, LOCAL_CONFIG_FILENAME, LOCAL_ENV_FILENAME, LaunchOptions, ListListenersResult, ListenerEntry, ListenerOpResult, LocalConfig, LogEntry, MemoryFunnelClock, MemoryFunnelFileSystem, MemoryFunnelIdGenerator, MemoryFunnelLogger, MemoryFunnelProcessRunner, MemoryFunnelTokenPrompter, MemoryProcessCall, MemoryProcessHandler, MemoryProcessResponse, MemoryProcessSyncHandler, MockFunnelSettingsReader, NodeFunnelClock, NodeFunnelFileSystem, NodeFunnelIdGenerator, NodeFunnelLogger, NodeFunnelProcessRunner, NodeFunnelTokenPrompter, NoopFunnelLogger, NotifyFn, ProfileConfig, PublishRequest, PublishResponse, PublishResult, ReplayableEvent, RunOptions, RunResult, SETTINGS_PATH, SETTINGS_VERSION, ScheduleCatchupPolicy, ScheduleConnectorConfig, ScheduleEntry, ScheduleListenerOptions, Settings, SlackConnectorConfig, SlackListenerOptions, SlackProcessed, SlackProcessedEmit, SlackProcessedSkip, SlackRawEvent, channelConfigSchema, channelDeliveryModeSchema, channelSpecSchema, app as cliApp, connectorConfigSchema, connectorSpecSchema, createCliApp, createSettings, discordConnectorSchema, factory, funnelEventSchema, funnelJsonSchema, ghConnectorSchema, launchTui, localConfigSchema, profileConfigSchema, publishRequestSchema, publishResponseSchema, queryToCliArgs, scheduleCatchupPolicySchema, scheduleConnectorSchema, scheduleEntrySchema, settingsSchema, slackConnectorSchema, startChannelServer, toRequest };
4266
+ export { AttachOptions, BroadcastEvent, BroadcastSubscriber, ChannelConfig, ChannelConnectorView, ChannelDeliveryMode, ChannelServerOptions, ChannelSpec, ConnectorConfig, ConnectorSpec, ConnectorSyncOutcome, ConnectorType, DEFAULT_GATEWAY_TOKEN_PATH, DetachOptions, DiscordConnectorConfig, Env, FUNNEL_DIR, FUNNEL_MCP_COMMAND, FUNNEL_MCP_NAME, FileStat, Funnel, FunnelBroadcaster, FunnelChannelPublisher, FunnelChannels, FunnelClaude, FunnelClock, FunnelConnectorFactory, FunnelConnectorListener, FunnelDotenvReader, FunnelEvent, FunnelEventStore, FunnelFileSystem, FunnelGateway, FunnelGatewayServer, FunnelGatewayToken, FunnelIdGenerator, FunnelListenerSupervisor, FunnelListenersClient, FunnelLocalConfig, FunnelLocalConfigSync, FunnelLogger, FunnelMcp, FunnelProcessRunner, FunnelProfiles, FunnelSessions, FunnelSettingsReader, FunnelSettingsStore, FunnelSlackEventProcessor, FunnelTokenPrompter, type GatewayEmitInput, type GatewayRouteDeps, type Env$1 as GatewayServerEnv, GhConnectorConfig, LOCAL_CONFIG_FILENAME, LOCAL_ENV_FILENAME, LaunchOptions, ListListenersResult, ListenerEntry, ListenerOpResult, LocalConfig, LocalConfigSyncResult, LogEntry, MemoryFunnelClock, MemoryFunnelFileSystem, MemoryFunnelIdGenerator, MemoryFunnelLogger, MemoryFunnelProcessRunner, MemoryFunnelTokenPrompter, MemoryProcessCall, MemoryProcessHandler, MemoryProcessResponse, MemoryProcessSyncHandler, MockFunnelSettingsReader, NodeFunnelClock, NodeFunnelFileSystem, NodeFunnelIdGenerator, NodeFunnelLogger, NodeFunnelProcessRunner, NodeFunnelTokenPrompter, NoopFunnelLogger, NotifyFn, ProfileConfig, PublishRequest, PublishResponse, PublishResult, ReplayableEvent, RunOptions, RunResult, SETTINGS_PATH, SETTINGS_VERSION, ScheduleCatchupPolicy, ScheduleConnectorConfig, ScheduleEntry, ScheduleListenerOptions, Settings, SlackConnectorConfig, SlackListenerOptions, SlackProcessed, SlackProcessedEmit, SlackProcessedSkip, SlackRawEvent, channelConfigSchema, channelDeliveryModeSchema, channelSpecSchema, app as cliApp, connectorConfigSchema, connectorSpecSchema, createCliApp, createSettings, discordConnectorSchema, factory, funnelEventSchema, funnelJsonSchema, ghConnectorSchema, launchTui, localConfigSchema, profileConfigSchema, publishRequestSchema, publishResponseSchema, queryToCliArgs, scheduleCatchupPolicySchema, scheduleConnectorSchema, scheduleEntrySchema, settingsSchema, slackConnectorSchema, startChannelServer, toRequest };