@technomoron/agent-run 0.99.29 → 0.99.30

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.
@@ -1,69 +1,45 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- export HOME="${HOME:-/root}"
5
- export NPM_CONFIG_PREFIX="${NPM_CONFIG_PREFIX:-/usr/local}"
6
- export PNPM_HOME="${PNPM_HOME:-/usr/local}"
7
- export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH:-}"
4
+ export HOME=/root
5
+ export NPM_CONFIG_PREFIX=/usr/local
6
+ export PNPM_HOME=/usr/local
7
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
8
8
 
9
- NPM_BIN="${AI_TOOLS_NPM_BIN:-/usr/bin/npm}"
10
- NODE_BIN="${AI_TOOLS_NODE_BIN:-/usr/bin/node}"
11
- APT_GET_BIN="${AI_TOOLS_APT_GET_BIN:-/usr/bin/apt-get}"
9
+ NPM_BIN=/usr/local/bin/npm
10
+ NODE_BIN=/usr/local/bin/node
11
+ PNPM_BIN=/usr/local/bin/pnpm
12
+ APT_GET_BIN=/usr/bin/apt-get
12
13
 
13
- AI_TOOLS_NPM_PACKAGES="${AI_TOOLS_NPM_PACKAGES:-npm@latest pnpm@latest corepack@latest fallow@latest ripgrep@latest pm2@latest tsx@latest typescript@latest @openai/codex@latest @anthropic-ai/claude-code@latest @technomoron/agent-run@latest}"
14
- AI_TOOLS_PNPM_PACKAGE="${AI_TOOLS_PNPM_PACKAGE:-pnpm@latest}"
15
14
  AI_TOOLS_APT_PACKAGES="${AI_TOOLS_APT_PACKAGES:-gh}"
16
- AI_TOOLS_CLEAN_BINS="${AI_TOOLS_CLEAN_BINS:-agent-run claude codex}"
17
- AI_TOOLS_SYSTEM_BIN_DIRS="${AI_TOOLS_SYSTEM_BIN_DIRS:-/usr/local/bin /usr/bin}"
15
+
16
+ packages=(
17
+ npm@latest corepack@latest fallow@latest ripgrep@latest
18
+ pm2@latest tsx@latest typescript@latest @openai/codex@latest
19
+ @anthropic-ai/claude-code@latest @google/gemini-cli@latest
20
+ @xai-official/grok@latest @technomoron/agent-run@latest
21
+ )
18
22
 
19
23
  if [ "$(id -u)" -ne 0 ]; then
20
24
  echo "update-ai-tools.sh must run as root" >&2
21
25
  exit 1
22
26
  fi
23
27
 
24
- clean_tool_bins() {
25
- local bin_dir="$1"
26
- local bin_name
27
- local -a bin_names
28
-
29
- [ -d "$bin_dir" ] || return 0
30
- read -r -a bin_names <<<"$AI_TOOLS_CLEAN_BINS"
31
- for bin_name in "${bin_names[@]}"; do
32
- case "$bin_name" in
33
- agent-run|claude|codex)
34
- rm -f -- "$bin_dir/$bin_name"
35
- ;;
36
- *)
37
- echo "Refusing to clean unexpected AI tool bin: $bin_name" >&2
38
- exit 1
39
- ;;
40
- esac
41
- done
42
- }
43
-
44
- target_bin_dir="${NPM_CONFIG_PREFIX%/}/bin"
45
- clean_tool_bins "$target_bin_dir"
46
-
47
- if [ -n "$AI_TOOLS_NPM_PACKAGES" ]; then
48
- read -r -a npm_packages <<<"$AI_TOOLS_NPM_PACKAGES"
49
- "$NPM_BIN" install -g --force "${npm_packages[@]}"
28
+ if [ "$("$NPM_BIN" prefix -g)" != /usr/local ] || [ "$("$NPM_BIN" root -g)" != /usr/local/lib/node_modules ]; then
29
+ echo "npm global tooling must use /usr/local" >&2
30
+ exit 1
50
31
  fi
51
32
 
