ruicode 0.83.0 → 0.88.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
@@ -196,11 +196,14 @@ The settings process test also runs on MySQL when `RUI_TEST_MYSQL_SOCKET`, `RUI_
196
196
 
197
197
  ## Session settings
198
198
 
199
- `create` needs `model`, `effort`, `compactAt`, `tools` and `permissionMode`, and `workspace` when `tools` includes `bash`, or a `preset` name with optional overrides.
199
+ Creation requires a `model`, supplied directly or by a named preset.
200
+ Root creation also carries the caller's `workspace`, supplied directly or by the preset.
201
+ Within that Workspace, the Host fills omitted `effort`, `compactAt`, `tools`, `loadedTools` and `permissionMode` settings.
202
+ An explicit `tools: []` allows no tools.
200
203
  `provider` may be left out when the Host serves one provider.
201
- `effort: null` sends no effort, so the provider uses its own; it is accepted only for a model Rui does not list.
202
- Updates may change the model within the Session's fixed provider; the Workspace also remains fixed.
203
- An omitted setting stays as it is.
204
+ A creation naming `parent` inherits that Session's Workspace and provider and cannot supply either field.
205
+ `effort: null` and `compactAt: null` request the Host defaults for the selected model.
206
+ Updates preserve omitted settings and may change the model within the Session's fixed provider; the Workspace remains fixed.
204
207
 
205
208
  ```ts
