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.
Files changed (33) hide show
  1. package/LICENSES/README.md +1 -1
  2. package/README.md +19 -4
  3. package/bin/zcode.js +47 -16
  4. package/docs/CONFIGURATION.md +2 -1
  5. package/docs/CONFIGURATION.zh-CN.md +2 -1
  6. package/docs/THIRD_PARTY_CONTENT.md +2 -2
  7. package/package.json +2 -2
  8. package/vendor/cli-config.cjs +21 -0
  9. package/vendor/extraction.json +9 -4
  10. package/vendor/node_modules/@zcode/tui/dist/index.js +79 -22
  11. package/vendor/packages/documents-plugin/.zcode-plugin/plugin.json +3 -2
  12. package/vendor/packages/documents-plugin/dist/server.mjs +201 -152
  13. package/vendor/packages/documents-plugin/dist/ui/bundle-0.txt +1 -1
  14. package/vendor/packages/documents-plugin/dist/ui/panel.html +1 -1
  15. package/vendor/packages/documents-plugin/package.json +1 -1
  16. package/vendor/packages/node-repl-host/dist/mcp/server.js +1 -1
  17. package/vendor/packages/pdf-plugin/.zcode-plugin/plugin.json +3 -2
  18. package/vendor/packages/pdf-plugin/dist/server.mjs +201 -152
  19. package/vendor/packages/pdf-plugin/dist/ui/bundle-0.txt +1 -1
  20. package/vendor/packages/pdf-plugin/dist/ui/panel.html +1 -1
  21. package/vendor/packages/pdf-plugin/package.json +1 -1
  22. package/vendor/packages/presentations-plugin/.zcode-plugin/plugin.json +3 -2
  23. package/vendor/packages/presentations-plugin/dist/server.mjs +201 -152
  24. package/vendor/packages/presentations-plugin/dist/ui/bundle-0.txt +1 -1
  25. package/vendor/packages/presentations-plugin/dist/ui/panel.html +1 -1
  26. package/vendor/packages/presentations-plugin/package.json +1 -1
  27. package/vendor/packages/spreadsheets-plugin/.zcode-plugin/plugin.json +3 -2
  28. package/vendor/packages/spreadsheets-plugin/dist/server.mjs +201 -152
  29. package/vendor/packages/spreadsheets-plugin/dist/ui/bundle-0.txt +1 -1
  30. package/vendor/packages/spreadsheets-plugin/dist/ui/panel.html +1 -1
  31. package/vendor/packages/spreadsheets-plugin/package.json +1 -1
  32. package/vendor/zcode.cjs +1033 -1031
  33. package/zcode-runtime.lock.json +3 -3
@@ -126083,7 +126083,7 @@ var StdioServerTransport = class {
126083
126083
  };
126084
126084
 
126085
126085
  // ../office-runtime/src/profile.ts
126086
- var PROFILE = { "name": "pdf", "version": "0.2.1", "title": { "en": "PDF", "zh-CN": "PDF" }, "kinds": ["pdf"] };
126086
+ var PROFILE = { "name": "pdf", "version": "0.2.2", "title": { "en": "PDF", "zh-CN": "PDF" }, "kinds": ["pdf"] };
126087
126087
 
126088
126088
  // ../office-runtime/src/contract.ts
126089
126089
  var PLUGIN_VERSION = PROFILE.version;
