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.
ParametersRetryOptions
fnrequired() => Promise<T>Async function to retry.
maxRetriesoptionalnumberMaximum retry attempts.
Default:3baseDelayMsoptionalnumberBase delay in milliseconds.
Default:1000maxDelayMsoptionalnumberMaximum delay cap in milliseconds.
Default:30000shouldRetryoptional(error: unknown) => booleanCustom predicate to determine if error is retryable.
retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>import { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.retry({ fn: 'example-value' });Promise<T>utils.sleep()
Sleep for a specified number of milliseconds.
Parameters
msrequirednumberDuration in milliseconds.
sleep(ms: number): Promise<void>import { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.sleep(85.5);Promise<void>utils.isUuid()
Check if a string is a valid UUID (v1–v5).
Parameters
valuerequiredstringString to validate.
isUuid(value: string): booleanimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.isUuid('example-value');booleanutils.truncate()
Truncate a string to a maximum length, appending '...' if trimmed.
Parameters
strrequiredstringString to truncate.
maxLengthrequirednumberMaximum length before truncation.
truncate(str: string, maxLength: number): stringimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.truncate('example-value', 85.5);stringutils.parseRateLimitHeaders()
Parse rate limit headers from a fetch Response. Returns null if headers are missing.
Parameters
headersrequiredHeadersResponse headers to parse.
parseRateLimitHeaders(headers: Headers): RateLimitInfo | nullimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.parseRateLimitHeaders('example-value');RateLimitInfo | nullutils.createLogger()
Create a logger instance. When disabled, debug/info are no-ops; warn/error always emit. Automatically redacts sensitive values.
Parameters
prefixrequiredstringLog prefix (e.g., '[ops-sdk:http]').
enabledrequiredbooleanWhether debug/info logging is enabled.
createLogger(prefix: string, enabled: boolean): Loggerimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.createLogger('example-value', true);Loggerutils.redactSensitive()
Redact sensitive values for safe logging. Shows only the last N characters.
Parameters
valuerequiredstringValue to redact.
showLastoptionalnumberNumber of trailing characters to show.
Default:4redactSensitive(value: string, showLast?: number): stringimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.redactSensitive('example-value');stringutils.computeHash()
SHA-256 hash of definition YAML — the value integrity pins (`--hash`) verify against.
Parameters
contentrequiredstringDefinition YAML content.
computeHash(content: string)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');stringutils.computePromptHash()
SHA-256 hash of a rendered prompt — the value `--prompt-hash` pins verify against.
Parameters
promptrequiredstringRendered prompt text.
computePromptHash(prompt: string)import { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.computePromptHash('example-value');stringutils.verifyHash()
Verify definition YAML against an expected sha256 pin.
Parameters
contentrequiredstringDefinition YAML content.
expectedrequiredstringExpected sha256:<hex> pin.
verifyHash(content, expected)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');booleanutils.verifyPromptHash()
Verify a rendered prompt against an expected sha256 pin.
Parameters
promptrequiredstringRendered prompt text.
expectedrequiredstringExpected sha256:<hex> pin.
verifyPromptHash(prompt, expected)import { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await utils.verifyPromptHash('example-value', 'example-value');boolean