@agent-native/core 0.15.5 → 0.15.7

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.
Files changed (166) hide show
  1. package/dist/client/AgentPanel.d.ts.map +1 -1
  2. package/dist/client/AgentPanel.js +3 -2
  3. package/dist/client/AgentPanel.js.map +1 -1
  4. package/dist/client/AssistantChat.d.ts.map +1 -1
  5. package/dist/client/AssistantChat.js +14 -2
  6. package/dist/client/AssistantChat.js.map +1 -1
  7. package/dist/client/components/CodeRequiredDialog.js +1 -1
  8. package/dist/client/components/CodeRequiredDialog.js.map +1 -1
  9. package/dist/client/settings/BackgroundAgentSection.d.ts.map +1 -1
  10. package/dist/client/settings/BackgroundAgentSection.js +2 -1
  11. package/dist/client/settings/BackgroundAgentSection.js.map +1 -1
  12. package/dist/client/settings/BrowserSection.d.ts.map +1 -1
  13. package/dist/client/settings/BrowserSection.js +3 -2
  14. package/dist/client/settings/BrowserSection.js.map +1 -1
  15. package/dist/client/settings/SettingsPanel.js +1 -1
  16. package/dist/client/settings/SettingsPanel.js.map +1 -1
  17. package/dist/client/settings/VoiceTranscriptionSection.d.ts.map +1 -1
  18. package/dist/client/settings/VoiceTranscriptionSection.js +1 -0
  19. package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
  20. package/dist/client/settings/useBuilderStatus.d.ts +1 -0
  21. package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
  22. package/dist/client/settings/useBuilderStatus.js +120 -23
  23. package/dist/client/settings/useBuilderStatus.js.map +1 -1
  24. package/dist/client/settings/useBuilderStatus.spec.js +85 -7
  25. package/dist/client/settings/useBuilderStatus.spec.js.map +1 -1
  26. package/dist/client/transcription/BuilderTranscriptionCta.d.ts.map +1 -1
  27. package/dist/client/transcription/BuilderTranscriptionCta.js +7 -2
  28. package/dist/client/transcription/BuilderTranscriptionCta.js.map +1 -1
  29. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  30. package/dist/server/agent-chat-plugin.js +3 -1
  31. package/dist/server/agent-chat-plugin.js.map +1 -1
  32. package/dist/server/auth.d.ts.map +1 -1
  33. package/dist/server/auth.js +19 -2
  34. package/dist/server/auth.js.map +1 -1
  35. package/dist/server/builder-browser.d.ts +8 -0
  36. package/dist/server/builder-browser.d.ts.map +1 -1
  37. package/dist/server/builder-browser.js +78 -4
  38. package/dist/server/builder-browser.js.map +1 -1
  39. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  40. package/dist/server/core-routes-plugin.js +55 -23
  41. package/dist/server/core-routes-plugin.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/client/dev-mode.d.ts +0 -14
  44. package/dist/client/dev-mode.d.ts.map +0 -1
  45. package/dist/client/dev-mode.js +0 -14
  46. package/dist/client/dev-mode.js.map +0 -1
  47. package/dist/client/extensions/EmbeddedTool.d.ts +0 -20
  48. package/dist/client/extensions/EmbeddedTool.d.ts.map +0 -1
  49. package/dist/client/extensions/EmbeddedTool.js +0 -199
  50. package/dist/client/extensions/EmbeddedTool.js.map +0 -1
  51. package/dist/client/extensions/ToolEditor.d.ts +0 -5
  52. package/dist/client/extensions/ToolEditor.d.ts.map +0 -1
  53. package/dist/client/extensions/ToolEditor.js +0 -129
  54. package/dist/client/extensions/ToolEditor.js.map +0 -1
  55. package/dist/client/extensions/ToolViewer.d.ts +0 -5
  56. package/dist/client/extensions/ToolViewer.d.ts.map +0 -1
  57. package/dist/client/extensions/ToolViewer.js +0 -400
  58. package/dist/client/extensions/ToolViewer.js.map +0 -1
  59. package/dist/client/extensions/ToolViewerPage.d.ts +0 -2
  60. package/dist/client/extensions/ToolViewerPage.d.ts.map +0 -1
  61. package/dist/client/extensions/ToolViewerPage.js +0 -24
  62. package/dist/client/extensions/ToolViewerPage.js.map +0 -1
  63. package/dist/client/extensions/ToolsListPage.d.ts +0 -2
  64. package/dist/client/extensions/ToolsListPage.d.ts.map +0 -1
  65. package/dist/client/extensions/ToolsListPage.js +0 -67
  66. package/dist/client/extensions/ToolsListPage.js.map +0 -1
  67. package/dist/client/extensions/ToolsSidebarSection.d.ts +0 -2
  68. package/dist/client/extensions/ToolsSidebarSection.d.ts.map +0 -1
  69. package/dist/client/extensions/ToolsSidebarSection.js +0 -236
  70. package/dist/client/extensions/ToolsSidebarSection.js.map +0 -1
  71. package/dist/client/extensions/tool-order.d.ts +0 -7
  72. package/dist/client/extensions/tool-order.d.ts.map +0 -1
  73. package/dist/client/extensions/tool-order.js +0 -47
  74. package/dist/client/extensions/tool-order.js.map +0 -1
  75. package/dist/client/tools/EmbeddedTool.d.ts +0 -20
  76. package/dist/client/tools/EmbeddedTool.d.ts.map +0 -1
  77. package/dist/client/tools/EmbeddedTool.js +0 -199
  78. package/dist/client/tools/EmbeddedTool.js.map +0 -1
  79. package/dist/client/tools/ExtensionSlot.d.ts +0 -27
  80. package/dist/client/tools/ExtensionSlot.d.ts.map +0 -1
  81. package/dist/client/tools/ExtensionSlot.js +0 -96
  82. package/dist/client/tools/ExtensionSlot.js.map +0 -1
  83. package/dist/client/tools/ToolEditor.d.ts +0 -5
  84. package/dist/client/tools/ToolEditor.d.ts.map +0 -1
  85. package/dist/client/tools/ToolEditor.js +0 -129
  86. package/dist/client/tools/ToolEditor.js.map +0 -1
  87. package/dist/client/tools/ToolViewer.d.ts +0 -5
  88. package/dist/client/tools/ToolViewer.d.ts.map +0 -1
  89. package/dist/client/tools/ToolViewer.js +0 -400
  90. package/dist/client/tools/ToolViewer.js.map +0 -1
  91. package/dist/client/tools/ToolViewerPage.d.ts +0 -2
  92. package/dist/client/tools/ToolViewerPage.d.ts.map +0 -1
  93. package/dist/client/tools/ToolViewerPage.js +0 -24
  94. package/dist/client/tools/ToolViewerPage.js.map +0 -1
  95. package/dist/client/tools/ToolsListPage.d.ts +0 -2
  96. package/dist/client/tools/ToolsListPage.d.ts.map +0 -1
  97. package/dist/client/tools/ToolsListPage.js +0 -67
  98. package/dist/client/tools/ToolsListPage.js.map +0 -1
  99. package/dist/client/tools/ToolsSidebarSection.d.ts +0 -2
  100. package/dist/client/tools/ToolsSidebarSection.d.ts.map +0 -1
  101. package/dist/client/tools/ToolsSidebarSection.js +0 -236
  102. package/dist/client/tools/ToolsSidebarSection.js.map +0 -1
  103. package/dist/client/tools/iframe-bridge.d.ts +0 -38
  104. package/dist/client/tools/iframe-bridge.d.ts.map +0 -1
  105. package/dist/client/tools/iframe-bridge.js +0 -207
  106. package/dist/client/tools/iframe-bridge.js.map +0 -1
  107. package/dist/client/tools/index.d.ts +0 -8
  108. package/dist/client/tools/index.d.ts.map +0 -1
  109. package/dist/client/tools/index.js +0 -8
  110. package/dist/client/tools/index.js.map +0 -1
  111. package/dist/client/tools/tool-order.d.ts +0 -7
  112. package/dist/client/tools/tool-order.d.ts.map +0 -1
  113. package/dist/client/tools/tool-order.js +0 -47
  114. package/dist/client/tools/tool-order.js.map +0 -1
  115. package/dist/server/local-migration.d.ts +0 -41
  116. package/dist/server/local-migration.d.ts.map +0 -1
  117. package/dist/server/local-migration.js +0 -235
  118. package/dist/server/local-migration.js.map +0 -1
  119. package/dist/tools/actions.d.ts +0 -3
  120. package/dist/tools/actions.d.ts.map +0 -1
  121. package/dist/tools/actions.js +0 -272
  122. package/dist/tools/actions.js.map +0 -1
  123. package/dist/tools/fetch-tool.d.ts +0 -23
  124. package/dist/tools/fetch-tool.d.ts.map +0 -1
  125. package/dist/tools/fetch-tool.js +0 -178
  126. package/dist/tools/fetch-tool.js.map +0 -1
  127. package/dist/tools/html-shell.d.ts +0 -45
  128. package/dist/tools/html-shell.d.ts.map +0 -1
  129. package/dist/tools/html-shell.js +0 -514
  130. package/dist/tools/html-shell.js.map +0 -1
  131. package/dist/tools/proxy-security.d.ts +0 -12
  132. package/dist/tools/proxy-security.d.ts.map +0 -1
  133. package/dist/tools/proxy-security.js +0 -158
  134. package/dist/tools/proxy-security.js.map +0 -1
  135. package/dist/tools/routes.d.ts +0 -2
  136. package/dist/tools/routes.d.ts.map +0 -1
  137. package/dist/tools/routes.js +0 -627
  138. package/dist/tools/routes.js.map +0 -1
  139. package/dist/tools/schema.d.ts +0 -664
  140. package/dist/tools/schema.d.ts.map +0 -1
  141. package/dist/tools/schema.js +0 -146
  142. package/dist/tools/schema.js.map +0 -1
  143. package/dist/tools/slots/routes.d.ts +0 -15
  144. package/dist/tools/slots/routes.d.ts.map +0 -1
  145. package/dist/tools/slots/routes.js +0 -94
  146. package/dist/tools/slots/routes.js.map +0 -1
  147. package/dist/tools/slots/schema.d.ts +0 -303
  148. package/dist/tools/slots/schema.d.ts.map +0 -1
  149. package/dist/tools/slots/schema.js +0 -76
  150. package/dist/tools/slots/schema.js.map +0 -1
  151. package/dist/tools/slots/store.d.ts +0 -66
  152. package/dist/tools/slots/store.d.ts.map +0 -1
  153. package/dist/tools/slots/store.js +0 -227
  154. package/dist/tools/slots/store.js.map +0 -1
  155. package/dist/tools/store.d.ts +0 -40
  156. package/dist/tools/store.d.ts.map +0 -1
  157. package/dist/tools/store.js +0 -193
  158. package/dist/tools/store.js.map +0 -1
  159. package/dist/tools/theme.d.ts +0 -2
  160. package/dist/tools/theme.d.ts.map +0 -1
  161. package/dist/tools/theme.js +0 -67
  162. package/dist/tools/theme.js.map +0 -1
  163. package/dist/tools/url-safety.d.ts +0 -24
  164. package/dist/tools/url-safety.d.ts.map +0 -1
  165. package/dist/tools/url-safety.js +0 -224
  166. package/dist/tools/url-safety.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "type": "module",
