@mmmbuto/masix 0.4.0 → 0.4.2

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.
Files changed (42) hide show
  1. package/README.md +18 -14
  2. package/install.js +53 -27
  3. package/package.json +4 -3
  4. package/packages/plugin-base/codex-backend/0.1.4/SHA256SUMS +3 -0
  5. package/packages/plugin-base/codex-backend/0.1.4/codex-backend-android-aarch64-termux.pkg +0 -0
  6. package/packages/plugin-base/codex-backend/0.1.4/codex-backend-linux-x86_64.pkg +0 -0
  7. package/packages/plugin-base/codex-backend/0.1.4/codex-backend-macos-aarch64.pkg +0 -0
  8. package/packages/plugin-base/codex-backend/0.1.4/manifest.json +33 -0
  9. package/packages/plugin-base/codex-backend/CHANGELOG.md +17 -0
  10. package/packages/plugin-base/codex-backend/README.md +33 -0
  11. package/packages/plugin-base/codex-backend/source/Cargo.toml +25 -0
  12. package/packages/plugin-base/codex-backend/source/README-PACKAGE.txt +54 -0
  13. package/packages/plugin-base/codex-backend/source/plugin.manifest.json +103 -0
  14. package/packages/plugin-base/codex-backend/source/src/error.rs +60 -0
  15. package/packages/plugin-base/codex-backend/source/src/exec.rs +436 -0
  16. package/packages/plugin-base/codex-backend/source/src/http_backend.rs +1198 -0
  17. package/packages/plugin-base/codex-backend/source/src/lib.rs +328 -0
  18. package/packages/plugin-base/codex-backend/source/src/patch.rs +767 -0
  19. package/packages/plugin-base/codex-backend/source/src/policy.rs +297 -0
  20. package/packages/plugin-base/codex-backend/source/src/tools.rs +72 -0
  21. package/packages/plugin-base/codex-backend/source/src/workspace.rs +433 -0
  22. package/packages/plugin-base/codex-tools/0.1.3/SHA256SUMS +3 -0
  23. package/packages/plugin-base/codex-tools/0.1.3/codex-tools-android-aarch64-termux.pkg +0 -0
  24. package/packages/plugin-base/codex-tools/0.1.3/codex-tools-linux-x86_64.pkg +0 -0
  25. package/packages/plugin-base/codex-tools/0.1.3/codex-tools-macos-aarch64.pkg +0 -0
  26. package/packages/plugin-base/codex-tools/0.1.3/manifest.json +33 -0
  27. package/packages/plugin-base/codex-tools/CHANGELOG.md +17 -0
  28. package/packages/plugin-base/codex-tools/README.md +33 -0
  29. package/packages/plugin-base/codex-tools/source/Cargo.toml +23 -0
  30. package/packages/plugin-base/codex-tools/source/plugin.manifest.json +124 -0
  31. package/packages/plugin-base/codex-tools/source/src/main.rs +995 -0
  32. package/packages/plugin-base/discovery/0.2.4/SHA256SUMS +3 -0
  33. package/packages/plugin-base/discovery/0.2.4/discovery-android-aarch64-termux.pkg +0 -0
  34. package/packages/plugin-base/discovery/0.2.4/discovery-linux-x86_64.pkg +0 -0
  35. package/packages/plugin-base/discovery/0.2.4/discovery-macos-aarch64.pkg +0 -0
  36. package/packages/plugin-base/discovery/0.2.4/manifest.json +31 -0
  37. package/packages/plugin-base/discovery/CHANGELOG.md +17 -0
  38. package/packages/plugin-base/discovery/README.md +48 -0
  39. package/packages/plugin-base/discovery/source/Cargo.toml +14 -0
  40. package/packages/plugin-base/discovery/source/plugin.manifest.json +30 -0
  41. package/packages/plugin-base/discovery/source/src/main.rs +2570 -0
  42. package/prebuilt/masix +0 -0
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # @mmmbuto/masix
2
2
 
3
- Official Termux package for MasiX (MIT).
3
+ Official npm package for the Termux distribution of MasiX (MIT).
4
4
 
5
- MasiX is an AI-friendly modular assistant runtime in Rust, optimized for smartphone (Termux/Android) and compatible with Linux/macOS.
5
+ MasiX is Termux-first. Linux and macOS are supported through source builds and the Homebrew tap.
6
6
 
7
- Current package line: `0.4.0`.
7
+ Current package line: `0.4.2`.
8
8
 
9
9
  ## Function Summary
10
10
 
