JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 163
  • Score
    100M100P100Q56813F
  • License ISC

Shared utilities — CircuitBreaker, createDeferred, sleep, withTimeout, withAbortSignal, and more for AgForge SDK

Package Exports

  • @agforge/utils
  • @agforge/utils/cjs/index.js
  • @agforge/utils/esm/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@agforge/utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@agforge/utils

Shared general-purpose utilities — the foundation layer of AgForge SDK.

Overview

@agforge/utils provides runtime-agnostic utility functions used across all AgForge packages:

  • CircuitBreaker — fault tolerance with configurable failure threshold and cooldown
  • createDeferredPromise with externally accessible resolve/reject
  • createPrompt / interpolate — multi-line prompt building and variable interpolation
  • sleep — async delay
  • withTimeout — wrap a promise with a timeout
  • withAbortSignal — wrap a promise with AbortSignal support
  • promisify — convert callback-style functions to promises
  • noop — no-operation function

Install

npm install @agforge/utils
# or
pnpm add @agforge/utils

Usage

CircuitBreaker

import { CircuitBreaker } from '@agforge/utils';

const breaker = new CircuitBreaker({
  failureThreshold: 3,
  cooldownPeriod: 60000,
});

const result = await breaker.execute(() => fetchExternalService());

createDeferred

import { createDeferred } from '@agforge/utils';

const deferred = createDeferred<string>();

setTimeout(() => deferred.resolve('done'), 1000);

const result = await deferred.promise;

withTimeout

import { withTimeout } from '@agforge/utils';

const result = await withTimeout(fetchData(), 5000);

withAbortSignal

import { withAbortSignal } from '@agforge/utils';

const controller = new AbortController();

const result = await withAbortSignal(fetchData(), controller.signal);

Prompt Building

import { createPrompt, interpolate } from '@agforge/utils';

const prompt = createPrompt`
  You are a helpful assistant.
  The user's name is ${name}.
`;

const text = interpolate('Hello, {{name}}!', { name: 'Alice' });
Package Role
@agforge/core Agent protocol, interfaces, execution skeleton
@agforge/engine DefaultAgent, interceptors, MCP, tools
@agforge/models LLM provider adapters (Vercel AI SDK v6)
@agforge/logger Hierarchical logging with scoped config

License

ISC