140 Commits

Author SHA1 Message Date
0xmrpeter
e193309e08 feat: enhance path validation and plugin configuration
- Added a new test to verify that allowedPaths can override ignore patterns for paths within the current working directory, ensuring proper access control for file uploads.
- Updated the path-guard logic to clarify that allowedPaths take precedence over ignore patterns.
- Simplified the plugin configuration logic for the Telegram channel by removing unnecessary mapping, directly importing the plugin when the channelId matches.
2026-04-03 15:50:24 +07:00
0xmrpeter
62cf9bd2bf fix: improve daemon restart logic and config management
- Added console log for stopping the daemon to enhance user feedback.
- Updated ConfigManager initialization to load from the specified config file.
- Refined the logic for determining the run mode, ensuring correct behavior when restarting a daemon based on its previous state.
2026-04-03 14:14:29 +07:00
0xmrpeter
8b9b7ffc36 fix(channels): read config from plugin settings instead of config.channels
After the plugin system migration, channel configuration (botToken, chatId,
etc.) is stored in SettingsManager (~/.openacp/plugins/data/) rather than
in config.channels. Several UI and diagnostic code paths still read from
the old location, causing channels to always appear as "Not configured"
even after a successful setup.

Fixes #194

Changes:
- getChannelStatuses(): make async, check SettingsManager before config.channels
- configureChannels(): accept settingsManager param, use it for status display
  and when invoking plugin configure()
- editChannels(): check SettingsManager for configured/enabled display status
- editDiscord(): fix wrong SettingsManager basePath (plugins → plugins/data)
- summarizeConfig(): make async, check SettingsManager for channel status
- telegramCheck (openacp doctor): read botToken/chatId from plugin settings
  first, fall back to legacy config.channels
- config.ts cmdConfig: fix SettingsManager basePath (plugins → plugins/data)
- onboard.ts cmdOnboard: pass settingsManager to runReconfigure()
- runReconfigure(): accept and propagate settingsManager to sub-functions

Tests: add setup-channels, helpers, and telegram-check unit tests covering
the plugin-settings-first read behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 10:55:38 +07:00
0xmrpeter
eea6e9a4fe fix: update tests for current API and add config value-type validation
- Add TypedEmitter to mock AgentInstance (Session constructor requires .on())
- Update config-migrations test for cloudflare→openacp tunnel provider migration
- Add missing mock fields (api, agentCatalog, settingsManager, setPath)
- Isolate instance-context tests from OPENACP_INSTANCE_ROOT env var
- Fix SSE tests to read past initial `: connected` comment
- Add validateFieldValue() to config-registry for type-safe config writes
- Handle ConfigValidationError in API error handler (→ 400)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 10:03:53 +07:00
0xmrpeter
378b97d3d0 fix: config editor routes edits to plugin settings for migrated fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 09:47:26 +07:00
0xmrpeter
6d631d3966 fix(cli): instances.ts — three code review fixes
Fix 1 (IMPORTANT): Use jsonError() for error paths in cmdInstancesCreate
when --json flag is active. Missing --dir and already-registered cases
now call jsonError() before the console.error/process.exit path.

Fix 2 (IMPORTANT): Move wantsHelp(args) check to the very top of
cmdInstances() so `openacp instances --help` is handled before the
subcommand dispatch, preventing it from falling through to "Unknown
subcommand" error.

Fix 3 (MINOR): Move fs.mkdirSync(instanceRoot) inside each branch
(--from, --no-interactive, interactive) to avoid leaving an orphaned
empty directory if copyInstance throws or config write fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 18:07:55 +07:00
0xmrpeter
2e3c1f7007 feat(cli): extend default.ts --json output with name, directory, port
Mirror the same extended JSON output shape from start.ts into default.ts
for both the daemon start path and the foreground start path.

Output shape: { success: true, data: { pid, instanceId, name, directory, dir, port } }

- Imports isJsonMode, jsonSuccess, jsonError, muteForJson, ErrorCodes
- Daemon path: resolves instanceId from registry, reads api.port file,
  falls back to config.api.port, calls jsonSuccess with full payload
- Foreground path: outputs JSON with process.pid before starting server
- Error path: calls jsonError(DAEMON_NOT_RUNNING, ...) in JSON mode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 18:07:45 +07:00
0xmrpeter
077a254ba4 feat: extend start --json output with name, directory, port
Extend the JSON output of `openacp start --json` to include `name`
(from config.instanceName), `directory` (path.dirname of root),
and `port` (from api.port file or config fallback). The `dir` field
is kept for backward compatibility. instanceId is resolved from the
instance registry when available, falling back to path.basename(root).
2026-04-02 17:11:40 +07:00
0xmrpeter
3a45d8a209 feat: register instances subcommand in CLI
Add cmdInstances to the noInstanceCommands object so it reads directly
from the global registry without requiring an existing instance root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 17:09:37 +07:00
0xmrpeter
eb09ffd6d8 feat: add instances create command
Implement cmdInstancesCreate with support for --dir (required), --from (copy existing instance), --name, --agent, and --no-interactive flags. Handles three cases: .openacp already registered (error), .openacp exists but unregistered (register it), and fresh creation (write minimal config).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 17:06:41 +07:00
0xmrpeter
ded47458a7 feat: add instances list command with --json output
Implements `openacp instances list` command with buildInstanceListEntries
helper that maps the InstanceRegistry to InstanceListEntry objects with
status/port/directory fields. Adds 4 passing unit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 17:01:54 +07:00
0xmrpeter
0c302331cc docs(cli): enhance help documentation with --json flag support
- Added `--json` flag descriptions to various CLI commands in the help text.
- Updated command usage examples to include `--json` for machine-readable output.
- Clarified that commands supporting `--json` will output results in a consistent JSON format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 16:24:54 +07:00
0xmrpeter
a2ac1d2ac4 feat(instance): use UUID instead of slug for instance IDs
New instances created via setup wizard now get a UUID as their ID
instead of a slug derived from the instance name. This guarantees
uniqueness across instances without collision handling.

