mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-11-17 05:49:28 +00:00
## Summary
- OpenCode **2.2.3** becomes both the **technical minimum** and the
**recommended** runtime. The minimum moves because upstream
[#60258](https://github.com/anomalyco/opencode/pull/60258) (shipped in
2.2.2) changed the image tool contract that CodeNomad's Images gallery,
Design agent and Images settings consume: one name,
`experimental_image_generate`, for the tool, its permission action, its
job type and its completion notices' `metadata.source`, and the tool on
by default (only `experimental.image_generate: false` disables it). On
2.2.2+, the gallery lost every generation entry and the Design companion
fixture timed out; 2.2.1 passed.
- Images are implemented for the 2.2.3 contract only, with no fallback
to the old name: `IMAGE_TOOL` drives the gallery and its proof;
`imageGenerationSelection` reads unset as on; the Design agent and
skills name the new tool; the activation fixture exercises the image
tool instead of falling back to webfetch; the gallery fixture represents
the 2.2.3 transcript format.
- Older daemons (2.1.x, 2.2.1, 2.2.2) go through the existing
below-minimum path (`native_contract`). The 2.1.0 client/plugin/schema
pins stay.
- Help (all ten locales), READMEs, `CONTRIBUTING.md`, `dev-docs`
(compatibility, pruning, panel extensions, settings) and the
architecture skill describe the new minimum, its reason and default-on
image generation. The setup minimum-reason UI string is updated in all
locales.
## Contract review (v2.2.1 → v2.2.2 → v2.2.3; 40 + 101 commits)
Reviewed from the exact tags `v2.2.1` (`3ebcf9a32c`), `v2.2.2`
(`098aa7fd6e`) and `v2.2.3` (`082ac6281f`), the published npm packages,
and an authenticated OpenAPI dump from each official CLI running in its
own sandbox. The [changelog](https://opencode.ai/changelog) has entries
for both 2.2.2 (29 October, highlights only) and 2.2.3 (30 October, full
notes); everything below was also checked against the commit log and
source.
**Headline:** the HTTP contract CodeNomad consumes didn't change, but
2.2.2 **renamed the image tool** from `image_generate` to
`experimental_image_generate` and **turned it on by default**
([#60258](https://github.com/anomalyco/opencode/pull/60258)).
CodeNomad's Images/Design features match the old name and the old
default, so they break on 2.2.2 and later (see [Design companion
finding](#design-companion-finding)). Nothing else found affects
CodeNomad.
- **Authenticated OpenAPI:** **134 paths and 162 operations** on all
three, the same operation set. Schemas 355 → 350 → 351.
- **Added/removed operations:** none in either release.
- **Changed operations (2.2.2):** `GET /api/model`, `GET /api/event`,
`PUT /api/pty/{ptyID}`, `POST /api/shell`, `GET /api/shell/{id}/output`,
`POST /api/debug/heap-dump` and `GET /api/experimental/migration/v1`.
All of these are **representation-only**: the Effect 4.0.6 JSON Schema
output flattens nested `anyOf`, bounds integers with `maximum:
9007199254740991` (and `minimum` for signed integers), and rewrites the
numeric-string query pattern. The event-type and model-type enums are
unchanged.
- **Changed operations (2.2.3):** only the description of `POST
/api/credential`, which can now be refused by an `integration.connect`
policy.
- **Consumed schemas:** the same family selector as the 2.2.1 review
(`V2EventEncoded`, `Session.*`, `SessionStats.*`, `Form.*`,
`Permission.*`, `Prompt*`, `Event.*`, `Location.*`, PTY/Shell).
Re-derived from that description it selects 104 schemas at 2.2.1 (the
2.2.1 file says 103), all byte-identical from 2.1.4 to 2.2.1.
- In 2.2.2 the seven alias copies `Form.Fields_1..3` and
`Session.Message.Native_1..4` collapse into their base schemas, which
are byte-identical to the copies, leaving **97**. Of these, 71 are
byte-identical and 24 differ only in generator representation.
- Two changes are additive and optional: `Session.Info.time.busy`, the
start of the latest execution
([#59910](https://github.com/anomalyco/opencode/pull/59910)), and the
input field `PromptInput.FileAttachment.source` (`Prompt.FileSource`,
inline or uri; CodeNomad doesn't send it).
- `V2EventEncoded`, `Session.Message.*` content, `Session.Inbox.*`,
`Form.*` semantics, `Permission.*` and `Event.SeqEncoded` are unchanged.
- From 2.2.2 to 2.2.3 the family is byte-identical.
- **`Config.InfoEncoded`:** no semantic change in 2.2.2 (representation
only). 2.2.3 extends the managed-policy `action` enum (top-level and
`experimental.policies`) with `integration.connect`, `mcp.use`,
`skill.use` and `plugin.use`
([#60315](https://github.com/anomalyco/opencode/pull/60315)); CodeNomad
writes no policies. The *meaning* of `experimental.image_generate`
changed: unset now means on, and only `false` turns it off. The schema
shape stayed the same and the OpenAPI carries no description, so no
contract signal reveals it.
- **Schedules (not consumed on dev):** `when` becomes optional;
`if`/`until` conditions (shell in 2.2.2, Code Mode in 2.2.3) are added;
outcomes gain `checked`/`expired`.
- **Admission:** every predicate in `compatibility/negotiate.ts`
(unchanged since the 2.2.1 review) holds on 2.2.1, 2.2.2 and 2.2.3.
- **Instance proxy:** no new routes and an unchanged allowlist. Proxied
routes whose representation changed: `GET /api/model`, `PUT
/api/pty/{id}`, `POST /api/shell` and `GET /api/shell/{id}/output`.
Integer bounds and an equivalent numeric pattern accept everything
CodeNomad sends.
- **Published declarations** (2.2.1 → 2.2.3):
- **Client:** 185 methods on all three; the method tree is identical.
2.2.2 adds the generated types `ScheduleCondition*`; `FormFields2` is
renamed to `FormFields1`, which is generated-type churn. 2.2.3 adds the
Promise media helpers `withMediaRefs`, `mediaHashFromUri` and
`MediaRequestOptions`
([#60116](https://github.com/anomalyco/opencode/pull/60116)) and
persistent-PTY frame helpers in `solid/pty`. CodeNomad imports none of
these.
- **Schema:** 2.2.2 adds schedule conditions (`ShellCondition`,
`CheckMode`, …) and exports `SessionLegacy.part`. 2.2.3 adds
`CodeCondition*` and `policy.Action`.
- **Plugin:** 2.2.2 adds the GUI
`ComposerQuoteAnchor`/`ComposerFocusOptions`. 2.2.3 has no export
changes, but the optional peers `@opentui/*` become `>=0.8.0`
([#60385](https://github.com/anomalyco/opencode/pull/60385)). The
published `dependencies.effect` moves from **4.0.1 to 4.0.6** (2.2.2).
- **Typecheck:** the server and UI typecheck with **0 errors** against
the 2.2.2 and 2.2.3 client/schema/plugin/effect declarations through
scratch `paths` overrides. The pinned 2.1.0 control is also clean. The
harness now also remaps `effect` itself; the 2.2.1 harness skipped it
because effect's `exports` are plain `.js` strings.
- **Host modules:** the three daemon-loaded bundles still import
`@opencode/plugin` (`Plugin`), `/effect` (`Plugin`, `Rpc`, `Location`),
`/promise/adapter` (`fromPromise`), `/rpc` (`Rpc`), `effect` and
`effect/encoding` (`Base64Url`) from the host. A probe plugin in an
isolated **2.2.3** daemon resolves every module and binding, as on
2.2.1. `runtime-modules.ts` is unchanged between the tags.
- **Host Effect: 4.0.1 → 4.0.6** (2.2.2,
[#59630](https://github.com/anomalyco/opencode/pull/59630)). The 2.1.0
`@opencode/schema`/`@opencode/client` code bundled into the Missions and
pruning plugins now runs on host Effect 4.0.6. The plugin-runtime,
pruning, Missions-contract, permission-receipts and image-settings
native suites pass on 2.2.3.
- **Private native services:** the keys (`LocationServiceMap`, `Form`,
`Permission`, `Location`, `Job`, `Database`, `Session`, `Bus`) and the
members CodeNomad calls are unchanged. The changes are additive:
`Permission.Unattended` (a reference that denies unanswerable asks for
schedule checks), a `CorrectedError.message` getter, and `Session`
deciding fork media from the parent's location.
- **Storage** (three migrations): `session_part` (new table),
`session_v2.time_busy` and four `schedule` check columns.
- **`session_part`**
([#58915](https://github.com/anomalyco/opencode/pull/58915)): history
reads now *prefer* `session_part` rows over
`session_message.data.content` for assistant messages. The projector
writes parts there only for messages that already have part rows, so new
messages stay inline. Every 2.2.3 fixture DB inspected has **0**
`session_part` rows, and upstream `dev` (`1e28374e48`, 30 October) has
no writer either.
- The tables CodeNomad reads directly keep their shape.
- **Forward risk:** when a release starts writing parts, CodeNomad's
direct `session_message.data.content` readers and the pruning `UPDATE …
json_set(data,'$.content',…)` (`session-pruning/transaction.ts`) would
silently miss or be shadowed by part rows. See Recommendations.
- **Behavior changes checked:**
- **Image generation** (2.2.2): renamed and on by default. See the
[dedicated section](#design-companion-finding).
- **Code Mode:** inner tool progress no longer replaces the `execute`
call rows ([#60480](https://github.com/anomalyco/opencode/pull/60480)),
and progress is throttled to at most one update per 100 ms
([#60120](https://github.com/anomalyco/opencode/pull/60120)). Programs
see the same failure text as direct calls
([#60109](https://github.com/anomalyco/opencode/pull/60109)), `fetch` in
Code Mode is now subject to `webfetch` permissions
([#59954](https://github.com/anomalyco/opencode/pull/59954)), `for…in`
visits inherited keys
([#59933](https://github.com/anomalyco/opencode/pull/59933)) and `null`
survives text encoding
([#57639](https://github.com/anomalyco/opencode/pull/57639)). The
run-to-completion regression behind the 2.1.2 minimum passes on 2.2.3:
`{ total: 2000, beforeAwait: 1000, count: 1000 }`.
- **Permissions and MCP:** permission reasons and feedback are kept in
MCP tool failures
([#60102](https://github.com/anomalyco/opencode/pull/60102)). Shell
permission checks moved fully off tree-sitter and now check redirects,
PowerShell method calls and dynamic directory changes
([#60332](https://github.com/anomalyco/opencode/pull/60332),
[#60376](https://github.com/anomalyco/opencode/pull/60376)), so some
shell commands may now ask where they didn't. The managed-policy split
(`integration.use` vs `mcp.use`/`skill.use`/`plugin.use`) is a changelog
"breaking change" for managed deployments only.
- **Sessions:** deleting a session removes its persistent terminals
([#60322](https://github.com/anomalyco/opencode/pull/60322)), and a
persistent terminal with a missing cwd is rejected
([#60300](https://github.com/anomalyco/opencode/pull/60300)). Forked and
imported sessions store media as blobs when `media_blob` is on
([#60118](https://github.com/anomalyco/opencode/pull/60118)). The native
fork suite passes on 2.2.3.
- **Providers:** a built-in **Claude Agent** provider uses the user's
Claude Code login
([#58782](https://github.com/anomalyco/opencode/pull/58782)).
Plugin-supplied model variants are preserved
([#60097](https://github.com/anomalyco/opencode/pull/60097)), and the
dynamic provider npm fallback runs after external SDK hooks
([#60380](https://github.com/anomalyco/opencode/pull/60380)). These are
source-reviewed and touch no consumed contract.
- **Persistent PTY binary** (the process daemon): 2.2.2 switches from
`@opencode-ai/pty` 0.3.1 to `@opencode/pty` **0.3.3**
([#60276](https://github.com/anomalyco/opencode/pull/60276)).
`process-daemon-v0.3.3` contains only the release commit after 0.3.2 (a
version bump of the `@opencode/pty-*` binaries). **v0.4.0** (terminal
renaming, [#60324](https://github.com/anomalyco/opencode/pull/60324)) is
**not** shipped in CLI 2.2.3, which pins 0.3.3. CodeNomad only lists
persistent PTYs (worktree deletion guard), whose schema is unchanged
apart from representation.
- **Client fix not inherited:** the 2.2.3 client evicts missing sessions
on 404 ([#60459](https://github.com/anomalyco/opencode/pull/60459)).
CodeNomad stays on the 2.1.0 client.
- **`@opencode/ai` breaking changes** (media moved to `/experimental`,
one `tool()`): CodeNomad doesn't import `@opencode/ai`.
- Desktop/TUI-only changes (timeline performance, side-panel tabs,
spellcheck, question sounds, OpenTUI 0.8) don't affect CodeNomad.
**Verdict:**
- The **2.1.0 client/plugin pins stay**. Bumping them would bring
nothing CodeNomad consumes.
- No consumed HTTP/plugin contract broke; the breaking change is the
image tool contract of #60258, consumed by the Images gallery, the
Design agent and the Images settings.
- **Decision applied in this PR:** 2.2.3 becomes both the minimum and
the recommendation, and Images are implemented for the 2.2.3 contract
only (see Summary). This replaces the review's initial suggestion to
keep the 2.1.2 minimum and accept both tool names.
**Not verified here:**
- the full native suite matrix on 2.2.2/2.2.3; only the runs in Appendix
I were performed;
- the forward-compatibility of the `session_part` readers against a
runtime that writes parts (no such runtime exists yet);
- the Claude Agent provider and shell-permission changes at runtime
(source only);
- macOS/Linux.
---
## Design companion finding
**Symptom:** `scripts/test-design-companion-native.mjs <cli>` passes on
2.2.1 and fails on 2.2.2 and 2.2.3 with `Error: Timed out: series 1
generated and read`. Reproduced independently in a scratch checkout of
`origin/dev` (`f39642bc4`), with `CODENOMAD_NATIVE_FIXTURE_PARENT`
outside the home:
```
test-design-companion-native 2.2.1 exit=0 PASS AC-16, AC-52
test-design-companion-native 2.2.2 exit=1 Timed out: series 1 generated and read
test-design-companion-native 2.2.3 exit=1 Timed out: series 1 generated and read
```
**What the step waits for**
(`test-design-companion-native.mjs:238-241`): the fixture's loopback
chat provider answers a `RUN [...]` turn with two tool calls `{ tool:
"image_generate", args: { prompt, path: ".codenomad/design/icon/<name>"
} }`. The step then waits until the transcript holds two synthetic
notices with `metadata.source === "image_generate"` (line 209) and two
`read` parts of the generated files. No HTTP generate route, file watch
or media blob is involved; it is the agent tool path.
**Cause: an intentional upstream contract change, not an upstream bug.**
In 2.2.2, [#60258](https://github.com/anomalyco/opencode/pull/60258)
(`d4e48f54da`, "turn experimental_image_generate on by default") changed
`packages/core/src/tool/plugin/image-generate.ts`:
- `export const name = "image_generate"` →
`"experimental_image_generate"`. That one constant is the tool name, the
permission action (`assertions: ["experimental_image_generate", "edit",
"read"]`), the Job `type`, and the completion notice's
`metadata.source`. `session/execution/restart.ts` also tags
restart-recovery notices `source: "experimental_image_generate"`.
- The opt-in became default-on: `if (!enabled || imageGenerate(entries)
=== false) return`. An unset `experimental.image_generate` now offers
the tool; only `false` removes it ("still honored for configs from when
the tool was opt-in; permissions are the supported way to turn it off").
- The 2.2.2 changelog states it: "agents can now use
`experimental_image_generate` without additional configuration".
2.2.2 also wraps the notice text as `<image id="…"
state="…">\n…\n</image>` and adds `id` to the tool output
([#60098](https://github.com/anomalyco/opencode/pull/60098)).
CodeNomad's `Saved image: (.+) \(` parse still matches; `jobID`, `state`
and `path` metadata are unchanged.
**Evidence** (fixture DBs copied read-only to `evidence/`):
```
2.2.3, original fixture (calls "image_generate"):
seq 5 tool image_generate error "No tool named \"image_generate\" is currently available. Please use a tool from the available tool list." (x2)
-> no image job, no notice, no read: the wait times out.
2.2.3, fixture with the tool name changed (scratch copy; CodeNomad server code unmodified):
seq 5 tool experimental_image_generate completed {path:…/icon-minimal-a, model:"fiximg/image", jobID:"image_18cfb59…"}
seq 18 synthetic {"source":"experimental_image_generate","jobID":"image_18cfb59…","state":"completed",…}
<image id="image_18cfb59…" state="completed"> | Image request finished. Saved image: …
seq 20 tool read completed (x2) … seq 40/48/49 refinement
-> files, image calls and reads all correct, then
AssertionError: generations.length 0 !== 3 (test line 260: gallery "generation" entries)
```
So the product bug is real and independent of the fixture: on 2.2.2+
CodeNomad's Images gallery finds **no generation entries**. Images still
appear through their `read` parts, but without prompt, model, lineage or
"proven" origin, and `galleryImageReference` refuses them as `changed`.
**CodeNomad code that assumes the 2.2.1 name or default** (origin/dev):
| Where | Assumption | Effect on 2.2.2+ |
| --- | --- | --- |
| `session-pruning/assets-gallery.ts:56,139` | `part.name ===
"image_generate"` | no generation entries; references refused `changed`
|
| `session-pruning/assets-gallery-proof.ts:104,130` | tool name and
notice `source === "image_generate"` | no calls or notices, so no
provenance proof |
| `opencode/image-settings.ts` `imageGenerationSelection(undefined) →
false` (doc: "Reads … as OpenCode does") | unset means off | Settings →
Images shows **Off** and `images.status()` returns `"disabled"` while
the tool is offered; help step "Turn on image generation"
(`docs/help/en/extensions.md:73`) is no longer needed |
| `opencode/design/opencode/agents/design.md`, `skills/design-core`,
`design-logo`, `design-ui-mockup` | the agent is told to call
`image_generate` | the model sees only `experimental_image_generate`;
the first call can fail with "No tool named …" |
| `scripts/test-design-companion-native.mjs:125,209,238,301` | fixture
calls/filters `image_generate` | red on 2.2.2+ |
| `scripts/test-design-activation-native.mjs:76,307` | ask rule on
action `image_generate`; tool detection by that name | **passes but
loses coverage**: `askTool` falls back to `webfetch` on 2.2.2/2.2.3
(logged) |
| `dev-docs/SESSION_PRUNING_RPC.md`, `PANEL_EXTENSIONS.md`,
`SETTINGS.md` | describe `image_generate` parts and opt-in | out of date
for 2.2.2+ |
User permission rules written for action `image_generate` no longer
match on 2.2.2+; that is an OpenCode-side change for users. CodeNomad's
help never names the permission action; the Design fixtures and agent
use `experimental_image_generate`.
**Fix in this PR** (2.2.3 contract only, no fallback):
1. One `IMAGE_TOOL = "experimental_image_generate"` constant drives the
gallery and its proof; the gallery reads the 2.2.3 notice format.
2. The native fixtures use the new tool; the activation fixture
exercises it (default on) instead of falling back to webfetch.
3. The Design agent and skills name `experimental_image_generate`.
4. `imageGenerationSelection` reads an unset
`experimental.image_generate` as on; only `false` disables it. Settings
→ Images and `images.status()` report it that way.
## Follow-up
- Hardening for `session_part` (independent of this upgrade, no 2.2.3
regression): make the direct readers and the pruning transaction fail
safe when `session_part` has rows for the target messages.
## Isolated Windows qualification
Base: dev `f39642bc4`; Node 25.2.1 (local; CI runs the pinned 24.20.0);
exact official CLI **2.2.3**; locked client/plugin **2.1.0**;
`CODENOMAD_NATIVE_FIXTURE_PARENT` outside the user profile for the
Design fixtures.
- **Before the image fix (recommendation-only change):** every native
suite passed on 2.2.3 except the Design companion end to end, which
passes on 2.2.1 and times out on 2.2.2/2.2.3 at "series 1 generated and
read" (`No tool named "image_generate" is currently available`).
- **After this change, on 2.2.3:** Design companion (3 files, 2 series,
all proven, lineage), Design activation (image tool offered to Design
and Build, default on), Design content, image settings (default on,
Off→On hot reload), session pruning including session images/media, Code
Mode jobs `{ total: 2000, beforeAwait: 1000, count: 1000 }`.
- **Full native set on 2.2.3 (before the image fix, unaffected areas):**
plugin runtime, automation, Location/worktrees/event relay, permission
receipts, Git init/degraded, Missions (contract, family control, native,
trajectory) and all 11 recurring journeys, sessions (environment, fork,
aside, interrupt, lifecycle, blank cleanup, compaction, prompt skills,
providers, service usage, web search, plugin packages, output limit,
Promise-tool failure, subagent depth, temporary workspaces), migrations
from 2.1.2/2.2.1/2.2.2, install/upgrade/legacy replacement.
- **Units and checks after the change:** root and server typecheck
clean; server **2,825 passed, 9 skipped, 1 cancelled** (`index.test.ts`
shutdown test timed out under full-suite load; **4/4** alone); gallery
107/107; Design 23/23; opencode-update 62 passed / 1 skipped; touched UI
units 8/8; browser `opencode-setup` + `websearch-settings` 38/38; native
plugin build 2/2; ten-locale help 31/31.
410 lines
26 KiB
JavaScript
410 lines
26 KiB
JavaScript
// Design agent activation against an explicit isolated CLI: private home, config,
|
|
// database and ProgramData, loopback fake chat and image models (no paid call),
|
|
// and only processes this script starts. Usage:
|
|
// node scripts/test-design-activation-native.mjs <absolute opencode executable>
|
|
// Requires the session-pruning bundle (npm run build:pruning --workspace @neuralnomads/codenomad).
|
|
import assert from "node:assert/strict"
|
|
import { spawn, spawnSync } from "node:child_process"
|
|
import { createHash, randomUUID } from "node:crypto"
|
|
import { createServer } from "node:http"
|
|
import { mkdir, mkdtemp, readdir, readFile, writeFile } from "node:fs/promises"
|
|
import path from "node:path"
|
|
import readline from "node:readline"
|
|
import { setTimeout as delay } from "node:timers/promises"
|
|
import { fileURLToPath } from "node:url"
|
|
import { tsImport } from "tsx/esm/api"
|
|
import { OpenCode } from "@opencode/client"
|
|
import { stopFixtureChild } from "./native-fixture-guards.mjs"
|
|
import { fixtureEnvironment, fixtureParent } from "./native-product-fixture.mjs"
|
|
|
|
const server = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "packages", "server", "src", "opencode")
|
|
const load = file => tsImport(`../packages/server/src/opencode/${file}`, import.meta.url)
|
|
const { DesktopPluginLifecycle, prepareDesktopPluginPresence } = await load("desktop-plugin-lifecycle.ts")
|
|
const { resolveDesktopPluginPaths } = await load("desktop-plugin-paths.ts")
|
|
const { designLeaseContent } = await load("design/activation.ts")
|
|
const { designAgentStatus } = await load("design/status.ts")
|
|
const { DESIGN_CONTENT_MARK, DESIGN_SKILL_IDS, DESIGN_SOURCE_FILES, parseDesignContent } = await load("design/content.ts")
|
|
const { PRESENCE_EXPIRY_MS, PRESENCE_INTERVAL_MS } = await load("desktop-plugin-presence.ts")
|
|
|
|
const connect = (url, password) => OpenCode.make({ baseUrl: url,
|
|
headers: { authorization: `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}` } })
|
|
async function provision(client, lifecycle) {
|
|
const paths = await resolveDesktopPluginPaths({ client, assertCurrent() {} }, { kind: "host", platform: process.platform, binary: "fixture" })
|
|
await prepareDesktopPluginPresence(paths, () => {}, { pruning: lifecycle })
|
|
return paths
|
|
}
|
|
|
|
// Child backend: a separate process whose crash leaves its lease to expire.
|
|
if (process.argv[2] === "--backend") {
|
|
const lifecycle = new DesktopPluginLifecycle("session-pruning")
|
|
await lifecycle.setLeaseContent(designLeaseContent(process.argv[5] === "design"))
|
|
await provision(connect(process.argv[3], process.argv[4]), lifecycle)
|
|
process.stdout.write("ready\n")
|
|
for await (const line of readline.createInterface({ input: process.stdin })) {
|
|
await lifecycle.setLeaseContent(designLeaseContent(JSON.parse(line).design))
|
|
process.stdout.write("ok\n")
|
|
}
|
|
await lifecycle.stop()
|
|
process.exit(0)
|
|
}
|
|
|
|
const cli = process.argv[2]
|
|
assert(cli && path.isAbsolute(cli), "Pass an absolute isolated CLI executable path")
|
|
// The checkout's native files, as the bundle embeds them (tsx cannot import `.md`).
|
|
const checkout = path.resolve(server, "..", "..", "..", "..")
|
|
const readSource = file => readFile(path.join(server, "design", file), "utf8")
|
|
const sources = {
|
|
agent: await readSource(DESIGN_SOURCE_FILES.agent),
|
|
skills: Object.fromEntries(await Promise.all(DESIGN_SKILL_IDS.map(async id => [id, await readSource(DESIGN_SOURCE_FILES.skill(id))]))),
|
|
notice: await readSource(DESIGN_SOURCE_FILES.notice),
|
|
apacheLicense: await readSource(DESIGN_SOURCE_FILES.apacheLicense),
|
|
}
|
|
const content = parseDesignContent(sources)
|
|
// Project discovery walks every ancestor directory: outside CI the fixture must live
|
|
// outside the user's home, or it would read the user's own agents and skills.
|
|
const root = await mkdtemp(path.join(await fixtureParent({ projectConfig: true }), "design-activation-"))
|
|
const configDirectory = path.join(root, "config")
|
|
const project = name => path.join(root, name)
|
|
// Children (Git, the CLI, the daemon, the backends) get only allowlisted variables and a private profile.
|
|
const childEnv = await fixtureEnvironment(root)
|
|
const version = spawnSync(cli, ["--version"], { env: childEnv, encoding: "utf8" }).stdout.trim()
|
|
const USER_AGENT = "USER-DESIGN-AGENT"
|
|
const USER_SKILL = "USER-DESIGN-CORE"
|
|
const files = {
|
|
[path.join(configDirectory, "opencode.json")]: "{}\n",
|
|
[path.join(configDirectory, "skills", "fixture-visible", "SKILL.md")]: "---\nname: fixture-visible\ndescription: Announced fixture skill\n---\nFixture.\n",
|
|
[path.join(project("p2-ask"), "opencode.json")]: JSON.stringify({ permissions: [{ action: "experimental_image_generate", resource: "*", effect: "ask" }] }),
|
|
[path.join(project("p3-user"), ".opencode", "agents", "design.md")]: `---\ndescription: The user's design agent\nmode: primary\n---\n${USER_AGENT}\n`,
|
|
[path.join(project("p3-user"), ".opencode", "skills", "design-core", "SKILL.md")]: `---\nname: design-core\ndescription: The user's skill\n---\n${USER_SKILL}\n`,
|
|
}
|
|
for (const name of ["p1", "p2-ask", "p3-user", "p4-late"]) {
|
|
await mkdir(project(name), { recursive: true })
|
|
// A Git root stops OpenCode's upward project-configuration search.
|
|
assert.equal(spawnSync("git", ["init", "-q", project(name)], { env: childEnv }).status, 0)
|
|
}
|
|
for (const [file, content] of Object.entries(files)) {
|
|
await mkdir(path.dirname(file), { recursive: true })
|
|
await writeFile(file, content)
|
|
}
|
|
|
|
// Scripted chat model ("RUN <json>" emits those tool calls) and a fake image model.
|
|
const requests = []
|
|
let imageCalls = 0, providerError
|
|
const sse = (res, delta, finish) => {
|
|
res.setHeader("content-type", "text/event-stream")
|
|
for (const [d, f] of [[delta, null], [{}, finish]]) res.write(`data: ${JSON.stringify({ id: "f", object: "chat.completion.chunk", model: "fixture",
|
|
choices: [{ index: 0, delta: d, finish_reason: f }], usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 } })}\n\n`)
|
|
res.end("data: [DONE]\n\n")
|
|
}
|
|
const text = content => typeof content === "string" ? content : Array.isArray(content) ? content.map(part => part.text ?? "").join("\n") : ""
|
|
const provider = createServer(async (req, res) => {
|
|
try {
|
|
let raw = ""
|
|
for await (const chunk of req) raw += chunk
|
|
if (req.url.startsWith("/v1/images/")) {
|
|
imageCalls++
|
|
res.setHeader("content-type", "application/json")
|
|
return res.end(JSON.stringify({ created: 1, data: [{ b64_json: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" }] }))
|
|
}
|
|
const body = JSON.parse(raw)
|
|
const messages = body.messages ?? []
|
|
requests.push({ session: req.headers["x-opencode-session"], all: messages.map(message => text(message.content)).join("\n"), tools: (body.tools ?? []).map(tool => tool.function?.name) })
|
|
if (!body.tools?.length) return sse(res, { role: "assistant", content: "Images" }, "stop")
|
|
const last = messages.findLastIndex(message => message.role === "assistant" || message.role === "tool")
|
|
if (messages[last]?.role === "tool") return sse(res, { role: "assistant", content: "FIXTURE_AFTER_TOOL" }, "stop")
|
|
const run = messages.slice(last + 1).map(message => /RUN (\[.*\])/s.exec(text(message.content))).findLast(Boolean)
|
|
if (!run) return sse(res, { role: "assistant", content: "FIXTURE_OK" }, "stop")
|
|
sse(res, { role: "assistant", tool_calls: JSON.parse(run[1]).map((call, index) => ({ index, id: `call_${randomUUID()}`, type: "function",
|
|
function: { name: call.tool, arguments: JSON.stringify(call.args) } })) }, "tool_calls")
|
|
} catch (error) { providerError = error; res.destroy(error) }
|
|
})
|
|
await new Promise(resolve => provider.listen(0, "127.0.0.1", resolve))
|
|
const settings = { baseURL: `http://127.0.0.1:${provider.address().port}/v1`, apiKey: "fixture-only" }
|
|
|
|
const password = randomUUID()
|
|
// Only the fixture providers load, so the image tool, on by default without `experimental.image_generate`,
|
|
// can only select the fake image model.
|
|
const env = await fixtureEnvironment(root, {
|
|
OPENCODE_CONFIG_DIR: configDirectory, OPENCODE_DB: path.join(root, "fixture.db"), OPENCODE_SERVER_PASSWORD: password,
|
|
OPENCODE_DISABLE_MODELS_FETCH: "1", OPENCODE_DISABLE_FFF: "1",
|
|
OPENCODE_CONFIG_CONTENT: JSON.stringify({ model: "fixture/vision", small_model: "fixture/vision", enabled_providers: ["fixture", "fiximg"], providers: {
|
|
fixture: { package: "@opencode/ai/providers/openai-compatible", settings, models: { vision: { name: "Fixture", capabilities: { tools: true, input: ["text", "image/png"], output: ["text"] } } } },
|
|
fiximg: { package: "@opencode/ai/providers/openai-compatible/images", settings, models: { image: { name: "Fixture image", type: "image", capabilities: { tools: false, input: ["text"], output: ["image"] } } } },
|
|
} }),
|
|
})
|
|
|
|
let output = ""
|
|
const daemon = spawn(cli, ["serve", "--hostname", "127.0.0.1", "--port", "0", "--print-logs"], { cwd: root, env, windowsHide: true })
|
|
const daemonStopped = new Promise(resolve => daemon.once("close", resolve))
|
|
daemon.stdout.on("data", data => { output += data })
|
|
daemon.stderr.on("data", data => { output += data })
|
|
const backends = new Set(), lifecycles = []
|
|
const results = {}
|
|
|
|
async function until(label, predicate, ms = 30_000) {
|
|
const end = Date.now() + ms
|
|
for (;;) {
|
|
if (providerError) throw providerError
|
|
const value = await predicate()
|
|
if (value) return value
|
|
if (daemon.exitCode !== null) throw new Error(`Isolated CLI exited: ${output.slice(-3000)}`)
|
|
if (Date.now() > end) throw new Error(`Timed out: ${label}`)
|
|
await delay(100)
|
|
}
|
|
}
|
|
|
|
try {
|
|
await until("daemon URL", () => /http:\/\/127\.0\.0\.1:\d+/.test(output))
|
|
const url = output.match(/http:\/\/127\.0\.0\.1:\d+/)[0]
|
|
const client = connect(url, password)
|
|
const authorization = `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`
|
|
const api = async (method, route, body) => {
|
|
const response = await fetch(url + route, { method, signal: AbortSignal.timeout(30_000),
|
|
headers: { authorization, ...(body === undefined ? {} : { "content-type": "application/json" }) }, body: body === undefined ? undefined : JSON.stringify(body) })
|
|
const raw = await response.text()
|
|
let json; try { json = JSON.parse(raw) } catch { json = raw }
|
|
return { status: response.status, json }
|
|
}
|
|
const located = route => async directory => (await api("GET", `${route}?location[directory]=${encodeURIComponent(directory)}`)).json?.data ?? []
|
|
const agents = located("/api/agent"), skills = located("/api/skill"), plugins = located("/api/plugin")
|
|
// Discovery sees only the fixture's loopback providers, whatever the caller's environment holds.
|
|
results.models = (await located("/api/model")(project("p1"))).map(model => `${model.providerID}/${model.id}`)
|
|
assert(results.models.every(ref => /^(fixture|fiximg)\//.test(ref)), `only fixture models are discovered: ${results.models}`)
|
|
const designSkills = async directory => (await skills(directory)).filter(skill => skill.id.startsWith("design-"))
|
|
const hasDesign = async directory => (await agents(directory)).some(agent => agent.id === "design")
|
|
const allHave = async (names, wanted) => (await Promise.all(names.map(name => hasDesign(project(name))))).every(value => value === wanted)
|
|
const loaded = ["p1", "p2-ask", "p3-user"]
|
|
|
|
async function startBackend(design) {
|
|
const child = spawn(process.execPath, [fileURLToPath(import.meta.url), "--backend", url, password, design ? "design" : "none"], { env: childEnv, stdio: ["pipe", "pipe", "pipe"], windowsHide: true })
|
|
backends.add(child)
|
|
const closed = new Promise(resolve => child.once("close", resolve))
|
|
const lines = readline.createInterface({ input: child.stdout })[Symbol.asyncIterator]()
|
|
let errors = ""
|
|
child.stderr.on("data", data => { errors += data })
|
|
const next = async () => {
|
|
// Unreferenced: a losing timeout never keeps the fixture process alive.
|
|
const line = await Promise.race([lines.next(), delay(60_000, undefined, { ref: false }).then(() => ({ done: true }))])
|
|
if (line.done) throw new Error(`Backend child failed: ${errors}`)
|
|
return line.value
|
|
}
|
|
assert.equal(await next(), "ready")
|
|
return {
|
|
async design(value) { child.stdin.write(`${JSON.stringify({ design: value })}\n`); assert.equal(await next(), "ok") },
|
|
// A crash: its lease is left behind and expires.
|
|
async crash() { child.kill("SIGKILL"); await closed; backends.delete(child) },
|
|
async stop() { child.stdin.end(); await closed; backends.delete(child) },
|
|
}
|
|
}
|
|
async function snapshot() {
|
|
const entries = []
|
|
const walk = async directory => {
|
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
const file = path.join(directory, entry.name)
|
|
if (entry.isDirectory()) { if (entry.name !== ".git") await walk(file) }
|
|
else entries.push(`${path.relative(root, file)} ${createHash("sha256").update(await readFile(file)).digest("hex")}`)
|
|
}
|
|
}
|
|
for (const directory of [configDirectory, ...["p1", "p2-ask", "p3-user", "p4-late"].map(project)]) await walk(directory)
|
|
return entries.sort()
|
|
}
|
|
const markers = async (sessionID, marker) => (JSON.stringify((await api("GET", `/api/session/${sessionID}/message`)).json).match(new RegExp(marker, "g")) ?? []).length
|
|
async function turn(sessionID, prompt, marker, during = async () => {}) {
|
|
const before = await markers(sessionID, marker)
|
|
assert((await api("POST", `/api/session/${sessionID}/prompt`, { text: prompt })).status < 300)
|
|
await until(`turn ${marker}`, async () => { await during(); return await markers(sessionID, marker) > before }).catch(async error => {
|
|
const messages = JSON.stringify((await api("GET", `/api/session/${sessionID}/message`)).json).slice(-3000)
|
|
const sent = requests.filter(entry => entry.session === sessionID).map(entry => ({ tools: entry.tools, tail: entry.all.slice(-300) }))
|
|
throw new Error(`${error.message}\nmessages: ${messages}\nrequests: ${JSON.stringify(sent).slice(-3000)}`)
|
|
})
|
|
}
|
|
const session = async (directory, body = {}) => {
|
|
const response = await api("POST", "/api/session", { location: { directory }, ...body })
|
|
assert(response.status < 300, JSON.stringify(response.json))
|
|
return response.json?.data?.id ?? response.json?.id
|
|
}
|
|
const imagesSession = directory => session(directory, { agent: "design", title: "Images", metadata: { "codenomad.companion": "images" } })
|
|
// Rejects every permission request of one generation turn and counts them.
|
|
async function permissionRequests(sessionID, prompt) {
|
|
const asked = []
|
|
const reject = async () => {
|
|
for (const request of (await api("GET", `/api/session/${sessionID}/permission`)).json?.data ?? []) {
|
|
if (asked.includes(request.id)) continue
|
|
asked.push(request.id)
|
|
await api("POST", `/api/session/${sessionID}/permission/${request.id}/reply`, { decision: "reject" })
|
|
}
|
|
}
|
|
// A rejected call ends the turn with the native declined error.
|
|
await turn(sessionID, prompt, "declined this tool call", reject)
|
|
await delay(2_000)
|
|
await reject()
|
|
return asked.length
|
|
}
|
|
|
|
// Locations load before any request, so registration happens before activation (V1 "early").
|
|
for (const name of ["p1", "p2-ask"]) assert.equal(await hasDesign(project(name)), false)
|
|
await until("the user's project agent", async () => designAgentStatus(await agents(project("p3-user"))).designAgent === "user")
|
|
const backendA = await startBackend(false)
|
|
for (const name of loaded) await until(`pruning plugin active in ${name}`, async () => (await plugins(project(name))).some(plugin => plugin.id === "codenomad-session-pruning" && plugin.state?.status === "active"))
|
|
assert.equal(await readFile(path.join(configDirectory, "opencode.json"), "utf8"), "{}\n")
|
|
const pristine = await snapshot()
|
|
|
|
// AC-1: requested by a live backend, listed in every Location within 5 s, nothing written.
|
|
let started = Date.now()
|
|
await backendA.design(true)
|
|
await until("Design listed everywhere", () => allHave(loaded, true), 10_000)
|
|
results.activationMs = Date.now() - started
|
|
assert(results.activationMs < 5_000, `Design took ${results.activationMs} ms`)
|
|
for (const name of ["p1", "p2-ask"]) {
|
|
const agent = (await agents(project(name))).find(entry => entry.id === "design")
|
|
assert.equal(agent.mode, "primary")
|
|
assert.deepEqual(designAgentStatus(await agents(project(name))), { designAgent: "present", contentVersion: 1 })
|
|
const listed = await designSkills(project(name))
|
|
assert.deepEqual(listed.map(skill => skill.id).sort(), [...DESIGN_SKILL_IDS].sort())
|
|
assert(listed.every(skill => skill.autoinvoke === false), "Design skills are never auto-invoked")
|
|
// AC-49: the installed bundle provides the checkout's content.
|
|
assert.equal(agent.system, content.agent.system)
|
|
assert.equal(agent.description, content.agent.description)
|
|
for (const expected of content.skills) {
|
|
const skill = listed.find(entry => entry.id === expected.id)
|
|
assert.deepEqual([skill.name, skill.description, skill.content.trim()], [expected.name, expected.description, expected.content], expected.id)
|
|
}
|
|
}
|
|
// AC-49: the skills point at the installed content-addressed bundle, outside the checkout, whose
|
|
// bytes carry every file's notice, NOTICE.md and the Apache licence. ASCII lines without quotes or
|
|
// backslashes appear verbatim in esbuild's string literals.
|
|
const installed = (await designSkills(project("p1")))[0].path
|
|
const fromCheckout = path.relative(checkout, installed)
|
|
assert(/[\\/]session-pruning[\\/][a-f\d]{64}\.mjs$/.test(installed) && (fromCheckout.startsWith("..") || path.isAbsolute(fromCheckout)), installed)
|
|
const bundleText = await readFile(installed, "utf8")
|
|
assert(!bundleText.includes(checkout) && !bundleText.includes(checkout.replaceAll("\\", "/")), "The bundle never names the checkout")
|
|
for (const source of [sources.agent, ...Object.values(sources.skills), sources.notice, sources.apacheLicense]) {
|
|
for (const line of source.split(/\r?\n/).map(entry => entry.replace(/^#\s*/, "").trim()).filter(entry => /^[\x20-\x7e]{12,}$/.test(entry) && !/["'\\`$]/.test(entry))) {
|
|
assert(bundleText.includes(line), `Installed bundle lacks: ${line}`)
|
|
}
|
|
}
|
|
assert.deepEqual(await snapshot(), pristine, "Activation writes nothing in configuration roots or projects")
|
|
|
|
// AC-3: no design-* skill announced to Design or Build; loadable by identifier.
|
|
const images = await imagesSession(project("p1"))
|
|
await turn(images, `RUN ${JSON.stringify([{ tool: "skill", args: { id: "design-core" } }])}`, "FIXTURE_AFTER_TOOL")
|
|
const build = await session(project("p1"))
|
|
await turn(build, "hello", "FIXTURE_OK")
|
|
const designRequests = requests.filter(entry => entry.session === images && entry.tools.length)
|
|
const buildRequests = requests.filter(entry => entry.session === build && entry.tools.length)
|
|
assert(designRequests.length && buildRequests.length, "Both conversations reached the model")
|
|
assert(designRequests.every(entry => entry.all.includes(DESIGN_CONTENT_MARK)), "The Design system prompt applies")
|
|
assert(buildRequests.every(entry => !entry.all.includes(DESIGN_CONTENT_MARK)))
|
|
for (const entry of [...designRequests, ...buildRequests]) {
|
|
assert(entry.all.includes("<id>fixture-visible</id>"), "Ordinary skills are announced")
|
|
assert(!/<id>design-/.test(entry.all), "No design-* skill is announced")
|
|
}
|
|
const core = (await skills(project("p1"))).find(skill => skill.id === "design-core")
|
|
assert(JSON.stringify((await api("GET", `/api/session/${images}/message`)).json).includes(JSON.stringify(core.content.trim()).slice(1, -1)),
|
|
"design-core loads by identifier")
|
|
|
|
// AC-4: the user's ask rule on the image tool applies to Design exactly as to Build.
|
|
for (const entry of [...designRequests, ...buildRequests])
|
|
assert(entry.tools.includes("experimental_image_generate"), `The image tool is offered by default: ${entry.tools}`)
|
|
const generate = JSON.stringify([{ tool: "experimental_image_generate",
|
|
args: { prompt: "Flat blue app icon", path: ".codenomad/design/icon/app-icon-minimal-a.png" } }])
|
|
const askedFor = async () => ({
|
|
design: await permissionRequests(await imagesSession(project("p2-ask")), `RUN ${generate}`),
|
|
build: await permissionRequests(await session(project("p2-ask")), `RUN ${generate}`),
|
|
})
|
|
results.ask = await askedFor()
|
|
assert.deepEqual(results.ask, { design: 1, build: 1 })
|
|
|
|
// AC-5: the user's own design agent and design-core win.
|
|
const userWins = async () => {
|
|
const directory = project("p3-user")
|
|
assert.deepEqual(designAgentStatus(await agents(directory)), { designAgent: "user", contentVersion: null })
|
|
const core = (await skills(directory)).find(skill => skill.id === "design-core")
|
|
assert(core.content.includes(USER_SKILL))
|
|
const id = await imagesSession(directory)
|
|
await turn(id, "hello", "FIXTURE_OK")
|
|
const sent = requests.filter(entry => entry.session === id && entry.tools.length)
|
|
assert(sent.length && sent.every(entry => entry.all.includes(USER_AGENT) && !entry.all.includes(DESIGN_CONTENT_MARK)))
|
|
}
|
|
await userWins()
|
|
|
|
// AC-7: A requests, B does not; a later Location starts from the current union.
|
|
const backendB = await startBackend(false)
|
|
const all = [...loaded, "p4-late"]
|
|
// A Location loaded later starts from the current union once its plugins load.
|
|
started = Date.now()
|
|
await until("Design in a later Location", () => hasDesign(project("p4-late")), 5_000)
|
|
results.lateLocationMs = Date.now() - started
|
|
started = Date.now()
|
|
await backendA.crash()
|
|
await until("Design gone when only A expires", () => allHave(["p1", "p2-ask", "p4-late"], false), PRESENCE_EXPIRY_MS + 10_000)
|
|
results.expiryMs = Date.now() - started
|
|
assert(results.expiryMs <= PRESENCE_EXPIRY_MS + 2 * PRESENCE_INTERVAL_MS + 2_000, `Expiry took ${results.expiryMs} ms`)
|
|
assert((await plugins(project("p1"))).some(plugin => plugin.id === "codenomad-session-pruning" && plugin.state?.status === "active"), "B keeps the plugin present")
|
|
const backendA2 = await startBackend(true)
|
|
await until("Design back with A", () => allHave(all.filter(name => name !== "p3-user"), true), 10_000)
|
|
|
|
// AC-2: disabling the only request removes the agent and skills within the expiry plus one interval.
|
|
started = Date.now()
|
|
await backendA2.design(false)
|
|
await until("Design gone after disabling", async () => await allHave(all.filter(name => name !== "p3-user"), false)
|
|
&& (await designSkills(project("p1"))).length === 0, PRESENCE_EXPIRY_MS + PRESENCE_INTERVAL_MS)
|
|
results.disableMs = Date.now() - started
|
|
|
|
// AC-57: one backend with two live installations rewrites both leases; a later installation gets the current state.
|
|
const presenceOf = data => path.join(data, "session-pruning", "presence")
|
|
const leaseNames = async data => (await readdir(presenceOf(data))).filter(name => name.endsWith(".lease"))
|
|
const leases = async (data, names) => Promise.all((names ?? await leaseNames(data)).map(name => readFile(path.join(presenceOf(data), name), "utf8")))
|
|
const daemonPaths = await resolveDesktopPluginPaths({ client, assertCurrent() {} }, { kind: "host", platform: process.platform, binary: "fixture" })
|
|
const others = new Set(await leaseNames(daemonPaths.data))
|
|
const backendC = new DesktopPluginLifecycle("session-pruning")
|
|
lifecycles.push(backendC)
|
|
await provision(client, backendC)
|
|
const own = (await leaseNames(daemonPaths.data)).filter(name => !others.has(name))
|
|
assert.equal(own.length, 1)
|
|
const other = { config: path.join(root, "other-config"), data: path.join(root, "other-config-data") }
|
|
await backendC.start(other)
|
|
await backendC.setLeaseContent(designLeaseContent(true))
|
|
assert.deepEqual(await leases(daemonPaths.data, own), [designLeaseContent(true)], "The older retained lease is rewritten")
|
|
assert.deepEqual(await leases(other.data), [designLeaseContent(true)])
|
|
await until("Design with C", () => hasDesign(project("p1")), 10_000)
|
|
await backendC.setLeaseContent("")
|
|
assert.deepEqual(await leases(daemonPaths.data, own), [""])
|
|
assert.deepEqual(await leases(other.data), [""])
|
|
await until("Design gone with C disabled", async () => !await hasDesign(project("p1")), 10_000)
|
|
await backendC.setLeaseContent(designLeaseContent(true))
|
|
await until("Design back with C", () => hasDesign(project("p1")), 10_000)
|
|
const third = { config: path.join(root, "third-config"), data: path.join(root, "third-config-data") }
|
|
await backendC.start(third)
|
|
assert.deepEqual(await leases(third.data), [designLeaseContent(true)])
|
|
await backendC.stop()
|
|
await until("Design gone with C stopped", async () => !await hasDesign(project("p1")), 10_000)
|
|
|
|
// AC-1 (replacement): another shim and bundle version keeps AC-4 and AC-5 true.
|
|
const bundleFile = path.join(server, "..", "..", "dist", "plugins", "session-pruning", "plugin.mjs")
|
|
const variant = Buffer.concat([await readFile(bundleFile), Buffer.from("\n// Isolated fixture variant\n")])
|
|
const variantHash = createHash("sha256").update(variant).digest("hex")
|
|
const backendD = new DesktopPluginLifecycle("session-pruning", async () => variant)
|
|
lifecycles.push(backendD)
|
|
await backendD.setLeaseContent(designLeaseContent(true))
|
|
await provision(client, backendD)
|
|
assert((await readFile(path.join(configDirectory, "plugins", "codenomad-session-pruning.ts"), "utf8")).includes(variantHash), "The shim names the replacement bundle")
|
|
await until("replacement bundle loaded", async () => (await designSkills(project("p1"))).some(skill => skill.path.includes(variantHash)), 30_000)
|
|
results.replacedAsk = await askedFor()
|
|
assert.deepEqual(results.replacedAsk, { design: 1, build: 1 })
|
|
await userWins()
|
|
await backendD.stop()
|
|
await backendA2.stop()
|
|
await backendB.stop()
|
|
assert.equal(imageCalls, 0, "Rejected requests never reach the image model")
|
|
console.log(`PASS ${version}: ${JSON.stringify(results)}`)
|
|
} finally {
|
|
for (const child of backends) child.kill("SIGKILL")
|
|
await Promise.all(lifecycles.map(lifecycle => lifecycle.stop()))
|
|
try { await stopFixtureChild(daemon, daemonStopped) } finally {
|
|
provider.closeAllConnections()
|
|
await new Promise(resolve => provider.close(resolve))
|
|
await writeFile(path.join(root, "daemon.log"), output).catch(() => {})
|
|
console.log(`Isolated fixture: ${root}`)
|
|
}
|
|
}
|