@mgamadeus/ddd-agents 0.1.2 → 0.1.3
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 +31 -2
- package/dist/chat.js +284 -163
- package/dist/chat.js.map +1 -1
- package/dist/chunks/{contract-Z08LBOqt.js → contract-kmmw_19Y.js} +2 -2
- package/dist/chunks/{contract-Z08LBOqt.js.map → contract-kmmw_19Y.js.map} +1 -1
- package/dist/chunks/{conversation-BEF0aesf.js → conversation-CbWEHPbL.js} +12 -3
- package/dist/chunks/{conversation-BEF0aesf.js.map → conversation-CbWEHPbL.js.map} +1 -1
- package/dist/chunks/link-navigation-DyTApNeA.js.map +1 -1
- package/dist/chunks/{withPollingChangeSubscription-CNXgt3Ri.js → withPollingChangeSubscription-CWavoKjJ.js} +2 -2
- package/dist/chunks/{withPollingChangeSubscription-CNXgt3Ri.js.map → withPollingChangeSubscription-CWavoKjJ.js.map} +1 -1
- package/dist/client-testing.js +1 -1
- package/dist/client.js +45 -6
- package/dist/client.js.map +1 -1
- package/dist/contract.js +6 -5
- package/dist/files/i18n-keys.json +19 -0
- package/dist/styles.css +148 -15
- package/dist/types/chat/AgentChatActivityDots/AgentChatActivityDots.d.ts +11 -0
- package/dist/types/chat/AgentChatActivityIndicator/AgentChatActivityIndicator.d.ts +7 -2
- package/dist/types/chat/AgentChatActivityStack/AgentChatActivityStack.d.ts +15 -0
- package/dist/types/chat/controller/AgentChatController.d.ts +10 -0
- package/dist/types/chat/controller/activity-ticker.d.ts +5 -2
- package/dist/types/chat/controller/chat-activity-timing.d.ts +30 -0
- package/dist/types/chat/controller/use-activity-ticker.d.ts +6 -0
- package/dist/types/chat/controller/use-conversation-activity.d.ts +6 -2
- package/dist/types/client/http/agents-http-mappers.d.ts +9 -2
- package/dist/types/client/http/agents-http-wire.d.ts +13 -0
- package/dist/types/client/http/createAgentsHttpConversationClient.d.ts +9 -0
- package/dist/types/contract/conversation.d.ts +27 -0
- package/dist/types/entries/chat.d.ts +4 -1
- package/dist/types/provider/environment.d.ts +7 -0
- package/package.json +1 -1
- package/public-api.json +16 -0
package/README.md
CHANGED
|
@@ -53,19 +53,45 @@ const client = createAgentsHttpConversationClient({
|
|
|
53
53
|
| `getSelectableModels` | `GET /selectable-models`, only with `hasSelectableModelsRoute: true` |
|
|
54
54
|
|
|
55
55
|
Further options: `fetch` (default: the global one), `extraRequestParameters` (query parameters per operation),
|
|
56
|
-
`polling` (the intervals of the live updates, or `false` for a host with its own push transport)
|
|
56
|
+
`polling` (the intervals of the live updates, or `false` for a host with its own push transport), `clientContext`
|
|
57
|
+
(below). Attachments travel in
|
|
57
58
|
the message text (`composeAttachmentMessageText`). Every failure rejects with `AgentsClientError`: the `errorCode` of the
|
|
58
59
|
body first (`AI_BUDGET_REACHED`, `RATE_LIMIT_EXCEEDED`, `CONVERSATION_CLOSED`), then the status (429 with `Retry-After`,
|
|
59
60
|
404, 401/403, 5xx), a transport failure as `network`, a cancelled request as `other` / `REQUEST_ABORTED`. The wire types
|
|
60
61
|
(`Wire…`) and the mappers (`mapWireConversation`, `mapWireConversationMessage`, …) are exported for a binding of its own
|
|
61
62
|
over the same routes.
|
|
62
63
|
|
|
64
|
+
**Client context.** `clientContext(operation)` tells the agent what the owner sees: it is read on every start, posted
|
|
65
|
+
message and injected signal and sent as the body field `clientContext` — the route path, the route parameters (a flat
|
|
66
|
+
map), the record kind and id, the tab (`AgentsClientContext`). The server stores it on that owner message, and the agent
|
|
67
|
+
reads the newest one as one line beside the owner's newest message (never part of the transcript). Caps
|
|
68
|
+
(`AGENTS_CLIENT_CONTEXT_LIMITS`): 512 characters for the path and for the parameters as `name=value&…`, at most 20
|
|
69
|
+
parameters, 64 for the kind and the tab, 128 for the id. The binding leaves out a field over its cap or with a control
|
|
70
|
+
character, never cuts it (`mapClientContextToWire`), so a send never fails on it; the server refuses such a field with
|
|
71
|
+
HTTP 400.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const client = createAgentsHttpConversationClient({
|
|
75
|
+
baseUrl: "/api/agents/conversations",
|
|
76
|
+
clientContext: () => ({ routePath: location.pathname, routeParameters: readRouteParameters(), recordKind: "ticket", recordId: currentTicketId, tab: currentTab }),
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
63
80
|
**Live updates.** The client comes with the polling default over `GET /{id}/runState`, which reads at once after a post,
|
|
64
81
|
a signal or a retry the server accepted. A binding of its own gets the same from `withPollingChangeSubscription(client)`;
|
|
65
82
|
the port's optional `getConversationRunState` is read before `getConversationMetadata` when a binding has it.
|
|
66
83
|
`useAgentsConversationClient()` (`/client`, `/chat`, the root and `/provider`) returns the client of the chat around —
|
|
67
84
|
the one of `AgentsProvider`, or the `client` an `AgentChat` got as a prop.
|
|
68
85
|
|
|
86
|
+
### A binding of its own (adapter)
|
|
87
|
+
|
|
88
|
+
A host may serve the port from its own data layer instead (its API client, its store), with the wire types and the
|
|
89
|
+
mappers above. One trap with RTK Query: a binding that reads with forced refetches and holds no subscription (a
|
|
90
|
+
`initiate(…, { forceRefetch: true })` per port read, unsubscribed at once) must **not** set `keepUnusedDataFor: 0` on
|
|
91
|
+
those endpoints. With 0 the store drops the cache entry the moment the first read ends and aborts a request still in
|
|
92
|
+
flight when a second read of the same key arrives — the chat then shows an empty conversation after a page load with a
|
|
93
|
+
conversation in the URL. Keep the default (or any value above 0) and let the forced reads refresh the entry.
|
|
94
|
+
|
|
69
95
|
## Texts and translations
|
|
70
96
|
|
|
71
97
|
Every interface text of the package goes through `AgentsEnvironment.texts.translate(key, replacements, context)`; the key
|
|
@@ -79,7 +105,8 @@ setAgentsEnvironment({
|
|
|
79
105
|
});
|
|
80
106
|
```
|
|
81
107
|
|
|
82
|
-
|
|
108
|
+
Icon-only buttons carry their accessible name through the same function (the composer's send button: `Send message`;
|
|
109
|
+
the scroll-to-latest button beside it: `Scroll to the latest message`). In the package, `pnpm i18n-keys` rewrites the manifest from the sources; the build and the specs fail when it is stale. A
|
|
83
110
|
key the generator cannot see as a literal is wrapped in `textKey("…")`.
|
|
84
111
|
|
|
85
112
|
## Links, entities and default components
|
|
@@ -102,6 +129,8 @@ key the generator cannot see as a literal is wrapped in `textKey("…")`.
|
|
|
102
129
|
| `backgroundPaintedByHost` | `true` | `false` paints the pane with `--agents-chat-background` |
|
|
103
130
|
| `showsTopBlurBand` | `false` | the frosted band under a floating top bar, following the chat pane |
|
|
104
131
|
| `composerRef` | — | `setComposerDraft(text)` puts a draft into the mounted composer, never sends |
|
|
132
|
+
| `ThinkingIndicator` | `AgentChatActivityIndicator` | the activity at the tail of the thread; `AgentChatActivityStack` is the stacked feed (one sentence per tool call, older lines drifting up under a top mask, a polite status region for the newest), and `(props) => <AgentChatActivityIndicator {...props} dotsVariant="pulse" />` the calm dots |
|
|
133
|
+
| `activityTiming` | `AgentsEnvironment.chatActivityTiming`, else the package | the activity read window (3000 ms), the read floor while a turn runs (4000), the line paces (2200 / 1400 with a backlog) and the success beat (1400); a host with a realtime push that writes `activityUpdatedAt` lowers the read window so a narrated line shows at once |
|
|
105
134
|
|
|
106
135
|
The canvas split fits by the width of the chat's own container (`ResizeObserver`), not the viewport: below 850 px the
|
|
107
136
|
open canvas covers the chat. The default `SplitView` honours `coversBelowWidth` the same way. The default chat starts its
|