- wizard.ts: use randomUUID() instead of generateSlug + uniqueId
- default.ts / restart.ts: look up existing registry entry first,
  fall back to a fresh UUID for unregistered instances
- cli.ts: replace 'unknown' fallback with randomUUID()
- main.ts: look up registry before falling back to randomUUID()

Existing instances with slug/hardcoded IDs remain fully compatible —
the registry lookup ensures their stored IDs are reused on subsequent
starts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 16:15:44 +07:00
0xmrpeter
3caaa5c397 test(cli): add integration tests for api and legacy install/uninstall --json
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:12:58 +07:00
0xmrpeter
672b7635ca test(cli): add integration tests for config set, adopt, restart --json
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:11:09 +07:00
0xmrpeter
46fadb72fe fix(cli): address code review issues for --json implementation
- Add muteForJson() to version command
- Fix wrong error code in setup.ts (MISSING_ARGUMENT → CONFIG_INVALID)
- Use ErrorCode type in jsonError signature for type safety
- Add process.exit re-throw guards to adopt.ts and remote.ts
- Remove dead return statements after jsonError calls
- Fix any types in doctor.ts
- Update spec for apiPort/tunnelPort naming

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:08:52 +07:00
0xmrpeter
09627a0eeb docs(cli): add --json flag to help text for all supported commands
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:51:04 +07:00
0xmrpeter
fca3e82737 feat(cli): add --json support to api command (all subcommands)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:46:09 +07:00
0xmrpeter
4259ba76ea feat(cli): add --json support to plugin install/uninstall and legacy install/uninstall
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:44:03 +07:00
0xmrpeter
b15af4abe0 feat(cli): add --json support to config set, adopt, remote
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:43:53 +07:00
0xmrpeter
5dba1746a5 feat(cli): add --json support to agents install, uninstall, info
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:41:18 +07:00
0xmrpeter
fdf9ae990f feat(cli): add --json support to doctor command (implies --dry-run)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:40:30 +07:00
0xmrpeter
d3a690294b feat(cli): add --json support to plugins, plugin search, plugin enable/disable
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:36:28 +07:00
0xmrpeter
3a254e58c7 feat(cli): add --json support to start, stop, restart commands
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:36:18 +07:00
0xmrpeter
27c4229f55 feat(cli): add --json support to status command
Also fix pre-existing type error in stop.ts (result.error possibly undefined).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:35:44 +07:00
0xmrpeter
fbec2ce94f refactor(cli): migrate agents list and setup to standardized --json envelope
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:32:30 +07:00
0xmrpeter
481a0e3921 feat(cli): add --json support to version command
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:31:18 +07:00
0xmrpeter
b7bab6703b test(cli): add JSON output test utilities
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:29:52 +07:00
0xmrpeter
e8aa355516 feat(cli): add standardized JSON output helpers (output.ts)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:29:45 +07:00
0xmrpeter
9b8239373a feat(setup): enhance channel configuration and desktop app detection
- Preserve existing channels and ensure the SSE adapter is enabled during setup.
- Update configuration schema to provide a default for channels.
- Implement desktop app detection for the SSE channel, checking common installation paths across platforms.
- Adjust setup integrations to remove unnecessary config parameter and streamline integration checks.
- Update wizard to include desktop app in channel options and handle installation prompts accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 12:55:11 +07:00
0xmrpeter
602ea7b620 fix(cli): validate runMode flag, improve test tmpDir lifecycle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 02:18:30 +07:00
0xmrpeter
875a1a2b54 fix(cli): remove extra channels field, add autoStart assertion in setup tests 2026-04-02 02:15:40 +07:00
0xmrpeter
ae7a7b726b feat(cli): add non-interactive openacp setup command
Adds `openacp setup` command for programmatic configuration by the desktop app, accepting --workspace, --agent, --run-mode, and --json flags.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 02:11:43 +07:00
0xmrpeter
d78c1454c2 fix(cli): normalize agents --json test mock pattern and remove undocumented switch case
- Remove case "--json": from switch statement in agents.ts to prevent undocumented behavior like "openacp agents --json gemini" silently misbehaving. The "list" and "undefined" cases are sufficient.
- Update test 2 to use ['list', '--json'] instead of ['--json'] now that the undocumented case is removed.
- Normalize mock pattern to use standard vi.fn().mockImplementation() with class syntax for better maintainability.
- Add afterEach(() => vi.restoreAllMocks()) to ensure proper cleanup between tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 02:09:40 +07:00
0xmrpeter
d361c2f69b feat(cli): add --json flag to openacp agents list
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 02:06:41 +07:00
0xmrpeter
7571bd12ba enhance(api): add channel and thread information to session details
- Updated the API command output to include the channel ID and thread ID for better session tracking.
- Modified prompt constants to emphasize the necessity of passing `--channel <current_channel>` when creating sessions to avoid headless sessions.
- Enhanced session creation instructions to clarify the importance of specifying the channel to ensure user visibility in Telegram.
2026-04-02 00:20:52 +07:00
Mr.Peter
04f29de190
Merge pull request #186 from Open-ACP/refactor/cmd-assistant-impl
refactor: unify command dispatch, move assistant to core, extensible menu
2026-04-01 20:40:30 +07:00
0xmrpeter
055da3b800 feat(remote): use one-time codes, show copyable links outside box 2026-04-01 19:17:29 +07:00
0xmrpeter
1b59e80977 fix: address code review critical and important issues
- Use closure core variable instead of args.coreAccess in command handlers
- Remove pendingResumes state machine from resume.ts
- Replace silent fallback with delegated in command-registry
- Fix plugin template signatures for registerMenuItem and registerAssistantSection
- Add delegated type to CommandResponse docs in plugin template
- Update test to match silent->delegated change

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 18:48:46 +07:00
0xmrpeter
24fbd3e670 docs: update plugin template for new registries, final cleanup
Add registerMenuItem/unregisterMenuItem and registerAssistantSection/unregisterAssistantSection
to PluginContext API docs in claude-md.ts and plugin-guide.ts templates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 18:22:51 +07:00
0xmrpeter
8ffbdd0644 refactor: adjust argument indexing in CLI commands for consistency
Updated argument indexing across multiple CLI command files to ensure the first argument is consistently used for the primary command. This change affects the `adopt`, `agents`, `api`, `config`, `install`, `integrate`, `tunnel`, and `uninstall` commands, improving usability and reducing confusion in command usage.