11
11
  - Telegram bot automation with interactive inline menus
12
12
  - Real MCP tool-calling flow through API-compatible endpoints
13
- - Natural-language reminder scheduling (cron persistence)
13
+ - Natural-language reminder scheduling with cron persistence
14
14
  - Cron scope isolation per bot/account (`account_tag`)
15
15
  - Workdir isolation per Telegram account
16
16
  - User memory isolation with per-user catalog (`meta.json`)
@@ -18,8 +18,8 @@ Current package line: `0.4.0`.
18
18
  - Guarded command execution (`/exec`, `/termux`) with allowlists
19
19
  - Termux boot automation (`masix termux boot enable|disable|status`)
20
20
  - Optional local STT via whisper.cpp (`masix config stt`)
21
- - Optional modules can be installed from local `.pkg`
22
- - SOUL.md startup memory context
21
+ - Bundled `plugin-base` packages are included and installed during `npm install`
22
+ - If a bundled `.pkg` is missing, MasiX can fall back to source build for the module
23
23
  - Startup update checks are available on demand via `masix check-update`
24
24
 
25
25
  ## Install (Termux)
@@ -40,6 +40,15 @@ masix start
40
40
  masix status
41
41
  ```
42
42
 
43
+ ## Bundled Packages
44
+
45
+ Postinstall installs these bundled `plugin-base` packages into `~/.masix/plugins`:
46
+ - `discovery` `0.2.4`
47
+ - `codex-backend` `0.1.4`
48
+ - `codex-tools` `0.1.3`
49
+
50
+ Package artifacts and source trees are included in the npm tarball under `packages/plugin-base/`.
51
+
43
52
  ## Useful Commands
44
53
 
45
54
  ```bash
@@ -55,16 +64,11 @@ masix termux boot status
55
64
  masix stats
