@saadnvd1/agent-os 0.3.678 → 0.3.684

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.
@@ -11,6 +11,7 @@ import { healthConfig, type HealthConfig } from "./config";
11
11
  import { runDetectors } from "./detectors";
12
12
  import { gatherFacts, liveBackgroundJobs } from "./facts";
13
13
  import { envTick, realEnv, type EnvDeps } from "./env/envTick";
14
+ import { spinTick } from "./spin-tick";
14
15
  import { addNote } from "./notes";
15
16
  import { closeResolvedPieces } from "./pieces";
16
17
  import { deliver, deliverClosed, type RouteDeps, realRoute } from "./route";
@@ -43,9 +44,10 @@ export const MAX_WAKES = 2;
43
44
  // A wake that never came back (a restart cut it off) is given up on.
44
45
  export const WAKE_GIVE_UP_MS = 3 * MIN;
45
46
 
46
- // The checks the tick evaluates: piece-dup is raised where a piece starts.
47
+ // The checks the tick evaluates: piece-dup is raised where a piece starts,
48
+ // bg-spin by the process step (spin-tick.ts).
47
49
  export const TICK_CHECKS: readonly CheckId[] = CHECKS.filter(
48
- (c) => c !== "piece-dup"
50
+ (c) => c !== "piece-dup" && c !== "bg-spin"
49
51
  );
50
52
 
