mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1400] [MERGED] Surface legacy script custom tools as preserved-only with migration path #5067
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#5067
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/1400
Author: @Romuromylus
Created: 5/27/2026
Status: ✅ Merged
Merged: 5/27/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/refactor-issue-1353-legacy-script-tools📝 Commits (7)
cd39d68Surface legacy script custom tools as preserved-only with migration path8a315daMerge branch 'refactor' into fix/refactor-issue-1353-legacy-script-toolse8d7a57Address PR review: fix ToolEditor hook order and block save while legacyd81f072Merge branch 'fix/refactor-issue-1353-legacy-script-tools' of https://github.com/Romuromylus/Marinara-Engine into fix/refactor-issue-1353-legacy-script-tools6624d3fMerge branch 'refactor' into fix/refactor-issue-1353-legacy-script-tools713f6adAddress CodeRabbit Major: gate Save & close on handleSave success8e34e01Merge branch 'fix/refactor-issue-1353-legacy-script-tools' of https://github.com/Romuromylus/Marinara-Engine into fix/refactor-issue-1353-legacy-script-tools📊 Changes
6 files changed (+233 additions, -17 deletions)
View changed files
📝
src-tauri/src/commands/storage/custom_tools.rs(+88 -0)📝
src/engine/contracts/schemas/custom-tool.schema.ts(+7 -1)📝
src/engine/generation/main-tool-loop.test.ts(+33 -0)📝
src/engine/generation/tools-runtime.ts(+4 -0)📝
src/features/catalog/agents/components/ToolEditor.tsx(+99 -16)📝
src/features/catalog/agents/hooks/use-custom-tools.ts(+2 -0)📄 Description
Why this change
Issue #1353 reports that the refactor cannot run legacy custom tools with
executionType: "script"+ a storedscriptBody, while the pre-refactor staging codebase did execute them (gated byCUSTOM_TOOL_SCRIPT_ENABLEDenv var, default off, sandboxed vianode:vm). The refactor has no Nodevmequivalent in the Tauri runtime, and embedding a JS engine would re-introduce arbitrary-code-execution risk that even staging shipped disabled-by-default.The real bug today is worse than "cannot run". On a clean read of the code:
customToolRecordinsrc/engine/generation/tools-runtime.tssilently filters script tools out of the LLM-visible tool set, so the AI never sees them.ToolEditorcoercesexecutionType === "script"to"static"on load, omitsscriptBodyfrom the save payload, and has no banner — so opening a legacy script tool and pressing Save destroys thescriptBodyfield with no warning."Unsupported custom tool execution type: script"with no migration guidance.This PR implements the "migration-aware preserve + clear error" outcome named in the issue's expected behavior. It does not add a sandboxed script execution path.
What changed
src/engine/contracts/schemas/custom-tool.schema.ts: extendtoolExecutionTypeSchematowebhook | static | script; add nullablescriptBodyfield so legacy data round-trips intact through any future schema-validating layer. Comment pins intent.src/engine/generation/tools-runtime.ts: add an explanatory comment to the existing static/webhook filter incustomToolRecordso future readers do not accidentally re-admit script tools.src/features/catalog/agents/hooks/use-custom-tools.ts: addscriptBody: string | nulltoCustomToolRow;isCustomToolSelectablealready returns false for script tools, now with a comment noting why.src/features/catalog/agents/components/ToolEditor.tsx: expand the local execution-type union to include"script"; loaddbTool.scriptBodyinto local state; render an amberShieldAlertbanner when the loaded tool is a legacy script; show the script body in a read-only textarea; swap the execution-type picker into a"Convert to Static / Convert to Webhook"pair when the user is editing a legacy script tool; preservescriptBodyin the save payload while the tool is still in legacy state and clear it once the user picks a supported execution type.src-tauri/src/commands/storage/custom_tools.rs: replace the generic "Unsupported{other}" branch with an explicit"script"case returningcustom_tool_script_unsupported+ a message naming the tool and pointing at the webhook migration path. Generic unknown types still fall through to the original error string. Adds two#[tokio::test]cases covering both branches.src/engine/generation/main-tool-loop.test.ts: add a regression test proving aexecutionType: "script"custom tool withenabled: truenever appears inbuildMainToolDefinitions().toolDefs.Verification
pnpm check:architecture→ green (boundary guard + Rust structure).pnpm check:frontend(tsc -b) → green.pnpm check:docs→ green.pnpm test(vitest) → 24 files / 156 tests pass, including the new row inmain-tool-loop.test.ts.pnpm check:rust:clippy(-D warnings) → green.cargo test -p marinara-engine→ 118/118 pass, including the two newcustom_tools::testscases.storage_createwithexecutionType: "script"+scriptBody; opened it through the agents panel in the real ToolEditor; asserted the amber legacy banner, the read-onlyscriptBodytextarea with the exact seeded body, and bothConvert to ...buttons; clicked Convert to Webhook, filled a URL, saved, then re-read the row viastorage_getand confirmed the post-save shape (executionType: "webhook",webhookUrlpreserved,scriptBody: null). No fatal pageerrors. Cleanup ran viastorage_deleteinafterEach.marinara-architecture-guard,marinara-mode-separation, andmarinara-bugfix-disciplineskills. Schema in engine/contracts, hook in features, Rust in commands/storage. No cross-boundary imports. No mode-flag patches. No catch-and-ignore. Custom tools are mode-agnostic, so mode-separation is not engaged.The unrelated
marinara-assets::tests::rejects_paths_that_escape_root_through_symlinked_directoryfails on this Windows host (noSeCreateSymbolicLinkPrivilege); confirmed identical failure on a clean checkout ofrefactorHEAD without this PR's changes.Known caveat: legacy profile import already preserves script-tool rows
The Rust storage layer for
custom-toolsis schemaless, soimport_legacy_profile_tablesinsrc-tauri/src/commands/storage/profile/legacy.rsalready round-trips script-type rows intact today. This PR does not change the import path. What it adds is the surface that lets the user see the preserved data and migrate it; before this PR, the data was on disk but invisible (and destroyed on next save).Follow-ups (not in this PR)
useCustomToolCapabilitieshook drive the banner copy (today the banner is unconditional for script tools — it does not check the capability flag becausescriptExecutionEnabledis hard-codedfalseincustom_tool_capabilities()and there is no realistic future where it becomes true on the refactor desktop runtime).custom_tool_script_unsupportederror structurally to the chat UI so the user sees the same migration hint when the AI tries to call a script tool via name (currently filtered out before reaching the executor; the executor error is only reachable through the directcustom_tool_executeinvoke path).Linked issue
Closes #1353
Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.