@powerhousedao/reactor-browser 6.2.3-dev.94 → 6.2.3-dev.96
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-10Qn5nIw.d.ts → attachment-service-DXfpfp98.d.ts} +4 -3
- package/dist/attachment-service-DXfpfp98.d.ts.map +1 -0
- package/dist/client-1n_ZUXeu.js +135 -0
- package/dist/client-1n_ZUXeu.js.map +1 -0
- package/dist/{client-C-NgSjoc.d.ts → client-BFk0MY6A.d.ts} +2 -2
- package/dist/client-BFk0MY6A.d.ts.map +1 -0
- package/dist/{document-model-modules-ChmfyIxT.js → document-model-modules-BG-61uke.js} +68 -2
- package/dist/document-model-modules-BG-61uke.js.map +1 -0
- package/dist/{document-operations-QtU34A52.js → document-operations-D5QXcJbV.js} +6 -61
- package/dist/document-operations-D5QXcJbV.js.map +1 -0
- package/dist/{global-bbfp3_1x.d.ts → global-DAAmZGCO.d.ts} +7 -44
- package/dist/global-DAAmZGCO.d.ts.map +1 -0
- package/dist/{index-Bfr_cWdi.d.ts → index-Bj1poVfa.d.ts} +2 -2
- package/dist/{index-Bfr_cWdi.d.ts.map → index-Bj1poVfa.d.ts.map} +1 -1
- package/dist/index.d.ts +78 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -187
- package/dist/index.js.map +1 -1
- package/dist/{client-BNMyQ_Z2.js → schema-D0G1oAo9.js} +2 -133
- package/dist/schema-D0G1oAo9.js.map +1 -0
- package/dist/src/ai/index.d.ts +41 -8
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +302 -6
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/graphql/client.d.ts +2 -2
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +3 -2
- package/dist/src/graphql-client/entry.js +2 -2
- package/dist/src/renown/index.d.ts +1 -1
- package/dist/switchboard-directory-CWf5SRo7.js +435 -0
- package/dist/switchboard-directory-CWf5SRo7.js.map +1 -0
- package/dist/switchboards-D-_JBUbF.d.ts +75 -0
- package/dist/switchboards-D-_JBUbF.d.ts.map +1 -0
- package/dist/{types-CT44EMmw.d.ts → types-CyPDurGV.d.ts} +5 -1
- package/dist/types-CyPDurGV.d.ts.map +1 -0
- package/package.json +10 -10
- package/dist/attachment-service-10Qn5nIw.d.ts.map +0 -1
- package/dist/client-BNMyQ_Z2.js.map +0 -1
- package/dist/client-C-NgSjoc.d.ts.map +0 -1
- package/dist/document-model-modules-ChmfyIxT.js.map +0 -1
- package/dist/document-operations-QtU34A52.js.map +0 -1
- package/dist/global-bbfp3_1x.d.ts.map +0 -1
- package/dist/switchboard-B640iT1L.js +0 -321
- package/dist/switchboard-B640iT1L.js.map +0 -1
- package/dist/types-CT44EMmw.d.ts.map +0 -1
package/dist/src/ai/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { c as getPHStore } from "../../make-ph-event-functions-B5GU5xcR.js";
|
|
2
|
-
import {
|
|
2
|
+
import { $ as useReactorHalves, _t as ambientRenownTokenProvider, u as useSwitchboards, y as useSelectedDriveSafe } from "../../document-model-modules-BG-61uke.js";
|
|
3
3
|
import { o as useUser } from "../../renown-CBoTdGrg.js";
|
|
4
|
-
import {
|
|
4
|
+
import { b as useSelectedNode, f as GQL_CHANNEL_SUFFIX, m as useSelectedDocumentId, r as resolveSwitchboard } from "../../switchboard-directory-CWf5SRo7.js";
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { DriveCollectionId } from "@powerhousedao/reactor";
|
|
7
8
|
import { isFileNode, isFolderNode } from "@powerhousedao/shared/document-drive";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { isStepCount, streamText, tool } from "ai";
|
|
@@ -335,6 +336,16 @@ function unwrapToolResult(raw) {
|
|
|
335
336
|
}
|
|
336
337
|
return raw;
|
|
337
338
|
}
|
|
339
|
+
/** Which switchboards the host reaches, and how the tools pick one. */
|
|
340
|
+
function switchboardsLine(switchboards) {
|
|
341
|
+
const describe = (entry) => {
|
|
342
|
+
const workflows = entry.workflows === "unknown" ? "" : entry.workflows ? ", runs workflows" : ", runs no workflows";
|
|
343
|
+
return `${entry.name} at ${entry.url}${workflows}`;
|
|
344
|
+
};
|
|
345
|
+
if (switchboards.length === 0) return "This app reaches no switchboard, so tools that ask one will fail.";
|
|
346
|
+
if (switchboards.length === 1) return `This app reaches one switchboard: ${describe(switchboards[0])}. Tools that ask a switchboard use it without being told; getSwitchboardSchema lists what it exposes.`;
|
|
347
|
+
return `This app reaches several switchboards: ${switchboards.map(describe).join("; ")}. Tools that ask a switchboard take its name as "switchboard" when they can't tell which one is meant; listSwitchboards lists them.`;
|
|
348
|
+
}
|
|
338
349
|
/** Builds the system prompt, grounding the agent in the current selection. */
|
|
339
350
|
function buildSystemPrompt(context) {
|
|
340
351
|
const lines = [
|
|
@@ -354,7 +365,8 @@ function buildSystemPrompt(context) {
|
|
|
354
365
|
if (context.driveName) selection.push(`The current drive is "${context.driveName}"` + (context.driveId ? ` (id: ${context.driveId})` : "") + ".");
|
|
355
366
|
if (context.nodeKind === "folder" && context.nodeName) selection.push(`The current folder is "${context.nodeName}".`);
|
|
356
367
|
if (context.documentType) selection.push(`The current document is "${context.documentName ?? "unnamed"}" of type "${context.documentType}"` + (context.documentId ? ` (id: ${context.documentId})` : "") + ".");
|
|
357
|
-
if (context.
|
|
368
|
+
if (context.switchboards) lines.push(switchboardsLine(context.switchboards));
|
|
369
|
+
else if (context.switchboardUrl) selection.push(`The switchboard for this drive is at ${context.switchboardUrl}; its GraphQL endpoint is ${context.switchboardGraphqlUrl ?? ""}. Use the getSwitchboardSchema tool to list the queries and mutations it exposes.`);
|
|
358
370
|
else if (context.driveId) selection.push("This drive is not synced to a switchboard, so no switchboard endpoints are available for it.");
|
|
359
371
|
if (selection.length > 0) lines.push("Current selection:", ...selection.map((s) => `- ${s}`));
|
|
360
372
|
else lines.push("Nothing is currently selected. When the target of an action is ambiguous, ask the user which drive, folder or document it should apply to.");
|
|
@@ -447,10 +459,12 @@ var ReactorChatAgent = class {
|
|
|
447
459
|
description: descriptor.description,
|
|
448
460
|
inputSchema: z.object(descriptor.inputSchema),
|
|
449
461
|
execute: async (args, { toolCallId }) => {
|
|
450
|
-
const
|
|
462
|
+
const toolContext = {
|
|
463
|
+
...this.options.services?.(),
|
|
451
464
|
signal,
|
|
452
465
|
chatImages: this.chatImages
|
|
453
|
-
}
|
|
466
|
+
};
|
|
467
|
+
const raw = await descriptor.callback(args, toolContext);
|
|
454
468
|
const returned = toolResultImages(raw);
|
|
455
469
|
if (returned.length > 0) toolImages.set(toolCallId, returned);
|
|
456
470
|
return boundedToolResult(unwrapToolResult(raw));
|
|
@@ -1177,6 +1191,269 @@ function isAiConfigured(settings) {
|
|
|
1177
1191
|
return settings.baseUrl.trim().length > 0 && settings.apiKey.trim().length > 0 && settings.model.trim().length > 0;
|
|
1178
1192
|
}
|
|
1179
1193
|
//#endregion
|
|
1194
|
+
//#region src/ai/switchboard.ts
|
|
1195
|
+
/**
|
|
1196
|
+
* Reads the tab-side sync manager from the browser global. Returns
|
|
1197
|
+
* `undefined` in non-browser environments or before the reactor client
|
|
1198
|
+
* module is initialized.
|
|
1199
|
+
*/
|
|
1200
|
+
function getBrowserSyncManager() {
|
|
1201
|
+
if (typeof window === "undefined") return;
|
|
1202
|
+
return getPHStore()?.reactorClientModule?.reactorModule?.syncModule?.syncManager;
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Resolves the switchboard that serves a drive, if any.
|
|
1206
|
+
*
|
|
1207
|
+
* Every remote drive stores its switchboard's exact GraphQL channel
|
|
1208
|
+
* endpoint in its sync remote — `channelConfig = { type: "gql",
|
|
1209
|
+
* parameters: { url: "<origin>/graphql/r" } }` — and the switchboard base
|
|
1210
|
+
* is that URL minus the `/graphql/r` suffix. Deriving it per drive (rather
|
|
1211
|
+
* than from a global setting) is what keeps multi-switchboard deployments
|
|
1212
|
+
* correct. Drives that are not synced to a remote switchboard (local
|
|
1213
|
+
* drives, other channel types, unexpected shapes) return `undefined`.
|
|
1214
|
+
*
|
|
1215
|
+
* @deprecated Reads synced drives only, so it finds nothing for a remote
|
|
1216
|
+
* client's drives. Use the host's switchboard directory (`resolveSwitchboard`).
|
|
1217
|
+
*/
|
|
1218
|
+
function resolveDriveSwitchboard(driveId, syncManager) {
|
|
1219
|
+
const manager = syncManager ?? getBrowserSyncManager();
|
|
1220
|
+
if (!driveId || !manager) return;
|
|
1221
|
+
const collectionId = DriveCollectionId.forDrive(driveId);
|
|
1222
|
+
const remote = manager.list().find((r) => r.meta.collectionId.equals(collectionId));
|
|
1223
|
+
if (!remote) return;
|
|
1224
|
+
const { channelConfig } = remote.meta;
|
|
1225
|
+
if (channelConfig.type !== "gql") return;
|
|
1226
|
+
const url = channelConfig.parameters.url;
|
|
1227
|
+
if (typeof url !== "string" || !url.endsWith("/graphql/r")) return;
|
|
1228
|
+
const switchboardUrl = url.slice(0, -GQL_CHANNEL_SUFFIX.length);
|
|
1229
|
+
return {
|
|
1230
|
+
switchboardUrl,
|
|
1231
|
+
graphqlUrl: `${switchboardUrl}/graphql`
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Introspection over the switchboard supergraph's root query and mutation
|
|
1236
|
+
* fields. Types are requested with three levels of `ofType` nesting so
|
|
1237
|
+
* that common shapes like `[X!]!` (LIST(NON_NULL(LIST(X)))) render fully.
|
|
1238
|
+
*/
|
|
1239
|
+
const SWITCHBOARD_INTROSPECTION_QUERY = `
|
|
1240
|
+
query SwitchboardIntrospection {
|
|
1241
|
+
__schema {
|
|
1242
|
+
queryType {
|
|
1243
|
+
fields {
|
|
1244
|
+
name
|
|
1245
|
+
description
|
|
1246
|
+
args {
|
|
1247
|
+
name
|
|
1248
|
+
type {
|
|
1249
|
+
kind
|
|
1250
|
+
name
|
|
1251
|
+
ofType {
|
|
1252
|
+
kind
|
|
1253
|
+
name
|
|
1254
|
+
ofType {
|
|
1255
|
+
kind
|
|
1256
|
+
name
|
|
1257
|
+
ofType {
|
|
1258
|
+
kind
|
|
1259
|
+
name
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
type {
|
|
1266
|
+
kind
|
|
1267
|
+
name
|
|
1268
|
+
ofType {
|
|
1269
|
+
kind
|
|
1270
|
+
name
|
|
1271
|
+
ofType {
|
|
1272
|
+
kind
|
|
1273
|
+
name
|
|
1274
|
+
ofType {
|
|
1275
|
+
kind
|
|
1276
|
+
name
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
mutationType {
|
|
1284
|
+
fields {
|
|
1285
|
+
name
|
|
1286
|
+
description
|
|
1287
|
+
args {
|
|
1288
|
+
name
|
|
1289
|
+
type {
|
|
1290
|
+
kind
|
|
1291
|
+
name
|
|
1292
|
+
ofType {
|
|
1293
|
+
kind
|
|
1294
|
+
name
|
|
1295
|
+
ofType {
|
|
1296
|
+
kind
|
|
1297
|
+
name
|
|
1298
|
+
ofType {
|
|
1299
|
+
kind
|
|
1300
|
+
name
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
type {
|
|
1307
|
+
kind
|
|
1308
|
+
name
|
|
1309
|
+
ofType {
|
|
1310
|
+
kind
|
|
1311
|
+
name
|
|
1312
|
+
ofType {
|
|
1313
|
+
kind
|
|
1314
|
+
name
|
|
1315
|
+
ofType {
|
|
1316
|
+
kind
|
|
1317
|
+
name
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
`;
|
|
1327
|
+
/**
|
|
1328
|
+
* Renders an introspected type reference as a GraphQL type string.
|
|
1329
|
+
* Recursion is bounded by the `ofType` nesting of the query, so it always
|
|
1330
|
+
* terminates.
|
|
1331
|
+
*/
|
|
1332
|
+
function renderTypeRef(type) {
|
|
1333
|
+
if (!type) return "Unknown";
|
|
1334
|
+
switch (type.kind) {
|
|
1335
|
+
case "NON_NULL": return `${renderTypeRef(type.ofType)}!`;
|
|
1336
|
+
case "LIST": return `[${renderTypeRef(type.ofType)}]`;
|
|
1337
|
+
default: return type.name ?? "Unknown";
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
/** Cap on the number of fields reported per root type. */
|
|
1341
|
+
const MAX_FIELDS_PER_ROOT = 200;
|
|
1342
|
+
function summarizeFields(fields) {
|
|
1343
|
+
const list = fields ?? [];
|
|
1344
|
+
return {
|
|
1345
|
+
fields: list.slice(0, MAX_FIELDS_PER_ROOT).map((field) => ({
|
|
1346
|
+
name: field.name,
|
|
1347
|
+
...field.description ? { description: field.description } : {},
|
|
1348
|
+
args: field.args.map((arg) => `${arg.name}: ${renderTypeRef(arg.type)}`).join(", "),
|
|
1349
|
+
returns: renderTypeRef(field.type)
|
|
1350
|
+
})),
|
|
1351
|
+
truncated: list.length > MAX_FIELDS_PER_ROOT
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Reduces a GraphQL `__schema` introspection payload (the `data.__schema`
|
|
1356
|
+
* object) to a compact summary of its root query and mutation fields.
|
|
1357
|
+
* Accepts `unknown` because the payload arrives over the wire.
|
|
1358
|
+
*/
|
|
1359
|
+
function summarizeIntrospectionSchema(schema) {
|
|
1360
|
+
const introspection = schema ?? {};
|
|
1361
|
+
const queries = summarizeFields(introspection.queryType?.fields);
|
|
1362
|
+
const mutations = summarizeFields(introspection.mutationType?.fields);
|
|
1363
|
+
return {
|
|
1364
|
+
queries: queries.fields,
|
|
1365
|
+
mutations: mutations.fields,
|
|
1366
|
+
truncated: queries.truncated || mutations.truncated
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
const SWITCHBOARD_SCHEMA_TOOL_NAME = "getSwitchboardSchema";
|
|
1370
|
+
/**
|
|
1371
|
+
* Creates the read-only `getSwitchboardSchema` tool: it introspects the
|
|
1372
|
+
* GraphQL supergraph of a switchboard the host reaches and returns a summary
|
|
1373
|
+
* of its root queries and mutations. It reads the schema only and never
|
|
1374
|
+
* modifies data. The switchboard comes from the host's directory, which the
|
|
1375
|
+
* agent hands every call.
|
|
1376
|
+
*/
|
|
1377
|
+
function createSwitchboardSchemaTool(deps) {
|
|
1378
|
+
const tokenProvider = deps?.tokenProvider ?? ambientRenownTokenProvider;
|
|
1379
|
+
const fetchImpl = deps?.fetchImpl ?? fetch;
|
|
1380
|
+
const timeoutMs = deps?.timeoutMs ?? 1e4;
|
|
1381
|
+
return {
|
|
1382
|
+
name: SWITCHBOARD_SCHEMA_TOOL_NAME,
|
|
1383
|
+
description: "Introspect the GraphQL endpoint of a switchboard and list the queries and mutations it exposes (reactor operations, document-model read models, package subgraphs). Read-only: it reads the schema only and never modifies data. Omit both inputs when the app reaches one switchboard.",
|
|
1384
|
+
inputSchema: {
|
|
1385
|
+
driveId: z.string().describe("A drive whose switchboard to introspect.").optional(),
|
|
1386
|
+
switchboard: z.string().describe("The switchboard to introspect: a name or URL from listSwitchboards.").optional()
|
|
1387
|
+
},
|
|
1388
|
+
annotations: { readOnlyHint: true },
|
|
1389
|
+
callback: async (input, context) => {
|
|
1390
|
+
const { switchboards, signal } = context ?? {};
|
|
1391
|
+
const entry = await resolveSwitchboard(switchboards, {
|
|
1392
|
+
switchboard: input?.switchboard,
|
|
1393
|
+
documentId: input?.driveId,
|
|
1394
|
+
signal
|
|
1395
|
+
});
|
|
1396
|
+
const sb = {
|
|
1397
|
+
switchboardUrl: entry.base,
|
|
1398
|
+
graphqlUrl: entry.graphqlUrl
|
|
1399
|
+
};
|
|
1400
|
+
const token = await tokenProvider();
|
|
1401
|
+
let response;
|
|
1402
|
+
try {
|
|
1403
|
+
response = await fetchImpl(sb.graphqlUrl, {
|
|
1404
|
+
method: "POST",
|
|
1405
|
+
headers: {
|
|
1406
|
+
"content-type": "application/json",
|
|
1407
|
+
...token ? { authorization: `Bearer ${token}` } : {}
|
|
1408
|
+
},
|
|
1409
|
+
body: JSON.stringify({ query: SWITCHBOARD_INTROSPECTION_QUERY }),
|
|
1410
|
+
signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs)
|
|
1411
|
+
});
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
throw new Error(`Switchboard at ${sb.graphqlUrl} is not reachable: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
1414
|
+
}
|
|
1415
|
+
if (response.status === 401 || response.status === 403) throw new Error(`Switchboard at ${sb.graphqlUrl} refused the request (HTTP ${response.status}). Sign in to the switchboard (Renown) and try again.`);
|
|
1416
|
+
if (!response.ok) throw new Error(`Switchboard introspection failed: HTTP ${response.status} ${response.statusText} from ${sb.graphqlUrl}`);
|
|
1417
|
+
const body = await response.json();
|
|
1418
|
+
const schemaErrors = body?.errors;
|
|
1419
|
+
if (schemaErrors && schemaErrors.length > 0) throw new Error(schemaErrors.map((e) => e.message ?? "unknown error").join("; "));
|
|
1420
|
+
const schema = body?.data?.__schema;
|
|
1421
|
+
if (!schema?.queryType) throw new Error(`Switchboard at ${sb.graphqlUrl} did not return a GraphQL schema.`);
|
|
1422
|
+
const summary = summarizeIntrospectionSchema(schema);
|
|
1423
|
+
return {
|
|
1424
|
+
switchboard: entry.name,
|
|
1425
|
+
switchboardUrl: sb.switchboardUrl,
|
|
1426
|
+
graphqlUrl: sb.graphqlUrl,
|
|
1427
|
+
...summary
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
const LIST_SWITCHBOARDS_TOOL_NAME = "listSwitchboards";
|
|
1433
|
+
/**
|
|
1434
|
+
* Creates the read-only `listSwitchboards` tool: the switchboards the host
|
|
1435
|
+
* reaches, by the names other tools take as `switchboard`.
|
|
1436
|
+
*/
|
|
1437
|
+
function createListSwitchboardsTool() {
|
|
1438
|
+
return {
|
|
1439
|
+
name: LIST_SWITCHBOARDS_TOOL_NAME,
|
|
1440
|
+
description: "Lists the switchboards this app reaches: each one's name, URL, how it is reached, and whether it runs a workflow runtime (true, false or \"unknown\"). Pass a name or URL as `switchboard` to the tools that ask a switchboard; with one switchboard they need none.",
|
|
1441
|
+
inputSchema: {},
|
|
1442
|
+
annotations: { readOnlyHint: true },
|
|
1443
|
+
callback: (_input, context) => {
|
|
1444
|
+
const { switchboards } = context ?? {};
|
|
1445
|
+
if (!switchboards) return Promise.reject(/* @__PURE__ */ new Error("This app provides no switchboard directory, so it lists no switchboards."));
|
|
1446
|
+
return Promise.resolve({ switchboards: switchboards.list().map((entry) => ({
|
|
1447
|
+
name: entry.name,
|
|
1448
|
+
url: entry.base,
|
|
1449
|
+
graphqlUrl: entry.graphqlUrl,
|
|
1450
|
+
via: entry.via,
|
|
1451
|
+
workflows: entry.workflows
|
|
1452
|
+
})) });
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
//#endregion
|
|
1180
1457
|
//#region src/ai/context.ts
|
|
1181
1458
|
/**
|
|
1182
1459
|
* Snapshot of the current selection in the drive explorer, used to make the
|
|
@@ -1187,6 +1464,7 @@ function useChatContext() {
|
|
|
1187
1464
|
const [drive] = useSelectedDriveSafe();
|
|
1188
1465
|
const node = useSelectedNode();
|
|
1189
1466
|
const documentId = useSelectedDocumentId();
|
|
1467
|
+
const switchboards = useSwitchboards();
|
|
1190
1468
|
const context = {
|
|
1191
1469
|
driveId: drive?.header.id,
|
|
1192
1470
|
driveName: drive?.header.name
|
|
@@ -1202,6 +1480,14 @@ function useChatContext() {
|
|
|
1202
1480
|
context.documentType = node.documentType;
|
|
1203
1481
|
context.documentId = documentId;
|
|
1204
1482
|
}
|
|
1483
|
+
if (switchboards) {
|
|
1484
|
+
context.switchboards = switchboards.list().map((entry) => ({
|
|
1485
|
+
name: entry.name,
|
|
1486
|
+
url: entry.base,
|
|
1487
|
+
workflows: entry.workflows
|
|
1488
|
+
}));
|
|
1489
|
+
return context;
|
|
1490
|
+
}
|
|
1205
1491
|
const sb = resolveDriveSwitchboard(drive?.header.id);
|
|
1206
1492
|
if (sb) {
|
|
1207
1493
|
context.switchboardUrl = sb.switchboardUrl;
|
|
@@ -1250,6 +1536,15 @@ function useReactorChat(toolsProvider, options) {
|
|
|
1250
1536
|
}, [autoApprove]);
|
|
1251
1537
|
const settings = useSyncExternalStore(subscribeAiSettings, getAiSettings);
|
|
1252
1538
|
const context = useChatContext();
|
|
1539
|
+
const switchboards = useSwitchboards();
|
|
1540
|
+
const reactor = useReactorHalves();
|
|
1541
|
+
const servicesRef = useRef({});
|
|
1542
|
+
useEffect(() => {
|
|
1543
|
+
servicesRef.current = {
|
|
1544
|
+
switchboards,
|
|
1545
|
+
reactor
|
|
1546
|
+
};
|
|
1547
|
+
}, [switchboards, reactor]);
|
|
1253
1548
|
const handleEvent = useCallback((event) => {
|
|
1254
1549
|
const assistantId = assistantIdRef.current;
|
|
1255
1550
|
switch (event.type) {
|
|
@@ -1337,6 +1632,7 @@ function useReactorChat(toolsProvider, options) {
|
|
|
1337
1632
|
instructions,
|
|
1338
1633
|
tools,
|
|
1339
1634
|
context,
|
|
1635
|
+
services: () => servicesRef.current,
|
|
1340
1636
|
onEvent: handleEvent,
|
|
1341
1637
|
signal: controller.signal,
|
|
1342
1638
|
history: historyRef.current,
|
|
@@ -1623,6 +1919,6 @@ function getHostAiTools() {
|
|
|
1623
1919
|
return tools ? tools() : Promise.reject(/* @__PURE__ */ new Error("This app offers no tools to the assistant."));
|
|
1624
1920
|
}
|
|
1625
1921
|
//#endregion
|
|
1626
|
-
export { AI_GATEWAY_PATH, ApprovalCard, CHAT_IMAGE_TYPES, ChatPanel, ChatWindow, DEFAULT_AI_SETTINGS, FULL_RESULT_TURNS, GQL_CHANNEL_SUFFIX, MAX_AGENT_STEPS, MAX_REQUEST_IMAGES, MAX_REQUEST_IMAGE_CHARS, MAX_TOOL_RESULT_CHARS, Markdown, ReactorChatAgent, ReactorChatFab, STUB_MIN_CHARS, SWITCHBOARD_INTROSPECTION_QUERY, SWITCHBOARD_SCHEMA_TOOL_NAME, buildSystemPrompt, clearAiSettings, createConnectionChatModel, createReactorChatModel, createSwitchboardSchemaTool, fetchAiGatewayAccess, gatewayConnection, gatewayFetch, getAiSettings, getBrowserSyncManager, getHostAiTools, hasToolImages, isAiConfigured, isWriteTool, readChatImage, resetAiGatewayKey, resolveDriveSwitchboard, setAiGatewayDemoKey, setAiGatewayKey, setAiGatewayModel, stubStaleToolResults, subscribeAiSettings, summarizeIntrospectionSchema, toolOutput, toolOutputImageCount, toolOutputTextChars, toolResultImages, unwrapToolResult, updateAiSettings, useAiGateway, useChatContext, useReactorChat, watchAiGatewayAccess, withToolImages };
|
|
1922
|
+
export { AI_GATEWAY_PATH, ApprovalCard, CHAT_IMAGE_TYPES, ChatPanel, ChatWindow, DEFAULT_AI_SETTINGS, FULL_RESULT_TURNS, GQL_CHANNEL_SUFFIX, LIST_SWITCHBOARDS_TOOL_NAME, MAX_AGENT_STEPS, MAX_REQUEST_IMAGES, MAX_REQUEST_IMAGE_CHARS, MAX_TOOL_RESULT_CHARS, Markdown, ReactorChatAgent, ReactorChatFab, STUB_MIN_CHARS, SWITCHBOARD_INTROSPECTION_QUERY, SWITCHBOARD_SCHEMA_TOOL_NAME, buildSystemPrompt, clearAiSettings, createConnectionChatModel, createListSwitchboardsTool, createReactorChatModel, createSwitchboardSchemaTool, fetchAiGatewayAccess, gatewayConnection, gatewayFetch, getAiSettings, getBrowserSyncManager, getHostAiTools, hasToolImages, isAiConfigured, isWriteTool, readChatImage, resetAiGatewayKey, resolveDriveSwitchboard, setAiGatewayDemoKey, setAiGatewayKey, setAiGatewayModel, stubStaleToolResults, subscribeAiSettings, summarizeIntrospectionSchema, toolOutput, toolOutputImageCount, toolOutputTextChars, toolResultImages, unwrapToolResult, updateAiSettings, useAiGateway, useChatContext, useReactorChat, watchAiGatewayAccess, withToolImages };
|
|
1627
1923
|
|
|
1628
1924
|
//# sourceMappingURL=index.js.map
|