@@ -126297,21 +126297,12 @@ function wellFormedDeep(value) {
126297
126297
  // ../office-runtime/src/app/documents.ts
126298
126298
  var MAX_CACHED = 6;
126299
126299
  var MAX_HANDLES = 4;
126300
+ var MAX_SESSIONS = 32;
126301
+ var DEFAULT_SESSION = "default";
126300
126302
  function createDocumentOwner({ files, parse: parse3 }) {
126301
126303
  const cache = /* @__PURE__ */ new Map();
126302
126304
  const handles = /* @__PURE__ */ new Map();
126303
- let current = null;
126304
- const emptyView = () => ({
126305
- path: null,
126306
- kind: null,
126307
- at: null,
126308
- selection: null,
126309
- updatedAt: 0
126310
- });
126311
- const views = /* @__PURE__ */ new Map();
126312
- const reports = /* @__PURE__ */ new Map();
126313
- let sequence = 0;
126314
- let revealSeq = 0;
126305
+ const sessions = /* @__PURE__ */ new Map();
126315
126306
  async function entry(input2) {
126316
126307
  const { path } = await files.resolve(input2);
126317
126308
  const fingerprint = await files.fingerprint(path);
@@ -126344,83 +126335,165 @@ function createDocumentOwner({ files, parse: parse3 }) {
126344
126335
  function canonical(doc, at) {
126345
126336
  return formatLocator(doc.check(parseLocator(doc.kind, at)));
126346
126337
  }
126347
- function snapshot(reveal) {
126338
+ function createSession(id) {
126339
+ let current = null;
126340
+ let disposed = false;
126341
+ const emptyView = () => ({
126342
+ path: null,
126343
+ kind: null,
126344
+ at: null,
126345
+ selection: null,
126346
+ updatedAt: 0
126347
+ });
126348
+ const views = /* @__PURE__ */ new Map();
126349
+ const reports = /* @__PURE__ */ new Map();
126350
+ const tokens = [];
126351
+ let sequence = 0;
126352
+ let revealSeq = 0;
126353
+ function snapshot(reveal) {
126354
+ return {
126355
+ document: current,
126356
+ ...reveal ? { reveal: { ...reveal, seq: ++revealSeq } } : {}
126357
+ };
126358
+ }
126348
126359
  return {
126349
- document: current,
126350
- ...reveal ? { reveal: { ...reveal, seq: ++revealSeq } } : {}
126351
- };
126352
- }
126353
- return {
126354
- async info(path) {
126355
- const { file: file2, doc } = await document2(path);
126356
- return describe3(file2, doc);
126357
- },
126358
- /** Make `path` the viewer's document, optionally revealing a location in it. */
126359
- async open(path, at) {
126360
- const { file: file2, doc } = await document2(path);
126361
- const target = at ? canonical(doc, at) : null;
126362
- current = describe3(file2, doc);
126363
- return snapshot(target ? { targets: [{ at: target }] } : void 0);
126364
- },
126365
- /** Point the user at one or more places in one document; opens it if needed. */
126366
- async show(targets, note) {
126367
- if (!targets.length)
126368
- throw new OfficeError("invalid_anchor", "Give at least one anchor to show.");
126369
- const split = targets.map((target) => ({
126370
- ...splitAnchor(target.anchor),
126371
- quote: target.quote
126372
- }));
126373
- const path = split[0].path;
126374
- const { path: resolved } = await files.resolve(path);
126375
- for (const item of split) {
126376
- if ((await files.resolve(item.path)).path !== resolved)
126360
+ /** The key this session is stored under; also owns the session's file imports. */
126361
+ id,
126362
+ async info(path) {
126363
+ const { file: file2, doc } = await document2(path);
126364
+ return describe3(file2, doc);
126365
+ },
126366
+ /** Make `path` the viewer's document, optionally revealing a location in it. */
126367
+ async open(path, at) {
126368
+ const { file: file2, doc } = await document2(path);
126369
+ const target = at ? canonical(doc, at) : null;
126370
+ current = describe3(file2, doc);
126371
+ return snapshot(target ? { targets: [{ at: target }] } : void 0);
126372
+ },
126373
+ /** Point the user at one or more places in one document; opens it if needed. */
126374
+ async show(targets, note) {
126375
+ if (!targets.length)
126376
+ throw new OfficeError("invalid_anchor", "Give at least one anchor to show.");
126377
+ const split = targets.map((target) => ({
126378
+ ...splitAnchor(target.anchor),
126379
+ quote: target.quote
126380
+ }));
126381
+ const path = split[0].path;
126382
+ const { path: resolved } = await files.resolve(path);
126383
+ for (const item of split) {
126384
+ if ((await files.resolve(item.path)).path !== resolved)
126385
+ throw new OfficeError(
126386
+ "invalid_anchor",
126387
+ "All anchors passed to show must be in the same document."
126388
+ );
126389
+ }
126390
+ const { file: file2, doc } = await document2(resolved);
126391
+ const resolvedTargets = split.map((item) => ({
126392
+ at: item.at ? canonical(doc, item.at) : defaultAt(doc),
126393
+ ...item.quote?.trim() ? { quote: cut(item.quote.trim(), 0, 500) } : {}
126394
+ }));
126395
+ current = describe3(file2, doc);
126396
+ return snapshot({
126397
+ targets: resolvedTargets,
126398
+ ...note?.trim() ? { note: cut(note.trim(), 0, 500) } : {}
126399
+ });
126400
+ },
126401
+ async read(anchor2, cursor = 0) {
126402
+ const { path, at } = splitAnchor(anchor2);
126403
+ const { file: file2, doc } = await document2(path);
126404
+ const locator = at ? doc.check(parseLocator(doc.kind, at)) : null;
126405
+ return {
126406
+ info: describe3(file2, doc),
126407
+ at: locator ? formatLocator(locator) : null,
126408
+ page: doc.read(locator, cursor)
126409
+ };
126410
+ },
126411
+ async search(path, query, limit) {
126412
+ if (!query.trim()) throw new OfficeError("invalid_anchor", "The search query is empty.");
126413
+ const { file: file2, doc } = await document2(path);
126414
+ return { info: describe3(file2, doc), hits: doc.search(query.trim(), limit) };
126415
+ },
126416
+ /** Panel only: load bytes for rendering and hand out a token to read them in chunks. */
126417
+ async load(path) {
126418
+ const { file: file2, doc } = await document2(path);
126419
+ if (disposed)
126377
126420
  throw new OfficeError(
126378
- "invalid_anchor",
126379
- "All anchors passed to show must be in the same document."
126421
+ "invalid_token",
126422
+ "This viewer session was reset; reload the document."
126380
126423
  );
126424
+ const token = randomUUID();
126425
+ handles.set(token, { bytes: file2.bytes, path: file2.path, revision: file2.revision });
126426
+ tokens.push(token);
126427
+ while (tokens.length > MAX_HANDLES) handles.delete(tokens.shift());
126428
+ return {
126429
+ info: describe3(file2, doc),
126430
+ file: {
126431
+ token,
126432
+ bytes: file2.bytes.byteLength,
126433
+ chunks: Math.max(1, Math.ceil(file2.bytes.byteLength / FILE_CHUNK_BYTES))
126434
+ },
126435
+ ...doc.blocks ? { blocks: doc.blocks } : {}
126436
+ };
126437
+ },
126438
+ /** Panel only: record where the user is. The path must be the panel's current document. */
126439
+ async report(input2) {
126440
+ const viewId = input2.viewId ?? "legacy";
126441
+ const ticket = ++sequence;
126442
+ reports.set(viewId, ticket);
126443
+ const { path, kind } = await files.resolve(input2.path);
126444
+ const clip = (text) => cut(text, 0, 2e3);
126445
+ const view = {
126446
+ path,
126447
+ kind,
126448
+ at: input2.at ? cut(input2.at, 0, 300) : null,
126449
+ selection: input2.selection?.at ? { at: cut(input2.selection.at, 0, 300), text: clip(input2.selection.text ?? "") } : null,
126450
+ updatedAt: Date.now()
126451
+ };
126452
+ if (reports.get(viewId) !== ticket) return views.get(viewId) ?? emptyView();
126453
+ views.set(viewId, view);
126454
+ return view;
126455
+ },
126456
+ views: () => [...views].map(([viewId, view]) => ({ viewId, ...view })),
126457
+ releaseView: (viewId) => {
126458
+ reports.delete(viewId);
126459
+ views.delete(viewId);
126460
+ },
126461
+ view: (viewId) => viewId ? views.get(viewId) ?? emptyView() : views.size === 1 ? views.values().next().value : emptyView(),
126462
+ current: () => current,
126463
+ snapshot: () => snapshot(),
126464
+ close() {
126465
+ current = null;
126466
+ reports.clear();
126467
+ views.clear();
126468
+ return snapshot();
126469
+ },
126470
+ list: (limit) => files.list({ limit }),
126471
+ /** Drop this session's handles when the session itself is dropped. */
126472
+ dispose() {
126473
+ disposed = true;
126474
+ for (const token of tokens.splice(0)) handles.delete(token);
126381
126475
  }
126382
- const { file: file2, doc } = await document2(resolved);
126383
- const resolvedTargets = split.map((item) => ({
126384
- at: item.at ? canonical(doc, item.at) : defaultAt(doc),
126385
- ...item.quote?.trim() ? { quote: cut(item.quote.trim(), 0, 500) } : {}
126386
- }));
126387
- current = describe3(file2, doc);
126388
- return snapshot({
126389
- targets: resolvedTargets,
126390
- ...note?.trim() ? { note: cut(note.trim(), 0, 500) } : {}
126391
- });
126392
- },
126393
- async read(anchor2, cursor = 0) {
126394
- const { path, at } = splitAnchor(anchor2);
126395
- const { file: file2, doc } = await document2(path);
126396
- const locator = at ? doc.check(parseLocator(doc.kind, at)) : null;
126397
- return {
126398
- info: describe3(file2, doc),
126399
- at: locator ? formatLocator(locator) : null,
126400
- page: doc.read(locator, cursor)
126401
- };
126402
- },
126403
- async search(path, query, limit) {
126404
- if (!query.trim()) throw new OfficeError("invalid_anchor", "The search query is empty.");
126405
- const { file: file2, doc } = await document2(path);
126406
- return { info: describe3(file2, doc), hits: doc.search(query.trim(), limit) };
126407
- },
126408
- /** Panel only: load bytes for rendering and hand out a token to read them in chunks. */
126409
- async load(path) {
126410
- const { file: file2, doc } = await document2(path);
126411
- const token = randomUUID();
126412
- handles.set(token, { bytes: file2.bytes, path: file2.path, revision: file2.revision });
126413
- while (handles.size > MAX_HANDLES) handles.delete(handles.keys().next().value);
126414
- return {
126415
- info: describe3(file2, doc),
126416
- file: {
126417
- token,
126418
- bytes: file2.bytes.byteLength,
126419
- chunks: Math.max(1, Math.ceil(file2.bytes.byteLength / FILE_CHUNK_BYTES))
126420
- },
126421
- ...doc.blocks ? { blocks: doc.blocks } : {}
126422
- };
126476
+ };
126477
+ }
126478
+ return {
126479
+ /**
126480
+ * The viewer state of one session (`_meta.session_id` of the call); calls without one share
126481
+ * the default session. Keeps the {@link MAX_SESSIONS} most recently used sessions.
126482
+ */
126483
+ session(id) {
126484
+ const key = id || DEFAULT_SESSION;
126485
+ let state = sessions.get(key);
126486
+ if (state) sessions.delete(key);
126487
+ else state = createSession(key);
126488
+ sessions.set(key, state);
126489
+ while (sessions.size > MAX_SESSIONS) {
126490
+ const [oldest, dropped] = sessions.entries().next().value;
126491
+ sessions.delete(oldest);
126492
+ dropped.dispose();
126493
+ }
126494
+ return state;
126423
126495
  },
126496
+ /** Panel only: one chunk of a loaded file. Tokens are unique across sessions. */
126424
126497
  chunk(token, index) {
126425
126498
  const handle = handles.get(token);
126426
126499
  if (!handle)
@@ -126428,41 +126501,12 @@ function createDocumentOwner({ files, parse: parse3 }) {
126428
126501
  const start = index * FILE_CHUNK_BYTES;
126429
126502
  if (!Number.isInteger(index) || index < 0 || start >= handle.bytes.byteLength && index > 0)
126430
126503
  throw new OfficeError("invalid_token", "Chunk index out of range.");
126431
- return Buffer.from(handle.bytes.subarray(start, start + FILE_CHUNK_BYTES)).toString("base64");
126432
- },
126433
- /** Panel only: record where the user is. The path must be the panel's current document. */
126434
- async report(input2) {
126435
- const viewId = input2.viewId ?? "legacy";
126436
- const ticket = ++sequence;
126437
- reports.set(viewId, ticket);
126438
- const { path, kind } = await files.resolve(input2.path);
126439
- const clip = (text) => cut(text, 0, 2e3);
126440
- const view = {
126441
- path,
126442
- kind,
126443
- at: input2.at ? cut(input2.at, 0, 300) : null,
126444
- selection: input2.selection?.at ? { at: cut(input2.selection.at, 0, 300), text: clip(input2.selection.text ?? "") } : null,
126445
- updatedAt: Date.now()
126446
- };
126447
- if (reports.get(viewId) !== ticket) return views.get(viewId) ?? emptyView();
126448
- views.set(viewId, view);
126449
- return view;
126450
- },
126451
- views: () => [...views].map(([viewId, view]) => ({ viewId, ...view })),
126452
- releaseView: (viewId) => {
126453
- reports.delete(viewId);
126454
- views.delete(viewId);
126455
- },
126456
- view: (viewId) => viewId ? views.get(viewId) ?? emptyView() : views.size === 1 ? views.values().next().value : emptyView(),
126457
- current: () => current,
126458
- snapshot: () => snapshot(),
126459
- close() {
126460
- current = null;
126461
- reports.clear();
126462
- views.clear();
126463
- return snapshot();
126464
- },
126465
- list: (limit) => files.list({ limit })
126504
+ const data = Buffer.from(handle.bytes.subarray(start, start + FILE_CHUNK_BYTES)).toString(
126505
+ "base64"
126506
+ );
126507
+ if (start + FILE_CHUNK_BYTES >= handle.bytes.byteLength) handles.delete(token);
126508
+ return data;
126509
+ }
126466
126510
  };
126467
126511
  }
126468
126512
  function defaultAt(doc) {
@@ -126714,21 +126758,21 @@ function createDocumentImporter(workspace, options = {}) {
126714
126758
  return {
126715
126759
  // 只读工作区仍可预览;启动清扫失败只记录,不能阻断插件连接。
126716
126760
  initialize: () => run(() => sweep().catch((error62) => options.onCleanupError?.(error62))),
126717
- begin: (name, size) => run(async () => {
126761
+ begin: (name, size, owner = "default") => run(async () => {
126718
126762
  if (closed) throw new OfficeError("invalid_token", "Importer is closed.");
126719
126763
  if (basename(name) !== name || name.includes("\\") || !kindOf(name))
126720
126764
  throw new OfficeError("unsupported_type", "Unsupported file name or type.");
126721
126765
  if (!Number.isInteger(size) || size < 1 || size > MAX_FILE_BYTES)
126722
126766
  throw new OfficeError("file_too_large", "File size is outside the supported range.");
126723
126767
  await sweep();
126724
- if (uploads.size >= MAX_IMPORTS)
126768
+ if ([...uploads.values()].filter((upload) => upload.owner === owner).length >= MAX_IMPORTS)
126725
126769
  throw new OfficeError("invalid_token", "Too many pending imports.");
126726
126770
  const id = randomUUID2();
126727
126771
  const directory = join(await parent(), id);
126728
126772
  await mkdir(directory);
126729
126773
  try {
126730
126774
  const handle = await open2(join(directory, ".partial"), "wx");
126731
- uploads.set(id, { directory, name, size, offset: 0, handle, touched: now() });
126775
+ uploads.set(id, { directory, name, size, offset: 0, handle, touched: now(), owner });
126732
126776
  return id;
126733
126777
  } catch (error62) {
126734
126778
  await rm(directory, { recursive: true, force: true }).catch(
@@ -138976,6 +139020,11 @@ function describeSnapshot(snapshot, verb) {
138976
139020
  );
138977
139021
  return parts.join("\n");
138978
139022
  }
139023
+ function sessionOf(meta3) {
139024
+ for (const id of [meta3?.root_session_id, meta3?.session_id])
139025
+ if (typeof id === "string" && id) return id;
139026
+ return void 0;
139027
+ }
138979
139028
  var textResult = (text, structuredContent) => ({
138980
139029
  content: [{ type: "text", text: wellFormed(text) }],
138981
139030
  ...structuredContent ? { structuredContent: wellFormedDeep(structuredContent) } : {}
@@ -138998,9 +139047,9 @@ function createOfficeServer({
138998
139047
  ...config2.openPanel ? { "openai/ui": { preferredModelDisplayMode: "fullscreen" } } : {}
138999
139048
  }
139000
139049
  },
139001
- (async (input2) => {
139050
+ (async (input2, extra) => {
139002
139051
  try {
139003
- const { text, structured } = await execute(input2);
139052
+ const { text, structured } = await execute(input2, owner.session(sessionOf(extra._meta)));
139004
139053
  return textResult(text, structured);
139005
139054
  } catch (error62) {
139006
139055
  const code = error62 instanceof OfficeError ? error62.code : "corrupt_file";
@@ -139033,8 +139082,8 @@ function createOfficeServer({
139033
139082
  panel: true,
139034
139083
  openPanel: true
139035
139084
  },
139036
- async ({ path, at }) => {
139037
- const snapshot = await owner.open(path, at);
139085
+ async ({ path, at }, session) => {
139086
+ const snapshot = await session.open(path, at);
139038
139087
  return { text: describeSnapshot(snapshot, "Opened"), structured: { ...snapshot } };
139039
139088
  }
139040
139089
  );
@@ -139048,8 +139097,8 @@ function createOfficeServer({
139048
139097
  },
139049
139098
  visibility: ["model"]
139050
139099
  },
139051
- async ({ anchor: target, cursor }) => {
139052
- const { info: info3, at, page } = await owner.read(target, cursor ?? 0);
139100
+ async ({ anchor: target, cursor }, session) => {
139101
+ const { info: info3, at, page } = await session.read(target, cursor ?? 0);
139053
139102
  const head = `${formatAnchor(info3.path, at)} (${KIND_NAMES[info3.kind]}, revision ${info3.revision})`;
139054
139103
  const tail = page.next === null ? "[end]" : `[more: call read_document with anchor "${formatAnchor(info3.path, at)}" and cursor ${page.next}]`;
139055
139104
  return {
@@ -139073,8 +139122,8 @@ ${tail}`,
139073
139122
  },
139074
139123
  visibility: ["model"]
139075
139124
  },
139076
- async ({ path, query, limit }) => {
139077
- const { info: info3, hits } = await owner.search(path, query, limit ?? 20);
139125
+ async ({ path, query, limit }, session) => {
139126
+ const { info: info3, hits } = await session.search(path, query, limit ?? 20);
139078
139127
  const text = hits.length ? [
139079
139128
  `${hits.length} match${hits.length === 1 ? "" : "es"} for "${query}" in ${info3.path}:`,
139080
139129
  ...hits.map((hit) => `- ${formatAnchor(info3.path, hit.at)} ${hit.snippet}`)
@@ -139102,8 +139151,8 @@ ${tail}`,
139102
139151
  panel: true,
139103
139152
  openPanel: true
139104
139153
  },
139105
- async ({ targets, note }) => {
139106
- const snapshot = await owner.show(targets, note);
139154
+ async ({ targets, note }, session) => {
139155
+ const snapshot = await session.show(targets, note);
139107
139156
  return { text: describeSnapshot(snapshot, "Showing"), structured: { ...snapshot } };
139108
139157
  }
139109
139158
  );
@@ -139116,8 +139165,8 @@ ${tail}`,
139116
139165
  },
139117
139166
  visibility: ["model"]
139118
139167
  },
139119
- async ({ viewId }) => {
139120
- const views = owner.views();
139168
+ async ({ viewId }, session) => {
139169
+ const views = session.views();
139121
139170
  if (!viewId && views.length > 1)
139122
139171
  return {
139123
139172
  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"),
@@ -139128,8 +139177,8 @@ ${tail}`,
139128
139177
  "invalid_token",
139129
139178
  "Unknown viewer. Call get_view without viewId to list viewers."
139130
139179
  );
139131
- const view = owner.view(viewId);
139132
- const current = view.path ? await owner.info(view.path) : owner.current();
139180
+ const view = session.view(viewId);
139181
+ const current = view.path ? await session.info(view.path) : session.current();
139133
139182
  if (!current && !view.path)
139134
139183
  return {
139135
139184
  text: `The ${TITLE} viewer has no document open. Use open_document to open one.`,
@@ -139142,7 +139191,7 @@ ${tail}`,
139142
139191
  lines.push(`User selection: ${formatAnchor(path, view.selection.at)}`);
139143
139192
  if (view.selection.text) lines.push(`Selected text: """${view.selection.text}"""`);
139144
139193
  if (view.kind === "xlsx") {
139145
- const stored = await owner.read(formatAnchor(path, view.selection.at)).catch(() => null);
139194
+ const stored = await session.read(formatAnchor(path, view.selection.at)).catch(() => null);
139146
139195
  if (stored)
139147
139196
  lines.push(
139148
139197
  "Selected cells as stored in the file:",
@@ -139170,9 +139219,9 @@ ${tail}`,
139170
139219
  visibility: ["app"],
139171
139220
  readOnly: false
139172
139221
  },
139173
- async ({ name, size }) => ({
139222
+ async ({ name, size }, session) => ({
139174
139223
  text: "Import started",
139175
- structured: { id: await importer.begin(name, size) }
139224
+ structured: { id: await importer.begin(name, size, session.id) }
139176
139225
  })
139177
139226
  );
139178
139227
  register(
@@ -139226,8 +139275,8 @@ ${tail}`,
139226
139275
  input: { limit: external_exports.number().int().min(1).max(1e3).optional() },
139227
139276
  visibility: ["app"]
139228
139277
  },
139229
- async ({ limit }) => {
139230
- const documents = await owner.list(limit ?? 500);
139278
+ async ({ limit }, session) => {
139279
+ const documents = await session.list(limit ?? 500);
139231
139280
  return { text: `${documents.length} documents`, structured: { documents } };
139232
139281
  }
139233
139282
  );
@@ -139238,8 +139287,8 @@ ${tail}`,
139238
139287
  input: { path: external_exports.string().min(1).max(1e3) },
139239
139288
  visibility: ["app"]
139240
139289
  },
139241
- async ({ path }) => {
139242
- const loaded = await owner.load(path);
139290
+ async ({ path }, session) => {
139291
+ const loaded = await session.load(path);
139243
139292
  return { text: describeDocument(loaded.info, 10), structured: { ...loaded } };
139244
139293
  }
139245
139294
  );
@@ -139250,8 +139299,8 @@ ${tail}`,
139250
139299
  input: { path: external_exports.string().min(1).max(1e3) },
139251
139300
  visibility: ["app"]
139252
139301
  },
139253
- async ({ path }) => {
139254
- const info3 = await owner.info(path);
139302
+ async ({ path }, session) => {
139303
+ const info3 = await session.info(path);
139255
139304
  return { text: info3.revision, structured: { path: info3.path, revision: info3.revision } };
139256
139305
  }
139257
139306
  );
@@ -139262,8 +139311,8 @@ ${tail}`,
139262
139311
  input: {},
139263
139312
  visibility: ["app"]
139264
139313
  },
139265
- async () => {
139266
- const snapshot = owner.snapshot();
139314
+ async (_input, session) => {
139315
+ const snapshot = session.snapshot();
139267
139316
  return { text: describeSnapshot(snapshot, "Viewer has"), structured: { ...snapshot } };
139268
139317
  }
139269
139318
  );
@@ -139280,8 +139329,8 @@ ${tail}`,
139280
139329
  visibility: ["app"],
139281
139330
  readOnly: false
139282
139331
  },
139283
- async (input2) => {
139284
- const view = await owner.report(input2);
139332
+ async (input2, session) => {
139333
+ const view = await session.report(input2);
139285
139334
  return { text: "ok", structured: { view } };
139286
139335
  }
139287
139336
  );
@@ -139293,8 +139342,8 @@ ${tail}`,
139293
139342
  visibility: ["app"],
139294
139343
  readOnly: false
139295
139344
  },
139296
- async ({ viewId }) => {
139297
- owner.releaseView(viewId);
139345
+ async ({ viewId }, session) => {
139346
+ session.releaseView(viewId);
139298
139347
  return { text: "ok" };
139299
139348
  }
139300
139349
  );