@mgamadeus/ddd-agents 0.10.6 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/chat.js +10 -10
  2. package/dist/chunks/{ConversationMarkdown-06rFO7Fr.js → ConversationMarkdown-C3SKd3i-.js} +4 -4
  3. package/dist/chunks/{ConversationMarkdown-06rFO7Fr.js.map → ConversationMarkdown-C3SKd3i-.js.map} +1 -1
  4. package/dist/chunks/{ConversationMessageInputComposerWidgets-BbIuDOUV.js → ConversationMessageInputComposerWidgets-D7x-TFKG.js} +6 -6
  5. package/dist/chunks/{ConversationMessageInputComposerWidgets-BbIuDOUV.js.map → ConversationMessageInputComposerWidgets-D7x-TFKG.js.map} +1 -1
  6. package/dist/chunks/{VoiceBarsIcon-BKtx_QIg.js → VoiceBarsIcon-CNIPOLtV.js} +5 -5
  7. package/dist/chunks/VoiceBarsIcon-CNIPOLtV.js.map +1 -0
  8. package/dist/chunks/{WebSearchResultsConversationWidget-W7O1fBB0.js → WebSearchResultsConversationWidget-CUtKAdMM.js} +3 -3
  9. package/dist/chunks/{WebSearchResultsConversationWidget-W7O1fBB0.js.map → WebSearchResultsConversationWidget-CUtKAdMM.js.map} +1 -1
  10. package/dist/chunks/{browser-request-interception-BnzFbH0m.js → browser-request-interception-ydNOzeUL.js} +2 -2
  11. package/dist/chunks/{browser-request-interception-BnzFbH0m.js.map → browser-request-interception-ydNOzeUL.js.map} +1 -1
  12. package/dist/chunks/{canvas-reducers-DDg9T7t8.js → canvas-reducers-CAtcbD4i.js} +2 -2
  13. package/dist/chunks/{canvas-reducers-DDg9T7t8.js.map → canvas-reducers-CAtcbD4i.js.map} +1 -1
  14. package/dist/chunks/{canvas-title-slot-context-8HUvNDuc.js → canvas-title-slot-context-rl94V4u4.js} +3 -3
  15. package/dist/chunks/{canvas-title-slot-context-8HUvNDuc.js.map → canvas-title-slot-context-rl94V4u4.js.map} +1 -1
  16. package/dist/chunks/{canvasBodies-qC-A_rlz.js → canvasBodies-C3wydcKZ.js} +4 -4
  17. package/dist/chunks/{canvasBodies-qC-A_rlz.js.map → canvasBodies-C3wydcKZ.js.map} +1 -1
  18. package/dist/chunks/{canvasStorage-DaM9851h.js → canvasStorage-D9EnBraV.js} +2 -2
  19. package/dist/chunks/{canvasStorage-DaM9851h.js.map → canvasStorage-D9EnBraV.js.map} +1 -1
  20. package/dist/chunks/{link-navigation-BUcy5qWW.js → link-navigation-DRHt6g7U.js} +17 -1
  21. package/dist/chunks/{link-navigation-BUcy5qWW.js.map → link-navigation-DRHt6g7U.js.map} +1 -1
  22. package/dist/chunks/{widget-name-resolver-BNSfO2Aw.js → widget-name-resolver-akTPWt63.js} +514 -384
  23. package/dist/chunks/widget-name-resolver-akTPWt63.js.map +1 -0
  24. package/dist/client-testing.js +4 -4
  25. package/dist/files/i18n-keys.json +36 -0
  26. package/dist/files/renderer/widget-tree/composed-node-schema.json +2 -0
  27. package/dist/image-render.js +7 -7
  28. package/dist/index.js +6 -6
  29. package/dist/kit.js +2 -2
  30. package/dist/preview.js +7 -7
  31. package/dist/provider.js +1 -1
  32. package/dist/renderer.js +10 -10
  33. package/dist/styles.css +28 -0
  34. package/dist/types/provider/environment.d.ts +32 -2
  35. package/dist/types/provider/index.d.ts +1 -1
  36. package/dist/voice.js +2 -2
  37. package/dist/widgets.js +4 -4
  38. package/package.json +1 -1
  39. package/dist/chunks/VoiceBarsIcon-BKtx_QIg.js.map +0 -1
  40. package/dist/chunks/widget-name-resolver-BNSfO2Aw.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { V as getSandboxLegacyAliases } from "./link-navigation-BUcy5qWW.js";
2
+ import { V as getSandboxLegacyAliases } from "./link-navigation-DRHt6g7U.js";
3
3
  const WIDGET_IMAGE_READINESS_GLOBAL_NAME = "__AGENTS_WIDGET_IMAGE_V1__";
