mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7868] [MERGED] feat(packages): agent package servers use the Engine's runtime services #7976
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7976
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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)
abcaf75feat(packages): agent package servers use the Engine's runtime services1537776fix(packages): keep agent runtime hooks and Mari actions out of runtime.services.get67ebc3eMerge 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
Linked issue
Closes #7858
Part of #7858: this is the server half (the
api.runtimemembers, 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:
updateMetadata(chat.id, { ...metadata, characterSchedules })) outside the Engine's metadata queue. A concurrent Engine change to the same chat can be lost.EEXISTon 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):
globalThis.__MARINARA_HOST__ = { version: 1, ... }, with no__MARINARA_HOST_UI_STORE__alias (it was never published).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.versions/.stagingbefore the Agents PR.Contract decisions this PR relies on:
packages/serverand the symlink chain the host already has, with no import map or loader hook. The host repairs a stale or dangling link.Closes #7858.Decisions I made in this PR:
patchChatMetadatakeeps the Global Gallery reference guard thatupdateChatMetadataalready has. A package patch cannot add a reference to a Global Gallery image that no longer exists.withChatLockfor the same chat,patchChatMetadataruns within that lock instead of waiting on it forever (the metadata queue is not reentrant). A patch from outside the lock still waits.appendMessagesrefuses a chat that does not exist, so a package cannot leave orphan message rows.images.addToChatGalleryaccepts only a file thatimages.savewrote inside the gallery folder.runtime.services.getreturnsnullforagent-runtime:andmari-actions:keys, even for the package that registered them. Only the Engine reads those hooks (throughgetCapabilityService), so a package cannot call another package's agent hooks or Mari actions. (Review follow-up.)capability-native-dependencies.service.ts), so the disk-cleanup PR's edits tocapability-module-runtime.service.tsdo not collide with it.What changed
capability-packages/node_moduleslink that dangles or points at another install is replaced by a link to this Engine'spackages/server/node_modules. A correct link is kept, and anything there that is not a link is left alone.supportedCapabilityApi, with its history line).api.runtimemembers, 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,stripandinstructionsuse the Engine's command registry and grammar.logger.isLevelEnabled(level)reports whether the Engine logger writes that level.persistence.patchChatMetadatauses the Engine's queued patch (one queue per chat, the shared-room guard, write ordinals).persistence.appendMessages,createChatNoteandcreateChatInfluenceuse the Engine's chat storage. All four needchat-write.integrations.admission(withProvider,run,tryBackground,isFailure) uses the Engine's connection admission.withProviderrefuses a provider that this package's integrations did not create.integrations.haptics,integrations.spotifyandintegrations.speech.transcribeLocaluse the Engine's Intiface client, the Music DJ agent's Spotify account and Local Whisper. All three neednetwork.integrations.images.addToChatGalleryandimages.persistToEntityGalleriesuse the Engine's gallery storage. Both needstorage.zod,adm-zip,dotenv,nanoidandjsonrepairfrom the Engine. A regression pins them as production dependencies ofpackages/server. It also checks that both Docker images keeppackages/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.capability-runtime-host-services.regression.tscovers every new member, its permission and its shared host state.capability-server-externals.regression.tscovers the dependency names, host-identical module instances in a real package snapshot,wsnot resolving, dangling and foreign links being rebuilt, and a non-link being kept.capability-package-lifecycle.regression.tsnow pins 1.341.capability-gm-verbs.regression.tscounts one more audited variable metadata write. It is the newpatchChatMetadata, which writes the package's own patch, so it adds no Engine key.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.withChatLockis that it now records the held lock, so a patch inside it is reentrant.Risky-work claim boundary (
.github/agents/chai-workflow.md):api.runtimeand thenode_moduleslink chain, under the same permissions it declares. A moved data folder no longer breaks package imports.createCapabilityRuntimeHost;createCapabilityIntegrationHost;createCapabilityPersistenceHost;ensureModuleResolution, vialinkCapabilityPackageDependencies;supportedCapabilityApi.distserver) and throughactivatePackage; schemaVersion 2 manifests declaring 1.341.capability*regressions (21/21).touchUpdatedAt: falsekeepsupdatedAt; a patch insidewithChatLockcompletes, and a patch from outside waits.zodby name and sees every new member.patchChatMetadatawithout the queue: the concurrent host patches lose the package key.withChatLockdeadlocks (caught by the 5 s deadline).existsSynclink check:Cannot find package 'zod'for the package.Dockerfile.litewithoutpackages/server/node_modulesfails the Docker pin.ws(a dependency of a dependency) does not resolve for a package;chat-write,network,storage);withProviderrefuses a foreign provider;appendMessagesrefuses a missing chat;services.getreturnsnullforagent-runtime:andmari-actions:keys (without the guard it returns the host-only hook);addToChatGalleryrefuses a path outside the gallery and a file that does not exist..npmrcvirtual-store-dir=.pnpm, no hoisting) resolves only the direct dependencies ofpackages/server;unlinkremoves a Windows junction itself;getCapabilityApiCompatibilityIssuechecks onlyschemaVersion: 2manifests.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
What the agent ran on this Mac (not a substitute for the boxes above):
pnpm install --frozen-lockfile --prefer-offlineandpnpm check(exit 0; the only lint output is an existing warning inHomeProfessorMariChat.tsx).node scripts/run-regressions.mjs --filter <file>afterpnpm build:sharedfor:capability-runtime-host-services;capability-server-externals;capability-package-lifecycle;capability-gm-verbs;capability-integrations;capability-persistence-permissions;capabilitygroup (21/21);haptic,galleryandspatial;mari-package-service,package-table-registration,scene-package-origin,game-metadata-raceandmusic-dj-and-floating-ui.Manually verify, for Mari:
capability-packages\node_modulesshould be a junction to the new install'spackages\server\node_modules.Not testable on this Mac: a real
~/.codex/auth.jsonrefresh, 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
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)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 noCHANGELOG.mdentry; release notes are compiled from merged PRs.UI evidence (if applicable)
No UI changes.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.