ruicode 0.88.1 → 0.92.0

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.
package/dist/line.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ /** A frame the Host sends on the held line. A nudge names a Session and carries no saved fact. */
2
+ export type LineFrame = {
3
+ type: "hello";
4
+ line: number;
5
+ instance: string;
6
+ } | {
7
+ type: "changed";
8
+ session: string;
9
+ } | {
10
+ type: "resync";
11
+ } | {
12
+ type: "failed";
13
+ code: string;
14
+ } | {
15
+ type: "ping";
16
+ };
17
+ /** The Host sent a frame outside the line's grammar: a length of 0 or above 16 KiB, or a payload that is no known frame. */
18
+ export declare class LineProtocolError extends Error {
19
+ readonly name = "LineProtocolError";
20
+ }
21
+ export interface LineHandler {
22
+ frame(frame: LineFrame): void;
23
+ /** Called once per line. `error` is set when the line ended by a socket error or a malformed frame. */
24
+ closed(line: Line, error: Error | undefined): void;
25
+ }
26
+ /**
27
+ * One held, notification-only connection to a Host (`GET /v1/line`, docs/contracts/inspection.md#live-line). The client
28
+ * sends `watch` frames and reads nudges. It holds no Session state; `Follows` decides what a nudge means.
29
+ */
30
+ export declare class Line {
31
+ #private;
32
+ private constructor();
33
+ /** Upgrades to a line on the Host's socket. Resolves once the Host has switched protocols; a refusal rejects with its error. */
34
+ static open(options: {
35
+ socketPath: string;
36
+ instance: string;
37
+ handler: LineHandler;
38
+ }): Promise<Line>;
39
+ /** False once the line has ended, by either side. */
40
+ get isOpen(): boolean;
41
+ /** Replaces the watched set with `sessions`. The Host nudges each listed Session once. */
42
+ watch(sessions: readonly string[]): void;
43
+ /** Closes the socket. The handler's `closed` runs once, with no error. */
44
+ close(): void;
45
+ }
package/dist/line.js ADDED
@@ -0,0 +1,132 @@
1
+ import { request } from "node:http";
2
+ import { ConnectionError, refusal, WIRE_VERSION } from "./transport.js";
3
+ const MAX_FRAME_BYTES = 16 * 1024;
4
+ /** The Host sent a frame outside the line's grammar: a length of 0 or above 16 KiB, or a payload that is no known frame. */
5
+ export class LineProtocolError extends Error {
6
+ name = "LineProtocolError";
7
+ }
8
+ /**
9
+ * One held, notification-only connection to a Host (`GET /v1/line`, docs/contracts/inspection.md#live-line). The client
10
+ * sends `watch` frames and reads nudges. It holds no Session state; `Follows` decides what a nudge means.
11
+ */
12
+ export class Line {
13
+ #socket;
14
+ #handler;
15
+ #pending = Buffer.alloc(0);
16
+ #ended = false;
17
+ constructor(socket, handler) {
18
+ this.#socket = socket;
19
+ this.#handler = handler;
20
+ }
21
+ /** Upgrades to a line on the Host's socket. Resolves once the Host has switched protocols; a refusal rejects with its error. */
22
+ static open(options) {
23
+ return new Promise((resolve, reject) => {
24
+ const outgoing = request({
25
+ socketPath: options.socketPath,
26
+ path: "/v1/line",
27
+ method: "GET",
28
+ agent: false,
29
+ headers: {
30
+ Connection: "Upgrade",
31
+ Upgrade: "rui-line/1",
32
+ "X-Rui-Wire-Version": WIRE_VERSION,
33
+ "X-Rui-Host-Instance": options.instance,
34
+ },
35
+ });
36
+ outgoing.on("error", (error) => reject(new ConnectionError(error.message, { cause: error })));
37
+ outgoing.on("response", (incoming) => {
38
+ const chunks = [];
39
+ incoming.on("data", (chunk) => chunks.push(chunk));
40
+ incoming.on("error", (error) => reject(new ConnectionError(error.message, { cause: error })));
41
+ incoming.on("end", () => reject(refusal(incoming.statusCode, Buffer.concat(chunks))));
42
+ });
43
+ outgoing.on("upgrade", (_incoming, socket, head) => {
44
+ // Held while a watcher follows: a following script stays alive until its watch ends, and the line closes with the last one.
45
+ const line = new Line(socket, options.handler);
46
+ socket.on("data", (chunk) => line.#receive(chunk));
47
+ socket.on("error", (error) => line.#finish(new ConnectionError(error.message, { cause: error })));
48
+ socket.on("close", () => line.#finish(undefined));
49
+ resolve(line);
50
+ if (head.length > 0)
51
+ line.#receive(head);
52
+ });
53
+ outgoing.end();
54
+ });
55
+ }
56
+ /** False once the line has ended, by either side. */
57
+ get isOpen() {
58
+ return !this.#ended;
59
+ }
60
+ /** Replaces the watched set with `sessions`. The Host nudges each listed Session once. */
61
+ watch(sessions) {
62
+ this.#send({ type: "watch", sessions: [...sessions] });
63
+ }
64
+ /** Closes the socket. The handler's `closed` runs once, with no error. */
65
+ close() {
66
+ this.#finish(undefined);
67
+ }
68
+ #send(payload) {
69
+ if (this.#ended)
70
+ return;
71
+ const json = Buffer.from(JSON.stringify(payload));
72
+ const frame = Buffer.alloc(4 + json.length);
73
+ frame.writeUInt32BE(json.length, 0);
74
+ json.copy(frame, 4);
75
+ this.#socket.write(frame);
76
+ }
77
+ #receive(chunk) {
78
+ this.#pending = this.#pending.length === 0 ? chunk : Buffer.concat([this.#pending, chunk]);
79
+ while (!this.#ended && this.#pending.length >= 4) {
80
+ const length = this.#pending.readUInt32BE(0);
81
+ if (length === 0 || length > MAX_FRAME_BYTES) {
82
+ this.#finish(new LineProtocolError(`the line sent a frame of ${length} bytes`));
83
+ return;
84
+ }
85
+ if (this.#pending.length < 4 + length)
86
+ return;
87
+ const payload = this.#pending.subarray(4, 4 + length).toString("utf8");
88
+ this.#pending = this.#pending.subarray(4 + length);
89
+ let frame;
90
+ try {
91
+ frame = parseFrame(payload);
92
+ }
93
+ catch (error) {
94
+ this.#finish(new LineProtocolError("the line sent a frame it does not know", { cause: error }));
95
+ return;
96
+ }
97
+ this.#handler.frame(frame);
98
+ }
99
+ }
100
+ #finish(error) {
101
+ if (this.#ended)
102
+ return;
103
+ this.#ended = true;
104
+ this.#pending = Buffer.alloc(0);
105
+ this.#socket.destroy();
106
+ this.#handler.closed(this, error);
107
+ }
108
+ }
109
+ function parseFrame(text) {
110
+ const value = JSON.parse(text);
111
+ if (typeof value !== "object" || value === null || !("type" in value))
112
+ throw new TypeError("not a frame");
113
+ switch (value.type) {
114
+ case "hello":
115
+ if ("line" in value && typeof value.line === "number" && "instance" in value && typeof value.instance === "string") {
116
+ return { type: "hello", line: value.line, instance: value.instance };
117
+ }
118
+ break;
119
+ case "changed":
120
+ if ("session" in value && typeof value.session === "string")
121
+ return { type: "changed", session: value.session };
122
+ break;
123
+ case "resync":
124
+ case "ping":
125
+ return { type: value.type };
126
+ case "failed":
127
+ if ("code" in value && typeof value.code === "string")
128
+ return { type: "failed", code: value.code };
129
+ break;
130
+ }
131
+ throw new TypeError(`unknown frame ${String(value.type)}`);
132
+ }
@@ -0,0 +1 @@
1
+ export declare const REJECTION_SENTENCES: Readonly<Record<string, string>>;
@@ -0,0 +1,52 @@
1
+ // Generated from src/caller_error.zig by `zig build openapi`. Do not edit.
2
+ export const REJECTION_SENTENCES = {
3
+ "action_not_backgroundable": "This core tool does not run as a background Action.",
4
+ "action_not_pending": "That Action is not awaiting a permission decision.",
5
+ "archive_pending": "This Session is still settling its archive request.",
6
+ "background_unavailable": "This saved promotion was refused under an earlier Host policy.",
7
+ "compact_at_too_large": "The compaction trigger is larger than the model's context window.",
8
+ "invalid_arguments": "The tool arguments are invalid.",
9
+ "invalid_compaction_trigger": "The compaction trigger is not a positive token count.",
10
+ "invalid_label": "The Label is too long or contains a line break or control character.",
11
+ "invalid_model": "The model ID is empty.",
12
+ "invalid_output_reservation": "The output reservation is not a nonnegative token count.",
13
+ "invalid_output_schema": "The output schema is not valid JSON.",
14
+ "invalid_sender_handle": "The peer sender handle is invalid or no longer live.",
15
+ "invalid_session_reference": "That Session reference is malformed.",
16
+ "invalid_target": "A target ID is invalid.",
17
+ "invalid_workspace": "The workspace is not a usable absolute directory.",
18
+ "loaded_tools_not_in_tools": "A loaded tool is not one of the Session's tools.",
19
+ "loaded_tools_unreachable": "Some tools would never be reachable: the loaded tools leave some out without loading find_tools.",
20
+ "mcp_server_unavailable": "A requested tool is unknown and a configured MCP server has no tools; it may provide the name.",
21
+ "missing_settings": "A new Session is missing a required setting.",
22
+ "model_capability_unavailable": "This Host does not serve the Session's required provider.",
23
+ "model_is_immutable": "This saved command was rejected when a Session could not change its model.",
24
+ "operation_resolved": "That Operation has already resolved.",
25
+ "parent_on_update": "spec.parent: an existing Session cannot change its parent. Nothing was changed.",
26
+ "parent_provider_forbidden": "A child Session always uses its parent's provider.",
27
+ "parent_workspace_forbidden": "A child Session always works in its parent's Workspace.",
28
+ "permission_mode_wider_than_parent": "The parent asks before running commands, so its child Session must ask too. Nothing was created.",
29
+ "preferences_on_update": "An existing Session cannot apply creation preferences.",
30
+ "preset_on_update": "An existing Session cannot apply a preset.",
31
+ "provider_is_immutable": "An existing Session cannot change its provider.",
32
+ "provider_tool_missing": "The selected provider cannot run a requested tool.",
33
+ "revision_exhausted": "This Session has exhausted its configuration revisions.",
34
+ "session_archiving": "This Session is still settling its archive request and cannot take new Messages.",
35
+ "settings_on_reload": "A Skills reload cannot change settings.",
36
+ "skill_file_too_large": "The selected skill files exceed the per-file or combined read limit.",
37
+ "skill_file_unavailable": "The selected skill file could not be read.",
38
+ "skill_text_invalid": "The selected skill file is not valid UTF-8 text.",
39
+ "skills_unavailable": "The skills catalog could not be read completely.",
40
+ "source_stopped": "This Action was selected by Session Stop and cannot be promoted.",
41
+ "target_mismatch": "The target IDs do not identify the requested work in this Session.",
42
+ "tools_not_in_parent": "A requested tool is not one of the parent's tools. Nothing was created.",
43
+ "unknown_action": "That Action does not exist in this Session.",
44
+ "unknown_operation": "That Operation does not exist in this Session.",
45
+ "unknown_preset": "The Host does not have that preset.",
46
+ "unknown_session": "No Session with this ID exists in this Store.",
47
+ "unknown_tool": "A requested tool is not offered by this Host.",
48
+ "unsupported_permission_mode": "Rui has no such permission mode.",
49
+ "unsupported_provider": "Rui has no such provider.",
50
+ "unsupported_reasoning_effort": "The effort word is invalid, unsupported by the listed model, or clears an assigned effort.",
51
+ "workspace_is_immutable": "An existing Session cannot change its workspace."
52
+ };
@@ -1,10 +1,11 @@
1
- import type { SessionNotifications } from "./notifications.ts";
2
- import { type ActivitySearchEntry, type SearchActivityOptions, type FeedEntry, type ListActivityOptions } from "./feed.ts";
1
+ import type { Follows } from "./follow.ts";
2
+ import { type ActivitySearchEntry, type SearchActivityOptions, type FeedEntry, type ListActivityOptions, type WatchOptions } from "./feed.ts";
3
3
  import { type ContentValue } from "./parts.ts";
4
4
  import { type ReplyLimits } from "./transport.ts";
5
5
  import type { components } from "./wire.ts";
6
6
  export interface Link {
7
- readonly activity?: SessionNotifications;
7
+ /** The client's one way to follow a Session. A link without it cannot `watch`. */
8
+ readonly follows?: Follows;
8
9
  exchange(path: string, build: (store: string) => string, environment?: Buffer, limits?: ReplyLimits): Promise<Buffer>;
9
10
  }
10
11
  type Schemas = components["schemas"];
@@ -154,11 +155,15 @@ export declare class Session {
154
155
  constructor(link: Link, id: string);
155
156
  /**
156
157
  * The Session's feed, in order, as an async iterator (D9). Without `follow`
157
- * it ends at the current end. With it, busy Sessions poll with backoff; idle Sessions
158
- * wait for a local write on this Rui instance (not writes from another process).
159
- * See `ListActivityOptions.follow`; `signal` abort also ends an idle wait.
158
+ * it ends at the current end. With it, the iterator is `watch`.
160
159
  */
161
160
  listActivity(options?: ListActivityOptions): AsyncGenerator<FeedEntry, void, undefined>;
161
+ /**
162
+ * Follows the Session's feed from `after`, yielding each new entry once and in order. The Host's line nudges
163
+ * this client when the Session commits; the iterator reads only then, so an idle Session makes no requests.
164
+ * Every watcher of this client shares one line. `signal` abort ends the iterator, even while it waits.
165
+ */
166
+ watch(options?: WatchOptions): AsyncGenerator<FeedEntry, void, undefined>;
162
167
  /** Search public feed text newest first, with bounded snippets. */
163
168
  searchActivity(query: string, options?: SearchActivityOptions): AsyncGenerator<ActivitySearchEntry, void, undefined>;
164
169
  /** The whole text of an entry (D134). Past about 512 MiB a string cannot hold it and this throws: use `readContentBytes`. */
@@ -215,4 +220,21 @@ export declare class Sessions {
215
220
  }
216
221
  export declare function models(link: Link): Promise<ModelSummary[]>;
217
222
  export declare function setPaused(link: Link, paused: boolean): Promise<void>;
223
+ export interface ToolReloadOutcome {
224
+ server: string;
225
+ /** The latest outcome of the asked list. */
226
+ outcome: "listed" | "failed";
227
+ tools: number;
228
+ /** Tools the server listed that the offered set left out (a clashing name, a name too long after prefixing, or the record limit). */
229
+ leftOut: number;
230
+ }
231
+ /**
232
+ * Asks the Host to list one MCP server, or every configured server, again, then polls `tools_status` until each asked
233
+ * generation has landed. An empty ask resolves at once with no poll. Rejects with RuiWaitTimeoutError after 60 s.
234
+ *
235
+ * Landing follows the CLI's owner (`toolsProgress` in client.zig): a server has landed in the Host that asked once
236
+ * its finished generation reaches the ask's; a Host with another instance has restarted its generations, so a
237
+ * server has landed there once any list has finished. A missing row, or `never` once landed, is an invalid reply.
238
+ */
239
+ export declare function reloadTools(link: Link, server?: string): Promise<ToolReloadOutcome[]>;
218
240
  export {};
package/dist/sessions.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { RuiRequestError } from "./errors.js";
3
- import { servedWork, listActivity, searchActivity, readContent, readContentBytes } from "./feed.js";
2
+ import { RuiRequestError, RuiWaitTimeoutError } from "./errors.js";
3
+ import { servedWork, listActivity, watchActivity, searchActivity, readContent, readContentBytes } from "./feed.js";
4
4
  import { readPartBytes } from "./parts.js";
5
5
  import { WIRE_VERSION } from "./transport.js";
6
6
  export function agentSpec(spec) {
@@ -42,7 +42,7 @@ function parse(reply) {
42
42
  }
43
43
  function accepted(answer) {
44
44
  if (answer.status !== "accepted")
45
- throw new RuiRequestError(answer.status, answer.code, "message" in answer ? answer.message : undefined);
45
+ throw new RuiRequestError(answer.status, answer.code, "message" in answer ? answer.message : undefined, "missing" in answer ? answer.missing : undefined);
46
46
  return answer;
47
47
  }
48
48
  export function environmentBytes(env) {
@@ -59,13 +59,19 @@ export class Session {
59
59
  }
60
60
  /**
61
61
  * The Session's feed, in order, as an async iterator (D9). Without `follow`
62
- * it ends at the current end. With it, busy Sessions poll with backoff; idle Sessions
63
- * wait for a local write on this Rui instance (not writes from another process).
64
- * See `ListActivityOptions.follow`; `signal` abort also ends an idle wait.
62
+ * it ends at the current end. With it, the iterator is `watch`.
65
63
  */
66
64
  listActivity(options) {
67
65
  return listActivity(this.#link, this.id, options, (target) => { this.#interruptTarget = target; });
68
66
  }
67
+ /**
68
+ * Follows the Session's feed from `after`, yielding each new entry once and in order. The Host's line nudges
69
+ * this client when the Session commits; the iterator reads only then, so an idle Session makes no requests.
70
+ * Every watcher of this client shares one line. `signal` abort ends the iterator, even while it waits.
71
+ */
72
+ watch(options) {
73
+ return watchActivity(this.#link, this.id, options, (target) => { this.#interruptTarget = target; });
74
+ }
69
75
  /** Search public feed text newest first, with bounded snippets. */
70
76
  searchActivity(query, options) {
71
77
  return searchActivity(this.#link, this.id, query, options);
@@ -128,7 +134,6 @@ export class Session {
128
134
  });
129
135
  const reply = parse(await this.#link.exchange("/v1/message", body, environmentBytes(options.env)));
130
136
  const messageId = accepted(reply.answer).admission;
131
- this.#link.activity?.notify(this.id);
132
137
  return { messageId };
133
138
  }
134
139
  /** Changes settings. Omitted fields stay as they are. Resolves once the Host accepted the change (D7). */
@@ -136,7 +141,6 @@ export class Session {
136
141
  const idempotencyKey = key(options);
137
142
  const reply = parse(await this.#link.exchange("/v1/configure", (store) => configureBody(store, idempotencyKey, this.id, fields)));
138
143
  accepted(reply.answer);
139
- this.#link.activity?.notify(this.id);
140
144
  }
141
145
  /** Stops the current and queued work. The Session stays usable (D14). */
142
146
  async stop(options) {
@@ -149,7 +153,6 @@ export class Session {
149
153
  session: this.id,
150
154
  });
151
155
  accepted(parse(await this.#link.exchange("/v1/control/session-stop", body)).answer);
152
- this.#link.activity?.notify(this.id);
153
156
  }
154
157
  /** Stops work and archives after real settlement, using one durable intent. */
155
158
  archive(options) {
@@ -173,7 +176,6 @@ export class Session {
173
176
  const completion = reply.completion.status;
174
177
  if (completion === "unavailable")
175
178
  throw new RuiRequestError("invocation_error", "invalid_response");
176
- this.#link.activity?.notify(this.id);
177
179
  return { archived: answer.archived, completion };
178
180
  }
179
181
  /** Pins this Session without starting or interrupting work. Repeated pins preserve its position. */
@@ -195,7 +197,6 @@ export class Session {
195
197
  pinned,
196
198
  })));
197
199
  const answer = accepted(reply.answer);
198
- this.#link.activity?.notify(this.id);
199
200
  return { pinned: answer.pinned };
200
201
  }
201
202
  /** Releases the original call with an immutable receipt. Poll `readAction` for the sole final result. */
@@ -206,7 +207,6 @@ export class Session {
206
207
  key: idempotencyKey, session: this.id, action,
207
208
  })));
208
209
  const answer = accepted(reply.answer);
209
- this.#link.activity?.notify(this.id);
210
210
  return answer.action_selection;
211
211
  }
212
212
  /** Selects an owned Action for stop. Reuse the key to recover a lost reply. */
@@ -217,7 +217,6 @@ export class Session {
217
217
  key: idempotencyKey, session: this.id, action,
218
218
  })));
219
219
  const answer = accepted(reply.answer);
220
- this.#link.activity?.notify(this.id);
221
220
  return answer.resolution_position;
222
221
  }
