agentskit.js

mockAdapter

Auto-generated API reference for mockAdapter.

Function: mockAdapter()

mockAdapter(options): AdapterFactory

Defined in: adapters/src/mock.ts:61

A deterministic adapter for tests, demos, and dry-run experiments.

Conforms to ADR 0001 β€” Adapter contract:

  • createSource is pure (A1) β€” no work until stream() runs
  • Always emits a terminal chunk (A3)
  • abort() is safe (A6)
  • Does not mutate input messages (A7)

Examples:

// Static const adapter = mockAdapter({ response: [ { type: 'text', content: 'Hello!' }, { type: 'done' }, ], })

// Request-aware const adapter = mockAdapter({ response: req => { const last = req.messages[req.messages.length - 1]?.content ?? '' return [ { type: 'text', content: 'Echo: ' + last }, { type: 'done' }, ] }, })

// Sequenced β€” different output each call const adapter = mockAdapter({ response: [ [{ type: 'text', content: 'first' }, { type: 'done' }], [{ type: 'text', content: 'second' }, { type: 'done' }], ], })

#Parameters

#options

MockAdapterOptions

#Returns

AdapterFactory

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page