@cadraos/sdk 0.3.6 → 0.3.8
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/chat/index.cjs +47 -6
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +9 -1
- package/dist/chat/index.d.ts +9 -1
- package/dist/chat/index.js +47 -6
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +43 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -4
- package/dist/index.js.map +1 -1
- package/dist/kanban/engine/index.cjs +0 -6
- package/dist/kanban/engine/index.cjs.map +1 -1
- package/dist/kanban/engine/index.js +0 -6
- package/dist/kanban/engine/index.js.map +1 -1
- package/dist/kanban/index.cjs +43 -4
- package/dist/kanban/index.cjs.map +1 -1
- package/dist/kanban/index.js +43 -4
- package/dist/kanban/index.js.map +1 -1
- package/dist/teams/index.cjs +43 -4
- package/dist/teams/index.cjs.map +1 -1
- package/dist/teams/index.js +43 -4
- package/dist/teams/index.js.map +1 -1
- package/package.json +1 -1
package/dist/teams/index.js
CHANGED
|
@@ -669,6 +669,15 @@ var ExecutionStreamControllerImpl = class {
|
|
|
669
669
|
sseClient = null;
|
|
670
670
|
status = "connecting";
|
|
671
671
|
reconnectAttempts = 0;
|
|
672
|
+
// CAD-39 / webchat dual-plane create-connect race. `hasConnected` flips true on
|
|
673
|
+
// the first successful SSE open; `notFoundRetries` bounds retries of a 404
|
|
674
|
+
// encountered BEFORE we ever connect (the run row is persisted slightly AFTER
|
|
675
|
+
// the client opens the stream — the norm on the webchat path where msg-api owns
|
|
676
|
+
// the executionId and cadra persists the agent_executions row via an async
|
|
677
|
+
// worker callback). See handleConnectionError.
|
|
678
|
+
hasConnected = false;
|
|
679
|
+
notFoundRetries = 0;
|
|
680
|
+
maxConnectRaceRetries = 3;
|
|
672
681
|
seenEventIds = /* @__PURE__ */ new Set();
|
|
673
682
|
_lastEventId = null;
|
|
674
683
|
activityTimeoutId = null;
|
|
@@ -808,6 +817,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
808
817
|
if (connected) {
|
|
809
818
|
this.status = "connected";
|
|
810
819
|
this.reconnectAttempts = 0;
|
|
820
|
+
this.hasConnected = true;
|
|
821
|
+
this.notFoundRetries = 0;
|
|
811
822
|
this.resetActivityTimeout();
|
|
812
823
|
}
|
|
813
824
|
this.emit("connectionChange", { connected, usingFallback: false });
|
|
@@ -1097,6 +1108,38 @@ var ExecutionStreamControllerImpl = class {
|
|
|
1097
1108
|
return;
|
|
1098
1109
|
}
|
|
1099
1110
|
const msg = error instanceof Error ? error.message : String(error);
|
|
1111
|
+
const isNotFound = /\b404\b/.test(msg);
|
|
1112
|
+
const isAuthFailure = /\b40[13]\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg);
|
|
1113
|
+
if (isNotFound && !isAuthFailure && !this.hasConnected) {
|
|
1114
|
+
if (this.notFoundRetries < this.maxConnectRaceRetries) {
|
|
1115
|
+
this.notFoundRetries++;
|
|
1116
|
+
this.status = "reconnecting";
|
|
1117
|
+
const delay = Math.min(
|
|
1118
|
+
this.config.reconnectBaseDelayMs * this.notFoundRetries,
|
|
1119
|
+
this.config.reconnectMaxDelayMs
|
|
1120
|
+
);
|
|
1121
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1122
|
+
if (this.status === "closed") {
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
try {
|
|
1126
|
+
await this.connectSSE();
|
|
1127
|
+
} catch (retryError) {
|
|
1128
|
+
await this.handleConnectionError(retryError);
|
|
1129
|
+
}
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
if (this.pollingEnabled) {
|
|
1133
|
+
if (this.sseClient) {
|
|
1134
|
+
this.sseClient.disconnect();
|
|
1135
|
+
this.sseClient = null;
|
|
1136
|
+
}
|
|
1137
|
+
this.status = "fallback_polling";
|
|
1138
|
+
this.emit("connectionChange", { connected: false, usingFallback: true });
|
|
1139
|
+
this.startPolling();
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1100
1143
|
if (/\b4\d\d\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg)) {
|
|
1101
1144
|
if (this.sseClient) {
|
|
1102
1145
|
this.sseClient.disconnect();
|
|
@@ -1346,7 +1389,6 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1346
1389
|
super(http, "/api/v1/agents");
|
|
1347
1390
|
this.getStreamConfig = getStreamConfig;
|
|
1348
1391
|
}
|
|
1349
|
-
getStreamConfig;
|
|
1350
1392
|
// ===== LIST Operations =====
|
|
1351
1393
|
/**
|
|
1352
1394
|
* List all agents in the organization
|
|
@@ -2252,7 +2294,6 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2252
2294
|
super(http, "/api/v1/sessions");
|
|
2253
2295
|
this.getStreamConfig = getStreamConfig;
|
|
2254
2296
|
}
|
|
2255
|
-
getStreamConfig;
|
|
2256
2297
|
// ===== LIST Operations =====
|
|
2257
2298
|
/**
|
|
2258
2299
|
* List all sessions in the organization
|
|
@@ -2572,7 +2613,6 @@ var KanbanAPI = class extends BaseResourceAPI {
|
|
|
2572
2613
|
super(http, "/api/v1/kanban");
|
|
2573
2614
|
this.getStreamConfig = getStreamConfig;
|
|
2574
2615
|
}
|
|
2575
|
-
getStreamConfig;
|
|
2576
2616
|
// ===== BOARD =====
|
|
2577
2617
|
/**
|
|
2578
2618
|
* Get the current org's board (lanes in declared order). Auto-provisions
|
|
@@ -2774,7 +2814,6 @@ var RemoteAgentsAPI = class extends BaseResourceAPI {
|
|
|
2774
2814
|
super(http, "/api/v1/remote-agents");
|
|
2775
2815
|
this.getStreamConfig = getStreamConfig;
|
|
2776
2816
|
}
|
|
2777
|
-
getStreamConfig;
|
|
2778
2817
|
/**
|
|
2779
2818
|
* List all remote agents in the organization
|
|
2780
2819
|
*
|