@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
@@ -3,7 +3,7 @@ import { t as errorMessageOf } from "./error-message-of-BG4ezZ_s.js";
3
3
  import { t as discordConnectorSchema } from "./discord-connector-schema-saAGuPmJ.js";
4
4
  import { t as FunnelConnectorAdapter } from "./connector-adapter-BL2ehMej.js";
5
5
  import { t as resolveConnectorToken } from "./resolve-connector-token-BwiJCu82.js";
6
- import { i as resolveFlumeDeps, n as FunnelFlumeSourceListener, r as flumeLogHandler, t as slotFields } from "./slot-fields-5ERhytIA.js";
6
+ import { i as resolveFlumeDeps, n as FunnelFlumeSourceListener, r as flumeLogHandler, t as slotFields } from "./slot-fields-eCWizJqS.js";
7
7
  import { FlumeDiscordGatewayIntents, FlumeDiscordSource } from "@interactive-inc/flume/discord";
8
8
  //#region lib/engine/connectors/discord-adapter.ts
9
9
  const DISCORD_API_BASE = "https://discord.com/api/v10";
package/dist/docs.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as FunnelDocs } from "./funnel-docs-BFcqITFA.js";
1
+ import { t as FunnelDocs } from "./funnel-docs-CI4hMkhq.js";
2
2
  export { FunnelDocs };
package/dist/doctor.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as DoctorReport, r as FunnelDoctor, t as DoctorFixMode } from "./funnel-doctor-CviUTINw.js";
1
+ import { n as DoctorReport, r as FunnelDoctor, t as DoctorFixMode } from "./funnel-doctor-CY4S5cnz.js";
2
2
  export { DoctorFixMode, DoctorReport, FunnelDoctor };
@@ -0,0 +1,2 @@
1
+ import { a as MemoryEventLogProps, c as EventLogValidator, d as EventLogEntry, i as MemoryEventLog, l as EventLogRelay, n as SqliteEventLogProps, o as EventLog, r as SqliteEventLogQuery, s as EventLogProps, t as SqliteEventLog, u as EventLogStore } from "./sqlite-event-log-BYgCFMxC.js";
2
+ export { EventLog, EventLogEntry, EventLogProps, EventLogRelay, EventLogStore, EventLogValidator, MemoryEventLog, MemoryEventLogProps, SqliteEventLog, SqliteEventLogProps, SqliteEventLogQuery };
@@ -0,0 +1,3 @@
1
+ import { t as SqliteEventLog } from "./sqlite-event-log-eZuXKszJ.js";
2
+ import { n as EventLog, t as MemoryEventLog } from "./memory-event-log-BY8XjFzi.js";
3
+ export { EventLog, MemoryEventLog, SqliteEventLog };
@@ -2,7 +2,7 @@ import { t as FunnelLogger } from "./logger-mMZvblTx.js";
2
2
  import { n as FunnelFileSystem } from "./file-system-BNtl997T.js";
3
3
  import { t as ChannelConfig } from "./settings-schema-B-CKLuST.js";
4
4
  import { n as FunnelIdGenerator } from "./settings-reader-CyTpbAre.js";
5
- import { z as FunnelProcessRunner } from "./connector-descriptor-F75ZI8Fh.js";
5
+ import { b as FunnelProcessRunner } from "./connector-descriptor-D4XtEsH8.js";
6
6
  //#region lib/engine/claude/channel-resolver.d.ts