56
65
  ```
57
66
 
58
- ## Runtime Chat Commands
59
-
60
- - `/cron ...`, `/cron list`, `/cron cancel <id>`
61
- - `/exec <allowlisted-command>`
62
- - `/termux ...`
63
-
64
67
  ## Notes
65
68
 
66
- - This package targets Android + arm64 (Termux environments)
69
+ - This package targets Android + arm64 in Termux
67
70
  - If no prebuilt binary is available, postinstall builds from source
71
+ - The postinstall step uses `masix plugin install-base` so dependency order and source fallback stay aligned with the CLI
68
72
  - `masix config stt` can auto-pick and auto-download a Whisper model based on device resources
69
73
 
70
74
  ## Full Documentation
@@ -72,7 +76,7 @@ masix stats
72
76
  - Repository README: https://github.com/DioNanos/MasiX
73
77
  - Detailed guide: https://github.com/DioNanos/MasiX/blob/main/docs/USER_GUIDE.md
74
78
  - Commands reference: https://github.com/DioNanos/MasiX/blob/main/docs/COMMANDS_REFERENCE.md
75
- - Homebrew tap (Linux/macOS formula): https://github.com/DioNanos/homebrew-masix
79
+ - Homebrew tap: https://github.com/DioNanos/homebrew-masix
76
80
  - Local llama.cpp endpoint guide: https://github.com/DioNanos/MasiX/blob/main/docs/TERMUX_LLAMA_CPP_LOCAL_ENDPOINT.md
77
81
 
78
82
  ## Branding
package/install.js CHANGED
@@ -1,14 +1,15 @@
1
1
  const fs = require('fs');
2
+ const os = require('os');
2
3
  const path = require('path');
3
- const { execSync } = require('child_process');
4
+ const { execSync, execFileSync } = require('child_process');
4
5
 
5
6
  const BINARY_NAME = 'masix';
6
7
  const PACKAGE_BIN_PATH = path.join(__dirname, 'prebuilt', BINARY_NAME);
7
8
  const PREBUILT_DIR = path.join(__dirname, 'prebuilt');
8
-
9
- // Check if running in Termux
10
- const isTermux = process.env.TERMUX_VERSION !== undefined ||
11
- process.env.PREFIX === '/data/data/com.termux/files/usr';
9
+ const BUNDLED_PACKAGES_DIR = path.join(__dirname, 'packages', 'plugin-base');
10
+ const isTermux =
11
+ process.env.TERMUX_VERSION !== undefined ||
12
+ process.env.PREFIX === '/data/data/com.termux/files/usr';
12
13
 
13
14
  if (!isTermux) {
14
15
  console.warn('⚠️ @mmmbuto/masix is designed for Android Termux only!');
@@ -22,39 +23,42 @@ function hasValidElfPrebuilt(binaryPath) {
22
23
  const buf = Buffer.alloc(4);
23
24
  fs.readSync(fd, buf, 0, 4, 0);
24
25
  fs.closeSync(fd);
25
- return buf[0] === 0x7f && buf[1] === 0x45 && buf[2] === 0x4c && buf[3] === 0x46; // ELF
26
+ return buf[0] === 0x7f && buf[1] === 0x45 && buf[2] === 0x4c && buf[3] === 0x46;
26
27
  } catch {
27
28
  return false;
28
29
  }
29
30
  }
30
31
 
31
- if (hasValidElfPrebuilt(PACKAGE_BIN_PATH)) {
32
- fs.chmodSync(PACKAGE_BIN_PATH, 0o755);
33
- console.log(`✅ Using packaged prebuilt binary: ${PACKAGE_BIN_PATH}`);
34
- } else {
32
+ function ensureBinary() {
33
+ if (hasValidElfPrebuilt(PACKAGE_BIN_PATH)) {
34
+ fs.chmodSync(PACKAGE_BIN_PATH, 0o755);
35
+ console.log(`✅ Using packaged prebuilt binary: ${PACKAGE_BIN_PATH}`);
36
+ return;
37
+ }
38
+
35
39
  console.log('🔨 No prebuilt binary found. Building from source...');
36
40
  console.log(' This requires Rust to be installed in Termux.');
37
-
41
+
38
42
  try {
39
43
  const masixRoot = path.join(__dirname, '..', '..');
40
44
  execSync('cargo build --release', {
41
45
  cwd: masixRoot,
42
46
  stdio: 'inherit'
43
47
  });
44
-
48
+
45
49
  let sourceBinary = path.join(masixRoot, 'target', 'release', BINARY_NAME);
46
50
  if (!fs.existsSync(sourceBinary)) {
47
51
  sourceBinary = path.join(masixRoot, 'target', 'aarch64-linux-android', 'release', BINARY_NAME);
48
52
  }
49
-
50
- if (fs.existsSync(sourceBinary)) {
51
- fs.mkdirSync(PREBUILT_DIR, { recursive: true });
52
- fs.copyFileSync(sourceBinary, PACKAGE_BIN_PATH);
53
- fs.chmodSync(PACKAGE_BIN_PATH, 0o755);
54
- console.log(`✅ Binary built and installed at: ${PACKAGE_BIN_PATH}`);
55
- } else {
53
+
54
+ if (!fs.existsSync(sourceBinary)) {
56
55
  throw new Error('Binary not found after build');
57
56
  }
57
+
58
+ fs.mkdirSync(PREBUILT_DIR, { recursive: true });
59
+ fs.copyFileSync(sourceBinary, PACKAGE_BIN_PATH);
60
+ fs.chmodSync(PACKAGE_BIN_PATH, 0o755);
61
+ console.log(`✅ Binary built and installed at: ${PACKAGE_BIN_PATH}`);
58
62
  } catch (error) {
59
63
  console.error('❌ Build failed:', error.message);
60
64
  console.error('\n📦 Please install Rust in Termux:');
@@ -63,14 +67,36 @@ if (hasValidElfPrebuilt(PACKAGE_BIN_PATH)) {
63
67
  }
64
68
  }
65
69
 
66
- // Run update check in background (don't block install)
70
+ function ensureMasixHome() {
71
+ const masixDir = path.join(os.homedir(), '.masix');
72
+ if (!fs.existsSync(masixDir)) {
73
+ fs.mkdirSync(masixDir, { recursive: true });
74
+ }
75
+ }
76
+
77
+ function installBundledPlugins() {
78
+ if (!fs.existsSync(BUNDLED_PACKAGES_DIR)) {
79
+ throw new Error(`Bundled packages root missing: ${BUNDLED_PACKAGES_DIR}`);
80
+ }
81
+
82
+ execFileSync(
83
+ PACKAGE_BIN_PATH,
84
+ [
85
+ 'plugin',
86
+ 'install-base',
87
+ '--packages-root',
88
+ BUNDLED_PACKAGES_DIR
89
+ ],
90
+ { stdio: 'inherit' }
91
+ );
92
+ }
93
+
94
+ ensureBinary();
95
+ ensureMasixHome();
96
+ installBundledPlugins();
97
+
67
98
  console.log('\n🎉 masix installed successfully!');
68
99
  console.log(' Run "masix --help" to get started.');
69
100
  console.log(' Run "masix config init" to create default config.');
70
- console.log(' Run "masix check-update" to check for updates.\n');
71
-
72
- // Create .masix directory if needed
73
- const masixDir = path.join(require('os').homedir(), '.masix');
74
- if (!fs.existsSync(masixDir)) {
75
- fs.mkdirSync(masixDir, { recursive: true });
76
- }
101
+ console.log(' Run "masix check-update" to check for updates.');
102
+ console.log(' Bundled plugin-base packages installed: discovery, codex-backend, codex-tools.\n');
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@mmmbuto/masix",
3
- "version": "0.4.0",
4
- "description": "Termux-first MIT automation runtime (Telegram, MCP, Cron) with optional in-core STT",
3
+ "version": "0.4.2",
4
+ "description": "Termux-first MIT automation runtime for Android/Termux; Linux/macOS supported via source builds and Homebrew; bundled plugin-base packages auto-install or auto-build as needed",
5
5
  "main": "check-update.js",
6
6
  "files": [
7
7
  "README.md",
8
8
  "install.js",
9
9
  "check-update.js",
10
- "prebuilt/"
10
+ "prebuilt/",
11
+ "packages/"
11
12
  ],
12
13
  "bin": {
13
14
  "masix": "prebuilt/masix",
@@ -0,0 +1,3 @@
1
+ 3175ff8fc1e6336ea63d881b2a72d6660496656314c0ed8408c9168f3e67754d codex-backend-android-aarch64-termux.pkg
2
+ 3175ff8fc1e6336ea63d881b2a72d6660496656314c0ed8408c9168f3e67754d codex-backend-linux-x86_64.pkg
3
+ 3175ff8fc1e6336ea63d881b2a72d6660496656314c0ed8408c9168f3e67754d codex-backend-macos-aarch64.pkg
@@ -0,0 +1,33 @@
1
+ {
2
+ "plugin_id": "codex-backend",
3
+ "version": "0.1.4",
4
+ "visibility": "plugin-base",
5
+ "license": "MIT",
6
+ "admin_only": true,
7
+ "package_type": "library",
8
+ "platforms": [
9
+ {
10
+ "id": "android-aarch64-termux",
11
+ "file": "codex-backend-android-aarch64-termux.pkg",
12
+ "sha256": "3175ff8fc1e6336ea63d881b2a72d6660496656314c0ed8408c9168f3e67754d"
13
+ },
14
+ {
15
+ "id": "linux-x86_64",
16
+ "file": "codex-backend-linux-x86_64.pkg",
17
+ "sha256": "3175ff8fc1e6336ea63d881b2a72d6660496656314c0ed8408c9168f3e67754d"
18
+ },
19
+ {
20
+ "id": "macos-aarch64",
21
+ "file": "codex-backend-macos-aarch64.pkg",
22
+ "sha256": "3175ff8fc1e6336ea63d881b2a72d6660496656314c0ed8408c9168f3e67754d"
23
+ }
24
+ ],
25
+ "install": {
26
+ "command": "masix plugin install-file --file <path-to-pkg> --plugin codex-backend --version 0.1.4 --package-type library --admin-only"
27
+ },
28
+ "notes": [
29
+ "Admin-only module. Non-admin users cannot call codex-backend tools.",
30
+ "Package usable without plugin server.",
31
+ "See docs/THIRD_PARTY_NOTICES.md for upstream Codex attribution."
32
+ ]
33
+ }
@@ -0,0 +1,17 @@
1
+ # codex-backend Package Changelog
2
+
3
+ ## 0.1.4 - 2026-03-05
4
+
5
+ - Refreshed package artifacts for android-aarch64-termux, linux-x86_64, macos-aarch64.
6
+ - Added `packages/plugin-base/codex-backend/0.1.4/` with updated `manifest.json` and `SHA256SUMS`.
7
+
8
+
9
+ ## 0.1.3 - 2026-03-02
10
+
11
+ - Added MIT package publication layout under `packages/plugin-base/codex-backend/0.1.3`.
12
+ - Included platform artifacts:
13
+ - `codex-backend-android-aarch64-termux.pkg`
14
+ - `codex-backend-linux-x86_64.pkg`
15
+ - `codex-backend-macos-aarch64.pkg`
16
+ - Added `manifest.json` with platform metadata and checksums.
17
+ - Added `SHA256SUMS` for manual integrity verification.
@@ -0,0 +1,33 @@
1
+ # codex-backend (`plugin-base`)
2
+
3
+ `codex-backend` provides the coding backend runtime used by `codex-tools`.
4
+
5
+ ## What It Is
6
+
7
+ - Package type: `library`
8
+ - Visibility: `plugin-base`
9
+ - Admin-only: `true`
10
+ - Distribution: local `.pkg` install supported (`install-file`)
11
+
12
+ ## Install Example
13
+
14
+ ```bash
15
+ masix plugin install-file \
16
+ --file packages/plugin-base/codex-backend/0.1.4/codex-backend-linux-x86_64.pkg \
17
+ --plugin codex-backend \
18
+ --version 0.1.4 \
19
+ --package-type library \
20
+ --admin-only
21
+ ```
22
+
23
+ Then enable and restart:
24
+
25
+ ```bash
26
+ masix plugin enable codex-backend
27
+ masix restart
28
+ ```
29
+
30
+ ## Notes
31
+
32
+ - `codex-backend` is typically used together with `codex-tools`.
33
+ - Upstream attribution for Codex-derived behavior is documented in `docs/THIRD_PARTY_NOTICES.md`.
@@ -0,0 +1,25 @@
1
+ [package]
2
+ name = "masix-plugin-codex-backend"
3
+ version = "0.1.4"
4
+ edition.workspace = true
5
+ license.workspace = true
6
+ description = "Codex backend module for MasiX - OpenAI/Anthropic coding agent with admin policy enforcement"
7
+
8
+ [lib]
9
+ name = "masix_codex_backend"
10
+ path = "src/lib.rs"
11
+
12
+ [dependencies]
13
+ anyhow.workspace = true
14
+ async-trait.workspace = true
15
+ reqwest.workspace = true
16
+ serde.workspace = true
17
+ serde_json.workspace = true
18
+ sha2.workspace = true
19
+ thiserror.workspace = true
20
+ tokio.workspace = true
21
+ tracing.workspace = true
22
+
23
+ [dev-dependencies]
24
+ mockito = "1.7"
25
+ tokio-test = "0.4"
@@ -0,0 +1,54 @@
1
+ MasiX Codex Backend Plugin v0.1.2
2
+ ==================================
3
+
4
+ This package contains the codex-backend module for MasiX.
5
+
6
+ INSTALLATION
7
+ ------------
8
+ 1. Extract to ~/.masix/plugins/codex-backend/
9
+ 2. Run: masix plugin enable codex-backend
10
+
11
+ REQUIREMENTS
12
+ ------------
13
+ - MasiX >= 0.3.0
14
+ - Admin privileges required for execution
15
+
16
+ PROVIDERS
17
+ ---------
18
+ - OpenAI (gpt-4.1 default)
19
+ - Anthropic (claude-3-5-sonnet-latest default)
20
+ - OpenAI-compatible endpoints
21
+
22
+ FEATURES
23
+ --------
24
+ - HTTP backend with fallback routing
25
+ - Admin-only policy enforcement
26
+ - Bounded timeouts, logs, and output
27
+ - Safe path handling (no traversal, symlinks)
28
+ - Dry-run preview mode
29
+
30
+ CONFIGURATION
31
+ -------------
32
+ Set in ~/.masix/config.toml:
33
+
34
+ [plugins.codex-backend]
35
+ provider = "openai"
36
+ api_key = "sk-..."
37
+ base_url = "https://api.openai.com" # optional
38
+ model = "gpt-4.1" # optional
39
+ timeout_secs = 300
40
+ max_tokens = 4096
41
+
42
+ SECURITY
43
+ --------
44
+ - Admin-only execution enforced
45
+ - No path traversal allowed
46
+ - Symlink escapes blocked
47
+ - Output truncation prevents memory exhaustion
48
+
49
+ LICENSE
50
+ -------
51
+ MIT License - See LICENSE file
52
+
53
+ Copyright (c) 2026 Davide A. Guglielmi
54
+ Made in Italy
@@ -0,0 +1,103 @@
1
+ {
2
+ "id": "codex-backend",
3
+ "name": "Codex Backend",
4
+ "version": "0.1.4",
5
+ "visibility": "plugin-base",
6
+ "package_type": "library",
7
+ "entrypoint": "masix_codex_backend",
8
+ "provides": {
9
+ "trait": "CodingBackend",
10
+ "methods": [
11
+ "run",
12
+ "dry_run"
13
+ ]
14
+ },
15
+ "admin_only": true,
16
+ "permissions": {
17
+ "required": [
18
+ "admin"
19
+ ],
20
+ "description": "Codex backend requires admin privileges for file write operations and API access"
21
+ },
22
+ "platforms_supported": [
23
+ "linux-x86_64",
24
+ "android-aarch64-termux",
25
+ "macos-aarch64"
26
+ ],
27
+ "platforms_tested": [
28
+ "linux-x86_64",
29
+ "android-aarch64-termux",
30
+ "macos-aarch64"
31
+ ],
32
+ "platforms_planned": [
33
+ "linux-aarch64"
34
+ ],
35
+ "config": {
36
+ "properties": {
37
+ "provider": {
38
+ "type": "string",
39
+ "enum": [
40
+ "openai",
41
+ "anthropic",
42
+ "openai-compatible"
43
+ ],
44
+ "default": "openai"
45
+ },
46
+ "api_key": {
47
+ "type": "string",
48
+ "secret": true
49
+ },
50
+ "base_url": {
51
+ "type": "string"
52
+ },
53
+ "model": {
54
+ "type": "string"
55
+ },
56
+ "timeout_secs": {
57
+ "type": "integer",
58
+ "default": 300,
59
+ "minimum": 10,
60
+ "maximum": 3600
61
+ },
62
+ "max_tokens": {
63
+ "type": "integer",
64
+ "default": 4096,
65
+ "minimum": 1,
66
+ "maximum": 128000
67
+ },
68
+ "max_output_bytes": {
69
+ "type": "integer",
70
+ "default": 1048576,
71
+ "minimum": 1024
72
+ },
73
+ "max_log_bytes": {
74
+ "type": "integer",
75
+ "default": 65536,
76
+ "minimum": 1024
77
+ },
78
+ "legacy_fallback": {
79
+ "type": "boolean",
80
+ "default": false
81
+ }
82
+ },
83
+ "required": [
84
+ "api_key"
85
+ ]
86
+ },
87
+ "min_masix_version": "0.3.0",
88
+ "max_masix_version": "0.4.1",
89
+ "capabilities": [
90
+ "http_client",
91
+ "file_read",
92
+ "file_write"
93
+ ],
94
+ "constraints": {
95
+ "max_concurrent_tasks": 1,
96
+ "requires_isolation": false,
97
+ "timeout_enforcement": "strict"
98
+ },
99
+ "tool_access": {
100
+ "default_required_role": "admin",
101
+ "per_tool_required_role": {}
102
+ }
103
+ }
@@ -0,0 +1,60 @@
1
+ use std::time::Duration;
2
+ use thiserror::Error;
3
+
4
+ #[derive(Debug, Clone, Error)]
5
+ pub enum CodingError {
6
+ #[error("API key not configured")]
7
+ MissingApiKey,
8
+
9
+ #[error("Invalid provider type: {0}")]
10
+ InvalidProvider(String),
11
+
12
+ #[error("HTTP request failed: {0}")]
13
+ HttpError(String),
14
+
15
+ #[error("API error: {0}")]
16
+ ApiError(String),
17
+
18
+ #[error("Operation timed out after {0:?}")]
19
+ Timeout(Duration),
20
+
21
+ #[error("Invalid response: {0}")]
22
+ InvalidResponse(String),
23
+
24
+ #[error("Tool execution failed: {0}")]
25
+ ToolError(String),
26
+
27
+ #[error("IO error: {0}")]
28
+ IoError(String),
29
+
30
+ #[error("Max iterations exceeded ({0})")]
31
+ MaxIterationsExceeded(u32),
32
+
33
+ #[error("Output exceeded limit ({0} bytes)")]
34
+ OutputTooLarge(usize),
35
+
36
+ #[error("Path security violation: {0}")]
37
+ PathSecurityViolation(String),
38
+
39
+ #[error("Policy violation: {0}")]
40
+ PolicyError(String),
41
+ }
42
+
43
+ #[derive(Debug, Clone, PartialEq, serde::Serialize)]
44
+ pub enum ExitStatus {
45
+ Success,
46
+ Timeout,
47
+ Error(String),
48
+ MaxIterations,
49
+ }
50
+
51
+ impl std::fmt::Display for ExitStatus {
52
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53
+ match self {
54
+ ExitStatus::Success => write!(f, "success"),
55
+ ExitStatus::Timeout => write!(f, "timeout"),
56
+ ExitStatus::Error(msg) => write!(f, "error: {}", msg),
57
+ ExitStatus::MaxIterations => write!(f, "max_iterations"),
58
+ }
59
+ }
60
+ }