@stigmer/react 3.1.7 → 3.1.9

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 (206) hide show
  1. package/agent/AgentDetailView.d.ts +9 -1
  2. package/agent/AgentDetailView.d.ts.map +1 -1
  3. package/agent/AgentDetailView.js +15 -4
  4. package/agent/AgentDetailView.js.map +1 -1
  5. package/environment/EnvironmentListPanel.d.ts.map +1 -1
  6. package/environment/EnvironmentListPanel.js +11 -3
  7. package/environment/EnvironmentListPanel.js.map +1 -1
  8. package/environment/EnvironmentPicker.d.ts +17 -1
  9. package/environment/EnvironmentPicker.d.ts.map +1 -1
  10. package/environment/EnvironmentPicker.js +3 -2
  11. package/environment/EnvironmentPicker.js.map +1 -1
  12. package/environment/EnvironmentVariableEditor.d.ts.map +1 -1
  13. package/environment/EnvironmentVariableEditor.js +9 -3
  14. package/environment/EnvironmentVariableEditor.js.map +1 -1
  15. package/environment/index.d.ts +1 -0
  16. package/environment/index.d.ts.map +1 -1
  17. package/environment/index.js +1 -0
  18. package/environment/index.js.map +1 -1
  19. package/environment/shareRestriction.d.ts +13 -0
  20. package/environment/shareRestriction.d.ts.map +1 -0
  21. package/environment/shareRestriction.js +15 -0
  22. package/environment/shareRestriction.js.map +1 -0
  23. package/execution/ToolCallItem.d.ts.map +1 -1
  24. package/execution/ToolCallItem.js +12 -0
  25. package/execution/ToolCallItem.js.map +1 -1
  26. package/execution/ToolRunGroup.js +4 -0
  27. package/execution/ToolRunGroup.js.map +1 -1
  28. package/execution/WriteBackCard.d.ts +14 -5
  29. package/execution/WriteBackCard.d.ts.map +1 -1
  30. package/execution/WriteBackCard.js +103 -32
  31. package/execution/WriteBackCard.js.map +1 -1
  32. package/execution/WriteBacksWidget.d.ts +1 -1
  33. package/execution/WriteBacksWidget.js +2 -2
  34. package/execution/WriteBacksWidget.js.map +1 -1
  35. package/execution/index.d.ts +2 -0
  36. package/execution/index.d.ts.map +1 -1
  37. package/execution/index.js +1 -0
  38. package/execution/index.js.map +1 -1
  39. package/execution/write-back-utils.d.ts +57 -0
  40. package/execution/write-back-utils.d.ts.map +1 -0
  41. package/execution/write-back-utils.js +81 -0
  42. package/execution/write-back-utils.js.map +1 -0
  43. package/index.d.ts +6 -2
  44. package/index.d.ts.map +1 -1
  45. package/index.js +6 -1
  46. package/index.js.map +1 -1
  47. package/internal/dev/dom-counter.d.ts.map +1 -1
  48. package/internal/dev/dom-counter.js +2 -2
  49. package/internal/dev/dom-counter.js.map +1 -1
  50. package/internal/dev/enabled.d.ts +7 -0
  51. package/internal/dev/enabled.d.ts.map +1 -0
  52. package/internal/dev/enabled.js +38 -0
  53. package/internal/dev/enabled.js.map +1 -0
  54. package/internal/dev/profiler-wrapper.d.ts +3 -3
  55. package/internal/dev/profiler-wrapper.d.ts.map +1 -1
  56. package/internal/dev/profiler-wrapper.js +5 -5
  57. package/internal/dev/profiler-wrapper.js.map +1 -1
  58. package/internal/dev/use-key-stability.d.ts.map +1 -1
  59. package/internal/dev/use-key-stability.js +2 -2
  60. package/internal/dev/use-key-stability.js.map +1 -1
  61. package/internal/dev/use-render-tracer.d.ts +2 -2
  62. package/internal/dev/use-render-tracer.d.ts.map +1 -1
  63. package/internal/dev/use-render-tracer.js +4 -4
  64. package/internal/dev/use-render-tracer.js.map +1 -1
  65. package/internal/dev/use-stream-rate.d.ts +2 -1
  66. package/internal/dev/use-stream-rate.d.ts.map +1 -1
  67. package/internal/dev/use-stream-rate.js +4 -3
  68. package/internal/dev/use-stream-rate.js.map +1 -1
  69. package/library/ResourceVisibilityControl.d.ts +3 -0
  70. package/library/ResourceVisibilityControl.d.ts.map +1 -1
  71. package/library/ResourceVisibilityControl.js +22 -8
  72. package/library/ResourceVisibilityControl.js.map +1 -1
  73. package/library/useUpdateVisibility.d.ts +5 -3
  74. package/library/useUpdateVisibility.d.ts.map +1 -1
  75. package/library/useUpdateVisibility.js +7 -2
  76. package/library/useUpdateVisibility.js.map +1 -1
  77. package/library/visibilityLevels.d.ts +17 -0
  78. package/library/visibilityLevels.d.ts.map +1 -1
  79. package/library/visibilityLevels.js +32 -0
  80. package/library/visibilityLevels.js.map +1 -1
  81. package/package.json +4 -4
  82. package/session/NewSessionViewer.d.ts +11 -1
  83. package/session/NewSessionViewer.d.ts.map +1 -1
  84. package/session/NewSessionViewer.js +28 -8
  85. package/session/NewSessionViewer.js.map +1 -1
  86. package/session/SessionViewer.d.ts +9 -2
  87. package/session/SessionViewer.d.ts.map +1 -1
  88. package/session/SessionViewer.js +26 -12
  89. package/session/SessionViewer.js.map +1 -1
  90. package/session/audience.d.ts +12 -4
  91. package/session/audience.d.ts.map +1 -1
  92. package/session/facets/ChangesTab.d.ts.map +1 -1
  93. package/session/facets/ChangesTab.js +3 -1
  94. package/session/facets/ChangesTab.js.map +1 -1
  95. package/session/useNewSessionFlow.d.ts +12 -0
  96. package/session/useNewSessionFlow.d.ts.map +1 -1
  97. package/session/useNewSessionFlow.js +13 -1
  98. package/session/useNewSessionFlow.js.map +1 -1
  99. package/session/useSessionPageFlow.d.ts +13 -0
  100. package/session/useSessionPageFlow.d.ts.map +1 -1
  101. package/session/useSessionPageFlow.js +7 -2
  102. package/session/useSessionPageFlow.js.map +1 -1
  103. package/sharing/ShareAgentDialog.d.ts +57 -0
  104. package/sharing/ShareAgentDialog.d.ts.map +1 -0
  105. package/sharing/ShareAgentDialog.js +478 -0
  106. package/sharing/ShareAgentDialog.js.map +1 -0
  107. package/sharing/SharedAgentChat.d.ts +84 -0
  108. package/sharing/SharedAgentChat.d.ts.map +1 -0
  109. package/sharing/SharedAgentChat.js +80 -0
  110. package/sharing/SharedAgentChat.js.map +1 -0
  111. package/sharing/index.d.ts +18 -0
  112. package/sharing/index.d.ts.map +1 -0
  113. package/sharing/index.js +12 -0
  114. package/sharing/index.js.map +1 -0
  115. package/sharing/useAgentShare.d.ts +43 -0
  116. package/sharing/useAgentShare.d.ts.map +1 -0
  117. package/sharing/useAgentShare.js +54 -0
  118. package/sharing/useAgentShare.js.map +1 -0
  119. package/sharing/useRotateShareLink.d.ts +45 -0
  120. package/sharing/useRotateShareLink.d.ts.map +1 -0
  121. package/sharing/useRotateShareLink.js +58 -0
  122. package/sharing/useRotateShareLink.js.map +1 -0
  123. package/sharing/useSaveAgentShare.d.ts +105 -0
  124. package/sharing/useSaveAgentShare.d.ts.map +1 -0
  125. package/sharing/useSaveAgentShare.js +97 -0
  126. package/sharing/useSaveAgentShare.js.map +1 -0
  127. package/sharing/useShareAgent.d.ts +69 -0
  128. package/sharing/useShareAgent.d.ts.map +1 -0
  129. package/sharing/useShareAgent.js +42 -0
  130. package/sharing/useShareAgent.js.map +1 -0
  131. package/sharing/useShareToolReadiness.d.ts +52 -0
  132. package/sharing/useShareToolReadiness.d.ts.map +1 -0
  133. package/sharing/useShareToolReadiness.js +89 -0
  134. package/sharing/useShareToolReadiness.js.map +1 -0
  135. package/sharing/useSharedAgentProfile.d.ts +85 -0
  136. package/sharing/useSharedAgentProfile.d.ts.map +1 -0
  137. package/sharing/useSharedAgentProfile.js +73 -0
  138. package/sharing/useSharedAgentProfile.js.map +1 -0
  139. package/src/agent/AgentDetailView.tsx +28 -3
  140. package/src/environment/EnvironmentListPanel.tsx +47 -18
  141. package/src/environment/EnvironmentPicker.tsx +23 -2
  142. package/src/environment/EnvironmentVariableEditor.tsx +27 -17
  143. package/src/environment/__tests__/shareRestriction.test.ts +35 -0
  144. package/src/environment/index.ts +5 -0
  145. package/src/environment/shareRestriction.ts +22 -0
  146. package/src/execution/ToolCallItem.tsx +19 -1
  147. package/src/execution/ToolRunGroup.tsx +4 -0
  148. package/src/execution/WriteBackCard.tsx +285 -88
  149. package/src/execution/WriteBacksWidget.tsx +5 -5
  150. package/src/execution/__tests__/ToolCallItem.test.tsx +51 -0
  151. package/src/execution/__tests__/ToolRunGroup.test.tsx +22 -0
  152. package/src/execution/__tests__/WriteBackCard.test.tsx +64 -10
  153. package/src/execution/__tests__/write-back-utils.test.ts +135 -0
  154. package/src/execution/index.ts +7 -0
  155. package/src/execution/write-back-utils.ts +107 -0
  156. package/src/index.ts +38 -0
  157. package/src/internal/dev/__tests__/use-key-stability.test.ts +4 -0
  158. package/src/internal/dev/__tests__/use-render-tracer.test.ts +4 -0
  159. package/src/internal/dev/dom-counter.ts +2 -3
  160. package/src/internal/dev/enabled.ts +39 -0
  161. package/src/internal/dev/profiler-wrapper.tsx +5 -6
  162. package/src/internal/dev/use-key-stability.ts +2 -3
  163. package/src/internal/dev/use-render-tracer.ts +4 -5
  164. package/src/internal/dev/use-stream-rate.ts +4 -4
  165. package/src/library/ResourceVisibilityControl.tsx +23 -7
  166. package/src/library/__tests__/visibilityLevels.test.ts +33 -0
  167. package/src/library/useUpdateVisibility.ts +9 -3
  168. package/src/library/visibilityLevels.ts +36 -0
  169. package/src/session/NewSessionViewer.tsx +67 -31
  170. package/src/session/SessionViewer.tsx +67 -36
  171. package/src/session/__tests__/audienceWiring.test.tsx +99 -0
  172. package/src/session/__tests__/useNewSessionFlow.test.tsx +75 -1
  173. package/src/session/__tests__/useSessionPageFlow.guest.test.tsx +112 -0
  174. package/src/session/audience.ts +12 -4
  175. package/src/session/facets/ChangesTab.tsx +6 -4
  176. package/src/session/useNewSessionFlow.ts +26 -1
  177. package/src/session/useSessionPageFlow.ts +24 -2
  178. package/src/sharing/ShareAgentDialog.tsx +1489 -0
  179. package/src/sharing/SharedAgentChat.tsx +283 -0
  180. package/src/sharing/__tests__/ShareAgentDialog.test.tsx +926 -0
  181. package/src/sharing/__tests__/SharedAgentChat.test.tsx +222 -0
  182. package/src/sharing/__tests__/useAgentShare.test.tsx +149 -0
  183. package/src/sharing/__tests__/useRotateShareLink.test.tsx +96 -0
  184. package/src/sharing/__tests__/useSaveAgentShare.test.tsx +241 -0
  185. package/src/sharing/__tests__/useShareAgent.test.tsx +131 -0
  186. package/src/sharing/__tests__/useShareToolReadiness.test.tsx +219 -0
  187. package/src/sharing/__tests__/useSharedAgentProfile.test.tsx +201 -0
  188. package/src/sharing/index.ts +32 -0
  189. package/src/sharing/useAgentShare.ts +91 -0
  190. package/src/sharing/useRotateShareLink.ts +81 -0
  191. package/src/sharing/useSaveAgentShare.ts +186 -0
  192. package/src/sharing/useShareAgent.tsx +107 -0
  193. package/src/sharing/useShareToolReadiness.ts +131 -0
  194. package/src/sharing/useSharedAgentProfile.ts +132 -0
  195. package/src/switch/Switch.tsx +97 -0
  196. package/src/switch/__tests__/Switch.test.tsx +107 -0
  197. package/src/switch/index.ts +2 -0
  198. package/styles.css +1 -1
  199. package/switch/Switch.d.ts +47 -0
  200. package/switch/Switch.d.ts.map +1 -0
  201. package/switch/Switch.js +41 -0
  202. package/switch/Switch.js.map +1 -0
  203. package/switch/index.d.ts +3 -0
  204. package/switch/index.d.ts.map +1 -0
  205. package/switch/index.js +2 -0
  206. package/switch/index.js.map +1 -0
