@interactive-inc/claude-funnel 0.68.0 → 0.68.2

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/claude.js CHANGED
@@ -7,7 +7,7 @@ import { t as FunnelDocs } from "./funnel-docs-CI4hMkhq.js";
7
7
  import { t as discordConnector } from "./discord-connector-CAcWifJn.js";
8
8
  import { t as ghConnector } from "./gh-connector-DMwI6zJA.js";
9
9
  import { t as scheduleConnector } from "./schedule-connector-BXUOYgwZ.js";
10
- import { t as slackConnector } from "./slack-connector-CC3V2VXQ.js";
10
+ import { t as slackConnector } from "./slack-connector-BTtUiXAU.js";
11
11
  import { join } from "node:path";
12
12
  import { existsSync, readFileSync } from "node:fs";
13
13
  import { homedir } from "node:os";
@@ -1,4 +1,4 @@
1
1
  import { t as slackConnectorSchema } from "../slack-connector-schema-EGVuuqSX.js";
2
2
  import { t as FunnelSlackEventProcessor } from "../slack-event-processor-Cs_YuI3w.js";
3
- import { n as FunnelFlumeSlackListener, r as FunnelSlackAdapter, t as slackConnector } from "../slack-connector-CC3V2VXQ.js";
3
+ import { n as FunnelFlumeSlackListener, r as FunnelSlackAdapter, t as slackConnector } from "../slack-connector-BTtUiXAU.js";
4
4
  export { FunnelFlumeSlackListener, FunnelSlackAdapter, FunnelSlackEventProcessor, slackConnector, slackConnectorSchema };
@@ -1,3 +1,3 @@
1
1
  import { a as queryRows, i as previewOf, n as diagnosticEventOfProcessed, o as toDiagnosticConnectionError, r as diagnosticEventOfRaw, s as toDiagnosticEvent, t as diagnosticConnectionEventOf } from "./diagnostic-event-CxMM5Bl2.js";
2
- import { t as FunnelDiagnostics } from "./funnel-diagnostics-CAG7hJP0.js";
2
+ import { t as FunnelDiagnostics } from "./funnel-diagnostics-DremV1of.js";
3
3
  export { FunnelDiagnostics, diagnosticConnectionEventOf, diagnosticEventOfProcessed, diagnosticEventOfRaw, previewOf, queryRows, toDiagnosticConnectionError, toDiagnosticEvent };
@@ -15,8 +15,20 @@ const connectorOf = (channel, connectorId) => {
15
15
  return channel.connectors?.find((connector) => connector.id === connectorId)?.name;
16
16
  };
17
17
  const FLAPPING_ERROR_THRESHOLD = 3;
18
- const buildDiagnosis = (report) => {
19
- const rootCause = (report.connectionErrors[report.connectionErrors.length - 1] ?? null)?.detail ?? null;
18
+ const CONNECTION_DIAGNOSIS_WINDOW = 100;
19
+ const connectionKeyOf = (event) => `${event.type}\u0000${event.connectorId ?? ""}`;
20
+ const unresolvedConnectionFailures = (timeline) => {
21
+ const lastConnectedIndex = /* @__PURE__ */ new Map();
22
+ timeline.forEach((event, index) => {
23
+ if (event.status === "connected") lastConnectedIndex.set(connectionKeyOf(event), index);
24
+ });
25
+ return timeline.filter((event, index) => {
26
+ if (event.status !== "auth-failed" && event.status !== "error") return false;
27
+ return (lastConnectedIndex.get(connectionKeyOf(event)) ?? -1) < index;
28
+ });
29
+ };
30
+ const buildDiagnosis = (report, unresolvedErrors = report.connectionErrors) => {
31
+ const rootCause = (unresolvedErrors[unresolvedErrors.length - 1] ?? null)?.detail ?? null;
20
32
  const channel = report.channel;
21
33
  if (!report.gateway.running) return {
22
34
  status: "error",
@@ -36,13 +48,7 @@ const buildDiagnosis = (report) => {
36
48
  nextActions: ["fnl gateway restart"],
37
49
  rootCause: "supervisor missing listeners declared in settings.json"
38
50
  };
39
- if (report.configuredConnectors === 0) return {
40
- status: "warn",
41
- message: "no connectors configured on this channel",
42
- nextActions: [`fnl channels ${channel} connectors add <name> --type=slack ...`],
43
- rootCause: null
44
- };
45
- const authFailed = report.connectionErrors.filter((e) => e.status === "auth-failed");
51
+ const authFailed = unresolvedErrors.filter((e) => e.status === "auth-failed");
46
52
  if (authFailed.length > 0) {
47
53
  const detail = authFailed[authFailed.length - 1]?.detail ?? null;
48
54
  return {
@@ -52,7 +58,7 @@ const buildDiagnosis = (report) => {
52
58
  rootCause: detail ?? "token rejected by upstream auth.test"
53
59
  };
54
60
  }
55
- const allDead = report.listeners.every((l) => !l.alive);
61
+ const allDead = report.listeners.length > 0 && report.listeners.every((l) => !l.alive);
56
62
  const someDead = report.listeners.some((l) => !l.alive);
57
63
  if (allDead) return {
58
64
  status: "error",
@@ -390,20 +396,22 @@ var FunnelDiagnostics = class {
390
396
  }));
391
397
  baseReport.claudeClients = gatewayBody.clients.filter((cl) => cl.channelName === targetName).length;
392
398
  }
399
+ let unresolvedErrors = [];
393
400
  if (this.props.diagnosticLog) {
394
401
  baseReport.recentEvents = this.queryLog((log) => log.queryProcessed({
395
402
  channelId: target.id,
396
403
  limit: eventLimit
397
404
  })).map(diagnosticEventOfProcessed);
398
- baseReport.connectionErrors = this.queryLog((log) => log.queryConnection({
405
+ const connectionRows = this.queryLog((log) => log.queryConnection({
399
406
  channelId: target.id,
400
- statuses: ["auth-failed", "error"],
401
- limit: 3
402
- })).map(diagnosticConnectionEventOf);
407
+ limit: CONNECTION_DIAGNOSIS_WINDOW
408
+ }));
409
+ baseReport.connectionErrors = connectionRows.filter((row) => row.status === "auth-failed" || row.status === "error").slice(-3).map(diagnosticConnectionEventOf);
410
+ unresolvedErrors = unresolvedConnectionFailures(connectionRows).map(diagnosticConnectionEventOf);
403
411
  }
404
412
  return {
405
413
  ...baseReport,
406
- diagnosis: buildDiagnosis(baseReport)
414
+ diagnosis: buildDiagnosis(baseReport, unresolvedErrors)
407
415
  };
408
416
  }
409
417
  };