7
7
  type ChannelResolver = {
8
8
  get(name: string): ChannelConfig | null;
@@ -1,5 +1,6 @@
1
1
  import { t as FunnelLogger } from "./logger-mMZvblTx.js";
2
- import { A as FunnelConnectorListener, g as ConnectorDiagnosticLog, h as ConnectorConnectionStatus } from "./connector-descriptor-F75ZI8Fh.js";
2
+ import { d as FunnelConnectorListener } from "./connector-descriptor-D4XtEsH8.js";
3
+ import { a as ConnectorConnectionStatus, o as ConnectorDiagnosticLog } from "./diagnostic-log-BsAg5qZK.js";
3
4
  import { FlumeEventHandler, FlumeLogHandler, FlumeReconnectOptions, FlumeRunning, FlumeRuntimeDeps, FlumeSource, FlumeStatus } from "@interactive-inc/flume";
4
5
  //#region lib/engine/connectors/connector-diagnostics-recorder.d.ts
5
6
  type Props$1 = {
@@ -1,58 +1,8 @@
1
1
  import { n as gatewayLoopbackUrl, t as loopbackFetch } from "./loopback-fetch-HP-bo9Kv.js";
2
2
  import { t as errorMessageOf } from "./error-message-of-BG4ezZ_s.js";
3
- import { t as ConnectorDiagnosticSqlReader } from "./diagnostic-sql-reader-CoBk_EFF.js";
3
+ import { n as diagnosticEventOfProcessed, r as diagnosticEventOfRaw, t as diagnosticConnectionEventOf } from "./diagnostic-event-CxMM5Bl2.js";
4
4
  import { join } from "node:path";
5
5
  import { existsSync, readFileSync } from "node:fs";
6
- //#region lib/services/diagnostics/diagnostic-event.ts
7
- const stringOrNull = (value) => typeof value === "string" && value.length > 0 ? value : null;
8
- const numberOrNull = (value) => typeof value === "number" ? value : null;
9
- const stringOr = (value, fallback) => typeof value === "string" ? value : fallback;
10
- const isStringKeyedObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
11
- const parsePayloadObject = (payload) => {
12
- if (payload === null) return null;
13
- try {
14
- const parsed = JSON.parse(payload);
15
- if (isStringKeyedObject(parsed)) return parsed;
16
- } catch {
17
- return null;
18
- }
19
- return null;
20
- };
21
- const truncate = (text, max) => text.length <= max ? text : `${text.slice(0, max)}…`;
22
- const previewOf = (payload) => {
23
- if (typeof payload !== "string" || payload.length === 0) return null;
24
- const parsed = parsePayloadObject(payload);
25
- if (parsed !== null && "text" in parsed) return truncate(String(parsed.text), 60);
26
- return truncate(payload, 60);
27
- };
28
- const toDiagnosticEvent = (row) => {
29
- const payload = stringOrNull(row.payload);
30
- return {
31
- seq: numberOrNull(row.seq),
32
- ts: numberOrNull(row.ts),
33
- type: stringOr(row.type, "?"),
34
- outcome: stringOr(row.outcome, "?"),
35
- eventId: stringOrNull(row.event_id),
36
- payload,
37
- payloadParsed: parsePayloadObject(payload),
38
- preview: previewOf(row.payload)
39
- };
40
- };
41
- const toDiagnosticConnectionError = (row) => ({
42
- seq: numberOrNull(row.seq),
43
- ts: numberOrNull(row.ts),
44
- type: stringOr(row.type, "?"),
45
- status: stringOr(row.status, "?"),
46
- detail: stringOrNull(row.detail)
47
- });
48
- const queryRows = (reader, sql, params) => {
49
- try {
50
- return reader.query(sql, params);
51
- } finally {
52
- reader.close();
53
- }
54
- };
55
- //#endregion
56
6
  //#region lib/services/diagnostics/funnel-diagnostics.ts
57
7
  const isGatewayStatusResponse = (value) => {
58
8
  if (value === null || typeof value !== "object") return false;
@@ -174,14 +124,12 @@ var FunnelDiagnostics = class {
174
124
  const target = channelName ? channels.find((ch) => ch.name === channelName) ?? null : channels[0] ?? null;
175
125
  if (!target) return null;
176
126
  const gatewayProbe = await this.fetchGatewayStatus();
177
- const store = this.resolveStore();
178
- return this.buildChannelDiagnosis(target, gatewayProbe, store, 5);
127
+ return this.buildChannelDiagnosis(target, gatewayProbe, 5);
179
128
  }
180
129
  async diagnoseAll() {
181
130
  const channels = this.props.channels.list();
182
131
  const gatewayProbe = await this.fetchGatewayStatus();
183
- const store = this.resolveStore();
184
- const reports = await Promise.all(channels.map((ch) => this.buildChannelDiagnosis(ch, gatewayProbe, store, 5)));
132
+ const reports = await Promise.all(channels.map((ch) => this.buildChannelDiagnosis(ch, gatewayProbe, 5)));
185
133
  const errorChannels = reports.filter((r) => r.diagnosis.status === "error").map((r) => r.channel);
186
134
  const warnChannels = reports.filter((r) => r.diagnosis.status === "warn").map((r) => r.channel);
187
135
  const okChannels = reports.filter((r) => r.diagnosis.status === "ok").map((r) => r.channel);
@@ -201,20 +149,22 @@ var FunnelDiagnostics = class {
201
149
  }
202
150
  async recentEvents(channelName, options = {}) {
203
151
  const limit = options.limit ?? 20;
204
- const ids = this.resolveScope(channelName, options.connector);
205
- if (ids === null) return [];
206
- const rows = queryRows(new ConnectorDiagnosticSqlReader(ids.store), `SELECT seq, ts, type, outcome, payload, event_id FROM processed ${ids.whereClause} ORDER BY seq DESC LIMIT ?`, [...ids.params, limit]);
207
- if (rows instanceof Error) return [];
208
- return rows.reverse().map(toDiagnosticEvent);
152
+ const scope = this.resolveScope(channelName, options.connector);
153
+ if (scope === null) return [];
154
+ return this.queryLog((log) => log.queryProcessed({
155
+ ...scope,
156
+ limit
157
+ })).map(diagnosticEventOfProcessed);
209
158
  }
210
159
  async droppedEvents(channelName, options = {}) {
211
160
  const limit = options.limit ?? 20;
212
- const ids = this.resolveScope(channelName, options.connector);
213
- if (ids === null) return [];
214
- const where = ids.whereClause ? `${ids.whereClause} AND outcome LIKE 'skip:%'` : "WHERE outcome LIKE 'skip:%'";
215
- const rows = queryRows(new ConnectorDiagnosticSqlReader(ids.store), `SELECT seq, ts, type, outcome, payload, event_id FROM processed ${where} ORDER BY seq DESC LIMIT ?`, [...ids.params, limit]);
216
- if (rows instanceof Error) return [];
217
- return rows.reverse().map(toDiagnosticEvent);
161
+ const scope = this.resolveScope(channelName, options.connector);
162
+ if (scope === null) return [];
163
+ return this.queryLog((log) => log.queryProcessed({
164
+ ...scope,
165
+ outcomePrefix: "skip:",
166
+ limit
167
+ })).map(diagnosticEventOfProcessed);
218
168
  }
219
169
  /**
220
170
  * Raw inbound rows the connector recorded before any processing. The most
@@ -224,20 +174,22 @@ var FunnelDiagnostics = class {
224
174
  */
225
175
  async rawEvents(channelName, options = {}) {
226
176
  const limit = options.limit ?? 20;
227
- const ids = this.resolveScope(channelName, options.connector);
228
- if (ids === null) return [];
229
- const rows = queryRows(new ConnectorDiagnosticSqlReader(ids.store), `SELECT seq, ts, type, '' AS outcome, payload, event_id FROM raw ${ids.whereClause} ORDER BY seq DESC LIMIT ?`, [...ids.params, limit]);
230
- if (rows instanceof Error) return [];
231
- return rows.reverse().map(toDiagnosticEvent);
177
+ const scope = this.resolveScope(channelName, options.connector);
178
+ if (scope === null) return [];
179
+ return this.queryLog((log) => log.queryRaw({
180
+ ...scope,
181
+ limit
182
+ })).map(diagnosticEventOfRaw);
232
183
  }
233
184
  async connectionErrors(channelName, options = {}) {
234
185
  const limit = options.limit ?? 20;
235
- const ids = this.resolveScope(channelName, options.connector);
236
- if (ids === null) return [];
237
- const where = ids.whereClause ? `${ids.whereClause} AND status IN ('auth-failed','error')` : "WHERE status IN ('auth-failed','error')";
238
- const rows = queryRows(new ConnectorDiagnosticSqlReader(ids.store), `SELECT seq, ts, type, status, detail FROM connection ${where} ORDER BY seq DESC LIMIT ?`, [...ids.params, limit]);
239
- if (rows instanceof Error) return [];
240
- return rows.reverse().map(toDiagnosticConnectionError);
186
+ const scope = this.resolveScope(channelName, options.connector);
187
+ if (scope === null) return [];
188
+ return this.queryLog((log) => log.queryConnection({
189
+ ...scope,
190
+ statuses: ["auth-failed", "error"],
191
+ limit
192
+ })).map(diagnosticConnectionEventOf);
241
193
  }
242
194
  /**
243
195
  * Full connection lifecycle for one channel/connector — started, connected,
@@ -248,11 +200,12 @@ var FunnelDiagnostics = class {
248
200
  */
249
201
  async connectionTimeline(channelName, options = {}) {
250
202
  const limit = options.limit ?? 20;
251
- const ids = this.resolveScope(channelName, options.connector);
252
- if (ids === null) return [];
253
- const rows = queryRows(new ConnectorDiagnosticSqlReader(ids.store), `SELECT seq, ts, type, status, detail FROM connection ${ids.whereClause} ORDER BY seq DESC LIMIT ?`, [...ids.params, limit]);
254
- if (rows instanceof Error) return [];
255
- return rows.reverse().map(toDiagnosticConnectionError);
203
+ const scope = this.resolveScope(channelName, options.connector);
204
+ if (scope === null) return [];
205
+ return this.queryLog((log) => log.queryConnection({
206
+ ...scope,
207
+ limit
208
+ })).map(diagnosticConnectionEventOf);
256
209
  }
257
210
  /**
258
211
  * Tail of `~/.funnel/.../funnel.log`. Use when a flume internal log (e.g.
@@ -293,28 +246,30 @@ var FunnelDiagnostics = class {
293
246
  async replay(channelName, seq) {
294
247
  const channel = this.props.channels.list().find((ch) => ch.name === channelName);
295
248
  if (!channel) return { state: "not-found" };
296
- const store = this.resolveStore();
297
- if (!store) return {
249
+ if (!this.props.diagnosticLog) return {
298
250
  state: "error",
299
- reason: "no diagnostic store yet"
251
+ reason: "no diagnostic log configured"
300
252
  };
301
- const reader = new ConnectorDiagnosticSqlReader(store);
302
- const rows = seq !== void 0 ? queryRows(reader, "SELECT seq, event_id, type, payload, connector_id, channel_id FROM processed WHERE channel_id = ? AND seq = ? LIMIT 1", [channel.id, seq]) : queryRows(reader, "SELECT seq, event_id, type, payload, connector_id, channel_id FROM processed WHERE channel_id = ? AND outcome LIKE 'emitted%' ORDER BY seq DESC LIMIT 1", [channel.id]);
253
+ const rows = this.queryLogResult((log) => log.queryProcessed({
254
+ channelId: channel.id,
255
+ ...seq !== void 0 ? { seq } : { outcomePrefix: "emitted" },
256
+ limit: 1
257
+ }));
303
258
  if (rows instanceof Error) return {
304
259
  state: "error",
305
260
  reason: rows.message
306
261
  };
307
262
  const firstRow = rows[0];
308
263
  if (!firstRow) return { state: "not-found" };
309
- const replaySeq = typeof firstRow.seq === "number" ? firstRow.seq : null;
310
- const eventId = typeof firstRow.event_id === "string" ? firstRow.event_id : null;
311
- const connectorId = typeof firstRow.connector_id === "string" ? firstRow.connector_id : null;
312
- let content = typeof firstRow.payload === "string" ? firstRow.payload : null;
313
- if ((!content || content.length === 0) && eventId) {
314
- const rawRows = queryRows(new ConnectorDiagnosticSqlReader(store), "SELECT payload FROM raw WHERE event_id = ? LIMIT 1", [eventId]);
315
- const rawRow = rawRows instanceof Error ? null : rawRows[0];
316
- if (rawRow) content = typeof rawRow.payload === "string" ? rawRow.payload : null;
317
- }
264
+ const replaySeq = firstRow.seq;
265
+ const eventId = firstRow.eventId;
266
+ const connectorId = firstRow.connectorId;
267
+ const processedContent = firstRow.payload.length > 0 ? firstRow.payload : null;
268
+ const rawContent = processedContent === null ? this.queryLog((log) => log.queryRaw({
269
+ eventId,
270
+ limit: 1
271
+ }))[0]?.payload ?? null : null;
272
+ const content = processedContent ?? rawContent;
318
273
  if (!content) return {
319
274
  state: "error",
320
275
  reason: "event has no payload to replay"
@@ -336,52 +291,35 @@ var FunnelDiagnostics = class {
336
291
  preview: content.slice(0, 60)
337
292
  };
338
293
  }
339
- resolveStore() {
340
- const tmpDir = this.props.tmpDir;
341
- const rawPath = join(tmpDir, "connector-raw.db");
342
- const processedPath = join(tmpDir, "connector-processed.db");
343
- const connectionPath = join(tmpDir, "connector-connection.db");
344
- if (!existsSync(rawPath) || !existsSync(processedPath) || !existsSync(connectionPath)) return null;
345
- return {
346
- rawPath,
347
- processedPath,
348
- connectionPath
349
- };
350
- }
351
- resolveChannelId(channelName) {
352
- if (!channelName) return null;
353
- return this.props.channels.list().find((ch) => ch.name === channelName)?.id ?? null;
354
- }
355
294
  /**
356
- * Resolves a (channel, connector) filter into the SQL where-clause + the
357
- * positional params, or returns `null` when the requested scope cannot be
358
- * resolved (channel not found, connector not found in that channel, no
359
- * store on disk yet). Centralises the channel/connector → id mapping so
360
- * each read method does not redo the lookup.
295
+ * Resolves human-facing channel/connector names into the stable ids stored
296
+ * by the diagnostic log. Connector names are only unique inside a channel.
361
297
  */
362
298
  resolveScope(channelName, connectorName) {
363
- const store = this.resolveStore();
364
- if (!store) return null;
365
- if (!channelName) return {
366
- store,
367
- whereClause: "",
368
- params: []
369
- };
299
+ if (!channelName) return {};
370
300
  const channel = this.props.channels.list().find((ch) => ch.name === channelName) ?? null;
371
301
  if (!channel) return null;
372
- if (!connectorName) return {
373
- store,
374
- whereClause: "WHERE channel_id = ?",
375
- params: [channel.id]
376
- };
302
+ if (!connectorName) return { channelId: channel.id };
377
303
  const connectorId = channel.connectors?.find((c) => c.name === connectorName)?.id ?? null;
378
304
  if (!connectorId) return null;
379
305
  return {
380
- store,
381
- whereClause: "WHERE channel_id = ? AND connector_id = ?",
382
- params: [channel.id, connectorId]
306
+ channelId: channel.id,
307
+ connectorId
383
308
  };
384
309
  }
310
+ queryLog(query) {
311
+ const result = this.queryLogResult(query);
312
+ return result instanceof Error ? [] : result;
313
+ }
314
+ queryLogResult(query) {
315
+ const log = this.props.diagnosticLog;
316
+ if (!log) return /* @__PURE__ */ new Error("no diagnostic log configured");
317
+ try {
318
+ return query(log);
319
+ } catch (error) {
320
+ return new Error(errorMessageOf(error));
321
+ }
322
+ }
385
323
  async fetchGatewayStatus() {
386
324
  const gatewayStatus = this.props.gateway.getStatus();
387
325
  if (!gatewayStatus.running) return {
@@ -421,7 +359,7 @@ var FunnelDiagnostics = class {
421
359
  error: null
422
360
  };
423
361
  }
424
- async buildChannelDiagnosis(target, gatewayProbe, store, eventLimit) {
362
+ async buildChannelDiagnosis(target, gatewayProbe, eventLimit) {
425
363
  const gatewayStatus = this.props.gateway.getStatus();
426
364
  const targetName = target.name;
427
365
  const gatewayBody = gatewayProbe.body;
@@ -452,11 +390,16 @@ var FunnelDiagnostics = class {
452
390
  }));
453
391
  baseReport.claudeClients = gatewayBody.clients.filter((cl) => cl.channelName === targetName).length;
454
392
  }
455
- if (store) {
456
- const evRows = queryRows(new ConnectorDiagnosticSqlReader(store), "SELECT seq, ts, type, outcome, payload FROM processed WHERE channel_id = ? ORDER BY seq DESC LIMIT ?", [target.id, eventLimit]);
457
- if (!(evRows instanceof Error)) baseReport.recentEvents = evRows.reverse().map(toDiagnosticEvent);
458
- const errRows = queryRows(new ConnectorDiagnosticSqlReader(store), "SELECT ts, type, status, detail FROM connection WHERE channel_id = ? AND status IN ('auth-failed','error') ORDER BY seq DESC LIMIT 3", [target.id]);
459
- if (!(errRows instanceof Error)) baseReport.connectionErrors = errRows.reverse().map(toDiagnosticConnectionError);
393
+ if (this.props.diagnosticLog) {
394
+ baseReport.recentEvents = this.queryLog((log) => log.queryProcessed({
395
+ channelId: target.id,
396
+ limit: eventLimit
397
+ })).map(diagnosticEventOfProcessed);
398
+ baseReport.connectionErrors = this.queryLog((log) => log.queryConnection({
399
+ channelId: target.id,
400
+ statuses: ["auth-failed", "error"],
401
+ limit: 3
402
+ })).map(diagnosticConnectionEventOf);
460
403
  }
461
404
  return {
462
405
  ...baseReport,
@@ -465,4 +408,4 @@ var FunnelDiagnostics = class {
465
408
  }
466
409
  };
467
410
  //#endregion
468
- export { toDiagnosticEvent as a, toDiagnosticConnectionError as i, previewOf as n, queryRows as r, FunnelDiagnostics as t };
411
+ export { FunnelDiagnostics as t };
@@ -1,4 +1,5 @@
1
1
  import { t as ChannelConfig } from "./settings-schema-B-CKLuST.js";
2
+ import { g as StoredRawEvent, h as StoredProcessedEvent, m as StoredConnectionEvent, o as ConnectorDiagnosticLog } from "./diagnostic-log-BsAg5qZK.js";
2
3
  //#region lib/engine/diagnostic-log/diagnostic-sql-reader.d.ts
3
4
  type Props$1 = {
4
5
  /** SQLite file holding the raw (pre-filter) table. */
@@ -56,6 +57,9 @@ type DiagnosticConnectionError = {
56
57
  declare const previewOf: (payload: unknown) => string | null;
57
58
  declare const toDiagnosticEvent: (row: Record<string, unknown>) => DiagnosticEvent;
58
59
  declare const toDiagnosticConnectionError: (row: Record<string, unknown>) => DiagnosticConnectionError;
60
+ declare const diagnosticEventOfProcessed: (event: StoredProcessedEvent) => DiagnosticEvent;
61
+ declare const diagnosticEventOfRaw: (event: StoredRawEvent) => DiagnosticEvent;
62
+ declare const diagnosticConnectionEventOf: (event: StoredConnectionEvent) => DiagnosticConnectionError;
59
63
  declare const queryRows: (reader: ConnectorDiagnosticSqlReader, sql: string, params: (string | number | null)[]) => Record<string, unknown>[] | Error;
60
64
  //#endregion
61
65
  //#region lib/services/diagnostics/funnel-diagnostics.d.ts
@@ -95,6 +99,7 @@ type Props = {
95
99
  gatewayToken: DiagnosticsTokenReader;
96
100
  channels: DiagnosticsChannelSource;
97
101
  publisher: DiagnosticsPublisher;
102
+ diagnosticLog?: ConnectorDiagnosticLog;
98
103
  tmpDir: string;
99
104
  };
100
105
  type DiagnosisStatus = "ok" | "warn" | "error";
@@ -159,11 +164,6 @@ type ReplayResult = {
159
164
  } | {
160
165
  state: "not-found";
161
166
  };
162
- type StorePaths = {
163
- rawPath: string;
164
- processedPath: string;
165
- connectionPath: string;
166
- };
167
167
  /**
168
168
  * Programmable diagnostics surface — used by both the CLI (fnl debug …) and
169
169
  * the MCP tools (fnl_debug, fnl_recent_events, …). Pure read-side, no
@@ -224,18 +224,15 @@ declare class FunnelDiagnostics {
224
224
  truncated: boolean;
225
225
  }>;
226
226
  replay(channelName: string, seq?: number): Promise<ReplayResult>;
227
- resolveStore(): StorePaths | null;
228
- private resolveChannelId;
229
227
  /**
230
- * Resolves a (channel, connector) filter into the SQL where-clause + the
231
- * positional params, or returns `null` when the requested scope cannot be
232
- * resolved (channel not found, connector not found in that channel, no
233
- * store on disk yet). Centralises the channel/connector → id mapping so
234
- * each read method does not redo the lookup.
228
+ * Resolves human-facing channel/connector names into the stable ids stored
229
+ * by the diagnostic log. Connector names are only unique inside a channel.
235
230
  */
236
231
  private resolveScope;
232
+ private queryLog;
233
+ private queryLogResult;
237
234
  private fetchGatewayStatus;
238
235
  private buildChannelDiagnosis;
239
236
  }
240
237
  //#endregion
241
- export { DiagnosticsGatewayProbe as a, FunnelDiagnostics as c, DiagnosticEvent as d, previewOf as f, ConnectorDiagnosticSqlReader as g, toDiagnosticEvent as h, DiagnosticsChannelSource as i, ReplayResult as l, toDiagnosticConnectionError as m, DiagnoseAllReport as n, DiagnosticsPublisher as o, queryRows as p, DiagnosisStatus as r, DiagnosticsTokenReader as s, ChannelDiagnosis as t, DiagnosticConnectionError as u };
238
+ export { toDiagnosticConnectionError as _, DiagnosticsGatewayProbe as a, FunnelDiagnostics as c, DiagnosticEvent as d, diagnosticConnectionEventOf as f, queryRows as g, previewOf as h, DiagnosticsChannelSource as i, ReplayResult as l, diagnosticEventOfRaw as m, DiagnoseAllReport as n, DiagnosticsPublisher as o, diagnosticEventOfProcessed as p, DiagnosisStatus as r, DiagnosticsTokenReader as s, ChannelDiagnosis as t, DiagnosticConnectionError as u, toDiagnosticEvent as v, ConnectorDiagnosticSqlReader as y };
@@ -124,7 +124,7 @@ types:
124
124
  slack Socket Mode listener + REST adapter
125
125
  gh GitHub polling listener + REST adapter
126
126
  discord Discord listener + REST adapter
127
- schedule cron-style tick listener (no adapter — schedule does not send out)
127
+ schedule cron + one-shot tick listener (no adapter — schedule does not send out)
128
128
 
129
129
  per-type parts:
130
130
 
@@ -145,8 +145,8 @@ operations (all nested under a channel):
145
145
  fnl channels <ch> connectors <name> request … proxy an HTTP call to the
146
146
  adapter (e.g. send a Slack
147
147
  message via Claude path)
148
- fnl channels <ch> connectors <name> schedules … manage cron entries on a
149
- schedule connector
148
+ fnl channels <ch> connectors <name> schedules … manage cron / one-shot
149
+ schedule entries
150
150
 
151
151
  tokens:
152
152
 
@@ -708,6 +708,11 @@ related: fnl docs architecture, fnl docs debugging, fnl docs mcp`,
708
708
  fnl channels daily connectors cron schedules add morning \\
709
709
  --cron="0 9 * * *" --prompt="summarize yesterday's PRs"
710
710
 
711
+ — schedule a one-shot prompt —
712
+
713
+ fnl channels daily connectors cron schedules add release \\
714
+ --run-at="2026-08-01T09:00:00+09:00" --prompt="run the release check"
715
+
711
716
  — diagnose "events stopped arriving" —
712
717
 
713
718
  fnl debug --all --json
@@ -1,4 +1,4 @@
1
- import { c as FunnelDiagnostics, n as DiagnoseAllReport, t as ChannelDiagnosis } from "./funnel-diagnostics-CnKus3Jg.js";
1
+ import { c as FunnelDiagnostics, n as DiagnoseAllReport, t as ChannelDiagnosis } from "./funnel-diagnostics-CDrZznTB.js";
2
2
  import { n as RecoveryAction, t as FunnelRecovery } from "./funnel-recovery-BwcSNNSN.js";
3
3
  //#region lib/services/doctor/funnel-doctor.d.ts
4
4
  type Props = {