@page-speed/agent-everywhere 0.4.0 → 0.6.0

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
@@ -55,6 +55,7 @@ container. There are no per-surface forks of the conversation logic.
55
55
  | `fullscreen` | `FullscreenDashboard` | Full-screen chat + report sidebar. |
56
56
  | `split` | `SplitView` | Chat beside a live results/preview pane. |
57
57
  | `mobile` | `MobileShell` | Full-height mobile-optimized layout. |
58
+ | `native` | `NativeSurface` | Host-placed, position-agnostic pieces — see [Native variant](#native-variant). |
58
59
 
59
60
  ```tsx
60
61
  import { AgentSurface } from '@page-speed/agent-everywhere';
@@ -71,6 +72,125 @@ import { AgentSurface } from '@page-speed/agent-everywhere';
71
72
  />;
72
73
  ```
73
74
 
75
+ ### Native variant
76
+
77
+ The `native` variant is unlike the other placements: it has **no opinion on
78
+ position**. The agent's composer and conversation renderer are native,
79
+ fully-customizable pieces the host places anywhere — a docked bottom bar, a pane,
80
+ a modal, a dashboard card — and styles itself. The two pieces work **disconnected
81
+ from each other**, and a provider lets them **share one live session even when
82
+ rendered in completely separate DOM regions**.
83
+
84
+ **Simple, controlled case** — one component you position yourself:
85
+
86
+ ```tsx
87
+ import { AgentSurface } from '@page-speed/agent-everywhere';
88
+
89
+ <AgentSurface
90
+ mode="native"
91
+ messages={messages}
92
+ isLoading={isStreaming}
93
+ inputValue={draft}
94
+ onInputChange={setDraft}
95
+ onSubmit={() => send(draft)}
96
+ />;
97
+ ```
98
+
99
+ **Decoupled case** — one shared session feeding pieces in separate regions of the
100
+ page. The composer sits idle at the bottom; once the user submits, the host swaps
101
+ its own content for the conversation surface:
102
+
103
+ ```tsx
104
+ import {
105
+ NativeAgentProvider,
106
+ AgentComposer,
107
+ AgentConversation,
108
+ useNativeAgent,
109
+ } from '@page-speed/agent-everywhere';
110
+
111
+ function PagesDashboard() {
112
+ return (
113
+ <NativeAgentProvider
114
+ // Host supplies the socket URL (or a resolver) — never hardcoded here.
115
+ resolveSocketUrl={resolveSocketUrl}
116
+ websiteId={websiteId}
117
+ pageCategoryId="pages"
118
+ connectionStrategy="lazy" // default: no socket until the first submit
119
+ >
120
+ <Content />
121
+ {/* Place the composer anywhere — here, a docked bottom bar. */}
122
+ <AgentComposer
123
+ className="fixed inset-x-0 bottom-0 m-4"
124
+ footer="Grounded in your connected sources."
125
+ />
126
+ </NativeAgentProvider>
127
+ );
128
+ }
129
+
130
+ function Content() {
131
+ const { isActive } = useNativeAgent();
132
+ // The host owns the swap — render your own page until the agent is engaged.
133
+ return isActive ? <AgentConversation /> : <PagesTable />;
134
+ }
135
+ ```
136
+
137
+ Both `AgentComposer` and `AgentConversation` are **dual-mode**: inside a
138
+ `NativeAgentProvider` they wire themselves to the shared session; given explicit
139
+ `value`/`onChange`/`onSubmit` (composer) or `messages` (conversation) props they
140
+ run fully controlled with no provider. For 100%-custom UI, read the session
141
+ directly with `useNativeAgent()`. The connection is lazy by default
142
+ (`connectionStrategy="eager"` to pre-connect on mount).
143
+
144
+ ### AgentWorkspace — the page-level AI layout wrapper
145
+
146
+ `AgentWorkspace` composes the native pieces into a full workspace layout: an
147
+ optional left panel, the host's page content in a growing center column with the
148
+ prompt composer docked at the bottom, an optional right panel, and a
149
+ conversation layer that **slides in over the center content** when the shared
150
+ session activates (and slides away on `reset()`).
151
+
152
+ ```tsx
153
+ import {
154
+ NativeAgentProvider,
155
+ AgentWorkspace,
156
+ AgentWorkspacePanelToggle,
157
+ } from '@page-speed/agent-everywhere';
158
+
159
+ <NativeAgentProvider resolveSocketUrl={resolveSocketUrl} websiteId={id} pageCategoryId="pages">
160
+ <AgentWorkspace
161
+ className="h-dvh"
162
+ leftPanel={<KnowledgePanel />} // omit → no panel, no toggle
163
+ rightPanel={<AnalyticsPanel />} // widths via left/rightPanelWidth
164
+ composerPlaceholder="Describe a site-wide change…"
165
+ composerHint="Agents render live, interactive artifacts inline."
166
+ >
167
+ <YourPage />
168
+ </AgentWorkspace>
169
+ </NativeAgentProvider>;
170
+ ```
171
+
172
+ Every region is independently optional and controllable:
173
+
174
+ - **Panels** collapse/expand with a smooth width-collapse animation (the
175
+ outer rail animates to `0` while the inner wrapper keeps its open width, so
176
+ content clips out instead of reflowing). Uncontrolled by default;
177
+ controlled via `leftPanelOpen`/`onLeftPanelOpenChange` (and the right-side
178
+ equivalents). Built-in floating toggles render in the top corners
179
+ (`showPanelToggles={false}` to place `<AgentWorkspacePanelToggle side="…"/>`
180
+ in your own chrome). Panels are gated to `lg:` viewports.
181
+ - **Conversation layer** auto-opens on the first submit (or `activate()`),
182
+ can be minimized back to the page without ending the session (a
183
+ "View conversation" chip appears in the dock), and accepts a custom node via
184
+ `conversation` for decorated transcripts. Controlled via `conversationOpen`.
185
+ - **Composer dock** renders `AgentWorkspaceComposer` — a pill input with an
186
+ auto-growing textarea (Enter submits, Shift+Enter inserts a newline), an
187
+ optional attach affordance (`onAttach`), and a circular send button. Pass
188
+ `composer={false}` to drop it, a node to replace it, or `onComposerSubmit`
189
+ to intercept submits.
190
+ - **Programmatic control** from anywhere inside: `useAgentWorkspace()` exposes
191
+ `toggleLeftPanel`, `setRightPanelOpen`, `openConversation`,
192
+ `closeConversation`, and friends for dynamic layout scenarios.
193
+
74
194
  ### Inline confirmation / proposed-plan panels
75
195
 
76
196
  Confirmation and proposed-plan panels flow **inline in the transcript** — attach
@@ -166,9 +286,11 @@ function Designer({ websiteId, pageCategoryId, blocks, onBlocks }) {
166
286
  ```
167
287
 
168
288
  The hook returns `{ messages, connectionState, connectionError, statusLabel,
169
- isConnected, isStreaming, sendMessage, retry }` and manages connection
289
+ isConnected, isStreaming, sendMessage, retry, reset }` and manages connection
170
290
  lifecycle, reconnect with backoff, the streaming message state machine, hidden
171
- (background) requests, and block-extraction fallbacks.
291
+ (background) requests, and block-extraction fallbacks. Pass
292
+ `seedWelcomeMessage: false` to start with an empty transcript (the `native`
293
+ variant does this for its idle composer).
172
294
 
173
295
  ### Low-level client
174
296