@docyrus/docyrus 0.0.56 → 0.0.58

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
@@ -139349,7 +139349,7 @@ function buildInputSchema(args2, env2, options2) {
139349
139349
  // package.json
139350
139350
  var package_default = {
139351
139351
  name: "@docyrus/docyrus",
139352
- version: "0.0.56",
139352
+ version: "0.0.58",
139353
139353
  private: false,
139354
139354
  description: "Docyrus API CLI",
139355
139355
  main: "./main.js",
@@ -139372,8 +139372,8 @@ var package_default = {
139372
139372
  "@repomix/tree-sitter-wasms": "^0.1.16",
139373
139373
  "@sinclair/typebox": "^0.34.48",
139374
139374
  "@xterm/headless": "^5.5.0",
139375
- diff: "^8.0.4",
139376
- hono: "^4.12.12",
139375
+ diff: "^9.0.0",
139376
+ hono: "^4.12.14",
139377
139377
  "ignore-walk": "^8.0.0",
139378
139378
  incur: "^0.1.6",
139379
139379
  jsdom: "^29.0.1",
@@ -139866,7 +139866,8 @@ function createServerCli(dependencies) {
139866
139866
  sessionDir: external_exports.string().optional().describe("Override session storage directory"),
139867
139867
  apiKey: external_exports.string().optional().describe("Temporary provider API key override for this run"),
139868
139868
  auth: external_exports.string().optional().describe("Require this bearer token for all HTTP requests"),
139869
- verbose: external_exports.boolean().optional().describe("Enable verbose pi startup output")
139869
+ verbose: external_exports.boolean().optional().describe("Enable verbose pi startup output"),
139870
+ sandbox: external_exports.boolean().optional().describe("Enable sandbox browser mode (remote Cloudflare Browser Rendering)")
139870
139871
  }),
139871
139872
  run: async (context) => {
139872
139873
  await dependencies.launchPiAgentServer({
@@ -139878,7 +139879,8 @@ function createServerCli(dependencies) {
139878
139879
  sessionDir: context.options.sessionDir,
139879
139880
  apiKey: context.options.apiKey,
139880
139881
  auth: context.options.auth,
139881
- verbose: context.options.verbose || hasRawVerboseFlag2() ? true : void 0
139882
+ verbose: context.options.verbose || hasRawVerboseFlag2() ? true : void 0,
139883
+ sandbox: context.options.sandbox
139882
139884
  });
139883
139885
  }
139884
139886
  });
@@ -140668,6 +140670,38 @@ function createAuthCli(dependencies) {
140668
140670
  });
140669
140671
  }
140670
140672
  });
