zidane-ui/ session/ testing/ contract
import { … } from 'zidane-ui/session/testing/contract'ui/src/session/testing/contract.ts
Functions#
describeSessionHostContractFunction#
Declares the shared SessionHost suite for one implementation.
function describeSessionHostContract(
name: string,
makeHarness: SessionHostHarnessFactory,
capabilities: readonly SessionHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | SessionHostHarnessFactory | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly SessionHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
SessionHostContractBackendInterface#
What the backend behind the host holds, per session id.
interface SessionHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| artifacts | Readonly<Record<string, readonly SessionArtifact[]>> | The stored artifacts per session, newest first. |
| queue | Readonly<Record<string, readonly SessionHostContractEntry[]>> | The queue per session. |
| scheduleFires | Readonly<Record<string, readonly ScheduleFire[]>> | Each reminder's fires, newest first. |
| schedules | readonly Schedule[] | The stored reminders, oldest first (the Reminders setting is on). Serve them as |
| secrets | Readonly<Record<string, readonly SessionSecretEntry[]>> | The saved secrets per session (its project's), without values. |
| sides | Record<string, string> | Each session's side chat, by the parent's id: side chats created land here, removed ones leave. |
| todos | Readonly<Record<string, readonly TodoItem[]>> | Each session's task list as the agent wrote it ( |
| turns | Readonly<Record<string, readonly SessionTurn[]>> | The stored turns per session. |
| work | Readonly<Record<string, readonly RunningWorkItem[]>> | The running work per session. |
SessionHostContractControlInterface#
Changes the backend from outside and announces it as the backend does.
interface SessionHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| recordArtifact | (sessionId: string, artifact: SessionArtifact) => void | The session recorded an artifact (it becomes the newest). |
| setQueue | (sessionId: string, entries: readonly SessionHostContractEntry[]) => void | Another window changed the session's queue. |
| setSchedules? | (list: readonly Schedule[]) => void | The stored reminders changed (the agent set one, one fired): announced as |
| setSecrets | (sessionId: string, entries: readonly SecretEntry[]) => void | The session's project secrets changed (the agent saved one, another window revoked one): announced as a store change. |
| setWork | (sessionId: string, items: readonly RunningWorkItem[]) => void | The session's work changed (a tool call started or ended). |
| writeTodos | (sessionId: string, items: readonly TodoItem[]) => void | The agent wrote its task list again ( |
SessionHostContractEntryInterface#
A queued message the backend holds, with its attachments' bytes.
interface SessionHostContractEntryProperties
| Name | Type | Description |
|---|---|---|
| attachments? | PromptAttachment[] | Its attachments, with their bytes. |
| id | string | The entry's id. |
| text | string | The message text. |
SessionHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface SessionHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| control | SessionHostContractControl | Changes the backend from outside. |
| host | SessionHost | The host under test. |
| dispose? | () => void | Closes connections and timers after each test. |
Types#
SessionHostCapabilityType#
An optional SessionHost member, by its path.
type SessionHostCapability =
| 'plans'
| 'plans.edit'
| 'plans.control'
| 'plans.retry'
| 'queue'
| 'queue.add'
| 'queue.remove'
| 'queue.update'
| 'queue.attachments'
| 'queue.pushNow'
| 'artifacts'
| 'artifacts.remove'
| 'artifacts.refreshRow'
| 'runningWork'
| 'runningWork.cancel'
| 'turns'
| 'turns.fork'
| 'turns.editText'
| 'turns.delete'
| 'turns.rewind'
| 'details'
| 'details.titleStatus'
| 'details.generateTitle'
| 'details.export'
| 'details.compact'
| 'details.setFolder'
| 'details.cacheReport'
| 'usage'
| 'usage.summary'
| 'usage.providers'
| 'usage.github'
| 'usage.redeemReset'
| 'side'
| 'side.subscribe'
| 'secrets'
| 'secrets.save'
| 'secrets.revoke'
| 'schedules'
| 'schedules.create'
| 'schedules.update'
| 'schedules.remove'
| 'schedules.runNow'
| 'schedules.fires'SessionHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type SessionHostHarnessFactory = (backend: SessionHostContractBackend) => SessionHostHarness | Promise<SessionHostHarness>