@docyrus/docyrus 0.0.38 → 0.0.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/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@docyrus/docyrus",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "private": false,
5
5
  "description": "Docyrus API CLI",
6
6
  "main": "./main.js",
7
7
  "bin": {
8
8
  "docyrus": "main.js"
9
9
  },
10
+ "scripts": {
11
+ "postinstall": "node ./resources/officecli/install.mjs"
12
+ },
10
13
  "dependencies": {
11
14
  "@clack/prompts": "^0.11.0",
12
15
  "@hono/node-server": "^1.14.1",
@@ -0,0 +1,111 @@
1
+ import { existsSync } from "node:fs";
2
+ import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const SKIP_ENV_NAME = "DOCYRUS_SKIP_OFFICECLI_POSTINSTALL";
7
+ const scriptDirectoryPath = dirname(fileURLToPath(import.meta.url));
8
+ const packageRootPath = resolve(scriptDirectoryPath, "..", "..");
9
+ const manifestPath = join(scriptDirectoryPath, "manifest.json");
10
+ const bundledRootPath = join(scriptDirectoryPath, "bundled");
11
+
12
+ function resolveOfficeCliAssetName() {
13
+ switch (process.platform) {
14
+ case "darwin":
15
+ if (process.arch === "arm64") {
16
+ return "officecli-mac-arm64";
17
+ }
18
+ if (process.arch === "x64") {
19
+ return "officecli-mac-x64";
20
+ }
21
+ break;
22
+ case "linux": {
23
+ const alpineSuffix = existsSync("/etc/alpine-release") ? "-alpine" : "";
24
+ if (process.arch === "arm64") {
25
+ return `officecli-linux${alpineSuffix}-arm64`;
26
+ }
27
+ if (process.arch === "x64") {
28
+ return `officecli-linux${alpineSuffix}-x64`;
29
+ }
30
+ break;
31
+ }
32
+ case "win32":
33
+ if (process.arch === "arm64") {
34
+ return "officecli-win-arm64.exe";
35
+ }
36
+ if (process.arch === "x64") {
37
+ return "officecli-win-x64.exe";
38
+ }
39
+ break;
40
+ default:
41
+ break;
42
+ }
43
+
44
+ throw new Error(`Unsupported OfficeCLI platform: ${process.platform}/${process.arch}`);
45
+ }
46
+
47
+ async function readManifest() {
48
+ const manifestRaw = await readFile(manifestPath, "utf8");
49
+ const manifest = JSON.parse(manifestRaw);
50
+
51
+ if (!manifest || typeof manifest.version !== "string" || manifest.version.trim().length === 0) {
52
+ throw new Error("OfficeCLI manifest is missing a valid version.");
53
+ }
54
+
55
+ return {
56
+ version: manifest.version.trim(),
57
+ };
58
+ }
59
+
60
+ async function main() {
61
+ if (process.env[SKIP_ENV_NAME] === "1") {
62
+ return;
63
+ }
64
+
65
+ if (existsSync(join(packageRootPath, "project.json"))) {
66
+ return;
67
+ }
68
+
69
+ const { version } = await readManifest();
70
+ const assetName = resolveOfficeCliAssetName();
71
+ const targetPath = join(bundledRootPath, assetName);
72
+
73
+ if (existsSync(targetPath)) {
74
+ return;
75
+ }
76
+
77
+ await mkdir(bundledRootPath, {
78
+ recursive: true,
79
+ mode: 0o755,
80
+ });
81
+
82
+ const tempPath = `${targetPath}.download${process.platform === "win32" ? ".exe" : ""}`;
83
+
84
+ try {
85
+ const response = await fetch(`https://github.com/iOfficeAI/OfficeCLI/releases/download/v${version}/${assetName}`);
86
+ if (!response.ok) {
87
+ throw new Error(`HTTP ${response.status}`);
88
+ }
89
+
90
+ const binary = Buffer.from(await response.arrayBuffer());
91
+ await writeFile(tempPath, binary, {
92
+ mode: process.platform === "win32" ? 0o644 : 0o755,
93
+ });
94
+
95
+ if (process.platform !== "win32") {
96
+ await chmod(tempPath, 0o755);
97
+ }
98
+
99
+ await rename(tempPath, targetPath);
100
+ } catch (error) {
101
+ await rm(tempPath, {
102
+ force: true,
103
+ });
104
+
105
+ const reason = error instanceof Error ? error.message : "Unknown error";
106
+ process.stderr.write(`[docyrus] OfficeCLI postinstall download failed: ${reason}\n`);
107
+ process.exitCode = 0;
108
+ }
109
+ }
110
+
111
+ await main();
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.31"
3
+ }
@@ -5,7 +5,8 @@ description: Use OfficeCLI to create, inspect, validate, and modify Office docum
5
5
 