33
+ "$NPM_BIN" install -g --force "${packages[@]}"
34
+
52
35
  # corepack and pnpm both own the pnpm/pnpx shims; install pnpm last so npm's
53
36
  # current pnpm package remains the command users execute.
54
- if [ -n "$AI_TOOLS_PNPM_PACKAGE" ]; then
55
- read -r -a pnpm_packages <<<"$AI_TOOLS_PNPM_PACKAGE"
56
- "$NPM_BIN" install -g --force "${pnpm_packages[@]}"
57
- fi
37
+ "$NPM_BIN" install -g --force pnpm@latest
58
38
 
59
- # Once the new launchers are installed, remove exact-name duplicates from the
60
- # other conventional system prefix so PATH ordering cannot select a stale copy.
61
- read -r -a system_bin_dirs <<<"$AI_TOOLS_SYSTEM_BIN_DIRS"
62
- for system_bin_dir in "${system_bin_dirs[@]}"; do
63
- if [ "${system_bin_dir%/}" != "${target_bin_dir%/}" ]; then
64
- clean_tool_bins "$system_bin_dir"
65
- fi
66
- done
39
+ install -d -o root -g root -m 0755 /usr/local/share/pnpm/global /usr/local/share/pnpm/store /usr/local/bin
40
+ "$PNPM_BIN" config set --global global-dir /usr/local/share/pnpm/global
41
+ "$PNPM_BIN" config set --global global-bin-dir /usr/local/bin
42
+ "$PNPM_BIN" config set --global store-dir /usr/local/share/pnpm/store
67
43
 
68
44
  CLAUDE_INSTALL="$("$NPM_BIN" root -g)/@anthropic-ai/claude-code/install.cjs"
69
45
  if [ -f "$CLAUDE_INSTALL" ]; then