206
209
  const session = await rui.sessions.create({
@@ -227,15 +230,16 @@ if (interruptTarget) await session.interrupt(interruptTarget, { key: "interrupt:
227
230
 
228
231
  `key` is also accepted by other writes using `WriteOptions`; it takes precedence if `idempotencyKey` is also supplied. `operation_resolved` and `target_mismatch` resolve without effect; other rejections throw. The convenience `interrupt({ key: "interrupt:1" })` uses the last target observed by this handle through `status()` or a feed page. It sends nothing if the handle has observed no target, or its last observation had a null target. Neither form reads first.
229
232
 
230
- Presets are complete agent specs passed at connect and kept only in Host memory.
231
- Creation copies the preset, with every supplied field (including `null`) overriding it.
233
+ Presets supply a model and may omit the other agent settings; they are passed at connect and kept only in Host memory.
234
+ Creation copies the preset, with every supplied field (including `null`) overriding it, then the Host resolves omitted settings.
235
+ A root creation must resolve a Workspace from the preset or its overrides.
232
236
 
233
237
  ```ts
234
238
  const rui = await Rui.connect({
235
239
  store: { sqlite: { dir: "/var/lib/myapp/rui-store" } },
236
240
  providers: { openai: { endpoint: "https://api.openai.com/v1/responses", key: process.env.OPENAI_API_KEY! } },
237
241
  presets: {
238
- review: { model: "gpt-6.1-sol", effort: "low", compactAt: 100000, tools: [], permissionMode: "ask" },
242
+ review: { workspace: "/work/project", model: "gpt-6.1-sol", instructions: "Review patches", tools: [], permissionMode: "ask" },
239
243
  },
240
244
  });
241
245
  const review = await rui.sessions.create({ preset: "review", instructions: "Review this patch" }, { idempotencyKey: "review:1" });
@@ -12,42 +12,56 @@ export type ActionStatus = Schemas["ReadActionReply"];
12
12
  export type ActionSelection = Extract<Schemas["ActionBackgroundReply"]["answer"], {
13
13
  status: "accepted";
14
14
  }>["action_selection"];
15
- /** The Session settings the Host takes today. */
15
+ /** Session settings. The Host resolves omitted creation settings. */
16
16
  export interface AgentSpec {
17
- /** The working directory for Bash. Required with `bash`, fixed for the Session's life. */
17
+ /** The Session Workspace, fixed for its life. Root creation requires it; children inherit it. */
18
18
  workspace?: string;
19
19
  /** `openai` or `codex`. Fixed for the Session's life. */
20
20
  provider?: NonNullable<Schemas["AgentSpec"]["provider"]>;
21
- /** May change within the Session's fixed provider. */
21
+ /** Creation requires a model, supplied directly or by a preset. May change within the fixed provider. */
22
22
  model: string;
23
23
  instructions?: string;
24
24
  /** JSON output schema object; `null` clears it. */
25
25
  outputSchema?: Record<string, unknown> | null;
26
26
  /** Configured allowed tool names, such as `bash` and `web_search`. */
27
- tools: readonly string[];
27
+ tools?: readonly string[];
28
28
  /** Loaded tool intent within `tools`; each Operation freezes its effective model offer. */
29
29
  loadedTools?: readonly string[];
30
30
  /** Tokens reserved for model output; null clears the override. */
31
31
  outputReservation?: number | null;
32
- permissionMode: "ask" | "bypass";
33
- /** Reasoning effort. `null` sends none, so the provider uses its own; only for a model Rui does not list (D111). */
34
- effort: Schemas["AgentSpec"]["effort"];
35
- /** Compact the conversation at this many tokens. */
36
- compactAt: number;
32
+ permissionMode?: "ask" | "bypass";
33
+ /** Reasoning effort. `null` requests the Host default for the selected model. */
34
+ effort?: Schemas["AgentSpec"]["effort"];
35
+ /** Compact the conversation at this many tokens. `null` requests the Host default. */
36
+ compactAt?: number | null;
37
+ /** Soft creation preferences, used when no stronger setting applies. */
38
+ preferences?: {
39
+ reasoningEffort?: NonNullable<Schemas["AgentSpec"]["effort"]>;
40
+ permissionMode?: "ask" | "bypass";
41
+ };
37
42
  /** A name shown in lists. `null` clears it. */
38
43
  label?: string | null;
39
44
  }
40
45
  /** The same agent spec accepted by creation and connect-time presets. */
41
46
  export type SessionSpec = AgentSpec;
42
- /** Creation needs a complete spec, or a named preset with explicit overrides. */
43
- export type SessionCreate = ((AgentSpec & {
47
+ type CreationSettings = (AgentSpec & {
44
48
  preset?: never;
45
- }) | ({
49
+ }) | (Partial<AgentSpec> & {
46
50
  preset: string;
47
- } & Partial<AgentSpec>)) & {
48
- /** Create an attached child, inheriting provider, workspace and Bash environment. */
49
- parent?: string;
50
- };
51
+ });
52
+ /** Creation needs a model, directly or from a preset. Roots carry a Workspace; children inherit it. */
53
+ export type SessionCreate = CreationSettings & ({
54
+ workspace: string;
55
+ parent?: never;
56
+ } | {
57
+ preset: string;
58
+ parent?: never;
59
+ } | {
60
+ /** Create an attached child, inheriting provider, Workspace and Bash environment. */
61
+ parent: string;
62
+ workspace?: never;
63
+ provider?: never;
64
+ });
51
65
  /** The settings `update` may change: everything but the ones fixed at creation. */
52
66
  export type SessionUpdate = Partial<Pick<SessionSpec, "model" | "instructions" | "outputSchema" | "tools" | "permissionMode" | "effort" | "compactAt" | "label" | "loadedTools" | "outputReservation">>;
53
67
  export interface WriteOptions {
@@ -82,6 +96,11 @@ export interface ServedWork {
82
96
  interruptTarget: InterruptTarget | null;
83
97
  }
84
98
  export interface SessionSummary extends ServedWork {
99
+ /** Decimal times and counts remain lossless strings. */
100
+ stateChangeAt: Schemas["SessionRow"]["state_change_at"];
101
+ subtreeStateChangeAt: Schemas["SessionRow"]["subtree_state_change_at"];
102
+ descendantCount: Schemas["SessionRow"]["descendant_count"];
103
+ descendantNeedsYouCount: Schemas["SessionRow"]["descendant_needs_you_count"];
85
104
  id: string;
86
105
  label: string | null;
87
106
  /** The Session's work state, such as `idle`, `working` or `approval`. */
package/dist/sessions.js CHANGED
@@ -17,6 +17,10 @@ export function agentSpec(spec) {
17
17
  ...(spec.outputReservation === undefined ? {} : { outputReservation: spec.outputReservation }),
18
18
  ...(spec.effort === undefined ? {} : { effort: spec.effort }),
19
19
  ...(spec.label === undefined ? {} : { label: spec.label }),
20
+ ...(spec.preferences === undefined ? {} : { preferences: {
21
+ ...(spec.preferences.reasoningEffort === undefined ? {} : { reasoning_effort: spec.preferences.reasoningEffort }),
22
+ ...(spec.preferences.permissionMode === undefined ? {} : { permission_mode: spec.preferences.permissionMode }),
23
+ } }),
20
24
  };
21
25
  }
22
26
  function configureBody(store, key, session, spec) {
@@ -278,6 +282,7 @@ export class Sessions {
278
282
  for (;;) {
279
283
  const wireAfter = after;
280
284
  const wireCeiling = ceiling;
285
+ // The live roster: the Archived window reply (the one with `next.more_above`) is read by its own client.
281
286
  const page = parse(await this.#link.exchange("/v1/list-sessions", (store) => JSON.stringify({
282
287
  version: WIRE_VERSION,
283
288
  kind: "list_sessions",
@@ -288,7 +293,11 @@ export class Sessions {
288
293
  ceiling: wireCeiling,
289
294
  })));
290
295
  for (const row of page.sessions) {
291
- summaries.push({ id: row.reference, label: row.label, state: row.work.state.kind, ...servedWork(row.work), archiveState: row.archive_state, parent: row.parent, creator: row.creator });
296
+ summaries.push({
297
+ id: row.reference, label: row.label, state: row.work.state.kind, ...servedWork(row.work), archiveState: row.archive_state, parent: row.parent, creator: row.creator,
298
+ stateChangeAt: row.state_change_at, subtreeStateChangeAt: row.subtree_state_change_at,
299
+ descendantCount: row.descendant_count, descendantNeedsYouCount: row.descendant_needs_you_count,
300
+ });
292
301
  }
293
302
  if (page.next === null || !("after" in page.next))
294
303
  return summaries.reverse();
@@ -1,4 +1,4 @@
1
- export declare const WIRE_VERSION = "21";
1
+ export declare const WIRE_VERSION = "22";
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 = "21";
3
+ export const WIRE_VERSION = "22";
4
4
  const MAX_REPLY_BYTES = 64 * 1024 * 1024;
5
5
  const RESPONSE_WAIT_MS = 5_000;
6
6
  const TRANSFER_IDLE_MS = 60_000;