@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.
Files changed (86) hide show
  1. package/README.md +108 -2
  2. package/dist/chat.js +132 -111
  3. package/dist/chat.js.map +1 -1
  4. package/dist/chunks/{ConversationMessageInputComposerWidgets-BO3jS0eZ.js → ConversationMessageInputComposerWidgets-r_RwCqr7.js} +11 -8
  5. package/dist/chunks/ConversationMessageInputComposerWidgets-r_RwCqr7.js.map +1 -0
  6. package/dist/chunks/{WebSearchResultsConversationWidget-H6cbTapV.js → WebSearchResultsConversationWidget-BXt98hGu.js} +161 -102
  7. package/dist/chunks/WebSearchResultsConversationWidget-BXt98hGu.js.map +1 -0
  8. package/dist/chunks/{canvas-behaviours-AvzKSYyv.js → canvas-behaviours-BpN_1xdZ.js} +2 -2
  9. package/dist/chunks/{canvas-behaviours-AvzKSYyv.js.map → canvas-behaviours-BpN_1xdZ.js.map} +1 -1
  10. package/dist/chunks/{canvas-reducers-Cdxt8yDF.js → canvas-reducers-CuX6L1zg.js} +3 -3
  11. package/dist/chunks/{canvas-reducers-Cdxt8yDF.js.map → canvas-reducers-CuX6L1zg.js.map} +1 -1
  12. package/dist/chunks/{canvasBodies-CsLrZ-M-.js → canvasBodies-Ds-cTn47.js} +9 -6
  13. package/dist/chunks/{canvasBodies-CsLrZ-M-.js.map → canvasBodies-Ds-cTn47.js.map} +1 -1
  14. package/dist/chunks/{canvasStorage-EvQsGdto.js → canvasStorage-DHNluopA.js} +2 -2
  15. package/dist/chunks/{canvasStorage-EvQsGdto.js.map → canvasStorage-DHNluopA.js.map} +1 -1
  16. package/dist/chunks/compose-attachment-message-text-FvVJbrge.js +8 -0
  17. package/dist/chunks/compose-attachment-message-text-FvVJbrge.js.map +1 -0
  18. package/dist/chunks/{contract-BxmMxYPF.js → contract-Z08LBOqt.js} +4 -3
  19. package/dist/chunks/contract-Z08LBOqt.js.map +1 -0
  20. package/dist/chunks/conversation-BEF0aesf.js.map +1 -1
  21. package/dist/chunks/host-color-scheme-Jhb7JZR7.js +30 -0
  22. package/dist/chunks/host-color-scheme-Jhb7JZR7.js.map +1 -0
  23. package/dist/chunks/{index-7Qc_3GbG.js → link-navigation-DyTApNeA.js} +156 -73
  24. package/dist/chunks/link-navigation-DyTApNeA.js.map +1 -0
  25. package/dist/chunks/text-key-DnoZ4lAk.js +6 -0
  26. package/dist/chunks/text-key-DnoZ4lAk.js.map +1 -0
  27. package/dist/chunks/{widget-click-signal-sources-1gIs1yiN.js → widget-click-signal-sources-Ch-y8gxw.js} +9 -5
  28. package/dist/chunks/{widget-click-signal-sources-1gIs1yiN.js.map → widget-click-signal-sources-Ch-y8gxw.js.map} +1 -1
  29. package/dist/chunks/{widget-image-readiness-signal-D3ci53xr.js → widget-image-readiness-signal-C5yaKpJJ.js} +2 -2
  30. package/dist/chunks/{widget-image-readiness-signal-D3ci53xr.js.map → widget-image-readiness-signal-C5yaKpJJ.js.map} +1 -1
  31. package/dist/chunks/{widget-name-resolver-D_ZzXy-Q.js → widget-name-resolver-DboFMAq2.js} +25 -25
  32. package/dist/chunks/widget-name-resolver-DboFMAq2.js.map +1 -0
  33. package/dist/chunks/{withPollingChangeSubscription-B16htQGd.js → withPollingChangeSubscription-CNXgt3Ri.js} +6 -2
  34. package/dist/chunks/withPollingChangeSubscription-CNXgt3Ri.js.map +1 -0
  35. package/dist/client-testing.js +6 -7
  36. package/dist/client-testing.js.map +1 -1
  37. package/dist/client.js +431 -2
  38. package/dist/client.js.map +1 -1
  39. package/dist/contract.js +1 -1
  40. package/dist/files/chat/Conversation.module.scss +1 -1
  41. package/dist/files/chat/ConversationViewBody/ConversationViewBody.module.scss +1 -1
  42. package/dist/files/i18n-keys.json +1617 -0
  43. package/dist/files/image-render/WidgetImageRender.module.scss +9 -3
  44. package/dist/files/styles/_surfaces.scss +6 -6
  45. package/dist/image-render.js +7 -7
  46. package/dist/index.js +64 -55
  47. package/dist/index.js.map +1 -1
  48. package/dist/kit.js +2 -2
  49. package/dist/preview.js +8 -8
  50. package/dist/provider.js +61 -52
  51. package/dist/provider.js.map +1 -1
  52. package/dist/renderer.js +16 -15
  53. package/dist/styles.css +170 -107
  54. package/dist/types/chat/AgentChat/AgentChat.d.ts +6 -0
  55. package/dist/types/chat/controller/AgentChatController.d.ts +28 -1
  56. package/dist/types/client/AgentsConversationClient.d.ts +7 -1
  57. package/dist/types/client/compose-attachment-message-text.d.ts +7 -0
  58. package/dist/types/client/http/agents-http-mappers.d.ts +23 -0
  59. package/dist/types/client/http/agents-http-wire.d.ts +188 -0
  60. package/dist/types/client/http/createAgentsHttpConversationClient.d.ts +55 -0
  61. package/dist/types/client/polling/createPollingConversationChangeSubscription.d.ts +7 -4
  62. package/dist/types/client/polling/withPollingChangeSubscription.d.ts +3 -2
  63. package/dist/types/contract/conversation.d.ts +8 -0
  64. package/dist/types/entries/chat.d.ts +2 -1
  65. package/dist/types/entries/client.d.ts +4 -0
  66. package/dist/types/entries/renderer.d.ts +1 -0
  67. package/dist/types/entries/widgets.d.ts +1 -1
  68. package/dist/types/provider/components/types.d.ts +5 -2
  69. package/dist/types/provider/environment.d.ts +13 -0
  70. package/dist/types/provider/host-color-scheme.d.ts +24 -0
  71. package/dist/types/provider/index.d.ts +4 -0
  72. package/dist/types/provider/link-navigation.d.ts +28 -0
  73. package/dist/types/provider/text-key.d.ts +6 -0
  74. package/dist/types/renderer/MarkdownLink.d.ts +8 -6
  75. package/dist/types/widgets/CanvasLauncherWidget/use-canvas-viable.d.ts +43 -9
  76. package/dist/types/widgets/EntityMentionConversationWidget/shared/entity-mention-presentation.d.ts +1 -1
  77. package/dist/types/widgets/_shared/modern/WidgetKpiValue.d.ts +2 -1
  78. package/dist/widgets.js +43 -40
  79. package/package.json +8 -6
  80. package/public-api.json +85 -18
  81. package/dist/chunks/ConversationMessageInputComposerWidgets-BO3jS0eZ.js.map +0 -1
  82. package/dist/chunks/WebSearchResultsConversationWidget-H6cbTapV.js.map +0 -1
  83. package/dist/chunks/contract-BxmMxYPF.js.map +0 -1
  84. package/dist/chunks/index-7Qc_3GbG.js.map +0 -1
  85. package/dist/chunks/widget-name-resolver-D_ZzXy-Q.js.map +0 -1
  86. package/dist/chunks/withPollingChangeSubscription-B16htQGd.js.map +0 -1
