feat(protocol): AgentFn<Opt> type + createAgentAdapter bridge #256
Reference in New Issue
Block a user
Delete Branch "feat/252-agent-fn"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Add
AgentFn<Opt = void>as the formal agent boundary type +createAgentAdapterbridge toAdapterFn.Why
No typed agent abstraction existed. Agent behavior was scattered across adapter implementations. Structured agent options (e.g. Cursor workspace) had no type-level expression. See #252.
Changes
workflow-protocol/src/types.ts— newAgentFn<Opt>conditional typeworkflow-runtime/src/{types,index}.ts— re-exportAgentFnworkflow-util-agent/src/create-agent-adapter.ts—createAgentAdapter<Opt>+createSimpleAgentAdapterworkflow-util-agent/src/index.ts— exportsworkflow-cas/tsconfig.json— addcomposite: trueworkflow-agent-cursor/tsconfig.json— addworkflow-casreferenceTesting
bun run build✅bun run test— 104 tests pass ✅Ref
Phase 1 of #252
Add AgentFn<Opt = void> as the formal agent boundary type: - Input: ThreadContext (fixed), Output: string (fixed) - Opt: agent-specific structured options (e.g. { workspace } for Cursor) Add createAgentAdapter<Opt>(agent, extract) → AdapterFn bridge in workflow-util-agent, plus createSimpleAgentAdapter for Opt = void. Also fixes: workflow-cas composite flag + cursor tsconfig reference. Refs #252LGTM ✅
Phase 1 设计合理。AgentFn conditional type + createAgentAdapter 桥接模式干净。
小 note:
undefined as unknown as undefinedcast chain 略绕,不 block整体质量好,approve。