- Changed argument references from `args[1]` to `args[0]` for primary commands.
- Adjusted subsequent argument references accordingly to maintain correct functionality.
2026-04-01 15:56:03 +07:00
0xmrpeter
ff9c6028bb fix: dev-loop, config command, instance-context and startup improvements
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 15:48:43 +07:00
0xmrpeter
914fc013d6 refactor: rename 'dangerous mode' to 'bypass permissions' across documentation and code
- Updated all references from 'dangerous mode' to 'bypass permissions' in CLI commands, API documentation, and internal logic.
- Adjusted command usage and descriptions to reflect the new terminology for clarity and consistency.
- Removed warmup functionality from session management as part of the refactor.
2026-04-01 13:28:08 +07:00
0xmrpeter
e720f84dd0 fix(cli): correct plugin subcommand arg indexing and add local dir install docs
Args were off-by-one (args[2] instead of args[1]) after refactoring
the CLI dispatch. Also added help text for local directory install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 13:09:32 +07:00
0xmrpeter
d1850da198 refactor: rename 'label' to 'name' in config options for consistency
- Updated the ConfigSelectChoice interface to replace 'label' with 'name'.
- Adjusted related code in API commands and tests to reflect this change.
- Ensured consistency across configuration options and improved clarity in the codebase.
2026-04-01 12:42:53 +07:00
0xmrpeter
a9a8111ae1 Merge branch 'develop' of github.com-peter:Open-ACP/OpenACP into develop 2026-04-01 10:59:11 +07:00
0xmrpeter
e8aabd58fd chore: update workspace terminology and improve instance handling
Changes include:
- Updated `.gitignore` to include `.openacp` for local workspace secrets.
- Refactored CLI commands to replace "instance" with "workspace" for consistency.
- Enhanced workspace setup and registration logic, including deduplication of entries.
- Improved user prompts and error messages related to workspaces.
- Added functionality to protect local workspace secrets from being tracked by git.

This commit aims to clarify the distinction between workspaces and instances, enhancing user experience and code maintainability.
2026-04-01 10:58:33 +07:00
0xmrpeter
b4d27a0af4 feat: add session config CLI commands
Add `openacp api session-config` subcommand group to manage ACP session
config options via the REST API: list options, set a value, show
clientOverrides, and toggle bypassPermissions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 10:41:03 +07:00
0xmrpeter
7e9f319cc4 refactor: remove setMode/setModel and legacy middleware hooks
Remove the deprecated setMode() and setModel() methods from AgentInstance
since all config changes now go through setConfigOption(). Also remove the
mode:beforeChange and model:beforeChange middleware hooks from
MiddlewarePayloadMap and plugin templates, keeping config:beforeChange as
the single unified hook.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 10:22:32 +07:00
0xmrpeter
32caea5d59 refactor: group instance-* files into core/instance/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:50:30 +07:00