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

@sdlcagent/agent-sdk

v1.0.4

Published

Contract library for Sage platform agents

Readme

@sdlcagent/agent-sdk

Contract library for Sage platform agents. Provides the HTTP server scaffold, the ContextEnvelope / ResultEnvelope contract types (validated with Zod), structured logging, and error types that every Sage agent runtime is expected to implement against.

Install

npm install @sdlcagent/agent-sdk

Quick start

An agent implements a single handler — (ctx: ContextEnvelope) => Promise<ResultEnvelope> — and hands it to AgentServer, which exposes /invoke, /health, /ready, and /start over HTTP.

import { AgentServer, type AgentHandler } from '@sdlcagent/agent-sdk';
import manifest from './agent.manifest.json';

const handler: AgentHandler = async (ctx) => {
  // ctx is a validated ContextEnvelope
  return {
    status: 'SUCCEEDED',
    summary: 'Did the thing',
    output_data: { result: 42 },
  };
};

AgentServer.start({ manifest, handler });

agent.manifest.json must contain at least agent_id and version.

Endpoints

| Method | Path | Purpose | | ------ | --------- | ------------------------------------------------------------------- | | POST | /invoke | Parses the request body as a ContextEnvelope, runs handler, validates and returns a ResultEnvelope. Never throws over HTTP — failures come back as status: "FAILED" with a 200. | | GET | /health | Returns { status, agent_id, version, image_digest }. | | GET | /ready | Returns { status: "ready" }. | | POST | /start | Injects per-tenant runtime env vars ({ env_vars: {...} }) before the first /invoke. |

Configuration (env vars)

  • AGENT_PORT — port to listen on (default 8080)
  • AGENT_TIMEOUT_MS — per-invocation handler timeout (default 300000)
  • LOG_LEVELdebug | info | warn | error (default info)

A .env file in the process working directory is loaded automatically on import.

Envelopes

ContextEnvelope

The validated input to every agent invocation (parseContextEnvelope is called internally by AgentServer, but is exported for standalone use):

import { parseContextEnvelope, type ContextEnvelope } from '@sdlcagent/agent-sdk';

const ctx: ContextEnvelope = parseContextEnvelope(req.body);

Key fields: org_id, project_id, team_id, run_id, step_id, workflow_type, run_mode ('CREATE' | 'MODIFY_ENHANCE'), trigger, work_item_context, policy_snapshot, prompt_refs, redaction_profile, memory_refs?, agent_config, log_callback_url, step_token.

Throws ContextEnvelopeParseError (code CONTEXT_INVALID) on validation failure.

ResultEnvelope

The validated output every handler must resolve to:

import { validateResultEnvelope, type ResultEnvelope } from '@sdlcagent/agent-sdk';

Key fields: status ('SUCCEEDED' | 'FAILED' | 'HITL_REQUIRED'), summary, output_data?, action_requests?, artifacts_created?, critic_signal?, hitl_reason?, hitl_options?, remember?, agent_summary?, next_step_hint?, metrics?.

Throws ResultEnvelopeValidationError (code OUTPUT_BUILD_FAILED) on validation failure.

Errors

AgentError is the base error type for agent handlers, carrying a stable code, a retryable flag (derived automatically per code unless overridden), and an optional detail payload:

import { AgentError } from '@sdlcagent/agent-sdk';

throw new AgentError('MODEL_ERROR', 'LLM returned garbage');

Codes: CONTEXT_INCOMPLETE, CONTEXT_INVALID, MODEL_ERROR, MODEL_REFUSED, ACTION_FORBIDDEN, WORK_ITEM_PARSE_ERROR, OUTPUT_BUILD_FAILED, TIMEOUT, UNEXPECTED, and the Model Rail gateway codes INVALID_REQUEST, BUDGET_EXCEEDED, PURPOSE_NOT_ALLOWED, POLICY_NOT_FOUND. Any error thrown out of a handler is caught by AgentServer and turned into a FAILED ResultEnvelope.

Logging

logger writes structured JSON lines to stdout and threads run context (run_id, org_id, project_id, step_id, agent_id) through AsyncLocalStorage, so any log call inside a handler automatically carries it:

import { logger } from '@sdlcagent/agent-sdk';

logger.info({ event: 'DOING_WORK' });

await logger.time('llm_invoke', async () => {
  // logs STEP_START / STEP_END / STEP_ERROR with duration_ms
});

emitLog(ctx, phase, message, opts?) posts a log line to the run's log_callback_url (best-effort, swallows errors) using one of the fixed AGENT_PHASES: context_parse, llm_invoke, llm_complete, critic_tier1, critic_tier2, tool_call, artifact_write, result_emit.

Development

npm run build         # compile to dist/
npm test              # run the jest suite
npm run test:coverage
npm run typecheck