ruicode 0.93.0 → 0.94.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/README.md CHANGED
@@ -47,7 +47,7 @@ const rui = await Rui.connect({
47
47
  providers: { chatgpt: {} }, // Or { credentialFile: "/private/chatgpt.json" }.
48
48
  tools: { mcp: { drift: { url: "http://127.0.0.1:3000/mcp" } } },
49
49
  presets: { drift: {
50
- provider: "chatgpt", model: "gpt-6.1-sol", effort: "low", compactAt: 100000,
50
+ connection: "chatgpt", model: "gpt-6.1-sol", effort: "low", compactAt: 100000,
51
51
  workspace: "/workspace", tools: ["drift_tool"], permissionMode: "bypass",
52
52
  } },
53
53
  });
@@ -195,7 +195,7 @@ await session.update({ compactAt: 200000 });
195
195
  await session.update({ model: "gpt-5.5" });
196
196
  ```
197
197
 
198
- `await session.status()` reads the Current report: work `state` and `since`, `turn`, `operation`, `pendingMessages`, `parent`, `label`, `model`, `effort`, `tools`, `permissionMode`, `latestOutcome` and `archiveState`.
198
+ `await session.status()` reads the Current report: work `state` and `since`, `turn`, `operation`, `pendingMessages`, `parent`, `label`, `model`, `effort`, `tools`, `appTools`, `permissionMode`, `latestOutcome` and `archiveState`.
199
199
  Counts, times and Turn/Operation IDs stay decimal strings; absent targets, parents and outcomes are `null`.
200
200
  A separate ending is not in the report, so status does not invent one.
201
201
  `interruptTarget` is the Host-served target from that snapshot. Pass it explicitly with a key to interrupt that observed call in one request, and reuse the same key to recover its answer:
@@ -223,6 +223,22 @@ const review = await rui.sessions.create({ preset: "review", instructions: "Revi
223
223
  await rui.close();
224
224
  ```
225
225
 
226
+ ## App tools
227
+
228
+ A lane root declares the app tools its tree offers with `appTools` on `create` or `update`; `[]` clears them.
229
+ Each record has a `name`, a `description` and an `inputSchema` object; `replay` (`"safe"` or `"unsafe"`, the default), `restartLimit` (0 to 16) and `waitMs` (1000 to 3600000) are optional.
230
+ The Host validates the whole list and refuses a bad one by name, so nothing is saved partly.
231
+ A child Session refuses `appTools` with `app_tools_on_child`.
232
+ Connect-time presets do not take `appTools`.
233
+
234
+ ```ts
235
+ await rui.sessions.create({
236
+ workspace: "/work/project",
237
+ model: "gpt-6.1-sol",
238
+ appTools: [{ name: "lookup", description: "Find a record by id.", inputSchema: { type: "object", properties: { id: { type: "string" } }, required: ["id"] }, replay: "safe" }],
239
+ }, { idempotencyKey: "project:tools" });
240
+ ```
241
+
226
242
  ## Archive and restore
227
243
 
228
244
  Archive metadata is independent of work state. `archiveState` is `active`, `archiving` or `archived` in Session summaries and status.
