@athenaintel/react 0.10.40 → 0.10.41-rc.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 CHANGED
@@ -50,12 +50,63 @@ function App() {
50
50
  </AthenaProvider>
51
51
  ```
52
52
 
53
- `config` accepts `apiKey`, `token`, `apiUrl`, `backendUrl`, `appUrl`, `trustedParentOrigins`, and `environment`. Top-level `apiKey`, `token`, `apiUrl`, `backendUrl`, `appUrl`, and `environment` props remain supported as compatibility aliases, but `config` is now the preferred API.
53
+ `config` accepts `apiKey`, `token`, `apiUrl`, `backendUrl`, `appUrl`, `trustedParentOrigins`, `environment`, `transport`, and `statewireSyncUrl`. Top-level `apiKey`, `token`, `apiUrl`, `backendUrl`, `appUrl`, and `environment` props remain supported as compatibility aliases, but `config` is now the preferred API.
54
54
 
55
55
  If `config.appUrl` is omitted, the provider resolves it from the parent bridge or from the matching Athena environment defaults. Known Athena staging and production `apiUrl` and `backendUrl` values automatically fall back to the corresponding frontend origin.
56
56
 
57
57
  Use `trustedParentOrigins` when the SDK runs inside an iframe on a private-cloud or custom parent domain and you want to explicitly allow postMessage auth/config from that parent.
58
58
 
59
+ ## Statewire Transport (opt-in)
60
+
61
+ The default chat transport is the legacy Iris `/api/chat` stream. Pass
62
+ `transport: 'statewire'` to attach to the deep-agent statewire sync host
63
+ instead — the thread is hosted server-side and replicated live, so history,
64
+ reconnect, and run scheduling come from the server snapshot:
65
+
66
+ ```tsx
67
+ <AthenaProvider config={{ environment: 'staging', transport: 'statewire' }}>
68
+ <AthenaChat />
69
+ </AthenaProvider>
70
+ ```
71
+
72
+ The sync endpoint defaults to the effective `apiUrl` host + `/v2/threads`
73
+ (e.g. staging resolves to `https://iris.stg.athenaintel.com/v2/threads`, the
74
+ same statewire base the mobile app and Chrome extension ship); pass
75
+ `statewireSyncUrl` to override it for custom hosts whose sync mount lives on
76
+ a different origin. If neither yields a URL (e.g. an unparseable custom
77
+ `apiUrl`), the provider throws instead of falling back to an Athena default —
78
+ credentials are never sent to a host you didn't configure. Auth reuses the
79
+ provider's existing credential plumbing: tokens ride `Authorization: Bearer`
80
+ and API keys ride `X-API-KEY`.
81
+
82
+ What the statewire transport wires up in `AthenaChat`:
83
+
84
+ - **Approvals (HITL):** when the backend parks a run on an approval-gated
85
+ tool call, an approval card renders above the composer with Approve/Reject
86
+ (or Continue for a generic pause) and resumes the run through the statewire
87
+ `run/input` command. Hosts that build their own thread UI should mount the
88
+ exported `StatewireApprovalCard` themselves — without it an approval-gated
89
+ run stays parked with no way to answer it.
90
+ - **Frontend tools:** tools in `frontendTools` with a local `execute` are
91
+ declared to the backend as `client_tools` and executed by the mounted
92
+ client-tool bridge, which resumes the run with each tool's result.
93
+ - **Mid-run sends and the queue:** a message sent while a run is active
94
+ queues on the server. The queue panel above the composer lists queued
95
+ entries with remove and "Send now" (steer), plus Continue for a stopped
96
+ run's steer lane.
97
+ - **Errors and connection state:** transport errors (send rejections,
98
+ paywall refusals) render as a dismissible banner; a degraded connection
99
+ shows a reconnect strip; a read-only pre-cutover thread shows a read-only
100
+ notice. Custom hosts can read all of it via `useAthenaStatewireLifecycle`.
101
+ - **Thread list:** `enableThreadList` works with statewire. The list is the
102
+ same persisted Agora session list; switching threads re-attaches the
103
+ statewire session to the selected thread. `ThreadList` and
104
+ `useAthenaThreadManager` work in both modes.
105
+
106
+ Remaining limitations: the `agent` prop is legacy-only (the statewire host
107
+ always runs the Athena deep agent), and `model` defaults to the deep-agent
108
+ default model in this mode.
109
+
59
110
  ## Authentication
60
111
 
61
112
  ### Same-origin SSO defaults
