UNPKG

@tangle-network/tcloud

Version:

TypeScript SDK and CLI for Tangle Router, Sandbox, model routing, and agent service calls

78 lines • 2.92 kB
import { Ot as TCloudConfig, o as TCloudClient } from "./client-EyknRDtd.cjs"; //#region src/instance.d.ts export interface InstanceOptions { /** Path to harness config TOML. Defaults to ./harness.toml or ~/.tangle/harness.toml */ config?: string; /** Only start these blueprints (subset) */ only?: string[]; /** Working directory for `cargo tangle harness` (default: current) */ cwd?: string; /** Stream anvil logs (default false) */ includeAnvilLogs?: boolean; /** Suppress stdout passthrough (default false) */ quiet?: boolean; /** Startup timeout in ms — how long to wait for "Harness up" marker (default 300_000) */ timeoutMs?: number; /** Router URL the instance exposes. Defaults to http://localhost:3000 */ routerUrl?: string; /** Override the `cargo tangle` binary path. Defaults to resolving `cargo-tangle` from PATH */ cargoBinary?: string; } export interface InstanceConfig { /** URL of the router the instance is serving on */ routerUrl: string; /** Names of blueprints that were started */ blueprints: string[]; } /** * Append a line to a bounded log buffer, evicting the oldest entry once the * buffer exceeds `maxLines`. Exported for unit testing. */ export declare function appendLogLine(buffer: string[], line: string, maxLines?: number): void; /** * A running Tangle dev environment. Hold one per test file or dev session. */ export declare class Instance { private child; private _config; private _stopped; private logBuffer; private readonly maxLogLines; private constructor(); /** * Start a new harness instance. Resolves once `cargo tangle harness up` * prints its "Harness up" marker, indicating all blueprints are healthy. * * Throws on timeout, process exit before ready, or missing `cargo-tangle`. */ static start(options?: InstanceOptions): Promise<Instance>; /** URL of the router serving this instance */ get routerUrl(): string; /** Names of blueprints that were started */ get blueprints(): string[]; /** * Create a pre-configured {@link TCloudClient} pointed at this instance's router. * Merges any passed config with the instance's routerUrl (instance wins). */ client(config?: Partial<TCloudConfig>): TCloudClient; /** Return the last N log lines from the harness */ logs(lines?: number): string[]; /** Whether the harness process is still running */ get isRunning(): boolean; /** * Stop the harness. Sends SIGTERM, waits up to 10s for clean shutdown, * then SIGKILL. */ stop(timeoutMs?: number): Promise<void>; } /** * Write a temporary harness.toml with the given blueprints, for inline test configs. * Returns the path to the created file. The caller is responsible for cleanup. */ export declare function writeTempHarnessConfig(blueprints: Array<{ name: string; path: string; port?: number; env?: Record<string, string>; }>): string; //#endregion