140673
+ authCli.command("sso-session", {
140674
+ description: "Create a short-lived SSO session token for headless browser authentication",
140675
+ options: external_exports.object({
140676
+ clientId: external_exports.string().min(1).describe("Target app's OAuth2 client ID"),
140677
+ scope: external_exports.string().default(DEFAULT_LOGIN_SCOPES).describe("OAuth2 scopes for the SSO session"),
140678
+ targetOrigin: external_exports.string().optional().describe("Restrict token exchange to this origin")
140679
+ }),
140680
+ run: async (context) => {
140681
+ const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
140682
+ const apiClient = dependencies.createApiClient(apiBaseUrl);
140683
+ const response = await apiClient.request({
140684
+ method: "POST",
140685
+ path: "/oauth2/sso/session",
140686
+ body: {
140687
+ client_id: context.options.clientId,
140688
+ scope: context.options.scope,
140689
+ target_origin: context.options.targetOrigin
140690
+ }
140691
+ });
140692
+ const ssoToken = response.data.sso_token;
140693
+ const targetOrigin = context.options.targetOrigin;
140694
+ return await injectContext({
140695
+ apiBaseUrl,
140696
+ authStore: dependencies.authStore,
140697
+ payload: {
140698
+ sso_token: ssoToken,
140699
+ expires_in: response.data.expires_in,
140700
+ url: targetOrigin ? `${targetOrigin}?sso_token=${ssoToken}` : void 0
140701
+ }
140702
+ });
140703
+ }
140704
+ });
140671
140705
  authCli.command("github", {
140672
140706
  description: "Regenerate the GitHub token and inject it into the active sandbox",
140673
140707
  options: external_exports.object({
@@ -140702,7 +140736,7 @@ function createAuthCli(dependencies) {
140702
140736
  return authCli;
140703
140737
  }
140704
140738
 
140705
- // src/commands/chromeCommands.ts
140739
+ // src/commands/browserCommands.ts
140706
140740
  var import_node_child_process3 = require("node:child_process");
140707
140741
  var import_node_fs3 = require("node:fs");
140708
140742
  var import_node_path4 = require("node:path");
@@ -140712,33 +140746,33 @@ function summarizeFailure(result) {
140712
140746
  return stderr;
140713
140747
  }
140714
140748
  if (typeof result.status === "number") {
140715
- return `Chrome tool exited with code ${result.status}.`;
140749
+ return `Browser tool exited with code ${result.status}.`;
140716
140750
  }
140717
140751
  if (result.signal) {
140718
- return `Chrome tool exited due to signal ${result.signal}.`;
140752
+ return `Browser tool exited due to signal ${result.signal}.`;
140719
140753
  }
140720
- return "Chrome tool terminated unexpectedly.";
140754
+ return "Browser tool terminated unexpectedly.";
140721
140755
  }
140722
- function resolveChromeToolsResourceRoot(options2 = {}) {
140756
+ function resolveBrowserToolsResourceRoot(options2 = {}) {
140723
140757
  const cwd = options2.cwd ?? process.cwd();
140724
140758
  const dirname13 = options2.dirname ?? __dirname;
140725
140759
  const fileExists = options2.existsSyncFn ?? import_node_fs3.existsSync;
140726
140760
  const candidates = options2.candidatePaths ?? [
140727
- (0, import_node_path4.resolve)(cwd, "apps/api-cli/resources/chrome-tools"),
140728
- (0, import_node_path4.resolve)(dirname13, "../resources/chrome-tools"),
140729
- (0, import_node_path4.resolve)(dirname13, "resources/chrome-tools"),
140730
- (0, import_node_path4.resolve)(cwd, "dist/apps/api-cli/resources/chrome-tools")
140761
+ (0, import_node_path4.resolve)(cwd, "apps/api-cli/resources/browser-tools"),
140762
+ (0, import_node_path4.resolve)(dirname13, "../resources/browser-tools"),
140763
+ (0, import_node_path4.resolve)(dirname13, "resources/browser-tools"),
140764
+ (0, import_node_path4.resolve)(cwd, "dist/apps/api-cli/resources/browser-tools")
140731
140765
  ];
140732
140766
  const resolved = candidates.find((candidate) => fileExists(candidate));
140733
140767
  if (!resolved) {
140734
- throw new UserInputError(`Unable to locate chrome tool resources. Checked: ${candidates.join(", ")}`);
140768
+ throw new UserInputError(`Unable to locate browser tool resources. Checked: ${candidates.join(", ")}`);
140735
140769
  }
140736
140770
  return resolved;
140737
140771
  }
140738
- function resolveChromeToolScriptPath(params) {
140772
+ function resolveBrowserToolScriptPath(params) {
140739
140773
  const scriptPath = (0, import_node_path4.join)(params.resourceRoot, params.scriptName);
140740
140774
  if (!(0, import_node_fs3.existsSync)(scriptPath)) {
140741
- throw new UserInputError(`Missing chrome tool script: ${scriptPath}`);
140775
+ throw new UserInputError(`Missing browser tool script: ${scriptPath}`);
140742
140776
  }
140743
140777
  return scriptPath;
140744
140778
  }
@@ -140753,18 +140787,18 @@ function parseJsonOutput(rawOutput) {
140753
140787
  try {
140754
140788
  return JSON.parse(trimmedOutput);
140755
140789
  } catch (error48) {
140756
- throw new UserInputError("Chrome tool returned invalid JSON output.", {
140790
+ throw new UserInputError("Browser tool returned invalid JSON output.", {
140757
140791
  cause: error48,
140758
140792
  rawOutput: trimmedOutput
140759
140793
  });
140760
140794
  }
140761
140795
  }
140762
- function executeChromeTool(params) {
140763
- const resolveResourceRoot = params.resolveChromeToolsResourceRootFn ?? resolveChromeToolsResourceRoot;
140796
+ function executeBrowserTool(params) {
140797
+ const resolveResourceRoot = params.resolveBrowserToolsResourceRootFn ?? resolveBrowserToolsResourceRoot;
140764
140798
  const resourceRoot = resolveResourceRoot({
140765
140799
  cwd: params.cwd
140766
140800
  });
140767
- const scriptPath = resolveChromeToolScriptPath({
140801
+ const scriptPath = resolveBrowserToolScriptPath({
140768
140802
  resourceRoot,
140769
140803
  scriptName: params.scriptName
140770
140804
  });
@@ -140778,12 +140812,12 @@ function executeChromeTool(params) {
140778
140812
  }
140779
140813
  });
140780
140814
  if (result.error) {
140781
- throw new UserInputError(`Unable to start chrome tool '${params.scriptName}': ${result.error.message}`, {
140815
+ throw new UserInputError(`Unable to start browser tool '${params.scriptName}': ${result.error.message}`, {
140782
140816
  cause: result.error
140783
140817
  });
140784
140818
  }
140785
140819
  if (result.status !== 0) {
140786
- throw new UserInputError(`Chrome tool '${params.scriptName}' failed: ${summarizeFailure(result)}`);
140820
+ throw new UserInputError(`Browser tool '${params.scriptName}' failed: ${summarizeFailure(result)}`);
140787
140821
  }
140788
140822
  const stdout = result.stdout?.toString() || "";
140789
140823
  if (params.outputMode === "json") {
@@ -140791,29 +140825,30 @@ function executeChromeTool(params) {
140791
140825
  }
140792
140826
  return parseTextOutput(stdout);
140793
140827
  }
140794
- function createChromeCli(options2 = {}) {
140795
- const chromeCli = Cli_exports.create("chrome", {
140796
- description: "Chrome DevTools browser automation commands",
140828
+ function createBrowserCli(options2 = {}) {
140829
+ const browserCli = Cli_exports.create("browser", {
140830
+ description: "Browser automation commands (local Chrome or remote Cloudflare)",
140797
140831
  env: EnvSchema
140798
140832
  });
140799
- chromeCli.command("start", {
140800
- description: "Launch Chrome with remote debugging on :9222",
140833
+ browserCli.command("start", {
140834
+ description: "Start a browser session (local Chrome or remote Cloudflare)",
140801
140835
  options: external_exports.object({
140802
- profile: external_exports.boolean().optional().describe("Copy your default Chrome profile (cookies, logins)")
140836
+ profile: external_exports.boolean().optional().describe("Copy your default Chrome profile (cookies, logins) \u2014 local mode only")
140803
140837
  }),
140804
140838
  run: async (context) => {
140805
- return executeChromeTool({
140839
+ return executeBrowserTool({
140806
140840
  scriptName: "browser-start.js",
140807
140841
  args: context.options.profile ? ["--profile"] : [],
140842
+ outputMode: "json",
140808
140843
  cwd: options2.cwd,
140809
140844
  processExecPath: options2.processExecPath,
140810
140845
  spawnSyncFn: options2.spawnSyncFn,
140811
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140846
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140812
140847
  });
140813
140848
  }
140814
140849
  });
140815
- chromeCli.command("nav", {
140816
- description: "Navigate the current Chrome tab or open a URL in a new tab",
140850
+ browserCli.command("nav", {
140851
+ description: "Navigate the active tab or open a URL in a new tab",
140817
140852
  args: external_exports.object({
140818
140853
  url: external_exports.string().min(1)
140819
140854
  }),
@@ -140829,112 +140864,128 @@ function createChromeCli(options2 = {}) {
140829
140864
  if (context.options.reload) {
140830
140865
  args2.push("--reload");
140831
140866
  }
140832
- return executeChromeTool({
140867
+ return executeBrowserTool({
140833
140868
  scriptName: "browser-nav.js",
140834
140869
  args: args2,
140870
+ outputMode: "json",
140835
140871
  cwd: options2.cwd,
140836
140872
  processExecPath: options2.processExecPath,
140837
140873
  spawnSyncFn: options2.spawnSyncFn,
140838
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140874
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140839
140875
  });
140840
140876
  }
140841
140877
  });
140842
- chromeCli.command("eval", {
140843
- description: "Evaluate JavaScript in the active Chrome tab",
140878
+ browserCli.command("eval", {
140879
+ description: "Evaluate JavaScript in the active browser tab",
140844
140880
  args: external_exports.object({
140845
140881
  code: external_exports.string().min(1)
140846
140882
  }),
140847
140883
  run: async (context) => {
140848
- return executeChromeTool({
140884
+ return executeBrowserTool({
140849
140885
  scriptName: "browser-eval.js",
140850
140886
  args: [context.args.code],
140887
+ outputMode: "json",
140851
140888
  cwd: options2.cwd,
140852
140889
  processExecPath: options2.processExecPath,
140853
140890
  spawnSyncFn: options2.spawnSyncFn,
140854
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140891
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140855
140892
  });
140856
140893
  }
140857
140894
  });
140858
- chromeCli.command("screenshot", {
140859
- description: "Capture a screenshot of the active Chrome tab",
140895
+ browserCli.command("screenshot", {
140896
+ description: "Capture a screenshot of the active browser tab",
140860
140897
  run: async () => {
140861
- return executeChromeTool({
140898
+ return executeBrowserTool({
140862
140899
  scriptName: "browser-screenshot.js",
140863
140900
  args: [],
140901
+ outputMode: "json",
140864
140902
  cwd: options2.cwd,
140865
140903
  processExecPath: options2.processExecPath,
140866
140904
  spawnSyncFn: options2.spawnSyncFn,
140867
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140905
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140868
140906
  });
140869
140907
  }
140870
140908
  });
140871
- chromeCli.command("pick", {
140872
- description: "Interactively pick DOM elements in the active Chrome tab",
140909
+ browserCli.command("pick", {
140910
+ description: "Interactively pick DOM elements in the active browser tab",
140873
140911
  args: external_exports.object({
140874
140912
  message: external_exports.string().min(1)
140875
140913
  }),
140876
140914
  run: async (context) => {
140877
- return executeChromeTool({
140915
+ return executeBrowserTool({
140878
140916
  scriptName: "browser-pick.js",
140879
140917
  args: [context.args.message],
140918
+ outputMode: "json",
140880
140919
  cwd: options2.cwd,
140881
140920
  processExecPath: options2.processExecPath,
140882
140921
  spawnSyncFn: options2.spawnSyncFn,
140883
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140922
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140884
140923
  });
140885
140924
  }
140886
140925
  });
140887
- chromeCli.command("cookies", {
140888
- description: "Show cookies for the active Chrome tab",
140926
+ browserCli.command("cookies", {
140927
+ description: "Show cookies for the active browser tab",
140889
140928
  run: async () => {
140890
- return executeChromeTool({
140929
+ return executeBrowserTool({
140891
140930
  scriptName: "browser-cookies.js",
140892
140931
  args: [],
140932
+ outputMode: "json",
140893
140933
  cwd: options2.cwd,
140894
140934
  processExecPath: options2.processExecPath,
140895
140935
  spawnSyncFn: options2.spawnSyncFn,
140896
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140936
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140897
140937
  });
140898
140938
  }
140899
140939
  });
140900
- chromeCli.command("content", {
140901
- description: "Extract readable markdown content from a URL in Chrome",
140940
+ browserCli.command("content", {
140941
+ description: "Extract readable markdown content from a URL",
140902
140942
  args: external_exports.object({
140903
140943
  url: external_exports.string().min(1)
140904
140944
  }),
140905
140945
  run: async (context) => {
140906
- return executeChromeTool({
140946
+ return executeBrowserTool({
140907
140947
  scriptName: "browser-content.js",
140908
140948
  args: [context.args.url],
140909
140949
  cwd: options2.cwd,
140910
140950
  processExecPath: options2.processExecPath,
140911
140951
  spawnSyncFn: options2.spawnSyncFn,
140912
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140952
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140913
140953
  });
140914
140954
  }
140915
140955
  });
140916
- chromeCli.command("hn-scraper", {
140917
- description: "Scrape Hacker News submissions as JSON",
140956
+ browserCli.command("run-script", {
140957
+ description: "Run a CDP script on the active browser session",
140958
+ args: external_exports.object({
140959
+ script: external_exports.string().min(1).describe("Path to a JS/TS file containing the CDP script to execute")
140960
+ }),
140918
140961
  options: external_exports.object({
140919
- limit: external_exports.number().int().positive().optional().describe("Maximum number of submissions to return")
140962
+ appSlug: external_exports.string().optional().describe("App slug to resolve the browser session from"),
140963
+ appId: external_exports.string().optional().describe("App ID to resolve the browser session from"),
140964
+ keepAlive: external_exports.number().int().positive().optional().describe("Session keep-alive in milliseconds (default: 600000)")
140920
140965
  }),
140921
140966
  run: async (context) => {
140922
- const args2 = [];
140923
- if (context.options.limit !== void 0) {
140924
- args2.push("--limit", String(context.options.limit));
140967
+ const args2 = [context.args.script];
140968
+ if (context.options.appSlug) {
140969
+ args2.push("--appSlug", context.options.appSlug);
140970
+ }
140971
+ if (context.options.appId) {
140972
+ args2.push("--appId", context.options.appId);
140973
+ }
140974
+ if (context.options.keepAlive !== void 0) {
140975
+ args2.push("--keepAlive", String(context.options.keepAlive));
140925
140976
  }
140926
- return executeChromeTool({
140927
- scriptName: "browser-hn-scraper.js",
140977
+ return executeBrowserTool({
140978
+ scriptName: "browser-run-script.js",
140928
140979
  args: args2,
140929
140980
  outputMode: "json",
140930
140981
  cwd: options2.cwd,
140931
140982
  processExecPath: options2.processExecPath,
140932
140983
  spawnSyncFn: options2.spawnSyncFn,
140933
- resolveChromeToolsResourceRootFn: options2.resolveChromeToolsResourceRootFn
140984
+ resolveBrowserToolsResourceRootFn: options2.resolveBrowserToolsResourceRootFn
140934
140985
  });
140935
140986
  }
140936
140987
  });
140937
- return chromeCli;
140988
+ return browserCli;
140938
140989
  }
140939
140990
 
140940
140991
  // src/services/inputReader.ts
@@ -154272,6 +154323,16 @@ function createPiAgentServerLauncher(options2) {
154272
154323
  cwd,
154273
154324
  spawnCommand: import_node_child_process9.spawnSync
154274
154325
  });
154326
+ if (request.sandbox) {
154327
+ const browserConfigDir = settingsRootPath;
154328
+ (0, import_node_fs18.mkdirSync)(browserConfigDir, { recursive: true, mode: 448 });
154329
+ const browserConfigPath = (0, import_node_path29.join)(browserConfigDir, "browser.json");
154330
+ const appId = process.env.DOCYRUS_SANDBOX_APP_ID || "";
154331
+ (0, import_node_fs18.writeFileSync)(browserConfigPath, JSON.stringify({ mode: "sandbox", appId }, null, 2) + "\n", {
154332
+ encoding: "utf8",
154333
+ mode: 384
154334
+ });
154335
+ }
154275
154336
  spinner.stop();
154276
154337
  const loaderEntryPath = resolveServerLoaderEntryPath(cwd, __dirname);
154277
154338
  const piPackageRoot = resolveInstalledPiPackageRootPath({ cwd });
@@ -154290,7 +154351,8 @@ function createPiAgentServerLauncher(options2) {
154290
154351
  DOCYRUS_CLI_EXECUTABLE: process.execPath,
154291
154352
  DOCYRUS_CLI_ENTRY: cliEntryPath,
154292
154353
  DOCYRUS_CLI_SCOPE: options2.settingsPaths.scope,
154293
- OFFICECLI_SKIP_UPDATE: "1"
154354
+ OFFICECLI_SKIP_UPDATE: "1",
154355
+ ...request.sandbox ? { DOCYRUS_BROWSER_SANDBOX: "1" } : {}
154294
154356
  }
154295
154357
  });
154296
154358
  await new Promise((resolve2, reject) => {
@@ -154475,9 +154537,9 @@ var ROOT_HELP_COMMANDS = [
154475
154537
  { command: "agent [prompt]", description: "Launch the Docyrus Cowork Agent" },
154476
154538
  { command: "coder [prompt]", description: "Launch the Docyrus Coding Agent" },
154477
154539
  { command: "server", description: "Start HTTP server bridging pi agent to AI SDK useChat" },
154478
- { command: "chrome start", description: "Launch Chrome with remote debugging on :9222" },
154479
- { command: "chrome nav <url>", description: "Navigate the active Chrome tab" },
154480
- { command: "chrome content <url>", description: "Extract readable page content as markdown" },
154540
+ { command: "browser start", description: "Start a browser session (local Chrome or remote Cloudflare)" },
154541
+ { command: "browser nav <url>", description: "Navigate the active browser tab" },
154542
+ { command: "browser content <url>", description: "Extract readable page content as markdown" },
154481
154543
  { command: "discover api", description: "Download active tenant OpenAPI spec" },
154482
154544
  { command: "discover namespaces", description: "List namespaces from tenant OpenAPI spec" },
154483
154545
  { command: "discover path <prefix>", description: "List endpoint paths by prefix" },
@@ -154589,7 +154651,7 @@ function createDocyrusCli(params) {
154589
154651
  cli2.command(createServerCli({
154590
154652
  launchPiAgentServer: piAgentServerLauncher
154591
154653
  }));
154592
- cli2.command(createChromeCli({
154654
+ cli2.command(createBrowserCli({
154593
154655
  cwd: params?.cwd
154594
154656
  }));
154595
154657
  cli2.command(createDsCli({