@copilotkit/react-native 1.71.2 → 1.72.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/USAGE.md +11 -12
- package/dist/CopilotKitProvider-Bpj5_ayo.mjs +118 -0
- package/dist/CopilotKitProvider-Bpj5_ayo.mjs.map +1 -0
- package/dist/CopilotKitProvider-DsAKy9gw.d.cts +67 -0
- package/dist/CopilotKitProvider-OJzclDZY.d.mts +67 -0
- package/dist/CopilotKitProvider-_pvFePrv.cjs +125 -0
- package/dist/CopilotKitProvider-_pvFePrv.cjs.map +1 -0
- package/dist/headless.cjs +8 -3
- package/dist/headless.d.cts +2 -2
- package/dist/headless.d.mts +2 -2
- package/dist/headless.mjs +2 -2
- package/dist/index.cjs +8 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
- package/src/__tests__/headless-entry-surface.test.ts +34 -88
- package/src/headless.ts +17 -18
- package/src/hooks/__tests__/useRenderTool.test.tsx +18 -480
- package/dist/useRenderTool-DFz206nL.d.cts +0 -149
- package/dist/useRenderTool-DsCxzyAP.d.mts +0 -149
- package/dist/useRenderTool-L3Rw6SYD.cjs +0 -298
- package/dist/useRenderTool-L3Rw6SYD.cjs.map +0 -1
- package/dist/useRenderTool-pLM3upcs.mjs +0 -285
- package/dist/useRenderTool-pLM3upcs.mjs.map +0 -1
- package/src/hooks/useRenderTool.ts +0 -501
|
@@ -108,12 +108,11 @@ const ALLOWED_REACT_CORE_ENTRIES = [
|
|
|
108
108
|
* were that `useComponent` (which registers into core's registry) rendered
|
|
109
109
|
* nowhere on RN, and that renderers vanished from chat history on unmount.
|
|
110
110
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* that
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* here) or stop calling core's hooks (caught there).
|
|
111
|
+
* This sits alongside the two identity assertions below rather than behind
|
|
112
|
+
* them. Identity pins what `useFrontendTool` and `useRenderTool` ARE; this pins
|
|
113
|
+
* that nothing ELSE in the graph has grown a registry to compete with core's —
|
|
114
|
+
* a component, a provider, a helper module that never touches either hook's
|
|
115
|
+
* name and would therefore pass identity untouched.
|
|
117
116
|
*/
|
|
118
117
|
const FORBIDDEN_REGISTRY_APIS: readonly (readonly [
|
|
119
118
|
identifier: string,
|
|
@@ -635,11 +634,9 @@ describe("@copilotkit/react-native/headless entry", () => {
|
|
|
635
634
|
// (src/hooks/__tests__/useRenderTool.test.tsx pins the behaviour; this pins
|
|
636
635
|
// the wiring).
|
|
637
636
|
//
|
|
638
|
-
//
|
|
639
|
-
//
|
|
640
|
-
//
|
|
641
|
-
// carry that half instead, deliberately at equal strength: the shim must
|
|
642
|
-
// DELEGATE, and no module in this entry's graph may own a registry.
|
|
637
|
+
// PR #6533 converged both names onto react-core behind a temporary
|
|
638
|
+
// routing shim, during which this half of the assertion could not be
|
|
639
|
+
// identity; #6976 removed the shim and the test below is identity again.
|
|
643
640
|
expect(
|
|
644
641
|
mod.useFrontendTool,
|
|
645
642
|
"`useFrontendTool` on the RN headless entry is NOT the binding from " +
|
|
@@ -649,27 +646,23 @@ describe("@copilotkit/react-native/headless entry", () => {
|
|
|
649
646
|
).toBe(coreHeadless.useFrontendTool);
|
|
650
647
|
});
|
|
651
648
|
|
|
652
|
-
it("
|
|
653
|
-
// The
|
|
654
|
-
//
|
|
655
|
-
//
|
|
649
|
+
it("exports react-core's `useRenderTool` ITSELF, not an RN copy of it", () => {
|
|
650
|
+
// The other half of the identity assertion above, and the one with the
|
|
651
|
+
// history. RN's local `useRenderTool` forwarded its whole body to core's
|
|
652
|
+
// `useFrontendTool`, so `name: "*"` registered a frontend tool literally
|
|
653
|
+
// named `*` — core's catch-all HANDLER name — and a display-only wildcard
|
|
654
|
+
// auto-answered every otherwise-unanswered tool call with an empty tool
|
|
655
|
+
// result and asked for a follow-up turn. Both names were present through
|
|
656
|
+
// that entire period, so every presence check above stayed green while
|
|
657
|
+
// verifying nothing about which hook a consumer gets.
|
|
656
658
|
//
|
|
657
|
-
//
|
|
658
|
-
//
|
|
659
|
-
//
|
|
660
|
-
//
|
|
661
|
-
//
|
|
662
|
-
//
|
|
663
|
-
//
|
|
664
|
-
// import BOTH core hooks from core's headless entry and CALL both. A
|
|
665
|
-
// local reimplementation — a hook that registers by itself instead of
|
|
666
|
-
// forwarding — fails here, and so does a shim that quietly stops
|
|
667
|
-
// delegating (the calls are what is asserted, not the imports alone).
|
|
668
|
-
//
|
|
669
|
-
// What this cannot see is WHICH core hook a given config reaches; that is
|
|
670
|
-
// routing, and it is asserted against core's own observable state (getTool,
|
|
671
|
-
// core.tools, the advertised tool list on a real run) in
|
|
672
|
-
// src/hooks/__tests__/useRenderTool.test.tsx.
|
|
659
|
+
// Asserted TWICE, on purpose. Runtime identity is the claim; the source
|
|
660
|
+
// check is what keeps the failure legible, because a local module that
|
|
661
|
+
// re-exported core's binding unchanged today could grow a body tomorrow
|
|
662
|
+
// and the runtime assertion would only start failing then. Requiring the
|
|
663
|
+
// export to come straight from core's headless entry means an RN-local
|
|
664
|
+
// module cannot be introduced under this name at all — which is the state
|
|
665
|
+
// #6976 restored when it removed the compatibility shim.
|
|
673
666
|
const source = fs.readFileSync(headlessEntry, "utf8");
|
|
674
667
|
const from = reExportSpecifierOf(source, "useRenderTool");
|
|
675
668
|
expect(
|
|
@@ -678,66 +671,19 @@ describe("@copilotkit/react-native/headless entry", () => {
|
|
|
678
671
|
"this guard cannot tell what a consumer gets. If the export moved to " +
|
|
679
672
|
"another form, teach `reExportSpecifierOf` about it.",
|
|
680
673
|
).not.toBeNull();
|
|
681
|
-
|
|
682
|
-
if (from === CORE_HEADLESS) {
|
|
683
|
-
expect(
|
|
684
|
-
mod.useRenderTool,
|
|
685
|
-
"`useRenderTool` on the RN headless entry is NOT the binding from " +
|
|
686
|
-
`${CORE_HEADLESS}, though src/headless.ts re-exports it from there.`,
|
|
687
|
-
).toBe(coreHeadless.useRenderTool);
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
expect(
|
|
692
|
-
from!.startsWith("."),
|
|
693
|
-
`src/headless.ts re-exports \`useRenderTool\` from "${from}", which is ` +
|
|
694
|
-
`neither ${CORE_HEADLESS} nor a local module. Only those two are ` +
|
|
695
|
-
`admissible: anything else is an implementation RN does not control.`,
|
|
696
|
-
).toBe(true);
|
|
697
|
-
|
|
698
|
-
const shimFile = resolveLocal(headlessEntry, from!);
|
|
699
|
-
expect(
|
|
700
|
-
shimFile,
|
|
701
|
-
`cannot resolve the module "${from}" that src/headless.ts exports ` +
|
|
702
|
-
`\`useRenderTool\` from`,
|
|
703
|
-
).not.toBeNull();
|
|
704
|
-
// Non-vacuity: the deny-list test below reasons about this file too, so a
|
|
705
|
-
// shim outside the walked graph would make both pass for the wrong reason.
|
|
706
674
|
expect(
|
|
707
|
-
|
|
708
|
-
`
|
|
709
|
-
|
|
675
|
+
from,
|
|
676
|
+
`src/headless.ts re-exports \`useRenderTool\` from "${from}". It must ` +
|
|
677
|
+
`come straight from ${CORE_HEADLESS}: an RN-local module under this ` +
|
|
678
|
+
`name is what shipped the \`*\`-named-tool bug, and the temporary ` +
|
|
679
|
+
`shim that replaced it was removed in #6976.`,
|
|
680
|
+
).toBe(CORE_HEADLESS);
|
|
710
681
|
|
|
711
|
-
const shimSource = stripComments(fs.readFileSync(shimFile!, "utf8"));
|
|
712
|
-
const { specs } = extractSpecs(shimSource);
|
|
713
682
|
expect(
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
`${CORE_HEADLESS},
|
|
717
|
-
|
|
718
|
-
).toContain(CORE_HEADLESS);
|
|
719
|
-
|
|
720
|
-
// Both core hooks must be REACHED, not merely imported: the shim's whole
|
|
721
|
-
// job is to route a legacy tool-shaped call to `useFrontendTool` and
|
|
722
|
-
// everything else to core's `useRenderTool`. An import with no call site
|
|
723
|
-
// is a shim that has stopped delegating.
|
|
724
|
-
for (const hook of ["useRenderTool", "useFrontendTool"]) {
|
|
725
|
-
const imported = new RegExp(
|
|
726
|
-
`\\b${hook}\\b(?:\\s+as\\s+(\\w+))?[^;]*?from\\s*["'\`]${CORE_HEADLESS.replace(/[/.]/g, "\\$&")}["'\`]`,
|
|
727
|
-
).exec(shimSource);
|
|
728
|
-
expect(
|
|
729
|
-
imported,
|
|
730
|
-
`${path.relative(srcDir, shimFile!)} does not import \`${hook}\` from ` +
|
|
731
|
-
`${CORE_HEADLESS}. The shim must delegate BOTH routes to core.`,
|
|
732
|
-
).not.toBeNull();
|
|
733
|
-
const localName = imported?.[1] ?? hook;
|
|
734
|
-
expect(
|
|
735
|
-
new RegExp(`\\b${localName}\\s*\\(`).test(shimSource),
|
|
736
|
-
`${path.relative(srcDir, shimFile!)} imports \`${hook}\` (as ` +
|
|
737
|
-
`\`${localName}\`) from ${CORE_HEADLESS} but never calls it. A shim ` +
|
|
738
|
-
`that does not delegate registers nothing, or registers it itself.`,
|
|
739
|
-
).toBe(true);
|
|
740
|
-
}
|
|
683
|
+
mod.useRenderTool,
|
|
684
|
+
"`useRenderTool` on the RN headless entry is NOT the binding from " +
|
|
685
|
+
`${CORE_HEADLESS}, though src/headless.ts re-exports it from there.`,
|
|
686
|
+
).toBe(coreHeadless.useRenderTool);
|
|
741
687
|
});
|
|
742
688
|
|
|
743
689
|
it("no longer exports the removed registry hook or its provider", () => {
|
package/src/headless.ts
CHANGED
|
@@ -119,25 +119,24 @@ export type {
|
|
|
119
119
|
AgentCapabilities,
|
|
120
120
|
} from "@ag-ui/client";
|
|
121
121
|
|
|
122
|
-
// Render tool registration
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
122
|
+
// Render tool registration — react-core's hooks THEMSELVES, not RN copies.
|
|
123
|
+
//
|
|
124
|
+
// DO NOT reintroduce a LOCAL hook under either name. RN once shipped its own
|
|
125
|
+
// `useRenderTool` whose whole body forwarded to `useFrontendTool` — core's
|
|
126
|
+
// OTHER hook, wearing this one's name — so `name: "*"` registered a frontend
|
|
127
|
+
// tool literally called `*`. Core never advertised it (`buildFrontendTools`
|
|
128
|
+
// filters that name out), but `*` IS core's catch-all handler name: a
|
|
129
|
+
// display-only wildcard therefore auto-answered every otherwise-unanswered
|
|
130
|
+
// tool call with an empty tool result and asked for a follow-up turn.
|
|
129
131
|
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
// src/__tests__/headless-entry-surface.test.ts fails the build if any module in
|
|
139
|
-
// this entry's graph grows a registry of its own.
|
|
140
|
-
export { useRenderTool } from "./hooks/useRenderTool";
|
|
132
|
+
// PR #6533 converged both names onto react-core behind a temporary routing
|
|
133
|
+
// shim; #6976 removed the shim, so these are now plain re-exports and this
|
|
134
|
+
// package carries no render-tool implementation of its own.
|
|
135
|
+
// src/__tests__/headless-entry-surface.test.ts asserts runtime identity for
|
|
136
|
+
// both names and fails the build if any module in this entry's graph grows a
|
|
137
|
+
// registry. Contract and migration notes:
|
|
138
|
+
// /reference/react-native/hooks/useRenderTool.
|
|
139
|
+
export { useRenderTool } from "@copilotkit/react-core/v2/headless";
|
|
141
140
|
export type { RenderToolProps } from "@copilotkit/react-core/v2/headless";
|
|
142
141
|
|
|
143
142
|
// Render tool consumption. react-core's hook is platform-agnostic — it pulls no
|