@particle-academy/agent-integrations 0.26.0 → 0.27.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/bridges/artboard.d.cts +3 -3
- package/dist/bridges/artboard.d.ts +3 -3
- package/dist/bridges/catalog.d.cts +3 -3
- package/dist/bridges/catalog.d.ts +3 -3
- package/dist/bridges/charts.d.cts +3 -3
- package/dist/bridges/charts.d.ts +3 -3
- package/dist/bridges/cms.d.cts +50 -0
- package/dist/bridges/cms.d.ts +50 -0
- package/dist/bridges/code.d.cts +3 -3
- package/dist/bridges/code.d.ts +3 -3
- package/dist/bridges/doc.d.cts +68 -0
- package/dist/bridges/doc.d.ts +68 -0
- package/dist/bridges/features.d.cts +3 -3
- package/dist/bridges/features.d.ts +3 -3
- package/dist/bridges/files.d.cts +3 -3
- package/dist/bridges/files.d.ts +3 -3
- package/dist/bridges/flow.d.cts +3 -3
- package/dist/bridges/flow.d.ts +3 -3
- package/dist/bridges/forms.d.cts +3 -3
- package/dist/bridges/forms.d.ts +3 -3
- package/dist/bridges/map.d.cts +3 -3
- package/dist/bridges/map.d.ts +3 -3
- package/dist/bridges/scene.d.cts +3 -3
- package/dist/bridges/scene.d.ts +3 -3
- package/dist/bridges/screens.d.cts +3 -3
- package/dist/bridges/screens.d.ts +3 -3
- package/dist/bridges/sheets.d.cts +3 -3
- package/dist/bridges/sheets.d.ts +3 -3
- package/dist/bridges/slides.d.cts +3 -3
- package/dist/bridges/slides.d.ts +3 -3
- package/dist/bridges/terminal.d.cts +3 -3
- package/dist/bridges/terminal.d.ts +3 -3
- package/dist/bridges/whiteboard.d.cts +3 -3
- package/dist/bridges/whiteboard.d.ts +3 -3
- package/dist/bridges-artboard.js +1 -1
- package/dist/bridges-catalog.js +2 -2
- package/dist/bridges-charts.js +2 -2
- package/dist/bridges-cms.cjs +437 -0
- package/dist/bridges-cms.cjs.map +1 -0
- package/dist/bridges-cms.js +8 -0
- package/dist/bridges-cms.js.map +1 -0
- package/dist/bridges-code.js +2 -2
- package/dist/bridges-doc.cjs +364 -0
- package/dist/bridges-doc.cjs.map +1 -0
- package/dist/bridges-doc.js +7 -0
- package/dist/bridges-doc.js.map +1 -0
- package/dist/bridges-features.js +2 -2
- package/dist/bridges-files.js +2 -2
- package/dist/bridges-flow.js +1 -1
- package/dist/bridges-forms.js +2 -2
- package/dist/bridges-map.js +2 -2
- package/dist/bridges-scene.js +2 -2
- package/dist/bridges-screens.js +2 -2
- package/dist/bridges-sheets.js +2 -2
- package/dist/bridges-slides.js +2 -2
- package/dist/bridges-terminal.js +2 -2
- package/dist/bridges-whiteboard.js +2 -2
- package/dist/{chunk-YMX7G3XM.js → chunk-66WOHZZJ.js} +3 -3
- package/dist/{chunk-YMX7G3XM.js.map → chunk-66WOHZZJ.js.map} +1 -1
- package/dist/chunk-A57CRGEK.js +79 -0
- package/dist/chunk-A57CRGEK.js.map +1 -0
- package/dist/{chunk-XQZGB4FP.js → chunk-AAD3Z5E7.js} +3 -3
- package/dist/{chunk-XQZGB4FP.js.map → chunk-AAD3Z5E7.js.map} +1 -1
- package/dist/{chunk-3QJSOS7G.js → chunk-AAMQOXZC.js} +3 -3
- package/dist/{chunk-3QJSOS7G.js.map → chunk-AAMQOXZC.js.map} +1 -1
- package/dist/{chunk-EP3G4LYW.js → chunk-AROVENCE.js} +3 -3
- package/dist/{chunk-EP3G4LYW.js.map → chunk-AROVENCE.js.map} +1 -1
- package/dist/chunk-FF5F526J.js +245 -0
- package/dist/chunk-FF5F526J.js.map +1 -0
- package/dist/{chunk-57KAMBAR.js → chunk-HWVVS6HE.js} +3 -3
- package/dist/{chunk-57KAMBAR.js.map → chunk-HWVVS6HE.js.map} +1 -1
- package/dist/{chunk-QDF37J3V.js → chunk-NN3ELTVO.js} +3 -3
- package/dist/{chunk-QDF37J3V.js.map → chunk-NN3ELTVO.js.map} +1 -1
- package/dist/{chunk-775LJJTJ.js → chunk-PCW2EK5G.js} +3 -3
- package/dist/{chunk-775LJJTJ.js.map → chunk-PCW2EK5G.js.map} +1 -1
- package/dist/{chunk-46H4C5AP.js → chunk-QDD4WHIV.js} +3 -3
- package/dist/{chunk-46H4C5AP.js.map → chunk-QDD4WHIV.js.map} +1 -1
- package/dist/{chunk-V5BXBX7U.js → chunk-QRDVJW6Q.js} +3 -3
- package/dist/{chunk-V5BXBX7U.js.map → chunk-QRDVJW6Q.js.map} +1 -1
- package/dist/{chunk-267JS64O.js → chunk-VFKO2VUR.js} +3 -3
- package/dist/{chunk-267JS64O.js.map → chunk-VFKO2VUR.js.map} +1 -1
- package/dist/{chunk-CLFDQ2BW.js → chunk-XMMCSQ4I.js} +3 -3
- package/dist/{chunk-CLFDQ2BW.js.map → chunk-XMMCSQ4I.js.map} +1 -1
- package/dist/{chunk-K3S6WSHZ.js → chunk-YGD2VTUM.js} +3 -3
- package/dist/{chunk-K3S6WSHZ.js.map → chunk-YGD2VTUM.js.map} +1 -1
- package/dist/{chunk-NKRSLCS7.js → chunk-ZX6UQURN.js} +3 -3
- package/dist/{chunk-NKRSLCS7.js.map → chunk-ZX6UQURN.js.map} +1 -1
- package/dist/components-shared-whiteboard.js +2 -2
- package/dist/index.cjs +314 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +20 -18
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.cts +5 -5
- package/dist/mcp/index.d.ts +5 -5
- package/dist/presence/index.d.cts +1 -1
- package/dist/presence/index.d.ts +1 -1
- package/dist/{server-BsSwfemr.d.cts → server-Dr3j48CU.d.cts} +2 -2
- package/dist/{server-Du3-IGqM.d.ts → server-FFZpYPyM.d.ts} +2 -2
- package/dist/sharing/index.d.cts +3 -3
- package/dist/sharing/index.d.ts +3 -3
- package/dist/sheets-adapter.d.cts +3 -3
- package/dist/sheets-adapter.d.ts +3 -3
- package/dist/{tool-host-C8JMMGYq.d.ts → tool-host-C_Vh17J_.d.ts} +1 -1
- package/dist/{tool-host-BQuUygLF.d.cts → tool-host-IDecPrF1.d.cts} +1 -1
- package/dist/{types-CCSBGW9T.d.cts → types-B0rmWyoR.d.cts} +1 -1
- package/dist/{types-aOQLTW0E.d.cts → types-BDI_g5UG.d.cts} +1 -1
- package/dist/{types-aOQLTW0E.d.ts → types-BDI_g5UG.d.ts} +1 -1
- package/dist/{types-DIVNcIQO.d.ts → types-CBoQhR8L.d.ts} +1 -1
- package/dist/undo/index.d.cts +2 -2
- package/dist/undo/index.d.ts +2 -2
- package/package.json +23 -2
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var fancyAutoCommon = require('@particle-academy/fancy-auto-common');
|
|
4
4
|
var react = require('react');
|
|
5
|
+
var fancyDocCommons = require('@particle-academy/fancy-doc-commons');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
var reactDom = require('react-dom');
|
|
7
8
|
|
|
@@ -3486,6 +3487,314 @@ function registerFeaturesBridge(host, options) {
|
|
|
3486
3487
|
}
|
|
3487
3488
|
};
|
|
3488
3489
|
}
|
|
3490
|
+
var DEFAULT_AGENT14 = { id: "agent", name: "Agent", color: "#a855f7" };
|
|
3491
|
+
function registerDocBridge(host, options) {
|
|
3492
|
+
const { adapter, surface } = options;
|
|
3493
|
+
const agent = { ...DEFAULT_AGENT14, ...options.agent ?? {} };
|
|
3494
|
+
const reducer = options.reducer ?? fancyDocCommons.treeReducer();
|
|
3495
|
+
const stage = options.stagePolicy ?? fancyDocCommons.autoApply;
|
|
3496
|
+
const makeNode = options.makeNode ?? (({ id, type, parent, order }, props) => ({ id, type, parent, order, props }));
|
|
3497
|
+
const describeNode = options.describeNode ?? ((n) => ({ id: n.id, type: n.type, parent: n.parent, props: Object.keys(n.props ?? {}) }));
|
|
3498
|
+
const disposers = [];
|
|
3499
|
+
ensureUndoToolsRegistered(host, { defaultAgentId: agent.id });
|
|
3500
|
+
let idSeq = 0;
|
|
3501
|
+
const mintId = () => adapter.newId?.() ?? `${surface}-${idSeq += 1}`;
|
|
3502
|
+
const target = (elementId) => ({ kind: surface, screenId: adapter.screenId, elementId });
|
|
3503
|
+
const pending = /* @__PURE__ */ new Map();
|
|
3504
|
+
function commit(op, label, targetId) {
|
|
3505
|
+
const prev = adapter.get();
|
|
3506
|
+
const next = reducer.reduce(prev, op);
|
|
3507
|
+
adapter.set(next);
|
|
3508
|
+
fancyAutoCommon.pushUndoEntry(agent.id, {
|
|
3509
|
+
timestamp: Date.now(),
|
|
3510
|
+
bridgeId: surface,
|
|
3511
|
+
action: label,
|
|
3512
|
+
label,
|
|
3513
|
+
undo: () => adapter.set(prev),
|
|
3514
|
+
redo: () => adapter.set(next)
|
|
3515
|
+
});
|
|
3516
|
+
return { ok: true, id: targetId };
|
|
3517
|
+
}
|
|
3518
|
+
function submit(op, label, targetId) {
|
|
3519
|
+
if (stage(op) === "confirm") {
|
|
3520
|
+
const id = `${surface}-pending-${idSeq += 1}`;
|
|
3521
|
+
pending.set(id, { op, label, targetId });
|
|
3522
|
+
options.onPending?.({ id, op, label });
|
|
3523
|
+
return { staged: true, id };
|
|
3524
|
+
}
|
|
3525
|
+
commit(op, label, targetId);
|
|
3526
|
+
return { staged: false, id: targetId };
|
|
3527
|
+
}
|
|
3528
|
+
const reg = (verb, description, properties, required, handler, isMutation, resolveTarget) => {
|
|
3529
|
+
const name = `${surface}_${verb}`;
|
|
3530
|
+
const wrapped = async (args) => {
|
|
3531
|
+
try {
|
|
3532
|
+
const { _text, ...structured } = await handler(args);
|
|
3533
|
+
return textResult(typeof _text === "string" ? _text : name, structured);
|
|
3534
|
+
} catch (e) {
|
|
3535
|
+
return errorResult(e instanceof Error ? e.message : String(e));
|
|
3536
|
+
}
|
|
3537
|
+
};
|
|
3538
|
+
const final = isMutation ? wrapToolWithActivity(wrapped, {
|
|
3539
|
+
toolName: name,
|
|
3540
|
+
agent,
|
|
3541
|
+
kind: surface,
|
|
3542
|
+
screenId: adapter.screenId,
|
|
3543
|
+
resolveTarget: ({ args, result }) => {
|
|
3544
|
+
if (result.structuredContent?.staged) return null;
|
|
3545
|
+
return resolveTarget?.(args, result.structuredContent ?? {}) ?? target();
|
|
3546
|
+
}
|
|
3547
|
+
}) : wrapped;
|
|
3548
|
+
disposers.push(
|
|
3549
|
+
host.registerTool(
|
|
3550
|
+
{ name, description, inputSchema: { type: "object", properties, required, additionalProperties: false } },
|
|
3551
|
+
final
|
|
3552
|
+
)
|
|
3553
|
+
);
|
|
3554
|
+
};
|
|
3555
|
+
reg(
|
|
3556
|
+
"describe",
|
|
3557
|
+
`Summarize the ${surface} document: node count, roots, and the active surface. Call before reading or writing.`,
|
|
3558
|
+
{},
|
|
3559
|
+
[],
|
|
3560
|
+
() => {
|
|
3561
|
+
const tree = adapter.get();
|
|
3562
|
+
const ids = Object.keys(tree.nodes);
|
|
3563
|
+
return { nodeCount: ids.length, roots: fancyDocCommons.childrenOf(tree, null).map((n) => n.id), _text: `${ids.length} nodes` };
|
|
3564
|
+
},
|
|
3565
|
+
false
|
|
3566
|
+
);
|
|
3567
|
+
reg(
|
|
3568
|
+
"get",
|
|
3569
|
+
`Get the whole ${surface} document tree as JSON.`,
|
|
3570
|
+
{},
|
|
3571
|
+
[],
|
|
3572
|
+
() => ({ tree: adapter.get(), _text: "full tree" }),
|
|
3573
|
+
false
|
|
3574
|
+
);
|
|
3575
|
+
reg(
|
|
3576
|
+
"list",
|
|
3577
|
+
"List nodes (optionally the children of `parent`), in order.",
|
|
3578
|
+
{ parent: { type: ["string", "null"], description: "Parent id, or null/omitted for roots." } },
|
|
3579
|
+
[],
|
|
3580
|
+
(args) => {
|
|
3581
|
+
const tree = adapter.get();
|
|
3582
|
+
const parent = typeof args.parent === "string" ? args.parent : null;
|
|
3583
|
+
return { nodes: fancyDocCommons.childrenOf(tree, parent).map(describeNode), _text: `children of ${parent ?? "root"}` };
|
|
3584
|
+
},
|
|
3585
|
+
false
|
|
3586
|
+
);
|
|
3587
|
+
reg(
|
|
3588
|
+
"get_node",
|
|
3589
|
+
"Get one node by id.",
|
|
3590
|
+
{ id: { type: "string" } },
|
|
3591
|
+
["id"],
|
|
3592
|
+
(args) => {
|
|
3593
|
+
const node = adapter.get().nodes[String(args.id)];
|
|
3594
|
+
if (!node) throw new Error(`No node ${args.id}`);
|
|
3595
|
+
return { node, _text: `node ${node.id}` };
|
|
3596
|
+
},
|
|
3597
|
+
false
|
|
3598
|
+
);
|
|
3599
|
+
reg(
|
|
3600
|
+
"add",
|
|
3601
|
+
"Insert a node. Returns its id. Appends under `parent` (or roots) unless `order` is given.",
|
|
3602
|
+
{
|
|
3603
|
+
type: { type: "string", description: "Node type discriminant." },
|
|
3604
|
+
parent: { type: ["string", "null"], description: "Parent id, or null for a root." },
|
|
3605
|
+
props: { type: "object", description: "JSON props bag." },
|
|
3606
|
+
order: { type: "string", description: "Fractional order key (default: append)." }
|
|
3607
|
+
},
|
|
3608
|
+
["type"],
|
|
3609
|
+
(args) => {
|
|
3610
|
+
const tree = adapter.get();
|
|
3611
|
+
const parent = typeof args.parent === "string" ? args.parent : null;
|
|
3612
|
+
const id = mintId();
|
|
3613
|
+
const order = typeof args.order === "string" ? args.order : fancyDocCommons.appendOrder(tree, parent);
|
|
3614
|
+
const props = args.props && typeof args.props === "object" ? args.props : {};
|
|
3615
|
+
const node = makeNode({ id, type: String(args.type), parent, order }, props);
|
|
3616
|
+
const res = submit({ t: "insert", node }, `add ${args.type} ${id}`, id);
|
|
3617
|
+
return { ...res, _text: res.staged ? `staged add ${id}` : `added ${id}` };
|
|
3618
|
+
},
|
|
3619
|
+
true,
|
|
3620
|
+
(_args, result) => target(result.id)
|
|
3621
|
+
);
|
|
3622
|
+
reg(
|
|
3623
|
+
"update",
|
|
3624
|
+
"Merge a props patch into a node.",
|
|
3625
|
+
{ id: { type: "string" }, patch: { type: "object" } },
|
|
3626
|
+
["id", "patch"],
|
|
3627
|
+
(args) => {
|
|
3628
|
+
const id = String(args.id);
|
|
3629
|
+
if (!adapter.get().nodes[id]) throw new Error(`No node ${id}`);
|
|
3630
|
+
const patch = args.patch && typeof args.patch === "object" ? args.patch : {};
|
|
3631
|
+
const res = submit({ t: "set_props", id, patch }, `update ${id}`, id);
|
|
3632
|
+
return { ...res, id, _text: res.staged ? `staged update ${id}` : `updated ${id}` };
|
|
3633
|
+
},
|
|
3634
|
+
true,
|
|
3635
|
+
(args) => target(String(args.id))
|
|
3636
|
+
);
|
|
3637
|
+
reg(
|
|
3638
|
+
"remove",
|
|
3639
|
+
"Remove a node and its subtree.",
|
|
3640
|
+
{ id: { type: "string" } },
|
|
3641
|
+
["id"],
|
|
3642
|
+
(args) => {
|
|
3643
|
+
const id = String(args.id);
|
|
3644
|
+
const tree = adapter.get();
|
|
3645
|
+
if (!tree.nodes[id]) throw new Error(`No node ${id}`);
|
|
3646
|
+
const count = fancyDocCommons.descendantsOf(tree, id).length + 1;
|
|
3647
|
+
const res = submit({ t: "remove", id }, `remove ${id} (${count} node${count === 1 ? "" : "s"})`, id);
|
|
3648
|
+
return { ...res, id, removed: count, _text: res.staged ? `staged remove ${id}` : `removed ${id}` };
|
|
3649
|
+
},
|
|
3650
|
+
true,
|
|
3651
|
+
(args) => target(String(args.id))
|
|
3652
|
+
);
|
|
3653
|
+
reg(
|
|
3654
|
+
"move",
|
|
3655
|
+
"Reparent + reorder a node.",
|
|
3656
|
+
{ id: { type: "string" }, parent: { type: ["string", "null"] }, order: { type: "string", description: "Fractional order key (default: append under the new parent)." } },
|
|
3657
|
+
["id"],
|
|
3658
|
+
(args) => {
|
|
3659
|
+
const id = String(args.id);
|
|
3660
|
+
const tree = adapter.get();
|
|
3661
|
+
if (!tree.nodes[id]) throw new Error(`No node ${id}`);
|
|
3662
|
+
const parent = args.parent === null ? null : typeof args.parent === "string" ? args.parent : tree.nodes[id].parent;
|
|
3663
|
+
const order = typeof args.order === "string" ? args.order : fancyDocCommons.appendOrder(tree, parent);
|
|
3664
|
+
const res = submit({ t: "move", id, parent, order }, `move ${id}`, id);
|
|
3665
|
+
return { ...res, id, _text: res.staged ? `staged move ${id}` : `moved ${id}` };
|
|
3666
|
+
},
|
|
3667
|
+
true,
|
|
3668
|
+
(args) => target(String(args.id))
|
|
3669
|
+
);
|
|
3670
|
+
for (const t of options.opTools ?? []) {
|
|
3671
|
+
reg(
|
|
3672
|
+
t.verb,
|
|
3673
|
+
t.description,
|
|
3674
|
+
t.properties,
|
|
3675
|
+
t.required,
|
|
3676
|
+
(args) => {
|
|
3677
|
+
const built = t.build(args, adapter.get());
|
|
3678
|
+
if (built && typeof built === "object" && "error" in built) throw new Error(built.error);
|
|
3679
|
+
const tid = t.targetId?.(args);
|
|
3680
|
+
const res = submit(built, `${t.verb} ${tid ?? ""}`.trim(), tid);
|
|
3681
|
+
return { ...res, id: tid, _text: res.staged ? `staged ${t.verb}` : t.verb };
|
|
3682
|
+
},
|
|
3683
|
+
true,
|
|
3684
|
+
(args) => target(t.targetId?.(args))
|
|
3685
|
+
);
|
|
3686
|
+
}
|
|
3687
|
+
reg(
|
|
3688
|
+
"confirm",
|
|
3689
|
+
"Apply a staged op by its pending id (from a staged mutation).",
|
|
3690
|
+
{ id: { type: "string" } },
|
|
3691
|
+
["id"],
|
|
3692
|
+
(args) => {
|
|
3693
|
+
const id = String(args.id);
|
|
3694
|
+
const p = pending.get(id);
|
|
3695
|
+
if (!p) throw new Error(`No pending op ${id}`);
|
|
3696
|
+
pending.delete(id);
|
|
3697
|
+
commit(p.op, p.label, p.targetId);
|
|
3698
|
+
return { ok: true, applied: p.label, id: p.targetId, _text: `applied ${p.label}` };
|
|
3699
|
+
},
|
|
3700
|
+
true,
|
|
3701
|
+
(_args, result) => target(result.id)
|
|
3702
|
+
);
|
|
3703
|
+
reg(
|
|
3704
|
+
"reject",
|
|
3705
|
+
"Discard a staged op by its pending id.",
|
|
3706
|
+
{ id: { type: "string" } },
|
|
3707
|
+
["id"],
|
|
3708
|
+
(args) => {
|
|
3709
|
+
const id = String(args.id);
|
|
3710
|
+
const p = pending.get(id);
|
|
3711
|
+
if (!p) throw new Error(`No pending op ${id}`);
|
|
3712
|
+
pending.delete(id);
|
|
3713
|
+
return { ok: true, rejected: p.label, _text: `rejected ${p.label}` };
|
|
3714
|
+
},
|
|
3715
|
+
false
|
|
3716
|
+
);
|
|
3717
|
+
return {
|
|
3718
|
+
id: surface,
|
|
3719
|
+
title: surface,
|
|
3720
|
+
dispose: () => {
|
|
3721
|
+
for (const d of disposers) d();
|
|
3722
|
+
pending.clear();
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
function cmsReducer() {
|
|
3727
|
+
const base = fancyDocCommons.treeReducer();
|
|
3728
|
+
return {
|
|
3729
|
+
reduce(doc, op) {
|
|
3730
|
+
if (op.t === "set_style") {
|
|
3731
|
+
const node = doc.nodes[op.id];
|
|
3732
|
+
if (!node) return doc;
|
|
3733
|
+
return { nodes: { ...doc.nodes, [op.id]: { ...node, style: { ...node.style, base: { ...node.style.base, ...op.patch } } } } };
|
|
3734
|
+
}
|
|
3735
|
+
if (op.t === "set_layout") {
|
|
3736
|
+
const node = doc.nodes[op.id];
|
|
3737
|
+
if (!node) return doc;
|
|
3738
|
+
return { nodes: { ...doc.nodes, [op.id]: { ...node, layout: op.layout } } };
|
|
3739
|
+
}
|
|
3740
|
+
return base.reduce(doc, op);
|
|
3741
|
+
},
|
|
3742
|
+
invert(doc, op) {
|
|
3743
|
+
if (op.t === "set_style") {
|
|
3744
|
+
const node = doc.nodes[op.id];
|
|
3745
|
+
if (!node) return [];
|
|
3746
|
+
const prev = {};
|
|
3747
|
+
for (const k in op.patch) prev[k] = node.style.base[k];
|
|
3748
|
+
return [{ t: "set_style", id: op.id, patch: prev }];
|
|
3749
|
+
}
|
|
3750
|
+
if (op.t === "set_layout") {
|
|
3751
|
+
const node = doc.nodes[op.id];
|
|
3752
|
+
if (!node) return [];
|
|
3753
|
+
return [{ t: "set_layout", id: op.id, layout: node.layout }];
|
|
3754
|
+
}
|
|
3755
|
+
return base.invert(doc, op);
|
|
3756
|
+
}
|
|
3757
|
+
};
|
|
3758
|
+
}
|
|
3759
|
+
function registerCmsBridge(host, options) {
|
|
3760
|
+
return registerDocBridge(host, {
|
|
3761
|
+
adapter: options.adapter,
|
|
3762
|
+
surface: "cms",
|
|
3763
|
+
agent: options.agent,
|
|
3764
|
+
reducer: cmsReducer(),
|
|
3765
|
+
stagePolicy: options.stagePolicy,
|
|
3766
|
+
onPending: options.onPending,
|
|
3767
|
+
// New nodes get an empty base style so they satisfy StyledNode.
|
|
3768
|
+
makeNode: ({ id, type, parent, order }, props) => ({ id, type, parent, order, props, style: { base: {} } }),
|
|
3769
|
+
describeNode: (n) => ({ id: n.id, type: n.type, parent: n.parent, layout: n.layout }),
|
|
3770
|
+
opTools: [
|
|
3771
|
+
{
|
|
3772
|
+
verb: "set_style",
|
|
3773
|
+
description: "Merge a StyleProps patch into a node's base style (color, background, padding, fontSize, gap, \u2026).",
|
|
3774
|
+
properties: { id: { type: "string" }, patch: { type: "object", description: "Partial StyleProps." } },
|
|
3775
|
+
required: ["id", "patch"],
|
|
3776
|
+
build: (args, tree) => {
|
|
3777
|
+
const id = String(args.id);
|
|
3778
|
+
if (!tree.nodes[id]) return { error: `No node ${id}` };
|
|
3779
|
+
return { t: "set_style", id, patch: args.patch && typeof args.patch === "object" ? args.patch : {} };
|
|
3780
|
+
},
|
|
3781
|
+
targetId: (args) => String(args.id)
|
|
3782
|
+
},
|
|
3783
|
+
{
|
|
3784
|
+
verb: "set_layout",
|
|
3785
|
+
description: "Set a container node's layout mode (free | stack | grid).",
|
|
3786
|
+
properties: { id: { type: "string" }, layout: { type: "string", enum: ["free", "stack", "grid"] } },
|
|
3787
|
+
required: ["id"],
|
|
3788
|
+
build: (args, tree) => {
|
|
3789
|
+
const id = String(args.id);
|
|
3790
|
+
if (!tree.nodes[id]) return { error: `No node ${id}` };
|
|
3791
|
+
return { t: "set_layout", id, layout: args.layout };
|
|
3792
|
+
},
|
|
3793
|
+
targetId: (args) => String(args.id)
|
|
3794
|
+
}
|
|
3795
|
+
]
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3489
3798
|
|
|
3490
3799
|
// src/sharing/token.ts
|
|
3491
3800
|
var TOKEN_BYTES = 24;
|
|
@@ -3681,11 +3990,11 @@ function attachSseRelay(server, options) {
|
|
|
3681
3990
|
|
|
3682
3991
|
// src/sharing/use-co-browse-session.ts
|
|
3683
3992
|
init_registry();
|
|
3684
|
-
var
|
|
3993
|
+
var DEFAULT_AGENT15 = { id: "agent", name: "Agent", color: "#a855f7" };
|
|
3685
3994
|
var USER = { id: "human", name: "You" };
|
|
3686
3995
|
function useCoBrowseSession(options) {
|
|
3687
3996
|
const { adapter, extraBridges } = options;
|
|
3688
|
-
const agent = { ...
|
|
3997
|
+
const agent = { ...DEFAULT_AGENT15, ...options.agent ?? {} };
|
|
3689
3998
|
const relayBaseUrl = options.relayBaseUrl ?? "/agent-relay";
|
|
3690
3999
|
const serverRef = react.useRef(null);
|
|
3691
4000
|
const relayRef = react.useRef(null);
|
|
@@ -4899,6 +5208,7 @@ exports.buildMcpbProxyStub = buildMcpbProxyStub;
|
|
|
4899
5208
|
exports.buildShareConfig = buildShareConfig;
|
|
4900
5209
|
exports.buildShareUrl = buildShareUrl;
|
|
4901
5210
|
exports.buildVscodeDeeplink = buildVscodeDeeplink;
|
|
5211
|
+
exports.cmsReducer = cmsReducer;
|
|
4902
5212
|
exports.connectorHref = connectorHref;
|
|
4903
5213
|
exports.createSessionDescriptor = createSessionDescriptor;
|
|
4904
5214
|
exports.describeSession = describeSession;
|
|
@@ -4909,7 +5219,9 @@ exports.mapActivityToHeuristicsEvent = mapActivityToEvent;
|
|
|
4909
5219
|
exports.readSessionFromUrl = readSessionFromUrl;
|
|
4910
5220
|
exports.registerCatalogBridge = registerCatalogBridge;
|
|
4911
5221
|
exports.registerChartsBridge = registerChartsBridge;
|
|
5222
|
+
exports.registerCmsBridge = registerCmsBridge;
|
|
4912
5223
|
exports.registerCodeBridge = registerCodeBridge;
|
|
5224
|
+
exports.registerDocBridge = registerDocBridge;
|
|
4913
5225
|
exports.registerFeaturesBridge = registerFeaturesBridge;
|
|
4914
5226
|
exports.registerFilesBridge = registerFilesBridge;
|
|
4915
5227
|
exports.registerFormBridge = registerFormBridge;
|