@parcha/agentrun-kernel 0.1.0-beta.61 → 0.1.0-beta.62

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/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.62 (2026-11-26)
6
+
7
+ **Breaking:**
8
+
9
+ - A script's file ops on a desktop or a phone need their tool among the agent's tools: `computer.files.read`, `files.list` and `files.stat` need `read`, and `files.write` needs `write`, as before. Naming a desktop no longer grants them: an agent that read files through `computer` without `read` in its `tools` is now refused in words (`computer_op files.read needs read among this agent's tools…`), whatever `read`'s setting says, on every desktop, mounted or not. Add `read` to the agent's `tools` to keep them. `computer_op`'s op list and a script's `computer` declarations offer only the ops the gate would let through: not one whose tool the agent is not given, nor one held to a tool set to deny, nor one held to a tool set to ask where no one can approve, nor one `bash`'s policy refuses whatever its command (`bash` set to deny drops `shell.run` and `processes.start`; the read-only policy drops `processes.start`). Both say that input ops on a computer with a terminal app or a GUI file manager, and `apps.open` with a `file://` URL, can do what a shell or the file ops do, whatever `bash`'s, `read`'s or `write`'s setting. `shell.run` and `processes.start` still follow `bash`'s setting, not a grant, so leaving `read` out keeps no file from an agent that has the shell, paired machines included: on a desktop with exec on, `computer.shell.run` reads and writes any file under `bash`'s setting, which allows by default. `computerDeclarations` takes the ops to leave out, and the kernel exports `withoutOps` for computer_op's definition and `GUI_REACH` for the words. <!-- changes/desktop-file-ops-need-grants.md -->
10
+
11
+ **Changes:**
12
+
13
+ - The parent-watch shim (`parentWatched`'s `shim` watch, used where `setpriv --pdeathsig` is not) takes TERM, INT and HUP before it starts its child. Before, a TERM that reached it in the moment after the child started ended the shim alone and left the child running with nothing watching it: a Claude sign-in stopped as it opened kept its CLI. <!-- changes/kernel-shim-signals-first.md -->
14
+ - A learned workflow call in a run's `workflow_calls` whose rerun was refused now reads `refused` only while every attempt the gate let go was closed by a refusal. One with an attempt left open (a crash cut it before it kept a record, or its record says it ran) reads `failed`, even when a sibling call ran beside it, so its model nodes' spend can't be told for its own: its `usd` is null there, and null for an attempt cut after the refused record. Before, it read `refused` at $0. A CLI's own side request on another model (its title or summary helper) inside a refused call's window no longer flips the call to `failed`. A tool that nests calls, issued again after an earlier attempt fixed a value or nested a call, is now asked at the gate as `replayed`. <!-- changes/workflow-calls-window.md -->
15
+
5
16
  ## 0.1.0-beta.59 (2026-11-25)
6
17
 
7
18
  **Breaking:**
@@ -26,7 +26,9 @@ if (!Number.isSafeInteger(parent) || parent < 1 || (graceAsked && termGraceMs ==
26
26
  // Started after the host was already gone: nothing to run for.
27
27
  if (process.ppid !== parent)
28
28
  process.exit(1);
29
- const child = spawn(command, args, { stdio: "inherit" });
29
+ // The signals are taken before the child is started: a handler runs on a later turn of the loop, once spawn has
30
+ // returned, so a TERM that lands as the child starts is passed on to it. Taken after, such a TERM would end this process
31
+ // alone, with its child left running and nothing watching it.
30
32
  const passed = ["SIGTERM", "SIGINT", "SIGHUP"];
31
33
  let grace;
32
34
  for (const signal of passed) {
@@ -36,6 +38,7 @@ for (const signal of passed) {
36
38
  grace ??= setTimeout(() => child.kill("SIGKILL"), termGraceMs);
37
39
  });
38
40
  }
41
+ const child = spawn(command, args, { stdio: "inherit" });
39
42
  child.on("error", (error) => {
40
43
  process.stderr.write(`parent-watch: ${error.message}\n`);
41
44
  process.exit(127);
@@ -5,5 +5,6 @@ export declare const COMPUTER_TOOL_SCHEMAS: {
5
5
  /** computer_act's steps as TypeScript, for its description: its schema types them, with no words. */
6
6
  export declare const ACT_STEPS = "type UiStep = { press: UiRef; } | { set: UiRef; value: string; } | { perform: UiRef; action: string; } | { click: UiRef | Point; button?: \"left\" | \"right\"; count?: 1 | 2 | 3; } | { type: string; into?: UiRef; } | { key: string; } | { nav: \"back\" | \"home\" | \"app_switch\"; } | { scroll: UiRef | Point; dx?: number; dy?: number; } | { drag: Point[]; ms?: number; }; type UiRef = string; type Point = [ x: number, y: number ];";
7
7
  /** The declarations a script on a computer with these groups reads: the types its members reach, Computer with only
8
- * the members its groups offer, and `declare const computer`, one line each. */
9
- export declare function computerDeclarations(groups: readonly string[]): string;
8
+ * the members its groups offer, less each op in `without` (a member left with none goes), and
9
+ * `declare const computer`, one line each. */
10
+ export declare function computerDeclarations(groups: readonly string[], without?: readonly string[]): string;
@@ -504,7 +504,8 @@ const TYPES = [
504
504
  "text": "interface FileInfo { path: string; type: FileType; size: number; mtimeMs: number; }"
505
505
  }
506
506
  ];
507
- /** Computer's members, each with the groups it needs one of and the types it names. */
507
+ /** Computer's members, each with the groups it needs one of: one that is an object of methods as its ops, put back
508
+ * together after `open` (its text up to the object's `{`); any other with the types it names and its text. */
508
509
  const MEMBERS = [
509
510
  {
510
511
  "uses": [
@@ -516,10 +517,21 @@ const MEMBERS = [
516
517
  "groups": [
517
518
  "apps"
518
519
  ],
519
- "uses": [
520
- "AppInfo"
521
- ],
522
- "text": "readonly apps: { list(): Promise<{ apps: AppInfo[]; foreground: string | null; }>; open(id: string, options?: { url?: string; background?: boolean; }): Promise<void>; };"
520
+ "open": "readonly apps: {",
521
+ "ops": [
522
+ {
523
+ "op": "apps.list",
524
+ "uses": [
525
+ "AppInfo"
526
+ ],
527
+ "text": "list(): Promise<{ apps: AppInfo[]; foreground: string | null; }>;"
528
+ },
529
+ {
530
+ "op": "apps.open",
531
+ "uses": [],
532
+ "text": "open(id: string, options?: { url?: string; background?: boolean; }): Promise<void>;"
533
+ }
534
+ ]
523
535
  },
524
536
  {
525
537
  "groups": [
@@ -534,11 +546,17 @@ const MEMBERS = [
534
546
  "groups": [
535
547
  "screen"
536
548
  ],
537
- "uses": [
538
- "Rect",
539
- "Image"
540
- ],
541
- "text": "readonly screen: { shot(options?: { region?: Rect; }): Promise<Image>; };"
549
+ "open": "readonly screen: {",
550
+ "ops": [
551
+ {
552
+ "op": "screen.shot",
553
+ "uses": [
554
+ "Rect",
555
+ "Image"
556
+ ],
557
+ "text": "shot(options?: { region?: Rect; }): Promise<Image>;"
558
+ }
559
+ ]
542
560
  },
543
561
  {
544
562
  "groups": [
@@ -546,42 +564,91 @@ const MEMBERS = [
546
564
  "input.touch",
547
565
  "input.keys"
548
566
  ],
549
- "uses": [
550
- "InputAction",
551
- "InputResult"
552
- ],
553
- "text": "readonly input: { act(actions: InputAction[]): Promise<InputResult>; };"
567
+ "open": "readonly input: {",
568
+ "ops": [
569
+ {
570
+ "op": "input.act",
571
+ "uses": [
572
+ "InputAction",
573
+ "InputResult"
574
+ ],
575
+ "text": "act(actions: InputAction[]): Promise<InputResult>;"
576
+ }
577
+ ]
554
578
  },
555
579
  {
556
580
  "groups": [
557
581
  "exec"
558
582
  ],
559
- "uses": [
560
- "RunResult"
561
- ],
562
- "text": "readonly shell: { run(command: string | string[], options?: { cwd?: string; timeoutMs?: number; env?: Record<string, string>; }): Promise<RunResult>; };"
583
+ "open": "readonly shell: {",
584
+ "ops": [
585
+ {
586
+ "op": "shell.run",
587
+ "uses": [
588
+ "RunResult"
589
+ ],
590
+ "text": "run(command: string | string[], options?: { cwd?: string; timeoutMs?: number; env?: Record<string, string>; }): Promise<RunResult>;"
591
+ }
592
+ ]
563
593
  },
564
594
  {
565
595
  "groups": [
566
596
  "processes"
567
597
  ],
568
- "uses": [],
569
- "text": "readonly processes: { start(command: string | string[], options?: { cwd?: string; env?: Record<string, string>; }): Promise<{ pid: number; }>; };"
598
+ "open": "readonly processes: {",
599
+ "ops": [
600
+ {
601
+ "op": "processes.start",
602
+ "uses": [],
603
+ "text": "start(command: string | string[], options?: { cwd?: string; env?: Record<string, string>; }): Promise<{ pid: number; }>;"
604
+ }
605
+ ]
570
606
  },
571
607
  {
572
608
  "groups": [
573
609
  "files"
574
610
  ],
575
- "uses": [
576
- "FileInfo"
577
- ],
578
- "text": "readonly files: { read(path: string, options?: { encoding?: \"utf8\" | \"base64\"; }): Promise<string>; write(path: string, data: string, options?: { encoding?: \"utf8\" | \"base64\"; }): Promise<void>; list(path: string): Promise<FileInfo[]>; stat(path: string): Promise<FileInfo>; };"
611
+ "open": "readonly files: {",
612
+ "ops": [
613
+ {
614
+ "op": "files.read",
615
+ "uses": [],
616
+ "text": "read(path: string, options?: { encoding?: \"utf8\" | \"base64\"; }): Promise<string>;"
617
+ },
618
+ {
619
+ "op": "files.write",
620
+ "uses": [],
621
+ "text": "write(path: string, data: string, options?: { encoding?: \"utf8\" | \"base64\"; }): Promise<void>;"
622
+ },
623
+ {
624
+ "op": "files.list",
625
+ "uses": [
626
+ "FileInfo"
627
+ ],
628
+ "text": "list(path: string): Promise<FileInfo[]>;"
629
+ },
630
+ {
631
+ "op": "files.stat",
632
+ "uses": [
633
+ "FileInfo"
634
+ ],
635
+ "text": "stat(path: string): Promise<FileInfo>;"
636
+ }
637
+ ]
579
638
  }
580
639
  ];
581
640
  /** The declarations a script on a computer with these groups reads: the types its members reach, Computer with only
582
- * the members its groups offer, and `declare const computer`, one line each. */
583
- export function computerDeclarations(groups) {
584
- const members = MEMBERS.filter((member) => member.groups === undefined || member.groups.some((group) => groups.includes(group)));
641
+ * the members its groups offer, less each op in `without` (a member left with none goes), and
642
+ * `declare const computer`, one line each. */
643
+ export function computerDeclarations(groups, without = []) {
644
+ const members = MEMBERS.flatMap((member) => {
645
+ if (member.groups !== undefined && !member.groups.some((group) => groups.includes(group)))
646
+ return [];
647
+ if (!("ops" in member))
648
+ return [member];
649
+ const kept = member.ops.filter((one) => !without.includes(one.op));
650
+ return kept.length === 0 ? [] : [{ uses: kept.flatMap((one) => one.uses), text: `${member.open} ${kept.map((one) => one.text).join(" ")} };` }];
651
+ });
585
652
  const uses = new Map(TYPES.map((type) => [type.name, type.uses]));
586
653
  const reached = new Set();
587
654
  const visit = (name) => {
@@ -15,11 +15,20 @@ export declare const unsavedScreenshot: <T extends {
15
15
  readonly description: string;
16
16
  readonly parameters: object;
17
17
  }>(def: T) => T;
18
+ /** What every offer of a computer's ops says of its screen: leaving bash, read or write out does not keep a script from
19
+ * a terminal app, a file manager, or an app opened on a file:// URL. */
20
+ export declare const GUI_REACH = "Input ops on a computer with a terminal app or a GUI file manager, and apps.open with a file:// URL, can do what a shell or the file ops do, whatever bash's, read's or write's setting.";
18
21
  /** The ops computer_op runs on a computer with `groups`. */
19
22
  export declare function computerOpsFor(groups: readonly string[]): readonly string[];
20
23
  /** The tools a computer with `groups` offers: observe and act with the ui group, or a screen (observe) and input (act)
21
24
  * without it; the screenshot with a screen; computer_op with any op past those (computerOpsFor). */
22
25
  export declare function computerToolsFor(groups: readonly string[]): readonly string[];
26
+ /** computer_op's definition `def` for a run whose gate refuses the ops `without` (its agent is not given their tool):
27
+ * its words and its op list name only the others. */
28
+ export declare const withoutOps: <T extends {
29
+ readonly description: string;
30
+ readonly parameters: object;
31
+ }>(def: T, without: readonly string[]) => T;
23
32
  /** The computer's tools in `kind`, under its settings key, for a computer with `groups`. An act or an op changes the
24
33
  * computer: never replayed. */
25
34
  export declare function computerToolDefs(kind: CapabilityKind, groups: readonly string[]): readonly ToolDef[];
@@ -61,7 +61,23 @@ function savePathOf(given) {
61
61
  throw new Error(`save_as names a .png file: not ${JSON.stringify(given)}`);
62
62
  return path;
63
63
  }
64
- const OP = `One of the computer's ops no other tool runs, as a script's \`computer\` calls it: input.act {actions}, apps.list, apps.open {id, url?, background?}, shell.run {command, cwd?, env?, timeoutMs?}, processes.start {command, cwd?, env?}, files.read {path, encoding?}, files.write {path, data, encoding?}, files.list {path}, files.stat {path}. An op this computer does not offer is refused.`;
64
+ /** Each op's arguments, as computer_op's words give them (none: it takes none). */
65
+ const OP_ARGS = Object.freeze({
66
+ "input.act": "{actions}",
67
+ "apps.open": "{id, url?, background?}",
68
+ "shell.run": "{command, cwd?, env?, timeoutMs?}",
69
+ "processes.start": "{command, cwd?, env?}",
70
+ "files.read": "{path, encoding?}",
71
+ "files.write": "{path, data, encoding?}",
72
+ "files.list": "{path}",
73
+ "files.stat": "{path}",
74
+ });
75
+ /** What every offer of a computer's ops says of its screen: leaving bash, read or write out does not keep a script from
76
+ * a terminal app, a file manager, or an app opened on a file:// URL. */
77
+ export const GUI_REACH = "Input ops on a computer with a terminal app or a GUI file manager, and apps.open with a file:// URL, can do what a shell or the file ops do, whatever bash's, read's or write's setting.";
78
+ /** computer_op's words for the ops it offers. */
79
+ const opWords = (ops) => `One of the computer's ops no other tool runs, as a script's \`computer\` calls it: ${ops.map((op) => (OP_ARGS[op] ? `${op} ${OP_ARGS[op]}` : op)).join(", ")}. An op this computer does not offer is refused. ${GUI_REACH}`;
80
+ const OP = opWords(Object.keys(COMPUTER_OPS));
65
81
  /** The ops computer_op runs on a computer with `groups`. */
66
82
  export function computerOpsFor(groups) {
67
83
  return Object.keys(COMPUTER_OPS).filter((op) => COMPUTER_OPS[op].some((group) => groups.includes(group)));
@@ -91,15 +107,22 @@ const def = (kind, name, description, replaySafe, parameters = COMPUTER_TOOL_SCH
91
107
  parameters,
92
108
  replaySafe,
93
109
  });
94
- /** computer_op's parameters: the op, and its arguments as a script's `computer` gives them. */
95
- const OP_PARAMETERS = {
110
+ /** computer_op's parameters over `ops`: the op, and its arguments as a script's `computer` gives them. */
111
+ const opParameters = (ops) => ({
96
112
  type: "object",
97
113
  properties: {
98
- op: { type: "string", enum: Object.keys(COMPUTER_OPS) },
114
+ op: { type: "string", enum: [...ops] },
99
115
  args: { type: "object", description: "The op's arguments." },
100
116
  },
101
117
  required: ["op"],
102
118
  additionalProperties: false,
119
+ });
120
+ const OP_PARAMETERS = opParameters(Object.keys(COMPUTER_OPS));
121
+ /** computer_op's definition `def` for a run whose gate refuses the ops `without` (its agent is not given their tool):
122
+ * its words and its op list name only the others. */
123
+ export const withoutOps = (def, without) => {
124
+ const ops = Object.keys(COMPUTER_OPS).filter((op) => !without.includes(op));
125
+ return { ...def, description: opWords(ops), parameters: opParameters(ops) };
103
126
  };
104
127
  /** The computer's tools in `kind`, under its settings key, for a computer with `groups`. An act or an op changes the
105
128
  * computer: never replayed. */
@@ -2,7 +2,7 @@ export { BACKGROUND_EXECUTORS, endBackground, NEEDS_A_COMPUTER, NO_SHELL } from
2
2
  export { boundedBash } from "./bash.js";
3
3
  export { bashTimeoutWords, CAPABILITY_KINDS, hostToolDefs } from "./defs.js";
4
4
  export type { ShellPlace, ToolDef } from "./defs.js";
5
- export { COMPUTER_OP_TOOL, COMPUTER_OPS, COMPUTER_TOOLS, computerExecutors, computerOpsFor, computerToolDefs, computerToolsFor, STEP_TOOL_OPS, unsavedScreenshot } from "./computer.js";
5
+ export { COMPUTER_OP_TOOL, COMPUTER_OPS, COMPUTER_TOOLS, computerExecutors, computerOpsFor, computerToolDefs, computerToolsFor, GUI_REACH, STEP_TOOL_OPS, unsavedScreenshot, withoutOps } from "./computer.js";
6
6
  export { COMPUTER_TOOL_SCHEMAS, computerDeclarations } from "./computer-surface.generated.js";
7
7
  export { defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "./gate.js";
8
8
  export type { Permission } from "./gate.js";
@@ -5,7 +5,7 @@
5
5
  export { BACKGROUND_EXECUTORS, endBackground, NEEDS_A_COMPUTER, NO_SHELL } from "./background.js";
6
6
  export { boundedBash } from "./bash.js";
7
7
  export { bashTimeoutWords, CAPABILITY_KINDS, hostToolDefs } from "./defs.js";
8
- export { COMPUTER_OP_TOOL, COMPUTER_OPS, COMPUTER_TOOLS, computerExecutors, computerOpsFor, computerToolDefs, computerToolsFor, STEP_TOOL_OPS, unsavedScreenshot } from "./computer.js";
8
+ export { COMPUTER_OP_TOOL, COMPUTER_OPS, COMPUTER_TOOLS, computerExecutors, computerOpsFor, computerToolDefs, computerToolsFor, GUI_REACH, STEP_TOOL_OPS, unsavedScreenshot, withoutOps } from "./computer.js";
9
9
  export { COMPUTER_TOOL_SCHEMAS, computerDeclarations } from "./computer-surface.generated.js";
10
10
  export { defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "./gate.js";
11
11
  export { answerOf, exitCodeOf, needsKindWords } from "./hands.js";
@@ -124,11 +124,15 @@ export function toolBridge(ctx, tools, options = {}) {
124
124
  };
125
125
  /** A tool that `nests`: asked at the gate as itself, then run with the session's tools as its nested calls, no effect
126
126
  * of its own written. Its error result is its answer; a throw while the drive or the call is aborted (a nested call
127
- * parked, the session let go) halts the drive, as an effect's does, so the harness is never handed a result. */
127
+ * parked, the session let go) halts the drive, as an effect's does, so the harness is never handed a result. Asked
128
+ * as `replayed` when the log holds an effect of an earlier attempt's (a value it fixed, a call nested in it), as a
129
+ * call whose own start is in the log is: that attempt was let go and may have spent. */
128
130
  const runNesting = async (args, callId, signal, nested) => {
129
131
  const aborted = signal ? AbortSignal.any([signal, ctx.signal]) : ctx.signal;
130
132
  if (options.gate) {
131
- const refused = await askGate(options.gate, { callId, tool: tool.name, args: (args ?? {}), ...(nested ? { nested } : {}) }, aborted);
133
+ const under = [`nested:${callId}/`, `${toolKey(callId)}/`];
134
+ const replayed = [...ctx.state().effects.keys()].some((key) => under.some((prefix) => key.startsWith(prefix)));
135
+ const refused = await askGate(options.gate, { callId, tool: tool.name, args: (args ?? {}), ...(replayed ? { replayed: true } : {}), ...(nested ? { nested } : {}) }, aborted);
132
136
  if (refused)
133
137
  return { text: refused.deny, isError: true, refused: true };
134
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-kernel",
3
- "version": "0.1.0-beta.61",
3
+ "version": "0.1.0-beta.62",
4
4
  "description": "Agent harnesses other than Pi, starting with Codex, behind one seam: a DSL node's runNode and an AgentRun run on a harness adapter, durable in AgentRun's own store.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -62,7 +62,7 @@
62
62
  "test": "node --test --test-concurrency=8 'test/*.test.mjs'"
63
63
  },
64
64
  "dependencies": {
65
- "@parcha/agentrun-dsl": "0.1.0-beta.61",
65
+ "@parcha/agentrun-dsl": "0.1.0-beta.62",
66
66
  "ajv": "8.18.0",
67
67
  "typebox": "1.3.27"
68
68
  },