zcode-app-cli 3.16.2-38 → 3.16.3-40
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/LICENSES/README.md +1 -1
- package/README.md +19 -4
- package/bin/zcode.js +47 -16
- package/docs/CONFIGURATION.md +2 -1
- package/docs/CONFIGURATION.zh-CN.md +2 -1
- package/docs/THIRD_PARTY_CONTENT.md +2 -2
- package/package.json +2 -2
- package/vendor/cli-config.cjs +21 -0
- package/vendor/extraction.json +9 -4
- package/vendor/node_modules/@zcode/tui/dist/index.js +79 -22
- package/vendor/packages/documents-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/documents-plugin/dist/server.mjs +201 -152
- package/vendor/packages/documents-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/documents-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/documents-plugin/package.json +1 -1
- package/vendor/packages/node-repl-host/dist/mcp/server.js +1 -1
- package/vendor/packages/pdf-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/pdf-plugin/dist/server.mjs +201 -152
- package/vendor/packages/pdf-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/pdf-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/pdf-plugin/package.json +1 -1
- package/vendor/packages/presentations-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/presentations-plugin/dist/server.mjs +201 -152
- package/vendor/packages/presentations-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/presentations-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/presentations-plugin/package.json +1 -1
- package/vendor/packages/spreadsheets-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/spreadsheets-plugin/dist/server.mjs +201 -152
- package/vendor/packages/spreadsheets-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/spreadsheets-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/spreadsheets-plugin/package.json +1 -1
- package/vendor/zcode.cjs +1033 -1031
- package/zcode-runtime.lock.json +3 -3
|
@@ -43439,7 +43439,7 @@ var StdioServerTransport = class {
|
|
|
43439
43439
|
};
|
|
43440
43440
|
|
|
43441
43441
|
// ../office-runtime/src/profile.ts
|
|
43442
|
-
var PROFILE = { "name": "presentations", "version": "0.2.
|
|
43442
|
+
var PROFILE = { "name": "presentations", "version": "0.2.1", "title": { "en": "Presentations", "zh-CN": "\u6F14\u793A\u6587\u7A3F" }, "kinds": ["pptx"] };
|
|
43443
43443
|
|
|
43444
43444
|
// ../office-runtime/src/contract.ts
|
|
43445
43445
|
var PLUGIN_VERSION = PROFILE.version;
|
|
@@ -43653,21 +43653,12 @@ function wellFormedDeep(value) {
|
|
|
43653
43653
|
// ../office-runtime/src/app/documents.ts
|
|
43654
43654
|
var MAX_CACHED = 6;
|
|
43655
43655
|
var MAX_HANDLES = 4;
|
|
43656
|
+
var MAX_SESSIONS = 32;
|
|
43657
|
+
var DEFAULT_SESSION = "default";
|
|
43656
43658
|
function createDocumentOwner({ files, parse: parse3 }) {
|
|
43657
43659
|
const cache = /* @__PURE__ */ new Map();
|
|
43658
43660
|
const handles = /* @__PURE__ */ new Map();
|
|
43659
|
-
|
|
43660
|
-
const emptyView = () => ({
|
|
43661
|
-
path: null,
|
|
43662
|
-
kind: null,
|
|
43663
|
-
at: null,
|
|
43664
|
-
selection: null,
|
|
43665
|
-
updatedAt: 0
|
|
43666
|
-
});
|
|
43667
|
-
const views = /* @__PURE__ */ new Map();
|
|
43668
|
-
const reports = /* @__PURE__ */ new Map();
|
|
43669
|
-
let sequence = 0;
|
|
43670
|
-
let revealSeq = 0;
|
|
43661
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
43671
43662
|
async function entry(input2) {
|
|
43672
43663
|
const { path } = await files.resolve(input2);
|
|
43673
43664
|
const fingerprint = await files.fingerprint(path);
|
|
@@ -43700,83 +43691,165 @@ function createDocumentOwner({ files, parse: parse3 }) {
|
|
|
43700
43691
|
function canonical(doc, at) {
|
|
43701
43692
|
return formatLocator(doc.check(parseLocator(doc.kind, at)));
|
|
43702
43693
|
}
|
|
43703
|
-
function
|
|
43694
|
+
function createSession(id) {
|
|
43695
|
+
let current = null;
|
|
43696
|
+
let disposed = false;
|
|
43697
|
+
const emptyView = () => ({
|
|
43698
|
+
path: null,
|
|
43699
|
+
kind: null,
|
|
43700
|
+
at: null,
|
|
43701
|
+
selection: null,
|
|
43702
|
+
updatedAt: 0
|
|
43703
|
+
});
|
|
43704
|
+
const views = /* @__PURE__ */ new Map();
|
|
43705
|
+
const reports = /* @__PURE__ */ new Map();
|
|
43706
|
+
const tokens = [];
|
|
43707
|
+
let sequence = 0;
|
|
43708
|
+
let revealSeq = 0;
|
|
43709
|
+
function snapshot(reveal) {
|
|
43710
|
+
return {
|
|
43711
|
+
document: current,
|
|
43712
|
+
...reveal ? { reveal: { ...reveal, seq: ++revealSeq } } : {}
|
|
43713
|
+
};
|
|
43714
|
+
}
|
|
43704
43715
|
return {
|
|
43705
|
-
|
|
43706
|
-
|
|
43707
|
-
|
|
43708
|
-
|
|
43709
|
-
|
|
43710
|
-
|
|
43711
|
-
|
|
43712
|
-
|
|
43713
|
-
|
|
43714
|
-
|
|
43715
|
-
|
|
43716
|
-
|
|
43717
|
-
|
|
43718
|
-
|
|
43719
|
-
|
|
43720
|
-
|
|
43721
|
-
|
|
43722
|
-
|
|
43723
|
-
|
|
43724
|
-
|
|
43725
|
-
|
|
43726
|
-
|
|
43727
|
-
|
|
43728
|
-
|
|
43729
|
-
|
|
43730
|
-
|
|
43731
|
-
|
|
43732
|
-
|
|
43716
|
+
/** The key this session is stored under; also owns the session's file imports. */
|
|
43717
|
+
id,
|
|
43718
|
+
async info(path) {
|
|
43719
|
+
const { file: file2, doc } = await document(path);
|
|
43720
|
+
return describe3(file2, doc);
|
|
43721
|
+
},
|
|
43722
|
+
/** Make `path` the viewer's document, optionally revealing a location in it. */
|
|
43723
|
+
async open(path, at) {
|
|
43724
|
+
const { file: file2, doc } = await document(path);
|
|
43725
|
+
const target = at ? canonical(doc, at) : null;
|
|
43726
|
+
current = describe3(file2, doc);
|
|
43727
|
+
return snapshot(target ? { targets: [{ at: target }] } : void 0);
|
|
43728
|
+
},
|
|
43729
|
+
/** Point the user at one or more places in one document; opens it if needed. */
|
|
43730
|
+
async show(targets, note) {
|
|
43731
|
+
if (!targets.length)
|
|
43732
|
+
throw new OfficeError("invalid_anchor", "Give at least one anchor to show.");
|
|
43733
|
+
const split = targets.map((target) => ({
|
|
43734
|
+
...splitAnchor(target.anchor),
|
|
43735
|
+
quote: target.quote
|
|
43736
|
+
}));
|
|
43737
|
+
const path = split[0].path;
|
|
43738
|
+
const { path: resolved } = await files.resolve(path);
|
|
43739
|
+
for (const item of split) {
|
|
43740
|
+
if ((await files.resolve(item.path)).path !== resolved)
|
|
43741
|
+
throw new OfficeError(
|
|
43742
|
+
"invalid_anchor",
|
|
43743
|
+
"All anchors passed to show must be in the same document."
|
|
43744
|
+
);
|
|
43745
|
+
}
|
|
43746
|
+
const { file: file2, doc } = await document(resolved);
|
|
43747
|
+
const resolvedTargets = split.map((item) => ({
|
|
43748
|
+
at: item.at ? canonical(doc, item.at) : defaultAt(doc),
|
|
43749
|
+
...item.quote?.trim() ? { quote: cut(item.quote.trim(), 0, 500) } : {}
|
|
43750
|
+
}));
|
|
43751
|
+
current = describe3(file2, doc);
|
|
43752
|
+
return snapshot({
|
|
43753
|
+
targets: resolvedTargets,
|
|
43754
|
+
...note?.trim() ? { note: cut(note.trim(), 0, 500) } : {}
|
|
43755
|
+
});
|
|
43756
|
+
},
|
|
43757
|
+
async read(anchor2, cursor = 0) {
|
|
43758
|
+
const { path, at } = splitAnchor(anchor2);
|
|
43759
|
+
const { file: file2, doc } = await document(path);
|
|
43760
|
+
const locator = at ? doc.check(parseLocator(doc.kind, at)) : null;
|
|
43761
|
+
return {
|
|
43762
|
+
info: describe3(file2, doc),
|
|
43763
|
+
at: locator ? formatLocator(locator) : null,
|
|
43764
|
+
page: doc.read(locator, cursor)
|
|
43765
|
+
};
|
|
43766
|
+
},
|
|
43767
|
+
async search(path, query, limit) {
|
|
43768
|
+
if (!query.trim()) throw new OfficeError("invalid_anchor", "The search query is empty.");
|
|
43769
|
+
const { file: file2, doc } = await document(path);
|
|
43770
|
+
return { info: describe3(file2, doc), hits: doc.search(query.trim(), limit) };
|
|
43771
|
+
},
|
|
43772
|
+
/** Panel only: load bytes for rendering and hand out a token to read them in chunks. */
|
|
43773
|
+
async load(path) {
|
|
43774
|
+
const { file: file2, doc } = await document(path);
|
|
43775
|
+
if (disposed)
|
|
43733
43776
|
throw new OfficeError(
|
|
43734
|
-
"
|
|
43735
|
-
"
|
|
43777
|
+
"invalid_token",
|
|
43778
|
+
"This viewer session was reset; reload the document."
|
|
43736
43779
|
);
|
|
43780
|
+
const token = randomUUID();
|
|
43781
|
+
handles.set(token, { bytes: file2.bytes, path: file2.path, revision: file2.revision });
|
|
43782
|
+
tokens.push(token);
|
|
43783
|
+
while (tokens.length > MAX_HANDLES) handles.delete(tokens.shift());
|
|
43784
|
+
return {
|
|
43785
|
+
info: describe3(file2, doc),
|
|
43786
|
+
file: {
|
|
43787
|
+
token,
|
|
43788
|
+
bytes: file2.bytes.byteLength,
|
|
43789
|
+
chunks: Math.max(1, Math.ceil(file2.bytes.byteLength / FILE_CHUNK_BYTES))
|
|
43790
|
+
},
|
|
43791
|
+
...doc.blocks ? { blocks: doc.blocks } : {}
|
|
43792
|
+
};
|
|
43793
|
+
},
|
|
43794
|
+
/** Panel only: record where the user is. The path must be the panel's current document. */
|
|
43795
|
+
async report(input2) {
|
|
43796
|
+
const viewId = input2.viewId ?? "legacy";
|
|
43797
|
+
const ticket = ++sequence;
|
|
43798
|
+
reports.set(viewId, ticket);
|
|
43799
|
+
const { path, kind } = await files.resolve(input2.path);
|
|
43800
|
+
const clip = (text) => cut(text, 0, 2e3);
|
|
43801
|
+
const view = {
|
|
43802
|
+
path,
|
|
43803
|
+
kind,
|
|
43804
|
+
at: input2.at ? cut(input2.at, 0, 300) : null,
|
|
43805
|
+
selection: input2.selection?.at ? { at: cut(input2.selection.at, 0, 300), text: clip(input2.selection.text ?? "") } : null,
|
|
43806
|
+
updatedAt: Date.now()
|
|
43807
|
+
};
|
|
43808
|
+
if (reports.get(viewId) !== ticket) return views.get(viewId) ?? emptyView();
|
|
43809
|
+
views.set(viewId, view);
|
|
43810
|
+
return view;
|
|
43811
|
+
},
|
|
43812
|
+
views: () => [...views].map(([viewId, view]) => ({ viewId, ...view })),
|
|
43813
|
+
releaseView: (viewId) => {
|
|
43814
|
+
reports.delete(viewId);
|
|
43815
|
+
views.delete(viewId);
|
|
43816
|
+
},
|
|
43817
|
+
view: (viewId) => viewId ? views.get(viewId) ?? emptyView() : views.size === 1 ? views.values().next().value : emptyView(),
|
|
43818
|
+
current: () => current,
|
|
43819
|
+
snapshot: () => snapshot(),
|
|
43820
|
+
close() {
|
|
43821
|
+
current = null;
|
|
43822
|
+
reports.clear();
|
|
43823
|
+
views.clear();
|
|
43824
|
+
return snapshot();
|
|
43825
|
+
},
|
|
43826
|
+
list: (limit) => files.list({ limit }),
|
|
43827
|
+
/** Drop this session's handles when the session itself is dropped. */
|
|
43828
|
+
dispose() {
|
|
43829
|
+
disposed = true;
|
|
43830
|
+
for (const token of tokens.splice(0)) handles.delete(token);
|
|
43737
43831
|
}
|
|
43738
|
-
|
|
43739
|
-
|
|
43740
|
-
|
|
43741
|
-
|
|
43742
|
-
|
|
43743
|
-
|
|
43744
|
-
|
|
43745
|
-
|
|
43746
|
-
|
|
43747
|
-
|
|
43748
|
-
|
|
43749
|
-
|
|
43750
|
-
|
|
43751
|
-
|
|
43752
|
-
|
|
43753
|
-
|
|
43754
|
-
|
|
43755
|
-
|
|
43756
|
-
|
|
43757
|
-
};
|
|
43758
|
-
},
|
|
43759
|
-
async search(path, query, limit) {
|
|
43760
|
-
if (!query.trim()) throw new OfficeError("invalid_anchor", "The search query is empty.");
|
|
43761
|
-
const { file: file2, doc } = await document(path);
|
|
43762
|
-
return { info: describe3(file2, doc), hits: doc.search(query.trim(), limit) };
|
|
43763
|
-
},
|
|
43764
|
-
/** Panel only: load bytes for rendering and hand out a token to read them in chunks. */
|
|
43765
|
-
async load(path) {
|
|
43766
|
-
const { file: file2, doc } = await document(path);
|
|
43767
|
-
const token = randomUUID();
|
|
43768
|
-
handles.set(token, { bytes: file2.bytes, path: file2.path, revision: file2.revision });
|
|
43769
|
-
while (handles.size > MAX_HANDLES) handles.delete(handles.keys().next().value);
|
|
43770
|
-
return {
|
|
43771
|
-
info: describe3(file2, doc),
|
|
43772
|
-
file: {
|
|
43773
|
-
token,
|
|
43774
|
-
bytes: file2.bytes.byteLength,
|
|
43775
|
-
chunks: Math.max(1, Math.ceil(file2.bytes.byteLength / FILE_CHUNK_BYTES))
|
|
43776
|
-
},
|
|
43777
|
-
...doc.blocks ? { blocks: doc.blocks } : {}
|
|
43778
|
-
};
|
|
43832
|
+
};
|
|
43833
|
+
}
|
|
43834
|
+
return {
|
|
43835
|
+
/**
|
|
43836
|
+
* The viewer state of one session (`_meta.session_id` of the call); calls without one share
|
|
43837
|
+
* the default session. Keeps the {@link MAX_SESSIONS} most recently used sessions.
|
|
43838
|
+
*/
|
|
43839
|
+
session(id) {
|
|
43840
|
+
const key = id || DEFAULT_SESSION;
|
|
43841
|
+
let state = sessions.get(key);
|
|
43842
|
+
if (state) sessions.delete(key);
|
|
43843
|
+
else state = createSession(key);
|
|
43844
|
+
sessions.set(key, state);
|
|
43845
|
+
while (sessions.size > MAX_SESSIONS) {
|
|
43846
|
+
const [oldest, dropped] = sessions.entries().next().value;
|
|
43847
|
+
sessions.delete(oldest);
|
|
43848
|
+
dropped.dispose();
|
|
43849
|
+
}
|
|
43850
|
+
return state;
|
|
43779
43851
|
},
|
|
43852
|
+
/** Panel only: one chunk of a loaded file. Tokens are unique across sessions. */
|
|
43780
43853
|
chunk(token, index) {
|
|
43781
43854
|
const handle = handles.get(token);
|
|
43782
43855
|
if (!handle)
|
|
@@ -43784,41 +43857,12 @@ function createDocumentOwner({ files, parse: parse3 }) {
|
|
|
43784
43857
|
const start = index * FILE_CHUNK_BYTES;
|
|
43785
43858
|
if (!Number.isInteger(index) || index < 0 || start >= handle.bytes.byteLength && index > 0)
|
|
43786
43859
|
throw new OfficeError("invalid_token", "Chunk index out of range.");
|
|
43787
|
-
|
|
43788
|
-
|
|
43789
|
-
|
|
43790
|
-
|
|
43791
|
-
|
|
43792
|
-
|
|
43793
|
-
reports.set(viewId, ticket);
|
|
43794
|
-
const { path, kind } = await files.resolve(input2.path);
|
|
43795
|
-
const clip = (text) => cut(text, 0, 2e3);
|
|
43796
|
-
const view = {
|
|
43797
|
-
path,
|
|
43798
|
-
kind,
|
|
43799
|
-
at: input2.at ? cut(input2.at, 0, 300) : null,
|
|
43800
|
-
selection: input2.selection?.at ? { at: cut(input2.selection.at, 0, 300), text: clip(input2.selection.text ?? "") } : null,
|
|
43801
|
-
updatedAt: Date.now()
|
|
43802
|
-
};
|
|
43803
|
-
if (reports.get(viewId) !== ticket) return views.get(viewId) ?? emptyView();
|
|
43804
|
-
views.set(viewId, view);
|
|
43805
|
-
return view;
|
|
43806
|
-
},
|
|
43807
|
-
views: () => [...views].map(([viewId, view]) => ({ viewId, ...view })),
|
|
43808
|
-
releaseView: (viewId) => {
|
|
43809
|
-
reports.delete(viewId);
|
|
43810
|
-
views.delete(viewId);
|
|
43811
|
-
},
|
|
43812
|
-
view: (viewId) => viewId ? views.get(viewId) ?? emptyView() : views.size === 1 ? views.values().next().value : emptyView(),
|
|
43813
|
-
current: () => current,
|
|
43814
|
-
snapshot: () => snapshot(),
|
|
43815
|
-
close() {
|
|
43816
|
-
current = null;
|
|
43817
|
-
reports.clear();
|
|
43818
|
-
views.clear();
|
|
43819
|
-
return snapshot();
|
|
43820
|
-
},
|
|
43821
|
-
list: (limit) => files.list({ limit })
|
|
43860
|
+
const data = Buffer.from(handle.bytes.subarray(start, start + FILE_CHUNK_BYTES)).toString(
|
|
43861
|
+
"base64"
|
|
43862
|
+
);
|
|
43863
|
+
if (start + FILE_CHUNK_BYTES >= handle.bytes.byteLength) handles.delete(token);
|
|
43864
|
+
return data;
|
|
43865
|
+
}
|
|
43822
43866
|
};
|
|
43823
43867
|
}
|
|
43824
43868
|
function defaultAt(doc) {
|
|
@@ -44070,21 +44114,21 @@ function createDocumentImporter(workspace, options = {}) {
|
|
|
44070
44114
|
return {
|
|
44071
44115
|
// 只读工作区仍可预览;启动清扫失败只记录,不能阻断插件连接。
|
|
44072
44116
|
initialize: () => run(() => sweep().catch((error62) => options.onCleanupError?.(error62))),
|
|
44073
|
-
begin: (name, size) => run(async () => {
|
|
44117
|
+
begin: (name, size, owner = "default") => run(async () => {
|
|
44074
44118
|
if (closed) throw new OfficeError("invalid_token", "Importer is closed.");
|
|
44075
44119
|
if (basename(name) !== name || name.includes("\\") || !kindOf(name))
|
|
44076
44120
|
throw new OfficeError("unsupported_type", "Unsupported file name or type.");
|
|
44077
44121
|
if (!Number.isInteger(size) || size < 1 || size > MAX_FILE_BYTES)
|
|
44078
44122
|
throw new OfficeError("file_too_large", "File size is outside the supported range.");
|
|
44079
44123
|
await sweep();
|
|
44080
|
-
if (uploads.
|
|
44124
|
+
if ([...uploads.values()].filter((upload) => upload.owner === owner).length >= MAX_IMPORTS)
|
|
44081
44125
|
throw new OfficeError("invalid_token", "Too many pending imports.");
|
|
44082
44126
|
const id = randomUUID2();
|
|
44083
44127
|
const directory = join(await parent(), id);
|
|
44084
44128
|
await mkdir(directory);
|
|
44085
44129
|
try {
|
|
44086
44130
|
const handle = await open2(join(directory, ".partial"), "wx");
|
|
44087
|
-
uploads.set(id, { directory, name, size, offset: 0, handle, touched: now() });
|
|
44131
|
+
uploads.set(id, { directory, name, size, offset: 0, handle, touched: now(), owner });
|
|
44088
44132
|
return id;
|
|
44089
44133
|
} catch (error62) {
|
|
44090
44134
|
await rm(directory, { recursive: true, force: true }).catch(
|
|
@@ -56344,6 +56388,11 @@ function describeSnapshot(snapshot, verb) {
|
|
|
56344
56388
|
);
|
|
56345
56389
|
return parts.join("\n");
|
|
56346
56390
|
}
|
|
56391
|
+
function sessionOf(meta3) {
|
|
56392
|
+
for (const id of [meta3?.root_session_id, meta3?.session_id])
|
|
56393
|
+
if (typeof id === "string" && id) return id;
|
|
56394
|
+
return void 0;
|
|
56395
|
+
}
|
|
56347
56396
|
var textResult = (text, structuredContent) => ({
|
|
56348
56397
|
content: [{ type: "text", text: wellFormed(text) }],
|
|
56349
56398
|
...structuredContent ? { structuredContent: wellFormedDeep(structuredContent) } : {}
|
|
@@ -56366,9 +56415,9 @@ function createOfficeServer({
|
|
|
56366
56415
|
...config2.openPanel ? { "openai/ui": { preferredModelDisplayMode: "fullscreen" } } : {}
|
|
56367
56416
|
}
|
|
56368
56417
|
},
|
|
56369
|
-
(async (input2) => {
|
|
56418
|
+
(async (input2, extra) => {
|
|
56370
56419
|
try {
|
|
56371
|
-
const { text, structured } = await execute(input2);
|
|
56420
|
+
const { text, structured } = await execute(input2, owner.session(sessionOf(extra._meta)));
|
|
56372
56421
|
return textResult(text, structured);
|
|
56373
56422
|
} catch (error62) {
|
|
56374
56423
|
const code = error62 instanceof OfficeError ? error62.code : "corrupt_file";
|
|
@@ -56401,8 +56450,8 @@ function createOfficeServer({
|
|
|
56401
56450
|
panel: true,
|
|
56402
56451
|
openPanel: true
|
|
56403
56452
|
},
|
|
56404
|
-
async ({ path, at }) => {
|
|
56405
|
-
const snapshot = await
|
|
56453
|
+
async ({ path, at }, session) => {
|
|
56454
|
+
const snapshot = await session.open(path, at);
|
|
56406
56455
|
return { text: describeSnapshot(snapshot, "Opened"), structured: { ...snapshot } };
|
|
56407
56456
|
}
|
|
56408
56457
|
);
|
|
@@ -56416,8 +56465,8 @@ function createOfficeServer({
|
|
|
56416
56465
|
},
|
|
56417
56466
|
visibility: ["model"]
|
|
56418
56467
|
},
|
|
56419
|
-
async ({ anchor: target, cursor }) => {
|
|
56420
|
-
const { info, at, page } = await
|
|
56468
|
+
async ({ anchor: target, cursor }, session) => {
|
|
56469
|
+
const { info, at, page } = await session.read(target, cursor ?? 0);
|
|
56421
56470
|
const head = `${formatAnchor(info.path, at)} (${KIND_NAMES[info.kind]}, revision ${info.revision})`;
|
|
56422
56471
|
const tail = page.next === null ? "[end]" : `[more: call read_document with anchor "${formatAnchor(info.path, at)}" and cursor ${page.next}]`;
|
|
56423
56472
|
return {
|
|
@@ -56441,8 +56490,8 @@ ${tail}`,
|
|
|
56441
56490
|
},
|
|
56442
56491
|
visibility: ["model"]
|
|
56443
56492
|
},
|
|
56444
|
-
async ({ path, query, limit }) => {
|
|
56445
|
-
const { info, hits } = await
|
|
56493
|
+
async ({ path, query, limit }, session) => {
|
|
56494
|
+
const { info, hits } = await session.search(path, query, limit ?? 20);
|
|
56446
56495
|
const text = hits.length ? [
|
|
56447
56496
|
`${hits.length} match${hits.length === 1 ? "" : "es"} for "${query}" in ${info.path}:`,
|
|
56448
56497
|
...hits.map((hit) => `- ${formatAnchor(info.path, hit.at)} ${hit.snippet}`)
|
|
@@ -56470,8 +56519,8 @@ ${tail}`,
|
|
|
56470
56519
|
panel: true,
|
|
56471
56520
|
openPanel: true
|
|
56472
56521
|
},
|
|
56473
|
-
async ({ targets, note }) => {
|
|
56474
|
-
const snapshot = await
|
|
56522
|
+
async ({ targets, note }, session) => {
|
|
56523
|
+
const snapshot = await session.show(targets, note);
|
|
56475
56524
|
return { text: describeSnapshot(snapshot, "Showing"), structured: { ...snapshot } };
|
|
56476
56525
|
}
|
|
56477
56526
|
);
|
|
@@ -56484,8 +56533,8 @@ ${tail}`,
|
|
|
56484
56533
|
},
|
|
56485
56534
|
visibility: ["model"]
|
|
56486
56535
|
},
|
|
56487
|
-
async ({ viewId }) => {
|
|
56488
|
-
const views =
|
|
56536
|
+
async ({ viewId }, session) => {
|
|
56537
|
+
const views = session.views();
|
|
56489
56538
|
if (!viewId && views.length > 1)
|
|
56490
56539
|
return {
|
|
56491
56540
|
text: "Multiple document viewers have reported views. Ask the user which document they mean, then call get_view with its viewId.\n" + views.map((view2) => `${view2.viewId}: ${view2.path}`).join("\n"),
|
|
@@ -56496,8 +56545,8 @@ ${tail}`,
|
|
|
56496
56545
|
"invalid_token",
|
|
56497
56546
|
"Unknown viewer. Call get_view without viewId to list viewers."
|
|
56498
56547
|
);
|
|
56499
|
-
const view =
|
|
56500
|
-
const current = view.path ? await
|
|
56548
|
+
const view = session.view(viewId);
|
|
56549
|
+
const current = view.path ? await session.info(view.path) : session.current();
|
|
56501
56550
|
if (!current && !view.path)
|
|
56502
56551
|
return {
|
|
56503
56552
|
text: `The ${TITLE} viewer has no document open. Use open_document to open one.`,
|
|
@@ -56510,7 +56559,7 @@ ${tail}`,
|
|
|
56510
56559
|
lines.push(`User selection: ${formatAnchor(path, view.selection.at)}`);
|
|
56511
56560
|
if (view.selection.text) lines.push(`Selected text: """${view.selection.text}"""`);
|
|
56512
56561
|
if (view.kind === "xlsx") {
|
|
56513
|
-
const stored = await
|
|
56562
|
+
const stored = await session.read(formatAnchor(path, view.selection.at)).catch(() => null);
|
|
56514
56563
|
if (stored)
|
|
56515
56564
|
lines.push(
|
|
56516
56565
|
"Selected cells as stored in the file:",
|
|
@@ -56538,9 +56587,9 @@ ${tail}`,
|
|
|
56538
56587
|
visibility: ["app"],
|
|
56539
56588
|
readOnly: false
|
|
56540
56589
|
},
|
|
56541
|
-
async ({ name, size }) => ({
|
|
56590
|
+
async ({ name, size }, session) => ({
|
|
56542
56591
|
text: "Import started",
|
|
56543
|
-
structured: { id: await importer.begin(name, size) }
|
|
56592
|
+
structured: { id: await importer.begin(name, size, session.id) }
|
|
56544
56593
|
})
|
|
56545
56594
|
);
|
|
56546
56595
|
register(
|
|
@@ -56594,8 +56643,8 @@ ${tail}`,
|
|
|
56594
56643
|
input: { limit: external_exports.number().int().min(1).max(1e3).optional() },
|
|
56595
56644
|
visibility: ["app"]
|
|
56596
56645
|
},
|
|
56597
|
-
async ({ limit }) => {
|
|
56598
|
-
const documents = await
|
|
56646
|
+
async ({ limit }, session) => {
|
|
56647
|
+
const documents = await session.list(limit ?? 500);
|
|
56599
56648
|
return { text: `${documents.length} documents`, structured: { documents } };
|
|
56600
56649
|
}
|
|
56601
56650
|
);
|
|
@@ -56606,8 +56655,8 @@ ${tail}`,
|
|
|
56606
56655
|
input: { path: external_exports.string().min(1).max(1e3) },
|
|
56607
56656
|
visibility: ["app"]
|
|
56608
56657
|
},
|
|
56609
|
-
async ({ path }) => {
|
|
56610
|
-
const loaded = await
|
|
56658
|
+
async ({ path }, session) => {
|
|
56659
|
+
const loaded = await session.load(path);
|
|
56611
56660
|
return { text: describeDocument(loaded.info, 10), structured: { ...loaded } };
|
|
56612
56661
|
}
|
|
56613
56662
|
);
|
|
@@ -56618,8 +56667,8 @@ ${tail}`,
|
|
|
56618
56667
|
input: { path: external_exports.string().min(1).max(1e3) },
|
|
56619
56668
|
visibility: ["app"]
|
|
56620
56669
|
},
|
|
56621
|
-
async ({ path }) => {
|
|
56622
|
-
const info = await
|
|
56670
|
+
async ({ path }, session) => {
|
|
56671
|
+
const info = await session.info(path);
|
|
56623
56672
|
return { text: info.revision, structured: { path: info.path, revision: info.revision } };
|
|
56624
56673
|
}
|
|
56625
56674
|
);
|
|
@@ -56630,8 +56679,8 @@ ${tail}`,
|
|
|
56630
56679
|
input: {},
|
|
56631
56680
|
visibility: ["app"]
|
|
56632
56681
|
},
|
|
56633
|
-
async () => {
|
|
56634
|
-
const snapshot =
|
|
56682
|
+
async (_input, session) => {
|
|
56683
|
+
const snapshot = session.snapshot();
|
|
56635
56684
|
return { text: describeSnapshot(snapshot, "Viewer has"), structured: { ...snapshot } };
|
|
56636
56685
|
}
|
|
56637
56686
|
);
|
|
@@ -56648,8 +56697,8 @@ ${tail}`,
|
|
|
56648
56697
|
visibility: ["app"],
|
|
56649
56698
|
readOnly: false
|
|
56650
56699
|
},
|
|
56651
|
-
async (input2) => {
|
|
56652
|
-
const view = await
|
|
56700
|
+
async (input2, session) => {
|
|
56701
|
+
const view = await session.report(input2);
|
|
56653
56702
|
return { text: "ok", structured: { view } };
|
|
56654
56703
|
}
|
|
56655
56704
|
);
|
|
@@ -56661,8 +56710,8 @@ ${tail}`,
|
|
|
56661
56710
|
visibility: ["app"],
|
|
56662
56711
|
readOnly: false
|
|
56663
56712
|
},
|
|
56664
|
-
async ({ viewId }) => {
|
|
56665
|
-
|
|
56713
|
+
async ({ viewId }, session) => {
|
|
56714
|
+
session.releaseView(viewId);
|
|
56666
56715
|
return { text: "ok" };
|
|
56667
56716
|
}
|
|
56668
56717
|
);
|