51
53
  export interface TickDeps {
@@ -54,6 +56,8 @@ export interface TickDeps {
54
56
  watch: WatchDeps;
55
57
  route: RouteDeps;
56
58
  env: EnvDeps;
59
+ // Stops background jobs that spin (spin-tick.ts).
60
+ spin: (now: number) => Promise<void>;
57
61
  wake: typeof wake;
58
62
  }
59
63
 
@@ -63,6 +67,7 @@ export const realTick: TickDeps = {
63
67
  watch: { run: runClaude, usagePct: currentUsagePct },
64
68
  route: realRoute,
65
69
  env: realEnv,
70
+ spin: spinTick,
66
71
  wake,
67
72
  };
68
73
 
@@ -145,6 +150,9 @@ export function healthTick(
145
150
  closeResolvedPieces(now);
146
151
  leaveHeartbeat(now, liveBackgroundJobs());
147
152
  giveUpStale(now, deps);
153
+ void deps
154
+ .spin(now)
155
+ .catch((error) => console.error("[health] spin check:", error));
148
156
  void envTick(now, c, deps.env).catch((error) =>
149
157
  console.error("[health] environment failures:", error)
150
158
  );
@@ -14,6 +14,7 @@ export const CHECKS = [
14
14
  "load-red",
15
15
  "queue-held",
16
16
  "bg-quiet",
17
+ "bg-spin",
17
18
  "piece-dup",
18
19
  "restarts",
19
20
  "ci-slow",
@@ -26,6 +27,7 @@ export const AREA_OF: Record<CheckId, Area> = {
26
27
  "load-red": "scheduler",
27
28
  "queue-held": "scheduler",
28
29
  "bg-quiet": "tasks",
30
+ "bg-spin": "tasks",
29
31
  "piece-dup": "pipeline",
30
32
  restarts: "pipeline",
31
33
  "ci-slow": "pipeline",
@@ -164,7 +164,7 @@ Acting:
164
164
 
165
165
  The MCP servers this workspace allows (Settings → Workspaces) are yours to use through their own tools, for reading and for additive, reversible changes. Anything outbound through them (sending a message, an email, a post) is a hard line: park it with \`ask_saad\`.
166
166
 
167
- Act through these tools, not the shell: they're scoped to this workspace and braked. ${full ? `The shell and your file writes are unchecked (Saad's decision, 2026-10-18: Orchestrator full access, switched in Settings → Workspaces): \`git push\`, \`gh pr merge\`, commits, \`stash\`, \`clean\`, edits in any project checkout or task worktree, AgentOS's own state, dotfiles, launch agents, .claude, CLAUDE.md, .mcp.json, hooks, \`sqlite3\` writes, \`aos sweep --arm\`, other workspaces' repositories. Use that to fix things directly instead of starting a task for every small job, but still prefer the tools for what they cover (they're scoped to this workspace and logged), and never use the shell to get around a hard line. One warning stays: never stop or restart AgentOS or its tmux; that ends every session it runs, this one included. If AgentOS itself needs a restart, \`ask_saad\`. Reading a secret file is allowed; its value is never printed, logged or sent off the machine. ` : `The shell runs anything without asking (Saad chose this on 2026-10-11), so use it to read and investigate yourself: \`gh pr list\`, \`gh run view --log-failed\`, \`gh api\` GETs, \`curl\`, \`sqlite3 -readonly\`, git in any repository, a skill's scripts, pipes and chains. Never use it to get around the tools. A deny list refuses, naming the tool to use instead: merging, closing or retargeting a PR (\`${TOOL_NAMES.sign_off}\`, \`${TOOL_NAMES.arm}\`, \`${TOOL_NAMES.land}\`, \`${TOOL_NAMES.drop}\`), \`git push\` (\`${TOOL_NAMES.quick_pr}\`), writing in a project repository or task worktree other than your own quick changes, except in a project checkout of your own workspace, where you may update and move the branch: \`git pull\` in any form, \`merge\`, \`reset\` (even \`--hard\`), \`checkout\`, \`switch\` and \`rebase\` (also as \`git -C <path>\`), then \`bundle install\`, \`npm install\` or \`bin/rails db:prepare\`. Commits, \`stash\`, \`clean\`, \`restore\` and file edits there still go through tasks and quick changes, and other workspaces' repositories, task worktrees and AgentOS's own live checkout (autodeploy deploys it) are refused for all of it are refused (\`${TOOL_NAMES.start_task}\`, \`${TOOL_NAMES.quick_change}\`), writing AgentOS's state (sqlite3 without \`-readonly\`, or files in ~/.agent-os outside your folder), stopping or restarting AgentOS or its tmux, and reading secret files (env files, keys, ~/.ssh, ~/.aws). `}Tokenvault is available through \`tv\`: use a token inside the command that needs it (e.g. \`FOO="\$(tv get <project> <desc>)" cmd\`), never print, echo or log a value, and never send one off the machine except to the service it's for. ${full ? `` : `The list catches honest mistakes, not a determined bypass: a script or \`python -c\` could do any of these unseen, and doing so would break Saad's trust in every gate. `}\`aos notify "<text>"\` pushes a message to Saad's phone. Use it for what he'd want to see now and asked for: the morning report, a real milestone (a stack landed, a blocker only he can clear). Never for routine status: one a minute at most, and he reads the rest here. ${full ? `You can read and write files anywhere (Read, Grep, Glob, Write, Edit, NotebookEdit); nothing is checked.` : `You can read files anywhere (Read, Grep, Glob), and write them (Write, Edit, NotebookEdit) anywhere except: a project repository or task worktree other than your own open quick changes' worktrees (start a task, or a quick change for a small edit, so the change goes through CI, review and scope), AgentOS's own state in ~/.agent-os outside your folder, secret files (.env, keys, ~/.ssh, ~/.aws, tokenvault and the like), and files that make something run: dotfiles and dot-folders at the top of your home (shell, git, Claude and tool config), ~/Library and /Library's launch agents, git's core.hooksPath folders, the folders on PATH, and any .git, .claude, .mcp.json, CLAUDE.md or AGENTS.md, which would hand you a shell or run code around the gates. Each write is checked before it runs, on the path with symlinks and \`..\` resolved; a refused one says why.`}
167
+ Act through these tools, not the shell: they're scoped to this workspace and braked. ${full ? `The shell and your file writes are unchecked (Saad's decision, 2026-10-18: Orchestrator full access, switched in Settings → Workspaces): \`git push\`, \`gh pr merge\`, commits, \`stash\`, \`clean\`, edits in any project checkout or task worktree, AgentOS's own state, dotfiles, launch agents, .claude, CLAUDE.md, .mcp.json, hooks, \`sqlite3\` writes, \`aos sweep --arm\`, other workspaces' repositories. Use that to fix things directly instead of starting a task for every small job, but still prefer the tools for what they cover (they're scoped to this workspace and logged), and never use the shell to get around a hard line. One warning stays: never stop or restart AgentOS or its tmux; that ends every session it runs, this one included. If AgentOS itself needs a restart, \`ask_saad\`. Reading a secret file is allowed; its value is never printed, logged or sent off the machine. ` : `The shell runs anything without asking (Saad chose this on 2026-10-11), so use it to read and investigate yourself: \`gh pr list\`, \`gh run view --log-failed\`, \`gh api\` GETs, \`curl\`, \`sqlite3 -readonly\`, git in any repository, a skill's scripts, pipes and chains. Never use it to get around the tools. A deny list refuses, naming the tool to use instead: merging, closing or retargeting a PR (\`${TOOL_NAMES.sign_off}\`, \`${TOOL_NAMES.arm}\`, \`${TOOL_NAMES.land}\`, \`${TOOL_NAMES.drop}\`), \`git push\` (\`${TOOL_NAMES.quick_pr}\`), writing in a project repository or task worktree other than your own quick changes, except in a project checkout of your own workspace, where you may update and move the branch: \`git pull\` in any form, \`merge\`, \`reset\` (even \`--hard\`), \`checkout\`, \`switch\` and \`rebase\` (also as \`git -C <path>\`), then \`bundle install\`, \`npm install\`, \`pnpm install\` or \`bin/rails db:prepare\`. Commits, \`stash\`, \`clean\`, \`restore\` and file edits there still go through tasks and quick changes, and other workspaces' repositories, task worktrees and AgentOS's own live checkout (autodeploy deploys it) are refused for all of it are refused (\`${TOOL_NAMES.start_task}\`, \`${TOOL_NAMES.quick_change}\`), writing AgentOS's state (sqlite3 without \`-readonly\`, or files in ~/.agent-os outside your folder), stopping or restarting AgentOS or its tmux, and reading secret files (env files, keys, ~/.ssh, ~/.aws). `}Tokenvault is available through \`tv\`: use a token inside the command that needs it (e.g. \`FOO="\$(tv get <project> <desc>)" cmd\`), never print, echo or log a value, and never send one off the machine except to the service it's for. ${full ? `` : `The list catches honest mistakes, not a determined bypass: a script or \`python -c\` could do any of these unseen, and doing so would break Saad's trust in every gate. `}\`aos notify "<text>"\` pushes a message to Saad's phone. Use it for what he'd want to see now and asked for: the morning report, a real milestone (a stack landed, a blocker only he can clear). Never for routine status: one a minute at most, and he reads the rest here. ${full ? `You can read and write files anywhere (Read, Grep, Glob, Write, Edit, NotebookEdit); nothing is checked.` : `You can read files anywhere (Read, Grep, Glob), and write them (Write, Edit, NotebookEdit) anywhere except: a project repository or task worktree other than your own open quick changes' worktrees (start a task, or a quick change for a small edit, so the change goes through CI, review and scope), AgentOS's own state in ~/.agent-os outside your folder, secret files (.env, keys, ~/.ssh, ~/.aws, tokenvault and the like), and files that make something run: dotfiles and dot-folders at the top of your home (shell, git, Claude and tool config), ~/Library and /Library's launch agents, git's core.hooksPath folders, the folders on PATH, and any .git, .claude, .mcp.json, CLAUDE.md or AGENTS.md, which would hand you a shell or run code around the gates. Each write is checked before it runs, on the path with symlinks and \`..\` resolved; a refused one says why.`}
168
168
 
