Skip to content

feat: v2 api support - #170

Open
einyx wants to merge 7 commits into
CyberStrikeus:mainfrom
einyx:main
Open

einyx wants to merge 7 commits into
CyberStrikeus:mainfrom
einyx:main

Conversation

@einyx

@einyx einyx commented Oct 28, 2026 •

Copy link
Copy Markdown

Summary

Fixes #171
Implements the v2 API over CyberStrike's existing v1 domain. Most endpoints now return real data, including session, message, permission, fs, vcs, mcp, worktree, pty, persistent pty, shell, credentials, saved permissions, debug, catalog reads, config, plugin and rpc registries, reference, websearch, generate, integration auth, pairing, client-hosted MCP, and session background.

Three voice endpoints (voice.models, voice.session, voice.instructions) still answer 503 not implemented. CyberStrike has no realtime or audio provider, so they're waiting on a provider choice.

Behaviour changes outside v2 (review these)

  • Saved permissions (security-relevant): "always" permission replies are now persisted in a permission_saved table and read back as allow rules by PermissionNext.ask.
  • patchJsonc now removes keys set to undefined, which changes v1 config writes.
  • Session: session.created is logged. prompt.ts injects session instructions into the system prompt. The bash tool and session shell take a per-session env overlay.
  • bash.ts / shell/registry.ts: session.background detaches a running bash command into the shell registry. Only one foreground command per session can be backgrounded.
  • Config: new integration.wellknown_commands allowlist. Only argv entries listed there are ever run from a discovered well-known document.
  • Migrations: two hand-written, since there's no drizzle snapshot in this checkout.

Security-sensitive additions

  • integration.wellknown.add: https only (http for localhost only), no redirects, size and time limits, and it executes only allowlisted argv.
  • server.pair / server.connect: 16-byte codes, 5-minute TTL, single use, hashed storage, 30-day bearer tokens, 5 failures per minute per peer. Bearer tokens are not accepted on terminal WebSocket upgrades, which still need Basic auth or a ticket.
  • mcp.clientToken / mcp.client: single-use token bound to a directory and client name, 5-minute TTL. Client tools exist only while the socket is attached.

Known issues

  • Client-hosted MCP: after a socket detaches, stale tool entries can remain in the lazy tool registry. Tracked for a follow-up fix.
  • Bun 1.3.12 can hang on server.stop after a server-initiated WebSocket close. Shutdown can hang in the connect-failure teardown path.
  • integration.connect.external is not advertised in integration.list, so clients can't discover it yet.

Testing

  • bun run typecheck: clean.
  • bun test --timeout 30000 test/api-v2: 92 pass, 0 fail, 33 files.
  • The client MCP expiry test runs against a 50 ms TTL store, since the live TTL is 5 minutes.

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title v2 api support doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, cyberstrike).

See CONTRIBUTING.md for details.

@einyx einyx changed the title v2 api support feat: v2 api support Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@deyoyk

deyoyk commented Oct 30, 2026

Copy link
Copy Markdown

can someone merge this

@einyx

einyx commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

rebased

Adds packages/api-v2 (wire, events, projections, OpenAPI) and the
api-v2 server routes in cyberstrike, migrates plugins to
@cyberstrike-io/sdk/v2, regenerates v2 SDK types, and adds the
contract check script with a CI workflow. Also documents the
v1-to-v2 mapping decisions and removes the applescript skill file.
Replace most 503 stubs in the v2 API with real handlers backed by the
v1 domain: session, message, permission, fs, vcs, mcp, worktree, pty,
persistent pty, shell, credential, saved permissions, debug, catalog
reads, config, and plugin and rpc registries.

Still answering 503 (no backing or pending a decision): server.pair,
server.connect, integration.wellknown.add, integration.connect.external,
mcp.client, mcp.clientToken, session.background, voice.models,
voice.session, voice.instructions.

Behaviour change outside v2: "always" permission replies are now
persisted and read back as allow rules by PermissionNext.ask.
Replace the 503 stubs with real handlers:

- integration.wellknown.add: https only (http for localhost), with the
  discovered auth command run only when it exactly matches the
  integration.wellknown_commands config allowlist.
- integration.connect.external: stores an env-var reference, never the
  secret; resolved when the provider is used.
- server.pair / server.connect: single-use 5-minute pairing codes, hashed
  storage, 30-day bearer tokens, per-peer failure rate limit.
- mcp.clientToken / mcp.client: single-use directory-bound token; the
  socket attaches its tools to v1 MCP only while connected.
- session.background: moves the session's running bash command into the
  shell registry.

Voice endpoints (voice.models, voice.session, voice.instructions) still
answer 503 pending a provider choice.

Also documents the 503 status of the v2 surface in docs/v2-api.md.
@einyx

einyx commented Nov 24, 2026

Copy link
Copy Markdown
Author

@badchars ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: v2 api support.

2 participants