@opensoftware/foreman 0.2.0 → 0.3.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
@@ -8,7 +8,8 @@ Run the factory's workflow for each work item: the stages of `factory.yaml` one
8
8
  through the harness port, with human gates, steering and cancel, on Temporal. A run survives a restart of the
9
9
  foreman, and Temporal's UI shows its history. Decisions: [ADR 0067](../../docs/decisions/0067-foreman.md), on
10
10
  [ADR 0004](../../docs/decisions/0004-temporal.md), [ADR 0068](../../docs/decisions/0068-foreman-sandboxes.md) for
11
- sandboxes, and [ADR 0069](../../docs/decisions/0069-foreman-checks.md) for checks.
11
+ sandboxes, [ADR 0069](../../docs/decisions/0069-foreman-checks.md) for checks, and
12
+ [ADR 0070](../../docs/decisions/0070-foreman-gateway-and-take-over.md) for the inference gateway and take over.
12
13
 
13
14
  ## Quick start
14
15
 
@@ -198,6 +199,82 @@ The forge adapter is the one the factory names under `providers.forge`; a factor
198
199
  `npx -y @opensoftware/forge-<name>`. It gets `FORGE_URL` and `FORGE_TOKEN` from `FOREMAN_FORGE_URL` and
199
200
  `FOREMAN_FORGE_TOKEN`.
200
201
 
202
+ ## Inference gateway
203
+
204
+ Give the factory's agents one model endpoint with a budget per run: name an
205
+ [inference adapter](../../ports/inference/README.md) under `providers.inference` and its config under `inference`.
206
+ This factory runs the [LiteLLM gateway](../../adapters/inference/litellm/README.md) on Docker and lets a run spend at
207
+ most 5 USD:
208
+
209
+ ```yaml gateway/factory.yaml
210
+ version: 1
211
+ factory: hello
212
+ providers:
213
+ harness:
214
+ acp: "^0"
215
+ inference:
216
+ litellm: "^0"
217
+ inference:
218
+ config: ./inference/litellm.yaml
219
+ budget: 5
220
+ agents:
221
+ plan:
222
+ harness: acp
223
+ model: routes/default
224
+ prompt: ./agents/plan.md
225
+ implement:
226
+ harness: acp
227
+ model: routes/default
228
+ prompt: ./agents/implement.md
229
+ workflow:
230
+ - stage: plan
231
+ - stage: implement
232
+ ```
233
+
234
+ ```yaml inference/litellm.yaml
235
+ model_list:
236
+ - model_name: routes/default
237
+ litellm_params:
238
+ model: anthropic/claude-sonnet-5-5
239
+ api_key: os.environ/OSF_SECRET_ANTHROPIC_API_KEY
240
+ ```
241
+
242
+ Serve it as in the quick start, with `export OSF_SECRET_ANTHROPIC_API_KEY=…` for the adapter. Then:
243
+
244
+ 1. `foreman serve` runs the adapter's `start` with the config, a path relative to `factory.yaml`, before it takes work,
245
+ and `stop` when it stops. A `start` that fails stops the server with exit code 1 and the adapter's message.
246
+ 2. Before a run's first stage, the foreman asks the adapter for the run's key: `key <gateway> <run ID> --budget 5`. The
247
+ gateway refuses the run's calls once it spent its budget. The key stays in the foreman's memory, not in Temporal.
248
+ 3. Each stage's harness adapter gets the gateway in the variables that the harness adapters read: `OPENAI_BASE_URL`
249
+ (the URL `start` printed) and `ANTHROPIC_BASE_URL` (the same without `/v1`), `OPENAI_API_KEY` and
250
+ `ANTHROPIC_API_KEY` (the run's key), and `OPENAI_MODEL` and `ANTHROPIC_MODEL` (the agent's `model`, a routing
251
+ alias of the config). A sandboxed stage gets them in its sandbox's environment.
252
+
253
+ `FOREMAN_INFERENCES` maps an adapter's name to its command line; an adapter it does not name runs
254
+ `npx -y @opensoftware/inference-<name>`. A factory names at most one inference adapter. Without one, the foreman sets
255
+ none of these variables, and each harness adapter calls the model API it is configured for.
256
+
257
+ ## Take over
258
+
259
+ A person can take a running stage over from its agent and hand the run back later
260
+ ([ADR 0070](../../docs/decisions/0070-foreman-gateway-and-take-over.md)):
261
+
262
+ ```sh
263
+ curl -H "Authorization: Bearer dev-token" -H "content-type: application/json" \
264
+ --data '{"type": "take-over"}' http://localhost:8080/v1/runs/run_…/signals
265
+ ```
266
+
267
+ 1. The running stage's agent ends its turn within `FOREMAN_POLL_MS`. A sandboxed stage copies its files out and
268
+ destroys its sandbox, as after every turn.
269
+ 2. The stage is `blocked` with `takenOverAt`, and the run is `blocked` with `folder`: the run's folder on the foreman's
270
+ machine, which holds the stage's files. The stage's `sessionId`, the run's `pullRequest` and the work item are the
271
+ rest of the context.
272
+ 3. The person works in that folder, then posts `{"type": "hand-back"}`. The stage is `succeeded`, and the next stage
273
+ starts from the files in the folder, or the run is `complete` after the last stage.
274
+
275
+ A take-over needs a running stage, and a hand-back a stage that a person took over; otherwise the answer is 409. A
276
+ cancel ends a run that a person took over.
277
+
201
278
  ## Commands
