@opentiny/next-sdk 0.2.6-beta.0 → 0.2.6-beta.1
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/index.es.dev.js +7 -5
- package/dist/index.es.js +14 -13
- package/dist/index.js +1064 -1063
- package/dist/index.umd.dev.js +7 -5
- package/dist/index.umd.js +1 -1
- package/dist/page-tool-bridge.d.ts +12 -3
- package/package.json +1 -1
- package/page-tool-bridge.ts +32 -13
package/dist/index.es.dev.js
CHANGED
|
@@ -50230,11 +50230,12 @@ function withPageTools(server) {
|
|
|
50230
50230
|
get(target, prop, receiver) {
|
|
50231
50231
|
if (prop === "registerTool") {
|
|
50232
50232
|
return (name16, config2, handlerOrRoute) => {
|
|
50233
|
+
const rawRegister = target.registerTool.bind(target);
|
|
50233
50234
|
if (typeof handlerOrRoute === "function") {
|
|
50234
|
-
return
|
|
50235
|
+
return rawRegister(name16, config2, handlerOrRoute);
|
|
50235
50236
|
}
|
|
50236
50237
|
const { route, timeout } = handlerOrRoute;
|
|
50237
|
-
return
|
|
50238
|
+
return rawRegister(name16, config2, buildPageHandler(name16, route, timeout));
|
|
50238
50239
|
};
|
|
50239
50240
|
}
|
|
50240
50241
|
return Reflect.get(target, prop, receiver);
|
|
@@ -50242,10 +50243,11 @@ function withPageTools(server) {
|
|
|
50242
50243
|
});
|
|
50243
50244
|
}
|
|
50244
50245
|
function registerPageTool(options) {
|
|
50245
|
-
const { handlers } = options;
|
|
50246
|
-
const
|
|
50246
|
+
const { route: routeOption, handlers } = options;
|
|
50247
|
+
const normalizeRoute = (value) => value.replace(/\/+$/, "") || "/";
|
|
50248
|
+
const route = normalizeRoute(routeOption ?? window.location.pathname);
|
|
50247
50249
|
const handleMessage = async (event) => {
|
|
50248
|
-
if (event.source !== window || event.data?.type !== MSG_TOOL_CALL || event.data?.route !== route || !(event.data.toolName in handlers)) {
|
|
50250
|
+
if (event.source !== window || event.data?.type !== MSG_TOOL_CALL || normalizeRoute(String(event.data?.route ?? "")) !== route || !(event.data.toolName in handlers)) {
|
|
50249
50251
|
return;
|
|
50250
50252
|
}
|
|
50251
50253
|
const { callId, toolName, input } = event.data;
|
package/dist/index.es.js
CHANGED
|
@@ -39655,35 +39655,36 @@ function gM(t) {
|
|
|
39655
39655
|
return new Proxy(t, {
|
|
39656
39656
|
get(e, r, n) {
|
|
39657
39657
|
return r === "registerTool" ? (o, s, a) => {
|
|
39658
|
+
const i = e.registerTool.bind(e);
|
|
39658
39659
|
if (typeof a == "function")
|
|
39659
|
-
return
|
|
39660
|
-
const { route:
|
|
39661
|
-
return
|
|
39660
|
+
return i(o, s, a);
|
|
39661
|
+
const { route: l, timeout: c } = a;
|
|
39662
|
+
return i(o, s, gP(o, l, c));
|
|
39662
39663
|
} : Reflect.get(e, r, n);
|
|
39663
39664
|
}
|
|
39664
39665
|
});
|
|
39665
39666
|
}
|
|
39666
39667
|
function yM(t) {
|
|
39667
|
-
const {
|
|
39668
|
-
if (
|
|
39668
|
+
const { route: e, handlers: r } = t, n = (a) => a.replace(/\/+$/, "") || "/", o = n(e ?? window.location.pathname), s = async (a) => {
|
|
39669
|
+
if (a.source !== window || a.data?.type !== U1 || n(String(a.data?.route ?? "")) !== o || !(a.data.toolName in r))
|
|
39669
39670
|
return;
|
|
39670
|
-
const { callId:
|
|
39671
|
+
const { callId: i, toolName: l, input: c } = a.data;
|
|
39671
39672
|
try {
|
|
39672
|
-
const
|
|
39673
|
-
window.postMessage({ type: Hu, callId:
|
|
39674
|
-
} catch (
|
|
39673
|
+
const u = await r[l](c);
|
|
39674
|
+
window.postMessage({ type: Hu, callId: i, result: u }, window.location.origin || "*");
|
|
39675
|
+
} catch (u) {
|
|
39675
39676
|
window.postMessage(
|
|
39676
39677
|
{
|
|
39677
39678
|
type: Hu,
|
|
39678
|
-
callId:
|
|
39679
|
-
error:
|
|
39679
|
+
callId: i,
|
|
39680
|
+
error: u instanceof Error ? u.message : String(u)
|
|
39680
39681
|
},
|
|
39681
39682
|
window.location.origin || "*"
|
|
39682
39683
|
);
|
|
39683
39684
|
}
|
|
39684
39685
|
};
|
|
39685
|
-
return dl.set(
|
|
39686
|
-
dl.delete(
|
|
39686
|
+
return dl.set(o, !0), window.addEventListener("message", s), window.postMessage({ type: z1, route: o }, window.location.origin || "*"), () => {
|
|
39687
|
+
dl.delete(o), window.removeEventListener("message", s);
|
|
39687
39688
|
};
|
|
39688
39689
|
}
|
|
39689
39690
|
const Z1 = /^\.\/[^/]+\/SKILL\.md$/, yP = /^---\s*\n([\s\S]+?)\s*\n---/;
|