@agent-native/core 0.153.8 → 0.153.9
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/corpus/templates/slides/app/components/editor/SlideEditor.tsx +5 -3
- package/dist/client/hooks/index.d.ts +1 -1
- package/dist/client/hooks/index.js +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/docs/content/client-advanced.mdx +200 -0
- package/docs/content/client-agent-chat.mdx +313 -0
- package/docs/content/client-data.mdx +432 -0
- package/docs/content/client-entry-points.mdx +27 -0
- package/docs/content/client-overview.mdx +206 -0
- package/docs/content/client-routing.mdx +121 -0
- package/docs/content/client-sync-internals.mdx +124 -0
- package/docs/content/context-awareness.mdx +1 -1
- package/docs/content/docs-components.mdx +201 -0
- package/docs/content/drop-in-agent.mdx +1 -1
- package/docs/content/internationalization.mdx +1 -1
- package/docs/content/key-concepts.mdx +4 -0
- package/docs/content/notifications.mdx +1 -1
- package/docs/content/progress.mdx +2 -2
- package/docs/content/real-time-collaboration.mdx +2 -2
- package/docs/content/template-chat-developers.mdx +1 -1
- package/docs/content/toolkit-command-navigation.mdx +1 -1
- package/package.json +1 -1
- package/docs/content/client.mdx +0 -486
- package/docs/content/routing.mdx +0 -119
|
@@ -5003,15 +5003,17 @@ export default function SlideEditor({
|
|
|
5003
5003
|
const objectOperationSelection = getObjectOperationSelection();
|
|
5004
5004
|
const hasObjectSelection = objectOperationSelection !== null;
|
|
5005
5005
|
const objectSelectionCount = objectOperationSelection?.elements.length ?? 0;
|
|
5006
|
+
const canZoomOut = canvasZoom > MIN_CANVAS_ZOOM;
|
|
5007
|
+
const canZoomIn =
|
|
5008
|
+
canvasZoom < CANVAS_ZOOM_PRESETS[CANVAS_ZOOM_PRESETS.length - 1];
|
|
5006
5009
|
const zoomControls = slide.excalidrawData
|
|
5007
5010
|
? undefined
|
|
5008
5011
|
: {
|
|
5009
5012
|
value: canvasZoom,
|
|
5010
5013
|
onZoomOut: canvasZoomOut,
|
|
5011
5014
|
onZoomIn: canvasZoomIn,
|
|
5012
|
-
canZoomOut
|
|
5013
|
-
canZoomIn
|
|
5014
|
-
canvasZoom < CANVAS_ZOOM_PRESETS[CANVAS_ZOOM_PRESETS.length - 1],
|
|
5015
|
+
canZoomOut,
|
|
5016
|
+
canZoomIn,
|
|
5015
5017
|
};
|
|
5016
5018
|
|
|
5017
5019
|
// Excalidraw slides have no selectable slide content, so the row collapses
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getBrowserTabId } from "../browser-tab-id.js";
|
|
2
|
-
export { deleteClientAppState, readClientAppState, setClientAppState, writeClientAppState, type ClientAppStateReadOptions, type ClientAppStateWriteOptions, } from "../application-state.js";
|
|
2
|
+
export { deleteClientAppState, readClientAppState, readClientAppStateMany, setClientAppState, writeClientAppState, type ClientAppStateBatch, type ClientAppStateReadOptions, type ClientAppStateWriteOptions, } from "../application-state.js";
|
|
3
3
|
export { useDbSync, useFileWatcher, useScreenRefreshKey, } from "../use-db-sync.js";
|
|
4
4
|
export { useChangeVersion, useChangeVersions, getChangeVersion, bumpChangeVersion, } from "../use-change-version.js";
|
|
5
5
|
export { useDemoModeStatus, type DemoModeStatus, } from "../use-demo-mode-status.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getBrowserTabId } from "../browser-tab-id.js";
|
|
2
|
-
export { deleteClientAppState, readClientAppState, setClientAppState, writeClientAppState, } from "../application-state.js";
|
|
2
|
+
export { deleteClientAppState, readClientAppState, readClientAppStateMany, setClientAppState, writeClientAppState, } from "../application-state.js";
|
|
3
3
|
export { useDbSync, useFileWatcher, useScreenRefreshKey, } from "../use-db-sync.js";
|
|
4
4
|
export { useChangeVersion, useChangeVersions, getChangeVersion, bumpChangeVersion, } from "../use-change-version.js";
|
|
5
5
|
export { useDemoModeStatus, } from "../use-demo-mode-status.js";
|
|
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
|
|
|
62
62
|
error: string;
|
|
63
63
|
states?: undefined;
|
|
64
64
|
} | {
|
|
65
|
-
error?: undefined;
|
|
66
65
|
states: {
|
|
67
66
|
clientId: number;
|
|
68
67
|
state: string;
|
|
69
68
|
}[];
|
|
69
|
+
error?: undefined;
|
|
70
70
|
}>>;
|
|
71
71
|
/**
|
|
72
72
|
* GET /_agent-native/collab/:docId/users
|
|
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
|
|
|
77
77
|
error: string;
|
|
78
78
|
users?: undefined;
|
|
79
79
|
} | {
|
|
80
|
-
error?: undefined;
|
|
81
80
|
users: {
|
|
82
81
|
clientId: number;
|
|
83
82
|
lastSeen: number;
|
|
84
83
|
}[];
|
|
84
|
+
error?: undefined;
|
|
85
85
|
}>>;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
|
|
14
14
|
*/
|
|
15
15
|
export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
error: string;
|
|
17
16
|
ok?: undefined;
|
|
17
|
+
error: string;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
|
@@ -41,27 +41,27 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
|
|
|
41
41
|
thumbsUpRate: number;
|
|
42
42
|
avgEvalScore: number;
|
|
43
43
|
} | {
|
|
44
|
+
error?: undefined;
|
|
45
|
+
ok?: undefined;
|
|
44
46
|
summary: import("./types.js").TraceSummary;
|
|
45
47
|
spans: import("./types.js").TraceSpan[];
|
|
46
48
|
id?: undefined;
|
|
49
|
+
} | {
|
|
47
50
|
error?: undefined;
|
|
48
51
|
ok?: undefined;
|
|
49
|
-
} | {
|
|
50
52
|
summary?: undefined;
|
|
51
53
|
spans?: undefined;
|
|
52
54
|
id: string;
|
|
53
|
-
error?: undefined;
|
|
54
|
-
ok?: undefined;
|
|
55
55
|
} | {
|
|
56
|
+
ok?: undefined;
|
|
56
57
|
summary?: undefined;
|
|
57
58
|
spans?: undefined;
|
|
58
59
|
id?: undefined;
|
|
59
60
|
error: any;
|
|
60
|
-
ok?: undefined;
|
|
61
61
|
} | {
|
|
62
|
+
error?: undefined;
|
|
62
63
|
summary?: undefined;
|
|
63
64
|
spans?: undefined;
|
|
64
65
|
id?: undefined;
|
|
65
66
|
ok: boolean;
|
|
66
|
-
error?: undefined;
|
|
67
67
|
}>>;
|
|
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
|
|
|
48
48
|
}>;
|
|
49
49
|
/** DELETE /_agent-native/resources/:id — delete a resource */
|
|
50
50
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
51
|
-
error: string;
|
|
52
51
|
ok?: undefined;
|
|
52
|
+
error: string;
|
|
53
53
|
} | {
|
|
54
54
|
error?: undefined;
|
|
55
55
|
ok: boolean;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
|
|
|
34
34
|
/** POST /_agent-native/secrets/:key — write a secret. */
|
|
35
35
|
export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
36
36
|
error: string;
|
|
37
|
-
status?: undefined;
|
|
38
37
|
ok?: undefined;
|
|
38
|
+
status?: undefined;
|
|
39
39
|
} | {
|
|
40
|
+
error?: undefined;
|
|
40
41
|
ok: boolean;
|
|
41
42
|
status: string;
|
|
42
|
-
error?: undefined;
|
|
43
43
|
} | {
|
|
44
|
+
ok?: undefined;
|
|
44
45
|
error: string;
|
|
45
46
|
removed?: undefined;
|
|
46
|
-
ok?: undefined;
|
|
47
47
|
} | {
|
|
48
|
+
error?: undefined;
|
|
48
49
|
ok: boolean;
|
|
49
50
|
removed: boolean;
|
|
50
|
-
error?: undefined;
|
|
51
51
|
}>>;
|
|
52
52
|
/**
|
|
53
53
|
* POST /_agent-native/secrets/:key/test — validate an optional candidate value
|
|
54
54
|
* or the current stored value without changing anything.
|
|
55
55
|
*/
|
|
56
56
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
57
|
+
ok?: undefined;
|
|
57
58
|
error: string;
|
|
58
59
|
note?: undefined;
|
|
59
|
-
ok?: undefined;
|
|
60
60
|
} | {
|
|
61
|
+
error?: undefined;
|
|
61
62
|
ok: boolean;
|
|
62
63
|
note?: undefined;
|
|
63
|
-
error?: undefined;
|
|
64
64
|
} | {
|
|
65
|
+
error?: undefined;
|
|
65
66
|
ok: boolean;
|
|
66
67
|
note: string;
|
|
67
|
-
error?: undefined;
|
|
68
68
|
} | {
|
|
69
69
|
note?: undefined;
|
|
70
70
|
ok: boolean;
|
|
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
|
|
|
95
95
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
96
96
|
error: string;
|
|
97
97
|
} | {
|
|
98
|
+
error?: undefined;
|
|
98
99
|
ok: boolean;
|
|
99
100
|
key: string;
|
|
100
|
-
error?: undefined;
|
|
101
101
|
} | {
|
|
102
|
+
error?: undefined;
|
|
102
103
|
ok: boolean;
|
|
103
104
|
removed: boolean;
|
|
104
|
-
error?: undefined;
|
|
105
105
|
}>>;
|
|
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
|
|
|
27
27
|
export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
28
28
|
error: any;
|
|
29
29
|
} | {
|
|
30
|
+
error?: undefined;
|
|
30
31
|
ok: boolean;
|
|
31
32
|
key: string;
|
|
32
33
|
baseUrlKey?: string;
|
|
33
34
|
scope: AgentEngineApiKeyScope;
|
|
34
|
-
error?: undefined;
|
|
35
35
|
}>>;
|
|
36
36
|
export {};
|
|
@@ -26,8 +26,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
|
|
|
26
26
|
expiresAt?: undefined;
|
|
27
27
|
ttlSeconds?: undefined;
|
|
28
28
|
} | {
|
|
29
|
+
error?: undefined;
|
|
29
30
|
token: string;
|
|
30
31
|
expiresAt: string;
|
|
31
32
|
ttlSeconds: number;
|
|
32
|
-
error?: undefined;
|
|
33
33
|
}>>;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Advanced"
|
|
3
|
+
description: "Lower-level app/ primitives and escape hatches: direct application-state access, background chat sends, custom suggestion chips, and the MCP App host bridge."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Advanced
|
|
7
|
+
|
|
8
|
+
Overview, Data & Sync, Agent Chat, and Routing cover the typical case: the hooks and helpers most pages need. This page covers the lower-level primitives and narrower escape hatches underneath them. Most apps never touch these directly. Reach for one when you're building something more custom than the default hooks support, such as a custom selection sync or an embedded MCP App. For syncing a raw `useQuery` with a hand-rolled key, see [Sync Internals](/docs/client-sync-internals) instead.
|
|
9
|
+
|
|
10
|
+
## Application State {#application-state}
|
|
11
|
+
|
|
12
|
+
`application_state` is the SQL-backed key/value store the agent reads to know what the UI is currently looking at, including navigation, selection, and other focused-object context (see [Context Awareness](/docs/context-awareness)). `useAgentRouteState` and `useSemanticNavigationState` (also covered in Context Awareness) already wrap these for the common navigation case. Reach for the primitives below directly when you're syncing something they don't cover, such as a custom selection, or writing from outside a component's render.
|
|
13
|
+
|
|
14
|
+
### readClientAppState {#read-client-app-state}
|
|
15
|
+
|
|
16
|
+
Read the current value for a key. Resolves to whatever was last written for that key, or `null` if the key has never been written.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { readClientAppState } from "@agent-native/core/client/hooks";
|
|
20
|
+
|
|
21
|
+
const selection = await readClientAppState("selection");
|
|
22
|
+
// selection is exactly what was last written to that key, e.g.:
|
|
23
|
+
// { kind: "tickets.rows", ids: ["tik_182", "tik_209"] }
|
|
24
|
+
//
|
|
25
|
+
// or, if nothing has written "selection" yet:
|
|
26
|
+
// null
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### writeClientAppState {#write-client-app-state}
|
|
30
|
+
|
|
31
|
+
Write a value for a key. Unlike `setClientAppState` below, it always writes, even if you pass `null`. Passing `undefined` throws instead, since `undefined` isn't valid JSON. Use `setClientAppState(key, undefined)` or `deleteClientAppState()` to clear a key.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { writeClientAppState } from "@agent-native/core/client/hooks";
|
|
35
|
+
|
|
36
|
+
await writeClientAppState(
|
|
37
|
+
"selection",
|
|
38
|
+
{ id: recordId },
|
|
39
|
+
{ requestSource: TAB_ID },
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### setClientAppState {#set-client-app-state}
|
|
44
|
+
|
|
45
|
+
The convenience wrapper most UI code should reach for: writes the value, or deletes the key when you pass `null`/`undefined`. Use this instead of `writeClientAppState` unless a call site genuinely needs "always write, never delete."
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { setClientAppState } from "@agent-native/core/client/hooks";
|
|
49
|
+
|
|
50
|
+
await setClientAppState(
|
|
51
|
+
"selection",
|
|
52
|
+
{ id: recordId },
|
|
53
|
+
{ requestSource: TAB_ID },
|
|
54
|
+
);
|
|
55
|
+
await setClientAppState("selection", null); // clears the key, same as deleteClientAppState
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### deleteClientAppState {#delete-client-app-state}
|
|
59
|
+
|
|
60
|
+
Remove a key entirely.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { deleteClientAppState } from "@agent-native/core/client/hooks";
|
|
64
|
+
|
|
65
|
+
await deleteClientAppState("pending-selection-context");
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### readClientAppStateMany {#read-client-app-state-many}
|
|
69
|
+
|
|
70
|
+
Read several keys in one request. Returns `{ values, missing }`. `values` holds an entry for every key the server has a row for, including a key that was explicitly written as `null`. `missing` lists the keys that have never been written at all. This is how "never written" stays distinguishable from "written as null."
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { readClientAppStateMany } from "@agent-native/core/client/hooks";
|
|
74
|
+
|
|
75
|
+
const { values, missing } = await readClientAppStateMany([
|
|
76
|
+
"selection",
|
|
77
|
+
"pending-selection-context",
|
|
78
|
+
]);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Requests over 100 keys are chunked automatically. `readClientAppState()` itself is built on this: calls issued in the same tick are coalesced into one batched request behind the scenes, so calling it many times in a single render pass costs one round trip, not one per call.
|
|
82
|
+
|
|
83
|
+
### Options {#application-state-options}
|
|
84
|
+
|
|
85
|
+
`signal` is accepted by all five functions above, to cancel an in-flight call. `requestSource` and `keepalive` only apply to the three write functions, since they don't mean anything for a read.
|
|
86
|
+
|
|
87
|
+
| Option | Type | Applies to | Description |
|
|
88
|
+
| --------------- | -------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
|
|
89
|
+
| `requestSource` | `string?` | `writeClientAppState`, `setClientAppState`, `deleteClientAppState` | Tags the write with an id so a matching `useDbSync({ ignoreSource })` can skip refetching it |
|
|
90
|
+
| `keepalive` | `boolean?` | `writeClientAppState`, `setClientAppState`, `deleteClientAppState` | Lets the request outlive page unload. Use for cleanup writes like clearing selection |
|
|
91
|
+
| `signal` | `AbortSignal?` | all five functions | Cancels the request |
|
|
92
|
+
|
|
93
|
+
### Failure behavior {#failure-behavior}
|
|
94
|
+
|
|
95
|
+
All five functions throw on a failed request, a non-2xx response, or a body that can't be parsed. The thrown `Error` carries a `.status` property when the server responded, so a caller can branch on the HTTP status if needed. Wrap a call in `try`/`catch`, or let it propagate to an error boundary, the same as any other network call.
|
|
96
|
+
|
|
97
|
+
### What TAB_ID is {#tab-id}
|
|
98
|
+
|
|
99
|
+
`requestSource` is commonly set to `TAB_ID`, a plain constant every template exports from `app/lib/tab-id.ts`: a short random string that stays the same for the life of a tab and differs between tabs. Pairing `requestSource: TAB_ID` on a write with `useDbSync({ ignoreSource: TAB_ID })` on the read side is how a tab avoids refetching its own write while still reacting to everyone else. See [Context Awareness](/docs/context-awareness#jitter-prevention) for the full walkthrough.
|
|
100
|
+
|
|
101
|
+
## sendToAgentChat: Background Sends {#background-send}
|
|
102
|
+
|
|
103
|
+
Use `background: true` when a UI action should kick off real agent work without
|
|
104
|
+
opening or focusing the sidebar. This still creates a normal chat thread/run,
|
|
105
|
+
uses the agent's tools/actions/context, and keeps the work observable through
|
|
106
|
+
the runs tray. It is not a raw one-shot model call.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { sendToAgentChat } from "@agent-native/core/client/agent-chat";
|
|
110
|
+
|
|
111
|
+
const tabId = sendToAgentChat({
|
|
112
|
+
message: "Analyze this import and create any missing records",
|
|
113
|
+
context: `Import batch id: ${batchId}`,
|
|
114
|
+
submit: true,
|
|
115
|
+
newTab: true,
|
|
116
|
+
background: true,
|
|
117
|
+
openSidebar: false,
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`background` is intended to be paired with `newTab` so the hidden work does not
|
|
122
|
+
overwrite the user's active conversation. Use the returned `tabId` if the UI
|
|
123
|
+
needs to correlate follow-up status or deep-link into the run later.
|
|
124
|
+
|
|
125
|
+
A few more `AgentChatMessage` options exist beyond the ones covered in [Agent Chat](/docs/client-agent-chat#agentchatmessage), mostly for embedded or downstream-integration cases:
|
|
126
|
+
|
|
127
|
+
| Option | Type | Description |
|
|
128
|
+
| --------------------- | ----------- | -------------------------------------------------------------------------- |
|
|
129
|
+
| `background` | `boolean?` | With `newTab`, run without focusing the tab and show the run in `RunsTray` |
|
|
130
|
+
| `projectSlug` | `string?` | Optional project slug for structured context |
|
|
131
|
+
| `preset` | `string?` | Optional preset name for downstream consumers |
|
|
132
|
+
| `referenceImagePaths` | `string[]?` | Optional reference image paths |
|
|
133
|
+
|
|
134
|
+
## MCP App Host Bridge {#mcp-app-host-bridge}
|
|
135
|
+
|
|
136
|
+
Routes embedded as MCP Apps should be URL-first: load the current artifact from
|
|
137
|
+
path/query params, render the real React route or a focused shared component,
|
|
138
|
+
and use the host bridge only for host-owned behavior. `@agent-native/core/client`
|
|
139
|
+
exports the helpers embedded routes call:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import {
|
|
143
|
+
getMcpAppHostContext,
|
|
144
|
+
openMcpAppHostLink,
|
|
145
|
+
requestMcpAppDisplayMode,
|
|
146
|
+
updateMcpAppModelContext,
|
|
147
|
+
useMcpAppHostContext,
|
|
148
|
+
} from "@agent-native/core/client/agent-chat";
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`getMcpAppHostContext()` reads the latest pushed host context snapshot.
|
|
152
|
+
`useMcpAppHostContext()` subscribes React components to changes. The request
|
|
153
|
+
helpers (`openMcpAppHostLink`, `requestMcpAppDisplayMode`,
|
|
154
|
+
`updateMcpAppModelContext`) return `false` outside an embedded MCP App frame, or
|
|
155
|
+
`Promise<boolean>` inside a frame.
|
|
156
|
+
|
|
157
|
+
`sendToAgentChat()` (see [Agent Chat](/docs/client-agent-chat#sendtoagentchat)) uses the same bridge for auto-submitted prompts from embedded routes. Inside an MCP App embed created with `embedApp()`, auto-submitted messages (`submit` omitted or `true`) are forwarded to the bridge, which asks the containing host to add hidden context and send the visible user turn. `context` stays model-visible without being posted as user-facing chat. `submit: false` keeps the local prefill/review behavior because MCP Apps do not define a standard draft-prefill API. Internally this is the submitted-chat path sometimes surfaced as `agentNative.submitChat`. App code should still call `sendToAgentChat()` rather than posting that event directly.
|
|
158
|
+
|
|
159
|
+
The bridge itself, the `ui/*` JSON-RPC messages, the `agentNative.mcpHost.*`
|
|
160
|
+
wrapper relay, transplant vs. controlled-frame rendering, host context, and
|
|
161
|
+
display-mode requests, is owned by
|
|
162
|
+
[External Agents](/docs/external-agents#mcp-app-bridge). See [MCP Apps](/docs/mcp-apps) for the full protocol.
|
|
163
|
+
|
|
164
|
+
## Custom Suggestion Chips {#custom-suggestions}
|
|
165
|
+
|
|
166
|
+
`<AgentSidebar>`'s `dynamicSuggestions` (see [Agent Chat](/docs/client-agent-chat#dynamic-suggestions)) already merges static `suggestions` with the framework's own context-aware heuristic. Pass a `getSuggestions` function inside `dynamicSuggestions` instead when an app wants deterministic, domain-specific chips computed from the same `application_state` context rather than the framework's default heuristic.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
<AgentSidebar
|
|
170
|
+
suggestions={["Summarize my inbox"]}
|
|
171
|
+
dynamicSuggestions={{
|
|
172
|
+
getSuggestions: ({ navigation }) => {
|
|
173
|
+
if (
|
|
174
|
+
typeof navigation !== "object" ||
|
|
175
|
+
navigation === null ||
|
|
176
|
+
(navigation as { view?: unknown }).view !== "inbox"
|
|
177
|
+
) {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
const label = (navigation as { label?: unknown }).label;
|
|
181
|
+
return [`Summarize ${typeof label === "string" ? label : "this"} label`];
|
|
182
|
+
},
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<App />
|
|
186
|
+
</AgentSidebar>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
`getSuggestions` receives the same `navigation`/`selection`/`pendingSelection` snapshot the built-in heuristic reads, typed as `unknown` since its shape is app-defined, so narrow it before reading fields. A custom implementation can react to exactly the state the default one does, just with app-specific rules instead of generic ones.
|
|
190
|
+
|
|
191
|
+
## What's next
|
|
192
|
+
|
|
193
|
+
- [**Overview**](/docs/client-overview) — the `app/` and `public/` directory layout these primitives live in
|
|
194
|
+
- [**Data & Sync**](/docs/client-data) — the default action hooks and `useDbSync` most pages should use instead
|
|
195
|
+
- [**Sync Internals**](/docs/client-sync-internals) — `useChangeVersion`/`useChangeVersions` and the two latency paths a refetch can take
|
|
196
|
+
- [**Agent Chat**](/docs/client-agent-chat) — the default `sendToAgentChat`/`askUserQuestion` helpers most UI should use instead, and the staged agent chat context-state APIs
|
|
197
|
+
- [**Entry Points**](/docs/client-entry-points) — `app/entry.client.tsx`/`app/entry.server.tsx` and SSR streaming customization
|
|
198
|
+
- [**Context Awareness**](/docs/context-awareness) — the `navigation`/`selection` semantics built on `application_state`, and the `TAB_ID`/jitter-prevention walkthrough
|
|
199
|
+
- [**Generative UI**](/docs/generative-ui) — richer inline chat controls beyond `askUserQuestion`
|
|
200
|
+
- [**External Agents**](/docs/external-agents#mcp-app-bridge) — the full MCP App host bridge internals
|