@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/index.cjs
CHANGED
|
@@ -677,6 +677,15 @@ var ExecutionStreamControllerImpl = class {
|
|
|
677
677
|
sseClient = null;
|
|
678
678
|
status = "connecting";
|
|
679
679
|
reconnectAttempts = 0;
|
|
680
|
+
// CAD-39 / webchat dual-plane create-connect race. `hasConnected` flips true on
|
|
681
|
+
// the first successful SSE open; `notFoundRetries` bounds retries of a 404
|
|
682
|
+
// encountered BEFORE we ever connect (the run row is persisted slightly AFTER
|
|
683
|
+
// the client opens the stream — the norm on the webchat path where msg-api owns
|
|
684
|
+
// the executionId and cadra persists the agent_executions row via an async
|
|
685
|
+
// worker callback). See handleConnectionError.
|
|
686
|
+
hasConnected = false;
|
|
687
|
+
notFoundRetries = 0;
|
|
688
|
+
maxConnectRaceRetries = 3;
|
|
680
689
|
seenEventIds = /* @__PURE__ */ new Set();
|
|
681
690
|
_lastEventId = null;
|
|
682
691
|
activityTimeoutId = null;
|
|
@@ -816,6 +825,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
816
825
|
if (connected) {
|
|
817
826
|
this.status = "connected";
|
|
818
827
|
this.reconnectAttempts = 0;
|
|
828
|
+
this.hasConnected = true;
|
|
829
|
+
this.notFoundRetries = 0;
|
|
819
830
|
this.resetActivityTimeout();
|
|
820
831
|
}
|
|
821
832
|
this.emit("connectionChange", { connected, usingFallback: false });
|
|
@@ -1105,6 +1116,38 @@ var ExecutionStreamControllerImpl = class {
|
|
|
1105
1116
|
return;
|
|
1106
1117
|
}
|
|
1107
1118
|
const msg = error instanceof Error ? error.message : String(error);
|
|
1119
|
+
const isNotFound = /\b404\b/.test(msg);
|
|
1120
|
+
const isAuthFailure = /\b40[13]\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg);
|
|
1121
|
+
if (isNotFound && !isAuthFailure && !this.hasConnected) {
|
|
1122
|
+
if (this.notFoundRetries < this.maxConnectRaceRetries) {
|
|
1123
|
+
this.notFoundRetries++;
|
|
1124
|
+
this.status = "reconnecting";
|
|
1125
|
+
const delay = Math.min(
|
|
1126
|
+
this.config.reconnectBaseDelayMs * this.notFoundRetries,
|
|
1127
|
+
this.config.reconnectMaxDelayMs
|
|
1128
|
+
);
|
|
1129
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1130
|
+
if (this.status === "closed") {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
try {
|
|
1134
|
+
await this.connectSSE();
|
|
1135
|
+
} catch (retryError) {
|
|
1136
|
+
await this.handleConnectionError(retryError);
|
|
1137
|
+
}
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
if (this.pollingEnabled) {
|
|
1141
|
+
if (this.sseClient) {
|
|
1142
|
+
this.sseClient.disconnect();
|
|
1143
|
+
this.sseClient = null;
|
|
1144
|
+
}
|
|
1145
|
+
this.status = "fallback_polling";
|
|
1146
|
+
this.emit("connectionChange", { connected: false, usingFallback: true });
|
|
1147
|
+
this.startPolling();
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1108
1151
|
if (/\b4\d\d\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg)) {
|
|
1109
1152
|
if (this.sseClient) {
|
|
1110
1153
|
this.sseClient.disconnect();
|
|
@@ -1354,7 +1397,6 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1354
1397
|
super(http, "/api/v1/agents");
|
|
1355
1398
|
this.getStreamConfig = getStreamConfig;
|
|
1356
1399
|
}
|
|
1357
|
-
getStreamConfig;
|
|
1358
1400
|
// ===== LIST Operations =====
|
|
1359
1401
|
/**
|
|
1360
1402
|
* List all agents in the organization
|
|
@@ -2260,7 +2302,6 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2260
2302
|
super(http, "/api/v1/sessions");
|
|
2261
2303
|
this.getStreamConfig = getStreamConfig;
|
|
2262
2304
|
}
|
|
2263
|
-
getStreamConfig;
|
|
2264
2305
|
// ===== LIST Operations =====
|
|
2265
2306
|
/**
|
|
2266
2307
|
* List all sessions in the organization
|
|
@@ -2580,7 +2621,6 @@ var KanbanAPI = class extends BaseResourceAPI {
|
|
|
2580
2621
|
super(http, "/api/v1/kanban");
|
|
2581
2622
|
this.getStreamConfig = getStreamConfig;
|
|
2582
2623
|
}
|
|
2583
|
-
getStreamConfig;
|
|
2584
2624
|
// ===== BOARD =====
|
|
2585
2625
|
/**
|
|
2586
2626
|
* Get the current org's board (lanes in declared order). Auto-provisions
|
|
@@ -2782,7 +2822,6 @@ var RemoteAgentsAPI = class extends BaseResourceAPI {
|
|
|
2782
2822
|
super(http, "/api/v1/remote-agents");
|
|
2783
2823
|
this.getStreamConfig = getStreamConfig;
|
|
2784
2824
|
}
|
|
2785
|
-
getStreamConfig;
|
|
2786
2825
|
/**
|
|
2787
2826
|
* List all remote agents in the organization
|
|
2788
2827
|
*
|