[PR #7868] [MERGED] feat(packages): agent package servers use the Engine's runtime services #7976

Closed
opened 2026-10-24 04:09:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7868
Author: @SpicyMarinara
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/packages-host-runtime


📝 Commits (3)

  • abcaf75 feat(packages): agent package servers use the Engine's runtime services
  • 1537776 fix(packages): keep agent runtime hooks and Mari actions out of runtime.services.get
  • 67ebc3e Merge remote-tracking branch 'origin/staging' into feat/packages-host-runtime

📊 Changes

12 files changed (+1129 additions, -25 deletions)

View changed files

📝 docs/development/optional-agent-packages.md (+61 -0)
📝 packages/server/src/services/capability-packages/capability-integrations.service.ts (+104 -0)
📝 packages/server/src/services/capability-packages/capability-module-runtime.service.ts (+26 -13)
📝 packages/server/src/services/capability-packages/capability-native-dependencies.service.ts (+37 -0)
📝 packages/server/src/services/capability-packages/capability-persistence.service.ts (+69 -2)
📝 packages/shared/src/schemas/capability-package.schema.ts (+2 -1)
📝 packages/shared/src/types/capability-runtime.ts (+57 -0)
📝 packages/shared/src/types/generation-integration.ts (+80 -0)
📝 scripts/regressions/capability-gm-verbs.regression.ts (+6 -3)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+7 -6)
➕ scripts/regressions/capability-runtime-host-services.regression.ts (+448 -0)
➕ scripts/regressions/capability-server-externals.regression.ts (+232 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7858

Part of #7858: this is the server half (the api.runtime members, capability API 1.341 and the shared server libraries). The client host namespace and the disk cleanup are separate Engine PRs. The package rebuild that uses these members is Pasta-Devs/Marinara-Agents#1487.

Merge order: merge this after the Engine client host namespace PR (__MARINARA_HOST__). This PR bumps the capability API to 1.341, so an Engine must never report 1.341 without the client namespace (contract C1). If staging has moved past 1.340 by then, this PR takes the next free minor. Every Engine PR of this work merges before the Agents PR (D8).

Why this change

The user problem. Calls, Noodle and Slurp bundle their own copies of Engine server services. Each copy runs a second instance with its own state, and the two drift apart:

  • Calls keeps its own Intiface client beside the Engine's, so haptics have two connections to one device.
  • Package LLM calls go through a copied connection admission table. A Noodle refresh or a Slurp background job therefore does not wait while the user's own reply streams on the same connection.
  • Calls saves character schedules by replacing the whole chat metadata blob (updateMetadata(chat.id, { ...metadata, characterSchedules })) outside the Engine's metadata queue. A concurrent Engine change to the same chat can be lost.
  • Slurp reads Long-Term Memory's storage through its own copy of the service registry, which never sees what Long-Term Memory registered.
  • Packages carry copies of the logger, the provider registry and the ChatGPT token refresh. Bugs we found only by reading code come from that: a shutdown hang, a token refresh race, two haptics clients and a cleared spatial transition coming back.
  • Package servers load bare imports through a link in the data folder. When the data folder moves to another install path (a Windows reinstall elsewhere, a moved checkout, a Termux reinstall), that link dangles. The old code then fails with EEXIST on every start, and every package import breaks for good.

This PR gives packages the Engine's live services through api.runtime, so the Agents rebuild can delete those copies. It also repairs the data folder link.

Lead decisions (binding; made by the lead while the maintainer sleeps):

  • D1 All of the audit plan ships in this release: this_release lanes 1-4, next_release phases 1-4, disk_cleanup and every guardrail. Nothing is deferred unless proven impossible.
  • D2 One namespace: globalThis.__MARINARA_HOST__ = { version: 1, ... }, with no __MARINARA_HOST_UI_STORE__ alias (it was never published).
  • D3 Rebuilt packages are gated on the host's capability API (bumped here to 1.341), not on engine.min. Engines without the members never install them and keep their installed version working. A package never falls back to a bundled copy of a stateful Engine service; it reports the feature as unavailable instead.
  • D4 Packages use the host's React and the other listed client libraries. A host React major upgrade requires a capability API major.
  • D5 During a call, Calls' connection switcher and emoji settings use the call's chat. Noodle and Slurp hide the chat-scoped emoji-selection settings.
  • D6 Bugs only reasoned from code (ChatGPT refresh race, two haptics clients, logger shutdown hang, a cleared spatial transition coming back) are fixed by moving to the host code, without a separate reproduction.
  • D7 Unchanged: uninstall keeps package data, and launcher update backups keep copying versions/.
  • D8 Every Engine PR of this work merges to staging before the Agents PR.
  • D9 Test what this Mac can. Everything else is listed below for Mari.
  • D10 Never delete user data.

Contract decisions this PR relies on:

  • C1 Target capability API 1.341, and this PR merges after the client namespace PR.
  • C5 Server externals load through the direct dependencies of packages/server and the symlink chain the host already has, with no import map or loader hook. The host repairs a stale or dangling link.
  • C12 The Engine PR body says Closes #7858.
  • C14 New regressions go in new files.

Decisions I made in this PR:

  • patchChatMetadata keeps the Global Gallery reference guard that updateChatMetadata already has. A package patch cannot add a reference to a Global Gallery image that no longer exists.
  • Inside the package's own withChatLock for the same chat, patchChatMetadata runs within that lock instead of waiting on it forever (the metadata queue is not reentrant). A patch from outside the lock still waits.
  • appendMessages refuses a chat that does not exist, so a package cannot leave orphan message rows.
  • images.addToChatGallery accepts only a file that images.save wrote inside the gallery folder.
  • runtime.services.get returns null for agent-runtime: and mari-actions: keys, even for the package that registered them. Only the Engine reads those hooks (through getCapabilityService), so a package cannot call another package's agent hooks or Mari actions. (Review follow-up.)
  • The link repair lives beside the existing native-dependency linker (capability-native-dependencies.service.ts), so the disk-cleanup PR's edits to capability-module-runtime.service.ts do not collide with it.

What changed

  • Package servers keep working when the data folder moved to a new install path (the dependency link is rebuilt). When the Engine starts or activates a package, a capability-packages/node_modules link that dangles or points at another install is replaced by a link to this Engine's packages/server/node_modules. A correct link is kept, and anything there that is not a link is left alone.
  • Capability API is now 1.341 (supportedCapabilityApi, with its history line).
  • New api.runtime members, each a thin facade over the live host function. All of them are optional in the shared types, so packages can feature-detect them:
    • services.get(key) reads the Engine's service registry. commands.parse, strip and instructions use the Engine's command registry and grammar. logger.isLevelEnabled(level) reports whether the Engine logger writes that level.
    • persistence.patchChatMetadata uses the Engine's queued patch (one queue per chat, the shared-room guard, write ordinals). persistence.appendMessages, createChatNote and createChatInfluence use the Engine's chat storage. All four need chat-write.
    • integrations.admission (withProvider, run, tryBackground, isFailure) uses the Engine's connection admission. withProvider refuses a provider that this package's integrations did not create.
    • integrations.haptics, integrations.spotify and integrations.speech.transcribeLocal use the Engine's Intiface client, the Music DJ agent's Spotify account and Local Whisper. All three need network.
    • integrations.images.addToChatGallery and images.persistToEntityGalleries use the Engine's gallery storage. Both need storage.
  • Package servers can import zod, adm-zip, dotenv, nanoid and jsonrepair from the Engine. A regression pins them as production dependencies of packages/server. It also checks that both Docker images keep packages/server/node_modules, and that neither image strips those five libraries. No install path needed a change: source, launchers, the Windows installer, Termux and both Dockerfiles already install the server's direct dependencies.
  • New regressions:
    • capability-runtime-host-services.regression.ts covers every new member, its permission and its shared host state.
    • capability-server-externals.regression.ts covers the dependency names, host-identical module instances in a real package snapshot, ws not resolving, dangling and foreign links being rebuilt, and a non-link being kept.
  • capability-package-lifecycle.regression.ts now pins 1.341.
  • capability-gm-verbs.regression.ts counts one more audited variable metadata write. It is the new patchChatMetadata, which writes the package's own patch, so it adds no Engine key.
  • Docs: a new "Capability API 1.341: host runtime services and shared server libraries" section in docs/development/optional-agent-packages.md. It covers the members, the "never a bundled copy" rule, how shared libraries resolve, the install layouts and how to declare 1.341.
  • Existing members behave as before. The only change to withChatLock is that it now records the held lock, so a patch inside it is reentrant.

Risky-work claim boundary (.github/agents/chai-workflow.md):

  • Core claim: a package server reaches the Engine's own live services and library instances through api.runtime and the node_modules link chain, under the same permissions it declares. A moved data folder no longer breaks package imports.
  • Risk type: user data (chat metadata, messages, galleries), filesystem links in the data folder, external services (Intiface, Spotify), and compatibility (capability API gate).
  • Entrypoints touched:
    • createCapabilityRuntimeHost;
    • createCapabilityIntegrationHost;
    • createCapabilityPersistenceHost;
    • ensureModuleResolution, via linkCapabilityPackageDependencies;
    • supportedCapabilityApi.
  • Current paths/formats tested: packages activated through the real module runtime, both at server start (built dist server) and through activatePackage; schemaVersion 2 manifests declaring 1.341.
  • Legacy paths/formats tested: schemaVersion 1 fixture packages still activate. The existing integrations, persistence-permission and lifecycle regressions still pass, and so do the other capability* regressions (21/21).
  • Positive rows tested:
    • services: a service is visible across packages and gone after deactivation.
    • commands: a registered tag is parsed and stripped, and its instruction is listed.
    • logger: the logger level is followed live.
    • metadata patches: 5 package and 5 host increments run concurrently and all survive; the patch is ordinal-stamped; touchUpdatedAt: false keeps updatedAt; a patch inside withChatLock completes, and a patch from outside waits.
    • messages, notes and influences: appended messages each get their first swipe, and the note and influence land in host storage.
    • admission: background work is busy while a foreground attempt runs, including one the Engine started outside any package, and becomes free after the idle window.
    • haptics, Spotify and local speech: haptics status equals the host service's status; Spotify reports unavailable with no Music DJ agent; local speech gives the host's "Download Local Whisper" message.
    • galleries: a chat gallery row and a character gallery row are created.
    • libraries: zod, adm-zip, dotenv, nanoid and jsonrepair are the host's own module instances inside a package snapshot.
    • live boot: the built server started on a data folder with a dangling link, relinked it (log line "Relinking package runtime dependencies"), and activated a 1.341 package that imports zod by name and sees every new member.
  • Negative controls tested (each one run and seen failing, then reverted):
    • patchChatMetadata without the queue: the concurrent host patches lose the package key.
    • Without lock reentrancy: the patch inside withChatLock deadlocks (caught by the 5 s deadline).
    • Without the gallery guard: a missing-image reference is accepted.
    • The old existsSync link check: Cannot find package 'zod' for the package.
    • A Dockerfile.lite without packages/server/node_modules fails the Docker pin.
    • In the regression itself:
      • ws (a dependency of a dependency) does not resolve for a package;
      • every new member refuses without its permission (chat-write, network, storage);
      • withProvider refuses a foreign provider;
      • appendMessages refuses a missing chat;
      • services.get returns null for agent-runtime: and mari-actions: keys (without the guard it returns the host-only hook);
      • addToChatGallery refuses a path outside the gallery and a file that does not exist.
  • Ground-truth facts used:
    • pnpm's strict layout (.npmrc virtual-store-dir=.pnpm, no hoisting) resolves only the direct dependencies of packages/server;
    • Node keys ES modules by realpath, so one URL is one instance;
    • libuv's unlink removes a Windows junction itself;
    • getCapabilityApiCompatibilityIssue checks only schemaVersion: 2 manifests.
  • Manual blockers: see the list below: Intiface, Spotify, Local Whisper with a real model, Windows junctions, Docker, Termux, and older Engines.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What the agent ran on this Mac (not a substitute for the boxes above):

  • pnpm install --frozen-lockfile --prefer-offline and pnpm check (exit 0; the only lint output is an existing warning in HomeProfessorMariChat.tsx).
  • node scripts/run-regressions.mjs --filter <file> after pnpm build:shared for:
    • capability-runtime-host-services;
    • capability-server-externals;
    • capability-package-lifecycle;
    • capability-gm-verbs;
    • capability-integrations;
    • capability-persistence-permissions;
    • the whole capability group (21/21);
    • haptic, gallery and spatial;
    • mari-package-service, package-table-registration, scene-package-origin, game-metadata-race and music-dj-and-floating-ui.
  • A live boot of the built server on its own data folder and port, described above.

Manually verify, for Mari:

  • Manually verify on a Windows install: move the Marinara data folder to another install path (or reinstall to another folder), start Marinara Engine, and check that an installed agent with server code (Calls, Noodle or Slurp) still activates. The log should say "Relinking package runtime dependencies", and capability-packages\node_modules should be a junction to the new install's packages\server\node_modules.
  • Manually verify that Docker (both the full and the lite image) and Termux start an agent with server code after the Agents PR lands (zod is then loaded from the Engine).
  • Manually verify Calls haptics with Intiface Central (or its simulator) after the Agents PR lands: one Intiface connection, and the device reacts.
  • Manually verify Calls song commands with a connected Spotify account after the Agents PR lands.
  • Manually verify a Calls call in Local Whisper mode, with Local Whisper downloaded in Connections, after the Agents PR lands.
  • Manually verify ChatGPT (subscription) generation in Noodle and Slurp after a token refresh, after the Agents PR lands.
  • Manually verify on a v2.5.0 install that the rebuilt agent versions are refused with "Package requires capability API 1.341; this Engine supports 1.66", and that the installed versions keep working.
  • Manually verify that character schedules set during a call are kept while you change another chat setting at the same time (after the Agents PR lands).

Not testable on this Mac: a real ~/.codex/auth.json refresh, Intiface with a device, Spotify playback, real provider keys, Windows junctions, Docker, Android/Termux, and older Engines reading the new catalog entries.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

The only docs change is the new developer section in docs/development/optional-agent-packages.md. No [docs-i18n] issue was opened, because the held release translation PR covers docs. There is no CHANGELOG.md entry; release notes are compiled from merged PRs.

UI evidence (if applicable)

No UI changes.

Summary by CodeRabbit

  • New Features
    • Capability packages can use shared services for commands, logging, metadata, messages, notes, and influences.
    • Added integrations for image galleries, local speech transcription, connection admission, haptics, and Spotify playback.
    • Packages can access shared server dependencies without bundling duplicate copies.
  • Compatibility
    • Updated the Capability API to version 1.341.
    • Incompatible or unauthorized packages are rejected or have restricted access.
  • Documentation
    • Added guidance for using the new package capabilities and handling unavailable services.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7868 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/20/2026 **Status:** ✅ Merged **Merged:** 10/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/packages-host-runtime` --- ### 📝 Commits (3) - [`abcaf75`](https://github.com/Pasta-Devs/Marinara-Engine/commit/abcaf758fa062d78e463d62e189dc37df02f72c9) feat(packages): agent package servers use the Engine's runtime services - [`1537776`](https://github.com/Pasta-Devs/Marinara-Engine/commit/153777686c4eff43d4a07f851a7a5ea5d6e49e04) fix(packages): keep agent runtime hooks and Mari actions out of runtime.services.get - [`67ebc3e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/67ebc3e4e1859be6e89086f31adf136146086740) Merge remote-tracking branch 'origin/staging' into feat/packages-host-runtime ### 📊 Changes **12 files changed** (+1129 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/optional-agent-packages.md` (+61 -0) 📝 `packages/server/src/services/capability-packages/capability-integrations.service.ts` (+104 -0) 📝 `packages/server/src/services/capability-packages/capability-module-runtime.service.ts` (+26 -13) 📝 `packages/server/src/services/capability-packages/capability-native-dependencies.service.ts` (+37 -0) 📝 `packages/server/src/services/capability-packages/capability-persistence.service.ts` (+69 -2) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+2 -1) 📝 `packages/shared/src/types/capability-runtime.ts` (+57 -0) 📝 `packages/shared/src/types/generation-integration.ts` (+80 -0) 📝 `scripts/regressions/capability-gm-verbs.regression.ts` (+6 -3) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+7 -6) ➕ `scripts/regressions/capability-runtime-host-services.regression.ts` (+448 -0) ➕ `scripts/regressions/capability-server-externals.regression.ts` (+232 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7858 Part of #7858: this is the server half (the `api.runtime` members, capability API 1.341 and the shared server libraries). The client host namespace and the disk cleanup are separate Engine PRs. The package rebuild that uses these members is Pasta-Devs/Marinara-Agents#1487. **Merge order:** merge this after the Engine client host namespace PR (`__MARINARA_HOST__`). This PR bumps the capability API to 1.341, so an Engine must never report 1.341 without the client namespace (contract C1). If staging has moved past 1.340 by then, this PR takes the next free minor. Every Engine PR of this work merges before the Agents PR (D8). ## Why this change **The user problem.** Calls, Noodle and Slurp bundle their own copies of Engine server services. Each copy runs a second instance with its own state, and the two drift apart: - Calls keeps its own Intiface client beside the Engine's, so haptics have two connections to one device. - Package LLM calls go through a copied connection admission table. A Noodle refresh or a Slurp background job therefore does not wait while the user's own reply streams on the same connection. - Calls saves character schedules by replacing the whole chat metadata blob (`updateMetadata(chat.id, { ...metadata, characterSchedules })`) outside the Engine's metadata queue. A concurrent Engine change to the same chat can be lost. - Slurp reads Long-Term Memory's storage through its own copy of the service registry, which never sees what Long-Term Memory registered. - Packages carry copies of the logger, the provider registry and the ChatGPT token refresh. Bugs we found only by reading code come from that: a shutdown hang, a token refresh race, two haptics clients and a cleared spatial transition coming back. - Package servers load bare imports through a link in the data folder. When the data folder moves to another install path (a Windows reinstall elsewhere, a moved checkout, a Termux reinstall), that link dangles. The old code then fails with `EEXIST` on every start, and every package import breaks for good. This PR gives packages the Engine's live services through `api.runtime`, so the Agents rebuild can delete those copies. It also repairs the data folder link. **Lead decisions** (binding; made by the lead while the maintainer sleeps): - **D1** All of the audit plan ships in this release: this_release lanes 1-4, next_release phases 1-4, disk_cleanup and every guardrail. Nothing is deferred unless proven impossible. - **D2** One namespace: `globalThis.__MARINARA_HOST__ = { version: 1, ... }`, with no `__MARINARA_HOST_UI_STORE__` alias (it was never published). - **D3** Rebuilt packages are gated on the host's capability API (bumped here to 1.341), not on `engine.min`. Engines without the members never install them and keep their installed version working. A package never falls back to a bundled copy of a stateful Engine service; it reports the feature as unavailable instead. - **D4** Packages use the host's React and the other listed client libraries. A host React major upgrade requires a capability API major. - **D5** During a call, Calls' connection switcher and emoji settings use the call's chat. Noodle and Slurp hide the chat-scoped emoji-selection settings. - **D6** Bugs only reasoned from code (ChatGPT refresh race, two haptics clients, logger shutdown hang, a cleared spatial transition coming back) are fixed by moving to the host code, without a separate reproduction. - **D7** Unchanged: uninstall keeps package data, and launcher update backups keep copying `versions/`. - **D8** Every Engine PR of this work merges to `staging` before the Agents PR. - **D9** Test what this Mac can. Everything else is listed below for Mari. - **D10** Never delete user data. **Contract decisions this PR relies on:** - **C1** Target capability API 1.341, and this PR merges after the client namespace PR. - **C5** Server externals load through the direct dependencies of `packages/server` and the symlink chain the host already has, with no import map or loader hook. The host repairs a stale or dangling link. - **C12** The Engine PR body says `Closes #7858`. - **C14** New regressions go in new files. **Decisions I made in this PR:** - `patchChatMetadata` keeps the Global Gallery reference guard that `updateChatMetadata` already has. A package patch cannot add a reference to a Global Gallery image that no longer exists. - Inside the package's own `withChatLock` for the same chat, `patchChatMetadata` runs within that lock instead of waiting on it forever (the metadata queue is not reentrant). A patch from outside the lock still waits. - `appendMessages` refuses a chat that does not exist, so a package cannot leave orphan message rows. - `images.addToChatGallery` accepts only a file that `images.save` wrote inside the gallery folder. - `runtime.services.get` returns `null` for `agent-runtime:` and `mari-actions:` keys, even for the package that registered them. Only the Engine reads those hooks (through `getCapabilityService`), so a package cannot call another package's agent hooks or Mari actions. (Review follow-up.) - The link repair lives beside the existing native-dependency linker (`capability-native-dependencies.service.ts`), so the disk-cleanup PR's edits to `capability-module-runtime.service.ts` do not collide with it. ## What changed - Package servers keep working when the data folder moved to a new install path (the dependency link is rebuilt). When the Engine starts or activates a package, a `capability-packages/node_modules` link that dangles or points at another install is replaced by a link to this Engine's `packages/server/node_modules`. A correct link is kept, and anything there that is not a link is left alone. - Capability API is now **1.341** (`supportedCapabilityApi`, with its history line). - New `api.runtime` members, each a thin facade over the live host function. All of them are optional in the shared types, so packages can feature-detect them: - `services.get(key)` reads the Engine's service registry. `commands.parse`, `strip` and `instructions` use the Engine's command registry and grammar. `logger.isLevelEnabled(level)` reports whether the Engine logger writes that level. - `persistence.patchChatMetadata` uses the Engine's queued patch (one queue per chat, the shared-room guard, write ordinals). `persistence.appendMessages`, `createChatNote` and `createChatInfluence` use the Engine's chat storage. All four need `chat-write`. - `integrations.admission` (`withProvider`, `run`, `tryBackground`, `isFailure`) uses the Engine's connection admission. `withProvider` refuses a provider that this package's integrations did not create. - `integrations.haptics`, `integrations.spotify` and `integrations.speech.transcribeLocal` use the Engine's Intiface client, the Music DJ agent's Spotify account and Local Whisper. All three need `network`. - `integrations.images.addToChatGallery` and `images.persistToEntityGalleries` use the Engine's gallery storage. Both need `storage`. - Package servers can import `zod`, `adm-zip`, `dotenv`, `nanoid` and `jsonrepair` from the Engine. A regression pins them as production dependencies of `packages/server`. It also checks that both Docker images keep `packages/server/node_modules`, and that neither image strips those five libraries. No install path needed a change: source, launchers, the Windows installer, Termux and both Dockerfiles already install the server's direct dependencies. - New regressions: - `capability-runtime-host-services.regression.ts` covers every new member, its permission and its shared host state. - `capability-server-externals.regression.ts` covers the dependency names, host-identical module instances in a real package snapshot, `ws` not resolving, dangling and foreign links being rebuilt, and a non-link being kept. - `capability-package-lifecycle.regression.ts` now pins 1.341. - `capability-gm-verbs.regression.ts` counts one more audited variable metadata write. It is the new `patchChatMetadata`, which writes the package's own patch, so it adds no Engine key. - Docs: a new "Capability API 1.341: host runtime services and shared server libraries" section in `docs/development/optional-agent-packages.md`. It covers the members, the "never a bundled copy" rule, how shared libraries resolve, the install layouts and how to declare 1.341. - Existing members behave as before. The only change to `withChatLock` is that it now records the held lock, so a patch inside it is reentrant. **Risky-work claim boundary** (`.github/agents/chai-workflow.md`): - **Core claim:** a package server reaches the Engine's own live services and library instances through `api.runtime` and the `node_modules` link chain, under the same permissions it declares. A moved data folder no longer breaks package imports. - **Risk type:** user data (chat metadata, messages, galleries), filesystem links in the data folder, external services (Intiface, Spotify), and compatibility (capability API gate). - **Entrypoints touched:** - `createCapabilityRuntimeHost`; - `createCapabilityIntegrationHost`; - `createCapabilityPersistenceHost`; - `ensureModuleResolution`, via `linkCapabilityPackageDependencies`; - `supportedCapabilityApi`. - **Current paths/formats tested:** packages activated through the real module runtime, both at server start (built `dist` server) and through `activatePackage`; schemaVersion 2 manifests declaring 1.341. - **Legacy paths/formats tested:** schemaVersion 1 fixture packages still activate. The existing integrations, persistence-permission and lifecycle regressions still pass, and so do the other `capability*` regressions (21/21). - **Positive rows tested:** - services: a service is visible across packages and gone after deactivation. - commands: a registered tag is parsed and stripped, and its instruction is listed. - logger: the logger level is followed live. - metadata patches: 5 package and 5 host increments run concurrently and all survive; the patch is ordinal-stamped; `touchUpdatedAt: false` keeps `updatedAt`; a patch inside `withChatLock` completes, and a patch from outside waits. - messages, notes and influences: appended messages each get their first swipe, and the note and influence land in host storage. - admission: background work is busy while a foreground attempt runs, including one the Engine started outside any package, and becomes free after the idle window. - haptics, Spotify and local speech: haptics status equals the host service's status; Spotify reports unavailable with no Music DJ agent; local speech gives the host's "Download Local Whisper" message. - galleries: a chat gallery row and a character gallery row are created. - libraries: zod, adm-zip, dotenv, nanoid and jsonrepair are the host's own module instances inside a package snapshot. - live boot: the built server started on a data folder with a dangling link, relinked it (log line "Relinking package runtime dependencies"), and activated a 1.341 package that imports `zod` by name and sees every new member. - **Negative controls tested** (each one run and seen failing, then reverted): - `patchChatMetadata` without the queue: the concurrent host patches lose the package key. - Without lock reentrancy: the patch inside `withChatLock` deadlocks (caught by the 5 s deadline). - Without the gallery guard: a missing-image reference is accepted. - The old `existsSync` link check: `Cannot find package 'zod'` for the package. - A `Dockerfile.lite` without `packages/server/node_modules` fails the Docker pin. - In the regression itself: - `ws` (a dependency of a dependency) does not resolve for a package; - every new member refuses without its permission (`chat-write`, `network`, `storage`); - `withProvider` refuses a foreign provider; - `appendMessages` refuses a missing chat; - `services.get` returns `null` for `agent-runtime:` and `mari-actions:` keys (without the guard it returns the host-only hook); - `addToChatGallery` refuses a path outside the gallery and a file that does not exist. - **Ground-truth facts used:** - pnpm's strict layout (`.npmrc` `virtual-store-dir=.pnpm`, no hoisting) resolves only the direct dependencies of `packages/server`; - Node keys ES modules by realpath, so one URL is one instance; - libuv's `unlink` removes a Windows junction itself; - `getCapabilityApiCompatibilityIssue` checks only `schemaVersion: 2` manifests. - **Manual blockers:** see the list below: Intiface, Spotify, Local Whisper with a real model, Windows junctions, Docker, Termux, and older Engines. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What the agent ran on this Mac (not a substitute for the boxes above): - `pnpm install --frozen-lockfile --prefer-offline` and `pnpm check` (exit 0; the only lint output is an existing warning in `HomeProfessorMariChat.tsx`). - `node scripts/run-regressions.mjs --filter <file>` after `pnpm build:shared` for: - `capability-runtime-host-services`; - `capability-server-externals`; - `capability-package-lifecycle`; - `capability-gm-verbs`; - `capability-integrations`; - `capability-persistence-permissions`; - the whole `capability` group (21/21); - `haptic`, `gallery` and `spatial`; - `mari-package-service`, `package-table-registration`, `scene-package-origin`, `game-metadata-race` and `music-dj-and-floating-ui`. - A live boot of the built server on its own data folder and port, described above. Manually verify, for Mari: - Manually verify on a Windows install: move the Marinara data folder to another install path (or reinstall to another folder), start Marinara Engine, and check that an installed agent with server code (Calls, Noodle or Slurp) still activates. The log should say "Relinking package runtime dependencies", and `capability-packages\node_modules` should be a junction to the new install's `packages\server\node_modules`. - Manually verify that Docker (both the full and the lite image) and Termux start an agent with server code after the Agents PR lands (zod is then loaded from the Engine). - Manually verify Calls haptics with Intiface Central (or its simulator) after the Agents PR lands: one Intiface connection, and the device reacts. - Manually verify Calls song commands with a connected Spotify account after the Agents PR lands. - Manually verify a Calls call in Local Whisper mode, with Local Whisper downloaded in Connections, after the Agents PR lands. - Manually verify ChatGPT (subscription) generation in Noodle and Slurp after a token refresh, after the Agents PR lands. - Manually verify on a v2.5.0 install that the rebuilt agent versions are refused with "Package requires capability API 1.341; this Engine supports 1.66", and that the installed versions keep working. - Manually verify that character schedules set during a call are kept while you change another chat setting at the same time (after the Agents PR lands). Not testable on this Mac: a real `~/.codex/auth.json` refresh, Intiface with a device, Spotify playback, real provider keys, Windows junctions, Docker, Android/Termux, and older Engines reading the new catalog entries. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) The only docs change is the new developer section in `docs/development/optional-agent-packages.md`. No `[docs-i18n]` issue was opened, because the held release translation PR covers docs. There is no `CHANGELOG.md` entry; release notes are compiled from merged PRs. ## UI evidence (if applicable) No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Capability packages can use shared services for commands, logging, metadata, messages, notes, and influences. - Added integrations for image galleries, local speech transcription, connection admission, haptics, and Spotify playback. - Packages can access shared server dependencies without bundling duplicate copies. - **Compatibility** - Updated the Capability API to version 1.341. - Incompatible or unauthorized packages are rejected or have restricted access. - **Documentation** - Added guidance for using the new package capabilities and handling unavailable services. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:09:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7976
No description provided.