Skip to content

refactor: inline playbook session runtime, unify base-resource identity#34

Open
heimanba wants to merge 6 commits into
mainfrom
refactor/inline-playbook-session-runtime
Open

refactor: inline playbook session runtime, unify base-resource identity#34
heimanba wants to merge 6 commits into
mainfrom
refactor/inline-playbook-session-runtime

Conversation

@heimanba

@heimanba heimanba commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR consolidates four changes that simplify the session runtime architecture and strengthen base-resource identity tracking:

1. feat(byoc): runtime config, sessions and vaults updates

  • Add metadata stamps (agents.base / agents.vault) to buildRuntimeConfig so the webui can identify managed base resources via remote listing.
  • Migrate playground state from examples/bailian/bailian-cli/agents.state.json to ~/.agents/playground.state.json (one-time auto-migration preserves remote_ids).
  • Relax findBaseVault to match on metadata stamp alone (not display_name), since the engine and imperative path may create vaults with different display_name values but both always set the stamp.

2. refactor: inline session runtime from playbooks into server

  • Move session-runtime.ts from @openagentpack/playbooks into apps/server/src/services/sessions/playbook-session-adapter/runtime.ts — the server is the only production consumer.
  • Replace the generic PlaybookSessionRuntimeAdapters<TDetail, TEvent, TSession, TAgent> with concrete PlaybookSessionRuntimeDeps using ProviderSessionEvent/Session directly.
  • Add runtime.test.ts with full coverage of pick, start, send, list, getDetail, delete.

3. refactor(playbooks): drop unused readiness mapping

  • Remove SKILL_STATUS_CODE, skillStatusFromCode, and numeric↔string mapping code — no remaining consumers after Mode B removal.
  • Update parity tests to only assert string-based status normalization.

4. chore: remove playground dead dep on playbooks, update description

  • Drop unused @openagentpack/playbooks devDependency from packages/playground.
  • Clean up all "Mode A"/"Mode B" terminology from comments across the codebase.

Agent declares environment + vault

  • toAgentBuildInput now resolves environment and vault names from the assembled config and sets them on the agent declaration, so syncAgentResources manages base resources through the plan/apply engine (state tracking + drift detection).
  • Fail-fast invariant checks ensure exactly one environment (and at most one vault per provider).

Test results

All 812 tests pass across all workspaces. Typecheck, architecture conformance, and lint all green.

Behavior / risk

No breaking API change is intended. Runtime base resources keep their managed identity while playground state moves to ~/.agents/playground.state.json with one-time legacy migration. The PR gate now asks for risk and validation evidence in the PR description for high-risk changes, including verification-policy changes, without requiring a special commit-message marker or history rewrite. A generated bun.lock change alone is covered by audit and compatibility checks.

Validation

  • bun scripts/verify.ts full --step typecheck
  • bun scripts/verify.ts full --step lint
  • bun scripts/verify.ts full --step architecture
  • bun scripts/verify.ts full --step test

heimanba added 6 commits July 19, 2026 14:27
Change-Id: I5d340bb58f1d0d9a68607024aa49fe0b37c1eab6
Co-developed-by: Qoder <noreply@qoder.com>
readinessFromPick, PlaybookReadiness, and their tests have no
production consumer: the server's agent readiness flows through the
sdk's listAgentsWithReadiness instead. Remove the dead code before
inlining the session runtime.

Change-Id: I131ba28e7fbee9ec2aaf3a44467d27bc590dfd28
Co-developed-by: OpenCode <noreply@opencode.ai>
The playbook session-runtime adapter layer (createPlaybookSessionRuntime,
pickPlaybookAgent, PlaybookAgentIdentityMismatchError, and ~15 input/output
types) lived in @openagentpack/playbooks but had exactly one production
consumer: the server's playbook-session-adapter. This commit:

- Moves the runtime orchestration and agent-pick logic into a new
  apps/server/.../playbook-session-adapter/runtime.ts with all generic
  type parameters instantiated to their concrete server types.
- Replaces the four adapter interfaces with a single concrete
  PlaybookSessionRuntimeDeps type (dependency injection preserved for
  testability, but no cross-package abstraction).
- Migrates tests to apps/server with type-safe fake constructors.
- Removes session-runtime.ts from @openagentpack/playbooks and cleans
  up all re-exports from the package index.
- Eliminates the duplicate ListPlaybookSessionsInput definition in
  sessions.ts (now imported from runtime.ts).

Behavioral changes: none. The PlaybookAgentIdentityMismatchError still
surfaces as HTTP 500 (no route-level catch); a future PR can map it to
4xx if desired.

Change-Id: Ia4276ea3626877163f60529342e7da1ba3a991bd
Co-developed-by: OpenCode <noreply@opencode.ai>
playground's devDependency on @openagentpack/playbooks had zero imports
in its source tree. Remove it.

Also update the playbooks package description now that the session
runtime orchestration no longer lives there.

Change-Id: Ic6ac9936561f2186da6b2cdd37d8ffd0121402d3
Co-developed-by: OpenCode <noreply@opencode.ai>
Change-Id: I1f4b06c06ca304d98f5a1151aad48f1bf4537cec
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.

1 participant