@haklex/rich-agent-core 0.39.6 → 0.39.7
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/document-tools.d.ts.map +1 -1
- package/dist/index.mjs +32 -6
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-tools.d.ts","sourceRoot":"","sources":["../src/document-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,sBAAsB,EAA0B,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"document-tools.d.ts","sourceRoot":"","sources":["../src/document-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,sBAAsB,EAA0B,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA0C9C,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,cAAc,EAAE,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,eAAe,EAAE,CAmMnB"}
|
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,33 @@ function extractText(node) {
|
|
|
15
15
|
if (n.children) return n.children.map(extractText).join("");
|
|
16
16
|
return "";
|
|
17
17
|
}
|
|
18
|
+
var STAGED_NOTE = "Staged for user review; the live document changes only after the user accepts. search_document already reflects staged edits — do not re-run the same edit to \"make it stick\".";
|
|
19
|
+
function stagedBlocks(snapshot, operations) {
|
|
20
|
+
let blocks = snapshot.blockIds.map((blockId) => ({
|
|
21
|
+
blockId,
|
|
22
|
+
node: snapshot.getBlock(blockId)
|
|
23
|
+
}));
|
|
24
|
+
let inserted = 0;
|
|
25
|
+
for (const op of operations) if (op.op === "replace") blocks = blocks.map((b) => b.blockId === op.blockId ? {
|
|
26
|
+
...b,
|
|
27
|
+
node: op.node
|
|
28
|
+
} : b);
|
|
29
|
+
else if (op.op === "delete") blocks = blocks.filter((b) => b.blockId !== op.blockId);
|
|
30
|
+
else {
|
|
31
|
+
const staged = {
|
|
32
|
+
blockId: `staged-${++inserted}`,
|
|
33
|
+
node: op.node
|
|
34
|
+
};
|
|
35
|
+
if (op.position.type === "root") blocks.splice(op.position.index ?? blocks.length, 0, staged);
|
|
36
|
+
else {
|
|
37
|
+
const anchor = op.position.blockId;
|
|
38
|
+
const idx = blocks.findIndex((b) => b.blockId === anchor);
|
|
39
|
+
if (idx === -1) blocks.push(staged);
|
|
40
|
+
else blocks.splice(op.position.type === "after" ? idx + 1 : idx, 0, staged);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return blocks;
|
|
44
|
+
}
|
|
18
45
|
function createDocumentTools(snapshot, operations, options) {
|
|
19
46
|
const registry = resolveLitexmlRegistry(options);
|
|
20
47
|
return [
|
|
@@ -100,7 +127,7 @@ function createDocumentTools(snapshot, operations, options) {
|
|
|
100
127
|
}
|
|
101
128
|
return {
|
|
102
129
|
ok: true,
|
|
103
|
-
content: `
|
|
130
|
+
content: `Staged insert of ${nodes.length} node(s) ${position.type} block "${position.blockId ?? "root"}". ${STAGED_NOTE}`
|
|
104
131
|
};
|
|
105
132
|
}
|
|
106
133
|
},
|
|
@@ -180,7 +207,7 @@ function createDocumentTools(snapshot, operations, options) {
|
|
|
180
207
|
});
|
|
181
208
|
return {
|
|
182
209
|
ok: true,
|
|
183
|
-
content: `
|
|
210
|
+
content: `Staged replacement of block "${blockId}" (${nodes.length} node(s)). ${STAGED_NOTE}`
|
|
184
211
|
};
|
|
185
212
|
}
|
|
186
213
|
},
|
|
@@ -212,13 +239,13 @@ function createDocumentTools(snapshot, operations, options) {
|
|
|
212
239
|
});
|
|
213
240
|
return {
|
|
214
241
|
ok: true,
|
|
215
|
-
content: `
|
|
242
|
+
content: `Staged deletion of block "${blockId}". ${STAGED_NOTE}`
|
|
216
243
|
};
|
|
217
244
|
}
|
|
218
245
|
},
|
|
219
246
|
{
|
|
220
247
|
name: "search_document",
|
|
221
|
-
description: "Search for blocks in the document by text content or block type",
|
|
248
|
+
description: "Search for blocks in the document by text content or block type. Results include edits staged in this session that the user has not accepted yet.",
|
|
222
249
|
parameters: {
|
|
223
250
|
type: "object",
|
|
224
251
|
properties: {
|
|
@@ -237,8 +264,7 @@ function createDocumentTools(snapshot, operations, options) {
|
|
|
237
264
|
execute: async (params) => {
|
|
238
265
|
const { query, blockType } = params;
|
|
239
266
|
const matches = [];
|
|
240
|
-
for (const blockId of snapshot
|
|
241
|
-
const block = snapshot.getBlock(blockId);
|
|
267
|
+
for (const { blockId, node: block } of stagedBlocks(snapshot, operations)) {
|
|
242
268
|
const nodeType = block.type ?? "unknown";
|
|
243
269
|
if (blockType && nodeType !== blockType) continue;
|
|
244
270
|
const text = extractText(block);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-agent-core",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.7",
|
|
4
4
|
"description": "Headless AI agent protocol, diff engine, and store for Lexical editor",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"nanoid": "^6.0.1",
|
|
24
24
|
"zustand": "^5.0.15",
|
|
25
|
-
"@haklex/rich-litexml": "0.39.
|
|
25
|
+
"@haklex/rich-litexml": "0.39.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"lexical": "^0.49.0",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"unplugin-dts": "^1.0.3",
|
|
31
31
|
"vite": "^8.2.2",
|
|
32
32
|
"vitest": "^4.1.11",
|
|
33
|
-
"@haklex/rich-editor": "0.39.
|
|
33
|
+
"@haklex/rich-editor": "0.39.7"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"lexical": "^0.49.0",
|
|
37
|
-
"@haklex/rich-editor": "^0.39.
|
|
37
|
+
"@haklex/rich-editor": "^0.39.7"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|