@interactive-inc/claude-funnel 0.68.0 → 0.68.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/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-7rV3HxY3.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",
@@ -42,7 +54,7 @@ const buildDiagnosis = (report) => {
42
54
  nextActions: [`fnl channels ${channel} connectors add <name> --type=slack ...`],
43
55
  rootCause: null
44
56
  };
45
- const authFailed = report.connectionErrors.filter((e) => e.status === "auth-failed");
57
+ const authFailed = unresolvedErrors.filter((e) => e.status === "auth-failed");
46
58
  if (authFailed.length > 0) {
47
59
  const detail = authFailed[authFailed.length - 1]?.detail ?? null;
48
60
  return {
@@ -390,20 +402,22 @@ var FunnelDiagnostics = class {
390
402
  }));
391
403
  baseReport.claudeClients = gatewayBody.clients.filter((cl) => cl.channelName === targetName).length;
392
404
  }
405
+ let unresolvedErrors = [];
393
406
  if (this.props.diagnosticLog) {
394
407
  baseReport.recentEvents = this.queryLog((log) => log.queryProcessed({
395
408
  channelId: target.id,
396
409
  limit: eventLimit
397
410
  })).map(diagnosticEventOfProcessed);
398
- baseReport.connectionErrors = this.queryLog((log) => log.queryConnection({
411
+ const connectionRows = this.queryLog((log) => log.queryConnection({
399
412
  channelId: target.id,
400
- statuses: ["auth-failed", "error"],
401
- limit: 3
402
- })).map(diagnosticConnectionEventOf);
413
+ limit: CONNECTION_DIAGNOSIS_WINDOW
414
+ }));
415
+ baseReport.connectionErrors = connectionRows.filter((row) => row.status === "auth-failed" || row.status === "error").slice(-3).map(diagnosticConnectionEventOf);
416
+ unresolvedErrors = unresolvedConnectionFailures(connectionRows).map(diagnosticConnectionEventOf);
403
417
  }
404
418
  return {
405
419
  ...baseReport,
406
- diagnosis: buildDiagnosis(baseReport)
420
+ diagnosis: buildDiagnosis(baseReport, unresolvedErrors)
407
421
  };
408
422
  }
409
423
  };