6
6
  # OfficeCLI
7
7
 
8
- OfficeCLI is available in Docyrus pi sessions as a local command-line tool for Word, Excel, and PowerPoint files.
8
+ OfficeCLI is bundled into Docyrus pi sessions as a local command-line tool for Word, Excel, and PowerPoint files.
9
+ The Docyrus package provisions the binary for the current platform, and OfficeCLI update checks are disabled because Docyrus releases manage binary updates.
9
10
 
10
11
  Use the CLI directly in this environment. Do not run `officecli mcp ...` unless the user explicitly asks to register OfficeCLI with another editor or agent.
11
12
 
package/server-loader.js CHANGED
@@ -6589,6 +6589,47 @@ function createServerRestrictedModelRegistry(modelRegistry) {
6589
6589
  });
6590
6590
  }
6591
6591
 
6592
+ // src/server/serverSessionAdapter.ts
6593
+ function createServerSessionAdapter(params) {
6594
+ return {
6595
+ id: params.session.sessionId ?? params.session.id,
6596
+ get isStreaming() {
6597
+ return params.session.isStreaming;
6598
+ },
6599
+ get model() {
6600
+ return params.session.model;
6601
+ },
6602
+ get thinkingLevel() {
6603
+ return params.session.thinkingLevel;
6604
+ },
6605
+ subscribe(listener) {
6606
+ return params.session.subscribe(listener);
6607
+ },
6608
+ prompt(text) {
6609
+ return params.session.prompt(text);
6610
+ },
6611
+ abort() {
6612
+ return params.session.abort();
6613
+ },
6614
+ setModel(model) {
6615
+ return params.session.setModel(model);
6616
+ },
6617
+ setThinkingLevel(level) {
6618
+ return params.session.setThinkingLevel(level);
6619
+ },
6620
+ getAvailableThinkingLevels() {
6621
+ return params.session.getAvailableThinkingLevels();
6622
+ },
6623
+ supportsThinking() {
6624
+ return params.session.supportsThinking();
6625
+ },
6626
+ listCommands() {
6627
+ const getCommands = params.extensionsResult.runtime.getCommands;
6628
+ return typeof getCommands === "function" ? getCommands() : [];
6629
+ }
6630
+ };
6631
+ }
6632
+
6592
6633
  // src/services/spinner.ts
6593
6634
  var import_picocolors = __toESM(require_picocolors());
6594
6635
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
@@ -6708,45 +6749,6 @@ function renderStartupSplash(version) {
6708
6749
  `
6709
6750
  );
6710
6751
  }
6711
- function createServerSessionAdapter(params) {
6712
- return {
6713
- id: params.session.id,
6714
- get isStreaming() {
6715
- return params.session.isStreaming;
6716
- },
6717
- get model() {
6718
- return params.session.model;
6719
- },
6720
- get thinkingLevel() {
6721
- return params.session.thinkingLevel;
6722
- },
6723
- subscribe(listener) {
6724
- return params.session.subscribe(listener);
6725
- },
6726
- prompt(text) {
6727
- return params.session.prompt(text);
6728
- },
6729
- abort() {
6730
- return params.session.abort();
6731
- },
6732
- setModel(model) {
6733
- return params.session.setModel(model);
6734
- },
6735
- setThinkingLevel(level) {
6736
- return params.session.setThinkingLevel(level);
6737
- },
6738
- getAvailableThinkingLevels() {
6739
- return params.session.getAvailableThinkingLevels();
6740
- },
6741
- supportsThinking() {
6742
- return params.session.supportsThinking();
6743
- },
6744
- listCommands() {
6745
- const getCommands = params.extensionsResult.runtime.getCommands;
6746
- return typeof getCommands === "function" ? getCommands() : [];
6747
- }
6748
- };
6749
- }
6750
6752
  async function ensureServerSelectableSessionModel(params) {
6751
6753
  const availableModels = params.modelRegistry.getAvailable();
6752
6754
  if (availableModels.length === 0) {