223
222
  /** Reads an owned Action. Acceptance and attempted state do not assert a running process. */
@@ -245,7 +244,6 @@ export class Session {
245
244
  if (!gone)
246
245
  throw error;
247
246
  }
248
- this.#link.activity?.notify(this.id);
249
247
  }
250
248
  /** Answers an approval. `requestId` is the Action id of the `approval_requested` entry (D15). */
251
249
  async decide(requestId, decision, options) {
@@ -261,7 +259,6 @@ export class Session {
261
259
  decision: wire,
262
260
  });
263
261
  accepted(parse(await this.#link.exchange("/v1/control/permission-decision", body)).answer);
264
- this.#link.activity?.notify(this.id);
265
262
  }
266
263
  }
267
264
  export class Sessions {
@@ -322,3 +319,76 @@ export async function setPaused(link, paused) {
322
319
  paused,
323
320
  }));
324
321
  }
322
+ const RELOAD_POLL_MS = 250;
323
+ const RELOAD_WAIT_MS = 60_000;
324
+ /**
325
+ * Asks the Host to list one MCP server, or every configured server, again, then polls `tools_status` until each asked
326
+ * generation has landed. An empty ask resolves at once with no poll. Rejects with RuiWaitTimeoutError after 60 s.
327
+ *
328
+ * Landing follows the CLI's owner (`toolsProgress` in client.zig): a server has landed in the Host that asked once
329
+ * its finished generation reaches the ask's; a Host with another instance has restarted its generations, so a
330
+ * server has landed there once any list has finished. A missing row, or `never` once landed, is an invalid reply.
331
+ */
332
+ export async function reloadTools(link, server) {
333
+ const reply = parse(await link.exchange("/v1/control/tools-reload", (store) => JSON.stringify({
334
+ version: WIRE_VERSION,
335
+ kind: "tools_reload",
336
+ store,
337
+ ...(server === undefined ? {} : { server }),
338
+ })));
339
+ if (reply.asked.length === 0)
340
+ return [];
341
+ const deadline = Date.now() + RELOAD_WAIT_MS;
342
+ for (;;) {
343
+ // A busy Host is still listing; ask again until the deadline, as the Zig client does.
344
+ const status = await readToolsStatus(link);
345
+ const pending = status === undefined ? reply.asked : reply.asked.filter((ask) => !serverLanded(reply.instance, status, ask));
346
+ if (status !== undefined && pending.length === 0) {
347
+ return reply.asked.map((ask) => {
348
+ const row = statusRow(status, ask.server);
349
+ return { server: ask.server, outcome: toolOutcome(row), tools: Number(row.tools), leftOut: Number(row.left_out) };
350
+ });
351
+ }
352
+ const remaining = deadline - Date.now();
353
+ if (remaining <= 0) {
354
+ throw new RuiWaitTimeoutError(`MCP tool lists still pending after 60 seconds: ${pending.map((ask) => ask.server).join(", ")}`);
355
+ }
356
+ await new Promise((resolve) => setTimeout(resolve, Math.min(RELOAD_POLL_MS, remaining)));
357
+ }
358
+ }
359
+ async function readToolsStatus(link) {
360
+ try {
361
+ return parse(await link.exchange("/v1/tools-status", (store) => JSON.stringify({
362
+ version: WIRE_VERSION,
363
+ kind: "tools_status",
364
+ store,
365
+ })));
366
+ }
367
+ catch (error) {
368
+ if (error instanceof RuiRequestError && error.type === "busy")
369
+ return undefined;
370
+ throw error;
371
+ }
372
+ }
373
+ function serverLanded(reloadInstance, status, ask) {
374
+ const row = statusRow(status, ask.server);
375
+ const finished = BigInt(row.finished);
376
+ const landed = status.instance === reloadInstance ? finished >= BigInt(ask.generation) : finished >= 1n;
377
+ if (landed && row.last === "never")
378
+ throw invalidToolsReply();
379
+ return landed;
380
+ }
381
+ function statusRow(status, name) {
382
+ const row = status.servers.find((entry) => entry.server === name);
383
+ if (row === undefined)
384
+ throw invalidToolsReply();
385
+ return row;
386
+ }
387
+ function toolOutcome(row) {
388
+ if (row.last === "never")
389
+ throw invalidToolsReply();
390
+ return row.last;
391
+ }
392
+ function invalidToolsReply() {
393
+ return new RuiRequestError("invocation_error", "invalid_response");
394
+ }
@@ -1,4 +1,4 @@
1
- export declare const WIRE_VERSION = "23";
1
+ export declare const WIRE_VERSION = "24";
2
2
  export interface Post {
3
3
  socketPath: string;
4
4
  path: string;
@@ -16,3 +16,4 @@ export declare class ConnectionError extends Error {
16
16
  readonly name = "ConnectionError";
17
17
  }
18
18
  export declare function post(call: Post): Promise<Buffer>;
19
+ export declare function refusal(status: number | undefined, reply: Buffer): Error;
package/dist/transport.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { request } from "node:http";
2
2
  import { RuiRequestError } from "./errors.js";
3
- export const WIRE_VERSION = "23";
3
+ export const WIRE_VERSION = "24";
4
4
  const MAX_REPLY_BYTES = 64 * 1024 * 1024;
5
5
  const TRANSFER_IDLE_MS = 60_000;
6
6
  export class ConnectionError extends Error {
@@ -57,7 +57,7 @@ export function post(call) {
57
57
  outgoing.end(payload);
58
58
  });
59
59
  }
60
- function refusal(status, reply) {
60
+ export function refusal(status, reply) {
61
61
  let parsed;
62
62
  try {
63
63
  parsed = JSON.parse(reply.toString("utf8"));