package/dist/tools.js DELETED
@@ -1,125 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runCodex = runCodex;
4
- exports.runClaude = runClaude;
5
- exports.getDangerArgs = getDangerArgs;
6
- exports.getPermissionArgs = getPermissionArgs;
7
- const fs = require("fs");
8
- const path = require("path");
9
- const process_1 = require("./process");
10
- const project_1 = require("./project");
11
- function runCodex(realBinary, permissionArgs, context, args, wrapperArgs) {
12
- const liveDir = context.paths.liveDir;
13
- const codexHomeDir = context.paths.codexHomeDir;
14
- const projectRoot = context.projectRoot;
15
- if (!fs.existsSync(path.join(codexHomeDir, 'AGENTS.md'))) {
16
- failMissingConfig('codex', context.profileDir);
17
- }
18
- const realPath = process.env.AGENT_RUN_REAL_PATH ?? process.env.PATH ?? '';
19
- fs.mkdirSync(codexHomeDir, { recursive: true });
20
- const env = {
21
- ...process.env,
22
- CODEX_HOME: codexHomeDir,
23
- AGENT_DIR: liveDir,
24
- AGENT_PROFILE_DIR: context.profileDir,
25
- AGENT_RUN_PROJECT_ROOT: projectRoot,
26
- AGENT_PROJECT_MEMORY_DIR: context.paths.projectMemoryDir,
27
- AGENT_RUN_REAL_PATH: realPath,
28
- PATH: `${path.join(liveDir, 'bin')}${path.delimiter}${realPath}`
29
- };
30
- const runtimeArgs = wrapperArgs.sandboxMode === 'danger' ? getDangerArgs('codex') : ['-a', 'on-request', '-s', 'workspace-write'];
31
- (0, process_1.execCommand)(realBinary, [
32
- ...permissionArgs,
33
- ...runtimeArgs,
34
- '--add-dir',
35
- context.paths.projectMemoryDir,
36
- '-C',
37
- projectRoot,
38
- ...(wrapperArgs.sandboxMode !== 'danger' && wrapperArgs.codexNetwork
39
- ? ['--config', 'sandbox_workspace_write.network_access=true']
40
- : []),
41
- ...args
42
- ], env, codexHomeDir, (code) => postflightProjectCheck(context, wrapperArgs.local, code));
43
- }
44
- function runClaude(realBinary, permissionArgs, context, args, wrapperArgs) {
45
- const liveDir = context.paths.liveDir;
46
- const claudePath = path.join(liveDir, 'CLAUDE.md');
47
- if (!fs.existsSync(claudePath)) {
48
- failMissingConfig('claude', context.profileDir);
49
- }
50
- const claudeConfigDir = path.join(liveDir, '.claude');
51
- const realPath = process.env.AGENT_RUN_REAL_PATH ?? process.env.PATH ?? '';
52
- const env = {
53
- ...process.env,
54
- AGENT_DIR: liveDir,
55
- AGENT_PROFILE_DIR: context.profileDir,
56
- AGENT_RUN_PROJECT_ROOT: context.projectRoot,
57
- AGENT_PROJECT_MEMORY_DIR: context.paths.projectMemoryDir,
58
- AGENT_RUN_REAL_PATH: realPath,
59
- PATH: `${path.join(liveDir, 'bin')}${path.delimiter}${realPath}`
60
- };
61
- const runtimeArgs = wrapperArgs.sandboxMode === 'danger' ? getDangerArgs('claude') : permissionArgs;
62
- (0, process_1.execCommand)(realBinary, [
63
- ...runtimeArgs,
64
- '--add-dir',
65
- context.paths.projectMemoryDir,
66
- '--append-system-prompt-file',
67
- claudePath,
68
- '--settings',
69
- path.join(claudeConfigDir, 'agent-run-settings.json'),
70
- '--plugin-dir',
71
- claudeConfigDir,
72
- ...args
73
- ], env, context.projectRoot, (code) => postflightProjectCheck(context, wrapperArgs.local, code));
74
- }
75
- function postflightProjectCheck(context, allowLocal, code) {
76
- if (!context.guardrails.forbidRepoAiFiles) {
77
- return code;
78
- }
79
- if (!allowLocal) {
80
- removeClaudeLocalSettings(context.projectRoot);
81
- }
82
- const localAiFiles = (0, project_1.findLocalAiFiles)(context.projectRoot, context.profileDir);
83
- if (localAiFiles.length === 0) {
84
- return code;
85
- }
86
- (0, project_1.warnForLocalAiFiles)(null, context.projectRoot, localAiFiles);
87
- return allowLocal ? code : 1;
88
- }
89
- function removeClaudeLocalSettings(projectRoot) {
90
- const claudeDir = path.join(projectRoot, '.claude');
91
- const localSettingsPath = path.join(claudeDir, 'settings.local.json');
92
- if (!fs.existsSync(localSettingsPath)) {
93
- return;
94
- }
95
- fs.rmSync(localSettingsPath);
96
- try {
97
- fs.rmdirSync(claudeDir);
98
- }
99
- catch (error) {
100
- if (!isDirectoryNotEmptyError(error)) {
101
- throw error;
102
- }
103
- }
104
- process.stderr.write(`agent-run: removed Claude's project-local settings: ${localSettingsPath}\n`);
105
- }
106
- function isDirectoryNotEmptyError(error) {
107
- return error instanceof Error && 'code' in error && error.code === 'ENOTEMPTY';
108
- }
109
- function failMissingConfig(tool, agentDir) {
110
- process.stderr.write(`agent-run: no ${tool} config found for this project: ${agentDir}\n`);
111
- process.stderr.write(`agent-run: run \`agent-run ${tool} --none\` to bypass agent setup, or \`agent-run ${tool} --create\` to create profile files.\n`);
112
- process.exit(1);
113
- }
114
- function getDangerArgs(tool) {
115
- return tool === 'codex' ? ['-a', 'never', '-s', 'danger-full-access'] : ['--dangerously-skip-permissions'];
116
- }
117
- function getPermissionArgs(tool) {
118
- if (process.env.AGENT_WRAPPER_FORCE_PERMISSIVE !== '1') {
119
- return [];
120
- }
121
- if (tool === 'claude' && typeof process.getuid === 'function' && process.getuid() !== 0) {
122
- return ['--permission-mode', 'bypassPermissions'];
123
- }
124
- return [];
125
- }