@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.cjs
CHANGED
|
@@ -690,6 +690,15 @@ var ExecutionStreamControllerImpl = class {
|
|
|
690
690
|
sseClient = null;
|
|
691
691
|
status = "connecting";
|
|
692
692
|
reconnectAttempts = 0;
|
|
693
|
+
// CAD-39 / webchat dual-plane create-connect race. `hasConnected` flips true on
|
|
694
|
+
// the first successful SSE open; `notFoundRetries` bounds retries of a 404
|
|
695
|
+
// encountered BEFORE we ever connect (the run row is persisted slightly AFTER
|
|
696
|
+
// the client opens the stream — the norm on the webchat path where msg-api owns
|
|
697
|
+
// the executionId and cadra persists the agent_executions row via an async
|
|
698
|
+
// worker callback). See handleConnectionError.
|
|
699
|
+
hasConnected = false;
|
|
700
|
+
notFoundRetries = 0;
|
|
701
|
+
maxConnectRaceRetries = 3;
|
|
693
702
|
seenEventIds = /* @__PURE__ */ new Set();
|
|
694
703
|
_lastEventId = null;
|
|
695
704
|
activityTimeoutId = null;
|
|
@@ -829,6 +838,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
829
838
|
if (connected) {
|
|
830
839
|
this.status = "connected";
|
|
831
840
|
this.reconnectAttempts = 0;
|
|
841
|
+
this.hasConnected = true;
|
|
842
|
+
this.notFoundRetries = 0;
|
|
832
843
|
this.resetActivityTimeout();
|
|
833
844
|
}
|
|
834
845
|
this.emit("connectionChange", { connected, usingFallback: false });
|
|
@@ -1118,6 +1129,38 @@ var ExecutionStreamControllerImpl = class {
|
|
|
1118
1129
|
return;
|
|
1119
1130
|
}
|
|
1120
1131
|
const msg = error instanceof Error ? error.message : String(error);
|
|
1132
|
+
const isNotFound = /\b404\b/.test(msg);
|
|
1133
|
+
const isAuthFailure = /\b40[13]\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg);
|
|
1134
|
+
if (isNotFound && !isAuthFailure && !this.hasConnected) {
|
|
1135
|
+
if (this.notFoundRetries < this.maxConnectRaceRetries) {
|
|
1136
|
+
this.notFoundRetries++;
|
|
1137
|
+
this.status = "reconnecting";
|
|
1138
|
+
const delay = Math.min(
|
|
1139
|
+
this.config.reconnectBaseDelayMs * this.notFoundRetries,
|
|
1140
|
+
this.config.reconnectMaxDelayMs
|
|
1141
|
+
);
|
|
1142
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1143
|
+
if (this.status === "closed") {
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
try {
|
|
1147
|
+
await this.connectSSE();
|
|
1148
|
+
} catch (retryError) {
|
|
1149
|
+
await this.handleConnectionError(retryError);
|
|
1150
|
+
}
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
if (this.pollingEnabled) {
|
|
1154
|
+
if (this.sseClient) {
|
|
1155
|
+
this.sseClient.disconnect();
|
|
1156
|
+
this.sseClient = null;
|
|
1157
|
+
}
|
|
1158
|
+
this.status = "fallback_polling";
|
|
1159
|
+
this.emit("connectionChange", { connected: false, usingFallback: true });
|
|
1160
|
+
this.startPolling();
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1121
1164
|
if (/\b4\d\d\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg)) {
|
|
1122
1165
|
if (this.sseClient) {
|
|
1123
1166
|
this.sseClient.disconnect();
|
|
@@ -1367,7 +1410,6 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1367
1410
|
super(http, "/api/v1/agents");
|
|
1368
1411
|
this.getStreamConfig = getStreamConfig;
|
|
1369
1412
|
}
|
|
1370
|
-
getStreamConfig;
|
|
1371
1413
|
// ===== LIST Operations =====
|
|
1372
1414
|
/**
|
|
1373
1415
|
* List all agents in the organization
|
|
@@ -2273,7 +2315,6 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2273
2315
|
super(http, "/api/v1/sessions");
|
|
2274
2316
|
this.getStreamConfig = getStreamConfig;
|
|
2275
2317
|
}
|
|
2276
|
-
getStreamConfig;
|
|
2277
2318
|
// ===== LIST Operations =====
|
|
2278
2319
|
/**
|
|
2279
2320
|
* List all sessions in the organization
|
|
@@ -2593,7 +2634,6 @@ var KanbanAPI = class extends BaseResourceAPI {
|
|
|
2593
2634
|
super(http, "/api/v1/kanban");
|
|
2594
2635
|
this.getStreamConfig = getStreamConfig;
|
|
2595
2636
|
}
|
|
2596
|
-
getStreamConfig;
|
|
2597
2637
|
// ===== BOARD =====
|
|
2598
2638
|
/**
|
|
2599
2639
|
* Get the current org's board (lanes in declared order). Auto-provisions
|
|
@@ -2795,7 +2835,6 @@ var RemoteAgentsAPI = class extends BaseResourceAPI {
|
|
|
2795
2835
|
super(http, "/api/v1/remote-agents");
|
|
2796
2836
|
this.getStreamConfig = getStreamConfig;
|
|
2797
2837
|
}
|
|
2798
|
-
getStreamConfig;
|
|
2799
2838
|
/**
|
|
2800
2839
|
* List all remote agents in the organization
|
|
2801
2840
|
*
|