@@ -2,9 +2,19 @@
2
2
  export const REJECTION_SENTENCES = {
3
3
  "action_not_backgroundable": "This core tool does not run as a background Action.",
4
4
  "action_not_pending": "That Action is not awaiting a permission decision.",
5
+ "app_tool_built_in_clash": "An app tool has the name of a built-in tool.",
6
+ "app_tool_host_clash": "An app tool has the name of a tool this Host offers.",
7
+ "app_tools_on_child": "A child Session cannot declare app tools; its lane root declares them.",
8
+ "app_tools_too_large": "The app tools declaration is larger than the Host accepts.",
5
9
  "archive_pending": "This Session is still settling its archive request.",
6
10
  "background_unavailable": "This saved promotion was refused under an earlier Host policy.",
7
11
  "compact_at_too_large": "The compaction trigger is larger than the model's context window.",
12
+ "connection_is_immutable": "An existing Session cannot change its connection.",
13
+ "connection_unserved": "This Host does not serve that connection.",
14
+ "duplicate_app_tool_name": "Two app tools share a name.",
15
+ "invalid_app_tool_name": "An app tool name is not a valid tool name.",
16
+ "invalid_app_tool_policy": "An app tool's replay, restart limit or wait is out of range.",
17
+ "invalid_app_tools": "The app tools are not a valid declaration.",
8
18
  "invalid_arguments": "The tool arguments are invalid.",
9
19
  "invalid_compaction_trigger": "The compaction trigger is not a positive token count.",
10
20
  "invalid_label": "The Label is too long or contains a line break or control character.",
@@ -28,7 +38,6 @@ export const REJECTION_SENTENCES = {
28
38
  "permission_mode_wider_than_parent": "The parent asks before running commands, so its child Session must ask too. Nothing was created.",
29
39
  "preferences_on_update": "An existing Session cannot apply creation preferences.",
30
40
  "preset_on_update": "An existing Session cannot apply a preset.",
31
- "provider_is_immutable": "An existing Session cannot change its provider.",
32
41
  "provider_tool_missing": "The selected provider cannot run a requested tool.",
33
42
  "revision_exhausted": "This Session has exhausted its configuration revisions.",
34
43
  "session_archiving": "This Session is still settling its archive request and cannot take new Messages.",
@@ -41,12 +50,12 @@ export const REJECTION_SENTENCES = {
41
50
  "target_mismatch": "The target IDs do not identify the requested work in this Session.",
42
51
  "tools_not_in_parent": "A requested tool is not one of the parent's tools. Nothing was created.",
43
52
  "unknown_action": "That Action does not exist in this Session.",
53
+ "unknown_connection": "Rui has no connection with that name.",
44
54
  "unknown_operation": "That Operation does not exist in this Session.",
45
55
  "unknown_preset": "The Host does not have that preset.",
46
56
  "unknown_session": "No Session with this ID exists in this Store.",
47
57
  "unknown_tool": "A requested tool is not offered by this Host.",
48
58
  "unsupported_permission_mode": "Rui has no such permission mode.",
49
- "unsupported_provider": "Rui has no such provider.",
50
59
  "unsupported_reasoning_effort": "The effort word is invalid, unsupported by the listed model, or clears an assigned effort.",
51
60
  "workspace_is_immutable": "An existing Session cannot change its workspace."
52
61
  };
@@ -13,12 +13,27 @@ export type ActionStatus = Schemas["ReadActionReply"];
13
13
  export type ActionSelection = Extract<Schemas["ActionBackgroundReply"]["answer"], {
14
14
  status: "accepted";
15
15
  }>["action_selection"];
16
+ /** An app tool a lane root declares: a tool its caller runs, served to the model beside the Host's own tools. */
17
+ export interface AppToolSpec {
18
+ /** 1 to 64 ASCII letters, digits, `_` or `-`; not a built-in tool's name. */
19
+ name: string;
20
+ /** 1 to 200 bytes of valid UTF-8. */
21
+ description: string;
22
+ /** The JSON Schema object of the tool's input. */
23
+ inputSchema: Record<string, unknown>;
24
+ /** `safe` lets the Host repeat a call that did not finish; `unsafe` (the default) never repeats one. */
25
+ replay?: "safe" | "unsafe";
26
+ /** Repeats a safe call may take, 0 to 16. Only a safe tool has repeats; the default is 3. */
27
+ restartLimit?: number;
28
+ /** Milliseconds an unclaimed call waits, 1000 to 3600000. The default is 900000. */
29
+ waitMs?: number;
30
+ }
16
31
  /** Session settings. The Host resolves omitted creation settings. */
17
32
  export interface AgentSpec {
18
33
  /** The Session Workspace, fixed for its life. Root creation requires it; children inherit it. */
19
34
  workspace?: string;
20
35
  /** `openai` or `codex`. Fixed for the Session's life. */
21
- provider?: NonNullable<Schemas["AgentSpec"]["provider"]>;
36
+ connection?: NonNullable<Schemas["AgentSpec"]["connection"]>;
22
37
  /** Creation requires a model, supplied directly or by a preset. May change within the fixed provider. */
23
38
  model: string;
24
39
  instructions?: string;
@@ -42,6 +57,8 @@ export interface AgentSpec {
42
57
  };
43
58
  /** A name shown in lists. `null` clears it. */
44
59
  label?: string | null;
60
+ /** The app tools a lane root declares; `[]` clears them. A child Session cannot declare them. */
61
+ appTools?: readonly AppToolSpec[];
45
62
  }
46
63
  /** The same agent spec accepted by creation and connect-time presets. */
47
64
  export type SessionSpec = AgentSpec;
@@ -61,10 +78,10 @@ export type SessionCreate = CreationSettings & ({
61
78
  /** Create an attached child, inheriting provider, Workspace and Bash environment. */
62
79
  parent: string;
63
80
  workspace?: never;
64
- provider?: never;
81
+ connection?: never;
65
82
  });
66
83
  /** The settings `update` may change: everything but the ones fixed at creation. */
67
- export type SessionUpdate = Partial<Pick<SessionSpec, "model" | "instructions" | "outputSchema" | "tools" | "permissionMode" | "effort" | "compactAt" | "label" | "loadedTools" | "outputReservation">>;
84
+ export type SessionUpdate = Partial<Pick<SessionSpec, "model" | "instructions" | "outputSchema" | "tools" | "permissionMode" | "effort" | "compactAt" | "label" | "loadedTools" | "outputReservation" | "appTools">>;
68
85
  export interface WriteOptions {
69
86
  /** Optional caller-supplied key for replay. Takes precedence over `idempotencyKey`. */
70
87
  key?: string;
@@ -139,11 +156,13 @@ export interface SessionStatus extends ServedWork {
139
156
  tools: CurrentReport["session"]["tools"];
140
157
  /** Loaded tool intent; an active Operation keeps its frozen model offer. */
141
158
  loadedTools: CurrentReport["session"]["loaded_tools"];
159
+ /** Names of the app tools this Session's lane declared. */
160
+ appTools: CurrentReport["session"]["app_tools"];
142
161
  permissionMode: CurrentReport["session"]["permission_mode"];
143
162
  latestOutcome: CurrentReport["work"]["latest_outcome"];
144
163
  }
145
164
  export interface ModelSummary {
146
- provider: string;
165
+ connection: string;
147
166
  id: string;
148
167
  known: boolean;
149
168
  }
package/dist/sessions.js CHANGED
@@ -3,10 +3,20 @@ import { RuiRequestError, RuiWaitTimeoutError } from "./errors.js";
3
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
+ function appToolRecord(tool) {
7
+ return {
8
+ name: tool.name,
9
+ description: tool.description,
10
+ input_schema: tool.inputSchema,
11
+ ...(tool.replay === undefined ? {} : { replay: tool.replay }),
12
+ ...(tool.restartLimit === undefined ? {} : { restart_limit: tool.restartLimit }),
13
+ ...(tool.waitMs === undefined ? {} : { wait_ms: tool.waitMs }),
14
+ };
15
+ }
6
16
  export function agentSpec(spec) {
7
17
  return {
8
18
  ...(spec.workspace === undefined ? {} : { workspace: spec.workspace }),
9
- ...(spec.provider === undefined ? {} : { provider: spec.provider }),
19
+ ...(spec.connection === undefined ? {} : { connection: spec.connection }),
10
20
  ...(spec.model === undefined ? {} : { model: spec.model }),
11
21
  ...(spec.instructions === undefined ? {} : { instructions: spec.instructions }),
12
22
  ...(spec.tools === undefined ? {} : { tools: [...new Set(spec.tools)].sort() }),
@@ -17,6 +27,7 @@ export function agentSpec(spec) {
17
27
  ...(spec.outputReservation === undefined ? {} : { outputReservation: spec.outputReservation }),
18
28
  ...(spec.effort === undefined ? {} : { effort: spec.effort }),
19
29
  ...(spec.label === undefined ? {} : { label: spec.label }),
30
+ ...(spec.appTools === undefined ? {} : { appTools: spec.appTools.map(appToolRecord) }),
20
31
  ...(spec.preferences === undefined ? {} : { preferences: {
21
32
  ...(spec.preferences.reasoningEffort === undefined ? {} : { reasoning_effort: spec.preferences.reasoningEffort }),
22
33
  ...(spec.preferences.permissionMode === undefined ? {} : { permission_mode: spec.preferences.permissionMode }),
@@ -116,6 +127,7 @@ export class Session {
116
127
  effort: reply.session.reasoning_effort,
117
128
  tools: reply.session.tools,
118
129
  loadedTools: reply.session.loaded_tools,
130
+ appTools: reply.session.app_tools,
119
131
  permissionMode: reply.session.permission_mode,
120
132
  latestOutcome: reply.work.latest_outcome,
121
133
  };
@@ -309,7 +321,7 @@ export async function models(link) {
309
321
  kind: "model_list",
310
322
  store,
311
323
  })));
312
- return reply.providers.flatMap((entry) => entry.models.map((model) => ({ provider: entry.provider, id: model.id, known: model.known })));
324
+ return reply.connections.flatMap((entry) => entry.models.map((model) => ({ connection: entry.connection, id: model.id, known: model.known })));
313
325
  }
314
326
  export async function setPaused(link, paused) {
315
327
  await link.exchange("/v1/control/host-pause", (store) => JSON.stringify({
@@ -10,7 +10,8 @@ type Input<T> = T extends {
10
10
  /** The generated Host document, with pipe-only secret strings and byte-array paths. */
11
11
  export type HostSettings = Omit<Input<components["schemas"]["HostSettings"]>, "presets"> & {
12
12
  /** Uses the same friendly Session spec and writer as sessions.create. */
13
- presets?: Record<string, AgentSpec>;
13
+ /** Connect-time presets take every agent setting but `appTools`: a lane root declares app tools on create or configure. */
14
+ presets?: Record<string, Omit<AgentSpec, "appTools">>;
14
15
  };
15
16
  export declare function pipeSettings(value: HostSettings, environmentSource?: (name: unknown, path: string) => void): components["schemas"]["HostSettings"];
16
17
  export interface PreparedSettings {
@@ -1,4 +1,4 @@
1
- export declare const WIRE_VERSION = "25";
1
+ export declare const WIRE_VERSION = "27";
2
2
  export interface Post {
3
3
  socketPath: string;
4
4
  path: string;
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 = "25";
3
+ export const WIRE_VERSION = "27";
4
4
  const MAX_REPLY_BYTES = 64 * 1024 * 1024;
5
5
  const TRANSFER_IDLE_MS = 60_000;
6
6
  export class ConnectionError extends Error {