From ddd7f7f93a48fdc4036c4518ba705bfb95905c24 Mon Sep 17 00:00:00 2001 From: Aleksey Chendemerov Date: Sat, 7 Nov 2026 22:45:48 +0000 Subject: [PATCH] feat(gui): add the experimental gui-experimental window part with the vvoc.gui.v1 rpc Ship the minimal ./gui-experimental GUI skeleton: a vvoc settings page stub and a profile composer pill built with host ui components and an English i18n catalog, built as one CommonJS bundle through the host-provided Vite GUI preset (vite build joins the build script). The portable versioned RPC contract (vvoc.gui.v1, Effect Schema codecs bridged to the portable Standard Schema surface) is registered server-side by the new GuiSettingsPlugin: defaults.get projects the bounded effective defaults, defaults.set writes the orchestration profile through the same conservative CLI path as vvoc orchestration set, session.get answers an honest stub read from the effective config, and session.patch answers unsupported until session-owned settings exist. Probed live against an OpenCode 2.2.6 host: the web GUI never requests /api/plugin/gui and renders no plugin settings page, while the server serves the built bundle and the RPC roundtrip works, so plugin GUI parts are Desktop-only until a Desktop probe says otherwise. The GUI SDK states the same for config plugins. The export checker now recognizes bundler-built CommonJS targets (./dist/*.cjs resolve to their same-named src twin). The upstream GUI API is experimental; the SDK and host versions are pinned and documented in the README. --- .grace/graph/index.xml | 2 + .grace/graph/main.xml | 2 + .grace/verification/index.xml | 2 + .grace/verification/main.xml | 2 + AGENTS.md | 16 +- README.md | 14 ++ bun.lock | 140 +++++++++++++++++ package.json | 7 +- scripts/check-exports.ts | 11 +- scripts/gui-bundle.test.ts | 114 ++++++++++++++ scripts/vite-gui.ts | 25 +++ src/gui-experimental.tsx | 137 +++++++++++++++++ src/index.ts | 15 +- src/plugins/gui-settings.test.ts | 236 ++++++++++++++++++++++++++++ src/plugins/gui-settings.ts | 253 +++++++++++++++++++++++++++++++ src/rpc.test.ts | 147 ++++++++++++++++++ src/rpc.ts | 200 ++++++++++++++++++++++++ 17 files changed, 1308 insertions(+), 15 deletions(-) create mode 100644 scripts/gui-bundle.test.ts create mode 100644 scripts/vite-gui.ts create mode 100644 src/gui-experimental.tsx create mode 100644 src/plugins/gui-settings.test.ts create mode 100644 src/plugins/gui-settings.ts create mode 100644 src/rpc.test.ts create mode 100644 src/rpc.ts diff --git a/.grace/graph/index.xml b/.grace/graph/index.xml index e2544710..51eebf5e 100644 --- a/.grace/graph/index.xml +++ b/.grace/graph/index.xml @@ -41,6 +41,8 @@ + + diff --git a/.grace/graph/main.xml b/.grace/graph/main.xml index 46302736..f0df5df8 100644 --- a/.grace/graph/main.xml +++ b/.grace/graph/main.xml @@ -33,6 +33,8 @@ TelegramGatewayINTEGRATIONimplementedBridge native sessions to Telegram topics and own the polling loop: structural event decoding without casting for session lifecycle, step, part-text, permission, question, and child-session events with per-event containment; top-level-only candidate reconciliation with immediate adoption of new sessions on creation, a resubscribing event pump with a periodic resync that purges evicted-thread delivery state; prompt, abort, and model-switch admission; streamed turns through the delivery layer; status transitions through throttled titles; bounded subagent cards; and the persisted-offset long-poll loop with owner allowlist, stale dropping, album grouping, and bounded backoff.src/plugins/telegram/sessions.ts, src/plugins/telegram/gateway.ts, src/plugins/telegram/commands.tsM-TELEGRAM-TOPICS, M-TELEGRAM-DELIVERY, M-TELEGRAM-BOT-APIV-M-TELEGRAM-GATEWAY TelegramBridgePluginINTEGRATIONimplementedAssemble the native vvoc.telegram server plugin: resolve the telegram section and toggle with value-free disabled diagnostics, run exactly one grammy gateway per process behind an app-identity singleton, wire topology, delivery, session bridge, interactions, commands, and the polling gateway over structural context and full-client seams, register owner commands, resurface pending permissions, and tear everything down in reverse on the last cleanup with partial-setup rollback; the entire bootstrap including native client acquisition runs as a supervised background task with bounded backoff retries after setup returns, because awaiting the client during setup deadlocks server boot, and every bootstrap await is abortable so cleanup resolves even when the client never becomes ready, and the assembly wires the maxTopics rotation cap and a bounded file log whose tail the CLI reads.src/plugins/telegram/index.ts, src/plugins/telegram/log.tsM-NATIVE-RUNTIME, M-TELEGRAM-GATEWAY, M-TELEGRAM-TOPICS, M-TELEGRAM-DELIVERY, M-TELEGRAM-BOT-API, M-TELEGRAM-CONFIG, M-PLUGIN-TOGGLE-CONFIG, M-CLI-CONFIG, @opencode/pluginV-M-PLUGIN-TELEGRAM-BRIDGE SpecGuardPluginINTEGRATIONimplementedAnnotate reads of active spec-package artifacts with cache-backed lint verdicts through tool.execute.after, validate post-write state with sibling spec cross-file inputs, refuse enforce-mode full-content writes that would leave ERROR findings through tool.execute.before, never annotate archived files, and degrade fail-open on any internal error.src/plugins/spec-guard/index.tsM-SPEC-LINT, M-CONFIG-LAYERS, M-PLUGIN-TOGGLE-CONFIGV-M-PLUGIN-SPEC-GUARD + GuiSpikeINTEGRATIONimplementedShip the minimal experimental `./gui-experimental` window part and its portable versioned RPC contract: a "vvoc" settings page stub and a composer pill that show the orchestration profile from the effective vvoc defaults through `vvoc.gui.v1` (defaults.get/set, session.get/patch) with strict Effect Schema codecs bridged to the portable Standard Schema surface, host ui components, and an English i18n catalog; the bundle builds with the host-provided Vite GUI preset as one CommonJS file.src/gui-experimental.tsx, src/rpc.ts, src/rpc.test.ts, scripts/vite-gui.ts, scripts/gui-bundle.test.tsM-PLUGIN-GUI-SETTINGS, M-CONFIG-LAYERS, M-PLUGIN-TOGGLE-CONFIG, @opencode/plugin/gui, vite, solid-jsV-M-GUI-SPIKE + GuiSettingsPluginINTEGRATIONimplementedRegister the versioned GUI RPC (`vvoc.gui.v1`) on the native server context so the `./gui-experimental` window part reads the bounded effective-defaults projection, writes the orchestration profile through the conservative CLI write path with an explicit global/project scope, and receives honest stub/unsupported session-settings verdicts with value-free error mapping; teardown disposes only its own registration.src/plugins/gui-settings.tsM-GUI-SPIKE, M-CONFIG-LAYERS, M-PLUGIN-TOGGLE-CONFIG, M-NATIVE-RUNTIME, M-CLI-COMMANDSV-M-PLUGIN-GUI-SETTINGS ContextTuiPluginINTEGRATIONimplementedRegister /context and the /vv-rebind rebind-marker facade in the native OpenCode TUI, collect the selected session’s location-scoped state through the read-only versioned context-inspection RPC (registered tool catalog plus allowlisted family or current-runtime policy) together with provider-reported usage and active message history, combine measured truth with honest observable category estimates, classify canonical web tools as vvoc-managed, derive reconciled per-tool and per-MCP schema/history attribution and context-limit percentages, disclose schema catalogs the host cannot expose, render a bounded Overview/Tools/MCP dialog, and fail softly on missing or ambiguous state; the default TUI module also registers the analytics indicator, branding footer, and persistent peak-hours banner beside /context.src/tui.tsx, src/tui/context/*.ts, src/tui/context/*.tsxM-NATIVE-RUNTIME, M-CONFIG-LAYERS, M-CLI-CONFIG, M-PLUGIN-TOGGLE-CONFIG, M-TUI-PEAK-HOURS-BANNER, @opencode/plugin/tui, @opentui/keymap, @opentui/solid, solid-jsV-M-PLUGIN-CONTEXT-TUI WebToolsPluginINTEGRATIONimplementedRegister web_search and web_fetch with closed provider-neutral input schemas and declared text/metadata/attachment result envelopes, reject unknown or invalid fields before dispatch, and select per bound family between the owned tools and the genuine native websearch/webfetch builtins through per-session tool visibility driven by the captured policy — never by mutating user permissions or unrelated host/MCP tools — while resolving provider config per session and reporting credential source metadata.src/plugins/web-tools/index.ts, src/plugins/web-tools/schemas.ts, src/plugins/web-tools/contracts.test.ts, src/plugins/web-tools.integration.test.tsM-NATIVE-RUNTIME, M-WEB-CONFIG, M-WEB-SEARCH-SERVICE, M-WEB-FETCH-SERVICE, M-CONFIG-LAYERS, M-PLUGIN-TOGGLE-CONFIG, M-AGENT-TOOL-CONTRACTV-M-PLUGIN-WEB-TOOLS ToolHistoryCompactionPluginINTEGRATIONimplementedShrink the replayed conversation context non-destructively: through the native session context hook, deterministically rewrite only the in-memory tool part outputs the model is about to receive under the bound family’s captured policy — collapsing old read outputs to [Read <file>, lines X-Y] headers and head/marker/tail pruning over-budget ephemeral outputs (bash/grep/glob), while retaining knowledge outputs (web fetch/search, skill, subagent) — with an absolute recency-time recent-message window (protectRecentMessages, default 8) that never rewrites the working context, per-call protection that retained tools no longer consume, recoverable disk-backed pruning (savePrunedOutput with the full output path embedded in the marker), a min-savings guard, and strict vvoc config materialized on sync.src/plugins/tool-history-compaction/*.tsM-NATIVE-RUNTIME, M-PLUGIN-TOGGLE-CONFIG, M-CONFIG-LAYERS, M-CLI-CONFIGV-M-PLUGIN-TOOL-HISTORY-COMPACTION diff --git a/.grace/verification/index.xml b/.grace/verification/index.xml index d1f663fc..086c247e 100644 --- a/.grace/verification/index.xml +++ b/.grace/verification/index.xml @@ -32,6 +32,8 @@ + + diff --git a/.grace/verification/main.xml b/.grace/verification/main.xml index c9e0fecd..a9575385 100644 --- a/.grace/verification/main.xml +++ b/.grace/verification/main.xml @@ -62,6 +62,8 @@ src/plugins/secrets-redaction/engine.test.tssrc/plugins/secrets-redaction/index.test.tssrc/plugins/secrets-redaction/patterns.test.tssrc/plugins/secrets-redaction/session.test.tssrc/plugins/secrets-redaction/stream.test.tsbun test src/plugins/secrets-redaction/engine.test.ts src/plugins/secrets-redaction/index.test.ts src/plugins/secrets-redaction/patterns.test.ts src/plugins/secrets-redaction/session.test.ts src/plugins/secrets-redaction/stream.test.tsbun run typecheckbun run lintBuilt-in, custom, and configured secrets redact before provider exposure under the immutable family policy, restore copy-on-write for frozen native tool input and streamed provider responses — including placeholders split across SSE and WebSocket TEXT deltas with bounded lane carry — and preserve opaque frames.The declared TestFiles and Checks exercise this scenario deterministically.Built-in, regex, custom keyword, and configured web apiKey values redact before provider calls, with ${VAR} placeholders in web apiKey fields resolved from the environment so redaction covers the real key rather than the placeholder text; split placeholders restore across text pushes, SSE events, and byte chunks with per-lane scoping, bounded carry, byte-for-byte opaque/comment/malformed frame preservation, and non-SSE body restoration; placeholder restoration and session behavior remain deterministic. src/lib/spec-lint.test.tssrc/lib/spec-lint-cache.test.tssrc/lib/config-layers.test.tsbun test src/lib/spec-lint.test.ts src/lib/spec-lint-cache.test.ts src/lib/config-layers.test.tsbun run typecheckThe strict engine validates well-formedness, template contracts, identity patterns, references, lifecycle-aware severity, cross-file subset rules, layout checks, the optional delegated execution and review-checkpoint vocabulary with scope paths, reviewer sets, wave barriers, and final coverage, typed extractDelegatedPlanDefinition, and the content-addressed cache with content and version invalidation including rejection of old-version disk caches.The declared TestFiles and Checks exercise this scenario deterministically.Fixture corpus proves every violation class carries a specific rule with file and line, draft documents tolerate emptiness while approved documents do not, plan components must exist in the linked spec, legacy plans without execution stay valid, delegated obligations are required only for approved plans, the shipped reference templates lint clean, and cache runs hit on unchanged inputs and invalidate when any input hash or the lint version changes. src/plugins/spec-guard/index.test.tssrc/lib/plugin-toggle-config.test.tssrc/lib/vvoc-config.test.tssrc/lib/opencode.test.tsbun test src/plugins/spec-guard/index.test.ts src/lib/plugin-toggle-config.test.ts src/lib/vvoc-config.test.ts src/lib/opencode.test.tsbun run typecheckThe spec-guard plugin annotates reads of active artifacts, validates post-write state, refuses only enforce-mode ERROR writes, stays silent on archived files, and fails open on internal errors; strict schema v3 accepts the warn/enforce entry and sync materializes it conservatively.The declared TestFiles and Checks exercise this scenario deterministically.Hook-level tests with injected dependencies prove read verdict injection, archive silence, warn append, enforce refusal and edit prefixes, warning-only and draft states never failing, unreadable-file degradation, schema acceptance and rejection for the spec-guard arm, and canonical sync writes materializing the default warn entry without overwriting user values. + src/rpc.test.tsscripts/gui-bundle.test.tsbun test src/rpc.test.ts scripts/gui-bundle.test.tsbun run typecheckvite build --config scripts/vite-gui.tsThe portable GUI RPC contract keeps its versioned identity and four-method surface, decodes bounded replies strictly (wrong version, unknown status, unknown error codes, and out-of-projection keys are stripped), validates the defaults write verdict, and validates the session stub and unsupported verdict surfaces; the Vite preset writes one CommonJS `./gui-experimental` bundle.The declared TestFiles and Checks exercise this scenario deterministically.Contract identity and method-map tests pass, strict reply decoders accept the bounded projections and reject malformed or out-of-vocabulary replies, unknown keys never survive decoding, and the built `dist/gui-experimental.cjs` default-exports the GUI definition with its i18n catalog and setup. + src/plugins/gui-settings.test.tsbun test src/plugins/gui-settings.test.tsbun run typecheckThe GUI settings plugin projects the effective defaults as an available bounded reply, maps read and write failures to value-free unavailable verdicts, routes the profile write through the conservative CLI write path with an explicit scope, answers session reads with the honest stub projection for existing sessions and the lookup-failure verdict otherwise, keeps session patches explicitly unsupported, registers `vvoc.gui.v1` on the server registrar, and roundtrips the production wiring against a sandbox vvoc.json including the on-disk orchestration patch.The declared TestFiles and Checks exercise this scenario deterministically.Handler tests prove the available projection, the value-free unavailable mapping without raw error text, the injected conservative write with scope, the stub and unsupported session verdicts, and the registrar-level registration; the sandbox roundtrip proves the production seams read the layered vvoc.json, patch its orchestration profile on disk through the CLI write path, and re-read the updated value. src/tui/context/analyze.test.tssrc/tui/context/collect.test.tssrc/tui/context/plugin.test.tssrc/tui/context/view.test.tssrc/tui/policy.test.tssrc/tui/analytics/indicator.test.tssrc/tui/branding/footer.test.tssrc/tui/rebind/plugin.test.tsbun test src/tui/context/analyze.test.ts src/tui/context/collect.test.ts src/tui/context/plugin.test.ts src/tui/context/view.test.ts src/tui/policy.test.ts src/tui/analytics/indicator.test.ts src/tui/branding/footer.test.ts src/tui/rebind/plugin.test.tsbun run typecheckbun run checkbun run buildbun run pack:checkThe enabled /context command collects the selected session’s location-scoped state through the read-only context-inspection RPC plus native message history and model metadata, computes honest attribution, and renders bounded responsive tabs with fail-soft behavior; the selection-keyed policy controller refreshes on native policy-binding events; the default TUI module additionally registers the analytics indicator, branding footer, app_bottom peak-hours banner, and /vv-rebind command with per-registration fail-soft isolation; /vv-rebind writes exactly one project-scoped rebind request marker naming the active session, is disabled without an open session, and answers with one bounded toast.The declared TestFiles and Checks exercise this scenario deterministically.Percentages derive only from a positive finite context limit; absent or malformed usage stays unknown field-by-field instead of zero; the latest completed compaction cutoff separates pre/post occupancy and compaction request tokens never count as occupancy; registered-catalog budgets stay separate from observed context and provider residual; native built-in and vvoc tools classify while unknown tools stay unattributed under Other external/plugin instead of being guessed onto an MCP server; unavailable or partial catalogs and failed/mismatched RPC reads are disclosed as unknown rather than empty; skill history is counted once; drift is reported positively; host-owned tab composition, middle-half host geometry, preloaded reactive keyboard navigation and cleanup, scrolling, narrow rendering, post-replacement xlarge sizing, and indicator/footer/banner registration tolerance remain deterministic; /vv-rebind writes one marker carrying the TUI working directory and the active session id, shows a single bounded toast, never displays configuration content or credential values, and writes nothing without an open session. src/plugins/web-tools.integration.test.tssrc/plugins/web-tools/contracts.test.tsbun test src/plugins/web-tools.integration.test.ts src/plugins/web-tools/contracts.test.tsbun run typecheckThe plugin always registers exactly the two owned tools, publishes closed provider-neutral query/count/freshness and URL/format/timeout schemas that reject unknown or invalid provided values before dispatch, and selects owned versus genuine native builtin visibility per bound family from the captured policy without mutating permissions; it reports provider metadata without credentials.The declared TestFiles and Checks exercise this scenario deterministically.An enabled capture publishes the owned contracts and hides native builtins, an explicitly disabled capture exposes the genuine native builtins and hides the owned tools, an unknown policy exposes neither and refuses the owned provider-bound path, and startup-enabled config never hijacks a disabled captured family; invalid arguments are rejected before permission or dispatch, count 8/markdown/bounded-timeout defaults apply at execute time even when the host forwards unparsed arguments, document/binary content and per-call provider selection stay out of the caller contract, direct Z.AI regions and credential sources are reported safely, git-tracked literal apiKey warnings name no values, and logs contain no credential values. src/plugins/tool-history-compaction/config.test.tssrc/plugins/tool-history-compaction/prune.test.tssrc/plugins/tool-history-compaction/read-slim.test.tssrc/plugins/tool-history-compaction/transform.test.tssrc/plugins/tool-history-compaction/saved-output.test.tssrc/plugins/tool-history-compaction.integration.test.tssrc/lib/plugin-toggle-config.test.tssrc/lib/opencode.test.tsbun test src/plugins/tool-history-compaction.integration.test.ts src/plugins/tool-history-compaction/config.test.ts src/plugins/tool-history-compaction/prune.test.ts src/plugins/tool-history-compaction/read-slim.test.ts src/plugins/tool-history-compaction/transform.test.ts src/plugins/tool-history-compaction/saved-output.test.ts src/lib/plugin-toggle-config.test.ts src/lib/opencode.test.tsbun run typecheckThe native session-context-hook transform-only plugin compacts old ephemeral tool outputs (read headers, head/marker/tail pruning) while retaining knowledge outputs under the bound family’s captured policy, never touching inputs or part structure, protecting an absolute recency-time recent-message window plus per-call budget that retained tools do not consume, persisting full pruned outputs for recoverable markers, enforcing min-savings, and materializing strict vvoc config on sync.The declared TestFiles and Checks exercise this scenario deterministically.Deterministic idempotent rewrites over native message and tool-result parts; retained webfetch/search/skill outputs untouched and not consuming protection budget; the newest messages (recency-time window) never rewritten even under size/parallel/reordering pressure; old reads collapse to [Read <file>, lines X-Y] with fail-closed fallback; saved-output markers embed the persisted full-output path and the file exists with original content; error/compacted parts untouched; inputs byte-identical; sync materializes the default config conservatively and strict schema v3 accepts the new keys. diff --git a/AGENTS.md b/AGENTS.md index 4b7230d2..990e251e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -94,12 +94,15 @@ the conflict rather than guessing. `effect` `4.0.6` (schema-owned peer used by `@opencode/schema` codecs), `zod` `4.1.8`, `@opentui/{core,keymap,solid}` `0.8.2`, `solid-js` `1.9.15`. There is no `@opencode-ai/*` dependency. -- Public plugins: eleven native server plugins (Guardian, Hashline Edit, Model +- Public plugins: twelve native server plugins (Guardian, Hashline Edit, Model Roles, System Context Injection, Workflow, Secrets Redaction, Web Tools, Tool - History Compaction, Analytics, Peak Hours, Spec Guard) plus the native TUI - plugin (`/context` inspector, analytics indicator, branding footer, peak-hours - banner). One pinned base-package entry in the native `plugins` array serves - both the `./server` and `./tui` exports. + History Compaction, Analytics, Peak Hours, Spec Guard, GUI Settings) plus the + native TUI plugin (`/context` inspector, analytics indicator, branding footer, + peak-hours banner) and the experimental `./gui-experimental` GUI part (vvoc + settings page stub, profile composer pill, and the `vvoc.gui.v1` RPC over the + conservative defaults write). One pinned base-package entry in the native + `plugins` array serves the `./server` and `./tui` exports; the GUI part is + loaded by OpenCode's GUI from the same package's `./gui-experimental` export. ## Repository Map @@ -113,8 +116,9 @@ the conflict rather than guessing. | Native runtime | `src/runtime/*` | Shared native context/snapshot/client/permissions/model/auxiliary/coordination services and the read-only context-inspection RPC (`M-NATIVE-RUNTIME`). | | Managed agents/skills | `src/lib/managed-agents.ts`, `src/lib/managed-skills.ts`, `templates/` | Installed by `vvoc install`/`sync`. | | Model roles/presets | `src/lib/model-roles.ts`, `src/lib/agent-models.ts`, `src/lib/vvoc-preset-registry.ts` | Semantic role resolution and built-in presets. | -| Plugins | `src/plugins/` | Eleven native server plugin entry points and plugin-local tests. | +| Plugins | `src/plugins/` | Twelve native server plugin entry points and plugin-local tests. | | TUI plugin | `src/tui.tsx`, `src/tui/context/` | Default native TUI module, `/context` collection/analysis/dialog, and focused tests. | +| GUI part (experimental) | `src/gui-experimental.tsx`, `src/rpc.ts`, `scripts/vite-gui.ts` | The `./gui-experimental` window part: vvoc settings page stub, profile composer pill, the `vvoc.gui.v1` RPC contract, and the Vite-preset CommonJS bundle. | | Workflow engine | `src/plugins/workflow/` | Protocol, state, transitions, host/cancellation mapping, tooling, repair, and persistence. | | Real-host harness | `scripts/e2e-v2.ts`, `scripts/e2e-v2/*` | Installed-package native parity harness (`M-E2E-V2-HARNESS`); run with `bun run e2e:v2`. | | Release automation | `scripts/release-*.ts`, `.github/workflows/publish.yml` | Follow deployment policy; do not duplicate it here. | diff --git a/README.md b/README.md index a1fb9741..14738d05 100644 --- a/README.md +++ b/README.md @@ -182,9 +182,23 @@ The server plugins run inside the OpenCode server process; **ContextTuiPlugin** | **AnalyticsPlugin** | Local-only token and cache telemetry per model step, a live `cache NN%` indicator in the TUI, and `vvoc analytics cache-hit-rate` for retrospective comparison. | | **PeakHoursPlugin** | Warns or blocks models whose provider is in peak-priced hours right now, suggests connected off-peak providers, and shows a persistent orange banner in the TUI. | | **SpecGuardPlugin** | Deterministic host-side verification of spec-package artifacts: annotates reads with lint verdicts and validates writes; in enforce mode refuses writes that would break the format. | +| **GuiSettingsPlugin** | Registers the versioned GUI RPC (`vvoc.gui.v1`) so the experimental GUI window part can read the effective vvoc defaults, write the orchestration profile through the same conservative CLI path as `vvoc orchestration set`, and receive honest stub/unsupported session-settings verdicts. | | **TelegramBridgePlugin** | Runs a single-owner Telegram bot inside the OpenCode server process: one private-chat DM topic per active session with a live status emoji in the topic title, a General control topic, manual permission and question buttons, and durable state that survives `opencode service restart`. | | **ContextTuiPlugin** | The `/context` inspector: an honest, scrollable TUI dialog showing context-window usage by category, tool, and MCP server. | +### The experimental GUI part (spike) + +The package also ships a minimal experimental GUI part: the `./gui-experimental` export that OpenCode's GUI loads as a plugin's window half (the GUI SDK, `@opencode/plugin/gui`). The upstream API is experimental and may change between releases — the `-experimental` export name says so on purpose. Used surface: `@opencode/plugin` **2.2.5** (`./gui`, `./gui/vite`), probed live against an OpenCode **2.2.6** host (`@opencode/cli@2.2.6`, sha256-checked download). + +What it contains today: + +- A "vvoc" settings page stub (host ui components, English i18n catalog) and a composer pill showing the current orchestration profile from the effective vvoc config. +- The portable versioned RPC contract `vvoc.gui.v1` (`src/rpc.ts`; Effect Schema codecs bridged to the portable Standard Schema RPC surface): `defaults.get` reads a bounded effective-defaults projection (profile, three plugin toggles, config source), `defaults.set` writes the orchestration profile through the same conservative CLI write path as `vvoc orchestration set` (explicit global/project scope, strict parse, kept-if-unchanged, canonical output), `session.get` answers with an honest stub read from the effective config, and `session.patch` answers `unsupported` until session-owned settings exist. + +Web vs Desktop verdict (live probe, host 2.2.6): **the web GUI does not load plugin `./gui-experimental` bundles.** A paired browser (`opencode serve` web app) fetched the plugin inventory but never requested `/api/plugin/gui`, and the contributed "vvoc" page does not appear in the web settings. The serving half works — the server returns the prebuilt CommonJS bundle for `id=vvoc` — so the missing half is the web app's loader, not the plugin. The Desktop app was not available on the probe machine, so the Desktop half is unverified here; the GUI SDK documents Desktop windows as the loading environment and its `Declarations.os` states that a plugin from the config runs only in the desktop app. Until a Desktop probe says otherwise, treat the GUI part as Desktop-only. + +Build: `bun run build` also runs the Vite preset (`scripts/vite-gui.ts`; devDependencies `vite` 7.3.7, `vite-plugin-solid` 2.11.10, `solid-js` 1.9.15) producing one CommonJS bundle at `dist/gui-experimental.cjs` from `src/gui-experimental.tsx` — app-provided modules (Solid, Effect, `@opencode/plugin/gui`, `@opencode/schema/rpc`, `@opencode/client`) stay external and every dynamic import is inlined, per the preset contract. + ### Managed agents All prompt files are scaffolded by `vvoc install` / `vvoc sync`: diff --git a/bun.lock b/bun.lock index 0de27553..dc2d4211 100644 --- a/bun.lock +++ b/bun.lock @@ -34,6 +34,8 @@ "oxlint": "1.58.0", "solid-js": "1.9.15", "typescript": "5.8.2", + "vite": "7.3.7", + "vite-plugin-solid": "2.11.10", }, "peerDependencies": { "@opentui/core": ">=0.5.12", @@ -195,6 +197,58 @@ "@effect/platform-node-shared": ["@effect/platform-node-shared@4.0.6", "", { "dependencies": { "@types/ws": "^8.18.2", "ws": "^8.22.0" }, "peerDependencies": { "effect": "^4.0.6" } }, "sha512-0PhyC4uG30xGtsajnxjkcBWfTjNRzUh4ZKl1Kvo/MNyCTb+W2O+fBzf7wCRCoqt+nLudiq4V7vX40Q8XIBuMaQ=="], + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.28.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.28.2", "", { "os": "android", "cpu": "arm" }, "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.28.2", "", { "os": "android", "cpu": "arm64" }, "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.28.2", "", { "os": "android", "cpu": "x64" }, "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.28.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.28.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.28.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.28.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.28.2", "", { "os": "linux", "cpu": "arm" }, "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.28.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.28.2", "", { "os": "linux", "cpu": "ia32" }, "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.28.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.28.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.28.2", "", { "os": "linux", "cpu": "x64" }, "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ=="], + + "@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.28.2", "", { "os": "none", "cpu": "arm64" }, "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.28.2", "", { "os": "none", "cpu": "x64" }, "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw=="], + + "@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.28.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.28.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw=="], + + "@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.28.2", "", { "os": "none", "cpu": "arm64" }, "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.28.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.28.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.28.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.28.2", "", { "os": "win32", "cpu": "x64" }, "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g=="], + "@gar/promise-retry": ["@gar/promise-retry@1.0.3", "", {}, "sha512-GmzA9ckNokPypTg10pgpeHNQe7ph+iIKKmhKu3Ob9ANkswreCx7R3cKmY781K8QK3AqVL3xVh9A42JvIAbkkSA=="], "@hutson/parse-repository-url": ["@hutson/parse-repository-url@5.0.0", "", {}, "sha512-e5+YUKENATs1JgYHMzTr2MW/NDcXGfYFAuOQU8gJgF/kEh4EqKgfGrfLI67bMD4tbhZVlkigz/9YYwWcbOFthg=="], @@ -395,6 +449,58 @@ "@redis/time-series": ["@redis/time-series@6.2.1", "", { "peerDependencies": { "@redis/client": "^6.2.1" } }, "sha512-kiYniph04dJOole+L359B6C9E+jYS2uDP7hca6Onj0xF38ZIpyxARO0Iq0W4ZRn1e8Q6vqW00QFZVSMRA/2Ijw=="], + "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.68.0", "", { "os": "android", "cpu": "arm" }, "sha512-Ta2n0ntLfzP0LqwwcXOIh2z0mnHjlxMS+h4Y9lo+w33Quyf9KFKEi9QZ2IKqeEBKr0qxNpXc/DQjz5KVIs8AEA=="], + + "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.68.0", "", { "os": "android", "cpu": "arm64" }, "sha512-iFDtS0oMaBvKbtrRKXmRcBSsI0UaWL2bWpd62iHzb0A8RSPrVz47mUGE0CfrrD0c/7/7dUhNtoN3cc6aEUn1Ow=="], + + "@rollup/rollup-android-x64": ["@rollup/rollup-android-x64@4.68.0", "", { "os": "android", "cpu": "x64" }, "sha512-OnYETr+cZYSbesBD1tCvUjrBUTkjSaOcewRUoIHqD0XI3yn5i9WpdFaE3LZwrMlq0yeJNU0N5sxfHK/fNVMqlQ=="], + + "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.68.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-2qavWZtFeon/6oMkjsBF3OH7ENKgRTW4xRTwmz9VJeNUYhmPitpR9Jd4sAAc2OZJryHs2neoovMTCYnNvhvANQ=="], + + "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.68.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-QpgJO+GwNQDPt6uYcFSjZTFVyHNIeumN2am7RISDR9Nf3e/h8sur9cIfplPGihZPUn+sTw9j3JErZIUkHg8+Pw=="], + + "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.68.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-TERqEn6P9bp4lsTyoFjT3nLKV6G++76HhGb4k6dRGcs+jvhVcTGaS2zkeRdLLRjwKxpBtdCZe11kUQ2hNGgFSA=="], + + "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.68.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-RBjDrqb7h5l6Xgdgz5eKYvbpnUkii/z5ejWuZmHJsXORi0X0tTtFzEEgJj2DX995kW18c6T9LGFn/deEAMXDcQ=="], + + "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.68.0", "", { "os": "linux", "cpu": "arm" }, "sha512-HtLgXBqjF1Ampt9eJjzSmoGDvNb4LP8Y2aPXQZeQ5qhyExXLmoXJB9Jfm/nPi/8fJ3UFn4sZ7pQKyr8V+oTN8g=="], + + "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.68.0", "", { "os": "linux", "cpu": "arm" }, "sha512-q51xJyqjaqCNtDjYD7xNVwsPa2TcVfAIBeP6E20wicKZ6XYp8Taz9SUPYhIENojAQIAoV7cO3mUdMUgWYEAuhQ=="], + + "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.68.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-wejnVabl92oFC/o4sr/EEJuJZMHtMq4C+LBIPphN4EUiVHe9qvZNw+biqhVHpX2ggs1+Z3ugXGwJxT+qhyaaYQ=="], + + "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.68.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-tyu+hrsCWHHqV6+2tligV/recJH+HVvNV2Sp4nS1C+MKQPkNXRovKIzyHy0V0xXjm6igCLgsT2vTky5CvWP37g=="], + + "@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.68.0", "", { "os": "linux", "cpu": "none" }, "sha512-5gjJNglKDfgs3OmnGi/RVZQPhEfRoCIHxwSAP9ngmdnxreu0Vl9lI4gxmFBXOhKdftpS82xRdc/7Dp5/A1F0qg=="], + + "@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.68.0", "", { "os": "linux", "cpu": "none" }, "sha512-2IBxTUds33rFYwOIEyf77wfW8WQThwiQQ1ofXSraZQG7PiIq7BnQBf/ge0qEI/Ny/2cSc7SKkGO/wUDqmYXqTg=="], + + "@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.68.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-mE/Pj2PPTZIVHkNNuHq+eYoU3td8LCm73zjrXoBWkNlnuULJS2l/fxwgGPpN4WUCNZgKZ1IXwrnnETPyOcWPmg=="], + + "@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.68.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-dYuykUkAiTv+RQdP3Ib47XcFiImkBWiRpTGSQWAMfZPQyoQYGe8Je4IUeZYNUQWIojmRCUnt5xsH4BbUb2uqSw=="], + + "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.68.0", "", { "os": "linux", "cpu": "none" }, "sha512-OnPDDFXLqJewY56T6ow8sA4wuzbqlliD7QJgkrx2KX+pWOpjI3usYXgB0pwK3nsgTF2odCw9IuJs0Uis/jy2qA=="], + + "@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.68.0", "", { "os": "linux", "cpu": "none" }, "sha512-CqoQf06cK0brrRfDqH7Mt8G4MdteFGbjBdC61zEMaSVna6xo6QMUixa9bAkAD4a92g3ElPbQAkLMUzdf+Lk8dg=="], + + "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.68.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-LPHNmE8GwiyELGLUTkqj4zsP1YEHzGdtwnKxAcdP/swsNxXsfxPtpe5nrD/KGxr136xPB+eWv2r/SGj9md0pnQ=="], + + "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.68.0", "", { "os": "linux", "cpu": "x64" }, "sha512-GDOmvgephpRCNyNGRQOZh0KD2gTyRVM1Bb1iOo759xeCUpCAoRCmJioOOSu2MwyWfNOocGd0V5I9vYLfteC6/A=="], + + "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.68.0", "", { "os": "linux", "cpu": "x64" }, "sha512-HADRxkvl5eg3hbemCmv81UwTfdQy/CiSJDOabLE+p5tpm3OTjuRtzpLXy5zPfGY9FQD4Qv7qHptXmG/YjmNmyw=="], + + "@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.68.0", "", { "os": "openbsd", "cpu": "x64" }, "sha512-iERrpqu1VEfyX736HLKiXRbwGDkCV/iybARY/mn14KcI6oKhJGBx1e+bU+g+umTKghtiGSPaHkwwpII4/N3RjA=="], + + "@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.68.0", "", { "os": "none", "cpu": "arm64" }, "sha512-hBn57IqAbpXpyktckonwePTaFOQS6THph8ZnpRO3eZHY4LncuZGjSsseigBnKuSMKKpLnJJ7PemDvXEzniXC+A=="], + + "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.68.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-pJWb7mIw9Z25Hl3Q6nHFjl7AnczfOpm2gbOFYguSRv6TiH7DzsoAk/thymb/URSQu9OUEK7uaDMC5Xfm+7TAww=="], + + "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.68.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-pnrhmoyF2otH2Mezol14/ELUFGuRddOCz6+I+J0pq2Itnp4UxkjABQcXawCNMaKNsCRiuL90BtNzbEd0fHjpIg=="], + + "@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.68.0", "", { "os": "win32", "cpu": "x64" }, "sha512-1dJ3U+ktdtaIdPaOZKwIX57+bKQk4iAjs5M1wQWLKRB6Wglp98qf8LUeuN4u6bGlIYouZKaySZJ5Qd4OalUMnA=="], + + "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.68.0", "", { "os": "win32", "cpu": "x64" }, "sha512-e/NRJFl48wL5DFNSzQrvm4kaB5dzNNmqWjIJ6And2Sjuw4klO3w3TXMvCAEF1tHTrQQgpOD4QVkBE/92/yBGrQ=="], + "@sigstore/bundle": ["@sigstore/bundle@4.0.0", "", { "dependencies": { "@sigstore/protobuf-specs": "^0.5.0" } }, "sha512-NwCl5Y0V6Di0NexvkTqdoVfmjTaQwoLM236r89KEojGmq/jMls8S+zb7yOwAPdXvbwfKDlP+lmXgAL4vKSQT+A=="], "@sigstore/core": ["@sigstore/core@3.2.1", "", {}, "sha512-qRsxPnCrbC/puegGxKuynfnxgLiHqWStrSjxkoB4YKqq3Z3s4cyZyj42ZdWFAEblNP65C+rBH8EuREHIXoi83g=="], @@ -439,8 +545,18 @@ "@tufjs/models": ["@tufjs/models@4.1.0", "", { "dependencies": { "@tufjs/canonical-json": "2.0.0", "minimatch": "^10.1.1" } }, "sha512-Y8cK9aggNRsqJVaKUlEYs4s7CvQ1b1ta2DVPyAimb0I2qhzjNk+A+mxvll/klL0RlfuIUei8BF7YWiua4kQqww=="], + "@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="], + + "@types/babel__generator": ["@types/babel__generator@7.27.0", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg=="], + + "@types/babel__template": ["@types/babel__template@7.4.4", "", { "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A=="], + + "@types/babel__traverse": ["@types/babel__traverse@7.28.0", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="], + "@types/conventional-commits-parser": ["@types/conventional-commits-parser@5.0.2", "", { "dependencies": { "@types/node": "*" } }, "sha512-BgT2szDXnVypgpNxOK8aL5SGjUdaQbC++WZNjF1Qge3Og2+zhHj+RWhmehLhYyvQwqAmvezruVfOf8+3m74W+g=="], + "@types/estree": ["@types/estree@1.0.10", "", {}, "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g=="], + "@types/node": ["@types/node@22.13.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw=="], "@types/normalize-package-data": ["@types/normalize-package-data@2.4.4", "", {}, "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA=="], @@ -615,6 +731,8 @@ "es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="], + "esbuild": ["esbuild@0.28.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.28.2", "@esbuild/android-arm": "0.28.2", "@esbuild/android-arm64": "0.28.2", "@esbuild/android-x64": "0.28.2", "@esbuild/darwin-arm64": "0.28.2", "@esbuild/darwin-x64": "0.28.2", "@esbuild/freebsd-arm64": "0.28.2", "@esbuild/freebsd-x64": "0.28.2", "@esbuild/linux-arm": "0.28.2", "@esbuild/linux-arm64": "0.28.2", "@esbuild/linux-ia32": "0.28.2", "@esbuild/linux-loong64": "0.28.2", "@esbuild/linux-mips64el": "0.28.2", "@esbuild/linux-ppc64": "0.28.2", "@esbuild/linux-riscv64": "0.28.2", "@esbuild/linux-s390x": "0.28.2", "@esbuild/linux-x64": "0.28.2", "@esbuild/netbsd-arm64": "0.28.2", "@esbuild/netbsd-x64": "0.28.2", "@esbuild/openbsd-arm64": "0.28.2", "@esbuild/openbsd-x64": "0.28.2", "@esbuild/openharmony-arm64": "0.28.2", "@esbuild/sunos-x64": "0.28.2", "@esbuild/win32-arm64": "0.28.2", "@esbuild/win32-ia32": "0.28.2", "@esbuild/win32-x64": "0.28.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA=="], + "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], "exponential-backoff": ["exponential-backoff@3.1.3", "", {}, "sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA=="], @@ -649,6 +767,8 @@ "fs.realpath": ["fs.realpath@1.0.0", "", {}, "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="], + "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], + "function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="], "gaxios": ["gaxios@7.3.1", "", { "dependencies": { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2" } }, "sha512-kB3rzJV7d9juLZh8/56QTXCwQfxyhdOMdyYk1HdQKFtF8TJTDTZQJtixWIwXdE9Jji91mC41DUNpjleo4L4eAQ=="], @@ -723,6 +843,8 @@ "is-text-path": ["is-text-path@2.0.0", "", { "dependencies": { "text-extensions": "^2.0.0" } }, "sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw=="], + "is-what": ["is-what@4.1.16", "", {}, "sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A=="], + "is-wsl": ["is-wsl@3.1.1", "", { "dependencies": { "is-inside-container": "^1.0.0" } }, "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw=="], "isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="], @@ -813,6 +935,8 @@ "meow": ["meow@13.2.0", "", {}, "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA=="], + "merge-anything": ["merge-anything@5.1.7", "", { "dependencies": { "is-what": "^4.1.8" } }, "sha512-eRtbOb1N5iyH0tkQDAoQ4Ipsp/5qSR79Dzrz8hEPxRX10RWWR/iQXdoKmBSRCThY1Fh5EhISDtpSc93fpxUniQ=="], + "mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="], "mime-types": ["mime-types@3.0.2", "", { "dependencies": { "mime-db": "^1.54.0" } }, "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A=="], @@ -837,6 +961,8 @@ "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="], + "nanoid": ["nanoid@3.3.20", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ=="], + "negotiator": ["negotiator@1.1.0", "", { "dependencies": { "content-type": "^2.1.0" } }, "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg=="], "neo-async": ["neo-async@2.6.2", "", {}, "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="], @@ -907,6 +1033,8 @@ "pkg-up": ["pkg-up@3.1.0", "", { "dependencies": { "find-up": "^3.0.0" } }, "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA=="], + "postcss": ["postcss@8.5.32", "", { "dependencies": { "nanoid": "^3.3.20", "picocolors": "^1.1.1", "source-map-js": "^1.2.2" } }, "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g=="], + "postcss-selector-parser": ["postcss-selector-parser@7.1.6", "", { "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" } }, "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw=="], "powershell-utils": ["powershell-utils@0.2.1", "", {}, "sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A=="], @@ -939,6 +1067,8 @@ "rimraf": ["rimraf@5.0.10", "", { "dependencies": { "glob": "^10.3.7" }, "bin": { "rimraf": "dist/esm/bin.mjs" } }, "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ=="], + "rollup": ["rollup@4.68.0", "", { "dependencies": { "@types/estree": "^1.0.10" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.68.0", "@rollup/rollup-android-arm64": "4.68.0", "@rollup/rollup-android-x64": "4.68.0", "@rollup/rollup-darwin-arm64": "4.68.0", "@rollup/rollup-darwin-x64": "4.68.0", "@rollup/rollup-freebsd-arm64": "4.68.0", "@rollup/rollup-freebsd-x64": "4.68.0", "@rollup/rollup-linux-arm-gnueabihf": "4.68.0", "@rollup/rollup-linux-arm-musleabihf": "4.68.0", "@rollup/rollup-linux-arm64-gnu": "4.68.0", "@rollup/rollup-linux-arm64-musl": "4.68.0", "@rollup/rollup-linux-loong64-gnu": "4.68.0", "@rollup/rollup-linux-loong64-musl": "4.68.0", "@rollup/rollup-linux-ppc64-gnu": "4.68.0", "@rollup/rollup-linux-ppc64-musl": "4.68.0", "@rollup/rollup-linux-riscv64-gnu": "4.68.0", "@rollup/rollup-linux-riscv64-musl": "4.68.0", "@rollup/rollup-linux-s390x-gnu": "4.68.0", "@rollup/rollup-linux-x64-gnu": "4.68.0", "@rollup/rollup-linux-x64-musl": "4.68.0", "@rollup/rollup-openbsd-x64": "4.68.0", "@rollup/rollup-openharmony-arm64": "4.68.0", "@rollup/rollup-win32-arm64-msvc": "4.68.0", "@rollup/rollup-win32-ia32-msvc": "4.68.0", "@rollup/rollup-win32-x64-gnu": "4.68.0", "@rollup/rollup-win32-x64-msvc": "4.68.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-BIHWnc1Qjdy+WLfOdcSd67sxO4iW6pTnhdZosg+7ywSaiMWxxzKldkkNpUJqeXYAiJzyB14P2cIjqC6tlb6xzw=="], + "run-applescript": ["run-applescript@7.1.0", "", {}, "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q=="], "s-js": ["s-js@0.4.9", "", {}, "sha512-RtpOm+cM6O0sHg6IA70wH+UC3FZcND+rccBZpBAHzlUgNO2Bm5BN+FnM8+OBxzXdwpKWFwX11JGF0MFRkhSoIQ=="], @@ -971,8 +1101,12 @@ "solid-js": ["solid-js@1.9.15", "", { "dependencies": { "csstype": "^3.1.0", "seroval": "~1.5.4", "seroval-plugins": "~1.5.4" } }, "sha512-EeiY2xfpZJqPLjXspVEKjAII4yv8NyG//NxZ3IpOFHdUNnnTyL0uJOeS9LWGvA7cFCz5y94cjFwYlmw5Luncsg=="], + "solid-refresh": ["solid-refresh@0.6.3", "", { "dependencies": { "@babel/generator": "^7.23.6", "@babel/helper-module-imports": "^7.22.15", "@babel/types": "^7.23.6" }, "peerDependencies": { "solid-js": "^1.3" } }, "sha512-F3aPsX6hVw9ttm5LYlth8Q15x6MlI/J3Dn+o3EQyRTtTxidepSTwAYdozt01/YA+7ObcciagGEyXIopGZzQtbA=="], + "source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="], + "source-map-js": ["source-map-js@1.2.2", "", {}, "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw=="], + "spdx-correct": ["spdx-correct@3.2.0", "", { "dependencies": { "spdx-expression-parse": "^3.0.0", "spdx-license-ids": "^3.0.0" } }, "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA=="], "spdx-exceptions": ["spdx-exceptions@2.5.0", "", {}, "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w=="], @@ -1039,6 +1173,12 @@ "validate-npm-package-name": ["validate-npm-package-name@7.0.2", "", {}, "sha512-hVDIBwsRruT73PbK7uP5ebUt+ezEtCmzZz3F59BSr2F6OVFnJ/6h8liuvdLrQ88Xmnk6/+xGGuq+pG9WwTuy3A=="], + "vite": ["vite@7.3.7", "", { "dependencies": { "esbuild": "^0.27.0 || ^0.28.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-AHEzTORMbi7/7aXp7w7KZ5+DCUdSeLsJz0grY8xHpc9DHdYb0vQu6DqJfm2tOw3gDExNgPgnJTXxM6syYFHaCA=="], + + "vite-plugin-solid": ["vite-plugin-solid@2.11.10", "", { "dependencies": { "@babel/core": "^7.23.3", "@types/babel__core": "^7.20.4", "babel-preset-solid": "^1.8.4", "merge-anything": "^5.1.7", "solid-refresh": "^0.6.3", "vitefu": "^1.0.4" }, "peerDependencies": { "@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.*", "solid-js": "^1.7.2", "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" }, "optionalPeers": ["@testing-library/jest-dom"] }, "sha512-Yr1dQybmtDtDAHkii6hXuc1oVH9CPcS/Zb2jN/P36qqcrkNnVPsMTzQ06jyzFPFjj3U1IYKMVt/9ZqcwGCEbjw=="], + + "vitefu": ["vitefu@1.1.3", "", { "peerDependencies": { "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" }, "optionalPeers": ["vite"] }, "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg=="], + "walk-up-path": ["walk-up-path@4.0.0", "", {}, "sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A=="], "web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="], diff --git a/package.json b/package.json index fbeb44cf..c50f8de3 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "types": "./dist/tui.d.ts", "import": "./dist/tui.js" }, + "./gui-experimental": "./dist/gui-experimental.cjs", "./plugins/guardian": { "types": "./dist/plugins/guardian/index.d.ts", "import": "./dist/plugins/guardian/index.js" @@ -102,7 +103,7 @@ } }, "scripts": { - "build": "rm -rf dist && tsc -p tsconfig.build.json && bun scripts/copy-dist-assets.ts", + "build": "rm -rf dist && tsc -p tsconfig.build.json && bun scripts/copy-dist-assets.ts && vite build --config scripts/vite-gui.ts", "prepublishOnly": "bun run build", "typecheck": "tsc --noEmit -p tsconfig.json", "lint": "oxlint --deny warnings src", @@ -151,7 +152,9 @@ "oxfmt": "0.43.0", "oxlint": "1.58.0", "solid-js": "1.9.15", - "typescript": "5.8.2" + "typescript": "5.8.2", + "vite": "7.3.7", + "vite-plugin-solid": "2.11.10" }, "peerDependencies": { "@opentui/core": ">=0.5.12", diff --git a/scripts/check-exports.ts b/scripts/check-exports.ts index e8dfb7f3..180cfde2 100644 --- a/scripts/check-exports.ts +++ b/scripts/check-exports.ts @@ -27,7 +27,7 @@ // END_MODULE_MAP // // START_CHANGE_SUMMARY -// LAST_CHANGE: [C-CONTEXT-TUI-PLUGIN - Added TSX source lookup and TUI plugin export recognition.] +// LAST_CHANGE: [GUI spike skeleton - Recognized bundler-built CommonJS export targets (./dist/*.cjs) and their src/tsx|ts entry twins.] // END_CHANGE_SUMMARY import { readFileSync } from "node:fs"; @@ -75,6 +75,15 @@ function getExportPaths(exports: PackageExports): Map { } function resolveDistPath(importPath: string): string | null { + const bundled = importPath.match(/^\.\/dist\/(.+)\.cjs$/); + if (bundled) { + const basePath = "src/" + bundled[1]; + for (const extension of [".tsx", ".ts"]) { + const candidate = basePath + extension; + if (checkExportExists(candidate).exists) return candidate; + } + return basePath + ".tsx"; + } const match = importPath.match(/^\.\/dist\/(.+)\.js$/); if (!match) return null; const basePath = "src/" + match[1]; diff --git a/scripts/gui-bundle.test.ts b/scripts/gui-bundle.test.ts new file mode 100644 index 00000000..3e366080 --- /dev/null +++ b/scripts/gui-bundle.test.ts @@ -0,0 +1,114 @@ +// FILE: scripts/gui-bundle.test.ts +// VERSION: 1.0.0 +// START_MODULE_CONTRACT +// PURPOSE: Execute the built `./gui-experimental` CommonJS bundle with the host SDK modules stubbed and assert that its default export is a loadable GUI definition: an English i18n catalog and a setup that registers the vvoc settings page and the profile composer pill. +// SCOPE: Bundle-level loadability harness over `dist/gui-experimental.cjs` when it exists (skipped on a fresh tree without a build); externals are stubbed because the app provides them at runtime. No DOM and no real host. +// DEPENDS: [node:fs, node:module, bun:test] +// LINKS: [M-GUI-SPIKE, V-M-GUI-SPIKE] +// ROLE: TEST +// MAP_MODE: LOCALS +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// BUNDLE_PATH - Repo-relative path of the built GUI bundle. +// loadBundle - Evaluates the built bundle with stubbed app-provided modules and returns its default export. +// recorded - The registry items the stubbed context captured during setup. +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added the built-bundle loadability harness proving the default export registers both GUI contributions with its i18n catalog.] +// END_CHANGE_SUMMARY + +import { describe, expect, test } from "bun:test"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +/** Repo-relative path of the built GUI bundle. */ +export const BUNDLE_PATH = join(import.meta.dir, "..", "dist", "gui-experimental.cjs"); + +/** The registry items the stubbed context captured during setup. */ +const recorded: Array<{ registry: string; item: Record }> = []; + +/** + * Evaluates the built bundle with stubbed app-provided modules and returns its + * default export. The stubs mirror the host's shared-module contract: + * `@opencode/plugin/gui` provides the define/registries surface, `effect` + * provides the Schema namespace, and Solid provides the reactive primitives. + */ +function loadBundle(): Record { + const source = require("node:fs").readFileSync(BUNDLE_PATH, "utf8") as string; + const stubSchema = new Proxy( + {}, + { + get: (_target, prop) => { + if (prop === "toStandardSchemaV1") return (value: unknown) => value; + return () => ({}); + }, + }, + ); + const stubs: Record = { + "solid-js": { + createResource: () => [() => undefined, { refetch: () => undefined }], + Show: () => null, + }, + "solid-js/web": { insert: () => undefined, createComponent: () => null, template: () => null }, + "@opencode/plugin/gui": { + Plugin: { define: (definition: unknown) => definition }, + SettingsPage: { name: "SettingsPage" }, + ComposerPill: { name: "ComposerPill" }, + }, + effect: { Schema: stubSchema }, + }; + const module = { exports: {} as Record }; + const loader = new Function("require", "module", "exports", source); + loader( + (name: string) => { + const stub = stubs[name]; + if (stub !== undefined) return stub; + return require(name); + }, + module, + module.exports, + ); + return (module.exports.default ?? {}) as Record; +} + +describe("gui bundle loadability", () => { + test("default export registers the settings page and the composer pill", () => { + if (!existsSync(BUNDLE_PATH)) { + console.log("dist/gui-experimental.cjs is absent (no build); skipping bundle harness"); + return; + } + const definition = loadBundle(); + const i18n = definition.i18n as { en?: Record } | undefined; + expect(typeof definition.setup).toBe("function"); + expect(i18n?.en).toBeDefined(); + expect(Object.keys(i18n?.en ?? {})).toContain("settings.title"); + + const context = { + id: "vvoc", + app: { platform: "web", version: "0.0.0" }, + t: (key: string) => i18n?.en?.[key] ?? key, + add: (registry: { name: string }, item: Record) => { + recorded.push({ registry: String(registry.name), item }); + return () => undefined; + }, + layout: { settings: () => undefined }, + client: { + rpc: () => ({ + "defaults.get": async () => { + throw new Error("stub client"); + }, + }), + }, + signal: new AbortController().signal, + }; + (definition.setup as (ctx: unknown) => unknown)(context); + const page = recorded.find((entry) => entry.registry === "SettingsPage"); + const pill = recorded.find((entry) => entry.registry === "ComposerPill"); + expect(page?.item.id).toBe("vvoc"); + expect(typeof page?.item.render).toBe("function"); + expect(pill?.item.id).toBe("profile"); + expect(typeof (pill?.item as { show?: unknown }).show).toBe("function"); + }); +}); diff --git a/scripts/vite-gui.ts b/scripts/vite-gui.ts new file mode 100644 index 00000000..a7286130 --- /dev/null +++ b/scripts/vite-gui.ts @@ -0,0 +1,25 @@ +// FILE: scripts/vite-gui.ts +// VERSION: 1.0.0 +import { defineConfig } from "vite"; +import { gui } from "@opencode/plugin/gui/vite"; + +// START_MODULE_CONTRACT +// PURPOSE: Build the `./gui-experimental` window part with the host-provided Vite GUI preset: one CommonJS bundle from the `src/gui-experimental.tsx` entry at `dist/gui-experimental.cjs`, app-provided modules external, dynamic imports inlined. +// SCOPE: Vite build configuration only; no server behavior, no packaging beyond the bundle the preset writes. +// DEPENDS: [vite, @opencode/plugin/gui/vite] +// LINKS: [M-GUI-SPIKE, V-M-PLUGIN-GUI-SETTINGS] +// ROLE: CONFIG +// MAP_MODE: NONE +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added the preset-driven Vite config for the experimental GUI bundle, explicitly not named vite.config.ts because the oxlint/oxfmt gates auto-discover root TS configs.] +// END_CHANGE_SUMMARY + +// Run explicitly: `vite build --config scripts/vite-gui.ts`. +export default defineConfig({ + plugins: [gui({ entry: "src/gui-experimental.tsx" })], +}); \ No newline at end of file diff --git a/src/gui-experimental.tsx b/src/gui-experimental.tsx new file mode 100644 index 00000000..8464a56f --- /dev/null +++ b/src/gui-experimental.tsx @@ -0,0 +1,137 @@ +/** @jsxImportSource solid-js */ +// FILE: src/gui-experimental.tsx +// VERSION: 1.0.0 +// START_MODULE_CONTRACT +// PURPOSE: Define the minimal `./gui-experimental` window part of the GUI spike: a "vvoc" settings page stub and a composer pill that show the orchestration profile from the effective vvoc defaults through the versioned GUI RPC, plus the platform/app badge that makes the web-versus-desktop loading verdict observable in the DOM. +// SCOPE: One GUI plugin definition with an English i18n catalog, a SettingsPage contribution rendered with host ui components, one ComposerPill that opens the page, and a bounded RPC read with strict reply decoding. It registers no server behavior and owns no stores; the full settings panels are later, separately planned work. +// DEPENDS: [solid-js, @opencode/plugin/gui, src/rpc.ts] +// LINKS: [M-GUI-SPIKE, DF-GUI-RPC, V-M-PLUGIN-GUI-SETTINGS] +// ROLE: RUNTIME +// MAP_MODE: EXPORTS +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// default - The `./gui-experimental` GUI definition (settings page stub plus profile composer pill). +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added the minimal vvoc settings page stub and profile composer pill over the versioned GUI RPC, with host ui components and an English i18n catalog.] +// END_CHANGE_SUMMARY + +import { createResource, Show, type Accessor } from "solid-js"; +import { ComposerPill, Plugin, SettingsPage, type ComposerPillView } from "@opencode/plugin/gui"; +import { + VVOC_GUI_METHODS, + decodeDefaultsGetOutput, + vvocGuiRpc, + type DefaultsGetOutput, +} from "./rpc.js"; + +const SETTINGS_PAGE_ID = "vvoc"; + +// START_BLOCK_GUI_DEFINITION +export default Plugin.define({ + i18n: { + en: { + "settings.title": "vvoc", + "settings.description": + "GUI spike: the vvoc window part loaded and reached the server plugin over its versioned RPC.", + "settings.profile": "Orchestration profile", + "settings.source": "Config source", + "settings.platform": "Platform", + "settings.unavailable": "vvoc defaults are unavailable right now.", + "settings.retry": "Retry", + "pill.label": "vvoc · {{profile}}", + "pill.missing": "vvoc · no profile", + }, + }, + setup(ctx) { + const [defaults, { refetch }] = createResource(async () => { + const reply = await ctx.client + .rpc(vvocGuiRpc) + [VVOC_GUI_METHODS.defaultsGet]({}, { signal: ctx.signal }); + return decodeDefaultsGetOutput(reply); + }); + + const profile = () => { + const value: DefaultsGetOutput | undefined = defaults(); + return value?.status === "available" ? value.profile : undefined; + }; + + ctx.add(SettingsPage, { + id: SETTINGS_PAGE_ID, + title: ctx.t("settings.title"), + icon: "sliders", + entries: [ + { + id: SETTINGS_PAGE_ID, + title: ctx.t("settings.title"), + description: ctx.t("settings.description"), + }, + ], + render: () => ( +
+

{ctx.t("settings.title")}

+

{ctx.t("settings.description")}

+
+ {ctx.t("settings.platform")}: {ctx.app.platform} ({ctx.app.version}) +
+ +

{ctx.t("settings.unavailable")}

+ void refetch()}> + {ctx.t("settings.retry")} + +
+ } + > + + + + } + > + {(value: Accessor) => ( +
+
+ {ctx.t("settings.profile")}: {value().profile ?? "—"} +
+ + {(source: Accessor>) => ( +
+ {ctx.t("settings.source")}: {source().kind} + {source().path === undefined ? "" : ` (${source().path})`} +
+ )} +
+
+ )} +
+ + + ), + }); + + ctx.add(ComposerPill, { + id: "profile", + show: () => { + const current = profile(); + const view: ComposerPillView = { + icon: "flask", + label: + current === undefined + ? ctx.t("pill.missing") + : ctx.t("pill.label", { profile: current }), + title: ctx.t("settings.title"), + run: () => ctx.layout.settings(SETTINGS_PAGE_ID), + }; + return view; + }, + }); + }, +}); +// END_BLOCK_GUI_DEFINITION diff --git a/src/index.ts b/src/index.ts index 93f599dd..58efe00f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,17 +2,17 @@ // VERSION: 1.1.0 // START_MODULE_CONTRACT // PURPOSE: Re-export the public vv-opencode plugin entrypoints from the package root and assemble them into one native aggregate server plugin. -// SCOPE: Package-root exports for GuardianPlugin, HashlineEditPlugin, ModelRolesPlugin, SystemContextInjectionPlugin, WorkflowPlugin, SecretsRedactionPlugin, WebToolsPlugin, ToolHistoryCompactionPlugin, AnalyticsPlugin, PeakHoursPlugin, SpecGuardPlugin, and TelegramBridgePlugin, plus the native default definition that sets all of them up against one shared Context with complete reverse-order teardown and partial-setup rollback. -// DEPENDS: [@opencode/plugin, src/plugins/guardian/index.ts, src/plugins/hashline-edit/index.ts, src/plugins/model-roles/index.ts, src/plugins/system-context-injection/index.ts, src/plugins/workflow/index.ts, src/plugins/secrets-redaction.ts, src/plugins/web-tools/index.ts, src/plugins/tool-history-compaction/index.ts, src/plugins/analytics/index.ts, src/plugins/peak-hours/index.ts, src/plugins/spec-guard/index.ts] +// SCOPE: Package-root exports for GuardianPlugin, HashlineEditPlugin, ModelRolesPlugin, SystemContextInjectionPlugin, WorkflowPlugin, SecretsRedactionPlugin, WebToolsPlugin, ToolHistoryCompactionPlugin, AnalyticsPlugin, PeakHoursPlugin, SpecGuardPlugin, GuiSettingsPlugin, and TelegramBridgePlugin, plus the native default definition that sets all of them up against one shared Context with complete reverse-order teardown and partial-setup rollback. +// DEPENDS: [@opencode/plugin, src/plugins/guardian/index.ts, src/plugins/hashline-edit/index.ts, src/plugins/model-roles/index.ts, src/plugins/system-context-injection/index.ts, src/plugins/workflow/index.ts, src/plugins/secrets-redaction.ts, src/plugins/web-tools/index.ts, src/plugins/tool-history-compaction/index.ts, src/plugins/analytics/index.ts, src/plugins/peak-hours/index.ts, src/plugins/spec-guard/index.ts, src/plugins/gui-settings.ts] // LINKS: [M-PLUGIN-GUARDIAN, M-PLUGIN-HASHLINE-EDIT, M-PLUGIN-MODEL-ROLES, M-PLUGIN-SYSTEM-CONTEXT-INJECTION, M-PLUGIN-WORKFLOW, M-PLUGIN-SECRETS-REDACTION, M-PLUGIN-WEB-TOOLS, M-PLUGIN-TOOL-HISTORY-COMPACTION, M-PLUGIN-ANALYTICS, M-PLUGIN-PEAK-HOURS, M-PLUGIN-SPEC-GUARD] // ROLE: BARREL // MAP_MODE: SUMMARY // END_MODULE_CONTRACT // // START_MODULE_MAP -// GuardianPlugin, HashlineEditPlugin, ModelRolesPlugin, SystemContextInjectionPlugin, WorkflowPlugin, SecretsRedactionPlugin, WebToolsPlugin, ToolHistoryCompactionPlugin, AnalyticsPlugin, PeakHoursPlugin, SpecGuardPlugin, TelegramBridgePlugin - Public plugin exports available from @osovv/vv-opencode. -// VVOC_SERVER_PLUGINS - The native server plugins in deterministic setup order (model roles first so the shared snapshot runtime exists before consumers; the telegram bridge last as a standalone gateway). -// VvocPlugin - Native aggregate server plugin that sets up all eleven plugins on one Context and tears them down in reverse order. +// GuardianPlugin, HashlineEditPlugin, ModelRolesPlugin, SystemContextInjectionPlugin, WorkflowPlugin, SecretsRedactionPlugin, WebToolsPlugin, ToolHistoryCompactionPlugin, AnalyticsPlugin, PeakHoursPlugin, SpecGuardPlugin, GuiSettingsPlugin, TelegramBridgePlugin - Public plugin exports available from @osovv/vv-opencode. +// VVOC_SERVER_PLUGINS - The native server plugins in deterministic setup order (model roles first so the shared snapshot runtime exists before consumers; the GUI settings RPC beside them as a standalone seam; the telegram bridge last as a standalone gateway). +// VvocPlugin - Native aggregate server plugin that sets up all twelve plugins on one Context and tears them down in reverse order. // default - Native default server plugin definition loaded by OpenCode from the package or a local directory. // END_MODULE_MAP // @@ -25,6 +25,7 @@ import { Plugin } from "@opencode/plugin"; import { AnalyticsPlugin } from "./plugins/analytics/index.js"; import { GuardianPlugin } from "./plugins/guardian/index.js"; import { HashlineEditPlugin } from "./plugins/hashline-edit/index.js"; +import { GuiSettingsPlugin } from "./plugins/gui-settings.js"; import { ModelRolesPlugin } from "./plugins/model-roles/index.js"; import { PeakHoursPlugin } from "./plugins/peak-hours/index.js"; import { SecretsRedactionPlugin } from "./plugins/secrets-redaction.js"; @@ -37,6 +38,7 @@ import { WorkflowPlugin } from "./plugins/workflow/index.js"; export { GuardianPlugin } from "./plugins/guardian/index.js"; export { HashlineEditPlugin } from "./plugins/hashline-edit/index.js"; +export { GuiSettingsPlugin } from "./plugins/gui-settings.js"; export { ModelRolesPlugin } from "./plugins/model-roles/index.js"; export { SystemContextInjectionPlugin } from "./plugins/system-context-injection/index.js"; export { WorkflowPlugin } from "./plugins/workflow/index.js"; @@ -50,7 +52,7 @@ export { TelegramBridgePlugin } from "./plugins/telegram/index.js"; // START_BLOCK_AGGREGATE /** - * The eleven native server plugins in deterministic setup order. Model roles is + * The twelve native server plugins in deterministic setup order. Model roles is * first so the shared snapshot runtime exists before every consumer acquires it; * every plugin still tolerates being set up standalone. */ @@ -66,6 +68,7 @@ export const VVOC_SERVER_PLUGINS: readonly Plugin.Plugin[] = [ AnalyticsPlugin, PeakHoursPlugin, SpecGuardPlugin, + GuiSettingsPlugin, TelegramBridgePlugin, ]; diff --git a/src/plugins/gui-settings.test.ts b/src/plugins/gui-settings.test.ts new file mode 100644 index 00000000..8185d08d --- /dev/null +++ b/src/plugins/gui-settings.test.ts @@ -0,0 +1,236 @@ +// FILE: src/plugins/gui-settings.test.ts +// VERSION: 1.0.0 +// START_MODULE_CONTRACT +// PURPOSE: Test the GUI settings RPC handlers and their production wiring: bounded defaults projection, conservative CLI-reused profile write, honest stub/unsupported session verdicts, value-free failure mapping, and a registrar-level roundtrip that decodes replies with the client decoders. +// SCOPE: In-memory deps for the four handlers plus a disk-backed production-wiring roundtrip over a temporary sandbox vvoc.json; no live host and no network. +// DEPENDS: [node:fs/promises, node:os, node:path, src/plugins/gui-settings.ts, src/rpc.ts, src/lib/vvoc-config.ts] +// LINKS: [M-PLUGIN-GUI-SETTINGS, M-GUI-SPIKE, V-M-PLUGIN-GUI-SETTINGS] +// ROLE: TEST +// MAP_MODE: LOCALS +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// memoryDeps - Builds the in-memory handler deps and records profile writes. +// mkdtempRoot - Creates the sandbox directory for the production-wiring roundtrip. +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added handler verdict tests plus the sandbox roundtrip over the production CLI-reused wiring.] +// END_CHANGE_SUMMARY + +import { describe, expect, test } from "bun:test"; +import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { + createGuiSettingsHandlers, + GuiSettingsPlugin, + STUB_SETTINGS_NOTE, + registerGuiSettingsRpc, + type GuiSettingsDeps, +} from "./gui-settings.js"; +import { + VVOC_GUI_RPC_ID, + decodeDefaultsGetOutput, + decodeSessionGetOutput, + type DefaultsGetOutput, +} from "../rpc.js"; +import { createDefaultVvocConfig, renderVvocConfig } from "../lib/vvoc-config.js"; + +function memoryDeps( + overrides: Partial = {}, +): GuiSettingsDeps & { writes: Array<{ profile: string; scope: string }> } { + const writes: Array<{ profile: string; scope: string }> = []; + return { + writes, + readDefaults: async () => ({ + profile: "balanced", + plugins: { guardian: true, analytics: true, peakHours: false }, + source: { kind: "project", path: "/sandbox/.vvoc/vvoc.json" }, + }), + writeProfile: async (profile, scope) => { + writes.push({ profile, scope }); + return { action: "updated", path: "/sandbox/.vvoc/vvoc.json" }; + }, + sessionExists: async (sessionID) => sessionID === "ses-known", + ...overrides, + }; +} + +describe("gui settings handlers", () => { + test("projects the effective defaults as an available reply", async () => { + const deps = memoryDeps(); + const handlers = createGuiSettingsHandlers(deps); + const reply = await handlers["defaults.get"]({}); + const decoded: DefaultsGetOutput = decodeDefaultsGetOutput(reply); + expect(decoded.status).toBe("available"); + expect(decoded.profile).toBe("balanced"); + expect(decoded.plugins).toEqual({ guardian: true, analytics: true, peakHours: false }); + expect(decoded.source?.kind).toBe("project"); + expect(decoded.source?.path).toBe("/sandbox/.vvoc/vvoc.json"); + }); + + test("maps a defaults read failure to the value-free unavailable verdict", async () => { + const deps = memoryDeps({ + readDefaults: async () => { + throw new Error("effective config unavailable"); + }, + }); + const handlers = createGuiSettingsHandlers(deps); + const decoded = decodeDefaultsGetOutput(await handlers["defaults.get"]({})); + expect(decoded.status).toBe("unavailable"); + expect(decoded.error).toBe("config_unavailable"); + expect(JSON.stringify(decoded)).not.toContain("effective config unavailable"); + }); + + test("routes defaults.set through the injected conservative write", async () => { + const deps = memoryDeps(); + const handlers = createGuiSettingsHandlers(deps); + const reply = await handlers["defaults.set"]({ profile: "delegated", scope: "project" }); + expect(deps.writes).toEqual([{ profile: "delegated", scope: "project" }]); + expect(reply.action).toBe("updated"); + expect(reply.profile).toBe("delegated"); + expect(reply.path).toBe("/sandbox/.vvoc/vvoc.json"); + }); + + test("maps a failed write to the unavailable verdict without raw errors", async () => { + const deps = memoryDeps({ + writeProfile: async () => { + throw new Error("EACCES: permission denied, open '/sandbox/.vvoc/vvoc.json'"); + }, + }); + const handlers = createGuiSettingsHandlers(deps); + const reply = await handlers["defaults.set"]({ profile: "orchestrated", scope: "global" }); + expect(reply.action).toBe("unavailable"); + expect(reply.error).toBe("config_unavailable"); + expect(JSON.stringify(reply)).not.toContain("EACCES"); + }); + + test("session.get answers the stub projection for an existing session", async () => { + const handlers = createGuiSettingsHandlers(memoryDeps()); + const decoded = decodeSessionGetOutput( + await handlers["session.get"]({ sessionID: "ses-known" }), + ); + expect(decoded.status).toBe("stub"); + expect(decoded.profile).toBe("balanced"); + expect(decoded.note).toBe(STUB_SETTINGS_NOTE); + expect(decoded.error).toBeUndefined(); + }); + + test("session.get reports the lookup failure for an unknown session", async () => { + const handlers = createGuiSettingsHandlers(memoryDeps()); + const decoded = decodeSessionGetOutput( + await handlers["session.get"]({ sessionID: "ses-missing" }), + ); + expect(decoded.status).toBe("unavailable"); + expect(decoded.error).toBe("session_lookup_failed"); + }); + + test("session.get degrades to the config verdict when the defaults read fails", async () => { + const deps = memoryDeps({ + readDefaults: async () => { + throw new Error("broken"); + }, + }); + const handlers = createGuiSettingsHandlers(deps); + const decoded = decodeSessionGetOutput( + await handlers["session.get"]({ sessionID: "ses-known" }), + ); + expect(decoded.status).toBe("unavailable"); + expect(decoded.error).toBe("config_unavailable"); + }); + + test("session.patch stays explicitly unsupported for an existing session", async () => { + const handlers = createGuiSettingsHandlers(memoryDeps()); + const reply = await handlers["session.patch"]({ sessionID: "ses-known" }); + expect(reply.status).toBe("unsupported"); + expect(reply.error).toBe("session_settings_unsupported"); + }); + + test("session.patch reports the lookup failure for an unknown session", async () => { + const handlers = createGuiSettingsHandlers(memoryDeps()); + const reply = await handlers["session.patch"]({ sessionID: "ses-missing" }); + expect(reply.status).toBe("unavailable"); + expect(reply.error).toBe("session_lookup_failed"); + }); +}); + +describe("gui settings registration", () => { + test("registers the versioned contract on the server registrar", async () => { + const registered: Array<{ id: string }> = []; + const registration = await registerGuiSettingsRpc({ + location: { directory: "/sandbox" }, + rpc: { + register: async (definition) => { + registered.push({ id: definition.id }); + return { dispose: async () => undefined }; + }, + }, + session: { get: async () => undefined }, + }); + expect(registered).toEqual([{ id: VVOC_GUI_RPC_ID }]); + await registration.dispose(); + }); + + test("exposes the native aggregate plugin shape", () => { + expect(GuiSettingsPlugin.id).toBe("vvoc-gui-settings"); + expect(typeof GuiSettingsPlugin.setup).toBe("function"); + }); + + test("roundtrips the production wiring against a sandbox vvoc.json", async () => { + const sandbox = await mkdtempRoot(); + try { + const configDir = join(sandbox, ".vvoc"); + await mkdir(configDir, { recursive: true }); + await writeFile(join(configDir, "vvoc.json"), renderVvocConfig(createDefaultVvocConfig())); + + let registered: + | { + id: string; + handlers: Record Promise>; + } + | undefined; + const handle = await registerGuiSettingsRpc({ + location: { directory: sandbox }, + rpc: { + register: async (definition, handlers) => { + registered = { + id: definition.id, + handlers: handlers as Record Promise>, + }; + return { dispose: async () => undefined }; + }, + }, + session: { get: async (input) => ({ id: input.sessionID }) }, + }); + + expect(registered?.id).toBe(VVOC_GUI_RPC_ID); + const reply = (await registered?.handlers["defaults.get"]({})) as DefaultsGetOutput; + const decoded = decodeDefaultsGetOutput(reply); + expect(decoded.status).toBe("available"); + expect(decoded.profile).toBe("balanced"); + expect(decoded.source?.kind).toBe("project"); + + const setReply = (await registered?.handlers["defaults.set"]({ + profile: "orchestrated", + scope: "project", + })) as { action: string; path: string }; + expect(setReply.action).toBe("updated"); + const written = await readFile(join(configDir, "vvoc.json"), "utf8"); + expect(JSON.parse(written).orchestration.profile).toBe("orchestrated"); + + const reread = decodeDefaultsGetOutput( + (await registered?.handlers["defaults.get"]({})) as unknown, + ); + expect(reread.profile).toBe("orchestrated"); + + await handle.dispose(); + } finally { + await rm(sandbox, { recursive: true, force: true }); + } + }); +}); + +async function mkdtempRoot(): Promise { + return await mkdtemp(join(tmpdir(), "vvoc-gui-settings-test-")); +} diff --git a/src/plugins/gui-settings.ts b/src/plugins/gui-settings.ts new file mode 100644 index 00000000..7e93740d --- /dev/null +++ b/src/plugins/gui-settings.ts @@ -0,0 +1,253 @@ +// FILE: src/plugins/gui-settings.ts +// VERSION: 1.0.0 +// START_MODULE_CONTRACT +// PURPOSE: Register the versioned GUI RPC (`vvoc.gui.v1`) on the native server context so the `./gui-experimental` window part can read the effective vvoc defaults, write the orchestration profile through the conservative CLI write path, and receive honest stub/unsupported session-settings verdicts. +// SCOPE: Structural server-context seam, bounded effective-defaults projection (orchestration profile, three plugin toggles, config source), CLI-reused conservative profile write with explicit global/project scope, session-existence validation via ctx.session.get, and value-free stable error mapping. It never patches session-owned settings, never writes anything but the canonical vvoc.json orchestration section, and never exposes credentials, model settings, or raw error messages. +// DEPENDS: [@opencode/plugin, src/rpc.ts, src/commands/orchestration.ts, src/lib/config-layers.ts, src/lib/orchestration.ts, src/lib/plugin-toggle-config.ts, src/runtime/types.ts] +// LINKS: [M-PLUGIN-GUI-SETTINGS, M-GUI-SPIKE, DF-GUI-RPC, V-M-PLUGIN-GUI-SETTINGS] +// ROLE: RUNTIME +// MAP_MODE: EXPORTS +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// STUB_SETTINGS_NOTE - Fixed value-free note carried by every session.get stub reply. +// GuiSettingsServerContext - Structural native server plugin context accepted by the registration helper. +// GuiSettingsSourceKind - Bounded config-source kind accepted and returned by the handlers. +// GuiSettingsDeps - Injected defaults/read/write/session seams used by the handlers. +// createGuiSettingsHandlers - Build the four bounded handlers with injected seams. +// registerGuiSettingsRpc - Register the versioned GUI RPC and return its registration handle. +// GuiSettingsPlugin - Native server plugin that registers the GUI RPC on setup. +// default - Alias of GuiSettingsPlugin for the native default-import contract. +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added the native server-side GUI RPC registration with the CLI-reused conservative profile write and stub/unsupported session verdicts.] +// END_CHANGE_SUMMARY + +import { Plugin } from "@opencode/plugin"; +import { loadVvocConfigForRead } from "../lib/config-layers.js"; +import { resolveOrchestrationPolicy, type OrchestrationProfile } from "../lib/orchestration.js"; +import { isVvocPluginEnabled } from "../lib/plugin-toggle-config.js"; +import { + VVOC_GUI_METHODS, + VVOC_GUI_RPC_VERSION, + vvocGuiRpc, + type DefaultsGetInput, + type DefaultsGetOutput, + type DefaultsSetInput, + type DefaultsSetOutput, + type SessionGetInput, + type SessionGetOutput, + type SessionPatchInput, + type SessionPatchOutput, +} from "../rpc.js"; +import { setOrchestrationProfile } from "../commands/orchestration.js"; +import type { RuntimeRpcRegistrar, RuntimeRpcRegistration } from "../runtime/types.js"; + +/** Fixed value-free note carried by every `session.get` stub reply. */ +export const STUB_SETTINGS_NOTE = + "session-owned settings are not implemented yet; values are read from the effective vvoc defaults"; + +/** Bounded config-source kind accepted and returned by the handlers. */ +export type GuiSettingsSourceKind = "env" | "project" | "global" | "default" | "missing"; + +/** Structural native server plugin context accepted by the registration helper. */ +export interface GuiSettingsServerContext { + readonly location: { readonly directory: string }; + readonly rpc: RuntimeRpcRegistrar; + readonly session: { + get(input: { readonly sessionID: string }): Promise; + }; +} + +/** + * Injected defaults/read/write/session seams. The production wiring reuses the + * CLI's layered reader and conservative orchestration writer verbatim; tests + * replace them with in-memory seams. + */ +export interface GuiSettingsDeps { + /** Reads the bounded effective-defaults projection for the server's project directory. */ + readonly readDefaults: () => Promise<{ + readonly profile: OrchestrationProfile; + readonly plugins: { guardian: boolean; analytics: boolean; peakHours: boolean }; + readonly source: { kind: GuiSettingsSourceKind; path?: string }; + }>; + /** Writes one orchestration profile through the conservative CLI write path. */ + readonly writeProfile: ( + profile: OrchestrationProfile, + scope: "global" | "project", + ) => Promise<{ action: "updated" | "kept"; path: string }>; + /** Resolves whether one session id exists on this server. */ + readonly sessionExists: (sessionID: string) => Promise; +} + +type GuiHandlers = { + [VVOC_GUI_METHODS.defaultsGet]: (input: DefaultsGetInput) => Promise; + [VVOC_GUI_METHODS.defaultsSet]: (input: DefaultsSetInput) => Promise; + [VVOC_GUI_METHODS.sessionGet]: (input: SessionGetInput) => Promise; + [VVOC_GUI_METHODS.sessionPatch]: (input: SessionPatchInput) => Promise; +}; + +// START_BLOCK_HANDLERS +/** + * Builds the four bounded handlers. Every failure becomes a value-free stable + * verdict: config problems degrade to `unavailable` codes, a failed write is + * `rejected`, and session settings stay explicitly `stub`/`unsupported`. + */ +export function createGuiSettingsHandlers(deps: GuiSettingsDeps): GuiHandlers { + return { + async [VVOC_GUI_METHODS.defaultsGet]() { + try { + const defaults = await deps.readDefaults(); + return { + version: VVOC_GUI_RPC_VERSION, + status: "available", + profile: defaults.profile, + plugins: defaults.plugins, + source: { + kind: defaults.source.kind, + ...(defaults.source.path === undefined ? {} : { path: defaults.source.path }), + }, + } satisfies DefaultsGetOutput; + } catch { + return { + version: VVOC_GUI_RPC_VERSION, + status: "unavailable", + error: "config_unavailable", + } satisfies DefaultsGetOutput; + } + }, + async [VVOC_GUI_METHODS.defaultsSet](input) { + try { + const result = await deps.writeProfile(input.profile, input.scope); + return { + version: VVOC_GUI_RPC_VERSION, + action: result.action, + profile: input.profile, + path: result.path, + } satisfies DefaultsSetOutput; + } catch { + return { + version: VVOC_GUI_RPC_VERSION, + action: "unavailable", + profile: input.profile, + error: "config_unavailable", + } satisfies DefaultsSetOutput; + } + }, + async [VVOC_GUI_METHODS.sessionGet](input) { + try { + if (!(await deps.sessionExists(input.sessionID))) { + return { + version: VVOC_GUI_RPC_VERSION, + status: "unavailable", + note: STUB_SETTINGS_NOTE, + error: "session_lookup_failed", + } satisfies SessionGetOutput; + } + try { + const defaults = await deps.readDefaults(); + return { + version: VVOC_GUI_RPC_VERSION, + status: "stub", + profile: defaults.profile, + note: STUB_SETTINGS_NOTE, + } satisfies SessionGetOutput; + } catch { + return { + version: VVOC_GUI_RPC_VERSION, + status: "unavailable", + note: STUB_SETTINGS_NOTE, + error: "config_unavailable", + } satisfies SessionGetOutput; + } + } catch { + return { + version: VVOC_GUI_RPC_VERSION, + status: "unavailable", + note: STUB_SETTINGS_NOTE, + error: "session_lookup_failed", + } satisfies SessionGetOutput; + } + }, + async [VVOC_GUI_METHODS.sessionPatch](input) { + try { + if (!(await deps.sessionExists(input.sessionID))) { + return { + version: VVOC_GUI_RPC_VERSION, + status: "unavailable", + error: "session_lookup_failed", + } satisfies SessionPatchOutput; + } + return { + version: VVOC_GUI_RPC_VERSION, + status: "unsupported", + error: "session_settings_unsupported", + } satisfies SessionPatchOutput; + } catch { + return { + version: VVOC_GUI_RPC_VERSION, + status: "unavailable", + error: "session_lookup_failed", + } satisfies SessionPatchOutput; + } + }, + }; +} +// END_BLOCK_HANDLERS + +/** Register the versioned GUI RPC; the returned handle disposes only this registration. */ +export async function registerGuiSettingsRpc( + ctx: GuiSettingsServerContext, +): Promise { + const handlers = createGuiSettingsHandlers(productionDeps(ctx)); + return ctx.rpc.register(vvocGuiRpc, handlers); +} + +/** Production seams: the CLI's layered reader and conservative writer, unchanged. */ +function productionDeps(ctx: GuiSettingsServerContext): GuiSettingsDeps { + const directory = ctx.location.directory; + return { + async readDefaults() { + const { config, source } = await loadVvocConfigForRead({ + scope: "effective", + cwd: directory, + allowDefault: true, + }); + return { + profile: resolveOrchestrationPolicy(config).profile, + plugins: { + guardian: isVvocPluginEnabled(config, "guardian"), + analytics: isVvocPluginEnabled(config, "analytics"), + peakHours: isVvocPluginEnabled(config, "peak-hours"), + }, + source: { kind: source.kind, ...(source.path === undefined ? {} : { path: source.path }) }, + }; + }, + writeProfile: (profile, scope) => setOrchestrationProfile(profile, { cwd: directory, scope }), + sessionExists: async (sessionID) => { + await ctx.session.get({ sessionID }); + return true; + }, + }; +} + +// START_BLOCK_PLUGIN_ENTRY +/** + * Native server plugin that registers the versioned GUI RPC. Composed inside + * the aggregate `vvoc` server plugin; teardown disposes only its own + * registration. + */ +const GuiSettingsPlugin = Plugin.define({ + id: "vvoc-gui-settings", + async setup(ctx) { + const registration = await registerGuiSettingsRpc(ctx as GuiSettingsServerContext); + return async () => { + await registration.dispose(); + }; + }, +}); + +export { GuiSettingsPlugin }; +export default GuiSettingsPlugin; +// END_BLOCK_PLUGIN_ENTRY diff --git a/src/rpc.test.ts b/src/rpc.test.ts new file mode 100644 index 00000000..18e5a144 --- /dev/null +++ b/src/rpc.test.ts @@ -0,0 +1,147 @@ +// FILE: src/rpc.test.ts +// VERSION: 1.0.0 +// START_MODULE_CONTRACT +// PURPOSE: Test the versioned GUI RPC contract: identity, portable method surface, strict reply-decoder acceptance and rejection, and the bounded DTO shapes both sides depend on. +// SCOPE: Pure contract assertions over src/rpc.ts; no server runtime, no window code, no I/O. +// DEPENDS: [src/rpc.ts] +// LINKS: [M-GUI-SPIKE, V-M-PLUGIN-GUI-SETTINGS] +// ROLE: TEST +// MAP_MODE: LOCALS +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// AVAILABLE_DEFAULTS_REPLY - Valid available defaults.get reply fixture. +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added contract identity, decoder acceptance/rejection, and bounded-DTO tests for the GUI RPC surface.] +// END_CHANGE_SUMMARY + +import { describe, expect, test } from "bun:test"; +import { + VVOC_GUI_METHODS, + VVOC_GUI_RPC_ID, + VVOC_GUI_RPC_VERSION, + decodeDefaultsGetOutput, + decodeDefaultsSetOutput, + decodeSessionGetOutput, + decodeSessionPatchOutput, + vvocGuiRpc, +} from "./rpc.js"; + +const AVAILABLE_DEFAULTS_REPLY = { + version: 1, + status: "available", + profile: "balanced", + plugins: { guardian: true, analytics: false, peakHours: true }, + source: { kind: "project", path: "/tmp/.vvoc/vvoc.json" }, +} as const; + +describe("gui rpc contract", () => { + test("exposes the stable versioned identity and method surface", () => { + expect(VVOC_GUI_RPC_ID).toBe("vvoc.gui.v1"); + expect(VVOC_GUI_RPC_VERSION).toBe(1); + expect(vvocGuiRpc.id).toBe(VVOC_GUI_RPC_ID); + expect(Object.keys(vvocGuiRpc.methods)).toEqual([ + "defaults.get", + "defaults.set", + "session.get", + "session.patch", + ]); + expect(vvocGuiRpc.events).toEqual({}); + }); + + test("decodes an available defaults.get reply and keeps the bounded projection", () => { + const decoded = decodeDefaultsGetOutput(AVAILABLE_DEFAULTS_REPLY); + expect(decoded.status).toBe("available"); + expect(decoded.profile).toBe("balanced"); + expect(decoded.plugins).toEqual({ guardian: true, analytics: false, peakHours: true }); + expect(decoded.source?.kind).toBe("project"); + expect(decoded.error).toBeUndefined(); + }); + + test("decodes an unavailable defaults.get verdict without profile data", () => { + const decoded = decodeDefaultsGetOutput({ + version: 1, + status: "unavailable", + error: "config_unavailable", + }); + expect(decoded.status).toBe("unavailable"); + expect(decoded.profile).toBeUndefined(); + expect(decoded.source).toBeUndefined(); + }); + + test("rejects wrong version, unknown status, and unknown error codes", () => { + expect(() => + decodeDefaultsGetOutput({ version: 2, status: "available", profile: "balanced" }), + ).toThrow(); + expect(() => decodeDefaultsGetOutput({ version: 1, status: "maybe" })).toThrow(); + expect(() => + decodeDefaultsGetOutput({ version: 1, status: "unavailable", error: "something_else" }), + ).toThrow(); + }); + + test("strips keys outside the bounded projection", () => { + const decoded = decodeDefaultsGetOutput({ + version: 1, + status: "available", + profile: "balanced", + extra: true, + plugins: { guardian: true, analytics: true, peakHours: true, smuggled: "x" }, + }); + expect(decoded).not.toHaveProperty("extra"); + expect(decoded.plugins).toEqual({ guardian: true, analytics: true, peakHours: true }); + }); + + test("validates the defaults.set write verdict surface", () => { + const updated = decodeDefaultsSetOutput({ + version: 1, + action: "updated", + profile: "delegated", + path: "/p", + }); + expect(updated.action).toBe("updated"); + expect(updated.profile).toBe("delegated"); + expect(updated.path).toBe("/p"); + const unavailable = decodeDefaultsSetOutput({ + version: 1, + action: "unavailable", + profile: "balanced", + }); + expect(unavailable.action).toBe("unavailable"); + expect(unavailable.error).toBeUndefined(); + expect(unavailable.path).toBeUndefined(); + expect(() => + decodeDefaultsSetOutput({ version: 1, action: "exploded", profile: "balanced" }), + ).toThrow(); + expect(() => + decodeDefaultsSetOutput({ version: 1, action: "updated", profile: "nope" }), + ).toThrow(); + }); + + test("validates the session stub and unsupported verdict surfaces", () => { + const stub = decodeSessionGetOutput({ + version: 1, + status: "stub", + profile: "orchestrated", + note: "stub note", + }); + expect(stub.status).toBe("stub"); + expect(stub.note).toBe("stub note"); + expect(() => decodeSessionGetOutput({ version: 1, status: "complete", note: "x" })).toThrow(); + + const unsupported = decodeSessionPatchOutput({ + version: 1, + status: "unsupported", + error: "session_settings_unsupported", + }); + expect(unsupported.status).toBe("unsupported"); + expect(() => + decodeSessionPatchOutput({ version: 1, status: "unsupported", error: "write_rejected" }), + ).toThrow(); + }); + + test("keeps the method-name map in sync with the definition", () => { + expect(Object.keys(vvocGuiRpc.methods)).toEqual(Object.values(VVOC_GUI_METHODS)); + }); +}); diff --git a/src/rpc.ts b/src/rpc.ts new file mode 100644 index 00000000..d2291a11 --- /dev/null +++ b/src/rpc.ts @@ -0,0 +1,200 @@ +// FILE: src/rpc.ts +// VERSION: 1.0.0 +// START_MODULE_CONTRACT +// PURPOSE: Define the portable, versioned GUI RPC contract between the native server plugin and the `./gui-experimental` window part: bounded reads and conservative writes of the effective vvoc defaults plus explicit stub/unsupported session-settings verdicts, with Effect Schema codecs bridged to the portable Standard Schema RPC surface. +// SCOPE: RPC identity/version, four method schemas (defaults.get, defaults.set, session.get, session.patch), bounded value-free DTOs (orchestration profile, config source, plugin toggles projection, stable error codes), and strict client-side reply decoders. It carries no server runtime, no CLI wiring, and no window code, so both the server plugin and the GUI bundle import it without node built-ins. +// DEPENDS: [effect, @opencode/schema/rpc, src/lib/orchestration.ts] +// LINKS: [M-GUI-SPIKE, M-PLUGIN-GUI-SETTINGS, DF-GUI-RPC, V-M-PLUGIN-GUI-SETTINGS] +// ROLE: TYPES +// MAP_MODE: EXPORTS +// END_MODULE_CONTRACT +// +// START_MODULE_MAP +// VVOC_GUI_RPC_ID - Stable versioned GUI RPC id. +// VVOC_GUI_RPC_VERSION - DTO schema version required in every reply. +// VVOC_GUI_METHODS - Registered method names. +// VvocGuiErrorCode - Stable value-free error codes surfaced through the GUI contract. +// DefaultsGetInput - Input type of the defaults.get method. +// DefaultsGetOutput - Output type of the defaults.get method. +// DefaultsSetInput - Input type of the defaults.set method. +// DefaultsSetOutput - Output type of the defaults.set method. +// SessionGetInput - Input type of the session.get method. +// SessionGetOutput - Output type of the session.get method. +// SessionPatchInput - Input type of the session.patch method. +// SessionPatchOutput - Output type of the session.patch method. +// vvocGuiRpc - Portable RPC definition registered server-side and called from the GUI part. +// decodeDefaultsGetOutput - Strict client-side decoder for the defaults.get reply. +// decodeDefaultsSetOutput - Strict client-side decoder for the defaults.set reply. +// decodeSessionGetOutput - Strict client-side decoder for the session.get reply. +// decodeSessionPatchOutput - Strict client-side decoder for the session.patch reply. +// END_MODULE_MAP +// +// START_CHANGE_SUMMARY +// LAST_CHANGE: [GUI-SPike initial skeleton - Added the versioned GUI RPC contract with Effect Schema codecs bridged to the portable RPC surface, bounded defaults/session DTOs, and strict reply decoders.] +// END_CHANGE_SUMMARY + +import { Schema } from "effect"; +import type { StandardSchemaV1 } from "@standard-schema/spec"; +import type { Rpc } from "@opencode/schema/rpc"; +import { ORCHESTRATION_PROFILE_NAMES } from "./lib/orchestration.js"; + +/** Stable versioned GUI RPC id. */ +export const VVOC_GUI_RPC_ID = "vvoc.gui.v1" as const; +/** DTO schema version required in every reply. */ +export const VVOC_GUI_RPC_VERSION = 1 as const; + +/** Stable value-free error codes surfaced through the GUI contract. */ +export type VvocGuiErrorCode = + | "config_unavailable" + | "config_invalid" + | "session_lookup_failed" + | "session_settings_unsupported"; + +/** Registered method names. */ +export const VVOC_GUI_METHODS = { + defaultsGet: "defaults.get", + defaultsSet: "defaults.set", + sessionGet: "session.get", + sessionPatch: "session.patch", +} as const; + +// START_BLOCK_CONTRACT_SCHEMAS +const CONFIG_ERROR_CODES = ["config_unavailable", "config_invalid"] as const; +const SESSION_ERROR_CODES = ["session_lookup_failed", "session_settings_unsupported"] as const; + +/** Bounded config-source projection: where the effective vvoc defaults came from. */ +const SourceSchema = Schema.Struct({ + kind: Schema.Literals(["env", "project", "global", "default", "missing"]), + path: Schema.optional(Schema.String), +}); + +/** Input of `defaults.get`: no parameters. */ +export type DefaultsGetInput = Schema.Struct.Type<{}>; +const DefaultsGetInputSchema = Schema.Struct({}); + +/** Output of `defaults.get`: the bounded effective-defaults projection, or a value-free unavailable verdict. */ +const DefaultsGetOutputSchema = Schema.Struct({ + version: Schema.Literal(VVOC_GUI_RPC_VERSION), + status: Schema.Literals(["available", "unavailable"]), + profile: Schema.optional(Schema.Literals([...ORCHESTRATION_PROFILE_NAMES])), + plugins: Schema.optional( + Schema.Struct({ + guardian: Schema.Boolean, + analytics: Schema.Boolean, + peakHours: Schema.Boolean, + }), + ), + source: Schema.optional(SourceSchema), + error: Schema.optional(Schema.Literals([...CONFIG_ERROR_CODES])), +}); +export type DefaultsGetOutput = (typeof DefaultsGetOutputSchema)["Type"]; + +/** Input of `defaults.set`: one bounded profile write with an explicit config scope. */ +const DefaultsSetInputSchema = Schema.Struct({ + profile: Schema.Literals([...ORCHESTRATION_PROFILE_NAMES]), + scope: Schema.Literals(["global", "project"]), +}); +export type DefaultsSetInput = (typeof DefaultsSetInputSchema)["Type"]; + +/** Output of `defaults.set`: the conservative CLI write verdict for the requested profile. */ +const DefaultsSetOutputSchema = Schema.Struct({ + version: Schema.Literal(VVOC_GUI_RPC_VERSION), + action: Schema.Literals(["updated", "kept", "rejected", "unavailable"]), + profile: Schema.Literals([...ORCHESTRATION_PROFILE_NAMES]), + path: Schema.optional(Schema.String), + error: Schema.optional(Schema.Literals([...CONFIG_ERROR_CODES])), +}); +export type DefaultsSetOutput = (typeof DefaultsSetOutputSchema)["Type"]; + +/** Input of `session.get`: one session id. */ +const SessionGetInputSchema = Schema.Struct({ + sessionID: Schema.String, +}); +export type SessionGetInput = (typeof SessionGetInputSchema)["Type"]; + +/** Output of `session.get`: the stub projection until session-owned settings merge. */ +const SessionGetOutputSchema = Schema.Struct({ + version: Schema.Literal(VVOC_GUI_RPC_VERSION), + status: Schema.Literals(["stub", "unavailable"]), + profile: Schema.optional(Schema.Literals([...ORCHESTRATION_PROFILE_NAMES])), + note: Schema.String, + error: Schema.optional(Schema.Literals(["session_lookup_failed", ...CONFIG_ERROR_CODES])), +}); +export type SessionGetOutput = (typeof SessionGetOutputSchema)["Type"]; + +/** Input of `session.patch`: one session id; the patchable shape arrives with session-owned settings. */ +const SessionPatchInputSchema = Schema.Struct({ + sessionID: Schema.String, +}); +export type SessionPatchInput = (typeof SessionPatchInputSchema)["Type"]; + +/** Output of `session.patch`: the explicit unsupported verdict, or a session lookup failure. */ +const SessionPatchOutputSchema = Schema.Struct({ + version: Schema.Literal(VVOC_GUI_RPC_VERSION), + status: Schema.Literals(["unsupported", "unavailable"]), + error: Schema.Literals([...SESSION_ERROR_CODES, ...CONFIG_ERROR_CODES]), +}); +export type SessionPatchOutput = (typeof SessionPatchOutputSchema)["Type"]; + +/** + * Bridges one Effect Schema codec onto the portable Standard Schema surface the + * host registrar and client require, keeping the Effect codecs as the single + * source of truth for validation and types. + */ +function portable>( + schema: S, +): StandardSchemaV1 { + return Schema.toStandardSchemaV1(schema); +} +// END_BLOCK_CONTRACT_SCHEMAS + +// START_BLOCK_RPC_DEFINITION +/** + * Portable GUI RPC definition registered server-side by the native server plugin + * and called from the `./gui-experimental` window part through `ctx.client.rpc`. + */ +export const vvocGuiRpc = { + id: VVOC_GUI_RPC_ID, + methods: { + [VVOC_GUI_METHODS.defaultsGet]: { + input: portable(DefaultsGetInputSchema), + output: portable(DefaultsGetOutputSchema), + }, + [VVOC_GUI_METHODS.defaultsSet]: { + input: portable(DefaultsSetInputSchema), + output: portable(DefaultsSetOutputSchema), + }, + [VVOC_GUI_METHODS.sessionGet]: { + input: portable(SessionGetInputSchema), + output: portable(SessionGetOutputSchema), + }, + [VVOC_GUI_METHODS.sessionPatch]: { + input: portable(SessionPatchInputSchema), + output: portable(SessionPatchOutputSchema), + }, + }, + events: {}, +} satisfies Rpc.PortableDefinition; +// END_BLOCK_RPC_DEFINITION + +// START_BLOCK_REPLY_DECODERS +/** Strict client-side decoder for the `defaults.get` reply. */ +export function decodeDefaultsGetOutput(value: unknown): DefaultsGetOutput { + return Schema.decodeUnknownSync(DefaultsGetOutputSchema)(value); +} + +/** Strict client-side decoder for the `defaults.set` reply. */ +export function decodeDefaultsSetOutput(value: unknown): DefaultsSetOutput { + return Schema.decodeUnknownSync(DefaultsSetOutputSchema)(value); +} + +/** Strict client-side decoder for the `session.get` reply. */ +export function decodeSessionGetOutput(value: unknown): SessionGetOutput { + return Schema.decodeUnknownSync(SessionGetOutputSchema)(value); +} + +/** Strict client-side decoder for the `session.patch` reply. */ +export function decodeSessionPatchOutput(value: unknown): SessionPatchOutput { + return Schema.decodeUnknownSync(SessionPatchOutputSchema)(value); +} +// END_BLOCK_REPLY_DECODERS