202
279
 
203
280
  | Command | What it does |
@@ -209,18 +286,18 @@ The forge adapter is the one the factory names under `providers.forge`; a factor
209
286
  | Route | What it does |
210
287
  | --- | --- |
211
288
  | `POST /v1/runs` | Start the run of a work item (the [work item](../../contracts/work-item/work-item.schema.json) format). 201 with the new run, 200 with the run the same work item started before, 400 with a problem that names the field. |
212
- | `GET /v1/runs/{runId}` | The run: `state`, `factory`, `factoryVersion`, `pullRequest`, `startedAt`, `endedAt` and its `stages`. 404 for a run the server does not know. |
213
- | `POST /v1/runs/{runId}/signals` | `{ "type": "steer", "message": "…" }` sends the message to the running stage's agent; `{ "type": "cancel" }` cancels the run. 202 with the run, 409 when the run ended. |
289
+ | `GET /v1/runs/{runId}` | The run: `state`, `factory`, `factoryVersion`, `pullRequest`, `folder`, `startedAt`, `endedAt` and its `stages`. 404 for a run the server does not know. |
290
+ | `POST /v1/runs/{runId}/signals` | `{ "type": "steer", "message": "…" }` sends the message to the running stage's agent; `{ "type": "cancel" }` cancels the run; `{ "type": "take-over" }` and `{ "type": "hand-back" }` hand the running stage to a person and back ([Take over](#take-over)). 202 with the run, 409 when the run ended or the signal does not fit its state. |
214
291
 
215
292
  The OpenAPI of the routes is in [`contracts/openapi/openapi.json`](../../contracts/openapi/openapi.json); the
216
293
  TypeScript type `paths` of `@opensoftware/contracts` types a client. Every route needs `Authorization: Bearer
217
294
  <FOREMAN_API_TOKEN>`, else 401. Errors are `application/problem+json` with `title`, `status` and `detail`.
218
295
 
219
296
  A run's ID is `run_` and 20 hex digits of the SHA-256 of the work item's ID, so a work item has one run. A run is
220
- `running`, `blocked` (at a gate or waiting for checks), `complete`, `failed` or `cancelled`. A stage is `pending`,
297
+ `running`, `blocked` (at a gate, waiting for checks, or taken over by a person), `complete`, `failed` or `cancelled`. A stage is `pending`,
221
298
  `blocked`, `running`, `succeeded`, `failed`, `rejected` (by its gate) or `cancelled`; it has its harness `sessionId` once
222
- it started, its `gateId` once its gate was asked, its `checks` once they were read, and a `reason` when it failed for a
223
- reason the foreman knows.
299
+ it started, its `gateId` once its gate was asked, its `checks` once they were read, its `takenOverAt` once a person
300
+ took it over, and a `reason` when it failed for a reason the foreman knows.
224
301
 
225
302
  ## How a run goes
226
303
 
@@ -235,7 +312,8 @@ reason the foreman knows.
235
312
  the agent's prompt file, then the work item's ID, title and description. It allows the tool calls the adapter asks
236
313
  about; limit them with the adapter's `--allow`. A turn that ends with `end_turn` succeeds the stage; any other end
237
314
  fails or cancels it, ends the run, and leaves the later stages `pending`. The adapter gets
