@dna113p/machines 0.3.1 → 0.3.2

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
@@ -176,10 +176,10 @@ npm ci
176
176
  npm pack
177
177
  ```
178
178
 
179
- Then install the generated `dna113p-machines-0.3.1.tgz` into a project:
179
+ Then install the generated `dna113p-machines-0.3.2.tgz` into a project:
180
180
 
181
181
  ```bash
182
- npm install /absolute/path/to/machines/dna113p-machines-0.3.1.tgz
182
+ npm install /absolute/path/to/machines/dna113p-machines-0.3.2.tgz
183
183
  npx machine list
184
184
  ```
185
185
 
@@ -177,7 +177,7 @@ export class MachineSession {
177
177
  }
178
178
  async start(input) {
179
179
  // This server publishes its runs itself, so that they also take responses through their inbox.
180
- const run = await this.#session.start({ ...parse(startInput, input), publishRunStatus: false });
180
+ const run = await this.#session.start({ ...parse(startInput, input), publishRunStatus: "caller" });
181
181
  return result(`Started ${run.machine}.\nRun id: ${run.id}\nStatus: ${run.status}`, { run });
182
182
  }
183
183
  status(input) {
@@ -11,8 +11,13 @@ export interface MachineHostOptions extends PrepareMachineRunOptions {
11
11
  readonly label?: string;
12
12
  /** The session that owns the run in its published run status. The environment's owner applies when absent. */
13
13
  readonly owner?: string;
14
- /** Set to false by a caller that publishes the run's status itself, as the MCP server does. */
15
- readonly publishRunStatus?: boolean;
14
+ /**
15
+ * Asks for the run's status to be published where run-status publication is on.
16
+ * `true`: this host publishes it. `"caller"`: the caller publishes it itself,
17
+ * under the run's id, as the MCP server does. Absent: nothing about the run is
18
+ * published or handed down, and the caller presents the run in its own way.
19
+ */
20
+ readonly publishRunStatus?: boolean | "caller";
16
21
  readonly onAgentUpdate?: (update: AgentUpdate) => void;
17
22
  readonly onHumanRequest?: (request: HostedHumanRequest) => void;
18
23
  readonly onState?: (state: StateValue) => void;
package/dist/src/host.js CHANGED
@@ -118,7 +118,9 @@ export function startMachineHost(options) {
118
118
  // below), so a reader that finds the pid gone rightly shows the run as lost.
119
119
  const id = randomUUID();
120
120
  const publication = runStatusDirectory() !== undefined;
121
- const publishes = publication && options.publishRunStatus !== false;
121
+ // An embedding program has to ask: its environment alone must not make its runs appear elsewhere.
122
+ const publishes = publication && options.publishRunStatus === true;
123
+ const recorded = publishes || (publication && options.publishRunStatus === "caller");
122
124
  let published;
123
125
  const child = fork(fileURLToPath(import.meta.url), [childArgument], {
124
126
  cwd,
@@ -322,7 +324,7 @@ export function startMachineHost(options) {
322
324
  ...(options.agents === undefined ? {} : { agents: options.agents }),
323
325
  ...(options.home === undefined ? {} : { home: options.home }),
324
326
  // A caller that publishes the record itself still publishes it under this id.
325
- ...(publication ? { runId: id } : {}),
327
+ ...(recorded ? { runId: id } : {}),
326
328
  ...(publishes ? { reportStatus: true } : {}),
327
329
  };
328
330
  void sendChild(child, launch).catch((cause) => fail(asError(cause)));
@@ -108,7 +108,7 @@ session `respond` path as its tool, and inbox questions through the session's
108
108
  `ask`. The inbox is a second way to deliver a response to the owning run, not a
109
109
  second owner: the run still validates the request ID and choices, and a response
110
110
  to any other request is discarded. A run hosted directly through
111
- `startMachineHost` publishes its status without an inbox: its host remains the
111
+ `startMachineHost` publishes its status only when its host asks, and without an inbox: its host remains the
112
112
  only way to answer it, its record says so, and `machine respond` refuses it. See
113
113
  [Integrations](integrations.md#answering-a-waiting-run-from-outside).
114
114
 
@@ -199,8 +199,11 @@ choice to publish that text. `machine run` exports its run id as
199
199
  records that id as `parent`; the status line shows only top-level runs.
200
200
 
201
201
  A run hosted through `startMachineHost` from `@dna113p/machines/host` publishes
202
- the same record when the variable is set in the hosting process, for example a
203
- daemon that runs tickets, or Pi with the extension loaded. Two options replace the environment for that one run:
202
+ the same record when its host asks with `publishRunStatus: true` and the
203
+ variable is set in the hosting process, as a daemon that runs tickets does. A
204
+ host that does not ask publishes nothing, whatever its environment says: a
205
+ program that presents its runs itself, such as Pi with the extension loaded, is
206
+ not changed by the variable. Two options replace the environment for that one run:
204
207
  `label`, shortened as `MACHINES_RUN_LABEL` is, and `owner`. When an option is
205
208
  absent the environment rule above applies; an empty one publishes the run
206
209
  without that field. The run exports its id as `MACHINES_RUN_PARENT` to its
@@ -216,7 +219,8 @@ only through the host's own `respond` and `ask`: the run reads no inbox, its
216
219
  `human` has no `requestId`, and `machine respond` refuses it. The field is absent
217
220
  from every other record and did not exist in earlier version 2 records. A caller
218
221
  that publishes its own record for the run, as the MCP server does so that its
219
- runs keep their inbox, passes `publishRunStatus: false`.
222
+ runs keep their inbox, passes `publishRunStatus: "caller"`: the host then writes
223
+ nothing, and the run still hands its id down to the runs it starts.
220
224
 
221
225
  While an Agent state waits for a [usage limit](authoring.md#usage-limits) to
222
226
  reset, the record stays `running` and carries the wait in `limit`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dna113p/machines",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Reusable workflows coordinating agents, local operations, and human decisions.",
5
5
  "license": "MIT",
6
6
  "repository": {