169
169
  ## Untrusted text
170
170
 
package/lib/share/pdf.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import fs from "fs";
9
+ import path from "path";
9
10
  import type { Browser, LaunchOptions } from "playwright";
10
11
 
11
12
  const IDLE_MS = 60_000;
@@ -32,13 +33,43 @@ h1,h2,h3,h4{break-after:avoid}
32
33
  img{max-width:100%;break-inside:avoid}
33
34
  `;
34
35
 
36
+ /**
37
+ * Playwright's headless shell, which `playwright install
38
+ * chromium-headless-shell` puts beside the full Chromium (same cache folder,
39
+ * the revision the locked package names). Null when it isn't installed.
40
+ */
41
+ export function headlessShellPath(chromiumExecutable: string): string | null {
42
+ // <cache>/chromium-<rev>/<platform>/...: the shell's folder has the same <rev>.
43
+ const m = /^(.*)[\\/]chromium-(\d+)[\\/]/.exec(chromiumExecutable);
44
+ if (!m) return null;
45
+ const folder = path.join(m[1], `chromium_headless_shell-${m[2]}`);
46
+ let platform: string | undefined;
47
+ try {
48
+ platform = fs
49
+ .readdirSync(folder)
50
+ .find((d) => d.startsWith("chrome-headless-shell-"));
51
+ } catch {
52
+ return null;
53
+ }
54
+ if (!platform) return null;
55
+ const exe = path.join(
56
+ folder,
57
+ platform,
58
+ process.platform === "win32"
59
+ ? "chrome-headless-shell.exe"
60
+ : "chrome-headless-shell"
61
+ );
62
+ return fs.existsSync(exe) ? exe : null;
63
+ }
64
+
35
65
  let found: LaunchOptions | null | undefined;
36
66
 
37
67
  /** How to launch a browser on this machine, or null when there is none. */
38
68
  export async function findBrowser(): Promise<LaunchOptions | null> {
39
69
  if (found !== undefined) return found;
40
70
  const { chromium } = await import("playwright");
41
- const candidates = [chromium.executablePath(), ...CHROME_PATHS];
71
+ const full = chromium.executablePath();
72
+ const candidates = [headlessShellPath(full), full, ...CHROME_PATHS];
42
73
  const path = candidates.find((p) => p && fs.existsSync(p));
43
74
  found = path ? { executablePath: path, headless: true } : null;
44
75
  return found;
@@ -20,8 +20,10 @@ const tail = (s: string, n: number) => (s.length > n ? `...${s.slice(-n)}` : s);
20
20
  export function setupOutcome(result: SetupResult | Error): TaskSetup {
21
21
  if (result instanceof Error)
22
22
  return { status: "failed", ms: null, error: redact(result.message) };
23
- if (result.success)
24
- return { status: "ok", ms: result.durationMs, error: null };
23
+ if (result.success) {
24
+ const warning = result.steps.find((s) => s.warning)?.warning;
25
+ return { status: "ok", ms: result.durationMs, error: warning ?? null };
26
+ }
25
27
  const failed = result.steps.filter((s) => !s.success);
26
28
  const last = failed[failed.length - 1];
27
29
  const error = last
@@ -31,6 +33,11 @@ export function setupOutcome(result: SetupResult | Error): TaskSetup {
31
33
  }
32
34
 
33
35
  export function setupNote(setup: TaskSetup): string {
36
+ if (setup.status === "ok" && setup.error)
37
+ return `
38
+
39
+ ---
40
+ Note from AgentOS: ${setup.error}`;
34
41
  if (setup.status !== "failed") return "";
35
42
  return `
