zcode-app-cli 3.16.2-38 → 3.16.3-39
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 +8 -2
- package/bin/zcode.js +8 -1
- package/docs/CONFIGURATION.md +1 -1
- package/docs/CONFIGURATION.zh-CN.md +1 -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 +19 -3
- 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
|
@@ -65694,7 +65694,7 @@ var StdioServerTransport = class {
|
|
|
65694
65694
|
};
|
|
65695
65695
|
|
|
65696
65696
|
// ../office-runtime/src/profile.ts
|
|
65697
|
-
var PROFILE = { "name": "spreadsheets", "version": "0.2.
|
|
65697
|
+
var PROFILE = { "name": "spreadsheets", "version": "0.2.1", "title": { "en": "Spreadsheets", "zh-CN": "\u7535\u5B50\u8868\u683C" }, "kinds": ["xlsx"] };
|
|
65698
65698
|
|
|
65699
65699
|
// ../office-runtime/src/contract.ts
|
|
65700
65700
|
var PLUGIN_VERSION = PROFILE.version;
|
|
@@ -65908,21 +65908,12 @@ function wellFormedDeep(value) {
|
|
|
65908
65908
|
// ../office-runtime/src/app/documents.ts
|
|
65909
65909
|
var MAX_CACHED = 6;
|
|
65910
65910
|
var MAX_HANDLES = 4;
|
|
65911
|
+
var MAX_SESSIONS = 32;
|
|
65912
|
+
var DEFAULT_SESSION = "default";
|
|
65911
65913
|
function createDocumentOwner({ files, parse: parse4 }) {
|
|
65912
65914
|
const cache = /* @__PURE__ */ new Map();
|
|
65913
65915
|
const handles = /* @__PURE__ */ new Map();
|
|
65914
|
-
|
|
65915
|
-
const emptyView = () => ({
|
|
65916
|
-
path: null,
|
|
65917
|
-
kind: null,
|
|
65918
|
-
at: null,
|
|
65919
|
-
selection: null,
|
|
65920
|
-
updatedAt: 0
|
|
65921
|
-
});
|
|
65922
|
-
const views = /* @__PURE__ */ new Map();
|
|
65923
|
-
const reports = /* @__PURE__ */ new Map();
|
|
65924
|
-
let sequence = 0;
|
|
65925
|
-
let revealSeq = 0;
|
|
65916
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
65926
65917
|
async function entry(input2) {
|
|
65927
65918
|
const { path } = await files.resolve(input2);
|
|
65928
65919
|
const fingerprint = await files.fingerprint(path);
|
|
@@ -65955,83 +65946,165 @@ function createDocumentOwner({ files, parse: parse4 }) {
|
|
|
65955
65946
|
function canonical(doc, at) {
|
|
65956
65947
|
return formatLocator(doc.check(parseLocator(doc.kind, at)));
|
|
65957
65948
|
}
|
|
65958
|
-
function
|
|
65949
|
+
function createSession(id) {
|
|
65950
|
+
let current = null;
|
|
65951
|
+
let disposed = false;
|
|
65952
|
+
const emptyView = () => ({
|
|
65953
|
+
path: null,
|
|
65954
|
+
kind: null,
|
|
65955
|
+
at: null,
|
|
65956
|
+
selection: null,
|
|
65957
|
+
updatedAt: 0
|
|
65958
|
+
});
|
|
65959
|
+
const views = /* @__PURE__ */ new Map();
|
|
65960
|
+
const reports = /* @__PURE__ */ new Map();
|
|
65961
|
+
const tokens = [];
|
|
65962
|
+
let sequence = 0;
|
|
65963
|
+
let revealSeq = 0;
|
|
65964
|
+
function snapshot(reveal) {
|
|
65965
|
+
return {
|
|
65966
|
+
document: current,
|
|
65967
|
+
...reveal ? { reveal: { ...reveal, seq: ++revealSeq } } : {}
|
|
65968
|
+
};
|
|
65969
|
+
}
|
|
65959
65970
|
return {
|
|
65960
|
-
|
|
65961
|
-
|
|
65962
|
-
|
|
65963
|
-
|
|
65964
|
-
|
|
65965
|
-
|
|
65966
|
-
|
|
65967
|
-
|
|
65968
|
-
|
|
65969
|
-
|
|
65970
|
-
|
|
65971
|
-
|
|
65972
|
-
|
|
65973
|
-
|
|
65974
|
-
|
|
65975
|
-
|
|
65976
|
-
|
|
65977
|
-
|
|
65978
|
-
|
|
65979
|
-
|
|
65980
|
-
|
|
65981
|
-
|
|
65982
|
-
|
|
65983
|
-
|
|
65984
|
-
|
|
65985
|
-
|
|
65986
|
-
|
|
65987
|
-
|
|
65971
|
+
/** The key this session is stored under; also owns the session's file imports. */
|
|
65972
|
+
id,
|
|
65973
|
+
async info(path) {
|
|
65974
|
+
const { file: file2, doc } = await document(path);
|
|
65975
|
+
return describe3(file2, doc);
|
|
65976
|
+
},
|
|
65977
|
+
/** Make `path` the viewer's document, optionally revealing a location in it. */
|
|
65978
|
+
async open(path, at) {
|
|
65979
|
+
const { file: file2, doc } = await document(path);
|
|
65980
|
+
const target = at ? canonical(doc, at) : null;
|
|
65981
|
+
current = describe3(file2, doc);
|
|
65982
|
+
return snapshot(target ? { targets: [{ at: target }] } : void 0);
|
|
65983
|
+
},
|
|
65984
|
+
/** Point the user at one or more places in one document; opens it if needed. */
|
|
65985
|
+
async show(targets, note) {
|
|
65986
|
+
if (!targets.length)
|
|
65987
|
+
throw new OfficeError("invalid_anchor", "Give at least one anchor to show.");
|
|
65988
|
+
const split = targets.map((target) => ({
|
|
65989
|
+
...splitAnchor(target.anchor),
|
|
65990
|
+
quote: target.quote
|
|
65991
|
+
}));
|
|
65992
|
+
const path = split[0].path;
|
|
65993
|
+
const { path: resolved } = await files.resolve(path);
|
|
65994
|
+
for (const item of split) {
|
|
65995
|
+
if ((await files.resolve(item.path)).path !== resolved)
|
|
65996
|
+
throw new OfficeError(
|
|
65997
|
+
"invalid_anchor",
|
|
65998
|
+
"All anchors passed to show must be in the same document."
|
|
65999
|
+
);
|
|
66000
|
+
}
|
|
66001
|
+
const { file: file2, doc } = await document(resolved);
|
|
66002
|
+
const resolvedTargets = split.map((item) => ({
|
|
66003
|
+
at: item.at ? canonical(doc, item.at) : defaultAt(doc),
|
|
66004
|
+
...item.quote?.trim() ? { quote: cut(item.quote.trim(), 0, 500) } : {}
|
|
66005
|
+
}));
|
|
66006
|
+
current = describe3(file2, doc);
|
|
66007
|
+
return snapshot({
|
|
66008
|
+
targets: resolvedTargets,
|
|
66009
|
+
...note?.trim() ? { note: cut(note.trim(), 0, 500) } : {}
|
|
66010
|
+
});
|
|
66011
|
+
},
|
|
66012
|
+
async read(anchor2, cursor = 0) {
|
|
66013
|
+
const { path, at } = splitAnchor(anchor2);
|
|
66014
|
+
const { file: file2, doc } = await document(path);
|
|
66015
|
+
const locator = at ? doc.check(parseLocator(doc.kind, at)) : null;
|
|
66016
|
+
return {
|
|
66017
|
+
info: describe3(file2, doc),
|
|
66018
|
+
at: locator ? formatLocator(locator) : null,
|
|
66019
|
+
page: doc.read(locator, cursor)
|
|
66020
|
+
};
|
|
66021
|
+
},
|
|
66022
|
+
async search(path, query, limit) {
|
|
66023
|
+
if (!query.trim()) throw new OfficeError("invalid_anchor", "The search query is empty.");
|
|
66024
|
+
const { file: file2, doc } = await document(path);
|
|
66025
|
+
return { info: describe3(file2, doc), hits: doc.search(query.trim(), limit) };
|
|
66026
|
+
},
|
|
66027
|
+
/** Panel only: load bytes for rendering and hand out a token to read them in chunks. */
|
|
66028
|
+
async load(path) {
|
|
66029
|
+
const { file: file2, doc } = await document(path);
|
|
66030
|
+
if (disposed)
|
|
65988
66031
|
throw new OfficeError(
|
|
65989
|
-
"
|
|
65990
|
-
"
|
|
66032
|
+
"invalid_token",
|
|
66033
|
+
"This viewer session was reset; reload the document."
|
|
65991
66034
|
);
|
|
66035
|
+
const token = randomUUID();
|
|
66036
|
+
handles.set(token, { bytes: file2.bytes, path: file2.path, revision: file2.revision });
|
|
66037
|
+
tokens.push(token);
|
|
66038
|
+
while (tokens.length > MAX_HANDLES) handles.delete(tokens.shift());
|
|
66039
|
+
return {
|
|
66040
|
+
info: describe3(file2, doc),
|
|
66041
|
+
file: {
|
|
66042
|
+
token,
|
|
66043
|
+
bytes: file2.bytes.byteLength,
|
|
66044
|
+
chunks: Math.max(1, Math.ceil(file2.bytes.byteLength / FILE_CHUNK_BYTES))
|
|
66045
|
+
},
|
|
66046
|
+
...doc.blocks ? { blocks: doc.blocks } : {}
|
|
66047
|
+
};
|
|
66048
|
+
},
|
|
66049
|
+
/** Panel only: record where the user is. The path must be the panel's current document. */
|
|
66050
|
+
async report(input2) {
|
|
66051
|
+
const viewId = input2.viewId ?? "legacy";
|
|
66052
|
+
const ticket = ++sequence;
|
|
66053
|
+
reports.set(viewId, ticket);
|
|
66054
|
+
const { path, kind } = await files.resolve(input2.path);
|
|
66055
|
+
const clip = (text) => cut(text, 0, 2e3);
|
|
66056
|
+
const view = {
|
|
66057
|
+
path,
|
|
66058
|
+
kind,
|
|
66059
|
+
at: input2.at ? cut(input2.at, 0, 300) : null,
|
|
66060
|
+
selection: input2.selection?.at ? { at: cut(input2.selection.at, 0, 300), text: clip(input2.selection.text ?? "") } : null,
|
|
66061
|
+
updatedAt: Date.now()
|
|
66062
|
+
};
|
|
66063
|
+
if (reports.get(viewId) !== ticket) return views.get(viewId) ?? emptyView();
|
|
66064
|
+
views.set(viewId, view);
|
|
66065
|
+
return view;
|
|
66066
|
+
},
|
|
66067
|
+
views: () => [...views].map(([viewId, view]) => ({ viewId, ...view })),
|
|
66068
|
+
releaseView: (viewId) => {
|
|
66069
|
+
reports.delete(viewId);
|
|
66070
|
+
views.delete(viewId);
|
|
66071
|
+
},
|
|
66072
|
+
view: (viewId) => viewId ? views.get(viewId) ?? emptyView() : views.size === 1 ? views.values().next().value : emptyView(),
|
|
66073
|
+
current: () => current,
|
|
66074
|
+
snapshot: () => snapshot(),
|
|
66075
|
+
close() {
|
|
66076
|
+
current = null;
|
|
66077
|
+
reports.clear();
|
|
66078
|
+
views.clear();
|
|
66079
|
+
return snapshot();
|
|
66080
|
+
},
|
|
66081
|
+
list: (limit) => files.list({ limit }),
|
|
66082
|
+
/** Drop this session's handles when the session itself is dropped. */
|
|
66083
|
+
dispose() {
|
|
66084
|
+
disposed = true;
|
|
66085
|
+
for (const token of tokens.splice(0)) handles.delete(token);
|
|
65992
66086
|
}
|
|
65993
|
-
|
|
65994
|
-
|
|
65995
|
-
|
|
65996
|
-
|
|
65997
|
-
|
|
65998
|
-
|
|
65999
|
-
|
|
66000
|
-
|
|
66001
|
-
|
|
66002
|
-
|
|
66003
|
-
|
|
66004
|
-
|
|
66005
|
-
|
|
66006
|
-
|
|
66007
|
-
|
|
66008
|
-
|
|
66009
|
-
|
|
66010
|
-
|
|
66011
|
-
|
|
66012
|
-
};
|
|
66013
|
-
},
|
|
66014
|
-
async search(path, query, limit) {
|
|
66015
|
-
if (!query.trim()) throw new OfficeError("invalid_anchor", "The search query is empty.");
|
|
66016
|
-
const { file: file2, doc } = await document(path);
|
|
66017
|
-
return { info: describe3(file2, doc), hits: doc.search(query.trim(), limit) };
|
|
66018
|
-
},
|
|
66019
|
-
/** Panel only: load bytes for rendering and hand out a token to read them in chunks. */
|
|
66020
|
-
async load(path) {
|
|
66021
|
-
const { file: file2, doc } = await document(path);
|
|
66022
|
-
const token = randomUUID();
|
|
66023
|
-
handles.set(token, { bytes: file2.bytes, path: file2.path, revision: file2.revision });
|
|
66024
|
-
while (handles.size > MAX_HANDLES) handles.delete(handles.keys().next().value);
|
|
66025
|
-
return {
|
|
66026
|
-
info: describe3(file2, doc),
|
|
66027
|
-
file: {
|
|
66028
|
-
token,
|
|
66029
|
-
bytes: file2.bytes.byteLength,
|
|
66030
|
-
chunks: Math.max(1, Math.ceil(file2.bytes.byteLength / FILE_CHUNK_BYTES))
|
|
66031
|
-
},
|
|
66032
|
-
...doc.blocks ? { blocks: doc.blocks } : {}
|
|
66033
|
-
};
|
|
66087
|
+
};
|
|
66088
|
+
}
|
|
66089
|
+
return {
|
|
66090
|
+
/**
|
|
66091
|
+
* The viewer state of one session (`_meta.session_id` of the call); calls without one share
|
|
66092
|
+
* the default session. Keeps the {@link MAX_SESSIONS} most recently used sessions.
|
|
66093
|
+
*/
|
|
66094
|
+
session(id) {
|
|
66095
|
+
const key = id || DEFAULT_SESSION;
|
|
66096
|
+
let state = sessions.get(key);
|
|
66097
|
+
if (state) sessions.delete(key);
|
|
66098
|
+
else state = createSession(key);
|
|
66099
|
+
sessions.set(key, state);
|
|
66100
|
+
while (sessions.size > MAX_SESSIONS) {
|
|
66101
|
+
const [oldest, dropped] = sessions.entries().next().value;
|
|
66102
|
+
sessions.delete(oldest);
|
|
66103
|
+
dropped.dispose();
|
|
66104
|
+
}
|
|
66105
|
+
return state;
|
|
66034
66106
|
},
|
|
66107
|
+
/** Panel only: one chunk of a loaded file. Tokens are unique across sessions. */
|
|
66035
66108
|
chunk(token, index) {
|
|
66036
66109
|
const handle = handles.get(token);
|
|
66037
66110
|
if (!handle)
|
|
@@ -66039,41 +66112,12 @@ function createDocumentOwner({ files, parse: parse4 }) {
|
|
|
66039
66112
|
const start = index * FILE_CHUNK_BYTES;
|
|
66040
66113
|
if (!Number.isInteger(index) || index < 0 || start >= handle.bytes.byteLength && index > 0)
|
|
66041
66114
|
throw new OfficeError("invalid_token", "Chunk index out of range.");
|
|
66042
|
-
|
|
66043
|
-
|
|
66044
|
-
|
|
66045
|
-
|
|
66046
|
-
|
|
66047
|
-
|
|
66048
|
-
reports.set(viewId, ticket);
|
|
66049
|
-
const { path, kind } = await files.resolve(input2.path);
|
|
66050
|
-
const clip = (text) => cut(text, 0, 2e3);
|
|
66051
|
-
const view = {
|
|
66052
|
-
path,
|
|
66053
|
-
kind,
|
|
66054
|
-
at: input2.at ? cut(input2.at, 0, 300) : null,
|
|
66055
|
-
selection: input2.selection?.at ? { at: cut(input2.selection.at, 0, 300), text: clip(input2.selection.text ?? "") } : null,
|
|
66056
|
-
updatedAt: Date.now()
|
|
66057
|
-
};
|
|
66058
|
-
if (reports.get(viewId) !== ticket) return views.get(viewId) ?? emptyView();
|
|
66059
|
-
views.set(viewId, view);
|
|
66060
|
-
return view;
|
|
66061
|
-
},
|
|
66062
|
-
views: () => [...views].map(([viewId, view]) => ({ viewId, ...view })),
|
|
66063
|
-
releaseView: (viewId) => {
|
|
66064
|
-
reports.delete(viewId);
|
|
66065
|
-
views.delete(viewId);
|
|
66066
|
-
},
|
|
66067
|
-
view: (viewId) => viewId ? views.get(viewId) ?? emptyView() : views.size === 1 ? views.values().next().value : emptyView(),
|
|
66068
|
-
current: () => current,
|
|
66069
|
-
snapshot: () => snapshot(),
|
|
66070
|
-
close() {
|
|
66071
|
-
current = null;
|
|
66072
|
-
reports.clear();
|
|
66073
|
-
views.clear();
|
|
66074
|
-
return snapshot();
|
|
66075
|
-
},
|
|
66076
|
-
list: (limit) => files.list({ limit })
|
|
66115
|
+
const data = Buffer.from(handle.bytes.subarray(start, start + FILE_CHUNK_BYTES)).toString(
|
|
66116
|
+
"base64"
|
|
66117
|
+
);
|
|
66118
|
+
if (start + FILE_CHUNK_BYTES >= handle.bytes.byteLength) handles.delete(token);
|
|
66119
|
+
return data;
|
|
66120
|
+
}
|
|
66077
66121
|
};
|
|
66078
66122
|
}
|
|
66079
66123
|
function defaultAt(doc) {
|
|
@@ -66325,21 +66369,21 @@ function createDocumentImporter(workspace, options = {}) {
|
|
|
66325
66369
|
return {
|
|
66326
66370
|
// 只读工作区仍可预览;启动清扫失败只记录,不能阻断插件连接。
|
|
66327
66371
|
initialize: () => run(() => sweep().catch((error62) => options.onCleanupError?.(error62))),
|
|
66328
|
-
begin: (name, size) => run(async () => {
|
|
66372
|
+
begin: (name, size, owner = "default") => run(async () => {
|
|
66329
66373
|
if (closed) throw new OfficeError("invalid_token", "Importer is closed.");
|
|
66330
66374
|
if (basename(name) !== name || name.includes("\\") || !kindOf(name))
|
|
66331
66375
|
throw new OfficeError("unsupported_type", "Unsupported file name or type.");
|
|
66332
66376
|
if (!Number.isInteger(size) || size < 1 || size > MAX_FILE_BYTES)
|
|
66333
66377
|
throw new OfficeError("file_too_large", "File size is outside the supported range.");
|
|
66334
66378
|
await sweep();
|
|
66335
|
-
if (uploads.
|
|
66379
|
+
if ([...uploads.values()].filter((upload) => upload.owner === owner).length >= MAX_IMPORTS)
|
|
66336
66380
|
throw new OfficeError("invalid_token", "Too many pending imports.");
|
|
66337
66381
|
const id = randomUUID2();
|
|
66338
66382
|
const directory = join(await parent(), id);
|
|
66339
66383
|
await mkdir(directory);
|
|
66340
66384
|
try {
|
|
66341
66385
|
const handle = await open2(join(directory, ".partial"), "wx");
|
|
66342
|
-
uploads.set(id, { directory, name, size, offset: 0, handle, touched: now() });
|
|
66386
|
+
uploads.set(id, { directory, name, size, offset: 0, handle, touched: now(), owner });
|
|
66343
66387
|
return id;
|
|
66344
66388
|
} catch (error62) {
|
|
66345
66389
|
await rm(directory, { recursive: true, force: true }).catch(
|
|
@@ -78591,6 +78635,11 @@ function describeSnapshot(snapshot, verb) {
|
|
|
78591
78635
|
);
|
|
78592
78636
|
return parts.join("\n");
|
|
78593
78637
|
}
|
|
78638
|
+
function sessionOf(meta3) {
|
|
78639
|
+
for (const id of [meta3?.root_session_id, meta3?.session_id])
|
|
78640
|
+
if (typeof id === "string" && id) return id;
|
|
78641
|
+
return void 0;
|
|
78642
|
+
}
|
|
78594
78643
|
var textResult = (text, structuredContent) => ({
|
|
78595
78644
|
content: [{ type: "text", text: wellFormed(text) }],
|
|
78596
78645
|
...structuredContent ? { structuredContent: wellFormedDeep(structuredContent) } : {}
|
|
@@ -78613,9 +78662,9 @@ function createOfficeServer({
|
|
|
78613
78662
|
...config2.openPanel ? { "openai/ui": { preferredModelDisplayMode: "fullscreen" } } : {}
|
|
78614
78663
|
}
|
|
78615
78664
|
},
|
|
78616
|
-
(async (input2) => {
|
|
78665
|
+
(async (input2, extra) => {
|
|
78617
78666
|
try {
|
|
78618
|
-
const { text, structured } = await execute(input2);
|
|
78667
|
+
const { text, structured } = await execute(input2, owner.session(sessionOf(extra._meta)));
|
|
78619
78668
|
return textResult(text, structured);
|
|
78620
78669
|
} catch (error62) {
|
|
78621
78670
|
const code = error62 instanceof OfficeError ? error62.code : "corrupt_file";
|
|
@@ -78648,8 +78697,8 @@ function createOfficeServer({
|
|
|
78648
78697
|
panel: true,
|
|
78649
78698
|
openPanel: true
|
|
78650
78699
|
},
|
|
78651
|
-
async ({ path, at }) => {
|
|
78652
|
-
const snapshot = await
|
|
78700
|
+
async ({ path, at }, session) => {
|
|
78701
|
+
const snapshot = await session.open(path, at);
|
|
78653
78702
|
return { text: describeSnapshot(snapshot, "Opened"), structured: { ...snapshot } };
|
|
78654
78703
|
}
|
|
78655
78704
|
);
|
|
@@ -78663,8 +78712,8 @@ function createOfficeServer({
|
|
|
78663
78712
|
},
|
|
78664
78713
|
visibility: ["model"]
|
|
78665
78714
|
},
|
|
78666
|
-
async ({ anchor: target, cursor }) => {
|
|
78667
|
-
const { info, at, page } = await
|
|
78715
|
+
async ({ anchor: target, cursor }, session) => {
|
|
78716
|
+
const { info, at, page } = await session.read(target, cursor ?? 0);
|
|
78668
78717
|
const head = `${formatAnchor(info.path, at)} (${KIND_NAMES[info.kind]}, revision ${info.revision})`;
|
|
78669
78718
|
const tail = page.next === null ? "[end]" : `[more: call read_document with anchor "${formatAnchor(info.path, at)}" and cursor ${page.next}]`;
|
|
78670
78719
|
return {
|
|
@@ -78688,8 +78737,8 @@ ${tail}`,
|
|
|
78688
78737
|
},
|
|
78689
78738
|
visibility: ["model"]
|
|
78690
78739
|
},
|
|
78691
|
-
async ({ path, query, limit }) => {
|
|
78692
|
-
const { info, hits } = await
|
|
78740
|
+
async ({ path, query, limit }, session) => {
|
|
78741
|
+
const { info, hits } = await session.search(path, query, limit ?? 20);
|
|
78693
78742
|
const text = hits.length ? [
|
|
78694
78743
|
`${hits.length} match${hits.length === 1 ? "" : "es"} for "${query}" in ${info.path}:`,
|
|
78695
78744
|
...hits.map((hit) => `- ${formatAnchor(info.path, hit.at)} ${hit.snippet}`)
|
|
@@ -78717,8 +78766,8 @@ ${tail}`,
|
|
|
78717
78766
|
panel: true,
|
|
78718
78767
|
openPanel: true
|
|
78719
78768
|
},
|
|
78720
|
-
async ({ targets, note }) => {
|
|
78721
|
-
const snapshot = await
|
|
78769
|
+
async ({ targets, note }, session) => {
|
|
78770
|
+
const snapshot = await session.show(targets, note);
|
|
78722
78771
|
return { text: describeSnapshot(snapshot, "Showing"), structured: { ...snapshot } };
|
|
78723
78772
|
}
|
|
78724
78773
|
);
|
|
@@ -78731,8 +78780,8 @@ ${tail}`,
|
|
|
78731
78780
|
},
|
|
78732
78781
|
visibility: ["model"]
|
|
78733
78782
|
},
|
|
78734
|
-
async ({ viewId }) => {
|
|
78735
|
-
const views =
|
|
78783
|
+
async ({ viewId }, session) => {
|
|
78784
|
+
const views = session.views();
|
|
78736
78785
|
if (!viewId && views.length > 1)
|
|
78737
78786
|
return {
|
|
78738
78787
|
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"),
|
|
@@ -78743,8 +78792,8 @@ ${tail}`,
|
|
|
78743
78792
|
"invalid_token",
|
|
78744
78793
|
"Unknown viewer. Call get_view without viewId to list viewers."
|
|
78745
78794
|
);
|
|
78746
|
-
const view =
|
|
78747
|
-
const current = view.path ? await
|
|
78795
|
+
const view = session.view(viewId);
|
|
78796
|
+
const current = view.path ? await session.info(view.path) : session.current();
|
|
78748
78797
|
if (!current && !view.path)
|
|
78749
78798
|
return {
|
|
78750
78799
|
text: `The ${TITLE} viewer has no document open. Use open_document to open one.`,
|
|
@@ -78757,7 +78806,7 @@ ${tail}`,
|
|
|
78757
78806
|
lines.push(`User selection: ${formatAnchor(path, view.selection.at)}`);
|
|
78758
78807
|
if (view.selection.text) lines.push(`Selected text: """${view.selection.text}"""`);
|
|
78759
78808
|
if (view.kind === "xlsx") {
|
|
78760
|
-
const stored = await
|
|
78809
|
+
const stored = await session.read(formatAnchor(path, view.selection.at)).catch(() => null);
|
|
78761
78810
|
if (stored)
|
|
78762
78811
|
lines.push(
|
|
78763
78812
|
"Selected cells as stored in the file:",
|
|
@@ -78785,9 +78834,9 @@ ${tail}`,
|
|
|
78785
78834
|
visibility: ["app"],
|
|
78786
78835
|
readOnly: false
|
|
78787
78836
|
},
|
|
78788
|
-
async ({ name, size }) => ({
|
|
78837
|
+
async ({ name, size }, session) => ({
|
|
78789
78838
|
text: "Import started",
|
|
78790
|
-
structured: { id: await importer.begin(name, size) }
|
|
78839
|
+
structured: { id: await importer.begin(name, size, session.id) }
|
|
78791
78840
|
})
|
|
78792
78841
|
);
|
|
78793
78842
|
register(
|
|
@@ -78841,8 +78890,8 @@ ${tail}`,
|
|
|
78841
78890
|
input: { limit: external_exports.number().int().min(1).max(1e3).optional() },
|
|
78842
78891
|
visibility: ["app"]
|
|
78843
78892
|
},
|
|
78844
|
-
async ({ limit }) => {
|
|
78845
|
-
const documents = await
|
|
78893
|
+
async ({ limit }, session) => {
|
|
78894
|
+
const documents = await session.list(limit ?? 500);
|
|
78846
78895
|
return { text: `${documents.length} documents`, structured: { documents } };
|
|
78847
78896
|
}
|
|
78848
78897
|
);
|
|
@@ -78853,8 +78902,8 @@ ${tail}`,
|
|
|
78853
78902
|
input: { path: external_exports.string().min(1).max(1e3) },
|
|
78854
78903
|
visibility: ["app"]
|
|
78855
78904
|
},
|
|
78856
|
-
async ({ path }) => {
|
|
78857
|
-
const loaded = await
|
|
78905
|
+
async ({ path }, session) => {
|
|
78906
|
+
const loaded = await session.load(path);
|
|
78858
78907
|
return { text: describeDocument(loaded.info, 10), structured: { ...loaded } };
|
|
78859
78908
|
}
|
|
78860
78909
|
);
|
|
@@ -78865,8 +78914,8 @@ ${tail}`,
|
|
|
78865
78914
|
input: { path: external_exports.string().min(1).max(1e3) },
|
|
78866
78915
|
visibility: ["app"]
|
|
78867
78916
|
},
|
|
78868
|
-
async ({ path }) => {
|
|
78869
|
-
const info = await
|
|
78917
|
+
async ({ path }, session) => {
|
|
78918
|
+
const info = await session.info(path);
|
|
78870
78919
|
return { text: info.revision, structured: { path: info.path, revision: info.revision } };
|
|
78871
78920
|
}
|
|
78872
78921
|
);
|
|
@@ -78877,8 +78926,8 @@ ${tail}`,
|
|
|
78877
78926
|
input: {},
|
|
78878
78927
|
visibility: ["app"]
|
|
78879
78928
|
},
|
|
78880
|
-
async () => {
|
|
78881
|
-
const snapshot =
|
|
78929
|
+
async (_input, session) => {
|
|
78930
|
+
const snapshot = session.snapshot();
|
|
78882
78931
|
return { text: describeSnapshot(snapshot, "Viewer has"), structured: { ...snapshot } };
|
|
78883
78932
|
}
|
|
78884
78933
|
);
|
|
@@ -78895,8 +78944,8 @@ ${tail}`,
|
|
|
78895
78944
|
visibility: ["app"],
|
|
78896
78945
|
readOnly: false
|
|
78897
78946
|
},
|
|
78898
|
-
async (input2) => {
|
|
78899
|
-
const view = await
|
|
78947
|
+
async (input2, session) => {
|
|
78948
|
+
const view = await session.report(input2);
|
|
78900
78949
|
return { text: "ok", structured: { view } };
|
|
78901
78950
|
}
|
|
78902
78951
|
);
|
|
@@ -78908,8 +78957,8 @@ ${tail}`,
|
|
|
78908
78957
|
visibility: ["app"],
|
|
78909
78958
|
readOnly: false
|
|
78910
78959
|
},
|
|
78911
|
-
async ({ viewId }) => {
|
|
78912
|
-
|
|
78960
|
+
async ({ viewId }, session) => {
|
|
78961
|
+
session.releaseView(viewId);
|
|
78913
78962
|
return { text: "ok" };
|
|
78914
78963
|
}
|
|
78915
78964
|
);
|