feat(protocol): AgentFn<Opt> type + createAgentAdapter bridge #256

Merged
xiaomo merged 1 commits from feat/252-agent-fn into main 2026-05-14 08:53:30 +00:00
Owner

What

Add AgentFn<Opt = void> as the formal agent boundary type + createAgentAdapter bridge to AdapterFn.

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 — new AgentFn<Opt> conditional type
  • workflow-runtime/src/{types,index}.ts — re-export AgentFn
  • workflow-util-agent/src/create-agent-adapter.tscreateAgentAdapter<Opt> + createSimpleAgentAdapter
  • workflow-util-agent/src/index.ts — exports
  • workflow-cas/tsconfig.json — add composite: true
  • workflow-agent-cursor/tsconfig.json — add workflow-cas reference

Testing

  • bun run build
  • bun run test — 104 tests pass
  • biome clean on changed files

Ref

Phase 1 of #252

## What Add `AgentFn<Opt = void>` as the formal agent boundary type + `createAgentAdapter` bridge to `AdapterFn`. ## 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` — new `AgentFn<Opt>` conditional type - `workflow-runtime/src/{types,index}.ts` — re-export `AgentFn` - `workflow-util-agent/src/create-agent-adapter.ts` — `createAgentAdapter<Opt>` + `createSimpleAgentAdapter` - `workflow-util-agent/src/index.ts` — exports - `workflow-cas/tsconfig.json` — add `composite: true` - `workflow-agent-cursor/tsconfig.json` — add `workflow-cas` reference ## Testing - `bun run build` ✅ - `bun run test` — 104 tests pass ✅ - biome clean on changed files ✅ ## Ref Phase 1 of #252
xiaoju added 1 commit 2026-05-14 08:41:43 +00:00
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 #252
xiaomo approved these changes 2026-05-14 08:53:25 +00:00
xiaomo left a comment
Owner

LGTM

Phase 1 设计合理。AgentFn conditional type + createAgentAdapter 桥接模式干净。

小 note:

  • createSimpleAgentAdapter 的 undefined as unknown as undefined cast chain 略绕,不 block
  • agent 一参→二参强转是 conditional type 的固有代价,JS 运行时安全

整体质量好,approve。

LGTM ✅ Phase 1 设计合理。AgentFn<Opt> conditional type + createAgentAdapter 桥接模式干净。 小 note: - createSimpleAgentAdapter 的 `undefined as unknown as undefined` cast chain 略绕,不 block - agent 一参→二参强转是 conditional type 的固有代价,JS 运行时安全 整体质量好,approve。
xiaomo merged commit 07f52594d1 into main 2026-05-14 08:53:30 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#256