4
4
  const readWidgetImageReadinessGlobalNames = () => [
5
5
  WIDGET_IMAGE_READINESS_GLOBAL_NAME,
@@ -332,4 +332,4 @@ export {
332
332
  readWidgetImageReadiness as r,
333
333
  toSameRealmFetchInput as t
334
334
  };
335
- //# sourceMappingURL=browser-request-interception-BnzFbH0m.js.map
335
+ //# sourceMappingURL=browser-request-interception-ydNOzeUL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-request-interception-BnzFbH0m.js","sources":["../../src/image-render/widget-image-readiness-signal.ts","../../src/request-interception/intercepted-xml-http-request-upload.ts","../../src/request-interception/browser-request-interception.ts"],"sourcesContent":["import { getSandboxLegacyAliases } from \"../provider/environment\";\nimport type { WidgetImageReadiness } from \"./widget-image-render.types\";\n\n/** The `window` property the image capture waits on. */\nexport const WIDGET_IMAGE_READINESS_GLOBAL_NAME = \"__AGENTS_WIDGET_IMAGE_V1__\";\n\ntype WindowSignals = Record<string, WidgetImageReadiness | undefined>;\n\n/**\n * Every name the image readiness signal is published under: the package's own, then each name the app declares\n * (`AgentsEnvironment.sandboxLegacyAliases.imageReadinessGlobalNames`) — read at each publish, so an app may declare\n * them after a readiness was created.\n */\nexport const readWidgetImageReadinessGlobalNames = (): string[] => [\n WIDGET_IMAGE_READINESS_GLOBAL_NAME,\n ...(getSandboxLegacyAliases().imageReadinessGlobalNames ?? []).filter(\n (aliasName) => aliasName !== WIDGET_IMAGE_READINESS_GLOBAL_NAME,\n ),\n];\n\n/** Publishes (or with `undefined` clears) the image readiness signal under every name. */\nexport const publishWidgetImageReadiness = (readiness: WidgetImageReadiness | undefined): void => {\n const windowSignals = window as unknown as WindowSignals;\n for (const globalName of readWidgetImageReadinessGlobalNames()) windowSignals[globalName] = readiness;\n};\n\n/**\n * The published image readiness signal. A `failed` value under ANY name wins — the app's own capture code may have\n * written it under a name it declared — otherwise the value under the package's name, otherwise the first value found.\n */\nexport const readWidgetImageReadiness = (): WidgetImageReadiness | undefined => {\n const windowSignals = window as unknown as WindowSignals;\n const publishedSignals = readWidgetImageReadinessGlobalNames()\n .map((globalName) => windowSignals[globalName])\n .filter((signal): signal is WidgetImageReadiness => signal !== undefined && signal !== null);\n return publishedSignals.find((signal) => signal.state === \"failed\") ?? publishedSignals[0];\n};\n","/** The upload side of the `XMLHttpRequest` stand-in (`xhr.upload`) and the events both sides dispatch. */\n\nexport type XhrEventName = \"loadstart\" | \"progress\" | \"load\" | \"error\" | \"abort\" | \"timeout\" | \"loadend\" | \"readystatechange\";\nexport type XhrEventHandler = ((this: unknown, event: Event) => unknown) | null;\n\nexport const createProgressEvent = (type: string, loaded: number, total: number): Event =>\n typeof ProgressEvent === \"function\"\n ? new ProgressEvent(type, { lengthComputable: total > 0, loaded, total })\n : new Event(type);\n\n/** The event target of `xhr.upload`: listeners and `on…` handlers for the upload's progress. */\nexport class InterceptedXMLHttpRequestUpload extends EventTarget {\n onloadstart: XhrEventHandler = null;\n onprogress: XhrEventHandler = null;\n onload: XhrEventHandler = null;\n onerror: XhrEventHandler = null;\n onabort: XhrEventHandler = null;\n ontimeout: XhrEventHandler = null;\n onloadend: XhrEventHandler = null;\n\n emit(type: XhrEventName, loaded = 0, total = 0) {\n const event = createProgressEvent(type, loaded, total);\n this.dispatchEvent(event);\n (this[`on${type}` as keyof this] as XhrEventHandler)?.call(this, event);\n }\n}\n","import {\n createProgressEvent,\n InterceptedXMLHttpRequestUpload,\n type XhrEventHandler,\n type XhrEventName,\n} from \"./intercepted-xml-http-request-upload\";\n\n/**\n * The browser-level request stand-in of the capture and preview pages: `XMLHttpRequest` (the transport of axios's\n * browser adapter and of uploads with progress) and, where an install asks for it, `window.fetch` are replaced for the\n * duration of an install and send every request into one handler, whatever HTTP client the application uses.\n *\n * The handler answers with a `Response` or throws: `fetch` then rejects with the thrown error, an `XMLHttpRequest`\n * fails like a network error (status 0, `error` and `loadend`, no body, no header). A handler that never settles\n * leaves the request pending. Nothing of the request reaches the network unless the handler sends it itself\n * (`forward()`, or its own copy of the original `fetch`).\n */\n\n/** A request as the handler sees it, the same for `fetch` and `XMLHttpRequest`. */\nexport interface InterceptedRequest {\n /** Upper case (`GET`, `POST`, …). */\n method: string;\n /** Absolute, resolved against the page's origin. A fresh object per request; the handler may change it. */\n url: URL;\n headers: Headers;\n /** The body the client passed (`fetch`'s, or the argument of `XMLHttpRequest.send`, also for a GET), or null. */\n body: BodyInit | null;\n signal: AbortSignal | undefined;\n transport: \"fetch\" | \"xhr\";\n /** Sends the request unchanged through the original `fetch` (an `XMLHttpRequest` with its own credentials mode). */\n forward: () => Promise<Response>;\n}\n\nexport type InterceptedRequestHandler = (request: InterceptedRequest) => Promise<Response>;\n\ntype FetchInput = RequestInfo | URL;\n\n/**\n * An answer without any header, as the former axios adapters answered (`headers: {}`): a string body would add a\n * `Content-Type`, the bytes of it do not.\n */\nexport const createHeaderlessResponse = (body: string | null, status: number, statusText = \"\"): Response =>\n new Response(body === null ? null : new TextEncoder().encode(body), { status, statusText });\n\n/** A `Request` of any realm (an iframe's, jsdom's, Node's) — never `instanceof`, which holds only for this realm. */\nexport const isFetchRequest = (input: unknown): input is Request =>\n Object.prototype.toString.call(input) === \"[object Request]\";\n\nconst pageOrigin = (): string =>\n typeof window !== \"undefined\" && window.location ? window.location.origin : \"http://localhost\";\n\nconst copyHeaders = (target: Headers, source: HeadersInit | undefined) => {\n if (source === undefined) return;\n new Headers(source).forEach((value, name) => target.set(name, value));\n};\n\n/** The `fetch` arguments as one request: a `Request` of any realm, a `URL` or a string, with `init` taking precedence. */\nexport const readFetchRequest = async (\n input: FetchInput,\n init: RequestInit | undefined,\n originalFetch: typeof fetch,\n): Promise<InterceptedRequest> => {\n const fromRequest = isFetchRequest(input) ? input : undefined;\n const headers = new Headers();\n if (fromRequest) fromRequest.headers.forEach((value, name) => headers.set(name, value));\n copyHeaders(headers, init?.headers);\n const initBody = init?.body ?? null;\n const body =\n initBody !== null\n ? initBody\n : fromRequest && fromRequest.body !== null\n ? await fromRequest.clone().arrayBuffer()\n : null;\n return {\n method: (init?.method ?? fromRequest?.method ?? \"GET\").toUpperCase(),\n url: new URL(fromRequest ? fromRequest.url : String(input), pageOrigin()),\n headers,\n body,\n signal: init?.signal ?? fromRequest?.signal ?? undefined,\n transport: \"fetch\",\n forward: () => originalFetch(input, init),\n };\n};\n\nconst bodySize = (body: BodyInit | null): number => {\n if (body === null) return 0;\n if (typeof body === \"string\") return new TextEncoder().encode(body).byteLength;\n if (typeof Blob !== \"undefined\" && body instanceof Blob) return body.size;\n if (body instanceof ArrayBuffer) return body.byteLength;\n if (ArrayBuffer.isView(body)) return body.byteLength;\n return 0;\n};\n\nconst invalidState = (message: string) => new DOMException(message, \"InvalidStateError\");\n\n/** Builds the `XMLHttpRequest` class an install puts on the page: every request goes to `handle`. */\nconst createInterceptedXMLHttpRequest = (handle: InterceptedRequestHandler, originalFetch: typeof fetch) =>\n class InterceptedXMLHttpRequest extends EventTarget {\n static readonly UNSENT = 0;\n static readonly OPENED = 1;\n static readonly HEADERS_RECEIVED = 2;\n static readonly LOADING = 3;\n static readonly DONE = 4;\n readonly UNSENT = 0;\n readonly OPENED = 1;\n readonly HEADERS_RECEIVED = 2;\n readonly LOADING = 3;\n readonly DONE = 4;\n\n readyState = 0;\n status = 0;\n statusText = \"\";\n responseURL = \"\";\n responseType: XMLHttpRequestResponseType = \"\";\n timeout = 0;\n withCredentials = false;\n readonly upload = new InterceptedXMLHttpRequestUpload();\n readonly responseXML = null;\n\n onreadystatechange: XhrEventHandler = null;\n onloadstart: XhrEventHandler = null;\n onprogress: XhrEventHandler = null;\n onload: XhrEventHandler = null;\n onerror: XhrEventHandler = null;\n onabort: XhrEventHandler = null;\n ontimeout: XhrEventHandler = null;\n onloadend: XhrEventHandler = null;\n\n protected method = \"GET\";\n protected requestUrl = \"\";\n protected requestHeaders = new Headers();\n protected responseHeaders = new Headers();\n protected responseValue: unknown = \"\";\n protected responseTextValue = \"\";\n protected sent = false;\n protected settled = false;\n protected controller: AbortController | undefined;\n protected timer: ReturnType<typeof setTimeout> | undefined;\n\n get response(): unknown {\n if (this.responseType === \"\" || this.responseType === \"text\") return this.responseText;\n return this.readyState === 4 ? this.responseValue : null;\n }\n\n get responseText(): string {\n if (this.responseType !== \"\" && this.responseType !== \"text\") {\n throw invalidState(`responseText is not available for responseType \"${this.responseType}\"`);\n }\n return this.readyState >= 3 ? this.responseTextValue : \"\";\n }\n\n open(method: string, url: string | URL) {\n // A running request is dropped without events, as a browser does.\n if (this.sent && !this.settled) this.settle();\n this.controller?.abort();\n this.controller = undefined;\n this.method = method.toUpperCase();\n this.requestUrl = String(url);\n this.requestHeaders = new Headers();\n this.responseHeaders = new Headers();\n this.responseValue = \"\";\n this.responseTextValue = \"\";\n this.status = 0;\n this.statusText = \"\";\n this.responseURL = \"\";\n this.sent = false;\n this.settled = false;\n this.setReadyState(1);\n }\n\n setRequestHeader(name: string, value: string) {\n if (this.readyState !== 1 || this.sent) throw invalidState(\"setRequestHeader needs an opened, unsent request\");\n this.requestHeaders.append(name, value);\n }\n\n overrideMimeType() {}\n\n getAllResponseHeaders(): string {\n if (this.readyState < 2) return \"\";\n let lines = \"\";\n this.responseHeaders.forEach((value, name) => {\n lines += `${name}: ${value}\\r\\n`;\n });\n return lines;\n }\n\n getResponseHeader(name: string): string | null {\n return this.readyState < 2 ? null : this.responseHeaders.get(name);\n }\n\n send(body?: Document | XMLHttpRequestBodyInit | null) {\n if (this.readyState !== 1 || this.sent) throw invalidState(\"send needs an opened, unsent request\");\n this.sent = true;\n const controller = new AbortController();\n this.controller = controller;\n const passedBody = body === undefined || body === null ? null : (body as BodyInit);\n // A browser sends no body with a GET or HEAD; the handler still sees what the client passed.\n const requestBody = this.method === \"GET\" || this.method === \"HEAD\" ? null : passedBody;\n const headers = new Headers(this.requestHeaders);\n const url = new URL(this.requestUrl, pageOrigin());\n const credentials: RequestCredentials = this.withCredentials ? \"include\" : \"same-origin\";\n const method = this.method;\n const request: InterceptedRequest = {\n method,\n url,\n headers,\n body: passedBody,\n signal: controller.signal,\n transport: \"xhr\",\n forward: () =>\n originalFetch(url.href, {\n method,\n headers: new Headers(headers),\n body: requestBody,\n credentials,\n signal: controller.signal,\n }),\n };\n const responseUrl = url.href;\n if (this.timeout > 0) this.timer = setTimeout(() => this.finishWithoutResponse(\"timeout\"), this.timeout);\n this.emit(\"loadstart\");\n const size = bodySize(requestBody);\n if (requestBody !== null) {\n this.upload.emit(\"loadstart\", 0, size);\n this.upload.emit(\"progress\", size, size);\n this.upload.emit(\"load\", size, size);\n this.upload.emit(\"loadend\", size, size);\n }\n Promise.resolve()\n .then(() => handle(request))\n .then(\n (response) => this.receive(controller, response, responseUrl),\n () => {\n if (this.controller === controller) this.finishWithoutResponse(\"error\");\n },\n );\n }\n\n abort() {\n if (!this.sent || this.settled) return;\n this.finishWithoutResponse(\"abort\");\n this.readyState = 0;\n }\n\n protected async receive(controller: AbortController, response: Response, responseUrl: string) {\n if (this.controller !== controller || this.settled) return;\n try {\n this.status = response.status;\n this.statusText = response.statusText;\n this.responseURL = responseUrl;\n this.responseHeaders = new Headers(response.headers);\n this.setReadyState(2);\n const value = await this.readBody(response);\n if (this.controller !== controller || this.settled) return;\n this.responseValue = value;\n this.setReadyState(3);\n const size = typeof this.responseTextValue === \"string\" ? this.responseTextValue.length : 0;\n this.emit(\"progress\", size, size);\n this.settle();\n this.setReadyState(4);\n this.emit(\"load\", size, size);\n this.emit(\"loadend\", size, size);\n } catch {\n if (this.controller === controller && !this.settled) this.finishWithoutResponse(\"error\");\n }\n }\n\n protected async readBody(response: Response): Promise<unknown> {\n switch (this.responseType) {\n case \"json\": {\n const text = await response.text();\n this.responseTextValue = text;\n try {\n return text === \"\" ? null : JSON.parse(text);\n } catch {\n return null;\n }\n }\n case \"blob\":\n return response.blob();\n case \"arraybuffer\":\n return response.arrayBuffer();\n case \"document\":\n return null;\n default: {\n const text = await response.text();\n this.responseTextValue = text;\n return text;\n }\n }\n }\n\n /** A request that ends without a response — an error, an abort or a timeout: status 0, nothing of a body. */\n protected finishWithoutResponse(type: \"error\" | \"abort\" | \"timeout\") {\n if (this.settled) return;\n this.settle();\n this.controller?.abort();\n this.status = 0;\n this.statusText = \"\";\n this.responseHeaders = new Headers();\n this.responseValue = null;\n this.responseTextValue = \"\";\n this.setReadyState(4);\n this.emit(type);\n this.emit(\"loadend\");\n }\n\n protected settle() {\n this.settled = true;\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = undefined;\n }\n\n protected setReadyState(state: number) {\n this.readyState = state;\n this.emit(\"readystatechange\");\n }\n\n protected emit(type: XhrEventName, loaded = 0, total = 0) {\n const event = type === \"readystatechange\" ? new Event(type) : createProgressEvent(type, loaded, total);\n this.dispatchEvent(event);\n (this[`on${type}` as keyof this] as XhrEventHandler)?.call(this, event);\n }\n };\n\ntype GlobalScope = { fetch?: typeof fetch; XMLHttpRequest?: typeof XMLHttpRequest };\n\n/** The scopes that carry the page's `fetch` and `XMLHttpRequest` (the window and the global object, once each). */\nconst globalScopes = (): GlobalScope[] => {\n const scopes: GlobalScope[] = [globalThis as GlobalScope];\n if (typeof window !== \"undefined\" && (window as unknown) !== globalThis) scopes.push(window as GlobalScope);\n return scopes;\n};\n\n/** The page's `fetch` as it is now (the window's), callable after an install replaced it. */\nconst capturePageFetch = (): typeof fetch => {\n const pageFetch = (typeof window !== \"undefined\" ? window.fetch : globalThis.fetch) as typeof fetch;\n return (input, init) => pageFetch.call(globalThis, input, init);\n};\n\n/** Puts `value` on every global scope under `name` until the returned function restores what was there. */\nconst replaceGlobal = <Name extends keyof GlobalScope>(name: Name, value: GlobalScope[Name]): (() => void) => {\n const saved = globalScopes().map((scope) => ({ scope, value: scope[name] }));\n for (const { scope } of saved) scope[name] = value;\n return () => {\n for (const entry of saved) entry.scope[name] = entry.value;\n };\n};\n\n/**\n * Replaces `XMLHttpRequest` on the page until the returned function is called; `fetch` stays as it is. A handler's\n * `forward()` goes through the page's `fetch` as it was at the install.\n */\nexport const interceptXMLHttpRequests = (handle: InterceptedRequestHandler): (() => void) =>\n replaceGlobal(\n \"XMLHttpRequest\",\n createInterceptedXMLHttpRequest(handle, capturePageFetch()) as unknown as typeof XMLHttpRequest,\n );\n\n/** Replaces `fetch` on the page until the returned function is called; `XMLHttpRequest` stays as it is. */\nexport const interceptFetchRequests = (handle: InterceptedRequestHandler): (() => void) => {\n const originalFetch = capturePageFetch();\n const interceptedFetch = async (input: FetchInput, init?: RequestInit): Promise<Response> =>\n handle(await readFetchRequest(input, init, originalFetch));\n return replaceGlobal(\"fetch\", interceptedFetch as typeof fetch);\n};\n\n/**\n * A `fetch` input this realm's `Request` constructor reads correctly: a `Request` of another realm becomes one of this\n * realm with the same URL, method, headers, body and signal; anything else is returned as it is.\n */\nexport const toSameRealmFetchInput = async (input: FetchInput): Promise<FetchInput> => {\n if (!isFetchRequest(input) || (input as unknown) instanceof Request) return input;\n const foreign: Request = input;\n const body = foreign.body !== null ? await foreign.clone().arrayBuffer() : null;\n return new Request(foreign.url, {\n method: foreign.method,\n headers: new Headers(foreign.headers),\n body,\n // A signal of another realm is not accepted by this realm's constructor.\n signal: foreign.signal instanceof AbortSignal ? foreign.signal : undefined,\n });\n};\n"],"names":[],"mappings":";;AAIO,MAAM,qCAAqC;AAS3C,MAAM,sCAAsC,MAAgB;AAAA,EACjE;AAAA,EACA,IAAI,wBAAA,EAA0B,6BAA6B,CAAA,GAAI;AAAA,IAC7D,CAAC,cAAc,cAAc;AAAA,EAAA;AAEjC;AAGO,MAAM,8BAA8B,CAAC,cAAsD;AAChG,QAAM,gBAAgB;AACtB,aAAW,cAAc,oCAAA,EAAuC,eAAc,UAAU,IAAI;AAC9F;AAMO,MAAM,2BAA2B,MAAwC;AAC9E,QAAM,gBAAgB;AACtB,QAAM,mBAAmB,oCAAA,EACtB,IAAI,CAAC,eAAe,cAAc,UAAU,CAAC,EAC7C,OAAO,CAAC,WAA2C,WAAW,UAAa,WAAW,IAAI;AAC7F,SAAO,iBAAiB,KAAK,CAAC,WAAW,OAAO,UAAU,QAAQ,KAAK,iBAAiB,CAAC;AAC3F;AC/BO,MAAM,sBAAsB,CAAC,MAAc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AAI,QAAQ,QAAQ,OAAO;AAAA,IACpC;AAAA;AAAA,IAEA,QAAQ,QAAQ,kBAAkB,cAAc,QAAQ,SAAS;AAAA,EAAA,CAClE;AACH;"}
1
+ {"version":3,"file":"browser-request-interception-ydNOzeUL.js","sources":["../../src/image-render/widget-image-readiness-signal.ts","../../src/request-interception/intercepted-xml-http-request-upload.ts","../../src/request-interception/browser-request-interception.ts"],"sourcesContent":["import { getSandboxLegacyAliases } from \"../provider/environment\";\nimport type { WidgetImageReadiness } from \"./widget-image-render.types\";\n\n/** The `window` property the image capture waits on. */\nexport const WIDGET_IMAGE_READINESS_GLOBAL_NAME = \"__AGENTS_WIDGET_IMAGE_V1__\";\n\ntype WindowSignals = Record<string, WidgetImageReadiness | undefined>;\n\n/**\n * Every name the image readiness signal is published under: the package's own, then each name the app declares\n * (`AgentsEnvironment.sandboxLegacyAliases.imageReadinessGlobalNames`) — read at each publish, so an app may declare\n * them after a readiness was created.\n */\nexport const readWidgetImageReadinessGlobalNames = (): string[] => [\n WIDGET_IMAGE_READINESS_GLOBAL_NAME,\n ...(getSandboxLegacyAliases().imageReadinessGlobalNames ?? []).filter(\n (aliasName) => aliasName !== WIDGET_IMAGE_READINESS_GLOBAL_NAME,\n ),\n];\n\n/** Publishes (or with `undefined` clears) the image readiness signal under every name. */\nexport const publishWidgetImageReadiness = (readiness: WidgetImageReadiness | undefined): void => {\n const windowSignals = window as unknown as WindowSignals;\n for (const globalName of readWidgetImageReadinessGlobalNames()) windowSignals[globalName] = readiness;\n};\n\n/**\n * The published image readiness signal. A `failed` value under ANY name wins — the app's own capture code may have\n * written it under a name it declared — otherwise the value under the package's name, otherwise the first value found.\n */\nexport const readWidgetImageReadiness = (): WidgetImageReadiness | undefined => {\n const windowSignals = window as unknown as WindowSignals;\n const publishedSignals = readWidgetImageReadinessGlobalNames()\n .map((globalName) => windowSignals[globalName])\n .filter((signal): signal is WidgetImageReadiness => signal !== undefined && signal !== null);\n return publishedSignals.find((signal) => signal.state === \"failed\") ?? publishedSignals[0];\n};\n","/** The upload side of the `XMLHttpRequest` stand-in (`xhr.upload`) and the events both sides dispatch. */\n\nexport type XhrEventName = \"loadstart\" | \"progress\" | \"load\" | \"error\" | \"abort\" | \"timeout\" | \"loadend\" | \"readystatechange\";\nexport type XhrEventHandler = ((this: unknown, event: Event) => unknown) | null;\n\nexport const createProgressEvent = (type: string, loaded: number, total: number): Event =>\n typeof ProgressEvent === \"function\"\n ? new ProgressEvent(type, { lengthComputable: total > 0, loaded, total })\n : new Event(type);\n\n/** The event target of `xhr.upload`: listeners and `on…` handlers for the upload's progress. */\nexport class InterceptedXMLHttpRequestUpload extends EventTarget {\n onloadstart: XhrEventHandler = null;\n onprogress: XhrEventHandler = null;\n onload: XhrEventHandler = null;\n onerror: XhrEventHandler = null;\n onabort: XhrEventHandler = null;\n ontimeout: XhrEventHandler = null;\n onloadend: XhrEventHandler = null;\n\n emit(type: XhrEventName, loaded = 0, total = 0) {\n const event = createProgressEvent(type, loaded, total);\n this.dispatchEvent(event);\n (this[`on${type}` as keyof this] as XhrEventHandler)?.call(this, event);\n }\n}\n","import {\n createProgressEvent,\n InterceptedXMLHttpRequestUpload,\n type XhrEventHandler,\n type XhrEventName,\n} from \"./intercepted-xml-http-request-upload\";\n\n/**\n * The browser-level request stand-in of the capture and preview pages: `XMLHttpRequest` (the transport of axios's\n * browser adapter and of uploads with progress) and, where an install asks for it, `window.fetch` are replaced for the\n * duration of an install and send every request into one handler, whatever HTTP client the application uses.\n *\n * The handler answers with a `Response` or throws: `fetch` then rejects with the thrown error, an `XMLHttpRequest`\n * fails like a network error (status 0, `error` and `loadend`, no body, no header). A handler that never settles\n * leaves the request pending. Nothing of the request reaches the network unless the handler sends it itself\n * (`forward()`, or its own copy of the original `fetch`).\n */\n\n/** A request as the handler sees it, the same for `fetch` and `XMLHttpRequest`. */\nexport interface InterceptedRequest {\n /** Upper case (`GET`, `POST`, …). */\n method: string;\n /** Absolute, resolved against the page's origin. A fresh object per request; the handler may change it. */\n url: URL;\n headers: Headers;\n /** The body the client passed (`fetch`'s, or the argument of `XMLHttpRequest.send`, also for a GET), or null. */\n body: BodyInit | null;\n signal: AbortSignal | undefined;\n transport: \"fetch\" | \"xhr\";\n /** Sends the request unchanged through the original `fetch` (an `XMLHttpRequest` with its own credentials mode). */\n forward: () => Promise<Response>;\n}\n\nexport type InterceptedRequestHandler = (request: InterceptedRequest) => Promise<Response>;\n\ntype FetchInput = RequestInfo | URL;\n\n/**\n * An answer without any header, as the former axios adapters answered (`headers: {}`): a string body would add a\n * `Content-Type`, the bytes of it do not.\n */\nexport const createHeaderlessResponse = (body: string | null, status: number, statusText = \"\"): Response =>\n new Response(body === null ? null : new TextEncoder().encode(body), { status, statusText });\n\n/** A `Request` of any realm (an iframe's, jsdom's, Node's) — never `instanceof`, which holds only for this realm. */\nexport const isFetchRequest = (input: unknown): input is Request =>\n Object.prototype.toString.call(input) === \"[object Request]\";\n\nconst pageOrigin = (): string =>\n typeof window !== \"undefined\" && window.location ? window.location.origin : \"http://localhost\";\n\nconst copyHeaders = (target: Headers, source: HeadersInit | undefined) => {\n if (source === undefined) return;\n new Headers(source).forEach((value, name) => target.set(name, value));\n};\n\n/** The `fetch` arguments as one request: a `Request` of any realm, a `URL` or a string, with `init` taking precedence. */\nexport const readFetchRequest = async (\n input: FetchInput,\n init: RequestInit | undefined,\n originalFetch: typeof fetch,\n): Promise<InterceptedRequest> => {\n const fromRequest = isFetchRequest(input) ? input : undefined;\n const headers = new Headers();\n if (fromRequest) fromRequest.headers.forEach((value, name) => headers.set(name, value));\n copyHeaders(headers, init?.headers);\n const initBody = init?.body ?? null;\n const body =\n initBody !== null\n ? initBody\n : fromRequest && fromRequest.body !== null\n ? await fromRequest.clone().arrayBuffer()\n : null;\n return {\n method: (init?.method ?? fromRequest?.method ?? \"GET\").toUpperCase(),\n url: new URL(fromRequest ? fromRequest.url : String(input), pageOrigin()),\n headers,\n body,\n signal: init?.signal ?? fromRequest?.signal ?? undefined,\n transport: \"fetch\",\n forward: () => originalFetch(input, init),\n };\n};\n\nconst bodySize = (body: BodyInit | null): number => {\n if (body === null) return 0;\n if (typeof body === \"string\") return new TextEncoder().encode(body).byteLength;\n if (typeof Blob !== \"undefined\" && body instanceof Blob) return body.size;\n if (body instanceof ArrayBuffer) return body.byteLength;\n if (ArrayBuffer.isView(body)) return body.byteLength;\n return 0;\n};\n\nconst invalidState = (message: string) => new DOMException(message, \"InvalidStateError\");\n\n/** Builds the `XMLHttpRequest` class an install puts on the page: every request goes to `handle`. */\nconst createInterceptedXMLHttpRequest = (handle: InterceptedRequestHandler, originalFetch: typeof fetch) =>\n class InterceptedXMLHttpRequest extends EventTarget {\n static readonly UNSENT = 0;\n static readonly OPENED = 1;\n static readonly HEADERS_RECEIVED = 2;\n static readonly LOADING = 3;\n static readonly DONE = 4;\n readonly UNSENT = 0;\n readonly OPENED = 1;\n readonly HEADERS_RECEIVED = 2;\n readonly LOADING = 3;\n readonly DONE = 4;\n\n readyState = 0;\n status = 0;\n statusText = \"\";\n responseURL = \"\";\n responseType: XMLHttpRequestResponseType = \"\";\n timeout = 0;\n withCredentials = false;\n readonly upload = new InterceptedXMLHttpRequestUpload();\n readonly responseXML = null;\n\n onreadystatechange: XhrEventHandler = null;\n onloadstart: XhrEventHandler = null;\n onprogress: XhrEventHandler = null;\n onload: XhrEventHandler = null;\n onerror: XhrEventHandler = null;\n onabort: XhrEventHandler = null;\n ontimeout: XhrEventHandler = null;\n onloadend: XhrEventHandler = null;\n\n protected method = \"GET\";\n protected requestUrl = \"\";\n protected requestHeaders = new Headers();\n protected responseHeaders = new Headers();\n protected responseValue: unknown = \"\";\n protected responseTextValue = \"\";\n protected sent = false;\n protected settled = false;\n protected controller: AbortController | undefined;\n protected timer: ReturnType<typeof setTimeout> | undefined;\n\n get response(): unknown {\n if (this.responseType === \"\" || this.responseType === \"text\") return this.responseText;\n return this.readyState === 4 ? this.responseValue : null;\n }\n\n get responseText(): string {\n if (this.responseType !== \"\" && this.responseType !== \"text\") {\n throw invalidState(`responseText is not available for responseType \"${this.responseType}\"`);\n }\n return this.readyState >= 3 ? this.responseTextValue : \"\";\n }\n\n open(method: string, url: string | URL) {\n // A running request is dropped without events, as a browser does.\n if (this.sent && !this.settled) this.settle();\n this.controller?.abort();\n this.controller = undefined;\n this.method = method.toUpperCase();\n this.requestUrl = String(url);\n this.requestHeaders = new Headers();\n this.responseHeaders = new Headers();\n this.responseValue = \"\";\n this.responseTextValue = \"\";\n this.status = 0;\n this.statusText = \"\";\n this.responseURL = \"\";\n this.sent = false;\n this.settled = false;\n this.setReadyState(1);\n }\n\n setRequestHeader(name: string, value: string) {\n if (this.readyState !== 1 || this.sent) throw invalidState(\"setRequestHeader needs an opened, unsent request\");\n this.requestHeaders.append(name, value);\n }\n\n overrideMimeType() {}\n\n getAllResponseHeaders(): string {\n if (this.readyState < 2) return \"\";\n let lines = \"\";\n this.responseHeaders.forEach((value, name) => {\n lines += `${name}: ${value}\\r\\n`;\n });\n return lines;\n }\n\n getResponseHeader(name: string): string | null {\n return this.readyState < 2 ? null : this.responseHeaders.get(name);\n }\n\n send(body?: Document | XMLHttpRequestBodyInit | null) {\n if (this.readyState !== 1 || this.sent) throw invalidState(\"send needs an opened, unsent request\");\n this.sent = true;\n const controller = new AbortController();\n this.controller = controller;\n const passedBody = body === undefined || body === null ? null : (body as BodyInit);\n // A browser sends no body with a GET or HEAD; the handler still sees what the client passed.\n const requestBody = this.method === \"GET\" || this.method === \"HEAD\" ? null : passedBody;\n const headers = new Headers(this.requestHeaders);\n const url = new URL(this.requestUrl, pageOrigin());\n const credentials: RequestCredentials = this.withCredentials ? \"include\" : \"same-origin\";\n const method = this.method;\n const request: InterceptedRequest = {\n method,\n url,\n headers,\n body: passedBody,\n signal: controller.signal,\n transport: \"xhr\",\n forward: () =>\n originalFetch(url.href, {\n method,\n headers: new Headers(headers),\n body: requestBody,\n credentials,\n signal: controller.signal,\n }),\n };\n const responseUrl = url.href;\n if (this.timeout > 0) this.timer = setTimeout(() => this.finishWithoutResponse(\"timeout\"), this.timeout);\n this.emit(\"loadstart\");\n const size = bodySize(requestBody);\n if (requestBody !== null) {\n this.upload.emit(\"loadstart\", 0, size);\n this.upload.emit(\"progress\", size, size);\n this.upload.emit(\"load\", size, size);\n this.upload.emit(\"loadend\", size, size);\n }\n Promise.resolve()\n .then(() => handle(request))\n .then(\n (response) => this.receive(controller, response, responseUrl),\n () => {\n if (this.controller === controller) this.finishWithoutResponse(\"error\");\n },\n );\n }\n\n abort() {\n if (!this.sent || this.settled) return;\n this.finishWithoutResponse(\"abort\");\n this.readyState = 0;\n }\n\n protected async receive(controller: AbortController, response: Response, responseUrl: string) {\n if (this.controller !== controller || this.settled) return;\n try {\n this.status = response.status;\n this.statusText = response.statusText;\n this.responseURL = responseUrl;\n this.responseHeaders = new Headers(response.headers);\n this.setReadyState(2);\n const value = await this.readBody(response);\n if (this.controller !== controller || this.settled) return;\n this.responseValue = value;\n this.setReadyState(3);\n const size = typeof this.responseTextValue === \"string\" ? this.responseTextValue.length : 0;\n this.emit(\"progress\", size, size);\n this.settle();\n this.setReadyState(4);\n this.emit(\"load\", size, size);\n this.emit(\"loadend\", size, size);\n } catch {\n if (this.controller === controller && !this.settled) this.finishWithoutResponse(\"error\");\n }\n }\n\n protected async readBody(response: Response): Promise<unknown> {\n switch (this.responseType) {\n case \"json\": {\n const text = await response.text();\n this.responseTextValue = text;\n try {\n return text === \"\" ? null : JSON.parse(text);\n } catch {\n return null;\n }\n }\n case \"blob\":\n return response.blob();\n case \"arraybuffer\":\n return response.arrayBuffer();\n case \"document\":\n return null;\n default: {\n const text = await response.text();\n this.responseTextValue = text;\n return text;\n }\n }\n }\n\n /** A request that ends without a response — an error, an abort or a timeout: status 0, nothing of a body. */\n protected finishWithoutResponse(type: \"error\" | \"abort\" | \"timeout\") {\n if (this.settled) return;\n this.settle();\n this.controller?.abort();\n this.status = 0;\n this.statusText = \"\";\n this.responseHeaders = new Headers();\n this.responseValue = null;\n this.responseTextValue = \"\";\n this.setReadyState(4);\n this.emit(type);\n this.emit(\"loadend\");\n }\n\n protected settle() {\n this.settled = true;\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = undefined;\n }\n\n protected setReadyState(state: number) {\n this.readyState = state;\n this.emit(\"readystatechange\");\n }\n\n protected emit(type: XhrEventName, loaded = 0, total = 0) {\n const event = type === \"readystatechange\" ? new Event(type) : createProgressEvent(type, loaded, total);\n this.dispatchEvent(event);\n (this[`on${type}` as keyof this] as XhrEventHandler)?.call(this, event);\n }\n };\n\ntype GlobalScope = { fetch?: typeof fetch; XMLHttpRequest?: typeof XMLHttpRequest };\n\n/** The scopes that carry the page's `fetch` and `XMLHttpRequest` (the window and the global object, once each). */\nconst globalScopes = (): GlobalScope[] => {\n const scopes: GlobalScope[] = [globalThis as GlobalScope];\n if (typeof window !== \"undefined\" && (window as unknown) !== globalThis) scopes.push(window as GlobalScope);\n return scopes;\n};\n\n/** The page's `fetch` as it is now (the window's), callable after an install replaced it. */\nconst capturePageFetch = (): typeof fetch => {\n const pageFetch = (typeof window !== \"undefined\" ? window.fetch : globalThis.fetch) as typeof fetch;\n return (input, init) => pageFetch.call(globalThis, input, init);\n};\n\n/** Puts `value` on every global scope under `name` until the returned function restores what was there. */\nconst replaceGlobal = <Name extends keyof GlobalScope>(name: Name, value: GlobalScope[Name]): (() => void) => {\n const saved = globalScopes().map((scope) => ({ scope, value: scope[name] }));\n for (const { scope } of saved) scope[name] = value;\n return () => {\n for (const entry of saved) entry.scope[name] = entry.value;\n };\n};\n\n/**\n * Replaces `XMLHttpRequest` on the page until the returned function is called; `fetch` stays as it is. A handler's\n * `forward()` goes through the page's `fetch` as it was at the install.\n */\nexport const interceptXMLHttpRequests = (handle: InterceptedRequestHandler): (() => void) =>\n replaceGlobal(\n \"XMLHttpRequest\",\n createInterceptedXMLHttpRequest(handle, capturePageFetch()) as unknown as typeof XMLHttpRequest,\n );\n\n/** Replaces `fetch` on the page until the returned function is called; `XMLHttpRequest` stays as it is. */\nexport const interceptFetchRequests = (handle: InterceptedRequestHandler): (() => void) => {\n const originalFetch = capturePageFetch();\n const interceptedFetch = async (input: FetchInput, init?: RequestInit): Promise<Response> =>\n handle(await readFetchRequest(input, init, originalFetch));\n return replaceGlobal(\"fetch\", interceptedFetch as typeof fetch);\n};\n\n/**\n * A `fetch` input this realm's `Request` constructor reads correctly: a `Request` of another realm becomes one of this\n * realm with the same URL, method, headers, body and signal; anything else is returned as it is.\n */\nexport const toSameRealmFetchInput = async (input: FetchInput): Promise<FetchInput> => {\n if (!isFetchRequest(input) || (input as unknown) instanceof Request) return input;\n const foreign: Request = input;\n const body = foreign.body !== null ? await foreign.clone().arrayBuffer() : null;\n return new Request(foreign.url, {\n method: foreign.method,\n headers: new Headers(foreign.headers),\n body,\n // A signal of another realm is not accepted by this realm's constructor.\n signal: foreign.signal instanceof AbortSignal ? foreign.signal : undefined,\n });\n};\n"],"names":[],"mappings":";;AAIO,MAAM,qCAAqC;AAS3C,MAAM,sCAAsC,MAAgB;AAAA,EACjE;AAAA,EACA,IAAI,wBAAA,EAA0B,6BAA6B,CAAA,GAAI;AAAA,IAC7D,CAAC,cAAc,cAAc;AAAA,EAAA;AAEjC;AAGO,MAAM,8BAA8B,CAAC,cAAsD;AAChG,QAAM,gBAAgB;AACtB,aAAW,cAAc,oCAAA,EAAuC,eAAc,UAAU,IAAI;AAC9F;AAMO,MAAM,2BAA2B,MAAwC;AAC9E,QAAM,gBAAgB;AACtB,QAAM,mBAAmB,oCAAA,EACtB,IAAI,CAAC,eAAe,cAAc,UAAU,CAAC,EAC7C,OAAO,CAAC,WAA2C,WAAW,UAAa,WAAW,IAAI;AAC7F,SAAO,iBAAiB,KAAK,CAAC,WAAW,OAAO,UAAU,QAAQ,KAAK,iBAAiB,CAAC;AAC3F;AC/BO,MAAM,sBAAsB,CAAC,MAAc,QAAgB,UAChE,OAAO,kBAAkB,aACrB,IAAI,cAAc,MAAM,EAAE,kBAAkB,QAAQ,G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B,cAAc,QAAQ,SAAS;AAAA,EAAA,CAClE;AACH;"}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { s as sameCanvasIdentity, j as canvasBehaviourOf } from "./WebSearchResultsConversationWidget-W7O1fBB0.js";
2
+ import { s as sameCanvasIdentity, j as canvasBehaviourOf } from "./WebSearchResultsConversationWidget-CUtKAdMM.js";
3
3
  const ACCEPT = { kind: "accept" };
4
4
  const ignore = (reason) => ({ kind: "ignore", reason });
5
5
  const decideCanvasOpen = (behaviour, openCanvas, lastClosedCanvas, request) => {
@@ -84,4 +84,4 @@ export {
84
84
  applySetCanvasCreatedEntityId as e,
85
85
  decideCanvasOpen as f
86
86
  };
87
- //# sourceMappingURL=canvas-reducers-DDg9T7t8.js.map
87
+ //# sourceMappingURL=canvas-reducers-CAtcbD4i.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-reducers-DDg9T7t8.js","sources":["../../src/renderer/canvas/decide-canvas-open.ts","../../src/renderer/canvas/canvas-reducers.ts"],"sourcesContent":["import type { CanvasBehaviour } from \"./canvas-behaviours\";\nimport { CanvasOpenRequest, CanvasState, LastClosedCanvas, sameCanvasIdentity } from \"./canvas-state\";\n\n/**\n * Why an open request is ignored. Every reason is a sentence the shell could log:\n * - `unknownCanvas` no behaviour is declared for the id (a stale stored pointer, a typo)\n * - `noSurface` the host renders no split (`disableSplitView`), so there is nowhere to open\n * - `replay` a delivery-origin request for a message that was NOT just delivered — history\n * replay, a reload, scroll-back; rejected BEFORE anything is read or written\n * - `alreadyOpen` a delivery-origin request for the identity that is already open (the agent re-emits\n * an editor widget after a rebuild) — the open canvas is kept, never remounted\n * - `customerClosedIt` the customer closed exactly this identity and nothing has cleared the veto yet\n * - `noTakeoverOnNarrowViewport` a live delivery on a narrow viewport of a canvas that declares no overlay — the\n * card stays, the customer taps it\n */\nexport type CanvasOpenIgnoreReason =\n | \"unknownCanvas\"\n | \"noSurface\"\n | \"replay\"\n | \"alreadyOpen\"\n | \"customerClosedIt\"\n | \"noTakeoverOnNarrowViewport\";\n\nexport type CanvasOpenDecision =\n | { readonly kind: \"accept\" }\n | { readonly kind: \"ignore\"; readonly reason: CanvasOpenIgnoreReason };\n\nconst ACCEPT: CanvasOpenDecision = { kind: \"accept\" };\n\nconst ignore = (reason: CanvasOpenIgnoreReason): CanvasOpenDecision => ({ kind: \"ignore\", reason });\n\n/**\n * THE opening rule — the one place that answers \"may this canvas open now?\". Pure: it reads the behaviour, the open\n * canvas, the last closed one and the request, and returns Accept or Ignore. It never mutates; the reducer\n * (`canvas-reducers.ts`) applies an Accept. There is no merge rung: the same identity opened again from a card click\n * is a fresh Accept (remount), and the refresh contract of a pinned work surface is a value the body derives from the\n * message list, not a reducer merge.\n *\n * A `widgetClick`, an `openedByPage` and a `restoredAfterReload` request always open (the customer, the page or the\n * stored pointer decided); only `deliveredInMessage` is judged.\n */\nexport const decideCanvasOpen = (\n behaviour: CanvasBehaviour | undefined,\n openCanvas: CanvasState | null,\n lastClosedCanvas: LastClosedCanvas | null,\n request: CanvasOpenRequest,\n): CanvasOpenDecision => {\n if (behaviour === undefined) return ignore(\"unknownCanvas\");\n if (!request.hostHasCanvasSurface) return ignore(\"noSurface\");\n if (request.origin !== \"deliveredInMessage\") return ACCEPT;\n\n // Replay is rejected first: a replayed message must not touch the open canvas in any way.\n if (!request.justDelivered) return ignore(\"replay\");\n if (openCanvas !== null && sameCanvasIdentity(openCanvas, request)) return ignore(\"alreadyOpen\");\n if (lastClosedCanvas !== null && lastClosedCanvas.closedByCustomer && sameCanvasIdentity(lastClosedCanvas, request)) {\n return ignore(\"customerClosedIt\");\n }\n if (!request.viewportViable && behaviour.narrowViewport === \"none\") return ignore(\"noTakeoverOnNarrowViewport\");\n return ACCEPT;\n};\n","import { canvasBehaviourOf } from \"./canvas-behaviours\";\nimport { CanvasOpenRequest, CanvasState, LastClosedCanvas, sameCanvasIdentity } from \"./canvas-state\";\nimport { CanvasOpenDecision, decideCanvasOpen } from \"./decide-canvas-open\";\n\n/**\n * The canvas part of a chat slice partition — the two fields every transition reads and writes. Both chat doors carry\n * them (`ConversationState`); the shell is shared, so the state must have the same shape in both partitions.\n */\nexport interface CanvasSliceState {\n canvas: CanvasState | null;\n lastClosedCanvas: LastClosedCanvas | null;\n /**\n * How many canvases this partition has mounted so far — the source of `mountGeneration`. Never reset by a close,\n * a send or a clear (and exempt from `resetState`), so a late asynchronous write from a body that was replaced,\n * cleared or belonged to the previous conversation can never match a new canvas's generation.\n */\n canvasMountCount: number;\n}\n\n/**\n * The lifetime state machine as REDUCERS. Hand-written, not generated setters:\n * a generated setter is a blind overwrite of a snapshot the caller read a render earlier, and two opens in one commit\n * would both see the same stale state. Each function mutates the Immer draft it receives and returns the decision it\n * applied, so the slice can expose them as case reducers and a spec can assert every transition on a plain object.\n */\n\nconst toLastClosed = (canvas: CanvasState, closedByCustomer: boolean): LastClosedCanvas => ({\n canvasId: canvas.canvasId,\n instanceId: canvas.instanceId,\n anchor: canvas.anchor,\n mountGeneration: canvas.mountGeneration,\n closedByCustomer,\n ...(canvas.createdEntityId !== undefined ? { createdEntityId: canvas.createdEntityId } : {}),\n});\n\n/** Next render key: strictly increasing for the partition's lifetime, so no two mounts ever share a generation. */\nconst nextMountGeneration = (state: CanvasSliceState): number => {\n state.canvasMountCount += 1;\n return state.canvasMountCount;\n};\n\n/**\n * Open a canvas — the ONE way to open, for all four origins. On Accept: the replaced canvas (a different identity)\n * becomes `lastClosedCanvas`; a `lastClosedCanvas` of the accepted identity is consumed (its veto is cleared — the\n * customer, the page or the restore decided to have it back); the created entity survives a re-open of the same\n * identity so a restored editor keeps its draft.\n */\nexport const applyOpenCanvas = (state: CanvasSliceState, request: CanvasOpenRequest): CanvasOpenDecision => {\n const decision = decideCanvasOpen(canvasBehaviourOf(request.canvasId), state.canvas, state.lastClosedCanvas, request);\n if (decision.kind === \"ignore\") return decision;\n\n const previous = state.canvas;\n const mountGeneration = nextMountGeneration(state);\n const carriedCreatedEntityId =\n request.createdEntityId ??\n (previous !== null && sameCanvasIdentity(previous, request) ? previous.createdEntityId : undefined) ??\n (state.lastClosedCanvas !== null && sameCanvasIdentity(state.lastClosedCanvas, request)\n ? state.lastClosedCanvas.createdEntityId\n : undefined);\n\n if (previous !== null && !sameCanvasIdentity(previous, request)) {\n state.lastClosedCanvas = toLastClosed(previous, false);\n } else if (state.lastClosedCanvas !== null && sameCanvasIdentity(state.lastClosedCanvas, request)) {\n state.lastClosedCanvas = null;\n }\n state.canvas = {\n canvasId: request.canvasId,\n instanceId: request.instanceId,\n anchor: request.anchor,\n origin: request.origin,\n mountGeneration,\n ...(carriedCreatedEntityId !== undefined ? { createdEntityId: carriedCreatedEntityId } : {}),\n };\n return decision;\n};\n\n/**\n * Close the open canvas but keep it re-openable: it becomes `lastClosedCanvas`. `byCustomer` marks the customer's own\n * close (the canvas close control) — a live delivery of the same identity is then ignored until a send, a card click\n * or a page hand-over. A shell-driven close (compact mode, the side panel opening, a narrow crossing) passes false.\n */\nexport const applyCloseCanvas = (state: CanvasSliceState, byCustomer: boolean): void => {\n if (state.canvas === null) return;\n state.lastClosedCanvas = toLastClosed(state.canvas, byCustomer);\n state.canvas = null;\n};\n\n/**\n * The SEND boundary: a new user message starts a new turn. A `turn` canvas is over for good — it leaves the open slot\n * AND `lastClosedCanvas` (the card in the transcript is the way back). A `pinned` canvas stays open,\n * and a closed pinned one stays re-openable with its customer veto cleared (the send is a clearing edge).\n */\nexport const applyResetCanvasForNewTurn = (state: CanvasSliceState): void => {\n if (state.canvas !== null && canvasBehaviourOf(state.canvas.canvasId)?.lifetime === \"turn\") {\n state.canvas = null;\n }\n if (state.lastClosedCanvas !== null) {\n if (canvasBehaviourOf(state.lastClosedCanvas.canvasId)?.lifetime === \"turn\") {\n state.lastClosedCanvas = null;\n } else if (state.lastClosedCanvas.closedByCustomer) {\n state.lastClosedCanvas = { ...state.lastClosedCanvas, closedByCustomer: false };\n }\n }\n};\n\n/** Forget the canvas entirely — a conversation switch, `closeAgent`, the modal unmount. Nothing is re-openable. */\nexport const applyClearCanvas = (state: CanvasSliceState): void => {\n state.canvas = null;\n state.lastClosedCanvas = null;\n};\n\nexport interface CanvasCreatedEntity {\n readonly canvasId: CanvasState[\"canvasId\"];\n readonly instanceId: string;\n /** The generation the body was mounted with — a late write from a body that was replaced meanwhile is dropped. */\n readonly mountGeneration: number;\n readonly createdEntityId: number;\n}\n\n/** A body created its entity (the post editor's draft): remember the id on the canvas it was created for. */\nexport const applySetCanvasCreatedEntityId = (state: CanvasSliceState, created: CanvasCreatedEntity): boolean => {\n const canvas = state.canvas;\n if (canvas === null || !sameCanvasIdentity(canvas, created) || canvas.mountGeneration !== created.mountGeneration) {\n return false;\n }\n state.canvas = { ...canvas, createdEntityId: created.createdEntityId };\n return true;\n};\n"],"names":[],"mappings":";;AA2BA,MAAM,SAA6B,EAAE,MAAM,SAAA;AAE3C,MAAM,SAAS,CAAC,YAAwD,EAAE,MAAM,UAAU,OAAA;AAYnF,MAAM,mBAAmB,CAC9B,WACA,YACA,kBACA,YACuB;AACvB,MAAI,cAAc,OAAW,QAAO,OAAO,eAAe;AAC1D,MAAI,CAAC,QAAQ,qBAAsB,QAAO,OAAO,WAAW;AAC5D,MAAI,QAAQ,WAAW,qBAAsB,QAAO;AAGpD,MAAI,CAAC,QAAQ,cAAe,QAAO,OAAO,QAAQ;AAClD,MAAI,eAAe,QAAQ,mBAAmB,YAAY,OAAO,EAAG,QAAO,OAAO,aAAa;AAC/F,MAAI,qBAAqB,QAAQ,iBAAiB,oBAAoB,mBAAmB,kBAAkB,OAAO,GAAG;AACnH,WAAO,OAAO,kBAAkB;AAAA,EAClC;AACA,MAAI,CAAC,QAAQ,kBAAkB,UAAU,mBAAmB,OAAQ,QAAO,OAAO,4BAA4B;AAC9G,SAAO;AACT;ACjCA,MAAM,eAAe,CAAC,QAAqB,sBAAiD;AAAA,EAC1F,UAAU,OAAO;AAAA,EACjB,YAAY,OAAO;AAAA,EACnB,QAAQ,OAAO;AAAA,EACf,iBA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AAM,OAAO,QAAQ,GAAG,aAAa,QAAQ;AAC1F,UAAM,SAAS;AAAA,EACjB;AACA,MAAI,MAAM,qBAAqB,MAAM;AACnC,QAAI,kBAAkB,MAAM,iBAAiB,QAAQ,GAAG,aAAa,QAAQ;AAC3E,YAAM,mBAAmB;AAAA,IAC3B,WAAW,MAAM,iBAAiB,kBAAkB;AAClD,YAAM,mBAAmB,EAAE,GAAG,MAAM,kBAAkB,kBAAkB,MAAA;AAAA,IAC1E;AAAA,EACF;AACF;AAGO,MAAM,mBAAmB,CAAC,UAAkC;AACjE,QAAM,SAAS;AACf,QAAM,mBAAmB;AAC3B;AAWO,MAAM,gCAAgC,CAAC,OAAyB,YAA0C;AAC/G,QAAM,SAAS,MAAM;AACrB,MAAI,WAAW,QAAQ,CAAC,mBAAmB,QAAQ,OAAO,KAAK,OAAO,oBAAoB,QAAQ,iBAAiB;AACjH,WAAO;AAAA,EACT;AACA,QAAM,SAAS,EAAE,GAAG,QAAQ,iBAAiB,QAAQ,gBAAA;AACrD,SAAO;AACT;"}
1
+ {"version":3,"file":"canvas-reducers-CAtcbD4i.js","sources":["../../src/renderer/canvas/decide-canvas-open.ts","../../src/renderer/canvas/canvas-reducers.ts"],"sourcesContent":["import type { CanvasBehaviour } from \"./canvas-behaviours\";\nimport { CanvasOpenRequest, CanvasState, LastClosedCanvas, sameCanvasIdentity } from \"./canvas-state\";\n\n/**\n * Why an open request is ignored. Every reason is a sentence the shell could log:\n * - `unknownCanvas` no behaviour is declared for the id (a stale stored pointer, a typo)\n * - `noSurface` the host renders no split (`disableSplitView`), so there is nowhere to open\n * - `replay` a delivery-origin request for a message that was NOT just delivered — history\n * replay, a reload, scroll-back; rejected BEFORE anything is read or written\n * - `alreadyOpen` a delivery-origin request for the identity that is already open (the agent re-emits\n * an editor widget after a rebuild) — the open canvas is kept, never remounted\n * - `customerClosedIt` the customer closed exactly this identity and nothing has cleared the veto yet\n * - `noTakeoverOnNarrowViewport` a live delivery on a narrow viewport of a canvas that declares no overlay — the\n * card stays, the customer taps it\n */\nexport type CanvasOpenIgnoreReason =\n | \"unknownCanvas\"\n | \"noSurface\"\n | \"replay\"\n | \"alreadyOpen\"\n | \"customerClosedIt\"\n | \"noTakeoverOnNarrowViewport\";\n\nexport type CanvasOpenDecision =\n | { readonly kind: \"accept\" }\n | { readonly kind: \"ignore\"; readonly reason: CanvasOpenIgnoreReason };\n\nconst ACCEPT: CanvasOpenDecision = { kind: \"accept\" };\n\nconst ignore = (reason: CanvasOpenIgnoreReason): CanvasOpenDecision => ({ kind: \"ignore\", reason });\n\n/**\n * THE opening rule — the one place that answers \"may this canvas open now?\". Pure: it reads the behaviour, the open\n * canvas, the last closed one and the request, and returns Accept or Ignore. It never mutates; the reducer\n * (`canvas-reducers.ts`) applies an Accept. There is no merge rung: the same identity opened again from a card click\n * is a fresh Accept (remount), and the refresh contract of a pinned work surface is a value the body derives from the\n * message list, not a reducer merge.\n *\n * A `widgetClick`, an `openedByPage` and a `restoredAfterReload` request always open (the customer, the page or the\n * stored pointer decided); only `deliveredInMessage` is judged.\n */\nexport const decideCanvasOpen = (\n behaviour: CanvasBehaviour | undefined,\n openCanvas: CanvasState | null,\n lastClosedCanvas: LastClosedCanvas | null,\n request: CanvasOpenRequest,\n): CanvasOpenDecision => {\n if (behaviour === undefined) return ignore(\"unknownCanvas\");\n if (!request.hostHasCanvasSurface) return ignore(\"noSurface\");\n if (request.origin !== \"deliveredInMessage\") return ACCEPT;\n\n // Replay is rejected first: a replayed message must not touch the open canvas in any way.\n if (!request.justDelivered) return ignore(\"replay\");\n if (openCanvas !== null && sameCanvasIdentity(openCanvas, request)) return ignore(\"alreadyOpen\");\n if (lastClosedCanvas !== null && lastClosedCanvas.closedByCustomer && sameCanvasIdentity(lastClosedCanvas, request)) {\n return ignore(\"customerClosedIt\");\n }\n if (!request.viewportViable && behaviour.narrowViewport === \"none\") return ignore(\"noTakeoverOnNarrowViewport\");\n return ACCEPT;\n};\n","import { canvasBehaviourOf } from \"./canvas-behaviours\";\nimport { CanvasOpenRequest, CanvasState, LastClosedCanvas, sameCanvasIdentity } from \"./canvas-state\";\nimport { CanvasOpenDecision, decideCanvasOpen } from \"./decide-canvas-open\";\n\n/**\n * The canvas part of a chat slice partition — the two fields every transition reads and writes. Both chat doors carry\n * them (`ConversationState`); the shell is shared, so the state must have the same shape in both partitions.\n */\nexport interface CanvasSliceState {\n canvas: CanvasState | null;\n lastClosedCanvas: LastClosedCanvas | null;\n /**\n * How many canvases this partition has mounted so far — the source of `mountGeneration`. Never reset by a close,\n * a send or a clear (and exempt from `resetState`), so a late asynchronous write from a body that was replaced,\n * cleared or belonged to the previous conversation can never match a new canvas's generation.\n */\n canvasMountCount: number;\n}\n\n/**\n * The lifetime state machine as REDUCERS. Hand-written, not generated setters:\n * a generated setter is a blind overwrite of a snapshot the caller read a render earlier, and two opens in one commit\n * would both see the same stale state. Each function mutates the Immer draft it receives and returns the decision it\n * applied, so the slice can expose them as case reducers and a spec can assert every transition on a plain object.\n */\n\nconst toLastClosed = (canvas: CanvasState, closedByCustomer: boolean): LastClosedCanvas => ({\n canvasId: canvas.canvasId,\n instanceId: canvas.instanceId,\n anchor: canvas.anchor,\n mountGeneration: canvas.mountGeneration,\n closedByCustomer,\n ...(canvas.createdEntityId !== undefined ? { createdEntityId: canvas.createdEntityId } : {}),\n});\n\n/** Next render key: strictly increasing for the partition's lifetime, so no two mounts ever share a generation. */\nconst nextMountGeneration = (state: CanvasSliceState): number => {\n state.canvasMountCount += 1;\n return state.canvasMountCount;\n};\n\n/**\n * Open a canvas — the ONE way to open, for all four origins. On Accept: the replaced canvas (a different identity)\n * becomes `lastClosedCanvas`; a `lastClosedCanvas` of the accepted identity is consumed (its veto is cleared — the\n * customer, the page or the restore decided to have it back); the created entity survives a re-open of the same\n * identity so a restored editor keeps its draft.\n */\nexport const applyOpenCanvas = (state: CanvasSliceState, request: CanvasOpenRequest): CanvasOpenDecision => {\n const decision = decideCanvasOpen(canvasBehaviourOf(request.canvasId), state.canvas, state.lastClosedCanvas, request);\n if (decision.kind === \"ignore\") return decision;\n\n const previous = state.canvas;\n const mountGeneration = nextMountGeneration(state);\n const carriedCreatedEntityId =\n request.createdEntityId ??\n (previous !== null && sameCanvasIdentity(previous, request) ? previous.createdEntityId : undefined) ??\n (state.lastClosedCanvas !== null && sameCanvasIdentity(state.lastClosedCanvas, request)\n ? state.lastClosedCanvas.createdEntityId\n : undefined);\n\n if (previous !== null && !sameCanvasIdentity(previous, request)) {\n state.lastClosedCanvas = toLastClosed(previous, false);\n } else if (state.lastClosedCanvas !== null && sameCanvasIdentity(state.lastClosedCanvas, request)) {\n state.lastClosedCanvas = null;\n }\n state.canvas = {\n canvasId: request.canvasId,\n instanceId: request.instanceId,\n anchor: request.anchor,\n origin: request.origin,\n mountGeneration,\n ...(carriedCreatedEntityId !== undefined ? { createdEntityId: carriedCreatedEntityId } : {}),\n };\n return decision;\n};\n\n/**\n * Close the open canvas but keep it re-openable: it becomes `lastClosedCanvas`. `byCustomer` marks the customer's own\n * close (the canvas close control) — a live delivery of the same identity is then ignored until a send, a card click\n * or a page hand-over. A shell-driven close (compact mode, the side panel opening, a narrow crossing) passes false.\n */\nexport const applyCloseCanvas = (state: CanvasSliceState, byCustomer: boolean): void => {\n if (state.canvas === null) return;\n state.lastClosedCanvas = toLastClosed(state.canvas, byCustomer);\n state.canvas = null;\n};\n\n/**\n * The SEND boundary: a new user message starts a new turn. A `turn` canvas is over for good — it leaves the open slot\n * AND `lastClosedCanvas` (the card in the transcript is the way back). A `pinned` canvas stays open,\n * and a closed pinned one stays re-openable with its customer veto cleared (the send is a clearing edge).\n */\nexport const applyResetCanvasForNewTurn = (state: CanvasSliceState): void => {\n if (state.canvas !== null && canvasBehaviourOf(state.canvas.canvasId)?.lifetime === \"turn\") {\n state.canvas = null;\n }\n if (state.lastClosedCanvas !== null) {\n if (canvasBehaviourOf(state.lastClosedCanvas.canvasId)?.lifetime === \"turn\") {\n state.lastClosedCanvas = null;\n } else if (state.lastClosedCanvas.closedByCustomer) {\n state.lastClosedCanvas = { ...state.lastClosedCanvas, closedByCustomer: false };\n }\n }\n};\n\n/** Forget the canvas entirely — a conversation switch, `closeAgent`, the modal unmount. Nothing is re-openable. */\nexport const applyClearCanvas = (state: CanvasSliceState): void => {\n state.canvas = null;\n state.lastClosedCanvas = null;\n};\n\nexport interface CanvasCreatedEntity {\n readonly canvasId: CanvasState[\"canvasId\"];\n readonly instanceId: string;\n /** The generation the body was mounted with — a late write from a body that was replaced meanwhile is dropped. */\n readonly mountGeneration: number;\n readonly createdEntityId: number;\n}\n\n/** A body created its entity (the post editor's draft): remember the id on the canvas it was created for. */\nexport const applySetCanvasCreatedEntityId = (state: CanvasSliceState, created: CanvasCreatedEntity): boolean => {\n const canvas = state.canvas;\n if (canvas === null || !sameCanvasIdentity(canvas, created) || canvas.mountGeneration !== created.mountGeneration) {\n return false;\n }\n state.canvas = { ...canvas, createdEntityId: created.createdEntityId };\n return true;\n};\n"],"names":[],"mappings":";;AA2BA,MAAM,SAA6B,EAAE,MAAM,SAAA;AAE3C,MAAM,SAAS,CAAC,YAAwD,EAAE,MAAM,UAAU,OAAA;AAYnF,MAAM,mBAAmB,CAC9B,WACA,YACA,kBACA,YACuB;AACvB,MAAI,cAAc,OAAW,QAAO,OAAO,eAAe;AAC1D,MAAI,CAAC,QAAQ,qBAAsB,QAAO,OAAO,WAAW;AAC5D,MAAI,QAAQ,WAAW,qBAAsB,QAAO;AAGpD,MAAI,CAAC,QAAQ,cAAe,QAAO,OAAO,QAAQ;AAClD,MAAI,eAAe,QAAQ,mBAAmB,YAAY,OAAO,EAAG,QAAO,OAAO,aAAa;AAC/F,MAAI,qBAAqB,QAAQ,iBAAiB,oBAAoB,mBAAmB,kBAAkB,OAAO,GAAG;AACnH,WAAO,OAAO,kBAAkB;AAAA,EAClC;AACA,MAAI,CAAC,QAAQ,kBAAkB,UAAU,mBAAmB,OAAQ,QAAO,OAAO,4BAA4B;AAC9G,SAAO;AACT;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B,aAAa,MAAM,QAAQ,UAAU;AAC9D,QAAM,SAAS;AACjB;AAOO,MAAM,6BAA6B,CAAC,UAAkC;AAC3E,MAAI,MAAM,WAAW,QAAQ,kBAAkB,MAAM,OAAO,QAAQ,GAAG,aAAa,QAAQ;AAC1F,UAAM,SAAS;AAAA,EACjB;AACA,MAAI,MAAM,qBAAqB,MAAM;AACnC,QAAI,kBAAkB,MAAM,iBAAiB,QAAQ,GAAG,aAAa,QAAQ;AAC3E,YAAM,mBAAmB;AAAA,IAC3B,WAAW,MAAM,iBAAiB,kBAAkB;AAClD,YAAM,mBAAmB,EAAE,GAAG,MAAM,kBAAkB,kBAAkB,MAAA;AAAA,IAC1E;AAAA,EACF;AACF;AAGO,MAAM,mBAAmB,CAAC,UAAkC;AACjE,QAAM,SAAS;AACf,QAAM,mBAAmB;AAC3B;AAWO,MAAM,gCAAgC,CAAC,OAAyB,YAA0C;AAC/G,QAAM,SAAS,MAAM;AACrB,MAAI,WAAW,QAAQ,CAAC,mBAAmB,QAAQ,OAAO,KAAK,OAAO,oBAAoB,QAAQ,iBAAiB;AACjH,WAAO;AAAA,EACT;AACA,QAAM,SAAS,EAAE,GAAG,QAAQ,iBAAiB,QAAQ,gBAAA;AACrD,SAAO;AACT;"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { j as conversationWidgetRegistry } from "./widget-name-resolver-BNSfO2Aw.js";
3
- import { Q as getFurtherWidgetClickSignalSources } from "./link-navigation-BUcy5qWW.js";
2
+ import { j as conversationWidgetRegistry } from "./widget-name-resolver-akTPWt63.js";
3
+ import { Q as getFurtherWidgetClickSignalSources } from "./link-navigation-DRHt6g7U.js";
4
4
  import { createContext, useContext } from "react";
5
5
  const resolveDeepLinkableWidget = (widgetName) => {
6
6
  if (!widgetName) return null;
@@ -33,4 +33,4 @@ export {
33
33
  resolveDeepLinkableWidget as r,
34
34
  useCanvasTitleSlot as u
35
35
  };
36
- //# sourceMappingURL=canvas-title-slot-context-8HUvNDuc.js.map
36
+ //# sourceMappingURL=canvas-title-slot-context-rl94V4u4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-title-slot-context-8HUvNDuc.js","sources":["../../src/renderer/resolve-deep-linkable-widget.ts","../../src/renderer/widget-click-signal-sources.ts","../../src/renderer/canvas/canvas-title-slot-context.ts"],"sourcesContent":["import type { CanvasId } from \"./canvas/canvas-behaviours\";\nimport { ConversationWidgetEntry, conversationWidgetRegistry } from \"./conversationWidgetRegistry\";\n\n/**\n * Resolves the widget a `?agentWidget=<name>` deep-link (or a restored pinned canvas) may mount, by its CANONICAL\n * registry wire name.\n *\n * A URL is untrusted input, so this is an allow-list rather than a registry lookup: only an entry that declares\n * `deepLinkable: true` can be opened this way. Every other widget is emitted by the agent inside a message, where the\n * conversation itself is the authorisation — a link must not be able to mount an arbitrary widget (some carry\n * mount-time side effects) just because its name was typed into the address bar.\n *\n * Returns the entry (the caller renders its `component`, applying the feature gate the entry declares) or null when the\n * name is empty, unknown, or not deep-linkable.\n */\nexport const resolveDeepLinkableWidget = (widgetName?: string | null): ConversationWidgetEntry | null => {\n if (!widgetName) return null;\n return (\n conversationWidgetRegistry.widgets.find((entry) => entry.name === widgetName && entry.deepLinkable === true) ?? null\n );\n};\n\n/**\n * The reverse direction: which deep-linkable widget re-opens THIS canvas. The open canvas of the agent chat is\n * mirrored into `?agentWidget=` (AgentTrigger) so a reload brings the customer back to the surface they were working\n * on — an editor a cold chat opened has no conversation id yet, so the canvas model's own pointer storage\n * has nothing to restore from.\n *\n * Null for every canvas no deep-linkable widget declares: it is the agent's to open inside a message, and a URL must\n * not be able to mount it (the allow-list above).\n */\nexport const deepLinkableWidgetNameForCanvas = (canvasId: CanvasId | null | undefined): string | null => {\n if (!canvasId) return null;\n return (\n conversationWidgetRegistry.widgets.find(\n (entry) => entry.deepLinkable === true && entry.opensCanvases?.includes(canvasId),\n )?.name ?? null\n );\n};\n","import { getFurtherWidgetClickSignalSources } from \"../provider/environment\";\n\n/**\n * The `signalSource`s a widget CLICK posts into the conversation (`injectSignal`): the generic widget click and the\n * dedicated source the former owner-action consent widget sent (no component posts it any more; stored rows keep it),\n * plus the further sources an app's own widgets post (`AgentsEnvironment.furtherWidgetClickSignalSources`, e.g. a form\n * submit that starts its own owner turn). The message list reads them to tell an answered widget from an open one after\n * a reload — a widget the owner already clicked must never come back interactive (a consent widget re-armed is a second\n * confirmation for a destructive tool). Add a source here when a widget of the package starts posting a new one.\n */\nexport const FRONTEND_WIDGET_CLICK_SIGNAL_SOURCE = \"FRONTEND_WIDGET_CLICK\";\nexport const OWNER_ACTION_CONFIRM_SIGNAL_SOURCE = \"OWNER_ACTION_CONFIRM\";\n\n/** The package's own widget click sources (the backend's sources of the package that carry an owner statement). */\nexport const PACKAGE_WIDGET_CLICK_SIGNAL_SOURCES: readonly string[] = [\n FRONTEND_WIDGET_CLICK_SIGNAL_SOURCE,\n OWNER_ACTION_CONFIRM_SIGNAL_SOURCE,\n];\n\n/** Every widget click source: the package's own and the app's further ones. */\nexport const getWidgetClickSignalSources = (): readonly string[] => [\n ...PACKAGE_WIDGET_CLICK_SIGNAL_SOURCES,\n ...getFurtherWidgetClickSignalSources(),\n];\n\nexport const isWidgetClickSignalSource = (signalSource: string | undefined | null): boolean =>\n signalSource != null && getWidgetClickSignalSources().includes(signalSource);\n","import { createContext, useContext } from \"react\";\n\n/**\n * The place beside the canvas pane's close button, for a canvas whose behaviour declares `titleBesideCloseButton`:\n * its body portals its title there. Null outside a canvas pane and for every other canvas.\n */\nexport const CanvasTitleSlotContext = createContext<HTMLElement | null>(null);\n\nexport const useCanvasTitleSlot = (): HTMLElement | null => useContext(CanvasTitleSlotContext);\n"],"names":[],"mappings":";;;;AAeO,MAAM,4BAA4B,CAAC,eAA+D;AACvG,MAAI,CAAC,WAAY,QAAO;AACxB,SACE,2BAA2B,QAAQ,KAAK,CAAC,UAAU,MAAM,SAAS,cAAc,MAAM,iBAAiB,IAAI,KAAK;AAEpH;AAWO,MAAM,kCAAkC,CAAC,aAAyD;AACvG,MAAI,CAAC,SAAU,QAAO;AACtB,SACE,2BAA2B,QAAQ;AAAA,IACjC,CAAC,UAAU,MAAM,iBAAiB,QAAQ,MAAM,eAAe,SAAS,QAAQ;AAAA,EAAA,GAC/E,QAAQ;AAEf;AC5BO,MAAM,sCAAsC;AAC5C,MAAM,qCAAqC;AAG3C,MAAM,sCAAyD;AAAA,EACpE;AAAA,EACA;AACF;AAGO,MAAM,8BAA8B,MAAyB;AAAA,EAClE,GAAG;AAAA,EACH,GAAG,mCAAA;AACL;AAEO,MAAM,4BAA4B,CAAC,iBACxC,gBAAgB,QAAQ,4BAAA,EAA8B,SAAS,YAAY;ACpBtE,MAAM,yBAAyB,cAAkC,IAAI;AAErE,MAAM,qBAAqB,MAA0B,WAAW,sBAAsB;"}
1
+ {"version":3,"file":"canvas-title-slot-context-rl94V4u4.js","sources":["../../src/renderer/resolve-deep-linkable-widget.ts","../../src/renderer/widget-click-signal-sources.ts","../../src/renderer/canvas/canvas-title-slot-context.ts"],"sourcesContent":["import type { CanvasId } from \"./canvas/canvas-behaviours\";\nimport { ConversationWidgetEntry, conversationWidgetRegistry } from \"./conversationWidgetRegistry\";\n\n/**\n * Resolves the widget a `?agentWidget=<name>` deep-link (or a restored pinned canvas) may mount, by its CANONICAL\n * registry wire name.\n *\n * A URL is untrusted input, so this is an allow-list rather than a registry lookup: only an entry that declares\n * `deepLinkable: true` can be opened this way. Every other widget is emitted by the agent inside a message, where the\n * conversation itself is the authorisation — a link must not be able to mount an arbitrary widget (some carry\n * mount-time side effects) just because its name was typed into the address bar.\n *\n * Returns the entry (the caller renders its `component`, applying the feature gate the entry declares) or null when the\n * name is empty, unknown, or not deep-linkable.\n */\nexport const resolveDeepLinkableWidget = (widgetName?: string | null): ConversationWidgetEntry | null => {\n if (!widgetName) return null;\n return (\n conversationWidgetRegistry.widgets.find((entry) => entry.name === widgetName && entry.deepLinkable === true) ?? null\n );\n};\n\n/**\n * The reverse direction: which deep-linkable widget re-opens THIS canvas. The open canvas of the agent chat is\n * mirrored into `?agentWidget=` (AgentTrigger) so a reload brings the customer back to the surface they were working\n * on — an editor a cold chat opened has no conversation id yet, so the canvas model's own pointer storage\n * has nothing to restore from.\n *\n * Null for every canvas no deep-linkable widget declares: it is the agent's to open inside a message, and a URL must\n * not be able to mount it (the allow-list above).\n */\nexport const deepLinkableWidgetNameForCanvas = (canvasId: CanvasId | null | undefined): string | null => {\n if (!canvasId) return null;\n return (\n conversationWidgetRegistry.widgets.find(\n (entry) => entry.deepLinkable === true && entry.opensCanvases?.includes(canvasId),\n )?.name ?? null\n );\n};\n","import { getFurtherWidgetClickSignalSources } from \"../provider/environment\";\n\n/**\n * The `signalSource`s a widget CLICK posts into the conversation (`injectSignal`): the generic widget click and the\n * dedicated source the former owner-action consent widget sent (no component posts it any more; stored rows keep it),\n * plus the further sources an app's own widgets post (`AgentsEnvironment.furtherWidgetClickSignalSources`, e.g. a form\n * submit that starts its own owner turn). The message list reads them to tell an answered widget from an open one after\n * a reload — a widget the owner already clicked must never come back interactive (a consent widget re-armed is a second\n * confirmation for a destructive tool). Add a source here when a widget of the package starts posting a new one.\n */\nexport const FRONTEND_WIDGET_CLICK_SIGNAL_SOURCE = \"FRONTEND_WIDGET_CLICK\";\nexport const OWNER_ACTION_CONFIRM_SIGNAL_SOURCE = \"OWNER_ACTION_CONFIRM\";\n\n/** The package's own widget click sources (the backend's sources of the package that carry an owner statement). */\nexport const PACKAGE_WIDGET_CLICK_SIGNAL_SOURCES: readonly string[] = [\n FRONTEND_WIDGET_CLICK_SIGNAL_SOURCE,\n OWNER_ACTION_CONFIRM_SIGNAL_SOURCE,\n];\n\n/** Every widget click source: the package's own and the app's further ones. */\nexport const getWidgetClickSignalSources = (): readonly string[] => [\n ...PACKAGE_WIDGET_CLICK_SIGNAL_SOURCES,\n ...getFurtherWidgetClickSignalSources(),\n];\n\nexport const isWidgetClickSignalSource = (signalSource: string | undefined | null): boolean =>\n signalSource != null && getWidgetClickSignalSources().includes(signalSource);\n","import { createContext, useContext } from \"react\";\n\n/**\n * The place beside the canvas pane's close button, for a canvas whose behaviour declares `titleBesideCloseButton`:\n * its body portals its title there. Null outside a canvas pane and for every other canvas.\n */\nexport const CanvasTitleSlotContext = createContext<HTMLElement | null>(null);\n\nexport const useCanvasTitleSlot = (): HTMLElement | null => useContext(CanvasTitleSlotContext);\n"],"names":[],"mappings":";;;;AAeO,MAAM,4BAA4B,CAAC,eAA+D;AACvG,MAAI,CAAC,WAAY,QAAO;AACxB,SACE,2BAA2B,QAAQ,KAAK,CAAC,UAAU,MAAM,SAAS,cAAc,MAAM,iBAAiB,IAAI,KAAK;AAEpH;AAWO,MAAM,kCAAkC,CAAC,aAAyD;AACvG,MAAI,CAAC,SAAU,QAAO;AACtB,SACE,2BAA2B,QAAQ;AAAA,IACjC,CAAC,UAAU,MAAM,iBAAiB,QAAQ,MAAM,eAAe,SAAS,QAAQ;AAAA,EAAA,GAC/E,QAAQ;AAEf;AC5BO,MAAM,sCAAsC;AAC5C,MAAM,qCAAqC;AAG3C,MAAM,sCAAyD;AAAA,EACpE;AAAA,EACA;AACF;AAGO,MAAM,8BAA8B,MAAyB;AAAA,EAClE,GAAG;AAAA,EACH,GAAG,mCAAA;AACL;AAEO,MAAM,4BAA4B,CAAC,iBACxC,gBAAgB,QAAQ,4BAAA,EAA8B,SAAS,YAAY;ACpBtE,MAAM,yBAAyB,cAAkC,IAAI;AAErE,MAAM,qBAAqB,MAA0B,WAAW,sBAAsB;"}
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useMemo, useCallback, useContext, createContext, useState } from "react";
4
- import { p as payloadHashOfInstanceId, a1 as useConversationWidgetContext, bn as parseConversationSearchResultsPayload, bo as WebSearchAnswer, bp as WebSearchSourcesList, bq as parseWebSearchResultsPayload, br as ENTITY_MENTION_WIDGET_NAME, bs as buildEntityMentionFields, bt as normalizeEntityMentionFields, bu as entityMentionKey, bv as MAX_ENTITY_MENTIONS_PER_MESSAGE, bw as toEntityMentionWireFields, a2 as useIsEmailWidgetRender, bx as ConversationWidgetButton, b2 as parseImageGalleryPayload, by as ImageGallery, aA as IMAGE_GALLERY_WIDGET_TYPE } from "./WebSearchResultsConversationWidget-W7O1fBB0.js";
5
- import { m as findWidgetFenceByPayloadHash, n as findWidgetFencesInMarkdown, K as readEntityDetailInstanceId, L as readMapNodeKeyOfInstanceId, M as findMapNodeInMarkdown, D as readOpenEntityActionTarget, N as canvasInstanceIdForEntityDetail, O as mapStyles, P as MapPresentationContext, e as ComposedViewRenderer } from "./widget-name-resolver-BNSfO2Aw.js";
6
- import { s as Text, b as ConversationSearchResultsList, a5 as useAgentsEnvironment } from "./link-navigation-BUcy5qWW.js";
4
+ import { p as payloadHashOfInstanceId, a1 as useConversationWidgetContext, bn as parseConversationSearchResultsPayload, bo as WebSearchAnswer, bp as WebSearchSourcesList, bq as parseWebSearchResultsPayload, br as ENTITY_MENTION_WIDGET_NAME, bs as buildEntityMentionFields, bt as normalizeEntityMentionFields, bu as entityMentionKey, bv as MAX_ENTITY_MENTIONS_PER_MESSAGE, bw as toEntityMentionWireFields, a2 as useIsEmailWidgetRender, bx as ConversationWidgetButton, b2 as parseImageGalleryPayload, by as ImageGallery, aA as IMAGE_GALLERY_WIDGET_TYPE } from "./WebSearchResultsConversationWidget-CUtKAdMM.js";
5
+ import { m as findWidgetFenceByPayloadHash, n as findWidgetFencesInMarkdown, K as readEntityDetailInstanceId, L as readMapNodeKeyOfInstanceId, M as findMapNodeInMarkdown, D as readOpenEntityActionTarget, N as canvasInstanceIdForEntityDetail, O as mapStyles, P as MapPresentationContext, e as ComposedViewRenderer } from "./widget-name-resolver-akTPWt63.js";
6
+ import { s as Text, b as ConversationSearchResultsList, a5 as useAgentsEnvironment } from "./link-navigation-DRHt6g7U.js";
7
7
  import { E as EntityDetailNameReportContext } from "./entity-detail-name-3A82gDAp.js";
8
8
  const useAnchorWidgetPayload = (canvas, anchorMessageMarkdown, widgetName) => useMemo(() => {
9
9
  if (canvas.anchor.kind !== "message" || anchorMessageMarkdown === null) return void 0;
@@ -309,4 +309,4 @@ export {
309
309
  registerCanvasBodies as r,
310
310
  useAnchorWidgetPayload as u
311
311
  };
312
- //# sourceMappingURL=canvasBodies-qC-A_rlz.js.map
312
+ //# sourceMappingURL=canvasBodies-C3wydcKZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvasBodies-qC-A_rlz.js","sources":["../../src/renderer/canvas/use-anchor-widget-payload.ts","../../src/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvas.tsx","../../src/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvasBody.tsx","../../src/widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvas.tsx","../../src/widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvasBody.tsx","../../src/widgets/EntityMentionConversationWidget/shared/use-entity-mention-composer.ts","../../src/widgets/EntityMentionConversationWidget/EntityMentionAskButton/EntityMentionAskButton.tsx","../../src/kit/entity-detail/entity-detail-bodies.ts","../../src/kit/entity-detail/EntityDetailCanvasBody.tsx","../../src/kit/map-full-screen/MapFullScreenCanvasBody.tsx","../../src/widgets/ImageGalleryConversationWidget/ImageGalleryCanvasBody.tsx","../../src/renderer/canvas/canvasBodies.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { CanvasState } from \"./canvas-state\";\nimport { payloadHashOfInstanceId } from \"./canvas-state\";\nimport { findWidgetFenceByPayloadHash, findWidgetFencesInMarkdown } from \"./find-widget-fences-in-markdown\";\n\n/**\n * The payload string of the widget a message-anchored canvas was opened from: the fence of `widgetName` in the anchor\n * message whose payload hash the canvas instance id carries (`canvasInstanceIdForMessagePayload`); when the instance\n * id carries no hash (one canvas per message), the first fence of that name. Undefined for a page anchor, a missing\n * anchor message, or a message that no longer carries the fence — the body then renders nothing.\n */\nexport const useAnchorWidgetPayload = (\n canvas: CanvasState,\n anchorMessageMarkdown: string | null,\n widgetName: string,\n): string | undefined =>\n useMemo(() => {\n if (canvas.anchor.kind !== \"message\" || anchorMessageMarkdown === null) return undefined;\n const payloadHash = payloadHashOfInstanceId(canvas.instanceId);\n if (payloadHash !== undefined) {\n return findWidgetFenceByPayloadHash(anchorMessageMarkdown, widgetName, payloadHash)?.payload;\n }\n return findWidgetFencesInMarkdown(anchorMessageMarkdown).find((fence) => fence.name === widgetName)?.payload;\n }, [canvas.anchor, canvas.instanceId, anchorMessageMarkdown, widgetName]);\n","import { ConversationSearchResultsList, Text } from \"../../provider/components\";\nimport React from \"react\";\nimport { parseConversationSearchResultsPayload } from \"./shared/conversation-search-results-widget-payload\";\n\ntype ConversationSearchResultsCanvasProps = {\n query: string;\n groups: ReturnType<typeof parseConversationSearchResultsPayload>[\"groups\"];\n onOpenConversation: (conversationId: number, messageId?: number) => void;\n};\n\n// Canvas body styles — the same as every list canvas body, so the full-screen panel behaves the same:\n// a full-height flex column whose inner area SCROLLS (scrollStyle: flex 1 + overflowY auto — without it the content\n// overflows the panel with no scrollbar), plus a horizontal inset (contentStyle) because the results list is built\n// for the narrow inline chat column where the bubble provides the gutter — in the canvas there is no bubble, so it would\n// otherwise render edge-to-edge.\nconst canvasStyle: React.CSSProperties = {\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n background: \"var(--agents-bg)\",\n};\nconst scrollStyle: React.CSSProperties = {\n flex: 1,\n minHeight: 0,\n overflowY: \"auto\",\n};\nconst contentStyle: React.CSSProperties = {\n padding: \"16px 24px 24px\",\n};\n\n/** The canvas body — a titled wrapper around the same grouped results, scrollable + inset like the other canvas widgets. */\nexport const ConversationSearchResultsCanvas = (props: ConversationSearchResultsCanvasProps) => (\n <div style={canvasStyle} data-testid=\"conversation-search-results-widget-canvas\">\n <div style={scrollStyle}>\n <div style={contentStyle} data-testid=\"conversation-search-results-widget-canvas-results\">\n <Text\n role=\"title\"\n replacements={{ query: props.query }}\n testId=\"conversation-search-results-widget-canvas-title\"\n >\n {'Search results for \"%query%\"'}\n </Text>\n <ConversationSearchResultsList groups={props.groups} query={props.query} onOpenConversation={props.onOpenConversation} />\n </div>\n </div>\n </div>\n);\n","import React, { useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useConversationWidgetContext } from \"../../renderer/ConversationWidgetCallbacksContext\";\nimport { useAnchorWidgetPayload } from \"../../renderer/canvas/use-anchor-widget-payload\";\nimport { parseConversationSearchResultsPayload } from \"./shared/conversation-search-results-widget-payload\";\nimport { ConversationSearchResultsCanvas } from \"./ConversationSearchResultsCanvas\";\n\n/**\n * The `conversationSearchResults` CANVAS BODY (`canvasBodies.tsx`): re-reads the `ConversationSearchResults` fence of\n * the anchor message — the same payload the inline widget rendered from — and shows the grouped results. Nothing was\n * stored for it but the pointer. Renders nothing when the anchor message no longer carries the fence.\n */\nexport const ConversationSearchResultsCanvasBody = ({ canvas, anchorMessageMarkdown }: CanvasBodyProps) => {\n const { onOpenConversation } = useConversationWidgetContext();\n const payload = useAnchorWidgetPayload(canvas, anchorMessageMarkdown, \"ConversationSearchResults\");\n const parsed = useMemo(\n () => (payload === undefined ? null : parseConversationSearchResultsPayload(payload)),\n [payload],\n );\n if (parsed === null || parsed.groups.length === 0) return null;\n return (\n <ConversationSearchResultsCanvas\n query={parsed.query}\n groups={parsed.groups}\n onOpenConversation={(conversationId, messageId) => onOpenConversation?.(conversationId, messageId)}\n />\n );\n};\n","import { Text } from \"../../provider/components\";\nimport React from \"react\";\nimport { WebSearchResultSource } from \"./shared/web-search-results-widget-payload\";\nimport { WebSearchAnswer } from \"./WebSearchAnswer\";\nimport { WebSearchSourcesList } from \"./WebSearchSourcesList\";\n\ntype WebSearchResultsCanvasProps = {\n query: string;\n answer: string;\n sources: WebSearchResultSource[];\n provider?: string;\n};\n\n// Canvas body styles — mirror the ConversationSearchResults / listReviews drawer widgets: a full-height flex column\n// whose inner area SCROLLS (flex 1 + overflowY auto) with a horizontal inset (there is no chat bubble gutter in the canvas).\nconst canvasStyle: React.CSSProperties = {\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n background: \"var(--agents-bg)\",\n};\nconst scrollStyle: React.CSSProperties = { flex: 1, minHeight: 0, overflowY: \"auto\" };\nconst contentStyle: React.CSSProperties = { padding: \"16px 24px 24px\" };\n\n/** The canvas body — the full answer + sources, scrollable + inset like the other canvas widgets. */\nexport const WebSearchResultsCanvas = (props: WebSearchResultsCanvasProps) => (\n <div style={canvasStyle} data-testid=\"web-search-results-widget-canvas\">\n <div style={scrollStyle}>\n <div style={contentStyle}>\n {props.query ? (\n <Text\n role=\"title\"\n replacements={{ query: props.query }}\n testId=\"web-search-results-widget-canvas-title\"\n >\n {'\"%query%\"'}\n </Text>\n ) : (\n <Text role=\"title\" testId=\"web-search-results-widget-canvas-title\">\n Web search\n </Text>\n )}\n <div style={{ marginTop: 12 }}>\n <WebSearchAnswer answer={props.answer} />\n </div>\n <WebSearchSourcesList\n sources={props.sources}\n provider={props.provider}\n testId=\"web-search-results-widget-canvas\"\n />\n </div>\n </div>\n </div>\n);\n","import React, { useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useAnchorWidgetPayload } from \"../../renderer/canvas/use-anchor-widget-payload\";\nimport { parseWebSearchResultsPayload } from \"./shared/web-search-results-widget-payload\";\nimport { WebSearchResultsCanvas } from \"./WebSearchResultsCanvas\";\n\n/**\n * The `webSearchResults` CANVAS BODY (`canvasBodies.tsx`): re-reads the `WebSearchResults` fence of the anchor message\n * — the answer and its cited sources the inline widget rendered from — and shows them in the canvas. Renders nothing\n * when the anchor message no longer carries the fence.\n */\nexport const WebSearchResultsCanvasBody = ({ canvas, anchorMessageMarkdown }: CanvasBodyProps) => {\n const payload = useAnchorWidgetPayload(canvas, anchorMessageMarkdown, \"WebSearchResults\");\n const parsed = useMemo(() => (payload === undefined ? null : parseWebSearchResultsPayload(payload)), [payload]);\n if (parsed === null || (parsed.answer.trim() === \"\" && parsed.sources.length === 0)) return null;\n return (\n <WebSearchResultsCanvas\n query={parsed.query}\n answer={parsed.answer}\n sources={parsed.sources}\n provider={parsed.provider}\n />\n );\n};\n","import { useCallback } from \"react\";\nimport { useConversationWidgetContext } from \"../../../renderer/ConversationWidgetCallbacksContext\";\nimport {\n buildEntityMentionFields,\n ENTITY_MENTION_WIDGET_NAME,\n entityMentionKey,\n EntityMentionTarget,\n MAX_ENTITY_MENTIONS_PER_MESSAGE,\n normalizeEntityMentionFields,\n toEntityMentionWireFields,\n} from \"./entity-mention\";\n\nexport interface UseEntityMentionComposerResult {\n /** Whether this entity is already mentioned in the composer. */\n isMentioned: (target: EntityMentionTarget) => boolean;\n /**\n * Puts the entity into the composer as an `EntityMention` chip — once per entity (a second click is a no-op); past\n * {@link MAX_ENTITY_MENTIONS_PER_MESSAGE} the new entity takes the place of the oldest mention (one write: a remove\n * and an add in one event would both read the list before either). Sends nothing: the owner writes the question.\n * Returns false for a target that names no entity.\n */\n mentionEntity: (target: EntityMentionTarget) => boolean;\n}\n\n/**\n * The opener side of the `EntityMention` composer widget: what the detail panel's \"Ask about this\"\n * button calls. Reads and writes the composer widgets of the chat's widget context; the composer strip renders them.\n */\nexport const useEntityMentionComposer = (): UseEntityMentionComposerResult => {\n const { composerWidgets, addComposerWidget, replaceComposerWidgetFields } = useConversationWidgetContext();\n\n const findMentionWidgets = useCallback(\n () => composerWidgets.filter((composerWidget) => composerWidget.widgetName === ENTITY_MENTION_WIDGET_NAME),\n [composerWidgets],\n );\n\n const isMentioned = useCallback(\n (target: EntityMentionTarget) => {\n const mention = buildEntityMentionFields(target);\n if (mention === null) return false;\n return findMentionWidgets().some((composerWidget) => {\n const heldMention = normalizeEntityMentionFields(composerWidget.fields);\n return heldMention !== null && entityMentionKey(heldMention) === entityMentionKey(mention);\n });\n },\n [findMentionWidgets],\n );\n\n const mentionEntity = useCallback(\n (target: EntityMentionTarget) => {\n const mention = buildEntityMentionFields(target);\n if (mention === null) return false;\n if (isMentioned(target)) return true;\n const mentionWidgets = findMentionWidgets();\n if (mentionWidgets.length >= MAX_ENTITY_MENTIONS_PER_MESSAGE) {\n replaceComposerWidgetFields(mentionWidgets[0].composerWidgetId, toEntityMentionWireFields(mention));\n } else {\n addComposerWidget(ENTITY_MENTION_WIDGET_NAME, toEntityMentionWireFields(mention));\n }\n return true;\n },\n [isMentioned, findMentionWidgets, replaceComposerWidgetFields, addComposerWidget],\n );\n\n return { isMentioned, mentionEntity };\n};\n","import { useIsEmailWidgetRender } from \"../../../renderer/ConversationWidgetRenderContext\";\nimport { ConversationWidgetButton } from \"../../_shared/ConversationWidgetButton\";\nimport type { EntityMentionTarget } from \"../shared/entity-mention\";\nimport { useEntityMentionComposer } from \"../shared/use-entity-mention-composer\";\n\nexport interface EntityMentionAskButtonProps extends EntityMentionTarget {\n testId?: string;\n}\n\n/**\n * The detail panel's \"Ask about this\" button (ChatGPT's \"Anschlussfrage stellen\"):\n * puts the entity into the chat input as an `EntityMention` chip and sends NOTHING — the owner writes the question,\n * the chip rides in that message as a fence, and the backend reads which entity the question is about. Not a\n * next-step CTA: it posts no prompt. A second click on the same entity changes nothing; the\n * label turns into \"Added to your message\". Mounted by the `entityDetail` canvas (the shell or a domain body) with\n * the entity the panel shows; renders nothing in the e-mail capture or for a target that names no entity.\n */\nexport const EntityMentionAskButton = (props: EntityMentionAskButtonProps) => {\n const { entityType, entityId, label, agentSpaceKey, testId = \"entity-mention-ask\" } = props;\n const isEmailRender = useIsEmailWidgetRender();\n const { isMentioned, mentionEntity } = useEntityMentionComposer();\n const target = { entityType, entityId, label, agentSpaceKey };\n if (isEmailRender) return null;\n const isAlreadyMentioned = isMentioned(target);\n return (\n <ConversationWidgetButton\n variant=\"primary\"\n size=\"medium\"\n icon={isAlreadyMentioned ? \"check\" : \"message\"}\n disabled={isAlreadyMentioned}\n onClick={() => mentionEntity(target)}\n testId={testId}\n >\n {isAlreadyMentioned ? \"Added to your message\" : \"Ask about this\"}\n </ConversationWidgetButton>\n );\n};\n","import type React from \"react\";\nimport { createContext, useContext } from \"react\";\n\n/**\n * The bodies of the `entityDetail` canvas, one per entity type: every `*.entity-detail-body.tsx` below\n * `widgets/` that exports `entityDetailBody` registers itself by folder glob — an entity type is added with\n * the backend `<Type>EntityReferenceResolver` and this one file, and edits no list. A second body for one entity type\n * is a build error (thrown at module load).\n */\n\nexport interface EntityDetailBodyProps {\n entityType: string;\n /** The id as the backend resolved it (a row id or an external id). */\n entityId: string;\n /** The key of the agent space the chat is scoped to, for a body whose read endpoint is agent-space-scoped. */\n agentSpaceKey?: number;\n}\n\nexport interface EntityDetailBodyDefinition {\n /** The backend resolver's `ENTITY_TYPE`. */\n entityType: string;\n /** Self-hydrates the entity by id through its own read endpoint (the endpoint's entity rights apply). */\n component: React.ComponentType<EntityDetailBodyProps>;\n}\n\nconst bodyModules = import.meta.glob<{ entityDetailBody?: EntityDetailBodyDefinition }>(\n [\"../../widgets/**/*.entity-detail-body.tsx\", \"../**/*.entity-detail-body.tsx\"],\n { eager: true },\n);\n\nexport const buildEntityDetailBodyRegistry = (\n definitions: EntityDetailBodyDefinition[],\n): Readonly<Record<string, EntityDetailBodyDefinition>> => {\n const registry: Record<string, EntityDetailBodyDefinition> = {};\n for (const definition of definitions) {\n if (Object.prototype.hasOwnProperty.call(registry, definition.entityType)) {\n throw new Error(`Two entity detail bodies register the entity type \"${definition.entityType}\".`);\n }\n registry[definition.entityType] = definition;\n }\n return registry;\n};\n\n/** The body definitions a set of `*.entity-detail-body.tsx` modules export (the package's or an app's glob). */\nexport const readEntityDetailBodyDefinitions = (\n modules: Record<string, { entityDetailBody?: EntityDetailBodyDefinition }>,\n): EntityDetailBodyDefinition[] =>\n Object.values(modules)\n .map((bodyModule) => bodyModule.entityDetailBody)\n .filter((definition): definition is EntityDetailBodyDefinition => definition !== undefined);\n\n/** Entity type → body: the package's folder, then what an app registers (`registerEntityDetailBodies`). */\nexport const entityDetailBodies: Record<string, EntityDetailBodyDefinition> = {\n ...buildEntityDetailBodyRegistry(readEntityDetailBodyDefinitions(bodyModules)),\n};\n\n/** Adds an app's entity detail bodies. Runs outside React, before the first render; an entity type registers once. */\nexport const registerEntityDetailBodies = (definitions: readonly EntityDetailBodyDefinition[]): void => {\n Object.assign(\n entityDetailBodies,\n buildEntityDetailBodyRegistry([...Object.values(entityDetailBodies), ...definitions]),\n );\n};\n\n/** The body registered for one entity type (the package's or an app's), or undefined when none is. */\nexport const getEntityDetailBody = (entityType: string): EntityDetailBodyDefinition | undefined =>\n Object.prototype.hasOwnProperty.call(entityDetailBodies, entityType) ? entityDetailBodies[entityType] : undefined;\n\n/** The registry the canvas body uses — the folder's by default; a spec or a story may provide stubs. */\nexport const EntityDetailBodiesContext =\n createContext<Readonly<Record<string, EntityDetailBodyDefinition>>>(entityDetailBodies);\n\nexport const useEntityDetailBodies = () => useContext(EntityDetailBodiesContext);\n","import { Text } from \"../../provider/components\";\nimport { useCallback, useState } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { readEntityDetailInstanceId } from \"../../renderer/canvas/entity-detail-instance\";\nimport { EntityMentionAskButton } from \"../../widgets/EntityMentionConversationWidget/EntityMentionAskButton/EntityMentionAskButton\";\nimport { useEntityDetailBodies } from \"./entity-detail-bodies\";\nimport { EntityDetailNameReportContext } from \"./entity-detail-name\";\nimport styles from \"./EntityDetailCanvasBody.module.scss\";\n\n/**\n * The `entityDetail` CANVAS BODY (`canvasBodies.tsx`): the shell around one entity's detail. It reads\n * WHICH entity from the canvas instance id (`entityDetail:<entityType>:<id>`) and mounts the body registered for that\n * entity type; the body self-hydrates by id. An entity type without a body renders a short notice instead of nothing,\n * so a click never lands on an empty pane. \"Ask about this\" stays at the pane's foot while the detail scrolls and\n * names the entity in its chip once the body reported the name (`useReportEntityDetailName`).\n */\nexport const EntityDetailCanvasBody = ({ canvas, agentSpaceKey }: CanvasBodyProps) => {\n const bodies = useEntityDetailBodies();\n const [reportedEntity, setReportedEntity] = useState<{ instanceId: string; name: string | undefined }>();\n const reportEntityName = useCallback(\n (entityName: string | undefined) => setReportedEntity({ instanceId: canvas.instanceId, name: entityName }),\n [canvas.instanceId],\n );\n const target = readEntityDetailInstanceId(canvas.instanceId);\n if (target === undefined) return null;\n const definition = Object.prototype.hasOwnProperty.call(bodies, target.entityType)\n ? bodies[target.entityType]\n : undefined;\n if (!definition) {\n return (\n <div className={styles.entityDetail} data-testid=\"entity-detail-canvas\">\n <Text role=\"help\" color=\"var(--agents-fg-light)\" testId=\"entity-detail-canvas-unsupported\">\n {\"This detail cannot be shown here yet.\"}\n </Text>\n </div>\n );\n }\n const Body = definition.component;\n // A name reported for the previous entity never labels the next one's chip.\n const entityName = reportedEntity?.instanceId === canvas.instanceId ? reportedEntity.name : undefined;\n return (\n <div className={styles.entityDetail} data-testid=\"entity-detail-canvas\">\n <EntityDetailNameReportContext.Provider value={reportEntityName}>\n <Body entityType={target.entityType} entityId={target.entityId} agentSpaceKey={agentSpaceKey} />\n </EntityDetailNameReportContext.Provider>\n <div className={styles.entityDetailFooter}>\n <EntityMentionAskButton\n entityType={target.entityType}\n entityId={target.entityId}\n label={entityName}\n agentSpaceKey={agentSpaceKey}\n />\n </div>\n </div>\n );\n};\n","import { Text } from \"../../provider/components\";\nimport { useCallback, useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useConversationWidgetContext } from \"../../renderer/ConversationWidgetCallbacksContext\";\nimport {\n canvasInstanceIdForEntityDetail,\n readOpenEntityActionTarget,\n} from \"../../renderer/canvas/entity-detail-instance\";\nimport type {\n ComposedViewAction,\n ComposedViewTree,\n} from \"../../renderer/widget-tree/composed-view-tree\";\nimport type { ExpressionValue } from \"../../renderer/widget-tree/expression/evaluate-expression\";\nimport { ComposedViewRenderer } from \"../ComposedViewRenderer\";\nimport { findMapNodeInMarkdown, readMapNodeKeyOfInstanceId } from \"../components/map/map-full-screen-instance\";\nimport { MapPresentationContext } from \"../components/map/map-presentation-context\";\nimport mapStyles from \"../components/map/Map.module.scss\";\nimport { useAgentsEnvironment } from \"../../provider/AgentsProvider\";\n\n/** The body reports nothing of its own: the inline block already reported this map to the model. */\nconst ignoreRenderReport = () => {};\n\n/**\n * The `mapFullScreen` CANVAS BODY (`canvasBodies.tsx`): one `Map` node of the anchor\n * message, full screen — the map filling the pane beside the list of its points. It finds the node through the\n * message's `ComposedView` fences and the node key its instance id carries (`map-full-screen-instance.ts`), then\n * renders it through the same `ComposedViewRenderer` with the node's own tree, so its bindings (`$data`, `$from`,\n * `$source`, `$computed`, `$state` at its initial value) and its actions resolve exactly as inline; the\n * `MapPresentationContext` switches the node to its full-screen layout. A point's `openEntity` action opens the\n * `entityDetail` canvas on the same anchor message (it replaces this canvas, as a click on an inline point would).\n */\nexport const MapFullScreenCanvasBody = (props: CanvasBodyProps) => {\n const { canvas, anchorMessageMarkdown, agentSpaceKey } = props;\n const { openCanvas } = useConversationWidgetContext();\n const { onOpenEntity: openEntityOnHostRoute } = useAgentsEnvironment();\n const mapNodeKey = readMapNodeKeyOfInstanceId(canvas.instanceId);\n\n const mapTree = useMemo<ComposedViewTree | undefined>(() => {\n if (anchorMessageMarkdown === null || mapNodeKey === undefined) return undefined;\n const mapNodeInComposedView = findMapNodeInMarkdown(anchorMessageMarkdown, mapNodeKey);\n if (!mapNodeInComposedView) return undefined;\n // The map alone, with its tree's state, data, computed values and actions; the tree's findings were the inline\n // block's to report.\n return { ...mapNodeInComposedView.tree, title: null, view: mapNodeInComposedView.mapNode, findings: [] };\n }, [anchorMessageMarkdown, mapNodeKey]);\n\n const anchor = canvas.anchor;\n const onOpenEntity = useCallback(\n (action: ComposedViewAction, currentRow?: ExpressionValue) => {\n const target = readOpenEntityActionTarget(action, currentRow);\n if (target === undefined) return;\n // The host opens the entity on a route of its own (`AgentsEnvironment.onOpenEntity`) instead of the canvas.\n if (openEntityOnHostRoute?.(target) === true) return;\n if (anchor.kind !== \"message\") return;\n openCanvas({\n canvasId: \"entityDetail\",\n instanceId: canvasInstanceIdForEntityDetail(target),\n anchor,\n origin: \"widgetClick\",\n justDelivered: false,\n });\n },\n [openCanvas, anchor, openEntityOnHostRoute],\n );\n\n if (!mapTree) {\n return (\n <div\n className={mapStyles.fullScreenNotice}\n data-canvas-instance={canvas.instanceId}\n data-testid=\"map-full-screen-canvas-unavailable\"\n >\n <Text role=\"help\" color=\"var(--agents-fg-light)\">\n {\"This map is no longer available.\"}\n </Text>\n </div>\n );\n }\n return (\n <div\n className={mapStyles.fullScreenBody}\n data-canvas-instance={canvas.instanceId}\n data-testid=\"map-full-screen-canvas\"\n >\n <MapPresentationContext.Provider value=\"fullScreen\">\n <ComposedViewRenderer\n tree={mapTree}\n interactive\n isEmailRender={false}\n messageId={anchor.kind === \"message\" ? anchor.messageId : undefined}\n agentSpaceKey={agentSpaceKey}\n onReport={ignoreRenderReport}\n onOpenEntity={onOpenEntity}\n testId=\"map-full-screen-canvas-view\"\n />\n </MapPresentationContext.Provider>\n </div>\n );\n};\n","import { useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useAnchorWidgetPayload } from \"../../renderer/canvas/use-anchor-widget-payload\";\nimport { useConversationWidgetContext } from \"../../renderer/ConversationWidgetCallbacksContext\";\nimport { ImageGallery } from \"./ImageGallery\";\nimport { IMAGE_GALLERY_WIDGET_TYPE, parseImageGalleryPayload } from \"./shared/image-gallery-payload\";\n\n/**\n * The `imageGallery` canvas body: re-reads the `ImageGallery` fence of the anchor message and shows the same gallery\n * with more room. The pick works here as inline; it is inert once a newer owner message exists past the anchor.\n */\nexport const ImageGalleryCanvasBody = ({ canvas, anchorMessageMarkdown }: CanvasBodyProps) => {\n const payload = useAnchorWidgetPayload(canvas, anchorMessageMarkdown, IMAGE_GALLERY_WIDGET_TYPE);\n const gallery = useMemo(() => (payload === undefined ? null : parseImageGalleryPayload(payload)), [payload]);\n const { messages } = useConversationWidgetContext();\n const anchorMessageId = canvas.anchor.kind === \"message\" ? canvas.anchor.messageId : undefined;\n const isStale = useMemo(() => {\n if (!messages || anchorMessageId === undefined) return false;\n const hostIndex = messages.findIndex((message) => String(message.id) === String(anchorMessageId));\n return hostIndex !== -1 && messages.slice(hostIndex + 1).some((message) => message.role === \"USER\");\n }, [messages, anchorMessageId]);\n if (gallery === null) return null;\n return <ImageGallery gallery={gallery} interactive={!isStale} surface=\"canvas\" testId=\"image-gallery-widget-canvas\" />;\n};\n","import type React from \"react\";\nimport type { CanvasId } from \"./canvas-behaviours\";\nimport type { CanvasBodyProps } from \"./canvas-body-props\";\nimport { ConversationSearchResultsCanvasBody } from \"../../widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvasBody\";\nimport { WebSearchResultsCanvasBody } from \"../../widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvasBody\";\nimport { EntityDetailCanvasBody } from \"../../kit/entity-detail/EntityDetailCanvasBody\";\nimport { MapFullScreenCanvasBody } from \"../../kit/map-full-screen/MapFullScreenCanvasBody\";\nimport { ImageGalleryCanvasBody } from \"../../widgets/ImageGalleryConversationWidget/ImageGalleryCanvasBody\";\n\nexport type { CanvasBodyProps } from \"./canvas-body-props\";\nexport { canvasFeatureFlagOf } from \"./canvas-feature-flags\";\n\n/**\n * THE CANVAS BODIES — canvas id → the React component the shell mounts in the canvas pane. The one module that knows\n * both the canvas ids and React components, and it is imported ONLY by `CanvasPane` (the shell), never by\n * the slice, the behaviours or a widget — that is the import layering that keeps the store-init temporal-dead-zone\n * cycle away. The bodies themselves are small: a body that hosts a heavy page (an app's list page or editor)\n * lazy-loads that page, exactly as its widget did. Every canvas has a body; nothing\n * else hands the pane a rendered node.\n *\n * The package's own bodies are listed here; an app adds the bodies of its canvases with `registerCanvasBodies` before\n * the first render. The object is filled in place, so the shell reads every registration.\n */\nexport const canvasBodies = {\n conversationSearchResults: ConversationSearchResultsCanvasBody,\n webSearchResults: WebSearchResultsCanvasBody,\n entityDetail: EntityDetailCanvasBody,\n mapFullScreen: MapFullScreenCanvasBody,\n imageGallery: ImageGalleryCanvasBody,\n} as Record<CanvasId, React.ComponentType<CanvasBodyProps>>;\n\n/** Adds an app's canvas bodies (canvas id → body). Runs outside React, before the first render. */\nexport const registerCanvasBodies = (\n bodies: Readonly<Partial<Record<CanvasId, React.ComponentType<CanvasBodyProps>>>>,\n): void => {\n Object.assign(canvasBodies, bodies);\n};\n"],"names":["canvasStyle","scrollStyle","contentStyle","entityName"],"mappings":";;;;;;;AAWO,MAAM,yBAAyB,CACpC,QACA,uBACA,eAEA,QAAQ,MAAM;AACZ,MAAI,OAAO,OAAO,SAAS,aAAa,0BAA0B,KAAM,QAAO;AAC/E,QAAM,cAAc,wBAAwB,OAAO,UAAU;AAC7D,MAAI,gBAAgB,QAAW;AAC7B,WAAO,6BAA6B,uBAAuB,YAAY,WAAW,GAAG;AAAA,EACvF;AACA,SAAO,2BAA2B,qBAAqB,EAAE,KAAK,CAAC,UAAU,MAAM,SAAS,UAAU,GAAG;AACvG,GAAG,CAAC,OAAO,QAAQ,OAAO,YAAY,uBAAuB,UAAU,CAAC;ACR1E,MAAMA,gBAAmC;AAAA,EACvC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,eAAe;AAAA,EACf,WAAW;AAAA,EACX,YAAY;AACd;AACA,MAAMC,gBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,WAAW;AAAA,EACX,WAAW;AACb;AACA,MAAMC,iBAAoC;AAAA,EACxC,SAAS;AACX;AAGO,MAAM,kCAAkC,CAAC,8BAC7C,OAAA,EAAI,OAAOF,eAAa,eAAY,6CACnC,UAAA,oBAAC,OAAA,EAAI,OAAOC,eACV,UAAA,qBAAC,SAAI,OAAOC,gBAAc,eAAY,qDACpC,UAAA;AAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAc,EAAE,OAAO,MAAM,MAAA;AAAA,MA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,QAAQ,EAAE,MAAM,OAAO,eAAe,CAAC;AAChG,WAAO,cAAc,MAAM,SAAS,MAAM,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,QAAQ,SAAS,MAAM;AAAA,EACpG,GAAG,CAAC,UAAU,eAAe,CAAC;AAC9B,MAAI,YAAY,KAAM,QAAO;AAC7B,SAAO,oBAAC,gBAAa,SAAkB,aAAa,CAAC,SAAS,SAAQ,UAAS,QAAO,8BAAA,CAA8B;AACtH;ACAO,MAAM,eAAe;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAChB;AAGO,MAAM,uBAAuB,CAClC,WACS;AACT,SAAO,OAAO,cAAc,MAAM;AACpC;"}
1
+ {"version":3,"file":"canvasBodies-C3wydcKZ.js","sources":["../../src/renderer/canvas/use-anchor-widget-payload.ts","../../src/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvas.tsx","../../src/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvasBody.tsx","../../src/widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvas.tsx","../../src/widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvasBody.tsx","../../src/widgets/EntityMentionConversationWidget/shared/use-entity-mention-composer.ts","../../src/widgets/EntityMentionConversationWidget/EntityMentionAskButton/EntityMentionAskButton.tsx","../../src/kit/entity-detail/entity-detail-bodies.ts","../../src/kit/entity-detail/EntityDetailCanvasBody.tsx","../../src/kit/map-full-screen/MapFullScreenCanvasBody.tsx","../../src/widgets/ImageGalleryConversationWidget/ImageGalleryCanvasBody.tsx","../../src/renderer/canvas/canvasBodies.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { CanvasState } from \"./canvas-state\";\nimport { payloadHashOfInstanceId } from \"./canvas-state\";\nimport { findWidgetFenceByPayloadHash, findWidgetFencesInMarkdown } from \"./find-widget-fences-in-markdown\";\n\n/**\n * The payload string of the widget a message-anchored canvas was opened from: the fence of `widgetName` in the anchor\n * message whose payload hash the canvas instance id carries (`canvasInstanceIdForMessagePayload`); when the instance\n * id carries no hash (one canvas per message), the first fence of that name. Undefined for a page anchor, a missing\n * anchor message, or a message that no longer carries the fence — the body then renders nothing.\n */\nexport const useAnchorWidgetPayload = (\n canvas: CanvasState,\n anchorMessageMarkdown: string | null,\n widgetName: string,\n): string | undefined =>\n useMemo(() => {\n if (canvas.anchor.kind !== \"message\" || anchorMessageMarkdown === null) return undefined;\n const payloadHash = payloadHashOfInstanceId(canvas.instanceId);\n if (payloadHash !== undefined) {\n return findWidgetFenceByPayloadHash(anchorMessageMarkdown, widgetName, payloadHash)?.payload;\n }\n return findWidgetFencesInMarkdown(anchorMessageMarkdown).find((fence) => fence.name === widgetName)?.payload;\n }, [canvas.anchor, canvas.instanceId, anchorMessageMarkdown, widgetName]);\n","import { ConversationSearchResultsList, Text } from \"../../provider/components\";\nimport React from \"react\";\nimport { parseConversationSearchResultsPayload } from \"./shared/conversation-search-results-widget-payload\";\n\ntype ConversationSearchResultsCanvasProps = {\n query: string;\n groups: ReturnType<typeof parseConversationSearchResultsPayload>[\"groups\"];\n onOpenConversation: (conversationId: number, messageId?: number) => void;\n};\n\n// Canvas body styles — the same as every list canvas body, so the full-screen panel behaves the same:\n// a full-height flex column whose inner area SCROLLS (scrollStyle: flex 1 + overflowY auto — without it the content\n// overflows the panel with no scrollbar), plus a horizontal inset (contentStyle) because the results list is built\n// for the narrow inline chat column where the bubble provides the gutter — in the canvas there is no bubble, so it would\n// otherwise render edge-to-edge.\nconst canvasStyle: React.CSSProperties = {\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n background: \"var(--agents-bg)\",\n};\nconst scrollStyle: React.CSSProperties = {\n flex: 1,\n minHeight: 0,\n overflowY: \"auto\",\n};\nconst contentStyle: React.CSSProperties = {\n padding: \"16px 24px 24px\",\n};\n\n/** The canvas body — a titled wrapper around the same grouped results, scrollable + inset like the other canvas widgets. */\nexport const ConversationSearchResultsCanvas = (props: ConversationSearchResultsCanvasProps) => (\n <div style={canvasStyle} data-testid=\"conversation-search-results-widget-canvas\">\n <div style={scrollStyle}>\n <div style={contentStyle} data-testid=\"conversation-search-results-widget-canvas-results\">\n <Text\n role=\"title\"\n replacements={{ query: props.query }}\n testId=\"conversation-search-results-widget-canvas-title\"\n >\n {'Search results for \"%query%\"'}\n </Text>\n <ConversationSearchResultsList groups={props.groups} query={props.query} onOpenConversation={props.onOpenConversation} />\n </div>\n </div>\n </div>\n);\n","import React, { useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useConversationWidgetContext } from \"../../renderer/ConversationWidgetCallbacksContext\";\nimport { useAnchorWidgetPayload } from \"../../renderer/canvas/use-anchor-widget-payload\";\nimport { parseConversationSearchResultsPayload } from \"./shared/conversation-search-results-widget-payload\";\nimport { ConversationSearchResultsCanvas } from \"./ConversationSearchResultsCanvas\";\n\n/**\n * The `conversationSearchResults` CANVAS BODY (`canvasBodies.tsx`): re-reads the `ConversationSearchResults` fence of\n * the anchor message — the same payload the inline widget rendered from — and shows the grouped results. Nothing was\n * stored for it but the pointer. Renders nothing when the anchor message no longer carries the fence.\n */\nexport const ConversationSearchResultsCanvasBody = ({ canvas, anchorMessageMarkdown }: CanvasBodyProps) => {\n const { onOpenConversation } = useConversationWidgetContext();\n const payload = useAnchorWidgetPayload(canvas, anchorMessageMarkdown, \"ConversationSearchResults\");\n const parsed = useMemo(\n () => (payload === undefined ? null : parseConversationSearchResultsPayload(payload)),\n [payload],\n );\n if (parsed === null || parsed.groups.length === 0) return null;\n return (\n <ConversationSearchResultsCanvas\n query={parsed.query}\n groups={parsed.groups}\n onOpenConversation={(conversationId, messageId) => onOpenConversation?.(conversationId, messageId)}\n />\n );\n};\n","import { Text } from \"../../provider/components\";\nimport React from \"react\";\nimport { WebSearchResultSource } from \"./shared/web-search-results-widget-payload\";\nimport { WebSearchAnswer } from \"./WebSearchAnswer\";\nimport { WebSearchSourcesList } from \"./WebSearchSourcesList\";\n\ntype WebSearchResultsCanvasProps = {\n query: string;\n answer: string;\n sources: WebSearchResultSource[];\n provider?: string;\n};\n\n// Canvas body styles — mirror the ConversationSearchResults / listReviews drawer widgets: a full-height flex column\n// whose inner area SCROLLS (flex 1 + overflowY auto) with a horizontal inset (there is no chat bubble gutter in the canvas).\nconst canvasStyle: React.CSSProperties = {\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n background: \"var(--agents-bg)\",\n};\nconst scrollStyle: React.CSSProperties = { flex: 1, minHeight: 0, overflowY: \"auto\" };\nconst contentStyle: React.CSSProperties = { padding: \"16px 24px 24px\" };\n\n/** The canvas body — the full answer + sources, scrollable + inset like the other canvas widgets. */\nexport const WebSearchResultsCanvas = (props: WebSearchResultsCanvasProps) => (\n <div style={canvasStyle} data-testid=\"web-search-results-widget-canvas\">\n <div style={scrollStyle}>\n <div style={contentStyle}>\n {props.query ? (\n <Text\n role=\"title\"\n replacements={{ query: props.query }}\n testId=\"web-search-results-widget-canvas-title\"\n >\n {'\"%query%\"'}\n </Text>\n ) : (\n <Text role=\"title\" testId=\"web-search-results-widget-canvas-title\">\n Web search\n </Text>\n )}\n <div style={{ marginTop: 12 }}>\n <WebSearchAnswer answer={props.answer} />\n </div>\n <WebSearchSourcesList\n sources={props.sources}\n provider={props.provider}\n testId=\"web-search-results-widget-canvas\"\n />\n </div>\n </div>\n </div>\n);\n","import React, { useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useAnchorWidgetPayload } from \"../../renderer/canvas/use-anchor-widget-payload\";\nimport { parseWebSearchResultsPayload } from \"./shared/web-search-results-widget-payload\";\nimport { WebSearchResultsCanvas } from \"./WebSearchResultsCanvas\";\n\n/**\n * The `webSearchResults` CANVAS BODY (`canvasBodies.tsx`): re-reads the `WebSearchResults` fence of the anchor message\n * — the answer and its cited sources the inline widget rendered from — and shows them in the canvas. Renders nothing\n * when the anchor message no longer carries the fence.\n */\nexport const WebSearchResultsCanvasBody = ({ canvas, anchorMessageMarkdown }: CanvasBodyProps) => {\n const payload = useAnchorWidgetPayload(canvas, anchorMessageMarkdown, \"WebSearchResults\");\n const parsed = useMemo(() => (payload === undefined ? null : parseWebSearchResultsPayload(payload)), [payload]);\n if (parsed === null || (parsed.answer.trim() === \"\" && parsed.sources.length === 0)) return null;\n return (\n <WebSearchResultsCanvas\n query={parsed.query}\n answer={parsed.answer}\n sources={parsed.sources}\n provider={parsed.provider}\n />\n );\n};\n","import { useCallback } from \"react\";\nimport { useConversationWidgetContext } from \"../../../renderer/ConversationWidgetCallbacksContext\";\nimport {\n buildEntityMentionFields,\n ENTITY_MENTION_WIDGET_NAME,\n entityMentionKey,\n EntityMentionTarget,\n MAX_ENTITY_MENTIONS_PER_MESSAGE,\n normalizeEntityMentionFields,\n toEntityMentionWireFields,\n} from \"./entity-mention\";\n\nexport interface UseEntityMentionComposerResult {\n /** Whether this entity is already mentioned in the composer. */\n isMentioned: (target: EntityMentionTarget) => boolean;\n /**\n * Puts the entity into the composer as an `EntityMention` chip — once per entity (a second click is a no-op); past\n * {@link MAX_ENTITY_MENTIONS_PER_MESSAGE} the new entity takes the place of the oldest mention (one write: a remove\n * and an add in one event would both read the list before either). Sends nothing: the owner writes the question.\n * Returns false for a target that names no entity.\n */\n mentionEntity: (target: EntityMentionTarget) => boolean;\n}\n\n/**\n * The opener side of the `EntityMention` composer widget: what the detail panel's \"Ask about this\"\n * button calls. Reads and writes the composer widgets of the chat's widget context; the composer strip renders them.\n */\nexport const useEntityMentionComposer = (): UseEntityMentionComposerResult => {\n const { composerWidgets, addComposerWidget, replaceComposerWidgetFields } = useConversationWidgetContext();\n\n const findMentionWidgets = useCallback(\n () => composerWidgets.filter((composerWidget) => composerWidget.widgetName === ENTITY_MENTION_WIDGET_NAME),\n [composerWidgets],\n );\n\n const isMentioned = useCallback(\n (target: EntityMentionTarget) => {\n const mention = buildEntityMentionFields(target);\n if (mention === null) return false;\n return findMentionWidgets().some((composerWidget) => {\n const heldMention = normalizeEntityMentionFields(composerWidget.fields);\n return heldMention !== null && entityMentionKey(heldMention) === entityMentionKey(mention);\n });\n },\n [findMentionWidgets],\n );\n\n const mentionEntity = useCallback(\n (target: EntityMentionTarget) => {\n const mention = buildEntityMentionFields(target);\n if (mention === null) return false;\n if (isMentioned(target)) return true;\n const mentionWidgets = findMentionWidgets();\n if (mentionWidgets.length >= MAX_ENTITY_MENTIONS_PER_MESSAGE) {\n replaceComposerWidgetFields(mentionWidgets[0].composerWidgetId, toEntityMentionWireFields(mention));\n } else {\n addComposerWidget(ENTITY_MENTION_WIDGET_NAME, toEntityMentionWireFields(mention));\n }\n return true;\n },\n [isMentioned, findMentionWidgets, replaceComposerWidgetFields, addComposerWidget],\n );\n\n return { isMentioned, mentionEntity };\n};\n","import { useIsEmailWidgetRender } from \"../../../renderer/ConversationWidgetRenderContext\";\nimport { ConversationWidgetButton } from \"../../_shared/ConversationWidgetButton\";\nimport type { EntityMentionTarget } from \"../shared/entity-mention\";\nimport { useEntityMentionComposer } from \"../shared/use-entity-mention-composer\";\n\nexport interface EntityMentionAskButtonProps extends EntityMentionTarget {\n testId?: string;\n}\n\n/**\n * The detail panel's \"Ask about this\" button (ChatGPT's \"Anschlussfrage stellen\"):\n * puts the entity into the chat input as an `EntityMention` chip and sends NOTHING — the owner writes the question,\n * the chip rides in that message as a fence, and the backend reads which entity the question is about. Not a\n * next-step CTA: it posts no prompt. A second click on the same entity changes nothing; the\n * label turns into \"Added to your message\". Mounted by the `entityDetail` canvas (the shell or a domain body) with\n * the entity the panel shows; renders nothing in the e-mail capture or for a target that names no entity.\n */\nexport const EntityMentionAskButton = (props: EntityMentionAskButtonProps) => {\n const { entityType, entityId, label, agentSpaceKey, testId = \"entity-mention-ask\" } = props;\n const isEmailRender = useIsEmailWidgetRender();\n const { isMentioned, mentionEntity } = useEntityMentionComposer();\n const target = { entityType, entityId, label, agentSpaceKey };\n if (isEmailRender) return null;\n const isAlreadyMentioned = isMentioned(target);\n return (\n <ConversationWidgetButton\n variant=\"primary\"\n size=\"medium\"\n icon={isAlreadyMentioned ? \"check\" : \"message\"}\n disabled={isAlreadyMentioned}\n onClick={() => mentionEntity(target)}\n testId={testId}\n >\n {isAlreadyMentioned ? \"Added to your message\" : \"Ask about this\"}\n </ConversationWidgetButton>\n );\n};\n","import type React from \"react\";\nimport { createContext, useContext } from \"react\";\n\n/**\n * The bodies of the `entityDetail` canvas, one per entity type: every `*.entity-detail-body.tsx` below\n * `widgets/` that exports `entityDetailBody` registers itself by folder glob — an entity type is added with\n * the backend `<Type>EntityReferenceResolver` and this one file, and edits no list. A second body for one entity type\n * is a build error (thrown at module load).\n */\n\nexport interface EntityDetailBodyProps {\n entityType: string;\n /** The id as the backend resolved it (a row id or an external id). */\n entityId: string;\n /** The key of the agent space the chat is scoped to, for a body whose read endpoint is agent-space-scoped. */\n agentSpaceKey?: number;\n}\n\nexport interface EntityDetailBodyDefinition {\n /** The backend resolver's `ENTITY_TYPE`. */\n entityType: string;\n /** Self-hydrates the entity by id through its own read endpoint (the endpoint's entity rights apply). */\n component: React.ComponentType<EntityDetailBodyProps>;\n}\n\nconst bodyModules = import.meta.glob<{ entityDetailBody?: EntityDetailBodyDefinition }>(\n [\"../../widgets/**/*.entity-detail-body.tsx\", \"../**/*.entity-detail-body.tsx\"],\n { eager: true },\n);\n\nexport const buildEntityDetailBodyRegistry = (\n definitions: EntityDetailBodyDefinition[],\n): Readonly<Record<string, EntityDetailBodyDefinition>> => {\n const registry: Record<string, EntityDetailBodyDefinition> = {};\n for (const definition of definitions) {\n if (Object.prototype.hasOwnProperty.call(registry, definition.entityType)) {\n throw new Error(`Two entity detail bodies register the entity type \"${definition.entityType}\".`);\n }\n registry[definition.entityType] = definition;\n }\n return registry;\n};\n\n/** The body definitions a set of `*.entity-detail-body.tsx` modules export (the package's or an app's glob). */\nexport const readEntityDetailBodyDefinitions = (\n modules: Record<string, { entityDetailBody?: EntityDetailBodyDefinition }>,\n): EntityDetailBodyDefinition[] =>\n Object.values(modules)\n .map((bodyModule) => bodyModule.entityDetailBody)\n .filter((definition): definition is EntityDetailBodyDefinition => definition !== undefined);\n\n/** Entity type → body: the package's folder, then what an app registers (`registerEntityDetailBodies`). */\nexport const entityDetailBodies: Record<string, EntityDetailBodyDefinition> = {\n ...buildEntityDetailBodyRegistry(readEntityDetailBodyDefinitions(bodyModules)),\n};\n\n/** Adds an app's entity detail bodies. Runs outside React, before the first render; an entity type registers once. */\nexport const registerEntityDetailBodies = (definitions: readonly EntityDetailBodyDefinition[]): void => {\n Object.assign(\n entityDetailBodies,\n buildEntityDetailBodyRegistry([...Object.values(entityDetailBodies), ...definitions]),\n );\n};\n\n/** The body registered for one entity type (the package's or an app's), or undefined when none is. */\nexport const getEntityDetailBody = (entityType: string): EntityDetailBodyDefinition | undefined =>\n Object.prototype.hasOwnProperty.call(entityDetailBodies, entityType) ? entityDetailBodies[entityType] : undefined;\n\n/** The registry the canvas body uses — the folder's by default; a spec or a story may provide stubs. */\nexport const EntityDetailBodiesContext =\n createContext<Readonly<Record<string, EntityDetailBodyDefinition>>>(entityDetailBodies);\n\nexport const useEntityDetailBodies = () => useContext(EntityDetailBodiesContext);\n","import { Text } from \"../../provider/components\";\nimport { useCallback, useState } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { readEntityDetailInstanceId } from \"../../renderer/canvas/entity-detail-instance\";\nimport { EntityMentionAskButton } from \"../../widgets/EntityMentionConversationWidget/EntityMentionAskButton/EntityMentionAskButton\";\nimport { useEntityDetailBodies } from \"./entity-detail-bodies\";\nimport { EntityDetailNameReportContext } from \"./entity-detail-name\";\nimport styles from \"./EntityDetailCanvasBody.module.scss\";\n\n/**\n * The `entityDetail` CANVAS BODY (`canvasBodies.tsx`): the shell around one entity's detail. It reads\n * WHICH entity from the canvas instance id (`entityDetail:<entityType>:<id>`) and mounts the body registered for that\n * entity type; the body self-hydrates by id. An entity type without a body renders a short notice instead of nothing,\n * so a click never lands on an empty pane. \"Ask about this\" stays at the pane's foot while the detail scrolls and\n * names the entity in its chip once the body reported the name (`useReportEntityDetailName`).\n */\nexport const EntityDetailCanvasBody = ({ canvas, agentSpaceKey }: CanvasBodyProps) => {\n const bodies = useEntityDetailBodies();\n const [reportedEntity, setReportedEntity] = useState<{ instanceId: string; name: string | undefined }>();\n const reportEntityName = useCallback(\n (entityName: string | undefined) => setReportedEntity({ instanceId: canvas.instanceId, name: entityName }),\n [canvas.instanceId],\n );\n const target = readEntityDetailInstanceId(canvas.instanceId);\n if (target === undefined) return null;\n const definition = Object.prototype.hasOwnProperty.call(bodies, target.entityType)\n ? bodies[target.entityType]\n : undefined;\n if (!definition) {\n return (\n <div className={styles.entityDetail} data-testid=\"entity-detail-canvas\">\n <Text role=\"help\" color=\"var(--agents-fg-light)\" testId=\"entity-detail-canvas-unsupported\">\n {\"This detail cannot be shown here yet.\"}\n </Text>\n </div>\n );\n }\n const Body = definition.component;\n // A name reported for the previous entity never labels the next one's chip.\n const entityName = reportedEntity?.instanceId === canvas.instanceId ? reportedEntity.name : undefined;\n return (\n <div className={styles.entityDetail} data-testid=\"entity-detail-canvas\">\n <EntityDetailNameReportContext.Provider value={reportEntityName}>\n <Body entityType={target.entityType} entityId={target.entityId} agentSpaceKey={agentSpaceKey} />\n </EntityDetailNameReportContext.Provider>\n <div className={styles.entityDetailFooter}>\n <EntityMentionAskButton\n entityType={target.entityType}\n entityId={target.entityId}\n label={entityName}\n agentSpaceKey={agentSpaceKey}\n />\n </div>\n </div>\n );\n};\n","import { Text } from \"../../provider/components\";\nimport { useCallback, useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useConversationWidgetContext } from \"../../renderer/ConversationWidgetCallbacksContext\";\nimport {\n canvasInstanceIdForEntityDetail,\n readOpenEntityActionTarget,\n} from \"../../renderer/canvas/entity-detail-instance\";\nimport type {\n ComposedViewAction,\n ComposedViewTree,\n} from \"../../renderer/widget-tree/composed-view-tree\";\nimport type { ExpressionValue } from \"../../renderer/widget-tree/expression/evaluate-expression\";\nimport { ComposedViewRenderer } from \"../ComposedViewRenderer\";\nimport { findMapNodeInMarkdown, readMapNodeKeyOfInstanceId } from \"../components/map/map-full-screen-instance\";\nimport { MapPresentationContext } from \"../components/map/map-presentation-context\";\nimport mapStyles from \"../components/map/Map.module.scss\";\nimport { useAgentsEnvironment } from \"../../provider/AgentsProvider\";\n\n/** The body reports nothing of its own: the inline block already reported this map to the model. */\nconst ignoreRenderReport = () => {};\n\n/**\n * The `mapFullScreen` CANVAS BODY (`canvasBodies.tsx`): one `Map` node of the anchor\n * message, full screen — the map filling the pane beside the list of its points. It finds the node through the\n * message's `ComposedView` fences and the node key its instance id carries (`map-full-screen-instance.ts`), then\n * renders it through the same `ComposedViewRenderer` with the node's own tree, so its bindings (`$data`, `$from`,\n * `$source`, `$computed`, `$state` at its initial value) and its actions resolve exactly as inline; the\n * `MapPresentationContext` switches the node to its full-screen layout. A point's `openEntity` action opens the\n * `entityDetail` canvas on the same anchor message (it replaces this canvas, as a click on an inline point would).\n */\nexport const MapFullScreenCanvasBody = (props: CanvasBodyProps) => {\n const { canvas, anchorMessageMarkdown, agentSpaceKey } = props;\n const { openCanvas } = useConversationWidgetContext();\n const { onOpenEntity: openEntityOnHostRoute } = useAgentsEnvironment();\n const mapNodeKey = readMapNodeKeyOfInstanceId(canvas.instanceId);\n\n const mapTree = useMemo<ComposedViewTree | undefined>(() => {\n if (anchorMessageMarkdown === null || mapNodeKey === undefined) return undefined;\n const mapNodeInComposedView = findMapNodeInMarkdown(anchorMessageMarkdown, mapNodeKey);\n if (!mapNodeInComposedView) return undefined;\n // The map alone, with its tree's state, data, computed values and actions; the tree's findings were the inline\n // block's to report.\n return { ...mapNodeInComposedView.tree, title: null, view: mapNodeInComposedView.mapNode, findings: [] };\n }, [anchorMessageMarkdown, mapNodeKey]);\n\n const anchor = canvas.anchor;\n const onOpenEntity = useCallback(\n (action: ComposedViewAction, currentRow?: ExpressionValue) => {\n const target = readOpenEntityActionTarget(action, currentRow);\n if (target === undefined) return;\n // The host opens the entity on a route of its own (`AgentsEnvironment.onOpenEntity`) instead of the canvas.\n if (openEntityOnHostRoute?.(target) === true) return;\n if (anchor.kind !== \"message\") return;\n openCanvas({\n canvasId: \"entityDetail\",\n instanceId: canvasInstanceIdForEntityDetail(target),\n anchor,\n origin: \"widgetClick\",\n justDelivered: false,\n });\n },\n [openCanvas, anchor, openEntityOnHostRoute],\n );\n\n if (!mapTree) {\n return (\n <div\n className={mapStyles.fullScreenNotice}\n data-canvas-instance={canvas.instanceId}\n data-testid=\"map-full-screen-canvas-unavailable\"\n >\n <Text role=\"help\" color=\"var(--agents-fg-light)\">\n {\"This map is no longer available.\"}\n </Text>\n </div>\n );\n }\n return (\n <div\n className={mapStyles.fullScreenBody}\n data-canvas-instance={canvas.instanceId}\n data-testid=\"map-full-screen-canvas\"\n >\n <MapPresentationContext.Provider value=\"fullScreen\">\n <ComposedViewRenderer\n tree={mapTree}\n interactive\n isEmailRender={false}\n messageId={anchor.kind === \"message\" ? anchor.messageId : undefined}\n agentSpaceKey={agentSpaceKey}\n onReport={ignoreRenderReport}\n onOpenEntity={onOpenEntity}\n testId=\"map-full-screen-canvas-view\"\n />\n </MapPresentationContext.Provider>\n </div>\n );\n};\n","import { useMemo } from \"react\";\nimport type { CanvasBodyProps } from \"../../renderer/canvas/canvas-body-props\";\nimport { useAnchorWidgetPayload } from \"../../renderer/canvas/use-anchor-widget-payload\";\nimport { useConversationWidgetContext } from \"../../renderer/ConversationWidgetCallbacksContext\";\nimport { ImageGallery } from \"./ImageGallery\";\nimport { IMAGE_GALLERY_WIDGET_TYPE, parseImageGalleryPayload } from \"./shared/image-gallery-payload\";\n\n/**\n * The `imageGallery` canvas body: re-reads the `ImageGallery` fence of the anchor message and shows the same gallery\n * with more room. The pick works here as inline; it is inert once a newer owner message exists past the anchor.\n */\nexport const ImageGalleryCanvasBody = ({ canvas, anchorMessageMarkdown }: CanvasBodyProps) => {\n const payload = useAnchorWidgetPayload(canvas, anchorMessageMarkdown, IMAGE_GALLERY_WIDGET_TYPE);\n const gallery = useMemo(() => (payload === undefined ? null : parseImageGalleryPayload(payload)), [payload]);\n const { messages } = useConversationWidgetContext();\n const anchorMessageId = canvas.anchor.kind === \"message\" ? canvas.anchor.messageId : undefined;\n const isStale = useMemo(() => {\n if (!messages || anchorMessageId === undefined) return false;\n const hostIndex = messages.findIndex((message) => String(message.id) === String(anchorMessageId));\n return hostIndex !== -1 && messages.slice(hostIndex + 1).some((message) => message.role === \"USER\");\n }, [messages, anchorMessageId]);\n if (gallery === null) return null;\n return <ImageGallery gallery={gallery} interactive={!isStale} surface=\"canvas\" testId=\"image-gallery-widget-canvas\" />;\n};\n","import type React from \"react\";\nimport type { CanvasId } from \"./canvas-behaviours\";\nimport type { CanvasBodyProps } from \"./canvas-body-props\";\nimport { ConversationSearchResultsCanvasBody } from \"../../widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvasBody\";\nimport { WebSearchResultsCanvasBody } from \"../../widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvasBody\";\nimport { EntityDetailCanvasBody } from \"../../kit/entity-detail/EntityDetailCanvasBody\";\nimport { MapFullScreenCanvasBody } from \"../../kit/map-full-screen/MapFullScreenCanvasBody\";\nimport { ImageGalleryCanvasBody } from \"../../widgets/ImageGalleryConversationWidget/ImageGalleryCanvasBody\";\n\nexport type { CanvasBodyProps } from \"./canvas-body-props\";\nexport { canvasFeatureFlagOf } from \"./canvas-feature-flags\";\n\n/**\n * THE CANVAS BODIES — canvas id → the React component the shell mounts in the canvas pane. The one module that knows\n * both the canvas ids and React components, and it is imported ONLY by `CanvasPane` (the shell), never by\n * the slice, the behaviours or a widget — that is the import layering that keeps the store-init temporal-dead-zone\n * cycle away. The bodies themselves are small: a body that hosts a heavy page (an app's list page or editor)\n * lazy-loads that page, exactly as its widget did. Every canvas has a body; nothing\n * else hands the pane a rendered node.\n *\n * The package's own bodies are listed here; an app adds the bodies of its canvases with `registerCanvasBodies` before\n * the first render. The object is filled in place, so the shell reads every registration.\n */\nexport const canvasBodies = {\n conversationSearchResults: ConversationSearchResultsCanvasBody,\n webSearchResults: WebSearchResultsCanvasBody,\n entityDetail: EntityDetailCanvasBody,\n mapFullScreen: MapFullScreenCanvasBody,\n imageGallery: ImageGalleryCanvasBody,\n} as Record<CanvasId, React.ComponentType<CanvasBodyProps>>;\n\n/** Adds an app's canvas bodies (canvas id → body). Runs outside React, before the first render. */\nexport const registerCanvasBodies = (\n bodies: Readonly<Partial<Record<CanvasId, React.ComponentType<CanvasBodyProps>>>>,\n): void => {\n Object.assign(canvasBodies, bodies);\n};\n"],"names":["canvasStyle","scrollStyle","contentStyle","entityName"],"mappings":";;;;;;;AAWO,MAAM,yBAAyB,CACpC,QACA,uBACA,eAEA,QAAQ,MAAM;AACZ,MAAI,OAAO,OAAO,SAAS,aAAa,0BAA0B,KAAM,QAAO;AAC/E,QAAM,cAAc,wBAAwB,OAAO,UAAU;AAC7D,MAAI,gBAAgB,QAAW;AAC7B,WAAO,6BAA6B,uBAAuB,YAAY,WAAW,GAAG;AAAA,EACvF;AACA,SAAO,2BAA2B,qBAAqB,EAAE,KAAK,CAAC,UAAU,MAAM,SAAS,UAAU,GAAG;AACvG,GAAG,CAAC,OAAO,QAAQ,OAAO,YAAY,uBAAuB,UAAU,CAAC;ACR1E,MAAMA,gBAAmC;AAAA,EACvC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,eAAe;AAAA,EACf,WAAW;AAAA,EACX,YAAY;AACd;AACA,MAAMC,gBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,WAAW;AAAA,EACX,WAAW;AACb;AACA,MAAMC,iBAAoC;AAAA,EACxC,SAAS;AACX;AAGO,MAAM,kCAAkC,CAAC,8BAC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AO,CAAC;AAC3G,QAAM,EAAE,SAAA,IAAa,6BAAA;AACrB,QAAM,kBAAkB,OAAO,OAAO,SAAS,YAAY,OAAO,OAAO,YAAY;AACrF,QAAM,UAAU,QAAQ,MAAM;AAC5B,QAAI,CAAC,YAAY,oBAAoB,OAAW,QAAO;AACvD,UAAM,YAAY,SAAS,UAAU,CAAC,YAAY,OAAO,QAAQ,EAAE,MAAM,OAAO,eAAe,CAAC;AAChG,WAAO,cAAc,MAAM,SAAS,MAAM,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,QAAQ,SAAS,MAAM;AAAA,EACpG,GAAG,CAAC,UAAU,eAAe,CAAC;AAC9B,MAAI,YAAY,KAAM,QAAO;AAC7B,SAAO,oBAAC,gBAAa,SAAkB,aAAa,CAAC,SAAS,SAAQ,UAAS,QAAO,8BAAA,CAA8B;AACtH;ACAO,MAAM,eAAe;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAChB;AAGO,MAAM,uBAAuB,CAClC,WACS;AACT,SAAO,OAAO,cAAc,MAAM;AACpC;"}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { i as isCanvasId } from "./WebSearchResultsConversationWidget-W7O1fBB0.js";
2
+ import { i as isCanvasId } from "./WebSearchResultsConversationWidget-CUtKAdMM.js";
3
3
  const CANVAS_STORAGE_KEY_PREFIX = "agent.canvas.";
4
4
  const canvasStorageKey = (conversationId) => `${CANVAS_STORAGE_KEY_PREFIX}${conversationId}`;
5
5
  const isPositiveInteger = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
@@ -62,4 +62,4 @@ export {
62
62
  readStoredCanvas as r,
63
63
  storeOpenCanvas as s
64
64
  };
65
- //# sourceMappingURL=canvasStorage-DaM9851h.js.map
65
+ //# sourceMappingURL=canvasStorage-D9EnBraV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvasStorage-DaM9851h.js","sources":["../../src/renderer/canvas/canvasStorage.ts"],"sourcesContent":["import { isCanvasId } from \"./canvas-behaviours\";\nimport type { CanvasAnchor, CanvasState } from \"./canvas-state\";\n\n/**\n * Where the open canvas of a conversation is remembered across a reload: `sessionStorage`, per conversation, holding\n * the POINTER only — which canvas, which anchor, which instance, and the entity a body created. Never\n * content: the anchor message's fence supplies the body's data on restore. Tab-local by design (the canvas is viewing\n * state of this tab); a new tab starts with no canvas.\n *\n * Written on every change of the open canvas for ANY lifetime, cleared when the canvas closes; on read the pointer is\n * validated shape by shape — a stale id or a mangled entry reads as \"nothing stored\". Every accessor is try/catch-\n * guarded: a private window, blocked site data or a preview context can throw on the accessor itself.\n */\nexport interface StoredCanvasPointer {\n readonly canvasId: CanvasState[\"canvasId\"];\n readonly anchor: CanvasAnchor;\n readonly instanceId: string;\n readonly createdEntityId?: number;\n}\n\nconst CANVAS_STORAGE_KEY_PREFIX = \"agent.canvas.\";\n\nconst canvasStorageKey = (conversationId: number): string => `${CANVAS_STORAGE_KEY_PREFIX}${conversationId}`;\n\nconst isPositiveInteger = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isInteger(value) && value > 0;\n\nconst parseAnchor = (value: unknown): CanvasAnchor | null => {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as { kind?: unknown; messageId?: unknown; agentSpaceKey?: unknown };\n if (candidate.kind === \"message\" && isPositiveInteger(candidate.messageId)) {\n return { kind: \"message\", messageId: candidate.messageId };\n }\n if (candidate.kind === \"page\" && isPositiveInteger(candidate.agentSpaceKey)) {\n return { kind: \"page\", agentSpaceKey: candidate.agentSpaceKey };\n }\n return null;\n};\n\n/** Validate an untrusted value into a pointer, or null. Exported for the spec and for the shell's restore path. */\nexport const parseStoredCanvasPointer = (value: unknown): StoredCanvasPointer | null => {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as { canvasId?: unknown; anchor?: unknown; instanceId?: unknown; createdEntityId?: unknown };\n const anchor = parseAnchor(candidate.anchor);\n if (!isCanvasId(candidate.canvasId) || anchor === null) return null;\n if (typeof candidate.instanceId !== \"string\" || candidate.instanceId.length === 0) return null;\n return {\n canvasId: candidate.canvasId,\n anchor,\n instanceId: candidate.instanceId,\n ...(isPositiveInteger(candidate.createdEntityId) ? { createdEntityId: candidate.createdEntityId } : {}),\n };\n};\n\n/** Remember the canvas open in this conversation. No-op without a conversation id (a cold chat has none yet). */\nexport const storeOpenCanvas = (conversationId: number | undefined, canvas: CanvasState): void => {\n if (conversationId === undefined) return;\n const pointer: StoredCanvasPointer = {\n canvasId: canvas.canvasId,\n anchor: canvas.anchor,\n instanceId: canvas.instanceId,\n ...(canvas.createdEntityId !== undefined ? { createdEntityId: canvas.createdEntityId } : {}),\n };\n try {\n window.sessionStorage.setItem(canvasStorageKey(conversationId), JSON.stringify(pointer));\n } catch {\n // Storage unavailable — the canvas then simply does not survive the reload.\n }\n};\n\n/** The canvas that was open in this conversation, validated, or null (nothing stored, stale, or storage unusable). */\nexport const readStoredCanvas = (conversationId: number | undefined): StoredCanvasPointer | null => {\n if (conversationId === undefined) return null;\n try {\n const raw = window.sessionStorage.getItem(canvasStorageKey(conversationId));\n if (raw === null) return null;\n return parseStoredCanvasPointer(JSON.parse(raw));\n } catch {\n return null;\n }\n};\n\n/** Forget the canvas of this conversation — it closed, or its anchor is no longer among the loaded messages. */\nexport const clearStoredCanvas = (conversationId: number | undefined): void => {\n if (conversationId === undefined) return;\n try {\n window.sessionStorage.removeItem(canvasStorageKey(conversationId));\n } catch {\n // Storage unavailable — nothing was stored either.\n }\n};\n"],"names":[],"mappings":";;AAoBA,MAAM,4BAA4B;AAElC,MAAM,mBAAmB,CAAC,mBAAmC,GAAG,yBAAyB,GAAG,cAAc;AAE1G,MAAM,oBAAoB,CAAC,UACzB,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,QAAQ;AAElE,MAAM,cAAc,CAAC,UAAwC;AAC3D,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,Y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O,yBAAyB,KAAK,MAAM,GAAG,CAAC;AAAA,EACjD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,MAAM,oBAAoB,CAAC,mBAA6C;AAC7E,MAAI,mBAAmB,OAAW;AAClC,MAAI;AACF,WAAO,eAAe,WAAW,iBAAiB,cAAc,CAAC;AAAA,EACnE,QAAQ;AAAA,EAER;AACF;"}
1
+ {"version":3,"file":"canvasStorage-D9EnBraV.js","sources":["../../src/renderer/canvas/canvasStorage.ts"],"sourcesContent":["import { isCanvasId } from \"./canvas-behaviours\";\nimport type { CanvasAnchor, CanvasState } from \"./canvas-state\";\n\n/**\n * Where the open canvas of a conversation is remembered across a reload: `sessionStorage`, per conversation, holding\n * the POINTER only — which canvas, which anchor, which instance, and the entity a body created. Never\n * content: the anchor message's fence supplies the body's data on restore. Tab-local by design (the canvas is viewing\n * state of this tab); a new tab starts with no canvas.\n *\n * Written on every change of the open canvas for ANY lifetime, cleared when the canvas closes; on read the pointer is\n * validated shape by shape — a stale id or a mangled entry reads as \"nothing stored\". Every accessor is try/catch-\n * guarded: a private window, blocked site data or a preview context can throw on the accessor itself.\n */\nexport interface StoredCanvasPointer {\n readonly canvasId: CanvasState[\"canvasId\"];\n readonly anchor: CanvasAnchor;\n readonly instanceId: string;\n readonly createdEntityId?: number;\n}\n\nconst CANVAS_STORAGE_KEY_PREFIX = \"agent.canvas.\";\n\nconst canvasStorageKey = (conversationId: number): string => `${CANVAS_STORAGE_KEY_PREFIX}${conversationId}`;\n\nconst isPositiveInteger = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isInteger(value) && value > 0;\n\nconst parseAnchor = (value: unknown): CanvasAnchor | null => {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as { kind?: unknown; messageId?: unknown; agentSpaceKey?: unknown };\n if (candidate.kind === \"message\" && isPositiveInteger(candidate.messageId)) {\n return { kind: \"message\", messageId: candidate.messageId };\n }\n if (candidate.kind === \"page\" && isPositiveInteger(candidate.agentSpaceKey)) {\n return { kind: \"page\", agentSpaceKey: candidate.agentSpaceKey };\n }\n return null;\n};\n\n/** Validate an untrusted value into a pointer, or null. Exported for the spec and for the shell's restore path. */\nexport const parseStoredCanvasPointer = (value: unknown): StoredCanvasPointer | null => {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as { canvasId?: unknown; anchor?: unknown; instanceId?: unknown; createdEntityId?: unknown };\n const anchor = parseAnchor(candidate.anchor);\n if (!isCanvasId(candidate.canvasId) || anchor === null) return null;\n if (typeof candidate.instanceId !== \"string\" || candidate.instanceId.length === 0) return null;\n return {\n canvasId: candidate.canvasId,\n anchor,\n instanceId: candidate.instanceId,\n ...(isPositiveInteger(candidate.createdEntityId) ? { createdEntityId: candidate.createdEntityId } : {}),\n };\n};\n\n/** Remember the canvas open in this conversation. No-op without a conversation id (a cold chat has none yet). */\nexport const storeOpenCanvas = (conversationId: number | undefined, canvas: CanvasState): void => {\n if (conversationId === undefined) return;\n const pointer: StoredCanvasPointer = {\n canvasId: canvas.canvasId,\n anchor: canvas.anchor,\n instanceId: canvas.instanceId,\n ...(canvas.createdEntityId !== undefined ? { createdEntityId: canvas.createdEntityId } : {}),\n };\n try {\n window.sessionStorage.setItem(canvasStorageKey(conversationId), JSON.stringify(pointer));\n } catch {\n // Storage unavailable — the canvas then simply does not survive the reload.\n }\n};\n\n/** The canvas that was open in this conversation, validated, or null (nothing stored, stale, or storage unusable). */\nexport const readStoredCanvas = (conversationId: number | undefined): StoredCanvasPointer | null => {\n if (conversationId === undefined) return null;\n try {\n const raw = window.sessionStorage.getItem(canvasStorageKey(conversationId));\n if (raw === null) return null;\n return parseStoredCanvasPointer(JSON.parse(raw));\n } catch {\n return null;\n }\n};\n\n/** Forget the canvas of this conversation — it closed, or its anchor is no longer among the loaded messages. */\nexport const clearStoredCanvas = (conversationId: number | undefined): void => {\n if (conversationId === undefined) return;\n try {\n window.sessionStorage.removeItem(canvasStorageKey(conversationId));\n } catch {\n // Storage unavailable — nothing was stored either.\n }\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AACF,WAAO,eAAe,QAAQ,iBAAiB,cAAc,GAAG,KAAK,UAAU,OAAO,CAAC;AAAA,EACzF,QAAQ;AAAA,EAER;AACF;AAGO,MAAM,mBAAmB,CAAC,mBAAmE;AAClG,MAAI,mBAAmB,OAAW,QAAO;AACzC,MAAI;AACF,UAAM,MAAM,OAAO,eAAe,QAAQ,iBAAiB,cAAc,CAAC;AAC1E,QAAI,QAAQ,KAAM,QAAO;AACzB,WAAO,yBAAyB,KAAK,MAAM,GAAG,CAAC;AAAA,EACjD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,MAAM,oBAAoB,CAAC,mBAA6C;AAC7E,MAAI,mBAAmB,OAAW;AAClC,MAAI;AACF,WAAO,eAAe,WAAW,iBAAiB,cAAc,CAAC;AAAA,EACnE,QAAQ;AAAA,EAER;AACF;"}
@@ -909,6 +909,18 @@ const openImageGallery = (images, startIndex) => {
909
909
  if (appEnvironment.onNavigate?.(startImage.url, null) === true) return;
910
910
  window.open(startImage.url, "_blank", "noopener,noreferrer");
911
911
  };
912
+ const canStartConversationInPersonalSpace = () => appEnvironment.startConversationInPersonalSpace !== void 0;
913
+ const startConversationInPersonalSpace = (ownerText) => {
914
+ if (!appEnvironment.startConversationInPersonalSpace) return false;
915
+ appEnvironment.startConversationInPersonalSpace(ownerText);
916
+ return true;
917
+ };
918
+ const canOpenConnectionPermissions = () => appEnvironment.openConnectionPermissions !== void 0;
919
+ const openConnectionPermissions = (target) => {
920
+ if (!appEnvironment.openConnectionPermissions) return false;
921
+ appEnvironment.openConnectionPermissions(target);
922
+ return true;
923
+ };
912
924
  const DEFAULT_WIDGET_SELF_HYDRATION_KEY_FIELD_NAME = "agentSpaceId";
913
925
  const getWidgetSelfHydrationKeyFieldName = () => appEnvironment.widgetSelfHydrationKeyFieldName ?? DEFAULT_WIDGET_SELF_HYDRATION_KEY_FIELD_NAME;
914
926
  const appendAnotherAgentSpaceToOwnerText = (ownerText, anotherAgentSpaceKey) => appEnvironment.appendAnotherAgentSpaceToOwnerText ? appEnvironment.appendAnotherAgentSpaceToOwnerText(ownerText, anotherAgentSpaceKey) : ownerText;
@@ -1201,6 +1213,10 @@ export {
1201
1213
  WidgetHydrationSlice as ae,
1202
1214
  createAgentsWidgetHydrationStateStore as af,
1203
1215
  getDefaultAgentsStateStore as ag,
1216
+ canStartConversationInPersonalSpace as ah,
1217
+ startConversationInPersonalSpace as ai,
1218
+ canOpenConnectionPermissions as aj,
1219
+ openConnectionPermissions as ak,
1204
1220
  ConversationSearchResultsList as b,
1205
1221
  DEFAULT_AGENTS_TEXTS as c,
1206
1222
  DEFAULT_WIDGET_IMAGE_CAPTURE_READ_PATH_PREFIX as d,
@@ -1227,4 +1243,4 @@ export {
1227
1243
  appendAnotherAgentSpaceToOwnerText as y,
1228
1244
  buildUnnamedAgentSpaceLabel as z
1229
1245
  };
1230
- //# sourceMappingURL=link-navigation-BUcy5qWW.js.map
1246
+ //# sourceMappingURL=link-navigation-DRHt6g7U.js.map