npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tangle-network/agent-runtime

v0.5.4

Published

Reusable runtime lifecycle for domain-specific agents.

Downloads

580

Readme

agent-runtime

Reusable runtime lifecycle for domain-specific agents.

agent-runtime is the shared skeleton for domain agents, generated agents, red-team harnesses, coding agents, and similar packages. It does not own domain policy, tools, connectors, model routing, or UI. It standardizes the task lifecycle and delegates domain behavior to an adapter.

TaskSpec
  -> Knowledge readiness
  -> Question / acquisition decision
  -> Agent control loop
  -> Eval / verification
  -> Run evidence

For product agents that already have a streaming backend, use the stream kernel:

TaskSpec
  -> Knowledge readiness
  -> Session create/resume
  -> Backend stream
  -> Sanitized RuntimeStreamEvent/SSE

Install

pnpm add @tangle-network/agent-runtime @tangle-network/agent-eval

Usage

import { runAgentTask } from '@tangle-network/agent-runtime'

const result = await runAgentTask({
  task: {
    id: 'tax-2026-return-review',
    intent: 'Review the return for missing evidence',
    domain: 'tax',
    requiredKnowledge: [{
      id: 'filing-status',
      description: 'Taxpayer filing status',
      requiredFor: ['return-review'],
      category: 'user_specific',
      acquisitionMode: 'ask_user',
      importance: 'blocking',
      freshness: 'static',
      sensitivity: 'private',
      confidenceNeeded: 1,
      currentConfidence: 0,
      evidenceIds: [],
      fallbackPolicy: 'ask',
    }],
  },
  adapter,
})

If knowledge readiness fails, runAgentTask stops before domain actions by default. Adapters can override onKnowledgeBlocked to emit a domain action, such as asking a user, querying a connector, or inspecting a repo.

runAgentTask also emits typed lifecycle events through onEvent:

await runAgentTask({
  task,
  adapter,
  knowledge,
  onEvent(event) {
    console.log(event.type)
  },
})

Events cover readiness, question answering, acquisition, control-loop steps, and task completion. This keeps streaming UI, logs, and telemetry out of domain adapters while making every runtime transition observable.

This package does not stream model tokens for you. Domain adapters and product routes still own model calls, tool execution, and token streaming. agent-runtime emits lifecycle events around those actions, and provides small helpers for safe telemetry streams:

import { readinessServerSentEvent } from '@tangle-network/agent-runtime'

writer.write(encoder.encode(readinessServerSentEvent(readinessReport)))

Use these helpers when an app wants to expose readiness or runtime metadata over Server-Sent Events without leaking raw task inputs, credentials, or evidence.

For main product loops, prefer runAgentTaskStream with an execution backend:

import {
  InMemoryRuntimeSessionStore,
  createSandboxPromptBackend,
  runAgentTaskStream,
  runtimeStreamServerSentEvent,
} from '@tangle-network/agent-runtime'

const backend = createSandboxPromptBackend({
  getBox: () => sandboxClient.get(sandboxId),
  streamPrompt: (box, message) => box.streamPrompt(message),
  getSessionId: (box) => box.id,
})

const sessions = new InMemoryRuntimeSessionStore()

for await (const event of runAgentTaskStream({
  task,
  backend,
  input: { message },
  sessionId,
  resume: Boolean(sessionId),
  sessionStore: sessions,
})) {
  writer.write(encoder.encode(runtimeStreamServerSentEvent(event)))
}

runAgentTaskStream is the product-facing kernel. It readiness-gates execution, creates or resumes a backend session, normalizes text/tool/artifact/error/final events, and lets callers persist resumable session history. The package ships SDK-agnostic adapter factories for:

  • createOpenAICompatibleBackend for TCloud/OpenAI-compatible chat APIs.
  • createCliBridgeBackend for HTTP CLI bridge streams.
  • createSandboxPromptBackend for sandbox/sidecar streamPrompt clients.
  • createIterableBackend for custom coding harnesses or browser agents.

The adapters are intentionally thin. Product repos still own client construction, auth, concrete tool permissions, and UI behavior.

For logs, reports, and UI telemetry, do not serialize raw events directly. Use the built-in sanitized collector:

import { createRuntimeEventCollector, summarizeAgentTaskRun } from '@tangle-network/agent-runtime'

const telemetry = createRuntimeEventCollector()
const result = await runAgentTask({ task, adapter, onEvent: telemetry.onEvent })

console.log(telemetry.events)
console.log(summarizeAgentTaskRun(result))

Sanitized telemetry redacts task inputs, user answers, credential questions, control payloads, and evidence IDs by default. Private diagnostics can opt into specific fields with includeInputs, includeUserAnswers, includeControlPayloads, includeEvidenceIds, and includeRequirementDescriptions. Task metadata and eval details are also redacted unless includeMetadata or includeEvalDetails is set.

For control policies or route handlers that need a stable readiness branch, use decideKnowledgeReadiness(report). It returns ready, blocked, or caveat plus gap IDs and the recommended action.

Knowledge providers may implement:

  • buildReadiness
  • answerQuestions
  • executeAcquisitionPlans
  • refreshReadiness

That lets a task collect missing context before the control loop starts, then rerun readiness scoring against the new evidence.

Package Boundaries

  • agent-runtime owns the reusable lifecycle and adapter contracts.
  • agent-eval owns control loops, readiness scoring, traces, evals, failure classes, optimization, and release evidence.
  • agent-knowledge owns evidence, claims, wiki pages, retrieval, and knowledge bundle builders.
  • Domain packages own domain tools, policies, credentials, UI text, and rubrics.

The primary API intentionally uses runAgentTask, not runVerticalAgentTask. domain is metadata on the task, because the runtime should be reusable across many kinds of agents without baking taxonomy into type names.