[PR #1813] [MERGED] Gate script custom tools #5284

Closed
opened 2026-10-22 04:14:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1813
Author: @Xelvanis
Created: 6/1/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @Xelvanis

Base: refactor ← Head: issue-1791-custom-tool-script-gate


📝 Commits (2)

  • bd341fb Gate script custom tools
  • 26e3e0e Address script tool review notes

📊 Changes

7 files changed (+30 additions, -120 deletions)

View changed files

📝 src-tauri/src/commands/storage/custom_tools.rs (+14 -4)
📝 src/engine/contracts/schemas/custom-tool.schema.ts (+1 -4)
📝 src/engine/contracts/types/agent.ts (+1 -2)
📝 src/engine/generation/tools-runtime.ts (+2 -72)
📝 src/features/catalog/agents/components/ToolEditor.tsx (+11 -34)
📝 src/features/catalog/agents/hooks/use-custom-tools.ts (+0 -3)
📝 src/features/catalog/characters/lib/character-search.ts (+1 -1)

📄 Description

Linked issue

Refs #1791

Partial slice for the script custom-tool safety gap. Does not close #1791 because imported run metadata and cadence-status parity remain separate slices.

Why this change

  • Refactor still allowed script custom tools through the TypeScript generation runtime with new Function, while the native custom-tool command already rejected script execution. That left script tools selectable/executable in one runtime path despite the capability model saying script execution should be gated.

What changed

  • Removed script execution from the TypeScript custom-tool runtime and stopped loading script rows as executable custom tools.
  • Limited custom-tool create/update schema and types to static results and webhooks.
  • Removed the Script option and script body editor from the custom tool editor; legacy script rows show a conversion warning.
  • Changed native custom-tool capabilities to report scriptExecutionEnabled: false and kept an actionable rejection for legacy script rows.
  • Removed a stale exported character-search type so the required pnpm check unused-code gate passes on current refactor.

Refactor impact

Primary owner:

  • Engine generation custom-tool runtime, catalog agents UI, and Rust storage custom-tool capability.

Impact areas reviewed:

  • Agent/tool selection in AgentEditor and chat settings via isCustomToolSelectable.
  • Main-generation and agent-generation custom-tool dispatch through tools-runtime.ts.
  • Native custom_tool_execute and custom_tool_capabilities behavior for static, webhook, legacy script, and unknown execution types.

Boundary notes:

  • Engine still calls custom tools through the IntegrationGateway port, not direct Tauri APIs.
  • Feature UI still uses catalog hooks and schemas for create/update.
  • Native Rust command remains the privileged static/webhook executor and rejects unsupported script rows.
  • Remote runtime command routing was already present for custom_tool_execute / custom_tool_capabilities; this PR does not add command surface.

Pressure points touched:

  • None of the named broad pressure points. ToolEditor.tsx and tools-runtime.ts were touched narrowly to remove script execution support.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • pnpm check passes locally before PR push/handoff, including the unused-code check
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Browser screenshot/recording evidence added when UI/browser state is the claim
  • Remote runtime smoke checked when relevant

Manual verification notes

  • pnpm typecheck passed locally.
  • cargo test --manifest-path src-tauri/Cargo.toml custom_tools --lib passed locally.
  • pnpm check:architecture passed locally.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed locally.
  • pnpm check passed locally after removing the stale exported CharacterSearchScope type that was already failing the unused-code gate on current refactor.
  • No browser or Tauri manual pass was run; this PR is a runtime/schema safety gate rather than a visual layout claim.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • N/A. This removes an unsafe/unsupported execution path and does not add a new discoverable feature.

Docs and release impact

  • No docs changes needed

  • Updated README.md

  • Updated CONTRIBUTING.md

  • Updated docs/developer/

  • Updated repo skills or AGENTS.md

  • Confirmed this PR does not restore old staging/package-workspace/release claims

  • No docs changes needed: current custom-tools guidance already describes ME-Refactor as static/webhook only with script execution disabled.

  • This PR does not restore old staging/package-workspace/release claims.

UI evidence

  • Not added. UI impact is removal of the Script execution option plus a conversion warning for legacy script rows; no browser/Tauri screenshot pass was run.

Summary by CodeRabbit

  • Breaking Changes

    • Custom tools no longer support script-based execution; only webhook and static execution types are available.
  • Refactor

    • Streamlined custom tool runtime to handle only webhook and static result types.
    • Simplified tool editor interface with 2-column execution type selector.
  • Bug Fixes

    • Added runtime validation to prevent execution of incompatible tool types.
    • Tool editor now displays a warning banner when loading unsupported script tools.

🔄 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/1813 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `issue-1791-custom-tool-script-gate` --- ### 📝 Commits (2) - [`bd341fb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bd341fb3311c59bc8802e2541408f00583c958c4) Gate script custom tools - [`26e3e0e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26e3e0e7ee7d013df33409f08d847de8fc7e79e7) Address script tool review notes ### 📊 Changes **7 files changed** (+30 additions, -120 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/custom_tools.rs` (+14 -4) 📝 `src/engine/contracts/schemas/custom-tool.schema.ts` (+1 -4) 📝 `src/engine/contracts/types/agent.ts` (+1 -2) 📝 `src/engine/generation/tools-runtime.ts` (+2 -72) 📝 `src/features/catalog/agents/components/ToolEditor.tsx` (+11 -34) 📝 `src/features/catalog/agents/hooks/use-custom-tools.ts` (+0 -3) 📝 `src/features/catalog/characters/lib/character-search.ts` (+1 -1) </details> ### 📄 Description ## Linked issue Refs #1791 Partial slice for the script custom-tool safety gap. Does not close #1791 because imported run metadata and cadence-status parity remain separate slices. ## Why this change - Refactor still allowed script custom tools through the TypeScript generation runtime with `new Function`, while the native custom-tool command already rejected script execution. That left script tools selectable/executable in one runtime path despite the capability model saying script execution should be gated. ## What changed - Removed script execution from the TypeScript custom-tool runtime and stopped loading script rows as executable custom tools. - Limited custom-tool create/update schema and types to static results and webhooks. - Removed the Script option and script body editor from the custom tool editor; legacy script rows show a conversion warning. - Changed native custom-tool capabilities to report `scriptExecutionEnabled: false` and kept an actionable rejection for legacy script rows. - Removed a stale exported character-search type so the required `pnpm check` unused-code gate passes on current refactor. ## Refactor impact Primary owner: - Engine generation custom-tool runtime, catalog agents UI, and Rust storage custom-tool capability. Impact areas reviewed: - Agent/tool selection in `AgentEditor` and chat settings via `isCustomToolSelectable`. - Main-generation and agent-generation custom-tool dispatch through `tools-runtime.ts`. - Native `custom_tool_execute` and `custom_tool_capabilities` behavior for static, webhook, legacy script, and unknown execution types. Boundary notes: - Engine still calls custom tools through the `IntegrationGateway` port, not direct Tauri APIs. - Feature UI still uses catalog hooks and schemas for create/update. - Native Rust command remains the privileged static/webhook executor and rejects unsupported script rows. - Remote runtime command routing was already present for `custom_tool_execute` / `custom_tool_capabilities`; this PR does not add command surface. Pressure points touched: - None of the named broad pressure points. `ToolEditor.tsx` and `tools-runtime.ts` were touched narrowly to remove script execution support. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] `pnpm check` passes locally before PR push/handoff, including the unused-code check - [x] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Browser screenshot/recording evidence added when UI/browser state is the claim - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - `pnpm typecheck` passed locally. - `cargo test --manifest-path src-tauri/Cargo.toml custom_tools --lib` passed locally. - `pnpm check:architecture` passed locally. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed locally. - `pnpm check` passed locally after removing the stale exported `CharacterSearchScope` type that was already failing the unused-code gate on current refactor. - No browser or Tauri manual pass was run; this PR is a runtime/schema safety gate rather than a visual layout claim. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - N/A. This removes an unsafe/unsupported execution path and does not add a new discoverable feature. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims - No docs changes needed: current custom-tools guidance already describes ME-Refactor as static/webhook only with script execution disabled. - This PR does not restore old staging/package-workspace/release claims. ## UI evidence - Not added. UI impact is removal of the Script execution option plus a conversion warning for legacy script rows; no browser/Tauri screenshot pass was run. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Breaking Changes** * Custom tools no longer support script-based execution; only webhook and static execution types are available. * **Refactor** * Streamlined custom tool runtime to handle only webhook and static result types. * Simplified tool editor interface with 2-column execution type selector. * **Bug Fixes** * Added runtime validation to prevent execution of incompatible tool types. * Tool editor now displays a warning banner when loading unsupported script tools. <!-- 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-22 04:14:55 +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#5284
No description provided.