@@ -0,0 +1,478 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useCallback, useMemo, useRef, useState } from "react";
4
+ import { cn } from "@stigmer/theme";
5
+ import { MAX_ALLOWED_ORIGINS, appendLinkToken, buildEmbedSnippet, chatPath, getUserMessage, validateOrigin, } from "@stigmer/sdk";
6
+ import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
7
+ import { Switch } from "../switch/Switch.js";
8
+ import { Tabs } from "../tabs/Tabs.js";
9
+ import { toast } from "../feedback/toast.js";
10
+ import { useCopyResource } from "../resource-detail/useCopyResource.js";
11
+ import { useDeploymentMode } from "../deployment-mode.js";
12
+ import { useBillingAccount } from "../billing/useBillingAccount.js";
13
+ import { formatCreditBalance } from "../billing/format.js";
14
+ import { EnvironmentPicker } from "../environment/EnvironmentPicker.js";
15
+ import { useAgentShare } from "./useAgentShare.js";
16
+ import { sharingAudienceFromProto, useSaveAgentShare, } from "./useSaveAgentShare.js";
17
+ import { useRotateShareLink } from "./useRotateShareLink.js";
18
+ import { useShareToolReadiness } from "./useShareToolReadiness.js";
19
+ /** Maximum length of each visitor message (proto: `string.max_len = 300`). */
20
+ const MAX_MESSAGE_LENGTH = 300;
21
+ const SHARE_TABS = [
22
+ { id: "link", label: "Link" },
23
+ { id: "embed", label: "Embed" },
24
+ { id: "developer", label: "Developer" },
25
+ ];
26
+ const PLATFORM_CLIENT_DOCS_URL = "https://docs.stigmer.ai/guides/authentication/platform-client/overview";
27
+ /**
28
+ * The Share dialog for an agent: toggle sharing, copy the hosted chat
29
+ * link, copy an embeddable snippet, manage allowed embed origins, bind
30
+ * tool credentials for visitors, customize visitor refusal messages,
31
+ * and discover the PlatformClient SDK path.
32
+ *
33
+ * Sharing is a distinct consent from marketplace visibility: visibility
34
+ * governs who can *read* the blueprint; sharing governs who can *chat*
35
+ * with the running agent — billed to the owning org. The dialog states
36
+ * who pays next to the toggle so enabling sharing never surprises.
37
+ *
38
+ * Sharing lives in its own **AgentShare resource** (decision 011), so
39
+ * the dialog loads the agent's canonical share when it opens and every
40
+ * save is an idempotent `apply` of the complete configuration — the
41
+ * first enable creates the share, later edits update it, one code path
42
+ * (see {@link useSaveAgentShare}). The local draft is refreshed from
43
+ * every returned share, so the dialog never drifts from the server.
44
+ *
45
+ * Built on the native `<dialog>` element for focus trapping and escape
46
+ * handling, matching the SDK's modal convention ({@link ManageAccessDialog}).
47
+ * All visual properties flow through `--stgm-*` design tokens.
48
+ *
49
+ * Most hosts mount it via {@link useShareAgent} (a kebab-menu action).
50
+ * Render it directly only when you own the open-state.
51
+ */
52
+ export function ShareAgentDialog({ open, onOpenChange, agent, buildShareUrl, onSharingChanged, modal = true, }) {
53
+ const dialogRef = useRef(null);
54
+ const handleClose = useCallback(() => {
55
+ dialogRef.current?.close();
56
+ onOpenChange(false);
57
+ }, [onOpenChange]);
58
+ // Sync native dialog open state (matches the SDK dialog convention).
59
+ // Non-modal hosts pass `open` as a plain attribute instead — the dialog
60
+ // renders in-flow with no top layer to manage.
61
+ const prevOpenRef = useRef(false);
62
+ if (modal && open !== prevOpenRef.current) {
63
+ prevOpenRef.current = open;
64
+ if (open) {
65
+ requestAnimationFrame(() => {
66
+ if (dialogRef.current && !dialogRef.current.open) {
67
+ dialogRef.current.showModal();
68
+ }
69
+ });
70
+ }
71
+ else if (dialogRef.current?.open) {
72
+ dialogRef.current.close();
73
+ }
74
+ }
75
+ return (_jsx("dialog", { ref: dialogRef, open: modal ? undefined : open, onClose: handleClose, className: cn("w-full max-w-lg rounded-xl border border-border bg-popover p-0 shadow-xl", modal ? "fixed inset-0 m-auto backdrop:bg-black/50" : "relative"), "aria-labelledby": "share-agent-title", children: open && (_jsx(ShareAgentDialogBody, { agent: agent, buildShareUrl: buildShareUrl, onSharingChanged: onSharingChanged, onClose: handleClose })) }));
76
+ }
77
+ // ---------------------------------------------------------------------------
78
+ // Dialog body — resolves the canonical share, then hands off to the form
79
+ // ---------------------------------------------------------------------------
80
+ /**
81
+ * Loads the agent's canonical share and mounts the form once resolved.
82
+ * The split keeps the form's draft seeding synchronous (`useState`
83
+ * initializer from the loaded share) — no hydrate-on-effect, no window
84
+ * where the switch shows a state the server never had.
85
+ */
86
+ function ShareAgentDialogBody({ agent, buildShareUrl, onSharingChanged, onClose, }) {
87
+ const { share, isLoading, error, refetch } = useAgentShare(agent);
88
+ return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-start justify-between border-b border-border px-6 py-4", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h2", { id: "share-agent-title", className: "text-base font-semibold text-foreground", children: "Share" }), _jsx("p", { className: "mt-0.5 truncate text-xs text-muted-foreground", children: agent.metadata?.name || agent.metadata?.slug })] }), _jsx("button", { type: "button", onClick: onClose, "aria-label": "Close", className: cn("rounded-md p-1 text-muted-foreground", "hover:text-foreground hover:bg-accent-hover", "focus:outline-none focus:ring-2 focus:ring-ring"), children: _jsx(CloseIcon, {}) })] }), isLoading ? (_jsxs("div", { className: "px-6 py-10 text-center", "aria-busy": "true", "aria-label": "Loading sharing settings", children: [_jsx("div", { className: "mx-auto h-4 w-2/3 animate-pulse rounded bg-muted" }), _jsx("div", { className: "mx-auto mt-2 h-3 w-1/2 animate-pulse rounded bg-muted" })] })) : error ? (_jsxs("div", { className: "px-6 py-8 text-center", role: "alert", children: [_jsx("p", { className: "text-sm text-foreground", children: "Couldn't load this agent's sharing settings." }), _jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: getUserMessage(error) }), _jsx("button", { type: "button", onClick: refetch, className: cn("mt-3 rounded-md px-3 py-1.5 text-xs font-medium", "border border-border text-foreground hover:bg-accent-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"), children: "Try again" })] })) : (_jsx(ShareAgentForm, { agent: agent, initialShare: share, buildShareUrl: buildShareUrl, onSharingChanged: onSharingChanged })), _jsx("div", { className: "flex items-center justify-end border-t border-border px-6 py-3", children: _jsx("button", { type: "button", onClick: onClose, className: cn("rounded-md px-3 py-1.5 text-sm font-medium", "bg-primary text-primary-foreground hover:bg-primary-hover", "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"), children: "Done" }) })] }));
89
+ }
90
+ // ---------------------------------------------------------------------------
91
+ // Form — owns the share draft for the session
92
+ // ---------------------------------------------------------------------------
93
+ /**
94
+ * The dialog's editable projection of a share. `null` (never shared)
95
+ * seeds the same defaults the server would apply on first create, so
96
+ * the form needs no "no share yet" special case beyond the disabled
97
+ * copy fields that `enabled: false` already produces.
98
+ */
99
+ function draftFromShare(share) {
100
+ const spec = share?.spec;
101
+ return {
102
+ enabled: spec?.enabled ?? false,
103
+ audience: sharingAudienceFromProto(spec?.audience),
104
+ allowedOrigins: spec?.allowedOrigins ?? [],
105
+ messages: {
106
+ rateLimited: spec?.messages?.rateLimited ?? "",
107
+ unavailable: spec?.messages?.unavailable ?? "",
108
+ conversationEnded: spec?.messages?.conversationEnded ?? "",
109
+ },
110
+ environmentRefs: (spec?.environmentRefs ?? []).map((ref) => ({
111
+ org: ref.org,
112
+ slug: ref.slug,
113
+ })),
114
+ };
115
+ }
116
+ function ShareAgentForm({ agent, initialShare, buildShareUrl, onSharingChanged, }) {
117
+ const agentName = agent.metadata?.name || (agent.metadata?.slug ?? "");
118
+ // The latest server share is the single baseline: the draft, the link
119
+ // token, and the share id for rotation all derive from it. `null`
120
+ // until the first save creates the share.
121
+ const [share, setShare] = useState(initialShare);
122
+ const [draft, setDraft] = useState(() => draftFromShare(initialShare));
123
+ const [activeTab, setActiveTab] = useState("link");
124
+ const { save, isPending } = useSaveAgentShare(agent);
125
+ const { rotateShareLink, isPending: isRotating } = useRotateShareLink(share?.metadata?.id ?? null);
126
+ // The share's own org/slug form the hosted URL. Before the first save
127
+ // the agent's stand in — exactly the identity the server will assign
128
+ // on create (D2: share slug defaults to the agent's).
129
+ const org = share?.metadata?.org || (agent.metadata?.org ?? "");
130
+ const slug = share?.metadata?.slug || (agent.metadata?.slug ?? "");
131
+ const linkToken = share?.status?.shareLinkToken ?? "";
132
+ // Single commit path: apply the complete draft, adopt the server's
133
+ // returned share as the new baseline, notify the host.
134
+ const commit = useCallback(async (next, successMessage) => {
135
+ try {
136
+ const persisted = await save(next, share);
137
+ if (persisted) {
138
+ setShare(persisted);
139
+ setDraft(draftFromShare(persisted));
140
+ }
141
+ else {
142
+ setDraft(next);
143
+ }
144
+ toast.success(successMessage);
145
+ onSharingChanged?.();
146
+ return true;
147
+ }
148
+ catch (err) {
149
+ toast.error(getUserMessage(err));
150
+ return false;
151
+ }
152
+ }, [save, share, onSharingChanged]);
153
+ const handleRotateLink = useCallback(async () => {
154
+ try {
155
+ const updated = await rotateShareLink();
156
+ if (updated) {
157
+ setShare(updated);
158
+ }
159
+ toast.success("Link reset — the old link no longer works");
160
+ onSharingChanged?.();
161
+ }
162
+ catch (err) {
163
+ toast.error(getUserMessage(err));
164
+ }
165
+ }, [rotateShareLink, onSharingChanged]);
166
+ const handleToggle = useCallback((enabled) => {
167
+ void commit({ ...draft, enabled }, enabled ? "Sharing enabled" : "Sharing disabled");
168
+ }, [commit, draft]);
169
+ const handleAudienceChange = useCallback((audience) => {
170
+ if (audience === draft.audience)
171
+ return;
172
+ // Credential bindings are public-audience only (the proto CEL rule
173
+ // rejects them on org shares — decision 011 addendum), so switching
174
+ // to org drops them, and the toast says so: silent config loss is
175
+ // worse than a wordier confirmation.
176
+ const dropsBindings = audience === "org" && draft.environmentRefs.length > 0;
177
+ void commit({
178
+ ...draft,
179
+ audience,
180
+ environmentRefs: dropsBindings ? [] : draft.environmentRefs,
181
+ }, audience === "org"
182
+ ? dropsBindings
183
+ ? "Only organization members can chat now — tool credential bindings were removed (they apply to public links only)"
184
+ : "Only organization members can chat now"
185
+ : "Anyone with the link can chat now");
186
+ }, [commit, draft]);
187
+ const isOrgAudience = draft.audience === "org";
188
+ // Hosts build the base URL; the token rides it only on public shares
189
+ // (org-audience access is gated by membership, not the link token).
190
+ const baseShareUrl = buildShareUrl
191
+ ? buildShareUrl(org, slug)
192
+ : chatPath(org, slug);
193
+ const shareUrl = isOrgAudience
194
+ ? baseShareUrl
195
+ : appendLinkToken(baseShareUrl, linkToken);
196
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "border-b border-border px-6 py-4", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("span", { id: "share-enabled-label", className: "text-sm font-medium text-foreground", children: isOrgAudience
197
+ ? "Organization members can chat"
198
+ : "Anyone with the link can chat" }), _jsx(WhoPaysLine, { org: org, audience: draft.audience })] }), _jsx(Switch, { checked: draft.enabled, onCheckedChange: handleToggle, disabled: isPending, "aria-labelledby": "share-enabled-label" })] }), _jsx(AudienceSelector, { audience: draft.audience, onChange: handleAudienceChange, disabled: isPending }), _jsx(ToolReadinessHint, { agent: agent, draft: draft })] }), _jsx("div", { className: "px-6 pb-2 pt-3", children: _jsx(Tabs, { tabs: SHARE_TABS, activeTab: activeTab, onTabChange: setActiveTab, "aria-label": "Sharing options", children: _jsxs("div", { className: "pt-4", children: [activeTab === "link" && (_jsx(LinkTab, { shareUrl: shareUrl, org: org, agent: agent, enabled: draft.enabled, draft: draft, isPending: isPending, commit: commit, hasLinkToken: linkToken !== "", isRotating: isRotating, onResetLink: handleRotateLink })), activeTab === "embed" && (_jsx(EmbedTab, { shareUrl: shareUrl, org: org, slug: slug, agentName: agentName, linkToken: linkToken, enabled: draft.enabled, draft: draft, isPending: isPending, commit: commit })), activeTab === "developer" && _jsx(DeveloperTab, { org: org, slug: slug })] }) }) })] }));
199
+ }
200
+ // ---------------------------------------------------------------------------
201
+ // Tool readiness — visitors' tool use needs credentials bound to the share
202
+ // ---------------------------------------------------------------------------
203
+ /**
204
+ * Pre-flight hint for tool-using agents: visitors' chats receive
205
+ * credentials only from the share's own environment bindings, so a
206
+ * tool-using agent with no bindings (`needs-credentials`) or a binding
207
+ * that is still private (`blocked`) will fail at the visitor's first
208
+ * message. Renders nothing when there is nothing to fix — sharing stays
209
+ * one toggle; this only catches the misconfiguration at share time.
210
+ */
211
+ function ToolReadinessHint({ agent, draft, }) {
212
+ const readiness = useShareToolReadiness(agent, draft);
213
+ if (readiness.status === "needs-credentials") {
214
+ return (_jsxs("p", { className: "mt-2 text-xs text-warning", role: "status", children: ["Visitors' chats can't use this agent's tools yet: no credentials are bound to this share. Bind an org-shared environment under ", _jsx("span", { className: "font-medium", children: "Tool credentials" }), " in the Link tab below."] }));
215
+ }
216
+ if (readiness.status !== "blocked") {
217
+ return null;
218
+ }
219
+ const envList = readiness.privateEnvironments.join(", ");
220
+ const plural = readiness.privateEnvironments.length > 1;
221
+ return (_jsxs("p", { className: "mt-2 text-xs text-warning", role: "status", children: ["Visitors' chats can't use this agent's tools yet: the environment", plural ? "s" : "", " ", _jsx("span", { className: "font-medium", children: envList }), " ", plural ? "are" : "is", " private. Share ", plural ? "them" : "it", " with your organization (Settings \u2192 Environments) so visitor runs can use the credentials. Secret values stay hidden either way."] }));
222
+ }
223
+ // ---------------------------------------------------------------------------
224
+ // Audience — who can chat over the hosted link
225
+ // ---------------------------------------------------------------------------
226
+ const AUDIENCE_OPTIONS = [
227
+ { value: "public", label: "Public link" },
228
+ { value: "org", label: "Org members" },
229
+ ];
230
+ /**
231
+ * Segmented control choosing between the two sharing audiences. Mutually
232
+ * exclusive by nature, so a radio group (not toggles); the master switch
233
+ * above stays the single on/off.
234
+ */
235
+ function AudienceSelector({ audience, onChange, disabled, }) {
236
+ return (_jsx("div", { role: "radiogroup", "aria-label": "Who can chat", className: "mt-3 inline-flex rounded-md border border-border p-0.5", children: AUDIENCE_OPTIONS.map(({ value, label }) => {
237
+ const selected = audience === value;
238
+ return (_jsx("button", { type: "button", role: "radio", "aria-checked": selected, onClick: () => onChange(value), disabled: disabled, className: cn("rounded px-2.5 py-1 text-xs font-medium", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50", selected
239
+ ? "bg-primary text-primary-foreground"
240
+ : "text-muted-foreground hover:text-foreground"), children: label }, value));
241
+ }) }));
242
+ }
243
+ // ---------------------------------------------------------------------------
244
+ // Who pays — cost attribution is always the org in the share URL
245
+ // ---------------------------------------------------------------------------
246
+ function WhoPaysLine({ org, audience, }) {
247
+ const mode = useDeploymentMode();
248
+ // An Organization's id equals its slug (see ApiResourceMetadata.id), so
249
+ // the share's org reference is directly usable as the billing org id.
250
+ // Cloud-only: local mode has no billing accounts.
251
+ const { account } = useBillingAccount(mode === "cloud" ? org : null);
252
+ const balance = account?.balance !== undefined
253
+ ? formatCreditBalance(account.balance?.availableMicros)
254
+ : null;
255
+ return (_jsxs("p", { className: "mt-0.5 text-xs text-muted-foreground", children: [audience === "org" ? "Members" : "Visitors", " chat on", " ", _jsx("span", { className: "font-medium", children: org }), "'s credits", balance !== null && _jsxs(_Fragment, { children: [" (", balance, " available)"] }), "."] }));
256
+ }
257
+ // ---------------------------------------------------------------------------
258
+ // Link tab
259
+ // ---------------------------------------------------------------------------
260
+ /**
261
+ * Names the reason the copy fields above are grayed out: sharing is off, so
262
+ * the link/embed would lead to NOT_FOUND (the fields stay disabled — handing
263
+ * out a dead link is worse than a disabled button). Points at the master
264
+ * switch as the remedy.
265
+ */
266
+ function SharingOffHint({ subject }) {
267
+ return (_jsxs("p", { className: "text-xs text-muted-foreground", role: "status", children: ["Sharing is off, so ", subject, " doesn't work yet \u2014 turn on the switch above to activate it."] }));
268
+ }
269
+ function LinkTab({ shareUrl, org, agent, enabled, draft, isPending, commit, hasLinkToken, isRotating, onResetLink, }) {
270
+ const isOrgAudience = draft.audience === "org";
271
+ return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(CopyField, { label: isOrgAudience ? "Member chat link" : "Public chat link", value: shareUrl, copyLabel: "Link", disabled: !enabled, openHref: enabled ? shareUrl : undefined }), !enabled && _jsx(SharingOffHint, { subject: "this link" }), isOrgAudience ? (_jsxs("p", { className: "text-xs text-muted-foreground", children: ["Only signed-in members of ", _jsx("span", { className: "font-medium", children: org }), " ", "can chat. Access is checked on every message, so it ends the moment someone leaves the organization. The link is safe to forward \u2014 it shows nothing to anyone else."] })) : (_jsx("p", { className: "text-xs text-warning", children: "Public links can be forwarded and indexed by search engines. Don't share agents that know internal or confidential information \u2014 or switch the audience to org members." })), !isOrgAudience && (_jsx(ResetLinkControl, { enabled: enabled, hasLinkToken: hasLinkToken, isRotating: isRotating, onResetLink: onResetLink })), !isOrgAudience && (_jsx(ToolCredentialsSection, { org: org, agent: agent, draft: draft, isPending: isPending, commit: commit })), _jsx(MessagesEditor, { draft: draft, isPending: isPending, commit: commit })] }));
272
+ }
273
+ /**
274
+ * The "kill a leaked link" lever: rotating generates a fresh `?k=` token
275
+ * so the old URL stops working immediately — sharing stays on, the agent
276
+ * keeps its name. Public audience only; org shares revoke via membership.
277
+ */
278
+ function ResetLinkControl({ enabled, hasLinkToken, isRotating, onResetLink, }) {
279
+ return (_jsx("section", { className: cn(!enabled && "opacity-50"), children: _jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h3", { className: "text-xs font-medium text-muted-foreground", children: "Reset link" }), _jsx("p", { className: "mt-0.5 text-[0.65rem] text-muted-foreground", children: hasLinkToken
280
+ ? "Generates a new link and kills the current one immediately — even mid-conversation. Re-share the new link with the people who should keep access."
281
+ : "Got forwarded further than you wanted? Resetting locks the link behind a secret and kills the plain address immediately." })] }), _jsx("button", { type: "button", onClick: onResetLink, disabled: !enabled || isRotating, className: cn("shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium", "border border-border text-foreground hover:bg-accent-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50"), children: isRotating ? "Resetting…" : "Reset link" })] }) }));
282
+ }
283
+ // ---------------------------------------------------------------------------
284
+ // Tool credentials — org-shared environments bound to the share for visitors
285
+ // ---------------------------------------------------------------------------
286
+ /**
287
+ * Binds org-shared environments to the share's `environment_refs` — the
288
+ * consent act that makes a tool-using agent work for visitors (decision
289
+ * 011: credentials belong to the channel, never to the agent's pristine
290
+ * default instance). Public audience only; the section disappears for
291
+ * org shares, whose member sessions carry no share linkage in Phase A.
292
+ *
293
+ * Expanded by default when the agent uses MCP tools — for those agents
294
+ * this is essential configuration, not an advanced option.
295
+ */
296
+ function ToolCredentialsSection({ org, agent, draft, isPending, commit, }) {
297
+ const hasMcpTools = (agent.spec?.mcpServerUsages?.length ?? 0) > 0;
298
+ const [expanded, setExpanded] = useState(hasMcpTools || draft.environmentRefs.length > 0);
299
+ const handleChange = useCallback((refs) => {
300
+ const added = refs.length > draft.environmentRefs.length;
301
+ void commit({ ...draft, environmentRefs: refs }, added ? "Credentials bound" : "Credential bindings updated");
302
+ }, [commit, draft]);
303
+ // Only org-shared environments are guest-usable (the runtime merge
304
+ // skips private ones — decision 006), so offering others would bind
305
+ // credentials that silently never apply.
306
+ const onlyOrgShared = useCallback((env) => env.metadata?.visibility === ApiResourceVisibility.visibility_org, []);
307
+ return (_jsxs("section", { children: [_jsxs("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, className: cn("inline-flex items-center gap-1 text-xs font-medium text-muted-foreground", "hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"), children: [_jsx(ChevronIcon, { className: cn("size-3 transition-transform", expanded && "rotate-90") }), "Tool credentials"] }), expanded && (_jsxs("div", { className: "mt-2 flex flex-col gap-2", children: [_jsx("p", { className: "text-[0.65rem] text-muted-foreground", children: "Environments whose values visitors' chats can use \u2014 bind one holding the credentials this agent's tools need (a read-only token is safest). Only environments shared with your organization can be bound; share one first in Settings \u2192 Environments. Secret values stay hidden from visitors either way." }), _jsx(EnvironmentPicker, { org: org, value: draft.environmentRefs, onChange: handleChange, disabled: isPending, filterEnvironment: onlyOrgShared })] }))] }));
308
+ }
309
+ // ---------------------------------------------------------------------------
310
+ // Embed tab
311
+ // ---------------------------------------------------------------------------
312
+ /**
313
+ * The app origin the loader is served from — derived from the share URL
314
+ * the host built. Empty when the host never wired `buildShareUrl` (a
315
+ * relative share URL), which degrades {@link buildEmbedSnippet} to a
316
+ * relative `/embed.js` — same degradation as the relative link itself.
317
+ */
318
+ function appOriginFrom(shareUrl) {
319
+ try {
320
+ return new URL(shareUrl).origin;
321
+ }
322
+ catch {
323
+ return "";
324
+ }
325
+ }
326
+ /** The no-JavaScript alternative: a plain iframe onto the hosted page. */
327
+ function buildIframeSnippet(shareUrl, agentName) {
328
+ return [
329
+ `<iframe`,
330
+ ` src="${shareUrl}"`,
331
+ ` title="${agentName}"`,
332
+ ` width="400"`,
333
+ ` height="600"`,
334
+ ` style="border: 0; border-radius: 12px;"`,
335
+ `></iframe>`,
336
+ ].join("\n");
337
+ }
338
+ function EmbedTab({ shareUrl, org, slug, agentName, linkToken, enabled, draft, isPending, commit, }) {
339
+ const scriptSnippet = useMemo(() => buildEmbedSnippet(appOriginFrom(shareUrl), org, slug, linkToken || undefined), [shareUrl, org, slug, linkToken]);
340
+ // Embedding serves anonymous visitors via guest tokens, which an
341
+ // org-audience share refuses by design — a sign-in flow inside a
342
+ // third-party iframe is its own project. Say so instead of showing
343
+ // snippets that would render nothing.
344
+ if (draft.audience === "org") {
345
+ return (_jsxs("p", { className: "text-xs text-muted-foreground", role: "status", children: ["Embedding isn't available for org-members-only sharing: embeds serve anonymous visitors, and this agent requires a signed-in organization member. Switch the audience to", " ", _jsx("span", { className: "font-medium", children: "Public link" }), " to embed it on a site."] }));
346
+ }
347
+ return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(CopyField, { label: "Embed on your site", value: scriptSnippet, copyLabel: "Embed code", disabled: !enabled, multiline: true }), !enabled && _jsx(SharingOffHint, { subject: "this embed" }), _jsx("p", { className: "text-xs text-muted-foreground", children: "The widget hides itself on sites that aren't allowed to embed this agent. Free embeds show a \"Powered by Stigmer\" badge." }), _jsx(OriginsEditor, { draft: draft, isPending: isPending, commit: commit }), _jsx(IframeAlternative, { shareUrl: shareUrl, agentName: agentName, enabled: enabled })] }));
348
+ }
349
+ /**
350
+ * Collapsible fallback for hosts that cannot run scripts (locked-down CMSes,
351
+ * strict sanitizers). Same widget, same origin enforcement — minus the
352
+ * hide-on-refusal behavior the loader provides.
353
+ */
354
+ function IframeAlternative({ shareUrl, agentName, enabled, }) {
355
+ const [expanded, setExpanded] = useState(false);
356
+ const snippet = useMemo(() => buildIframeSnippet(shareUrl, agentName), [shareUrl, agentName]);
357
+ return (_jsxs("section", { children: [_jsxs("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, className: cn("inline-flex items-center gap-1 text-xs font-medium text-muted-foreground", "hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"), children: [_jsx(ChevronIcon, { className: cn("size-3 transition-transform", expanded && "rotate-90") }), "No-JavaScript alternative"] }), expanded && (_jsxs("div", { className: "mt-2 flex flex-col gap-2", children: [_jsx("p", { className: "text-[0.65rem] text-muted-foreground", children: "For sites that can't run scripts. A blocked embed shows an empty frame instead of hiding." }), _jsx(CopyField, { label: "Iframe embed", value: snippet, copyLabel: "Iframe code", disabled: !enabled, multiline: true })] }))] }));
358
+ }
359
+ // ---------------------------------------------------------------------------
360
+ // Allowed origins editor
361
+ // ---------------------------------------------------------------------------
362
+ function OriginsEditor({ draft, isPending, commit, }) {
363
+ const [newOrigin, setNewOrigin] = useState("");
364
+ const [inputError, setInputError] = useState(null);
365
+ const handleAdd = useCallback(async () => {
366
+ const value = newOrigin.trim();
367
+ const validationError = validateOrigin(value);
368
+ if (validationError) {
369
+ setInputError(validationError);
370
+ return;
371
+ }
372
+ if (draft.allowedOrigins.includes(value)) {
373
+ setInputError("That origin is already in the list");
374
+ return;
375
+ }
376
+ if (draft.allowedOrigins.length >= MAX_ALLOWED_ORIGINS) {
377
+ setInputError(`At most ${MAX_ALLOWED_ORIGINS} origins are allowed`);
378
+ return;
379
+ }
380
+ setInputError(null);
381
+ const ok = await commit({ ...draft, allowedOrigins: [...draft.allowedOrigins, value] }, "Origin added");
382
+ if (ok)
383
+ setNewOrigin("");
384
+ }, [newOrigin, draft, commit]);
385
+ const handleRemove = useCallback((origin) => {
386
+ void commit({
387
+ ...draft,
388
+ allowedOrigins: draft.allowedOrigins.filter((o) => o !== origin),
389
+ }, "Origin removed");
390
+ }, [draft, commit]);
391
+ return (_jsxs("section", { children: [_jsx("h3", { className: "text-xs font-medium text-muted-foreground", children: "Allowed embed origins" }), _jsx("p", { className: "mt-0.5 text-[0.65rem] text-muted-foreground", children: "Sites allowed to embed this agent. An empty list allows any site; adding origins restricts embedding to those sites. The hosted link works either way." }), draft.allowedOrigins.length > 0 && (_jsx("ul", { className: "mt-2 flex flex-col divide-y divide-border rounded-md border border-border", children: draft.allowedOrigins.map((origin) => (_jsxs("li", { className: "flex items-center justify-between gap-2 px-2.5 py-1.5", children: [_jsx("code", { className: "truncate font-mono text-xs text-foreground", children: origin }), _jsx("button", { type: "button", onClick: () => handleRemove(origin), disabled: isPending, "aria-label": `Remove ${origin}`, className: cn("inline-flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground", "hover:bg-destructive-subtle hover:text-destructive", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50"), children: _jsx(RemoveIcon, {}) })] }, origin))) })), _jsxs("div", { className: "mt-2 flex items-start gap-1.5", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("input", { type: "text", value: newOrigin, onChange: (e) => {
392
+ setNewOrigin(e.target.value);
393
+ if (inputError)
394
+ setInputError(null);
395
+ }, onKeyDown: (e) => {
396
+ if (e.key === "Enter") {
397
+ e.preventDefault();
398
+ void handleAdd();
399
+ }
400
+ }, placeholder: "https://example.com", "aria-label": "Add allowed origin", "aria-invalid": inputError != null, className: cn("w-full rounded-md border border-border bg-input-bg px-2 py-1.5 font-mono text-xs text-foreground", "focus:outline-none focus:ring-2 focus:ring-ring") }), inputError && (_jsx("p", { role: "alert", className: "mt-1 text-xs text-destructive", children: inputError }))] }), _jsx("button", { type: "button", onClick: () => void handleAdd(), disabled: isPending || !newOrigin.trim(), className: cn("shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium", "border border-border text-foreground hover:bg-accent-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50"), children: "Add" })] })] }));
401
+ }
402
+ // ---------------------------------------------------------------------------
403
+ // Visitor messages editor (collapsible)
404
+ // ---------------------------------------------------------------------------
405
+ const MESSAGE_FIELDS = [
406
+ {
407
+ key: "rateLimited",
408
+ label: "Rate limited",
409
+ placeholder: "Shown when a visitor sends messages too quickly",
410
+ },
411
+ {
412
+ key: "unavailable",
413
+ label: "Unavailable",
414
+ placeholder: "Shown when the agent is temporarily unavailable",
415
+ },
416
+ {
417
+ key: "conversationEnded",
418
+ label: "Conversation ended",
419
+ placeholder: "Shown when a conversation reaches its limit",
420
+ },
421
+ ];
422
+ function MessagesEditor({ draft, isPending, commit, }) {
423
+ const [expanded, setExpanded] = useState(false);
424
+ const [localMessages, setLocalMessages] = useState(draft.messages);
425
+ const isDirty = localMessages.rateLimited !== draft.messages.rateLimited ||
426
+ localMessages.unavailable !== draft.messages.unavailable ||
427
+ localMessages.conversationEnded !== draft.messages.conversationEnded;
428
+ const handleSave = useCallback(() => {
429
+ void commit({ ...draft, messages: localMessages }, "Messages saved");
430
+ }, [commit, draft, localMessages]);
431
+ return (_jsxs("section", { children: [_jsxs("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, className: cn("inline-flex items-center gap-1 text-xs font-medium text-muted-foreground", "hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"), children: [_jsx(ChevronIcon, { className: cn("size-3 transition-transform", expanded && "rotate-90") }), "Customize visitor messages"] }), expanded && (_jsxs("div", { className: "mt-2 flex flex-col gap-3", children: [_jsx("p", { className: "text-[0.65rem] text-muted-foreground", children: "Shown to visitors when a limit is reached. Leave empty to use the platform defaults." }), MESSAGE_FIELDS.map(({ key, label, placeholder }) => (_jsx(MessageField, { label: label, placeholder: placeholder, value: localMessages[key], onChange: (value) => setLocalMessages((prev) => ({ ...prev, [key]: value })) }, key))), isDirty && (_jsxs("div", { className: "flex items-center justify-end gap-1.5", children: [_jsx("button", { type: "button", onClick: () => setLocalMessages(draft.messages), disabled: isPending, className: cn("rounded-md px-2.5 py-1 text-xs font-medium", "border border-border text-foreground hover:bg-accent-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"), children: "Reset" }), _jsx("button", { type: "button", onClick: handleSave, disabled: isPending, className: cn("rounded-md px-2.5 py-1 text-xs font-medium", "bg-primary text-primary-foreground hover:bg-primary-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50"), children: "Save messages" })] }))] }))] }));
432
+ }
433
+ function MessageField({ label, placeholder, value, onChange, }) {
434
+ return (_jsxs("label", { className: "flex flex-col gap-1", children: [_jsxs("span", { className: "flex items-center justify-between text-xs font-medium text-muted-foreground", children: [label, _jsxs("span", { className: "tabular-nums text-[0.65rem]", children: [value.length, "/", MAX_MESSAGE_LENGTH] })] }), _jsx("textarea", { value: value, onChange: (e) => onChange(e.target.value.slice(0, MAX_MESSAGE_LENGTH)), placeholder: placeholder, rows: 2, maxLength: MAX_MESSAGE_LENGTH, className: cn("w-full resize-y rounded-md border border-border bg-input-bg px-2 py-1.5 text-xs text-foreground", "focus:outline-none focus:ring-2 focus:ring-ring") })] }));
435
+ }
436
+ // ---------------------------------------------------------------------------
437
+ // Developer tab — the graduation ladder to the full SDK
438
+ // ---------------------------------------------------------------------------
439
+ function buildDeveloperSnippet(org, slug) {
440
+ return [
441
+ `import { createPlatformClientAuth } from "@stigmer/sdk/node";`,
442
+ ``,
443
+ `const auth = createPlatformClientAuth({`,
444
+ ` baseUrl: "https://api.stigmer.ai",`,
445
+ ` clientId: process.env.STIGMER_CLIENT_ID,`,
446
+ ` clientSecret: process.env.STIGMER_CLIENT_SECRET,`,
447
+ `});`,
448
+ ``,
449
+ `// Mint tokens for your own users, then chat with ${org}/${slug}`,
450
+ `const { accessToken } = await auth.mintUserToken({`,
451
+ ` userId: "user-123",`,
452
+ `});`,
453
+ ].join("\n");
454
+ }
455
+ function DeveloperTab({ org, slug, }) {
456
+ const snippet = useMemo(() => buildDeveloperSnippet(org, slug), [org, slug]);
457
+ return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("p", { className: "text-xs text-muted-foreground", children: "Need your own auth, branding, or UI? Create a platform client and integrate this agent with the Stigmer SDK \u2014 the same runtime, full control." }), _jsx(CopyField, { label: "Platform client integration", value: snippet, copyLabel: "Code", multiline: true }), _jsx("a", { href: PLATFORM_CLIENT_DOCS_URL, target: "_blank", rel: "noreferrer", className: cn("text-xs font-medium text-primary hover:text-primary-muted", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded"), children: "Read the platform client guide \u2192" })] }));
458
+ }
459
+ // ---------------------------------------------------------------------------
460
+ // Copy field — labeled value with copy (and optional open) affordances
461
+ // ---------------------------------------------------------------------------
462
+ function CopyField({ label, value, copyLabel, disabled, multiline, openHref, }) {
463
+ const { copy } = useCopyResource();
464
+ return (_jsxs("section", { className: cn(disabled && "opacity-50"), children: [_jsx("h3", { className: "text-xs font-medium text-muted-foreground", children: label }), _jsxs("div", { className: "mt-1.5 flex items-start gap-1.5", children: [multiline ? (_jsx("pre", { className: cn("min-w-0 flex-1 overflow-x-auto rounded-md border border-border bg-muted-subtle px-2.5 py-2", "font-mono text-xs leading-relaxed text-foreground"), children: value })) : (_jsx("code", { className: cn("min-w-0 flex-1 truncate rounded-md border border-border bg-muted-subtle px-2.5 py-1.5", "font-mono text-xs text-foreground"), title: value, children: value })), _jsxs("div", { className: "flex shrink-0 flex-col gap-1.5", children: [_jsx("button", { type: "button", onClick: () => void copy(value, copyLabel), disabled: disabled, className: cn("rounded-md px-2.5 py-1.5 text-xs font-medium", "border border-border text-foreground hover:bg-accent-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50"), children: "Copy" }), openHref && (_jsx("a", { href: openHref, target: "_blank", rel: "noreferrer", className: cn("rounded-md px-2.5 py-1.5 text-center text-xs font-medium", "border border-border text-foreground hover:bg-accent-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"), children: "Open" }))] })] })] }));
465
+ }
466
+ // ---------------------------------------------------------------------------
467
+ // Icons — inline SVGs following the SDK pattern (no icon library dependency)
468
+ // ---------------------------------------------------------------------------
469
+ function CloseIcon() {
470
+ return (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }));
471
+ }
472
+ function RemoveIcon() {
473
+ return (_jsx("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m4 4 8 8M12 4l-8 8" }) }));
474
+ }
475
+ function ChevronIcon({ className }) {
476
+ return (_jsx("svg", { className: className, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 3 5 5-5 5" }) }));
477
+ }
478
+ //# sourceMappingURL=ShareAgentDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShareAgentDialog.js","sourceRoot":"","sources":["../../src/sharing/ShareAgentDialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,cAAc,GAEf,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAgB,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAGlB,MAAM,wBAAwB,CAAC;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D,EAC1D,4DAA4D,EAC5D,yEAAyE,CAC1E,qBAGC,CACL,IACG,IACF,IACE,CACX,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAE9E,SAAS,SAAS;IAChB,OAAO,CACL,cAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,YAC5E,eAAM,CAAC,EAAC,oBAAoB,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,KAAK,EAAC,aAAa,EAAC,OAAO,GAAG,GACzF,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,CACL,cAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,iBAAa,MAAM,YACxI,eAAM,CAAC,EAAC,oBAAoB,GAAG,GAC3B,CACP,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,SAAS,EAAmC;IACjE,OAAO,CACL,cACE,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,iBACV,MAAM,YAElB,eAAM,CAAC,EAAC,cAAc,GAAG,GACrB,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,84 @@
1
+ import type { SharingAudience } from "./useSaveAgentShare.js";
2
+ /** Props for {@link SharedAgentChat}. */
3
+ export interface SharedAgentChatProps {
4
+ /** Organization slug from the share URL. */
5
+ readonly org: string;
6
+ /** Agent slug from the share URL. */
7
+ readonly slug: string;
8
+ /**
9
+ * Heading above the composer before the first message.
10
+ * Defaults to a prompt built from the agent's name.
11
+ */
12
+ readonly heading?: string;
13
+ /** Placeholder for the composer textarea. */
14
+ readonly placeholder?: string;
15
+ /**
16
+ * Render the "Powered by Stigmer" footer.
17
+ *
18
+ * @default true
19
+ */
20
+ readonly showPoweredBy?: boolean;
21
+ /**
22
+ * Called after the visitor's session and first execution are
23
+ * created — e.g. to reflect the session in the host page's URL.
24
+ */
25
+ readonly onSessionCreated?: (sessionId: string) => void;
26
+ /**
27
+ * Which sharing audience this surface serves. Selects the profile
28
+ * resolution path: `"public"` uses the anonymous `getSharedProfile`
29
+ * RPC (pair with `createGuestAuth`); `"org"` uses the authenticated
30
+ * `getSharedProfileForMember` RPC and requires a `StigmerProvider`
31
+ * whose client carries a signed-in org member's token. The chat
32
+ * presentation is identical either way.
33
+ *
34
+ * @default "public"
35
+ */
36
+ readonly sharingAudience?: SharingAudience;
37
+ /**
38
+ * Share-link token from the URL's `?k=` parameter (public audience
39
+ * only). Required when the share link has been locked with a
40
+ * rotatable token; harmless on plain links. Pair it with the same
41
+ * `linkToken` on `createGuestAuth` so profile resolution and token
42
+ * minting present the same credentialing.
43
+ */
44
+ readonly linkToken?: string;
45
+ /** Additional CSS class names for the root container. */
46
+ readonly className?: string;
47
+ }
48
+ /**
49
+ * The complete shared-agent chat experience for anonymous visitors —
50
+ * the organism behind a shared agent's hosted page and embeds.
51
+ *
52
+ * Resolves the agent's public profile (name, description, icon, and
53
+ * the pinned deployment) via {@link useSharedAgentProfile}, then
54
+ * renders the session organisms with `audience="guest"`: a pure chat
55
+ * surface with no configuration pickers, pinned to the shared agent's
56
+ * default instance so the session binds synchronously on mount.
57
+ *
58
+ * Handles all states: loading, unavailable (the agent does not exist
59
+ * or is not shared — indistinguishable by design), transient errors
60
+ * (with retry), and the live chat.
61
+ *
62
+ * **Auth contract:** requires a `StigmerProvider` whose client can
63
+ * chat with this agent. For public shares (the default), pair with
64
+ * `createGuestAuth({ baseUrl, org, slug })` from `@stigmer/sdk` —
65
+ * the profile fetch is public and sessions use the guest token the
66
+ * provider mints on demand. For org-members-only shares, pass
67
+ * `sharingAudience="org"` and a client carrying the signed-in
68
+ * member's own token; the presentation stays the same pure chat.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * const guestAuth = createGuestAuth({ baseUrl, org, slug });
73
+ * const client = useMemo(
74
+ * () => new Stigmer({ baseUrl, getAccessToken: guestAuth.getAccessToken }),
75
+ * [guestAuth],
76
+ * );
77
+ *
78
+ * <StigmerProvider client={client} colorMode="system">
79
+ * <SharedAgentChat org={org} slug={slug} />
80
+ * </StigmerProvider>
81
+ * ```
82
+ */
83
+ export declare function SharedAgentChat({ org, slug, heading, placeholder, showPoweredBy, onSessionCreated, sharingAudience, linkToken, className, }: SharedAgentChatProps): import("react/jsx-runtime").JSX.Element;
84
+ //# sourceMappingURL=SharedAgentChat.d.ts.map