36
43
 
@@ -236,6 +236,16 @@ export async function cloneDeps(opts: {
236
236
  // not, and cloning it would hand the worktree missing dependencies. Other
237
237
  // package managers have no hidden lockfile to check, so they pass.
238
238
  export async function nodeModulesMatchLock(dir: string): Promise<boolean> {
239
+ // pnpm copies the lockfile it installed from into node_modules/.pnpm.
240
+ const pnpmLock = await fs.promises
241
+ .readFile(path.join(dir, "pnpm-lock.yaml"), "utf-8")
242
+ .catch(() => null);
243
+ if (pnpmLock !== null) {
244
+ const installed = await fs.promises
245
+ .readFile(path.join(dir, "node_modules", ".pnpm", "lock.yaml"), "utf-8")
246
+ .catch(() => null);
247
+ return installed === pnpmLock;
248
+ }
239
249
  const read = (file: string) =>
240
250
  fs.promises
241
251
  .readFile(file, "utf-8")
@@ -22,7 +22,14 @@ export const STORE_ROOT = agentosHome("deps-store");
22
22
 
23
23
  // Files tools rewrite in place. A hardlink would carry the write back into
24
24
  // the store, so these are real copies in every worktree.
25
- export const MUTABLE_IN_MODULES = [".package-lock.json", ".cache", ".vite"];
25
+ export const MUTABLE_IN_MODULES = [
26
+ ".package-lock.json",
27
+ ".modules.yaml",
28
+ ".pnpm/lock.yaml",
29
+ ".pnpm-workspace-state-v1.json",
30
+ ".cache",
31
+ ".vite",
32
+ ];
26
33
 
27
34
  const probed = new Map<string, boolean>();
28
35
 
@@ -7,7 +7,7 @@ import { exec } from "child_process";
7
7
  import { promisify } from "util";
8
8
  import type { SetupResult } from "../env-setup";
9
9
  import { NO_FAST_COPY, cloneDeps } from "./clone";
10
- import { detectPackageManager, setupEnv } from "./install";
10
+ import { detectPackageManager, setupEnv, shellCommand } from "./install";
11
11
 
12
12
  const execAsync = promisify(exec);
13
13
 
@@ -47,8 +47,8 @@ export async function runCommand(
47
47
 
48
48
  /**
49
49
  * Clone the main checkout's node_modules (or exactly agentos.json's `clone`
50
- * paths), or else install: the lockfile's frozen install first, then a
51
- * plain one.
50
+ * paths), or else install: the lockfile's frozen install first, then (for
51
+ * a project other than AgentOS) a plain one.
52
52
  */
53
53
  export async function bringDependencies(
54
54
  result: SetupResult,
@@ -81,20 +81,15 @@ export async function bringDependencies(
81
81
  return;
82
82
  }
83
83
 
84
- let error: string | undefined;
85
- for (const command of pm.installs) {
86
- const run = await deps.run(command, worktreePath, envVars);
87
- result.steps.push({
88
- name: `Install dependencies (${pm.name})`,
89
- command,
90
- success: run.success,
91
- output: [clone.reason && `Not cloned: ${clone.reason}`, run.output]
92
- .filter(Boolean)
93
- .join("\n"),
94
- error: run.error,
95
- });
96
- if (run.success) return;
97
- error = run.error;
98
- }
99
- if (error !== undefined) result.success = false;
84
+ const run = await deps.run(shellCommand(pm.install), worktreePath, envVars);
85
+ result.steps.push({
86
+ name: `Install dependencies (${pm.name})`,
87
+ command: pm.install,
88
+ success: run.success,
89
+ output: [clone.reason && `Not cloned: ${clone.reason}`, run.output]
90
+ .filter(Boolean)
91
+ .join("\n"),
92
+ error: run.error,
93
+ });
94
+ if (!run.success) result.success = false;
100
95
  }
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Installing a worktree's dependencies when they can't be cloned: the
3
- * lockfile's own frozen install first, then a plain install.
3
+ * lockfile's own frozen install, and nothing else. A plain install would
4
+ * resolve ranges to versions newer than the lockfile, so a lockfile that
5
+ * disagrees with package.json fails setup and the agent is told.
4
6
  */
5
7
 
6
8
  import * as fs from "fs";
@@ -8,8 +10,7 @@ import * as path from "path";
8
10
 
9
11
  export interface PackageManager {
10
12
  name: "bun" | "pnpm" | "yarn" | "npm";
11
- // Tried in order until one succeeds: frozen to the lockfile, then plain.
12
- installs: string[];
13
+ install: string;
13
14
  }
14
15
 
15
16
  // Each install includes devDependencies: the agent needs typecheck, tests
@@ -17,44 +18,29 @@ export interface PackageManager {
17
18
  const BY_LOCKFILE: Array<{ file: string; pm: PackageManager }> = [
18
19
  {
19
20
  file: "bun.lock",
20
- pm: {
21
- name: "bun",
22
- installs: ["bun install --frozen-lockfile", "bun install"],
23
- },
21
+ pm: { name: "bun", install: "bun install --frozen-lockfile" },
24
22
  },
25
23
  {
26
24
  file: "bun.lockb",
27
- pm: {
28
- name: "bun",
29
- installs: ["bun install --frozen-lockfile", "bun install"],
30
- },
25
+ pm: { name: "bun", install: "bun install --frozen-lockfile" },
31
26
  },
32
27
  {
33
28
  file: "pnpm-lock.yaml",
34
29
  pm: {
35
30
  name: "pnpm",
36
- installs: [
37
- "pnpm install --frozen-lockfile --prod=false",
38
- "pnpm install --prod=false",
39
- ],
31
+ install: "pnpm install --frozen-lockfile --prod=false",
40
32
  },
41
33
  },
42
34
  {
43
35
  file: "yarn.lock",
44
36
  pm: {
45
37
  name: "yarn",
46
- installs: [
47
- "yarn install --frozen-lockfile --production=false",
48
- "yarn install --production=false",
49
- ],
38
+ install: "yarn install --frozen-lockfile --production=false",
50
39
  },
51
40
  },
52
41
  {
53
42
  file: "package-lock.json",
54
- pm: {
55
- name: "npm",
56
- installs: ["npm ci --include=dev", "npm install --include=dev"],
57
- },
43
+ pm: { name: "npm", install: "npm ci --include=dev" },
58
44
  },
59
45
  ];
60
46
 
@@ -68,11 +54,18 @@ export function detectPackageManager(
68
54
  }
69
55
  if (fs.existsSync(path.join(projectPath, "package.json"))) {
70
56
  // No lockfile, so nothing to be frozen to.
71
- return { name: "npm", installs: ["npm install --include=dev"] };
57
+ return { name: "npm", install: "npm install --include=dev" };
72
58
  }
73
59
  return null;
74
60
  }
75
61
 
62
+ // pnpm may exist only as a corepack shim that was never enabled; the shell
63
+ // defines `pnpm` through corepack when the command is missing.
64
+ export function shellCommand(command: string): string {
65
+ if (!command.startsWith("pnpm ")) return command;
66
+ return `if ! command -v pnpm >/dev/null 2>&1; then pnpm() { COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm "$@"; }; fi; ${command}`;
67
+ }
68
+
76
69
  // What setup commands run under: the server's environment without the
77
70
  // settings that make an install skip devDependencies.
78
71
  export function setupEnv(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saadnvd1/agent-os",
3
- "version": "0.3.678",
3
+ "version": "0.3.684",
4
4
  "description": "Self-hosted web UI for managing Claude Code sessions",
5
5
  "bin": {
6
6
  "agent-os": "scripts/agent-os"
@@ -24,29 +24,24 @@
24
24
  "tsconfig.json",
25
25
  "postcss.config.mjs",
26
26
  "tailwind.config.ts",
27
- "package-lock.json",
28
27
  "README.md",
29
28
  "LICENSE"
30
29
  ],
31
30
  "scripts": {
32
- "predev": "node scripts/ensure-native.mjs && node scripts/gen-migrations-index.mjs",
31
+ "predev": "node scripts/check-native.mjs --rebuild && node scripts/gen-migrations-index.mjs",
33
32
  "dev": "AGENTOS_DEV=1 tsx server.ts",
34
33
  "dev:task": "tsx scripts/dev-task.ts",
35
34
  "dev:stop": "tsx scripts/dev-stop.ts",
36
35
  "disk:dry-run": "tsx scripts/disk-dry-run.ts",
37
36
  "prebuild": "node scripts/gen-migrations-index.mjs",
38
37
  "build": "next build",
39
- "prestart": "node scripts/ensure-native.mjs && node scripts/gen-migrations-index.mjs",
38
+ "prestart": "node scripts/check-native.mjs --rebuild && node scripts/gen-migrations-index.mjs",
40
39
  "start": "NODE_ENV=production AGENTOS_SERVER=live node --import tsx server.ts",
41
40
  "pretypecheck": "node scripts/gen-migrations-index.mjs",
42
41
  "typecheck": "tsc --noEmit",
43
42
  "setup": "bash scripts/setup.sh",
44
43
  "postinstall": "chmod +x node_modules/node-pty/prebuilds/*/spawn-helper 2>/dev/null || true",
45
44
  "prepare": "husky",
46
- "tauri": "tauri",
47
- "tauri:dev": "tauri dev",
48
- "tauri:build": "tauri build",
49
- "tauri:build:linux": "docker build -t agentos-linux -f src-tauri/Dockerfile.linux src-tauri && docker run --rm -v $(pwd)/src-tauri/target:/app/target agentos-linux",
50
45
  "prelint": "node scripts/gen-migrations-index.mjs",
51
46
  "lint": "eslint .",
52
47
  "format": "prettier --write .",
@@ -71,7 +66,7 @@
71
66
  "author": "Saad Naveed",
72
67
  "license": "MIT",
73
68
  "engines": {
74
- "node": ">=20"
69
+ "node": ">=22"
75
70
  },
76
71
  "bugs": {
77
72
  "url": "https://github.com/saadnvd1/agent-os/issues"
@@ -155,15 +150,15 @@
155
150
  "serwist": "^9.5.7",
156
151
  "sonner": "^2.0.7",
157
152
  "tailwind-merge": "^3.4.0",
153
+ "unified": "^11.0.5",
158
154
  "valtio": "^2.3.0",
159
155
  "ws": "^8.19.0",
160
156
  "zod": "^4.6.5"
161
157
  },
162
158
  "devDependencies": {
163
159
  "@tailwindcss/postcss": "^4.1.18",
164
- "@tauri-apps/api": "^2.12.1",
165
- "@tauri-apps/cli": "^2.12.1",
166
160
  "@types/better-sqlite3": "^7.6.13",
161
+ "@types/hast": "^3.0.4",
167
162
  "@types/jsdom": "^30.0.0",
168
163
  "@types/mdast": "^4.0.4",
169
164
  "@types/node": "^20.19.27",
@@ -177,6 +172,7 @@
177
172
  "jsdom": "^30.1.2",
178
173
  "prettier": "^3.7.4",
179
174
  "prettier-plugin-tailwindcss": "^0.7.2",
175
+ "remark-parse": "^11.0.0",
180
176
  "sharp": "^0.35.5",
181
177
  "tailwindcss": "^4.1.18",
182
178
  "tsx": "^4.23.15",
@@ -184,8 +180,5 @@
184
180
  "typescript": "^5.9.3",
185
181
  "vitest": "^4.1.11"
186
182
  },
187
- "overrides": {
188
- "dompurify": "^3.4.16",
189
- "postcss-selector-parser": "^7.1.6"
190
- }
183
+ "packageManager": "pnpm@11.28.5+sha512.484563d30b4c2ad27cb48aa94ff2b302dbcebc8ff6bf28816c2589886e146ce7f76f354f3bc1a438e6f5e9768c302aa0a6f7add8232903cd4cf81426cbc14d9e"
191
184
  }
@@ -0,0 +1,86 @@
1
+ // Proves the native modules work in a node_modules tree: open a SQLite
2
+ // database with better-sqlite3 and spawn a pty with node-pty. Used before a
3
+ // deploy swaps an install in, and by predev/prestart.
4
+ // node scripts/check-native.mjs [node_modules dir] (default: this checkout's)
5
+ // --rebuild on a Node ABI mismatch, run `pnpm rebuild` once and check again
6
+ import { createRequire } from "module";
7
+ import { execFileSync } from "child_process";
8
+ import fs from "fs";
9
+ import os from "os";
10
+ import path from "path";
11
+ import { fileURLToPath } from "url";
12
+
13
+ const here = path.dirname(fileURLToPath(import.meta.url));
14
+ const args = process.argv.slice(2);
15
+ const rebuild = args.includes("--rebuild");
16
+ const modules = path.resolve(
17
+ args.find((a) => !a.startsWith("--")) ?? path.join(here, "..", "node_modules")
18
+ );
19
+
20
+ async function sqlite(require) {
21
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "aos-native-"));
22
+ try {
23
+ const db = require("better-sqlite3")(path.join(dir, "check.db"));
24
+ db.exec("create table t (v text); insert into t values ('ok')");
25
+ const row = db.prepare("select v from t").get();
26
+ db.close();
27
+ if (row?.v !== "ok") throw new Error("better-sqlite3 read back nothing");
28
+ } finally {
29
+ fs.rmSync(dir, { recursive: true, force: true });
30
+ }
31
+ }
32
+
33
+ function pty(require) {
34
+ return new Promise((resolve, reject) => {
35
+ const p = require("node-pty").spawn("/bin/sh", ["-c", "echo pty-ok"], {});
36
+ let out = "";
37
+ const timer = setTimeout(() => {
38
+ p.kill();
39
+ reject(new Error("node-pty: no exit within 10s"));
40
+ }, 10_000);
41
+ p.onData((d) => (out += d));
42
+ p.onExit(({ exitCode }) => {
43
+ clearTimeout(timer);
44
+ if (exitCode === 0 && out.includes("pty-ok")) resolve();
45
+ else reject(new Error(`node-pty: exit ${exitCode}, output ${out}`));
46
+ });
47
+ });
48
+ }
49
+
50
+ async function failures() {
51
+ const require = createRequire(path.join(modules, "noop.js"));
52
+ const found = [];
53
+ for (const [name, run] of [
54
+ ["better-sqlite3", sqlite],
55
+ ["node-pty", pty],
56
+ ]) {
57
+ try {
58
+ await run(require);
59
+ } catch (err) {
60
+ found.push({ name, message: String(err?.message ?? err) });
61
+ }
62
+ }
63
+ return found;
64
+ }
65
+
66
+ let bad = await failures();
67
+ if (
68
+ bad.length &&
69
+ rebuild &&
70
+ bad.some((b) => b.message.includes("NODE_MODULE_VERSION"))
71
+ ) {
72
+ const names = bad.map((b) => b.name);
73
+ console.log(`Rebuilding ${names.join(", ")} for Node ${process.version}...`);
74
+ execFileSync("pnpm", ["rebuild", ...names], {
75
+ cwd: path.dirname(modules),
76
+ stdio: "inherit",
77
+ });
78
+ bad = await failures();
79
+ }
80
+ if (bad.length) {
81
+ for (const b of bad)
82
+ console.error(`native check failed: ${b.name}: ${b.message}`);
83
+ process.exit(1);
84
+ }
85
+ console.log(`native modules ok (${modules})`);
86
+ process.exit(0);
@@ -142,11 +142,11 @@ async function prepass(args: string[]) {
142
142
  const steps: Record<Collector, () => string | void> = {
143
143
  deps: () => {
144
144
  const prod = JSON.parse(
145
- run("npm", ["audit", "--omit=dev", "--json"], root) || "{}"
145
+ run("pnpm", ["audit", "--prod", "--json"], root) || "{}"
146
146
  );
147
- const all = JSON.parse(run("npm", ["audit", "--json"], root) || "{}");
147
+ const all = JSON.parse(run("pnpm", ["audit", "--json"], root) || "{}");
148
148
  const outdated = JSON.parse(
149
- run("npm", ["outdated", "--json"], root) || "{}"
149
+ run("pnpm", ["outdated", "--format", "json"], root) || "{}"
150
150
  );
151
151
  result.deps = {
152
152
  prod: summarizeNpmAudit(prod),
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bash
2
+ # Install this checkout's dependencies the one way AgentOS does: pnpm, frozen
3
+ # to pnpm-lock.yaml, only the build scripts pnpm-workspace.yaml allows, then a
4
+ # check that the native modules work and the PDF browser. For first installs
5
+ # (setup, `agent-os install`); a running server's updates go through
6
+ # scripts/redeploy, which installs beside the live tree.
7
+ # scripts/install-deps [--no-browser]
8
+ set -euo pipefail
9
+ cd "$(dirname "$0")/.."
10
+ # shellcheck source=lib/pnpm.sh
11
+ source scripts/lib/pnpm.sh
12
+
13
+ if [ -s "$HOME/.nvm/nvm.sh" ]; then
14
+ # shellcheck disable=SC1091
15
+ source "$HOME/.nvm/nvm.sh" >/dev/null
16
+ nvm use >/dev/null
17
+ fi
18
+ use_pnpm
19
+
20
+ # devDependencies are needed to build, even when the shell has NODE_ENV=production.
21
+ unset NODE_ENV npm_config_production npm_config_omit
22
+ pnpm install --frozen-lockfile
23
+ node scripts/check-native.mjs
24
+ [ "${1:-}" = "--no-browser" ] || install_pdf_browser
@@ -43,7 +43,7 @@ cmd_install() {
43
43
 
44
44
  # Install dependencies
45
45
  log_info "Installing dependencies..."
46
- npm install --include=dev --legacy-peer-deps
46
+ scripts/install-deps
47
47
 
48
48
  # Build for production
49
49
  log_info "Building for production..."
@@ -296,7 +296,7 @@ cmd_update() {
296
296
  git pull --ff-only
297
297
 
298
298
  log_info "Installing dependencies..."
299
- npm install --include=dev --legacy-peer-deps
299
+ scripts/install-deps
300
300
 
301
301
  log_info "Rebuilding..."
302
302
  npm run build
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env bash
2
+ # Install dependencies beside the live ones, prove the native modules work in
3
+ # them, and only then swap them in. A deploy that brings a broken install
4
+ # fails here, and the node_modules the running server reads is never touched.
5
+ # The tree being replaced stays in .deps/prev for one rollback.
6
+ # Sourced by scripts/redeploy; run from the repository root, after use_pnpm.
7
+ # Test hooks: AGENTOS_INSTALL_CMD (default `pnpm install --frozen-lockfile`),
8
+ # AGENTOS_NATIVE_CHECK (default `node scripts/check-native.mjs <dir>`).
9
+
10
+ DEPS=.deps
11
+ STAGE=$DEPS/stage
12
+ PREV=$DEPS/prev
13
+ STAMP=.agentos-deps
14
+
15
+ # What an install depends on. A new Node or CPU rebuilds the native modules.
16
+ deps_stamp() {
17
+ {
18
+ cat package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc 2>/dev/null
19
+ node -p 'process.version + process.platform + process.arch'
20
+ } | shasum -a 256 | cut -d' ' -f1
21
+ }
22
+
23
+ # 0 and a staged tree to swap in, or 10 when the live install is already
24
+ # right, or 1 with the live tree untouched.
25
+ install_beside() {
26
+ local stamp
27
+ stamp=$(deps_stamp)
28
+ if [ -d node_modules ] && [ "$(cat "node_modules/$STAMP" 2>/dev/null)" = "$stamp" ]; then
29
+ echo "Dependencies unchanged."
30
+ # The last build ran on these same dependencies, so a rollback has
31
+ # nothing to put back.
32
+ rm -rf "$PREV"
33
+ return 10
34
+ fi
35
+ rm -rf "$STAGE"
36
+ mkdir -p "$STAGE"
37
+ cp package.json pnpm-lock.yaml pnpm-workspace.yaml "$STAGE/"
38
+ [ -f .npmrc ] && cp .npmrc "$STAGE/"
39
+ # HUSKY=0: the staged copy is not a git checkout.
40
+ if ! (cd "$STAGE" && HUSKY=0 bash -c "${AGENTOS_INSTALL_CMD:-pnpm install --frozen-lockfile}"); then
41
+ rm -rf "$STAGE"
42
+ echo "Install failed; the live node_modules is untouched." >&2
43
+ return 1
44
+ fi
45
+ if ! bash -c "${AGENTOS_NATIVE_CHECK:-node scripts/check-native.mjs \"\$1\"}" _ "$STAGE/node_modules"; then
46
+ rm -rf "$STAGE"
47
+ echo "Native modules do not load in the new install; the live node_modules is untouched." >&2
48
+ return 1
49
+ fi
50
+ echo "$stamp" > "$STAGE/node_modules/$STAMP"
51
+ }
52
+
53
+ swap_deps() {
54
+ [ -d "$STAGE/node_modules" ] || { echo "no checked install to swap in" >&2; return 1; }
55
+ rm -rf "$PREV"
56
+ mkdir -p "$DEPS"
57
+ [ -d node_modules ] && mv node_modules "$PREV"
58
+ mv "$STAGE/node_modules" node_modules
59
+ rm -rf "$STAGE"
60
+ }
61
+
62
+ # Put the node_modules from before the last swap back (a failed build, or
63
+ # `redeploy --rollback`); the current one is dropped.
64
+ restore_deps() {
65
+ [ -d "$PREV" ] || return 0
66
+ rm -rf node_modules
67
+ mv "$PREV" node_modules
68
+ }