Registry↗Dashboard↗

Utilities

Helper functions for retry logic, UUID validation, rate limit parsing, and logging.

11 methods

utils.retry()

Retry a function with exponential backoff. Delay doubles on each attempt (1s, 2s, 4s...) up to maxDelayMs.

fnrequired() => Promise<T>

Async function to retry.

maxRetriesoptionalnumber

Maximum retry attempts.

Default: 3
baseDelayMsoptionalnumber

Base delay in milliseconds.

Default: 1000
maxDelayMsoptionalnumber

Maximum delay cap in milliseconds.

Default: 30000
shouldRetryoptional(error: unknown) => boolean

Custom predicate to determine if error is retryable.

Throws the last error if all retries are exhausted.
retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.retry({ fn: 'example-value' });
Response Type
Promise<T>

utils.sleep()

Sleep for a specified number of milliseconds.

msrequirednumber

Duration in milliseconds.

sleep(ms: number): Promise<void>
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.sleep(85.5);
Response Type
Promise<void>

utils.isUuid()

Check if a string is a valid UUID (v1–v5).

valuerequiredstring

String to validate.

isUuid(value: string): boolean
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.isUuid('example-value');
Response Type
boolean

utils.truncate()

Truncate a string to a maximum length, appending '...' if trimmed.

strrequiredstring

String to truncate.

maxLengthrequirednumber

Maximum length before truncation.

truncate(str: string, maxLength: number): string
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.truncate('example-value', 85.5);
Response Type
string

utils.parseRateLimitHeaders()

Parse rate limit headers from a fetch Response. Returns null if headers are missing.

headersrequiredHeaders

Response headers to parse.

parseRateLimitHeaders(headers: Headers): RateLimitInfo | null
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.parseRateLimitHeaders('example-value');
Response Type
RateLimitInfo | null

utils.createLogger()

Create a logger instance. When disabled, debug/info are no-ops; warn/error always emit. Automatically redacts sensitive values.

prefixrequiredstring

Log prefix (e.g., '[ops-sdk:http]').

enabledrequiredboolean

Whether debug/info logging is enabled.

createLogger(prefix: string, enabled: boolean): Logger
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.createLogger('example-value', true);
Response Type
Logger

utils.redactSensitive()

Redact sensitive values for safe logging. Shows only the last N characters.

valuerequiredstring

Value to redact.

showLastoptionalnumber

Number of trailing characters to show.

Default: 4
redactSensitive(value: string, showLast?: number): string
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.redactSensitive('example-value');
Response Type
string

utils.computeHash()

SHA-256 hash of definition YAML — the value integrity pins (`--hash`) verify against.

contentrequiredstring

Definition YAML content.

computeHash(content: string)
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.computeHash('name: example-agent\nversion: 1.0.0');
Response Type
string

utils.computePromptHash()

SHA-256 hash of a rendered prompt — the value `--prompt-hash` pins verify against.

promptrequiredstring

Rendered prompt text.

computePromptHash(prompt: string)
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.computePromptHash('example-value');
Response Type
string

utils.verifyHash()

Verify definition YAML against an expected sha256 pin.

contentrequiredstring

Definition YAML content.

expectedrequiredstring

Expected sha256:<hex> pin.

verifyHash(content, expected)
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.verifyHash('name: example-agent\nversion: 1.0.0', 'example-value');
Response Type
boolean

utils.verifyPromptHash()

Verify a rendered prompt against an expected sha256 pin.

promptrequiredstring

Rendered prompt text.

expectedrequiredstring

Expected sha256:<hex> pin.

verifyPromptHash(prompt, expected)
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await utils.verifyPromptHash('example-value', 'example-value');
Response Type
boolean