@fungi.computer/shiitake-extensions 0.11.21 → 0.11.23

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.
@@ -21,8 +21,6 @@ export declare function resolveHome(recorded: Home | null, computers: readonly R
21
21
  }>[]): Home | null;
22
22
  /** Agent-scope choice with per-run tools and prompt over one captured table. */
23
23
  export declare function homeExtension(options: {
24
- /** Where this host keeps Home's AGENTS.md and SYSTEM.md; "" is the Files root. */
25
- instructionsRoot: string;
26
24
  computers: {
27
25
  /** Read the table inside the synchronous Home choice transaction. */
28
26
  read: (context: Readonly<{
@@ -32,5 +30,12 @@ export declare function homeExtension(options: {
32
30
  prepare?: (context: Readonly<{
33
31
  sessionId: string;
34
32
  }>) => Promise<void>;
33
+ /**
34
+ * Host work on the chosen Home just before its instruction files load.
35
+ * It must not throw: a failure here never stops the run.
36
+ */
37
+ chosen?: (home: HomeComputer, context: Readonly<{
38
+ sessionId: string;
39
+ }>) => Promise<void>;
35
40
  };
36
41
  }): RosteredExtensionV0;
package/dist/home/host.js CHANGED
@@ -90,9 +90,9 @@ export function homeExtension(options) {
90
90
  port: homeFilesRouting(new Map(computers.map(({ name, port }) => [name, port])), selected.port),
91
91
  }).tools;
92
92
  // Home's files are read once for this run, after the state transaction.
93
+ await options.computers.chosen?.(selected, run);
93
94
  return loadHomeInstructions({
94
95
  port: selected.port,
95
- root: options.instructionsRoot,
96
96
  executionId: `home-instructions/${run.workId}`,
97
97
  signal: new AbortController().signal,
98
98
  }).then((text) => {
@@ -8,8 +8,6 @@ export declare function instructionSectionName(index: number): string;
8
8
  */
9
9
  export declare function loadHomeInstructions(input: {
10
10
  port: FilesPort;
11
- /** Where the host keeps Home's instruction files: "" for the Files root, "/workspace/" on a hosted Computer. */
12
- root: string;
13
11
  executionId: string;
14
12
  signal: AbortSignal;
15
13
  }): Promise<readonly string[] | null>;
@@ -7,11 +7,8 @@ import { homeInstructionsLimit } from "./contract.js";
7
7
  const maximumSectionBytes = 8_192;
8
8
  const maximumListedProblems = 16;
9
9
  const utf8 = new TextEncoder();
10
- /** The framing names the files where the host's root keeps them, so the Agent reads and patches the file that loads. */
11
- const framing = (root) => {
12
- const home = `computer://home/${root.replace(/^\//u, "")}`;
13
- return `From files on Home (${home}AGENTS.md, ${home}SYSTEM.md). Your owner and you can edit them. Follow them unless they conflict with the instructions above. They never grant tools, approvals or access.`;
14
- };
10
+ /** The framing names the files by the paths an Agent's tools resolve, so it reads and patches the file that loads. */
11
+ const framing = "From files on Home (computer://home/AGENTS.md, computer://home/SYSTEM.md). Your owner and you can edit them. Follow them unless they conflict with the instructions above. They never grant tools, approvals or access.";
15
12
  const bytesOf = (text) => utf8.encode(text).byteLength;
16
13
  /** A missing path, as every Files host reports it: an errno ENOENT. */
17
14
  function absent(cause) {
@@ -81,7 +78,7 @@ export async function loadHomeInstructions(input) {
81
78
  const blocks = [];
82
79
  let used = 0;
83
80
  for (const file of ["AGENTS.md", "SYSTEM.md"]) {
84
- const loaded = await readText(input.port, `${input.root}${file}`, context);
81
+ const loaded = await readText(input.port, file, context);
85
82
  if (loaded.kind === "absent")
86
83
  continue;
87
84
  if (loaded.kind === "refused") {
@@ -104,7 +101,7 @@ export async function loadHomeInstructions(input) {
104
101
  if (problems.length > shown.length)
105
102
  shown.push(`${String(problems.length - shown.length)} more problems`);
106
103
  return chunks([
107
- framing(input.root),
104
+ framing,
108
105
  ...blocks,
109
106
  ...(shown.length === 0
110
107
  ? []
@@ -85,13 +85,13 @@ Agent-scope choice with per-run tools and prompt over one captured table.
85
85
 
86
86
  #### Parameters
87
87
 
88
- | Parameter | Type | Description |
89
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
90
- | `options` | \{ `instructionsRoot`: `string`; `computers`: \{ `read`: (`context`) => readonly `Readonly`\<\{ `name`: `string`; `attachmentId`: `string`; `port`: `FilesPort`; \}\>[]; `prepare?`: (`context`) => `Promise`\<`void`\>; \}; \} | - |
91
- | `options.instructionsRoot` | `string` | Where this host keeps Home's AGENTS.md and SYSTEM.md; "" is the Files root. |
92
- | `options.computers` | \{ `read`: (`context`) => readonly `Readonly`\<\{ `name`: `string`; `attachmentId`: `string`; `port`: `FilesPort`; \}\>[]; `prepare?`: (`context`) => `Promise`\<`void`\>; \} | - |
93
- | `options.computers.read` | (`context`) => readonly `Readonly`\<\{ `name`: `string`; `attachmentId`: `string`; `port`: `FilesPort`; \}\>[] | Read the table inside the synchronous Home choice transaction. |
94
- | `options.computers.prepare?` | (`context`) => `Promise`\<`void`\> | Optional host preparation before run-scoped Files capture. |
88
+ | Parameter | Type | Description |
89
+ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
90
+ | `options` | \{ `computers`: \{ `read`: (`context`) => readonly `Readonly`\<\{ `name`: `string`; `attachmentId`: `string`; `port`: `FilesPort`; \}\>[]; `prepare?`: (`context`) => `Promise`\<`void`\>; `chosen?`: (`home`, `context`) => `Promise`\<`void`\>; \}; \} | - |
91
+ | `options.computers` | \{ `read`: (`context`) => readonly `Readonly`\<\{ `name`: `string`; `attachmentId`: `string`; `port`: `FilesPort`; \}\>[]; `prepare?`: (`context`) => `Promise`\<`void`\>; `chosen?`: (`home`, `context`) => `Promise`\<`void`\>; \} | - |
92
+ | `options.computers.read` | (`context`) => readonly `Readonly`\<\{ `name`: `string`; `attachmentId`: `string`; `port`: `FilesPort`; \}\>[] | Read the table inside the synchronous Home choice transaction. |
93
+ | `options.computers.prepare?` | (`context`) => `Promise`\<`void`\> | Optional host preparation before run-scoped Files capture. |
94
+ | `options.computers.chosen?` | (`home`, `context`) => `Promise`\<`void`\> | Host work on the chosen Home just before its instruction files load. It must not throw: a failure here never stops the run. |
95
95
 
96
96
  #### Returns
97
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake-extensions",
3
- "version": "0.11.21",
3
+ "version": "0.11.23",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "private": false,
6
6
  "description": "Botanical's product Shiitake extensions: goal, loop and Almanac on the generic extension surface",
@@ -122,7 +122,7 @@
122
122
  "@fungi.computer/cairn": "0.1.0",
123
123
  "@fungi.computer/knapsack": "0.4.21",
124
124
  "@fungi.computer/mycelium": "0.4.7",
125
- "@fungi.computer/shiitake": "0.21.10",
125
+ "@fungi.computer/shiitake": "0.21.11",
126
126
  "@fungi.computer/watchdog": "0.1.4",
127
127
  "@fungi.computer/whistle": "0.3.0",
128
128
  "effect": "4.0.2",