@athenaintel/react 0.11.0 → 0.11.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 +150 -3
- package/dist/index.cjs +257 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +257 -56
- package/dist/index.js.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +1 -1
- package/dist/styles.css +2 -150
- package/dist/tools/tool-uis.d.ts +18 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -103,9 +103,83 @@ What the statewire transport wires up in `AthenaChat`:
|
|
|
103
103
|
statewire session to the selected thread. `ThreadList` and
|
|
104
104
|
`useAthenaThreadManager` work in both modes.
|
|
105
105
|
|
|
106
|
-
Remaining limitations: the `agent` prop
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
Remaining limitations: on statewire the `agent` prop only accepts
|
|
107
|
+
`collab_agent:<asset_id>` refs (see below) — any other value is ignored,
|
|
108
|
+
because the statewire host always runs the Athena deep agent. `model`
|
|
109
|
+
defaults to the deep-agent default model unless a collab agent supplies one.
|
|
110
|
+
|
|
111
|
+
## Collab Agents
|
|
112
|
+
|
|
113
|
+
A **collab agent** is an agent configuration authored in Athena (prompt,
|
|
114
|
+
model, toolkits, behavior) and addressed as `collab_agent:<asset_id>`. Point
|
|
115
|
+
the provider at one and the chat runs **as** that agent:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<AthenaProvider
|
|
119
|
+
transport="statewire"
|
|
120
|
+
agent="collab_agent:asset_432af46f-293d-480b-a518-30b1f42a9ef7"
|
|
121
|
+
channel="askbob_web"
|
|
122
|
+
>
|
|
123
|
+
<AthenaChat />
|
|
124
|
+
</AthenaProvider>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Copy the snippet with real ids from the agent's **Channels** tab in Athena.
|
|
128
|
+
|
|
129
|
+
`channel` is optional. It selects a **channel override layer** — a built-in
|
|
130
|
+
channel (`email`, `sms`, …) or a custom channel defined on that agent — so one
|
|
131
|
+
agent can present different prompts, models, and tools per surface. Omit it to
|
|
132
|
+
run the agent's base configuration.
|
|
133
|
+
|
|
134
|
+
### Requirements
|
|
135
|
+
|
|
136
|
+
- **`transport="statewire"`.** The legacy transport ignores `collab_agent:` refs.
|
|
137
|
+
- **Publish the agent.** Resolution reads the *published* snapshot, not the
|
|
138
|
+
live draft, so a channel that exists only in the editor is rejected with
|
|
139
|
+
`collab_agent_channel_unknown`.
|
|
140
|
+
- **The acting user needs VIEW access** to the agent asset (admins bypass).
|
|
141
|
+
Running as an agent exposes its prompt and tool policy, so the same gate that
|
|
142
|
+
governs opening the asset governs running it.
|
|
143
|
+
|
|
144
|
+
### Do not also pass `model`, `systemPrompt`, or `tools`
|
|
145
|
+
|
|
146
|
+
Request keys override the agent definition, so **anything you pass here
|
|
147
|
+
silently replaces what the agent's author configured** — the run succeeds and
|
|
148
|
+
returns a plausible answer using your config instead of theirs.
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
// ❌ the agent's prompt, model, and tools are all discarded
|
|
152
|
+
<AthenaProvider
|
|
153
|
+
transport="statewire"
|
|
154
|
+
agent="collab_agent:asset_1234"
|
|
155
|
+
model="claude-opus-4-6"
|
|
156
|
+
systemPrompt="You are a helpful assistant."
|
|
157
|
+
tools={['web_search_browse_toolkit']}
|
|
158
|
+
/>
|
|
159
|
+
|
|
160
|
+
// ✅ the agent's own configuration wins
|
|
161
|
+
<AthenaProvider transport="statewire" agent="collab_agent:asset_1234" />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Pass them only when you deliberately want to override the agent — an explicit
|
|
165
|
+
`model` is honoured as a caller override, with the agent's model as the default
|
|
166
|
+
beneath it.
|
|
167
|
+
|
|
168
|
+
### Failure codes
|
|
169
|
+
|
|
170
|
+
A refused selection surfaces as an `AthenaSdkError` with
|
|
171
|
+
`code: 'collab_agent_rejected'`; the specific reason below rides in the error's
|
|
172
|
+
`detail`. Subscribe with `onError` (see
|
|
173
|
+
[Debugging](#debugging-and-diagnostics)) rather than guessing from messages:
|
|
174
|
+
|
|
175
|
+
| Code | Meaning |
|
|
176
|
+
|---|---|
|
|
177
|
+
| `collab_agent_not_found` | No such asset, or it is not a `collab_agent` |
|
|
178
|
+
| `collab_agent_forbidden` | The acting user lacks VIEW on the asset |
|
|
179
|
+
| `collab_agent_channel_unknown` | No such channel (the message lists the known ones) |
|
|
180
|
+
| `collab_agent_channel_disabled` | The channel exists but is toggled off |
|
|
181
|
+
| `collab_agent_channel_kind_mismatch` | A voice channel was selected for a text run |
|
|
182
|
+
| `collab_agent_runs_disabled` | The deployment has the SDK seam turned off |
|
|
109
183
|
|
|
110
184
|
## Authentication
|
|
111
185
|
|
|
@@ -283,6 +357,24 @@ text anchors, and positioned citations are also preserved by `parseAthenaCitatio
|
|
|
283
357
|
`page_rect` may include `unit=percent` (the default) or `unit=point`; retain the unit so the region
|
|
284
358
|
maps to the correct PDF coordinates.
|
|
285
359
|
|
|
360
|
+
## Styling
|
|
361
|
+
|
|
362
|
+
`styles.css` is a self-contained stylesheet compiled at package build time. One import styles every SDK component — the host app does **not** need Tailwind:
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
import '@athenaintel/react/styles.css';
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
It contains the design tokens, the Tailwind utilities the SDK components use, and an element reset (preflight) **scoped to the SDK's own chrome** (`.aui-root` trees and `.athena-sdk-chrome` roots, including portaled tooltips/popups). It never restyles the host page — not even host components you nest inside `AthenaProvider` to use hooks like `useSendMessage`: the reset only reaches SDK-rendered roots, design tokens live on the provider's `.athena-sdk` wrapper (inert custom properties) rather than `:root`, and everything ships in CSS cascade layers so any unlayered host rule wins on conflict.
|
|
369
|
+
|
|
370
|
+
Hosts that already run **Tailwind v4** (like the athena-app template) may instead — or additionally — compile the SDK's classes themselves:
|
|
371
|
+
|
|
372
|
+
```css
|
|
373
|
+
@source "../node_modules/@athenaintel/react/dist";
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Importing `styles.css` alongside a host Tailwind build is harmless (utilities are identical and layered). One caveat for themed Tailwind hosts: token values set on the `.athena-sdk` element shadow values inherited from `:root`, so define your app's token overrides on `.athena-sdk` too (`:root, .athena-sdk { --primary: …; }`) — or use the `theme` prop below, which always wins.
|
|
377
|
+
|
|
286
378
|
## Theming
|
|
287
379
|
|
|
288
380
|
```tsx
|
|
@@ -295,6 +387,15 @@ import { themes } from '@athenaintel/react';
|
|
|
295
387
|
|
|
296
388
|
Preset themes: `light`, `dark`, `midnight`, `warm`, `purple`, `green`.
|
|
297
389
|
|
|
390
|
+
For CSS-level theming without the `theme` prop, set the design-token custom properties on `.athena-sdk` (unlayered rules override the SDK's layered defaults):
|
|
391
|
+
|
|
392
|
+
```css
|
|
393
|
+
.athena-sdk {
|
|
394
|
+
--primary: oklch(0.4 0.15 260);
|
|
395
|
+
--radius: 1rem;
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
298
399
|
## Key Components
|
|
299
400
|
|
|
300
401
|
- **`<AthenaProvider>`** — Runtime, auth, theming, and configuration
|
|
@@ -323,6 +424,52 @@ function WorkflowButton() {
|
|
|
323
424
|
}
|
|
324
425
|
```
|
|
325
426
|
|
|
427
|
+
## Debugging and Diagnostics
|
|
428
|
+
|
|
429
|
+
The SDK emits structured diagnostic events — auth handshake, thread list,
|
|
430
|
+
statewire attach, sends, errors — with timings. Nothing is logged by default;
|
|
431
|
+
turn it on with the `debug` prop:
|
|
432
|
+
|
|
433
|
+
```tsx
|
|
434
|
+
<AthenaProvider
|
|
435
|
+
debug // or 'debug' | 'info' | { console: 'debug', posthog: true }
|
|
436
|
+
onDiagnostic={(event) => console.log(event.name, event.durationMs)}
|
|
437
|
+
onError={(error) => reportToSentry(error)}
|
|
438
|
+
>
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
`onError` receives an `AthenaSdkError` with a stable `code`, a human `hint`,
|
|
442
|
+
and the originating `status`/`detail` — match on `code`, never on message text:
|
|
443
|
+
|
|
444
|
+
```tsx
|
|
445
|
+
import { ATHENA_SDK_ERROR_CODES } from '@athenaintel/react';
|
|
446
|
+
|
|
447
|
+
onError={(error) => {
|
|
448
|
+
if (error.code === ATHENA_SDK_ERROR_CODES.collab_agent_rejected) {
|
|
449
|
+
// the backend's granular reason rides in `detail`, e.g.
|
|
450
|
+
// 'collab_agent_channel_unknown' — whose message lists the known channels
|
|
451
|
+
console.warn(error.detail, error.hint);
|
|
452
|
+
}
|
|
453
|
+
}}
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Each provider registers its own consumer, so multiple mounted providers all
|
|
457
|
+
receive every event; a callback that throws is caught and cannot break the chat.
|
|
458
|
+
|
|
459
|
+
Without a rebuild, from the browser console:
|
|
460
|
+
|
|
461
|
+
```js
|
|
462
|
+
localStorage.setItem('athena:debug', 'debug'); // console echo on, survives reload
|
|
463
|
+
__ATHENA_SDK__.diagnostics.snapshot(); // recent events + timings
|
|
464
|
+
__ATHENA_SDK__.diagnostics.export(); // JSON, for attaching to a bug report
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Credentials are redacted everywhere (buffer, console, PostHog): any key
|
|
468
|
+
matching `token`, `secret`, `api[-_]?key`, `authorization`, `cookie`, or
|
|
469
|
+
`password` is stripped before an event is recorded. Spans also emit
|
|
470
|
+
`performance.mark`/`measure` entries prefixed `athena-sdk:`, so they show up on
|
|
471
|
+
the browser Performance timeline.
|
|
472
|
+
|
|
326
473
|
## License
|
|
327
474
|
|
|
328
475
|
Proprietary. For licensed enterprise customers only.
|