@cadraos/sdk 0.3.14 → 0.3.16-dev.0
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 +165 -2
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +136 -2
- package/dist/chat/index.d.ts +136 -2
- package/dist/chat/index.js +163 -3
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +65 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -4
- package/dist/index.d.ts +112 -4
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/dist/kanban/index.cjs +62 -2
- package/dist/kanban/index.cjs.map +1 -1
- package/dist/kanban/index.d.cts +91 -1
- package/dist/kanban/index.d.ts +91 -1
- package/dist/kanban/index.js +62 -2
- package/dist/kanban/index.js.map +1 -1
- package/dist/teams/index.cjs +62 -2
- package/dist/teams/index.cjs.map +1 -1
- package/dist/teams/index.d.cts +91 -1
- package/dist/teams/index.d.ts +91 -1
- package/dist/teams/index.js +62 -2
- package/dist/teams/index.js.map +1 -1
- package/package.json +1 -1
package/dist/chat/index.cjs
CHANGED
|
@@ -301,6 +301,10 @@ var HttpClient = class {
|
|
|
301
301
|
constructor(config) {
|
|
302
302
|
this.config = config;
|
|
303
303
|
}
|
|
304
|
+
/** The client-wide request timeout (ms) this client was configured with. */
|
|
305
|
+
get timeoutMs() {
|
|
306
|
+
return this.config.timeout;
|
|
307
|
+
}
|
|
304
308
|
/**
|
|
305
309
|
* Get authorization header value
|
|
306
310
|
*/
|
|
@@ -1826,13 +1830,69 @@ function executionCancelPath(executionId) {
|
|
|
1826
1830
|
return `${EXECUTION_PATH}/${executionId}/cancel`;
|
|
1827
1831
|
}
|
|
1828
1832
|
|
|
1833
|
+
// src/utils/message-key.ts
|
|
1834
|
+
var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
|
|
1835
|
+
function isValidMessageKey(key) {
|
|
1836
|
+
return MESSAGE_KEY_PATTERN.test(key);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
// src/resources/agent-messages.ts
|
|
1840
|
+
var AgentMessagesAPI = class extends BaseResourceAPI {
|
|
1841
|
+
constructor(http) {
|
|
1842
|
+
super(http, "/api/v1/agents");
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* List an agent's saved messages and the known keys
|
|
1846
|
+
*
|
|
1847
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
1848
|
+
*
|
|
1849
|
+
* @example
|
|
1850
|
+
* ```typescript
|
|
1851
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
1852
|
+
* ```
|
|
1853
|
+
*/
|
|
1854
|
+
async list(agentUuid) {
|
|
1855
|
+
return this.httpGet(`/${agentUuid}/messages`);
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Render one message with placeholders filled
|
|
1859
|
+
*
|
|
1860
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
1861
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
1862
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ```typescript
|
|
1866
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
1867
|
+
* lang: 'es',
|
|
1868
|
+
* vars: { agentName: 'Ana' },
|
|
1869
|
+
* });
|
|
1870
|
+
* ```
|
|
1871
|
+
*/
|
|
1872
|
+
async render(agentUuid, key, options = {}) {
|
|
1873
|
+
if (!isValidMessageKey(key)) {
|
|
1874
|
+
throw new ValidationError(`Invalid message key "${key}"`, [
|
|
1875
|
+
{ field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
|
|
1876
|
+
]);
|
|
1877
|
+
}
|
|
1878
|
+
return this.httpPost(`/${agentUuid}/messages/render`, {
|
|
1879
|
+
key,
|
|
1880
|
+
...options.lang ? { lang: options.lang } : {},
|
|
1881
|
+
...options.vars ? { vars: options.vars } : {}
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1829
1886
|
// src/resources/agents.ts
|
|
1830
1887
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1831
1888
|
constructor(http, getStreamConfig) {
|
|
1832
1889
|
super(http, "/api/v1/agents");
|
|
1833
1890
|
this.getStreamConfig = getStreamConfig;
|
|
1891
|
+
this.messages = new AgentMessagesAPI(http);
|
|
1834
1892
|
}
|
|
1835
1893
|
getStreamConfig;
|
|
1894
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
1895
|
+
messages;
|
|
1836
1896
|
// ===== LIST Operations =====
|
|
1837
1897
|
/**
|
|
1838
1898
|
* List all agents in the organization
|
|
@@ -3427,7 +3487,7 @@ var RemoteRunnersAPI = class extends BaseResourceAPI {
|
|
|
3427
3487
|
};
|
|
3428
3488
|
|
|
3429
3489
|
// src/resources/ai-functions.ts
|
|
3430
|
-
var AI_FUNCTION_RUN_TIMEOUT_MS =
|
|
3490
|
+
var AI_FUNCTION_RUN_TIMEOUT_MS = 31e4;
|
|
3431
3491
|
var AI_FUNCTION_DESCRIPTOR_TTL_MS = 6e4;
|
|
3432
3492
|
function checkAiFunctionParameters(parameters, variables) {
|
|
3433
3493
|
const issues = [];
|
|
@@ -3540,7 +3600,7 @@ var AiFunctionsAPI = class extends BaseResourceAPI {
|
|
|
3540
3600
|
try {
|
|
3541
3601
|
return await this.httpPost("/run", body, {
|
|
3542
3602
|
skipRetry: true,
|
|
3543
|
-
timeoutMs: AI_FUNCTION_RUN_TIMEOUT_MS
|
|
3603
|
+
timeoutMs: Math.max(AI_FUNCTION_RUN_TIMEOUT_MS, this.http.timeoutMs ?? 0)
|
|
3544
3604
|
});
|
|
3545
3605
|
} catch (error) {
|
|
3546
3606
|
throw this.mapRunError(error, functionKey);
|
|
@@ -9606,6 +9666,106 @@ function useImageStream(options) {
|
|
|
9606
9666
|
}, [client, providedExecutionId, agentUuid, inputKey, sessionId, shouldConnect]);
|
|
9607
9667
|
return { images, status, error, executionId, output, cancel };
|
|
9608
9668
|
}
|
|
9669
|
+
var DEFAULT_LABELS = {
|
|
9670
|
+
search: "Search messages",
|
|
9671
|
+
loading: "Loading messages",
|
|
9672
|
+
loadError: "Could not load messages",
|
|
9673
|
+
empty: "No matching messages",
|
|
9674
|
+
notSet: "not set",
|
|
9675
|
+
useCustom: (key) => `Use "${key}"`,
|
|
9676
|
+
invalidCustom: "Keys are lowercase and dotted, like chat.welcome"
|
|
9677
|
+
};
|
|
9678
|
+
function previewOf(message, lang) {
|
|
9679
|
+
return message.text[lang] ?? message.text.en ?? Object.values(message.text).find(Boolean) ?? null;
|
|
9680
|
+
}
|
|
9681
|
+
function AgentMessagePicker({
|
|
9682
|
+
client,
|
|
9683
|
+
agentUuid,
|
|
9684
|
+
value,
|
|
9685
|
+
onChange,
|
|
9686
|
+
allowCustom = false,
|
|
9687
|
+
lang = "en",
|
|
9688
|
+
labels: labelOverrides,
|
|
9689
|
+
className = ""
|
|
9690
|
+
}) {
|
|
9691
|
+
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
9692
|
+
const [data, setData] = react.useState(null);
|
|
9693
|
+
const [error, setError] = react.useState(false);
|
|
9694
|
+
const [query, setQuery] = react.useState("");
|
|
9695
|
+
react.useEffect(() => {
|
|
9696
|
+
let cancelled = false;
|
|
9697
|
+
setData(null);
|
|
9698
|
+
setError(false);
|
|
9699
|
+
client.agents.messages.list(agentUuid).then((result) => {
|
|
9700
|
+
if (!cancelled) setData(result);
|
|
9701
|
+
}).catch(() => {
|
|
9702
|
+
if (!cancelled) setError(true);
|
|
9703
|
+
});
|
|
9704
|
+
return () => {
|
|
9705
|
+
cancelled = true;
|
|
9706
|
+
};
|
|
9707
|
+
}, [client, agentUuid]);
|
|
9708
|
+
const items = react.useMemo(() => {
|
|
9709
|
+
if (!data) return [];
|
|
9710
|
+
const saved = data.messages.map((m) => ({ key: m.key, preview: previewOf(m, lang) }));
|
|
9711
|
+
const savedKeys = new Set(saved.map((i) => i.key));
|
|
9712
|
+
const unsaved = data.knownKeys.filter((k) => !savedKeys.has(k)).sort().map((key) => ({ key, preview: null }));
|
|
9713
|
+
return [...saved, ...unsaved];
|
|
9714
|
+
}, [data, lang]);
|
|
9715
|
+
const needle = query.trim().toLowerCase();
|
|
9716
|
+
const visible = needle ? items.filter(
|
|
9717
|
+
(i) => i.key.includes(needle) || (i.preview?.toLowerCase().includes(needle) ?? false)
|
|
9718
|
+
) : items;
|
|
9719
|
+
const custom = query.trim();
|
|
9720
|
+
const showCustom = allowCustom && custom.length > 0 && !items.some((i) => i.key === custom);
|
|
9721
|
+
const customValid = showCustom && isValidMessageKey(custom);
|
|
9722
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col gap-2 text-sm ${className}`, children: [
|
|
9723
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9724
|
+
"input",
|
|
9725
|
+
{
|
|
9726
|
+
type: "search",
|
|
9727
|
+
value: query,
|
|
9728
|
+
onChange: (e) => setQuery(e.target.value),
|
|
9729
|
+
placeholder: labels.search,
|
|
9730
|
+
"aria-label": labels.search,
|
|
9731
|
+
className: "w-full rounded-lg bg-gray-100 dark:bg-gray-800 px-3 py-2 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
9732
|
+
}
|
|
9733
|
+
),
|
|
9734
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "px-1 text-red-500", children: labels.loadError }) : !data ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex items-center gap-2 px-1 text-gray-500 dark:text-gray-400", children: [
|
|
9735
|
+
/* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, { className: "h-4 w-4" }),
|
|
9736
|
+
labels.loading
|
|
9737
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("ul", { role: "listbox", "aria-label": labels.search, className: "flex max-h-72 flex-col gap-0.5 overflow-y-auto", children: [
|
|
9738
|
+
visible.map((item) => {
|
|
9739
|
+
const selected = item.key === value;
|
|
9740
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { role: "option", "aria-selected": selected, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9741
|
+
"button",
|
|
9742
|
+
{
|
|
9743
|
+
type: "button",
|
|
9744
|
+
onClick: () => onChange(item.key),
|
|
9745
|
+
className: `flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left transition-colors ${selected ? "bg-blue-50 dark:bg-blue-900/30" : "hover:bg-gray-100 dark:hover:bg-gray-800"}`,
|
|
9746
|
+
children: [
|
|
9747
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
9748
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-xs text-gray-900 dark:text-gray-100", children: item.key }),
|
|
9749
|
+
item.preview !== null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-gray-500 dark:text-gray-400", children: item.preview }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "italic text-gray-400 dark:text-gray-500", children: labels.notSet })
|
|
9750
|
+
] }),
|
|
9751
|
+
selected && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "h-4 w-4 flex-shrink-0 text-blue-500" })
|
|
9752
|
+
]
|
|
9753
|
+
}
|
|
9754
|
+
) }, item.key);
|
|
9755
|
+
}),
|
|
9756
|
+
visible.length === 0 && !showCustom && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "px-3 py-2 text-gray-500 dark:text-gray-400", children: labels.empty })
|
|
9757
|
+
] }),
|
|
9758
|
+
data && showCustom && (customValid ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9759
|
+
"button",
|
|
9760
|
+
{
|
|
9761
|
+
type: "button",
|
|
9762
|
+
onClick: () => onChange(custom),
|
|
9763
|
+
className: "rounded-lg bg-gray-100 dark:bg-gray-800 px-3 py-2 text-left font-mono text-xs text-blue-600 dark:text-blue-400 hover:bg-gray-200 dark:hover:bg-gray-700",
|
|
9764
|
+
children: labels.useCustom(custom)
|
|
9765
|
+
}
|
|
9766
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-1 text-xs text-gray-500 dark:text-gray-400", children: labels.invalidCustom }))
|
|
9767
|
+
] });
|
|
9768
|
+
}
|
|
9609
9769
|
function cn13(...classes) {
|
|
9610
9770
|
return classes.filter(Boolean).join(" ");
|
|
9611
9771
|
}
|
|
@@ -9702,6 +9862,7 @@ function TodoList({
|
|
|
9702
9862
|
}
|
|
9703
9863
|
|
|
9704
9864
|
exports.AgentChat = AgentChat;
|
|
9865
|
+
exports.AgentMessagePicker = AgentMessagePicker;
|
|
9705
9866
|
exports.AlertCircleIcon = AlertCircleIcon;
|
|
9706
9867
|
exports.AskUserPrompt = AskUserPrompt;
|
|
9707
9868
|
exports.BotIcon = BotIcon;
|
|
@@ -9734,6 +9895,7 @@ exports.ImageLightbox = ImageLightbox;
|
|
|
9734
9895
|
exports.ImagesIcon = ImagesIcon;
|
|
9735
9896
|
exports.ListTodoIcon = ListTodoIcon;
|
|
9736
9897
|
exports.LoadingSpinner = LoadingSpinner;
|
|
9898
|
+
exports.MESSAGE_KEY_PATTERN = MESSAGE_KEY_PATTERN;
|
|
9737
9899
|
exports.MarkdownContent = MarkdownContent;
|
|
9738
9900
|
exports.Maximize2Icon = Maximize2Icon;
|
|
9739
9901
|
exports.MessageCircleIcon = MessageCircleIcon;
|
|
@@ -9754,6 +9916,7 @@ exports.ZoomOutIcon = ZoomOutIcon;
|
|
|
9754
9916
|
exports.compressImage = compressImage;
|
|
9755
9917
|
exports.createDefaultAdapter = createDefaultAdapter;
|
|
9756
9918
|
exports.isInternalTool = isInternalTool;
|
|
9919
|
+
exports.isValidMessageKey = isValidMessageKey;
|
|
9757
9920
|
exports.useAgentChat = useAgentChat;
|
|
9758
9921
|
exports.useChatConfig = useChatConfig;
|
|
9759
9922
|
exports.useChatConfigOptional = useChatConfigOptional;
|