@theaileverage/marionette 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ // Generated from Herdr 0.9.0 (Apache-2.0); see vendor/herdr-0.9.0/LICENSE.
2
+ // Do not edit. Run npm run sdk:generate.
3
+ export const HERDR_PROTOCOL = 22;
4
+ export const HERDR_SCHEMA_SHA256 = '5fb46b13fdaf39c88cf699b9806685868c7ee6b0142523d84391b1606416dc0a';
5
+ export const HERDR_METHODS = [
6
+ 'ping',
7
+ 'server.stop',
8
+ 'server.live_handoff',
9
+ 'server.reload_config',
10
+ 'server.agent_manifests',
11
+ 'server.reload_agent_manifests',
12
+ 'notification.show',
13
+ 'product_announcement.dismiss',
14
+ 'release_notes.dismiss',
15
+ 'command.invoke',
16
+ 'client.window_title.set',
17
+ 'client.window_title.clear',
18
+ 'client_shell.surface.set',
19
+ 'session.snapshot',
20
+ 'workspace.create',
21
+ 'workspace.list',
22
+ 'workspace.get',
23
+ 'workspace.focus',
24
+ 'workspace.rename',
25
+ 'workspace.move',
26
+ 'workspace.move_block',
27
+ 'workspace.report_metadata',
28
+ 'workspace.close',
29
+ 'worktree.list',
30
+ 'worktree.create',
31
+ 'worktree.open',
32
+ 'worktree.remove',
33
+ 'tab.create',
34
+ 'tab.list',
35
+ 'tab.get',
36
+ 'tab.focus',
37
+ 'tab.rename',
38
+ 'tab.move',
39
+ 'tab.close',
40
+ 'agent.list',
41
+ 'agent.get',
42
+ 'agent.read',
43
+ 'agent.explain',
44
+ 'agent.send_keys',
45
+ 'agent.rename',
46
+ 'agent.view.set',
47
+ 'agent.view.clear',
48
+ 'agent.focus',
49
+ 'agent.start',
50
+ 'agent.prompt',
51
+ 'agent.wait',
52
+ 'pane.split',
53
+ 'pane.swap',
54
+ 'pane.move',
55
+ 'pane.zoom',
56
+ 'pane.layout',
57
+ 'pane.process_info',
58
+ 'layout.export',
59
+ 'layout.apply',
60
+ 'layout.set_split_ratio',
61
+ 'pane.neighbor',
62
+ 'pane.edges',
63
+ 'pane.focus_direction',
64
+ 'pane.resize',
65
+ 'pane.scroll',
66
+ 'pane.edit_scrollback',
67
+ 'pane.selection.read',
68
+ 'pane.copy_motion',
69
+ 'pane.copy_search',
70
+ 'pane.list',
71
+ 'pane.current',
72
+ 'pane.get',
73
+ 'pane.focus',
74
+ 'pane.input.set',
75
+ 'pane.link.activate',
76
+ 'pane.rename',
77
+ 'pane.send_text',
78
+ 'pane.send_keys',
79
+ 'pane.send_input',
80
+ 'pane.read',
81
+ 'pane.graphics.set',
82
+ 'pane.graphics.clear',
83
+ 'pane.graphics.info',
84
+ 'pane.report_agent',
85
+ 'pane.report_agent_session',
86
+ 'pane.report_metadata',
87
+ 'pane.clear_agent_authority',
88
+ 'pane.release_agent',
89
+ 'pane.close',
90
+ 'popup.close',
91
+ 'events.subscribe',
92
+ 'events.wait',
93
+ 'pane.wait_for_output',
94
+ 'integration.list',
95
+ 'integration.install',
96
+ 'integration.uninstall',
97
+ 'plugin.link',
98
+ 'plugin.list',
99
+ 'plugin.unlink',
100
+ 'plugin.enable',
101
+ 'plugin.disable',
102
+ 'plugin.action.list',
103
+ 'plugin.action.invoke',
104
+ 'plugin.log.list',
105
+ 'plugin.pane.open',
106
+ 'plugin.pane.focus',
107
+ 'plugin.pane.close',
108
+ ];
@@ -0,0 +1,105 @@
1
+ import { type HerdrMethod, type HerdrParams, type HerdrResult, type ResponseTypes, type RequestTypes } from './herdr-protocol.js';
2
+ import { HerdrEventStream, HerdrGraphicsStream, type GraphicsStreamParams } from './herdr-streams.js';
3
+ import { type RequestOptions, type StreamOptions } from './herdr-transport.js';
4
+ export * from './herdr-protocol.js';
5
+ export { HerdrError } from './herdr-transport.js';
6
+ export type { RequestOptions, StreamOptions } from './herdr-transport.js';
7
+ export { HerdrEventStream, HerdrGraphicsStream } from './herdr-streams.js';
8
+ export type { GraphicsStreamParams, GraphicsFrame, GraphicsFileFrame, GraphicsFrameAck, } from './herdr-streams.js';
9
+ export type Pane = ResponseTypes.PaneInfo;
10
+ export type Agent = ResponseTypes.AgentInfo;
11
+ export type PaneLayout = ResponseTypes.PaneLayoutSnapshot;
12
+ export type RequestMethod = Exclude<HerdrMethod, 'events.subscribe'>;
13
+ export type RequestArgs<M extends RequestMethod> = {} extends HerdrParams[M] ? [params?: HerdrParams[M], options?: RequestOptions] : [params: HerdrParams[M], options?: RequestOptions];
14
+ export type HerdrApi = {
15
+ readonly [M in RequestMethod]: (...args: RequestArgs<M>) => Promise<HerdrResult>;
16
+ } & {
17
+ readonly 'events.subscribe': (params: HerdrParams['events.subscribe'], options?: StreamOptions) => Promise<HerdrEventStream>;
18
+ readonly 'pane.graphics.stream': (params: GraphicsStreamParams, options?: StreamOptions) => Promise<HerdrGraphicsStream>;
19
+ };
20
+ export interface LaunchOptions {
21
+ cwd: string;
22
+ env?: Record<string, string>;
23
+ focus?: boolean;
24
+ }
25
+ export interface WaitOptions {
26
+ timeout_ms: number;
27
+ until?: ('idle' | 'working' | 'blocked' | 'done' | 'unknown')[];
28
+ }
29
+ /** Explicit connection selection, typed wire APIs, and small convenience helpers. */
30
+ export declare class HerdrClient {
31
+ readonly socketPath: string;
32
+ constructor(socketPath: string);
33
+ static fromEnv(env?: NodeJS.ProcessEnv): HerdrClient;
34
+ /** Escape hatch for future one-shot methods. Streams require their dedicated transports. */
35
+ call<T = unknown>(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
36
+ /** All schema-defined one-shot methods with exact typed parameter objects. */
37
+ request<M extends RequestMethod>(method: M, ...args: RequestArgs<M>): Promise<HerdrResult>;
38
+ subscribe(subscriptions: RequestTypes.Subscription[], options?: StreamOptions): Promise<HerdrEventStream>;
39
+ graphicsStream(params: GraphicsStreamParams, options?: StreamOptions): Promise<HerdrGraphicsStream>;
40
+ /** One-to-one method names, including streams, for discovery and generated agent code. */
41
+ readonly api: HerdrApi;
42
+ readonly workspace: {
43
+ list: () => Promise<{
44
+ workspaces: {
45
+ workspace_id: string;
46
+ label?: string;
47
+ }[];
48
+ }>;
49
+ create: (options: LaunchOptions & {
50
+ label: string;
51
+ }) => Promise<{
52
+ root_pane: Pane;
53
+ workspace: {
54
+ workspace_id: string;
55
+ };
56
+ }>;
57
+ };
58
+ readonly tab: {
59
+ create: (workspaceId: string, options: LaunchOptions & {
60
+ label?: string;
61
+ }) => Promise<{
62
+ root_pane: Pane;
63
+ }>;
64
+ list: (workspaceId: string) => Promise<{
65
+ tabs: {
66
+ tab_id: string;
67
+ workspace_id: string;
68
+ label?: string;
69
+ pane_count: number;
70
+ }[];
71
+ }>;
72
+ close: (tabId: string) => Promise<unknown>;
73
+ };
74
+ readonly pane: {
75
+ list: (workspaceId: string) => Promise<{
76
+ panes: Pane[];
77
+ }>;
78
+ layout: (paneId: string) => Promise<{
79
+ layout: PaneLayout;
80
+ }>;
81
+ split: (paneId: string, options: LaunchOptions & {
82
+ direction: "right" | "down";
83
+ ratio?: number;
84
+ }) => Promise<{
85
+ pane: Pane;
86
+ }>;
87
+ read: (paneId: string, lines?: number) => Promise<{
88
+ read: {
89
+ text: string;
90
+ };
91
+ }>;
92
+ sendText: (paneId: string, text: string) => Promise<unknown>;
93
+ sendKeys: (paneId: string, keys: string[]) => Promise<unknown>;
94
+ close: (paneId: string) => Promise<unknown>;
95
+ };
96
+ readonly agent: {
97
+ start: (paneId: string, name: string, kind: string, args?: string[], timeoutMs?: number) => Promise<unknown>;
98
+ get: (target: string) => Promise<{
99
+ agent: Agent;
100
+ }>;
101
+ prompt: (target: string, text: string, wait?: WaitOptions) => Promise<unknown>;
102
+ wait: (target: string, options: WaitOptions) => Promise<unknown>;
103
+ sendKeys: (target: string, keys: string[]) => Promise<unknown>;
104
+ };
105
+ }
@@ -0,0 +1,105 @@
1
+ import { HERDR_METHODS, } from './herdr-protocol.js';
2
+ import { HerdrEventStream, HerdrGraphicsStream, } from './herdr-streams.js';
3
+ import { socketRequest, validateSocketPath, } from './herdr-transport.js';
4
+ export * from './herdr-protocol.js';
5
+ export { HerdrError } from './herdr-transport.js';
6
+ export { HerdrEventStream, HerdrGraphicsStream } from './herdr-streams.js';
7
+ /** Respect server waits; the transport must not time out an otherwise valid long wait. */
8
+ function deadline(method, params) {
9
+ if (method === 'agent.start')
10
+ return (params.timeout_ms ?? 30000) + 5000;
11
+ const wait = method === 'agent.prompt'
12
+ ? params.wait
13
+ : ['agent.wait', 'events.wait', 'pane.wait_for_output'].includes(method)
14
+ ? params
15
+ : undefined;
16
+ if (wait)
17
+ return wait.timeout_ms == null ? null : wait.timeout_ms + 5000;
18
+ return 10000;
19
+ }
20
+ /** Explicit connection selection, typed wire APIs, and small convenience helpers. */
21
+ export class HerdrClient {
22
+ socketPath;
23
+ constructor(socketPath) {
24
+ this.socketPath = socketPath;
25
+ validateSocketPath(socketPath);
26
+ }
27
+ static fromEnv(env = process.env) {
28
+ if (env.HERDR_ENV !== '1' || !env.HERDR_SOCKET_PATH)
29
+ throw new Error('Run inside Herdr or supply an explicitly selected socket path');
30
+ return new HerdrClient(env.HERDR_SOCKET_PATH);
31
+ }
32
+ /** Escape hatch for future one-shot methods. Streams require their dedicated transports. */
33
+ call(method, params = {}, timeoutMs = 10000) {
34
+ if (method === 'events.subscribe' || method === 'pane.graphics.stream')
35
+ return Promise.reject(new TypeError('Use subscribe(), graphicsStream(), or api for a streaming method'));
36
+ return socketRequest(this.socketPath, method, params, { timeoutMs });
37
+ }
38
+ /** All schema-defined one-shot methods with exact typed parameter objects. */
39
+ request(method, ...args) {
40
+ const [params = {}, options = {}] = args;
41
+ if (!HERDR_METHODS.includes(method) ||
42
+ method === 'events.subscribe')
43
+ return Promise.reject(new TypeError('Unknown one-shot method; use call() for extensions or subscribe() for events'));
44
+ return socketRequest(this.socketPath, method, params, {
45
+ ...options,
46
+ timeoutMs: options.timeoutMs === undefined ? deadline(method, params) : options.timeoutMs,
47
+ });
48
+ }
49
+ subscribe(subscriptions, options) {
50
+ return HerdrEventStream.open(this.socketPath, subscriptions, options);
51
+ }
52
+ graphicsStream(params, options) {
53
+ return HerdrGraphicsStream.open(this.socketPath, params, options);
54
+ }
55
+ /** One-to-one method names, including streams, for discovery and generated agent code. */
56
+ api = Object.freeze(Object.fromEntries([
57
+ ...HERDR_METHODS.map((method) => [
58
+ method,
59
+ method === 'events.subscribe'
60
+ ? (params, options) => this.subscribe(params.subscriptions, options)
61
+ : (params = {}, options) => this.request(method, params, options),
62
+ ]),
63
+ [
64
+ 'pane.graphics.stream',
65
+ (params, options) => this.graphicsStream(params, options),
66
+ ],
67
+ ]));
68
+ workspace = {
69
+ list: () => this.call('workspace.list'),
70
+ create: (options) => this.call('workspace.create', {
71
+ focus: false,
72
+ ...options,
73
+ }),
74
+ };
75
+ tab = {
76
+ create: (workspaceId, options) => this.call('tab.create', {
77
+ focus: false,
78
+ ...options,
79
+ workspace_id: workspaceId,
80
+ }),
81
+ list: (workspaceId) => this.call('tab.list', { workspace_id: workspaceId }),
82
+ close: (tabId) => this.call('tab.close', { tab_id: tabId }),
83
+ };
84
+ pane = {
85
+ list: (workspaceId) => this.call('pane.list', { workspace_id: workspaceId }),
86
+ layout: (paneId) => this.call('pane.layout', { pane_id: paneId }),
87
+ split: (paneId, options) => this.call('pane.split', { focus: false, ...options, target_pane_id: paneId }),
88
+ read: (paneId, lines = 120) => this.call('pane.read', {
89
+ pane_id: paneId,
90
+ source: 'recent_unwrapped',
91
+ format: 'text',
92
+ lines,
93
+ }),
94
+ sendText: (paneId, text) => this.call('pane.send_text', { pane_id: paneId, text }),
95
+ sendKeys: (paneId, keys) => this.call('pane.send_keys', { pane_id: paneId, keys }),
96
+ close: (paneId) => this.call('pane.close', { pane_id: paneId }),
97
+ };
98
+ agent = {
99
+ start: (paneId, name, kind, args = [], timeoutMs = 30000) => this.call('agent.start', { pane_id: paneId, name, kind, args, timeout_ms: timeoutMs }, timeoutMs + 5000),
100
+ get: (target) => this.call('agent.get', { target }),
101
+ prompt: (target, text, wait) => this.call('agent.prompt', { target, text, ...(wait ? { wait } : {}) }, wait ? wait.timeout_ms + 5000 : 10000),
102
+ wait: (target, options) => this.call('agent.wait', { target, ...options }, options.timeout_ms + 5000),
103
+ sendKeys: (target, keys) => this.call('agent.send_keys', { target, keys }),
104
+ };
105
+ }
@@ -0,0 +1,49 @@
1
+ import { type StreamOptions } from './herdr-transport.js';
2
+ import type { HerdrEvent, HerdrResult, RequestTypes } from './herdr-protocol.js';
3
+ export declare class HerdrEventStream implements AsyncIterableIterator<HerdrEvent> {
4
+ private connection;
5
+ private constructor();
6
+ static open(socketPath: string, subscriptions: RequestTypes.Subscription[], options?: StreamOptions): Promise<HerdrEventStream>;
7
+ get closed(): Promise<void>;
8
+ [Symbol.asyncIterator](): this;
9
+ next(): Promise<IteratorResult<HerdrEvent>>;
10
+ close(): void;
11
+ return(): Promise<IteratorResult<HerdrEvent>>;
12
+ }
13
+ /** This wire method is documented but omitted from Herdr 0.9.0's exported JSON schema. */
14
+ export interface GraphicsStreamParams {
15
+ pane_id: string;
16
+ layer_id?: string | null;
17
+ z_index?: number;
18
+ }
19
+ export interface GraphicsFrame {
20
+ format: RequestTypes.PaneGraphicsFormat;
21
+ image_width: number;
22
+ image_height: number;
23
+ placement?: RequestTypes.PaneGraphicsPlacementParams;
24
+ }
25
+ export interface GraphicsFileFrame extends Omit<GraphicsFrame, 'format'> {
26
+ format: 'rgba' | 'bgra';
27
+ file: {
28
+ path: string;
29
+ };
30
+ sequence: number;
31
+ revision: number;
32
+ }
33
+ export type GraphicsFrameAck = Extract<HerdrResult, {
34
+ type: 'pane_graphics_frame_ack';
35
+ }>;
36
+ export declare class HerdrGraphicsStream {
37
+ private connection;
38
+ private busy;
39
+ private constructor();
40
+ static open(socketPath: string, params: GraphicsStreamParams, options?: StreamOptions): Promise<HerdrGraphicsStream>;
41
+ /** Resolves after local close; rejects on remote failure, cancellation, or disconnect. */
42
+ get closed(): Promise<void>;
43
+ private exclusive;
44
+ /** Resolves after local socket write, not a render ACK: inline success has no wire reply. */
45
+ frame(frame: GraphicsFrame, data: Uint8Array, timeoutMs?: number): Promise<void>;
46
+ /** Keep the immutable source file until this method acknowledges its sequence and revision. */
47
+ fileFrame(frame: GraphicsFileFrame, timeoutMs?: number): Promise<GraphicsFrameAck>;
48
+ close(): void;
49
+ }
@@ -0,0 +1,156 @@
1
+ import { isAbsolute } from 'node:path';
2
+ import { HerdrError, JsonConnection, validateTimeout, } from './herdr-transport.js';
3
+ export class HerdrEventStream {
4
+ connection;
5
+ constructor(connection) {
6
+ this.connection = connection;
7
+ }
8
+ static async open(socketPath, subscriptions, options = {}) {
9
+ const timeout = options.timeoutMs === undefined ? 10000 : options.timeoutMs;
10
+ validateTimeout(timeout);
11
+ JSON.stringify(subscriptions);
12
+ const connection = new JsonConnection(socketPath, options);
13
+ try {
14
+ const result = await connection.start('events.subscribe', { subscriptions }, timeout);
15
+ if (result?.type !== 'subscription_started')
16
+ throw new HerdrError('herdr_invalid_response', 'Missing subscription acknowledgement');
17
+ return new HerdrEventStream(connection);
18
+ }
19
+ catch (error) {
20
+ connection.close();
21
+ throw error;
22
+ }
23
+ }
24
+ get closed() {
25
+ return this.connection.closed;
26
+ }
27
+ [Symbol.asyncIterator]() {
28
+ return this;
29
+ }
30
+ async next() {
31
+ const value = await this.connection.read();
32
+ if (value === undefined)
33
+ return { done: true, value: undefined };
34
+ if (!value || typeof value.event !== 'string' || !Object.hasOwn(value, 'data')) {
35
+ const error = new HerdrError('herdr_invalid_response', 'Expected a Herdr event envelope');
36
+ this.connection.fail(error, true);
37
+ throw error;
38
+ }
39
+ return { done: false, value: value };
40
+ }
41
+ close() {
42
+ this.connection.close();
43
+ }
44
+ async return() {
45
+ this.close();
46
+ return { done: true, value: undefined };
47
+ }
48
+ }
49
+ const maxInlineBytes = 16 * 1024 * 1024;
50
+ function integer(value, name, min = 0, max = Number.MAX_SAFE_INTEGER) {
51
+ if (!Number.isSafeInteger(value) || value < min || value > max)
52
+ throw new TypeError(`Invalid ${name}`);
53
+ }
54
+ function frameHeader(frame) {
55
+ integer(frame.image_width, 'image_width', 1, 0xffffffff);
56
+ integer(frame.image_height, 'image_height', 1, 0xffffffff);
57
+ if (!['png', 'rgb', 'rgba', 'bgra'].includes(frame.format))
58
+ throw new TypeError('Invalid frame format');
59
+ return {
60
+ format: frame.format,
61
+ image_width: frame.image_width,
62
+ image_height: frame.image_height,
63
+ ...(frame.placement ? { placement: frame.placement } : {}),
64
+ };
65
+ }
66
+ function encodeHeader(header) {
67
+ const line = JSON.stringify(header) + '\n';
68
+ if (Buffer.byteLength(line) > 64 * 1024)
69
+ throw new TypeError('Graphics header exceeds 64 KiB');
70
+ return line;
71
+ }
72
+ export class HerdrGraphicsStream {
73
+ connection;
74
+ busy = false;
75
+ constructor(connection) {
76
+ this.connection = connection;
77
+ }
78
+ static async open(socketPath, params, options = {}) {
79
+ const timeout = options.timeoutMs === undefined ? 10000 : options.timeoutMs;
80
+ validateTimeout(timeout);
81
+ JSON.stringify(params);
82
+ const connection = new JsonConnection(socketPath, options);
83
+ try {
84
+ const result = await connection.start('pane.graphics.stream', params, timeout);
85
+ if (result?.type !== 'ok')
86
+ throw new HerdrError('herdr_invalid_response', 'Missing graphics stream acknowledgement');
87
+ return new HerdrGraphicsStream(connection);
88
+ }
89
+ catch (error) {
90
+ connection.close();
91
+ throw error;
92
+ }
93
+ }
94
+ /** Resolves after local close; rejects on remote failure, cancellation, or disconnect. */
95
+ get closed() {
96
+ return this.connection.closed;
97
+ }
98
+ async exclusive(action) {
99
+ if (this.busy)
100
+ throw new HerdrError('herdr_stream_busy', 'Await the previous frame before sending another');
101
+ this.busy = true;
102
+ try {
103
+ return await action();
104
+ }
105
+ finally {
106
+ this.busy = false;
107
+ }
108
+ }
109
+ /** Resolves after local socket write, not a render ACK: inline success has no wire reply. */
110
+ async frame(frame, data, timeoutMs = 30000) {
111
+ validateTimeout(timeoutMs);
112
+ if (!data.byteLength || data.byteLength > maxInlineBytes)
113
+ throw new TypeError('Inline graphics data must be 1 byte to 16 MiB');
114
+ const header = encodeHeader({ ...frameHeader(frame), data_length: data.byteLength });
115
+ return this.exclusive(async () => {
116
+ // Snapshot bytes before awaiting writes so caller mutation cannot corrupt framing.
117
+ const bytes = Buffer.from(data);
118
+ await this.connection.within(timeoutMs, async () => {
119
+ await this.connection.write(header);
120
+ await this.connection.write(bytes);
121
+ });
122
+ });
123
+ }
124
+ /** Keep the immutable source file until this method acknowledges its sequence and revision. */
125
+ async fileFrame(frame, timeoutMs = 30000) {
126
+ validateTimeout(timeoutMs);
127
+ if (!['rgba', 'bgra'].includes(frame.format) || !isAbsolute(frame.file.path))
128
+ throw new TypeError('File frames require rgba/bgra and an absolute source path');
129
+ integer(frame.sequence, 'sequence');
130
+ integer(frame.revision, 'revision');
131
+ const { sequence, revision } = frame;
132
+ const header = encodeHeader({
133
+ ...frameHeader(frame),
134
+ file: { path: frame.file.path },
135
+ sequence,
136
+ revision,
137
+ });
138
+ return this.exclusive(() => this.connection.within(timeoutMs, async () => {
139
+ await this.connection.write(header);
140
+ const message = await this.connection.read();
141
+ const result = message?.result;
142
+ if (message?.id !== `${this.connection.id}:file:${sequence}` ||
143
+ result?.type !== 'pane_graphics_frame_ack' ||
144
+ result.sequence !== sequence ||
145
+ result.revision !== revision) {
146
+ const error = new HerdrError('herdr_invalid_response', 'Graphics acknowledgement did not match the file frame');
147
+ this.connection.fail(error, true);
148
+ throw error;
149
+ }
150
+ return result;
151
+ }));
152
+ }
153
+ close() {
154
+ this.connection.close();
155
+ }
156
+ }
@@ -0,0 +1,50 @@
1
+ export declare class HerdrError extends Error {
2
+ code: string;
3
+ constructor(code: string, message: string);
4
+ }
5
+ export interface RequestOptions {
6
+ /** Transport deadline, including connection time; null disables it. */
7
+ timeoutMs?: number | null;
8
+ signal?: AbortSignal;
9
+ maxResponseBytes?: number;
10
+ }
11
+ export interface StreamOptions extends RequestOptions {
12
+ maxQueuedEvents?: number;
13
+ maxQueuedBytes?: number;
14
+ }
15
+ export declare function validateSocketPath(path: string): void;
16
+ export declare function validateTimeout(value: number | null): void;
17
+ /** Internal, single-reader NDJSON connection. JSON reads and binary writes stay separate. */
18
+ export declare class JsonConnection {
19
+ private options;
20
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
21
+ readonly closed: Promise<void>;
22
+ private resolveClosed;
23
+ private rejectClosed;
24
+ private socket;
25
+ private buffer;
26
+ private queue;
27
+ private queuedBytes;
28
+ private reader?;
29
+ private writes;
30
+ private ended;
31
+ private failure?;
32
+ private explicitClose;
33
+ private readonly maxMessageBytes;
34
+ private readonly maxQueuedEvents;
35
+ private readonly maxQueuedBytes;
36
+ private readonly abort;
37
+ constructor(socketPath: string, options?: StreamOptions);
38
+ private error;
39
+ private detachAbort;
40
+ private rejectWrites;
41
+ fail(error: Error, discard?: boolean): void;
42
+ close(): void;
43
+ private deliver;
44
+ private receive;
45
+ read(): Promise<any>;
46
+ write(data: string | Uint8Array): Promise<void>;
47
+ within<T>(timeoutMs: number | null, action: () => Promise<T>): Promise<T>;
48
+ start(method: string, params: unknown, timeoutMs: number | null): Promise<any>;
49
+ }
50
+ export declare function socketRequest<T>(socketPath: string, method: string, params: unknown, options?: RequestOptions): Promise<T>;