]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
ui: add opt-in run_javascript frontend tool (#24244)
authorPascal <redacted>
Tue, 9 Jun 2026 16:02:31 +0000 (18:02 +0200)
committerGitHub <redacted>
Tue, 9 Jun 2026 16:02:31 +0000 (18:02 +0200)
commit483609509d58c3a09f77ff10d1b2acfca42977d2
tree8fa4f1c4ab39540ef89a2e167026b6f340d5c042
parent49f354219059fc22316ae3efa54e54ba37f77860
ui: add opt-in run_javascript frontend tool (#24244)

* ui: add opt-in run_javascript frontend tool

Expose a run_javascript tool to the model, executed entirely in the
browser through the existing agentic loop. Code runs in a Web Worker
inside a sandboxed iframe with an opaque origin, isolated from the
WebUI and its API. Console output, errors and the return value are
fed back as the tool result. The parent enforces a hard timeout by
removing the iframe, which terminates the worker.

Disabled by default, toggle in Settings > Developer.

* ui: address review feedback from allozaur

Use the JsonSchemaType enum for the tool definition parameter types
instead of raw string literals, extending it with STRING and NUMBER.

Move the worker shim and the iframe harness html into their own files
so the service no longer carries inline source blobs.

Replace the remaining magic strings with constants: SANDBOX_EMPTY_OUTPUT
and SANDBOX_TRUNCATION_NOTICE, and reuse NEWLINE_SEPARATOR for joins.

* ui: move sandbox worker shim to a raw imported file

Replace the inline worker template string with a real sandbox-worker.js
imported as raw text, and build the iframe harness from it in
sandbox-harness.ts. The raw worker ships as a string, not a module, so
it is excluded from eslint and the typecheck program.
15 files changed:
tools/ui/eslint.config.js
tools/ui/src/lib/constants/index.ts
tools/ui/src/lib/constants/sandbox.ts [new file with mode: 0644]
tools/ui/src/lib/constants/settings-keys.ts
tools/ui/src/lib/constants/settings-registry.ts
tools/ui/src/lib/constants/tools.ts
tools/ui/src/lib/enums/mcp.enums.ts
tools/ui/src/lib/enums/tools.enums.ts
tools/ui/src/lib/services/index.ts
tools/ui/src/lib/services/sandbox-harness.ts [new file with mode: 0644]
tools/ui/src/lib/services/sandbox-worker.js [new file with mode: 0644]
tools/ui/src/lib/services/sandbox.service.ts [new file with mode: 0644]
tools/ui/src/lib/stores/agentic.svelte.ts
tools/ui/src/lib/stores/tools.svelte.ts
tools/ui/tsconfig.json