@rendkit/copilotkit 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rendkit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @rendkit/copilotkit
2
+
3
+ The [CopilotKit v2](https://copilotkit.ai) adapter for the
4
+ [Rendkit](https://github.com/rendkit-ui/rendkit) agentic component catalog.
5
+
6
+ CopilotKit ships the sockets (`useFrontendTool`, `useHumanInTheLoop`); Rendkit is
7
+ the components you bring. This package binds a Rendkit catalog to CopilotKit and
8
+ exposes only that value-add — it never re-exports CopilotKit's own runtime or
9
+ client primitives, so your host owns the `@copilotkit/*` version directly.
10
+
11
+ - `RegisterCatalog` — mount one registration wrapper per catalog def; display
12
+ defs register via `useFrontendTool`, interactive defs via `useHumanInTheLoop`.
13
+ - Every render path runs `schema.safeParse` and degrades to a `FallbackCard` on
14
+ invalid args (CopilotKit does no runtime validation of tool args).
15
+ - `checkSchemaBudget` / `checkSchemaPortability` — advertised-schema byte budget
16
+ and the portable tool-schema subset check, for tests and `/debug` surfaces.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @rendkit/copilotkit @rendkit/core
22
+ # peers you already own as a CopilotKit v2 host:
23
+ npm install @copilotkit/react-core@1.62.3 react zod
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```tsx
29
+ "use client";
30
+
31
+ import { RegisterCatalog } from "@rendkit/copilotkit";
32
+ import "@rendkit/copilotkit/styles.css";
33
+ import { createCatalogRegistry } from "./catalog"; // your copied catalog
34
+
35
+ const registry = createCatalogRegistry();
36
+
37
+ export function Chat() {
38
+ return <RegisterCatalog registry={registry} />;
39
+ }
40
+ ```
41
+
42
+ The package is **ESM-only** — any CopilotKit v2 host is ESM-capable by
43
+ construction (the upstream runtime is ESM-only). Client components ship with the
44
+ `"use client"` directive preserved, so they import cleanly in Next.js App Router
45
+ without `transpilePackages`.
46
+
47
+ Subpath exports: `.`, `./fallback-card`, `./schema`, `./styles.css`.
48
+
49
+ ## License
50
+
51
+ MIT
@@ -0,0 +1,16 @@
1
+ import { ComponentType } from 'react';
2
+ import { ComponentDef } from '@rendkit/core';
3
+ import { RndDebugEvent } from './tool-bridge.js';
4
+ import { FallbackProps } from './fallback-card.js';
5
+ import './upstream.js';
6
+ import 'zod';
7
+ import '@copilotkit/react-core/v2';
8
+
9
+ type DisplayToolProps = {
10
+ def: ComponentDef;
11
+ fallback?: ComponentType<FallbackProps>;
12
+ onEvent?: (event: RndDebugEvent) => void;
13
+ };
14
+ declare const DisplayTool: ({ def, fallback, onEvent }: DisplayToolProps) => null;
15
+
16
+ export { DisplayTool };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useFrontendTool } from "./upstream";
4
+ import { ToolBridge } from "./tool-bridge";
5
+ const DisplayTool = ({ def, fallback, onEvent }) => {
6
+ useFrontendTool({
7
+ name: def.name,
8
+ description: def.description,
9
+ parameters: def.parameters,
10
+ handler: async () => ({ displayed: true }),
11
+ render: (props) => /* @__PURE__ */ jsx(ToolBridge, { def, upstream: props, fallback, onEvent })
12
+ });
13
+ return null;
14
+ };
15
+ export {
16
+ DisplayTool
17
+ };
@@ -0,0 +1,9 @@
1
+ import * as react from 'react';
2
+
3
+ type FallbackProps = {
4
+ toolName: string;
5
+ args: unknown;
6
+ };
7
+ declare const FallbackCard: ({ toolName, args }: FallbackProps) => react.JSX.Element;
8
+
9
+ export { FallbackCard, type FallbackProps };
@@ -0,0 +1,45 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ const cardStyle = {
3
+ background: "var(--gk-card, var(--card, transparent))",
4
+ color: "var(--gk-card-foreground, var(--card-foreground, inherit))",
5
+ border: "1px solid var(--gk-border, var(--border, currentColor))",
6
+ borderRadius: "var(--gk-radius, var(--radius, 0.5rem))",
7
+ padding: "12px 16px",
8
+ fontSize: "0.875rem",
9
+ lineHeight: 1.5
10
+ };
11
+ const summaryStyle = {
12
+ cursor: "pointer",
13
+ color: "var(--gk-muted-foreground, var(--muted-foreground, inherit))",
14
+ fontSize: "0.75rem"
15
+ };
16
+ const argsStyle = {
17
+ margin: "8px 0 0",
18
+ padding: 8,
19
+ maxHeight: 240,
20
+ overflow: "auto",
21
+ // chat clips at 768px with no horizontal scroll — scroll internally
22
+ fontSize: "0.75rem",
23
+ background: "var(--gk-muted, var(--muted, transparent))",
24
+ borderRadius: "var(--gk-radius, var(--radius, 0.5rem))"
25
+ };
26
+ function safeStringify(value) {
27
+ try {
28
+ return JSON.stringify(value, null, 2) ?? String(value);
29
+ } catch {
30
+ return String(value);
31
+ }
32
+ }
33
+ const FallbackCard = ({ toolName, args }) => /* @__PURE__ */ jsxs("div", { role: "status", style: cardStyle, children: [
34
+ /* @__PURE__ */ jsxs("p", { style: { margin: 0 }, children: [
35
+ /* @__PURE__ */ jsx("strong", { children: toolName }),
36
+ " couldn't render this response."
37
+ ] }),
38
+ /* @__PURE__ */ jsxs("details", { style: { marginTop: 8 }, children: [
39
+ /* @__PURE__ */ jsx("summary", { style: summaryStyle, children: "Raw arguments" }),
40
+ /* @__PURE__ */ jsx("pre", { style: argsStyle, children: safeStringify(args) })
41
+ ] })
42
+ ] });
43
+ export {
44
+ FallbackCard
45
+ };
@@ -0,0 +1,12 @@
1
+ export { RegisterCatalog } from './register-catalog.js';
2
+ export { DisplayTool } from './display-tool.js';
3
+ export { InteractiveTool } from './interactive-tool.js';
4
+ export { RndDebugEvent, ToolBridge } from './tool-bridge.js';
5
+ export { FallbackCard, FallbackProps } from './fallback-card.js';
6
+ export { MAX_DEF_SCHEMA_BYTES, MAX_REGISTRY_SCHEMA_BYTES, SchemaBudgetReport, checkSchemaBudget, serializeAdvertisedTool, serializedToolSchemaBytes } from './schema-budget.js';
7
+ export { SchemaPortabilityReport, checkSchemaPortability } from './schema-portability.js';
8
+ import 'react';
9
+ import '@rendkit/core';
10
+ import './upstream.js';
11
+ import 'zod';
12
+ import '@copilotkit/react-core/v2';
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import { RegisterCatalog } from "./register-catalog";
2
+ import { DisplayTool } from "./display-tool";
3
+ import { InteractiveTool } from "./interactive-tool";
4
+ import { ToolBridge } from "./tool-bridge";
5
+ import { FallbackCard } from "./fallback-card";
6
+ import {
7
+ MAX_DEF_SCHEMA_BYTES,
8
+ MAX_REGISTRY_SCHEMA_BYTES,
9
+ checkSchemaBudget,
10
+ serializeAdvertisedTool,
11
+ serializedToolSchemaBytes
12
+ } from "./schema-budget";
13
+ import {
14
+ checkSchemaPortability
15
+ } from "./schema-portability";
16
+ export {
17
+ DisplayTool,
18
+ FallbackCard,
19
+ InteractiveTool,
20
+ MAX_DEF_SCHEMA_BYTES,
21
+ MAX_REGISTRY_SCHEMA_BYTES,
22
+ RegisterCatalog,
23
+ ToolBridge,
24
+ checkSchemaBudget,
25
+ checkSchemaPortability,
26
+ serializeAdvertisedTool,
27
+ serializedToolSchemaBytes
28
+ };
@@ -0,0 +1,16 @@
1
+ import { ComponentType } from 'react';
2
+ import { ComponentDef } from '@rendkit/core';
3
+ import { RndDebugEvent } from './tool-bridge.js';
4
+ import { FallbackProps } from './fallback-card.js';
5
+ import './upstream.js';
6
+ import 'zod';
7
+ import '@copilotkit/react-core/v2';
8
+
9
+ type InteractiveToolProps = {
10
+ def: ComponentDef;
11
+ fallback?: ComponentType<FallbackProps>;
12
+ onEvent?: (event: RndDebugEvent) => void;
13
+ };
14
+ declare const InteractiveTool: ({ def, fallback, onEvent }: InteractiveToolProps) => null;
15
+
16
+ export { InteractiveTool };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useHumanInTheLoop } from "./upstream";
4
+ import { ToolBridge } from "./tool-bridge";
5
+ const InteractiveTool = ({ def, fallback, onEvent }) => {
6
+ useHumanInTheLoop({
7
+ name: def.name,
8
+ description: def.description,
9
+ parameters: def.parameters,
10
+ render: (props) => /* @__PURE__ */ jsx(ToolBridge, { def, upstream: props, fallback, onEvent })
11
+ });
12
+ return null;
13
+ };
14
+ export {
15
+ InteractiveTool
16
+ };
@@ -0,0 +1,17 @@
1
+ import * as react from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { ComponentRegistry } from '@rendkit/core';
4
+ import { FallbackProps } from './fallback-card.js';
5
+ import { RndDebugEvent } from './tool-bridge.js';
6
+ import './upstream.js';
7
+ import 'zod';
8
+ import '@copilotkit/react-core/v2';
9
+
10
+ type RegisterCatalogProps = {
11
+ registry: ComponentRegistry;
12
+ fallback?: ComponentType<FallbackProps>;
13
+ onEvent?: (event: RndDebugEvent) => void;
14
+ };
15
+ declare const RegisterCatalog: ({ registry, fallback, onEvent }: RegisterCatalogProps) => react.JSX.Element;
16
+
17
+ export { RegisterCatalog };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import { DisplayTool } from "./display-tool";
4
+ import { InteractiveTool } from "./interactive-tool";
5
+ const RegisterCatalog = ({ registry, fallback, onEvent }) => /* @__PURE__ */ jsx(Fragment, { children: registry.defs.map(
6
+ (def) => def.kind === "display" ? /* @__PURE__ */ jsx(DisplayTool, { def, fallback, onEvent }, def.name) : /* @__PURE__ */ jsx(InteractiveTool, { def, fallback, onEvent }, def.name)
7
+ ) });
8
+ export {
9
+ RegisterCatalog
10
+ };
@@ -0,0 +1,11 @@
1
+ import { RndEvent } from '@rendkit/core';
2
+
3
+ type CreateRespondParams = {
4
+ tool: string;
5
+ toolCallId: string;
6
+ events: readonly string[];
7
+ send: (envelope: RndEvent) => Promise<void>;
8
+ };
9
+ declare function createRespond({ tool, toolCallId, events, send, }: CreateRespondParams): (action: string, payload?: unknown) => Promise<void>;
10
+
11
+ export { type CreateRespondParams, createRespond };
@@ -0,0 +1,22 @@
1
+ function createRespond({
2
+ tool,
3
+ toolCallId,
4
+ events,
5
+ send
6
+ }) {
7
+ let consumed = false;
8
+ return async (action, payload) => {
9
+ if (!events.includes(action)) {
10
+ throw new Error(
11
+ `respond: action "${action}" is not declared in events of "${tool}" (allowed: ${events.join(", ")})`
12
+ );
13
+ }
14
+ if (consumed) return;
15
+ consumed = true;
16
+ const envelope = { tool, toolCallId, action, payload: payload ?? null };
17
+ await send(envelope);
18
+ };
19
+ }
20
+ export {
21
+ createRespond
22
+ };
@@ -0,0 +1,22 @@
1
+ import { ComponentDef } from '@rendkit/core';
2
+ export { SchemaPortabilityReport, checkSchemaPortability } from './schema-portability.js';
3
+
4
+ declare const MAX_DEF_SCHEMA_BYTES = 1536;
5
+ declare const MAX_REGISTRY_SCHEMA_BYTES: number;
6
+ type SchemaBudgetReport = {
7
+ perDef: {
8
+ name: string;
9
+ bytes: number;
10
+ }[];
11
+ totalBytes: number;
12
+ violations: string[];
13
+ };
14
+ declare function serializeAdvertisedTool(def: Pick<ComponentDef, "name" | "description" | "parameters">): {
15
+ name: string;
16
+ description: string;
17
+ parameters: unknown;
18
+ };
19
+ declare function serializedToolSchemaBytes(def: Pick<ComponentDef, "name" | "description" | "parameters">): number;
20
+ declare function checkSchemaBudget(defs: readonly ComponentDef[]): SchemaBudgetReport;
21
+
22
+ export { MAX_DEF_SCHEMA_BYTES, MAX_REGISTRY_SCHEMA_BYTES, type SchemaBudgetReport, checkSchemaBudget, serializeAdvertisedTool, serializedToolSchemaBytes };
@@ -0,0 +1,38 @@
1
+ import { zodToJsonSchema } from "zod-to-json-schema";
2
+ import { checkSchemaPortability } from "./schema-portability";
3
+ const MAX_DEF_SCHEMA_BYTES = 1536;
4
+ const MAX_REGISTRY_SCHEMA_BYTES = 25 * 1024;
5
+ function serializeAdvertisedTool(def) {
6
+ return {
7
+ name: def.name,
8
+ description: def.description,
9
+ parameters: zodToJsonSchema(def.parameters)
10
+ };
11
+ }
12
+ function serializedToolSchemaBytes(def) {
13
+ return new TextEncoder().encode(JSON.stringify(serializeAdvertisedTool(def))).length;
14
+ }
15
+ function checkSchemaBudget(defs) {
16
+ const perDef = defs.map((def) => ({
17
+ name: def.name,
18
+ bytes: serializedToolSchemaBytes(def)
19
+ }));
20
+ const totalBytes = perDef.reduce((sum, entry) => sum + entry.bytes, 0);
21
+ const violations = perDef.filter((entry) => entry.bytes > MAX_DEF_SCHEMA_BYTES).map(
22
+ (entry) => `def "${entry.name}" schema is ${entry.bytes} bytes (budget ${MAX_DEF_SCHEMA_BYTES})`
23
+ );
24
+ if (totalBytes > MAX_REGISTRY_SCHEMA_BYTES) {
25
+ violations.push(
26
+ `registry total is ${totalBytes} bytes (budget ${MAX_REGISTRY_SCHEMA_BYTES})`
27
+ );
28
+ }
29
+ return { perDef, totalBytes, violations };
30
+ }
31
+ export {
32
+ MAX_DEF_SCHEMA_BYTES,
33
+ MAX_REGISTRY_SCHEMA_BYTES,
34
+ checkSchemaBudget,
35
+ checkSchemaPortability,
36
+ serializeAdvertisedTool,
37
+ serializedToolSchemaBytes
38
+ };
@@ -0,0 +1,9 @@
1
+ import { ComponentDef } from '@rendkit/core';
2
+
3
+ type DefLike = Pick<ComponentDef, "name" | "description" | "parameters">;
4
+ type SchemaPortabilityReport = {
5
+ violations: string[];
6
+ };
7
+ declare function checkSchemaPortability(defs: readonly DefLike[]): SchemaPortabilityReport;
8
+
9
+ export { type SchemaPortabilityReport, checkSchemaPortability };
@@ -0,0 +1,60 @@
1
+ import { zodToJsonSchema } from "zod-to-json-schema";
2
+ const PORTABLE_LEAF_TYPES = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
3
+ function checkSchemaPortability(defs) {
4
+ const violations = [];
5
+ for (const def of defs) {
6
+ walk(zodToJsonSchema(def.parameters), `${def.name}:`, violations);
7
+ }
8
+ return { violations };
9
+ }
10
+ function walk(node, path, violations) {
11
+ if (typeof node !== "object" || node === null) {
12
+ violations.push(`${path} unsupported non-object schema node`);
13
+ return;
14
+ }
15
+ const schema = node;
16
+ for (const combinator of ["anyOf", "oneOf", "allOf", "not"]) {
17
+ if (combinator in schema) {
18
+ violations.push(`${path} uses ${combinator} (type union/composition \u2014 not in the portable subset)`);
19
+ return;
20
+ }
21
+ }
22
+ const type = schema.type;
23
+ if (Array.isArray(type)) {
24
+ violations.push(`${path} declares a type union ${JSON.stringify(type)} (anyOf-equivalent)`);
25
+ return;
26
+ }
27
+ if (type === "object") {
28
+ const additional = schema.additionalProperties;
29
+ if (additional !== void 0 && additional !== false) {
30
+ violations.push(`${path} allows dynamic-key records via additionalProperties`);
31
+ return;
32
+ }
33
+ const properties = schema.properties;
34
+ if (typeof properties !== "object" || properties === null || Object.keys(properties).length === 0) {
35
+ violations.push(`${path} is an object without fixed keys (empty/free-form objects are rejected)`);
36
+ return;
37
+ }
38
+ for (const [key, child] of Object.entries(properties)) {
39
+ walk(child, `${path}.${key}`, violations);
40
+ }
41
+ return;
42
+ }
43
+ if (type === "array") {
44
+ if (schema.items === void 0) {
45
+ violations.push(`${path} is an array without an items schema`);
46
+ return;
47
+ }
48
+ walk(schema.items, `${path}[]`, violations);
49
+ return;
50
+ }
51
+ if (typeof type === "string" && PORTABLE_LEAF_TYPES.has(type)) {
52
+ return;
53
+ }
54
+ violations.push(
55
+ `${path} has unsupported type ${JSON.stringify(type ?? "(none)")} \u2014 portable leaves are string/number/integer/boolean`
56
+ );
57
+ }
58
+ export {
59
+ checkSchemaPortability
60
+ };
@@ -0,0 +1,5 @@
1
+ import { RndStatus } from '@rendkit/core';
2
+
3
+ declare function toRndStatus(status: string): RndStatus;
4
+
5
+ export { toRndStatus };
package/dist/status.js ADDED
@@ -0,0 +1,9 @@
1
+ function toRndStatus(status) {
2
+ if (status === "inProgress" || status === "executing" || status === "complete") {
3
+ return status;
4
+ }
5
+ throw new Error(`Unknown upstream tool call status "${status}"`);
6
+ }
7
+ export {
8
+ toRndStatus
9
+ };
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Chat UI stylesheet seam. Hosts import THIS file, never the upstream path
3
+ * directly (CLAUDE.md #9 — the boundary script does not scan CSS, but the
4
+ * one-file-fix discipline applies to stylesheets the same way).
5
+ */
6
+ @import "@copilotkit/react-core/v2/styles.css";
@@ -0,0 +1,23 @@
1
+ import * as react from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { ComponentDef } from '@rendkit/core';
4
+ import { UpstreamRenderProps } from './upstream.js';
5
+ import { FallbackProps } from './fallback-card.js';
6
+ import 'zod';
7
+ import '@copilotkit/react-core/v2';
8
+
9
+ type RndDebugEvent = {
10
+ tool: string;
11
+ toolCallId: string;
12
+ kind: ComponentDef["kind"];
13
+ result: unknown;
14
+ };
15
+ type ToolBridgeProps = {
16
+ def: ComponentDef;
17
+ upstream: UpstreamRenderProps;
18
+ fallback?: ComponentType<FallbackProps>;
19
+ onEvent?: (event: RndDebugEvent) => void;
20
+ };
21
+ declare const ToolBridge: ({ def, upstream, fallback, onEvent }: ToolBridgeProps) => react.JSX.Element;
22
+
23
+ export { type RndDebugEvent, ToolBridge };
@@ -0,0 +1,79 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useEffect, useMemo } from "react";
4
+ import { toRndStatus } from "./status";
5
+ import { createRespond } from "./respond";
6
+ import { FallbackCard } from "./fallback-card";
7
+ const ToolBridge = ({ def, upstream, fallback, onEvent }) => {
8
+ const status = toRndStatus(upstream.status);
9
+ const upstreamRespond = upstream.respond;
10
+ const respond = useMemo(
11
+ () => upstreamRespond === void 0 ? void 0 : createRespond({
12
+ tool: def.name,
13
+ toolCallId: upstream.toolCallId,
14
+ events: def.events ?? [],
15
+ send: upstreamRespond
16
+ }),
17
+ [def, upstream.toolCallId, upstreamRespond]
18
+ );
19
+ const result = useMemo(() => parseUpstreamResult(upstream.result), [upstream.result]);
20
+ const toolCallId = upstream.toolCallId;
21
+ useEffect(() => {
22
+ if (status === "complete" && result !== void 0) {
23
+ onEvent?.({ tool: def.name, toolCallId, kind: def.kind, result });
24
+ }
25
+ }, [status, result, def.name, def.kind, toolCallId, onEvent]);
26
+ const Component = def.component;
27
+ if (status === "inProgress") {
28
+ return /* @__PURE__ */ jsx(
29
+ Component,
30
+ {
31
+ args: toPartialArgs(upstream.args),
32
+ status,
33
+ toolCallId: upstream.toolCallId,
34
+ surface: "chat"
35
+ }
36
+ );
37
+ }
38
+ const parsed = def.parameters.safeParse(upstream.args);
39
+ if (!parsed.success) {
40
+ warnInvalidArgs(def.name, upstream.toolCallId, parsed.error);
41
+ const Fallback = fallback ?? FallbackCard;
42
+ return /* @__PURE__ */ jsx(Fallback, { toolName: def.name, args: upstream.args });
43
+ }
44
+ return /* @__PURE__ */ jsx(
45
+ Component,
46
+ {
47
+ args: parsed.data,
48
+ status,
49
+ toolCallId: upstream.toolCallId,
50
+ surface: "chat",
51
+ respond: status === "executing" ? respond : void 0,
52
+ result
53
+ }
54
+ );
55
+ };
56
+ function toPartialArgs(value) {
57
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
58
+ return value;
59
+ }
60
+ return {};
61
+ }
62
+ function parseUpstreamResult(result) {
63
+ if (result === void 0 || result === "") return void 0;
64
+ try {
65
+ return JSON.parse(result);
66
+ } catch {
67
+ return result;
68
+ }
69
+ }
70
+ function warnInvalidArgs(tool, toolCallId, error) {
71
+ console.warn("[rendkit] tool args failed schema validation; rendering FallbackCard", {
72
+ tool,
73
+ toolCallId,
74
+ issues: error.issues
75
+ });
76
+ }
77
+ export {
78
+ ToolBridge
79
+ };
@@ -0,0 +1,21 @@
1
+ import { ReactElement } from 'react';
2
+ import { z } from 'zod';
3
+ export { useFrontendTool, useHumanInTheLoop } from '@copilotkit/react-core/v2';
4
+
5
+ type UpstreamRenderProps = {
6
+ name: string;
7
+ toolCallId: string;
8
+ args: unknown;
9
+ status: string;
10
+ result: string | undefined;
11
+ respond?: (result: unknown) => Promise<void>;
12
+ };
13
+ type UpstreamToolConfig = {
14
+ name: string;
15
+ description: string;
16
+ parameters: z.ZodTypeAny;
17
+ handler?: (args: unknown) => Promise<unknown>;
18
+ render: (props: UpstreamRenderProps) => ReactElement | null;
19
+ };
20
+
21
+ export type { UpstreamRenderProps, UpstreamToolConfig };
@@ -0,0 +1,5 @@
1
+ import { useFrontendTool, useHumanInTheLoop } from "@copilotkit/react-core/v2";
2
+ export {
3
+ useFrontendTool,
4
+ useHumanInTheLoop
5
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@rendkit/copilotkit",
3
+ "version": "0.1.0",
4
+ "description": "CopilotKit v2 adapter for the Rendkit agentic component catalog — RegisterCatalog, the display/interactive tool bridges, the schema byte budget, and the portable-schema check.",
5
+ "keywords": [
6
+ "rendkit",
7
+ "copilotkit",
8
+ "agentic",
9
+ "generative-ui",
10
+ "ai",
11
+ "react",
12
+ "human-in-the-loop",
13
+ "shadcn"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "Houssem Djeghri",
17
+ "homepage": "https://github.com/rendkit-ui/rendkit#readme",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/rendkit-ui/rendkit.git",
21
+ "directory": "packages/copilotkit"
22
+ },
23
+ "type": "module",
24
+ "sideEffects": [
25
+ "**/*.css"
26
+ ],
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./fallback-card": {
34
+ "types": "./dist/fallback-card.d.ts",
35
+ "import": "./dist/fallback-card.js"
36
+ },
37
+ "./schema": {
38
+ "types": "./dist/schema-budget.d.ts",
39
+ "import": "./dist/schema-budget.js"
40
+ },
41
+ "./styles.css": "./dist/styles.css"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "LICENSE",
46
+ "README.md"
47
+ ],
48
+ "engines": {
49
+ "node": ">=18"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {
55
+ "zod-to-json-schema": "^3.25.2",
56
+ "@rendkit/core": "^0.1.0"
57
+ },
58
+ "peerDependencies": {
59
+ "@copilotkit/react-core": "1.62.3",
60
+ "react": "^18 || ^19",
61
+ "zod": "^3.25.0"
62
+ },
63
+ "devDependencies": {
64
+ "@copilotkit/react-core": "1.62.3",
65
+ "@testing-library/react": "^16.3.2",
66
+ "@types/react": "^19.1.0",
67
+ "happy-dom": "^20.10.6",
68
+ "react": "^19.1.0",
69
+ "react-dom": "^19.1.0",
70
+ "zod": "^3.25.76"
71
+ },
72
+ "scripts": {
73
+ "build": "tsup",
74
+ "typecheck": "tsc --noEmit",
75
+ "test": "vitest run"
76
+ },
77
+ "module": "./dist/index.js"
78
+ }