@docyrus/docyrus 0.0.32 → 0.0.34

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/main.js CHANGED
@@ -124764,7 +124764,7 @@ function buildInputSchema(args, env2, options2) {
124764
124764
  // package.json
124765
124765
  var package_default = {
124766
124766
  name: "@docyrus/docyrus",
124767
- version: "0.0.32",
124767
+ version: "0.0.34",
124768
124768
  private: false,
124769
124769
  description: "Docyrus API CLI",
124770
124770
  main: "./main.js",
@@ -129577,18 +129577,19 @@ var DOCYRUS_EXTERNAL_SKILL_AGENT_IDS = [
129577
129577
  ];
129578
129578
  var DOCYRUS_EXTERNAL_SKILL_MARKER_FILE = ".docyrus-external-skills-installed.json";
129579
129579
  var DOCYRUS_DIFFITY_PACKAGE_SPEC = "diffity@0.9.0";
129580
- function summarizeFailure3(result) {
129580
+ var DOCYRUS_OFFICECLI_RELEASES_BASE_URL = "https://github.com/iOfficeAI/OfficeCli/releases/latest/download";
129581
+ function summarizeFailure3(result, commandLabel = "Command") {
129581
129582
  const stderr = result.stderr?.toString().trim();
129582
129583
  if (stderr && stderr.length > 0) {
129583
129584
  return stderr;
129584
129585
  }
129585
129586
  if (typeof result.status === "number") {
129586
- return `Docyrus pi loader exited with code ${result.status}.`;
129587
+ return `${commandLabel} exited with code ${result.status}.`;
129587
129588
  }
129588
129589
  if (result.signal) {
129589
- return `Docyrus pi loader exited due to signal ${result.signal}.`;
129590
+ return `${commandLabel} exited due to signal ${result.signal}.`;
129590
129591
  }
129591
- return "Docyrus pi loader terminated unexpectedly.";
129592
+ return `${commandLabel} terminated unexpectedly.`;
129592
129593
  }
129593
129594
  function resolvePackagedPiResourceRoot(options2 = {}) {
129594
129595
  const cwd = options2.cwd ?? process.cwd();
@@ -129866,7 +129867,7 @@ async function installExternalDocyrusSkillsOnce(params) {
129866
129867
  });
129867
129868
  if (result.error || result.status !== 0) {
129868
129869
  process.stderr.write(
129869
- `[docyrus] Automatic Docyrus skill install failed. Continuing without it: ${result.error?.message || summarizeFailure3(result)}
129870
+ `[docyrus] Automatic Docyrus skill install failed. Continuing without it: ${result.error?.message || summarizeFailure3(result, "npx skills add")}
129870
129871
  `
129871
129872
  );
129872
129873
  return;
@@ -129908,7 +129909,7 @@ async function ensureManagedDiffityInstalled(params) {
129908
129909
  );
129909
129910
  if (result.error || result.status !== 0) {
129910
129911
  process.stderr.write(
129911
- `[docyrus] Automatic diffity install failed. Continuing without it: ${result.error?.message || summarizeFailure3(result)}
129912
+ `[docyrus] Automatic diffity install failed. Continuing without it: ${result.error?.message || summarizeFailure3(result, "npm install diffity")}
129912
129913
  `
129913
129914
  );
129914
129915
  return {
@@ -129926,6 +129927,114 @@ async function ensureManagedDiffityInstalled(params) {
129926
129927
  function resolvePackagedDocyrusPlatformSkillPath(resourceRoot) {
129927
129928
  return (0, import_node_path11.join)(resourceRoot, "skills", DOCYRUS_PACKAGED_PLATFORM_SKILL_NAME);
129928
129929
  }
129930
+ function resolveManagedOfficeCliInstallRoot(agentRootPath) {
129931
+ return (0, import_node_path11.join)(agentRootPath, "tools", "officecli");
129932
+ }
129933
+ function resolveManagedOfficeCliExecutablePath(agentRootPath) {
129934
+ return (0, import_node_path11.join)(
129935
+ resolveManagedOfficeCliInstallRoot(agentRootPath),
129936
+ process.platform === "win32" ? "officecli.exe" : "officecli"
129937
+ );
129938
+ }
129939
+ function resolveOfficeCliReleaseAssetName() {
129940
+ switch (process.platform) {
129941
+ case "darwin":
129942
+ if (process.arch === "arm64") {
129943
+ return "officecli-mac-arm64";
129944
+ }
129945
+ if (process.arch === "x64") {
129946
+ return "officecli-mac-x64";
129947
+ }
129948
+ break;
129949
+ case "linux": {
129950
+ const alpineSuffix = (0, import_node_fs5.existsSync)("/etc/alpine-release") ? "-alpine" : "";
129951
+ if (process.arch === "arm64") {
129952
+ return `officecli-linux${alpineSuffix}-arm64`;
129953
+ }
129954
+ if (process.arch === "x64") {
129955
+ return `officecli-linux${alpineSuffix}-x64`;
129956
+ }
129957
+ break;
129958
+ }
129959
+ case "win32":
129960
+ if (process.arch === "arm64") {
129961
+ return "officecli-win-arm64.exe";
129962
+ }
129963
+ if (process.arch === "x64") {
129964
+ return "officecli-win-x64.exe";
129965
+ }
129966
+ break;
129967
+ default:
129968
+ break;
129969
+ }
129970
+ throw new UserInputError(`OfficeCLI is not supported on ${process.platform}/${process.arch}.`);
129971
+ }
129972
+ async function ensureManagedOfficeCliInstalled(params) {
129973
+ const executablePath = resolveManagedOfficeCliExecutablePath(params.agentRootPath);
129974
+ const binDir = (0, import_node_path11.dirname)(executablePath);
129975
+ if ((0, import_node_fs5.existsSync)(executablePath)) {
129976
+ return {
129977
+ available: true,
129978
+ executablePath,
129979
+ binDir
129980
+ };
129981
+ }
129982
+ const tempPath = `${executablePath}.download${process.platform === "win32" ? ".exe" : ""}`;
129983
+ try {
129984
+ await (0, import_promises8.mkdir)(binDir, {
129985
+ recursive: true,
129986
+ mode: 448
129987
+ });
129988
+ const assetName = resolveOfficeCliReleaseAssetName();
129989
+ const response = await fetch(`${DOCYRUS_OFFICECLI_RELEASES_BASE_URL}/${assetName}`);
129990
+ if (!response.ok) {
129991
+ throw new UserInputError(`OfficeCLI download failed with status ${response.status}.`);
129992
+ }
129993
+ const binary = Buffer.from(await response.arrayBuffer());
129994
+ await (0, import_promises8.writeFile)(tempPath, binary, {
129995
+ mode: process.platform === "win32" ? 384 : 448
129996
+ });
129997
+ if (process.platform !== "win32") {
129998
+ await (0, import_promises8.chmod)(tempPath, 448);
129999
+ }
130000
+ const verificationResult = params.spawnCommand(tempPath, ["--version"], {
130001
+ stdio: ["ignore", "pipe", "pipe"],
130002
+ encoding: "utf8",
130003
+ cwd: params.cwd,
130004
+ env: {
130005
+ ...process.env,
130006
+ OFFICECLI_SKIP_UPDATE: "1"
130007
+ }
130008
+ });
130009
+ if (verificationResult.error || verificationResult.status !== 0) {
130010
+ throw new UserInputError(
130011
+ verificationResult.error?.message || summarizeFailure3(verificationResult, "officecli --version")
130012
+ );
130013
+ }
130014
+ await (0, import_promises8.rename)(tempPath, executablePath);
130015
+ if (process.platform !== "win32") {
130016
+ await (0, import_promises8.chmod)(executablePath, 448);
130017
+ }
130018
+ return {
130019
+ available: true,
130020
+ executablePath,
130021
+ binDir
130022
+ };
130023
+ } catch (error48) {
130024
+ await (0, import_promises8.rm)(tempPath, {
130025
+ force: true
130026
+ });
130027
+ process.stderr.write(
130028
+ `[docyrus] Automatic OfficeCLI install failed. Continuing without it: ${error48 instanceof Error ? error48.message : "Unknown error"}
130029
+ `
130030
+ );
130031
+ return {
130032
+ available: false,
130033
+ executablePath,
130034
+ binDir
130035
+ };
130036
+ }
130037
+ }
129929
130038
  function installPackagedDocyrusPlatformSkill(params) {
129930
130039
  const skillSourcePath = resolvePackagedDocyrusPlatformSkillPath(params.resourceRoot);
129931
130040
  if (!(0, import_node_fs5.existsSync)(skillSourcePath)) {
@@ -129949,7 +130058,7 @@ function installPackagedDocyrusPlatformSkill(params) {
129949
130058
  );
129950
130059
  if (result.error || result.status !== 0) {
129951
130060
  process.stderr.write(
129952
- `[docyrus] Automatic docyrus-platform skill sync failed. Continuing without it: ${result.error?.message || summarizeFailure3(result)}
130061
+ `[docyrus] Automatic docyrus-platform skill sync failed. Continuing without it: ${result.error?.message || summarizeFailure3(result, "npx skills add")}
129953
130062
  `
129954
130063
  );
129955
130064
  }
@@ -130016,10 +130125,16 @@ function createPiAgentLauncher(options2) {
130016
130125
  cwd,
130017
130126
  spawnCommand
130018
130127
  });
130128
+ const officeCli = await ensureManagedOfficeCliInstalled({
130129
+ agentRootPath,
130130
+ cwd,
130131
+ spawnCommand
130132
+ });
130019
130133
  spinner.stop();
130020
130134
  const loaderEntryPath = resolveLoaderPath({ cwd });
130021
130135
  const cliEntryPath = resolveCliEntryPath({ cwd });
130022
130136
  const piPackageRoot = resolvePiPackageRoot({ cwd });
130137
+ const runtimePath = officeCli.available ? prependPathEntry(officeCli.binDir, process.env.PATH) : process.env.PATH;
130023
130138
  const result = spawnCommand(processExecPath, [loaderEntryPath], {
130024
130139
  stdio: ["inherit", "inherit", "inherit"],
130025
130140
  encoding: "utf8",
@@ -130033,7 +130148,8 @@ function createPiAgentLauncher(options2) {
130033
130148
  DOCYRUS_CLI_EXECUTABLE: processExecPath,
130034
130149
  DOCYRUS_CLI_ENTRY: cliEntryPath,
130035
130150
  DOCYRUS_CLI_SCOPE: options2.settingsPaths.scope,
130036
- PATH: diffity.available ? prependPathEntry(diffity.binDir, process.env.PATH) : process.env.PATH
130151
+ OFFICECLI_SKIP_UPDATE: "1",
130152
+ PATH: diffity.available ? prependPathEntry(diffity.binDir, runtimePath) : runtimePath
130037
130153
  }
130038
130154
  });
130039
130155
  if (result.error) {
@@ -130042,7 +130158,7 @@ function createPiAgentLauncher(options2) {
130042
130158
  });
130043
130159
  }
130044
130160
  if (result.status !== 0) {
130045
- throw new UserInputError(`Docyrus pi loader failed: ${summarizeFailure3(result)}`);
130161
+ throw new UserInputError(`Docyrus pi loader failed: ${summarizeFailure3(result, "Docyrus pi loader")}`);
130046
130162
  }
130047
130163
  };
130048
130164
  }
@@ -130126,18 +130242,27 @@ function createPiAgentServerLauncher(options2) {
130126
130242
  scope: options2.settingsPaths.scope,
130127
130243
  spawnCommand: import_node_child_process5.spawnSync
130128
130244
  });
130245
+ spinner.update("Installing tools...");
130246
+ const officeCli = await ensureManagedOfficeCliInstalled({
130247
+ agentRootPath,
130248
+ cwd,
130249
+ spawnCommand: import_node_child_process5.spawnSync
130250
+ });
130129
130251
  spinner.stop();
130130
130252
  const loaderEntryPath = resolveServerLoaderEntryPath(cwd, __dirname);
130131
130253
  const piPackageRoot = resolveInstalledPiPackageRootPath({ cwd });
130254
+ const runtimePath = officeCli.available ? prependPathEntry(officeCli.binDir, process.env.PATH) : process.env.PATH;
130132
130255
  const child = (0, import_node_child_process5.spawn)(process.execPath, [loaderEntryPath], {
130133
130256
  stdio: "inherit",
130134
130257
  cwd,
130135
130258
  env: {
130136
130259
  ...process.env,
130260
+ PATH: runtimePath,
130137
130261
  PI_CODING_AGENT_DIR: agentRootPath,
130138
130262
  PI_PACKAGE_DIR: piPackageRoot,
130139
130263
  DOCYRUS_PI_REQUEST: serializePiAgentServerRequest(request),
130140
- DOCYRUS_PI_VERSION: options2.version || "dev"
130264
+ DOCYRUS_PI_VERSION: options2.version || "dev",
130265
+ OFFICECLI_SKIP_UPDATE: "1"
130141
130266
  }
130142
130267
  });
130143
130268
  await new Promise((resolve, reject) => {