@mgamadeus/ddd-agents 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -2
- package/dist/chat.js +132 -111
- package/dist/chat.js.map +1 -1
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BO3jS0eZ.js → ConversationMessageInputComposerWidgets-r_RwCqr7.js} +11 -8
- package/dist/chunks/ConversationMessageInputComposerWidgets-r_RwCqr7.js.map +1 -0
- package/dist/chunks/{WebSearchResultsConversationWidget-H6cbTapV.js → WebSearchResultsConversationWidget-BXt98hGu.js} +161 -102
- package/dist/chunks/WebSearchResultsConversationWidget-BXt98hGu.js.map +1 -0
- package/dist/chunks/{canvas-behaviours-AvzKSYyv.js → canvas-behaviours-BpN_1xdZ.js} +2 -2
- package/dist/chunks/{canvas-behaviours-AvzKSYyv.js.map → canvas-behaviours-BpN_1xdZ.js.map} +1 -1
- package/dist/chunks/{canvas-reducers-Cdxt8yDF.js → canvas-reducers-CuX6L1zg.js} +3 -3
- package/dist/chunks/{canvas-reducers-Cdxt8yDF.js.map → canvas-reducers-CuX6L1zg.js.map} +1 -1
- package/dist/chunks/{canvasBodies-CsLrZ-M-.js → canvasBodies-Ds-cTn47.js} +9 -6
- package/dist/chunks/{canvasBodies-CsLrZ-M-.js.map → canvasBodies-Ds-cTn47.js.map} +1 -1
- package/dist/chunks/{canvasStorage-EvQsGdto.js → canvasStorage-DHNluopA.js} +2 -2
- package/dist/chunks/{canvasStorage-EvQsGdto.js.map → canvasStorage-DHNluopA.js.map} +1 -1
- package/dist/chunks/compose-attachment-message-text-FvVJbrge.js +8 -0
- package/dist/chunks/compose-attachment-message-text-FvVJbrge.js.map +1 -0
- package/dist/chunks/{contract-BxmMxYPF.js → contract-Z08LBOqt.js} +4 -3
- package/dist/chunks/contract-Z08LBOqt.js.map +1 -0
- package/dist/chunks/conversation-BEF0aesf.js.map +1 -1
- package/dist/chunks/host-color-scheme-Jhb7JZR7.js +30 -0
- package/dist/chunks/host-color-scheme-Jhb7JZR7.js.map +1 -0
- package/dist/chunks/{index-7Qc_3GbG.js → link-navigation-DyTApNeA.js} +156 -73
- package/dist/chunks/link-navigation-DyTApNeA.js.map +1 -0
- package/dist/chunks/text-key-DnoZ4lAk.js +6 -0
- package/dist/chunks/text-key-DnoZ4lAk.js.map +1 -0
- package/dist/chunks/{widget-click-signal-sources-1gIs1yiN.js → widget-click-signal-sources-Ch-y8gxw.js} +9 -5
- package/dist/chunks/{widget-click-signal-sources-1gIs1yiN.js.map → widget-click-signal-sources-Ch-y8gxw.js.map} +1 -1
- package/dist/chunks/{widget-image-readiness-signal-D3ci53xr.js → widget-image-readiness-signal-C5yaKpJJ.js} +2 -2
- package/dist/chunks/{widget-image-readiness-signal-D3ci53xr.js.map → widget-image-readiness-signal-C5yaKpJJ.js.map} +1 -1
- package/dist/chunks/{widget-name-resolver-D_ZzXy-Q.js → widget-name-resolver-DboFMAq2.js} +25 -25
- package/dist/chunks/widget-name-resolver-DboFMAq2.js.map +1 -0
- package/dist/chunks/{withPollingChangeSubscription-B16htQGd.js → withPollingChangeSubscription-CNXgt3Ri.js} +6 -2
- package/dist/chunks/withPollingChangeSubscription-CNXgt3Ri.js.map +1 -0
- package/dist/client-testing.js +6 -7
- package/dist/client-testing.js.map +1 -1
- package/dist/client.js +431 -2
- package/dist/client.js.map +1 -1
- package/dist/contract.js +1 -1
- package/dist/files/chat/Conversation.module.scss +1 -1
- package/dist/files/chat/ConversationViewBody/ConversationViewBody.module.scss +1 -1
- package/dist/files/i18n-keys.json +1617 -0
- package/dist/files/image-render/WidgetImageRender.module.scss +9 -3
- package/dist/files/styles/_surfaces.scss +6 -6
- package/dist/image-render.js +7 -7
- package/dist/index.js +64 -55
- package/dist/index.js.map +1 -1
- package/dist/kit.js +2 -2
- package/dist/preview.js +8 -8
- package/dist/provider.js +61 -52
- package/dist/provider.js.map +1 -1
- package/dist/renderer.js +16 -15
- package/dist/styles.css +170 -107
- package/dist/types/chat/AgentChat/AgentChat.d.ts +6 -0
- package/dist/types/chat/controller/AgentChatController.d.ts +28 -1
- package/dist/types/client/AgentsConversationClient.d.ts +7 -1
- package/dist/types/client/compose-attachment-message-text.d.ts +7 -0
- package/dist/types/client/http/agents-http-mappers.d.ts +23 -0
- package/dist/types/client/http/agents-http-wire.d.ts +188 -0
- package/dist/types/client/http/createAgentsHttpConversationClient.d.ts +55 -0
- package/dist/types/client/polling/createPollingConversationChangeSubscription.d.ts +7 -4
- package/dist/types/client/polling/withPollingChangeSubscription.d.ts +3 -2
- package/dist/types/contract/conversation.d.ts +8 -0
- package/dist/types/entries/chat.d.ts +2 -1
- package/dist/types/entries/client.d.ts +4 -0
- package/dist/types/entries/renderer.d.ts +1 -0
- package/dist/types/entries/widgets.d.ts +1 -1
- package/dist/types/provider/components/types.d.ts +5 -2
- package/dist/types/provider/environment.d.ts +13 -0
- package/dist/types/provider/host-color-scheme.d.ts +24 -0
- package/dist/types/provider/index.d.ts +4 -0
- package/dist/types/provider/link-navigation.d.ts +28 -0
- package/dist/types/provider/text-key.d.ts +6 -0
- package/dist/types/renderer/MarkdownLink.d.ts +8 -6
- package/dist/types/widgets/CanvasLauncherWidget/use-canvas-viable.d.ts +43 -9
- package/dist/types/widgets/EntityMentionConversationWidget/shared/entity-mention-presentation.d.ts +1 -1
- package/dist/types/widgets/_shared/modern/WidgetKpiValue.d.ts +2 -1
- package/dist/widgets.js +43 -40
- package/package.json +8 -6
- package/public-api.json +85 -18
- package/dist/chunks/ConversationMessageInputComposerWidgets-BO3jS0eZ.js.map +0 -1
- package/dist/chunks/WebSearchResultsConversationWidget-H6cbTapV.js.map +0 -1
- package/dist/chunks/contract-BxmMxYPF.js.map +0 -1
- package/dist/chunks/index-7Qc_3GbG.js.map +0 -1
- package/dist/chunks/widget-name-resolver-D_ZzXy-Q.js.map +0 -1
- package/dist/chunks/withPollingChangeSubscription-B16htQGd.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-BEF0aesf.js","sources":["../../src/contract/conversation.ts"],"sourcesContent":["/**\n * The conversation contract of the package: plain TypeScript types the conversation client port\n * (`client/AgentsConversationClient.ts`) returns and the chat reads. Every field is derived from what the chat files and\n * the chat controller read from the server today (the host application's generated `AIConversation`, `AIConversationMessage`,\n * `AgentActivityLine`, `SemanticSearchHit`, `AIConversationSearchGroup`, `AgentCustomerSelectableModel`); nothing the\n * chat does not read is here.\n *\n * Naming: a field keeps the wire name where the name is neutral (`message`, `indexInConversation`, `role`, `status`,\n * `toolCall`); a name that carries an app's vocabulary is renamed (`aiConversationId` → `conversationId`,\n * the app's own key of the thing the agent works for → `agentSpaceKey`, `summary.title` → `title`). Each field carries a\n * one-line note:\n * - `generic` — every app that runs the agent conversation backend has it;\n * - `app extension` — read by the chat today but specific to one app's backend or debug surface; optional, and a\n * binding may leave it out.\n *\n * Client-side state is NOT part of the contract: the `fresh` tag of a live-arrived message, the optimistic user\n * message without an id and the `isNewConversation` / `isReopenedConversation` flags belong to the package store.\n */\n\n// ── Vocabulary ───────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** The run state of a conversation as the server stores it (`AIConversationRunState`). */\nexport type ConversationRunState =\n | \"IDLE\"\n | \"QUEUED\"\n | \"RUNNING\"\n | \"AWAITING_DELEGATES\"\n | \"FAILED\"\n | \"COMPLETED\"\n | \"CANCELLED\";\n\n/** The three-value run status the live-update signal speaks; the chat keys its indicator and error card off it. */\nexport type ConversationRunStatus = \"running\" | \"idle\" | \"failed\";\n\nexport type ConversationMessageRole = \"SYSTEM\" | \"USER\" | \"ASSISTANT\";\n\nexport type ConversationMessageType = \"TEXT\" | \"TOOL_CALL\" | \"CHECKPOINT\" | \"ERROR\" | \"SIGNAL\" | \"TOOL_MESSAGE\";\n\nexport type ConversationMessageStatus =\n | \"PENDING\"\n | \"RUNNING\"\n | \"CANCEL_REQUESTED\"\n | \"CANCELLED\"\n | \"COMPLETED\"\n | \"FAILED\";\n\nexport type ConversationMessageAuthorType = \"USER\" | \"ASSISTANT\" | \"AGENT\" | \"TOOL\";\n\n/** Run states after which nothing runs any more and the server refuses further customer input. */\nexport const CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION: readonly ConversationRunState[] = [\n \"COMPLETED\",\n \"CANCELLED\",\n];\n\n/** Maps a stored run state onto the signal's three-value status (`runStateToSignalStatus` of the live-update hook). */\nexport const readConversationRunStatusOfRunState = (\n runState: string | null | undefined,\n): ConversationRunStatus | null => {\n if (!runState) return null;\n if (runState === \"FAILED\") return \"failed\";\n if (runState === \"RUNNING\" || runState === \"AWAITING_DELEGATES\" || runState === \"QUEUED\") return \"running\";\n return \"idle\";\n};\n\n// ── Conversation ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** One step of the progress stepper a purposed conversation declares (`CustomerProgressStep`). */\nexport interface ConversationProgressStep {\n /** generic */\n key: string;\n /** generic — already in the owner's language */\n label: string;\n /** generic */\n status: \"done\" | \"active\" | \"upcoming\";\n}\n\n/** A conversation as the chat, the conversation list and the window around the chat read it. */\nexport interface AgentsConversation {\n /** generic */\n id: number;\n /** generic — the key of the agent space the conversation belongs to */\n agentSpaceKey: number | null;\n /** generic */\n runState: ConversationRunState | null;\n /**\n * generic — set while the server owes a turn on an IDLE conversation (a failed hand-over the recovery re-drives);\n * an IDLE conversation with this set counts as running (`effectiveRunState`)\n */\n agentTurnOwedAt: string | null;\n /** generic — the display title (`summary.title`); null until the first title was generated */\n title: string | null;\n /** generic — the owner set the title by hand; the generated title never replaces it then */\n titleManuallyEdited: boolean;\n /** generic — the generated summary of what the conversation is about (`summary.text`); null until generated */\n summary: string | null;\n /** generic — when the conversation was created, in the server's date-time format */\n created: string | null;\n /** generic — when the conversation was last modified, in the server's date-time format */\n updated: string | null;\n /** generic — the purpose of a purposed conversation (e.g. `Example.Build`, a first-run setup purpose); null otherwise */\n purposeName: string | null;\n /** generic — who started the conversation (`SCHEDULE` for a run of a scheduled task) */\n initiatorType: string | null;\n /** generic — the scheduled task a `SCHEDULE` conversation is a run of */\n scheduleId: number | null;\n /** generic — the entry point a start came from; a start from the same entry point reopens this conversation */\n entryPointKey: string | null;\n /** generic — empty unless the purpose declares a progress stepper */\n progressSteps: ConversationProgressStep[];\n /**\n * generic — the id of the newest stored message; null before the first. The polling default of the live updates\n * (`client/polling/`) reads it to see a new message while the run status stays the same, and hands it to the rules as\n * the signal's `lastMessageId`. Optional: a binding with a push transport may leave it out (the host application's metadata\n * read does not carry it); without it the poller treats every poll of a running turn as a change.\n */\n lastMessageId?: number | null;\n /** app extension — the prompt extension of the host application's older AI-Extensions chat */\n promptExtensionId?: number | null;\n /** app extension — the category of that prompt extension (its colour and product name in the conversation list) */\n promptExtensionCategory?: { alias: string | null; name: string | null } | null;\n}\n\n// ── Messages ─────────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** A sub-agent conversation a delegation started, as far as the chat reads it (`delegatedConversations(select=id,runState)`). */\nexport interface ConversationDelegatedConversation {\n /** generic */\n id: number;\n /** generic */\n runState: ConversationRunState | null;\n}\n\n/** One run of a sub-agent, as the activity derivation reads it (`DelegationSubAgentRun`). */\nexport interface ConversationSubAgentRun {\n /** generic */\n runNumber: number | null;\n /** generic */\n status: string | null;\n}\n\n/** The sub-agent record a newer `delegate` call row carries instead of expanded children (`DelegationSubAgentRecord`). */\nexport interface ConversationSubAgent {\n /** generic */\n currentRunNumber: number | null;\n /** generic */\n runs: ConversationSubAgentRun[];\n}\n\n/** The tool call a `TOOL_CALL` row carries, as far as the chat reads it. */\nexport interface ConversationToolCall {\n /** generic */\n toolCallId: string | null;\n /** generic */\n name: string | null;\n /** generic — the call's arguments as the model wrote them (the `delegate` call's `tasks` is read) */\n arguments: unknown;\n /** generic — the call's own progress; a row's `status` says nothing about it */\n status: string | null;\n}\n\n/** The admin debug numbers of one message (the message forensics panel). */\nexport interface ConversationMessageForensics {\n /** app extension */\n inputTokens: number | null;\n /** app extension */\n outputTokens: number | null;\n /** app extension */\n costInUSD: number | null;\n /** app extension — the stored request snapshot of the model call (model name, reasoning effort, sent at) */\n requestSnapshot: unknown;\n}\n\n/** One stored message of a conversation. */\nexport interface AgentsConversationMessage {\n /** generic */\n id: number;\n /** generic */\n conversationId: number | null;\n /** generic — the position in the conversation; the merge key of every page */\n indexInConversation: number | null;\n /** generic */\n role: ConversationMessageRole | null;\n /** generic */\n messageType: ConversationMessageType | null;\n /** generic — non-final only on a waiting signal row */\n status: ConversationMessageStatus | null;\n /** generic */\n authorType: ConversationMessageAuthorType | null;\n /** generic — the source of a SIGNAL or ERROR row (`AI_BUDGET_REACHED`, `FRONTEND_WIDGET_CLICK`, …) */\n signalSource: string | null;\n /** generic — the text in markdown, widget blocks included */\n message: string;\n /** generic */\n createdDate: string | null;\n /** generic */\n toolCall: ConversationToolCall | null;\n /** generic — the sub-agent conversations a `delegate` call started (older rows) */\n delegatedConversations: ConversationDelegatedConversation[];\n /** generic — the sub-agent record of a `delegate` call (newer rows) */\n subAgent: ConversationSubAgent | null;\n /** app extension — admin debug numbers; absent outside the admin surfaces */\n forensics?: ConversationMessageForensics;\n}\n\n/** A file from the app's media library that rides along with a message. */\nexport interface ConversationAttachmentReference {\n /** generic — the app's id of the file (host application: the media manager file id) */\n fileId: string | number | null;\n /** generic */\n fileName: string | null;\n /** generic — a URL the model and the tools can fetch */\n publicUrl: string | null;\n}\n\n// ── Pages and results of the port ────────────────────────────────────────────────────────────────────────────────\n\n/** A page of messages read newest first (the newest page on open, an older page on scroll-up). */\nexport interface ConversationMessagesPage {\n /** generic — in any order; the store merges by `indexInConversation` */\n messages: AgentsConversationMessage[];\n /** generic — an older page exists */\n hasMoreOlder: boolean;\n}\n\n/**\n * What a live update reads: every message written since the newest known id, plus every message from the lowest\n * loaded index that can still change (`build-live-refetch-query.ts`). The package computes both values.\n */\nexport interface ChangedMessagesRequest {\n /** generic — the highest message id loaded */\n highestKnownId: number;\n /** generic — the lowest index that can still change, never below the newest page */\n fromIndex: number;\n /** generic — the page size of the read; the binding's default (host application: 50, as the chat sends) when omitted */\n pageSize?: number;\n}\n\n/** The answer of a changed-messages read; it says nothing about older pages (the store keeps `hasMoreOlder`). */\nexport interface ChangedConversationMessages {\n /** generic */\n messages: AgentsConversationMessage[];\n}\n\n/** The answer of a start: the new conversation with what it holds so far, or the reopened one of the entry point. */\nexport interface StartedConversation {\n /** generic */\n conversation: AgentsConversation;\n /** generic — the stored messages of a new conversation; empty for a reopened one (the chat reads its newest page) */\n messages: AgentsConversationMessage[];\n /** generic — the start returned the recent conversation of its entry point; nothing was appended, no turn started */\n reopenedExisting: boolean;\n}\n\n/** The answer of a post: the conversation's messages so far (the reply arrives through live updates). */\nexport interface PostedMessage {\n /** generic */\n messages: AgentsConversationMessage[];\n}\n\n/** A model-visible, owner-invisible note into a conversation (a widget click, a render report, a correction). */\nexport interface ConversationSignal {\n /** generic */\n text: string;\n /** generic — the signal source; the server's default applies when omitted (a widget click) */\n source?: string;\n}\n\n/** How a list read pages and which conversations it includes. */\nexport interface ConversationListQueryOptions {\n /** generic — include conversations that have no summary (title) yet, e.g. a just-started one */\n includeUnsummarized?: boolean;\n /** generic — the host application's history reads the newest 50 */\n paging?: { top?: number; skip?: number };\n}\n\n/** The size of a search answer. */\nexport interface ConversationSearchOptions {\n /** generic — the most groups (or hits) returned; the host application's chat asks for 10 */\n limit?: number;\n /** generic — the excerpt length in characters; the host application's chat asks for 420 */\n excerptLength?: number;\n}\n\n/** app extension — the reconstructed request a model call was sent with (the admin details panel); opaque data. */\nexport type ConversationMessageSentPayload = unknown[];\n\n/** One matched message of a message search (`SemanticSearchHit`). */\nexport interface ConversationMessageSearchHit {\n /** generic */\n messageId: number | null;\n /** generic */\n conversationId: number | null;\n /** generic */\n indexInConversation: number | null;\n /** generic */\n role: string | null;\n /** generic */\n excerpt: string;\n /** generic */\n relevance: number;\n /** generic */\n created: string | null;\n /** generic */\n updated: string | null;\n /** generic — the conversation's title */\n title: string | null;\n}\n\n/** One conversation of a search across conversations, with its matched messages (`AIConversationSearchGroup`). */\nexport interface ConversationSearchGroup {\n /** generic */\n conversationId: number | null;\n /** generic */\n title: string | null;\n /** generic */\n summary: string | null;\n /** generic */\n created: string | null;\n /** generic */\n updated: string | null;\n /** generic */\n relevance: number;\n /** generic */\n hits: ConversationMessageSearchHit[];\n}\n\n/** One generated line of what the agent is doing (`AgentActivityLine`). */\nexport interface ConversationActivityElement {\n /** generic — the row the line narrates; the merge key */\n toolCallMessageId: number;\n /** generic */\n batchId: string | null;\n /** generic */\n state: \"queued\" | \"running\" | \"finished\" | \"failed\" | \"skipped\" | null;\n /** generic */\n kind: \"tool\" | \"delegation\" | \"background\" | \"long\" | \"turnStart\" | null;\n /** generic */\n childCount: number | null;\n /** generic — the 1-based delegation helper that ran the step; null for the assistant's own steps */\n helperIndex: number | null;\n /** generic — the sentence; null while the narrator has not answered */\n line: string | null;\n}\n\n/** The activity of one turn (`GET …/activity`). */\nexport interface ConversationActivity {\n /** generic — the message that started the narrated turn */\n turnMessageId: number | null;\n /** generic */\n turnRunning: boolean;\n /** generic */\n elements: ConversationActivityElement[];\n}\n\n/** A model the owner (host application: an impersonating admin) may pick for the next turns (`AgentCustomerSelectableModel`). */\nexport interface SelectableModel {\n /** generic — the name a send carries */\n name: string;\n /** generic */\n displayName: string;\n /** generic */\n description: string;\n /** generic */\n strengthLevel: number | null;\n /** generic */\n speedLevel: number | null;\n /** app extension — the host application's credit multiplier of the model */\n creditsMultiplier?: number | null;\n}\n\n// ── Live updates ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n/**\n * What a live update carries: a claim check, never content. The chat reads the conversation again when\n * `changeCounter` advances, at once on a terminal status, and until `lastMessageId` is loaded.\n */\nexport interface ConversationChangeSignal {\n /** generic — advances on every change of the conversation */\n changeCounter: number;\n /** generic — the newest message the server wrote; null before the first */\n lastMessageId: number | null;\n /** generic */\n runStatus: ConversationRunStatus | null;\n /** generic — advances when the title or summary was generated again (a light metadata read is enough then) */\n summaryUpdatedAt: number | null;\n /**\n * generic — the binding produced this emission from a run-state read, not from a pushed change (a binding without\n * push, or a push transport whose path is not proven readable, or a check that corrects a stale status). It carries\n * only `runStatus` as news: `changeCounter`, `lastMessageId` and `summaryUpdatedAt` repeat the last pushed values\n * (before any push: a counter that counts down from -1, never equal to a pushed one). The package sets the status\n * from it and reads the conversation again on a status change while the push path is not alive (`isPushPathAlive`).\n */\n isStatusCheck?: boolean;\n /**\n * generic, on a status-check emission — the binding's push path delivers: a pushed change arrived and the path was not\n * denied since. False after a denied read until a push arrives again; then the status checks are the live path and a\n * status change reads the conversation again. A binding without push leaves it out: the package then counts the\n * pushed changes it saw itself.\n */\n isPushPathAlive?: boolean;\n}\n\n/** Why a subscription ended for good: the conversation was deleted or is no longer readable, or the account lost access. */\nexport type ConversationSubscriptionEndReason = \"gone\" | \"forbidden\";\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\n/**\n * What went wrong, as the chat tells the owner. The codes the chat's error handling reads today map\n * onto it: `AI_BUDGET_REACHED` → `budget`, HTTP 429 / `RATE_LIMIT_EXCEEDED` → `rateLimit`, `CONVERSATION_CLOSED` →\n * `closed`, the not-found and no-access answers → `notFound` / `forbidden` (`conversation-not-found.ts`), no answer or a\n * server failure → `network`, everything else (a refused retry, a cancelled request) → `other` with its `code`.\n */\nexport type AgentsClientErrorKind = \"budget\" | \"rateLimit\" | \"closed\" | \"notFound\" | \"forbidden\" | \"network\" | \"other\";\n\n/** The code `other` carries for a request the client cancelled; the chat shows no error card for it. */\nexport const AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED = \"REQUEST_ABORTED\";\n\n/** The one error shape every port function rejects with. */\nexport class AgentsClientError extends Error {\n readonly kind: AgentsClientErrorKind;\n /** The server's stable error code, or the client's own code (`REQUEST_ABORTED`); null when none arrived. */\n readonly code: string | null;\n /** Seconds until a quota frees up again; set only for `rateLimit`. */\n readonly retryAfterSeconds: number | null;\n /** The HTTP status when one arrived (not part of the contract's shape; kept for diagnostics). */\n readonly httpStatus: number | null;\n\n constructor(\n kind: AgentsClientErrorKind,\n details: { message?: string; code?: string | null; retryAfterSeconds?: number | null; httpStatus?: number | null } = {},\n ) {\n super(details.message ?? kind);\n this.name = \"AgentsClientError\";\n this.kind = kind;\n this.code = details.code ?? null;\n this.retryAfterSeconds = kind === \"rateLimit\" ? (details.retryAfterSeconds ?? null) : null;\n this.httpStatus = details.httpStatus ?? null;\n }\n}\n\nexport const isAgentsClientError = (value: unknown): value is AgentsClientError => value instanceof AgentsClientError;\n"],"names":[],"mappings":";AAiDO,MAAM,oDAAqF;AAAA,EAChG;AAAA,EACA;AACF;AAGO,MAAM,sCAAsC,CACjD,aACiC;AACjC,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,aAAa,SAAU,QAAO;AAClC,MAAI,aAAa,aAAa,aAAa,wBAAwB,aAAa,SAAU,QAAO;AACjG,SAAO;AACT;AAkWO,MAAM,2CAA2C;AAGjD,MAAM,0BAA0B,MAAM;AAAA,EAS3C,YACE,MACA,UAAqH,IACrH;AACA,UAAM,QAAQ,WAAW,IAAI;AAC7B,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,oBAAoB,SAAS,cAAe,QAAQ,qBAAqB,OAAQ;AACtF,SAAK,aAAa,QAAQ,cAAc;AAAA,EAC1C;AACF;AAEO,MAAM,sBAAsB,CAAC,UAA+C,iBAAiB;"}
|
|
1
|
+
{"version":3,"file":"conversation-BEF0aesf.js","sources":["../../src/contract/conversation.ts"],"sourcesContent":["/**\n * The conversation contract of the package: plain TypeScript types the conversation client port\n * (`client/AgentsConversationClient.ts`) returns and the chat reads. Every field is derived from what the chat files and\n * the chat controller read from the server today (the host application's generated `AIConversation`, `AIConversationMessage`,\n * `AgentActivityLine`, `SemanticSearchHit`, `AIConversationSearchGroup`, `AgentCustomerSelectableModel`); nothing the\n * chat does not read is here.\n *\n * Naming: a field keeps the wire name where the name is neutral (`message`, `indexInConversation`, `role`, `status`,\n * `toolCall`); a name that carries an app's vocabulary is renamed (`aiConversationId` → `conversationId`,\n * the app's own key of the thing the agent works for → `agentSpaceKey`, `summary.title` → `title`). Each field carries a\n * one-line note:\n * - `generic` — every app that runs the agent conversation backend has it;\n * - `app extension` — read by the chat today but specific to one app's backend or debug surface; optional, and a\n * binding may leave it out.\n *\n * Client-side state is NOT part of the contract: the `fresh` tag of a live-arrived message, the optimistic user\n * message without an id and the `isNewConversation` / `isReopenedConversation` flags belong to the package store.\n */\n\n// ── Vocabulary ───────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** The run state of a conversation as the server stores it (`AIConversationRunState`). */\nexport type ConversationRunState =\n | \"IDLE\"\n | \"QUEUED\"\n | \"RUNNING\"\n | \"AWAITING_DELEGATES\"\n | \"FAILED\"\n | \"COMPLETED\"\n | \"CANCELLED\";\n\n/** The three-value run status the live-update signal speaks; the chat keys its indicator and error card off it. */\nexport type ConversationRunStatus = \"running\" | \"idle\" | \"failed\";\n\nexport type ConversationMessageRole = \"SYSTEM\" | \"USER\" | \"ASSISTANT\";\n\nexport type ConversationMessageType = \"TEXT\" | \"TOOL_CALL\" | \"CHECKPOINT\" | \"ERROR\" | \"SIGNAL\" | \"TOOL_MESSAGE\";\n\nexport type ConversationMessageStatus =\n | \"PENDING\"\n | \"RUNNING\"\n | \"CANCEL_REQUESTED\"\n | \"CANCELLED\"\n | \"COMPLETED\"\n | \"FAILED\";\n\nexport type ConversationMessageAuthorType = \"USER\" | \"ASSISTANT\" | \"AGENT\" | \"TOOL\";\n\n/** Run states after which nothing runs any more and the server refuses further customer input. */\nexport const CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION: readonly ConversationRunState[] = [\n \"COMPLETED\",\n \"CANCELLED\",\n];\n\n/** Maps a stored run state onto the signal's three-value status (`runStateToSignalStatus` of the live-update hook). */\nexport const readConversationRunStatusOfRunState = (\n runState: string | null | undefined,\n): ConversationRunStatus | null => {\n if (!runState) return null;\n if (runState === \"FAILED\") return \"failed\";\n if (runState === \"RUNNING\" || runState === \"AWAITING_DELEGATES\" || runState === \"QUEUED\") return \"running\";\n return \"idle\";\n};\n\n// ── Conversation ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** One step of the progress stepper a purposed conversation declares (`CustomerProgressStep`). */\nexport interface ConversationProgressStep {\n /** generic */\n key: string;\n /** generic — already in the owner's language */\n label: string;\n /** generic */\n status: \"done\" | \"active\" | \"upcoming\";\n}\n\n/** A conversation as the chat, the conversation list and the window around the chat read it. */\nexport interface AgentsConversation {\n /** generic */\n id: number;\n /** generic — the key of the agent space the conversation belongs to */\n agentSpaceKey: number | null;\n /** generic */\n runState: ConversationRunState | null;\n /**\n * generic — set while the server owes a turn on an IDLE conversation (a failed hand-over the recovery re-drives);\n * an IDLE conversation with this set counts as running (`effectiveRunState`)\n */\n agentTurnOwedAt: string | null;\n /** generic — the display title (`summary.title`); null until the first title was generated */\n title: string | null;\n /** generic — the owner set the title by hand; the generated title never replaces it then */\n titleManuallyEdited: boolean;\n /** generic — the generated summary of what the conversation is about (`summary.text`); null until generated */\n summary: string | null;\n /** generic — when the conversation was created, in the server's date-time format */\n created: string | null;\n /** generic — when the conversation was last modified, in the server's date-time format */\n updated: string | null;\n /** generic — the purpose of a purposed conversation (e.g. `Example.Build`, a first-run setup purpose); null otherwise */\n purposeName: string | null;\n /** generic — who started the conversation (`SCHEDULE` for a run of a scheduled task) */\n initiatorType: string | null;\n /** generic — the scheduled task a `SCHEDULE` conversation is a run of */\n scheduleId: number | null;\n /** generic — the entry point a start came from; a start from the same entry point reopens this conversation */\n entryPointKey: string | null;\n /** generic — empty unless the purpose declares a progress stepper */\n progressSteps: ConversationProgressStep[];\n /**\n * generic — the id of the newest stored message; null before the first. The polling default of the live updates\n * (`client/polling/`) reads it to see a new message while the run status stays the same, and hands it to the rules as\n * the signal's `lastMessageId`. Optional: a binding with a push transport may leave it out (the host application's metadata\n * read does not carry it); without it the poller treats every poll of a running turn as a change.\n */\n lastMessageId?: number | null;\n /** app extension — the prompt extension of the host application's older AI-Extensions chat */\n promptExtensionId?: number | null;\n /** app extension — the category of that prompt extension (its colour and product name in the conversation list) */\n promptExtensionCategory?: { alias: string | null; name: string | null } | null;\n}\n\n/**\n * What the server's run-state read answers (`GET …/{id}/runState`): the lean subset of a conversation the live updates\n * poll. Every `AgentsConversation` is one, so a binding without the read may answer it with the metadata read.\n */\nexport type ConversationRunStateRead = Pick<\n AgentsConversation,\n \"id\" | \"runState\" | \"agentTurnOwedAt\" | \"title\" | \"titleManuallyEdited\" | \"summary\" | \"updated\"\n> & {\n /** generic — the id of the newest stored message; null before the first */\n lastMessageId?: number | null;\n};\n\n// ── Messages ─────────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** A sub-agent conversation a delegation started, as far as the chat reads it (`delegatedConversations(select=id,runState)`). */\nexport interface ConversationDelegatedConversation {\n /** generic */\n id: number;\n /** generic */\n runState: ConversationRunState | null;\n}\n\n/** One run of a sub-agent, as the activity derivation reads it (`DelegationSubAgentRun`). */\nexport interface ConversationSubAgentRun {\n /** generic */\n runNumber: number | null;\n /** generic */\n status: string | null;\n}\n\n/** The sub-agent record a newer `delegate` call row carries instead of expanded children (`DelegationSubAgentRecord`). */\nexport interface ConversationSubAgent {\n /** generic */\n currentRunNumber: number | null;\n /** generic */\n runs: ConversationSubAgentRun[];\n}\n\n/** The tool call a `TOOL_CALL` row carries, as far as the chat reads it. */\nexport interface ConversationToolCall {\n /** generic */\n toolCallId: string | null;\n /** generic */\n name: string | null;\n /** generic — the call's arguments as the model wrote them (the `delegate` call's `tasks` is read) */\n arguments: unknown;\n /** generic — the call's own progress; a row's `status` says nothing about it */\n status: string | null;\n}\n\n/** The admin debug numbers of one message (the message forensics panel). */\nexport interface ConversationMessageForensics {\n /** app extension */\n inputTokens: number | null;\n /** app extension */\n outputTokens: number | null;\n /** app extension */\n costInUSD: number | null;\n /** app extension — the stored request snapshot of the model call (model name, reasoning effort, sent at) */\n requestSnapshot: unknown;\n}\n\n/** One stored message of a conversation. */\nexport interface AgentsConversationMessage {\n /** generic */\n id: number;\n /** generic */\n conversationId: number | null;\n /** generic — the position in the conversation; the merge key of every page */\n indexInConversation: number | null;\n /** generic */\n role: ConversationMessageRole | null;\n /** generic */\n messageType: ConversationMessageType | null;\n /** generic — non-final only on a waiting signal row */\n status: ConversationMessageStatus | null;\n /** generic */\n authorType: ConversationMessageAuthorType | null;\n /** generic — the source of a SIGNAL or ERROR row (`AI_BUDGET_REACHED`, `FRONTEND_WIDGET_CLICK`, …) */\n signalSource: string | null;\n /** generic — the text in markdown, widget blocks included */\n message: string;\n /** generic */\n createdDate: string | null;\n /** generic */\n toolCall: ConversationToolCall | null;\n /** generic — the sub-agent conversations a `delegate` call started (older rows) */\n delegatedConversations: ConversationDelegatedConversation[];\n /** generic — the sub-agent record of a `delegate` call (newer rows) */\n subAgent: ConversationSubAgent | null;\n /** app extension — admin debug numbers; absent outside the admin surfaces */\n forensics?: ConversationMessageForensics;\n}\n\n/** A file from the app's media library that rides along with a message. */\nexport interface ConversationAttachmentReference {\n /** generic — the app's id of the file (host application: the media manager file id) */\n fileId: string | number | null;\n /** generic */\n fileName: string | null;\n /** generic — a URL the model and the tools can fetch */\n publicUrl: string | null;\n}\n\n// ── Pages and results of the port ────────────────────────────────────────────────────────────────────────────────\n\n/** A page of messages read newest first (the newest page on open, an older page on scroll-up). */\nexport interface ConversationMessagesPage {\n /** generic — in any order; the store merges by `indexInConversation` */\n messages: AgentsConversationMessage[];\n /** generic — an older page exists */\n hasMoreOlder: boolean;\n}\n\n/**\n * What a live update reads: every message written since the newest known id, plus every message from the lowest\n * loaded index that can still change (`build-live-refetch-query.ts`). The package computes both values.\n */\nexport interface ChangedMessagesRequest {\n /** generic — the highest message id loaded */\n highestKnownId: number;\n /** generic — the lowest index that can still change, never below the newest page */\n fromIndex: number;\n /** generic — the page size of the read; the binding's default (host application: 50, as the chat sends) when omitted */\n pageSize?: number;\n}\n\n/** The answer of a changed-messages read; it says nothing about older pages (the store keeps `hasMoreOlder`). */\nexport interface ChangedConversationMessages {\n /** generic */\n messages: AgentsConversationMessage[];\n}\n\n/** The answer of a start: the new conversation with what it holds so far, or the reopened one of the entry point. */\nexport interface StartedConversation {\n /** generic */\n conversation: AgentsConversation;\n /** generic — the stored messages of a new conversation; empty for a reopened one (the chat reads its newest page) */\n messages: AgentsConversationMessage[];\n /** generic — the start returned the recent conversation of its entry point; nothing was appended, no turn started */\n reopenedExisting: boolean;\n}\n\n/** The answer of a post: the conversation's messages so far (the reply arrives through live updates). */\nexport interface PostedMessage {\n /** generic */\n messages: AgentsConversationMessage[];\n}\n\n/** A model-visible, owner-invisible note into a conversation (a widget click, a render report, a correction). */\nexport interface ConversationSignal {\n /** generic */\n text: string;\n /** generic — the signal source; the server's default applies when omitted (a widget click) */\n source?: string;\n}\n\n/** How a list read pages and which conversations it includes. */\nexport interface ConversationListQueryOptions {\n /** generic — include conversations that have no summary (title) yet, e.g. a just-started one */\n includeUnsummarized?: boolean;\n /** generic — the host application's history reads the newest 50 */\n paging?: { top?: number; skip?: number };\n}\n\n/** The size of a search answer. */\nexport interface ConversationSearchOptions {\n /** generic — the most groups (or hits) returned; the host application's chat asks for 10 */\n limit?: number;\n /** generic — the excerpt length in characters; the host application's chat asks for 420 */\n excerptLength?: number;\n}\n\n/** app extension — the reconstructed request a model call was sent with (the admin details panel); opaque data. */\nexport type ConversationMessageSentPayload = unknown[];\n\n/** One matched message of a message search (`SemanticSearchHit`). */\nexport interface ConversationMessageSearchHit {\n /** generic */\n messageId: number | null;\n /** generic */\n conversationId: number | null;\n /** generic */\n indexInConversation: number | null;\n /** generic */\n role: string | null;\n /** generic */\n excerpt: string;\n /** generic */\n relevance: number;\n /** generic */\n created: string | null;\n /** generic */\n updated: string | null;\n /** generic — the conversation's title */\n title: string | null;\n}\n\n/** One conversation of a search across conversations, with its matched messages (`AIConversationSearchGroup`). */\nexport interface ConversationSearchGroup {\n /** generic */\n conversationId: number | null;\n /** generic */\n title: string | null;\n /** generic */\n summary: string | null;\n /** generic */\n created: string | null;\n /** generic */\n updated: string | null;\n /** generic */\n relevance: number;\n /** generic */\n hits: ConversationMessageSearchHit[];\n}\n\n/** One generated line of what the agent is doing (`AgentActivityLine`). */\nexport interface ConversationActivityElement {\n /** generic — the row the line narrates; the merge key */\n toolCallMessageId: number;\n /** generic */\n batchId: string | null;\n /** generic */\n state: \"queued\" | \"running\" | \"finished\" | \"failed\" | \"skipped\" | null;\n /** generic */\n kind: \"tool\" | \"delegation\" | \"background\" | \"long\" | \"turnStart\" | null;\n /** generic */\n childCount: number | null;\n /** generic — the 1-based delegation helper that ran the step; null for the assistant's own steps */\n helperIndex: number | null;\n /** generic — the sentence; null while the narrator has not answered */\n line: string | null;\n}\n\n/** The activity of one turn (`GET …/activity`). */\nexport interface ConversationActivity {\n /** generic — the message that started the narrated turn */\n turnMessageId: number | null;\n /** generic */\n turnRunning: boolean;\n /** generic */\n elements: ConversationActivityElement[];\n}\n\n/** A model the owner (host application: an impersonating admin) may pick for the next turns (`AgentCustomerSelectableModel`). */\nexport interface SelectableModel {\n /** generic — the name a send carries */\n name: string;\n /** generic */\n displayName: string;\n /** generic */\n description: string;\n /** generic */\n strengthLevel: number | null;\n /** generic */\n speedLevel: number | null;\n /** app extension — the host application's credit multiplier of the model */\n creditsMultiplier?: number | null;\n}\n\n// ── Live updates ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n/**\n * What a live update carries: a claim check, never content. The chat reads the conversation again when\n * `changeCounter` advances, at once on a terminal status, and until `lastMessageId` is loaded.\n */\nexport interface ConversationChangeSignal {\n /** generic — advances on every change of the conversation */\n changeCounter: number;\n /** generic — the newest message the server wrote; null before the first */\n lastMessageId: number | null;\n /** generic */\n runStatus: ConversationRunStatus | null;\n /** generic — advances when the title or summary was generated again (a light metadata read is enough then) */\n summaryUpdatedAt: number | null;\n /**\n * generic — the binding produced this emission from a run-state read, not from a pushed change (a binding without\n * push, or a push transport whose path is not proven readable, or a check that corrects a stale status). It carries\n * only `runStatus` as news: `changeCounter`, `lastMessageId` and `summaryUpdatedAt` repeat the last pushed values\n * (before any push: a counter that counts down from -1, never equal to a pushed one). The package sets the status\n * from it and reads the conversation again on a status change while the push path is not alive (`isPushPathAlive`).\n */\n isStatusCheck?: boolean;\n /**\n * generic, on a status-check emission — the binding's push path delivers: a pushed change arrived and the path was not\n * denied since. False after a denied read until a push arrives again; then the status checks are the live path and a\n * status change reads the conversation again. A binding without push leaves it out: the package then counts the\n * pushed changes it saw itself.\n */\n isPushPathAlive?: boolean;\n}\n\n/** Why a subscription ended for good: the conversation was deleted or is no longer readable, or the account lost access. */\nexport type ConversationSubscriptionEndReason = \"gone\" | \"forbidden\";\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\n/**\n * What went wrong, as the chat tells the owner. The codes the chat's error handling reads today map\n * onto it: `AI_BUDGET_REACHED` → `budget`, HTTP 429 / `RATE_LIMIT_EXCEEDED` → `rateLimit`, `CONVERSATION_CLOSED` →\n * `closed`, the not-found and no-access answers → `notFound` / `forbidden` (`conversation-not-found.ts`), no answer or a\n * server failure → `network`, everything else (a refused retry, a cancelled request) → `other` with its `code`.\n */\nexport type AgentsClientErrorKind = \"budget\" | \"rateLimit\" | \"closed\" | \"notFound\" | \"forbidden\" | \"network\" | \"other\";\n\n/** The code `other` carries for a request the client cancelled; the chat shows no error card for it. */\nexport const AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED = \"REQUEST_ABORTED\";\n\n/** The one error shape every port function rejects with. */\nexport class AgentsClientError extends Error {\n readonly kind: AgentsClientErrorKind;\n /** The server's stable error code, or the client's own code (`REQUEST_ABORTED`); null when none arrived. */\n readonly code: string | null;\n /** Seconds until a quota frees up again; set only for `rateLimit`. */\n readonly retryAfterSeconds: number | null;\n /** The HTTP status when one arrived (not part of the contract's shape; kept for diagnostics). */\n readonly httpStatus: number | null;\n\n constructor(\n kind: AgentsClientErrorKind,\n details: { message?: string; code?: string | null; retryAfterSeconds?: number | null; httpStatus?: number | null } = {},\n ) {\n super(details.message ?? kind);\n this.name = \"AgentsClientError\";\n this.kind = kind;\n this.code = details.code ?? null;\n this.retryAfterSeconds = kind === \"rateLimit\" ? (details.retryAfterSeconds ?? null) : null;\n this.httpStatus = details.httpStatus ?? null;\n }\n}\n\nexport const isAgentsClientError = (value: unknown): value is AgentsClientError => value instanceof AgentsClientError;\n"],"names":[],"mappings":";AAiDO,MAAM,oDAAqF;AAAA,EAChG;AAAA,EACA;AACF;AAGO,MAAM,sCAAsC,CACjD,aACiC;AACjC,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,aAAa,SAAU,QAAO;AAClC,MAAI,aAAa,aAAa,aAAa,wBAAwB,aAAa,SAAU,QAAO;AACjG,SAAO;AACT;AA8WO,MAAM,2CAA2C;AAGjD,MAAM,0BAA0B,MAAM;AAAA,EAS3C,YACE,MACA,UAAqH,IACrH;AACA,UAAM,QAAQ,WAAW,IAAI;AAC7B,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,oBAAoB,SAAS,cAAe,QAAQ,qBAAqB,OAAQ;AACtF,SAAK,aAAa,QAAQ,cAAc;AAAA,EAC1C;AACF;AAEO,MAAM,sBAAsB,CAAC,UAA+C,iBAAiB;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const AGENTS_THEME_ATTRIBUTE_NAME = "data-agents-theme";
|
|
3
|
+
const isHostDark = (element, source) => {
|
|
4
|
+
if (source.darkClassName && element.classList.contains(source.darkClassName)) return true;
|
|
5
|
+
if (source.attributeName) {
|
|
6
|
+
return element.getAttribute(source.attributeName) === (source.darkAttributeValue ?? "dark");
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
const followHostColorScheme = (source) => {
|
|
11
|
+
if (typeof document === "undefined") return () => void 0;
|
|
12
|
+
const rootElement = document.documentElement;
|
|
13
|
+
const themeElement = source.element ?? rootElement;
|
|
14
|
+
const mirrorHostColorScheme = () => {
|
|
15
|
+
rootElement.setAttribute(AGENTS_THEME_ATTRIBUTE_NAME, isHostDark(themeElement, source) ? "dark" : "light");
|
|
16
|
+
};
|
|
17
|
+
mirrorHostColorScheme();
|
|
18
|
+
const attributeFilter = ["class", ...source.attributeName ? [source.attributeName] : []];
|
|
19
|
+
const mutationObserver = new MutationObserver(mirrorHostColorScheme);
|
|
20
|
+
mutationObserver.observe(themeElement, { attributes: true, attributeFilter });
|
|
21
|
+
return () => {
|
|
22
|
+
mutationObserver.disconnect();
|
|
23
|
+
rootElement.removeAttribute(AGENTS_THEME_ATTRIBUTE_NAME);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
AGENTS_THEME_ATTRIBUTE_NAME as A,
|
|
28
|
+
followHostColorScheme as f
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=host-color-scheme-Jhb7JZR7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-color-scheme-Jhb7JZR7.js","sources":["../../src/provider/host-color-scheme.ts"],"sourcesContent":["/** Where a host keeps its colour theme on the root element: a class, or an attribute with a value. */\nexport interface HostColorSchemeSource {\n /** The element that carries the theme. Default: the root element (`<html>`). */\n element?: Element;\n /** Dark while the element has this class (e.g. `dark`). */\n darkClassName?: string;\n /** Dark while this attribute (e.g. `data-mode`) has the value `darkAttributeValue`. */\n attributeName?: string;\n /** The attribute's value for dark. Default `dark`. */\n darkAttributeValue?: string;\n}\n\n/** The attribute on the root element that pins the package's colour scheme (`dark` or `light`). */\nexport const AGENTS_THEME_ATTRIBUTE_NAME = \"data-agents-theme\";\n\nconst isHostDark = (element: Element, source: HostColorSchemeSource): boolean => {\n if (source.darkClassName && element.classList.contains(source.darkClassName)) return true;\n if (source.attributeName) {\n return element.getAttribute(source.attributeName) === (source.darkAttributeValue ?? \"dark\");\n }\n return false;\n};\n\n/**\n * Lets the package's colour scheme (its dark set, `color-scheme`) follow a host theme kept as a class or an attribute:\n * mirrors it now and on every change into `data-agents-theme=\"dark\" | \"light\"` on the root element, which the package\n * stylesheet reads before `prefers-color-scheme` and `data-theme`. Returns the stop, which removes the attribute again.\n *\n * ```ts\n * followHostColorScheme({ darkClassName: \"dark\" }); // <html class=\"dark\">\n * followHostColorScheme({ attributeName: \"data-mode\" }); // <html data-mode=\"dark\">\n * ```\n */\nexport const followHostColorScheme = (source: HostColorSchemeSource): (() => void) => {\n if (typeof document === \"undefined\") return () => undefined;\n const rootElement = document.documentElement;\n const themeElement = source.element ?? rootElement;\n const mirrorHostColorScheme = () => {\n rootElement.setAttribute(AGENTS_THEME_ATTRIBUTE_NAME, isHostDark(themeElement, source) ? \"dark\" : \"light\");\n };\n mirrorHostColorScheme();\n const attributeFilter = [\"class\", ...(source.attributeName ? [source.attributeName] : [])];\n const mutationObserver = new MutationObserver(mirrorHostColorScheme);\n mutationObserver.observe(themeElement, { attributes: true, attributeFilter });\n return () => {\n mutationObserver.disconnect();\n rootElement.removeAttribute(AGENTS_THEME_ATTRIBUTE_NAME);\n };\n};\n"],"names":[],"mappings":";AAaO,MAAM,8BAA8B;AAE3C,MAAM,aAAa,CAAC,SAAkB,WAA2C;AAC/E,MAAI,OAAO,iBAAiB,QAAQ,UAAU,SAAS,OAAO,aAAa,EAAG,QAAO;AACrF,MAAI,OAAO,eAAe;AACxB,WAAO,QAAQ,aAAa,OAAO,aAAa,OAAO,OAAO,sBAAsB;AAAA,EACtF;AACA,SAAO;AACT;AAYO,MAAM,wBAAwB,CAAC,WAAgD;AACpF,MAAI,OAAO,aAAa,YAAa,QAAO,MAAM;AAClD,QAAM,cAAc,SAAS;AAC7B,QAAM,eAAe,OAAO,WAAW;AACvC,QAAM,wBAAwB,MAAM;AAClC,gBAAY,aAAa,6BAA6B,WAAW,cAAc,MAAM,IAAI,SAAS,OAAO;AAAA,EAC3G;AACA,wBAAA;AACA,QAAM,kBAAkB,CAAC,SAAS,GAAI,OAAO,gBAAgB,CAAC,OAAO,aAAa,IAAI,EAAG;AACzF,QAAM,mBAAmB,IAAI,iBAAiB,qBAAqB;AACnE,mBAAiB,QAAQ,cAAc,EAAE,YAAY,MAAM,iBAAiB;AAC5E,SAAO,MAAM;AACX,qBAAiB,WAAA;AACjB,gBAAY,gBAAgB,2BAA2B;AAAA,EACzD;AACF;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useSyncExternalStore, useMemo, useState, useContext, createContext } from "react";
|
|
3
|
+
import { useSyncExternalStore, useMemo, useState, useRef, useCallback, useContext, createContext } from "react";
|
|
4
4
|
import { A as AgentsConversationClientProvider } from "./AgentsConversationClientContext-C4T7g_Qk.js";
|
|
5
5
|
import ReactMarkdown from "react-markdown";
|
|
6
6
|
import remarkGfm from "remark-gfm";
|
|
@@ -358,20 +358,58 @@ const DefaultProgressBar = (props) => {
|
|
|
358
358
|
}
|
|
359
359
|
);
|
|
360
360
|
};
|
|
361
|
+
const useElementWidth = () => {
|
|
362
|
+
const [width, setWidth] = useState(null);
|
|
363
|
+
const resizeObserverRef = useRef(null);
|
|
364
|
+
const observeElement = useCallback((element) => {
|
|
365
|
+
resizeObserverRef.current?.disconnect();
|
|
366
|
+
resizeObserverRef.current = null;
|
|
367
|
+
if (element === null) return;
|
|
368
|
+
const initialWidth = element.getBoundingClientRect().width;
|
|
369
|
+
setWidth(initialWidth > 0 ? initialWidth : null);
|
|
370
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
371
|
+
resizeObserverRef.current = new ResizeObserver((entries) => {
|
|
372
|
+
const entry = entries[entries.length - 1];
|
|
373
|
+
if (entry && entry.contentRect.width > 0) setWidth(entry.contentRect.width);
|
|
374
|
+
});
|
|
375
|
+
resizeObserverRef.current.observe(element);
|
|
376
|
+
}, []);
|
|
377
|
+
return [width, observeElement];
|
|
378
|
+
};
|
|
361
379
|
const DefaultSplitView = (props) => {
|
|
362
|
-
const { isSideOpen, main, side, sideToggle } = props;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
380
|
+
const { isSideOpen, coversBelowWidth, main, side, sideToggle } = props;
|
|
381
|
+
const [splitViewWidth, observeSplitView] = useElementWidth();
|
|
382
|
+
const coversMain = coversBelowWidth !== void 0 && splitViewWidth !== null && splitViewWidth < coversBelowWidth;
|
|
383
|
+
return /* @__PURE__ */ jsxs(
|
|
384
|
+
"div",
|
|
385
|
+
{
|
|
386
|
+
ref: observeSplitView,
|
|
387
|
+
className: classNames("agents-split-view", coversMain && "agents-split-view--covering"),
|
|
388
|
+
style: { display: "flex", width: "100%", height: "100%", position: "relative" },
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ jsx(
|
|
391
|
+
"div",
|
|
392
|
+
{
|
|
393
|
+
className: "agents-split-view__main",
|
|
394
|
+
style: {
|
|
395
|
+
width: isSideOpen && !coversMain ? main.narrowedWidth ?? main.width : main.width,
|
|
396
|
+
background: main.background
|
|
397
|
+
},
|
|
398
|
+
children: main.content
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
sideToggle && !coversMain ? /* @__PURE__ */ jsx("button", { type: "button", className: "agents-split-view__toggle", onClick: sideToggle.onToggle, "aria-expanded": isSideOpen }) : null,
|
|
402
|
+
isSideOpen ? /* @__PURE__ */ jsx(
|
|
403
|
+
"div",
|
|
404
|
+
{
|
|
405
|
+
className: "agents-split-view__side",
|
|
406
|
+
style: coversMain ? { position: "absolute", inset: 0, width: "100%", zIndex: 20, background: side.background } : { width: side.narrowedWidth ?? side.width, background: side.background },
|
|
407
|
+
children: side.content
|
|
408
|
+
}
|
|
409
|
+
) : null
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
);
|
|
375
413
|
};
|
|
376
414
|
const DefaultTrendDelta = (props) => {
|
|
377
415
|
const { current, previous = 0, higherIsBetter = true, format } = props;
|
|
@@ -766,7 +804,9 @@ const openImageGallery = (images, startIndex) => {
|
|
|
766
804
|
return;
|
|
767
805
|
}
|
|
768
806
|
const startImage = images[startIndex];
|
|
769
|
-
if (startImage)
|
|
807
|
+
if (!startImage) return;
|
|
808
|
+
if (appEnvironment.onNavigate?.(startImage.url, null) === true) return;
|
|
809
|
+
window.open(startImage.url, "_blank", "noopener,noreferrer");
|
|
770
810
|
};
|
|
771
811
|
const DEFAULT_WIDGET_SELF_HYDRATION_KEY_FIELD_NAME = "agentSpaceId";
|
|
772
812
|
const getWidgetSelfHydrationKeyFieldName = () => appEnvironment.widgetSelfHydrationKeyFieldName ?? DEFAULT_WIDGET_SELF_HYDRATION_KEY_FIELD_NAME;
|
|
@@ -973,74 +1013,117 @@ const ConversationSearchResultsList = (props) => {
|
|
|
973
1013
|
const { ConversationSearchResultsList: ConversationSearchResultsListComponent } = useAgentsComponents();
|
|
974
1014
|
return /* @__PURE__ */ jsx(ConversationSearchResultsListComponent, { ...props });
|
|
975
1015
|
};
|
|
1016
|
+
const openInNewTab = (href) => {
|
|
1017
|
+
window.open(href, "_blank", "noopener,noreferrer");
|
|
1018
|
+
};
|
|
1019
|
+
const openLinkThroughEnvironment = (environment, href, event) => {
|
|
1020
|
+
if (environment.onNavigate?.(href, event) === true) return;
|
|
1021
|
+
openInNewTab(href);
|
|
1022
|
+
};
|
|
1023
|
+
const readNativeEvent = (event) => event === void 0 ? null : "nativeEvent" in event ? event.nativeEvent : event;
|
|
1024
|
+
const useAgentsLinkNavigation = () => {
|
|
1025
|
+
const { onNavigate } = useAgentsEnvironment();
|
|
1026
|
+
return useMemo(
|
|
1027
|
+
() => ({
|
|
1028
|
+
openLink: (href, event) => openLinkThroughEnvironment({ onNavigate }, href, readNativeEvent(event)),
|
|
1029
|
+
handleLinkClick: (event, href) => {
|
|
1030
|
+
const target = href ?? event.currentTarget.getAttribute("href") ?? "";
|
|
1031
|
+
if (!target || !onNavigate) return;
|
|
1032
|
+
if (onNavigate(target, event.nativeEvent) === true) event.preventDefault();
|
|
1033
|
+
}
|
|
1034
|
+
}),
|
|
1035
|
+
[onNavigate]
|
|
1036
|
+
);
|
|
1037
|
+
};
|
|
1038
|
+
const AgentsLink = (props) => {
|
|
1039
|
+
const { node, href, onClick, children, ...anchorProps } = props;
|
|
1040
|
+
const { handleLinkClick } = useAgentsLinkNavigation();
|
|
1041
|
+
return /* @__PURE__ */ jsx(
|
|
1042
|
+
"a",
|
|
1043
|
+
{
|
|
1044
|
+
target: "_blank",
|
|
1045
|
+
rel: "noopener noreferrer",
|
|
1046
|
+
...anchorProps,
|
|
1047
|
+
href,
|
|
1048
|
+
onClick: (event) => {
|
|
1049
|
+
onClick?.(event);
|
|
1050
|
+
if (!event.defaultPrevented && href) handleLinkClick(event, href);
|
|
1051
|
+
},
|
|
1052
|
+
children
|
|
1053
|
+
}
|
|
1054
|
+
);
|
|
1055
|
+
};
|
|
976
1056
|
export {
|
|
977
|
-
|
|
978
|
-
|
|
1057
|
+
reportWidgetCrash as $,
|
|
1058
|
+
AgentsLink as A,
|
|
979
1059
|
Button as B,
|
|
980
1060
|
Checkbox as C,
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1061
|
+
DEFAULT_AGENTS_COMPONENTS as D,
|
|
1062
|
+
buildWidgetOfAnotherAgentSpaceExplanation as E,
|
|
1063
|
+
classNames as F,
|
|
984
1064
|
GlowFrame as G,
|
|
985
1065
|
HeroRow as H,
|
|
986
1066
|
Icon as I,
|
|
987
|
-
|
|
988
|
-
|
|
1067
|
+
escapePlainTextForText as J,
|
|
1068
|
+
getAgentDisplayName as K,
|
|
989
1069
|
LoadingSpinner as L,
|
|
990
1070
|
Map as M,
|
|
991
|
-
|
|
992
|
-
|
|
1071
|
+
getAgentsEnvironment as N,
|
|
1072
|
+
getFurtherCanvasBehaviours as O,
|
|
993
1073
|
ProgressBar as P,
|
|
994
|
-
|
|
1074
|
+
getFurtherWidgetClickSignalSources as Q,
|
|
995
1075
|
RadioGroup as R,
|
|
996
1076
|
SegmentBar as S,
|
|
997
1077
|
Tabs as T,
|
|
998
|
-
|
|
999
|
-
|
|
1078
|
+
getGoogleMapWidgetNames as U,
|
|
1079
|
+
getSandboxLegacyAliases as V,
|
|
1000
1080
|
WidgetFeatureGate as W,
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1081
|
+
getWidgetImageCaptureReadPathPrefix as X,
|
|
1082
|
+
getWidgetSelfHydrationKeyFieldName as Y,
|
|
1083
|
+
openImageGallery as Z,
|
|
1084
|
+
reportRunningTurn as _,
|
|
1085
|
+
AgentsProvider as a,
|
|
1086
|
+
setAgentsEnvironment as a0,
|
|
1087
|
+
translateText as a1,
|
|
1088
|
+
useAgentsActiveAgentSpaceKey as a2,
|
|
1089
|
+
useAgentsBudgetLimit as a3,
|
|
1090
|
+
useAgentsComponents as a4,
|
|
1091
|
+
useAgentsEnvironment as a5,
|
|
1092
|
+
useAgentsLinkNavigation as a6,
|
|
1093
|
+
useAgentsMapsLoader as a7,
|
|
1094
|
+
useAgentsOwnerSettings as a8,
|
|
1095
|
+
useAgentsStateDispatch as a9,
|
|
1096
|
+
useAgentsStateSelector as aa,
|
|
1097
|
+
useAgentsTexts as ab,
|
|
1098
|
+
AgentsWidgetHydrationStateContainer as ac,
|
|
1099
|
+
WidgetHydrationReducer as ad,
|
|
1100
|
+
WidgetHydrationSlice as ae,
|
|
1101
|
+
createAgentsWidgetHydrationStateStore as af,
|
|
1102
|
+
getDefaultAgentsStateStore as ag,
|
|
1103
|
+
ConversationSearchResultsList as b,
|
|
1104
|
+
DEFAULT_AGENTS_TEXTS as c,
|
|
1105
|
+
DEFAULT_WIDGET_IMAGE_CAPTURE_READ_PATH_PREFIX as d,
|
|
1106
|
+
DEFAULT_WIDGET_SELF_HYDRATION_KEY_FIELD_NAME as e,
|
|
1107
|
+
DateInput as f,
|
|
1108
|
+
HeroValue as g,
|
|
1109
|
+
InteractiveSurface as h,
|
|
1110
|
+
MapMarker as i,
|
|
1111
|
+
Markdown as j,
|
|
1112
|
+
ModalLayer as k,
|
|
1113
|
+
RangeSlider as l,
|
|
1114
|
+
Select as m,
|
|
1115
|
+
Skeleton as n,
|
|
1116
|
+
SkeletonText as o,
|
|
1117
|
+
SplitView as p,
|
|
1118
|
+
StatusBadge as q,
|
|
1119
|
+
StatusChip as r,
|
|
1120
|
+
Text as s,
|
|
1121
|
+
TextArea as t,
|
|
1122
|
+
TextInput as u,
|
|
1123
|
+
Tooltip as v,
|
|
1124
|
+
TrendDelta as w,
|
|
1125
|
+
WidgetText as x,
|
|
1126
|
+
appendAnotherAgentSpaceToOwnerText as y,
|
|
1127
|
+
buildUnnamedAgentSpaceLabel as z
|
|
1128
|
+
};
|
|
1129
|
+
//# sourceMappingURL=link-navigation-DyTApNeA.js.map
|