@@ -24,6 +24,12 @@ export interface AgentChatProps extends Omit<AgentChatControllerProps, Defaulted
24
24
  chatScrollRef?: RefObject<HTMLDivElement | null>;
25
25
  /** The agent's activity at the tail of the thread. Default: `AgentChatActivityIndicator` (dots and the ticker line). */
26
26
  ThinkingIndicator?: ComponentType<AgentChatActivityProps>;
27
+ /**
28
+ * The frosted band at the top of the message column that blurs what scrolls under a top bar floating over the chat.
29
+ * Shown, it follows the chat pane (`confineTopBlurBandToChatPane` defaults to true then). Default false: the default
30
+ * chat has no floating top bar.
31
+ */
32
+ showsTopBlurBand?: boolean;
27
33
  }
28
34
  /**
29
35
  * The agent chat with the package defaults (`./chat`): `<AgentsProvider client={client}><AgentChat
@@ -1,4 +1,4 @@
1
- import { type ComponentType, type ReactNode, type RefObject } from "react";
1
+ import { type ComponentType, type ReactNode, type Ref, type RefObject } from "react";
2
2
  import type { AgentsConversationClient } from "../../client/AgentsConversationClient";
3
3
  import { type ConversationAttachmentReference } from "../../contract/conversation";
4
4
  import type { AgentsChatStore } from "../store/create-agents-chat-store";
@@ -20,6 +20,14 @@ export interface AgentChatActivityProps {
20
20
  export interface AgentChatActivityHistoryProps {
21
21
  turn: ActivityTickerTurn | null;
22
22
  }
23
+ /** What a host does with the composer of a mounted chat (`AgentChat`'s `composerRef`). */
24
+ export interface AgentChatComposerHandle {
25
+ /**
26
+ * Replaces the composer's draft with `text` (empty clears it) and puts the caret at its end — never sends. Does
27
+ * nothing while the composer is not shown (a closed conversation).
28
+ */
29
+ setComposerDraft: (text: string) => void;
30
+ }
23
31
  /** Where the model of the next send comes from — read at send time (an admin's pick can change between renders). */
