@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/chat/index.d.cts
CHANGED
|
@@ -1624,6 +1624,14 @@ interface AgentChatProps {
|
|
|
1624
1624
|
onClarification?: (data: ClarificationData) => void;
|
|
1625
1625
|
/** Initial messages to populate the chat */
|
|
1626
1626
|
initialMessages?: ChatMessage$1[];
|
|
1627
|
+
/**
|
|
1628
|
+
* Extra messages MERGED into the rendered list by timestamp on every render
|
|
1629
|
+
* (interleaved chronologically, deduped by id). Use for durable turns that
|
|
1630
|
+
* arrive out-of-band on a separate delivery plane — e.g. human-operator /
|
|
1631
|
+
* system replies in a webchat handoff — so they don't dock at the bottom.
|
|
1632
|
+
* Unlike `initialMessages`, these are NOT seeded into internal state.
|
|
1633
|
+
*/
|
|
1634
|
+
injectedMessages?: ChatMessage$1[];
|
|
1627
1635
|
/** Placeholder text for the input */
|
|
1628
1636
|
placeholder?: string;
|
|
1629
1637
|
/** Welcome message shown when chat is empty */
|
|
@@ -1787,7 +1795,7 @@ interface AgentChatProps {
|
|
|
1787
1795
|
* />
|
|
1788
1796
|
* ```
|
|
1789
1797
|
*/
|
|
1790
|
-
declare function AgentChat({ agentId, teamId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onToolResult, onClarification, initialMessages, placeholder, welcomeMessage, renderWelcome, maxHeight, className, theme, layout, enableAttachments, enableMarkdown, showToolCalls, toolCallVerbosity, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, hideHeader, renderAboveInput, renderBelowMessages, renderMessage, renderToolCall, messageVariant, showThinking, showDelegation, showImages, pollingInterval, pollingEnabled, onDelegation, onAttachmentsReady, hideAvatars, agentName, hideHeaderWhileEmpty, hideTypingIndicator, onInputChange, onInputControlReady, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
1798
|
+
declare function AgentChat({ agentId, teamId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onToolResult, onClarification, initialMessages, placeholder, welcomeMessage, renderWelcome, maxHeight, className, theme, layout, enableAttachments, enableMarkdown, showToolCalls, toolCallVerbosity, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, hideHeader, renderAboveInput, renderBelowMessages, renderMessage, renderToolCall, messageVariant, showThinking, showDelegation, showImages, pollingInterval, pollingEnabled, onDelegation, onAttachmentsReady, hideAvatars, agentName, hideHeaderWhileEmpty, hideTypingIndicator, onInputChange, onInputControlReady, injectedMessages, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
1791
1799
|
|
|
1792
1800
|
/**
|
|
1793
1801
|
* Retry utility with exponential backoff
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1624,6 +1624,14 @@ interface AgentChatProps {
|
|
|
1624
1624
|
onClarification?: (data: ClarificationData) => void;
|
|
1625
1625
|
/** Initial messages to populate the chat */
|
|
1626
1626
|
initialMessages?: ChatMessage$1[];
|
|
1627
|
+
/**
|
|
1628
|
+
* Extra messages MERGED into the rendered list by timestamp on every render
|
|
1629
|
+
* (interleaved chronologically, deduped by id). Use for durable turns that
|
|
1630
|
+
* arrive out-of-band on a separate delivery plane — e.g. human-operator /
|
|
1631
|
+
* system replies in a webchat handoff — so they don't dock at the bottom.
|
|
1632
|
+
* Unlike `initialMessages`, these are NOT seeded into internal state.
|
|
1633
|
+
*/
|
|
1634
|
+
injectedMessages?: ChatMessage$1[];
|
|
1627
1635
|
/** Placeholder text for the input */
|
|
1628
1636
|
placeholder?: string;
|
|
1629
1637
|
/** Welcome message shown when chat is empty */
|
|
@@ -1787,7 +1795,7 @@ interface AgentChatProps {
|
|
|
1787
1795
|
* />
|
|
1788
1796
|
* ```
|
|
1789
1797
|
*/
|
|
1790
|
-
declare function AgentChat({ agentId, teamId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onToolResult, onClarification, initialMessages, placeholder, welcomeMessage, renderWelcome, maxHeight, className, theme, layout, enableAttachments, enableMarkdown, showToolCalls, toolCallVerbosity, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, hideHeader, renderAboveInput, renderBelowMessages, renderMessage, renderToolCall, messageVariant, showThinking, showDelegation, showImages, pollingInterval, pollingEnabled, onDelegation, onAttachmentsReady, hideAvatars, agentName, hideHeaderWhileEmpty, hideTypingIndicator, onInputChange, onInputControlReady, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
1798
|
+
declare function AgentChat({ agentId, teamId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onToolResult, onClarification, initialMessages, placeholder, welcomeMessage, renderWelcome, maxHeight, className, theme, layout, enableAttachments, enableMarkdown, showToolCalls, toolCallVerbosity, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, hideHeader, renderAboveInput, renderBelowMessages, renderMessage, renderToolCall, messageVariant, showThinking, showDelegation, showImages, pollingInterval, pollingEnabled, onDelegation, onAttachmentsReady, hideAvatars, agentName, hideHeaderWhileEmpty, hideTypingIndicator, onInputChange, onInputControlReady, injectedMessages, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
1791
1799
|
|
|
1792
1800
|
/**
|
|
1793
1801
|
* Retry utility with exponential backoff
|
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
|
*
|
|
@@ -8591,7 +8630,8 @@ function AgentChat({
|
|
|
8591
8630
|
hideHeaderWhileEmpty = false,
|
|
8592
8631
|
hideTypingIndicator = false,
|
|
8593
8632
|
onInputChange,
|
|
8594
|
-
onInputControlReady
|
|
8633
|
+
onInputControlReady,
|
|
8634
|
+
injectedMessages
|
|
8595
8635
|
}) {
|
|
8596
8636
|
const {
|
|
8597
8637
|
messages,
|
|
@@ -8655,8 +8695,9 @@ function AgentChat({
|
|
|
8655
8695
|
},
|
|
8656
8696
|
[enableAttachments, attachments, sendMessage]
|
|
8657
8697
|
);
|
|
8698
|
+
const renderedMessages = injectedMessages && injectedMessages.length > 0 ? [...messages, ...injectedMessages].filter((m, i, arr) => arr.findIndex((x) => x.id === m.id) === i).sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()) : messages;
|
|
8658
8699
|
const messageListProps = {
|
|
8659
|
-
messages,
|
|
8700
|
+
messages: renderedMessages,
|
|
8660
8701
|
welcomeMessage: hideHeader ? void 0 : welcomeMessage,
|
|
8661
8702
|
renderWelcome: hideHeader ? void 0 : renderWelcome,
|
|
8662
8703
|
isLoading,
|