Skip to content

feat(ai): add configurable custom ACP runtimes - #349

Merged
jsgrrchg merged 15 commits into
mainfrom
feature/custom-acp-runtimes
Jul 29, 2026
Merged

feat(ai): add configurable custom ACP runtimes#349
jsgrrchg merged 15 commits into
mainfrom
feature/custom-acp-runtimes

Conversation

@jsgrrchg

Copy link
Copy Markdown
Owner

Summary

Adds user-configurable local ACP runtimes alongside the built-in provider catalog.

  • Persist, validate, verify, edit, delete, and restore custom ACP definitions.
  • Launch custom executables directly with isolated environments and no built-in provider credentials.
  • Add Settings UI for custom runtime management, including argument/environment editors and tombstones retained for history.
  • Preserve runtime identity, revision, fingerprint, and continuation metadata in chat history.
  • Support capability-driven session/resume, session/load, and transcript-only recovery.
  • Refresh runtime selection/defaults dynamically without affecting existing live sessions.
  • Explicitly shut down owned ACP processes when runtime sessions are deleted.
  • Keep custom authentication errors isolated from built-in provider onboarding.
  • Extend the sidecar smoke test with fake custom ACP workflows, continuation modes, environment isolation, interactive ACP events, failure cases, restore/reconnect, and process cleanup.
  • Document the product contract, security boundary, lifecycle, recovery, and troubleshooting.

Security and behavior notes

  • Custom commands are launched without a shell.
  • Custom runtimes receive a controlled PATH and isolated environment.
  • Secret-like custom environment variables are rejected.
  • NeverWrite does not inject or persist built-in provider credentials for custom runtimes.
  • Editing or deleting a definition does not alter an already-running session’s launch snapshot.
  • Deleted definitions are retained as tombstones so historical chats remain identifiable and restorable.

Validation

  • cargo test -p neverwrite-native-backend
  • npm --prefix apps/desktop test -- --run src/features/ai/store/chatStore.test.ts
  • npm --prefix apps/desktop run lint
  • npm --prefix apps/desktop run build
  • npm --prefix apps/desktop run electron:sidecar:build
  • npm --prefix apps/desktop run electron:ai-runtime:smoke
  • git diff --check

@jsgrrchg jsgrrchg linked an issue Jul 26, 2026 that may be closed by this pull request
@jsgrrchg jsgrrchg linked an issue Jul 26, 2026 that may be closed by this pull request
@jsgrrchg

Copy link
Copy Markdown
Owner Author

@spamsch this is the last piece of the acp architecture, I waited on this because of security concerns and the stability of the acp protocol, but now it seems that the v1 version is stable enough.

Only if you can, give it a test with with other community acp adapters for popular agents like Pi or Hermes.

@jsgrrchg

Copy link
Copy Markdown
Owner Author

Fixed edge case found during testing with not very well done acp adapters.

@jsgrrchg jsgrrchg added type: ACP Agent Client Protocol related work type: enhancement New feature or improvement labels Jul 26, 2026
Preserve custom ACP continuation identity across transactional history reconciliation.
@jsgrrchg

Copy link
Copy Markdown
Owner Author

Resolved the conflicts with main and pushed the merge as b71aeb03.

The visible conflicts were resolved as follows:

  • apps/desktop/native-backend/src/ai.rs

    • Kept the unified runtime catalog as the source of truth for ACP protocol selection.
    • Removed the conflicting assertion that depended on the obsolete acp_protocol_flavor() helper.
  • apps/desktop/native-backend/src/main.rs

    • Registered both ai_history from main and custom_acp / runtime_catalog from this branch.
    • Preserved the complete transactional history service alongside custom ACP runtime management.
  • apps/desktop/src/features/ai/store/chatStore.test.ts

    • Combined the runtime mocks required by both branches: confirm, invoke, listen, and openUrl.
  • apps/desktop/src/features/ai/store/chatStore.ts

    • Preserved all three saved-session recovery strategies:
      • custom_acp_continuation
      • native_load_session
      • transcript_prompt_injection
    • Centralized recovery strategy selection so started, fallback, success, and failure logs report the strategy that was actually attempted.
    • Custom runtime transcript forks continue through a new ACP session instead of reconnecting to the source runtime session.
  • crates/ai/src/persistence.rs

    • Kept the custom runtime identity and continuation types.
    • Adopted main’s explicit history storage root boundary instead of rebuilding .neverwrite/sessions internally.
    • Preserved the custom runtime metadata fields across lazy, legacy, and paginated history representations.

Two non-textual integration issues were also fixed:

  1. The new transactional migration test fixtures from main did not initialize the custom ACP metadata fields added by this branch. The fixtures now exercise realistic custom runtime metadata and verify that reconciliation preserves:

    • runtime display name
    • runtime revision
    • launch fingerprint
    • runtime session ID
    • continuation strategy
  2. The transactional history content fingerprint introduced by main did not include those custom ACP identity fields. Without this fix, two copies of the same transcript with different ACP session identities could be treated as duplicates during reconciliation.

    The fingerprint now includes the complete custom continuation identity while remaining stable for pre-custom-runtime histories. An integration test also verifies that histories with identical transcripts but different runtime_session_id values block reconciliation instead of silently deduplicating one copy.

Custom runtime fork behavior remains intentionally isolated:

  • The source runtime_session_id is discarded.
  • The fork is persisted with new_session_only.
  • Reopening the fork creates a fresh ACP session and injects the copied transcript as context.

Validation completed successfully:

  • cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • Full Rust workspace test suite
  • 328 native backend tests
  • 67 neverwrite-ai tests
  • 188 frontend test files: 2,250 passed, 2 todo
  • ESLint
  • Renderer and Electron builds
  • Vault/editor sidecar smoke
  • AI runtime sidecar smoke

An independent review agent also compared the resolved merge against both parents and found no medium- or high-severity regressions in transactional history storage, custom ACP lifecycle behavior, inline review, or the agent changes panel.

@jsgrrchg

Copy link
Copy Markdown
Owner Author

QA, external acp working fine, same with chat history migration.

@jsgrrchg
jsgrrchg merged commit ff193d1 into main Jul 29, 2026
14 checks passed
@jsgrrchg
jsgrrchg deleted the feature/custom-acp-runtimes branch July 29, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: ACP Agent Client Protocol related work type: enhancement New feature or improvement

Projects

None yet

1 participant