UNPKG

akm-cli

Version:

akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur

57 lines (56 loc) • 2.73 kB
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. /** * OpenCode SDK harness DESCRIPTOR (#564). * * This module is a dependency-graph LEAF: it imports only the harness base * types (`../types`) and nothing from `core/config` or the SDK runner. Keeping * the descriptor separate from the runtime runner (`./sdk-runner`, which pulls * `core/config`) is load-bearing: `HARNESS_REGISTRY` in `../index.ts` imports * this class from HERE, not from the per-harness barrel (`./index.ts`). The * barrel additionally re-exports `runOpencodeSdk`/`closeServer` from * `./sdk-runner`; that re-export makes the barrel transitively depend on * `core/config`, and `core/config/config-types` derives `VALID_HARNESS_IDS` * back from `../index.ts`. If the registry imported the class through the * barrel, that cycle would evaluate `../index.ts` (and `new * OpencodeSdkHarness()`) while the barrel — and hence this class binding — was * still initializing, throwing a temporal-dead-zone "Cannot access * 'OpencodeSdkHarness' before initialization" whenever the barrel is the first * module loaded in a fresh graph (e.g. the workflow-exec subprocess entry). * Importing the descriptor from this leaf keeps the registry a config-leaf and * breaks the cycle. */ import { createAgentRequestLowerer } from "../../agent/request-lowering.js"; import { MODEL_WORK_AGENT_INFERENCE } from "../opencode/model-config.js"; import { caps } from "../shared.js"; import { BaseHarness } from "../types.js"; /** * OpenCode SDK (embedded-SDK dispatch path). * * Dispatch-only: no native session logs, but detected at setup. */ export class OpencodeSdkHarness extends BaseHarness { id = "opencode-sdk"; displayName = "OpenCode SDK"; // ── Workflow-engine descriptor (plan §"Capability matrix", P2) ──────────── executionLowerer = { platform: "opencode-sdk", personaChannel: "native", lower: createAgentRequestLowerer({ adapter: "opencode-sdk", personaChannel: "native", tools: "sdk", inference: MODEL_WORK_AGENT_INFERENCE, }), }; // No flag-shaped resume: session reuse is programmatic — the SDK session id is // stored opportunistically on the unit row and passed back to // `session.prompt`, not replayed via a CLI flag. // No `identityEnv`: the SDK runs in-process; it does not mark a child // process environment with a session id of its own. capabilities = caps({ agentDispatch: true, detection: true, }); }