feat(workflow-utils): add createLlmAdapter AgentFn factory #278

Merged
xingyue merged 2 commits from refactor/277-llm-adapter-four-tuple into main 2026-04-30 12:51:30 +00:00
Owner

What

Add createLlmAdapter(provider): AgentFn — a single-turn LLM chat adapter that conforms to the AgentFn interface, enabling pure-LLM roles to use the standard createRole(adapter, prompt, schema, extract) four-tuple pattern.

Why

questioner and answerer roles in knowledge-extraction were hand-assembled instead of using createRole. This adapter fills the gap — roles that don't need an agent (cursor/hermes) can use a simple LLM adapter instead.

Changes

  • create-llm-adapter.ts — new file: createLlmAdapter(provider) returns AgentFn using chatCompletionText
  • index.ts — export createLlmAdapter
  • create-llm-adapter.test.ts — unit tests

Workspace-side changes (questioner/answerer refactor to use createRole) committed separately to nerve-workspace.

Ref

Fixes #277

## What Add `createLlmAdapter(provider): AgentFn` — a single-turn LLM chat adapter that conforms to the `AgentFn` interface, enabling pure-LLM roles to use the standard `createRole(adapter, prompt, schema, extract)` four-tuple pattern. ## Why `questioner` and `answerer` roles in knowledge-extraction were hand-assembled instead of using `createRole`. This adapter fills the gap — roles that don't need an agent (cursor/hermes) can use a simple LLM adapter instead. ## Changes - **`create-llm-adapter.ts`** — new file: `createLlmAdapter(provider)` returns `AgentFn` using `chatCompletionText` - **`index.ts`** — export `createLlmAdapter` - **`create-llm-adapter.test.ts`** — unit tests Workspace-side changes (questioner/answerer refactor to use `createRole`) committed separately to `nerve-workspace`. ## Ref Fixes #277
xiaoju added 1 commit 2026-04-30 12:42:05 +00:00
Single-turn chat via chatCompletionText: system from createRole prompt, user from ctx.start.content.

Fixes #277

Made-with: Cursor
xiaoju added 1 commit 2026-04-30 12:47:14 +00:00
Remove createCursorRole, createHermesRole, createLlmRole, createReActRole
from public API — all superseded by createRole(adapter, prompt, schema, extract).
Source files retained as internal implementation.

Also remove unused type exports: CliPromptFn, CursorRole*, HermesRole*,
LlmPromptFn, LlmRole*, ReActRole*, ReActTool. Keep LlmMessage and
MetaExtractConfig (used internally).

Refs #277
xingyue merged commit d2bb0275dc into main 2026-04-30 12:51:30 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#278