Commit Graph

28 Commits

Author SHA1 Message Date
Carlos Florêncio 7076a40805 chore: change default ports to avoid common conflicts (#681) 2026-04-23 18:09:53 +01:00
João Salavisa dccff23cc0 feat(backend): per-launch authentication for agentctl (#666)
* feat(backend): per-launch authentication for agentctl

Add nonce-based handshake protocol to secure all agentctl HTTP/WS
endpoints. On launch, the parent (backend) passes a one-time bootstrap
nonce via AGENTCTL_BOOTSTRAP_NONCE env var. agentctl generates its own
auth token, enables Bearer auth immediately, and returns the token to
the parent via POST /auth/handshake (validated by nonce).

Standalone, Docker, and Sprites executors all use the same handshake
flow. Removes the old AGENTCTL_AUTH_TOKEN env var approach. For
Docker/Sprites, the retrieved token is persisted encrypted in
SecretStore (AES-256-GCM) for crash recovery.

Security properties:
- Auth enabled from boot (no unprotected window)
- Token never in env vars (only the burned nonce)
- Nonce is one-shot (replay impossible)
- Constant-time token comparison (timing-safe)

* fix: check fmt.Sscanf return value in integration test

* fix: address review feedback - constant-time nonce comparison, safe ID truncation

* fix(backend): exempt MCP routes from agentctl auth middleware

The agent subprocess connects to agentctl's MCP endpoints (/sse, /message,
/mcp) to use kandev tools (create_task, ask_user_question, etc.). These
endpoints run on the same HTTP server as the authenticated API, but the
agent process doesn't possess the auth token — it was only exchanged
between the backend and agentctl during the handshake.

Exempt /sse, /message, and /mcp from the Bearer auth middleware since the
agent process runs in the same trust boundary as agentctl.

* refactor(backend): remove query param token fallback and document SetAuthToken constraint

Remove the ?token= query parameter fallback from extractBearerToken —
tokens in URLs leak via access logs, referer headers, and browser history.
All WS callers already use Authorization headers via wsAuthHeaders().

Document SetAuthToken's concurrency constraint: it must not be called
concurrently with HTTP requests on the same client.

* fix(backend): enforce mutex in ControlClient/Launcher auth, fix Start() lock scope

- Add sync.Mutex to ControlClient; protect SetAuthToken and AuthToken() reads
- Guard Launcher.AuthToken() with l.mu (written under lock in Start, read unprotected)
- Extract buildAndStartProcess and performHandshake from Start() (was 106 lines, over 80-line limit)
- Release l.mu before blocking health/handshake calls so monitorExit() can close
  l.exited — previously the fast-fail path in waitForHealthy was unreachable
- Update stale executor_backend.go comment (standalone no longer uses env var auth)

Co-authored-by: João Salavisa <undefined@users.noreply.github.com>

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: João Salavisa <undefined@users.noreply.github.com>
2026-04-21 14:00:49 +01:00
João Salavisa 06cb48b300 fix(docker): use API version negotiation instead of hardcoded 1.41 (#636)
The default Docker API version was hardcoded to 1.41, which fails on
newer Docker daemons that require at least API version 1.44.

Change the default to empty string so the Docker client uses the
existing WithAPIVersionNegotiation() option to auto-negotiate a
compatible version with the daemon.
2026-04-18 11:06:32 +01:00
Carlos Florêncio 814efdfa67 fix(cli): isolate dev mode state when running inside a kandev task (#617) 2026-04-17 19:41:29 +01:00
Carlos Florêncio b07356b29b feat(debug): enable pprof memory profiling in dev/debug mode (#518) 2026-04-01 23:21:29 +01:00
Carlos Florêncio 42cdb56889 fix: use kandev home dir for worktrees, repos, sessions instead of data dir (#405) 2026-03-10 19:40:50 +00:00
Carlos Florêncio b48471e063 feat: single-port architecture and browser warning fixes (#390) 2026-03-08 13:10:39 +00:00
Carlos Florêncio e62498ba05 fix: correct default data directory to ~/.kandev/data (#389) 2026-03-08 11:25:21 +00:00
Carlos Florêncio 766e62d8c2 fix(worktree): improve startup readiness and base sync handling (#374) 2026-03-05 20:55:22 +00:00
Carlos Florêncio c81fb77f72 ci: improve docker image and KANDEV_DATA_DIR env var (#370) 2026-03-05 20:31:17 +00:00
Carlos Florêncio aea8dc7b67 feat: improve workflows and agent resume (#269) 2026-02-23 23:54:27 +00:00
Carlos Florêncio dff0b49c51 docs: add github integration (pr watcher) (#262) 2026-02-23 00:16:37 +00:00
Carlos Florêncio 9baa985bbf feat: improve db abstraction (#238) 2026-02-17 17:37:55 +00:00
Carlos Florêncio cad2d783b3 feat: improve windows support (#225)
release / build-web (push) Has been cancelled
release / build-bundles (aarch64-linux-gnu-gcc, arm64, linux, ubuntu-latest, linux-arm64) (push) Has been cancelled
release / build-bundles (amd64, darwin, macos-13, macos-x64) (push) Has been cancelled
release / build-bundles (amd64, linux, ubuntu-latest, linux-x64) (push) Has been cancelled
release / build-bundles (amd64, windows, windows-latest, windows-x64) (push) Has been cancelled
release / build-bundles (arm64, darwin, macos-14, macos-arm64) (push) Has been cancelled
feat: windows support
2026-02-15 18:16:21 +00:00
Carlos Florêncio 5c077062b2 feat: add make start (#151) 2026-02-02 16:35:47 +00:00
João Salavisa f229c72393 feat: migrate MCP server from backend to agentctl (#124) 2026-01-30 15:15:19 +00:00
João Salavisa 1888f8465f feat(backend): add thinking/reasoning streaming support (#113) 2026-01-28 17:22:19 +00:00
Carlos Florêncio 7c82ccdf24 feat: improve logging (#105) 2026-01-27 00:18:42 +00:00
João Salavisa 187d002717 feat: per-task executor selection with multi-runtime support (#92) 2026-01-25 02:05:19 +00:00
Carlos Florêncio efd36ffbb7 feat: http logging middleware + mcp random port (#74) 2026-01-22 02:27:14 +00:00
João Salavisa c57a82f81d feat(mcp): add embedded MCP server with dual transport support (#67) 2026-01-21 12:03:46 +00:00
João Salavisa fa8364307f fix: use AGENTCTL_PORT env var for backend ControlClient (#63) 2026-01-21 11:39:14 +00:00
João Salavisa 2fbc229eaf fix: bind KANDEV_AGENT_STANDALONE_PORT env var to config (#61) 2026-01-20 22:29:05 +00:00
João Salavisa 82e8c8905b feat: replace agent_type with agent_profile_id (#14)
* feat: replace agent_type with agent_profile_id

- Replace agent_type field with agent_profile_id across backend and frontend
- Add ProfileResolver interface and StoreProfileResolver implementation
- Update task creation/update to use agent_profile_id
- Change default agent runtime from docker to standalone
- Fix workspace state types to include all required fields
- Fix websocket handlers type mismatches for environments, executors, workspaces
- Update integration tests to use agent_profile_id

* feat: pass model as CLI argument to agents

- Add ModelFlag field to AgentTypeConfig for specifying the CLI flag
- Set ModelFlag to '--model' for all agents (auggie, claude, codex, gemini, opencode, copilot)
- Update launchStandalone to append model flag to agent command
- Update launchDocker/buildContainerConfig to append model flag to container command
- Model is passed when both agent supports ModelFlag and profile has Model configured

* fix: make WebSocket message handling async to prevent blocking

When a long-running handler like orchestrator.prompt was executing,
it blocked the ReadPump loop, preventing other requests (like
workspace.tree.get) from being processed until the handler completed.

Now each message is handled in its own goroutine, allowing concurrent
message handling so file tree requests work while the agent is working.

* feat: show task description as first message in chat

- Add 'Task' label with distinct styling (lighter background, border)
- Pass taskDescription from page to TaskChatPanel component
- Differentiate from regular user messages visually
2026-01-14 12:29:58 +00:00
João Salavisa 6d9f78b7b7 fix(agentctl): standalone mode workspace path and worktree lookup (#10) 2026-01-13 02:05:33 +00:00
jcfs 20c456dc07 feat: implement Git worktrees for concurrent agent execution
- Add worktree package with Manager, Store, Config, and error types
- Integrate worktree creation/reuse into lifecycle manager
- Update executor to pass worktree configuration
- Add WorktreeConfig to common config package
- Enable worktrees by default for agent isolation
- Add unit tests for worktree manager

This allows multiple agents to work on the same repository simultaneously
by creating isolated worktrees for each task. Worktrees persist between
agent runs for task resumption and are only cleaned up when tasks are
explicitly deleted.
2026-01-12 15:04:16 +00:00
Carlos Florêncio 473b336b13 feat: added repositories support 2026-01-11 19:59:28 +00:00
jcfs 20f5f43fb3 feat: complete acp-go-sdk integration with task state updates
- Use acp-go-sdk for all ACP communication in agentctl
- Mark agent as completed when Prompt() returns successfully
- Update task state to COMPLETED when agent completes
- Update task state to FAILED when agent fails and retries exhausted
- Enhanced E2E test to verify agent actually creates files
- E2E test now validates full flow: task creation -> agent work -> file creation -> task completion
2026-01-10 16:46:35 +00:00