5
5
  "description": "Framework for agent-native application development — where AI agents and UI share state via files",
6
6
  "license": "MIT",
@@ -1,14 +0,0 @@
1
- /**
2
- * Client-side mirror of the framework's dev-mode bypass identity.
3
- *
4
- * Mirrors `DEV_MODE_USER_EMAIL` from `packages/core/src/server/auth.ts`
5
- * (the source of truth) so that React components and other client code
6
- * can compare against it without importing from server-only modules.
7
- *
8
- * Use this when a client component needs to show / hide UI that is only
9
- * meaningful when the user is running in local/dev mode (e.g. the
10
- * "Migrate local data" prompt, the dev-only sign-in card, or hiding the
11
- * org switcher when there is no real account yet).
12
- */
13
- export declare const DEV_MODE_USER_EMAIL = "local@localhost";
14
- //# sourceMappingURL=dev-mode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev-mode.d.ts","sourceRoot":"","sources":["../../src/client/dev-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Client-side mirror of the framework's dev-mode bypass identity.
3
- *
4
- * Mirrors `DEV_MODE_USER_EMAIL` from `packages/core/src/server/auth.ts`
5
- * (the source of truth) so that React components and other client code
6
- * can compare against it without importing from server-only modules.
7
- *
8
- * Use this when a client component needs to show / hide UI that is only
9
- * meaningful when the user is running in local/dev mode (e.g. the
10
- * "Migrate local data" prompt, the dev-only sign-in card, or hiding the
11
- * org switcher when there is no real account yet).
12
- */
13
- export const DEV_MODE_USER_EMAIL = "local@localhost"; // guard:allow-localhost-fallback — client-side mirror of the framework dev-mode identity defined in server/auth.ts; not a session-pooling fallback
14
- //# sourceMappingURL=dev-mode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev-mode.js","sourceRoot":"","sources":["../../src/client/dev-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,CAAC,mJAAmJ","sourcesContent":["/**\n * Client-side mirror of the framework's dev-mode bypass identity.\n *\n * Mirrors `DEV_MODE_USER_EMAIL` from `packages/core/src/server/auth.ts`\n * (the source of truth) so that React components and other client code\n * can compare against it without importing from server-only modules.\n *\n * Use this when a client component needs to show / hide UI that is only\n * meaningful when the user is running in local/dev mode (e.g. the\n * \"Migrate local data\" prompt, the dev-only sign-in card, or hiding the\n * org switcher when there is no real account yet).\n */\nexport const DEV_MODE_USER_EMAIL = \"local@localhost\"; // guard:allow-localhost-fallback — client-side mirror of the framework dev-mode identity defined in server/auth.ts; not a session-pooling fallback\n"]}
@@ -1,20 +0,0 @@
1
- export interface EmbeddedToolProps {
2
- toolId: string;
3
- /** Slot identifier passed via the iframe URL so the tool runtime knows it's
4
- * embedded and enables auto-resize. */
5
- slotId: string;
6
- /** Object pushed into the tool as `window.slotContext`. Re-posted whenever
7
- * the host re-renders with a new context. */
8
- context?: Record<string, unknown> | null;
9
- /** Optional className applied to the iframe container. */
10
- className?: string;
11
- /** Initial iframe height before content reports a real height. */
12
- initialHeight?: number;
13
- }
14
- /**
15
- * Renders a tool inline as a small auto-sized iframe — for use inside an
16
- * `<ExtensionSlot>`. Different from `<ToolViewer>` (which is full-page with a
17
- * toolbar): no header, sized to content, receives a `slotContext`.
18
- */
19
- export declare function EmbeddedTool({ toolId, slotId, context, className, initialHeight, }: EmbeddedToolProps): import("react/jsx-runtime").JSX.Element;
20
- //# sourceMappingURL=EmbeddedTool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EmbeddedTool.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/EmbeddedTool.tsx"],"names":[],"mappings":"AA8BA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf;2CACuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf;iDAC6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,MAAM,EACN,OAAO,EACP,SAAS,EACT,aAAkB,GACnB,EAAE,iBAAiB,2CA6LnB"}
@@ -1,199 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { agentNativePath } from "../api-path.js";
3
- import { useEffect, useMemo, useRef, useState } from "react";
4
- import { useQuery, useQueryClient } from "@tanstack/react-query";
5
- import { useNavigate } from "react-router";
6
- import { IconDots, IconExternalLink, IconLayoutSidebarRightCollapse, IconTrash, } from "@tabler/icons-react";
7
- import { Popover, PopoverContent, PopoverTrigger, } from "../components/ui/popover.js";
8
- import { isAllowedToolPath, sanitizeToolRequestOptions, checkBridgePolicy, } from "./iframe-bridge.js";
9
- /**
10
- * Renders a tool inline as a small auto-sized iframe — for use inside an
11
- * `<ExtensionSlot>`. Different from `<ToolViewer>` (which is full-page with a
12
- * toolbar): no header, sized to content, receives a `slotContext`.
13
- */
14
- export function EmbeddedTool({ toolId, slotId, context, className, initialHeight = 80, }) {
15
- const iframeRef = useRef(null);
16
- const [height, setHeight] = useState(initialHeight);
17
- const [isDark, setIsDark] = useState(false);
18
- // (audit H4) Mirror ToolViewer's role-aware gating; deny-by-default until
19
- // the iframe's render binding announcement arrives.
20
- const bridgeContextRef = useRef({
21
- role: "viewer",
22
- isAuthor: false,
23
- });
24
- useEffect(() => {
25
- setIsDark(document.documentElement.classList.contains("dark"));
26
- const observer = new MutationObserver(() => {
27
- setIsDark(document.documentElement.classList.contains("dark"));
28
- });
29
- observer.observe(document.documentElement, {
30
- attributes: true,
31
- attributeFilter: ["class"],
32
- });
33
- return () => observer.disconnect();
34
- }, []);
35
- const { data: tool } = useQuery({
36
- queryKey: ["tool", toolId],
37
- queryFn: async () => {
38
- const res = await fetch(agentNativePath(`/_agent-native/tools/${toolId}`));
39
- if (!res.ok)
40
- throw new Error("Failed to fetch tool");
41
- return res.json();
42
- },
43
- });
44
- const iframeSrc = useMemo(() => {
45
- const v = encodeURIComponent(tool?.updatedAt ?? "");
46
- return agentNativePath(`/_agent-native/tools/${toolId}/render?slot=${encodeURIComponent(slotId)}&dark=${isDark}&v=${v}`);
47
- }, [toolId, slotId, isDark, tool?.updatedAt]);
48
- // Forward slot context whenever it changes. The iframe's own load handler
49
- // posts the initial value once it's ready; this effect handles updates.
50
- const contextJson = JSON.stringify(context ?? {});
51
- useEffect(() => {
52
- const win = iframeRef.current?.contentWindow;
53
- if (!win)
54
- return;
55
- win.postMessage({ type: "agent-native-slot-context", context: context ?? {} }, "*");
56
- }, [contextJson]);
57
- // Bridge tool requests + height reports.
58
- useEffect(() => {
59
- const handleMessage = async (event) => {
60
- if (event.source !== iframeRef.current?.contentWindow)
61
- return;
62
- const message = event.data;
63
- if (!message || typeof message !== "object")
64
- return;
65
- if (message.type === "agent-native-tool-binding") {
66
- const binding = message.binding ?? {};
67
- const role = binding.role === "owner" ||
68
- binding.role === "admin" ||
69
- binding.role === "editor" ||
70
- binding.role === "viewer"
71
- ? binding.role
72
- : "viewer";
73
- bridgeContextRef.current = {
74
- role,
75
- isAuthor: !!binding.isAuthor,
76
- };
77
- return;
78
- }
79
- if (message.type === "agent-native-tool-resize") {
80
- const h = Number(message.height);
81
- if (Number.isFinite(h) && h > 0) {
82
- setHeight(Math.ceil(h));
83
- }
84
- return;
85
- }
86
- if (message.type !== "agent-native-tool-request")
87
- return;
88
- const requestId = String(message.requestId ?? "");
89
- const path = String(message.path ?? "");
90
- const respond = (payload) => {
91
- iframeRef.current?.contentWindow?.postMessage({ type: "agent-native-tool-response", requestId, ...payload }, "*");
92
- };
93
- if (!requestId || !isAllowedToolPath(path, toolId)) {
94
- respond({ error: "Tool request path is not allowed" });
95
- return;
96
- }
97
- try {
98
- const options = sanitizeToolRequestOptions(message.options);
99
- // (audit H4) Role-aware gating: viewer-shared tools can read but not
100
- // write. The bridge policy is decided here in the parent before the
101
- // request leaves; the server enforces a second layer.
102
- const policy = checkBridgePolicy(path, options.method ?? "GET", bridgeContextRef.current);
103
- if (!policy.ok) {
104
- respond({
105
- response: {
106
- ok: false,
107
- status: 403,
108
- statusText: "Forbidden",
109
- body: { error: policy.error },
110
- },
111
- });
112
- return;
113
- }
114
- // (audit H5) Same tool-bridge tagging as <ToolViewer>. action-routes
115
- // uses these headers to enforce per-action `toolCallable` opt-in.
116
- const finalHeaders = new Headers(options.headers ?? undefined);
117
- finalHeaders.set("X-Agent-Native-Tool-Bridge", "1");
118
- finalHeaders.set("X-Agent-Native-Tool-Id", toolId);
119
- const res = await fetch(agentNativePath(path), {
120
- ...options,
121
- headers: finalHeaders,
122
- credentials: "same-origin",
123
- });
124
- const text = await res.text();
125
- let body = text;
126
- if (text) {
127
- try {
128
- body = JSON.parse(text);
129
- }
130
- catch {
131
- body = text;
132
- }
133
- }
134
- respond({
135
- response: {
136
- ok: res.ok,
137
- status: res.status,
138
- statusText: res.statusText,
139
- body,
140
- },
141
- });
142
- }
143
- catch (err) {
144
- respond({ error: err?.message ?? "Tool host request failed" });
145
- }
146
- };
147
- window.addEventListener("message", handleMessage);
148
- return () => window.removeEventListener("message", handleMessage);
149
- }, [toolId]);
150
- if (!tool) {
151
- return (_jsx("div", { className: className, style: { height: initialHeight }, "aria-busy": "true" }));
152
- }
153
- return (_jsxs("div", { className: `relative group/embedded-tool ${className ?? ""}`, children: [_jsx("iframe", { ref: iframeRef, src: iframeSrc, title: tool.name, sandbox: "allow-scripts allow-forms", style: { width: "100%", border: 0, height, display: "block" }, onLoad: () => {
154
- iframeRef.current?.contentWindow?.postMessage({ type: "agent-native-slot-context", context: context ?? {} }, "*");
155
- } }, `${toolId}-${tool.updatedAt ?? ""}`), _jsx(EmbeddedToolMenu, { toolId: toolId, slotId: slotId, toolName: tool.name })] }));
156
- }
157
- function EmbeddedToolMenu({ toolId, slotId, toolName, }) {
158
- const [open, setOpen] = useState(false);
159
- const [confirmingDelete, setConfirmingDelete] = useState(false);
160
- const queryClient = useQueryClient();
161
- const navigate = useNavigate();
162
- const closeMenu = () => {
163
- setOpen(false);
164
- setConfirmingDelete(false);
165
- };
166
- const removeFromSlot = async () => {
167
- closeMenu();
168
- queryClient.setQueryData(["slot-installs", slotId], (old) => (old ?? []).filter((i) => i.toolId !== toolId));
169
- try {
170
- await fetch(agentNativePath(`/_agent-native/slots/${encodeURIComponent(slotId)}/install/${encodeURIComponent(toolId)}`), { method: "DELETE" });
171
- }
172
- finally {
173
- queryClient.invalidateQueries({ queryKey: ["slot-installs", slotId] });
174
- }
175
- };
176
- const deleteTool = async () => {
177
- closeMenu();
178
- queryClient.setQueryData(["slot-installs", slotId], (old) => (old ?? []).filter((i) => i.toolId !== toolId));
179
- try {
180
- await fetch(agentNativePath(`/_agent-native/tools/${toolId}`), {
181
- method: "DELETE",
182
- });
183
- }
184
- finally {
185
- queryClient.invalidateQueries({ queryKey: ["slot-installs", slotId] });
186
- queryClient.invalidateQueries({ queryKey: ["tool", toolId] });
187
- queryClient.invalidateQueries({ queryKey: ["tools"] });
188
- }
189
- };
190
- return (_jsxs(Popover, { open: open, onOpenChange: (o) => {
191
- setOpen(o);
192
- if (!o)
193
- setConfirmingDelete(false);
194
- }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "absolute top-1 right-1 flex h-6 w-6 items-center justify-center rounded-md bg-background/60 text-muted-foreground/60 opacity-0 hover:bg-accent hover:text-foreground hover:opacity-100 group-hover/embedded-tool:opacity-100 cursor-pointer transition-opacity", title: `${toolName} options`, "aria-label": `${toolName} options`, children: _jsx(IconDots, { className: "h-3.5 w-3.5" }) }) }), _jsx(PopoverContent, { align: "end", sideOffset: 4, className: "w-56 p-1", children: !confirmingDelete ? (_jsxs("div", { className: "flex flex-col", children: [_jsxs("button", { type: "button", onClick: () => {
195
- closeMenu();
196
- navigate(`/tools/${toolId}`);
197
- }, className: "flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] hover:bg-accent cursor-pointer text-left", children: [_jsx(IconExternalLink, { className: "h-3.5 w-3.5" }), _jsx("span", { children: "Open full view" })] }), _jsxs("button", { type: "button", onClick: removeFromSlot, className: "flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] hover:bg-accent cursor-pointer text-left", children: [_jsx(IconLayoutSidebarRightCollapse, { className: "h-3.5 w-3.5" }), _jsx("span", { children: "Remove from this widget area" })] }), _jsx("div", { className: "my-1 h-px bg-border/40" }), _jsxs("button", { type: "button", onClick: () => setConfirmingDelete(true), className: "flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] text-destructive hover:bg-destructive/10 cursor-pointer text-left", children: [_jsx(IconTrash, { className: "h-3.5 w-3.5" }), _jsx("span", { children: "Delete tool\u2026" })] })] })) : (_jsxs("div", { className: "flex flex-col gap-2 p-2", children: [_jsxs("p", { className: "text-[12px]", children: ["Delete ", _jsx("span", { className: "font-medium", children: toolName }), "? This removes the tool everywhere, for everyone it's shared with."] }), _jsxs("div", { className: "flex justify-end gap-1", children: [_jsx("button", { type: "button", onClick: () => setConfirmingDelete(false), className: "rounded-md px-2 py-1 text-[12px] hover:bg-accent cursor-pointer", children: "Cancel" }), _jsx("button", { type: "button", onClick: deleteTool, className: "rounded-md bg-destructive px-2 py-1 text-[12px] text-destructive-foreground hover:bg-destructive/90 cursor-pointer", children: "Delete" })] })] })) })] }));
198
- }
199
- //# sourceMappingURL=EmbeddedTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EmbeddedTool.js","sourceRoot":"","sources":["../../../src/client/extensions/EmbeddedTool.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,8BAA8B,EAC9B,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,GA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E,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,EACnB,SAAS,EAAC,oHAAoH,uBAGvH,IACL,IACF,CACP,GACc,IACT,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { agentNativePath } from \"../api-path.js\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useNavigate } from \"react-router\";\nimport {\n IconDots,\n IconExternalLink,\n IconLayoutSidebarRightCollapse,\n IconTrash,\n} from \"@tabler/icons-react\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../components/ui/popover.js\";\nimport {\n isAllowedToolPath,\n sanitizeToolRequestOptions,\n checkBridgePolicy,\n type ToolBridgeRole,\n} from \"./iframe-bridge.js\";\n\ninterface Tool {\n id: string;\n name: string;\n description?: string;\n content?: string;\n updatedAt?: string;\n}\n\nexport interface EmbeddedToolProps {\n toolId: string;\n /** Slot identifier passed via the iframe URL so the tool runtime knows it's\n * embedded and enables auto-resize. */\n slotId: string;\n /** Object pushed into the tool as `window.slotContext`. Re-posted whenever\n * the host re-renders with a new context. */\n context?: Record<string, unknown> | null;\n /** Optional className applied to the iframe container. */\n className?: string;\n /** Initial iframe height before content reports a real height. */\n initialHeight?: number;\n}\n\n/**\n * Renders a tool inline as a small auto-sized iframe — for use inside an\n * `<ExtensionSlot>`. Different from `<ToolViewer>` (which is full-page with a\n * toolbar): no header, sized to content, receives a `slotContext`.\n */\nexport function EmbeddedTool({\n toolId,\n slotId,\n context,\n className,\n initialHeight = 80,\n}: EmbeddedToolProps) {\n const iframeRef = useRef<HTMLIFrameElement | null>(null);\n const [height, setHeight] = useState<number>(initialHeight);\n const [isDark, setIsDark] = useState(false);\n // (audit H4) Mirror ToolViewer's role-aware gating; deny-by-default until\n // the iframe's render binding announcement arrives.\n const bridgeContextRef = useRef<{\n role: ToolBridgeRole;\n isAuthor: boolean;\n }>({\n role: \"viewer\",\n isAuthor: false,\n });\n\n useEffect(() => {\n setIsDark(document.documentElement.classList.contains(\"dark\"));\n const observer = new MutationObserver(() => {\n setIsDark(document.documentElement.classList.contains(\"dark\"));\n });\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n return () => observer.disconnect();\n }, []);\n\n const { data: tool } = useQuery<Tool>({\n queryKey: [\"tool\", toolId],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(`/_agent-native/tools/${toolId}`),\n );\n if (!res.ok) throw new Error(\"Failed to fetch tool\");\n return res.json();\n },\n });\n\n const iframeSrc = useMemo(() => {\n const v = encodeURIComponent(tool?.updatedAt ?? \"\");\n return agentNativePath(\n `/_agent-native/tools/${toolId}/render?slot=${encodeURIComponent(slotId)}&dark=${isDark}&v=${v}`,\n );\n }, [toolId, slotId, isDark, tool?.updatedAt]);\n\n // Forward slot context whenever it changes. The iframe's own load handler\n // posts the initial value once it's ready; this effect handles updates.\n const contextJson = JSON.stringify(context ?? {});\n useEffect(() => {\n const win = iframeRef.current?.contentWindow;\n if (!win) return;\n win.postMessage(\n { type: \"agent-native-slot-context\", context: context ?? {} },\n \"*\",\n );\n }, [contextJson]);\n\n // Bridge tool requests + height reports.\n useEffect(() => {\n const handleMessage = async (event: MessageEvent) => {\n if (event.source !== iframeRef.current?.contentWindow) return;\n const message = event.data;\n if (!message || typeof message !== \"object\") return;\n\n if (message.type === \"agent-native-tool-binding\") {\n const binding = (message as any).binding ?? {};\n const role: ToolBridgeRole =\n binding.role === \"owner\" ||\n binding.role === \"admin\" ||\n binding.role === \"editor\" ||\n binding.role === \"viewer\"\n ? binding.role\n : \"viewer\";\n bridgeContextRef.current = {\n role,\n isAuthor: !!binding.isAuthor,\n };\n return;\n }\n\n if (message.type === \"agent-native-tool-resize\") {\n const h = Number(message.height);\n if (Number.isFinite(h) && h > 0) {\n setHeight(Math.ceil(h));\n }\n return;\n }\n\n if (message.type !== \"agent-native-tool-request\") return;\n\n const requestId = String(message.requestId ?? \"\");\n const path = String(message.path ?? \"\");\n const respond = (payload: Record<string, unknown>) => {\n iframeRef.current?.contentWindow?.postMessage(\n { type: \"agent-native-tool-response\", requestId, ...payload },\n \"*\",\n );\n };\n\n if (!requestId || !isAllowedToolPath(path, toolId)) {\n respond({ error: \"Tool request path is not allowed\" });\n return;\n }\n\n try {\n const options = sanitizeToolRequestOptions(message.options);\n // (audit H4) Role-aware gating: viewer-shared tools can read but not\n // write. The bridge policy is decided here in the parent before the\n // request leaves; the server enforces a second layer.\n const policy = checkBridgePolicy(\n path,\n options.method ?? \"GET\",\n bridgeContextRef.current,\n );\n if (!policy.ok) {\n respond({\n response: {\n ok: false,\n status: 403,\n statusText: \"Forbidden\",\n body: { error: policy.error },\n },\n });\n return;\n }\n // (audit H5) Same tool-bridge tagging as <ToolViewer>. action-routes\n // uses these headers to enforce per-action `toolCallable` opt-in.\n const finalHeaders = new Headers(options.headers ?? undefined);\n finalHeaders.set(\"X-Agent-Native-Tool-Bridge\", \"1\");\n finalHeaders.set(\"X-Agent-Native-Tool-Id\", toolId);\n const res = await fetch(agentNativePath(path), {\n ...options,\n headers: finalHeaders,\n credentials: \"same-origin\",\n });\n const text = await res.text();\n let body: unknown = text;\n if (text) {\n try {\n body = JSON.parse(text);\n } catch {\n body = text;\n }\n }\n respond({\n response: {\n ok: res.ok,\n status: res.status,\n statusText: res.statusText,\n body,\n },\n });\n } catch (err: any) {\n respond({ error: err?.message ?? \"Tool host request failed\" });\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n return () => window.removeEventListener(\"message\", handleMessage);\n }, [toolId]);\n\n if (!tool) {\n return (\n <div\n className={className}\n style={{ height: initialHeight }}\n aria-busy=\"true\"\n />\n );\n }\n\n return (\n <div className={`relative group/embedded-tool ${className ?? \"\"}`}>\n <iframe\n ref={iframeRef}\n key={`${toolId}-${tool.updatedAt ?? \"\"}`}\n src={iframeSrc}\n title={tool.name}\n sandbox=\"allow-scripts allow-forms\"\n style={{ width: \"100%\", border: 0, height, display: \"block\" }}\n onLoad={() => {\n iframeRef.current?.contentWindow?.postMessage(\n { type: \"agent-native-slot-context\", context: context ?? {} },\n \"*\",\n );\n }}\n />\n <EmbeddedToolMenu toolId={toolId} slotId={slotId} toolName={tool.name} />\n </div>\n );\n}\n\nfunction EmbeddedToolMenu({\n toolId,\n slotId,\n toolName,\n}: {\n toolId: string;\n slotId: string;\n toolName: string;\n}) {\n const [open, setOpen] = useState(false);\n const [confirmingDelete, setConfirmingDelete] = useState(false);\n const queryClient = useQueryClient();\n const navigate = useNavigate();\n\n const closeMenu = () => {\n setOpen(false);\n setConfirmingDelete(false);\n };\n\n const removeFromSlot = async () => {\n closeMenu();\n queryClient.setQueryData<any[]>([\"slot-installs\", slotId], (old) =>\n (old ?? []).filter((i) => i.toolId !== toolId),\n );\n try {\n await fetch(\n agentNativePath(\n `/_agent-native/slots/${encodeURIComponent(slotId)}/install/${encodeURIComponent(toolId)}`,\n ),\n { method: \"DELETE\" },\n );\n } finally {\n queryClient.invalidateQueries({ queryKey: [\"slot-installs\", slotId] });\n }\n };\n\n const deleteTool = async () => {\n closeMenu();\n queryClient.setQueryData<any[]>([\"slot-installs\", slotId], (old) =>\n (old ?? []).filter((i) => i.toolId !== toolId),\n );\n try {\n await fetch(agentNativePath(`/_agent-native/tools/${toolId}`), {\n method: \"DELETE\",\n });\n } finally {\n queryClient.invalidateQueries({ queryKey: [\"slot-installs\", slotId] });\n queryClient.invalidateQueries({ queryKey: [\"tool\", toolId] });\n queryClient.invalidateQueries({ queryKey: [\"tools\"] });\n }\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={(o) => {\n setOpen(o);\n if (!o) setConfirmingDelete(false);\n }}\n >\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n className=\"absolute top-1 right-1 flex h-6 w-6 items-center justify-center rounded-md bg-background/60 text-muted-foreground/60 opacity-0 hover:bg-accent hover:text-foreground hover:opacity-100 group-hover/embedded-tool:opacity-100 cursor-pointer transition-opacity\"\n title={`${toolName} options`}\n aria-label={`${toolName} options`}\n >\n <IconDots className=\"h-3.5 w-3.5\" />\n </button>\n </PopoverTrigger>\n <PopoverContent align=\"end\" sideOffset={4} className=\"w-56 p-1\">\n {!confirmingDelete ? (\n <div className=\"flex flex-col\">\n <button\n type=\"button\"\n onClick={() => {\n closeMenu();\n navigate(`/tools/${toolId}`);\n }}\n className=\"flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] hover:bg-accent cursor-pointer text-left\"\n >\n <IconExternalLink className=\"h-3.5 w-3.5\" />\n <span>Open full view</span>\n </button>\n <button\n type=\"button\"\n onClick={removeFromSlot}\n className=\"flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] hover:bg-accent cursor-pointer text-left\"\n >\n <IconLayoutSidebarRightCollapse className=\"h-3.5 w-3.5\" />\n <span>Remove from this widget area</span>\n </button>\n <div className=\"my-1 h-px bg-border/40\" />\n <button\n type=\"button\"\n onClick={() => setConfirmingDelete(true)}\n className=\"flex items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] text-destructive hover:bg-destructive/10 cursor-pointer text-left\"\n >\n <IconTrash className=\"h-3.5 w-3.5\" />\n <span>Delete tool…</span>\n </button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-2 p-2\">\n <p className=\"text-[12px]\">\n Delete <span className=\"font-medium\">{toolName}</span>? This\n removes the tool everywhere, for everyone it's shared with.\n </p>\n <div className=\"flex justify-end gap-1\">\n <button\n type=\"button\"\n onClick={() => setConfirmingDelete(false)}\n className=\"rounded-md px-2 py-1 text-[12px] hover:bg-accent cursor-pointer\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={deleteTool}\n className=\"rounded-md bg-destructive px-2 py-1 text-[12px] text-destructive-foreground hover:bg-destructive/90 cursor-pointer\"\n >\n Delete\n </button>\n </div>\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n"]}
@@ -1,5 +0,0 @@
1
- export interface ToolEditorProps {
2
- toolId?: string;
3
- }
4
- export declare function ToolEditor({ toolId }: ToolEditorProps): import("react/jsx-runtime").JSX.Element;
5
- //# sourceMappingURL=ToolEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToolEditor.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/ToolEditor.tsx"],"names":[],"mappings":"AA+BA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,2CAmUrD"}
@@ -1,129 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { agentNativePath } from "../api-path.js";
3
- import { useState, useEffect } from "react";
4
- import { useQuery, useQueryClient } from "@tanstack/react-query";
5
- import { Link, useNavigate } from "react-router";
6
- import { IconArrowLeft, IconDeviceFloppy, IconDots, IconTrash, IconX, } from "@tabler/icons-react";
7
- import { Popover, PopoverContent, PopoverTrigger, } from "../components/ui/popover.js";
8
- import { cn } from "../utils.js";
9
- export function ToolEditor({ toolId }) {
10
- const navigate = useNavigate();
11
- const queryClient = useQueryClient();
12
- const isEdit = !!toolId;
13
- const [name, setName] = useState("");
14
- const [description, setDescription] = useState("");
15
- const [content, setContent] = useState("");
16
- const [saving, setSaving] = useState(false);
17
- const [deleting, setDeleting] = useState(false);
18
- const [menuOpen, setMenuOpen] = useState(false);
19
- const [confirmingDelete, setConfirmingDelete] = useState(false);
20
- const { data: slots = [] } = useQuery({
21
- queryKey: ["tool-slots", toolId],
22
- queryFn: async () => {
23
- const res = await fetch(agentNativePath(`/_agent-native/slots/tool/${toolId}`));
24
- if (!res.ok)
25
- return [];
26
- return res.json();
27
- },
28
- enabled: isEdit && menuOpen,
29
- });
30
- const { data: existingTool } = useQuery({
31
- queryKey: ["tool", toolId],
32
- queryFn: async () => {
33
- const res = await fetch(agentNativePath(`/_agent-native/tools/${toolId}`));
34
- if (!res.ok)
35
- throw new Error("Failed to fetch tool");
36
- return res.json();
37
- },
38
- enabled: isEdit,
39
- });
40
- useEffect(() => {
41
- if (existingTool) {
42
- setName(existingTool.name ?? "");
43
- setDescription(existingTool.description ?? "");
44
- setContent(existingTool.content ?? "");
45
- }
46
- }, [existingTool]);
47
- const handleSave = async () => {
48
- if (!name.trim())
49
- return;
50
- setSaving(true);
51
- try {
52
- const body = JSON.stringify({
53
- name: name.trim(),
54
- description: description.trim() || undefined,
55
- content,
56
- });
57
- if (isEdit) {
58
- const res = await fetch(agentNativePath(`/_agent-native/tools/${toolId}`), {
59
- method: "PUT",
60
- headers: { "Content-Type": "application/json" },
61
- body,
62
- });
63
- if (!res.ok)
64
- throw new Error("Update failed");
65
- queryClient.invalidateQueries({ queryKey: ["tool", toolId] });
66
- queryClient.invalidateQueries({ queryKey: ["tools"] });
67
- navigate(`/tools/${toolId}`);
68
- }
69
- else {
70
- const res = await fetch(agentNativePath("/_agent-native/tools"), {
71
- method: "POST",
72
- headers: { "Content-Type": "application/json" },
73
- body,
74
- });
75
- if (!res.ok)
76
- throw new Error("Create failed");
77
- const created = await res.json();
78
- queryClient.invalidateQueries({ queryKey: ["tools"] });
79
- navigate(`/tools/${created.id}`);
80
- }
81
- }
82
- finally {
83
- setSaving(false);
84
- }
85
- };
86
- const handleDelete = async () => {
87
- if (!toolId)
88
- return;
89
- setDeleting(true);
90
- try {
91
- const prev = queryClient.getQueryData(["tools"]);
92
- queryClient.setQueryData(["tools"], (old) => (old ?? []).filter((t) => t.id !== toolId));
93
- const res = await fetch(agentNativePath(`/_agent-native/tools/${toolId}`), {
94
- method: "DELETE",
95
- });
96
- if (!res.ok) {
97
- if (prev)
98
- queryClient.setQueryData(["tools"], prev);
99
- throw new Error("Delete failed");
100
- }
101
- queryClient.invalidateQueries({ queryKey: ["tools"] });
102
- slots.forEach((s) => queryClient.invalidateQueries({
103
- queryKey: ["slot-installs", s.slotId],
104
- }));
105
- navigate("/tools");
106
- }
107
- finally {
108
- setDeleting(false);
109
- setConfirmingDelete(false);
110
- setMenuOpen(false);
111
- }
112
- };
113
- const handleRemoveFromSlot = async (slotId) => {
114
- if (!toolId)
115
- return;
116
- try {
117
- await fetch(agentNativePath(`/_agent-native/slots/${encodeURIComponent(slotId)}/install/${encodeURIComponent(toolId)}`), { method: "DELETE" });
118
- }
119
- finally {
120
- queryClient.invalidateQueries({ queryKey: ["slot-installs", slotId] });
121
- }
122
- };
123
- return (_jsxs("div", { className: "flex h-full flex-col", children: [_jsxs("header", { className: "flex items-center justify-between border-b px-4 py-3", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Link, { to: isEdit ? `/tools/${toolId}` : "/tools", className: "inline-flex cursor-pointer items-center justify-center rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground", "aria-label": "Back", children: _jsx(IconArrowLeft, { className: "h-4 w-4" }) }), _jsx("h1", { className: "text-sm font-semibold", children: isEdit ? "Edit Tool" : "New Tool" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("button", { type: "button", onClick: handleSave, disabled: saving || !name.trim(), className: cn("inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:bg-primary/90", (saving || !name.trim()) && "opacity-60"), children: [_jsx(IconDeviceFloppy, { className: "h-3.5 w-3.5" }), saving ? "Saving..." : isEdit ? "Save" : "Create"] }), isEdit && (_jsxs(Popover, { open: menuOpen, onOpenChange: (o) => {
124
- setMenuOpen(o);
125
- if (!o)
126
- setConfirmingDelete(false);
127
- }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "inline-flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground", title: "More options", "aria-label": "More options", children: _jsx(IconDots, { className: "h-4 w-4" }) }) }), _jsx(PopoverContent, { align: "end", sideOffset: 4, className: "w-72 p-0", children: !confirmingDelete ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "px-3 py-2 border-b border-border/40", children: [_jsx("p", { className: "text-[12px] font-medium", children: "Appears in" }), slots.length === 0 ? (_jsx("p", { className: "text-[11px] text-muted-foreground/70 mt-0.5", children: "Not installed in any widget areas. Ask the agent to add it somewhere." })) : (_jsxs("p", { className: "text-[11px] text-muted-foreground/70 mt-0.5", children: ["This tool can render in ", slots.length, " widget area", slots.length === 1 ? "" : "s", "."] }))] }), slots.length > 0 && (_jsx("div", { className: "max-h-48 overflow-y-auto py-1", children: slots.map((s) => (_jsxs("div", { className: "flex items-center gap-2 px-3 py-1.5 text-[12px]", children: [_jsx("span", { className: "flex-1 truncate font-mono text-[11px] text-muted-foreground", children: s.slotId }), _jsx("button", { type: "button", onClick: () => handleRemoveFromSlot(s.slotId), className: "rounded p-1 text-muted-foreground/60 hover:bg-accent hover:text-foreground cursor-pointer", title: "Remove from this widget area (for me)", "aria-label": "Remove from this widget area", children: _jsx(IconX, { className: "h-3.5 w-3.5" }) })] }, s.id))) })), _jsx("div", { className: "border-t border-border/40 p-1", children: _jsxs("button", { type: "button", onClick: () => setConfirmingDelete(true), className: "flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] text-destructive hover:bg-destructive/10 cursor-pointer text-left", children: [_jsx(IconTrash, { className: "h-3.5 w-3.5" }), _jsx("span", { children: "Delete tool\u2026" })] }) })] })) : (_jsxs("div", { className: "flex flex-col gap-2 p-3", children: [_jsxs("p", { className: "text-[12px]", children: ["Delete ", _jsx("span", { className: "font-medium", children: name }), "? This removes the tool everywhere, for everyone it's shared with."] }), _jsxs("div", { className: "flex justify-end gap-1", children: [_jsx("button", { type: "button", onClick: () => setConfirmingDelete(false), className: "rounded-md px-2 py-1 text-[12px] hover:bg-accent cursor-pointer", children: "Cancel" }), _jsx("button", { type: "button", onClick: handleDelete, disabled: deleting, className: cn("rounded-md bg-destructive px-2 py-1 text-[12px] text-destructive-foreground hover:bg-destructive/90 cursor-pointer", deleting && "opacity-60"), children: deleting ? "Deleting…" : "Delete" })] })] })) })] }))] })] }), _jsxs("div", { className: "flex flex-1 overflow-hidden", children: [_jsxs("div", { className: "flex w-1/2 flex-col gap-4 overflow-auto border-r p-4", children: [_jsxs("div", { children: [_jsx("label", { className: "mb-1.5 block text-sm font-medium text-foreground", children: "Name" }), _jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), placeholder: "My Tool", className: "h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background" })] }), _jsxs("div", { children: [_jsx("label", { className: "mb-1.5 block text-sm font-medium text-foreground", children: "Description" }), _jsx("textarea", { value: description, onChange: (e) => setDescription(e.target.value), placeholder: "What does this tool do?", rows: 2, className: "w-full resize-none rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background" })] }), _jsxs("div", { className: "flex flex-1 flex-col", children: [_jsx("label", { className: "mb-1.5 block text-sm font-medium text-foreground", children: "Content" }), _jsx("textarea", { value: content, onChange: (e) => setContent(e.target.value), placeholder: "<html>...</html>", className: "flex-1 resize-none rounded-md border border-input bg-background p-3 font-mono text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background", spellCheck: false })] })] }), _jsx("div", { className: "w-1/2", children: content ? (_jsx("iframe", { srcDoc: content, className: "h-full w-full border-0", sandbox: "allow-scripts allow-forms", title: "Tool preview" })) : (_jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Preview will appear here" })) })] })] }));
128
- }
129
- //# sourceMappingURL=ToolEditor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToolEditor.js","sourceRoot":"","sources":["../../../src/client/extensions/ToolEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,O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AC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACxC,WAAW,EAAC,SAAS,EACrB,SAAS,EAAC,yNAAyN,GACnO,IACE,EAEN,0BACE,gBAAO,SAAS,EAAC,kDAAkD,4BAE3D,EACR,mBACE,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,WAAW,EAAC,yBAAyB,EACrC,IAAI,EAAE,CAAC,EACP,SAAS,EAAC,sOAAsO,GAChP,IACE,EAEN,eAAK,SAAS,EAAC,sBAAsB,aACnC,gBAAO,SAAS,EAAC,kDAAkD,wBAE3D,EACR,mBACE,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC3C,WAAW,EAAC,kBAAkB,EAC9B,SAAS,EAAC,0OAA0O,EACpP,UAAU,EAAE,KAAK,GACjB,IACE,IACF,EAEN,cAAK,SAAS,EAAC,OAAO,YACnB,OAAO,CAAC,CAAC,CAAC,CACT,iBACE,MAAM,EAAE,OAAO,EACf,SAAS,EAAC,wBAAwB,EAClC,OAAO,EAAC,2BAA2B,EACnC,KAAK,EAAC,cAAc,GACpB,CACH,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,uEAAuE,yCAEhF,CACP,GACG,IACF,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { agentNativePath } from \"../api-path.js\";\nimport { useState, useEffect } from \"react\";\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { Link, useNavigate } from \"react-router\";\nimport {\n IconArrowLeft,\n IconDeviceFloppy,\n IconDots,\n IconTrash,\n IconX,\n} from \"@tabler/icons-react\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../components/ui/popover.js\";\nimport { cn } from \"../utils.js\";\n\ninterface SlotDeclaration {\n id: string;\n toolId: string;\n slotId: string;\n}\n\ninterface Tool {\n id: string;\n name: string;\n description?: string;\n content?: string;\n}\n\nexport interface ToolEditorProps {\n toolId?: string;\n}\n\nexport function ToolEditor({ toolId }: ToolEditorProps) {\n const navigate = useNavigate();\n const queryClient = useQueryClient();\n const isEdit = !!toolId;\n\n const [name, setName] = useState(\"\");\n const [description, setDescription] = useState(\"\");\n const [content, setContent] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const [menuOpen, setMenuOpen] = useState(false);\n const [confirmingDelete, setConfirmingDelete] = useState(false);\n\n const { data: slots = [] } = useQuery<SlotDeclaration[]>({\n queryKey: [\"tool-slots\", toolId],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(`/_agent-native/slots/tool/${toolId}`),\n );\n if (!res.ok) return [];\n return res.json();\n },\n enabled: isEdit && menuOpen,\n });\n\n const { data: existingTool } = useQuery<Tool>({\n queryKey: [\"tool\", toolId],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(`/_agent-native/tools/${toolId}`),\n );\n if (!res.ok) throw new Error(\"Failed to fetch tool\");\n return res.json();\n },\n enabled: isEdit,\n });\n\n useEffect(() => {\n if (existingTool) {\n setName(existingTool.name ?? \"\");\n setDescription(existingTool.description ?? \"\");\n setContent(existingTool.content ?? \"\");\n }\n }, [existingTool]);\n\n const handleSave = async () => {\n if (!name.trim()) return;\n setSaving(true);\n try {\n const body = JSON.stringify({\n name: name.trim(),\n description: description.trim() || undefined,\n content,\n });\n\n if (isEdit) {\n const res = await fetch(\n agentNativePath(`/_agent-native/tools/${toolId}`),\n {\n method: \"PUT\",\n headers: { \"Content-Type\": \"application/json\" },\n body,\n },\n );\n if (!res.ok) throw new Error(\"Update failed\");\n queryClient.invalidateQueries({ queryKey: [\"tool\", toolId] });\n queryClient.invalidateQueries({ queryKey: [\"tools\"] });\n navigate(`/tools/${toolId}`);\n } else {\n const res = await fetch(agentNativePath(\"/_agent-native/tools\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body,\n });\n if (!res.ok) throw new Error(\"Create failed\");\n const created = await res.json();\n queryClient.invalidateQueries({ queryKey: [\"tools\"] });\n navigate(`/tools/${created.id}`);\n }\n } finally {\n setSaving(false);\n }\n };\n\n const handleDelete = async () => {\n if (!toolId) return;\n setDeleting(true);\n try {\n const prev = queryClient.getQueryData<Tool[]>([\"tools\"]);\n queryClient.setQueryData<Tool[]>([\"tools\"], (old) =>\n (old ?? []).filter((t) => t.id !== toolId),\n );\n\n const res = await fetch(\n agentNativePath(`/_agent-native/tools/${toolId}`),\n {\n method: \"DELETE\",\n },\n );\n if (!res.ok) {\n if (prev) queryClient.setQueryData([\"tools\"], prev);\n throw new Error(\"Delete failed\");\n }\n\n queryClient.invalidateQueries({ queryKey: [\"tools\"] });\n slots.forEach((s) =>\n queryClient.invalidateQueries({\n queryKey: [\"slot-installs\", s.slotId],\n }),\n );\n navigate(\"/tools\");\n } finally {\n setDeleting(false);\n setConfirmingDelete(false);\n setMenuOpen(false);\n }\n };\n\n const handleRemoveFromSlot = async (slotId: string) => {\n if (!toolId) return;\n try {\n await fetch(\n agentNativePath(\n `/_agent-native/slots/${encodeURIComponent(slotId)}/install/${encodeURIComponent(toolId)}`,\n ),\n { method: \"DELETE\" },\n );\n } finally {\n queryClient.invalidateQueries({ queryKey: [\"slot-installs\", slotId] });\n }\n };\n\n return (\n <div className=\"flex h-full flex-col\">\n <header className=\"flex items-center justify-between border-b px-4 py-3\">\n <div className=\"flex items-center gap-3\">\n <Link\n to={isEdit ? `/tools/${toolId}` : \"/tools\"}\n className=\"inline-flex cursor-pointer items-center justify-center rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground\"\n aria-label=\"Back\"\n >\n <IconArrowLeft className=\"h-4 w-4\" />\n </Link>\n <h1 className=\"text-sm font-semibold\">\n {isEdit ? \"Edit Tool\" : \"New Tool\"}\n </h1>\n </div>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saving || !name.trim()}\n className={cn(\n \"inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:bg-primary/90\",\n (saving || !name.trim()) && \"opacity-60\",\n )}\n >\n <IconDeviceFloppy className=\"h-3.5 w-3.5\" />\n {saving ? \"Saving...\" : isEdit ? \"Save\" : \"Create\"}\n </button>\n {isEdit && (\n <Popover\n open={menuOpen}\n onOpenChange={(o) => {\n setMenuOpen(o);\n if (!o) setConfirmingDelete(false);\n }}\n >\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n className=\"inline-flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground\"\n title=\"More options\"\n aria-label=\"More options\"\n >\n <IconDots className=\"h-4 w-4\" />\n </button>\n </PopoverTrigger>\n <PopoverContent align=\"end\" sideOffset={4} className=\"w-72 p-0\">\n {!confirmingDelete ? (\n <>\n <div className=\"px-3 py-2 border-b border-border/40\">\n <p className=\"text-[12px] font-medium\">Appears in</p>\n {slots.length === 0 ? (\n <p className=\"text-[11px] text-muted-foreground/70 mt-0.5\">\n Not installed in any widget areas. Ask the agent to\n add it somewhere.\n </p>\n ) : (\n <p className=\"text-[11px] text-muted-foreground/70 mt-0.5\">\n This tool can render in {slots.length} widget area\n {slots.length === 1 ? \"\" : \"s\"}.\n </p>\n )}\n </div>\n {slots.length > 0 && (\n <div className=\"max-h-48 overflow-y-auto py-1\">\n {slots.map((s) => (\n <div\n key={s.id}\n className=\"flex items-center gap-2 px-3 py-1.5 text-[12px]\"\n >\n <span className=\"flex-1 truncate font-mono text-[11px] text-muted-foreground\">\n {s.slotId}\n </span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFromSlot(s.slotId)}\n className=\"rounded p-1 text-muted-foreground/60 hover:bg-accent hover:text-foreground cursor-pointer\"\n title=\"Remove from this widget area (for me)\"\n aria-label=\"Remove from this widget area\"\n >\n <IconX className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n ))}\n </div>\n )}\n <div className=\"border-t border-border/40 p-1\">\n <button\n type=\"button\"\n onClick={() => setConfirmingDelete(true)}\n className=\"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] text-destructive hover:bg-destructive/10 cursor-pointer text-left\"\n >\n <IconTrash className=\"h-3.5 w-3.5\" />\n <span>Delete tool…</span>\n </button>\n </div>\n </>\n ) : (\n <div className=\"flex flex-col gap-2 p-3\">\n <p className=\"text-[12px]\">\n Delete <span className=\"font-medium\">{name}</span>? This\n removes the tool everywhere, for everyone it's shared\n with.\n </p>\n <div className=\"flex justify-end gap-1\">\n <button\n type=\"button\"\n onClick={() => setConfirmingDelete(false)}\n className=\"rounded-md px-2 py-1 text-[12px] hover:bg-accent cursor-pointer\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={handleDelete}\n disabled={deleting}\n className={cn(\n \"rounded-md bg-destructive px-2 py-1 text-[12px] text-destructive-foreground hover:bg-destructive/90 cursor-pointer\",\n deleting && \"opacity-60\",\n )}\n >\n {deleting ? \"Deleting…\" : \"Delete\"}\n </button>\n </div>\n </div>\n )}\n </PopoverContent>\n </Popover>\n )}\n </div>\n </header>\n\n <div className=\"flex flex-1 overflow-hidden\">\n <div className=\"flex w-1/2 flex-col gap-4 overflow-auto border-r p-4\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-foreground\">\n Name\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder=\"My Tool\"\n className=\"h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\"\n />\n </div>\n\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-foreground\">\n Description\n </label>\n <textarea\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"What does this tool do?\"\n rows={2}\n className=\"w-full resize-none rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\"\n />\n </div>\n\n <div className=\"flex flex-1 flex-col\">\n <label className=\"mb-1.5 block text-sm font-medium text-foreground\">\n Content\n </label>\n <textarea\n value={content}\n onChange={(e) => setContent(e.target.value)}\n placeholder=\"<html>...</html>\"\n className=\"flex-1 resize-none rounded-md border border-input bg-background p-3 font-mono text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\"\n spellCheck={false}\n />\n </div>\n </div>\n\n <div className=\"w-1/2\">\n {content ? (\n <iframe\n srcDoc={content}\n className=\"h-full w-full border-0\"\n sandbox=\"allow-scripts allow-forms\"\n title=\"Tool preview\"\n />\n ) : (\n <div className=\"flex h-full items-center justify-center text-sm text-muted-foreground\">\n Preview will appear here\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -1,5 +0,0 @@
1
- export interface ToolViewerProps {
2
- toolId: string;
3
- }
4
- export declare function ToolViewer({ toolId }: ToolViewerProps): import("react/jsx-runtime").JSX.Element;
5
- //# sourceMappingURL=ToolViewer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToolViewer.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/ToolViewer.tsx"],"names":[],"mappings":"AA8EA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AA4DD,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,2CA8YrD"}