@kognitivedev/ui 0.2.11
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/.turbo/turbo-build.log +2 -0
- package/CHANGELOG.md +19 -0
- package/README.md +264 -0
- package/dist/__tests__/context-provider.test.d.ts +1 -0
- package/dist/__tests__/context-provider.test.js +38 -0
- package/dist/__tests__/event-emitter.test.d.ts +1 -0
- package/dist/__tests__/event-emitter.test.js +62 -0
- package/dist/__tests__/keyboard-shortcuts.test.d.ts +1 -0
- package/dist/__tests__/keyboard-shortcuts.test.js +36 -0
- package/dist/__tests__/kognitive-runtime.test.d.ts +1 -0
- package/dist/__tests__/kognitive-runtime.test.js +58 -0
- package/dist/__tests__/kognitive-transport.test.d.ts +1 -0
- package/dist/__tests__/kognitive-transport.test.js +96 -0
- package/dist/__tests__/make-tool-ui.test.d.ts +1 -0
- package/dist/__tests__/make-tool-ui.test.js +50 -0
- package/dist/__tests__/message-helpers.test.d.ts +1 -0
- package/dist/__tests__/message-helpers.test.js +80 -0
- package/dist/__tests__/thread-manager.test.d.ts +1 -0
- package/dist/__tests__/thread-manager.test.js +84 -0
- package/dist/__tests__/tool-ui-registry.test.d.ts +1 -0
- package/dist/__tests__/tool-ui-registry.test.js +68 -0
- package/dist/__tests__/toolkit.test.d.ts +1 -0
- package/dist/__tests__/toolkit.test.js +33 -0
- package/dist/components/attachment-preview.d.ts +8 -0
- package/dist/components/attachment-preview.js +10 -0
- package/dist/components/composer.d.ts +6 -0
- package/dist/components/composer.js +10 -0
- package/dist/components/error-banner.d.ts +6 -0
- package/dist/components/error-banner.js +8 -0
- package/dist/components/markdown-content.d.ts +13 -0
- package/dist/components/markdown-content.js +31 -0
- package/dist/components/message.d.ts +7 -0
- package/dist/components/message.js +28 -0
- package/dist/components/status-indicator.d.ts +6 -0
- package/dist/components/status-indicator.js +16 -0
- package/dist/components/suggestions.d.ts +4 -0
- package/dist/components/suggestions.js +12 -0
- package/dist/components/thread-list.d.ts +4 -0
- package/dist/components/thread-list.js +20 -0
- package/dist/components/thread.d.ts +15 -0
- package/dist/components/thread.js +19 -0
- package/dist/components/tool-approval.d.ts +7 -0
- package/dist/components/tool-approval.js +12 -0
- package/dist/components/tool-invocation.d.ts +5 -0
- package/dist/components/tool-invocation.js +33 -0
- package/dist/context/kognitive-context.d.ts +2 -0
- package/dist/context/kognitive-context.js +6 -0
- package/dist/context/types.d.ts +44 -0
- package/dist/context/types.js +2 -0
- package/dist/context/use-kognitive.d.ts +1 -0
- package/dist/context/use-kognitive.js +7 -0
- package/dist/hooks/use-auto-scroll.d.ts +2 -0
- package/dist/hooks/use-auto-scroll.js +18 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +4 -0
- package/dist/hooks/use-copy-to-clipboard.js +13 -0
- package/dist/hooks/use-keyboard-shortcuts.d.ts +8 -0
- package/dist/hooks/use-keyboard-shortcuts.js +24 -0
- package/dist/hooks/use-kognitive-chat.d.ts +38 -0
- package/dist/hooks/use-kognitive-chat.js +35 -0
- package/dist/hooks/use-kognitive-event.d.ts +12 -0
- package/dist/hooks/use-kognitive-event.js +47 -0
- package/dist/hooks/use-streaming-status.d.ts +2 -0
- package/dist/hooks/use-streaming-status.js +8 -0
- package/dist/hooks/use-thread-manager.d.ts +20 -0
- package/dist/hooks/use-thread-manager.js +83 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +92 -0
- package/dist/kognitive-ui.d.ts +48 -0
- package/dist/kognitive-ui.js +130 -0
- package/dist/primitives/action-bar/action-bar-copy.d.ts +6 -0
- package/dist/primitives/action-bar/action-bar-copy.js +16 -0
- package/dist/primitives/action-bar/action-bar-edit.d.ts +6 -0
- package/dist/primitives/action-bar/action-bar-edit.js +11 -0
- package/dist/primitives/action-bar/action-bar-feedback.d.ts +10 -0
- package/dist/primitives/action-bar/action-bar-feedback.js +30 -0
- package/dist/primitives/action-bar/action-bar-retry.d.ts +6 -0
- package/dist/primitives/action-bar/action-bar-retry.js +25 -0
- package/dist/primitives/action-bar/action-bar-root.d.ts +6 -0
- package/dist/primitives/action-bar/action-bar-root.js +7 -0
- package/dist/primitives/action-bar/action-bar-stop.d.ts +6 -0
- package/dist/primitives/action-bar/action-bar-stop.js +11 -0
- package/dist/primitives/action-bar/index.d.ts +14 -0
- package/dist/primitives/action-bar/index.js +17 -0
- package/dist/primitives/composer/composer-attachment-trigger.d.ts +7 -0
- package/dist/primitives/composer/composer-attachment-trigger.js +33 -0
- package/dist/primitives/composer/composer-attachments.d.ts +7 -0
- package/dist/primitives/composer/composer-attachments.js +16 -0
- package/dist/primitives/composer/composer-input.d.ts +6 -0
- package/dist/primitives/composer/composer-input.js +19 -0
- package/dist/primitives/composer/composer-root.d.ts +6 -0
- package/dist/primitives/composer/composer-root.js +91 -0
- package/dist/primitives/composer/composer-send.d.ts +6 -0
- package/dist/primitives/composer/composer-send.js +10 -0
- package/dist/primitives/composer/edit-composer-root.d.ts +11 -0
- package/dist/primitives/composer/edit-composer-root.js +24 -0
- package/dist/primitives/composer/index.d.ts +15 -0
- package/dist/primitives/composer/index.js +19 -0
- package/dist/primitives/composer/use-composer.d.ts +12 -0
- package/dist/primitives/composer/use-composer.js +6 -0
- package/dist/primitives/message/index.d.ts +9 -0
- package/dist/primitives/message/index.js +13 -0
- package/dist/primitives/message/message-content.d.ts +25 -0
- package/dist/primitives/message/message-content.js +70 -0
- package/dist/primitives/message/message-role.d.ts +6 -0
- package/dist/primitives/message/message-role.js +11 -0
- package/dist/primitives/message/message-root.d.ts +9 -0
- package/dist/primitives/message/message-root.js +38 -0
- package/dist/primitives/message/use-message.d.ts +10 -0
- package/dist/primitives/message/use-message.js +6 -0
- package/dist/primitives/thread/index.d.ts +17 -0
- package/dist/primitives/thread/index.js +21 -0
- package/dist/primitives/thread/thread-empty.d.ts +5 -0
- package/dist/primitives/thread/thread-empty.js +11 -0
- package/dist/primitives/thread/thread-error.d.ts +6 -0
- package/dist/primitives/thread/thread-error.js +11 -0
- package/dist/primitives/thread/thread-loading.d.ts +5 -0
- package/dist/primitives/thread/thread-loading.js +11 -0
- package/dist/primitives/thread/thread-messages.d.ts +6 -0
- package/dist/primitives/thread/thread-messages.js +9 -0
- package/dist/primitives/thread/thread-root.d.ts +6 -0
- package/dist/primitives/thread/thread-root.js +12 -0
- package/dist/primitives/thread/thread-scroll-to-bottom.d.ts +6 -0
- package/dist/primitives/thread/thread-scroll-to-bottom.js +14 -0
- package/dist/primitives/thread/thread-suggestions.d.ts +6 -0
- package/dist/primitives/thread/thread-suggestions.js +14 -0
- package/dist/primitives/thread/use-thread.d.ts +9 -0
- package/dist/primitives/thread/use-thread.js +6 -0
- package/dist/primitives/thread-list/index.d.ts +11 -0
- package/dist/primitives/thread-list/index.js +15 -0
- package/dist/primitives/thread-list/thread-list-item.d.ts +9 -0
- package/dist/primitives/thread-list/thread-list-item.js +13 -0
- package/dist/primitives/thread-list/thread-list-items.d.ts +6 -0
- package/dist/primitives/thread-list/thread-list-items.js +9 -0
- package/dist/primitives/thread-list/thread-list-new.d.ts +6 -0
- package/dist/primitives/thread-list/thread-list-new.js +13 -0
- package/dist/primitives/thread-list/thread-list-root.d.ts +6 -0
- package/dist/primitives/thread-list/thread-list-root.js +16 -0
- package/dist/primitives/thread-list/use-thread-list.d.ts +9 -0
- package/dist/primitives/thread-list/use-thread-list.js +6 -0
- package/dist/primitives/tool-ui/index.d.ts +7 -0
- package/dist/primitives/tool-ui/index.js +11 -0
- package/dist/primitives/tool-ui/tool-ui-fallback.d.ts +5 -0
- package/dist/primitives/tool-ui/tool-ui-fallback.js +20 -0
- package/dist/primitives/tool-ui/tool-ui-root.d.ts +5 -0
- package/dist/primitives/tool-ui/tool-ui-root.js +20 -0
- package/dist/primitives/tool-ui/use-tool-ui.d.ts +2 -0
- package/dist/primitives/tool-ui/use-tool-ui.js +8 -0
- package/dist/runtime/kognitive-runtime.d.ts +30 -0
- package/dist/runtime/kognitive-runtime.js +32 -0
- package/dist/runtime/kognitive-transport.d.ts +26 -0
- package/dist/runtime/kognitive-transport.js +42 -0
- package/dist/runtime/thread-manager.d.ts +17 -0
- package/dist/runtime/thread-manager.js +62 -0
- package/dist/runtime/types.d.ts +58 -0
- package/dist/runtime/types.js +2 -0
- package/dist/tool-ui/make-tool-ui.d.ts +59 -0
- package/dist/tool-ui/make-tool-ui.js +10 -0
- package/dist/tool-ui/registry.d.ts +9 -0
- package/dist/tool-ui/registry.js +26 -0
- package/dist/tool-ui/tool-ui-context.d.ts +2 -0
- package/dist/tool-ui/tool-ui-context.js +6 -0
- package/dist/tool-ui/toolkit.d.ts +31 -0
- package/dist/tool-ui/toolkit.js +33 -0
- package/dist/tool-ui/types.d.ts +19 -0
- package/dist/tool-ui/types.js +2 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +8 -0
- package/dist/utils/create-context.d.ts +1 -0
- package/dist/utils/create-context.js +16 -0
- package/dist/utils/message-helpers.d.ts +6 -0
- package/dist/utils/message-helpers.js +46 -0
- package/package.json +56 -0
- package/src/__tests__/context-provider.test.ts +43 -0
- package/src/__tests__/event-emitter.test.ts +69 -0
- package/src/__tests__/keyboard-shortcuts.test.ts +55 -0
- package/src/__tests__/kognitive-runtime.test.ts +62 -0
- package/src/__tests__/kognitive-transport.test.ts +113 -0
- package/src/__tests__/make-tool-ui.test.ts +60 -0
- package/src/__tests__/message-helpers.test.ts +101 -0
- package/src/__tests__/thread-manager.test.ts +118 -0
- package/src/__tests__/tool-ui-registry.test.ts +80 -0
- package/src/__tests__/toolkit.test.ts +37 -0
- package/src/components/attachment-preview.tsx +46 -0
- package/src/components/composer.tsx +59 -0
- package/src/components/error-banner.tsx +33 -0
- package/src/components/markdown-content.tsx +64 -0
- package/src/components/message.tsx +145 -0
- package/src/components/status-indicator.tsx +26 -0
- package/src/components/suggestions.tsx +27 -0
- package/src/components/thread-list.tsx +69 -0
- package/src/components/thread.tsx +89 -0
- package/src/components/tool-approval.tsx +54 -0
- package/src/components/tool-invocation.tsx +94 -0
- package/src/context/kognitive-context.tsx +8 -0
- package/src/context/types.ts +43 -0
- package/src/context/use-kognitive.ts +5 -0
- package/src/hooks/use-auto-scroll.ts +19 -0
- package/src/hooks/use-copy-to-clipboard.ts +16 -0
- package/src/hooks/use-keyboard-shortcuts.ts +34 -0
- package/src/hooks/use-kognitive-chat.ts +73 -0
- package/src/hooks/use-kognitive-event.ts +56 -0
- package/src/hooks/use-streaming-status.ts +7 -0
- package/src/hooks/use-thread-manager.ts +114 -0
- package/src/index.ts +56 -0
- package/src/kognitive-ui.tsx +216 -0
- package/src/primitives/action-bar/action-bar-copy.tsx +30 -0
- package/src/primitives/action-bar/action-bar-edit.tsx +24 -0
- package/src/primitives/action-bar/action-bar-feedback.tsx +59 -0
- package/src/primitives/action-bar/action-bar-retry.tsx +38 -0
- package/src/primitives/action-bar/action-bar-root.tsx +14 -0
- package/src/primitives/action-bar/action-bar-stop.tsx +24 -0
- package/src/primitives/action-bar/index.ts +15 -0
- package/src/primitives/composer/composer-attachment-trigger.tsx +70 -0
- package/src/primitives/composer/composer-attachments.tsx +36 -0
- package/src/primitives/composer/composer-input.tsx +46 -0
- package/src/primitives/composer/composer-root.tsx +130 -0
- package/src/primitives/composer/composer-send.tsx +23 -0
- package/src/primitives/composer/edit-composer-root.tsx +52 -0
- package/src/primitives/composer/index.ts +17 -0
- package/src/primitives/composer/use-composer.ts +19 -0
- package/src/primitives/message/index.ts +11 -0
- package/src/primitives/message/message-content.tsx +117 -0
- package/src/primitives/message/message-role.tsx +13 -0
- package/src/primitives/message/message-root.tsx +64 -0
- package/src/primitives/message/use-message.ts +17 -0
- package/src/primitives/thread/index.ts +19 -0
- package/src/primitives/thread/thread-empty.tsx +12 -0
- package/src/primitives/thread/thread-error.tsx +18 -0
- package/src/primitives/thread/thread-loading.tsx +12 -0
- package/src/primitives/thread/thread-messages.tsx +12 -0
- package/src/primitives/thread/thread-root.tsx +28 -0
- package/src/primitives/thread/thread-scroll-to-bottom.tsx +26 -0
- package/src/primitives/thread/thread-suggestions.tsx +31 -0
- package/src/primitives/thread/use-thread.ts +16 -0
- package/src/primitives/thread-list/index.ts +13 -0
- package/src/primitives/thread-list/thread-list-item.tsx +37 -0
- package/src/primitives/thread-list/thread-list-items.tsx +19 -0
- package/src/primitives/thread-list/thread-list-new.tsx +26 -0
- package/src/primitives/thread-list/thread-list-root.tsx +29 -0
- package/src/primitives/thread-list/use-thread-list.ts +16 -0
- package/src/primitives/tool-ui/index.ts +9 -0
- package/src/primitives/tool-ui/tool-ui-fallback.tsx +63 -0
- package/src/primitives/tool-ui/tool-ui-root.tsx +26 -0
- package/src/primitives/tool-ui/use-tool-ui.ts +7 -0
- package/src/runtime/kognitive-runtime.ts +56 -0
- package/src/runtime/kognitive-transport.ts +56 -0
- package/src/runtime/thread-manager.ts +92 -0
- package/src/runtime/types.ts +63 -0
- package/src/tool-ui/make-tool-ui.ts +71 -0
- package/src/tool-ui/registry.ts +27 -0
- package/src/tool-ui/tool-ui-context.tsx +8 -0
- package/src/tool-ui/toolkit.ts +40 -0
- package/src/tool-ui/types.ts +29 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/create-context.ts +18 -0
- package/src/utils/message-helpers.ts +42 -0
- package/tsconfig.json +15 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolUIRoot = ToolUIRoot;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const tool_ui_context_1 = require("../../tool-ui/tool-ui-context");
|
|
6
|
+
const tool_ui_fallback_1 = require("./tool-ui-fallback");
|
|
7
|
+
function ToolUIRoot(props) {
|
|
8
|
+
let registry;
|
|
9
|
+
try {
|
|
10
|
+
registry = (0, tool_ui_context_1.useToolUIRegistry)();
|
|
11
|
+
}
|
|
12
|
+
catch (_a) {
|
|
13
|
+
// Registry not available
|
|
14
|
+
}
|
|
15
|
+
const RegisteredUI = registry === null || registry === void 0 ? void 0 : registry.get(props.toolName);
|
|
16
|
+
if (RegisteredUI) {
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(RegisteredUI, Object.assign({}, props));
|
|
18
|
+
}
|
|
19
|
+
return (0, jsx_runtime_1.jsx)(tool_ui_fallback_1.ToolUIFallback, Object.assign({}, props));
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToolUI = useToolUI;
|
|
4
|
+
const tool_ui_context_1 = require("../../tool-ui/tool-ui-context");
|
|
5
|
+
function useToolUI(toolName) {
|
|
6
|
+
const registry = (0, tool_ui_context_1.useToolUIRegistry)();
|
|
7
|
+
return registry.get(toolName);
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DefaultChatTransport, UIMessage } from "ai";
|
|
2
|
+
import { ThreadManager } from "./thread-manager";
|
|
3
|
+
import type { ToolUIRegistry } from "../tool-ui/registry";
|
|
4
|
+
export interface KognitiveRuntimeConfig {
|
|
5
|
+
/** Base URL of the Kognitive runtime */
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Agent name to connect to */
|
|
8
|
+
agentName: string;
|
|
9
|
+
/** Additional headers (e.g., auth) */
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
/** User identity */
|
|
12
|
+
resourceId?: {
|
|
13
|
+
userId?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Initial session/thread ID */
|
|
16
|
+
sessionId?: string;
|
|
17
|
+
/** Enable thread management. When true, uses threadApiBase for CRUD. */
|
|
18
|
+
threads?: boolean;
|
|
19
|
+
/** Thread API base URL. Defaults to {baseUrl}/api/agents/{agentName}/threads */
|
|
20
|
+
threadApiBase?: string;
|
|
21
|
+
/** Tool UI registry */
|
|
22
|
+
toolUIRegistry?: ToolUIRegistry;
|
|
23
|
+
}
|
|
24
|
+
export declare class KognitiveRuntime {
|
|
25
|
+
readonly config: KognitiveRuntimeConfig;
|
|
26
|
+
readonly threadManager: ThreadManager | null;
|
|
27
|
+
readonly toolUIRegistry: ToolUIRegistry | null;
|
|
28
|
+
constructor(config: KognitiveRuntimeConfig);
|
|
29
|
+
createTransport(sessionId?: string): DefaultChatTransport<UIMessage>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KognitiveRuntime = void 0;
|
|
4
|
+
const kognitive_transport_1 = require("./kognitive-transport");
|
|
5
|
+
const thread_manager_1 = require("./thread-manager");
|
|
6
|
+
class KognitiveRuntime {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.toolUIRegistry = (_a = config.toolUIRegistry) !== null && _a !== void 0 ? _a : null;
|
|
11
|
+
if (config.threads) {
|
|
12
|
+
const threadApiBase = (_b = config.threadApiBase) !== null && _b !== void 0 ? _b : `${config.baseUrl.replace(/\/$/, "")}/api/agents/${encodeURIComponent(config.agentName)}/threads`;
|
|
13
|
+
this.threadManager = new thread_manager_1.ThreadManager({
|
|
14
|
+
baseUrl: threadApiBase,
|
|
15
|
+
headers: config.headers,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.threadManager = null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
createTransport(sessionId) {
|
|
23
|
+
return (0, kognitive_transport_1.createKognitiveTransport)({
|
|
24
|
+
baseUrl: this.config.baseUrl,
|
|
25
|
+
agentName: this.config.agentName,
|
|
26
|
+
sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : this.config.sessionId,
|
|
27
|
+
resourceId: this.config.resourceId,
|
|
28
|
+
headers: this.config.headers,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.KognitiveRuntime = KognitiveRuntime;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DefaultChatTransport, type UIMessage } from "ai";
|
|
2
|
+
export interface KognitiveTransportConfig {
|
|
3
|
+
/**
|
|
4
|
+
* Explicit API endpoint URL for streaming.
|
|
5
|
+
* When set, takes priority over baseUrl + agentName URL construction.
|
|
6
|
+
* Use this for custom proxy routes (e.g., "/api/chat").
|
|
7
|
+
*/
|
|
8
|
+
api?: string;
|
|
9
|
+
/** Base URL of the Kognitive runtime. Combined with agentName to construct the stream URL. */
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
/** Agent name. Used with baseUrl to build the URL. Also sent in body when using `api` mode. */
|
|
12
|
+
agentName?: string;
|
|
13
|
+
/** Current session/thread ID — sent in every request body */
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
/** User identity — sent in every request body as resourceId */
|
|
16
|
+
resourceId?: {
|
|
17
|
+
userId?: string;
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
organizationId?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Additional headers (e.g., auth) */
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
/** Extra fields merged into every request body (e.g., { agentName: "assistant" }) */
|
|
24
|
+
body?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export declare function createKognitiveTransport(config: KognitiveTransportConfig): DefaultChatTransport<UIMessage>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.createKognitiveTransport = createKognitiveTransport;
|
|
15
|
+
const ai_1 = require("ai");
|
|
16
|
+
function createKognitiveTransport(config) {
|
|
17
|
+
var _a;
|
|
18
|
+
let apiUrl;
|
|
19
|
+
if (config.api) {
|
|
20
|
+
apiUrl = config.api;
|
|
21
|
+
}
|
|
22
|
+
else if (config.baseUrl && config.agentName) {
|
|
23
|
+
apiUrl = `${config.baseUrl.replace(/\/$/, "")}/api/agents/${encodeURIComponent(config.agentName)}/stream`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error("createKognitiveTransport requires either `api` or both `baseUrl` and `agentName`.");
|
|
27
|
+
}
|
|
28
|
+
return new ai_1.DefaultChatTransport({
|
|
29
|
+
api: apiUrl,
|
|
30
|
+
headers: (_a = config.headers) !== null && _a !== void 0 ? _a : {},
|
|
31
|
+
body: () => {
|
|
32
|
+
var _a;
|
|
33
|
+
return (Object.assign(Object.assign(Object.assign(Object.assign({}, ((_a = config.body) !== null && _a !== void 0 ? _a : {})), (config.agentName && config.api ? { agentName: config.agentName } : {})), (config.sessionId ? { sessionId: config.sessionId } : {})), (config.resourceId ? { resourceId: config.resourceId } : {})));
|
|
34
|
+
},
|
|
35
|
+
prepareSendMessagesRequest: async ({ messages, body }) => ({
|
|
36
|
+
body: Object.assign(Object.assign({}, (body !== null && body !== void 0 ? body : {})), { messages: await (0, ai_1.convertToModelMessages)(messages.map((_a) => {
|
|
37
|
+
var { id: _id } = _a, message = __rest(_a, ["id"]);
|
|
38
|
+
return message;
|
|
39
|
+
})) }),
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ThreadSummary, ThreadDetail } from "./types";
|
|
2
|
+
export interface ThreadManagerConfig {
|
|
3
|
+
/** Base URL for thread API endpoints */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Additional headers (e.g., auth) */
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare class ThreadManager {
|
|
9
|
+
private baseUrl;
|
|
10
|
+
private headers;
|
|
11
|
+
constructor(config: ThreadManagerConfig);
|
|
12
|
+
list(): Promise<ThreadSummary[]>;
|
|
13
|
+
get(sessionId: string): Promise<ThreadDetail>;
|
|
14
|
+
create(): Promise<ThreadSummary>;
|
|
15
|
+
fork(sessionId: string): Promise<ThreadSummary>;
|
|
16
|
+
interrupt(sessionId: string): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThreadManager = void 0;
|
|
4
|
+
class ThreadManager {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
var _a;
|
|
7
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
8
|
+
this.headers = Object.assign({ "Content-Type": "application/json" }, ((_a = config.headers) !== null && _a !== void 0 ? _a : {}));
|
|
9
|
+
}
|
|
10
|
+
async list() {
|
|
11
|
+
var _a;
|
|
12
|
+
const res = await fetch(this.baseUrl, { headers: this.headers });
|
|
13
|
+
if (!res.ok) {
|
|
14
|
+
throw new Error((await res.json().catch(() => ({ error: "Failed to list threads" }))).error);
|
|
15
|
+
}
|
|
16
|
+
const data = await res.json();
|
|
17
|
+
return ((_a = data.threads) !== null && _a !== void 0 ? _a : []);
|
|
18
|
+
}
|
|
19
|
+
async get(sessionId) {
|
|
20
|
+
const res = await fetch(`${this.baseUrl}/${encodeURIComponent(sessionId)}`, {
|
|
21
|
+
headers: this.headers,
|
|
22
|
+
});
|
|
23
|
+
if (!res.ok) {
|
|
24
|
+
throw new Error((await res.json().catch(() => ({ error: "Failed to get thread" }))).error);
|
|
25
|
+
}
|
|
26
|
+
return (await res.json());
|
|
27
|
+
}
|
|
28
|
+
async create() {
|
|
29
|
+
const res = await fetch(this.baseUrl, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: this.headers,
|
|
32
|
+
body: JSON.stringify({}),
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
throw new Error((await res.json().catch(() => ({ error: "Failed to create thread" }))).error);
|
|
36
|
+
}
|
|
37
|
+
const data = await res.json();
|
|
38
|
+
return data.thread;
|
|
39
|
+
}
|
|
40
|
+
async fork(sessionId) {
|
|
41
|
+
const res = await fetch(`${this.baseUrl}/${encodeURIComponent(sessionId)}/fork`, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
headers: this.headers,
|
|
44
|
+
body: JSON.stringify({}),
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
throw new Error((await res.json().catch(() => ({ error: "Failed to fork thread" }))).error);
|
|
48
|
+
}
|
|
49
|
+
const data = await res.json();
|
|
50
|
+
return data.thread;
|
|
51
|
+
}
|
|
52
|
+
async interrupt(sessionId) {
|
|
53
|
+
const res = await fetch(`${this.baseUrl}/${encodeURIComponent(sessionId)}/interrupt`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: this.headers,
|
|
56
|
+
});
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
throw new Error((await res.json().catch(() => ({ error: "Failed to interrupt thread" }))).error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ThreadManager = ThreadManager;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type ThreadSummary = {
|
|
2
|
+
sessionDbId: string;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
title: string;
|
|
5
|
+
status: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
messageCount: number;
|
|
8
|
+
lastUserPreview: string;
|
|
9
|
+
lastAssistantPreview: string;
|
|
10
|
+
lastError?: string | null;
|
|
11
|
+
lastTraceDbId?: string | null;
|
|
12
|
+
};
|
|
13
|
+
export type ThreadEvent = {
|
|
14
|
+
id: string;
|
|
15
|
+
sequence: number;
|
|
16
|
+
eventType: "user_message" | "assistant_message" | "tool_call" | "tool_result" | "status";
|
|
17
|
+
payload: Record<string, unknown>;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
};
|
|
20
|
+
export type ThreadTrace = {
|
|
21
|
+
id: string;
|
|
22
|
+
traceId: string;
|
|
23
|
+
state: string;
|
|
24
|
+
durationMs: number | null;
|
|
25
|
+
totalCostCents: number;
|
|
26
|
+
inputTokens: number;
|
|
27
|
+
outputTokens: number;
|
|
28
|
+
modelId: string | null;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
};
|
|
31
|
+
export type ThreadRun = {
|
|
32
|
+
id: string;
|
|
33
|
+
runId: string;
|
|
34
|
+
agentName: string;
|
|
35
|
+
status: string;
|
|
36
|
+
triggerType: string;
|
|
37
|
+
inputPreview: string | null;
|
|
38
|
+
outputPreview: string | null;
|
|
39
|
+
inputTokens: number;
|
|
40
|
+
outputTokens: number;
|
|
41
|
+
totalCostCents: number;
|
|
42
|
+
durationMs: number | null;
|
|
43
|
+
startedAt: string;
|
|
44
|
+
completedAt: string | null;
|
|
45
|
+
parentRunId: string | null;
|
|
46
|
+
};
|
|
47
|
+
export type ThreadDetail = {
|
|
48
|
+
session: {
|
|
49
|
+
id: string;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
messageCount: number;
|
|
52
|
+
metadata?: Record<string, unknown> | null;
|
|
53
|
+
};
|
|
54
|
+
events: ThreadEvent[];
|
|
55
|
+
traces: ThreadTrace[];
|
|
56
|
+
runs: ThreadRun[];
|
|
57
|
+
};
|
|
58
|
+
export type RuntimeStatus = "ready" | "submitted" | "streaming" | "error";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ToolUIRenderProps, ToolUIRegistration } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Options for makeToolUI when using a @kognitivedev/tools Tool definition.
|
|
5
|
+
* The tool's inputSchema and outputSchema provide type inference.
|
|
6
|
+
*/
|
|
7
|
+
export interface MakeToolUIOptions<TInput = any, TOutput = any> {
|
|
8
|
+
/** The tool definition from createTool(). Provides name and type info. */
|
|
9
|
+
tool: {
|
|
10
|
+
id: string;
|
|
11
|
+
inputSchema?: unknown;
|
|
12
|
+
outputSchema?: unknown;
|
|
13
|
+
};
|
|
14
|
+
/** Render function with fully typed props from the tool definition. */
|
|
15
|
+
render: (props: ToolUIRenderProps<TInput, TOutput>) => ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Options for makeToolUI when registering by tool name string.
|
|
19
|
+
*/
|
|
20
|
+
export interface MakeToolUIByNameOptions {
|
|
21
|
+
/** The tool name (must match the tool ID used on the server) */
|
|
22
|
+
toolName: string;
|
|
23
|
+
/** Render function for the tool UI */
|
|
24
|
+
render: (props: ToolUIRenderProps) => ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a type-safe tool UI registration from a @kognitivedev/tools Tool definition.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const weatherTool = createTool({
|
|
32
|
+
* id: "get_weather",
|
|
33
|
+
* inputSchema: z.object({ city: z.string() }),
|
|
34
|
+
* execute: async ({ city }) => ({ temp: 22 }),
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* const WeatherUI = makeToolUI({
|
|
38
|
+
* tool: weatherTool,
|
|
39
|
+
* render: ({ input, output, state }) => (
|
|
40
|
+
* <div>{input.city}: {output?.temp}°</div>
|
|
41
|
+
* ),
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function makeToolUI<TInput, TOutput>(options: MakeToolUIOptions<TInput, TOutput>): ToolUIRegistration;
|
|
46
|
+
/**
|
|
47
|
+
* Create a tool UI registration by tool name string.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const SearchUI = makeToolUI({
|
|
52
|
+
* toolName: "search",
|
|
53
|
+
* render: ({ input, output, state }) => (
|
|
54
|
+
* <div>Searching for {input.query}...</div>
|
|
55
|
+
* ),
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function makeToolUI(options: MakeToolUIByNameOptions): ToolUIRegistration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeToolUI = makeToolUI;
|
|
4
|
+
function makeToolUI(options) {
|
|
5
|
+
const toolName = "tool" in options ? options.tool.id : options.toolName;
|
|
6
|
+
return {
|
|
7
|
+
toolName,
|
|
8
|
+
component: options.render,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolUIComponent, ToolUIRegistration } from "./types";
|
|
2
|
+
export declare class ToolUIRegistry {
|
|
3
|
+
private map;
|
|
4
|
+
register(registration: ToolUIRegistration): void;
|
|
5
|
+
registerAll(registrations: ToolUIRegistration[]): void;
|
|
6
|
+
get(toolName: string): ToolUIComponent | undefined;
|
|
7
|
+
has(toolName: string): boolean;
|
|
8
|
+
names(): string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolUIRegistry = void 0;
|
|
4
|
+
class ToolUIRegistry {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.map = new Map();
|
|
7
|
+
}
|
|
8
|
+
register(registration) {
|
|
9
|
+
this.map.set(registration.toolName, registration.component);
|
|
10
|
+
}
|
|
11
|
+
registerAll(registrations) {
|
|
12
|
+
for (const reg of registrations) {
|
|
13
|
+
this.register(reg);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
get(toolName) {
|
|
17
|
+
return this.map.get(toolName);
|
|
18
|
+
}
|
|
19
|
+
has(toolName) {
|
|
20
|
+
return this.map.has(toolName);
|
|
21
|
+
}
|
|
22
|
+
names() {
|
|
23
|
+
return Array.from(this.map.keys());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ToolUIRegistry = ToolUIRegistry;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ToolUIRegistryContext = exports.useToolUIRegistry = exports.ToolUIRegistryProvider = void 0;
|
|
5
|
+
const create_context_1 = require("../utils/create-context");
|
|
6
|
+
_a = (0, create_context_1.createContext)("ToolUIRegistry"), exports.ToolUIRegistryProvider = _a[0], exports.useToolUIRegistry = _a[1], exports.ToolUIRegistryContext = _a[2];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ToolUIRenderProps, ToolUIRegistration } from "./types";
|
|
3
|
+
export interface ToolkitEntry {
|
|
4
|
+
/** Render function for this tool's UI */
|
|
5
|
+
render: (props: ToolUIRenderProps) => ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Register multiple tool UIs at once by tool name.
|
|
9
|
+
*
|
|
10
|
+
* Useful when you don't have the Tool objects on the client
|
|
11
|
+
* (e.g., backend-only tools) but still want custom renderers.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const myToolkit = toolkit({
|
|
16
|
+
* get_weather: {
|
|
17
|
+
* render: ({ input, output, state }) => (
|
|
18
|
+
* <WeatherCard city={input.city} data={output} />
|
|
19
|
+
* ),
|
|
20
|
+
* },
|
|
21
|
+
* search_database: {
|
|
22
|
+
* render: ({ input, output }) => (
|
|
23
|
+
* <QueryResults query={input.query} results={output?.rows} />
|
|
24
|
+
* ),
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* <KognitiveUI toolkit={myToolkit} ... />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function toolkit(map: Record<string, ToolkitEntry>): ToolUIRegistration[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toolkit = toolkit;
|
|
4
|
+
/**
|
|
5
|
+
* Register multiple tool UIs at once by tool name.
|
|
6
|
+
*
|
|
7
|
+
* Useful when you don't have the Tool objects on the client
|
|
8
|
+
* (e.g., backend-only tools) but still want custom renderers.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const myToolkit = toolkit({
|
|
13
|
+
* get_weather: {
|
|
14
|
+
* render: ({ input, output, state }) => (
|
|
15
|
+
* <WeatherCard city={input.city} data={output} />
|
|
16
|
+
* ),
|
|
17
|
+
* },
|
|
18
|
+
* search_database: {
|
|
19
|
+
* render: ({ input, output }) => (
|
|
20
|
+
* <QueryResults query={input.query} results={output?.rows} />
|
|
21
|
+
* ),
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* <KognitiveUI toolkit={myToolkit} ... />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function toolkit(map) {
|
|
29
|
+
return Object.entries(map).map(([toolName, entry]) => ({
|
|
30
|
+
toolName,
|
|
31
|
+
component: entry.render,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
export type ToolInvocationState = "input-streaming" | "input-available" | "approval-requested" | "approval-responded" | "output-available" | "error";
|
|
3
|
+
export interface ToolUIRenderProps<TInput = any, TOutput = any> {
|
|
4
|
+
/** The tool's input arguments */
|
|
5
|
+
input: TInput;
|
|
6
|
+
/** The tool's output (undefined while executing) */
|
|
7
|
+
output: TOutput | undefined;
|
|
8
|
+
/** Current state of the tool invocation */
|
|
9
|
+
state: ToolInvocationState;
|
|
10
|
+
/** The tool call ID */
|
|
11
|
+
toolCallId: string;
|
|
12
|
+
/** The tool name */
|
|
13
|
+
toolName: string;
|
|
14
|
+
}
|
|
15
|
+
export type ToolUIComponent = ComponentType<ToolUIRenderProps<any, any>>;
|
|
16
|
+
export interface ToolUIRegistration {
|
|
17
|
+
toolName: string;
|
|
18
|
+
component: ToolUIComponent;
|
|
19
|
+
}
|
package/dist/utils/cn.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cn = cn;
|
|
4
|
+
const clsx_1 = require("clsx");
|
|
5
|
+
const tailwind_merge_1 = require("tailwind-merge");
|
|
6
|
+
function cn(...inputs) {
|
|
7
|
+
return (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(inputs));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createContext<T>(name: string): readonly [import("react").Provider<T | null>, () => T, import("react").Context<T | null>];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContext = createContext;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function createContext(name) {
|
|
6
|
+
const Context = (0, react_1.createContext)(null);
|
|
7
|
+
Context.displayName = name;
|
|
8
|
+
function useContextValue() {
|
|
9
|
+
const value = (0, react_1.useContext)(Context);
|
|
10
|
+
if (value === null) {
|
|
11
|
+
throw new Error(`use${name} must be used within a <${name}Provider>`);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
return [Context.Provider, useContextValue, Context];
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UIMessage } from "ai";
|
|
2
|
+
export declare function extractTextContent(content: unknown): string;
|
|
3
|
+
export declare function getMessageText(message: UIMessage): string;
|
|
4
|
+
export declare function getMessagePreview(message: UIMessage, maxLength?: number): string;
|
|
5
|
+
export declare function getToolInvocations(message: UIMessage): import("ai").UIMessagePart<import("ai").UIDataTypes, import("ai").UITools>[];
|
|
6
|
+
export declare function hasToolInvocations(message: UIMessage): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractTextContent = extractTextContent;
|
|
4
|
+
exports.getMessageText = getMessageText;
|
|
5
|
+
exports.getMessagePreview = getMessagePreview;
|
|
6
|
+
exports.getToolInvocations = getToolInvocations;
|
|
7
|
+
exports.hasToolInvocations = hasToolInvocations;
|
|
8
|
+
function extractTextContent(content) {
|
|
9
|
+
if (typeof content === "string")
|
|
10
|
+
return content;
|
|
11
|
+
if (!Array.isArray(content))
|
|
12
|
+
return "";
|
|
13
|
+
return content
|
|
14
|
+
.map((part) => {
|
|
15
|
+
if (!part || typeof part !== "object")
|
|
16
|
+
return "";
|
|
17
|
+
if ("text" in part && typeof part.text === "string")
|
|
18
|
+
return part.text;
|
|
19
|
+
return "";
|
|
20
|
+
})
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join("\n")
|
|
23
|
+
.trim();
|
|
24
|
+
}
|
|
25
|
+
function getMessageText(message) {
|
|
26
|
+
return message.parts
|
|
27
|
+
.filter((part) => part.type === "text")
|
|
28
|
+
.map((part) => part.text)
|
|
29
|
+
.join("\n")
|
|
30
|
+
.trim();
|
|
31
|
+
}
|
|
32
|
+
function getMessagePreview(message, maxLength = 80) {
|
|
33
|
+
const text = getMessageText(message);
|
|
34
|
+
if (text.length <= maxLength)
|
|
35
|
+
return text;
|
|
36
|
+
return text.slice(0, maxLength).trimEnd() + "...";
|
|
37
|
+
}
|
|
38
|
+
function isToolPart(part) {
|
|
39
|
+
return part.type.startsWith("tool-") || part.type === "dynamic-tool";
|
|
40
|
+
}
|
|
41
|
+
function getToolInvocations(message) {
|
|
42
|
+
return message.parts.filter((part) => isToolPart(part));
|
|
43
|
+
}
|
|
44
|
+
function hasToolInvocations(message) {
|
|
45
|
+
return message.parts.some((part) => isToolPart(part));
|
|
46
|
+
}
|