[PR #6800] [MERGED] feat(mari): let Professor Mari list and run actions that packages offer #7336

Closed
opened 2026-10-23 04:18:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6800
Author: @Gunterlie
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/28/2026
Merged by: @Gunterlie

Base: staging ← Head: feat/mari-package-service-tool


📝 Commits (7)

  • 7a5367e feat(mari): let Professor Mari list and run actions that packages offer her
  • 871090b fix(mari): bound package actions and their text
  • fecc4cf fix(mari): a package run that throws at once cannot crash the Engine
  • 3a4b752 docs(changelog): link the Mari package actions issue
  • b71246a Merge remote-tracking branch 'origin/staging' into codex/assigned-6800
  • 5a78945 fix(mari): cancel package action discovery on Stop
  • e0f4c13 fix(mari): reject stale package actions after deactivation

📊 Changes

10 files changed (+673 additions, -10 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 docs/development/optional-agent-packages.md (+46 -0)
➕ packages/server/src/services/capability-packages/capability-mari-actions.service.ts (+202 -0)
📝 packages/server/src/services/capability-packages/capability-module-runtime.service.ts (+2 -0)
📝 packages/server/src/services/capability-packages/capability-service-registry.service.ts (+4 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+82 -4)
📝 packages/shared/src/schemas/capability-package.schema.ts (+16 -1)
📝 packages/shared/src/types/professor-mari-workspace.ts (+2 -1)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+4 -4)
➕ scripts/regressions/mari-package-service.regression.ts (+311 -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 #6799

Why this change

  • Professor Mari cannot act inside a capability package. Her tools are a fixed list, her mari CLI only reaches the Engine data service, and the capability activation API has no way for a package to offer her anything.
  • Packages already have typed, validated action layers. Slurp (Marinara-Agents slurp2) registers a slurp2:actions service with nine actions (write or improve a text field, draw a picture, steer a Creator, add a post idea, write a post, …). A user who asks Mari "give this Creator an idea for a rainy-day post" gets nothing today.
  • This adds the smallest Engine seam for that: a package declares that Mari may call it, and Mari gets one tool to list and run what it offers.

What changed

  • New permission mari-actions, Capability API 1.50 (capability-package.schema.ts). A manifest that declares it with an older capabilityApi is refused, like tools and achievements.
  • Registration gate (capability-mari-actions.service.ts, wired into registerService in capability-module-runtime.service.ts). A package with the permission registers mari-actions:<its own id> with { list, run }. Without the permission, or under another package's id, registration throws. This mirrors the agent-runtime:<id> gate, so the key proves which package owns the actions.
  • New Mari workspace tool package_service (workspace-agent.service.ts, MariWorkspaceToolName):
    • No arguments → lists every active package's actions (name, summary, input descriptions). package only → one package. Read-only.
    • package + action + input → runs one action. This counts as a change for Permissions Mode: Plan refuses it, Manual holds it for Accept, and the ask latch applies.
    • Added to the tool list and definitions (native and textual tool calls), the JSON protocol name list, the XML fallback, the prompt's command families, a JSON example, and the understood-request diagnostics label.
    • A successful run carries no read-back debt: no Engine read can check a package's state, so demanding one would only force a meaningless extra round. A failed run still blocks completion claims. A package list never counts as a state read.
  • Bounds at the boundary (package code and model input): input must be a JSON object (a JSON string is accepted for text-protocol models), at most 64,000 characters, passed as a JSON round-tripped copy; the action must be in the package's own list. List text is typed and capped (50 actions, 40 inputs, 300 characters per text); lists run in parallel with a 5 s deadline per package. A run gets an AbortSignal that fires on Mari's Stop, and the Engine stops waiting after 5 minutes even if the package ignores it, so a stuck package cannot hold Mari's serialized change lane. Error text is capped at 2,000 characters. Data URLs are elided from results and errors.
  • listCapabilityServiceKeys(prefix) in the service registry.
  • Docs: new "Capability API 1.50: Professor Mari actions" section in docs/development/optional-agent-packages.md; CHANGELOG [Unreleased] entry.
  • Tests: new scripts/regressions/mari-package-service.regression.ts; capability-package-lifecycle.regression.ts bumped to 1.50.

Package side (not in this PR): Slurp would add the mari-actions permission, capabilityApi 1.50 and one api.registerService("mari-actions:slurp2", …) line next to its existing slurp2:actions registration. Until a package does that, Mari's list says no package offers actions.

Security notes

This lets a model-driven agent act inside package code, so it is security-sensitive.

  • Core claim: Mari can only run actions that an active package explicitly offers through mari-actions:<own-id>, only with a bounded plain-JSON object, and only under the user's Permissions Mode.
  • Entry points touched: registerService in the capability runtime; the Mari command dispatcher, classifiers (isReadOnlyWorkspaceCommand, isMutatingWorkspaceCommand), claim audit (resolveWorkspaceMutationVerification, isSuccessfulStateRead) and protocol parsers.
  • Trust boundary: packages are already trusted in-process code (official catalog or a trusted custom repository), so package-authored list text in Mari's prompt is no new trust grant; it is still typed and capped. Model input is untrusted: the Engine checks shape, size and action membership, and the package must validate against its own schema (documented).
  • Unchanged: no new HTTP route; no change to the mari CLI, the shell sandbox or app_data. Packages still cannot look up each other's services.
  • No preview / no Keep-Restore: the Engine cannot preview or undo a package action, so every run counts as mutating (Plan refuses even read-only actions), and the docs ask packages to offer their own undo action.
  • Negative controls in the regression: missing permission, foreign package id, API 1.49 manifest, unknown package, unknown or malformed action name, non-object and oversized input, a package error, a run that throws synchronously (no unhandled rejection), a hung run ended by Mari's Stop, a hung and a throwing list(), data URLs in results and errors, a list used as a state read.

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 devbox (automated only; the boxes above are for the human reviewer):

  • pnpm check: passed on the code commits (format, lint, e2e/token types, build). The last commit only adds the issue number to CHANGELOG.
  • node scripts/run-regressions.mjs --filter scripts/regressions/mari-package-service.regression.ts: passed. The synchronous-throw assertion was shown to fail with its fix removed.
  • --filter capability: 17/17 passed. --filter shell-sandbox: 1/1 passed.
  • --filter mari: 27/28 passed. mari-completion-frames.regression.ts times out at 30 s on this host, and times out the same way with this PR's server sources replaced by the staging versions, so it is not caused by this change.
  • Local CodeRabbit review against origin/staging: 0 findings. Two read-only Opus review passes; all their findings are fixed in this branch.

Still to verify by hand:

  • Manually verify in a running Engine with a test package that registers mari-actions:<id>: ask Mari which actions your packages offer, and check she lists them.
  • Manually verify Mari runs one action on request and reports its result, and that invalid input shows the package's error.
  • Manually verify Plan mode refuses a run and Manual mode holds it behind Accept.
  • Manually verify Stop during a slow action ends the run and Mari can continue.
  • Manually verify a text-protocol or local sidecar model can call the tool through the JSON fallback.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

Docs touched: CHANGELOG.md, docs/development/optional-agent-packages.md. The translated copies of development/optional-agent-packages.md on docs-i18n are not updated; translation follow-up #6803 covers this new section. No version bump.

UI evidence (if applicable)

No UI change. The Agents catalog shows raw permission ids, so the new permission appears as "mari actions" without new copy.

Summary by CodeRabbit

  • New Features
    • Professor Mari can discover and run actions provided by installed Agent packages, with optional filtering by package.
    • Package actions require the appropriate permission and Capability API 1.50 or later. The active Permissions Mode applies to each run.
  • Documentation
    • Added guidance for package authors on enabling and handling package actions.

Maintainer review validation

Reviewed and corrected at 5a789451c: Stop now cancels both discovery and pre-run action listing; malformed input is rejected before package code runs. The staging changelog conflict is resolved. pnpm check passed, package-service regression passed, capability regressions passed 17/17, and Mari regressions passed 28/28 (including the previously reported completion-frame timeout and shell sandbox). These checks use disposable data.

Local CodeRabbit completed with three findings dismissed after checking the actual source: the alleged duplicate module blocks do not exist (each function/regression declaration occurs once), and the requested signal parameter/abort race is present in actionsOf and listCapabilityMariActions. Type checking, production build and cancellation regression all pass. Hosted review of the pushed revision remains a merge gate. Human verification boxes remain unchanged.

Follow-up independent lifecycle review at e0f4c1393: if a package unregisters or replaces its service while list() is pending, the stale service is no longer advertised or executed. Deterministic removal/replacement regressions pass, pnpm check passes, and capability regressions pass 17/17. The prior head’s hosted CodeRabbit review completed before this follow-up was pushed; new-head review and checks remain required.


🔄 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/6800 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 9/28/2026 **Status:** ✅ Merged **Merged:** 9/28/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `feat/mari-package-service-tool` --- ### 📝 Commits (7) - [`7a5367e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7a5367eedac4ecc0a10aea5565c2d11e8e67a4c9) feat(mari): let Professor Mari list and run actions that packages offer her - [`871090b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/871090bf5c121611dc4062169e00dccbad4f99f4) fix(mari): bound package actions and their text - [`fecc4cf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fecc4cfbbbf7b62dcac7a26093af6519ebe8c981) fix(mari): a package run that throws at once cannot crash the Engine - [`3a4b752`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a4b752e1eacfbd77473dadec2394dbe62bca014) docs(changelog): link the Mari package actions issue - [`b71246a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b71246a6bc870a4b2ad81a7f403aa1ce0b580a53) Merge remote-tracking branch 'origin/staging' into codex/assigned-6800 - [`5a78945`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5a789451ca8ddb7accfefc5fdb2ace7621a35da5) fix(mari): cancel package action discovery on Stop - [`e0f4c13`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e0f4c139353aca40ae85f514a351c25c3bb8d2c7) fix(mari): reject stale package actions after deactivation ### 📊 Changes **10 files changed** (+673 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `docs/development/optional-agent-packages.md` (+46 -0) ➕ `packages/server/src/services/capability-packages/capability-mari-actions.service.ts` (+202 -0) 📝 `packages/server/src/services/capability-packages/capability-module-runtime.service.ts` (+2 -0) 📝 `packages/server/src/services/capability-packages/capability-service-registry.service.ts` (+4 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+82 -4) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+16 -1) 📝 `packages/shared/src/types/professor-mari-workspace.ts` (+2 -1) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+4 -4) ➕ `scripts/regressions/mari-package-service.regression.ts` (+311 -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 <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #6799 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Professor Mari cannot act inside a capability package. Her tools are a fixed list, her `mari` CLI only reaches the Engine data service, and the capability activation API has no way for a package to offer her anything. - Packages already have typed, validated action layers. Slurp (Marinara-Agents `slurp2`) registers a `slurp2:actions` service with nine actions (write or improve a text field, draw a picture, steer a Creator, add a post idea, write a post, …). A user who asks Mari "give this Creator an idea for a rainy-day post" gets nothing today. - This adds the smallest Engine seam for that: a package declares that Mari may call it, and Mari gets one tool to list and run what it offers. ## What changed <!-- List the key changes in this PR --> - **New permission `mari-actions`, Capability API 1.50** (`capability-package.schema.ts`). A manifest that declares it with an older `capabilityApi` is refused, like `tools` and `achievements`. - **Registration gate** (`capability-mari-actions.service.ts`, wired into `registerService` in `capability-module-runtime.service.ts`). A package with the permission registers `mari-actions:<its own id>` with `{ list, run }`. Without the permission, or under another package's id, registration throws. This mirrors the `agent-runtime:<id>` gate, so the key proves which package owns the actions. - **New Mari workspace tool `package_service`** (`workspace-agent.service.ts`, `MariWorkspaceToolName`): - No arguments → lists every active package's actions (name, summary, input descriptions). `package` only → one package. Read-only. - `package` + `action` + `input` → runs one action. This counts as a change for Permissions Mode: Plan refuses it, Manual holds it for Accept, and the ask latch applies. - Added to the tool list and definitions (native and textual tool calls), the JSON protocol name list, the XML fallback, the prompt's command families, a JSON example, and the understood-request diagnostics label. - A successful run carries no read-back debt: no Engine read can check a package's state, so demanding one would only force a meaningless extra round. A failed run still blocks completion claims. A package list never counts as a state read. - **Bounds at the boundary** (package code and model input): input must be a JSON object (a JSON string is accepted for text-protocol models), at most 64,000 characters, passed as a JSON round-tripped copy; the action must be in the package's own list. List text is typed and capped (50 actions, 40 inputs, 300 characters per text); lists run in parallel with a 5 s deadline per package. A run gets an `AbortSignal` that fires on Mari's Stop, and the Engine stops waiting after 5 minutes even if the package ignores it, so a stuck package cannot hold Mari's serialized change lane. Error text is capped at 2,000 characters. Data URLs are elided from results and errors. - `listCapabilityServiceKeys(prefix)` in the service registry. - Docs: new "Capability API 1.50: Professor Mari actions" section in `docs/development/optional-agent-packages.md`; CHANGELOG `[Unreleased]` entry. - Tests: new `scripts/regressions/mari-package-service.regression.ts`; `capability-package-lifecycle.regression.ts` bumped to 1.50. Package side (not in this PR): Slurp would add the `mari-actions` permission, `capabilityApi` 1.50 and one `api.registerService("mari-actions:slurp2", …)` line next to its existing `slurp2:actions` registration. Until a package does that, Mari's list says no package offers actions. ### Security notes This lets a model-driven agent act inside package code, so it is security-sensitive. - **Core claim:** Mari can only run actions that an active package explicitly offers through `mari-actions:<own-id>`, only with a bounded plain-JSON object, and only under the user's Permissions Mode. - **Entry points touched:** `registerService` in the capability runtime; the Mari command dispatcher, classifiers (`isReadOnlyWorkspaceCommand`, `isMutatingWorkspaceCommand`), claim audit (`resolveWorkspaceMutationVerification`, `isSuccessfulStateRead`) and protocol parsers. - **Trust boundary:** packages are already trusted in-process code (official catalog or a trusted custom repository), so package-authored list text in Mari's prompt is no new trust grant; it is still typed and capped. Model input is untrusted: the Engine checks shape, size and action membership, and the package must validate against its own schema (documented). - **Unchanged:** no new HTTP route; no change to the `mari` CLI, the shell sandbox or `app_data`. Packages still cannot look up each other's services. - **No preview / no Keep-Restore:** the Engine cannot preview or undo a package action, so every run counts as mutating (Plan refuses even read-only actions), and the docs ask packages to offer their own undo action. - **Negative controls in the regression:** missing permission, foreign package id, API 1.49 manifest, unknown package, unknown or malformed action name, non-object and oversized input, a package error, a run that throws synchronously (no unhandled rejection), a hung run ended by Mari's Stop, a hung and a throwing `list()`, data URLs in results and errors, a list used as a state read. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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 <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> What the agent ran on devbox (automated only; the boxes above are for the human reviewer): - `pnpm check`: passed on the code commits (format, lint, e2e/token types, build). The last commit only adds the issue number to CHANGELOG. - `node scripts/run-regressions.mjs --filter scripts/regressions/mari-package-service.regression.ts`: passed. The synchronous-throw assertion was shown to fail with its fix removed. - `--filter capability`: 17/17 passed. `--filter shell-sandbox`: 1/1 passed. - `--filter mari`: 27/28 passed. `mari-completion-frames.regression.ts` times out at 30 s on this host, and times out the same way with this PR's server sources replaced by the `staging` versions, so it is not caused by this change. - Local CodeRabbit review against `origin/staging`: 0 findings. Two read-only Opus review passes; all their findings are fixed in this branch. Still to verify by hand: - Manually verify in a running Engine with a test package that registers `mari-actions:<id>`: ask Mari which actions your packages offer, and check she lists them. - Manually verify Mari runs one action on request and reports its result, and that invalid input shows the package's error. - Manually verify Plan mode refuses a run and Manual mode holds it behind Accept. - Manually verify Stop during a slow action ends the run and Mari can continue. - Manually verify a text-protocol or local sidecar model can call the tool through the JSON fallback. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) Docs touched: `CHANGELOG.md`, `docs/development/optional-agent-packages.md`. The translated copies of `development/optional-agent-packages.md` on `docs-i18n` are not updated; translation follow-up #6803 covers this new section. No version bump. ## UI evidence (if applicable) <!-- Add before/after screenshots or recordings for UI changes --> No UI change. The Agents catalog shows raw permission ids, so the new permission appears as "mari actions" without new copy. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Professor Mari can discover and run actions provided by installed Agent packages, with optional filtering by package. * Package actions require the appropriate permission and Capability API 1.50 or later. The active Permissions Mode applies to each run. * **Documentation** * Added guidance for package authors on enabling and handling package actions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ### Maintainer review validation Reviewed and corrected at `5a789451c`: Stop now cancels both discovery and pre-run action listing; malformed input is rejected before package code runs. The staging changelog conflict is resolved. `pnpm check` passed, package-service regression passed, capability regressions passed 17/17, and Mari regressions passed 28/28 (including the previously reported completion-frame timeout and shell sandbox). These checks use disposable data. Local CodeRabbit completed with three findings dismissed after checking the actual source: the alleged duplicate module blocks do not exist (each function/regression declaration occurs once), and the requested signal parameter/abort race is present in `actionsOf` and `listCapabilityMariActions`. Type checking, production build and cancellation regression all pass. Hosted review of the pushed revision remains a merge gate. Human verification boxes remain unchanged. Follow-up independent lifecycle review at `e0f4c1393`: if a package unregisters or replaces its service while `list()` is pending, the stale service is no longer advertised or executed. Deterministic removal/replacement regressions pass, `pnpm check` passes, and capability regressions pass 17/17. The prior head’s hosted CodeRabbit review completed before this follow-up was pushed; new-head review and checks remain required. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:46 +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#7336
No description provided.