mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(secrets): repository secrets and variables injected into agent shells and terminals
Add a GitHub Actions-style store for secrets and variables so tests can read
credentials from the environment without .env files in the repo.
- secrets table keyed by kind, repo (NULL for global) and environment;
secrets are encrypted with encryptSecret and write-only, variables are plain
text. Names follow GitHub's rules and reject Manager-reserved names.
- Global (/api/secrets, /api/variables) and repo
(/api/repos/:id/secrets|variables) routes.
- The trusted .ocm/project.json gains environment and env fields that map
names to ${{ secrets.X }} / ${{ vars.X }} expressions. Both are part of the
trust hash; files without them hash as before, so existing trust survives.
- RepoEnvService.resolveForDirectory resolves the repo and approved mapping
for any directory, including worktrees outside the repo folder, with
environment > repo > global precedence. It never throws.
- /api/internal/shell-env replaces /git-credentials/gh-env and feeds the
ocm-gh-env plugin, the sandbox shell plan and TerminalService.create.
- The plugin masks injected secret values as *** in completed tool results.
- The sandbox shell plan is now the only source of the guest environment: the
plugin pins OCM_SANDBOX_FORWARD_ENV and the shim forwards only those names.
This commit is contained in:
1 parent
b431c121a2
commit
e0331b43bf
47 files changed
+2073
-156
No files matched your search
@@ -10,11 +10,16 @@ import { TerminalService } from '../../src/services/terminal'
|
||||
import { OpenCodeServerNotFoundError } from '../../src/services/opencode-server-registry'
|
||||
import type { OpenCodeClient } from '../../src/services/opencode/client'
|
||||
import type { CredentialProvider } from '../../src/services/credential-provider'
|
||||
import type { RepoEnvService } from '../../src/services/repo-env'
|
||||
import { startWebSocketServer, type WebSocketTestServer } from '../helpers/websocket-server'
|
||||
import { rawWebSocketHandshake } from '../helpers/raw-websocket-handshake'
|
||||
|
||||
const TRUSTED_ORIGIN = 'http://localhost:5003'
|
||||
const SERVER_ID = 'srv_kitchen'
|
||||
function stubRepoEnvService(): RepoEnvService {
|
||||
return { resolveForDirectory: async () => ({ env: {}, maskValues: [], missing: [] }) } as unknown as RepoEnvService
|
||||
}
|
||||
|
||||
const UNKNOWN_SERVER_ID = 'srv_missing'
|
||||
const DIRECTORY = '/home/me/app'
|
||||
|
||||
@@ -61,6 +66,7 @@ const managerWs = createNodeWebSocket({ app: managerApp })
|
||||
const terminalService = new TerminalService(
|
||||
{ client: remoteClient, baseUrl: () => `http://127.0.0.1:${upstream.port}`, includeLocalCredentials: false },
|
||||
credentialProvider,
|
||||
stubRepoEnvService(),
|
||||
)
|
||||
|
||||
const resolveTerminalService: ServerTerminalServiceResolver = (serverId) => {
|
||||
|
||||
Reference in new issue
Block a user