@anvia/react-ui 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attachment/index.d.ts +3 -21
- package/dist/attachment/index.js +3 -12
- package/dist/attachment-By2pged3.js +91 -0
- package/dist/attachment-By2pged3.js.map +1 -0
- package/dist/chat/index.d.ts +3 -152
- package/dist/chat/index.js +3 -25
- package/dist/chat-Dgz8hsVT.js +1210 -0
- package/dist/chat-Dgz8hsVT.js.map +1 -0
- package/dist/completion/index.d.ts +3 -29
- package/dist/completion/index.js +3 -16
- package/dist/completion-DDTKoZRJ.js +124 -0
- package/dist/completion-DDTKoZRJ.js.map +1 -0
- package/dist/connection-DeNq8wHS.js +203 -0
- package/dist/connection-DeNq8wHS.js.map +1 -0
- package/dist/contexts-B4ijG24z.js +212 -0
- package/dist/contexts-B4ijG24z.js.map +1 -0
- package/dist/elements-D4vmkkF8.js +19 -0
- package/dist/elements-D4vmkkF8.js.map +1 -0
- package/dist/graph-explorer/index.d.ts +54 -73
- package/dist/graph-explorer/index.d.ts.map +1 -0
- package/dist/graph-explorer/index.js +181 -248
- package/dist/graph-explorer/index.js.map +1 -1
- package/dist/human-input/index.d.ts +3 -78
- package/dist/human-input/index.js +3 -21
- package/dist/human-input-CsCbZomZ.js +314 -0
- package/dist/human-input-CsCbZomZ.js.map +1 -0
- package/dist/image/index.d.ts +3 -40
- package/dist/image/index.js +3 -12
- package/dist/image-aCWm6hFe.js +303 -0
- package/dist/image-aCWm6hFe.js.map +1 -0
- package/dist/index-B1Qs2Cjv.d.ts +145 -0
- package/dist/index-B1Qs2Cjv.d.ts.map +1 -0
- package/dist/index-BCBVcl0D.d.ts +277 -0
- package/dist/index-BCBVcl0D.d.ts.map +1 -0
- package/dist/index-CE22tsua.d.ts +20 -0
- package/dist/index-CE22tsua.d.ts.map +1 -0
- package/dist/index-CGqtpc6b.d.ts +25 -0
- package/dist/index-CGqtpc6b.d.ts.map +1 -0
- package/dist/index-DqdyM0Jm.d.ts +7 -0
- package/dist/index-DqdyM0Jm.d.ts.map +1 -0
- package/dist/index-Mw3ltwSG.d.ts +318 -0
- package/dist/index-Mw3ltwSG.d.ts.map +1 -0
- package/dist/index.d.ts +7 -40
- package/dist/index.js +34 -118
- package/dist/index.js.map +1 -1
- package/dist/message/index.d.ts +3 -105
- package/dist/message/index.js +3 -20
- package/dist/message-CElFEKgL.js +783 -0
- package/dist/message-CElFEKgL.js.map +1 -0
- package/dist/primitives-xfE7zfwJ.js +15 -0
- package/dist/primitives-xfE7zfwJ.js.map +1 -0
- package/dist/refs-Djj9rSvB.js +10 -0
- package/dist/refs-Djj9rSvB.js.map +1 -0
- package/dist/sandbox-desktop/index.d.ts +100 -104
- package/dist/sandbox-desktop/index.d.ts.map +1 -0
- package/dist/sandbox-desktop/index.js +344 -342
- package/dist/sandbox-desktop/index.js.map +1 -1
- package/dist/sandbox-terminal/index.d.ts +52 -56
- package/dist/sandbox-terminal/index.d.ts.map +1 -0
- package/dist/sandbox-terminal/index.js +217 -208
- package/dist/sandbox-terminal/index.js.map +1 -1
- package/dist/selection-toolbar/index.d.ts +3 -21
- package/dist/selection-toolbar/index.js +3 -13
- package/dist/selection-toolbar-CIkOoM-7.js +171 -0
- package/dist/selection-toolbar-CIkOoM-7.js.map +1 -0
- package/dist/shared-BSYElFU2.d.ts +2 -0
- package/dist/shared.d.ts +4 -14
- package/dist/shared.js +1 -43
- package/dist/stream/index.d.ts +2 -22
- package/dist/stream/index.js +1 -8
- package/dist/stream-CAO0x8_1.js +298 -0
- package/dist/stream-CAO0x8_1.js.map +1 -0
- package/dist/thread-list/index.d.ts +3 -47
- package/dist/thread-list/index.js +3 -18
- package/dist/thread-list-xJbGXFrE.js +228 -0
- package/dist/thread-list-xJbGXFrE.js.map +1 -0
- package/dist/ticket-CoJHBpdF.d.ts +32 -0
- package/dist/ticket-CoJHBpdF.d.ts.map +1 -0
- package/dist/url-CiYZkDks.js +52 -0
- package/dist/url-CiYZkDks.js.map +1 -0
- package/dist/value-BGGrx72L.js +13 -0
- package/dist/value-BGGrx72L.js.map +1 -0
- package/package.json +22 -22
- package/dist/attachment/index.js.map +0 -1
- package/dist/attachment-mbjsroli.d.ts +0 -9
- package/dist/chat/index.js.map +0 -1
- package/dist/chat-PSj1Fo4W.d.ts +0 -88
- package/dist/chunk-22EZJUPM.js +0 -120
- package/dist/chunk-22EZJUPM.js.map +0 -1
- package/dist/chunk-5FZKTDZR.js +0 -201
- package/dist/chunk-5FZKTDZR.js.map +0 -1
- package/dist/chunk-6XOJFLX4.js +0 -22
- package/dist/chunk-6XOJFLX4.js.map +0 -1
- package/dist/chunk-CKA4CE26.js +0 -25
- package/dist/chunk-CKA4CE26.js.map +0 -1
- package/dist/chunk-DLBNFBXQ.js +0 -425
- package/dist/chunk-DLBNFBXQ.js.map +0 -1
- package/dist/chunk-E73S3SOF.js +0 -404
- package/dist/chunk-E73S3SOF.js.map +0 -1
- package/dist/chunk-F6AKBUO3.js +0 -380
- package/dist/chunk-F6AKBUO3.js.map +0 -1
- package/dist/chunk-HGOPGZNQ.js +0 -195
- package/dist/chunk-HGOPGZNQ.js.map +0 -1
- package/dist/chunk-KHB5CHAU.js +0 -220
- package/dist/chunk-KHB5CHAU.js.map +0 -1
- package/dist/chunk-LHABOAOP.js +0 -316
- package/dist/chunk-LHABOAOP.js.map +0 -1
- package/dist/chunk-N5XQU36W.js +0 -410
- package/dist/chunk-N5XQU36W.js.map +0 -1
- package/dist/chunk-T3ZFZ3NP.js +0 -30
- package/dist/chunk-T3ZFZ3NP.js.map +0 -1
- package/dist/chunk-T4IYUEPH.js +0 -1612
- package/dist/chunk-T4IYUEPH.js.map +0 -1
- package/dist/chunk-W2AHKMRS.js +0 -1092
- package/dist/chunk-W2AHKMRS.js.map +0 -1
- package/dist/completion/index.js.map +0 -1
- package/dist/completion-input-DHlwrhxB.d.ts +0 -24
- package/dist/composer-6iCSIq6L.d.ts +0 -111
- package/dist/human-input/index.js.map +0 -1
- package/dist/human-input-CkLrZ8IC.d.ts +0 -27
- package/dist/image/index.js.map +0 -1
- package/dist/image-VZv6Ddsn.d.ts +0 -14
- package/dist/message/index.js.map +0 -1
- package/dist/message-CNRnZQwU.d.ts +0 -14
- package/dist/render-CRKWam2v.d.ts +0 -8
- package/dist/selection-toolbar/index.js.map +0 -1
- package/dist/selection-toolbar-Cwjbuv5S.d.ts +0 -14
- package/dist/shared.js.map +0 -1
- package/dist/stream/index.js.map +0 -1
- package/dist/thread-Bz6-1zaJ.d.ts +0 -12
- package/dist/thread-list/index.js.map +0 -1
- package/dist/thread-list-On8db4XL.d.ts +0 -34
- package/dist/ticket-pexI1zIa.d.ts +0 -33
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-DeNq8wHS.js","names":[],"sources":["../src/relay/status.tsx","../src/relay/ticket.ts","../src/relay/connection.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nimport type { RelayStatus } from \"./connection\";\n\nconst statusStyle: CSSProperties = {\n position: \"absolute\",\n top: 8,\n right: 8,\n padding: \"2px 8px\",\n borderRadius: 4,\n fontSize: 12,\n background: \"rgba(0, 0, 0, 0.7)\",\n color: \"#fff\",\n};\n\nexport function DefaultStatus({ status, retry }: { status: RelayStatus; retry: () => void }) {\n if (status.state === \"open\") return null;\n return (\n <div role=\"status\" data-relay-status={status.state} style={statusStyle}>\n {describe(status)}\n {status.state === \"failed\" ? (\n <>\n {\" \"}\n <button type=\"button\" onClick={retry}>\n Retry\n </button>\n </>\n ) : null}\n </div>\n );\n}\n\nfunction describe(status: RelayStatus): string {\n switch (status.state) {\n case \"loading\":\n case \"connecting\":\n return \"Connecting…\";\n case \"reconnecting\":\n return `Reconnecting in ${Math.max(1, Math.round((status.retryInMs ?? 0) / 1_000))}s…`;\n case \"ended\":\n return status.exitCode === undefined\n ? \"Session ended\"\n : `Session ended (exit ${status.exitCode})`;\n case \"failed\":\n return status.message ?? \"Disconnected\";\n case \"open\":\n return \"\";\n }\n}\n","/** What a viewer's `ticket` prop can be: a ticket, or a function returning one per connection. */\nexport type TicketSource = string | (() => string | Promise<string>);\n\n/**\n * Turn the latest `ticket` prop into the per-attempt function a connection wants. The prop is read\n * on every attempt, so a function is called afresh each time: tickets are single use.\n */\nexport function resolveTicket(\n read: () => TicketSource | undefined,\n): (() => string | Promise<string>) | undefined {\n if (read() === undefined) return undefined;\n return () => {\n const ticket = read();\n return typeof ticket === \"function\" ? ticket() : (ticket as string);\n };\n}\n","/** The prefix a ticket travels under in `Sec-WebSocket-Protocol`. */\nexport const ticketSubprotocolPrefix = \"anvia.ticket.\";\n\nexport type RelayState =\n /** The viewer library is still loading. */\n | \"loading\"\n | \"connecting\"\n | \"open\"\n /** The link dropped and another attempt is scheduled. */\n | \"reconnecting\"\n /** The session itself ended; reconnecting would not help. */\n | \"ended\"\n /** Gave up: a fatal error, or reconnect attempts ran out. */\n | \"failed\";\n\nexport interface RelayStatus {\n state: RelayState;\n /** Reconnect attempt number while `reconnecting`. */\n attempt?: number;\n /** Delay before the next attempt while `reconnecting`. */\n retryInMs?: number;\n /** Exit code when the session ended with one. */\n exitCode?: number;\n /** Human-readable cause for `ended` and `failed`. */\n message?: string;\n}\n\nexport interface RelayReconnectOptions {\n initialDelayMs?: number;\n maxDelayMs?: number;\n /** Consecutive failed attempts before giving up. Default 10. */\n maxAttempts?: number;\n}\n\n/** What a relay protocol can tell the connection about the socket it is driving. */\nexport interface RelaySession {\n /**\n * The relay accepted this attachment. Returns whether an earlier attachment had also been\n * accepted, so a viewer knows to start clean after a reconnect.\n */\n ready(): boolean;\n /** The session itself is over, so the socket closing is not a reason to reconnect. */\n ended(info: { message?: string | undefined; exitCode?: number | undefined }): void;\n /** Something retrying cannot fix. It takes effect when the socket closes. */\n fatal(message: string): void;\n}\n\n/** The part of a relay connection that differs between a terminal and a desktop. */\nexport interface RelayProtocol {\n /** The subprotocol the hub's upgrade handler selects. */\n subprotocol: string;\n /** Names the thing in error messages: \"terminal\", \"desktop\". */\n label: string;\n /** The socket opened. */\n open(socket: WebSocket, session: RelaySession): void;\n message(event: MessageEvent, session: RelaySession): void;\n /** The socket closed. A protocol that learns why from the close frame can call `fatal` here. */\n close?(event: CloseEvent, session: RelaySession): void;\n}\n\nexport interface RelayConnectionOptions {\n /** `ws:`, `wss:`, `http:`, `https:`, or a path relative to the page. */\n url: string;\n /** Appended as `?session=` so the server can pick the session. The server stays in charge. */\n sessionName?: string | undefined;\n /** Called for every attempt, because tickets are single use. */\n getTicket?: (() => string | Promise<string>) | undefined;\n onStatus: (status: RelayStatus) => void;\n reconnect?: RelayReconnectOptions | undefined;\n protocol: RelayProtocol;\n}\n\nconst defaultInitialDelayMs = 500;\nconst defaultMaxDelayMs = 15_000;\nconst defaultMaxAttempts = 10;\n/** Characters a ticket may use, since it travels as a WebSocket subprotocol (an HTTP token). */\nconst subprotocolToken = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/**\n * One browser link to a hub relay: opens the socket with a fresh ticket, reconnects with backoff,\n * and reports its state. What the socket carries is the protocol's business, so this knows nothing\n * about terminals or desktops and is shared by both.\n */\nexport class RelayConnection {\n private socketInUse: WebSocket | undefined;\n private timer: ReturnType<typeof setTimeout> | undefined;\n private attempt = 0;\n private everReady = false;\n private disposed = false;\n private finished = false;\n private fatalMessage: string | undefined;\n\n constructor(private readonly options: RelayConnectionOptions) {}\n\n start(): void {\n void this.connect();\n }\n\n /** Try again now, for a link that gave up. */\n retry(): void {\n // Only a link that gave up needs this; otherwise an attempt is already under way.\n if (this.disposed || !this.finished) return;\n clearTimeout(this.timer);\n this.finished = false;\n this.attempt = 0;\n void this.connect();\n }\n\n /** Send a JSON message, if the socket is open. */\n sendJson(value: Record<string, unknown>): void {\n if (this.socketInUse?.readyState === WebSocket.OPEN) {\n this.socketInUse.send(JSON.stringify(value));\n }\n }\n\n /** Send bytes, if the socket is open. */\n sendBinary(data: ArrayBufferLike | ArrayBufferView): void {\n if (this.socketInUse?.readyState === WebSocket.OPEN)\n this.socketInUse.send(data as BufferSource);\n }\n\n dispose(): void {\n this.disposed = true;\n clearTimeout(this.timer);\n const socket = this.socketInUse;\n this.socketInUse = undefined;\n socket?.close(1000);\n }\n\n private async connect(): Promise<void> {\n if (this.disposed) return;\n const { label } = this.options.protocol;\n this.options.onStatus({ state: \"connecting\" });\n // A fatal error belongs to the attempt that hit it. Without this, one that was retried away\n // would fail every later drop.\n this.fatalMessage = undefined;\n\n let ticket: string | undefined;\n try {\n ticket = await this.options.getTicket?.();\n } catch (error) {\n // Fetching a ticket usually fails because the control plane is restarting, which is exactly\n // when reconnecting is wanted, so it backs off like a dropped socket.\n if (this.disposed) return;\n const detail = error instanceof Error ? `: ${error.message}` : \"\";\n this.scheduleReconnect(`Could not get a ${label} ticket${detail}`);\n return;\n }\n if (this.disposed) return;\n\n let socket: WebSocket;\n try {\n socket = new WebSocket(this.resolveUrl(), this.resolveProtocols(ticket));\n } catch (error) {\n // A bad URL or a malformed ticket: trying again cannot fix either.\n this.fail(error instanceof Error ? error.message : `Could not open the ${label}.`);\n return;\n }\n if (this.disposed) {\n socket.close(1000);\n return;\n }\n this.socketInUse = socket;\n socket.binaryType = \"arraybuffer\";\n\n const session: RelaySession = {\n ready: () => {\n const reconnected = this.everReady;\n this.everReady = true;\n this.attempt = 0;\n this.options.onStatus({ state: \"open\" });\n return reconnected;\n },\n ended: (info) => {\n this.finished = true;\n const status: RelayStatus = { state: \"ended\", message: info.message ?? \"ended\" };\n if (info.exitCode !== undefined) status.exitCode = info.exitCode;\n this.options.onStatus(status);\n },\n fatal: (message) => {\n this.fatalMessage = message;\n },\n };\n const { protocol } = this.options;\n socket.addEventListener(\"open\", () => protocol.open(socket, session));\n socket.addEventListener(\"message\", (event: MessageEvent) => protocol.message(event, session));\n socket.addEventListener(\"close\", (event: CloseEvent) => {\n if (this.socketInUse === socket) this.socketInUse = undefined;\n protocol.close?.(event, session);\n if (this.disposed || this.finished) return;\n if (this.fatalMessage !== undefined) this.fail(this.fatalMessage);\n else this.scheduleReconnect();\n });\n }\n\n private scheduleReconnect(reason?: string): void {\n const { initialDelayMs, maxDelayMs, maxAttempts } = {\n initialDelayMs: defaultInitialDelayMs,\n maxDelayMs: defaultMaxDelayMs,\n maxAttempts: defaultMaxAttempts,\n ...this.options.reconnect,\n };\n if (this.attempt >= maxAttempts) {\n this.fail(reason ?? `The connection to the ${this.options.protocol.label} was lost.`);\n return;\n }\n const delay =\n Math.min(maxDelayMs, initialDelayMs * 2 ** this.attempt) * (0.8 + Math.random() * 0.4);\n this.attempt += 1;\n this.options.onStatus({\n state: \"reconnecting\",\n attempt: this.attempt,\n retryInMs: Math.round(delay),\n });\n this.timer = setTimeout(() => void this.connect(), delay);\n }\n\n private fail(message: string): void {\n this.finished = true;\n this.options.onStatus({ state: \"failed\", message });\n }\n\n private resolveUrl(): string {\n const url = new URL(this.options.url, globalThis.location?.href);\n if (url.protocol === \"http:\") url.protocol = \"ws:\";\n else if (url.protocol === \"https:\") url.protocol = \"wss:\";\n if (this.options.sessionName !== undefined) {\n url.searchParams.set(\"session\", this.options.sessionName);\n }\n return url.toString();\n }\n\n /** The subprotocols to offer: the relay's, plus the ticket when there is one. */\n private resolveProtocols(ticket: string | undefined): string[] {\n const { subprotocol, label } = this.options.protocol;\n if (ticket === undefined) return [subprotocol];\n if (!subprotocolToken.test(ticket)) {\n throw new Error(`The ${label} ticket must use only URL-safe characters (A-Z a-z 0-9 - _ .).`);\n }\n return [subprotocol, `${ticketSubprotocolPrefix}${ticket}`];\n }\n}\n"],"mappings":";;AAIA,MAAM,cAA6B;CACjC,UAAU;CACV,KAAK;CACL,OAAO;CACP,SAAS;CACT,cAAc;CACd,UAAU;CACV,YAAY;CACZ,OAAO;AACT;AAEA,SAAgB,cAAc,EAAE,QAAQ,SAAqD;CAC3F,IAAI,OAAO,UAAU,QAAQ,OAAO;CACpC,OACE,qBAAC,OAAD;EAAK,MAAK;EAAS,qBAAmB,OAAO;EAAO,OAAO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IAAI,aAAa,UAAU,IAAI,WAAW;EACnD,IAAI,KAAK,QAAQ,gBAAgB,KAAA,GAC/B,IAAI,aAAa,IAAI,WAAW,KAAK,QAAQ,WAAW;EAE1D,OAAO,IAAI,SAAS;CACtB;;CAGA,iBAAyB,QAAsC;EAC7D,MAAM,EAAE,aAAa,UAAU,KAAK,QAAQ;EAC5C,IAAI,WAAW,KAAA,GAAW,OAAO,CAAC,WAAW;EAC7C,IAAI,CAAC,iBAAiB,KAAK,MAAM,GAC/B,MAAM,IAAI,MAAM,OAAO,MAAM,+DAA+D;EAE9F,OAAO,CAAC,aAAa,GAAG,0BAA0B,QAAQ;CAC5D;AACF"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createContext, createElement, useContext, useMemo, useState } from "react";
|
|
2
|
+
// src/contexts/attachment.tsx
|
|
3
|
+
const AttachmentContext = createContext(void 0);
|
|
4
|
+
function InternalAttachmentProvider({ value, children }) {
|
|
5
|
+
return createElement(AttachmentContext.Provider, { value }, children);
|
|
6
|
+
}
|
|
7
|
+
function useAttachment() {
|
|
8
|
+
const value = useContext(AttachmentContext);
|
|
9
|
+
if (value === void 0) throw new Error("Attachment primitives must be used inside AttachmentPrimitive.Root.");
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
function useOptionalAttachment() {
|
|
13
|
+
return useContext(AttachmentContext);
|
|
14
|
+
}
|
|
15
|
+
// src/contexts/chat.tsx
|
|
16
|
+
const ChatContext = createContext(void 0);
|
|
17
|
+
function ChatProvider({ controller, children }) {
|
|
18
|
+
return createElement(ChatContext.Provider, { value: controller }, children);
|
|
19
|
+
}
|
|
20
|
+
function useChatContext() {
|
|
21
|
+
const value = useContext(ChatContext);
|
|
22
|
+
if (value === void 0) throw new Error("Anvia chat primitives must be used inside ChatProvider.");
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function useHumanInput() {
|
|
26
|
+
const interactions = useChatContext().interactions;
|
|
27
|
+
const approvals = interactions.all.filter((item) => item.request.type === "tool-approval");
|
|
28
|
+
const questions = interactions.all.filter((item) => item.request.type === "tool-question");
|
|
29
|
+
return {
|
|
30
|
+
approvals: {
|
|
31
|
+
all: approvals,
|
|
32
|
+
pending: approvals.filter((item) => item.status === "pending")
|
|
33
|
+
},
|
|
34
|
+
questions: {
|
|
35
|
+
all: questions,
|
|
36
|
+
pending: questions.filter((item) => item.status === "pending")
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// src/contexts/completion.tsx
|
|
41
|
+
const CompletionContext = createContext(void 0);
|
|
42
|
+
function CompletionProvider({ controller, children }) {
|
|
43
|
+
return createElement(CompletionContext.Provider, { value: controller }, children);
|
|
44
|
+
}
|
|
45
|
+
function useCompletionContext() {
|
|
46
|
+
const value = useContext(CompletionContext);
|
|
47
|
+
if (value === void 0) throw new Error("Anvia completion primitives must be used inside CompletionProvider.");
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
// src/contexts/graph-explorer.tsx
|
|
51
|
+
const GraphExplorerContext = createContext(void 0);
|
|
52
|
+
const GraphExplorerNodeContext = createContext(void 0);
|
|
53
|
+
function GraphExplorerProvider({ controller, children }) {
|
|
54
|
+
return createElement(GraphExplorerContext.Provider, { value: controller }, children);
|
|
55
|
+
}
|
|
56
|
+
function InternalGraphExplorerNodeProvider({ value, children }) {
|
|
57
|
+
return createElement(GraphExplorerNodeContext.Provider, { value }, children);
|
|
58
|
+
}
|
|
59
|
+
function useGraphExplorerContext() {
|
|
60
|
+
const value = useContext(GraphExplorerContext);
|
|
61
|
+
if (value === void 0) throw new Error("Graph explorer primitives must be used inside GraphExplorerProvider.");
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function useGraphExplorerNode() {
|
|
65
|
+
const value = useContext(GraphExplorerNodeContext);
|
|
66
|
+
if (value === void 0) throw new Error("Graph explorer node primitives must be used inside GraphExplorerNodePrimitive.Root or GraphExplorerPrimitive.Nodes.");
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function useOptionalGraphExplorerNode() {
|
|
70
|
+
return useContext(GraphExplorerNodeContext);
|
|
71
|
+
}
|
|
72
|
+
// src/contexts/completion-input.tsx
|
|
73
|
+
const CompletionInputContext = createContext(void 0);
|
|
74
|
+
function InternalCompletionInputProvider({ value, children }) {
|
|
75
|
+
return createElement(CompletionInputContext.Provider, { value }, children);
|
|
76
|
+
}
|
|
77
|
+
function useCompletionInput() {
|
|
78
|
+
const value = useContext(CompletionInputContext);
|
|
79
|
+
if (value === void 0) throw new Error("Completion input primitives must be used inside CompletionPrimitive.Form.");
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
// src/contexts/composer.tsx
|
|
83
|
+
const ComposerContext = createContext(void 0);
|
|
84
|
+
function InternalComposerProvider({ value, children }) {
|
|
85
|
+
return createElement(ComposerContext.Provider, { value }, children);
|
|
86
|
+
}
|
|
87
|
+
function useComposer() {
|
|
88
|
+
const value = useContext(ComposerContext);
|
|
89
|
+
if (value === void 0) throw new Error("Composer primitives must be used inside ComposerPrimitive.Root.");
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
// src/contexts/human-input.tsx
|
|
93
|
+
const ApprovalContext = createContext(void 0);
|
|
94
|
+
const QuestionContext = createContext(void 0);
|
|
95
|
+
const QuestionPromptContext = createContext(void 0);
|
|
96
|
+
function InternalApprovalProvider({ approval, children }) {
|
|
97
|
+
const [reason, setReason] = useState("");
|
|
98
|
+
const value = useMemo(() => ({
|
|
99
|
+
approval,
|
|
100
|
+
reason,
|
|
101
|
+
setReason
|
|
102
|
+
}), [approval, reason]);
|
|
103
|
+
return createElement(ApprovalContext.Provider, { value }, children);
|
|
104
|
+
}
|
|
105
|
+
function InternalQuestionProvider({ value, children }) {
|
|
106
|
+
return createElement(QuestionContext.Provider, { value }, children);
|
|
107
|
+
}
|
|
108
|
+
function InternalQuestionPromptProvider({ prompt, children }) {
|
|
109
|
+
return createElement(QuestionPromptContext.Provider, { value: { prompt } }, children);
|
|
110
|
+
}
|
|
111
|
+
function useApproval() {
|
|
112
|
+
const value = useContext(ApprovalContext);
|
|
113
|
+
if (value === void 0) throw new Error("Approval primitives must be used inside HumanInputPrimitive.Approval.");
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
function useQuestion() {
|
|
117
|
+
const value = useContext(QuestionContext);
|
|
118
|
+
if (value === void 0) throw new Error("Question primitives must be used inside HumanInputPrimitive.Question.");
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
function useQuestionPrompt() {
|
|
122
|
+
const value = useContext(QuestionPromptContext);
|
|
123
|
+
if (value === void 0) throw new Error("Question choice primitives must be used inside HumanInputPrimitive.QuestionPrompt.");
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
// src/contexts/image.tsx
|
|
127
|
+
const ImageContext = createContext(void 0);
|
|
128
|
+
function InternalImageProvider({ value, children }) {
|
|
129
|
+
return createElement(ImageContext.Provider, { value }, children);
|
|
130
|
+
}
|
|
131
|
+
function useImage() {
|
|
132
|
+
const value = useContext(ImageContext);
|
|
133
|
+
if (value === void 0) throw new Error("Image primitives must be used inside ImagePrimitive.Root.");
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
// src/contexts/message.tsx
|
|
137
|
+
const MessageContext = createContext(void 0);
|
|
138
|
+
const MessagePartContext = createContext(void 0);
|
|
139
|
+
function InternalMessageProvider({ message, children }) {
|
|
140
|
+
return createElement(MessageContext.Provider, { value: { message } }, children);
|
|
141
|
+
}
|
|
142
|
+
function InternalMessagePartProvider({ part, isLive = false, streamControlled = false, children }) {
|
|
143
|
+
return createElement(MessagePartContext.Provider, { value: {
|
|
144
|
+
isLive,
|
|
145
|
+
part,
|
|
146
|
+
streamControlled
|
|
147
|
+
} }, children);
|
|
148
|
+
}
|
|
149
|
+
function useMessage() {
|
|
150
|
+
const value = useContext(MessageContext);
|
|
151
|
+
if (value === void 0) throw new Error("Message primitives must be used inside MessagePrimitive.Root or ThreadPrimitive.Messages.");
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function useMessagePart() {
|
|
155
|
+
const value = useContext(MessagePartContext);
|
|
156
|
+
if (value === void 0) throw new Error("Message part primitives must be used inside MessagePrimitive.Parts or MessagePrimitive.Part.");
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
function useOptionalMessagePart() {
|
|
160
|
+
return useContext(MessagePartContext);
|
|
161
|
+
}
|
|
162
|
+
// src/contexts/selection-toolbar.tsx
|
|
163
|
+
const SelectionToolbarContext = createContext(void 0);
|
|
164
|
+
function InternalSelectionToolbarProvider({ value, children }) {
|
|
165
|
+
return createElement(SelectionToolbarContext.Provider, { value }, children);
|
|
166
|
+
}
|
|
167
|
+
function useSelectionToolbar() {
|
|
168
|
+
const value = useContext(SelectionToolbarContext);
|
|
169
|
+
if (value === void 0) throw new Error("SelectionToolbar primitives must be used inside SelectionToolbarPrimitive.Root.");
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
// src/contexts/thread.tsx
|
|
173
|
+
const ThreadContext = createContext(void 0);
|
|
174
|
+
function InternalThreadProvider({ value, children }) {
|
|
175
|
+
return createElement(ThreadContext.Provider, { value }, children);
|
|
176
|
+
}
|
|
177
|
+
function useThread() {
|
|
178
|
+
const value = useContext(ThreadContext);
|
|
179
|
+
if (value === void 0) throw new Error("Thread primitives must be used inside ThreadPrimitive.Root.");
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
// src/contexts/thread-list.tsx
|
|
183
|
+
const ThreadListContext = createContext(void 0);
|
|
184
|
+
const ThreadListItemContext = createContext(void 0);
|
|
185
|
+
const ThreadListRootContext = createContext(void 0);
|
|
186
|
+
function ThreadListProvider({ controller, children }) {
|
|
187
|
+
return createElement(ThreadListContext.Provider, { value: controller }, children);
|
|
188
|
+
}
|
|
189
|
+
function InternalThreadListItemProvider({ value, children }) {
|
|
190
|
+
return createElement(ThreadListItemContext.Provider, { value }, children);
|
|
191
|
+
}
|
|
192
|
+
function InternalThreadListRootProvider({ value, children }) {
|
|
193
|
+
return createElement(ThreadListRootContext.Provider, { value }, children);
|
|
194
|
+
}
|
|
195
|
+
function useThreadList() {
|
|
196
|
+
const value = useContext(ThreadListContext);
|
|
197
|
+
if (value === void 0) throw new Error("ThreadList primitives must be used inside ThreadListProvider.");
|
|
198
|
+
return value;
|
|
199
|
+
}
|
|
200
|
+
function useThreadListItem() {
|
|
201
|
+
const value = useContext(ThreadListItemContext);
|
|
202
|
+
if (value === void 0) throw new Error("ThreadListItem primitives must be used inside ThreadListPrimitive.Items.");
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
function useInternalThreadListRoot() {
|
|
206
|
+
const value = useContext(ThreadListRootContext);
|
|
207
|
+
if (value === void 0) throw new Error("Thread-list primitives must be used inside ThreadListPrimitive.Root.");
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
export { useGraphExplorerContext as A, useOptionalAttachment as B, useQuestionPrompt as C, useCompletionInput as D, InternalCompletionInputProvider as E, ChatProvider as F, useChatContext as I, useHumanInput as L, useOptionalGraphExplorerNode as M, CompletionProvider as N, GraphExplorerProvider as O, useCompletionContext as P, InternalAttachmentProvider as R, useQuestion as S, useComposer as T, useImage as _, useThreadList as a, InternalQuestionProvider as b, useThread as c, InternalMessagePartProvider as d, InternalMessageProvider as f, InternalImageProvider as g, useOptionalMessagePart as h, useInternalThreadListRoot as i, useGraphExplorerNode as j, InternalGraphExplorerNodeProvider as k, InternalSelectionToolbarProvider as l, useMessagePart as m, InternalThreadListRootProvider as n, useThreadListItem as o, useMessage as p, ThreadListProvider as r, InternalThreadProvider as s, InternalThreadListItemProvider as t, useSelectionToolbar as u, InternalApprovalProvider as v, InternalComposerProvider as w, useApproval as x, InternalQuestionPromptProvider as y, useAttachment as z };
|
|
211
|
+
|
|
212
|
+
//# sourceMappingURL=contexts-B4ijG24z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts-B4ijG24z.js","names":[],"sources":["../src/contexts/attachment.tsx","../src/contexts/chat.tsx","../src/contexts/completion.tsx","../src/contexts/graph-explorer.tsx","../src/contexts/completion-input.tsx","../src/contexts/composer.tsx","../src/contexts/human-input.tsx","../src/contexts/image.tsx","../src/contexts/message.tsx","../src/contexts/selection-toolbar.tsx","../src/contexts/thread.tsx","../src/contexts/thread-list.tsx"],"sourcesContent":["import type { UIAttachment } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type AttachmentContextValue = {\n attachment: UIAttachment;\n remove?(): void;\n};\n\nconst AttachmentContext = createContext<AttachmentContextValue | undefined>(undefined);\n\nexport function InternalAttachmentProvider({\n value,\n children,\n}: {\n value: AttachmentContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(AttachmentContext.Provider, { value }, children);\n}\n\nexport function useAttachment(): AttachmentContextValue {\n const value = useContext(AttachmentContext);\n if (value === undefined) {\n throw new Error(\"Attachment primitives must be used inside AttachmentPrimitive.Root.\");\n }\n return value;\n}\n\nexport function useOptionalAttachment(): AttachmentContextValue | undefined {\n return useContext(AttachmentContext);\n}\n","import type {\n ClientDataMap,\n ClientMetadata,\n ClientStreamRequest,\n ClientTransport,\n} from \"@anvia/client\";\nimport type {\n AgentToolApprovalRequest,\n AgentToolQuestionRequest,\n} from \"@anvia/core/agent/interactions\";\nimport type { UseChatResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ChatController<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = UseChatResult<ClientTransport<ClientStreamRequest, Data, Metadata>>;\n\nexport type ChatProviderProps<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = {\n controller: ChatController<Metadata, Data>;\n children?: ReactNode;\n};\n\nconst ChatContext = createContext<ChatController | undefined>(undefined);\n\nexport function ChatProvider<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>({ controller, children }: ChatProviderProps<Metadata, Data>): ReactElement {\n return createElement(\n ChatContext.Provider,\n { value: controller as unknown as ChatController },\n children,\n );\n}\n\nexport function useChatContext<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>(): ChatController<Metadata, Data> {\n const value = useContext(ChatContext);\n if (value === undefined) {\n throw new Error(\"Anvia chat primitives must be used inside ChatProvider.\");\n }\n return value as unknown as ChatController<Metadata, Data>;\n}\n\nexport function useHumanInput() {\n const interactions = useChatContext().interactions;\n const approvals = interactions.all.filter(\n (item): item is typeof item & { request: AgentToolApprovalRequest } =>\n item.request.type === \"tool-approval\",\n );\n const questions = interactions.all.filter(\n (item): item is typeof item & { request: AgentToolQuestionRequest } =>\n item.request.type === \"tool-question\",\n );\n return {\n approvals: {\n all: approvals,\n pending: approvals.filter((item) => item.status === \"pending\"),\n },\n questions: {\n all: questions,\n pending: questions.filter((item) => item.status === \"pending\"),\n },\n };\n}\n","import type { ClientDataMap, ClientMetadata } from \"@anvia/client\";\nimport type { UseCompletionResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type CompletionController<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = UseCompletionResult<Metadata, Data>;\n\nexport type CompletionProviderProps<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = {\n controller: CompletionController<Metadata, Data>;\n children?: ReactNode;\n};\n\nconst CompletionContext = createContext<CompletionController | undefined>(undefined);\n\nexport function CompletionProvider<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>({ controller, children }: CompletionProviderProps<Metadata, Data>): ReactElement {\n return createElement(\n CompletionContext.Provider,\n { value: controller as unknown as CompletionController },\n children,\n );\n}\n\nexport function useCompletionContext<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>(): CompletionController<Metadata, Data> {\n const value = useContext(CompletionContext);\n if (value === undefined) {\n throw new Error(\"Anvia completion primitives must be used inside CompletionProvider.\");\n }\n return value as unknown as CompletionController<Metadata, Data>;\n}\n","import type { GraphExploreNode, GraphSchemaLike } from \"@anvia/graph\";\nimport type {\n GraphExplorerController,\n GraphExplorerExpandNodeOptions,\n GraphExplorerStatus,\n} from \"@anvia/react/graph-explorer\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type { GraphExplorerController, GraphExplorerExpandNodeOptions, GraphExplorerStatus };\n\nexport type GraphExplorerProviderProps<Schema extends GraphSchemaLike = GraphSchemaLike> = {\n controller: GraphExplorerController<Schema>;\n children?: ReactNode;\n};\n\nexport type GraphExplorerNodeContextValue = {\n node: GraphExploreNode;\n selected: boolean;\n matched: boolean;\n};\n\nconst GraphExplorerContext = createContext<GraphExplorerController | undefined>(undefined);\nconst GraphExplorerNodeContext = createContext<GraphExplorerNodeContextValue | undefined>(\n undefined,\n);\n\nexport function GraphExplorerProvider<Schema extends GraphSchemaLike = GraphSchemaLike>({\n controller,\n children,\n}: GraphExplorerProviderProps<Schema>): ReactElement {\n return createElement(\n GraphExplorerContext.Provider,\n { value: controller as unknown as GraphExplorerController },\n children,\n );\n}\n\nexport function InternalGraphExplorerNodeProvider({\n value,\n children,\n}: {\n value: GraphExplorerNodeContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(GraphExplorerNodeContext.Provider, { value }, children);\n}\n\nexport function useGraphExplorerContext<\n Schema extends GraphSchemaLike = GraphSchemaLike,\n>(): GraphExplorerController<Schema> {\n const value = useContext(GraphExplorerContext);\n if (value === undefined) {\n throw new Error(\"Graph explorer primitives must be used inside GraphExplorerProvider.\");\n }\n return value as unknown as GraphExplorerController<Schema>;\n}\n\nexport function useGraphExplorerNode(): GraphExplorerNodeContextValue {\n const value = useContext(GraphExplorerNodeContext);\n if (value === undefined) {\n throw new Error(\n \"Graph explorer node primitives must be used inside GraphExplorerNodePrimitive.Root or GraphExplorerPrimitive.Nodes.\",\n );\n }\n return value;\n}\n\nexport function useOptionalGraphExplorerNode(): GraphExplorerNodeContextValue | undefined {\n return useContext(GraphExplorerNodeContext);\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nimport type { CompletionController } from \"./completion\";\n\nexport type CompletionInputContextValue = {\n input: string;\n setInput(input: string): void;\n submit(): Promise<void>;\n stop(): void;\n status: CompletionController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst CompletionInputContext = createContext<CompletionInputContextValue | undefined>(undefined);\n\nexport function InternalCompletionInputProvider({\n value,\n children,\n}: {\n value: CompletionInputContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(CompletionInputContext.Provider, { value }, children);\n}\n\nexport function useCompletionInput(): CompletionInputContextValue {\n const value = useContext(CompletionInputContext);\n if (value === undefined) {\n throw new Error(\"Completion input primitives must be used inside CompletionPrimitive.Form.\");\n }\n return value;\n}\n","import type { ClientMetadata, CreateUIAttachment, UIAttachment } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\nimport type { ChatController } from \"./chat\";\n\nexport type ComposerEntityData =\n | string\n | number\n | boolean\n | null\n | readonly ComposerEntityData[]\n | { [key: string]: ComposerEntityData };\n\nexport type ComposerAttachmentInput = File | CreateUIAttachment;\nexport type ComposerAttachmentsUpdate =\n | UIAttachment[]\n | ((attachments: UIAttachment[]) => UIAttachment[]);\nexport type ComposerEntitiesUpdate =\n | ComposerEntity[]\n | ((entities: ComposerEntity[]) => ComposerEntity[]);\nexport type ComposerQuote = {\n text: string;\n messageId: string;\n};\nexport type ComposerTriggerItem = {\n id: string;\n label: string;\n text?: string | undefined;\n detail?: ReactNode | undefined;\n data?: ComposerEntityData | undefined;\n disabled?: boolean | undefined;\n};\nexport type ComposerTriggerItemsArgs = {\n trigger: ComposerTriggerDefinition;\n query: string;\n input: string;\n entities: ComposerEntity[];\n signal: AbortSignal;\n};\nexport type ComposerTriggerItems =\n | ComposerTriggerItem[]\n | ((args: ComposerTriggerItemsArgs) => ComposerTriggerItem[] | Promise<ComposerTriggerItem[]>);\nexport type ComposerTriggerDefinition = {\n id: string;\n char: string;\n items: ComposerTriggerItems;\n minQueryLength?: number | undefined;\n allowedPrefixes?: string[] | null | undefined;\n startOfLine?: boolean | undefined;\n allowSpaces?: boolean | undefined;\n};\nexport type ComposerEntity = {\n id: string;\n triggerId: string;\n trigger: string;\n label: string;\n text: string;\n range: {\n from: number;\n to: number;\n };\n data?: ComposerEntityData | undefined;\n};\ntype ComposerMessageEntity = ClientMetadata & {\n id: string;\n triggerId: string;\n trigger: string;\n label: string;\n text: string;\n range: ClientMetadata & {\n from: number;\n to: number;\n };\n data?: ComposerEntityData | undefined;\n};\nexport type ComposerMessageMetadata = ClientMetadata & {\n composer: ClientMetadata & {\n entities: readonly ComposerMessageEntity[];\n };\n};\nexport type ComposerTriggerState = {\n trigger: ComposerTriggerDefinition;\n query: string;\n items: ComposerTriggerItem[];\n loading: boolean;\n selectedIndex: number;\n rect?: {\n top: number;\n right: number;\n bottom: number;\n left: number;\n width: number;\n height: number;\n };\n selectItem(item: ComposerTriggerItem): void;\n setSelectedIndex(index: number): void;\n};\nexport type ComposerTriggerStateUpdate =\n | ComposerTriggerState\n | undefined\n | ((state: ComposerTriggerState | undefined) => ComposerTriggerState | undefined);\n\nexport type ComposerContextValue = {\n input: string;\n setInput(input: string): void;\n attachments: UIAttachment[];\n setAttachments(update: ComposerAttachmentsUpdate): void;\n addAttachment(attachment: ComposerAttachmentInput): Promise<void>;\n removeAttachment(id: string): void;\n clearAttachments(): void;\n entities: ComposerEntity[];\n setEntities(update: ComposerEntitiesUpdate): void;\n quote?: ComposerQuote | undefined;\n setQuote(quote: ComposerQuote | undefined): void;\n clearQuote(): void;\n triggers: ComposerTriggerDefinition[];\n activeTrigger?: ComposerTriggerState | undefined;\n setActiveTrigger(update: ComposerTriggerStateUpdate): void;\n submit(): Promise<void>;\n stop(): void;\n status: ChatController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst ComposerContext = createContext<ComposerContextValue | undefined>(undefined);\n\nexport function InternalComposerProvider({\n value,\n children,\n}: {\n value: ComposerContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ComposerContext.Provider, { value }, children);\n}\n\nexport function useComposer(): ComposerContextValue {\n const value = useContext(ComposerContext);\n if (value === undefined) {\n throw new Error(\"Composer primitives must be used inside ComposerPrimitive.Root.\");\n }\n return value;\n}\n","import type { ClientInteraction } from \"@anvia/client\";\nimport type {\n AgentQuestionAnswer,\n AgentQuestionPrompt,\n AgentToolApprovalRequest,\n AgentToolQuestionRequest,\n} from \"@anvia/core/agent/interactions\";\nimport {\n createContext,\n createElement,\n type ReactElement,\n type ReactNode,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type ApprovalContextValue = {\n approval: ApprovalInteraction;\n reason: string;\n setReason(reason: string): void;\n};\n\nexport type QuestionContextValue = {\n question: QuestionInteraction;\n answers: Record<string, AgentQuestionAnswer>;\n setAnswer(prompt: AgentQuestionPrompt, answer: AgentQuestionAnswer): void;\n};\n\nexport type QuestionPromptContextValue = {\n prompt: AgentQuestionPrompt;\n};\n\nexport type ApprovalInteraction = ClientInteraction & { request: AgentToolApprovalRequest };\nexport type QuestionInteraction = ClientInteraction & { request: AgentToolQuestionRequest };\n\nconst ApprovalContext = createContext<ApprovalContextValue | undefined>(undefined);\nconst QuestionContext = createContext<QuestionContextValue | undefined>(undefined);\nconst QuestionPromptContext = createContext<QuestionPromptContextValue | undefined>(undefined);\n\nexport function InternalApprovalProvider({\n approval,\n children,\n}: {\n approval: ApprovalInteraction;\n children?: ReactNode;\n}): ReactElement {\n const [reason, setReason] = useState(\"\");\n const value = useMemo<ApprovalContextValue>(\n () => ({ approval, reason, setReason }),\n [approval, reason],\n );\n\n return createElement(ApprovalContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionProvider({\n value,\n children,\n}: {\n value: QuestionContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionPromptProvider({\n prompt,\n children,\n}: {\n prompt: AgentQuestionPrompt;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionPromptContext.Provider, { value: { prompt } }, children);\n}\n\nexport function useApproval(): ApprovalContextValue {\n const value = useContext(ApprovalContext);\n if (value === undefined) {\n throw new Error(\"Approval primitives must be used inside HumanInputPrimitive.Approval.\");\n }\n return value;\n}\n\nexport function useQuestion(): QuestionContextValue {\n const value = useContext(QuestionContext);\n if (value === undefined) {\n throw new Error(\"Question primitives must be used inside HumanInputPrimitive.Question.\");\n }\n return value;\n}\n\nexport function useQuestionPrompt(): QuestionPromptContextValue {\n const value = useContext(QuestionPromptContext);\n if (value === undefined) {\n throw new Error(\n \"Question choice primitives must be used inside HumanInputPrimitive.QuestionPrompt.\",\n );\n }\n return value;\n}\n","import type { UIAttachment } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ImageContextValue = {\n attachment: UIAttachment;\n src?: string;\n name?: string;\n mediaType?: string;\n isImage: boolean;\n zoomOpen: boolean;\n setZoomOpen(open: boolean): void;\n};\n\nconst ImageContext = createContext<ImageContextValue | undefined>(undefined);\n\nexport function InternalImageProvider({\n value,\n children,\n}: {\n value: ImageContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ImageContext.Provider, { value }, children);\n}\n\nexport function useImage(): ImageContextValue {\n const value = useContext(ImageContext);\n if (value === undefined) {\n throw new Error(\"Image primitives must be used inside ImagePrimitive.Root.\");\n }\n return value;\n}\n","import type { UIMessage, UIMessagePart } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type MessageContextValue = {\n message: UIMessage;\n};\n\nexport type MessagePartContextValue = {\n isLive: boolean;\n part: UIMessagePart;\n streamControlled: boolean;\n};\n\nconst MessageContext = createContext<MessageContextValue | undefined>(undefined);\nconst MessagePartContext = createContext<MessagePartContextValue | undefined>(undefined);\n\nexport function InternalMessageProvider({\n message,\n children,\n}: {\n message: UIMessage;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessageContext.Provider, { value: { message } }, children);\n}\n\nexport function InternalMessagePartProvider({\n part,\n isLive = false,\n streamControlled = false,\n children,\n}: {\n part: UIMessagePart;\n isLive?: boolean;\n streamControlled?: boolean;\n children?: ReactNode;\n}): ReactElement {\n return createElement(\n MessagePartContext.Provider,\n { value: { isLive, part, streamControlled } },\n children,\n );\n}\n\nexport function useMessage(): MessageContextValue {\n const value = useContext(MessageContext);\n if (value === undefined) {\n throw new Error(\n \"Message primitives must be used inside MessagePrimitive.Root or ThreadPrimitive.Messages.\",\n );\n }\n return value;\n}\n\nexport function useMessagePart(): MessagePartContextValue {\n const value = useContext(MessagePartContext);\n if (value === undefined) {\n throw new Error(\n \"Message part primitives must be used inside MessagePrimitive.Parts or MessagePrimitive.Part.\",\n );\n }\n return value;\n}\n\nexport function useOptionalMessagePart(): MessagePartContextValue | undefined {\n return useContext(MessagePartContext);\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type SelectionToolbarSelection = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nexport type SelectionToolbarContextValue = {\n selection?: SelectionToolbarSelection;\n quote(): void;\n copy(): Promise<void>;\n clear(): void;\n};\n\nconst SelectionToolbarContext = createContext<SelectionToolbarContextValue | undefined>(undefined);\n\nexport function InternalSelectionToolbarProvider({\n value,\n children,\n}: {\n value: SelectionToolbarContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(SelectionToolbarContext.Provider, { value }, children);\n}\n\nexport function useSelectionToolbar(): SelectionToolbarContextValue {\n const value = useContext(SelectionToolbarContext);\n if (value === undefined) {\n throw new Error(\n \"SelectionToolbar primitives must be used inside SelectionToolbarPrimitive.Root.\",\n );\n }\n return value;\n}\n","import {\n createContext,\n createElement,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n useContext,\n} from \"react\";\n\nexport type ThreadContextValue = {\n viewportRef: MutableRefObject<HTMLElement | null>;\n messagesRef: MutableRefObject<HTMLElement | null>;\n atBottom: boolean;\n setAtBottom(atBottom: boolean): void;\n scrollToBottom(behavior?: ScrollBehavior): void;\n};\n\nconst ThreadContext = createContext<ThreadContextValue | undefined>(undefined);\n\nexport function InternalThreadProvider({\n value,\n children,\n}: {\n value: ThreadContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadContext.Provider, { value }, children);\n}\n\nexport function useThread(): ThreadContextValue {\n const value = useContext(ThreadContext);\n if (value === undefined) {\n throw new Error(\"Thread primitives must be used inside ThreadPrimitive.Root.\");\n }\n return value;\n}\n","import {\n createContext,\n createElement,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n useContext,\n} from \"react\";\n\nexport type ThreadListRecord = {\n id: string;\n title?: string;\n createdAt?: string | Date;\n updatedAt?: string | Date;\n archived?: boolean;\n metadata?: unknown;\n};\n\nexport type ThreadListController = {\n threads: ThreadListRecord[];\n activeThreadId?: string;\n status?: \"idle\" | \"loading\" | \"error\";\n error?: unknown;\n createThread(): Promise<void> | void;\n switchThread(threadId: string): Promise<void> | void;\n archiveThread?(threadId: string): Promise<void> | void;\n unarchiveThread?(threadId: string): Promise<void> | void;\n deleteThread?(threadId: string): Promise<void> | void;\n};\n\nexport type ThreadListItemContextValue = {\n thread: ThreadListRecord;\n active: boolean;\n};\n\nexport type ThreadListProviderProps = {\n controller: ThreadListController;\n children?: ReactNode;\n};\n\nexport type InternalThreadListRootContextValue = {\n rootRef: MutableRefObject<HTMLDivElement | null>;\n newButtonRef: MutableRefObject<HTMLButtonElement | null>;\n itemElements: MutableRefObject<Map<string, HTMLDivElement>>;\n triggerElements: MutableRefObject<Map<string, HTMLButtonElement>>;\n registerItem(threadId: string, element: HTMLDivElement | null): void;\n registerTrigger(threadId: string, element: HTMLButtonElement | null): void;\n};\n\nconst ThreadListContext = createContext<ThreadListController | undefined>(undefined);\nconst ThreadListItemContext = createContext<ThreadListItemContextValue | undefined>(undefined);\nconst ThreadListRootContext = createContext<InternalThreadListRootContextValue | undefined>(\n undefined,\n);\n\nexport function ThreadListProvider({\n controller,\n children,\n}: ThreadListProviderProps): ReactElement {\n return createElement(ThreadListContext.Provider, { value: controller }, children);\n}\n\nexport function InternalThreadListItemProvider({\n value,\n children,\n}: {\n value: ThreadListItemContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadListItemContext.Provider, { value }, children);\n}\n\nexport function InternalThreadListRootProvider({\n value,\n children,\n}: {\n value: InternalThreadListRootContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadListRootContext.Provider, { value }, children);\n}\n\nexport function useThreadList(): ThreadListController {\n const value = useContext(ThreadListContext);\n if (value === undefined) {\n throw new Error(\"ThreadList primitives must be used inside ThreadListProvider.\");\n }\n return value;\n}\n\nexport function useThreadListItem(): ThreadListItemContextValue {\n const value = useContext(ThreadListItemContext);\n if (value === undefined) {\n throw new Error(\"ThreadListItem primitives must be used inside ThreadListPrimitive.Items.\");\n }\n return value;\n}\n\nexport function useInternalThreadListRoot(): InternalThreadListRootContextValue {\n const value = useContext(ThreadListRootContext);\n if (value === undefined) {\n throw new Error(\"Thread-list primitives must be used inside ThreadListPrimitive.Root.\");\n }\n return value;\n}\n"],"mappings":";;AAQA,MAAM,oBAAoB,cAAkD,KAAA,CAAS;AAErF,SAAgB,2BAA2B,EACzC,OACA,YAIe;CACf,OAAO,cAAc,kBAAkB,UAAU,EAAE,MAAM,GAAG,QAAQ;AACtE;AAEA,SAAgB,gBAAwC;CACtD,MAAM,QAAQ,WAAW,iBAAiB;CAC1C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAEA,SAAgB,wBA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MAAM,GAAG,QAAQ;AAC1E;AAEA,SAAgB,gBAAsC;CACpD,MAAM,QAAQ,WAAW,iBAAiB;CAC1C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,+DAA+D;CAEjF,OAAO;AACT;AAEA,SAAgB,oBAAgD;CAC9D,MAAM,QAAQ,WAAW,qBAAqB;CAC9C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,0EAA0E;CAE5F,OAAO;AACT;AAEA,SAAgB,4BAAgE;CAC9E,MAAM,QAAQ,WAAW,qBAAqB;CAC9C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,sEAAsE;CAExF,OAAO;AACT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/message/elements.ts
|
|
2
|
+
const messageIds = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function registerMessageElement(element, messageId) {
|
|
4
|
+
messageIds.set(element, messageId);
|
|
5
|
+
}
|
|
6
|
+
function messageElementFromNode(node) {
|
|
7
|
+
let element = node?.nodeType === Node.ELEMENT_NODE ? node : node?.parentElement ?? void 0;
|
|
8
|
+
while (element !== void 0 && element !== null) {
|
|
9
|
+
const messageId = messageIds.get(element);
|
|
10
|
+
if (messageId !== void 0) return {
|
|
11
|
+
element,
|
|
12
|
+
messageId
|
|
13
|
+
};
|
|
14
|
+
element = element.parentElement ?? void 0;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { registerMessageElement as n, messageElementFromNode as t };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=elements-D4vmkkF8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements-D4vmkkF8.js","names":[],"sources":["../src/message/elements.ts"],"sourcesContent":["const messageIds = new WeakMap<HTMLElement, string>();\n\nexport function registerMessageElement(element: HTMLElement, messageId: string): void {\n messageIds.set(element, messageId);\n}\n\nexport function messageElementFromNode(\n node: Node | null,\n): { element: HTMLElement; messageId: string } | undefined {\n let element =\n node?.nodeType === Node.ELEMENT_NODE\n ? (node as HTMLElement)\n : (node?.parentElement ?? undefined);\n\n while (element !== undefined && element !== null) {\n const messageId = messageIds.get(element);\n if (messageId !== undefined) {\n return { element, messageId };\n }\n element = element.parentElement ?? undefined;\n }\n return undefined;\n}\n"],"mappings":";AAAA,MAAM,6BAAa,IAAI,QAA6B;AAEpD,SAAgB,uBAAuB,SAAsB,WAAyB;CACpF,WAAW,IAAI,SAAS,SAAS;AACnC;AAEA,SAAgB,uBACd,MACyD;CACzD,IAAI,UACF,MAAM,aAAa,KAAK,eACnB,OACA,MAAM,iBAAiB,KAAA;CAE9B,OAAO,YAAY,KAAA,KAAa,YAAY,MAAM;EAChD,MAAM,YAAY,WAAW,IAAI,OAAO;EACxC,IAAI,cAAc,KAAA,GAChB,OAAO;GAAE;GAAS;EAAU;EAE9B,UAAU,QAAQ,iBAAiB,KAAA;CACrC;AAEF"}
|
|
@@ -1,77 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GraphExplorerController } from
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import { GraphExploreNode
|
|
6
|
-
|
|
7
|
-
import { ReactNode, ReactElement } from 'react';
|
|
8
|
-
import { P as PrimitiveProps } from '../render-CRKWam2v.js';
|
|
9
|
-
|
|
10
|
-
type GraphExplorerProviderProps<Schema extends GraphSchemaLike = GraphSchemaLike> = {
|
|
11
|
-
controller: GraphExplorerController<Schema>;
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
};
|
|
14
|
-
type GraphExplorerNodeContextValue = {
|
|
15
|
-
node: GraphExploreNode;
|
|
16
|
-
selected: boolean;
|
|
17
|
-
matched: boolean;
|
|
18
|
-
};
|
|
19
|
-
declare function GraphExplorerProvider<Schema extends GraphSchemaLike = GraphSchemaLike>({ controller, children, }: GraphExplorerProviderProps<Schema>): ReactElement;
|
|
20
|
-
declare function useGraphExplorerContext<Schema extends GraphSchemaLike = GraphSchemaLike>(): GraphExplorerController<Schema>;
|
|
21
|
-
declare function useGraphExplorerNode(): GraphExplorerNodeContextValue;
|
|
22
|
-
|
|
23
|
-
declare function graphExplorerNodeLabel(node: GraphExploreNode): string;
|
|
24
|
-
|
|
1
|
+
import "../index-BCBVcl0D.js";
|
|
2
|
+
import { G as GraphExplorerExpandNodeOptions, J as GraphExplorerProviderProps, K as GraphExplorerNodeContextValue, W as GraphExplorerController, X as useGraphExplorerContext, Y as GraphExplorerStatus, Z as useGraphExplorerNode, q as GraphExplorerProvider } from "../index-Mw3ltwSG.js";
|
|
3
|
+
import { t as PrimitiveProps } from "../index-DqdyM0Jm.js";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
import { GraphExploreNode } from "@anvia/graph";
|
|
6
|
+
export declare function graphExplorerNodeLabel(node: GraphExploreNode): string;
|
|
25
7
|
type GraphExplorerNodeRootProps = PrimitiveProps<"div"> & {
|
|
26
|
-
|
|
8
|
+
nodeId?: string;
|
|
27
9
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
export declare const GraphExplorerPrimitive: {
|
|
11
|
+
readonly Root: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
readonly Viewport: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
readonly Search: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "asChild"> & {
|
|
18
|
+
asChild?: boolean;
|
|
19
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
20
|
+
readonly Nodes: import("react").ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
21
|
+
children?: import("react").ReactNode | ((node: import("@anvia/graph").GraphExploreNode, state: GraphExplorerNodeContextValue) => import("react").ReactNode);
|
|
22
|
+
keepMounted?: boolean;
|
|
23
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
24
|
+
readonly Empty: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
readonly Status: import("react").ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
28
|
+
children?: import("react").ReactNode | ((explorer: import("@anvia/react/graph-explorer").GraphExplorerController) => import("react").ReactNode);
|
|
29
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
|
+
readonly Refresh: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
31
|
+
asChild?: boolean;
|
|
32
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
52
33
|
};
|
|
53
|
-
declare const GraphExplorerNodePrimitive: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
34
|
+
export declare const GraphExplorerNodePrimitive: {
|
|
35
|
+
readonly Root: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
} & {
|
|
38
|
+
nodeId?: string;
|
|
39
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
40
|
+
readonly Trigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
41
|
+
asChild?: boolean;
|
|
42
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
43
|
+
readonly Expand: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
} & {
|
|
46
|
+
options?: {
|
|
47
|
+
readonly relationships?: readonly string[] | undefined;
|
|
48
|
+
readonly nodeTypes?: readonly string[] | undefined;
|
|
49
|
+
readonly includeProvenance?: boolean | undefined | undefined;
|
|
50
|
+
readonly maxNodes?: number | undefined | undefined;
|
|
51
|
+
readonly maxRelationships?: number | undefined | undefined;
|
|
52
|
+
readonly direction?: import("@anvia/graph").GraphExploreDirection | undefined;
|
|
53
|
+
readonly maxDepth?: number | undefined | undefined;
|
|
54
|
+
};
|
|
55
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
75
56
|
};
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
export { type GraphExplorerController, type GraphExplorerExpandNodeOptions, type GraphExplorerNodeContextValue, type GraphExplorerNodeRootProps, GraphExplorerProvider, type GraphExplorerProviderProps, type GraphExplorerStatus, useGraphExplorerContext, useGraphExplorerNode };
|
|
58
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__0.PrimitiveProps","_$_0.GraphExplorerNodeContextValue"],"sources":["../../src/graph-explorer/helpers.ts","../../src/graph-explorer/parts.tsx","../../src/graph-explorer/index.ts"],"mappings":";;;;;wBAEgB,uBAAuB,MAAM;KCoKjC,6BAA6B;EAA0B;;qBCzJtD;;;;;;;;;;;;;;;;;;;;;;;;qBAUA"}
|