238
- `OTEL_RESOURCE_ATTRIBUTES` with `osf.run.id`, `osf.work_item.id`, `osf.stage` and `osf.factory.version`.
315
+ `OTEL_RESOURCE_ATTRIBUTES` with `osf.run.id`, `osf.work_item.id`, `osf.stage` and `osf.factory.version`, and the
316
+ factory's inference gateway with the run's key and the agent's model ([Inference gateway](#inference-gateway)).
239
317
  - **Checks.** Before a stage with `checks` starts, the foreman waits until those checks succeeded on the run's pull
240
318
  request; a failing one fails the run ([Checks](#checks)).
241
319
  - **Gates.** Before a stage with a `gate` starts, the foreman asks gatekeeper at `FOREMAN_GATEKEEPER_URL`
@@ -244,7 +322,8 @@ reason the foreman knows.
244
322
  `gate.decided@v1` for that gate arrives on NATS. `approved` starts the stage; `rejected` or `expired` fails the run.
245
323
  - **Signals.** A steering message reaches the running stage's agent within `FOREMAN_POLL_MS` as a prompt in its
246
324
  session, which the harness port treats as steering. A cancel ends the agent's turn, or the wait at a gate, and the
247
- run is `cancelled`.
325
+ run is `cancelled`. A person takes a running stage over and hands the run back with the signals `take-over` and
326
+ `hand-back` ([Take over](#take-over)).
248
327
  - **Restarts.** The runs live in Temporal's history. A foreman that stops and starts again goes on with them; a stage
249
328
  that ran when it stopped runs again, up to 3 times.
250
329
 
@@ -283,6 +362,7 @@ the minor version. The one-time setup is the same as for contracts
283
362
  | `FOREMAN_HARNESSES` | string | `"{}"` | serve: a JSON object from harness name to the command line of its adapter. A harness it does not name runs npx -y @opensoftware/harness-<name> run. |
284
363
  | `FOREMAN_SANDBOXES` | string | `"{}"` | serve: a JSON object from sandbox adapter name to the command line of the adapter. An adapter it does not name runs npx -y @opensoftware/sandbox-<name>. The factory names its adapter under providers.sandbox, docker by default. |
285
364
  | `FOREMAN_FORGES` | string | `"{}"` | serve: a JSON object from forge adapter name to the command line of the adapter. An adapter it does not name runs npx -y @opensoftware/forge-<name>. The factory names its adapter under providers.forge. |
365
+ | `FOREMAN_INFERENCES` | string | `"{}"` | serve: a JSON object from inference adapter name to the command line of the adapter. An adapter it does not name runs npx -y @opensoftware/inference-<name>. The factory names its adapter under providers.inference. |
286
366
  | `FOREMAN_FORGE_URL` | string | | serve: the forge adapter's FORGE_URL, for a factory whose stages have checks. Default: the adapter's own default. |
287
367
  | `FOREMAN_FORGE_TOKEN` | string | | serve: the forge adapter's FORGE_TOKEN: a token that may read the pull requests and their checks. Never written to a file. |
288
368
  | `FOREMAN_CHECK_POLL_MS` | string | `"30000"` | serve: how long a stage that waits for pending checks waits before it reads them again, in milliseconds. |
@@ -346,3 +426,17 @@ the minor version. The one-time setup is the same as for contracts
346
426
  | SCN-FORE-047 | implemented | A run shows its pull request and publishes it when it ends |
347
427
  | SCN-FORE-048 | implemented | A cancel ends a run that waits for a check |
348
428
  | SCN-FORE-049 | implemented | A factory with checks but without a forge adapter stops the server at the start |
429
+ | SCN-FORE-050 | implemented | A stage's agent calls the factory's gateway with the run's key |
430
+ | SCN-FORE-051 | implemented | Each stage's agent calls the gateway with its own model |
431
+ | SCN-FORE-052 | implemented | The foreman starts one gateway from the factory's inference config |
432
+ | SCN-FORE-053 | implemented | Each run gets its own key with the factory's budget |
433
+ | SCN-FORE-054 | implemented | A sandboxed stage gets the gateway in its sandbox's environment |
434
+ | SCN-FORE-055 | implemented | The foreman stops the gateway when it stops serving |
435
+ | SCN-FORE-056 | implemented | A gateway that does not start stops the server at the start |
436
+ | SCN-FORE-057 | implemented | A factory with an inference adapter but without its config stops the server at the start |
437
+ | SCN-FORE-058 | implemented | A person takes over the running stage |
438
+ | SCN-FORE-059 | implemented | The next stage starts from the files of the person who handed the run back |
439
+ | SCN-FORE-060 | implemented | A take-over destroys the stage's sandbox and keeps its files |
440
+ | SCN-FORE-061 | implemented | A take-over of a run without a running stage is refused |
441
+ | SCN-FORE-062 | implemented | A hand-back of a run nobody took over is refused |
442
+ | SCN-FORE-063 | implemented | A cancel ends a run a person took over |
@@ -1,16 +1,9 @@
1
1
  // The run's pull request through the forge port (ADR 0057, ADR 0069). The adapter is a program; the foreman runs its
2
2
  // `pr` command and reads the checks of the pull request's head commit.
3
- import { execFile } from "node:child_process";
3
+ import { adapterRun } from "./program.js";
4
4
  /** The checks of the pull request `<repo>#<number>`; a failure names the adapter's error. */
5
- export function pullRequestChecks(adapter, env, repo, number) {
6
- const [file, ...args] = adapter;
7
- return new Promise((resolve, reject) => {
8
- execFile(file, [...args, "pr", repo, number], { env }, (error, stdout, stderr) => {
9
- if (error)
10
- reject(new Error(`the forge adapter's pr failed: ${stderr.trim() || error.message}`));
11
- else
12
- resolve(JSON.parse(stdout).checks ?? []);
13
- });
14
- });
5
+ export async function pullRequestChecks(adapter, env, repo, number) {
6
+ const printed = await adapterRun("forge", adapter, env)("pr", repo, number);
7
+ return JSON.parse(printed).checks ?? [];
15
8
  }
16
9
  //# sourceMappingURL=forge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"forge.js","sourceRoot":"","sources":["../../src/adapters/forge.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,uEAAuE;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQ9C,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAC/B,OAAiB,EACjB,GAAuC,EACvC,IAAY,EACZ,MAAc;IAEd,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,OAAgC,CAAC;IACzD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAC/E,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;;gBAC5F,OAAO,CAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAiC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"forge.js","sourceRoot":"","sources":["../../src/adapters/forge.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ1C,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAiB,EACjB,GAAuC,EACvC,IAAY,EACZ,MAAc;IAEd,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5E,OAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiC,CAAC,MAAM,IAAI,EAAE,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,14 @@
1
+ // The factory's inference gateway through the inference port (ADR 0056, ADR 0070). The adapter is a program; the
2
+ // foreman starts one gateway while it serves, asks it for a key per run, and stops it at the end.
3
+ import { adapterRun, lastLine } from "./program.js";
4
+ /** Starts a gateway from the adapter's config file. */
5
+ export async function startGateway(adapter, config, env) {
6
+ const run = adapterRun("inference", adapter, env);
7
+ const { id, url } = JSON.parse(lastLine(await run("start", config)));
8
+ return {
9
+ url,
10
+ key: async (runId, budget) => lastLine(await run("key", id, runId, ...(budget === undefined ? [] : ["--budget", String(budget)]))),
11
+ stop: async () => void (await run("stop", id)),
12
+ };
13
+ }
14
+ //# sourceMappingURL=inference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inference.js","sourceRoot":"","sources":["../../src/adapters/inference.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,kGAAkG;AAClG,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUpD,uDAAuD;AACvD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAiB,EACjB,MAAc,EACd,GAAuC;IAEvC,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAClD,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAgC,CAAC;IACpG,OAAO;QACL,GAAG;QACH,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAC3B,QAAQ,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACtG,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ // An adapter of a port that is a program (ADR 0054, ADR 0056): the foreman runs one of its commands and reads what it
2
+ // printed.
3
+ import { execFile } from "node:child_process";
4
+ /**
5
+ * Runs commands of the `port`'s adapter and resolves with what it printed, trimmed; a failure names the port, the command
6
+ * and what the adapter wrote to standard error.
7
+ */
8
+ export function adapterRun(port, adapter, env) {
9
+ const [file, ...args] = adapter;
10
+ return (...command) => new Promise((resolve, reject) => {
11
+ execFile(file, [...args, ...command], { env }, (error, stdout, stderr) => {
12
+ if (error)
13
+ reject(new Error(`the ${port} adapter's ${command[0]} failed: ${stderr.trim() || error.message}`));
14
+ else
15
+ resolve(stdout.trim());
16
+ });
17
+ });
18
+ }
19
+ /** The last line an adapter printed. */
20
+ export const lastLine = (printed) => printed.split("\n").pop();
21
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/adapters/program.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAiB,EAAE,GAAuC;IACjG,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,OAAgC,CAAC;IACzD,OAAO,CAAC,GAAG,OAAiB,EAAE,EAAE,CAC9B,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACvE,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,cAAc,OAAO,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;;gBACzG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAY,CAAC"}
@@ -1,32 +1,20 @@
1
1
  // A stage's sandbox through the sandbox port (ADR 0054, ADR 0068). The adapter is a program; the foreman creates a
2
2
  // sandbox from the spec, copies the run's folder in, runs the harness with exec, copies the folder out and destroys it.
3
- import { execFile } from "node:child_process";
4
3
  import { cpSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
5
4
  import { tmpdir } from "node:os";
6
5
  import { join, posix } from "node:path";
7
- /** Runs one command of the adapter; a failure names the command and what the adapter wrote to standard error. */
8
- function adapterRun(adapter, env) {
9
- const [file, ...args] = adapter;
10
- return (...command) => new Promise((resolve, reject) => {
11
- execFile(file, [...args, ...command], { env }, (error, stdout, stderr) => {
12
- if (error)
13
- reject(new Error(`the sandbox adapter's ${command[0]} failed: ${stderr.trim() || error.message}`));
14
- else
15
- resolve(stdout.trim());
16
- });
17
- });
18
- }
6
+ import { adapterRun, lastLine } from "./program.js";
19
7
  /**
20
8
  * A new sandbox from the spec for the files of `local`, the run's folder, which it holds at `<working folder>/<name>`
21
9
  * after `copyIn`. The caller destroys it.
22
10
  */
23
11
  export async function createSandbox(adapter, spec, local, name, env) {
24
- const run = adapterRun(adapter, env);
12
+ const run = adapterRun("sandbox", adapter, env);
25
13
  const temporary = mkdtempSync(join(tmpdir(), "foreman-sandbox-"));
26
14
  let id;
27
15
  try {
28
16
  writeFileSync(join(temporary, "spec.json"), JSON.stringify(spec));
29
- id = (await run("create", join(temporary, "spec.json"))).split("\n").pop();
17
+ id = lastLine(await run("create", join(temporary, "spec.json")));
30
18
  }
31
19
  finally {
32
20
  rmSync(temporary, { recursive: true, force: true });
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../src/adapters/sandbox.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,wHAAwH;AACxH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAaxC,iHAAiH;AACjH,SAAS,UAAU,CAAC,OAAiB,EAAE,GAAuC;IAC5E,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,OAAgC,CAAC;IACzD,OAAO,CAAC,GAAG,OAAiB,EAAE,EAAE,CAC9B,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACvE,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,OAAO,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;;gBACzG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAiB,EACjB,IAAiB,EACjB,KAAa,EACb,IAAY,EACZ,GAAuC;IAEvC,MA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,CAAC,CAAC;YACtD,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;KACrD,CAAC;AACJ,CAAC"}
@@ -1,11 +1,18 @@
1
- // The runs of the foreman as Temporal workflows (ADR 0067): start one per work item, read its view, signal it.
1
+ // The runs of the foreman as Temporal workflows (ADR 0067): start one per work item, read its view, signal it: steer,
2
+ // cancel, take over and hand back (ADR 0070).
2
3
  import { UsageError } from "@opensoftware/cli";
3
4
  import { validate } from "@opensoftware/contracts";
4
5
  import { WorkflowExecutionAlreadyStartedError, WorkflowIdReusePolicy, WorkflowNotFoundError, } from "@temporalio/client";
5
- import { firstView, hasEnded, runIdOf, signalOf } from "../domain/run.js";
6
- import { factoryRun, gateSignal, steeringQuery, steerSignal, viewQuery } from "../workflows/run.js";
6
+ import { firstView, hasEnded, runIdOf, signalOf, } from "../domain/run.js";
7
+ import { controlQuery, factoryRun, gateSignal, handBackSignal, steerSignal, takeOverSignal, viewQuery, } from "../workflows/run.js";
7
8
  export class Conflict extends Error {
9
+ title;
10
+ constructor(message, title = "The run ended") {
11
+ super(message);
12
+ this.title = title;
13
+ }
8
14
  }
15
+ const NOT_NOW = "The signal does not fit the run's state";
9
16
  function checked(format, document, what) {
10
17
  const problems = validate(format, document);
11
18
  if (problems.length)
@@ -52,13 +59,24 @@ export function runs(options) {
52
59
  if (signal.type === "steer") {
53
60
  await handle(runId).signal(steerSignal, signal.message);
54
61
  }
62
+ else if (signal.type === "take-over") {
63
+ const index = current.stages.findIndex((stage) => stage.state === "running");
64
+ if (index < 0)
65
+ throw new Conflict(`no stage of ${runId} is running`, NOT_NOW);
66
+ await handle(runId).signal(takeOverSignal, index);
67
+ }
68
+ else if (signal.type === "hand-back") {
69
+ if (!current.stages.some((stage) => stage.state === "blocked" && stage.takenOverAt))
70
+ throw new Conflict(`nobody took over ${runId}`, NOT_NOW);
71
+ await handle(runId).signal(handBackSignal);
72
+ }
55
73
  else {
56
74
  await handle(runId).cancel();
57
75
  }
58
76
  return current;
59
77
  },
60
- async steering(runId) {
61
- return handle(runId).query(steeringQuery);
78
+ async control(runId) {
79
+ return handle(runId).query(controlQuery);
62
80
  },
63
81
  async decided(workItemId, decision) {
64
82
  await handle(runIdOf(workItemId)).signal(gateSignal, decision);
@@ -1 +1 @@
1
- {"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/commands/runs.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAiB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAEL,oCAAoC,EACpC,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAqB,QAAQ,EAAgB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEpG,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG;AAatC,SAAS,OAAO,CAAI,MAAc,EAAE,QAAiB,EAAE,IAAY;IACjE,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,MAAM;QACjB,MAAM,IAAI,UAAU,CAClB,GAAG,IAAI,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,IAAI,GAAG,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,C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K,WAAW,EAAE,CAAC;gBACvC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC;oBACjF,MAAM,IAAI,QAAQ,CAAC,oBAAoB,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC3D,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/B,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,KAAK;YACjB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ;YAChC,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,8 +1,8 @@
1
1
  // foreman serve: the run API on PORT and a Temporal worker that runs the factory's workflow (ADR 0067). With
2
- // FOREMAN_NATS_URL it also starts runs for work.received@v1 and passes gate.decided@v1 to the waiting runs. It runs
3
- // until SIGTERM or SIGINT.
2
+ // FOREMAN_NATS_URL it also starts runs for work.received@v1 and passes gate.decided@v1 to the waiting runs. A factory
3
+ // with an inference adapter gets its gateway while the server runs (ADR 0070). It runs until SIGTERM or SIGINT.
4
4
  import { timingSafeEqual } from "node:crypto";
5
- import { resolve } from "node:path";
5
+ import { dirname, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { UsageError } from "@opensoftware/cli";
8
8
  import { Client, Connection } from "@temporalio/client";
@@ -10,6 +10,7 @@ import { NativeConnection, Worker } from "@temporalio/worker";
10
10
  import Fastify, {} from "fastify";
11
11
  import { readFactory } from "../adapters/factory.js";
12
12
  import { gatekeeper } from "../adapters/gatekeeper.js";
13
+ import { startGateway } from "../adapters/inference.js";
13
14
  import { openBus, SUBJECTS } from "../adapters/nats.js";
14
15
  import { isoNow } from "../domain/time.js";
15
16
  import { activities } from "../workflows/activities.js";
@@ -27,7 +28,7 @@ function api(work, token) {
27
28
  if (error instanceof UsageError)
28
29
  return problem(reply, 400, "Bad request", error.message);
29
30
  if (error instanceof Conflict)
30
- return problem(reply, 409, "The run ended", error.message);
31
+ return problem(reply, 409, error.title, error.message);
31
32
  return problem(reply, error.statusCode ?? 500, "The request failed", error.message);
32
33
  });
33
34
  app.addHook("onRequest", async (request, reply) => {
@@ -64,7 +65,7 @@ export async function serve(env) {
64
65
  if (!token)
65
66
  throw new UsageError("set FOREMAN_API_TOKEN: the token that callers of the API send");
66
67
  const factoryPath = resolve(env.FOREMAN_FACTORY || "factory.yaml");
67
- await readFactory(factoryPath);
68
+ const { definition } = await readFactory(factoryPath);
68
69
  const now = () => isoNow(env.OSF_NOW);
69
70
  const warn = (text) => process.stderr.write(`foreman: ${text}\n`);
70
71
  const address = env.FOREMAN_TEMPORAL_ADDRESS || "localhost:7233";
@@ -73,44 +74,60 @@ export async function serve(env) {
73
74
  const taskQueue = env.FOREMAN_TASK_QUEUE || "foreman";
74
75
  const pollMs = Number(env.FOREMAN_POLL_MS || 1000);
75
76
  const bus = env.FOREMAN_NATS_URL ? await openBus(env.FOREMAN_NATS_URL, warn) : undefined;
76
- const client = new Client({ connection: await Connection.connect({ address }), namespace });
77
- const work = runs({ client, taskQueue, factory: () => readFactory(factoryPath), now });
78
- const worker = await Worker.create({
79
- connection: await NativeConnection.connect({ address }),
80
- namespace,
81
- taskQueue,
82
- workflowBundle: { codePath: BUNDLE },
83
- activities: activities({
84
- now,
85
- bus,
86
- gatekeeper: gatekeeper(env.FOREMAN_GATEKEEPER_URL, env.FOREMAN_GATEKEEPER_TOKEN),
87
- harnesses: JSON.parse(env.FOREMAN_HARNESSES || "{}"),
88
- sandboxes: JSON.parse(env.FOREMAN_SANDBOXES || "{}"),
89
- forges: JSON.parse(env.FOREMAN_FORGES || "{}"),
90
- forgeEnv: {
91
- ...(env.FOREMAN_FORGE_URL ? { FORGE_URL: env.FOREMAN_FORGE_URL } : {}),
92
- ...(env.FOREMAN_FORGE_TOKEN ? { FORGE_TOKEN: env.FOREMAN_FORGE_TOKEN } : {}),
93
- },
94
- checkPollMs: Number(env.FOREMAN_CHECK_POLL_MS || 30_000),
95
- data: resolve(env.OSF_DATA || ".foreman"),
96
- pollMs,
97
- steering: (runId) => work.steering(runId),
98
- env,
99
- }),
100
- maxHeartbeatThrottleInterval: pollMs,
101
- defaultHeartbeatThrottleInterval: pollMs,
102
- });
103
- const running = worker.run();
104
- if (bus)
105
- listen(bus, work);
106
- const app = api(work, token);
107
- const port = Number(env.PORT || 8080);
108
- await app.listen({ port, host: "0.0.0.0" });
109
- process.stdout.write(`foreman serves the run API on port ${port}, task queue ${taskQueue} at ${address}\n`);
110
- // Temporal's runtime stops the worker on SIGTERM and SIGINT; the server stops with it.
111
- await running;
112
- await app.close();
113
- await bus?.close();
77
+ const gateway = await gatewayOf(definition.inference, dirname(factoryPath), env);
78
+ // A gateway stops with the server, also when the server cannot start.
79
+ try {
80
+ const client = new Client({ connection: await Connection.connect({ address }), namespace });
81
+ const work = runs({ client, taskQueue, factory: () => readFactory(factoryPath), now });
82
+ const worker = await Worker.create({
83
+ connection: await NativeConnection.connect({ address }),
84
+ namespace,
85
+ taskQueue,
86
+ workflowBundle: { codePath: BUNDLE },
87
+ activities: activities({
88
+ now,
89
+ bus,
90
+ gatekeeper: gatekeeper(env.FOREMAN_GATEKEEPER_URL, env.FOREMAN_GATEKEEPER_TOKEN),
91
+ harnesses: JSON.parse(env.FOREMAN_HARNESSES || "{}"),
92
+ sandboxes: JSON.parse(env.FOREMAN_SANDBOXES || "{}"),
93
+ forges: JSON.parse(env.FOREMAN_FORGES || "{}"),
94
+ forgeEnv: {
95
+ ...(env.FOREMAN_FORGE_URL ? { FORGE_URL: env.FOREMAN_FORGE_URL } : {}),
96
+ ...(env.FOREMAN_FORGE_TOKEN ? { FORGE_TOKEN: env.FOREMAN_FORGE_TOKEN } : {}),
97
+ },
98
+ checkPollMs: Number(env.FOREMAN_CHECK_POLL_MS || 30_000),
99
+ data: resolve(env.OSF_DATA || ".foreman"),
100
+ pollMs,
101
+ control: (runId) => work.control(runId),
102
+ ...(gateway ? { gateway } : {}),
103
+ env,
104
+ }),
105
+ maxHeartbeatThrottleInterval: pollMs,
106
+ defaultHeartbeatThrottleInterval: pollMs,
107
+ });
108
+ const running = worker.run();
109
+ if (bus)
110
+ listen(bus, work);
111
+ const app = api(work, token);
112
+ const port = Number(env.PORT || 8080);
113
+ await app.listen({ port, host: "0.0.0.0" });
114
+ process.stdout.write(`foreman serves the run API on port ${port}, task queue ${taskQueue} at ${address}\n`);
115
+ // Temporal's runtime stops the worker on SIGTERM and SIGINT; the server stops with it.
116
+ await running;
117
+ await app.close();
118
+ await bus?.close();
119
+ }
120
+ finally {
121
+ await gateway?.stop();
122
+ }
114
123
  return { lines: [] };
115
124
  }
125
+ /** Starts the gateway of the factory's inference adapter from its config, a path relative to the factory's folder. */
126
+ async function gatewayOf(inference, folder, env) {
127
+ if (!inference)
128
+ return undefined;
129
+ const lines = JSON.parse(env.FOREMAN_INFERENCES || "{}");
130
+ const adapter = lines[inference.adapter] ?? `npx -y @opensoftware/inference-${inference.adapter}`;
131
+ return startGateway(adapter.split(" "), resolve(folder, inference.config), env);
132
+ }
116
133
  //# sourceMappingURL=serve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,oHAAoH;AACpH,2BAA2B;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC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I,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,IAAI,IAAI,CAA2B,CAAC;IACnF,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,kCAAkC,SAAS,CAAC,OAAO,EAAE,CAAC;IAClG,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;AAClF,CAAC"}
@@ -1,11 +1,21 @@
1
1
  /**
2
- * The problems that only the foreman sees: two sandbox adapters, a stage whose agent the factory does not declare, or
3
- * checks without exactly one forge adapter.
2
+ * The problems that only the foreman sees: two sandbox or inference adapters, a stage whose agent the factory does not
3
+ * declare, checks without exactly one forge adapter, or an inference adapter without its config.
4
4
  */
5
5
  export function stageProblems(factory) {
6
- const adapters = Object.keys(factory.providers?.sandbox ?? {}).length;
7
- const sandbox = adapters > 1 ? [{ path: "/providers/sandbox", message: `name one sandbox adapter, not ${adapters}` }] : [];
8
- return sandbox.concat(stageAgentProblems(factory), checkProblems(factory));
6
+ return oneAdapter(factory, "sandbox").concat(oneAdapter(factory, "inference"), stageAgentProblems(factory), checkProblems(factory), inferenceProblems(factory));
7
+ }
8
+ function oneAdapter(factory, port) {
9
+ const adapters = Object.keys(factory.providers?.[port] ?? {}).length;
10
+ return adapters > 1 ? [{ path: `/providers/${port}`, message: `name one ${port} adapter, not ${adapters}` }] : [];
11
+ }
12
+ function inferenceProblems(factory) {
13
+ const named = Object.keys(factory.providers?.inference ?? {}).length > 0;
14
+ if (named && !factory.inference)
15
+ return [{ path: "/inference", message: "give the inference adapter's config as inference.config" }];
16
+ if (!named && factory.inference)
17
+ return [{ path: "/inference", message: "name one inference adapter under providers.inference" }];
18
+ return [];
9
19
  }
10
20
  function checkProblems(factory) {
11
21
  if (Object.keys(factory.providers?.forge ?? {}).length === 1)
@@ -27,10 +37,12 @@ export const agentOf = (stage) => stage.agent ?? stage.stage;
27
37
  /** The definition of a checked factory, with the text of each prompt from `read`. */
28
38
  export function definitionOf(factory, read) {
29
39
  const forge = Object.keys(factory.providers?.forge ?? {})[0];
40
+ const inference = Object.keys(factory.providers?.inference ?? {})[0];
30
41
  return {
31
42
  factory: factory.factory,
32
43
  sandboxAdapter: Object.keys(factory.providers?.sandbox ?? {})[0] ?? "docker",
33
44
  ...(forge ? { forgeAdapter: forge } : {}),
45
+ ...(inference && factory.inference ? { inference: { adapter: inference, ...factory.inference } } : {}),
34
46
  stages: (factory.workflow ?? []).map((stage) => {
35
47
  const agent = agentOf(stage);
36
48
  const declared = factory.agents[agent];
@@ -38,6 +50,7 @@ export function definitionOf(factory, read) {
38
50
  stage: stage.stage,
39
51
  agent,
40
52
  harness: declared.harness,
53
+ model: declared.model,
41
54
  prompt: read(declared.prompt),
42
55
  ...(stage.gate ? { gate: stage.gate } : {}),
43
56
  ...(stage.checks?.length ? { checks: stage.checks } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/domain/definition.ts"],"names":[],"mappings":"AAiCA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACtE,MAAM,OAAO,GACX,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,iCAAiC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7G,OAAO,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,aAAa,CAAC,OAA0B;IAC/C,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,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