@cadraos/sdk 0.3.6 → 0.3.7
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 +43 -4
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.js +43 -4
- 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 +15 -16
package/dist/chat/index.js
CHANGED
|
@@ -682,6 +682,15 @@ var ExecutionStreamControllerImpl = class {
|
|
|
682
682
|
sseClient = null;
|
|
683
683
|
status = "connecting";
|
|
684
684
|
reconnectAttempts = 0;
|
|
685
|
+
// CAD-39 / webchat dual-plane create-connect race. `hasConnected` flips true on
|
|
686
|
+
// the first successful SSE open; `notFoundRetries` bounds retries of a 404
|
|
687
|
+
// encountered BEFORE we ever connect (the run row is persisted slightly AFTER
|
|
688
|
+
// the client opens the stream — the norm on the webchat path where msg-api owns
|
|
689
|
+
// the executionId and cadra persists the agent_executions row via an async
|
|
690
|
+
// worker callback). See handleConnectionError.
|
|
691
|
+
hasConnected = false;
|
|
692
|
+
notFoundRetries = 0;
|
|
693
|
+
maxConnectRaceRetries = 3;
|
|
685
694
|
seenEventIds = /* @__PURE__ */ new Set();
|
|
686
695
|
_lastEventId = null;
|
|
687
696
|
activityTimeoutId = null;
|
|
@@ -821,6 +830,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
821
830
|
if (connected) {
|
|
822
831
|
this.status = "connected";
|
|
823
832
|
this.reconnectAttempts = 0;
|
|
833
|
+
this.hasConnected = true;
|
|
834
|
+
this.notFoundRetries = 0;
|
|
824
835
|
this.resetActivityTimeout();
|
|
825
836
|
}
|
|
826
837
|
this.emit("connectionChange", { connected, usingFallback: false });
|
|
@@ -1110,6 +1121,38 @@ var ExecutionStreamControllerImpl = class {
|
|
|
1110
1121
|
return;
|
|
1111
1122
|
}
|
|
1112
1123
|
const msg = error instanceof Error ? error.message : String(error);
|
|
1124
|
+
const isNotFound = /\b404\b/.test(msg);
|
|
1125
|
+
const isAuthFailure = /\b40[13]\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg);
|
|
1126
|
+
if (isNotFound && !isAuthFailure && !this.hasConnected) {
|
|
1127
|
+
if (this.notFoundRetries < this.maxConnectRaceRetries) {
|
|
1128
|
+
this.notFoundRetries++;
|
|
1129
|
+
this.status = "reconnecting";
|
|
1130
|
+
const delay = Math.min(
|
|
1131
|
+
this.config.reconnectBaseDelayMs * this.notFoundRetries,
|
|
1132
|
+
this.config.reconnectMaxDelayMs
|
|
1133
|
+
);
|
|
1134
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1135
|
+
if (this.status === "closed") {
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
try {
|
|
1139
|
+
await this.connectSSE();
|
|
1140
|
+
} catch (retryError) {
|
|
1141
|
+
await this.handleConnectionError(retryError);
|
|
1142
|
+
}
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
if (this.pollingEnabled) {
|
|
1146
|
+
if (this.sseClient) {
|
|
1147
|
+
this.sseClient.disconnect();
|
|
1148
|
+
this.sseClient = null;
|
|
1149
|
+
}
|
|
1150
|
+
this.status = "fallback_polling";
|
|
1151
|
+
this.emit("connectionChange", { connected: false, usingFallback: true });
|
|
1152
|
+
this.startPolling();
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1113
1156
|
if (/\b4\d\d\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg)) {
|
|
1114
1157
|
if (this.sseClient) {
|
|
1115
1158
|
this.sseClient.disconnect();
|
|
@@ -1359,7 +1402,6 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1359
1402
|
super(http, "/api/v1/agents");
|
|
1360
1403
|
this.getStreamConfig = getStreamConfig;
|
|
1361
1404
|
}
|
|
1362
|
-
getStreamConfig;
|
|
1363
1405
|
// ===== LIST Operations =====
|
|
1364
1406
|
/**
|
|
1365
1407
|
* List all agents in the organization
|
|
@@ -2265,7 +2307,6 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2265
2307
|
super(http, "/api/v1/sessions");
|
|
2266
2308
|
this.getStreamConfig = getStreamConfig;
|
|
2267
2309
|
}
|
|
2268
|
-
getStreamConfig;
|
|
2269
2310
|
// ===== LIST Operations =====
|
|
2270
2311
|
/**
|
|
2271
2312
|
* List all sessions in the organization
|
|
@@ -2585,7 +2626,6 @@ var KanbanAPI = class extends BaseResourceAPI {
|
|
|
2585
2626
|
super(http, "/api/v1/kanban");
|
|
2586
2627
|
this.getStreamConfig = getStreamConfig;
|
|
2587
2628
|
}
|
|
2588
|
-
getStreamConfig;
|
|
2589
2629
|
// ===== BOARD =====
|
|
2590
2630
|
/**
|
|
2591
2631
|
* Get the current org's board (lanes in declared order). Auto-provisions
|
|
@@ -2787,7 +2827,6 @@ var RemoteAgentsAPI = class extends BaseResourceAPI {
|
|
|
2787
2827
|
super(http, "/api/v1/remote-agents");
|
|
2788
2828
|
this.getStreamConfig = getStreamConfig;
|
|
2789
2829
|
}
|
|
2790
|
-
getStreamConfig;
|
|
2791
2830
|
/**
|
|
2792
2831
|
* List all remote agents in the organization
|
|
2793
2832
|
*
|