@@ -0,0 +1,2 @@
1
+ import type { FC } from 'react';
2
+ export declare const StatewireApprovalCard: FC;
@@ -0,0 +1,14 @@
1
+ import type { StatewireClientTool } from './statewire-client-tools';
2
+ /**
3
+ * Executes the deep agent's frontend tool calls in statewire mode.
4
+ *
5
+ * Tools declared through `runConfig.custom.client_tools` have no backend
6
+ * implementation: a call parks the run and surfaces here as a statewire
7
+ * input request. The bridge runs the matching local handler and resumes the
8
+ * run with a per-call result envelope, so a missing tool or a thrown handler
9
+ * still frees the run with an error the model can act on instead of hanging.
10
+ */
11
+ export declare function StatewireClientToolBridge({ tools, threadId, }: {
12
+ tools: readonly StatewireClientTool[];
13
+ threadId: string;
14
+ }): null;
@@ -0,0 +1,8 @@
1
+ import { type FC } from 'react';
2
+ /**
3
+ * Controls for the server-owned statewire queue and steer lanes: a message
4
+ * sent mid-run queues behind the active run; entries can be removed or
5
+ * steered in ("Send now"), and a stopped run can continue with its queue.
6
+ * Renders nothing on the legacy transport or when the queue is empty.
7
+ */
8
+ export declare const StatewireQueuedMessages: FC;
@@ -0,0 +1,35 @@
1
+ import type { StatewireThread } from '@assistant-ui/react-statewire';
2
+ /** Human-in-the-loop approval payload the agora deep-agent runtime parks a run
3
+ * on (shaped by `athena_deep_agent/hitl_bridge.py`). */
4
+ export interface HitlApprovalPayload {
5
+ source: string;
6
+ type: string;
7
+ message: string;
8
+ context?: {
9
+ tool_name?: string;
10
+ tool_id?: string;
11
+ tool_args?: Record<string, unknown>;
12
+ pending_action_count?: number;
13
+ };
14
+ }
15
+ /**
16
+ * The statewire hooks read the nearest aui thread's extras and throw when
17
+ * those aren't statewire extras — which is the case on the SDK's legacy
18
+ * transport. Duck-type the pieces the approval card consumes so it can no-op
19
+ * on legacy threads instead of crashing.
20
+ */
21
+ export declare function hasStatewireThreadExtras(extras: unknown): boolean;
22
+ /** A parked interrupt that has not been answered yet. */
23
+ export declare function isPendingInterrupt(request: StatewireThread.InputRequestState): request is StatewireThread.CustomInputRequest;
24
+ /**
25
+ * A pending interrupt the approval card may answer. Client-tool parks are
26
+ * excluded — the client-tool bridge owns those, and a generic Continue resume
27
+ * would corrupt the parked tool call. The source check is deliberately loose
28
+ * (any payload stamped with the client-tool source) so a skewed deploy can
29
+ * never route one here.
30
+ */
31
+ export declare function isApprovalCardInterrupt(request: StatewireThread.InputRequestState): request is StatewireThread.CustomInputRequest;
32
+ /** Narrow an interrupt payload to the Athena HITL approval shape. */
33
+ export declare function asHitlApproval(value: unknown): HitlApprovalPayload | null;
34
+ /** Best-effort human-readable message from any interrupt payload. */
35
+ export declare function readInterruptMessage(value: unknown): string;
@@ -0,0 +1,17 @@
1
+ import type { FC } from 'react';
2
+ /**
3
+ * Dismissible transport-error banner for statewire mode: send rejections,
4
+ * paywall refusals, and command failures that would otherwise vanish into
5
+ * the console after the composer already cleared. Renders nothing on the
6
+ * legacy transport.
7
+ */
8
+ export declare const StatewireErrorBanner: FC;
9
+ /**
10
+ * Degraded-connection strip: shown only while the statewire channel is
11
+ * reconnecting or gone, with a manual reconnect affordance when the
12
+ * transport exposes one. Healthy states render nothing.
13
+ */
14
+ export declare const StatewireConnectionBanner: FC;
15
+ /** Read-only notice for pre-cutover threads whose history lives under the
16
+ * legacy runtime; the server fences dispatch into them. */
17
+ export declare const StatewireLegacyReadOnlyBanner: FC;
@@ -0,0 +1,24 @@
1
+ import type { Toolkit } from '@assistant-ui/react';
2
+ /** A frontend tool the statewire client-tool bridge can execute locally. */
3
+ export interface StatewireClientTool {
4
+ name: string;
5
+ description?: string;
6
+ /** JSON schema for the tool arguments. */
7
+ parameters: Record<string, unknown>;
8
+ handler: (args: Record<string, unknown>, context: {
9
+ toolCallId: string;
10
+ }) => Promise<unknown>;
11
+ }
12
+ /**
13
+ * Collect the client-executable tools from a frontend toolkit.
14
+ *
15
+ * The deep-agent runtime drops frontend (`ui_*`) tool definitions, so tools
16
+ * with a local `execute` must instead be declared through
17
+ * `runConfig.custom.client_tools` and answered by the statewire client-tool
18
+ * bridge. Schema conversion reuses `toToolsJSONSchema` — the same conversion
19
+ * the legacy assistant-transport applies — and a tool whose schema cannot be
20
+ * converted is skipped with a warning rather than failing the whole set.
21
+ */
22
+ export declare function collectStatewireClientTools(toolkit: Toolkit): StatewireClientTool[];
23
+ /** Wire entries for `runConfig.custom.client_tools`. */
24
+ export declare function statewireClientToolWireEntries(tools: readonly StatewireClientTool[]): Record<string, unknown>[];
@@ -20,7 +20,7 @@ export interface SuperGroupingCardProps {
20
20
  getToolGroupKey?: GetToolGroupKey;
21
21
  }
22
22
  /**
23
- * Ported from `olympus/src/components/copilotkit/sidebar/SuperGroupingCard.tsx`.
23
+ * Ported from `olympus/src/components/chat/sidebar/SuperGroupingCard.tsx`.
24
24
  *
25
25
  * Trimmed to drop Olympus-only deps:
26
26
  * - `useChatAllotmentStore.isWaitingForUserInput` (Olympus allotment system) — dropped.