24
32
  export interface AgentChatSendModelSource {
25
33
  readModelForNextSend: () => string | undefined;
@@ -87,6 +95,25 @@ export interface AgentChatControllerProps {
87
95
  ActivityHistory?: ComponentType<AgentChatActivityHistoryProps>;
88
96
  /** Rendered inside the chat's widget provider (the host's canvas syncs). */
89
97
  children?: ReactNode;
98
+ /**
99
+ * The chat renders without the canvas split: no side pane, the message column alone. Default false. Without a canvas
100
+ * surface of the host's own (`hostHasCanvasSurface`), every canvas open is then ignored.
101
+ */
102
+ disableSplitView?: boolean;
103
+ /**
104
+ * Whether a canvas may open in this chat: false ignores every open request (reason `noSurface`), true lets the canvas
105
+ * state open while the host draws it (with `disableSplitView`: in a surface of its own, e.g. `CanvasPane`). Default:
106
+ * true with the split view, false without it.
107
+ */
108
+ hostHasCanvasSurface?: boolean;
109
+ /**
110
+ * The host paints the chat's background behind it (the pane stays transparent, the frosted top band of a floating
111
+ * top bar keeps its look). Default true; false gives the chat the package's own background
112
+ * (`--agents-chat-background`).
113
+ */
114
+ backgroundPaintedByHost?: boolean;
115
+ /** The handle of the composer: put a draft into the mounted chat without a remount (`setComposerDraft`). */
116
+ composerRef?: Ref<AgentChatComposerHandle>;
90
117
  }
91
118
  /**
92
119
  * The agent chat: the controller over the conversation client port and the chat store — open, pages,
@@ -1,4 +1,4 @@
1
- import type { AgentsConversation, ChangedConversationMessages, ChangedMessagesRequest, ConversationActivity, ConversationAttachmentReference, ConversationChangeSignal, ConversationListQueryOptions, ConversationMessageSearchHit, ConversationMessageSentPayload, ConversationMessagesPage, ConversationSearchGroup, ConversationSearchOptions, ConversationSignal, ConversationSubscriptionEndReason, PostedMessage, SelectableModel, StartedConversation } from "../contract/conversation";
1
+ import type { AgentsConversation, ChangedConversationMessages, ChangedMessagesRequest, ConversationActivity, ConversationAttachmentReference, ConversationChangeSignal, ConversationListQueryOptions, ConversationMessageSearchHit, ConversationMessageSentPayload, ConversationMessagesPage, ConversationRunStateRead, ConversationSearchGroup, ConversationSearchOptions, ConversationSignal, ConversationSubscriptionEndReason, PostedMessage, SelectableModel, StartedConversation } from "../contract/conversation";
2
2
  /**
3
3
  * The conversation client port (one function per row of the table, derived from the chat
4
4
  * controller's requests). The package calls only this; an app binds it over its own request layer; the package
@@ -14,6 +14,12 @@ import type { AgentsConversation, ChangedConversationMessages, ChangedMessagesRe
14
14
  export interface AgentsConversationClient {
15
15
  /** The conversation without messages: title, run state, the owed-turn mark, purpose, initiator. */
16
16
  getConversationMetadata: (conversationId: number) => Promise<AgentsConversation>;
17
+ /**
18
+ * The server's lean run-state read: run state, owed turn, newest message id, title and summary. Optional: the
19
+ * polling default of the live updates (`withPollingChangeSubscription`) reads it instead of `getConversationMetadata`
20
+ * when the binding has it.
21
+ */
22
+ getConversationRunState?: (conversationId: number) => Promise<ConversationRunStateRead>;
17
23
  /** The newest page, each message with its delegated children's `{ id, runState }`. */
18
24
  getNewestMessagesPage: (conversationId: number, pageSize: number) => Promise<ConversationMessagesPage>;
19
25
  /** The page before `beforeIndex` (scroll-up). */
@@ -0,0 +1,7 @@
1
+ import type { ConversationAttachmentReference } from "../contract/conversation";
2
+ /**
3
+ * The message text a send with attachments stores: the typed text plus one reference line per attachment. The
4
+ * conversation routes of the package take the text only, so a binding carries the attachments in it; the chat shows the
5
+ * optimistic owner message with the same text (`AgentsConversationClient.composeSentMessageText`).
6
+ */
7
+ export declare const composeAttachmentMessageText: (text: string, attachments: ConversationAttachmentReference[] | undefined) => string;
@@ -0,0 +1,23 @@
1
+ import { AgentsClientError, type AgentsConversation, type AgentsConversationMessage, type ConversationActivity, type ConversationMessageSearchHit, type ConversationRunStateRead, type ConversationSearchGroup, type SelectableModel } from "../../contract/conversation";
2
+ import type { WireConversation, WireConversationActivityResponse, WireConversationMessage, WireConversationRunStateResponse, WireConversationSearchGroup, WireErrorBody, WireSelectableModel, WireSemanticSearchHit, WireSet } from "./agents-http-wire";
3
+ /** The elements of a serialized set (`{ elements: [...] }`), a plain array, or the values of a keyed object. */
4
+ export declare const readWireSetElements: <Element>(wireSet: WireSet<Element> | Record<string, Element> | null | undefined) => Element[];
5
+ /** An `AIConversation` as the contract's conversation. */
6
+ export declare const mapWireConversation: (wireConversation: WireConversation) => AgentsConversation;
7
+ /** An `AIConversationMessage` as the contract's message. */
8
+ export declare const mapWireConversationMessage: (wireMessage: WireConversationMessage) => AgentsConversationMessage;
9
+ /** The run-state read (`AIConversationRunStateGetResponseDto`). */
10
+ export declare const mapWireConversationRunState: (wireRunState: WireConversationRunStateResponse) => ConversationRunStateRead;
11
+ /** The activity of a turn (`AIConversationActivityGetResponseDto`). */
12
+ export declare const mapWireConversationActivity: (wireActivity: WireConversationActivityResponse) => ConversationActivity;
13
+ /** A `SemanticSearchHit`. */
14
+ export declare const mapWireSearchHit: (wireHit: WireSemanticSearchHit) => ConversationMessageSearchHit;
15
+ /** An `AIConversationSearchGroup`. */
16
+ export declare const mapWireSearchGroup: (wireGroup: WireConversationSearchGroup) => ConversationSearchGroup;
17
+ /** An `AgentCustomerSelectableModel`. */
18
+ export declare const mapWireSelectableModel: (wireModel: WireSelectableModel) => SelectableModel;
19
+ /**
20
+ * A refused request as the port's error: the stable code first (`errorCode` of the JSON body), then the status — 429
21
+ * `rateLimit` (with `Retry-After`), 404 `notFound`, 403 and 401 `forbidden`, 5xx `network`, everything else `other`.
22
+ */
23
+ export declare const mapHttpFailureToAgentsClientError: (httpStatus: number, wireErrorBody: WireErrorBody | null, retryAfterHeader: string | null) => AgentsClientError;
@@ -0,0 +1,188 @@
1
+ /**
2
+ * The wire shapes of the module's own conversation routes (`AgentConversationReadsTrait`, `AgentConversationWritesTrait`,
3
+ * `AgentConversationStartTrait`, `AgentSelectableModelsTrait`): the response DTOs and the entities they serialize, as far
4
+ * as the HTTP binding reads them. Every field is optional on the wire — a read hides some (the forensics outside an admin
5
+ * session, the summary on message rows), and an application may derive the classes — so the mappers
6
+ * (`agents-http-mappers.ts`) default each one. An entity set arrives as `{ elements: [...] }`; the mappers also take a
7
+ * plain array.
8
+ */
9
+ /** An entity set or object set as the server serializes it. */
10
+ export type WireSet<Element> = {
11
+ elements?: Element[] | null;
12
+ } | Element[];
13
+ /** `AIConversationSummary`. */
14
+ export interface WireConversationSummary {
15
+ title?: string | null;
16
+ text?: string | null;
17
+ manuallyEdited?: boolean | null;
18
+ }
19
+ /** `CustomerProgressStep`. */
20
+ export interface WireCustomerProgressStep {
21
+ key?: string | null;
22
+ customerLabel?: string | null;
23
+ status?: string | null;
24
+ }
25
+ /** `ChangeHistory` (`ChangeHistoryTrait`). */
26
+ export interface WireChangeHistory {
27
+ createdTime?: string | null;
28
+ modifiedTime?: string | null;
29
+ }
30
+ /** `AIConversation`. */
31
+ export interface WireConversation {
32
+ id?: number | null;
33
+ agentSpaceId?: number | null;
34
+ runState?: string | null;
35
+ agentTurnOwedAt?: string | null;
36
+ summary?: WireConversationSummary | null;
37
+ changeHistory?: WireChangeHistory | null;
38
+ /** Flat date-times, as a derived class or a projection may write them. */
39
+ created?: string | null;
40
+ updated?: string | null;
41
+ purposeName?: string | null;
42
+ initiatorType?: string | null;
43
+ scheduleId?: number | null;
44
+ entryPointKey?: string | null;
45
+ customerProgressSteps?: WireSet<WireCustomerProgressStep> | null;
46
+ lastMessageId?: number | null;
47
+ aiPromptExtensionId?: number | null;
48
+ messages?: WireSet<WireConversationMessage> | null;
49
+ }
50
+ /** `ToolCall`. */
51
+ export interface WireToolCall {
52
+ toolCallId?: string | null;
53
+ name?: string | null;
54
+ arguments?: unknown;
55
+ status?: string | null;
56
+ }
57
+ /** `DelegationSubAgentRun`. */
58
+ export interface WireDelegationSubAgentRun {
59
+ runNumber?: number | null;
60
+ status?: string | null;
61
+ }
62
+ /** `DelegationSubAgentRecord`. */
63
+ export interface WireDelegationSubAgentRecord {
64
+ currentRunNumber?: number | null;
65
+ runs?: WireSet<WireDelegationSubAgentRun> | Record<string, WireDelegationSubAgentRun> | null;
66
+ }
67
+ /** `AIConversationMessage`. */
68
+ export interface WireConversationMessage {
69
+ id?: number | null;
70
+ aiConversationId?: number | null;
71
+ indexInConversation?: number | null;
72
+ role?: string | null;
73
+ messageType?: string | null;
74
+ status?: string | null;
75
+ authorType?: string | null;
76
+ signalSource?: string | null;
77
+ message?: string | null;
78
+ createdDate?: string | null;
79
+ toolCall?: WireToolCall | null;
80
+ delegatedConversations?: WireSet<{
81
+ id?: number | null;
82
+ runState?: string | null;
83
+ }> | null;
84
+ /** `DelegationResults`: the sub-agent record of a newer `delegate` call row. */
85
+ delegationResults?: {
86
+ subAgent?: WireDelegationSubAgentRecord | null;
87
+ } | null;
88
+ /** The admin-only forensics; hidden outside an impersonating admin session. */
89
+ inputTokens?: number | null;
90
+ outputTokens?: number | null;
91
+ costInUSD?: number | null;
92
+ requestSnapshot?: unknown;
93
+ }
94
+ /** `AgentActivityLine`. */
95
+ export interface WireActivityLine {
96
+ toolCallMessageId?: number | null;
97
+ batchId?: string | null;
98
+ state?: string | null;
99
+ kind?: string | null;
100
+ childCount?: number | null;
101
+ helperIndex?: number | null;
102
+ line?: string | null;
103
+ }
104
+ /** `SemanticSearchHit`. */
105
+ export interface WireSemanticSearchHit {
106
+ messageId?: number | null;
107
+ conversationId?: number | null;
108
+ indexInConversation?: number | null;
109
+ role?: string | null;
110
+ excerpt?: string | null;
111
+ relevance?: number | null;
112
+ created?: string | null;
113
+ updated?: string | null;
114
+ title?: string | null;
115
+ }
116
+ /** `AIConversationSearchGroup`. */
117
+ export interface WireConversationSearchGroup {
118
+ conversationId?: number | null;
119
+ title?: string | null;
120
+ summary?: string | null;
121
+ created?: string | null;
122
+ updated?: string | null;
123
+ relevance?: number | null;
124
+ hits?: WireSet<WireSemanticSearchHit> | null;
125
+ }
126
+ /** `AgentCustomerSelectableModel`. */
127
+ export interface WireSelectableModel {
128
+ name?: string | null;
129
+ displayName?: string | null;
130
+ description?: string | null;
131
+ strengthLevel?: number | null;
132
+ speedLevel?: number | null;
133
+ creditsMultiplier?: number | null;
134
+ }
135
+ /** `AIConversationGetResponseDto` (get, postMessage, injectSignal, retry, title). */
136
+ export interface WireConversationResponse {
137
+ aiConversation?: WireConversation | null;
138
+ }
139
+ /** `AIConversationStartWithMessagePostResponseDto`. */
140
+ export interface WireConversationStartResponse extends WireConversationResponse {
141
+ reopenedExistingConversation?: boolean | null;
142
+ }
143
+ /** `AIConversationsGetResponseDto`. */
144
+ export interface WireConversationsResponse {
145
+ aiConversations?: WireSet<WireConversation> | null;
146
+ }
147
+ /** `AIConversationMessagesGetResponseDto`. */
148
+ export interface WireConversationMessagesResponse {
149
+ messages?: WireSet<WireConversationMessage> | null;
150
+ hasMoreOlder?: boolean | null;
151
+ }
152
+ /** `AIConversationRunStateGetResponseDto`. */
153
+ export interface WireConversationRunStateResponse {
154
+ id?: number | null;
155
+ runState?: string | null;
156
+ agentTurnOwedAt?: string | null;
157
+ lastMessageId?: number | null;
158
+ title?: string | null;
159
+ titleManuallyEdited?: boolean | null;
160
+ summary?: string | null;
161
+ updated?: string | null;
162
+ }
163
+ /** `AIConversationActivityGetResponseDto`. */
164
+ export interface WireConversationActivityResponse {
165
+ turnMessageId?: number | null;
166
+ turnRunning?: boolean | null;
167
+ elements?: WireSet<WireActivityLine> | null;
168
+ }
169
+ /** `AIConversationSearchGetResponseDto`. */
170
+ export interface WireConversationSearchResponse {
171
+ conversations?: WireSet<WireConversationSearchGroup> | null;
172
+ }
173
+ /** `AIConversationMessageSearchGetResponseDto`. */
174
+ export interface WireConversationMessageSearchResponse {
175
+ hits?: WireSet<WireSemanticSearchHit> | null;
176
+ }
177
+ /** `AIConversationSelectableModelsGetResponseDto`. */
178
+ export interface WireSelectableModelsResponse {
179
+ models?: WireSet<WireSelectableModel> | null;
180
+ }
181
+ /** The JSON error body of a refused request (`errorCode` on the coded exceptions, `retryAfterSeconds` on a quota). */
182
+ export interface WireErrorBody {
183
+ error?: string | null;
184
+ message?: string | null;
185
+ errorCode?: string | null;
186
+ code?: string | null;
187
+ retryAfterSeconds?: number | null;
188
+ }
@@ -0,0 +1,55 @@
1
+ import type { AgentsConversationClient, AgentsConversationClientBindingOptions } from "../AgentsConversationClient";
2
+ import type { PollingConversationChangeSubscriptionOptions } from "../polling/createPollingConversationChangeSubscription";
3
+ /** What every request of the binding carries from the host: headers, credentials, mode, cache. */
4
+ export type AgentsHttpFetchOptions = Omit<RequestInit, "method" | "body">;
5
+ export interface AgentsHttpConversationClientOptions extends AgentsConversationClientBindingOptions {
6
+ /**
7
+ * Where the application's conversations controller is mounted (its `#[Route]`): a path such as
8
+ * `/api/agents/conversations` or an absolute URL. The module's routes are relative to it.
9
+ */
10
+ baseUrl: string;
11
+ /**
12
+ * Request options every request carries (credentials, an authorization header). A function is called per request,
13
+ * so it may hand out a fresh token. Default: none (the browser's defaults: same-origin credentials).
14
+ */
15
+ fetchOptions?: AgentsHttpFetchOptions | (() => AgentsHttpFetchOptions | Promise<AgentsHttpFetchOptions>);
16
+ /** The fetch function. Default: the global `fetch`. */
17
+ fetch?: typeof fetch;
18
+ /**
19
+ * The application's start route below `baseUrl` (`AgentConversationStartTrait` declares none). Default: `/start` for
20
+ * a start without an agent space (key 0), `/start/{agentSpaceKey}` otherwise — the start DTO reads `agentSpaceId`
21
+ * from the path.
22
+ */
23
+ buildStartPath?: (agentSpaceKey: number) => string;
24
+ /**
25
+ * The controller uses `AgentSelectableModelsTrait` (`GET …/selectable-models`): the client offers
26
+ * `getSelectableModels` and the chat shows the model picker. Default false.
27
+ */
28
+ hasSelectableModelsRoute?: boolean;
29
+ /**
30
+ * The live updates: the polling default over the run-state read (`withPollingChangeSubscription`), which also reads
31
+ * at once after a post, a signal or a retry the server accepted. The intervals of
32
+ * `PollingConversationChangeSubscriptionOptions`; `false` = no subscription (the host adds its own push transport).
33
+ * Default: polling with the default intervals.
34
+ */
35
+ polling?: PollingConversationChangeSubscriptionOptions | false;
36
+ }
37
+ /** The page size of a changed-messages read when the request names none (as the chat sends it). */
38
+ export declare const AGENTS_HTTP_DEFAULT_CHANGED_MESSAGES_PAGE_SIZE = 50;
39
+ /**
40
+ * The conversation client over the module's own conversation routes (`AgentConversationReadsTrait`,
41
+ * `AgentConversationWritesTrait`, the application's start route of `AgentConversationStartTrait`, optionally
42
+ * `AgentSelectableModelsTrait`): `baseUrl` is where the application mounted its conversations controller, `fetchOptions`
43
+ * what every request carries. Every function rejects with `AgentsClientError`. The client comes with live updates —
44
+ * the polling default over the run-state read, which also reads at once after an accepted send — unless `polling` is
45
+ * `false`.
46
+ *
47
+ * ```ts
48
+ * const client = createAgentsHttpConversationClient({
49
+ * baseUrl: "/api/agents/conversations",
50
+ * fetchOptions: () => ({ headers: { Authorization: `Bearer ${readToken()}` } }),
51
+ * });
52
+ * <AgentsProvider client={client}><AgentChat /></AgentsProvider>
53
+ * ```
54
+ */
55
+ export declare const createAgentsHttpConversationClient: (options: AgentsHttpConversationClientOptions) => AgentsConversationClient;
@@ -1,4 +1,4 @@
1
- import { type AgentsConversation, type ConversationChangeSignal, type ConversationRunStatus, type ConversationSubscriptionEndReason } from "../../contract/conversation";
1
+ import { type ConversationChangeSignal, type ConversationRunStateRead, type ConversationRunStatus, type ConversationSubscriptionEndReason } from "../../contract/conversation";
2
2
  /** Read interval while a turn runs (or right after a local send). */
3
3
  export declare const POLLING_RUNNING_INTERVAL_MS = 2000;
4
4
  /** Read interval while the conversation is idle or failed. */
@@ -10,8 +10,11 @@ export declare const POLLING_MAX_BACKOFF_MS = 60000;
10
10
  * server may store the owner's message before it marks the turn as running.
11
11
  */
12
12
  export declare const POLLING_LOCAL_ACTIVITY_WINDOW_MS = 10000;
13
- /** Reads a conversation's metadata — the port's `getConversationMetadata`. */
14
- export type ConversationMetadataReader = (conversationId: number) => Promise<AgentsConversation>;
13
+ /**
14
+ * Reads a conversation's run state — the port's `getConversationRunState`, or its `getConversationMetadata` (every
15
+ * conversation carries the fields the poller reads).
16
+ */
17
+ export type ConversationMetadataReader = (conversationId: number) => Promise<ConversationRunStateRead>;
15
18
  /** The timer functions the poller uses; a spec hands in fake ones. */
16
19
  export interface PollingTimers {
17
20
  setTimeout: (callback: () => void, delayMs: number) => unknown;
@@ -51,7 +54,7 @@ export interface PollingConversationChangeSubscription {
51
54
  * The three-value run status a polled read reports: the stored run state, and "running" for an idle conversation the
52
55
  * server owes a turn (`agentTurnOwedAt`), as the chat's own derivation does.
53
56
  */
54
- export declare const readPolledRunStatus: (conversation: AgentsConversation) => ConversationRunStatus | null;
57
+ export declare const readPolledRunStatus: (conversation: Pick<ConversationRunStateRead, "runState" | "agentTurnOwedAt">) => ConversationRunStatus | null;
55
58
  /**
56
59
  * The polling default of `subscribeToConversationChanges` over a metadata read: every 2 s while a turn
57
60
  * runs, every 20 s while idle, at once after `notifyLocalActivity`; paused while the page is hidden and read once when
@@ -5,7 +5,8 @@ export type AgentsConversationClientWithChangeSubscription = AgentsConversationC
5
5
  /**
6
6
  * The client with live updates: a client that brings its own `subscribeToConversationChanges` (a push
7
7
  * transport — the host application's Firebase binding) is returned as it is; any other gets the polling default over its
8
- * `getConversationMetadata` (`createPollingConversationChangeSubscription`, `options` tune the intervals). The default
9
- * `AgentChat` calls this by itself.
8
+ * `getConversationRunState` when it has one, else over its `getConversationMetadata`
9
+ * (`createPollingConversationChangeSubscription`, `options` tune the intervals). A post, a signal or a retry the server
10
+ * accepted reads at once. The default `AgentChat` calls this by itself.
10
11
  */
11
12
  export declare const withPollingChangeSubscription: (client: AgentsConversationClient, options?: PollingConversationChangeSubscriptionOptions) => AgentsConversationClientWithChangeSubscription;
@@ -85,6 +85,14 @@ export interface AgentsConversation {
85
85
  name: string | null;
86
86
  } | null;
87
87
  }
88
+ /**
89
+ * What the server's run-state read answers (`GET …/{id}/runState`): the lean subset of a conversation the live updates
90
+ * poll. Every `AgentsConversation` is one, so a binding without the read may answer it with the metadata read.
91
+ */
92
+ export type ConversationRunStateRead = Pick<AgentsConversation, "id" | "runState" | "agentTurnOwedAt" | "title" | "titleManuallyEdited" | "summary" | "updated"> & {
93
+ /** generic — the id of the newest stored message; null before the first */
94
+ lastMessageId?: number | null;
95
+ };
88
96
  /** A sub-agent conversation a delegation started, as far as the chat reads it (`delegatedConversations(select=id,runState)`). */
89
97
  export interface ConversationDelegatedConversation {
90
98
  /** generic */
@@ -1,5 +1,6 @@
1
1
  export { AgentChat, type AgentChatProps } from "../chat/AgentChat/AgentChat";
2
- export { AgentChatController, type AgentChatActivityHistoryProps, type AgentChatActivityProps, type AgentChatControllerProps, type AgentChatSendModelSource, } from "../chat/controller/AgentChatController";
2
+ export { AgentChatController, type AgentChatActivityHistoryProps, type AgentChatActivityProps, type AgentChatComposerHandle, type AgentChatControllerProps, type AgentChatSendModelSource, } from "../chat/controller/AgentChatController";
3
+ export { useAgentsConversationClient, useOptionalAgentsConversationClient, } from "../client/AgentsConversationClientContext";
3
4
  export { AgentChatActivityIndicator } from "../chat/AgentChatActivityIndicator/AgentChatActivityIndicator";
4
5
  export { AgentChatActivityHistory } from "../chat/AgentChatActivityHistory/AgentChatActivityHistory";
5
6
  export { ConversationClosedBar, type ConversationClosedBarProps } from "../chat/ConversationClosedBar/ConversationClosedBar";
@@ -2,3 +2,7 @@ export * from "../client/AgentsConversationClient";
2
2
  export * from "../client/AgentsConversationClientContext";
3
3
  export * from "../client/polling/createPollingConversationChangeSubscription";
4
4
  export * from "../client/polling/withPollingChangeSubscription";
5
+ export * from "../client/http/createAgentsHttpConversationClient";
6
+ export * from "../client/http/agents-http-wire";
7
+ export * from "../client/http/agents-http-mappers";
8
+ export { composeAttachmentMessageText } from "../client/compose-attachment-message-text";
@@ -1,4 +1,5 @@
1
1
  export { ConversationMarkdown, type ConversationMarkdownProps } from "../renderer/ConversationMarkdown";
2
+ export { MarkdownLink, type MarkdownLinkProps } from "../renderer/MarkdownLink";
2
3
  export { ConversationWidgetHost, type ConversationWidgetRenderProps } from "../renderer/ConversationWidgetHost";
3
4
  export { ConversationWidgetErrorBoundary } from "../renderer/ConversationWidgetErrorBoundary";
4
5
  export { type ConversationWidgetUpsellProps, ConversationWidgetFeatureGate, } from "../renderer/_access/ConversationWidgetFeatureGate";
@@ -18,7 +18,7 @@ export { WebSearchResultsConversationWidget } from "../widgets/WebSearchResultsC
18
18
  export { WritingDraftConversationWidget } from "../widgets/WritingDraftConversationWidget/WritingDraftConversationWidget";
19
19
  export * from "../widgets/_shared/modern";
20
20
  export type { CanvasLauncherWidgetCanvas } from "../widgets/CanvasLauncherWidget/CanvasLauncherWidget";
21
- export { CANVAS_VIABLE_MIN_WIDTH, useCanvasViable } from "../widgets/CanvasLauncherWidget/use-canvas-viable";
21
+ export { CANVAS_VIABLE_MIN_WIDTH, CanvasViabilityContext, type CanvasViabilitySource, ElementWidthCanvasViability, readCanvasViable, useCanvasViable, } from "../widgets/CanvasLauncherWidget/use-canvas-viable";
22
22
  export { WidgetLabel } from "../widgets/_shared/WidgetLabel";
23
23
  export { WidgetFooter } from "../widgets/_shared/WidgetFooter";
24
24
  /** @deprecated Renamed to `WidgetFooter`. */
@@ -148,7 +148,10 @@ export interface AgentsSplitViewPane {
148
148
  /** Two panes side by side; the side pane slides in over the right edge and covers the screen below a width. */
149
149
  export interface AgentsSplitViewProps {
150
150
  isSideOpen: boolean;
151
- /** Below this viewport width the open side pane covers the main pane. */
151
+ /**
152
+ * Below this width the open side pane covers the main pane. The package default measures the split view's own box
153
+ * (the chat container); a replacement may keep reading the viewport.
154
+ */
152
155
  coversBelowWidth?: number;
153
156
  main: AgentsSplitViewPane;
154
157
  side: AgentsSplitViewPane;
@@ -311,7 +314,7 @@ export interface AgentsHeroValueProps {
311
314
  color?: string;
312
315
  }
313
316
  /** The type scale of the widgets, from the hero figure down to the micro label. */
314
- export type AgentsWidgetTextVariant = "hero" | "headline" | "gaugeValue" | "value" | "caption" | "label" | "micro" | "inherit";
317
+ export type AgentsWidgetTextVariant = "hero" | "headline" | "title" | "gaugeValue" | "value" | "caption" | "label" | "micro" | "inherit";
315
318
  export type AgentsWidgetTextTone = "default" | "light" | "cta";
316
319
  /** A text of the widget type scale. A string child is a text key unless `translate` is false. */
317
320
  export interface AgentsWidgetTextProps {
@@ -4,6 +4,7 @@ import type { ConversationWidgetStatePartition } from "../renderer/conversation-
4
4
  import type { ChatAssistantCategory } from "../chat/chat-assistant-identity";
5
5
  import type { ComposedNodeSchemaApplicationPart } from "../renderer/widget-tree/composed-node-schema";
6
6
  import type { CanvasBehaviour } from "../renderer/canvas/canvas-behaviours";
7
+ import type { OpenEntityActionTarget } from "../renderer/canvas/entity-detail-instance";
7
8
  /** Translates interface copy. The key is the English source text. */
8
9
  export interface AgentsTexts {
9
10
  translate: (key: string, replacements?: Record<string, string | number>, context?: string) => string;
@@ -154,6 +155,18 @@ export interface AgentsEnvironment {
154
155
  * replacements, which may read a string as markup. Default: the text unchanged.
155
156
  */
156
157
  escapePlainTextForText?: (text: string) => string;
158
+ /**
159
+ * Decides where a link of the package goes — every anchor (Markdown links, sources, kit links) and every link the
160
+ * package opens by code (a video's watch page, an `openUrl` action, a gallery image without a lightbox). `event` is
161
+ * the click, null when there is none. Return true when the host navigated itself (an in-app route; the package then
162
+ * does nothing), false to let the package open the link in a new tab. Default: every link opens in a new tab.
163
+ */
164
+ onNavigate?: (href: string, event: MouseEvent | null) => boolean;
165
+ /**
166
+ * Opens the entity of an `openEntity` action (a composed view's row, a map point) on a host route instead of the
167
+ * `entityDetail` canvas. Return true when the host opened it, false to open the canvas. Default: the canvas.
168
+ */
169
+ onOpenEntity?: (target: OpenEntityActionTarget) => boolean;
157
170
  /** Opens the images in the app's lightbox, starting at `startIndex`. Default: the start image in a new tab. */
158
171
  openImageGallery?: (images: AgentsGalleryImage[], startIndex: number) => void;
159
172
  /** Reports a widget that crashed while rendering. Default: nothing (the crash is logged to the console). */
@@ -0,0 +1,24 @@
1
+ /** Where a host keeps its colour theme on the root element: a class, or an attribute with a value. */
2
+ export interface HostColorSchemeSource {
3
+ /** The element that carries the theme. Default: the root element (`<html>`). */
4
+ element?: Element;
5
+ /** Dark while the element has this class (e.g. `dark`). */
6
+ darkClassName?: string;
7
+ /** Dark while this attribute (e.g. `data-mode`) has the value `darkAttributeValue`. */
8
+ attributeName?: string;
9
+ /** The attribute's value for dark. Default `dark`. */
10
+ darkAttributeValue?: string;
11
+ }
12
+ /** The attribute on the root element that pins the package's colour scheme (`dark` or `light`). */
13
+ export declare const AGENTS_THEME_ATTRIBUTE_NAME = "data-agents-theme";
14
+ /**
15
+ * Lets the package's colour scheme (its dark set, `color-scheme`) follow a host theme kept as a class or an attribute:
16
+ * mirrors it now and on every change into `data-agents-theme="dark" | "light"` on the root element, which the package
17
+ * stylesheet reads before `prefers-color-scheme` and `data-theme`. Returns the stop, which removes the attribute again.
18
+ *
19
+ * ```ts
20
+ * followHostColorScheme({ darkClassName: "dark" }); // <html class="dark">
21
+ * followHostColorScheme({ attributeName: "data-mode" }); // <html data-mode="dark">
22
+ * ```
23
+ */
24
+ export declare const followHostColorScheme: (source: HostColorSchemeSource) => (() => void);
@@ -1,5 +1,9 @@
1
1
  export { AgentsProvider, type AgentsProviderProps, useAgentsActiveAgentSpaceKey, useAgentsBudgetLimit, useAgentsComponents, useAgentsEnvironment, useAgentsMapsLoader, useAgentsOwnerSettings, useAgentsStateDispatch, useAgentsStateSelector, useAgentsTexts, } from "./AgentsProvider";
2
2
  export { type AgentsAssistantBackgroundProps, type AgentsAssistantIconBadgeProps, type AgentsBudgetLimit, type AgentsEnvironment, type AgentsGalleryImage, type AgentsMapsLoaderState, type AgentsOwnerSettings, type AgentsSandboxLegacyAliases, type AgentsStateAction, type AgentsStateStore, type AgentsTexts, appendAnotherAgentSpaceToOwnerText, buildUnnamedAgentSpaceLabel, buildWidgetOfAnotherAgentSpaceExplanation, DEFAULT_AGENTS_TEXTS, DEFAULT_WIDGET_IMAGE_CAPTURE_READ_PATH_PREFIX, DEFAULT_WIDGET_SELF_HYDRATION_KEY_FIELD_NAME, escapePlainTextForText, getAgentDisplayName, getAgentsEnvironment, getFurtherCanvasBehaviours, getFurtherWidgetClickSignalSources, getGoogleMapWidgetNames, getSandboxLegacyAliases, getWidgetImageCaptureReadPathPrefix, getWidgetSelfHydrationKeyFieldName, openImageGallery, reportRunningTurn, reportWidgetCrash, setAgentsEnvironment, translateText, } from "./environment";
3
3
  export { classNames } from "./class-names";
4
+ export { useAgentsConversationClient, useOptionalAgentsConversationClient, } from "../client/AgentsConversationClientContext";
5
+ export { AgentsLink, type AgentsLinkNavigation, type AgentsLinkProps, useAgentsLinkNavigation, } from "./link-navigation";
6
+ export { DEFAULT_AGENTS_COMPONENTS } from "./components/default-components";
7
+ export { AGENTS_THEME_ATTRIBUTE_NAME, followHostColorScheme, type HostColorSchemeSource, } from "./host-color-scheme";
4
8
  export * from "./components";
5
9
  export type { AgentsTextRole, AgentsTextWeight, AgentsTextReplacements, AgentsTextProps, AgentsButtonVariant, AgentsButtonSize, AgentsButtonProps, AgentsIconName, AgentsIconSize, AgentsIconProps, AgentsInteractiveSurfaceProps, AgentsSkeletonProps, AgentsLoadingSpinnerProps, AgentsTooltipProps, AgentsGlowFrameProps, AgentsProgressBarProps, AgentsSplitViewPane, AgentsSplitViewProps, AgentsTrendDeltaProps, AgentsCheckboxProps, AgentsTextInputProps, AgentsTextAreaProps, AgentsRangeSliderProps, AgentsDateInputProps, AgentsChoiceOption, AgentsRadioGroupProps, AgentsSelectOption, AgentsSelectProps, AgentsTabsOption, AgentsTabsProps, AgentsStatusBadgeStatus, AgentsStatusBadgeProps, AgentsMapPosition, AgentsMapProps, AgentsMapMarkerProps, AgentsModalLayerProps, AgentsHeroRowProps, AgentsHeroValueProps, AgentsWidgetTextVariant, AgentsWidgetTextTone, AgentsWidgetTextProps, AgentsSkeletonTextProps, AgentsStatusChipTone, AgentsStatusChipProps, AgentsSegment, AgentsSegmentBarProps, AgentsMarkdownComponents, AgentsMarkdownProps, AgentsWidgetFeatureGateProps, AgentsConversationSearchHit, AgentsConversationSearchGroup, AgentsConversationSearchResultsListProps, AgentsComponents, } from "./components/types";
@@ -0,0 +1,28 @@
1
+ import { type AnchorHTMLAttributes, type MouseEvent as ReactMouseEvent } from "react";
2
+ import type { AgentsEnvironment } from "./environment";
3
+ /**
4
+ * Opens a link through the environment's `onNavigate` (the host decides: an in-app route, a new tab, nothing), else in
5
+ * a new tab. `event` is the click that asked for it, when there is one.
6
+ */
7
+ export declare const openLinkThroughEnvironment: (environment: Pick<AgentsEnvironment, "onNavigate">, href: string, event: MouseEvent | null) => void;
8
+ /** How package code opens a link: through the host's `onNavigate`, else in a new tab. */
9
+ export interface AgentsLinkNavigation {
10
+ /** Opens `href` (a link opened by code, e.g. a button: the package's `window.open` places). */
11
+ openLink: (href: string, event?: ReactMouseEvent | MouseEvent) => void;
12
+ /**
13
+ * The click handler of an anchor that opens in a new tab: hands the click to the host's `onNavigate` and keeps the
14
+ * browser from following the anchor when the host took it.
15
+ */
16
+ handleLinkClick: (event: ReactMouseEvent<HTMLAnchorElement>, href?: string) => void;
17
+ }
18
+ /** The link navigation of this subtree (`AgentsEnvironment.onNavigate`). */
19
+ export declare const useAgentsLinkNavigation: () => AgentsLinkNavigation;
20
+ export type AgentsLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
21
+ /** The hast node react-markdown passes to a custom component; never put on the DOM element. */
22
+ node?: unknown;
23
+ };
24
+ /**
25
+ * The anchor every package link renders: a new tab without opener or referrer, unless the host's `onNavigate` takes
26
+ * the click (an in-app route). A host's own widget uses it for the same behaviour.
27
+ */
28
+ export declare const AgentsLink: (props: AgentsLinkProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Marks a text key the package translates later, where the translate call does not see it as a literal (a table of
3
+ * labels, a helper's argument): returns the key unchanged. `scripts/i18n-keys.mjs` lists every marked key in
4
+ * `i18n-keys.json`, so a host that translates the package's texts finds it there.
5
+ */
6
+ export declare const textKey: <Key extends string>(key: Key) => Key;
@@ -1,6 +1,8 @@
1
- import React from "react";
2
- export type MarkdownLinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
3
- /** The hast node react-markdown passes to every custom component; not a valid DOM attribute. */
4
- node?: unknown;
5
- };
6
- export declare const MarkdownLink: ({ node, children, ...anchorProps }: MarkdownLinkProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { type AgentsLinkProps } from "../provider/link-navigation";
2
+ export type MarkdownLinkProps = AgentsLinkProps;
3
+ /**
4
+ * The link of a chat message (the `a` component `ConversationMarkdown` hands to `Markdown`): a new-tab anchor with a
5
+ * dotted underline, or the host's own navigation (`AgentsEnvironment.onNavigate`). A host's `Markdown` replacement may
6
+ * wrap it (`components.a`). `node` is dropped so react-markdown's hast node never lands on the DOM element.
7
+ */
8
+ export declare const MarkdownLink: (props: MarkdownLinkProps) => import("react/jsx-runtime").JSX.Element;