Ai harness
Use when designing, implementing, configuring, testing, or extending applications built with @purista/harness and its provider adapters, including agents, workflows, tools, skills, models, state, sandbox, telemetry, and custom adapter packages.From its SKILL.md
npx -y skills add puristajs/harness --skill ai-harnessAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- reads credentialsReads from 1 credential source: `process.env.OPENAI_API_KEY`.
- 5 stars5 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.7 KB, ~1.7k tokens by cl100k_base, as published. Nobody here has run it
AI Harness
Use This For
Use this skill for work involving @purista/harness, @purista/harness-openai, or addon packages named @purista/harness-*.
Core Model
@purista/harness is a standalone, ESM-only agent runtime. It composes typed model aliases, tools, skills, agents, workflows, state, memory, sandboxing, logging, telemetry, and streaming behind one session API.
Keep these layers separate:
- configuration:
defineHarness()registers adapters, defaults, models, tools, skills, agents, and workflows - execution:
harness.getSession(id)returns typedsession.agents.*andsession.workflows.* - adapter code: provider, state, memory, sandbox, MCP, durable runtime, logger, and telemetry ports
- application integration: HTTP/SSE, queues, persistence, auth, and business state stay outside the harness unless represented by a port or tool
- optional governance: policy-as-code for tool decisions, approvals, audit, and policy-pack adapters is configured only when needed; ordinary agents do not require policy setup
Hard Rules
- Use
defineHarness()as the sole construction path. Do not invent standalonedefineAgent,defineWorkflow,defineTool,defineSkill, ordefineModelhelpers. - Preserve builder inference by declaring models before agents and agents before workflows.
- Use inline helper callbacks for agents and workflows:
.agents(({ agent }) => ({ ... }))and.workflows(({ workflow }) => ({ ... })). - Child-agent delegation is disabled by default. Any workflow that calls
ctx.agents.<id>(input)must declareworkflow.delegation; preferdelegation.agentsallowlists and document budget/model overrides there. - Declare model capabilities truthfully. Capability arrays gate both TypeScript handles and runtime behavior.
- Prefer
object/object_streamfor structured generation. Do not use legacyjsoncapability names. - Keep RAG orchestration in application/workflow code. The harness provides embeddings and rerank operations, not vector storage.
- Keep HTTP/SSE protocol mapping outside the harness. Harness streams are typed
RunEventvalues. - Do not import PURISTA framework packages from harness or harness addon packages.
- Do not leak prompts, documents, tool inputs, or secrets through logs or telemetry.
telemetry({ contentCaptureMode: 'NO_CONTENT' })is the production default. - Skills are mounted files, not prompt text. Register directories with
.skills(...), allowlist skill ids per agent, keepreadavailable for skill-backed agents, and verifySKILL.mdbodies are not inlined into prompts, logs, traces, or persisted events. - Prefer
ctx.metricsfor application-owned counters, histograms, and operation durations inside workflow handlers, custom agent handlers, and TypeScript tool handlers. Do not call the low-levelTelemetryShimdirectly for app metrics. - Governance policy is optional and late-bound through
.governance(...)after agents/workflows are declared. Keep simple use cases on per-agent permissions; use governance only for composable/audited policy, approval, or external policy-pack interoperability.
Default Workflow
- Inspect implementation first when behavior matters:
packages/harness/src/harness/defineHarness.ts,models/registry.ts,agents/index.ts,skills/index.ts,ports/*, and provider package source. - Decide whether the task is one agent loop, a custom handler agent, or an orchestrating workflow.
- Define Zod schemas at every agent, workflow, and tool boundary.
- Configure model aliases with model-specific provider options, defaults, and the minimal required capabilities.
- Attach tools, skill directories, permissions, sandbox, memory, state, runtime requirements, logger, and telemetry explicitly.
- Decide how state, history, memory, streaming, errors, security, and operations are handled at the application edge.
- Invoke through
harness.getSession(id)and close sessions/harnesses during shutdown. - Test with
@purista/harness/testingfakes/contracts before live-provider smoke tests.
Quick Pattern
import { z } from 'zod'
import { defineHarness, JsonLogger, inMemorySandbox } from '@purista/harness'
import { openai } from '@purista/harness-openai'
const harness = defineHarness({ name: 'support-ai' })
.logger(new JsonLogger({ level: 'info' }))
.telemetry({ contentCaptureMode: 'NO_CONTENT' })
.sandbox(inMemorySandbox())
.models({
assistant: {
provider: openai({ apiKey: process.env.OPENAI_API_KEY! }),
model: process.env.OPENAI_MODEL ?? 'gpt-5-mini',
capabilities: ['object', 'tool_use']
}
})
.tools({
lookup_ticket: {
description: 'Look up one support ticket by id.',
input: z.object({ id: z.string() }),
output: z.object({ status: z.string(), summary: z.string() }),
handler: async (_ctx, input) => ({ status: 'open', summary: `Ticket ${input.id}` })
}
})
.agents(({ agent }) => ({
triage: agent({
model: 'assistant',
input: z.object({ ticketId: z.string() }),
output: z.object({ priority: z.enum(['low', 'normal', 'high']), reason: z.string() }),
builtinTools: false,
tools: ['lookup_ticket'],
instructions: 'Use lookup_ticket, then return a validated triage object.'
})
}))
.workflows(({ workflow }) => ({
triage_ticket: workflow({
input: z.object({ ticketId: z.string() }),
output: z.object({ priority: z.string(), reason: z.string() }),
delegation: { agents: ['triage'] },
handler: (ctx) => {
ctx.metrics.counter('support.triage.started', 1)
return ctx.metrics.duration('support.triage.duration', undefined, () => ctx.agents.triage(ctx.input))
}
})
}))
.build()
const session = await harness.getSession('tenant-a:user-42')
const result = await session.workflows.triage_ticket.prompt({ ticketId: 'T-123' })
await session.close()
await harness.shutdown()
Read If Needed
references/configuration.mdfor package setup, builder order, sessions, state, sandbox, runtime capabilities, streaming, and shutdown.references/model-setup.mdfor provider aliases, OpenAI setup, defaults, capability-gated model handles, multimodal content, embeddings, and rerank.references/agents-workflows-tools.mdfor deciding between agents/workflows and wiring typed tools, permissions, MCP, and skill-mounted agents.references/agents-workflows-tools.mdalso covers optional governance policy and when to prefer it over simple permissions.references/skills.mdfor creating harness skill folders and registering/mounting them correctly.references/sandbox.mdfor in-memory/bash sandboxes, filesystem/exec APIs, snapshots, built-in tool risk, and custom sandbox adapters.references/state-sessions-streaming-errors.mdforStateStore, session lifecycle, memory/history, run events, error mapping, and replay.references/durable-feedback-operations.mdfor durable runtime checkpoints, adapter capabilities, feedback records, readiness, and operational runbooks.references/telemetry-observability.mdfor OpenTelemetry setup,TelemetryShim, span/metric names, logs, privacy, and adapter context propagation.references/adapters.mdfor creating and using provider, state store, memory, sandbox, durable runtime, logger, telemetry, tool/MCP, and addon adapter packages.references/testing.mdfor fake providers, type checks, contract tests, and live-provider boundaries.references/package-surface.mdfor exports, package boundaries, source files, public docs, and known source-vs-doc checks.
What ships with it: 12 files
86.3 KB alongside SKILL.md
agents/
- openai.yaml249 B
references/
- adapters.md14.2 KB
- agents-workflows-tools.md13.6 KB
- configuration.md6.5 KB
- durable-feedback-operations.md9.0 KB
- model-setup.md9.5 KB
- package-surface.md5.1 KB
- sandbox.md6.3 KB
- skills.md3.9 KB
- state-sessions-streaming-errors.md7.6 KB
- telemetry-observability.md5.2 KB
- testing.md5.1 KB