@powerhousedao/reactor-browser 6.2.3-dev.8 → 6.2.3-dev.81
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/dist/{attachment-service-D3EhiAJ7.d.ts → attachment-service-DPWkKp3y.d.ts} +636 -83
- package/dist/attachment-service-DPWkKp3y.d.ts.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-BFnMV-EO.js} +39 -22
- package/dist/client-BFnMV-EO.js.map +1 -0
- package/dist/{client-D66jVnot.js → client-BUpynoY6.js} +345 -33
- package/dist/client-BUpynoY6.js.map +1 -0
- package/dist/{client-BIHN_UyR.d.ts → client-XPGQrO4a.d.ts} +3 -3
- package/dist/client-XPGQrO4a.d.ts.map +1 -0
- package/dist/dispatch-C8J9jQ-o.js +1171 -0
- package/dist/dispatch-C8J9jQ-o.js.map +1 -0
- package/dist/document-by-id-Dpp76ZNE.js +16 -0
- package/dist/document-by-id-Dpp76ZNE.js.map +1 -0
- package/dist/document-model-modules-XrYfGXt8.js +644 -0
- package/dist/document-model-modules-XrYfGXt8.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-CdfiLNQN.js} +1919 -278
- package/dist/document-operations-CdfiLNQN.js.map +1 -0
- package/dist/global-BSyOOTvL.d.ts +647 -0
- package/dist/global-BSyOOTvL.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-Bjm0bSzf.d.ts} +19 -98
- package/dist/index-Bjm0bSzf.d.ts.map +1 -0
- package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
- package/dist/index-rtDmzViP.d.ts.map +1 -0
- package/dist/index.d.ts +813 -410
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +771 -119
- package/dist/index.js.map +1 -1
- package/dist/inspector-proxy-DODqs15F.d.ts +25 -0
- package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js +180 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js.map +1 -0
- package/dist/navigation-BqphkrOB.js +302 -0
- package/dist/navigation-BqphkrOB.js.map +1 -0
- package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
- package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
- package/dist/{relational-D1RB45sA.js → relational-DZuyKp2y.js} +66 -5
- package/dist/relational-DZuyKp2y.js.map +1 -0
- package/dist/{renown-rqK8sokh.js → renown-BtjgHBjH.js} +33 -28
- package/dist/{renown-rqK8sokh.js.map → renown-BtjgHBjH.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-BxkZYzbQ.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-BxkZYzbQ.js.map} +1 -1
- package/dist/src/ai/index.d.ts +53 -70
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +12 -28
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/analytics/index.d.ts +36 -44
- package/dist/src/analytics/index.d.ts.map +1 -1
- package/dist/src/analytics/index.js +4 -4
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/document-model.d.ts +3 -4
- package/dist/src/document-model.d.ts.map +1 -1
- package/dist/src/document-model.js.map +1 -1
- package/dist/src/graphql/client.d.ts +4 -3
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +5 -4
- package/dist/src/graphql-client/entry.js +4 -4
- package/dist/src/relational/index.d.ts +15 -9
- package/dist/src/relational/index.d.ts.map +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +3 -2
- package/dist/src/renown/index.js +2 -2
- package/dist/src/rpc/index.d.ts +214 -140
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +587 -622
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
- package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
- package/dist/{switchboard-CaXQ4-5Q.js → switchboard-CYTCYt4Z.js} +61 -11
- package/dist/switchboard-CYTCYt4Z.js.map +1 -0
- package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
- package/dist/types-520nWrB3.d.ts.map +1 -0
- package/dist/{types-Dcv1ZLoW.d.ts → types-BNVqRNli.d.ts} +320 -18
- package/dist/types-BNVqRNli.d.ts.map +1 -0
- package/package.json +23 -23
- package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
- package/dist/client-BIHN_UyR.d.ts.map +0 -1
- package/dist/client-D66jVnot.js.map +0 -1
- package/dist/client-DjK30EQ-.js.map +0 -1
- package/dist/document-by-id-B4FIzG1w.js +0 -519
- package/dist/document-by-id-B4FIzG1w.js.map +0 -1
- package/dist/document-model-modules-bTP87nyr.js +0 -419
- package/dist/document-model-modules-bTP87nyr.js.map +0 -1
- package/dist/document-operations-WeE6wIDt.js.map +0 -1
- package/dist/global-OuINvEGT.d.ts +0 -401
- package/dist/global-OuINvEGT.d.ts.map +0 -1
- package/dist/index-B33TKEqp.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts +0 -257
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/make-ph-event-functions-DBq3iWYn.js +0 -53
- package/dist/make-ph-event-functions-DBq3iWYn.js.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/relational-D1RB45sA.js.map +0 -1
- package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
- package/dist/types-6vDzbRRS.d.ts.map +0 -1
- package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
package/dist/src/ai/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PhAiToolAnnotations, PhAiToolDescriptor } from "@powerhousedao/shared/document-model";
|
|
2
2
|
import { ISyncManager } from "@powerhousedao/reactor";
|
|
3
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
3
|
import { LanguageModel, ModelMessage } from "ai";
|
|
5
|
-
|
|
6
4
|
//#region src/ai/types.d.ts
|
|
7
5
|
/**
|
|
8
6
|
* Browser-side AI chat over the reactor.
|
|
@@ -13,7 +11,7 @@ import { LanguageModel, ModelMessage } from "ai";
|
|
|
13
11
|
* same tool definitions drive both the MCP server and the in-browser chat.
|
|
14
12
|
*/
|
|
15
13
|
/** User-configured LLM connection settings, persisted in localStorage. */
|
|
16
|
-
interface AiSettings {
|
|
14
|
+
export interface AiSettings {
|
|
17
15
|
/** Master on/off for the in-browser assistant. Off by default. */
|
|
18
16
|
enabled: boolean;
|
|
19
17
|
/** OpenAI-compatible base URL, e.g. `https://api.openai.com/v1` */
|
|
@@ -29,30 +27,24 @@ interface AiSettings {
|
|
|
29
27
|
autoApproveWrites: boolean;
|
|
30
28
|
}
|
|
31
29
|
/** MCP-compatible annotation hints; structural, no MCP SDK dependency. */
|
|
32
|
-
type AiToolAnnotations = PhAiToolAnnotations;
|
|
30
|
+
export type AiToolAnnotations = PhAiToolAnnotations;
|
|
33
31
|
/**
|
|
34
32
|
* Provider-agnostic tool descriptor accepted by the chat agent.
|
|
35
33
|
*
|
|
36
34
|
* Structurally compatible with the MCP tool records produced by
|
|
37
|
-
* `
|
|
35
|
+
* `toMcpTool`: the callback parameter is `never` so any
|
|
38
36
|
* per-tool-args function type is assignable, and the result is `unknown`
|
|
39
37
|
* because the envelope shape (MCP `CallToolResult`) is unwrapped at the
|
|
40
38
|
* adapter boundary.
|
|
41
39
|
*/
|
|
42
|
-
type AiToolDescriptor = PhAiToolDescriptor;
|
|
40
|
+
export type AiToolDescriptor = PhAiToolDescriptor;
|
|
43
41
|
/** Tool descriptors the app resolves when the user sends a message. */
|
|
44
|
-
type AiToolsProvider = () => Promise<AiToolDescriptor[]>;
|
|
45
|
-
/**
|
|
46
|
-
declare
|
|
47
|
-
|
|
48
|
-
* Whether executing the tool mutates state and requires user approval:
|
|
49
|
-
* the built-in write tools, or any tool flagged destructive in its
|
|
50
|
-
* annotations (covers package-provided tools outside the built-in set).
|
|
51
|
-
*/
|
|
52
|
-
declare function isWriteTool(name: string, annotations?: AiToolAnnotations): boolean;
|
|
53
|
-
type ToolCallState = "awaiting-approval" | "executing" | "done" | "error" | "rejected";
|
|
42
|
+
export type AiToolsProvider = () => Promise<AiToolDescriptor[]>;
|
|
43
|
+
/** Whether running the tool needs approval: anything not annotated read-only. */
|
|
44
|
+
export declare function isWriteTool(annotations?: AiToolAnnotations): boolean;
|
|
45
|
+
export type ToolCallState = "awaiting-approval" | "executing" | "done" | "error" | "rejected";
|
|
54
46
|
/** One rendered unit inside a chat message. */
|
|
55
|
-
type ChatPart = {
|
|
47
|
+
export type ChatPart = {
|
|
56
48
|
type: "text";
|
|
57
49
|
text: string;
|
|
58
50
|
} | {
|
|
@@ -64,19 +56,19 @@ type ChatPart = {
|
|
|
64
56
|
result?: unknown;
|
|
65
57
|
error?: string;
|
|
66
58
|
};
|
|
67
|
-
interface ChatMessage {
|
|
59
|
+
export interface ChatMessage {
|
|
68
60
|
id: string;
|
|
69
61
|
role: "user" | "assistant";
|
|
70
62
|
parts: ChatPart[];
|
|
71
63
|
}
|
|
72
64
|
/** A write tool call the user must approve or reject. */
|
|
73
|
-
interface PendingApproval {
|
|
65
|
+
export interface PendingApproval {
|
|
74
66
|
toolCallId: string;
|
|
75
67
|
name: string;
|
|
76
68
|
args: unknown;
|
|
77
69
|
}
|
|
78
70
|
/** Context snapshot injected into the agent system prompt. */
|
|
79
|
-
interface ChatContext {
|
|
71
|
+
export interface ChatContext {
|
|
80
72
|
driveId?: string;
|
|
81
73
|
driveName?: string;
|
|
82
74
|
nodeId?: string;
|
|
@@ -89,7 +81,7 @@ interface ChatContext {
|
|
|
89
81
|
switchboardGraphqlUrl?: string;
|
|
90
82
|
}
|
|
91
83
|
/** Events the agent emits while running a turn. */
|
|
92
|
-
type AgentEvent = {
|
|
84
|
+
export type AgentEvent = {
|
|
93
85
|
type: "text-delta";
|
|
94
86
|
delta: string;
|
|
95
87
|
} | {
|
|
@@ -113,12 +105,12 @@ type AgentEvent = {
|
|
|
113
105
|
state: "done" | "error" | "rejected";
|
|
114
106
|
result?: unknown;
|
|
115
107
|
error?: string;
|
|
116
|
-
}
|
|
108
|
+
} |
|
|
117
109
|
/**
|
|
118
110
|
* Token accounting for the turn: the input tokens of the model's last
|
|
119
111
|
* step (i.e. the size of the context it was reasoning over).
|
|
120
112
|
*/
|
|
121
|
-
|
|
113
|
+
{
|
|
122
114
|
type: "usage";
|
|
123
115
|
inputTokens: number;
|
|
124
116
|
} | {
|
|
@@ -130,7 +122,7 @@ type AgentEvent = {
|
|
|
130
122
|
//#endregion
|
|
131
123
|
//#region src/ai/agent.d.ts
|
|
132
124
|
/** Hard cap on model round-trips per user message (each tool step counts). */
|
|
133
|
-
declare const MAX_AGENT_STEPS = 10;
|
|
125
|
+
export declare const MAX_AGENT_STEPS = 10;
|
|
134
126
|
/**
|
|
135
127
|
* Hard cap on the characters of one tool result fed back to the model.
|
|
136
128
|
*
|
|
@@ -140,7 +132,7 @@ declare const MAX_AGENT_STEPS = 10;
|
|
|
140
132
|
* context and stall the turn. Over-budget results are truncated with a
|
|
141
133
|
* marker so the model re-queries more narrowly.
|
|
142
134
|
*/
|
|
143
|
-
declare const MAX_TOOL_RESULT_CHARS = 12000;
|
|
135
|
+
export declare const MAX_TOOL_RESULT_CHARS = 12000;
|
|
144
136
|
/**
|
|
145
137
|
* Number of the most recent turns whose tool results are kept in full in
|
|
146
138
|
* the committed history. Tool results are re-derivable (the store is the
|
|
@@ -148,9 +140,9 @@ declare const MAX_TOOL_RESULT_CHARS = 12000;
|
|
|
148
140
|
* one-line stubs: this is what keeps a long conversation from exhausting
|
|
149
141
|
* the model's context.
|
|
150
142
|
*/
|
|
151
|
-
declare const FULL_RESULT_TURNS = 2;
|
|
143
|
+
export declare const FULL_RESULT_TURNS = 2;
|
|
152
144
|
/** Tool results smaller than this are cheap to keep and are never stubbed. */
|
|
153
|
-
declare const STUB_MIN_CHARS = 500;
|
|
145
|
+
export declare const STUB_MIN_CHARS = 500;
|
|
154
146
|
/**
|
|
155
147
|
* Replaces tool results older than the last {@link FULL_RESULT_TURNS}
|
|
156
148
|
* turns with one-line stubs naming the tool and its arguments. User and
|
|
@@ -158,17 +150,17 @@ declare const STUB_MIN_CHARS = 500;
|
|
|
158
150
|
* so the model can re-query any stubbed result with the same arguments.
|
|
159
151
|
* Idempotent: stubs are below {@link STUB_MIN_CHARS} and pass through.
|
|
160
152
|
*/
|
|
161
|
-
declare function stubStaleToolResults(history: ModelMessage[]): ModelMessage[];
|
|
162
|
-
declare function createReactorChatModel(settings: AiSettings): LanguageModel;
|
|
153
|
+
export declare function stubStaleToolResults(history: ModelMessage[]): ModelMessage[];
|
|
154
|
+
export declare function createReactorChatModel(settings: AiSettings): LanguageModel;
|
|
163
155
|
/**
|
|
164
156
|
* Unwraps the MCP `CallToolResult` envelope produced by the reactor tool
|
|
165
157
|
* core into a plain value for the AI SDK. Throws for error results so the
|
|
166
158
|
* SDK surfaces them as tool errors in the next model step.
|
|
167
159
|
*/
|
|
168
|
-
declare function unwrapToolResult(raw: unknown): unknown;
|
|
160
|
+
export declare function unwrapToolResult(raw: unknown): unknown;
|
|
169
161
|
/** Builds the system prompt, grounding the agent in the current selection. */
|
|
170
|
-
declare function buildSystemPrompt(context: ChatContext): string;
|
|
171
|
-
interface ReactorChatAgentOptions {
|
|
162
|
+
export declare function buildSystemPrompt(context: ChatContext): string;
|
|
163
|
+
export interface ReactorChatAgentOptions {
|
|
172
164
|
settings: AiSettings;
|
|
173
165
|
tools: AiToolDescriptor[];
|
|
174
166
|
context: ChatContext;
|
|
@@ -186,7 +178,7 @@ interface ReactorChatAgentOptions {
|
|
|
186
178
|
* gated by the AI SDK's tool approval: when auto-approval is off, the
|
|
187
179
|
* pending user decision is bridged through {@link approve}/{@link reject}.
|
|
188
180
|
*/
|
|
189
|
-
declare class ReactorChatAgent {
|
|
181
|
+
export declare class ReactorChatAgent {
|
|
190
182
|
private readonly options;
|
|
191
183
|
private history;
|
|
192
184
|
private approvals;
|
|
@@ -216,18 +208,14 @@ declare class ReactorChatAgent {
|
|
|
216
208
|
* In-chat approval card for a write tool call. Approving or rejecting
|
|
217
209
|
* resolves the pending approval inside the agent loop.
|
|
218
210
|
*/
|
|
219
|
-
declare function ApprovalCard({
|
|
220
|
-
approval,
|
|
221
|
-
onApprove,
|
|
222
|
-
onReject
|
|
223
|
-
}: {
|
|
211
|
+
export declare function ApprovalCard({ approval, onApprove, onReject }: {
|
|
224
212
|
approval: PendingApproval;
|
|
225
213
|
onApprove: (toolCallId: string) => void;
|
|
226
214
|
onReject: (toolCallId: string) => void;
|
|
227
|
-
}):
|
|
215
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
228
216
|
//#endregion
|
|
229
217
|
//#region src/ai/use-reactor-chat.d.ts
|
|
230
|
-
interface UseReactorChatResult {
|
|
218
|
+
export interface UseReactorChatResult {
|
|
231
219
|
messages: ChatMessage[];
|
|
232
220
|
isStreaming: boolean;
|
|
233
221
|
pendingApprovals: PendingApproval[];
|
|
@@ -244,35 +232,30 @@ interface UseReactorChatResult {
|
|
|
244
232
|
* Drives one in-browser chat conversation against the reactor tools.
|
|
245
233
|
*
|
|
246
234
|
* `toolsProvider` lazily resolves the tool descriptors (e.g. from
|
|
247
|
-
* `
|
|
235
|
+
* `toMcpTool` bound to `window.ph.reactorClient`) when the
|
|
248
236
|
* user sends a message, so the reactor does not need to be ready at render
|
|
249
237
|
* time.
|
|
250
238
|
*/
|
|
251
|
-
declare function useReactorChat(toolsProvider?: AiToolsProvider): UseReactorChatResult;
|
|
239
|
+
export declare function useReactorChat(toolsProvider?: AiToolsProvider): UseReactorChatResult;
|
|
252
240
|
//#endregion
|
|
253
241
|
//#region src/ai/components/chat-window.d.ts
|
|
254
242
|
/** The chat window panel, anchored above the FAB in the bottom-right. */
|
|
255
|
-
declare function ChatWindow({
|
|
256
|
-
chat,
|
|
257
|
-
onClose
|
|
258
|
-
}: {
|
|
243
|
+
export declare function ChatWindow({ chat, onClose }: {
|
|
259
244
|
chat: UseReactorChatResult;
|
|
260
245
|
onClose: () => void;
|
|
261
|
-
}):
|
|
246
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
262
247
|
//#endregion
|
|
263
248
|
//#region src/ai/components/reactor-chat-fab.d.ts
|
|
264
249
|
/**
|
|
265
250
|
* Bottom-right floating action button that opens the reactor AI chat window.
|
|
266
251
|
*
|
|
267
252
|
* `getTools` lazily resolves the reactor tool descriptors (from
|
|
268
|
-
* `
|
|
253
|
+
* `toMcpTool` bound to the browser reactor client) when the
|
|
269
254
|
* user sends a message.
|
|
270
255
|
*/
|
|
271
|
-
declare function ReactorChatFab({
|
|
272
|
-
getTools
|
|
273
|
-
}: {
|
|
256
|
+
export declare function ReactorChatFab({ getTools }: {
|
|
274
257
|
getTools?: AiToolsProvider;
|
|
275
|
-
}):
|
|
258
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
276
259
|
//#endregion
|
|
277
260
|
//#region src/ai/context.d.ts
|
|
278
261
|
/**
|
|
@@ -280,28 +263,28 @@ declare function ReactorChatFab({
|
|
|
280
263
|
* chat context-aware: "create a budget here" targets the selected drive,
|
|
281
264
|
* "summarize this document" targets the selected document.
|
|
282
265
|
*/
|
|
283
|
-
declare function useChatContext(): ChatContext;
|
|
266
|
+
export declare function useChatContext(): ChatContext;
|
|
284
267
|
//#endregion
|
|
285
268
|
//#region src/ai/settings-store.d.ts
|
|
286
|
-
declare const DEFAULT_AI_SETTINGS: AiSettings;
|
|
269
|
+
export declare const DEFAULT_AI_SETTINGS: AiSettings;
|
|
287
270
|
type Listener = () => void;
|
|
288
271
|
/** Returns the current settings (stable snapshot for useSyncExternalStore). */
|
|
289
|
-
declare function getAiSettings(): AiSettings;
|
|
272
|
+
export declare function getAiSettings(): AiSettings;
|
|
290
273
|
/** Merges a partial update, persists, and notifies subscribers. */
|
|
291
|
-
declare function updateAiSettings(patch: Partial<AiSettings>): AiSettings;
|
|
274
|
+
export declare function updateAiSettings(patch: Partial<AiSettings>): AiSettings;
|
|
292
275
|
/** Clears all stored settings. */
|
|
293
|
-
declare function clearAiSettings(): void;
|
|
276
|
+
export declare function clearAiSettings(): void;
|
|
294
277
|
/** Subscribes to settings changes. Returns the unsubscribe function. */
|
|
295
|
-
declare function subscribeAiSettings(listener: Listener): () => void;
|
|
278
|
+
export declare function subscribeAiSettings(listener: Listener): () => void;
|
|
296
279
|
/** True when the endpoint, key and model are all configured. */
|
|
297
|
-
declare function isAiConfigured(settings: AiSettings): boolean;
|
|
280
|
+
export declare function isAiConfigured(settings: AiSettings): boolean;
|
|
298
281
|
//#endregion
|
|
299
282
|
//#region src/ai/switchboard.d.ts
|
|
300
283
|
/**
|
|
301
284
|
* The switchboard serving a remote drive: the base URL the browser talks to
|
|
302
285
|
* and its GraphQL supergraph endpoint.
|
|
303
286
|
*/
|
|
304
|
-
interface DriveSwitchboard {
|
|
287
|
+
export interface DriveSwitchboard {
|
|
305
288
|
/** Switchboard base URL (e.g. `http://localhost:4001`). */
|
|
306
289
|
switchboardUrl: string;
|
|
307
290
|
/** GraphQL supergraph endpoint (`<base>/graphql`). */
|
|
@@ -312,9 +295,9 @@ interface DriveSwitchboard {
|
|
|
312
295
|
* `undefined` in non-browser environments or before the reactor client
|
|
313
296
|
* module is initialized.
|
|
314
297
|
*/
|
|
315
|
-
declare function getBrowserSyncManager(): ISyncManager | undefined;
|
|
298
|
+
export declare function getBrowserSyncManager(): ISyncManager | undefined;
|
|
316
299
|
/** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */
|
|
317
|
-
declare const GQL_CHANNEL_SUFFIX = "/graphql/r";
|
|
300
|
+
export declare const GQL_CHANNEL_SUFFIX = "/graphql/r";
|
|
318
301
|
/**
|
|
319
302
|
* Resolves the switchboard that serves a drive, if any.
|
|
320
303
|
*
|
|
@@ -326,15 +309,15 @@ declare const GQL_CHANNEL_SUFFIX = "/graphql/r";
|
|
|
326
309
|
* correct. Drives that are not synced to a remote switchboard (local
|
|
327
310
|
* drives, other channel types, unexpected shapes) return `undefined`.
|
|
328
311
|
*/
|
|
329
|
-
declare function resolveDriveSwitchboard(driveId: string | undefined, syncManager?: ISyncManager): DriveSwitchboard | undefined;
|
|
312
|
+
export declare function resolveDriveSwitchboard(driveId: string | undefined, syncManager?: ISyncManager): DriveSwitchboard | undefined;
|
|
330
313
|
/**
|
|
331
314
|
* Introspection over the switchboard supergraph's root query and mutation
|
|
332
315
|
* fields. Types are requested with three levels of `ofType` nesting so
|
|
333
316
|
* that common shapes like `[X!]!` (LIST(NON_NULL(LIST(X)))) render fully.
|
|
334
317
|
*/
|
|
335
|
-
declare const SWITCHBOARD_INTROSPECTION_QUERY: string;
|
|
318
|
+
export declare const SWITCHBOARD_INTROSPECTION_QUERY: string;
|
|
336
319
|
/** One root query or mutation field, reduced to a prompt-friendly line. */
|
|
337
|
-
type SchemaFieldSummary = {
|
|
320
|
+
export type SchemaFieldSummary = {
|
|
338
321
|
name: string;
|
|
339
322
|
description?: string;
|
|
340
323
|
args: string;
|
|
@@ -345,14 +328,14 @@ type SchemaFieldSummary = {
|
|
|
345
328
|
* object) to a compact summary of its root query and mutation fields.
|
|
346
329
|
* Accepts `unknown` because the payload arrives over the wire.
|
|
347
330
|
*/
|
|
348
|
-
declare function summarizeIntrospectionSchema(schema: unknown): {
|
|
331
|
+
export declare function summarizeIntrospectionSchema(schema: unknown): {
|
|
349
332
|
queries: SchemaFieldSummary[];
|
|
350
333
|
mutations: SchemaFieldSummary[];
|
|
351
334
|
truncated: boolean;
|
|
352
335
|
};
|
|
353
|
-
declare const SWITCHBOARD_SCHEMA_TOOL_NAME = "getSwitchboardSchema";
|
|
336
|
+
export declare const SWITCHBOARD_SCHEMA_TOOL_NAME = "getSwitchboardSchema";
|
|
354
337
|
/** Test seams for {@link createSwitchboardSchemaTool}. */
|
|
355
|
-
interface SwitchboardToolDeps {
|
|
338
|
+
export interface SwitchboardToolDeps {
|
|
356
339
|
getSyncManager?: () => ISyncManager | undefined;
|
|
357
340
|
getSelectedDriveId?: () => string | undefined;
|
|
358
341
|
tokenProvider?: () => Promise<string | undefined>;
|
|
@@ -365,7 +348,7 @@ interface SwitchboardToolDeps {
|
|
|
365
348
|
* summary of its root queries and mutations. It reads the schema only and
|
|
366
349
|
* never modifies data.
|
|
367
350
|
*/
|
|
368
|
-
declare function createSwitchboardSchemaTool(deps?: SwitchboardToolDeps): AiToolDescriptor;
|
|
351
|
+
export declare function createSwitchboardSchemaTool(deps?: SwitchboardToolDeps): AiToolDescriptor;
|
|
369
352
|
//#endregion
|
|
370
|
-
export {
|
|
353
|
+
export {};
|
|
371
354
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/ai/types.ts","../../../src/ai/agent.ts","../../../src/ai/components/approval-card.tsx","../../../src/ai/use-reactor-chat.ts","../../../src/ai/components/chat-window.tsx","../../../src/ai/components/reactor-chat-fab.tsx","../../../src/ai/context.ts","../../../src/ai/settings-store.ts","../../../src/ai/switchboard.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/ai/types.ts","../../../src/ai/agent.ts","../../../src/ai/components/approval-card.tsx","../../../src/ai/use-reactor-chat.ts","../../../src/ai/components/chat-window.tsx","../../../src/ai/components/reactor-chat-fab.tsx","../../../src/ai/context.ts","../../../src/ai/settings-store.ts","../../../src/ai/switchboard.ts"],"mappings":";;;;;;;;;;;;;iBAeiB;;EAEf;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;YAIU,oBAAoB;;;;;;;;;;YAWpB,mBAAmB;;YAGnB,wBAAwB,QAAQ;;wBAG5B,YAAY,cAAc;YAI9B;;YAQA;EACN;EAAc;;EAEd;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;;iBAGW;EACf;EACA;EACA,OAAO;;;iBAIQ;EACf;EACA;EACA;;;iBAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;YAIU;EACN;EAAoB;;EAEpB;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;EAEA;EAA2B;EAAoB;;EAE/C;EACA;EACA;EACA;EACA;EACA;;;;;;;EAMA;EAAe;;EACf;;EACA;EAAe;;;;;qBC9GR;;;;;;;;;;qBAWA;;;;;;;;qBA0BA;;qBAGA;;;;;;;;wBAiCG,qBAAqB,SAAS,iBAAiB;wBAiE/C,uBAAuB,UAAU,aAAa;;;;;;wBAc9C,iBAAiB;;wBAmCjB,kBAAkB,SAAS;iBAiD1B;EACf,UAAU;EACV,OAAO;EACP,SAAS;EACT,UAAU,OAAO;EACjB,SAAS;;EAET,QAAQ;;EAER,UAAU;;;;;;;;;qBAUC;mBAIkB;UAHrB;UACA;EAER,YAA6B,SAAS;;EAKtC,cAAc;;EAKd;;EAMA,QAAQ;;EAKR,OAAO;UAIC;UAQA;;EAQF,KAAK,eAAe;;;;;UA8FlB;UA8BA;;;;;;;;wBC3aM,eACd,UACA,WACA;EAEA,UAAU;EACV,YAAY;EACZ,WAAW;gCACZ,IAAA;;;iBCagB;EACf,UAAU;EACV;EACA,kBAAkB;EAClB;EACA,UAAU;EACV;EACA,OAAO;EACP;EACA,UAAU;EACV,SAAS;EACT;;;;;;;;;;wBAWc,eACd,gBAAgB,kBACf;;;;wBCyDa,aACd,MACA;EAEA,MAAM;EACN;gCACD,IAAA;;;;;;;;;;wBC/Ge,iBAAiB;EAAc,WAAW;gCAAiB,IAAA;;;;;;;;wBCF3D,kBAAkB;;;qBCRrB,qBAAqB;KAQ7B;;wBA6CW,iBAAiB;;wBAKjB,iBAAiB,OAAO,QAAQ,cAAc;;wBAQ9C;;wBAWA,oBAAoB,UAAU;;wBAQ9B,eAAe,UAAU;;;;;;;iBC/ExB;;EAEf;;EAEA;;;;;;;wBAQc,yBAAyB;;qBAS5B;;;;;;;;;;;;wBAaG,wBACd,6BACA,cAAc,eACb;;;;;;qBAoDU;;YA6GD;EACV;EACA;EACA;EACA;;;;;;;wBA6Bc,6BAA6B;EAC3C,SAAS;EACT,WAAW;EACX;;qBAYW;;iBAGI;EACf,uBAAuB;EACvB;EACA,sBAAsB;EACtB,mBAAmB;EACnB;;;;;;;;wBASc,4BACd,OAAO,sBACN"}
|
package/dist/src/ai/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as getBrowserSyncManager, i as createSwitchboardSchemaTool, l as useSelectedDocumentId, n as SWITCHBOARD_INTROSPECTION_QUERY, o as resolveDriveSwitchboard, r as SWITCHBOARD_SCHEMA_TOOL_NAME, s as summarizeIntrospectionSchema, t as GQL_CHANNEL_SUFFIX } from "../../switchboard-
|
|
3
|
-
import { isFileNode, isFolderNode } from "@powerhousedao/shared/document-drive";
|
|
1
|
+
import { g as useSelectedDriveSafe } from "../../document-model-modules-XrYfGXt8.js";
|
|
2
|
+
import { a as getBrowserSyncManager, h as useSelectedNode, i as createSwitchboardSchemaTool, l as useSelectedDocumentId, n as SWITCHBOARD_INTROSPECTION_QUERY, o as resolveDriveSwitchboard, r as SWITCHBOARD_SCHEMA_TOOL_NAME, s as summarizeIntrospectionSchema, t as GQL_CHANNEL_SUFFIX } from "../../switchboard-CYTCYt4Z.js";
|
|
4
3
|
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { isFileNode, isFolderNode } from "@powerhousedao/shared/document-drive";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { isStepCount, streamText, tool } from "ai";
|
|
8
8
|
import { toResponseMessages } from "ai/internal";
|
|
@@ -11,22 +11,9 @@ import { ArrowUp, Check, Maximize2, MessageCircle, Minimize2, Square, Trash2, X
|
|
|
11
11
|
import ReactMarkdown from "react-markdown";
|
|
12
12
|
import remarkGfm from "remark-gfm";
|
|
13
13
|
//#region src/ai/types.ts
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"addActions",
|
|
18
|
-
"deleteDocument",
|
|
19
|
-
"addDrive",
|
|
20
|
-
"deleteDrive",
|
|
21
|
-
"addRemoteDrive"
|
|
22
|
-
]);
|
|
23
|
-
/**
|
|
24
|
-
* Whether executing the tool mutates state and requires user approval:
|
|
25
|
-
* the built-in write tools, or any tool flagged destructive in its
|
|
26
|
-
* annotations (covers package-provided tools outside the built-in set).
|
|
27
|
-
*/
|
|
28
|
-
function isWriteTool(name, annotations) {
|
|
29
|
-
return WRITE_TOOLS.has(name) || annotations?.destructiveHint === true;
|
|
14
|
+
/** Whether running the tool needs approval: anything not annotated read-only. */
|
|
15
|
+
function isWriteTool(annotations) {
|
|
16
|
+
return annotations?.readOnlyHint !== true;
|
|
30
17
|
}
|
|
31
18
|
//#endregion
|
|
32
19
|
//#region src/ai/agent.ts
|
|
@@ -204,6 +191,7 @@ function buildSystemPrompt(context) {
|
|
|
204
191
|
* pending user decision is bridged through {@link approve}/{@link reject}.
|
|
205
192
|
*/
|
|
206
193
|
var ReactorChatAgent = class {
|
|
194
|
+
options;
|
|
207
195
|
history;
|
|
208
196
|
approvals = /* @__PURE__ */ new Map();
|
|
209
197
|
constructor(options) {
|
|
@@ -271,7 +259,7 @@ var ReactorChatAgent = class {
|
|
|
271
259
|
},
|
|
272
260
|
toolApproval: async ({ toolCall }) => {
|
|
273
261
|
const descriptor = this.options.tools.find((t) => t.name === toolCall.toolName);
|
|
274
|
-
if (settings.autoApproveWrites || !isWriteTool(
|
|
262
|
+
if (settings.autoApproveWrites || !isWriteTool(descriptor?.annotations)) return "not-applicable";
|
|
275
263
|
const toolCallId = toolCall.toolCallId;
|
|
276
264
|
onEvent({
|
|
277
265
|
type: "approval-request",
|
|
@@ -398,7 +386,6 @@ var ReactorChatAgent = class {
|
|
|
398
386
|
});
|
|
399
387
|
break;
|
|
400
388
|
}
|
|
401
|
-
default: break;
|
|
402
389
|
}
|
|
403
390
|
}
|
|
404
391
|
};
|
|
@@ -857,7 +844,7 @@ function toErrorMessage(error) {
|
|
|
857
844
|
* Drives one in-browser chat conversation against the reactor tools.
|
|
858
845
|
*
|
|
859
846
|
* `toolsProvider` lazily resolves the tool descriptors (e.g. from
|
|
860
|
-
* `
|
|
847
|
+
* `toMcpTool` bound to `window.ph.reactorClient`) when the
|
|
861
848
|
* user sends a message, so the reactor does not need to be ready at render
|
|
862
849
|
* time.
|
|
863
850
|
*/
|
|
@@ -927,10 +914,7 @@ function useReactorChat(toolsProvider) {
|
|
|
927
914
|
error: event.error
|
|
928
915
|
} : part)));
|
|
929
916
|
break;
|
|
930
|
-
case "error":
|
|
931
|
-
setError(event.error);
|
|
932
|
-
break;
|
|
933
|
-
case "finish": break;
|
|
917
|
+
case "error": setError(event.error);
|
|
934
918
|
}
|
|
935
919
|
}, []);
|
|
936
920
|
const send = useCallback((text) => {
|
|
@@ -1041,7 +1025,7 @@ function useReactorChat(toolsProvider) {
|
|
|
1041
1025
|
* Bottom-right floating action button that opens the reactor AI chat window.
|
|
1042
1026
|
*
|
|
1043
1027
|
* `getTools` lazily resolves the reactor tool descriptors (from
|
|
1044
|
-
* `
|
|
1028
|
+
* `toMcpTool` bound to the browser reactor client) when the
|
|
1045
1029
|
* user sends a message.
|
|
1046
1030
|
*/
|
|
1047
1031
|
function ReactorChatFab({ getTools }) {
|
|
@@ -1062,6 +1046,6 @@ function ReactorChatFab({ getTools }) {
|
|
|
1062
1046
|
})] });
|
|
1063
1047
|
}
|
|
1064
1048
|
//#endregion
|
|
1065
|
-
export { ApprovalCard, ChatWindow, DEFAULT_AI_SETTINGS, FULL_RESULT_TURNS, GQL_CHANNEL_SUFFIX, MAX_AGENT_STEPS, MAX_TOOL_RESULT_CHARS, ReactorChatAgent, ReactorChatFab, STUB_MIN_CHARS, SWITCHBOARD_INTROSPECTION_QUERY, SWITCHBOARD_SCHEMA_TOOL_NAME,
|
|
1049
|
+
export { ApprovalCard, ChatWindow, DEFAULT_AI_SETTINGS, FULL_RESULT_TURNS, GQL_CHANNEL_SUFFIX, MAX_AGENT_STEPS, MAX_TOOL_RESULT_CHARS, ReactorChatAgent, ReactorChatFab, STUB_MIN_CHARS, SWITCHBOARD_INTROSPECTION_QUERY, SWITCHBOARD_SCHEMA_TOOL_NAME, buildSystemPrompt, clearAiSettings, createReactorChatModel, createSwitchboardSchemaTool, getAiSettings, getBrowserSyncManager, isAiConfigured, isWriteTool, resolveDriveSwitchboard, stubStaleToolResults, subscribeAiSettings, summarizeIntrospectionSchema, unwrapToolResult, updateAiSettings, useChatContext, useReactorChat };
|
|
1066
1050
|
|
|
1067
1051
|
//# sourceMappingURL=index.js.map
|