@particle-academy/agent-integrations 0.35.0 → 0.37.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/dist/index.d.cts CHANGED
@@ -24,8 +24,10 @@ export { TerminalBridge, TerminalBridgeAdapter, TerminalBridgeOptions, TerminalR
24
24
  export { CatalogBridgeAdapter, CatalogBridgeOptions, CatalogCheckoutArgs, CatalogPrice, CatalogProduct, registerCatalogBridge } from './bridges/catalog.cjs';
25
25
  export { FeatureDefinition, FeatureGrant, FeaturesBridgeAdapter, FeaturesBridgeOptions, registerFeaturesBridge } from './bridges/features.cjs';
26
26
  export { PASSKEY_BRIDGE_TOOLS, PasskeyBridgeAdapter, PasskeyBridgeOptions, PasskeyProposal, PasskeySummaryLike, PasskeySupport, PasskeySurfaceState, registerPasskeyBridge } from './bridges/passkeys.cjs';
27
- export { DocAdapter, DocBridgeOptions, DocOpTool, registerDocBridge } from './bridges/doc.cjs';
27
+ import { DocAdapter } from './bridges/doc.cjs';
28
+ export { DocBridgeOptions, DocOpTool, registerDocBridge } from './bridges/doc.cjs';
28
29
  export { CmsBridgeOptions, CmsOp, cmsReducer, registerCmsBridge } from './bridges/cms.cjs';
30
+ import { DocNode, StagePolicy, TreeOp } from '@particle-academy/fancy-doc-commons';
29
31
  import { RelayState } from './sharing/index.cjs';
30
32
  export { SseRelayOptions, SseRelayTransport, attachSseRelay } from './sharing/index.cjs';
31
33
  import { S as SessionDescriptor } from './token-BZ8doMam.cjs';
@@ -40,7 +42,6 @@ export { CLAUDE_CONNECTORS_URL, CONNECTOR_GLYPHS, CONNECTOR_TARGETS, ClaudeMark,
40
42
  export { D as DEFAULT_MCPB_ENTRY_POINT, b as MCPB_MANIFEST_VERSION, c as MCPB_MIN_NODE, M as McpbManifestInput, a as McpbTool, d as buildMcpbManifest, e as buildMcpbProxyStub } from './mcpb-BXOrsRnv.cjs';
41
43
  import '@particle-academy/fancy-sheets';
42
44
  import '@particle-academy/fancy-slides';
43
- import '@particle-academy/fancy-doc-commons';
44
45
 
45
46
  /**
46
47
  * One interactive element the agent can act on, addressed by a STABLE handle
@@ -159,6 +160,46 @@ type NavigationBridgeOptions = {
159
160
  */
160
161
  declare function registerNavigationBridge(host: ToolHost, options: NavigationBridgeOptions): Bridge;
161
162
 
163
+ /**
164
+ * Reserved node type for a literal string child. Must match fancy-screens'
165
+ * `TEXT_NODE_TYPE`; duplicated rather than imported to keep this bridge free of
166
+ * a fancy-screens dependency.
167
+ */
168
+ declare const SCREEN_TEXT_NODE_TYPE = "#text";
169
+ /** A screen document node — a `DocNode` plus the minted-id flag. */
170
+ interface ScreenDocNode extends DocNode {
171
+ /**
172
+ * True when fancy-screens minted this id because the author supplied none.
173
+ * A synthetic id is derived from position, so it is not a durable handle.
174
+ */
175
+ synthetic?: boolean;
176
+ }
177
+ type ScreenDocOp = TreeOp<ScreenDocNode>;
178
+ interface ScreenDocBridgeOptions {
179
+ adapter: DocAdapter<ScreenDocNode>;
180
+ /**
181
+ * Tool-name prefix. Default `"screen"` → `screen_add`, `screen_set_text`, …
182
+ *
183
+ * Tool names are global, so a host wiring more than one doc-driven screen at
184
+ * once must give each a distinct prefix (`"screen_checkout"`).
185
+ */
186
+ surface?: string;
187
+ agent?: {
188
+ id: string;
189
+ name?: string;
190
+ color?: string;
191
+ };
192
+ /** Auto-apply vs. confirm per op (trust-but-verify). Default: auto. */
193
+ stagePolicy?: StagePolicy<ScreenDocOp>;
194
+ onPending?: (staged: {
195
+ id: string;
196
+ op: ScreenDocOp;
197
+ label: string;
198
+ }) => void;
199
+ }
200
+ /** Register the screen-content bridge (prefix `screen_`) over a screen's `DocTree`. */
201
+ declare function registerScreenDocBridge(host: ToolHost, options: ScreenDocBridgeOptions): Bridge;
202
+
162
203
  /** A thing the human did, surfaced so the connected agent stays aware. */
163
204
  type CoBrowseUserEvent = {
164
205
  kind: "navigation";
@@ -525,4 +566,4 @@ type SimulateUsersButtonProps = {
525
566
  */
526
567
  declare function SimulateUsersButton({ endpoint, count, label, csrfToken, onTriggered, onError, className, style, }: SimulateUsersButtonProps): react.JSX.Element;
527
568
 
528
- export { type AgentActivity, AgentActivityHighlight, type AgentActivityHighlightProps, AgentCursor, type AgentCursorProps, AgentPanel, type AgentPanelProps, Bridge, BridgedForm, type BridgedFormProps, CoBrowseCursorLayer, type CoBrowseCursorLayerProps, CoBrowsePresence, type CoBrowsePresenceProps, type CoBrowseSession, type CoBrowseUserEvent, FormFieldDescriptor, MicroMcpServer, type NavigationBridgeAdapter, type NavigationBridgeOptions, type NavigationConfirmRequest, type PageAction, type PageSnapshot, RelayState, ScreensActivityBridge, type ScreensActivityBridgeProps, SessionDescriptor, ShareControls, type ShareControlsProps, SimulateUsersButton, type SimulateUsersButtonProps, ToolHost, type UseCoBrowseSessionOptions, buildAgentPrompt, registerNavigationBridge, useCoBrowseSession };
569
+ export { type AgentActivity, AgentActivityHighlight, type AgentActivityHighlightProps, AgentCursor, type AgentCursorProps, AgentPanel, type AgentPanelProps, Bridge, BridgedForm, type BridgedFormProps, CoBrowseCursorLayer, type CoBrowseCursorLayerProps, CoBrowsePresence, type CoBrowsePresenceProps, type CoBrowseSession, type CoBrowseUserEvent, DocAdapter, FormFieldDescriptor, MicroMcpServer, type NavigationBridgeAdapter, type NavigationBridgeOptions, type NavigationConfirmRequest, type PageAction, type PageSnapshot, RelayState, SCREEN_TEXT_NODE_TYPE, type ScreenDocBridgeOptions, type ScreenDocNode, type ScreenDocOp, ScreensActivityBridge, type ScreensActivityBridgeProps, SessionDescriptor, ShareControls, type ShareControlsProps, SimulateUsersButton, type SimulateUsersButtonProps, ToolHost, type UseCoBrowseSessionOptions, buildAgentPrompt, registerNavigationBridge, registerScreenDocBridge, useCoBrowseSession };
package/dist/index.d.ts CHANGED
@@ -24,8 +24,10 @@ export { TerminalBridge, TerminalBridgeAdapter, TerminalBridgeOptions, TerminalR
24
24
  export { CatalogBridgeAdapter, CatalogBridgeOptions, CatalogCheckoutArgs, CatalogPrice, CatalogProduct, registerCatalogBridge } from './bridges/catalog.js';
25
25
  export { FeatureDefinition, FeatureGrant, FeaturesBridgeAdapter, FeaturesBridgeOptions, registerFeaturesBridge } from './bridges/features.js';
26
26
  export { PASSKEY_BRIDGE_TOOLS, PasskeyBridgeAdapter, PasskeyBridgeOptions, PasskeyProposal, PasskeySummaryLike, PasskeySupport, PasskeySurfaceState, registerPasskeyBridge } from './bridges/passkeys.js';
27
- export { DocAdapter, DocBridgeOptions, DocOpTool, registerDocBridge } from './bridges/doc.js';
27
+ import { DocAdapter } from './bridges/doc.js';
28
+ export { DocBridgeOptions, DocOpTool, registerDocBridge } from './bridges/doc.js';
28
29
  export { CmsBridgeOptions, CmsOp, cmsReducer, registerCmsBridge } from './bridges/cms.js';
30
+ import { DocNode, StagePolicy, TreeOp } from '@particle-academy/fancy-doc-commons';
29
31
  import { RelayState } from './sharing/index.js';
30
32
  export { SseRelayOptions, SseRelayTransport, attachSseRelay } from './sharing/index.js';
31
33
  import { S as SessionDescriptor } from './token-BZ8doMam.js';
@@ -40,7 +42,6 @@ export { CLAUDE_CONNECTORS_URL, CONNECTOR_GLYPHS, CONNECTOR_TARGETS, ClaudeMark,
40
42
  export { D as DEFAULT_MCPB_ENTRY_POINT, b as MCPB_MANIFEST_VERSION, c as MCPB_MIN_NODE, M as McpbManifestInput, a as McpbTool, d as buildMcpbManifest, e as buildMcpbProxyStub } from './mcpb-BXOrsRnv.js';
41
43
  import '@particle-academy/fancy-sheets';
42
44
  import '@particle-academy/fancy-slides';
43
- import '@particle-academy/fancy-doc-commons';
44
45
 
45
46
  /**
46
47
  * One interactive element the agent can act on, addressed by a STABLE handle
@@ -159,6 +160,46 @@ type NavigationBridgeOptions = {
159
160
  */
160
161
  declare function registerNavigationBridge(host: ToolHost, options: NavigationBridgeOptions): Bridge;
161
162
 
163
+ /**
164
+ * Reserved node type for a literal string child. Must match fancy-screens'
165
+ * `TEXT_NODE_TYPE`; duplicated rather than imported to keep this bridge free of
166
+ * a fancy-screens dependency.
167
+ */
168
+ declare const SCREEN_TEXT_NODE_TYPE = "#text";
169
+ /** A screen document node — a `DocNode` plus the minted-id flag. */
170
+ interface ScreenDocNode extends DocNode {
171
+ /**
172
+ * True when fancy-screens minted this id because the author supplied none.
173
+ * A synthetic id is derived from position, so it is not a durable handle.
174
+ */
175
+ synthetic?: boolean;
176
+ }
177
+ type ScreenDocOp = TreeOp<ScreenDocNode>;
178
+ interface ScreenDocBridgeOptions {
179
+ adapter: DocAdapter<ScreenDocNode>;
180
+ /**
181
+ * Tool-name prefix. Default `"screen"` → `screen_add`, `screen_set_text`, …
182
+ *
183
+ * Tool names are global, so a host wiring more than one doc-driven screen at
184
+ * once must give each a distinct prefix (`"screen_checkout"`).
185
+ */
186
+ surface?: string;
187
+ agent?: {
188
+ id: string;
189
+ name?: string;
190
+ color?: string;
191
+ };
192
+ /** Auto-apply vs. confirm per op (trust-but-verify). Default: auto. */
193
+ stagePolicy?: StagePolicy<ScreenDocOp>;
194
+ onPending?: (staged: {
195
+ id: string;
196
+ op: ScreenDocOp;
197
+ label: string;
198
+ }) => void;
199
+ }
200
+ /** Register the screen-content bridge (prefix `screen_`) over a screen's `DocTree`. */
201
+ declare function registerScreenDocBridge(host: ToolHost, options: ScreenDocBridgeOptions): Bridge;
202
+
162
203
  /** A thing the human did, surfaced so the connected agent stays aware. */
163
204
  type CoBrowseUserEvent = {
164
205
  kind: "navigation";
@@ -525,4 +566,4 @@ type SimulateUsersButtonProps = {
525
566
  */
526
567
  declare function SimulateUsersButton({ endpoint, count, label, csrfToken, onTriggered, onError, className, style, }: SimulateUsersButtonProps): react.JSX.Element;
527
568
 
528
- export { type AgentActivity, AgentActivityHighlight, type AgentActivityHighlightProps, AgentCursor, type AgentCursorProps, AgentPanel, type AgentPanelProps, Bridge, BridgedForm, type BridgedFormProps, CoBrowseCursorLayer, type CoBrowseCursorLayerProps, CoBrowsePresence, type CoBrowsePresenceProps, type CoBrowseSession, type CoBrowseUserEvent, FormFieldDescriptor, MicroMcpServer, type NavigationBridgeAdapter, type NavigationBridgeOptions, type NavigationConfirmRequest, type PageAction, type PageSnapshot, RelayState, ScreensActivityBridge, type ScreensActivityBridgeProps, SessionDescriptor, ShareControls, type ShareControlsProps, SimulateUsersButton, type SimulateUsersButtonProps, ToolHost, type UseCoBrowseSessionOptions, buildAgentPrompt, registerNavigationBridge, useCoBrowseSession };
569
+ export { type AgentActivity, AgentActivityHighlight, type AgentActivityHighlightProps, AgentCursor, type AgentCursorProps, AgentPanel, type AgentPanelProps, Bridge, BridgedForm, type BridgedFormProps, CoBrowseCursorLayer, type CoBrowseCursorLayerProps, CoBrowsePresence, type CoBrowsePresenceProps, type CoBrowseSession, type CoBrowseUserEvent, DocAdapter, FormFieldDescriptor, MicroMcpServer, type NavigationBridgeAdapter, type NavigationBridgeOptions, type NavigationConfirmRequest, type PageAction, type PageSnapshot, RelayState, SCREEN_TEXT_NODE_TYPE, type ScreenDocBridgeOptions, type ScreenDocNode, type ScreenDocOp, ScreensActivityBridge, type ScreensActivityBridgeProps, SessionDescriptor, ShareControls, type ShareControlsProps, SimulateUsersButton, type SimulateUsersButtonProps, ToolHost, type UseCoBrowseSessionOptions, buildAgentPrompt, registerNavigationBridge, registerScreenDocBridge, useCoBrowseSession };
package/dist/index.js CHANGED
@@ -12,8 +12,9 @@ export { useUndoStack } from './chunk-BT7HM5I6.js';
12
12
  export { registerCatalogBridge } from './chunk-OAFJ53X3.js';
13
13
  export { registerFeaturesBridge } from './chunk-ZNGTC4CO.js';
14
14
  export { PASSKEY_BRIDGE_TOOLS, registerPasskeyBridge } from './chunk-7THGQUX3.js';
15
- export { cmsReducer, registerCmsBridge } from './chunk-DKSR4R4O.js';
16
- export { registerDocBridge } from './chunk-LQZKRBWR.js';
15
+ export { cmsReducer, registerCmsBridge } from './chunk-JJUABMAP.js';
16
+ import { registerDocBridge } from './chunk-XY2TDE6E.js';
17
+ export { registerDocBridge } from './chunk-XY2TDE6E.js';
17
18
  export { registerTuiBridge } from './chunk-MFMBR6LN.js';
18
19
  import { useAgentActivity } from './chunk-UCKJAUBY.js';
19
20
  export { useAgentActivity, useAgentActivityForScreen } from './chunk-UCKJAUBY.js';
@@ -39,8 +40,9 @@ import { wrapToolWithActivity } from './chunk-2VENWGLZ.js';
39
40
  export { wrapToolWithActivity } from './chunk-2VENWGLZ.js';
40
41
  import { emitActivity, onActivity } from './chunk-C3TYI5TJ.js';
41
42
  export { emitActivity, onActivity, readActivityHistory, resetActivityRegistry } from './chunk-C3TYI5TJ.js';
42
- import { MicroMcpServer, textResult, errorResult } from './chunk-DF3PLL2E.js';
43
+ import { textResult, MicroMcpServer, errorResult } from './chunk-DF3PLL2E.js';
43
44
  export { MCP_PROTOCOL_VERSION, MicroMcpServer, ToolRegistry, errorResult, rpcError, textResult } from './chunk-DF3PLL2E.js';
45
+ import { childrenOf, appendOrder } from '@particle-academy/fancy-doc-commons';
44
46
  import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
45
47
  import { jsx, jsxs } from 'react/jsx-runtime';
46
48
  import { createPortal } from 'react-dom';
@@ -308,6 +310,90 @@ function registerNavigationBridge(host, options) {
308
310
  }
309
311
  };
310
312
  }
313
+ var SCREEN_TEXT_NODE_TYPE = "#text";
314
+ function registerScreenDocBridge(host, options) {
315
+ const { adapter } = options;
316
+ const surface = options.surface ?? "screen";
317
+ const setText = {
318
+ verb: "set_text",
319
+ description: "Replace the literal text of an element node \u2014 the natural way to change a label, heading or paragraph. Pass the ELEMENT's id, not the text node's.",
320
+ properties: {
321
+ id: { type: "string", description: "Id of the element whose text to set." },
322
+ text: { type: "string" }
323
+ },
324
+ required: ["id", "text"],
325
+ build: (args, tree) => {
326
+ const id = String(args.id);
327
+ const node = tree.nodes[id];
328
+ if (!node) return { error: `No node ${id}` };
329
+ if (node.type === SCREEN_TEXT_NODE_TYPE) {
330
+ return { t: "set_props", id, patch: { value: String(args.text) } };
331
+ }
332
+ const texts = childrenOf(tree, id).filter((c) => c.type === SCREEN_TEXT_NODE_TYPE);
333
+ if (texts.length === 1) {
334
+ return { t: "set_props", id: texts[0].id, patch: { value: String(args.text) } };
335
+ }
336
+ if (texts.length === 0) {
337
+ return {
338
+ t: "insert",
339
+ node: {
340
+ id: `${id}-text`,
341
+ type: SCREEN_TEXT_NODE_TYPE,
342
+ parent: id,
343
+ order: appendOrder(tree, id),
344
+ props: { value: String(args.text) }
345
+ }
346
+ };
347
+ }
348
+ return {
349
+ error: `Node ${id} has ${texts.length} text children (${texts.map((t) => t.id).join(", ")}) \u2014 set_text on the one you mean`
350
+ };
351
+ },
352
+ targetId: (args) => String(args.id)
353
+ };
354
+ const bridge = registerDocBridge(host, {
355
+ adapter,
356
+ surface,
357
+ agent: options.agent,
358
+ stagePolicy: options.stagePolicy,
359
+ onPending: options.onPending,
360
+ // Anything the AGENT adds is authored by definition — it chose or was given
361
+ // the id — so it must not inherit the synthetic flag from its neighbours.
362
+ makeNode: ({ id, type, parent, order }, props) => ({ id, type, parent, order, props }),
363
+ describeNode: (n) => ({
364
+ id: n.id,
365
+ type: n.type,
366
+ parent: n.parent,
367
+ ...n.synthetic ? { synthetic: true } : {},
368
+ ...n.type === SCREEN_TEXT_NODE_TYPE ? { text: String(n.props?.value ?? "") } : { props: Object.keys(n.props ?? {}) }
369
+ }),
370
+ opTools: [setText]
371
+ });
372
+ const disposeAddressable = host.registerTool(
373
+ {
374
+ name: `${surface}_addressable`,
375
+ description: "List the node ids that are safe to remember and use later. Ids NOT listed here were minted from a node's position: they resolve today and silently point at a different node once a sibling is inserted above them. Address those in the same turn you read them, and never store one.",
376
+ inputSchema: { type: "object", properties: {}, required: [], additionalProperties: false }
377
+ },
378
+ (async () => {
379
+ const nodes = Object.values(adapter.get().nodes);
380
+ const authored = nodes.filter((n) => !n.synthetic).map((n) => ({ id: n.id, type: n.type }));
381
+ const syntheticCount = nodes.length - authored.length;
382
+ return textResult(
383
+ authored.length ? `${authored.length} addressable, ${syntheticCount} positional` : `no addressable ids \u2014 all ${syntheticCount} nodes are positional`,
384
+ { addressable: authored, syntheticCount }
385
+ );
386
+ })
387
+ );
388
+ return {
389
+ id: surface,
390
+ title: "Screen content",
391
+ dispose: () => {
392
+ disposeAddressable();
393
+ bridge.dispose();
394
+ }
395
+ };
396
+ }
311
397
  var DEFAULT_AGENT2 = { id: "agent", name: "Agent", color: "#a855f7" };
312
398
  var USER = { id: "human", name: "You" };
313
399
  function useCoBrowseSession(options) {
@@ -702,6 +788,6 @@ function SimulateUsersButton({
702
788
  );
703
789
  }
704
790
 
705
- export { BridgedForm, CoBrowseCursorLayer, CoBrowsePresence, ScreensActivityBridge, SimulateUsersButton, registerNavigationBridge, useCoBrowseSession };
791
+ export { BridgedForm, CoBrowseCursorLayer, CoBrowsePresence, SCREEN_TEXT_NODE_TYPE, ScreensActivityBridge, SimulateUsersButton, registerNavigationBridge, registerScreenDocBridge, useCoBrowseSession };
706
792
  //# sourceMappingURL=index.js.map
707
793
  //# sourceMappingURL=index.js.map