@m6d/cortex-angular 0.13.0 → 0.14.1
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 +32 -27
- package/fesm2022/m6d-cortex-angular.mjs +4499 -4504
- package/package.json +2 -9
- package/types/m6d-cortex-angular.d.ts +358 -213
package/README.md
CHANGED
|
@@ -35,14 +35,14 @@ No root-level providers are needed. Each widget is self-contained, so one page c
|
|
|
35
35
|
|
|
36
36
|
| Property | Type | Description |
|
|
37
37
|
| -------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
38
|
-
| `locale` | `'en' \| 'ar'` | Active locale (default: `'en'`)
|
|
38
|
+
| `locale` | `'en' \| 'ar'` | Active locale; the widget lays out in its direction (default: `'en'`) |
|
|
39
39
|
| `transport.baseUrl` | `string \| () => string` | The agent's URL, `<engine origin>/agents/<slug>` |
|
|
40
40
|
| `transport.getHeaders` | `() => Headers \| Promise<Headers>` | Request headers provider; `Headers` is `Record<string, string>` |
|
|
41
41
|
| `wsUrl` | `string \| false` | WebSocket URL override; `false` disables the socket (optional) |
|
|
42
42
|
| `viewMode` | `'helper' \| 'full'` | Compact panel or full layout with a sidebar (default: `'helper'`) |
|
|
43
43
|
| `theme` | `'light' \| 'dark' \| 'system'` | Color scheme (default: `'light'`) |
|
|
44
44
|
| `agentName` | `string \| { en, ar }` | Header title while no thread is selected (optional) |
|
|
45
|
-
| `
|
|
45
|
+
| `thread` | `string` | A thread id to open on mount (optional) |
|
|
46
46
|
| `mediaRenderers` | `Record<string, MediaRenderer>` | Replace or add the media fences the assistant can draw (optional) |
|
|
47
47
|
| `trustSameOriginEmbeds` | `boolean` | Allow embedded tool pages served from this page's own origin (default: `false`) |
|
|
48
48
|
| `hooks.onToolCall` | `(toolCall, context) => unknown` | Answers a client tool; return `undefined` for tools you do not own (optional) |
|
|
@@ -51,7 +51,7 @@ No root-level providers are needed. Each widget is self-contained, so one page c
|
|
|
51
51
|
| `toolComponents` | `Record<string, Type<CortexToolComponentInputs>>` | Custom Angular components for tool rendering (optional) |
|
|
52
52
|
| `injector` | `Injector` | Injector for `toolComponents` (optional) |
|
|
53
53
|
|
|
54
|
-
`transport.getHeaders` returns the headers every call carries, usually a bearer `Authorization`. Called straight from another origin, the engine accepts only `Authorization` and the headers the widget sets itself; route anything else through a same-origin proxy. The WebSocket takes its `token` query param from a bearer `Authorization` header when there is one.
|
|
54
|
+
`transport.getHeaders` returns the headers every call carries, usually a bearer `Authorization`. Called straight from another origin, the engine accepts only `Authorization` and the headers the widget sets itself; route anything else through a same-origin proxy. The WebSocket takes its `token` query param from a bearer `Authorization` header when there is one. The debug toggle shows only when Cortex offers this caller the debug view: always to a console operator, and to everyone only where the engine runs with `ENGINE_DEBUG=true`. Anyone else gets only what the widget's normal view draws, and so does a `toolComponents` entry for one of the agent's server tools: the model's line for the user as the call's input, and only whether it failed (or a dataset read's row count) as its output.
|
|
55
55
|
|
|
56
56
|
## Custom parts
|
|
57
57
|
|
|
@@ -119,19 +119,19 @@ for typing your own rows and chips.
|
|
|
119
119
|
|
|
120
120
|
One header serves both screens; `screen` says which is showing.
|
|
121
121
|
|
|
122
|
-
| Field | Type | Description
|
|
123
|
-
| -------------- | --------------------- |
|
|
124
|
-
| `screen` | `'chat' \| 'threads'` | Which screen the header is on
|
|
125
|
-
| `viewMode` | `'helper' \| 'full'` | The configured view mode
|
|
126
|
-
| `title` | `string \| null` | The open thread's title; `null` on a new chat
|
|
127
|
-
| `agentName` | `string \| undefined` | `agentName` in the widget's locale
|
|
128
|
-
| `threadCount` | `number \| undefined` | How many conversations the history lists; undefined while it loads
|
|
129
|
-
| `isWorking` | `boolean` | The agent is answering
|
|
130
|
-
| `debug` | `{ shown, on }` | Whether
|
|
131
|
-
| `newChat` | `() => void` | Starts a new chat
|
|
132
|
-
| `openHistory` | `() => void` | Shows the history: its screen, or the sidebar in full mode
|
|
133
|
-
| `closeHistory` | `() => void` | Returns to the open chat
|
|
134
|
-
| `toggleDebug` | `() => void` | Switches debug mode
|
|
122
|
+
| Field | Type | Description |
|
|
123
|
+
| -------------- | --------------------- | -------------------------------------------------------------------- |
|
|
124
|
+
| `screen` | `'chat' \| 'threads'` | Which screen the header is on |
|
|
125
|
+
| `viewMode` | `'helper' \| 'full'` | The configured view mode |
|
|
126
|
+
| `title` | `string \| null` | The open thread's title; `null` on a new chat |
|
|
127
|
+
| `agentName` | `string \| undefined` | `agentName` in the widget's locale |
|
|
128
|
+
| `threadCount` | `number \| undefined` | How many conversations the history lists; undefined while it loads |
|
|
129
|
+
| `isWorking` | `boolean` | The agent is answering |
|
|
130
|
+
| `debug` | `{ shown, on }` | Whether Cortex offers the debug view, and whether it is on |
|
|
131
|
+
| `newChat` | `() => void` | Starts a new chat; absent until Cortex confirms the caller may write |
|
|
132
|
+
| `openHistory` | `() => void` | Shows the history: its screen, or the sidebar in full mode |
|
|
133
|
+
| `closeHistory` | `() => void` | Returns to the open chat |
|
|
134
|
+
| `toggleDebug` | `() => void` | Switches debug mode |
|
|
135
135
|
|
|
136
136
|
### `landing`
|
|
137
137
|
|
|
@@ -152,13 +152,13 @@ landing for it.
|
|
|
152
152
|
|
|
153
153
|
The history's list. Its header is the `header` slot.
|
|
154
154
|
|
|
155
|
-
| Field | Type | Description
|
|
156
|
-
| ------------------ | --------------------------------- |
|
|
157
|
-
| `threads` | `ThreadSummary[] \| undefined` | Newest first; `undefined` while the first load is out
|
|
158
|
-
| `selectedThreadId` | `string \| undefined` | The open thread's id; `undefined` on a new chat
|
|
159
|
-
| `openThread` | `(thread: ThreadSummary) => void` | Opens a thread
|
|
160
|
-
| `deleteThread` | `(threadId: string) => void` | Deletes a thread
|
|
161
|
-
| `newChat` | `() => void` | Starts a new chat
|
|
155
|
+
| Field | Type | Description |
|
|
156
|
+
| ------------------ | --------------------------------- | -------------------------------------------------------------------- |
|
|
157
|
+
| `threads` | `ThreadSummary[] \| undefined` | Newest first; `undefined` while the first load is out |
|
|
158
|
+
| `selectedThreadId` | `string \| undefined` | The open thread's id; `undefined` on a new chat |
|
|
159
|
+
| `openThread` | `(thread: ThreadSummary) => void` | Opens a thread |
|
|
160
|
+
| `deleteThread` | `(threadId: string) => void` | Deletes a thread; absent until Cortex confirms the caller may write |
|
|
161
|
+
| `newChat` | `() => void` | Starts a new chat; absent until Cortex confirms the caller may write |
|
|
162
162
|
|
|
163
163
|
## Theming
|
|
164
164
|
|
|
@@ -206,7 +206,10 @@ That is how a tool of type `client` ("Answered by your app" in the console)
|
|
|
206
206
|
works: return its output from `hooks.onToolCall` for that tool name, or draw it
|
|
207
207
|
with a tool component. A `hooks.onToolCall` must return `undefined` for tool
|
|
208
208
|
names it does not own, since answering an unknown pending call would settle an
|
|
209
|
-
embedded flow before the user completes it.
|
|
209
|
+
embedded flow before the user completes it. A tool component draws a pending
|
|
210
|
+
call only once Cortex confirms the caller may send; until then, and always for
|
|
211
|
+
an operator inspecting a thread, the call shows as the widget's own line, and
|
|
212
|
+
the component draws it once it settles.
|
|
210
213
|
|
|
211
214
|
## Media blocks
|
|
212
215
|
|
|
@@ -240,8 +243,10 @@ well:
|
|
|
240
243
|
```
|
|
241
244
|
|
|
242
245
|
`mediaRenderers` swaps a renderer or adds a fence tag of your own. A renderer
|
|
243
|
-
draws a closed fence's source into the host element and
|
|
244
|
-
its context carries the widget's
|
|
246
|
+
(`MediaRenderer`) draws a closed fence's source into the host element and
|
|
247
|
+
returns its teardown; its context (`MediaRenderContext`) carries the widget's
|
|
248
|
+
color `scheme` and `locale`. The field's map of tags to renderers is
|
|
249
|
+
`MediaRenderers`. The package exports all three types:
|
|
245
250
|
|
|
246
251
|
```ts
|
|
247
252
|
mediaRenderers: {
|
|
@@ -257,4 +262,4 @@ mediaRenderers: {
|
|
|
257
262
|
## Requirements
|
|
258
263
|
|
|
259
264
|
- Angular 21.2 or 22
|
|
260
|
-
- Peer dependencies: `@tanstack/ai`, `@tanstack/ai-
|
|
265
|
+
- Peer dependencies: `@tanstack/ai`, `@tanstack/ai-client`, `marked`, `dompurify`, `highlight.js`, plus the lazily loaded `mermaid`, `vega`, `vega-lite`, `vega-embed`, `leaflet`
|