@acryldev/workspace 0.2.2 → 0.2.3

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/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { randomBytes, randomUUID } from "node:crypto";
2
2
  import { basename, dirname, extname, isAbsolute, join, normalize, resolve, sep } from "node:path";
3
+ import { loopbackOnly, trustedFront } from "@acryldev/blends/loopback-only";
3
4
  import { Acryl } from "@acryldev/blends";
4
5
  import { INVALID_JSON, jsonBody, ownPage, ownPageSocket, privateApi, readJson } from "@acryldev/loopback-http/router";
5
6
  import { chmod, lstat, mkdir, readFile, readdir, realpath, rename, rmdir, stat, unlink, writeFile } from "node:fs/promises";
6
7
  import { bearerAuth } from "@acryldev/blends/bearer-auth";
7
- import { loopbackOnly } from "@acryldev/blends/loopback-only";
8
8
  import { execFile, spawn } from "node:child_process";
9
9
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
10
10
  import z from "@deepseek-ai/schemastery";
@@ -30,13 +30,14 @@ function isRecord$5(value) {
30
30
  }
31
31
  //#endregion
32
32
  //#region src/agents/known-agents.ts
33
- const agent = (id, label, command, homepageUrl, color, yoloArgs = [], yoloEnv) => ({
33
+ const agent = (id, label, command, homepageUrl, color, yoloArgs = [], yoloEnv, installCommand) => ({
34
34
  id,
35
35
  label,
36
36
  command,
37
37
  homepageUrl,
38
38
  yoloArgs,
39
39
  ...yoloEnv === void 0 ? {} : { yoloEnv },
40
+ ...installCommand === void 0 ? {} : { installCommand },
40
41
  badge: {
41
42
  letter: [...label][0]?.toUpperCase() ?? "?",
42
43
  color
@@ -45,15 +46,15 @@ const agent = (id, label, command, homepageUrl, color, yoloArgs = [], yoloEnv) =
45
46
  /** In the order the lists show them. Ids of agents that shipped earlier keep their spelling. */
46
47
  const KNOWN_AGENTS = [
47
48
  {
48
- ...agent("claude", "Claude", "claude", "https://code.claude.com/docs", "#d97757", ["--dangerously-skip-permissions"]),
49
+ ...agent("claude", "Claude", "claude", "https://code.claude.com/docs", "#d97757", ["--dangerously-skip-permissions"], void 0, "npm i -g @anthropic-ai/claude-code"),
49
50
  statusHooks: "claude"
50
51
  },
51
- agent("codex", "Codex", "codex", "https://github.com/openai/codex", "#10a37f", ["--dangerously-bypass-approvals-and-sandbox"]),
52
+ agent("codex", "Codex", "codex", "https://github.com/openai/codex", "#10a37f", ["--dangerously-bypass-approvals-and-sandbox"], void 0, "npm i -g @openai/codex"),
52
53
  agent("grok", "Grok", "grok", "https://x.ai/cli", "#94a3b8", ["--permission-mode", "bypassPermissions"]),
53
54
  agent("copilot", "GitHub Copilot", "copilot", "https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli", "#a78bfa", ["--yolo"]),
54
55
  agent("opencode", "OpenCode", "opencode", "https://opencode.ai/docs/cli/", "#94a3b8"),
55
56
  agent("ante", "Ante", "ante", "https://github.com/AntigmaLabs/ante-preview", "#fb923c", ["--yolo"]),
56
- agent("pi", "Pi", "pi", "https://pi.dev", "#a78bfa"),
57
+ agent("pi", "Pi", "pi", "https://pi.dev", "#a78bfa", [], void 0, "npm i -g @earendil-works/pi-coding-agent"),
57
58
  agent("omp", "OMP", "omp", "https://omp.sh", "#a78bfa"),
58
59
  agent("gemini", "Gemini", "gemini", "https://github.com/google-gemini/gemini-cli", "#4285f4", ["--yolo"]),
59
60
  agent("antigravity", "Antigravity", "agy", "https://antigravity.google/docs/cli-overview", "#4285f4", ["--dangerously-skip-permissions"]),
@@ -2959,7 +2960,10 @@ var WorkspacePtyRegistry = class {
2959
2960
  let process;
2960
2961
  try {
2961
2962
  const resolved = resolveWorkspacePtyCommand(plan.command, dirs, this.platform);
2962
- if (resolved === void 0 && !plan.command.includes("/") && !plan.command.includes("\\")) throw new Error(`workspace PTY command not found in PATH: ${plan.command}`);
2963
+ if (resolved === void 0 && !plan.command.includes("/") && !plan.command.includes("\\")) {
2964
+ const install = known?.installCommand;
2965
+ throw new Error(`workspace PTY command not found in PATH: ${plan.command}${install === void 0 ? "" : ` - install it with: ${install}`}`);
2966
+ }
2963
2967
  const reporting = plan.statusHooks !== void 0 && this.agentStatus !== void 0;
2964
2968
  const shared = commandId === "shell" ? void 0 : this.launchContext?.launchFor(commandId, cwd ?? this.cwd);
2965
2969
  const args = [
@@ -3673,7 +3677,7 @@ const inject = [
3673
3677
  * @param ctx - Host context for this generation.
3674
3678
  */
3675
3679
  function apply(ctx, config = {}) {
3676
- if (ctx.acrylWeb.host !== "127.0.0.1") throw new Error("@acryldev/workspace: requires a loopback Web server");
3680
+ if (ctx.acrylWeb.host !== "127.0.0.1" && trustedFront() === void 0) throw new Error("@acryldev/workspace: requires a loopback Web server, or a hosted app with a trusted front (ACRYL_PUBLIC_ORIGIN and ACRYL_TRUSTED_PROXY)");
3677
3681
  const appPage = typeof config.appPage === "string" && config.appPage.startsWith("/") ? config.appPage : void 0;
3678
3682
  const rendererOrigin = `http://127.0.0.1:${String(ctx.acrylWeb.port)}`;
3679
3683
  const reportHostError = (operation, cause) => {