- teamwork_task_update accepts optional agent; recorded agent resolves explicit ->
calling session agent (ctx.session.get, then snapshots bySession) -> plan agent.
Derivation is fail-open with a 2s bound; every value passes clean(value, 64).
- teamwork_cost: non-root spend buckets to input.taskId when given; without it the
agent-name bucketing is unchanged.
- costs.json gains additive byTaskTokens (per-bucket token deltas) in the same
locked section and the tree / single-session paths; manual addUsd adds no tokens.
- byTaskTokens initialised on new costs.json and tolerated when absent.
- isSafeTaskId: ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$, rejects . and ..
- validated at worktree entry point (all actions) before any path/branch is built
- containmentError: relative(runWorktreesDir, targetDir) must be non-empty, non-absolute, not '..'
- containment asserted before mkdirSync/rmSync/worktree add for sentinel and worker/verifier setup;
rmSync re-proves containment immediately before deletion
- teamwork_cost reads real, OpenCode-computed cost via ctx.session.get and
reports per-session deltas; fixes 4x over-reporting from agent self-reports
- serialize cost writes per run; atomic writes; byTask always sums to total
- budgetUsd:0 respected; negative addUsd rejected; re-plan keeps spend
- teamwork_budget preflight: opencode/ models + opencode_console connected ->
derive budget from credits, asking the user full or partial; plan records
budgetSource and warns when credits apply but weren't used
- sentinel: budget preflight step + post-completion verifier step
Audited by clean-context subagents across three rounds; every finding fixed and
re-verified.
- F1 path traversal: sessionId allowlist + lexical & realpath containment;
refuse a symlinked run root, symlinked run dir, and any symlinked run file
(lstat-based, dangling-safe)
- F2 command injection: no shell interpolation of session ids — server-derived
$SESSION_ID, quoted; lint scans agent files AND command templates (incl.
backslash line-continuations)
- F3 read-only guardrail: per-agent deny list (real permission actions),
fail-closed when the permission API is unavailable
- F4 stored prompt injection: sanitised run-state injection (phase allowlist,
validated dir name, no raw newlines/paths)
- F5 installer is non-destructive by default (refresh opt-in via --refresh)
- F6 refuse symlinked/JSONC configs; string-aware comment/trailing-comma strip
- F8 create-only reference copy on plugin load
- add team/security-auditor agent + docs/GUARDRAILS.md + guardrail lint rules
- plugins/opencode-teamwork/tools.ts registers teamwork_plan/status/resume/
cost/pitfall tools that own the run dir, plan.dag.json, state.json,
costs.json and the pitfall registry
- permission.hook('evaluate') enforces the read-only guarantee for verifier/
falsifier/scout in code, not just in the prompt
- session.hook('context') injects the active run's state + pitfalls into every
team agent's system prompt
- sentinel/orchestrator now call the tools instead of hand-writing files
- single canonical artifact root .opencode/teamwork/<session-id>/ everywhere
(was split between .teamwork-runs/<run-id>/ and .opencode/teamwork/)
- remove per-file 'run-time reminder' duplicates and the self-referential
'read your agent file' instructions
- fix stale refs: src/agents/defaults.ts, agent.team/* keys, 'four patterns',
Antigravity attributions, unverifiable Deep Think comparison
- restore interrupted.md handling in the orchestrator
Port the V1 opencode-teamwork plugin to the OpenCode V2 plugin API.
- plugin now default-exports { id, setup } and registers the 7 /team* commands
via ctx.command.transform (V1 config-hook injection no longer exists)
- agents moved to markdown files under agents/team/ (V2 plugins cannot add agents)
- command templates converted from {{ }} handlebars to $ARGUMENTS
- agent permissions converted to the V2 permissions array (edit/shell/webfetch/subagent)
- no runtime dependency on @opencode/plugin
Verified against OpenCode v2.0.26.