Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67636da106 | ||
|
|
efef23097a | ||
|
|
6947b4d47d | ||
|
|
8cc7135e3d | ||
|
|
f3d92c97d9 | ||
|
|
83ce5f4840 | ||
|
|
e7c4292d27 | ||
|
|
1990db7430 | ||
|
|
6238edb659 | ||
|
|
84e3659464 | ||
|
|
56349ee830 | ||
|
|
bb4f4d57e8 | ||
|
|
871fe5e8b8 | ||
|
|
976c2ed517 | ||
|
|
9b9f587e65 | ||
|
|
948947d92b | ||
|
|
f94bbc442d | ||
|
|
275863c67a | ||
|
|
b674d43f54 |
No files matched your search
@@ -8,7 +8,7 @@ on:
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
name: Lint, Typecheck, Test
|
||||
name: Lint, Typecheck, Test, Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -41,5 +41,10 @@ jobs:
|
||||
- name: Test
|
||||
run: bun run test
|
||||
|
||||
- name: Smoke Test (t3 runtime)
|
||||
run: bun run --cwd apps/t3 build && bun run smoke-test
|
||||
- name: Build desktop pipeline
|
||||
run: bun run build:desktop
|
||||
|
||||
- name: Verify preload bundle output
|
||||
run: |
|
||||
test -f apps/desktop/dist-electron/preload.js
|
||||
grep -nE "desktopBridge|getWsUrl|PICK_FOLDER_CHANNEL|wsUrl" apps/desktop/dist-electron/preload.js
|
||||
@@ -3,6 +3,7 @@
|
||||
"ignorePatterns": [
|
||||
".plans",
|
||||
"dist",
|
||||
"dist-electron",
|
||||
"node_modules",
|
||||
"bun.lock",
|
||||
"*.tsbuildinfo"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"ignorePatterns": ["dist", "node_modules", "bun.lock", "*.tsbuildinfo"],
|
||||
"ignorePatterns": ["dist", "dist-electron", "node_modules", "bun.lock", "*.tsbuildinfo"],
|
||||
"plugins": ["eslint", "oxc", "react", "unicorn", "typescript"],
|
||||
"categories": {
|
||||
"correctness": "warn",
|
||||
|
||||
@@ -5,7 +5,7 @@ Move model alias/default normalization into `packages/contracts` so desktop and
|
||||
|
||||
## Motivation
|
||||
- Removes duplicated logic between:
|
||||
- `packages/runtime-core/src/codexAppServerManager.ts`
|
||||
- `apps/desktop/src/codexAppServerManager.ts`
|
||||
- `apps/renderer/src/model-logic.ts`
|
||||
- Prevents behavior drift when model aliases/defaults are updated.
|
||||
|
||||
@@ -22,7 +22,7 @@ Move model alias/default normalization into `packages/contracts` so desktop and
|
||||
- `resolveModelSlug`
|
||||
- `DEFAULT_MODEL`
|
||||
2. Export model utilities from `packages/contracts/src/index.ts`.
|
||||
3. Update `packages/runtime-core/src/codexAppServerManager.ts` to replace local alias map/helper.
|
||||
3. Update `apps/desktop/src/codexAppServerManager.ts` to replace local alias map/helper.
|
||||
4. Update `apps/renderer/src/model-logic.ts` to wrap or re-export shared functions.
|
||||
5. Update tests:
|
||||
- Move/duplicate normalization tests to contracts.
|
||||
@@ -38,5 +38,5 @@ Move model alias/default normalization into `packages/contracts` so desktop and
|
||||
- Manual check that model selection and session start still send expected model slug.
|
||||
|
||||
## Done Criteria
|
||||
- No duplicated alias/default map in runtime-core and renderer.
|
||||
- No duplicated alias/default map in desktop and renderer.
|
||||
- Shared model utilities are contract-tested.
|
||||
@@ -1,37 +1,37 @@
|
||||
# Plan: Strengthen Typed WS RPC Boundaries in Runtime Server
|
||||
# Plan: Strengthen Typed IPC Boundaries in Main Process
|
||||
|
||||
## Summary
|
||||
Replace loose payload casting in runtime RPC handlers with strict schema parsing and typed helper wrappers.
|
||||
Replace loose payload casting in IPC handlers with strict schema parsing and typed helper wrappers.
|
||||
|
||||
## Motivation
|
||||
- `apps/t3/src/runtimeApiServer.ts` should avoid payload casts and parse all unknown input at the RPC boundary.
|
||||
- `apps/desktop/src/main.ts` currently uses casts like `payload as Parameters<...>`.
|
||||
- Casts can hide contract breakages until runtime.
|
||||
|
||||
## Scope
|
||||
- Runtime WebSocket RPC registration and method dispatch.
|
||||
- Optional shared helper for method-level parse/dispatch registration.
|
||||
- Desktop main process IPC registration.
|
||||
- Optional shared helper for handler registration.
|
||||
|
||||
## Proposed Changes
|
||||
1. Add RPC helper utility (e.g. `apps/t3/src/rpcHelpers.ts`) to:
|
||||
1. Add IPC helper utility (e.g. `apps/desktop/src/ipcHelpers.ts`) to:
|
||||
- Parse payload(s) with Zod schemas
|
||||
- Standardize typed handler signatures
|
||||
2. Refactor provider RPC handlers in `apps/t3/src/runtimeApiServer.ts` to use:
|
||||
2. Refactor provider IPC handlers in `apps/desktop/src/main.ts` to use:
|
||||
- `providerSessionStartInputSchema.parse`
|
||||
- `providerSendTurnInputSchema.parse`
|
||||
- `providerInterruptTurnInputSchema.parse`
|
||||
- `providerStopSessionInputSchema.parse`
|
||||
3. Apply same pattern to app/todo/agent/terminal/shell handlers where possible.
|
||||
4. Add tests for parsing failure paths (invalid payloads).
|
||||
3. Apply same pattern to agent/terminal handlers where possible.
|
||||
4. Add tests for handler parsing failure paths (invalid payloads).
|
||||
|
||||
## Risks
|
||||
- Refactor can subtly change RPC error shape/messages.
|
||||
- Refactor can subtly change IPC error shape/messages.
|
||||
- Helper abstraction should stay simple and not obscure control flow.
|
||||
|
||||
## Validation
|
||||
- `bun run test`
|
||||
- `bun run typecheck`
|
||||
- Manual invalid payload check from websocket client/devtools to confirm fast failure.
|
||||
- Manual invalid payload check from renderer/devtools to confirm fast failure.
|
||||
|
||||
## Done Criteria
|
||||
- No runtime handler uses `payload as Parameters<...>`.
|
||||
- All websocket RPC entrypoints parse unknown payloads at boundary.
|
||||
- No provider handler uses `payload as Parameters<...>`.
|
||||
- All IPC entrypoints parse unknown payloads at boundary.
|
||||
@@ -4,7 +4,7 @@
|
||||
Split `CodexAppServerManager` into smaller modules with clear responsibilities.
|
||||
|
||||
## Motivation
|
||||
- `packages/runtime-core/src/codexAppServerManager.ts` is large and mixes:
|
||||
- `apps/desktop/src/codexAppServerManager.ts` is large and mixes:
|
||||
- Process lifecycle
|
||||
- JSON-RPC parsing/routing
|
||||
- Session state transitions
|
||||
@@ -12,7 +12,7 @@ Split `CodexAppServerManager` into smaller modules with clear responsibilities.
|
||||
- This increases regression risk and slows changes.
|
||||
|
||||
## Scope
|
||||
- Runtime-core provider internals only.
|
||||
- Desktop provider internals only.
|
||||
- Keep external behavior/API stable.
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
Ensure `ProviderManager` logging stream is initialized, rotated/structured, and closed safely.
|
||||
|
||||
## Motivation
|
||||
- `packages/runtime-core/src/providerManager.ts` opens a write stream in constructor.
|
||||
- `apps/desktop/src/providerManager.ts` opens a write stream in constructor.
|
||||
- Stream lifecycle is not explicit on shutdown.
|
||||
|
||||
## Scope
|
||||
- Runtime-core provider logging behavior.
|
||||
- Runtime server shutdown integration.
|
||||
- Desktop provider logging behavior.
|
||||
- App shutdown integration.
|
||||
|
||||
## Proposed Changes
|
||||
1. Add explicit `dispose()` on `ProviderManager`:
|
||||
- Remove event listeners
|
||||
- End/close log stream
|
||||
2. Call `providerManager.dispose()` from app shutdown path in `apps/t3/src/runtimeApiServer.ts` close flow.
|
||||
2. Call `providerManager.dispose()` from app shutdown path in `apps/desktop/src/main.ts`.
|
||||
3. Optional: change log format to JSON lines with stable fields.
|
||||
4. Optional: per-session log files under `.logs/providers/`.
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
Refactor `ProcessManager` to use a single runtime-session interface for child-process and PTY modes.
|
||||
|
||||
## Motivation
|
||||
- `packages/runtime-core/src/processManager.ts` maintains parallel maps and branch-heavy logic.
|
||||
- `apps/desktop/src/processManager.ts` maintains parallel maps and branch-heavy logic.
|
||||
- New execution backends/providers will multiply complexity.
|
||||
|
||||
## Scope
|
||||
- Runtime-core process execution internals.
|
||||
- Desktop process execution internals.
|
||||
- Preserve public `ProcessManager` API.
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
# AGENTS.md
|
||||
# CLAUDE.md
|
||||
|
||||
## Project Snapshot
|
||||
|
||||
CodeThing is a minimal GUI for using code agents like Codex and Claude Code (coming soon).
|
||||
CodeThing is a minimal web GUI for using code agents like Codex and Claude Code (coming soon).
|
||||
|
||||
This repository is a VERY EARLY WIP. Proposing sweeping changes that improve long-term maintainability is encouraged.
|
||||
|
||||
## Core Priorities
|
||||
|
||||
1. Performance first.
|
||||
2. Reliability first.
|
||||
3. Keep behavior predictable under load and during failures (session restarts, reconnects, partial streams).
|
||||
@@ -15,30 +13,23 @@ This repository is a VERY EARLY WIP. Proposing sweeping changes that improve lon
|
||||
If a tradeoff is required, choose correctness and robustness over short-term convenience.
|
||||
|
||||
## Package Roles
|
||||
|
||||
- `apps/t3`: Node CLI/runtime. Owns WebSocket server lifecycle, browser launch, and RPC routing.
|
||||
- `apps/renderer`: React/Vite UI. Owns session UX, conversation/event rendering, and client-side state.
|
||||
- `packages/contracts`: Shared Zod schemas and TypeScript contracts for provider events, WebSocket payloads, and model/session types.
|
||||
- `packages/runtime-core`: Shared Node runtime services (`ProcessManager`, `TodoStore`, `ProviderManager`, `CodexAppServerManager`) used by `apps/t3`.
|
||||
- Legacy desktop runtime wrapper package has been removed; `runtime-core` is the canonical runtime service source.
|
||||
- Legacy desktop runtime wrapper package has been removed; `runtime-core` is the canonical runtime service source.
|
||||
- `apps/server`: Node.js WebSocket server. Wraps Codex app-server (JSON-RPC over stdio), serves the React web app, and manages provider sessions.
|
||||
- `apps/renderer`: React/Vite UI. Owns session UX, conversation/event rendering, and client-side state. Connects to the server via WebSocket.
|
||||
- `packages/contracts`: Shared Zod schemas and TypeScript contracts for provider events, WebSocket protocol, and model/session types.
|
||||
|
||||
## Codex App Server (Important)
|
||||
|
||||
CodeThing is currently Codex-first. The `t3` runtime starts `codex app-server` (JSON-RPC over stdio) per provider session, then streams structured events into the renderer through the provider APIs.
|
||||
CodeThing is currently Codex-first. The server starts `codex app-server` (JSON-RPC over stdio) per provider session, then streams structured events to the browser through WebSocket push messages.
|
||||
|
||||
How we use it in this codebase:
|
||||
|
||||
- Session startup/resume and turn lifecycle are brokered in `packages/runtime-core/src/codexAppServerManager.ts`.
|
||||
- Provider dispatch and thread event logging are coordinated in `packages/runtime-core/src/providerManager.ts`.
|
||||
- Renderer consumes provider event streams via `nativeApi.providers.onEvent`.
|
||||
- Session startup/resume and turn lifecycle are brokered in `apps/server/src/codexAppServerManager.ts`.
|
||||
- Provider dispatch and thread event logging are coordinated in `apps/server/src/providerManager.ts`.
|
||||
- WebSocket server routes NativeApi methods in `apps/server/src/wsServer.ts`.
|
||||
- Renderer consumes provider event streams via WebSocket push on channel `providers.event`.
|
||||
|
||||
Docs:
|
||||
|
||||
- Codex App Server docs: https://developers.openai.com/codex/sdk/#app-server
|
||||
|
||||
## Reference Repos
|
||||
|
||||
- Open-source Codex repo: https://github.com/openai/codex
|
||||
- Codex-Monitor (Tauri, feature-complete, strong reference implementation): https://github.com/Dimillian/CodexMonitor
|
||||
|
||||
|
||||
@@ -1,156 +1,94 @@
|
||||
# CodeThing (`t3`: Node + WebSocket + Browser)
|
||||
# CodeThing
|
||||
|
||||
CodeThing now runs as a local Node.js runtime that serves a browser UI and exposes a local WebSocket API.
|
||||
CodeThing is a minimal web GUI for coding agents. Currently Codex-first, with Claude Code support coming soon.
|
||||
|
||||
Current implementation is:
|
||||
Run `npx t3` in any project directory to launch the web interface.
|
||||
Run `bun run dev:desktop` to launch the Electron desktop app in this monorepo.
|
||||
|
||||
1. Codex-first: connects to `codex app-server` and streams turn/item events.
|
||||
2. Provider-ready: renderer speaks a provider abstraction so Claude Code can plug in later.
|
||||
3. Typed end-to-end: contracts validate payloads across the WebSocket boundary.
|
||||
## Architecture
|
||||
|
||||
## Quickstart
|
||||
CodeThing runs as a **Node.js WebSocket server** that wraps `codex app-server` (JSON-RPC over stdio) and serves a React web app.
|
||||
|
||||
```bash
|
||||
npx t3
|
||||
```
|
||||
|
||||
On launch, `t3`:
|
||||
|
||||
1. starts a local WebSocket runtime (`127.0.0.1`),
|
||||
2. serves the web UI in your browser,
|
||||
3. auto-connects to your current working directory as the default project.
|
||||
|
||||
CLI flags:
|
||||
|
||||
- `--no-open[=bool]` — disable browser auto-open (supports `true/false`, `1/0`, `yes/no`, `on/off` in equals form).
|
||||
- `-o, --open[=bool]` — force browser auto-open (supports `true/false`, `1/0`, `yes/no`, `on/off` in equals form; overrides `T3_NO_OPEN`).
|
||||
- `--backend-port <port>` — set WebSocket runtime port.
|
||||
- `--web-port <port>` — set web UI port.
|
||||
- `--cwd <path>` — choose launch project directory (defaults to current directory).
|
||||
- `<path>` — shorthand positional argument equivalent to `--cwd <path>`.
|
||||
- `-- <path>` — treat following argument as path even if it starts with `-`.
|
||||
- `--version` — print CLI version.
|
||||
- `--help` — print CLI usage.
|
||||
|
||||
`--cwd` (or positional path) must be a non-empty value pointing to an existing directory; startup fails fast with a clear error otherwise.
|
||||
Port values must be decimal integers in the range `1..65535`.
|
||||
|
||||
If default ports are busy, `t3` will automatically retry with the next available port pair unless ports are explicitly pinned via CLI flags or environment variables.
|
||||
|
||||
Optional environment variables:
|
||||
|
||||
- `T3_NO_OPEN=1` — start runtime without auto-opening a browser window (parses `true/false`, `1/0`, `yes/no`, `on/off`).
|
||||
- `T3_BACKEND_PORT` — override local WebSocket runtime port (default `4317`).
|
||||
- `T3_WEB_PORT` — override local web UI port (default `4318`).
|
||||
|
||||
Runtime command semantics:
|
||||
|
||||
- `terminal.run` executes in the launch directory when `cwd` is omitted.
|
||||
- Relative `cwd` values for `terminal.run` and `shell.openInEditor` resolve from the launch directory.
|
||||
- `terminal.run` and `shell.openInEditor` reject empty/whitespace, missing, or non-directory cwd targets with structured request errors.
|
||||
┌─────────────────────────────────┐
|
||||
│ Browser (React + Vite) │
|
||||
│ Connected via WebSocket │
|
||||
└──────────┬──────────────────────┘
|
||||
│ ws://localhost:3773
|
||||
┌──────────▼──────────────────────┐
|
||||
│ apps/server (Node.js) │
|
||||
│ WebSocket + HTTP static server │
|
||||
│ ProviderManager │
|
||||
│ CodexAppServerManager │
|
||||
└──────────┬──────────────────────┘
|
||||
│ JSON-RPC over stdio
|
||||
┌──────────▼──────────────────────┐
|
||||
│ codex app-server │
|
||||
└─────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Workspace layout
|
||||
|
||||
- `/apps/t3`: CLI launcher + local WebSocket runtime server.
|
||||
- `/apps/renderer`: React + Vite UI for session control, conversation, and protocol event stream.
|
||||
- `/packages/contracts`: shared Zod schemas + TypeScript types for WS protocol, provider events, and API contracts.
|
||||
- `/packages/runtime-core`: shared Node runtime services (`ProcessManager`, `TodoStore`, `ProviderManager`, `CodexAppServerManager`) consumed by `apps/t3`.
|
||||
- Legacy desktop runtime wrapper package has been removed; `runtime-core` is now the sole source of runtime service implementations.
|
||||
- `/apps/server`: Node.js WebSocket server. Wraps Codex app-server, serves the built renderer, and opens the browser on start.
|
||||
- `/apps/renderer`: React + Vite UI. Session control, conversation, and provider event rendering. Connects to the server via WebSocket.
|
||||
- `/apps/desktop`: Electron shell. Spawns a desktop-scoped `t3` backend process and loads the shared renderer.
|
||||
- `/packages/contracts`: Shared Zod schemas and TypeScript contracts for provider events, WebSocket protocol, and model/session types.
|
||||
|
||||
## Codex prerequisites
|
||||
|
||||
- Install Codex CLI so `codex` is on your PATH.
|
||||
- Authenticate Codex before running CodeThing (for example via API key or ChatGPT auth supported by Codex).
|
||||
- CodeThing starts the server via `codex app-server` per session.
|
||||
- Note: test suites use an in-process fake `codex app-server` shim, so CI/local tests do not require the real Codex CLI.
|
||||
|
||||
## Runtime boundary model
|
||||
## Quick start
|
||||
|
||||
- `t3` starts a localhost-only WebSocket server.
|
||||
- Launch URLs include an ephemeral WebSocket token so only the opened browser session can attach.
|
||||
- Connections missing the token (or using a wrong token) are rejected by the runtime.
|
||||
- Connections with duplicate token query parameters are also rejected (even when duplicate values match) to avoid ambiguous auth parsing.
|
||||
- Runtime auth token lookup is strict on the lowercase `token` query key; alternate key casing is rejected.
|
||||
- Connections with unexpected query parameters are rejected (auth mode requires only `token`; no-auth mode allows no query params).
|
||||
- WebSocket control connections are accepted only on the root runtime path (`/`) to keep the API surface narrow.
|
||||
- Unauthorized websocket attempts close with code `4001` and reason `unauthorized`.
|
||||
- Browser renderer talks through a typed `NativeApi` adapter over that WebSocket.
|
||||
- Runtime currently enforces a single active browser client (new client replaces old one).
|
||||
- When replaced by a newer connection, the previous active websocket is closed with code `4000`.
|
||||
- Replacement closes use reason string `replaced-by-new-client` for deterministic client handling.
|
||||
- Renderer websocket connection errors now preserve close metadata (`code`/`reason`) to improve reconnect diagnostics.
|
||||
- Renderer normalizes close metadata before diagnostics (e.g. trims close reasons and ignores malformed close codes) for cleaner error messages.
|
||||
- Renderer decodes websocket message payloads from strings, `ArrayBuffer`, `ArrayBufferView` (e.g. `Uint8Array`/`DataView`), and `Blob`.
|
||||
- Renderer validates provider/agent event payload shapes before dispatch, ignoring malformed event payloads to keep client state stable.
|
||||
- Renderer validates critical RPC success payload shapes (`app.health`, `app.bootstrap`, `providers.listSessions`, `dialogs.pickFolder`, plus terminal/todo/provider/agent control flows) and fails fast on malformed responses.
|
||||
- In-flight renderer requests now surface unauthorized/replacement disconnect causes explicitly.
|
||||
- Renderer also fails in-flight requests immediately on websocket `error` events (without waiting for close) for faster feedback.
|
||||
- After reconnect, renderer ignores stale events from prior sockets (including provider and agent streams) to avoid cross-connection state corruption.
|
||||
- Initial websocket connect failures now include detailed diagnostics from socket/open and constructor failures (including nested/string/cause-chain payload messages, with bounded-depth fallback for malformed/cyclic payloads).
|
||||
- Subsequent requests automatically reconnect after close/error disconnects, including idle (no pending request) error scenarios.
|
||||
- Renderer now proactively resets the websocket after request send failures, rejects any in-flight requests, and reconnects cleanly on later requests.
|
||||
- Send-failure request errors now include non-Error payload details when available (for clearer diagnostics).
|
||||
- Runtime validates request payloads with shared Zod contracts.
|
||||
- Websocket RPC method names are centralized in shared contracts (`WS_NATIVE_API_METHODS`), and runtime dispatch validates method strings against that shared list.
|
||||
- Runtime tests now assert that every declared websocket method is wired through the server dispatch path (preventing contract/runtime drift).
|
||||
- Runtime and renderer both validate critical success payloads with shared contracts to prevent malformed envelope data from entering app state.
|
||||
- Core transport schemas (provider/agent/todo/terminal/app payloads) are strict objects, so unexpected fields are rejected at the contract boundary.
|
||||
- Runtime successful responses always include `result` (using `null` for void methods) to keep websocket envelopes schema-safe.
|
||||
- Websocket event envelopes are channel-typed (`provider:event`, `agent:output`, `agent:exit`) and validated against shared payload schemas.
|
||||
- Websocket protocol envelopes are strict (unexpected top-level fields are rejected) to keep RPC/event parsing deterministic.
|
||||
- Websocket request envelope guards also cap request id/method lengths (currently 256 chars each); over-limit requests are treated as malformed and ignored.
|
||||
- Runtime error envelopes are bounded (`code`/`message` max lengths) and oversized error text is normalized before sending to avoid protocol-invalid responses.
|
||||
- Blank/whitespace-only websocket ids, methods, and error fields are rejected at schema boundaries.
|
||||
- Codex execution sandbox policy (`read-only`, `workspace-write`, `danger-full-access`) is still selected per session startup options.
|
||||
- Static HTML responses are served with `Cache-Control: no-store`; built `/assets/*` files are served with long-lived immutable cache headers.
|
||||
- Static file success responses include `Accept-Ranges: bytes`, `Vary: Range`, deterministic `ETag` and `Last-Modified` validators, plus hardened browser headers (`X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`, `Cross-Origin-Resource-Policy`, `Cross-Origin-Opener-Policy`).
|
||||
- Static files support single-range byte requests (`Range: bytes=...`) with standards-compliant `206` / `416` behavior.
|
||||
- Static range parsing tolerates optional separator whitespace (e.g. `Range: bytes = 0 - 1023`).
|
||||
- Oversized suffix ranges are normalized to full-file spans (for example `bytes=-999999` on small assets).
|
||||
- Static non-range requests support `If-None-Match` and `If-Modified-Since` conditional caching via `304 Not Modified`.
|
||||
- Static range requests support `If-Range` semantics (matched validator keeps `206`; mismatched validator falls back to full `200` response).
|
||||
- `If-None-Match` / `If-Modified-Since` preconditions are evaluated before range handling, so satisfied validators return `304` even when a `Range` header is present.
|
||||
- Static precondition headers `If-Match` and `If-Unmodified-Since` are enforced with `412 Precondition Failed` semantics.
|
||||
- Failed `If-Match` checks take precedence over cache validators (e.g. matching `If-None-Match` still results in `412` if `If-Match` fails).
|
||||
- Failed `If-Unmodified-Since` checks also return `412` before cache-based `304` handling.
|
||||
- Wildcard validators are supported where applicable (`If-None-Match: *`, `If-Match: *`).
|
||||
- Strong/weak validator semantics follow HTTP rules: weak ETags participate in `If-None-Match` weak comparison, but are rejected for strong-only checks (`If-Match`, `If-Range`).
|
||||
- `412` static precondition responses include validator headers (`ETag`, `Last-Modified`) and range capability metadata (`Accept-Ranges`, `Vary: Range`).
|
||||
- `416` unsatisfiable-range responses include both range metadata and validators (`Content-Range`, `Accept-Ranges`, `Vary: Range`, `ETag`, `Last-Modified`).
|
||||
```bash
|
||||
# Development (with hot reload)
|
||||
bun run dev
|
||||
|
||||
## Runtime modes
|
||||
# Desktop development
|
||||
bun run dev:desktop
|
||||
|
||||
CodeThing has a global runtime mode switch in the sidebar:
|
||||
# Production
|
||||
bun run build
|
||||
bun run start
|
||||
|
||||
- `Full access` (default): starts new sessions with `approvalPolicy: never` and `sandboxMode: danger-full-access`.
|
||||
- `Approval required`: starts new sessions with `approvalPolicy: on-request` and `sandboxMode: workspace-write`, then prompts in-app for command/file approvals.
|
||||
|
||||
Mode changes apply across all threads. Existing live sessions are restarted so old and new threads use the selected mode.
|
||||
# Or from any project directory after publishing:
|
||||
npx t3
|
||||
```
|
||||
|
||||
## Scripts
|
||||
|
||||
- `bun run dev`: builds contracts, starts `t3` runtime, opens browser UI.
|
||||
- `bun run build`: builds contracts, renderer static assets, and `t3` CLI bundle.
|
||||
- `bun run typecheck`: strict TypeScript checks for all packages.
|
||||
- `bun run test`: runs workspace tests.
|
||||
- `bun run smoke-test`: runs end-to-end CLI/WebSocket smoke coverage (against the fake Codex app-server shim).
|
||||
- `bun run --cwd apps/t3 dev`: run the CLI directly in dev mode.
|
||||
- `bun run dev` — Starts contracts, server, and web dev tasks via Turborepo's parallel task runner.
|
||||
- `bun run dev:server` — Starts just the WebSocket server (uses tsx for TS execution).
|
||||
- `bun run dev:web` — Starts just the Vite dev server for the renderer.
|
||||
- `bun run start` — Runs the production server (serves built renderer as static files).
|
||||
- `bun run build` — Builds contracts, renderer, and server through Turbo.
|
||||
- `bun run typecheck` — Strict TypeScript checks for all packages.
|
||||
- `bun run test` — Runs workspace tests.
|
||||
|
||||
## Runtime modes
|
||||
|
||||
CodeThing has a global runtime mode switch in the chat toolbar:
|
||||
|
||||
- **Full access** (default): starts sessions with `approvalPolicy: never` and `sandboxMode: danger-full-access`.
|
||||
- **Supervised**: starts sessions with `approvalPolicy: on-request` and `sandboxMode: workspace-write`, then prompts in-app for command/file approvals.
|
||||
|
||||
## Provider architecture
|
||||
|
||||
The renderer depends on `nativeApi.providers.*`:
|
||||
The renderer communicates with the server via WebSocket using a simple JSON-RPC-style protocol:
|
||||
|
||||
1. `startSession`
|
||||
2. `sendTurn`
|
||||
3. `interruptTurn`
|
||||
4. `respondToRequest`
|
||||
5. `stopSession`
|
||||
6. `listSessions`
|
||||
7. `onEvent`
|
||||
- **Request/Response**: `{ id, method, params }` → `{ id, result }` or `{ id, error }`
|
||||
- **Push events**: `{ type: "push", channel, data }` for streaming provider events
|
||||
|
||||
Codex is the only implemented provider right now. `claudeCode` is reserved in contracts/UI but currently returns a not-implemented runtime error.
|
||||
Methods mirror the `NativeApi` interface defined in `@acme/contracts`:
|
||||
|
||||
Runtime app utilities exposed via `nativeApi.app.*`:
|
||||
- `providers.startSession`, `providers.sendTurn`, `providers.interruptTurn`
|
||||
- `providers.respondToRequest`, `providers.stopSession`, `providers.listSessions`
|
||||
- `shell.openInEditor`, `server.getConfig`
|
||||
|
||||
1. `bootstrap`
|
||||
2. `health`
|
||||
Codex is the only implemented provider. `claudeCode` is reserved in contracts/UI.
|
||||
|
||||
## CI quality gates
|
||||
|
||||
- `.github/workflows/ci.yml` runs `bun run lint`, `bun run typecheck`, and `bun run test` on pull requests and pushes to `main`.
|
||||
@@ -7,6 +7,6 @@
|
||||
- [ ] Selecting folder should instantly create project
|
||||
- [ ] New projects should go on top
|
||||
- [ ] Projects should be sorted by latest thread update
|
||||
- [ ] "Response" bar should ONLY appear on work completed
|
||||
- [ ] "Response" bar should ONLY appear above the FINAL message in a series
|
||||
- [ ] Reduce noise of tool calls (combine "command run" and "command completed", make tool calls a "box" with limited # of calls shown at a time, etc)
|
||||
- [x] "Response" bar should ONLY appear on work completed
|
||||
- [x] "Response" bar should ONLY appear above the FINAL message in a series
|
||||
- [x] Reduce noise of tool calls (combine "command run" and "command completed", make tool calls a "box" with limited # of calls shown at a time, etc)
|
||||
@@ -0,0 +1 @@
|
||||
dist-electron/
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@acme/desktop",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "bun run --cwd ../server build && concurrently -k -n BUNDLE,RENDERER,ELECTRON \"bun run dev:bundle\" \"bun run --cwd ../renderer dev\" \"bun run dev:electron\"",
|
||||
"dev:bundle": "tsup --watch",
|
||||
"dev:electron": "bun run scripts/dev-electron.mjs",
|
||||
"build": "tsup",
|
||||
"start": "electron dist-electron/main.js",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run --passWithNoTests",
|
||||
"smoke-test": "node scripts/smoke-test.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron": "33.4.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"concurrently": "^9.1.2",
|
||||
"electronmon": "^2.0.2",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.3",
|
||||
"vitest": "^3.0.0",
|
||||
"wait-on": "^8.0.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
import waitOn from "wait-on";
|
||||
|
||||
const port = Number(process.env.ELECTRON_RENDERER_PORT ?? 5173);
|
||||
const devServerUrl = `http://localhost:${port}`;
|
||||
|
||||
await waitOn({
|
||||
resources: [
|
||||
`tcp:${port}`,
|
||||
"file:dist-electron/main.js",
|
||||
"file:dist-electron/preload.js",
|
||||
"file:../server/dist/index.js",
|
||||
],
|
||||
});
|
||||
|
||||
const command = process.platform === "win32" ? "electronmon.cmd" : "electronmon";
|
||||
const child = spawn(command, ["dist-electron/main.js"], {
|
||||
stdio: "inherit",
|
||||
env: {
|
||||
...process.env,
|
||||
VITE_DEV_SERVER_URL: devServerUrl,
|
||||
},
|
||||
});
|
||||
|
||||
child.on("exit", (code) => {
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import { execSync, spawn } from "node:child_process";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const desktopDir = resolve(__dirname, "..");
|
||||
const rootDir = resolve(__dirname, "../../..");
|
||||
const electronBin = resolve(desktopDir, "node_modules/.bin/electron");
|
||||
const mainJs = resolve(desktopDir, "dist-electron/main.js");
|
||||
|
||||
console.log("Building contracts + renderer + server + desktop...");
|
||||
execSync("bun run build", { cwd: rootDir, stdio: "inherit" });
|
||||
|
||||
console.log("\nLaunching Electron smoke test...");
|
||||
|
||||
const child = spawn(electronBin, [mainJs], {
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
env: {
|
||||
...process.env,
|
||||
VITE_DEV_SERVER_URL: "",
|
||||
ELECTRON_ENABLE_LOGGING: "1",
|
||||
},
|
||||
});
|
||||
|
||||
let output = "";
|
||||
child.stdout.on("data", (chunk) => {
|
||||
output += chunk.toString();
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
output += chunk.toString();
|
||||
});
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
child.kill();
|
||||
}, 8_000);
|
||||
|
||||
child.on("exit", () => {
|
||||
clearTimeout(timeout);
|
||||
|
||||
const fatalPatterns = [
|
||||
"Cannot find module",
|
||||
"MODULE_NOT_FOUND",
|
||||
"Refused to execute",
|
||||
"Uncaught Error",
|
||||
"Uncaught TypeError",
|
||||
"Uncaught ReferenceError",
|
||||
];
|
||||
const failures = fatalPatterns.filter((pattern) => output.includes(pattern));
|
||||
|
||||
if (failures.length > 0) {
|
||||
console.error("\nDesktop smoke test failed:");
|
||||
for (const failure of failures) {
|
||||
console.error(` - ${failure}`);
|
||||
}
|
||||
console.error("\nFull output:\n" + output);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("Desktop smoke test passed.");
|
||||
process.exit(0);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
export function fixPath(): void {
|
||||
if (process.platform !== "darwin") return;
|
||||
|
||||
try {
|
||||
const shell = process.env.SHELL ?? "/bin/zsh";
|
||||
const result = execFileSync(shell, ["-ilc", "echo -n $PATH"], {
|
||||
encoding: "utf8",
|
||||
timeout: 5000,
|
||||
});
|
||||
if (result) {
|
||||
process.env.PATH = result;
|
||||
}
|
||||
} catch {
|
||||
// Keep inherited PATH if shell lookup fails.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
import { spawn, type ChildProcess } from "node:child_process";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import net from "node:net";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { app, BrowserWindow, dialog, ipcMain } from "electron";
|
||||
|
||||
import { fixPath } from "./fixPath";
|
||||
|
||||
fixPath();
|
||||
|
||||
const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
|
||||
const ROOT_DIR = path.resolve(__dirname, "../../..");
|
||||
const BACKEND_ENTRY = path.join(ROOT_DIR, "apps/server/dist/index.js");
|
||||
const RENDERER_ENTRY = path.join(ROOT_DIR, "apps/renderer/dist/index.html");
|
||||
const STATE_DIR = path.join(os.homedir(), ".t3", "userdata");
|
||||
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let backendProcess: ChildProcess | null = null;
|
||||
let backendPort = 0;
|
||||
let backendAuthToken = "";
|
||||
let backendWsUrl = "";
|
||||
let restartAttempt = 0;
|
||||
let restartTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let isQuitting = false;
|
||||
|
||||
async function reserveLoopbackPort(): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const probe = net.createServer();
|
||||
probe.listen(0, "127.0.0.1", () => {
|
||||
const address = probe.address();
|
||||
const port = typeof address === "object" && address !== null ? address.port : 0;
|
||||
probe.close(() => {
|
||||
if (port > 0) {
|
||||
resolve(port);
|
||||
return;
|
||||
}
|
||||
reject(new Error("Failed to reserve backend port"));
|
||||
});
|
||||
});
|
||||
probe.on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
function backendEnv(): NodeJS.ProcessEnv {
|
||||
return {
|
||||
...process.env,
|
||||
CODETHING_MODE: "desktop",
|
||||
CODETHING_NO_BROWSER: "1",
|
||||
CODETHING_PORT: String(backendPort),
|
||||
CODETHING_STATE_DIR: STATE_DIR,
|
||||
CODETHING_AUTH_TOKEN: backendAuthToken,
|
||||
};
|
||||
}
|
||||
|
||||
function scheduleBackendRestart(reason: string): void {
|
||||
if (isQuitting || restartTimer) return;
|
||||
|
||||
const delayMs = Math.min(500 * 2 ** restartAttempt, 10_000);
|
||||
restartAttempt += 1;
|
||||
console.error(`[desktop] backend exited unexpectedly (${reason}); restarting in ${delayMs}ms`);
|
||||
|
||||
restartTimer = setTimeout(() => {
|
||||
restartTimer = null;
|
||||
startBackend();
|
||||
}, delayMs);
|
||||
}
|
||||
|
||||
function startBackend(): void {
|
||||
if (isQuitting || backendProcess) return;
|
||||
|
||||
if (!fs.existsSync(BACKEND_ENTRY)) {
|
||||
scheduleBackendRestart(`missing server entry at ${BACKEND_ENTRY}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const child = spawn(process.execPath, [BACKEND_ENTRY], {
|
||||
cwd: ROOT_DIR,
|
||||
env: backendEnv(),
|
||||
stdio: "inherit",
|
||||
});
|
||||
backendProcess = child;
|
||||
|
||||
child.once("spawn", () => {
|
||||
restartAttempt = 0;
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
if (backendProcess === child) {
|
||||
backendProcess = null;
|
||||
}
|
||||
scheduleBackendRestart(error.message);
|
||||
});
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
if (backendProcess === child) {
|
||||
backendProcess = null;
|
||||
}
|
||||
if (isQuitting) return;
|
||||
const reason = `code=${code ?? "null"} signal=${signal ?? "null"}`;
|
||||
scheduleBackendRestart(reason);
|
||||
});
|
||||
}
|
||||
|
||||
function stopBackend(): void {
|
||||
if (restartTimer) {
|
||||
clearTimeout(restartTimer);
|
||||
restartTimer = null;
|
||||
}
|
||||
|
||||
const child = backendProcess;
|
||||
backendProcess = null;
|
||||
if (!child) return;
|
||||
|
||||
if (!child.killed) {
|
||||
child.kill("SIGTERM");
|
||||
setTimeout(() => {
|
||||
if (!child.killed) {
|
||||
child.kill("SIGKILL");
|
||||
}
|
||||
}, 2_000).unref();
|
||||
}
|
||||
}
|
||||
|
||||
function registerIpcHandlers(): void {
|
||||
ipcMain.removeHandler(PICK_FOLDER_CHANNEL);
|
||||
ipcMain.handle(PICK_FOLDER_CHANNEL, async () => {
|
||||
const owner = BrowserWindow.getFocusedWindow() ?? mainWindow;
|
||||
const result = owner
|
||||
? await dialog.showOpenDialog(owner, {
|
||||
properties: ["openDirectory", "createDirectory"],
|
||||
})
|
||||
: await dialog.showOpenDialog({
|
||||
properties: ["openDirectory", "createDirectory"],
|
||||
});
|
||||
if (result.canceled) return null;
|
||||
return result.filePaths[0] ?? null;
|
||||
});
|
||||
}
|
||||
|
||||
function createWindow(): BrowserWindow {
|
||||
const window = new BrowserWindow({
|
||||
width: 1100,
|
||||
height: 780,
|
||||
minWidth: 840,
|
||||
minHeight: 620,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
titleBarStyle: "hiddenInset",
|
||||
trafficLightPosition: { x: 16, y: 18 },
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
sandbox: true,
|
||||
},
|
||||
});
|
||||
|
||||
window.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
|
||||
window.once("ready-to-show", () => {
|
||||
window.show();
|
||||
});
|
||||
|
||||
if (isDevelopment) {
|
||||
void window.loadURL(process.env.VITE_DEV_SERVER_URL as string);
|
||||
} else {
|
||||
if (!fs.existsSync(RENDERER_ENTRY)) {
|
||||
throw new Error(`Renderer bundle missing at ${RENDERER_ENTRY}`);
|
||||
}
|
||||
void window.loadFile(RENDERER_ENTRY);
|
||||
}
|
||||
|
||||
window.on("closed", () => {
|
||||
if (mainWindow === window) {
|
||||
mainWindow = null;
|
||||
}
|
||||
});
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
async function bootstrap(): Promise<void> {
|
||||
backendPort = await reserveLoopbackPort();
|
||||
backendAuthToken = randomBytes(24).toString("hex");
|
||||
backendWsUrl = `ws://127.0.0.1:${backendPort}/?token=${encodeURIComponent(backendAuthToken)}`;
|
||||
process.env.CODETHING_DESKTOP_WS_URL = backendWsUrl;
|
||||
|
||||
registerIpcHandlers();
|
||||
startBackend();
|
||||
mainWindow = createWindow();
|
||||
}
|
||||
|
||||
app.on("before-quit", () => {
|
||||
isQuitting = true;
|
||||
stopBackend();
|
||||
});
|
||||
|
||||
app.whenReady().then(() => {
|
||||
void bootstrap();
|
||||
|
||||
app.on("activate", () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
mainWindow = createWindow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
|
||||
const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
|
||||
const wsUrl = process.env.CODETHING_DESKTOP_WS_URL ?? null;
|
||||
|
||||
contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
getWsUrl: () => wsUrl,
|
||||
pickFolder: () => ipcRenderer.invoke(PICK_FOLDER_CHANNEL) as Promise<string | null>,
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"types": ["node", "electron"],
|
||||
"lib": ["ES2023", "DOM"]
|
||||
},
|
||||
"include": ["src", "tsup.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
export default defineConfig({
|
||||
entry: ["src/main.ts", "src/preload.ts"],
|
||||
format: "cjs",
|
||||
outDir: "dist-electron",
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
noExternal: ["@acme/contracts"],
|
||||
});
|
||||
+96
-61
@@ -1,13 +1,16 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect, useMemo, useRef } from "react";
|
||||
|
||||
import ChatView from "./components/ChatView";
|
||||
import DiffPanel from "./components/DiffPanel";
|
||||
import Sidebar from "./components/Sidebar";
|
||||
import { isElectron } from "./env";
|
||||
import { DEFAULT_MODEL } from "./model-logic";
|
||||
import { readNativeApi } from "./session-logic";
|
||||
import { StoreProvider, useStore } from "./store";
|
||||
import { onServerWelcome } from "./wsNativeApi";
|
||||
|
||||
function EventRouter() {
|
||||
const api = readNativeApi();
|
||||
const api = useMemo(() => readNativeApi(), []);
|
||||
const { dispatch } = useStore();
|
||||
const activeAssistantItemRef = useRef<string | null>(null);
|
||||
|
||||
@@ -25,74 +28,112 @@ function EventRouter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function BootstrapRouter() {
|
||||
const api = readNativeApi();
|
||||
const { dispatch } = useStore();
|
||||
function AutoProjectBootstrap() {
|
||||
const { state, dispatch } = useStore();
|
||||
const bootstrappedRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!api) return;
|
||||
let cancelled = false;
|
||||
void api.app
|
||||
.bootstrap()
|
||||
.then((bootstrap) => {
|
||||
if (cancelled) return;
|
||||
dispatch({
|
||||
type: "BOOTSTRAP_FROM_SERVER",
|
||||
bootstrap,
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (cancelled) return;
|
||||
dispatch({
|
||||
type: "SET_RUNTIME_ERROR",
|
||||
error:
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Could not connect to the local t3 runtime.",
|
||||
});
|
||||
});
|
||||
// Browser mode bootstraps from server welcome.
|
||||
// Electron bootstraps from persisted projects via DesktopProjectBootstrap.
|
||||
if (isElectron) return;
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [api, dispatch]);
|
||||
return onServerWelcome((payload) => {
|
||||
if (bootstrappedRef.current) return;
|
||||
|
||||
// Don't create duplicate projects for the same cwd
|
||||
const existing = state.projects.find((p) => p.cwd === payload.cwd);
|
||||
if (existing) {
|
||||
bootstrappedRef.current = true;
|
||||
// Ensure a thread is active
|
||||
const existingThread = state.threads.find((t) => t.projectId === existing.id);
|
||||
if (existingThread && !state.activeThreadId) {
|
||||
dispatch({
|
||||
type: "SET_ACTIVE_THREAD",
|
||||
threadId: existingThread.id,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bootstrappedRef.current = true;
|
||||
|
||||
// Create project + thread from server cwd
|
||||
const projectId = crypto.randomUUID();
|
||||
dispatch({
|
||||
type: "ADD_PROJECT",
|
||||
project: {
|
||||
id: projectId,
|
||||
name: payload.projectName,
|
||||
cwd: payload.cwd,
|
||||
model: DEFAULT_MODEL,
|
||||
expanded: true,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: "ADD_THREAD",
|
||||
thread: {
|
||||
id: crypto.randomUUID(),
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model: DEFAULT_MODEL,
|
||||
session: null,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
});
|
||||
}, [state.projects, state.threads, state.activeThreadId, dispatch]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function RuntimeHealthRouter() {
|
||||
const api = readNativeApi();
|
||||
function DesktopProjectBootstrap() {
|
||||
const api = useMemo(() => readNativeApi(), []);
|
||||
const { dispatch } = useStore();
|
||||
const bootstrappedRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!api) return;
|
||||
let cancelled = false;
|
||||
if (!isElectron || !api || bootstrappedRef.current) return;
|
||||
|
||||
const checkHealth = async () => {
|
||||
let disposed = false;
|
||||
let retryDelayMs = 500;
|
||||
let retryTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const attemptBootstrap = async () => {
|
||||
try {
|
||||
await api.app.health();
|
||||
if (cancelled) return;
|
||||
dispatch({ type: "SET_RUNTIME_ERROR", error: null });
|
||||
} catch (error) {
|
||||
if (cancelled) return;
|
||||
const projects = await api.projects.list();
|
||||
if (disposed) return;
|
||||
dispatch({
|
||||
type: "SET_RUNTIME_ERROR",
|
||||
error:
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Could not connect to the local t3 runtime.",
|
||||
type: "SYNC_PROJECTS",
|
||||
projects: projects.map((project) => ({
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
cwd: project.cwd,
|
||||
model: DEFAULT_MODEL,
|
||||
expanded: true,
|
||||
})),
|
||||
});
|
||||
bootstrappedRef.current = true;
|
||||
} catch {
|
||||
if (disposed) return;
|
||||
retryTimer = setTimeout(() => {
|
||||
retryTimer = null;
|
||||
void attemptBootstrap();
|
||||
}, retryDelayMs);
|
||||
retryDelayMs = Math.min(retryDelayMs * 2, 5_000);
|
||||
}
|
||||
};
|
||||
|
||||
void checkHealth();
|
||||
const interval = window.setInterval(() => {
|
||||
void checkHealth();
|
||||
}, 8_000);
|
||||
void attemptBootstrap();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
window.clearInterval(interval);
|
||||
disposed = true;
|
||||
if (retryTimer) {
|
||||
clearTimeout(retryTimer);
|
||||
}
|
||||
};
|
||||
}, [api, dispatch]);
|
||||
|
||||
@@ -100,15 +141,14 @@ function RuntimeHealthRouter() {
|
||||
}
|
||||
|
||||
function Layout() {
|
||||
const api = readNativeApi();
|
||||
const api = useMemo(() => readNativeApi(), []);
|
||||
const { state } = useStore();
|
||||
|
||||
if (!api) {
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background text-foreground">
|
||||
<div className="drag-region h-[52px] shrink-0" />
|
||||
<div className="flex flex-1 items-center justify-center">
|
||||
<p className="text-sm text-muted-foreground">Local t3 runtime unavailable.</p>
|
||||
<p className="text-sm text-muted-foreground">Connecting to CodeThing server...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -116,14 +156,9 @@ function Layout() {
|
||||
|
||||
return (
|
||||
<div className="flex h-screen overflow-hidden bg-background text-foreground">
|
||||
<BootstrapRouter />
|
||||
<RuntimeHealthRouter />
|
||||
<EventRouter />
|
||||
{state.runtimeError && state.projects.length === 0 && (
|
||||
<div className="pointer-events-none fixed right-4 top-4 z-50 max-w-[440px] rounded-lg border border-rose-400/30 bg-rose-500/10 px-3 py-2 text-xs text-rose-100">
|
||||
Runtime connection failed: {state.runtimeError}
|
||||
</div>
|
||||
)}
|
||||
<AutoProjectBootstrap />
|
||||
<DesktopProjectBootstrap />
|
||||
<Sidebar />
|
||||
<ChatView />
|
||||
{state.diffOpen && <DiffPanel />}
|
||||
|
||||
@@ -8,11 +8,13 @@ import {
|
||||
Fragment,
|
||||
type KeyboardEvent,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import { EDITORS, type EditorId } from "@acme/contracts";
|
||||
import { isElectron } from "../env";
|
||||
import { buildBootstrapInput } from "../historyBootstrap";
|
||||
import {
|
||||
DEFAULT_MODEL,
|
||||
@@ -49,6 +51,7 @@ function editorLabel(editor: (typeof EDITORS)[number]): string {
|
||||
}
|
||||
|
||||
const LAST_EDITOR_KEY = "codething:last-editor";
|
||||
const MAX_VISIBLE_WORK_LOG_ENTRIES = 6;
|
||||
|
||||
function workToneClass(tone: "thinking" | "tool" | "info" | "error"): string {
|
||||
if (tone === "error") return "text-rose-300/50 dark:text-rose-300/50";
|
||||
@@ -88,17 +91,23 @@ function approvalDetail(event: ProviderEvent): string | undefined {
|
||||
return asString(payload?.reason);
|
||||
}
|
||||
|
||||
function derivePendingApprovals(events: ProviderEvent[]): PendingApprovalCard[] {
|
||||
function derivePendingApprovals(
|
||||
events: ProviderEvent[],
|
||||
): PendingApprovalCard[] {
|
||||
const pending = new Map<string, PendingApprovalCard>();
|
||||
const ordered = events.toReversed();
|
||||
const ordered = [...events].toReversed();
|
||||
|
||||
for (const event of ordered) {
|
||||
if (event.method === "session/closed" || event.method === "session/exited") {
|
||||
if (
|
||||
event.method === "session/closed" ||
|
||||
event.method === "session/exited"
|
||||
) {
|
||||
pending.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
const requestId = event.requestId ?? asString(asRecord(event.payload)?.requestId);
|
||||
const requestId =
|
||||
event.requestId ?? asString(asRecord(event.payload)?.requestId);
|
||||
if (!requestId) continue;
|
||||
|
||||
if (
|
||||
@@ -125,7 +134,7 @@ function derivePendingApprovals(events: ProviderEvent[]): PendingApprovalCard[]
|
||||
|
||||
export default function ChatView() {
|
||||
const { state, dispatch } = useStore();
|
||||
const api = readNativeApi();
|
||||
const api = useMemo(() => readNativeApi(), []);
|
||||
const [prompt, setPrompt] = useState("");
|
||||
const [isSending, setIsSending] = useState(false);
|
||||
const [isConnecting, setIsConnecting] = useState(false);
|
||||
@@ -133,11 +142,19 @@ export default function ChatView() {
|
||||
const [isEditorMenuOpen, setIsEditorMenuOpen] = useState(false);
|
||||
const [lastEditor, setLastEditor] = useState<EditorId>(() => {
|
||||
const stored = localStorage.getItem(LAST_EDITOR_KEY);
|
||||
return EDITORS.some((e) => e.id === stored) ? (stored as EditorId) : EDITORS[0].id;
|
||||
return EDITORS.some((e) => e.id === stored)
|
||||
? (stored as EditorId)
|
||||
: EDITORS[0].id;
|
||||
});
|
||||
const [selectedEffort, setSelectedEffort] = useState<string>(DEFAULT_REASONING);
|
||||
const [selectedEffort, setSelectedEffort] =
|
||||
useState<string>(DEFAULT_REASONING);
|
||||
const [isSwitchingRuntimeMode, setIsSwitchingRuntimeMode] = useState(false);
|
||||
const [respondingRequestIds, setRespondingRequestIds] = useState<string[]>([]);
|
||||
const [respondingRequestIds, setRespondingRequestIds] = useState<string[]>(
|
||||
[],
|
||||
);
|
||||
const [expandedWorkGroups, setExpandedWorkGroups] = useState<
|
||||
Record<string, boolean>
|
||||
>({});
|
||||
const [nowTick, setNowTick] = useState(() => Date.now());
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
@@ -153,9 +170,23 @@ export default function ChatView() {
|
||||
const isWorking = phase === "running" || isSending || isConnecting;
|
||||
const nowIso = new Date(nowTick).toISOString();
|
||||
const modelOptions = MODEL_OPTIONS;
|
||||
const workLogEntries = deriveWorkLogEntries(activeThread?.events ?? [], undefined);
|
||||
const pendingApprovals = derivePendingApprovals(activeThread?.events ?? []);
|
||||
const assistantCompletionByItemId = (() => {
|
||||
const workLogEntries = useMemo(
|
||||
() => deriveWorkLogEntries(activeThread?.events ?? [], undefined),
|
||||
[activeThread?.events],
|
||||
);
|
||||
const latestTurnWorkEntries = useMemo(
|
||||
() =>
|
||||
deriveWorkLogEntries(
|
||||
activeThread?.events ?? [],
|
||||
activeThread?.latestTurnId,
|
||||
),
|
||||
[activeThread?.events, activeThread?.latestTurnId],
|
||||
);
|
||||
const pendingApprovals = useMemo(
|
||||
() => derivePendingApprovals(activeThread?.events ?? []),
|
||||
[activeThread?.events],
|
||||
);
|
||||
const assistantCompletionByItemId = useMemo(() => {
|
||||
const map = new Map<string, string>();
|
||||
const ordered = [...(activeThread?.events ?? [])].toReversed();
|
||||
for (const event of ordered) {
|
||||
@@ -164,12 +195,17 @@ export default function ChatView() {
|
||||
map.set(event.itemId, event.createdAt);
|
||||
}
|
||||
return map;
|
||||
})();
|
||||
const timelineEntries = deriveTimelineEntries(activeThread?.messages ?? [], workLogEntries);
|
||||
const completionSummary = (() => {
|
||||
}, [activeThread?.events]);
|
||||
const timelineEntries = useMemo(
|
||||
() => deriveTimelineEntries(activeThread?.messages ?? [], workLogEntries),
|
||||
[activeThread?.messages, workLogEntries],
|
||||
);
|
||||
const completionSummary = useMemo(() => {
|
||||
if (!activeThread?.latestTurnStartedAt) return null;
|
||||
if (!activeThread.latestTurnCompletedAt) return null;
|
||||
if (workLogEntries.length === 0) return null;
|
||||
if (!latestTurnWorkEntries.some((entry) => entry.tone === "tool")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof activeThread.latestTurnDurationMs === "number" &&
|
||||
@@ -184,23 +220,41 @@ export default function ChatView() {
|
||||
activeThread.latestTurnCompletedAt,
|
||||
);
|
||||
return elapsed ? `Worked for ${elapsed}` : null;
|
||||
})();
|
||||
const completionDividerBeforeEntryId = (() => {
|
||||
}, [
|
||||
activeThread?.latestTurnStartedAt,
|
||||
activeThread?.latestTurnCompletedAt,
|
||||
activeThread?.latestTurnDurationMs,
|
||||
latestTurnWorkEntries,
|
||||
]);
|
||||
const completionDividerBeforeEntryId = useMemo(() => {
|
||||
if (!activeThread?.latestTurnStartedAt) return null;
|
||||
if (!activeThread.latestTurnCompletedAt) return null;
|
||||
if (workLogEntries.length === 0) return null;
|
||||
if (!completionSummary) return null;
|
||||
|
||||
const turnStartedAt = Date.parse(activeThread.latestTurnStartedAt);
|
||||
const turnCompletedAt = Date.parse(activeThread.latestTurnCompletedAt);
|
||||
if (Number.isNaN(turnStartedAt)) return null;
|
||||
if (Number.isNaN(turnCompletedAt)) return null;
|
||||
|
||||
const entry = timelineEntries.find((timelineEntry) => {
|
||||
if (timelineEntry.kind !== "message") return false;
|
||||
if (timelineEntry.message.role !== "assistant") return false;
|
||||
let inRangeMatch: string | null = null;
|
||||
let fallbackMatch: string | null = null;
|
||||
for (const timelineEntry of timelineEntries) {
|
||||
if (timelineEntry.kind !== "message") continue;
|
||||
if (timelineEntry.message.role !== "assistant") continue;
|
||||
const messageAt = Date.parse(timelineEntry.message.createdAt);
|
||||
return !Number.isNaN(messageAt) && messageAt >= turnStartedAt;
|
||||
});
|
||||
return entry?.id ?? null;
|
||||
})();
|
||||
if (Number.isNaN(messageAt) || messageAt < turnStartedAt) continue;
|
||||
fallbackMatch = timelineEntry.id;
|
||||
if (messageAt <= turnCompletedAt) {
|
||||
inRangeMatch = timelineEntry.id;
|
||||
}
|
||||
}
|
||||
return inRangeMatch ?? fallbackMatch;
|
||||
}, [
|
||||
activeThread?.latestTurnCompletedAt,
|
||||
activeThread?.latestTurnStartedAt,
|
||||
completionSummary,
|
||||
timelineEntries,
|
||||
]);
|
||||
const runtimeSessionConfig =
|
||||
state.runtimeMode === "full-access"
|
||||
? ({
|
||||
@@ -212,14 +266,18 @@ export default function ChatView() {
|
||||
sandboxMode: "workspace-write",
|
||||
} as const);
|
||||
|
||||
const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {
|
||||
const handleRuntimeModeChange = async (
|
||||
mode: "approval-required" | "full-access",
|
||||
) => {
|
||||
if (mode === state.runtimeMode) return;
|
||||
dispatch({ type: "SET_RUNTIME_MODE", mode });
|
||||
if (!api) return;
|
||||
|
||||
const sessionIds = state.threads
|
||||
.map((t) => t.session)
|
||||
.filter((s): s is NonNullable<typeof s> => s !== null && s.status !== "closed")
|
||||
.filter(
|
||||
(s): s is NonNullable<typeof s> => s !== null && s.status !== "closed",
|
||||
)
|
||||
.map((s) => s.sessionId);
|
||||
|
||||
if (sessionIds.length === 0) return;
|
||||
@@ -227,7 +285,9 @@ export default function ChatView() {
|
||||
setIsSwitchingRuntimeMode(true);
|
||||
try {
|
||||
await Promise.all(
|
||||
sessionIds.map((id) => api.providers.stopSession({ sessionId: id }).catch(() => undefined)),
|
||||
sessionIds.map((id) =>
|
||||
api.providers.stopSession({ sessionId: id }).catch(() => undefined),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setIsSwitchingRuntimeMode(false);
|
||||
@@ -245,6 +305,10 @@ export default function ChatView() {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [phase, workLogCount]);
|
||||
|
||||
useEffect(() => {
|
||||
setExpandedWorkGroups({});
|
||||
}, [activeThread?.id]);
|
||||
|
||||
// Auto-resize textarea
|
||||
useEffect(() => {
|
||||
const ta = textareaRef.current;
|
||||
@@ -284,7 +348,10 @@ export default function ChatView() {
|
||||
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
if (!editorMenuRef.current) return;
|
||||
if (event.target instanceof Node && !editorMenuRef.current.contains(event.target)) {
|
||||
if (
|
||||
event.target instanceof Node &&
|
||||
!editorMenuRef.current.contains(event.target)
|
||||
) {
|
||||
setIsEditorMenuOpen(false);
|
||||
}
|
||||
};
|
||||
@@ -319,11 +386,7 @@ export default function ChatView() {
|
||||
|
||||
const ensureSession = async (): Promise<EnsuredSessionInfo | null> => {
|
||||
if (!api || !activeThread || !activeProject) return null;
|
||||
if (
|
||||
activeThread.session &&
|
||||
activeThread.session.status !== "closed" &&
|
||||
activeThread.session.status !== "error"
|
||||
) {
|
||||
if (activeThread.session && activeThread.session.status !== "closed") {
|
||||
const sessionThreadId = activeThread.session.threadId ?? null;
|
||||
const continuityState: SessionContinuityState =
|
||||
activeThread.codexThreadId === null
|
||||
@@ -415,9 +478,14 @@ export default function ChatView() {
|
||||
try {
|
||||
const shouldBootstrap =
|
||||
previousMessages.length > 0 &&
|
||||
(sessionInfo.continuityState === "new" || sessionInfo.continuityState === "fallback_new");
|
||||
(sessionInfo.continuityState === "new" ||
|
||||
sessionInfo.continuityState === "fallback_new");
|
||||
const input = shouldBootstrap
|
||||
? buildBootstrapInput(previousMessages, trimmed, PROVIDER_SEND_TURN_MAX_INPUT_CHARS).text
|
||||
? buildBootstrapInput(
|
||||
previousMessages,
|
||||
trimmed,
|
||||
PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
|
||||
).text
|
||||
: trimmed;
|
||||
await api.providers.sendTurn({
|
||||
sessionId: sessionInfo.sessionId,
|
||||
@@ -444,7 +512,10 @@ export default function ChatView() {
|
||||
});
|
||||
};
|
||||
|
||||
const onRespondToApproval = async (requestId: string, decision: ProviderApprovalDecision) => {
|
||||
const onRespondToApproval = async (
|
||||
requestId: string,
|
||||
decision: ProviderApprovalDecision,
|
||||
) => {
|
||||
if (!api || !activeThread?.session) return;
|
||||
|
||||
setRespondingRequestIds((existing) =>
|
||||
@@ -460,10 +531,15 @@ export default function ChatView() {
|
||||
dispatch({
|
||||
type: "SET_ERROR",
|
||||
threadId: activeThread.id,
|
||||
error: err instanceof Error ? err.message : "Failed to submit approval decision.",
|
||||
error:
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Failed to submit approval decision.",
|
||||
});
|
||||
} finally {
|
||||
setRespondingRequestIds((existing) => existing.filter((id) => id !== requestId));
|
||||
setRespondingRequestIds((existing) =>
|
||||
existing.filter((id) => id !== requestId),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -488,7 +564,7 @@ export default function ChatView() {
|
||||
if (!activeThread) {
|
||||
return (
|
||||
<div className="flex flex-1 flex-col bg-background text-muted-foreground/40">
|
||||
<div className="drag-region h-[52px] shrink-0" />
|
||||
{isElectron && <div className="drag-region h-[52px] shrink-0" />}
|
||||
<div className="flex flex-1 items-center justify-center">
|
||||
<div className="text-center">
|
||||
<p className="text-sm">Select a thread or create a new one to get started.</p>
|
||||
@@ -501,9 +577,11 @@ export default function ChatView() {
|
||||
return (
|
||||
<div className="flex flex-1 flex-col bg-background">
|
||||
{/* Top bar */}
|
||||
<header className="drag-region flex items-center justify-between border-b border-border px-5 pt-[28px] pb-3">
|
||||
<header className={`flex items-center justify-between border-b border-border px-5 pb-3 ${isElectron ? "drag-region pt-[28px]" : "pt-3"}`}>
|
||||
<div className="flex items-center gap-3">
|
||||
<h2 className="text-sm font-medium text-foreground">{activeThread.title}</h2>
|
||||
<h2 className="text-sm font-medium text-foreground">
|
||||
{activeThread.title}
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Open in editor */}
|
||||
@@ -528,7 +606,9 @@ export default function ChatView() {
|
||||
{editorLabel(editor)}
|
||||
{editor.id === lastEditor && (
|
||||
<kbd className="ml-auto text-[9px] text-muted-foreground/40">
|
||||
{navigator.platform.includes("Mac") ? "\u2318O" : "Ctrl+O"}
|
||||
{navigator.platform.includes("Mac")
|
||||
? "\u2318O"
|
||||
: "Ctrl+O"}
|
||||
</kbd>
|
||||
)}
|
||||
</button>
|
||||
@@ -562,7 +642,9 @@ export default function ChatView() {
|
||||
{pendingApprovals.length > 0 && (
|
||||
<div className="mx-4 mt-3 space-y-2">
|
||||
{pendingApprovals.map((approval) => {
|
||||
const isResponding = respondingRequestIds.includes(approval.requestId);
|
||||
const isResponding = respondingRequestIds.includes(
|
||||
approval.requestId,
|
||||
);
|
||||
return (
|
||||
<div
|
||||
key={approval.requestId}
|
||||
@@ -586,7 +668,9 @@ export default function ChatView() {
|
||||
type="button"
|
||||
className="rounded-md border border-border bg-accent px-2 py-1 text-[11px] text-foreground transition-colors duration-150 hover:bg-accent/80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(approval.requestId, "accept")}
|
||||
onClick={() =>
|
||||
void onRespondToApproval(approval.requestId, "accept")
|
||||
}
|
||||
>
|
||||
Approve once
|
||||
</button>
|
||||
@@ -594,7 +678,12 @@ export default function ChatView() {
|
||||
type="button"
|
||||
className="rounded-md border border-sky-300/30 bg-sky-500/[0.15] px-2 py-1 text-[11px] text-sky-100 transition-colors duration-150 hover:bg-sky-500/[0.22] disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(approval.requestId, "acceptForSession")}
|
||||
onClick={() =>
|
||||
void onRespondToApproval(
|
||||
approval.requestId,
|
||||
"acceptForSession",
|
||||
)
|
||||
}
|
||||
>
|
||||
Always allow this session
|
||||
</button>
|
||||
@@ -602,7 +691,9 @@ export default function ChatView() {
|
||||
type="button"
|
||||
className="rounded-md border border-border px-2 py-1 text-[11px] text-foreground/90 transition-colors duration-150 hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(approval.requestId, "decline")}
|
||||
onClick={() =>
|
||||
void onRespondToApproval(approval.requestId, "decline")
|
||||
}
|
||||
>
|
||||
Decline
|
||||
</button>
|
||||
@@ -610,7 +701,9 @@ export default function ChatView() {
|
||||
type="button"
|
||||
className="rounded-md border border-rose-300/30 bg-rose-500/[0.12] px-2 py-1 text-[11px] text-rose-100 transition-colors duration-150 hover:bg-rose-500/[0.2] disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(approval.requestId, "cancel")}
|
||||
onClick={() =>
|
||||
void onRespondToApproval(approval.requestId, "cancel")
|
||||
}
|
||||
>
|
||||
Cancel turn
|
||||
</button>
|
||||
@@ -625,93 +718,166 @@ export default function ChatView() {
|
||||
<div className="flex-1 overflow-y-auto px-5 py-4">
|
||||
{activeThread.messages.length === 0 && !isWorking ? (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-sm text-muted-foreground/30">
|
||||
Send a message to start the conversation.
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground/30">Send a message to start the conversation.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="mx-auto max-w-3xl space-y-4">
|
||||
{timelineEntries.map((timelineEntry, index) => (
|
||||
<Fragment key={timelineEntry.id}>
|
||||
{timelineEntry.kind === "message" &&
|
||||
timelineEntry.message.role === "assistant" &&
|
||||
(completionDividerBeforeEntryId === timelineEntry.id ||
|
||||
timelineEntries[index - 1]?.kind === "work") && (
|
||||
{timelineEntries.map((timelineEntry, index) => {
|
||||
if (
|
||||
timelineEntry.kind === "work" &&
|
||||
timelineEntries[index - 1]?.kind === "work"
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const showCompletionDivider =
|
||||
timelineEntry.kind === "message" &&
|
||||
timelineEntry.message.role === "assistant" &&
|
||||
completionDividerBeforeEntryId === timelineEntry.id;
|
||||
|
||||
if (timelineEntry.kind === "work") {
|
||||
const groupedEntries = [timelineEntry.entry];
|
||||
let cursor = index + 1;
|
||||
while (cursor < timelineEntries.length) {
|
||||
const nextEntry = timelineEntries[cursor];
|
||||
if (!nextEntry || nextEntry.kind !== "work") break;
|
||||
groupedEntries.push(nextEntry.entry);
|
||||
cursor += 1;
|
||||
}
|
||||
|
||||
const groupId = timelineEntry.id;
|
||||
const isExpanded = expandedWorkGroups[groupId] ?? false;
|
||||
const hasOverflow =
|
||||
groupedEntries.length > MAX_VISIBLE_WORK_LOG_ENTRIES;
|
||||
const visibleEntries =
|
||||
hasOverflow && !isExpanded
|
||||
? groupedEntries.slice(-MAX_VISIBLE_WORK_LOG_ENTRIES)
|
||||
: groupedEntries;
|
||||
const hiddenCount = groupedEntries.length - visibleEntries.length;
|
||||
const onlyToolEntries = groupedEntries.every(
|
||||
(entry) => entry.tone === "tool",
|
||||
);
|
||||
const groupLabel = onlyToolEntries
|
||||
? groupedEntries.length === 1
|
||||
? "Tool call"
|
||||
: `Tool calls (${groupedEntries.length})`
|
||||
: groupedEntries.length === 1
|
||||
? "Work event"
|
||||
: `Work log (${groupedEntries.length})`;
|
||||
|
||||
return (
|
||||
<Fragment key={timelineEntry.id}>
|
||||
<div className="rounded-lg border border-border/80 bg-card/45 px-3 py-2">
|
||||
<div className="mb-1.5 flex items-center justify-between gap-3">
|
||||
<p className="text-[10px] uppercase tracking-[0.12em] text-muted-foreground/65">
|
||||
{groupLabel}
|
||||
</p>
|
||||
{hasOverflow && (
|
||||
<button
|
||||
type="button"
|
||||
className="text-[10px] uppercase tracking-[0.12em] text-muted-foreground/55 transition-colors duration-150 hover:text-muted-foreground/80"
|
||||
onClick={() =>
|
||||
setExpandedWorkGroups((existing) => ({
|
||||
...existing,
|
||||
[groupId]: !existing[groupId],
|
||||
}))
|
||||
}
|
||||
>
|
||||
{isExpanded ? "Show less" : `Show ${hiddenCount} more`}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
{visibleEntries.map((workEntry) => (
|
||||
<div
|
||||
key={`work-row:${workEntry.id}`}
|
||||
className="flex items-start gap-2 py-0.5"
|
||||
>
|
||||
<span className="mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/30" />
|
||||
<p
|
||||
className={`py-[2px] text-[11px] leading-relaxed ${workToneClass(workEntry.tone)}`}
|
||||
>
|
||||
{workEntry.detail ? (
|
||||
<>
|
||||
{workEntry.label}
|
||||
<span
|
||||
className="ml-1.5 inline-block max-w-[70ch] truncate align-bottom font-mono text-[11px] opacity-60"
|
||||
title={workEntry.detail}
|
||||
>
|
||||
{workEntry.detail}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
workEntry.label
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
if (timelineEntry.message.role === "user") {
|
||||
return (
|
||||
<Fragment key={timelineEntry.id}>
|
||||
<div className="flex justify-end">
|
||||
<div className="max-w-[80%] rounded-2xl rounded-br-sm border border-border bg-secondary px-4 py-3">
|
||||
<pre className="whitespace-pre-wrap break-words font-mono text-sm leading-relaxed text-foreground">
|
||||
{timelineEntry.message.text}
|
||||
</pre>
|
||||
<p className="mt-1.5 text-right text-[10px] text-muted-foreground/30">
|
||||
{formatTimestamp(timelineEntry.message.createdAt)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment key={timelineEntry.id}>
|
||||
{showCompletionDivider && (
|
||||
<div className="my-3 flex items-center gap-3">
|
||||
<span className="h-px flex-1 bg-border" />
|
||||
<span className="rounded-full border border-border bg-background px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-muted-foreground/80">
|
||||
{completionSummary ? `Response • ${completionSummary}` : "Response"}
|
||||
{completionSummary
|
||||
? `Response • ${completionSummary}`
|
||||
: "Response"}
|
||||
</span>
|
||||
<span className="h-px flex-1 bg-border" />
|
||||
</div>
|
||||
)}
|
||||
{timelineEntry.kind === "work" ? (
|
||||
<div className="flex items-start gap-2 py-0.5 pl-1.5">
|
||||
<span className="mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/30" />
|
||||
<p
|
||||
className={`py-[2px] text-[11px] leading-relaxed ${workToneClass(timelineEntry.entry.tone)}`}
|
||||
>
|
||||
{timelineEntry.entry.detail ? (
|
||||
<>
|
||||
{timelineEntry.entry.label}
|
||||
<span
|
||||
className="ml-1.5 inline-block max-w-[70ch] truncate align-bottom font-mono text-[11px] opacity-60"
|
||||
title={timelineEntry.entry.detail}
|
||||
>
|
||||
{timelineEntry.entry.detail}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
timelineEntry.entry.label
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
) : timelineEntry.message.role === "user" ? (
|
||||
<div className="flex justify-end">
|
||||
<div className="max-w-[80%] rounded-2xl rounded-br-sm border border-border bg-secondary px-4 py-3">
|
||||
<pre className="whitespace-pre-wrap break-words font-mono text-sm leading-relaxed text-foreground">
|
||||
{timelineEntry.message.text}
|
||||
</pre>
|
||||
<p className="mt-1.5 text-right text-[10px] text-muted-foreground/30">
|
||||
{formatTimestamp(timelineEntry.message.createdAt)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="px-1 py-0.5">
|
||||
<ChatMarkdown
|
||||
text={
|
||||
timelineEntry.message.text ||
|
||||
(timelineEntry.message.streaming ? "" : "(empty response)")
|
||||
(timelineEntry.message.streaming
|
||||
? ""
|
||||
: "(empty response)")
|
||||
}
|
||||
/>
|
||||
{timelineEntry.message.streaming && (
|
||||
<div className="pt-1.5">
|
||||
<span className="inline-flex items-center gap-2 rounded-full border border-sky-400/25 bg-sky-500/[0.08] px-2 py-0.5 text-[10px] text-sky-100/90">
|
||||
<span className="inline-flex gap-1">
|
||||
<span className="h-1.5 w-1.5 animate-pulse rounded-full bg-sky-100/80" />
|
||||
<span className="h-1.5 w-1.5 animate-pulse rounded-full bg-sky-100/80 [animation-delay:150ms]" />
|
||||
<span className="h-1.5 w-1.5 animate-pulse rounded-full bg-sky-100/80 [animation-delay:300ms]" />
|
||||
</span>
|
||||
<span>Thinking</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<p className="mt-1.5 text-[10px] text-muted-foreground/30">
|
||||
{formatMessageMeta(
|
||||
timelineEntry.message.createdAt,
|
||||
timelineEntry.message.streaming
|
||||
? formatElapsed(timelineEntry.message.createdAt, nowIso)
|
||||
? formatElapsed(
|
||||
timelineEntry.message.createdAt,
|
||||
nowIso,
|
||||
)
|
||||
: formatElapsed(
|
||||
timelineEntry.message.createdAt,
|
||||
assistantCompletionByItemId.get(timelineEntry.message.id),
|
||||
assistantCompletionByItemId.get(
|
||||
timelineEntry.message.id,
|
||||
),
|
||||
),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</Fragment>
|
||||
))}
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
{isWorking && (
|
||||
<div className="flex items-center gap-2 py-0.5 pl-1.5">
|
||||
<span className="h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/30" />
|
||||
@@ -860,7 +1026,9 @@ export default function ChatView() {
|
||||
disabled={isSwitchingRuntimeMode}
|
||||
onClick={() =>
|
||||
void handleRuntimeModeChange(
|
||||
state.runtimeMode === "full-access" ? "approval-required" : "full-access",
|
||||
state.runtimeMode === "full-access"
|
||||
? "approval-required"
|
||||
: "full-access",
|
||||
)
|
||||
}
|
||||
title={
|
||||
@@ -870,7 +1038,13 @@ export default function ChatView() {
|
||||
}
|
||||
>
|
||||
{state.runtimeMode === "full-access" ? (
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
|
||||
<svg
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<rect
|
||||
x="2"
|
||||
y="5.5"
|
||||
@@ -888,7 +1062,13 @@ export default function ChatView() {
|
||||
/>
|
||||
</svg>
|
||||
) : (
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
|
||||
<svg
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<rect
|
||||
x="2"
|
||||
y="5.5"
|
||||
@@ -906,7 +1086,11 @@ export default function ChatView() {
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
<span>{state.runtimeMode === "full-access" ? "Full access" : "Supervised"}</span>
|
||||
<span>
|
||||
{state.runtimeMode === "full-access"
|
||||
? "Full access"
|
||||
: "Supervised"}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isElectron } from "../env";
|
||||
import { useStore } from "../store";
|
||||
|
||||
export default function DiffPanel() {
|
||||
@@ -6,7 +7,7 @@ export default function DiffPanel() {
|
||||
return (
|
||||
<aside className="flex h-full w-[400px] shrink-0 flex-col border-l border-border bg-card">
|
||||
{/* Header */}
|
||||
<div className="drag-region flex items-center justify-between border-b border-border px-4 pt-[28px] pb-3">
|
||||
<div className={`flex items-center justify-between border-b border-border px-4 pb-3 ${isElectron ? "drag-region pt-[28px]" : "pt-3"}`}>
|
||||
<h3 className="text-xs font-medium text-foreground">Uncommitted changes</h3>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { isElectron } from "../env";
|
||||
import { useTheme } from "../hooks/useTheme";
|
||||
import { DEFAULT_MODEL } from "../model-logic";
|
||||
import { readNativeApi } from "../session-logic";
|
||||
@@ -17,6 +18,13 @@ function formatRelativeTime(iso: string): string {
|
||||
return `${Math.floor(hours / 24)}d ago`;
|
||||
}
|
||||
|
||||
function inferProjectName(cwd: string): string {
|
||||
const normalized = cwd.replace(/\\/g, "/").replace(/\/+$/, "");
|
||||
const parts = normalized.split("/");
|
||||
const last = parts[parts.length - 1];
|
||||
return last && last.length > 0 ? last : "project";
|
||||
}
|
||||
|
||||
function threadStatusLabel(
|
||||
status: "connecting" | "ready" | "running" | "error" | "closed" | undefined,
|
||||
): "Working" | "Connecting" | null {
|
||||
@@ -27,44 +35,117 @@ function threadStatusLabel(
|
||||
|
||||
export default function Sidebar() {
|
||||
const { state, dispatch } = useStore();
|
||||
const api = readNativeApi();
|
||||
const api = useMemo(() => readNativeApi(), []);
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [addingProject, setAddingProject] = useState(false);
|
||||
const [newCwd, setNewCwd] = useState("");
|
||||
const [isPickingFolder, setIsPickingFolder] = useState(false);
|
||||
const [isAddingProject, setIsAddingProject] = useState(false);
|
||||
|
||||
const handleNewThread = useCallback(
|
||||
(projectId: string) => {
|
||||
dispatch({
|
||||
type: "ADD_THREAD",
|
||||
thread: {
|
||||
id: crypto.randomUUID(),
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model: state.projects.find((p) => p.id === projectId)?.model ?? DEFAULT_MODEL,
|
||||
session: null,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
},
|
||||
[dispatch, state.projects],
|
||||
);
|
||||
|
||||
const focusMostRecentThreadForProject = useCallback(
|
||||
(projectId: string) => {
|
||||
const latestThread = state.threads
|
||||
.filter((thread) => thread.projectId === projectId)
|
||||
.toSorted((a, b) => {
|
||||
const byDate = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
||||
if (byDate !== 0) return byDate;
|
||||
return b.id.localeCompare(a.id);
|
||||
})[0];
|
||||
if (!latestThread) return;
|
||||
|
||||
dispatch({
|
||||
type: "SET_ACTIVE_THREAD",
|
||||
threadId: latestThread.id,
|
||||
});
|
||||
},
|
||||
[dispatch, state.threads],
|
||||
);
|
||||
|
||||
const addProjectFromPath = useCallback(
|
||||
async (rawCwd: string) => {
|
||||
const cwd = rawCwd.trim();
|
||||
if (!cwd || isAddingProject) return;
|
||||
|
||||
setIsAddingProject(true);
|
||||
try {
|
||||
if (isElectron && api) {
|
||||
const result = await api.projects.add({ cwd });
|
||||
const project: Project = {
|
||||
id: result.project.id,
|
||||
name: result.project.name,
|
||||
cwd: result.project.cwd,
|
||||
model: DEFAULT_MODEL,
|
||||
expanded: true,
|
||||
};
|
||||
const existingById = state.projects.find((p) => p.id === project.id);
|
||||
const existingByCwd = state.projects.find((p) => p.cwd === project.cwd);
|
||||
if (!existingById && !existingByCwd) {
|
||||
dispatch({ type: "ADD_PROJECT", project });
|
||||
}
|
||||
const resolvedProjectId = existingByCwd?.id ?? project.id;
|
||||
|
||||
if (result.created) {
|
||||
handleNewThread(resolvedProjectId);
|
||||
} else {
|
||||
focusMostRecentThreadForProject(resolvedProjectId);
|
||||
}
|
||||
} else {
|
||||
const existing = state.projects.find((project) => project.cwd === cwd);
|
||||
if (existing) {
|
||||
focusMostRecentThreadForProject(existing.id);
|
||||
return;
|
||||
}
|
||||
|
||||
const name = inferProjectName(cwd);
|
||||
const project: Project = {
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
cwd,
|
||||
model: DEFAULT_MODEL,
|
||||
expanded: true,
|
||||
};
|
||||
dispatch({ type: "ADD_PROJECT", project });
|
||||
handleNewThread(project.id);
|
||||
}
|
||||
} finally {
|
||||
setIsAddingProject(false);
|
||||
setNewCwd("");
|
||||
setAddingProject(false);
|
||||
}
|
||||
},
|
||||
[
|
||||
api,
|
||||
dispatch,
|
||||
focusMostRecentThreadForProject,
|
||||
handleNewThread,
|
||||
isAddingProject,
|
||||
state.projects,
|
||||
],
|
||||
);
|
||||
|
||||
const handleAddProject = () => {
|
||||
const cwd = newCwd.trim();
|
||||
if (!cwd) return;
|
||||
const name = cwd.split("/").findLast((segment) => segment.length > 0) ?? "project";
|
||||
const project: Project = {
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
cwd,
|
||||
model: DEFAULT_MODEL,
|
||||
expanded: true,
|
||||
};
|
||||
dispatch({ type: "ADD_PROJECT", project });
|
||||
setNewCwd("");
|
||||
setAddingProject(false);
|
||||
};
|
||||
|
||||
const handleNewThread = (projectId: string) => {
|
||||
dispatch({
|
||||
type: "ADD_THREAD",
|
||||
thread: {
|
||||
id: crypto.randomUUID(),
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model: state.projects.find((p) => p.id === projectId)?.model ?? DEFAULT_MODEL,
|
||||
session: null,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
void addProjectFromPath(newCwd);
|
||||
};
|
||||
|
||||
const handlePickFolder = async () => {
|
||||
@@ -73,7 +154,7 @@ export default function Sidebar() {
|
||||
try {
|
||||
const pickedPath = await api.dialogs.pickFolder();
|
||||
if (!pickedPath) return;
|
||||
setNewCwd(pickedPath);
|
||||
await addProjectFromPath(pickedPath);
|
||||
} finally {
|
||||
setIsPickingFolder(false);
|
||||
}
|
||||
@@ -107,46 +188,27 @@ export default function Sidebar() {
|
||||
if (!projectId) return;
|
||||
|
||||
event.preventDefault();
|
||||
dispatch({
|
||||
type: "ADD_THREAD",
|
||||
thread: {
|
||||
id: crypto.randomUUID(),
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model: state.projects.find((project) => project.id === projectId)?.model ?? DEFAULT_MODEL,
|
||||
session: null,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
handleNewThread(projectId);
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", onWindowKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onWindowKeyDown);
|
||||
};
|
||||
}, [dispatch, state.activeThreadId, state.projects, state.threads]);
|
||||
}, [handleNewThread, state.activeThreadId, state.projects, state.threads]);
|
||||
|
||||
return (
|
||||
<aside className="sidebar flex h-full w-[260px] shrink-0 flex-col border-r border-border bg-card">
|
||||
{/* Drag region / traffic light space */}
|
||||
<div className="drag-region h-[52px] shrink-0" />
|
||||
{/* Drag region / traffic light space (Electron only) */}
|
||||
{isElectron && <div className="drag-region h-[52px] shrink-0" />}
|
||||
{/* Branding */}
|
||||
<div className="flex items-center gap-2 px-4 pb-4">
|
||||
<div className={`flex items-center gap-2 px-4 pb-4 ${isElectron ? "" : "pt-4"}`}>
|
||||
<div className="flex h-7 w-7 items-center justify-center rounded-lg bg-primary text-xs font-bold text-primary-foreground">
|
||||
CT
|
||||
</div>
|
||||
<span className="flex-1 text-sm font-semibold tracking-tight text-foreground">
|
||||
CodeThing
|
||||
</span>
|
||||
{state.runtimeError && (
|
||||
<span className="rounded-full border border-rose-400/30 bg-rose-500/10 px-2 py-0.5 text-[9px] font-medium uppercase tracking-wider text-rose-100">
|
||||
Offline
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="rounded-md p-1.5 text-muted-foreground/80 transition-colors duration-150 hover:bg-accent hover:text-muted-foreground"
|
||||
@@ -287,12 +349,12 @@ export default function Sidebar() {
|
||||
if (e.key === "Escape") setAddingProject(false);
|
||||
}}
|
||||
/>
|
||||
{api && (
|
||||
{isElectron && api && (
|
||||
<button
|
||||
type="button"
|
||||
className="mb-2 flex w-full items-center justify-center rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground transition-colors duration-150 hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-60"
|
||||
onClick={() => void handlePickFolder()}
|
||||
disabled={isPickingFolder}
|
||||
disabled={isPickingFolder || isAddingProject}
|
||||
>
|
||||
{isPickingFolder ? "Picking folder..." : "Browse for folder"}
|
||||
</button>
|
||||
@@ -302,8 +364,9 @@ export default function Sidebar() {
|
||||
type="button"
|
||||
className="flex-1 rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition-colors duration-150 hover:bg-primary/90"
|
||||
onClick={handleAddProject}
|
||||
disabled={isAddingProject}
|
||||
>
|
||||
Add
|
||||
{isAddingProject ? "Adding..." : "Add"}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* True when running inside the Electron preload bridge, false in a regular browser.
|
||||
* The preload script sets window.nativeApi via contextBridge before any renderer
|
||||
* code executes, so this is reliable at module load time.
|
||||
*/
|
||||
export const isElectron =
|
||||
typeof window !== "undefined" &&
|
||||
(window.desktopBridge !== undefined || window.nativeApi !== undefined);
|
||||
@@ -36,8 +36,13 @@ export function buildBootstrapInput(
|
||||
latestPrompt: string,
|
||||
maxChars: number,
|
||||
): BootstrapInputResult {
|
||||
const budget = Number.isFinite(maxChars) ? Math.max(1, Math.floor(maxChars)) : 1;
|
||||
const promptOnly = latestPrompt.length <= budget ? latestPrompt : latestPrompt.slice(0, budget);
|
||||
const budget = Number.isFinite(maxChars)
|
||||
? Math.max(1, Math.floor(maxChars))
|
||||
: 1;
|
||||
const promptOnly =
|
||||
latestPrompt.length <= budget
|
||||
? latestPrompt
|
||||
: latestPrompt.slice(0, budget);
|
||||
|
||||
if (previousMessages.length === 0) {
|
||||
return {
|
||||
@@ -68,7 +73,7 @@ export function buildBootstrapInput(
|
||||
let includedNewestFirst: string[] = [];
|
||||
for (const block of newestFirstBlocks) {
|
||||
const nextNewestFirst = [...includedNewestFirst, block];
|
||||
const nextChronological = nextNewestFirst.toReversed();
|
||||
const nextChronological = [...nextNewestFirst].reverse();
|
||||
const omittedCount = newestFirstBlocks.length - nextChronological.length;
|
||||
const transcriptBody =
|
||||
omittedCount > 0
|
||||
@@ -80,9 +85,10 @@ export function buildBootstrapInput(
|
||||
includedNewestFirst = nextNewestFirst;
|
||||
}
|
||||
|
||||
let includedChronological = includedNewestFirst.toReversed();
|
||||
let includedChronological = [...includedNewestFirst].reverse();
|
||||
while (true) {
|
||||
const omittedCount = newestFirstBlocks.length - includedChronological.length;
|
||||
const omittedCount =
|
||||
newestFirstBlocks.length - includedChronological.length;
|
||||
const transcriptBody =
|
||||
omittedCount > 0
|
||||
? includedChronological.length > 0
|
||||
@@ -95,7 +101,8 @@ export function buildBootstrapInput(
|
||||
text: finalized,
|
||||
includedCount: includedChronological.length,
|
||||
omittedCount,
|
||||
truncated: omittedCount > 0 || latestPrompt.length !== promptOnly.length,
|
||||
truncated:
|
||||
omittedCount > 0 || latestPrompt.length !== promptOnly.length,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useSyncExternalStore } from "react";
|
||||
import { useCallback, useEffect, useSyncExternalStore } from "react";
|
||||
|
||||
type Theme = "light" | "dark" | "system";
|
||||
|
||||
@@ -28,7 +28,7 @@ function applyTheme(theme: Theme, suppressTransitions = false) {
|
||||
document.documentElement.classList.toggle("dark", isDark);
|
||||
if (suppressTransitions) {
|
||||
// Force a reflow so the no-transitions class takes effect before removal
|
||||
void document.documentElement.offsetHeight;
|
||||
document.documentElement.offsetHeight;
|
||||
requestAnimationFrame(() => {
|
||||
document.documentElement.classList.remove("no-transitions");
|
||||
});
|
||||
@@ -75,11 +75,11 @@ export function useTheme() {
|
||||
const resolvedTheme: "light" | "dark" =
|
||||
theme === "system" ? (getSystemDark() ? "dark" : "light") : theme;
|
||||
|
||||
const setTheme = (next: Theme) => {
|
||||
const setTheme = useCallback((next: Theme) => {
|
||||
localStorage.setItem(STORAGE_KEY, next);
|
||||
applyTheme(next, true);
|
||||
emitChange();
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Keep DOM in sync on mount/change
|
||||
useEffect(() => {
|
||||
|
||||
@@ -88,7 +88,11 @@
|
||||
--secondary: --alpha(var(--color-black) / 4%);
|
||||
--secondary-foreground: var(--color-neutral-800);
|
||||
--muted: --alpha(var(--color-black) / 4%);
|
||||
--muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-black));
|
||||
--muted-foreground: color-mix(
|
||||
in srgb,
|
||||
var(--color-neutral-500) 90%,
|
||||
var(--color-black)
|
||||
);
|
||||
--accent: --alpha(var(--color-black) / 4%);
|
||||
--accent-foreground: var(--color-neutral-800);
|
||||
--destructive: var(--color-red-500);
|
||||
@@ -118,7 +122,11 @@
|
||||
|
||||
@variant dark {
|
||||
color-scheme: dark;
|
||||
--background: color-mix(in srgb, var(--color-neutral-950) 95%, var(--color-white));
|
||||
--background: color-mix(
|
||||
in srgb,
|
||||
var(--color-neutral-950) 95%,
|
||||
var(--color-white)
|
||||
);
|
||||
--foreground: var(--color-neutral-100);
|
||||
--card: color-mix(in srgb, var(--background) 98%, var(--color-white));
|
||||
--card-foreground: var(--color-neutral-100);
|
||||
@@ -129,10 +137,18 @@
|
||||
--secondary: --alpha(var(--color-white) / 4%);
|
||||
--secondary-foreground: var(--color-neutral-100);
|
||||
--muted: --alpha(var(--color-white) / 4%);
|
||||
--muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-white));
|
||||
--muted-foreground: color-mix(
|
||||
in srgb,
|
||||
var(--color-neutral-500) 90%,
|
||||
var(--color-white)
|
||||
);
|
||||
--accent: --alpha(var(--color-white) / 4%);
|
||||
--accent-foreground: var(--color-neutral-100);
|
||||
--destructive: color-mix(in srgb, var(--color-red-500) 90%, var(--color-white));
|
||||
--destructive: color-mix(
|
||||
in srgb,
|
||||
var(--color-red-500) 90%,
|
||||
var(--color-white)
|
||||
);
|
||||
--border: --alpha(var(--color-white) / 6%);
|
||||
--input: --alpha(var(--color-white) / 8%);
|
||||
--ring: var(--color-neutral-500);
|
||||
@@ -271,7 +287,11 @@ label:has(> select#reasoning-effort) select {
|
||||
.chat-markdown a {
|
||||
color: var(--info-foreground);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: color-mix(in srgb, var(--info-foreground) 40%, transparent);
|
||||
text-decoration-color: color-mix(
|
||||
in srgb,
|
||||
var(--info-foreground) 40%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.chat-markdown a:hover {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { DEFAULT_MODEL, resolveModelSlug } from "./model-logic";
|
||||
import { DEFAULT_RUNTIME_MODE, type Project, type RuntimeMode, type Thread } from "./types";
|
||||
import {
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
type Project,
|
||||
type RuntimeMode,
|
||||
type Thread,
|
||||
} from "./types";
|
||||
|
||||
const LEGACY_DEFAULT_MODEL = "gpt-5.2-codex";
|
||||
|
||||
@@ -141,9 +146,13 @@ export function hydratePersistedState(
|
||||
return {
|
||||
projects,
|
||||
threads,
|
||||
activeThreadId: hasActiveThread ? parsedState.data.activeThreadId : (threads[0]?.id ?? null),
|
||||
activeThreadId: hasActiveThread
|
||||
? parsedState.data.activeThreadId
|
||||
: (threads[0]?.id ?? null),
|
||||
runtimeMode:
|
||||
"runtimeMode" in parsedState.data ? parsedState.data.runtimeMode : DEFAULT_RUNTIME_MODE,
|
||||
"runtimeMode" in parsedState.data
|
||||
? parsedState.data.runtimeMode
|
||||
: DEFAULT_RUNTIME_MODE,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ describe("deriveWorkLogEntries", () => {
|
||||
expect(entries[0]?.label).toBe("Tool call");
|
||||
});
|
||||
|
||||
it("logs turn completion with elapsed time", () => {
|
||||
it("does not surface successful turn completion as a work-log row", () => {
|
||||
const entries = deriveWorkLogEntries(
|
||||
[
|
||||
makeEvent({
|
||||
@@ -154,7 +154,38 @@ describe("deriveWorkLogEntries", () => {
|
||||
"turn-1",
|
||||
);
|
||||
|
||||
expect(entries[0]?.label).toBe("Turn complete in 10s");
|
||||
expect(entries).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("shows failed turn completion in the work log", () => {
|
||||
const entries = deriveWorkLogEntries(
|
||||
[
|
||||
makeEvent({
|
||||
id: "evt-start",
|
||||
method: "turn/started",
|
||||
turnId: "turn-1",
|
||||
createdAt: "2026-02-08T10:00:00.000Z",
|
||||
}),
|
||||
makeEvent({
|
||||
id: "evt-complete",
|
||||
method: "turn/completed",
|
||||
turnId: "turn-1",
|
||||
createdAt: "2026-02-08T10:00:10.000Z",
|
||||
payload: {
|
||||
turn: {
|
||||
id: "turn-1",
|
||||
status: "failed",
|
||||
error: { message: "sandbox denied" },
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
"turn-1",
|
||||
);
|
||||
|
||||
expect(entries).toHaveLength(1);
|
||||
expect(entries[0]?.label).toBe("Turn failed");
|
||||
expect(entries[0]?.detail).toBe("sandbox denied");
|
||||
});
|
||||
|
||||
it("hides reasoning and agent-message noise from the visible work log", () => {
|
||||
@@ -229,11 +260,45 @@ describe("deriveWorkLogEntries", () => {
|
||||
"turn-1",
|
||||
);
|
||||
|
||||
expect(entries.map((entry) => entry.label)).toEqual([
|
||||
"Turn complete in 8.0s",
|
||||
"Tool call complete",
|
||||
"Tool call",
|
||||
]);
|
||||
expect(entries.map((entry) => entry.label)).toEqual(["Tool call"]);
|
||||
});
|
||||
|
||||
it("coalesces command start/completed lifecycle into one entry", () => {
|
||||
const entries = deriveWorkLogEntries(
|
||||
[
|
||||
makeEvent({
|
||||
id: "evt-command-start",
|
||||
method: "item/started",
|
||||
turnId: "turn-1",
|
||||
createdAt: "2026-02-08T10:00:01.000Z",
|
||||
payload: {
|
||||
item: {
|
||||
id: "item-command",
|
||||
type: "command_execution",
|
||||
command: "git status --short",
|
||||
},
|
||||
},
|
||||
}),
|
||||
makeEvent({
|
||||
id: "evt-command-complete",
|
||||
method: "item/completed",
|
||||
turnId: "turn-1",
|
||||
createdAt: "2026-02-08T10:00:02.000Z",
|
||||
payload: {
|
||||
item: {
|
||||
id: "item-command",
|
||||
type: "command_execution",
|
||||
command: "git status --short",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
"turn-1",
|
||||
);
|
||||
|
||||
expect(entries).toHaveLength(1);
|
||||
expect(entries[0]?.label).toBe("Command run");
|
||||
expect(entries[0]?.detail).toBe("git status --short");
|
||||
});
|
||||
|
||||
it("preserves full tool-call detail text without data truncation", () => {
|
||||
@@ -257,6 +322,50 @@ describe("deriveWorkLogEntries", () => {
|
||||
expect(entries[0]?.detail).toBe(longCommand);
|
||||
});
|
||||
|
||||
it("hides generic tool-call rows that have no identifying detail", () => {
|
||||
const entries = deriveWorkLogEntries(
|
||||
[
|
||||
makeEvent({
|
||||
id: "evt-tool-start",
|
||||
method: "item/started",
|
||||
turnId: "turn-1",
|
||||
createdAt: "2026-02-08T10:00:05.000Z",
|
||||
payload: {
|
||||
item: { id: "item-tool", type: "tool_call" },
|
||||
},
|
||||
}),
|
||||
],
|
||||
"turn-1",
|
||||
);
|
||||
|
||||
expect(entries).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("includes collab tool-call rows with tool name detail", () => {
|
||||
const entries = deriveWorkLogEntries(
|
||||
[
|
||||
makeEvent({
|
||||
id: "evt-collab-start",
|
||||
method: "item/started",
|
||||
turnId: "turn-1",
|
||||
createdAt: "2026-02-08T10:00:05.000Z",
|
||||
payload: {
|
||||
item: {
|
||||
id: "item-collab",
|
||||
type: "collabAgentToolCall",
|
||||
tool: "spawnAgent",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
"turn-1",
|
||||
);
|
||||
|
||||
expect(entries).toHaveLength(1);
|
||||
expect(entries[0]?.label).toBe("Tool call");
|
||||
expect(entries[0]?.detail).toBe("spawnAgent");
|
||||
});
|
||||
|
||||
it("can derive work-log entries across all turns when not scoped", () => {
|
||||
const entries = deriveWorkLogEntries(
|
||||
[
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ProviderEvent, ProviderKind, ProviderSession } from "@acme/contracts";
|
||||
import type { NativeApi, ProviderEvent, ProviderKind, ProviderSession } from "@acme/contracts";
|
||||
import type { ChatMessage, SessionPhase } from "./types";
|
||||
import { getOrCreateWsNativeApi } from "./wsNativeApi";
|
||||
import { createWsNativeApi } from "./wsNativeApi";
|
||||
|
||||
export const PROVIDER_OPTIONS: Array<{
|
||||
value: ProviderKind;
|
||||
@@ -11,9 +11,21 @@ export const PROVIDER_OPTIONS: Array<{
|
||||
{ value: "claudeCode", label: "Claude Code (soon)", available: false },
|
||||
];
|
||||
|
||||
export function readNativeApi() {
|
||||
let cachedApi: NativeApi | undefined;
|
||||
|
||||
export function readNativeApi(): NativeApi | undefined {
|
||||
if (typeof window === "undefined") return undefined;
|
||||
return window.nativeApi ?? getOrCreateWsNativeApi();
|
||||
if (cachedApi) return cachedApi;
|
||||
|
||||
// Prefer Electron preload bridge if available
|
||||
if (window.nativeApi) {
|
||||
cachedApi = window.nativeApi;
|
||||
return cachedApi;
|
||||
}
|
||||
|
||||
// Fall back to WebSocket transport
|
||||
cachedApi = createWsNativeApi();
|
||||
return cachedApi;
|
||||
}
|
||||
|
||||
export function asObject(value: unknown): Record<string, unknown> | undefined {
|
||||
@@ -97,7 +109,11 @@ function normalizeItemType(raw: string | undefined): string {
|
||||
}
|
||||
|
||||
function shouldDropItemType(type: string): boolean {
|
||||
if (type.includes("preamble") || type.includes("reasoning") || type.includes("thought")) {
|
||||
if (
|
||||
type.includes("preamble") ||
|
||||
type.includes("reasoning") ||
|
||||
type.includes("thought")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -105,7 +121,11 @@ function shouldDropItemType(type: string): boolean {
|
||||
}
|
||||
|
||||
function shouldShowItemLifecycle(type: string): boolean {
|
||||
return type.includes("tool") || type.includes("command") || type.includes("file change");
|
||||
return (
|
||||
type.includes("tool") ||
|
||||
type.includes("command") ||
|
||||
type.includes("file change")
|
||||
);
|
||||
}
|
||||
|
||||
function shouldDropMethod(method: string): boolean {
|
||||
@@ -128,15 +148,28 @@ function itemTypeMeta(type: string): {
|
||||
return { label: "Work item", tone: "info" };
|
||||
}
|
||||
|
||||
interface ItemLifecycleCandidate {
|
||||
id: string;
|
||||
itemId?: string;
|
||||
createdAt: string;
|
||||
label: string;
|
||||
detail?: string;
|
||||
tone: WorkLogEntry["tone"];
|
||||
phase: "started" | "completed";
|
||||
}
|
||||
|
||||
function extractDetail(
|
||||
payload: Record<string, unknown> | undefined,
|
||||
item: Record<string, unknown> | undefined,
|
||||
): string | undefined {
|
||||
const candidates = [
|
||||
asString(item?.command),
|
||||
asString(item?.tool),
|
||||
asString(item?.name),
|
||||
asString(item?.title),
|
||||
asString(item?.summary),
|
||||
asString(item?.text),
|
||||
asString(item?.command),
|
||||
asString(item?.prompt),
|
||||
asString(payload?.message),
|
||||
asString(payload?.prompt),
|
||||
asString(payload?.command),
|
||||
@@ -149,7 +182,9 @@ function extractDetail(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function entryFromItemLifecycle(event: ProviderEvent): WorkLogEntry | null {
|
||||
function lifecycleCandidateFromItemEvent(
|
||||
event: ProviderEvent,
|
||||
): ItemLifecycleCandidate | null {
|
||||
const payload = asObject(event.payload);
|
||||
const item = asObject(payload?.item);
|
||||
const normalizedType = normalizeItemType(asString(item?.type));
|
||||
@@ -167,14 +202,16 @@ function entryFromItemLifecycle(event: ProviderEvent): WorkLogEntry | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
const label = isCompleted ? `${meta.label} complete` : meta.label;
|
||||
const detail = extractDetail(payload, item);
|
||||
const itemId = event.itemId ?? asString(item?.id);
|
||||
return {
|
||||
id: event.id,
|
||||
...(itemId ? { itemId } : {}),
|
||||
createdAt: event.createdAt,
|
||||
label,
|
||||
label: meta.label,
|
||||
...(detail ? { detail } : {}),
|
||||
tone: meta.tone,
|
||||
phase: isCompleted ? "completed" : "started",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -217,7 +254,7 @@ function entryFromRequest(event: ProviderEvent): WorkLogEntry | null {
|
||||
};
|
||||
}
|
||||
|
||||
function entryFromNotification(event: ProviderEvent, turnStartedAt: number): WorkLogEntry | null {
|
||||
function entryFromNotification(event: ProviderEvent): WorkLogEntry | null {
|
||||
if (event.kind !== "notification") return null;
|
||||
if (shouldDropMethod(event.method)) return null;
|
||||
if (event.method === "item/agentMessage/delta") return null;
|
||||
@@ -230,32 +267,22 @@ function entryFromNotification(event: ProviderEvent, turnStartedAt: number): Wor
|
||||
const payload = asObject(event.payload);
|
||||
const turn = asObject(payload?.turn);
|
||||
const status = asString(turn?.status);
|
||||
if (status !== "failed") {
|
||||
return null;
|
||||
}
|
||||
const turnError = asObject(turn?.error);
|
||||
const turnErrorMessage = asString(turnError?.message);
|
||||
const turnErrorDetail = normalizeDetail(turnErrorMessage);
|
||||
const eventAt = Date.parse(event.createdAt);
|
||||
const durationMs =
|
||||
Number.isNaN(turnStartedAt) || Number.isNaN(eventAt) || eventAt < turnStartedAt
|
||||
? undefined
|
||||
: eventAt - turnStartedAt;
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
createdAt: event.createdAt,
|
||||
label:
|
||||
status === "failed"
|
||||
? "Turn failed"
|
||||
: durationMs !== undefined
|
||||
? `Turn complete in ${formatDuration(durationMs)}`
|
||||
: "Turn complete",
|
||||
label: "Turn failed",
|
||||
...(turnErrorDetail ? { detail: turnErrorDetail } : {}),
|
||||
tone: status === "failed" ? "error" : "info",
|
||||
tone: "error",
|
||||
};
|
||||
}
|
||||
|
||||
const lifecycleEntry = entryFromItemLifecycle(event);
|
||||
if (lifecycleEntry) return lifecycleEntry;
|
||||
|
||||
if (event.method.startsWith("item/")) return null;
|
||||
|
||||
return null;
|
||||
@@ -295,19 +322,61 @@ export function deriveWorkLogEntries(
|
||||
: undefined;
|
||||
const turnStartedAt = turnStartedAtIso ? Date.parse(turnStartedAtIso) : Number.NaN;
|
||||
|
||||
const shouldIncludeEvent = (event: ProviderEvent): boolean => {
|
||||
if (!turnId) return true;
|
||||
const scopedTurnId = eventTurnId(event);
|
||||
if (scopedTurnId && scopedTurnId !== turnId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!scopedTurnId && !Number.isNaN(turnStartedAt)) {
|
||||
const eventAt = Date.parse(event.createdAt);
|
||||
if (!Number.isNaN(eventAt) && eventAt < turnStartedAt) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const completedLifecycleItemIds = new Set<string>();
|
||||
for (const event of ordered) {
|
||||
if (turnId) {
|
||||
const scopedTurnId = eventTurnId(event);
|
||||
if (scopedTurnId && scopedTurnId !== turnId) {
|
||||
if (!shouldIncludeEvent(event)) continue;
|
||||
const candidate = lifecycleCandidateFromItemEvent(event);
|
||||
if (candidate?.phase === "completed" && candidate.itemId) {
|
||||
completedLifecycleItemIds.add(candidate.itemId);
|
||||
}
|
||||
}
|
||||
|
||||
for (const event of ordered) {
|
||||
if (!shouldIncludeEvent(event)) continue;
|
||||
|
||||
const lifecycleCandidate = lifecycleCandidateFromItemEvent(event);
|
||||
if (lifecycleCandidate) {
|
||||
if (
|
||||
lifecycleCandidate.phase === "started" &&
|
||||
lifecycleCandidate.itemId &&
|
||||
completedLifecycleItemIds.has(lifecycleCandidate.itemId)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
lifecycleCandidate.label === "Tool call" &&
|
||||
!lifecycleCandidate.detail
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!scopedTurnId && !Number.isNaN(turnStartedAt)) {
|
||||
const eventAt = Date.parse(event.createdAt);
|
||||
if (!Number.isNaN(eventAt) && eventAt < turnStartedAt) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
entries.push({
|
||||
id: lifecycleCandidate.id,
|
||||
createdAt: lifecycleCandidate.createdAt,
|
||||
label: lifecycleCandidate.label,
|
||||
...(lifecycleCandidate.detail
|
||||
? { detail: lifecycleCandidate.detail }
|
||||
: {}),
|
||||
tone: lifecycleCandidate.tone,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
const fromRequest = entryFromRequest(event);
|
||||
@@ -316,7 +385,7 @@ export function deriveWorkLogEntries(
|
||||
continue;
|
||||
}
|
||||
|
||||
const fromNotification = entryFromNotification(event, turnStartedAt);
|
||||
const fromNotification = entryFromNotification(event);
|
||||
if (fromNotification) {
|
||||
entries.push(fromNotification);
|
||||
continue;
|
||||
|
||||
@@ -58,82 +58,10 @@ function makeState(thread: Thread): AppState {
|
||||
activeThreadId: thread.id,
|
||||
runtimeMode: "full-access",
|
||||
diffOpen: false,
|
||||
runtimeError: null,
|
||||
};
|
||||
}
|
||||
|
||||
describe("store reducer thread continuity", () => {
|
||||
it("bootstraps project and active thread from runtime response", () => {
|
||||
const state: AppState = {
|
||||
projects: [],
|
||||
threads: [],
|
||||
activeThreadId: null,
|
||||
runtimeMode: "full-access",
|
||||
diffOpen: false,
|
||||
runtimeError: null,
|
||||
};
|
||||
const session = makeSession({
|
||||
sessionId: "sess-bootstrap",
|
||||
threadId: "thr-bootstrap",
|
||||
});
|
||||
|
||||
const next = reducer(state, {
|
||||
type: "BOOTSTRAP_FROM_SERVER",
|
||||
bootstrap: {
|
||||
launchCwd: "/workspace",
|
||||
projectName: "workspace",
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
session,
|
||||
},
|
||||
});
|
||||
|
||||
expect(next.projects).toHaveLength(1);
|
||||
expect(next.projects[0]?.cwd).toBe("/workspace");
|
||||
expect(next.threads).toHaveLength(1);
|
||||
expect(next.threads[0]?.session?.sessionId).toBe("sess-bootstrap");
|
||||
expect(next.activeThreadId).toBe(next.threads[0]?.id ?? null);
|
||||
});
|
||||
|
||||
it("surfaces bootstrap errors on the active thread", () => {
|
||||
const state: AppState = {
|
||||
projects: [],
|
||||
threads: [],
|
||||
activeThreadId: null,
|
||||
runtimeMode: "full-access",
|
||||
diffOpen: false,
|
||||
runtimeError: null,
|
||||
};
|
||||
|
||||
const next = reducer(state, {
|
||||
type: "BOOTSTRAP_FROM_SERVER",
|
||||
bootstrap: {
|
||||
launchCwd: "/workspace",
|
||||
projectName: "workspace",
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
session: makeSession({
|
||||
sessionId: "sess-bootstrap-error",
|
||||
status: "error",
|
||||
}),
|
||||
bootstrapError: "Timed out waiting for initialize.",
|
||||
},
|
||||
});
|
||||
|
||||
expect(next.threads[0]?.error).toBe("Timed out waiting for initialize.");
|
||||
});
|
||||
|
||||
it("stores runtime connection errors separately from thread errors", () => {
|
||||
const state = makeState(makeThread());
|
||||
const next = reducer(state, {
|
||||
type: "SET_RUNTIME_ERROR",
|
||||
error: "Connection refused",
|
||||
});
|
||||
|
||||
expect(next.runtimeError).toBe("Connection refused");
|
||||
expect(next.threads[0]?.error).toBeNull();
|
||||
});
|
||||
|
||||
it("stores codexThreadId from UPDATE_SESSION", () => {
|
||||
const state = makeState(
|
||||
makeThread({
|
||||
@@ -163,7 +91,7 @@ describe("store reducer thread continuity", () => {
|
||||
expect(next.threads[0]?.codexThreadId).toBe("thr_backfilled");
|
||||
});
|
||||
|
||||
it("surfaces thread id mismatches without overwriting stored identity", () => {
|
||||
it("ignores events from a foreign thread within the same session", () => {
|
||||
const state = makeState(makeThread({ codexThreadId: "thr_expected" }));
|
||||
const next = reducer(state, {
|
||||
type: "APPLY_EVENT",
|
||||
@@ -175,7 +103,86 @@ describe("store reducer thread continuity", () => {
|
||||
activeAssistantItemRef: { current: null },
|
||||
});
|
||||
|
||||
expect(next.threads[0]?.codexThreadId).toBe("thr_expected");
|
||||
expect(next.threads[0]?.error).toContain("Thread identity mismatch");
|
||||
expect(next).toBe(state);
|
||||
});
|
||||
|
||||
it("rebases thread identity on thread/started during connect", () => {
|
||||
const state = makeState(
|
||||
makeThread({
|
||||
codexThreadId: "thr_old",
|
||||
session: makeSession({
|
||||
status: "connecting",
|
||||
threadId: "thr_old",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const next = reducer(state, {
|
||||
type: "APPLY_EVENT",
|
||||
event: makeEvent({
|
||||
method: "thread/started",
|
||||
threadId: "thr_new",
|
||||
payload: { thread: { id: "thr_new" } },
|
||||
}),
|
||||
activeAssistantItemRef: { current: null },
|
||||
});
|
||||
|
||||
expect(next.threads[0]?.codexThreadId).toBe("thr_new");
|
||||
expect(next.threads[0]?.session?.threadId).toBe("thr_new");
|
||||
});
|
||||
|
||||
it("reconciles project ids by cwd when syncing backend projects", () => {
|
||||
const state: AppState = {
|
||||
projects: [
|
||||
{
|
||||
id: "project-old-a",
|
||||
name: "A",
|
||||
cwd: "/tmp/a",
|
||||
model: "gpt-5.3-codex",
|
||||
expanded: false,
|
||||
},
|
||||
{
|
||||
id: "project-old-b",
|
||||
name: "B",
|
||||
cwd: "/tmp/b",
|
||||
model: "gpt-5.3-codex",
|
||||
expanded: true,
|
||||
},
|
||||
],
|
||||
threads: [
|
||||
makeThread({
|
||||
id: "thread-a",
|
||||
projectId: "project-old-a",
|
||||
}),
|
||||
makeThread({
|
||||
id: "thread-b",
|
||||
projectId: "project-old-b",
|
||||
}),
|
||||
],
|
||||
activeThreadId: "thread-b",
|
||||
runtimeMode: "full-access",
|
||||
diffOpen: false,
|
||||
};
|
||||
|
||||
const next = reducer(state, {
|
||||
type: "SYNC_PROJECTS",
|
||||
projects: [
|
||||
{
|
||||
id: "project-new-a",
|
||||
name: "A",
|
||||
cwd: "/tmp/a",
|
||||
model: "gpt-5.3-codex",
|
||||
expanded: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(next.projects).toHaveLength(1);
|
||||
expect(next.projects[0]?.id).toBe("project-new-a");
|
||||
// Preserve existing project UI preferences by cwd
|
||||
expect(next.projects[0]?.expanded).toBe(false);
|
||||
expect(next.threads).toHaveLength(1);
|
||||
expect(next.threads[0]?.id).toBe("thread-a");
|
||||
expect(next.threads[0]?.projectId).toBe("project-new-a");
|
||||
expect(next.activeThreadId).toBe("thread-a");
|
||||
});
|
||||
});
|
||||
+84
-94
@@ -8,7 +8,7 @@ import {
|
||||
useReducer,
|
||||
} from "react";
|
||||
|
||||
import type { AppBootstrapResult, ProviderEvent, ProviderSession } from "@acme/contracts";
|
||||
import type { ProviderEvent, ProviderSession } from "@acme/contracts";
|
||||
import { resolveModelSlug } from "./model-logic";
|
||||
import { hydratePersistedState, toPersistedState } from "./persistenceSchema";
|
||||
import { applyEventToMessages, asObject, asString, evolveSession } from "./session-logic";
|
||||
@@ -18,6 +18,7 @@ import { DEFAULT_RUNTIME_MODE, type Project, type RuntimeMode, type Thread } fro
|
||||
|
||||
type Action =
|
||||
| { type: "ADD_PROJECT"; project: Project }
|
||||
| { type: "SYNC_PROJECTS"; projects: Project[] }
|
||||
| { type: "TOGGLE_PROJECT"; projectId: string }
|
||||
| { type: "ADD_THREAD"; thread: Thread }
|
||||
| { type: "SET_ACTIVE_THREAD"; threadId: string }
|
||||
@@ -32,9 +33,7 @@ type Action =
|
||||
| { type: "SET_ERROR"; threadId: string; error: string | null }
|
||||
| { type: "SET_THREAD_TITLE"; threadId: string; title: string }
|
||||
| { type: "SET_THREAD_MODEL"; threadId: string; model: string }
|
||||
| { type: "SET_RUNTIME_MODE"; mode: RuntimeMode }
|
||||
| { type: "SET_RUNTIME_ERROR"; error: string | null }
|
||||
| { type: "BOOTSTRAP_FROM_SERVER"; bootstrap: AppBootstrapResult };
|
||||
| { type: "SET_RUNTIME_MODE"; mode: RuntimeMode };
|
||||
|
||||
// ── State ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -44,7 +43,6 @@ export interface AppState {
|
||||
activeThreadId: string | null;
|
||||
runtimeMode: RuntimeMode;
|
||||
diffOpen: boolean;
|
||||
runtimeError: string | null;
|
||||
}
|
||||
|
||||
const PERSISTED_STATE_KEY = "codething:renderer-state:v4";
|
||||
@@ -60,7 +58,6 @@ const initialState: AppState = {
|
||||
activeThreadId: null,
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
diffOpen: false,
|
||||
runtimeError: null,
|
||||
};
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────
|
||||
@@ -82,7 +79,7 @@ function readPersistedState(): AppState {
|
||||
);
|
||||
if (!hydrated) return initialState;
|
||||
|
||||
return { ...hydrated, diffOpen: false, runtimeError: null };
|
||||
return { ...hydrated, diffOpen: false };
|
||||
} catch {
|
||||
return initialState;
|
||||
}
|
||||
@@ -123,7 +120,34 @@ function getEventTurnId(event: ProviderEvent): string | undefined {
|
||||
function getEventThreadId(event: ProviderEvent): string | undefined {
|
||||
if (event.threadId) return event.threadId;
|
||||
const payload = asObject(event.payload);
|
||||
return asString(payload?.threadId) ?? asString(asObject(payload?.thread)?.id);
|
||||
const payloadThread = asObject(payload?.thread);
|
||||
const payloadMessage = asObject(payload?.msg);
|
||||
return (
|
||||
asString(payload?.threadId) ??
|
||||
asString(payloadThread?.id) ??
|
||||
asString(payload?.conversationId) ??
|
||||
asString(payload?.thread_id) ??
|
||||
asString(payloadMessage?.thread_id)
|
||||
);
|
||||
}
|
||||
|
||||
function shouldIgnoreForeignThreadEvent(thread: Thread, event: ProviderEvent): boolean {
|
||||
const eventThreadId = getEventThreadId(event);
|
||||
if (!eventThreadId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const expectedThreadId = thread.session?.threadId ?? thread.codexThreadId;
|
||||
if (!expectedThreadId || eventThreadId === expectedThreadId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// During connect, accept a thread/started notification as an identity rebind.
|
||||
if (event.method === "thread/started" && thread.session?.status === "connecting") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function durationMs(startIso: string, endIso: string): number | undefined {
|
||||
@@ -170,6 +194,9 @@ function updateTurnFields(thread: Thread, event: ProviderEvent): Partial<Thread>
|
||||
export function reducer(state: AppState, action: Action): AppState {
|
||||
switch (action.type) {
|
||||
case "ADD_PROJECT":
|
||||
if (state.projects.some((project) => project.cwd === action.project.cwd)) {
|
||||
return state;
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
projects: [
|
||||
@@ -181,6 +208,48 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
],
|
||||
};
|
||||
|
||||
case "SYNC_PROJECTS": {
|
||||
const previousByCwd = new Map(
|
||||
state.projects.map((project) => [project.cwd, project] as const),
|
||||
);
|
||||
const nextProjects = action.projects.map((project) => {
|
||||
const previous = previousByCwd.get(project.cwd);
|
||||
return {
|
||||
...project,
|
||||
model: resolveModelSlug(previous?.model ?? project.model),
|
||||
expanded: previous?.expanded ?? project.expanded,
|
||||
};
|
||||
});
|
||||
const previousProjectById = new Map(
|
||||
state.projects.map((project) => [project.id, project] as const),
|
||||
);
|
||||
const nextProjectIdByCwd = new Map(
|
||||
nextProjects.map((project) => [project.cwd, project.id] as const),
|
||||
);
|
||||
const nextThreads = state.threads
|
||||
.map((thread) => {
|
||||
const previousProject = previousProjectById.get(thread.projectId);
|
||||
if (!previousProject) return null;
|
||||
const mappedProjectId = nextProjectIdByCwd.get(previousProject.cwd);
|
||||
if (!mappedProjectId) return null;
|
||||
return {
|
||||
...thread,
|
||||
projectId: mappedProjectId,
|
||||
};
|
||||
})
|
||||
.filter((thread): thread is Thread => thread !== null);
|
||||
const activeThreadId = nextThreads.some((thread) => thread.id === state.activeThreadId)
|
||||
? state.activeThreadId
|
||||
: (nextThreads[0]?.id ?? null);
|
||||
|
||||
return {
|
||||
...state,
|
||||
projects: nextProjects,
|
||||
threads: nextThreads,
|
||||
activeThreadId,
|
||||
};
|
||||
}
|
||||
|
||||
case "TOGGLE_PROJECT":
|
||||
return {
|
||||
...state,
|
||||
@@ -212,6 +281,7 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
const { event, activeAssistantItemRef } = action;
|
||||
const target = findThreadBySessionId(state.threads, event.sessionId);
|
||||
if (!target) return state;
|
||||
if (shouldIgnoreForeignThreadEvent(target, event)) return state;
|
||||
|
||||
return {
|
||||
...state,
|
||||
@@ -219,18 +289,13 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
...t,
|
||||
...(() => {
|
||||
const eventThreadId = getEventThreadId(event);
|
||||
const hasThreadMismatch =
|
||||
t.codexThreadId !== null &&
|
||||
eventThreadId !== undefined &&
|
||||
eventThreadId !== t.codexThreadId;
|
||||
const threadMismatchError = hasThreadMismatch
|
||||
? `Thread identity mismatch: expected ${t.codexThreadId}, received ${eventThreadId}.`
|
||||
: null;
|
||||
const shouldRebindIdentity =
|
||||
event.method === "thread/started" && t.session?.status === "connecting";
|
||||
return {
|
||||
codexThreadId: t.codexThreadId ?? eventThreadId ?? null,
|
||||
error:
|
||||
threadMismatchError ??
|
||||
(event.kind === "error" && event.message ? event.message : t.error),
|
||||
codexThreadId: shouldRebindIdentity
|
||||
? (eventThreadId ?? t.codexThreadId)
|
||||
: (t.codexThreadId ?? eventThreadId ?? null),
|
||||
error: event.kind === "error" && event.message ? event.message : t.error,
|
||||
};
|
||||
})(),
|
||||
session: t.session ? evolveSession(t.session, event) : t.session,
|
||||
@@ -308,81 +373,6 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
runtimeMode: action.mode,
|
||||
};
|
||||
|
||||
case "SET_RUNTIME_ERROR":
|
||||
return {
|
||||
...state,
|
||||
runtimeError: action.error,
|
||||
};
|
||||
|
||||
case "BOOTSTRAP_FROM_SERVER": {
|
||||
const { bootstrap } = action;
|
||||
const existingProject = state.projects.find((project) => project.cwd === bootstrap.launchCwd);
|
||||
const projectId = existingProject?.id ?? crypto.randomUUID();
|
||||
const project =
|
||||
existingProject ??
|
||||
({
|
||||
id: projectId,
|
||||
name: bootstrap.projectName,
|
||||
cwd: bootstrap.launchCwd,
|
||||
model: resolveModelSlug(bootstrap.model),
|
||||
expanded: true,
|
||||
} satisfies Project);
|
||||
|
||||
const projectThreads = state.threads.filter((thread) => thread.projectId === projectId);
|
||||
const existingThread =
|
||||
state.threads.find((thread) => thread.session?.sessionId === bootstrap.session.sessionId) ??
|
||||
projectThreads.find(
|
||||
(thread) =>
|
||||
bootstrap.session.threadId !== undefined &&
|
||||
thread.codexThreadId === bootstrap.session.threadId,
|
||||
) ??
|
||||
projectThreads[0];
|
||||
|
||||
const activeThreadId = existingThread?.id ?? crypto.randomUUID();
|
||||
const thread =
|
||||
existingThread ??
|
||||
({
|
||||
id: activeThreadId,
|
||||
codexThreadId: bootstrap.session.threadId ?? null,
|
||||
projectId,
|
||||
title: "New thread",
|
||||
model: resolveModelSlug(bootstrap.model),
|
||||
session: bootstrap.session,
|
||||
messages: [],
|
||||
events: [],
|
||||
error: bootstrap.bootstrapError ?? null,
|
||||
createdAt: new Date().toISOString(),
|
||||
} satisfies Thread);
|
||||
|
||||
return {
|
||||
...state,
|
||||
projects: existingProject
|
||||
? state.projects.map((entry) =>
|
||||
entry.id === existingProject.id
|
||||
? {
|
||||
...entry,
|
||||
model: resolveModelSlug(bootstrap.model),
|
||||
}
|
||||
: entry,
|
||||
)
|
||||
: [project, ...state.projects],
|
||||
threads: state.threads
|
||||
.map((entry) =>
|
||||
entry.id === thread.id
|
||||
? {
|
||||
...entry,
|
||||
session: bootstrap.session,
|
||||
codexThreadId: bootstrap.session.threadId ?? entry.codexThreadId,
|
||||
error: bootstrap.bootstrapError ?? entry.error,
|
||||
}
|
||||
: entry,
|
||||
)
|
||||
.concat(existingThread ? [] : [thread]),
|
||||
activeThreadId,
|
||||
runtimeError: null,
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Vendored
+6
@@ -2,8 +2,14 @@
|
||||
|
||||
import type { NativeApi } from "@acme/contracts";
|
||||
|
||||
interface DesktopBridge {
|
||||
getWsUrl: () => string | null;
|
||||
pickFolder: () => Promise<string | null>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
nativeApi?: NativeApi;
|
||||
desktopBridge?: DesktopBridge;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,525 +1,102 @@
|
||||
import type {
|
||||
AgentExit,
|
||||
NativeApi,
|
||||
OutputChunk,
|
||||
ProviderEvent,
|
||||
WsNativeApiMethod,
|
||||
WsClientMessage,
|
||||
WsEventMessage,
|
||||
WsResponseMessage,
|
||||
} from "@acme/contracts";
|
||||
import {
|
||||
WS_CLOSE_CODES,
|
||||
WS_CLOSE_REASONS,
|
||||
WS_EVENT_CHANNELS,
|
||||
agentSessionIdSchema,
|
||||
appBootstrapResultSchema,
|
||||
appHealthResultSchema,
|
||||
dialogsPickFolderResultSchema,
|
||||
providerSessionListSchema,
|
||||
providerSessionSchema,
|
||||
providerTurnStartResultSchema,
|
||||
terminalCommandResultSchema,
|
||||
todoListSchema,
|
||||
wsServerMessageSchema,
|
||||
} from "@acme/contracts";
|
||||
import { type NativeApi, WS_CHANNELS, WS_METHODS, type WsWelcomePayload } from "@acme/contracts";
|
||||
|
||||
type PendingRequest = {
|
||||
resolve: (value: unknown) => void;
|
||||
reject: (error: Error) => void;
|
||||
timeout: ReturnType<typeof setTimeout>;
|
||||
};
|
||||
import { WsTransport } from "./wsTransport";
|
||||
|
||||
type SubscriptionSet<TValue> = Set<(value: TValue) => void>;
|
||||
type SafeParseResult<TValue> = { success: true; data: TValue } | { success: false };
|
||||
type SchemaLike<TValue> = {
|
||||
safeParse: (value: unknown) => SafeParseResult<TValue>;
|
||||
};
|
||||
const REQUEST_TIMEOUT_MS = 30_000;
|
||||
const MAX_NESTED_ERROR_EXTRACTION_DEPTH = 8;
|
||||
const textDecoder = new TextDecoder();
|
||||
let instance: { api: NativeApi; transport: WsTransport } | null = null;
|
||||
const welcomeListeners = new Set<(payload: WsWelcomePayload) => void>();
|
||||
let lastWelcome: WsWelcomePayload | null = null;
|
||||
|
||||
function closeDetailsFromEvent(event: unknown) {
|
||||
const code = (event as { code?: unknown } | null)?.code;
|
||||
const reason = (event as { reason?: unknown } | null)?.reason;
|
||||
return {
|
||||
code: normalizeCloseCode(code),
|
||||
reason: normalizeNonEmptyString(reason),
|
||||
/**
|
||||
* Subscribe to the server welcome message. If a welcome was already received
|
||||
* before this call, the listener fires synchronously with the cached payload.
|
||||
* This avoids the race between WebSocket connect and React effect registration.
|
||||
*/
|
||||
export function onServerWelcome(listener: (payload: WsWelcomePayload) => void): () => void {
|
||||
welcomeListeners.add(listener);
|
||||
|
||||
// Replay cached welcome for late subscribers
|
||||
if (lastWelcome) {
|
||||
try {
|
||||
listener(lastWelcome);
|
||||
} catch {
|
||||
// Swallow listener errors
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
welcomeListeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
function runtimeConnectErrorFromClose(event: unknown) {
|
||||
const { code, reason } = closeDetailsFromEvent(event);
|
||||
if (code === WS_CLOSE_CODES.unauthorized || reason === WS_CLOSE_REASONS.unauthorized) {
|
||||
return new Error("Failed to connect to local t3 runtime: unauthorized websocket connection.");
|
||||
}
|
||||
if (
|
||||
code === WS_CLOSE_CODES.replacedByNewClient ||
|
||||
reason === WS_CLOSE_REASONS.replacedByNewClient
|
||||
) {
|
||||
return new Error(
|
||||
"Failed to connect to local t3 runtime: replaced by a newer websocket client.",
|
||||
);
|
||||
}
|
||||
if (code === null && (!reason || reason.length === 0)) {
|
||||
return new Error("Failed to connect to local t3 runtime.");
|
||||
}
|
||||
if (code === null) {
|
||||
return new Error(`Failed to connect to local t3 runtime (close reason: ${reason}).`);
|
||||
}
|
||||
if (!reason || reason.length === 0) {
|
||||
return new Error(`Failed to connect to local t3 runtime (close code ${code}).`);
|
||||
}
|
||||
return new Error(`Failed to connect to local t3 runtime (close code ${code}: ${reason}).`);
|
||||
}
|
||||
export function createWsNativeApi(): NativeApi {
|
||||
if (instance) return instance.api;
|
||||
|
||||
function requestDisconnectError(id: string, event: unknown) {
|
||||
const { code, reason } = closeDetailsFromEvent(event);
|
||||
if (code === WS_CLOSE_CODES.unauthorized || reason === WS_CLOSE_REASONS.unauthorized) {
|
||||
return new Error(`Request ${id} failed: websocket disconnected (unauthorized).`);
|
||||
}
|
||||
if (
|
||||
code === WS_CLOSE_CODES.replacedByNewClient ||
|
||||
reason === WS_CLOSE_REASONS.replacedByNewClient
|
||||
) {
|
||||
return new Error(`Request ${id} failed: websocket disconnected (replaced-by-new-client).`);
|
||||
}
|
||||
if (code === null && (!reason || reason.length === 0)) {
|
||||
return new Error(`Request ${id} failed: websocket disconnected.`);
|
||||
}
|
||||
if (code === null) {
|
||||
return new Error(`Request ${id} failed: websocket disconnected (reason: ${reason}).`);
|
||||
}
|
||||
if (!reason || reason.length === 0) {
|
||||
return new Error(`Request ${id} failed: websocket disconnected (code ${code}).`);
|
||||
}
|
||||
return new Error(`Request ${id} failed: websocket disconnected (code ${code}: ${reason}).`);
|
||||
}
|
||||
const transport = new WsTransport();
|
||||
|
||||
function requestSocketError(id: string, event: unknown) {
|
||||
const message = socketErrorMessage(event);
|
||||
if (typeof message === "string" && message.length > 0) {
|
||||
return new Error(`Request ${id} failed: websocket errored (${message}).`);
|
||||
}
|
||||
return new Error(`Request ${id} failed: websocket errored.`);
|
||||
}
|
||||
|
||||
function runtimeConnectErrorFromSocketError(event: unknown) {
|
||||
const message = socketErrorMessage(event);
|
||||
if (typeof message === "string" && message.length > 0) {
|
||||
return new Error(`Failed to connect to local t3 runtime: websocket error (${message}).`);
|
||||
}
|
||||
return new Error("Failed to connect to local t3 runtime.");
|
||||
}
|
||||
|
||||
function runtimeConnectErrorFromConstructionError(error: unknown) {
|
||||
const message = messageFromUnknown(error);
|
||||
if (message) {
|
||||
return new Error(`Failed to connect to local t3 runtime: websocket error (${message}).`);
|
||||
}
|
||||
return new Error("Failed to connect to local t3 runtime.");
|
||||
}
|
||||
|
||||
function socketErrorMessage(event: unknown) {
|
||||
return messageFromUnknown(event);
|
||||
}
|
||||
|
||||
function messageFromUnknown(value: unknown, depth = 0): string | null {
|
||||
if (depth > MAX_NESTED_ERROR_EXTRACTION_DEPTH) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const direct = normalizeNonEmptyString(value);
|
||||
if (direct) {
|
||||
return direct;
|
||||
}
|
||||
|
||||
const message = normalizeNonEmptyString((value as { message?: unknown } | null)?.message);
|
||||
if (message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
const nestedErrorMessage = messageFromUnknown(
|
||||
(value as { error?: unknown } | null)?.error,
|
||||
depth + 1,
|
||||
);
|
||||
if (nestedErrorMessage) {
|
||||
return nestedErrorMessage;
|
||||
}
|
||||
|
||||
return messageFromUnknown((value as { cause?: unknown } | null)?.cause, depth + 1);
|
||||
}
|
||||
|
||||
function normalizeNonEmptyString(value: unknown) {
|
||||
if (typeof value !== "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const normalized = value.trim();
|
||||
if (normalized.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function normalizeCloseCode(value: unknown) {
|
||||
if (typeof value !== "number" || !Number.isInteger(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
class WsNativeApiClient {
|
||||
private socket: WebSocket | null = null;
|
||||
private connectPromise: Promise<WebSocket> | null = null;
|
||||
private nextRequestId = 1;
|
||||
private pending = new Map<string, PendingRequest>();
|
||||
private providerEventListeners: SubscriptionSet<ProviderEvent> = new Set();
|
||||
private agentOutputListeners: SubscriptionSet<OutputChunk> = new Set();
|
||||
private agentExitListeners: SubscriptionSet<AgentExit> = new Set();
|
||||
|
||||
constructor(private readonly wsUrl: string) {}
|
||||
|
||||
private rejectPendingRequests(errorForRequest: (id: string) => Error) {
|
||||
for (const [id, pending] of this.pending.entries()) {
|
||||
clearTimeout(pending.timeout);
|
||||
pending.reject(errorForRequest(id));
|
||||
}
|
||||
this.pending.clear();
|
||||
}
|
||||
|
||||
private connect() {
|
||||
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
||||
return Promise.resolve(this.socket);
|
||||
}
|
||||
|
||||
if (this.connectPromise) {
|
||||
return this.connectPromise;
|
||||
}
|
||||
|
||||
const connectAttempt = new Promise<WebSocket>((resolve, reject) => {
|
||||
let socket: WebSocket;
|
||||
// Listen for server welcome and forward to registered listeners.
|
||||
// Also cache it so late subscribers (React effects) get it immediately.
|
||||
transport.subscribe(WS_CHANNELS.serverWelcome, (data) => {
|
||||
const payload = data as WsWelcomePayload;
|
||||
lastWelcome = payload;
|
||||
for (const listener of welcomeListeners) {
|
||||
try {
|
||||
socket = new WebSocket(this.wsUrl);
|
||||
} catch (error) {
|
||||
reject(runtimeConnectErrorFromConstructionError(error));
|
||||
return;
|
||||
}
|
||||
socket.binaryType = "arraybuffer";
|
||||
this.socket = socket;
|
||||
let hasOpened = false;
|
||||
let connectionSettled = false;
|
||||
const rejectConnection = (error?: Error) => {
|
||||
if (connectionSettled) {
|
||||
return;
|
||||
}
|
||||
connectionSettled = true;
|
||||
this.connectPromise = null;
|
||||
reject(error ?? new Error("Failed to connect to local t3 runtime."));
|
||||
};
|
||||
const resolveConnection = () => {
|
||||
if (connectionSettled) {
|
||||
return;
|
||||
}
|
||||
connectionSettled = true;
|
||||
this.connectPromise = null;
|
||||
resolve(socket);
|
||||
};
|
||||
|
||||
socket.addEventListener("open", () => {
|
||||
hasOpened = true;
|
||||
resolveConnection();
|
||||
});
|
||||
|
||||
socket.addEventListener("error", (event) => {
|
||||
if (this.socket !== socket) {
|
||||
if (!hasOpened) {
|
||||
rejectConnection(runtimeConnectErrorFromSocketError(event));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasOpened) {
|
||||
rejectConnection(runtimeConnectErrorFromSocketError(event));
|
||||
return;
|
||||
}
|
||||
|
||||
this.socket = null;
|
||||
this.rejectPendingRequests((id) => requestSocketError(id, event));
|
||||
try {
|
||||
socket.close();
|
||||
} catch {
|
||||
// best-effort close after error
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener("message", (event) => {
|
||||
if (this.socket !== socket) {
|
||||
return;
|
||||
}
|
||||
void this.handleMessage(event.data);
|
||||
});
|
||||
|
||||
socket.addEventListener("close", (event) => {
|
||||
if (this.socket !== socket) {
|
||||
if (!hasOpened) {
|
||||
rejectConnection(runtimeConnectErrorFromClose(event));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.socket = null;
|
||||
if (!hasOpened) {
|
||||
rejectConnection(runtimeConnectErrorFromClose(event));
|
||||
return;
|
||||
}
|
||||
this.rejectPendingRequests((id) => requestDisconnectError(id, event));
|
||||
});
|
||||
});
|
||||
|
||||
this.connectPromise = connectAttempt;
|
||||
connectAttempt.catch(() => {
|
||||
if (this.connectPromise === connectAttempt) {
|
||||
this.connectPromise = null;
|
||||
}
|
||||
});
|
||||
|
||||
return connectAttempt;
|
||||
}
|
||||
|
||||
private async request(method: WsNativeApiMethod, params?: unknown) {
|
||||
const socket = await this.connect();
|
||||
const id = String(this.nextRequestId);
|
||||
this.nextRequestId += 1;
|
||||
|
||||
const requestMessage: WsClientMessage = {
|
||||
type: "request",
|
||||
id,
|
||||
method,
|
||||
params,
|
||||
};
|
||||
|
||||
const requestPromise = new Promise<unknown>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
this.pending.delete(id);
|
||||
reject(new Error(`Request timed out for method '${method}'.`));
|
||||
}, REQUEST_TIMEOUT_MS);
|
||||
this.pending.set(id, { resolve, reject, timeout });
|
||||
});
|
||||
|
||||
try {
|
||||
socket.send(JSON.stringify(requestMessage));
|
||||
} catch (error) {
|
||||
const pending = this.pending.get(id);
|
||||
if (pending) {
|
||||
clearTimeout(pending.timeout);
|
||||
this.pending.delete(id);
|
||||
const sendErrorMessage = messageFromUnknown(error);
|
||||
pending.reject(
|
||||
new Error(
|
||||
`Failed to send runtime request '${method}': ${sendErrorMessage ?? "unknown websocket failure"}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
this.rejectPendingRequests((requestId) => requestSocketError(requestId, error));
|
||||
if (this.socket === socket) {
|
||||
this.socket = null;
|
||||
}
|
||||
try {
|
||||
socket.close();
|
||||
listener(payload);
|
||||
} catch {
|
||||
// best-effort close after send failure
|
||||
// Swallow listener errors
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return requestPromise;
|
||||
}
|
||||
|
||||
private async requestParsed<TValue>(
|
||||
method: WsNativeApiMethod,
|
||||
schema: SchemaLike<TValue>,
|
||||
params?: unknown,
|
||||
): Promise<TValue> {
|
||||
const value = await this.request(method, params);
|
||||
const parsed = schema.safeParse(value);
|
||||
if (!parsed.success) {
|
||||
throw new Error(`Runtime method '${method}' returned invalid response payload.`);
|
||||
}
|
||||
return parsed.data;
|
||||
}
|
||||
|
||||
private async requestNullResult(method: WsNativeApiMethod, params?: unknown): Promise<void> {
|
||||
const value = await this.request(method, params);
|
||||
if (value !== null) {
|
||||
throw new Error(`Runtime method '${method}' returned invalid response payload.`);
|
||||
}
|
||||
}
|
||||
|
||||
private handleResponse(message: WsResponseMessage) {
|
||||
const pending = this.pending.get(message.id);
|
||||
if (!pending) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pending.delete(message.id);
|
||||
clearTimeout(pending.timeout);
|
||||
if (message.ok) {
|
||||
pending.resolve(message.result);
|
||||
return;
|
||||
}
|
||||
|
||||
pending.reject(new Error(message.error?.message ?? "Unknown runtime request failure."));
|
||||
}
|
||||
|
||||
private handleEvent(message: WsEventMessage) {
|
||||
if (message.channel === WS_EVENT_CHANNELS.providerEvent) {
|
||||
for (const listener of this.providerEventListeners) {
|
||||
listener(message.payload as ProviderEvent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.channel === WS_EVENT_CHANNELS.agentOutput) {
|
||||
for (const listener of this.agentOutputListeners) {
|
||||
listener(message.payload as OutputChunk);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.channel === WS_EVENT_CHANNELS.agentExit) {
|
||||
for (const listener of this.agentExitListeners) {
|
||||
listener(message.payload as AgentExit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async decodeIncomingMessage(raw: unknown): Promise<string | null> {
|
||||
if (typeof raw === "string") {
|
||||
return raw;
|
||||
}
|
||||
|
||||
if (ArrayBuffer.isView(raw)) {
|
||||
return textDecoder.decode(raw);
|
||||
}
|
||||
|
||||
if (raw instanceof ArrayBuffer) {
|
||||
return textDecoder.decode(raw);
|
||||
}
|
||||
|
||||
if (raw instanceof Blob) {
|
||||
return raw.text();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private async handleMessage(raw: unknown) {
|
||||
let decoded: string | null;
|
||||
try {
|
||||
decoded = await this.decodeIncomingMessage(raw);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (!decoded) {
|
||||
return;
|
||||
}
|
||||
|
||||
let parsedRaw: unknown;
|
||||
try {
|
||||
parsedRaw = JSON.parse(decoded);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsed = wsServerMessageSchema.safeParse(parsedRaw);
|
||||
if (!parsed.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.data.type === "response") {
|
||||
this.handleResponse(parsed.data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.data.type === "event") {
|
||||
this.handleEvent(parsed.data);
|
||||
}
|
||||
}
|
||||
|
||||
asNativeApi(): NativeApi {
|
||||
return {
|
||||
app: {
|
||||
bootstrap: async () => this.requestParsed("app.bootstrap", appBootstrapResultSchema),
|
||||
health: async () => this.requestParsed("app.health", appHealthResultSchema),
|
||||
const api: NativeApi = {
|
||||
todos: {
|
||||
list: async () => [],
|
||||
add: async () => [],
|
||||
toggle: async () => [],
|
||||
remove: async () => [],
|
||||
},
|
||||
dialogs: {
|
||||
pickFolder: async () => {
|
||||
if (!window.desktopBridge) return null;
|
||||
return window.desktopBridge.pickFolder();
|
||||
},
|
||||
todos: {
|
||||
list: async () => this.requestParsed("todos.list", todoListSchema),
|
||||
add: async (input) => this.requestParsed("todos.add", todoListSchema, input),
|
||||
toggle: async (id) => this.requestParsed("todos.toggle", todoListSchema, id),
|
||||
remove: async (id) => this.requestParsed("todos.remove", todoListSchema, id),
|
||||
},
|
||||
dialogs: {
|
||||
pickFolder: async () =>
|
||||
this.requestParsed("dialogs.pickFolder", dialogsPickFolderResultSchema),
|
||||
},
|
||||
terminal: {
|
||||
run: async (input) => this.requestParsed("terminal.run", terminalCommandResultSchema, input),
|
||||
},
|
||||
agent: {
|
||||
spawn: async (config) => this.requestParsed("agent.spawn", agentSessionIdSchema, config),
|
||||
kill: async (sessionId) => this.requestNullResult("agent.kill", sessionId),
|
||||
write: async (sessionId, data) => this.requestNullResult("agent.write", { sessionId, data }),
|
||||
onOutput: (callback) => {
|
||||
this.agentOutputListeners.add(callback);
|
||||
return () => {
|
||||
this.agentOutputListeners.delete(callback);
|
||||
};
|
||||
},
|
||||
onExit: (callback) => {
|
||||
this.agentExitListeners.add(callback);
|
||||
return () => {
|
||||
this.agentExitListeners.delete(callback);
|
||||
};
|
||||
},
|
||||
},
|
||||
providers: {
|
||||
startSession: async (input) =>
|
||||
this.requestParsed("providers.startSession", providerSessionSchema, input),
|
||||
sendTurn: async (input) =>
|
||||
this.requestParsed("providers.sendTurn", providerTurnStartResultSchema, input),
|
||||
interruptTurn: async (input) => this.requestNullResult("providers.interruptTurn", input),
|
||||
respondToRequest: async (input) => this.requestNullResult("providers.respondToRequest", input),
|
||||
stopSession: async (input) => this.requestNullResult("providers.stopSession", input),
|
||||
listSessions: async () =>
|
||||
this.requestParsed("providers.listSessions", providerSessionListSchema),
|
||||
onEvent: (callback) => {
|
||||
this.providerEventListeners.add(callback);
|
||||
return () => {
|
||||
this.providerEventListeners.delete(callback);
|
||||
};
|
||||
},
|
||||
},
|
||||
shell: {
|
||||
openInEditor: async (cwd, editor) => this.requestNullResult("shell.openInEditor", { cwd, editor }),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function resolveWsUrl() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return params.get("ws") ?? "ws://127.0.0.1:4317";
|
||||
}
|
||||
|
||||
let cachedApi: NativeApi | undefined;
|
||||
|
||||
export function getOrCreateWsNativeApi() {
|
||||
if (cachedApi) {
|
||||
return cachedApi;
|
||||
}
|
||||
|
||||
cachedApi = new WsNativeApiClient(resolveWsUrl()).asNativeApi();
|
||||
return cachedApi;
|
||||
},
|
||||
terminal: {
|
||||
run: async () => ({
|
||||
stdout: "",
|
||||
stderr: "Terminal not available in web mode",
|
||||
code: 1,
|
||||
signal: null,
|
||||
timedOut: false,
|
||||
}),
|
||||
},
|
||||
agent: {
|
||||
spawn: async () => "",
|
||||
kill: async () => {},
|
||||
write: async () => {},
|
||||
onOutput: () => () => {},
|
||||
onExit: () => () => {},
|
||||
},
|
||||
providers: {
|
||||
startSession: (input) => transport.request(WS_METHODS.providersStartSession, input),
|
||||
sendTurn: (input) => transport.request(WS_METHODS.providersSendTurn, input),
|
||||
interruptTurn: (input) => transport.request(WS_METHODS.providersInterruptTurn, input),
|
||||
respondToRequest: (input) => transport.request(WS_METHODS.providersRespondToRequest, input),
|
||||
stopSession: (input) => transport.request(WS_METHODS.providersStopSession, input),
|
||||
listSessions: () => transport.request(WS_METHODS.providersListSessions),
|
||||
onEvent: (callback) =>
|
||||
transport.subscribe(WS_CHANNELS.providerEvent, callback as (data: unknown) => void),
|
||||
},
|
||||
projects: {
|
||||
list: () => transport.request(WS_METHODS.projectsList),
|
||||
add: (input) => transport.request(WS_METHODS.projectsAdd, input),
|
||||
remove: (input) => transport.request(WS_METHODS.projectsRemove, input),
|
||||
},
|
||||
shell: {
|
||||
openInEditor: (cwd, editor) =>
|
||||
transport.request(WS_METHODS.shellOpenInEditor, { cwd, editor }),
|
||||
},
|
||||
};
|
||||
|
||||
instance = { api, transport };
|
||||
return api;
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
import type { WsPush, WsRequest, WsResponse } from "@acme/contracts";
|
||||
|
||||
type PushListener = (data: unknown) => void;
|
||||
|
||||
interface PendingRequest {
|
||||
resolve: (result: unknown) => void;
|
||||
reject: (error: Error) => void;
|
||||
timeout: ReturnType<typeof setTimeout>;
|
||||
}
|
||||
|
||||
const REQUEST_TIMEOUT_MS = 60_000;
|
||||
const RECONNECT_DELAYS_MS = [500, 1_000, 2_000, 4_000, 8_000];
|
||||
|
||||
export class WsTransport {
|
||||
private ws: WebSocket | null = null;
|
||||
private nextId = 1;
|
||||
private readonly pending = new Map<string, PendingRequest>();
|
||||
private readonly listeners = new Map<string, Set<PushListener>>();
|
||||
private reconnectAttempt = 0;
|
||||
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
private disposed = false;
|
||||
private readonly url: string;
|
||||
|
||||
constructor(url?: string) {
|
||||
const bridgeUrl = window.desktopBridge?.getWsUrl();
|
||||
// In dev mode, VITE_WS_URL points to the server's WebSocket endpoint.
|
||||
// In production, the page is served by the WS server on the same host:port.
|
||||
const envUrl = import.meta.env.VITE_WS_URL as string | undefined;
|
||||
this.url =
|
||||
url ??
|
||||
(bridgeUrl && bridgeUrl.length > 0
|
||||
? bridgeUrl
|
||||
: envUrl && envUrl.length > 0
|
||||
? envUrl
|
||||
: `ws://${window.location.hostname}:${window.location.port}`);
|
||||
this.connect();
|
||||
}
|
||||
|
||||
async request<T = unknown>(method: string, params?: unknown): Promise<T> {
|
||||
const id = String(this.nextId++);
|
||||
const message: WsRequest = { id, method, ...(params !== undefined ? { params } : {}) };
|
||||
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
this.pending.delete(id);
|
||||
reject(new Error(`Request timed out: ${method}`));
|
||||
}, REQUEST_TIMEOUT_MS);
|
||||
|
||||
this.pending.set(id, {
|
||||
resolve: resolve as (result: unknown) => void,
|
||||
reject,
|
||||
timeout,
|
||||
});
|
||||
|
||||
this.send(message);
|
||||
});
|
||||
}
|
||||
|
||||
subscribe(channel: string, listener: PushListener): () => void {
|
||||
let channelListeners = this.listeners.get(channel);
|
||||
if (!channelListeners) {
|
||||
channelListeners = new Set();
|
||||
this.listeners.set(channel, channelListeners);
|
||||
}
|
||||
channelListeners.add(listener);
|
||||
|
||||
return () => {
|
||||
channelListeners!.delete(listener);
|
||||
if (channelListeners!.size === 0) {
|
||||
this.listeners.delete(channel);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.disposed = true;
|
||||
if (this.reconnectTimer !== null) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
this.reconnectTimer = null;
|
||||
}
|
||||
for (const pending of this.pending.values()) {
|
||||
clearTimeout(pending.timeout);
|
||||
pending.reject(new Error("Transport disposed"));
|
||||
}
|
||||
this.pending.clear();
|
||||
this.ws?.close();
|
||||
this.ws = null;
|
||||
}
|
||||
|
||||
private connect() {
|
||||
if (this.disposed) return;
|
||||
|
||||
const ws = new WebSocket(this.url);
|
||||
|
||||
ws.addEventListener("open", () => {
|
||||
this.ws = ws;
|
||||
this.reconnectAttempt = 0;
|
||||
});
|
||||
|
||||
ws.addEventListener("message", (event) => {
|
||||
this.handleMessage(event.data);
|
||||
});
|
||||
|
||||
ws.addEventListener("close", () => {
|
||||
this.ws = null;
|
||||
this.scheduleReconnect();
|
||||
});
|
||||
|
||||
ws.addEventListener("error", () => {
|
||||
// close event will fire after error
|
||||
});
|
||||
}
|
||||
|
||||
private handleMessage(raw: unknown) {
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(String(raw));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parsed || typeof parsed !== "object") return;
|
||||
|
||||
const message = parsed as Record<string, unknown>;
|
||||
|
||||
// Push event
|
||||
if (message.type === "push") {
|
||||
const push = message as unknown as WsPush;
|
||||
const channelListeners = this.listeners.get(push.channel);
|
||||
if (channelListeners) {
|
||||
for (const listener of channelListeners) {
|
||||
try {
|
||||
listener(push.data);
|
||||
} catch {
|
||||
// Swallow listener errors
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Response to a request
|
||||
if (typeof message.id === "string") {
|
||||
const response = message as unknown as WsResponse;
|
||||
const pending = this.pending.get(response.id);
|
||||
if (!pending) return;
|
||||
|
||||
clearTimeout(pending.timeout);
|
||||
this.pending.delete(response.id);
|
||||
|
||||
if (response.error) {
|
||||
pending.reject(new Error(response.error.message));
|
||||
} else {
|
||||
pending.resolve(response.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private send(message: WsRequest) {
|
||||
if (this.ws?.readyState === WebSocket.OPEN) {
|
||||
this.ws.send(JSON.stringify(message));
|
||||
return;
|
||||
}
|
||||
|
||||
// If not connected, wait for connection
|
||||
const waitForOpen = () => {
|
||||
const check = setInterval(() => {
|
||||
if (this.disposed) {
|
||||
clearInterval(check);
|
||||
return;
|
||||
}
|
||||
if (this.ws?.readyState === WebSocket.OPEN) {
|
||||
clearInterval(check);
|
||||
this.ws.send(JSON.stringify(message));
|
||||
}
|
||||
}, 50);
|
||||
|
||||
// Give up after timeout (the pending request will time out on its own)
|
||||
setTimeout(() => clearInterval(check), REQUEST_TIMEOUT_MS);
|
||||
};
|
||||
waitForOpen();
|
||||
}
|
||||
|
||||
private scheduleReconnect() {
|
||||
if (this.disposed) return;
|
||||
|
||||
const delay =
|
||||
RECONNECT_DELAYS_MS[Math.min(this.reconnectAttempt, RECONNECT_DELAYS_MS.length - 1)] ??
|
||||
RECONNECT_DELAYS_MS[0]!;
|
||||
|
||||
this.reconnectAttempt++;
|
||||
this.reconnectTimer = setTimeout(() => {
|
||||
this.reconnectTimer = null;
|
||||
this.connect();
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,14 @@ export default defineConfig({
|
||||
}),
|
||||
tailwindcss(),
|
||||
],
|
||||
define: {
|
||||
// In dev mode, tell the renderer where the WebSocket server lives
|
||||
"import.meta.env.VITE_WS_URL": JSON.stringify(
|
||||
process.env.VITE_WS_URL ?? "",
|
||||
),
|
||||
},
|
||||
server: {
|
||||
port: Number(process.env.T3_WEB_PORT ?? 5173),
|
||||
port: Number(process.env.PORT ?? 5173),
|
||||
strictPort: true,
|
||||
},
|
||||
build: {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "t3",
|
||||
"version": "0.1.0",
|
||||
"bin": {
|
||||
"t3": "./dist/index.js"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "VITE_DEV_SERVER_URL=http://localhost:5173 tsx src/index.ts",
|
||||
"dev:desktop": "CODETHING_MODE=desktop CODETHING_NO_BROWSER=1 tsx src/index.ts",
|
||||
"build": "tsup && node scripts/bundle-client.mjs",
|
||||
"start": "node dist/index.js",
|
||||
"start:desktop": "CODETHING_MODE=desktop CODETHING_NO_BROWSER=1 node dist/index.js",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"open": "^10.1.0",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@acme/contracts": "workspace:*",
|
||||
"@acme/renderer": "workspace:*",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/ws": "^8.5.13",
|
||||
"tsup": "^8.3.5",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copies the built renderer into dist/client/ so the published npm package
|
||||
* includes the web UI. This runs as a post-build step.
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rendererDist = path.resolve(__dirname, "../../renderer/dist");
|
||||
const target = path.resolve(__dirname, "../dist/client");
|
||||
|
||||
if (!fs.existsSync(rendererDist)) {
|
||||
console.log(
|
||||
"⚠ Renderer dist not found — skipping client bundle. Run `bun run --cwd apps/renderer build` first.",
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
fs.cpSync(rendererDist, target, { recursive: true });
|
||||
console.log("✓ Bundled renderer into dist/client");
|
||||
+6
-2
@@ -57,13 +57,17 @@ describe("normalizeCodexModelSlug", () => {
|
||||
describe("isRecoverableThreadResumeError", () => {
|
||||
it("matches not-found resume errors", () => {
|
||||
expect(
|
||||
isRecoverableThreadResumeError(new Error("thread/resume failed: thread not found")),
|
||||
isRecoverableThreadResumeError(
|
||||
new Error("thread/resume failed: thread not found"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores non-resume errors", () => {
|
||||
expect(
|
||||
isRecoverableThreadResumeError(new Error("thread/start failed: permission denied")),
|
||||
isRecoverableThreadResumeError(
|
||||
new Error("thread/start failed: permission denied"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
+33
-11
@@ -26,7 +26,9 @@ interface PendingRequest {
|
||||
interface PendingApprovalRequest {
|
||||
requestId: string;
|
||||
jsonRpcId: string | number;
|
||||
method: "item/commandExecution/requestApproval" | "item/fileChange/requestApproval";
|
||||
method:
|
||||
| "item/commandExecution/requestApproval"
|
||||
| "item/fileChange/requestApproval";
|
||||
requestKind: ProviderRequestKind;
|
||||
threadId?: string;
|
||||
turnId?: string;
|
||||
@@ -120,12 +122,16 @@ export function classifyCodexStderrLine(rawLine: string): { message: string } |
|
||||
}
|
||||
|
||||
export function isRecoverableThreadResumeError(error: unknown): boolean {
|
||||
const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
|
||||
const message = (
|
||||
error instanceof Error ? error.message : String(error)
|
||||
).toLowerCase();
|
||||
if (!message.includes("thread/resume")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return RECOVERABLE_THREAD_RESUME_ERROR_SNIPPETS.some((snippet) => message.includes(snippet));
|
||||
return RECOVERABLE_THREAD_RESUME_ERROR_SNIPPETS.some((snippet) =>
|
||||
message.includes(snippet),
|
||||
);
|
||||
}
|
||||
|
||||
export interface CodexAppServerManagerEvents {
|
||||
@@ -203,10 +209,14 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
if (input.resumeThreadId) {
|
||||
try {
|
||||
threadOpenMethod = "thread/resume";
|
||||
threadOpenResponse = await this.sendRequest(context, "thread/resume", {
|
||||
...sessionOverrides,
|
||||
threadId: input.resumeThreadId,
|
||||
});
|
||||
threadOpenResponse = await this.sendRequest(
|
||||
context,
|
||||
"thread/resume",
|
||||
{
|
||||
...sessionOverrides,
|
||||
threadId: input.resumeThreadId,
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
if (!isRecoverableThreadResumeError(error)) {
|
||||
throw error;
|
||||
@@ -218,11 +228,19 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
"session/threadResumeFallback",
|
||||
`Could not resume thread ${input.resumeThreadId}; started a new thread instead.`,
|
||||
);
|
||||
threadOpenResponse = await this.sendRequest(context, "thread/start", threadStartParams);
|
||||
threadOpenResponse = await this.sendRequest(
|
||||
context,
|
||||
"thread/start",
|
||||
threadStartParams,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
threadOpenMethod = "thread/start";
|
||||
threadOpenResponse = await this.sendRequest(context, "thread/start", threadStartParams);
|
||||
threadOpenResponse = await this.sendRequest(
|
||||
context,
|
||||
"thread/start",
|
||||
threadStartParams,
|
||||
);
|
||||
}
|
||||
|
||||
const threadOpenRecord = this.readObject(threadOpenResponse);
|
||||
@@ -230,7 +248,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
this.readString(this.readObject(threadOpenRecord, "thread"), "id") ??
|
||||
this.readString(threadOpenRecord, "threadId");
|
||||
if (!threadId) {
|
||||
throw new Error(`${threadOpenMethod} response did not include a thread id.`);
|
||||
throw new Error(
|
||||
`${threadOpenMethod} response did not include a thread id.`,
|
||||
);
|
||||
}
|
||||
|
||||
this.updateSession(context, {
|
||||
@@ -712,7 +732,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
};
|
||||
}
|
||||
|
||||
private requestKindForMethod(method: string): ProviderRequestKind | undefined {
|
||||
private requestKindForMethod(
|
||||
method: string,
|
||||
): ProviderRequestKind | undefined {
|
||||
if (method === "item/commandExecution/requestApproval") {
|
||||
return "command";
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
export function fixPath(): void {
|
||||
if (process.platform !== "darwin") return;
|
||||
|
||||
try {
|
||||
const shell = process.env.SHELL ?? "/bin/zsh";
|
||||
const result = execFileSync(shell, ["-ilc", "echo -n $PATH"], {
|
||||
encoding: "utf8",
|
||||
timeout: 5000,
|
||||
});
|
||||
if (result) {
|
||||
process.env.PATH = result;
|
||||
}
|
||||
} catch {
|
||||
// Silently ignore — keep default PATH
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import fs from "node:fs";
|
||||
import net from "node:net";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { fixPath } from "./fixPath";
|
||||
import { createLogger } from "./logger";
|
||||
import { ProjectRegistry } from "./projectRegistry";
|
||||
import { createServer } from "./wsServer";
|
||||
|
||||
fixPath();
|
||||
|
||||
const DEFAULT_PORT = 3773;
|
||||
const cwd = process.cwd();
|
||||
const logger = createLogger("server");
|
||||
|
||||
type RuntimeMode = "web" | "desktop";
|
||||
|
||||
function parseBooleanEnv(value: string | undefined): boolean | undefined {
|
||||
if (value === undefined) return undefined;
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (["1", "true", "yes", "on"].includes(normalized)) return true;
|
||||
if (["0", "false", "no", "off"].includes(normalized)) return false;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parsePort(value: string | undefined): number | undefined {
|
||||
if (!value) return undefined;
|
||||
const parsed = Number(value);
|
||||
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65535) {
|
||||
throw new Error(`Invalid CODETHING_PORT: ${value}`);
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function expandHomePath(input: string): string {
|
||||
if (input === "~") return os.homedir();
|
||||
if (input.startsWith("~/")) {
|
||||
return path.join(os.homedir(), input.slice(2));
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
function resolveStateDir(raw: string | undefined): string {
|
||||
if (!raw || raw.trim().length === 0) {
|
||||
return path.join(os.homedir(), ".t3", "userdata");
|
||||
}
|
||||
return path.resolve(expandHomePath(raw.trim()));
|
||||
}
|
||||
|
||||
async function findAvailablePort(preferred: number): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = net.createServer();
|
||||
server.listen(preferred, () => {
|
||||
server.close(() => resolve(preferred));
|
||||
});
|
||||
server.on("error", () => {
|
||||
// Preferred port busy — let the OS pick one
|
||||
const fallback = net.createServer();
|
||||
fallback.listen(0, () => {
|
||||
const addr = fallback.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
fallback.close(() => {
|
||||
if (port > 0) resolve(port);
|
||||
else reject(new Error("Could not find an available port."));
|
||||
});
|
||||
});
|
||||
fallback.on("error", reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resolveStaticDir(): string | undefined {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Check for bundled client (npm publish / npx scenario):
|
||||
// dist/client/ lives alongside dist/index.js
|
||||
const bundledClient = path.resolve(__dirname, "client");
|
||||
try {
|
||||
const stat = fs.statSync(path.join(bundledClient, "index.html"));
|
||||
if (stat.isFile()) return bundledClient;
|
||||
} catch {
|
||||
// Not bundled — check monorepo layout
|
||||
}
|
||||
|
||||
// Monorepo layout: apps/server/dist/index.js → apps/renderer/dist/
|
||||
const monorepoClient = path.resolve(__dirname, "../../renderer/dist");
|
||||
try {
|
||||
const stat = fs.statSync(path.join(monorepoClient, "index.html"));
|
||||
if (stat.isFile()) return monorepoClient;
|
||||
} catch {
|
||||
// Not found — probably dev mode, Vite will serve
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const mode: RuntimeMode = process.env.CODETHING_MODE === "desktop" ? "desktop" : "web";
|
||||
const requestedPort = parsePort(process.env.CODETHING_PORT);
|
||||
const port =
|
||||
requestedPort ?? (mode === "desktop" ? DEFAULT_PORT : await findAvailablePort(DEFAULT_PORT));
|
||||
const stateDir = resolveStateDir(process.env.CODETHING_STATE_DIR);
|
||||
const projectRegistry = new ProjectRegistry(stateDir);
|
||||
const devUrl = process.env.VITE_DEV_SERVER_URL;
|
||||
const noBrowser = parseBooleanEnv(process.env.CODETHING_NO_BROWSER) ?? mode === "desktop";
|
||||
const authToken = process.env.CODETHING_AUTH_TOKEN;
|
||||
const staticDir = devUrl ? undefined : resolveStaticDir();
|
||||
|
||||
if (!devUrl && !staticDir) {
|
||||
logger.warn("renderer bundle missing and no VITE_DEV_SERVER_URL; web UI unavailable", {
|
||||
hint: "Run `bun run --cwd apps/renderer build` or set VITE_DEV_SERVER_URL for dev mode.",
|
||||
});
|
||||
}
|
||||
|
||||
const server = createServer({
|
||||
port,
|
||||
host: mode === "desktop" ? "127.0.0.1" : undefined,
|
||||
cwd,
|
||||
staticDir,
|
||||
devUrl,
|
||||
projectRegistry,
|
||||
authToken,
|
||||
});
|
||||
await server.start();
|
||||
|
||||
const url = `http://localhost:${port}`;
|
||||
logger.info("CodeThing running", {
|
||||
url,
|
||||
cwd,
|
||||
mode,
|
||||
stateDir,
|
||||
authEnabled: Boolean(authToken),
|
||||
});
|
||||
|
||||
// Open browser (dynamic import because `open` is ESM-only)
|
||||
if (!noBrowser) {
|
||||
try {
|
||||
const open = await import("open");
|
||||
const target = devUrl ?? url;
|
||||
await open.default(target);
|
||||
} catch {
|
||||
logger.info("browser auto-open unavailable", {
|
||||
hint: `Open ${devUrl ?? url} in your browser.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Graceful shutdown
|
||||
let shuttingDown = false;
|
||||
async function shutdown() {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
logger.info("shutting down");
|
||||
try {
|
||||
await server.stop();
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
logger.error("failed to stop server cleanly", { error });
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
process.on("SIGINT", () => {
|
||||
void shutdown();
|
||||
});
|
||||
process.on("SIGTERM", () => {
|
||||
void shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
logger.error("failed to start CodeThing", { error: err });
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -0,0 +1,103 @@
|
||||
import util from "node:util";
|
||||
|
||||
type LogLevel = "info" | "warn" | "error" | "event";
|
||||
|
||||
type LogContext = Record<string, unknown>;
|
||||
|
||||
const ANSI = {
|
||||
reset: "\u001b[0m",
|
||||
dim: "\u001b[2m",
|
||||
cyan: "\u001b[36m",
|
||||
yellow: "\u001b[33m",
|
||||
red: "\u001b[31m",
|
||||
magenta: "\u001b[35m",
|
||||
} as const;
|
||||
|
||||
const LEVEL_LABEL: Record<LogLevel, string> = {
|
||||
info: "INFO",
|
||||
warn: "WARN",
|
||||
error: "ERROR",
|
||||
event: "EVENT",
|
||||
};
|
||||
|
||||
const LEVEL_COLOR: Record<LogLevel, string> = {
|
||||
info: ANSI.cyan,
|
||||
warn: ANSI.yellow,
|
||||
error: ANSI.red,
|
||||
event: ANSI.magenta,
|
||||
};
|
||||
|
||||
function useColors() {
|
||||
return Boolean(process.stdout.isTTY) && process.env.NO_COLOR === undefined;
|
||||
}
|
||||
|
||||
function colorize(value: string, color: string, enabled: boolean) {
|
||||
return enabled ? `${color}${value}${ANSI.reset}` : value;
|
||||
}
|
||||
|
||||
function timeStamp() {
|
||||
return new Date().toISOString().slice(11, 23);
|
||||
}
|
||||
|
||||
function formatValue(value: unknown) {
|
||||
if (typeof value === "string") {
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
if (
|
||||
typeof value === "number" ||
|
||||
typeof value === "boolean" ||
|
||||
value === null ||
|
||||
value === undefined
|
||||
) {
|
||||
return String(value);
|
||||
}
|
||||
return util.inspect(value, {
|
||||
depth: 4,
|
||||
breakLength: Infinity,
|
||||
compact: true,
|
||||
maxArrayLength: 25,
|
||||
maxStringLength: 320,
|
||||
});
|
||||
}
|
||||
|
||||
function formatContext(context: LogContext | undefined) {
|
||||
if (!context) return "";
|
||||
const entries = Object.entries(context).filter(([, value]) => value !== undefined);
|
||||
if (entries.length === 0) return "";
|
||||
return entries.map(([key, value]) => `${key}=${formatValue(value)}`).join(" ");
|
||||
}
|
||||
|
||||
function write(level: LogLevel, scope: string, message: string, context?: LogContext) {
|
||||
const colorEnabled = useColors();
|
||||
const ts = colorize(timeStamp(), ANSI.dim, colorEnabled);
|
||||
const levelLabel = colorize(LEVEL_LABEL[level], LEVEL_COLOR[level], colorEnabled);
|
||||
const contextText = formatContext(context);
|
||||
const line = `${ts} ${levelLabel} [${scope}] ${message}${contextText ? ` ${contextText}` : ""}`;
|
||||
|
||||
if (level === "warn") {
|
||||
console.warn(line);
|
||||
return;
|
||||
}
|
||||
if (level === "error") {
|
||||
console.error(line);
|
||||
return;
|
||||
}
|
||||
console.log(line);
|
||||
}
|
||||
|
||||
export function createLogger(scope: string) {
|
||||
return {
|
||||
info(message: string, context?: LogContext) {
|
||||
write("info", scope, message, context);
|
||||
},
|
||||
warn(message: string, context?: LogContext) {
|
||||
write("warn", scope, message, context);
|
||||
},
|
||||
error(message: string, context?: LogContext) {
|
||||
write("error", scope, message, context);
|
||||
},
|
||||
event(message: string, context?: LogContext) {
|
||||
write("event", scope, message, context);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import {
|
||||
type ProjectAddInput,
|
||||
type ProjectAddResult,
|
||||
type ProjectListResult,
|
||||
type ProjectRecord,
|
||||
type ProjectRemoveInput,
|
||||
projectAddInputSchema,
|
||||
projectRecordSchema,
|
||||
projectRemoveInputSchema,
|
||||
} from "@acme/contracts";
|
||||
|
||||
function normalizeCwd(rawCwd: string): string {
|
||||
const resolved = path.resolve(rawCwd.trim());
|
||||
const normalized = path.normalize(resolved);
|
||||
if (process.platform === "win32") {
|
||||
return normalized.toLowerCase();
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function isDirectory(cwd: string): boolean {
|
||||
try {
|
||||
return fs.statSync(cwd).isDirectory();
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function inferProjectName(cwd: string): string {
|
||||
const name = path.basename(cwd);
|
||||
return name.length > 0 ? name : "project";
|
||||
}
|
||||
|
||||
export class ProjectRegistry {
|
||||
private readonly stateDir: string;
|
||||
private readonly filePath: string;
|
||||
private projects: ProjectRecord[];
|
||||
|
||||
constructor(stateDir: string) {
|
||||
this.stateDir = stateDir;
|
||||
this.filePath = path.join(this.stateDir, "projects.json");
|
||||
fs.mkdirSync(this.stateDir, { recursive: true });
|
||||
this.projects = this.loadFromDisk();
|
||||
}
|
||||
|
||||
list(): ProjectListResult {
|
||||
return this.projects.map((project) => ({ ...project }));
|
||||
}
|
||||
|
||||
add(raw: ProjectAddInput): ProjectAddResult {
|
||||
const input = projectAddInputSchema.parse(raw);
|
||||
const normalizedCwd = normalizeCwd(input.cwd);
|
||||
if (!isDirectory(normalizedCwd)) {
|
||||
throw new Error(`Project path does not exist: ${normalizedCwd}`);
|
||||
}
|
||||
|
||||
const existing = this.projects.find((project) => normalizeCwd(project.cwd) === normalizedCwd);
|
||||
if (existing) {
|
||||
return { project: { ...existing }, created: false };
|
||||
}
|
||||
|
||||
const now = new Date().toISOString();
|
||||
const project: ProjectRecord = {
|
||||
id: randomUUID(),
|
||||
cwd: normalizedCwd,
|
||||
name: inferProjectName(normalizedCwd),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
|
||||
this.projects = [project, ...this.projects];
|
||||
this.persist();
|
||||
return { project: { ...project }, created: true };
|
||||
}
|
||||
|
||||
remove(raw: ProjectRemoveInput): void {
|
||||
const input = projectRemoveInputSchema.parse(raw);
|
||||
const next = this.projects.filter((project) => project.id !== input.id);
|
||||
if (next.length === this.projects.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.projects = next;
|
||||
this.persist();
|
||||
}
|
||||
|
||||
private loadFromDisk(): ProjectRecord[] {
|
||||
const loaded = this.readPersistedProjects();
|
||||
const deduped = new Map<string, ProjectRecord>();
|
||||
const normalizedProjects: ProjectRecord[] = [];
|
||||
|
||||
for (const project of loaded) {
|
||||
const normalizedCwd = normalizeCwd(project.cwd);
|
||||
if (!isDirectory(normalizedCwd)) {
|
||||
continue;
|
||||
}
|
||||
if (deduped.has(normalizedCwd)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const normalizedProject: ProjectRecord = {
|
||||
...project,
|
||||
cwd: normalizedCwd,
|
||||
name:
|
||||
project.name.trim().length > 0 ? project.name.trim() : inferProjectName(normalizedCwd),
|
||||
};
|
||||
deduped.set(normalizedCwd, normalizedProject);
|
||||
normalizedProjects.push(normalizedProject);
|
||||
}
|
||||
|
||||
const changed =
|
||||
normalizedProjects.length !== loaded.length ||
|
||||
normalizedProjects.some((project, index) => {
|
||||
const source = loaded[index];
|
||||
if (!source) return true;
|
||||
return (
|
||||
source.id !== project.id ||
|
||||
source.cwd !== project.cwd ||
|
||||
source.name !== project.name ||
|
||||
source.createdAt !== project.createdAt ||
|
||||
source.updatedAt !== project.updatedAt
|
||||
);
|
||||
});
|
||||
|
||||
if (changed) {
|
||||
this.projects = normalizedProjects;
|
||||
this.persist();
|
||||
}
|
||||
|
||||
return normalizedProjects;
|
||||
}
|
||||
|
||||
private readPersistedProjects(): ProjectRecord[] {
|
||||
try {
|
||||
const raw = fs.readFileSync(this.filePath, "utf8");
|
||||
const parsed = JSON.parse(raw) as { projects?: unknown };
|
||||
if (!parsed || !Array.isArray(parsed.projects)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const projects: ProjectRecord[] = [];
|
||||
for (const candidate of parsed.projects) {
|
||||
const row = projectRecordSchema.safeParse(candidate);
|
||||
if (!row.success) {
|
||||
continue;
|
||||
}
|
||||
projects.push(row.data);
|
||||
}
|
||||
return projects;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private persist(): void {
|
||||
const payload = JSON.stringify(
|
||||
{
|
||||
version: 1,
|
||||
projects: this.projects,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
);
|
||||
const tempFile = `${this.filePath}.tmp-${process.pid}-${Date.now()}`;
|
||||
fs.writeFileSync(tempFile, payload);
|
||||
fs.renameSync(tempFile, this.filePath);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -16,7 +16,10 @@ describe("ProviderManager", () => {
|
||||
method: string;
|
||||
threadId: string;
|
||||
}) => void;
|
||||
threadLogStreams: Map<string, { writableEnded: boolean; destroyed: boolean }>;
|
||||
threadLogStreams: Map<
|
||||
string,
|
||||
{ writableEnded: boolean; destroyed: boolean }
|
||||
>;
|
||||
};
|
||||
internals.onCodexEvent({
|
||||
id: "evt-1",
|
||||
@@ -87,7 +87,11 @@ export class ProviderManager extends EventEmitter<ProviderManagerEvents> {
|
||||
throw new Error(`Unknown provider session: ${input.sessionId}`);
|
||||
}
|
||||
|
||||
await this.codex.respondToRequest(input.sessionId, input.requestId, input.decision);
|
||||
await this.codex.respondToRequest(
|
||||
input.sessionId,
|
||||
input.requestId,
|
||||
input.decision,
|
||||
);
|
||||
}
|
||||
|
||||
stopSession(raw: ProviderStopSessionInput): void {
|
||||
@@ -147,7 +151,10 @@ export class ProviderManager extends EventEmitter<ProviderManagerEvents> {
|
||||
|
||||
private resolveThreadId(event: ProviderEvent): string | undefined {
|
||||
const fromPayload = this.readThreadIdFromPayload(event.payload);
|
||||
const threadId = event.threadId ?? fromPayload ?? this.sessionThreadIds.get(event.sessionId);
|
||||
const threadId =
|
||||
event.threadId ??
|
||||
fromPayload ??
|
||||
this.sessionThreadIds.get(event.sessionId);
|
||||
|
||||
if (threadId) {
|
||||
this.sessionThreadIds.set(event.sessionId, threadId);
|
||||
@@ -0,0 +1,347 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it, afterEach, vi } from "vitest";
|
||||
import { createServer } from "./wsServer";
|
||||
import WebSocket from "ws";
|
||||
|
||||
import { WS_CHANNELS, WS_METHODS, type WsPush, type WsResponse } from "@acme/contracts";
|
||||
import { ProjectRegistry } from "./projectRegistry";
|
||||
|
||||
interface PendingMessages {
|
||||
queue: unknown[];
|
||||
waiters: Array<(message: unknown) => void>;
|
||||
}
|
||||
|
||||
const pendingBySocket = new WeakMap<WebSocket, PendingMessages>();
|
||||
|
||||
function connectWs(port: number, token?: string): Promise<WebSocket> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const query = token ? `?token=${encodeURIComponent(token)}` : "";
|
||||
const ws = new WebSocket(`ws://127.0.0.1:${port}/${query}`);
|
||||
const pending: PendingMessages = { queue: [], waiters: [] };
|
||||
pendingBySocket.set(ws, pending);
|
||||
|
||||
ws.on("message", (raw) => {
|
||||
const parsed = JSON.parse(String(raw));
|
||||
const waiter = pending.waiters.shift();
|
||||
if (waiter) {
|
||||
waiter(parsed);
|
||||
return;
|
||||
}
|
||||
pending.queue.push(parsed);
|
||||
});
|
||||
|
||||
ws.once("open", () => resolve(ws));
|
||||
ws.once("error", () => reject(new Error("WebSocket connection failed")));
|
||||
});
|
||||
}
|
||||
|
||||
function waitForMessage(ws: WebSocket): Promise<unknown> {
|
||||
const pending = pendingBySocket.get(ws);
|
||||
if (!pending) {
|
||||
return Promise.reject(new Error("WebSocket not initialized"));
|
||||
}
|
||||
|
||||
const queued = pending.queue.shift();
|
||||
if (queued !== undefined) {
|
||||
return Promise.resolve(queued);
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
pending.waiters.push(resolve);
|
||||
});
|
||||
}
|
||||
|
||||
async function sendRequest(ws: WebSocket, method: string, params?: unknown): Promise<WsResponse> {
|
||||
const id = crypto.randomUUID();
|
||||
const message = JSON.stringify({ id, method, ...(params !== undefined ? { params } : {}) });
|
||||
ws.send(message);
|
||||
|
||||
// Wait for response with matching id
|
||||
while (true) {
|
||||
const parsed = (await waitForMessage(ws)) as Record<string, unknown>;
|
||||
if (parsed.id === id) {
|
||||
return parsed as WsResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe("WebSocket Server", () => {
|
||||
let server: ReturnType<typeof createServer> | null = null;
|
||||
const connections: WebSocket[] = [];
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
function makeTempDir(prefix: string): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
||||
tempDirs.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
function createTestServer(
|
||||
options: {
|
||||
cwd?: string;
|
||||
devUrl?: string;
|
||||
authToken?: string;
|
||||
stateDir?: string;
|
||||
} = {},
|
||||
): ReturnType<typeof createServer> {
|
||||
const stateDir = options.stateDir ?? makeTempDir("codething-ws-state-");
|
||||
return createServer({
|
||||
port: 0,
|
||||
cwd: options.cwd ?? "/test/project",
|
||||
...(options.devUrl ? { devUrl: options.devUrl } : {}),
|
||||
...(options.authToken ? { authToken: options.authToken } : {}),
|
||||
projectRegistry: new ProjectRegistry(stateDir),
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
for (const ws of connections) {
|
||||
ws.close();
|
||||
}
|
||||
connections.length = 0;
|
||||
if (server) {
|
||||
await server.stop();
|
||||
}
|
||||
server = null;
|
||||
for (const dir of tempDirs.splice(0, tempDirs.length)) {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("sends welcome message on connect", async () => {
|
||||
server = createTestServer({ cwd: "/test/project" });
|
||||
// Get the actual port after listen
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
expect(port).toBeGreaterThan(0);
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
|
||||
const message = (await waitForMessage(ws)) as WsPush;
|
||||
expect(message.type).toBe("push");
|
||||
expect(message.channel).toBe(WS_CHANNELS.serverWelcome);
|
||||
expect(message.data).toEqual({
|
||||
cwd: "/test/project",
|
||||
projectName: "project",
|
||||
});
|
||||
});
|
||||
|
||||
it("logs outbound websocket push events in dev mode", async () => {
|
||||
const logSpy = vi.spyOn(console, "log").mockImplementation(() => {
|
||||
// Keep test output clean while verifying websocket logs.
|
||||
});
|
||||
|
||||
server = createTestServer({
|
||||
cwd: "/test/project",
|
||||
devUrl: "http://localhost:5173",
|
||||
});
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
expect(port).toBeGreaterThan(0);
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
await waitForMessage(ws);
|
||||
|
||||
expect(
|
||||
logSpy.mock.calls.some(([message]) => {
|
||||
if (typeof message !== "string") return false;
|
||||
return (
|
||||
message.includes("[ws]") &&
|
||||
message.includes("outgoing push") &&
|
||||
message.includes(`channel="${WS_CHANNELS.serverWelcome}"`)
|
||||
);
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("responds to server.getConfig", async () => {
|
||||
server = createTestServer({ cwd: "/my/workspace" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
|
||||
// Consume welcome message
|
||||
await waitForMessage(ws);
|
||||
|
||||
const response = await sendRequest(ws, WS_METHODS.serverGetConfig);
|
||||
expect(response.error).toBeUndefined();
|
||||
expect(response.result).toEqual({ cwd: "/my/workspace" });
|
||||
});
|
||||
|
||||
it("returns error for unknown methods", async () => {
|
||||
server = createTestServer({ cwd: "/test" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
|
||||
// Consume welcome
|
||||
await waitForMessage(ws);
|
||||
|
||||
const response = await sendRequest(ws, "nonexistent.method");
|
||||
expect(response.error).toBeDefined();
|
||||
expect(response.error!.message).toContain("Unknown method");
|
||||
});
|
||||
|
||||
it("responds to providers.listSessions with empty array", async () => {
|
||||
server = createTestServer({ cwd: "/test" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
|
||||
// Consume welcome
|
||||
await waitForMessage(ws);
|
||||
|
||||
const response = await sendRequest(ws, WS_METHODS.providersListSessions);
|
||||
expect(response.error).toBeUndefined();
|
||||
expect(response.result).toEqual([]);
|
||||
});
|
||||
|
||||
it("handles invalid JSON gracefully", async () => {
|
||||
server = createTestServer({ cwd: "/test" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
|
||||
// Consume welcome
|
||||
await waitForMessage(ws);
|
||||
|
||||
// Send garbage
|
||||
ws.send("not json at all");
|
||||
|
||||
const response = (await waitForMessage(ws)) as WsResponse;
|
||||
expect(response.error).toBeDefined();
|
||||
expect(response.error!.message).toContain("Invalid request format");
|
||||
});
|
||||
|
||||
it("supports projects list/add/dedupe/remove", async () => {
|
||||
const stateDir = makeTempDir("codething-ws-projects-state-");
|
||||
const firstProjectCwd = makeTempDir("codething-ws-project-a-");
|
||||
|
||||
server = createTestServer({ stateDir, cwd: "/test" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
await waitForMessage(ws);
|
||||
|
||||
const emptyList = await sendRequest(ws, WS_METHODS.projectsList);
|
||||
expect(emptyList.error).toBeUndefined();
|
||||
expect(emptyList.result).toEqual([]);
|
||||
|
||||
const created = await sendRequest(ws, WS_METHODS.projectsAdd, {
|
||||
cwd: firstProjectCwd,
|
||||
});
|
||||
expect(created.error).toBeUndefined();
|
||||
expect((created.result as { created: boolean }).created).toBe(true);
|
||||
|
||||
const duplicate = await sendRequest(ws, WS_METHODS.projectsAdd, {
|
||||
cwd: firstProjectCwd,
|
||||
});
|
||||
expect(duplicate.error).toBeUndefined();
|
||||
expect((duplicate.result as { created: boolean }).created).toBe(false);
|
||||
|
||||
const listed = await sendRequest(ws, WS_METHODS.projectsList);
|
||||
expect(listed.error).toBeUndefined();
|
||||
const listedProjects = listed.result as Array<{ id: string; cwd: string }>;
|
||||
expect(listedProjects).toHaveLength(1);
|
||||
|
||||
const projectId = listedProjects[0]?.id;
|
||||
expect(projectId).toBeTruthy();
|
||||
if (!projectId) return;
|
||||
|
||||
const removed = await sendRequest(ws, WS_METHODS.projectsRemove, {
|
||||
id: projectId,
|
||||
});
|
||||
expect(removed.error).toBeUndefined();
|
||||
|
||||
const afterRemove = await sendRequest(ws, WS_METHODS.projectsList);
|
||||
expect(afterRemove.error).toBeUndefined();
|
||||
expect(afterRemove.result).toEqual([]);
|
||||
});
|
||||
|
||||
it("prunes missing projects on startup", async () => {
|
||||
const stateDir = makeTempDir("codething-ws-prune-state-");
|
||||
const existing = makeTempDir("codething-ws-existing-project-");
|
||||
const missing = path.join(stateDir, "definitely-missing");
|
||||
const now = new Date().toISOString();
|
||||
const projectsFile = path.join(stateDir, "projects.json");
|
||||
|
||||
fs.writeFileSync(
|
||||
projectsFile,
|
||||
JSON.stringify(
|
||||
{
|
||||
version: 1,
|
||||
projects: [
|
||||
{
|
||||
id: "project-existing",
|
||||
cwd: existing,
|
||||
name: "existing",
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
{
|
||||
id: "project-missing",
|
||||
cwd: missing,
|
||||
name: "missing",
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
server = createTestServer({ stateDir, cwd: "/test" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
await waitForMessage(ws);
|
||||
|
||||
const response = await sendRequest(ws, WS_METHODS.projectsList);
|
||||
expect(response.error).toBeUndefined();
|
||||
const listed = response.result as Array<{ id: string }>;
|
||||
expect(listed).toHaveLength(1);
|
||||
expect(listed[0]?.id).toBe("project-existing");
|
||||
});
|
||||
|
||||
it("rejects websocket connections without a valid auth token", async () => {
|
||||
server = createTestServer({ cwd: "/test", authToken: "secret-token" });
|
||||
await server.start();
|
||||
const addr = server.httpServer.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
await expect(connectWs(port)).rejects.toThrow("WebSocket connection failed");
|
||||
|
||||
const authorizedWs = await connectWs(port, "secret-token");
|
||||
connections.push(authorizedWs);
|
||||
const welcome = (await waitForMessage(authorizedWs)) as WsPush;
|
||||
expect(welcome.channel).toBe(WS_CHANNELS.serverWelcome);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,373 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import http from "node:http";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import type { Duplex } from "node:stream";
|
||||
|
||||
import {
|
||||
EDITORS,
|
||||
WS_CHANNELS,
|
||||
WS_METHODS,
|
||||
type WsPush,
|
||||
type WsRequest,
|
||||
type WsResponse,
|
||||
wsRequestSchema,
|
||||
} from "@acme/contracts";
|
||||
import { WebSocketServer, type WebSocket } from "ws";
|
||||
|
||||
import { createLogger } from "./logger";
|
||||
import { ProjectRegistry } from "./projectRegistry";
|
||||
import { ProviderManager } from "./providerManager";
|
||||
|
||||
const MIME_TYPES: Record<string, string> = {
|
||||
".html": "text/html; charset=utf-8",
|
||||
".js": "application/javascript; charset=utf-8",
|
||||
".css": "text/css; charset=utf-8",
|
||||
".json": "application/json; charset=utf-8",
|
||||
".png": "image/png",
|
||||
".jpg": "image/jpeg",
|
||||
".svg": "image/svg+xml",
|
||||
".ico": "image/x-icon",
|
||||
".woff": "font/woff",
|
||||
".woff2": "font/woff2",
|
||||
".ttf": "font/ttf",
|
||||
".map": "application/json",
|
||||
};
|
||||
|
||||
export interface ServerOptions {
|
||||
port: number;
|
||||
host?: string | undefined;
|
||||
cwd: string;
|
||||
staticDir?: string | undefined;
|
||||
devUrl?: string | undefined;
|
||||
logWebSocketEvents?: boolean | undefined;
|
||||
projectRegistry?: ProjectRegistry | undefined;
|
||||
authToken?: string | undefined;
|
||||
}
|
||||
|
||||
function parseBooleanEnv(value: string | undefined): boolean | undefined {
|
||||
if (value === undefined) return undefined;
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (["1", "true", "yes", "on"].includes(normalized)) return true;
|
||||
if (["0", "false", "no", "off"].includes(normalized)) return false;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function createServer(options: ServerOptions) {
|
||||
const {
|
||||
port,
|
||||
host,
|
||||
cwd,
|
||||
staticDir,
|
||||
devUrl,
|
||||
logWebSocketEvents: explicitLogWsEvents,
|
||||
projectRegistry: providedRegistry,
|
||||
authToken,
|
||||
} = options;
|
||||
const providerManager = new ProviderManager();
|
||||
const projectRegistry =
|
||||
providedRegistry ?? new ProjectRegistry(path.join(os.homedir(), ".t3", "userdata"));
|
||||
const clients = new Set<WebSocket>();
|
||||
const logger = createLogger("ws");
|
||||
const logWebSocketEvents =
|
||||
explicitLogWsEvents ?? parseBooleanEnv(process.env.CODETHING_LOG_WS_EVENTS) ?? Boolean(devUrl);
|
||||
|
||||
function logOutgoingPush(push: WsPush, recipients: number) {
|
||||
if (!logWebSocketEvents) return;
|
||||
logger.event("outgoing push", {
|
||||
channel: push.channel,
|
||||
recipients,
|
||||
payload: push.data,
|
||||
});
|
||||
}
|
||||
|
||||
// Forward provider events to all connected WebSocket clients
|
||||
providerManager.on("event", (event) => {
|
||||
const push: WsPush = {
|
||||
type: "push",
|
||||
channel: WS_CHANNELS.providerEvent,
|
||||
data: event,
|
||||
};
|
||||
const message = JSON.stringify(push);
|
||||
let recipients = 0;
|
||||
for (const client of clients) {
|
||||
if (client.readyState === client.OPEN) {
|
||||
client.send(message);
|
||||
recipients += 1;
|
||||
}
|
||||
}
|
||||
logOutgoingPush(push, recipients);
|
||||
});
|
||||
|
||||
// HTTP server — serves static files or redirects to Vite dev server
|
||||
const httpServer = http.createServer((req, res) => {
|
||||
// In dev mode, redirect to Vite dev server
|
||||
if (devUrl) {
|
||||
res.writeHead(302, { Location: devUrl });
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Serve static files from the renderer build
|
||||
if (!staticDir) {
|
||||
res.writeHead(503, { "Content-Type": "text/plain" });
|
||||
res.end("No static directory configured and no dev URL set.");
|
||||
return;
|
||||
}
|
||||
|
||||
const url = new URL(req.url ?? "/", `http://localhost:${port}`);
|
||||
let filePath = path.join(staticDir, url.pathname);
|
||||
|
||||
// SPA fallback: if no file extension and not found, serve index.html
|
||||
const ext = path.extname(filePath);
|
||||
if (!ext) {
|
||||
filePath = path.join(filePath, "index.html");
|
||||
}
|
||||
|
||||
fs.stat(filePath, (err, stats) => {
|
||||
if (err || !stats?.isFile()) {
|
||||
// SPA fallback
|
||||
const indexPath = path.join(staticDir, "index.html");
|
||||
fs.readFile(indexPath, (readErr, data) => {
|
||||
if (readErr) {
|
||||
res.writeHead(404, { "Content-Type": "text/plain" });
|
||||
res.end("Not Found");
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
||||
res.end(data);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const fileExt = path.extname(filePath);
|
||||
const contentType = MIME_TYPES[fileExt] ?? "application/octet-stream";
|
||||
|
||||
fs.readFile(filePath, (readErr, data) => {
|
||||
if (readErr) {
|
||||
res.writeHead(500, { "Content-Type": "text/plain" });
|
||||
res.end("Internal Server Error");
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { "Content-Type": contentType });
|
||||
res.end(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// WebSocket server — upgrades from the HTTP server
|
||||
const wss = new WebSocketServer({ noServer: true });
|
||||
|
||||
function rejectUpgrade(socket: Duplex, statusCode: number, message: string): void {
|
||||
socket.write(
|
||||
`HTTP/1.1 ${statusCode} ${statusCode === 401 ? "Unauthorized" : "Bad Request"}\r\n` +
|
||||
"Connection: close\r\n" +
|
||||
"Content-Type: text/plain\r\n" +
|
||||
`Content-Length: ${Buffer.byteLength(message)}\r\n` +
|
||||
"\r\n" +
|
||||
message,
|
||||
);
|
||||
socket.destroy();
|
||||
}
|
||||
|
||||
httpServer.on("upgrade", (request, socket, head) => {
|
||||
if (authToken) {
|
||||
let providedToken: string | null = null;
|
||||
try {
|
||||
const url = new URL(request.url ?? "/", `http://localhost:${port}`);
|
||||
providedToken = url.searchParams.get("token");
|
||||
} catch {
|
||||
rejectUpgrade(socket, 400, "Invalid WebSocket URL");
|
||||
return;
|
||||
}
|
||||
|
||||
if (providedToken !== authToken) {
|
||||
rejectUpgrade(socket, 401, "Unauthorized WebSocket connection");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wss.handleUpgrade(request, socket, head, (ws) => {
|
||||
wss.emit("connection", ws, request);
|
||||
});
|
||||
});
|
||||
|
||||
wss.on("connection", (ws) => {
|
||||
clients.add(ws);
|
||||
|
||||
// Send welcome message with project info
|
||||
const segments = cwd.split(/[/\\]/).filter(Boolean);
|
||||
const projectName = segments[segments.length - 1] ?? "project";
|
||||
|
||||
const welcome: WsPush = {
|
||||
type: "push",
|
||||
channel: WS_CHANNELS.serverWelcome,
|
||||
data: { cwd, projectName },
|
||||
};
|
||||
logOutgoingPush(welcome, 1);
|
||||
ws.send(JSON.stringify(welcome));
|
||||
|
||||
ws.on("message", (raw) => {
|
||||
void handleMessage(ws, raw);
|
||||
});
|
||||
|
||||
ws.on("close", () => {
|
||||
clients.delete(ws);
|
||||
});
|
||||
|
||||
ws.on("error", () => {
|
||||
clients.delete(ws);
|
||||
});
|
||||
});
|
||||
|
||||
async function handleMessage(ws: WebSocket, raw: unknown) {
|
||||
let request: WsRequest;
|
||||
try {
|
||||
const parsed = JSON.parse(String(raw));
|
||||
request = wsRequestSchema.parse(parsed);
|
||||
} catch {
|
||||
const errorResponse: WsResponse = {
|
||||
id: "unknown",
|
||||
error: { message: "Invalid request format" },
|
||||
};
|
||||
ws.send(JSON.stringify(errorResponse));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await routeRequest(request);
|
||||
const response: WsResponse = { id: request.id, result };
|
||||
ws.send(JSON.stringify(response));
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Unknown server error";
|
||||
const response: WsResponse = {
|
||||
id: request.id,
|
||||
error: { message },
|
||||
};
|
||||
ws.send(JSON.stringify(response));
|
||||
}
|
||||
}
|
||||
|
||||
async function routeRequest(request: WsRequest): Promise<unknown> {
|
||||
switch (request.method) {
|
||||
case WS_METHODS.providersStartSession:
|
||||
return providerManager.startSession(request.params as never);
|
||||
|
||||
case WS_METHODS.providersSendTurn:
|
||||
return providerManager.sendTurn(request.params as never);
|
||||
|
||||
case WS_METHODS.providersInterruptTurn:
|
||||
return providerManager.interruptTurn(request.params as never);
|
||||
|
||||
case WS_METHODS.providersRespondToRequest:
|
||||
return providerManager.respondToRequest(request.params as never);
|
||||
|
||||
case WS_METHODS.providersStopSession: {
|
||||
providerManager.stopSession(request.params as never);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
case WS_METHODS.providersListSessions:
|
||||
return providerManager.listSessions();
|
||||
|
||||
case WS_METHODS.projectsList:
|
||||
return projectRegistry.list();
|
||||
|
||||
case WS_METHODS.projectsAdd:
|
||||
return projectRegistry.add(request.params as never);
|
||||
|
||||
case WS_METHODS.projectsRemove:
|
||||
projectRegistry.remove(request.params as never);
|
||||
return undefined;
|
||||
|
||||
case WS_METHODS.shellOpenInEditor: {
|
||||
const params = request.params as {
|
||||
cwd: string;
|
||||
editor: string;
|
||||
};
|
||||
if (!params?.cwd) throw new Error("cwd is required");
|
||||
const editorDef = EDITORS.find((e) => e.id === params.editor);
|
||||
if (!editorDef) throw new Error(`Unknown editor: ${params.editor}`);
|
||||
if (!editorDef.command) {
|
||||
// Can't open file manager programmatically from server, just succeed silently
|
||||
return undefined;
|
||||
}
|
||||
const child = spawn(editorDef.command, [params.cwd], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
});
|
||||
child.on("error", () => {
|
||||
/* ignore spawn failures for detached editors */
|
||||
});
|
||||
child.unref();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
case WS_METHODS.serverGetConfig:
|
||||
return { cwd };
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown method: ${request.method}`);
|
||||
}
|
||||
}
|
||||
|
||||
function start() {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const onError = (error: Error) => {
|
||||
httpServer.off("error", onError);
|
||||
reject(error);
|
||||
};
|
||||
httpServer.once("error", onError);
|
||||
const onListening = () => {
|
||||
httpServer.off("error", onError);
|
||||
resolve();
|
||||
};
|
||||
if (host) {
|
||||
httpServer.listen(port, host, onListening);
|
||||
return;
|
||||
}
|
||||
httpServer.listen(port, onListening);
|
||||
});
|
||||
}
|
||||
|
||||
async function stop(): Promise<void> {
|
||||
providerManager.stopAll();
|
||||
providerManager.dispose();
|
||||
|
||||
for (const client of clients) {
|
||||
client.close();
|
||||
}
|
||||
clients.clear();
|
||||
|
||||
const isServerNotRunningError = (error: unknown): boolean => {
|
||||
if (!(error instanceof Error)) return false;
|
||||
const maybeCode = (error as NodeJS.ErrnoException).code;
|
||||
return maybeCode === "ERR_SERVER_NOT_RUNNING" || error.message.toLowerCase().includes("not running");
|
||||
};
|
||||
|
||||
const closeWebSocketServer = new Promise<void>((resolve, reject) => {
|
||||
wss.close((error) => {
|
||||
if (error && !isServerNotRunningError(error)) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const closeHttpServer = new Promise<void>((resolve, reject) => {
|
||||
httpServer.close((error) => {
|
||||
if (error && !isServerNotRunningError(error)) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all([closeWebSocketServer, closeHttpServer]);
|
||||
}
|
||||
|
||||
return { start, stop, httpServer };
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node"]
|
||||
"composite": true,
|
||||
"types": ["node"],
|
||||
"lib": ["ES2023"]
|
||||
},
|
||||
"include": ["src", "tsup.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
export default defineConfig({
|
||||
entry: ["src/index.ts"],
|
||||
format: "esm",
|
||||
outDir: "dist",
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
noExternal: ["@acme/contracts"],
|
||||
banner: {
|
||||
js: '#!/usr/bin/env node\n',
|
||||
},
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"name": "@acme/t3-runtime",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"t3": "dist/cli.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx src/cli.ts",
|
||||
"build": "tsup --config tsup.config.ts",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run --passWithNoTests",
|
||||
"smoke-test": "node scripts/smoke-test.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@acme/contracts": "workspace:*",
|
||||
"@acme/runtime-core": "workspace:*",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/ws": "^8.5.13",
|
||||
"tsup": "^8.3.5",
|
||||
"tsx": "^4.20.3",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
-1175
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,818 +0,0 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { WebSocket, WebSocketServer, type RawData } from "ws";
|
||||
|
||||
import {
|
||||
EDITORS,
|
||||
DEFAULT_MODEL,
|
||||
appBootstrapResultSchema,
|
||||
appHealthResultSchema,
|
||||
dialogsPickFolderResultSchema,
|
||||
type ProviderSession,
|
||||
type WsClientMessage,
|
||||
type WsResponseMessage,
|
||||
type WsServerMessage,
|
||||
WS_EVENT_CHANNELS,
|
||||
WS_ERROR_CODE_MAX_CHARS,
|
||||
WS_ERROR_MESSAGE_MAX_CHARS,
|
||||
WS_CLOSE_CODES,
|
||||
WS_CLOSE_REASONS,
|
||||
agentConfigSchema,
|
||||
agentSessionIdSchema,
|
||||
agentWriteInputSchema,
|
||||
newTodoInputSchema,
|
||||
todoIdSchema,
|
||||
providerInterruptTurnInputSchema,
|
||||
providerRespondToRequestInputSchema,
|
||||
providerSendTurnInputSchema,
|
||||
providerSessionListSchema,
|
||||
providerSessionStartInputSchema,
|
||||
providerSessionSchema,
|
||||
providerStopSessionInputSchema,
|
||||
providerTurnStartResultSchema,
|
||||
type TerminalCommandInput,
|
||||
shellOpenInEditorInputSchema,
|
||||
terminalCommandResultSchema,
|
||||
terminalCommandInputSchema,
|
||||
todoListSchema,
|
||||
wsClientMessageSchema,
|
||||
wsNativeApiMethodSchema,
|
||||
wsServerMessageSchema,
|
||||
} from "@acme/contracts";
|
||||
import { ProcessManager, ProviderManager, TodoStore } from "@acme/runtime-core";
|
||||
|
||||
interface RuntimeApiServerOptions {
|
||||
port: number;
|
||||
launchCwd: string;
|
||||
bootstrapSessionTimeoutMs?: number;
|
||||
authToken?: string;
|
||||
}
|
||||
|
||||
interface RuntimeApiServer {
|
||||
wsUrl: string;
|
||||
close: () => Promise<void>;
|
||||
}
|
||||
|
||||
interface JsonRpcErrorResult {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
const BOOTSTRAP_SESSION_TIMEOUT_MS = 3_000;
|
||||
const MAX_BOOTSTRAP_SESSION_TIMEOUT_MS = 120_000;
|
||||
const MAX_WS_CLIENT_PAYLOAD_BYTES = 5 * 1024 * 1024;
|
||||
const MAX_ERROR_PATH_CHARS = 2_048;
|
||||
|
||||
interface BootstrapSessionResult {
|
||||
session: ProviderSession;
|
||||
bootstrapError: string | undefined;
|
||||
}
|
||||
|
||||
type WsServerEventMessage = Extract<WsServerMessage, { type: "event" }>;
|
||||
|
||||
function raceWithTimeout<T>(
|
||||
promise: Promise<T>,
|
||||
timeoutMs: number,
|
||||
timeoutMessage: string,
|
||||
): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
reject(new Error(timeoutMessage));
|
||||
}, timeoutMs);
|
||||
timeout.unref();
|
||||
|
||||
promise.then(
|
||||
(value) => {
|
||||
clearTimeout(timeout);
|
||||
resolve(value);
|
||||
},
|
||||
(error) => {
|
||||
clearTimeout(timeout);
|
||||
reject(error);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function responseSuccess(id: string, result: unknown): WsResponseMessage {
|
||||
return {
|
||||
type: "response",
|
||||
id,
|
||||
ok: true,
|
||||
result: result === undefined ? null : result,
|
||||
};
|
||||
}
|
||||
|
||||
function responseError(id: string, error: JsonRpcErrorResult): WsResponseMessage {
|
||||
const normalizedCode = normalizeErrorField(
|
||||
error.code,
|
||||
"request_failed",
|
||||
WS_ERROR_CODE_MAX_CHARS,
|
||||
);
|
||||
const normalizedMessage = normalizeErrorField(
|
||||
error.message,
|
||||
"Request failed",
|
||||
WS_ERROR_MESSAGE_MAX_CHARS,
|
||||
);
|
||||
return {
|
||||
type: "response",
|
||||
id,
|
||||
ok: false,
|
||||
error: {
|
||||
code: normalizedCode,
|
||||
message: normalizedMessage,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeErrorField(value: string, fallback: string, maxChars: number): string {
|
||||
const trimmed = value.trim();
|
||||
const safeValue = trimmed.length > 0 ? trimmed : fallback;
|
||||
if (safeValue.length <= maxChars) {
|
||||
return safeValue;
|
||||
}
|
||||
|
||||
if (maxChars <= 1) {
|
||||
return safeValue.slice(0, maxChars);
|
||||
}
|
||||
|
||||
return `${safeValue.slice(0, maxChars - 1)}…`;
|
||||
}
|
||||
|
||||
function summarizePathForError(candidatePath: string): string {
|
||||
if (candidatePath.length <= MAX_ERROR_PATH_CHARS) {
|
||||
return candidatePath;
|
||||
}
|
||||
|
||||
const prefixLength = Math.floor((MAX_ERROR_PATH_CHARS - 1) / 2);
|
||||
const suffixLength = MAX_ERROR_PATH_CHARS - 1 - prefixLength;
|
||||
return `${candidatePath.slice(0, prefixLength)}…${candidatePath.slice(-suffixLength)}`;
|
||||
}
|
||||
|
||||
function sendMessage(socket: WebSocket, message: unknown): void {
|
||||
if (socket.readyState !== WebSocket.OPEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedMessage = wsServerMessageSchema.safeParse(message);
|
||||
if (!parsedMessage.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
socket.send(JSON.stringify(parsedMessage.data));
|
||||
} catch {
|
||||
// Best-effort event delivery. Socket may have transitioned states.
|
||||
}
|
||||
}
|
||||
|
||||
function decodeClientMessage(raw: RawData): string | null {
|
||||
if (typeof raw === "string") {
|
||||
return raw;
|
||||
}
|
||||
|
||||
if (raw instanceof Buffer) {
|
||||
return raw.toString("utf8");
|
||||
}
|
||||
|
||||
if (raw instanceof ArrayBuffer) {
|
||||
return Buffer.from(raw).toString("utf8");
|
||||
}
|
||||
|
||||
if (Array.isArray(raw)) {
|
||||
return Buffer.concat(raw).toString("utf8");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function openPathInFileManager(targetPath: string): void {
|
||||
const command =
|
||||
process.platform === "win32" ? "explorer" : process.platform === "darwin" ? "open" : "xdg-open";
|
||||
|
||||
const child = spawn(command, [targetPath], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
});
|
||||
child.on("error", () => {
|
||||
// Best-effort shell handoff.
|
||||
});
|
||||
child.unref();
|
||||
}
|
||||
|
||||
async function tryCommand(command: string, args: string[]): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
const child = spawn(command, args, {
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
|
||||
let output = "";
|
||||
child.stdout.on("data", (chunk: Buffer) => {
|
||||
output += chunk.toString();
|
||||
});
|
||||
|
||||
child.on("error", () => {
|
||||
resolve(null);
|
||||
});
|
||||
|
||||
child.on("close", (code) => {
|
||||
if (code !== 0) {
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const trimmed = output.trim();
|
||||
resolve(trimmed.length > 0 ? trimmed : null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function pickFolder(): Promise<string | null> {
|
||||
if (process.platform === "darwin") {
|
||||
const script =
|
||||
'try\nset selectedFolder to POSIX path of (choose folder with prompt "Choose a project folder")\nreturn selectedFolder\non error\nreturn ""\nend try';
|
||||
const result = await tryCommand("osascript", ["-e", script]);
|
||||
return result && result.length > 0 ? result : null;
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
const powershellScript = [
|
||||
"Add-Type -AssemblyName System.Windows.Forms",
|
||||
"$dialog = New-Object System.Windows.Forms.FolderBrowserDialog",
|
||||
'$dialog.Description = "Choose a project folder"',
|
||||
"if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {",
|
||||
" Write-Output $dialog.SelectedPath",
|
||||
"}",
|
||||
].join("; ");
|
||||
const result = await tryCommand("powershell", ["-NoProfile", "-Command", powershellScript]);
|
||||
return result && result.length > 0 ? result : null;
|
||||
}
|
||||
|
||||
const zenity = await tryCommand("zenity", ["--file-selection", "--directory"]);
|
||||
if (zenity) {
|
||||
return zenity;
|
||||
}
|
||||
|
||||
const kdialog = await tryCommand("kdialog", ["--getexistingdirectory"]);
|
||||
if (kdialog) {
|
||||
return kdialog;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async function runTerminalCommand(
|
||||
parsed: TerminalCommandInput,
|
||||
defaultCwd: string,
|
||||
) {
|
||||
const providedCwd = parsed.cwd ?? defaultCwd;
|
||||
const resolvedCwd = resolveExistingDirectoryFromBase(
|
||||
providedCwd,
|
||||
"Working directory",
|
||||
defaultCwd,
|
||||
);
|
||||
|
||||
const shellPath =
|
||||
process.platform === "win32"
|
||||
? (process.env.ComSpec ?? "cmd.exe")
|
||||
: (process.env.SHELL ?? "/bin/sh");
|
||||
const args =
|
||||
process.platform === "win32" ? ["/d", "/s", "/c", parsed.command] : ["-lc", parsed.command];
|
||||
|
||||
return new Promise<{
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
code: number | null;
|
||||
signal: string | null;
|
||||
timedOut: boolean;
|
||||
}>((resolve, reject) => {
|
||||
const child = spawn(shellPath, args, {
|
||||
cwd: resolvedCwd,
|
||||
env: process.env,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
let timedOut = false;
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
timedOut = true;
|
||||
child.kill("SIGTERM");
|
||||
setTimeout(() => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
child.kill("SIGKILL");
|
||||
}
|
||||
}, 1_000).unref();
|
||||
}, parsed.timeoutMs ?? 30_000);
|
||||
timeout.unref();
|
||||
|
||||
child.stdout?.on("data", (chunk: Buffer) => {
|
||||
stdout += chunk.toString();
|
||||
});
|
||||
child.stderr?.on("data", (chunk: Buffer) => {
|
||||
stderr += chunk.toString();
|
||||
});
|
||||
child.on("error", (error) => {
|
||||
clearTimeout(timeout);
|
||||
reject(error);
|
||||
});
|
||||
child.on("close", (code, signal) => {
|
||||
clearTimeout(timeout);
|
||||
resolve({
|
||||
stdout,
|
||||
stderr,
|
||||
code: code ?? null,
|
||||
signal: signal ?? null,
|
||||
timedOut,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resolveExistingDirectory(targetPath: string, label: string): string {
|
||||
if (typeof targetPath !== "string" || targetPath.trim().length === 0) {
|
||||
throw new Error(`${label} must be a non-empty path.`);
|
||||
}
|
||||
|
||||
const candidate = path.resolve(targetPath);
|
||||
let stats: fs.Stats;
|
||||
try {
|
||||
stats = fs.statSync(candidate);
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException | undefined)?.code;
|
||||
const safeCandidate = summarizePathForError(candidate);
|
||||
if (code && code !== "ENOENT") {
|
||||
throw new Error(`Failed to access ${label.toLowerCase()}: ${safeCandidate} (${code})`, {
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
throw new Error(`${label} does not exist: ${safeCandidate}`, {
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
|
||||
if (!stats.isDirectory()) {
|
||||
throw new Error(`${label} is not a directory: ${summarizePathForError(candidate)}`);
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
function resolveExistingDirectoryFromBase(
|
||||
targetPath: string,
|
||||
label: string,
|
||||
baseDirectory: string,
|
||||
): string {
|
||||
if (typeof targetPath !== "string" || targetPath.trim().length === 0) {
|
||||
throw new Error(`${label} must be a non-empty path.`);
|
||||
}
|
||||
|
||||
const candidate = path.isAbsolute(targetPath)
|
||||
? path.resolve(targetPath)
|
||||
: path.resolve(baseDirectory, targetPath);
|
||||
return resolveExistingDirectory(candidate, label);
|
||||
}
|
||||
|
||||
export async function startRuntimeApiServer(
|
||||
options: RuntimeApiServerOptions,
|
||||
): Promise<RuntimeApiServer> {
|
||||
if (!Number.isInteger(options.port) || options.port < 0 || options.port > 65_535) {
|
||||
throw new Error("Invalid runtime port: expected integer between 0 and 65535.");
|
||||
}
|
||||
const launchCwd = resolveExistingDirectory(options.launchCwd, "Invalid launchCwd");
|
||||
if (options.authToken !== undefined && typeof options.authToken !== "string") {
|
||||
throw new Error("Invalid runtime auth token: expected non-empty string.");
|
||||
}
|
||||
const authToken = options.authToken?.trim();
|
||||
if (options.authToken !== undefined && !authToken) {
|
||||
throw new Error("Invalid runtime auth token: expected non-empty string.");
|
||||
}
|
||||
const bootstrapSessionTimeoutMs =
|
||||
options.bootstrapSessionTimeoutMs ?? BOOTSTRAP_SESSION_TIMEOUT_MS;
|
||||
if (
|
||||
!Number.isInteger(bootstrapSessionTimeoutMs) ||
|
||||
bootstrapSessionTimeoutMs <= 0 ||
|
||||
bootstrapSessionTimeoutMs > MAX_BOOTSTRAP_SESSION_TIMEOUT_MS
|
||||
) {
|
||||
throw new Error(
|
||||
`Invalid bootstrapSessionTimeoutMs: expected integer between 1 and ${MAX_BOOTSTRAP_SESSION_TIMEOUT_MS}.`,
|
||||
);
|
||||
}
|
||||
const providerManager = new ProviderManager();
|
||||
const processManager = new ProcessManager();
|
||||
const todoStore = new TodoStore(path.join(os.homedir(), ".t3", "todos.json"));
|
||||
await todoStore.init();
|
||||
|
||||
let activeClient: WebSocket | null = null;
|
||||
let launchSessionPromise: Promise<BootstrapSessionResult> | null = null;
|
||||
let bootstrapFallbackSession: ProviderSession | null = null;
|
||||
|
||||
const emitEvent = <TChannel extends WsServerEventMessage["channel"]>(
|
||||
channel: TChannel,
|
||||
payload: Extract<WsServerEventMessage, { channel: TChannel }>["payload"],
|
||||
) => {
|
||||
if (!activeClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessage(activeClient, {
|
||||
type: "event",
|
||||
channel,
|
||||
payload,
|
||||
});
|
||||
};
|
||||
|
||||
processManager.on("output", (chunk) => {
|
||||
emitEvent(WS_EVENT_CHANNELS.agentOutput, chunk);
|
||||
});
|
||||
processManager.on("exit", (payload) => {
|
||||
emitEvent(WS_EVENT_CHANNELS.agentExit, payload);
|
||||
});
|
||||
providerManager.on("event", (payload) => {
|
||||
emitEvent(WS_EVENT_CHANNELS.providerEvent, payload);
|
||||
});
|
||||
|
||||
const createBootstrapErrorSession = (message: string): ProviderSession => {
|
||||
const timestamp = new Date().toISOString();
|
||||
return {
|
||||
sessionId: `bootstrap-error-${Date.now()}`,
|
||||
provider: "codex",
|
||||
status: "error",
|
||||
cwd: launchCwd,
|
||||
model: DEFAULT_MODEL,
|
||||
createdAt: timestamp,
|
||||
updatedAt: timestamp,
|
||||
lastError: message,
|
||||
};
|
||||
};
|
||||
|
||||
const ensureLaunchSession = async (): Promise<BootstrapSessionResult> => {
|
||||
const isLaunchProjectSession = (session: ProviderSession) => {
|
||||
if (!session.cwd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return path.resolve(session.cwd) === launchCwd;
|
||||
};
|
||||
|
||||
const existingSession = providerManager
|
||||
.listSessions()
|
||||
.find((session) => isLaunchProjectSession(session) && session.status !== "closed");
|
||||
if (existingSession) {
|
||||
bootstrapFallbackSession = null;
|
||||
return {
|
||||
session: existingSession,
|
||||
bootstrapError: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
if (bootstrapFallbackSession) {
|
||||
return {
|
||||
session: bootstrapFallbackSession,
|
||||
bootstrapError: bootstrapFallbackSession.lastError,
|
||||
};
|
||||
}
|
||||
|
||||
if (launchSessionPromise) {
|
||||
return launchSessionPromise;
|
||||
}
|
||||
|
||||
launchSessionPromise = (async () => {
|
||||
try {
|
||||
const startedSession = await raceWithTimeout(
|
||||
providerManager.startSession({
|
||||
provider: "codex",
|
||||
cwd: launchCwd,
|
||||
model: DEFAULT_MODEL,
|
||||
approvalPolicy: "never",
|
||||
sandboxMode: "danger-full-access",
|
||||
}),
|
||||
bootstrapSessionTimeoutMs,
|
||||
"Timed out starting launch session.",
|
||||
);
|
||||
bootstrapFallbackSession = null;
|
||||
return {
|
||||
session: startedSession,
|
||||
bootstrapError: undefined,
|
||||
};
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Failed to initialize Codex launch session.";
|
||||
const fallbackSession = (() => {
|
||||
if (!bootstrapFallbackSession) {
|
||||
return createBootstrapErrorSession(message);
|
||||
}
|
||||
|
||||
return Object.assign({}, bootstrapFallbackSession, {
|
||||
lastError: message,
|
||||
updatedAt: new Date().toISOString(),
|
||||
}) as ProviderSession;
|
||||
})();
|
||||
bootstrapFallbackSession = fallbackSession;
|
||||
return {
|
||||
session: fallbackSession,
|
||||
bootstrapError: message,
|
||||
};
|
||||
} finally {
|
||||
launchSessionPromise = null;
|
||||
}
|
||||
})();
|
||||
|
||||
const pendingLaunchSessionPromise = launchSessionPromise;
|
||||
if (!pendingLaunchSessionPromise) {
|
||||
throw new Error("Could not initialize launch session promise.");
|
||||
}
|
||||
return pendingLaunchSessionPromise;
|
||||
};
|
||||
|
||||
const wss = new WebSocketServer({
|
||||
host: "127.0.0.1",
|
||||
port: options.port,
|
||||
maxPayload: MAX_WS_CLIENT_PAYLOAD_BYTES,
|
||||
perMessageDeflate: false,
|
||||
});
|
||||
|
||||
const isAuthorizedConnection = (requestUrl: string | undefined) => {
|
||||
if (!requestUrl) {
|
||||
return authToken === null;
|
||||
}
|
||||
|
||||
try {
|
||||
const request = new URL(requestUrl, "ws://127.0.0.1");
|
||||
if (request.pathname !== "/") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!authToken) {
|
||||
return request.searchParams.size === 0;
|
||||
}
|
||||
|
||||
const tokens = request.searchParams.getAll("token");
|
||||
return (
|
||||
request.searchParams.size === 1 &&
|
||||
tokens.length === 1 &&
|
||||
tokens[0] === authToken
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveMethod = async (method: string, params: unknown) => {
|
||||
const parsedMethod = wsNativeApiMethodSchema.safeParse(method);
|
||||
if (!parsedMethod.success) {
|
||||
throw new Error(`Unknown API method: ${method}`);
|
||||
}
|
||||
|
||||
const apiMethod = parsedMethod.data;
|
||||
switch (apiMethod) {
|
||||
case "app.bootstrap": {
|
||||
const bootstrap = await ensureLaunchSession();
|
||||
const payload = {
|
||||
launchCwd,
|
||||
projectName: path.basename(launchCwd) || launchCwd,
|
||||
provider: "codex",
|
||||
model: bootstrap.session.model ?? DEFAULT_MODEL,
|
||||
session: bootstrap.session,
|
||||
...(bootstrap.bootstrapError
|
||||
? { bootstrapError: bootstrap.bootstrapError }
|
||||
: {}),
|
||||
};
|
||||
return appBootstrapResultSchema.parse(payload);
|
||||
}
|
||||
|
||||
case "app.health": {
|
||||
const payload = {
|
||||
status: "ok",
|
||||
launchCwd,
|
||||
sessionCount: providerManager.listSessions().length,
|
||||
activeClientConnected: activeClient !== null,
|
||||
};
|
||||
return appHealthResultSchema.parse(payload);
|
||||
}
|
||||
|
||||
case "todos.list":
|
||||
return todoListSchema.parse(await todoStore.list());
|
||||
case "todos.add":
|
||||
return todoListSchema.parse(await todoStore.add(newTodoInputSchema.parse(params)));
|
||||
case "todos.toggle":
|
||||
return todoListSchema.parse(await todoStore.toggle(todoIdSchema.parse(params)));
|
||||
case "todos.remove":
|
||||
return todoListSchema.parse(await todoStore.remove(todoIdSchema.parse(params)));
|
||||
|
||||
case "dialogs.pickFolder":
|
||||
return dialogsPickFolderResultSchema.parse(await pickFolder());
|
||||
case "terminal.run":
|
||||
return terminalCommandResultSchema.parse(
|
||||
await runTerminalCommand(terminalCommandInputSchema.parse(params), launchCwd),
|
||||
);
|
||||
|
||||
case "agent.spawn":
|
||||
return agentSessionIdSchema.parse(processManager.spawn(agentConfigSchema.parse(params)));
|
||||
case "agent.kill":
|
||||
processManager.kill(agentSessionIdSchema.parse(params));
|
||||
return null;
|
||||
case "agent.write": {
|
||||
const parsed = agentWriteInputSchema.parse(params);
|
||||
processManager.write(parsed.sessionId, parsed.data);
|
||||
return null;
|
||||
}
|
||||
|
||||
case "providers.startSession": {
|
||||
const session = await providerManager.startSession(
|
||||
providerSessionStartInputSchema.parse(params),
|
||||
);
|
||||
bootstrapFallbackSession = null;
|
||||
return providerSessionSchema.parse(session);
|
||||
}
|
||||
case "providers.sendTurn":
|
||||
return providerTurnStartResultSchema.parse(
|
||||
await providerManager.sendTurn(providerSendTurnInputSchema.parse(params)),
|
||||
);
|
||||
case "providers.interruptTurn":
|
||||
await providerManager.interruptTurn(providerInterruptTurnInputSchema.parse(params));
|
||||
return null;
|
||||
case "providers.respondToRequest":
|
||||
await providerManager.respondToRequest(providerRespondToRequestInputSchema.parse(params));
|
||||
return null;
|
||||
case "providers.stopSession":
|
||||
providerManager.stopSession(providerStopSessionInputSchema.parse(params));
|
||||
return null;
|
||||
case "providers.listSessions":
|
||||
return providerSessionListSchema.parse(providerManager.listSessions());
|
||||
|
||||
case "shell.openInEditor": {
|
||||
const parsed = shellOpenInEditorInputSchema.parse(params);
|
||||
const targetPath = resolveExistingDirectoryFromBase(parsed.cwd, "Editor target", launchCwd);
|
||||
|
||||
const editor = EDITORS.find((entry) => entry.id === parsed.editor);
|
||||
if (!editor) {
|
||||
throw new Error(`Unknown editor: ${parsed.editor}`);
|
||||
}
|
||||
|
||||
if (!editor.command) {
|
||||
openPathInFileManager(targetPath);
|
||||
return null;
|
||||
}
|
||||
|
||||
const child = spawn(editor.command, [targetPath], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
});
|
||||
child.on("error", () => {
|
||||
// Best-effort editor launch.
|
||||
});
|
||||
child.unref();
|
||||
return null;
|
||||
}
|
||||
|
||||
default: {
|
||||
const unreachableMethod: never = apiMethod;
|
||||
throw new Error(`Unknown API method: ${unreachableMethod}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
wss.on("connection", (socket, request) => {
|
||||
if (!isAuthorizedConnection(request.url)) {
|
||||
socket.close(WS_CLOSE_CODES.unauthorized, WS_CLOSE_REASONS.unauthorized);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeClient && activeClient !== socket) {
|
||||
activeClient.close(
|
||||
WS_CLOSE_CODES.replacedByNewClient,
|
||||
WS_CLOSE_REASONS.replacedByNewClient,
|
||||
);
|
||||
}
|
||||
|
||||
activeClient = socket;
|
||||
sendMessage(socket, {
|
||||
type: "hello",
|
||||
version: 1,
|
||||
launchCwd,
|
||||
});
|
||||
|
||||
socket.on("message", async (raw) => {
|
||||
const decoded = decodeClientMessage(raw);
|
||||
if (!decoded) {
|
||||
return;
|
||||
}
|
||||
|
||||
const maybeParsed = (() => {
|
||||
try {
|
||||
return JSON.parse(decoded) as unknown;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
if (!maybeParsed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsed = wsClientMessageSchema.safeParse(maybeParsed);
|
||||
if (!parsed.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = parsed.data as WsClientMessage;
|
||||
try {
|
||||
const result = await resolveMethod(message.method, message.params);
|
||||
sendMessage(socket, responseSuccess(message.id, result));
|
||||
} catch (error) {
|
||||
sendMessage(
|
||||
socket,
|
||||
responseError(message.id, {
|
||||
code: "request_failed",
|
||||
message: error instanceof Error ? error.message : "Request failed",
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("close", () => {
|
||||
if (activeClient === socket) {
|
||||
activeClient = null;
|
||||
}
|
||||
});
|
||||
socket.on("error", () => {
|
||||
// Connection-level protocol/socket errors are expected occasionally
|
||||
// (for example oversized client payloads). Keep server process alive.
|
||||
if (activeClient === socket && socket.readyState !== WebSocket.OPEN) {
|
||||
activeClient = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
if (wss.address()) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const onListening = () => {
|
||||
wss.off("error", onError);
|
||||
resolve();
|
||||
};
|
||||
const onError = (error: Error) => {
|
||||
wss.off("listening", onListening);
|
||||
reject(error);
|
||||
};
|
||||
|
||||
wss.once("listening", onListening);
|
||||
wss.once("error", onError);
|
||||
});
|
||||
} catch (error) {
|
||||
processManager.killAll();
|
||||
providerManager.stopAll();
|
||||
providerManager.dispose();
|
||||
await new Promise<void>((resolve) => {
|
||||
try {
|
||||
wss.close(() => resolve());
|
||||
} catch {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
const address = wss.address();
|
||||
const resolvedPort =
|
||||
typeof address === "object" && address !== null ? address.port : options.port;
|
||||
const wsBaseUrl = `ws://127.0.0.1:${resolvedPort}`;
|
||||
const wsUrl = authToken
|
||||
? `${wsBaseUrl}?token=${encodeURIComponent(authToken)}`
|
||||
: wsBaseUrl;
|
||||
let closePromise: Promise<void> | null = null;
|
||||
|
||||
return {
|
||||
wsUrl,
|
||||
close() {
|
||||
if (closePromise) {
|
||||
return closePromise;
|
||||
}
|
||||
|
||||
closePromise = (async () => {
|
||||
processManager.killAll();
|
||||
providerManager.stopAll();
|
||||
providerManager.dispose();
|
||||
activeClient = null;
|
||||
for (const client of wss.clients) {
|
||||
client.terminate();
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
wss.close(() => resolve());
|
||||
});
|
||||
})();
|
||||
|
||||
return closePromise;
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const RUNTIME_SOURCE_FILES = ["cli.ts", "runtimeApiServer.ts"] as const;
|
||||
|
||||
describe("runtime architecture boundaries", () => {
|
||||
it("keeps runtime API server wired through runtime-core services", () => {
|
||||
const sourcePath = path.resolve(import.meta.dirname, "runtimeApiServer.ts");
|
||||
const source = fs.readFileSync(sourcePath, "utf8");
|
||||
|
||||
expect(source).toContain("from \"@acme/runtime-core\"");
|
||||
expect(source).toContain("ProcessManager");
|
||||
expect(source).toContain("ProviderManager");
|
||||
expect(source).toContain("TodoStore");
|
||||
});
|
||||
|
||||
for (const fileName of RUNTIME_SOURCE_FILES) {
|
||||
it(`avoids direct desktop service imports in ${fileName}`, () => {
|
||||
const sourcePath = path.resolve(import.meta.dirname, fileName);
|
||||
const source = fs.readFileSync(sourcePath, "utf8");
|
||||
|
||||
expect(source).not.toContain("../../desktop/src/");
|
||||
});
|
||||
}
|
||||
|
||||
it("does not rely on a legacy desktop workspace package", () => {
|
||||
const legacyDesktopPackagePath = path.resolve(
|
||||
import.meta.dirname,
|
||||
"..",
|
||||
"..",
|
||||
"desktop",
|
||||
"package.json",
|
||||
);
|
||||
|
||||
expect(fs.existsSync(legacyDesktopPackagePath)).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps runtime-core bundled into published t3 runtime output", () => {
|
||||
const tsupConfigPath = path.resolve(import.meta.dirname, "..", "tsup.config.ts");
|
||||
const tsupConfigSource = fs.readFileSync(tsupConfigPath, "utf8");
|
||||
|
||||
expect(tsupConfigSource).toContain("\"@acme/runtime-core\"");
|
||||
expect(tsupConfigSource).toContain("noExternal");
|
||||
});
|
||||
|
||||
it("keeps smoke tests independent from real codex installation", () => {
|
||||
const smokeScriptPath = path.resolve(import.meta.dirname, "..", "scripts", "smoke-test.mjs");
|
||||
const smokeScriptSource = fs.readFileSync(smokeScriptPath, "utf8");
|
||||
|
||||
expect(smokeScriptSource).toContain("../../../test-support/fakeCodexAppServer.mjs");
|
||||
expect(smokeScriptSource).toContain("createFakeCodexAppServerBinary");
|
||||
expect(smokeScriptSource).toContain("PATH: `${fakeCodex.tempDir}${path.delimiter}");
|
||||
expect(smokeScriptSource).toContain("fs.rmSync(fakeCodex.tempDir");
|
||||
});
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
export default defineConfig({
|
||||
entry: ["src/cli.ts"],
|
||||
format: ["esm"],
|
||||
dts: true,
|
||||
clean: true,
|
||||
noExternal: ["@acme/contracts", "@acme/runtime-core"],
|
||||
outDir: "dist",
|
||||
});
|
||||
@@ -4,10 +4,6 @@
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "ct-round-5",
|
||||
"dependencies": {
|
||||
"ws": "^8.18.0",
|
||||
"zod": "^3.24.1",
|
||||
},
|
||||
"devDependencies": {
|
||||
"oxfmt": "^0.28.0",
|
||||
"oxlint": "^1.43.0",
|
||||
@@ -16,6 +12,22 @@
|
||||
"vitest": "^3.0.0",
|
||||
},
|
||||
},
|
||||
"apps/desktop": {
|
||||
"name": "@acme/desktop",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"electron": "33.4.11",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"concurrently": "^9.1.2",
|
||||
"electronmon": "^2.0.2",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.3",
|
||||
"vitest": "^3.0.0",
|
||||
"wait-on": "^8.0.2",
|
||||
},
|
||||
},
|
||||
"apps/renderer": {
|
||||
"name": "@acme/renderer",
|
||||
"version": "0.0.0",
|
||||
@@ -41,22 +53,23 @@
|
||||
"vite": "^6.0.5",
|
||||
},
|
||||
},
|
||||
"apps/t3": {
|
||||
"name": "@acme/t3-runtime",
|
||||
"version": "0.0.0",
|
||||
"apps/server": {
|
||||
"name": "t3",
|
||||
"version": "0.1.0",
|
||||
"bin": {
|
||||
"t3": "dist/cli.js",
|
||||
"t3": "./dist/index.js",
|
||||
},
|
||||
"dependencies": {
|
||||
"@acme/contracts": "workspace:*",
|
||||
"@acme/runtime-core": "workspace:*",
|
||||
"open": "^10.1.0",
|
||||
"ws": "^8.18.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@acme/contracts": "workspace:*",
|
||||
"@acme/renderer": "workspace:*",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/ws": "^8.5.13",
|
||||
"tsup": "^8.3.5",
|
||||
"tsx": "^4.20.3",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.7.3",
|
||||
},
|
||||
},
|
||||
@@ -71,28 +84,14 @@
|
||||
"typescript": "^5.7.3",
|
||||
},
|
||||
},
|
||||
"packages/runtime-core": {
|
||||
"name": "@acme/runtime-core",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@acme/contracts": "workspace:*",
|
||||
"node-pty": "^1.0.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"typescript": "^5.7.3",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@acme/contracts": ["@acme/contracts@workspace:packages/contracts"],
|
||||
|
||||
"@acme/desktop": ["@acme/desktop@workspace:apps/desktop"],
|
||||
|
||||
"@acme/renderer": ["@acme/renderer@workspace:apps/renderer"],
|
||||
|
||||
"@acme/runtime-core": ["@acme/runtime-core@workspace:packages/runtime-core"],
|
||||
|
||||
"@acme/t3-runtime": ["@acme/t3-runtime@workspace:apps/t3"],
|
||||
|
||||
"@babel/code-frame": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw=="],
|
||||
|
||||
"@babel/compat-data": ["@babel/[email protected]", "", {}, "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg=="],
|
||||
@@ -131,6 +130,8 @@
|
||||
|
||||
"@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
|
||||
|
||||
"@electron/get": ["@electron/[email protected]", "", { "dependencies": { "debug": "^4.1.1", "env-paths": "^2.2.0", "fs-extra": "^8.1.0", "got": "^11.8.5", "progress": "^2.0.3", "semver": "^6.2.0", "sumchecker": "^3.0.1" }, "optionalDependencies": { "global-agent": "^3.0.0" } }, "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ=="],
|
||||
|
||||
"@esbuild/aix-ppc64": ["@esbuild/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg=="],
|
||||
|
||||
"@esbuild/android-arm": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA=="],
|
||||
@@ -183,6 +184,18 @@
|
||||
|
||||
"@esbuild/win32-x64": ["@esbuild/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA=="],
|
||||
|
||||
"@hapi/address": ["@hapi/[email protected]", "", { "dependencies": { "@hapi/hoek": "^11.0.2" } }, "sha512-A+po2d/dVoY7cYajycYI43ZbYMXukuopIsqCjh5QzsBCipDtdofHntljDlpccMjIfTy6UOkg+5KPriwYch2bXA=="],
|
||||
|
||||
"@hapi/formula": ["@hapi/[email protected]", "", {}, "sha512-hY5YPNXzw1He7s0iqkRQi+uMGh383CGdyyIGYtB+W5N3KHPXoqychklvHhKCC9M3Xtv0OCs/IHw+r4dcHtBYWw=="],
|
||||
|
||||
"@hapi/hoek": ["@hapi/[email protected]", "", {}, "sha512-HV5undWkKzcB4RZUusqOpcgxOaq6VOAH7zhhIr2g3G8NF/MlFO75SjOr2NfuSx0Mh40+1FqCkagKLJRykUWoFQ=="],
|
||||
|
||||
"@hapi/pinpoint": ["@hapi/[email protected]", "", {}, "sha512-EKQmr16tM8s16vTT3cA5L0kZZcTMU5DUOZTuvpnY738m+jyP3JIUj+Mm1xc1rsLkGBQ/gVnfKYPwOmPg1tUR4Q=="],
|
||||
|
||||
"@hapi/tlds": ["@hapi/[email protected]", "", {}, "sha512-Fq+20dxsxLaUn5jSSWrdtSRcIUba2JquuorF9UW1wIJS5cSUwxIsO2GIhaWynPRflvxSzFN+gxKte2HEW1OuoA=="],
|
||||
|
||||
"@hapi/topo": ["@hapi/[email protected]", "", { "dependencies": { "@hapi/hoek": "^11.0.2" } }, "sha512-KR3rD5inZbGMrHmgPxsJ9dbi6zEK+C3ZwUwTa+eMwWLz7oijWUTWD2pMSNNYJAU6Qq+65NkxXjqHr/7LM2Xkqg=="],
|
||||
|
||||
"@jridgewell/gen-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
|
||||
|
||||
"@jridgewell/remapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
|
||||
@@ -277,6 +290,12 @@
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA=="],
|
||||
|
||||
"@sindresorhus/is": ["@sindresorhus/[email protected]", "", {}, "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw=="],
|
||||
|
||||
"@standard-schema/spec": ["@standard-schema/[email protected]", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
|
||||
|
||||
"@szmarczak/http-timer": ["@szmarczak/[email protected]", "", { "dependencies": { "defer-to-connect": "^2.0.0" } }, "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w=="],
|
||||
|
||||
"@tailwindcss/node": ["@tailwindcss/[email protected]", "", { "dependencies": { "@jridgewell/remapping": "^2.3.4", "enhanced-resolve": "^5.18.3", "jiti": "^2.6.1", "lightningcss": "1.30.2", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.1.18" } }, "sha512-DoR7U1P7iYhw16qJ49fgXUlry1t4CpXeErJHnQ44JgTSKMaZUdf17cfn5mHchfJ4KRBZRFA/Coo+MUF5+gOaCQ=="],
|
||||
|
||||
"@tailwindcss/oxide": ["@tailwindcss/[email protected]", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.1.18", "@tailwindcss/oxide-darwin-arm64": "4.1.18", "@tailwindcss/oxide-darwin-x64": "4.1.18", "@tailwindcss/oxide-freebsd-x64": "4.1.18", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.18", "@tailwindcss/oxide-linux-arm64-gnu": "4.1.18", "@tailwindcss/oxide-linux-arm64-musl": "4.1.18", "@tailwindcss/oxide-linux-x64-gnu": "4.1.18", "@tailwindcss/oxide-linux-x64-musl": "4.1.18", "@tailwindcss/oxide-wasm32-wasi": "4.1.18", "@tailwindcss/oxide-win32-arm64-msvc": "4.1.18", "@tailwindcss/oxide-win32-x64-msvc": "4.1.18" } }, "sha512-EgCR5tTS5bUSKQgzeMClT6iCY3ToqE1y+ZB0AKldj809QXk1Y+3jB0upOYZrn9aGIzPtUsP7sX4QQ4XtjBB95A=="],
|
||||
@@ -315,6 +334,8 @@
|
||||
|
||||
"@types/babel__traverse": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="],
|
||||
|
||||
"@types/cacheable-request": ["@types/[email protected]", "", { "dependencies": { "@types/http-cache-semantics": "*", "@types/keyv": "^3.1.4", "@types/node": "*", "@types/responselike": "^1.0.0" } }, "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw=="],
|
||||
|
||||
"@types/chai": ["@types/[email protected]", "", { "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" } }, "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA=="],
|
||||
|
||||
"@types/debug": ["@types/[email protected]", "", { "dependencies": { "@types/ms": "*" } }, "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ=="],
|
||||
@@ -327,6 +348,10 @@
|
||||
|
||||
"@types/hast": ["@types/[email protected]", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
|
||||
|
||||
"@types/http-cache-semantics": ["@types/[email protected]", "", {}, "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q=="],
|
||||
|
||||
"@types/keyv": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg=="],
|
||||
|
||||
"@types/mdast": ["@types/[email protected]", "", { "dependencies": { "@types/unist": "*" } }, "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA=="],
|
||||
|
||||
"@types/ms": ["@types/[email protected]", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
|
||||
@@ -337,10 +362,14 @@
|
||||
|
||||
"@types/react-dom": ["@types/[email protected]", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="],
|
||||
|
||||
"@types/responselike": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw=="],
|
||||
|
||||
"@types/unist": ["@types/[email protected]", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
|
||||
|
||||
"@types/ws": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
||||
|
||||
"@types/yauzl": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q=="],
|
||||
|
||||
"@ungap/structured-clone": ["@ungap/[email protected]", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="],
|
||||
|
||||
"@vitejs/plugin-react": ["@vitejs/[email protected]", "", { "dependencies": { "@babel/core": "^7.28.0", "@babel/plugin-transform-react-jsx-self": "^7.27.1", "@babel/plugin-transform-react-jsx-source": "^7.27.1", "@rolldown/pluginutils": "1.0.0-beta.27", "@types/babel__core": "^7.20.5", "react-refresh": "^0.17.0" }, "peerDependencies": { "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA=="],
|
||||
@@ -361,28 +390,52 @@
|
||||
|
||||
"acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="],
|
||||
|
||||
"ansi-regex": ["[email protected]", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
||||
|
||||
"ansi-styles": ["[email protected]", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
||||
|
||||
"any-promise": ["[email protected]", "", {}, "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A=="],
|
||||
|
||||
"assertion-error": ["[email protected]", "", {}, "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA=="],
|
||||
|
||||
"asynckit": ["[email protected]", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
||||
|
||||
"axios": ["[email protected]", "", { "dependencies": { "follow-redirects": "^1.15.11", "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q=="],
|
||||
|
||||
"babel-plugin-react-compiler": ["[email protected]", "", { "dependencies": { "@babel/types": "^7.26.0" } }, "sha512-q84bNR9JG1crykAlJUt5Ud0/5BUyMFuQww/mrwIQDFBaxsikqBDj3f/FNDsVd2iR26A1HvXKWPEIfgJDv8/V2g=="],
|
||||
|
||||
"bail": ["[email protected]", "", {}, "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw=="],
|
||||
|
||||
"baseline-browser-mapping": ["[email protected]", "", { "bin": { "baseline-browser-mapping": "dist/cli.js" } }, "sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg=="],
|
||||
|
||||
"boolean": ["[email protected]", "", {}, "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw=="],
|
||||
|
||||
"braces": ["[email protected]", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
|
||||
|
||||
"browserslist": ["[email protected]", "", { "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", "electron-to-chromium": "^1.5.263", "node-releases": "^2.0.27", "update-browserslist-db": "^1.2.0" }, "bin": { "browserslist": "cli.js" } }, "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA=="],
|
||||
|
||||
"buffer-crc32": ["[email protected]", "", {}, "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ=="],
|
||||
|
||||
"bundle-name": ["[email protected]", "", { "dependencies": { "run-applescript": "^7.0.0" } }, "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q=="],
|
||||
|
||||
"bundle-require": ["[email protected]", "", { "dependencies": { "load-tsconfig": "^0.2.3" }, "peerDependencies": { "esbuild": ">=0.18" } }, "sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA=="],
|
||||
|
||||
"cac": ["[email protected]", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
||||
|
||||
"cacheable-lookup": ["[email protected]", "", {}, "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="],
|
||||
|
||||
"cacheable-request": ["[email protected]", "", { "dependencies": { "clone-response": "^1.0.2", "get-stream": "^5.1.0", "http-cache-semantics": "^4.0.0", "keyv": "^4.0.0", "lowercase-keys": "^2.0.0", "normalize-url": "^6.0.1", "responselike": "^2.0.0" } }, "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg=="],
|
||||
|
||||
"call-bind-apply-helpers": ["[email protected]", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
||||
|
||||
"caniuse-lite": ["[email protected]", "", {}, "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg=="],
|
||||
|
||||
"ccount": ["[email protected]", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
|
||||
|
||||
"chai": ["[email protected]", "", { "dependencies": { "assertion-error": "^2.0.1", "check-error": "^2.1.1", "deep-eql": "^5.0.1", "loupe": "^3.1.0", "pathval": "^2.0.0" } }, "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw=="],
|
||||
|
||||
"chalk": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
|
||||
|
||||
"character-entities": ["[email protected]", "", {}, "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ=="],
|
||||
|
||||
"character-entities-html4": ["[email protected]", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="],
|
||||
@@ -395,10 +448,22 @@
|
||||
|
||||
"chokidar": ["[email protected]", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="],
|
||||
|
||||
"cliui": ["[email protected]", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ=="],
|
||||
|
||||
"clone-response": ["[email protected]", "", { "dependencies": { "mimic-response": "^1.0.0" } }, "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA=="],
|
||||
|
||||
"color-convert": ["[email protected]", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
|
||||
|
||||
"color-name": ["[email protected]", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
|
||||
|
||||
"combined-stream": ["[email protected]", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
|
||||
|
||||
"comma-separated-tokens": ["[email protected]", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
|
||||
|
||||
"commander": ["[email protected]", "", {}, "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="],
|
||||
|
||||
"concurrently": ["[email protected]", "", { "dependencies": { "chalk": "4.1.2", "rxjs": "7.8.2", "shell-quote": "1.8.3", "supports-color": "8.1.1", "tree-kill": "1.2.2", "yargs": "17.7.2" }, "bin": { "conc": "dist/bin/concurrently.js", "concurrently": "dist/bin/concurrently.js" } }, "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng=="],
|
||||
|
||||
"confbox": ["[email protected]", "", {}, "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w=="],
|
||||
|
||||
"consola": ["[email protected]", "", {}, "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA=="],
|
||||
@@ -411,25 +476,65 @@
|
||||
|
||||
"decode-named-character-reference": ["[email protected]", "", { "dependencies": { "character-entities": "^2.0.0" } }, "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q=="],
|
||||
|
||||
"decompress-response": ["[email protected]", "", { "dependencies": { "mimic-response": "^3.1.0" } }, "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ=="],
|
||||
|
||||
"deep-eql": ["[email protected]", "", {}, "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q=="],
|
||||
|
||||
"default-browser": ["[email protected]", "", { "dependencies": { "bundle-name": "^4.1.0", "default-browser-id": "^5.0.0" } }, "sha512-H9LMLr5zwIbSxrmvikGuI/5KGhZ8E2zH3stkMgM5LpOWDutGM2JZaj460Udnf1a+946zc7YBgrqEWwbk7zHvGw=="],
|
||||
|
||||
"default-browser-id": ["[email protected]", "", {}, "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q=="],
|
||||
|
||||
"defer-to-connect": ["[email protected]", "", {}, "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg=="],
|
||||
|
||||
"define-data-property": ["[email protected]", "", { "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" } }, "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A=="],
|
||||
|
||||
"define-lazy-prop": ["[email protected]", "", {}, "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg=="],
|
||||
|
||||
"define-properties": ["[email protected]", "", { "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg=="],
|
||||
|
||||
"delayed-stream": ["[email protected]", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
|
||||
|
||||
"dequal": ["[email protected]", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
|
||||
|
||||
"detect-libc": ["[email protected]", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
||||
|
||||
"detect-node": ["[email protected]", "", {}, "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g=="],
|
||||
|
||||
"devlop": ["[email protected]", "", { "dependencies": { "dequal": "^2.0.0" } }, "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA=="],
|
||||
|
||||
"dunder-proto": ["[email protected]", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
|
||||
|
||||
"electron": ["[email protected]", "", { "dependencies": { "@electron/get": "^2.0.0", "@types/node": "^20.9.0", "extract-zip": "^2.0.1" }, "bin": { "electron": "cli.js" } }, "sha512-xmdAs5QWRkInC7TpXGNvzo/7exojubk+72jn1oJL7keNeIlw7xNglf8TGtJtkR4rWC5FJq0oXiIXPS9BcK2Irg=="],
|
||||
|
||||
"electron-to-chromium": ["[email protected]", "", {}, "sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A=="],
|
||||
|
||||
"electronmon": ["[email protected]", "", { "dependencies": { "chalk": "^3.0.0", "import-from": "^3.0.0", "runtime-required": "^1.1.0", "watchboy": "^0.4.3" }, "bin": { "electronmon": "bin/cli.js" } }, "sha512-u6eDrvUbqa+wsnMrhG2vHmo5neL1owLg2e5i1avGWcOb4rHsUf9lSfbs0FvfPsBNpLxxlPO98nrMhAGV+zw/fQ=="],
|
||||
|
||||
"emoji-regex": ["[email protected]", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
|
||||
|
||||
"end-of-stream": ["[email protected]", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="],
|
||||
|
||||
"enhanced-resolve": ["[email protected]", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.0" } }, "sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg=="],
|
||||
|
||||
"env-paths": ["[email protected]", "", {}, "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A=="],
|
||||
|
||||
"es-define-property": ["[email protected]", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||
|
||||
"es-errors": ["[email protected]", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
|
||||
|
||||
"es-module-lexer": ["[email protected]", "", {}, "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA=="],
|
||||
|
||||
"es-object-atoms": ["[email protected]", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
|
||||
|
||||
"es-set-tostringtag": ["[email protected]", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
|
||||
|
||||
"es6-error": ["[email protected]", "", {}, "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg=="],
|
||||
|
||||
"esbuild": ["[email protected]", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.3", "@esbuild/android-arm": "0.27.3", "@esbuild/android-arm64": "0.27.3", "@esbuild/android-x64": "0.27.3", "@esbuild/darwin-arm64": "0.27.3", "@esbuild/darwin-x64": "0.27.3", "@esbuild/freebsd-arm64": "0.27.3", "@esbuild/freebsd-x64": "0.27.3", "@esbuild/linux-arm": "0.27.3", "@esbuild/linux-arm64": "0.27.3", "@esbuild/linux-ia32": "0.27.3", "@esbuild/linux-loong64": "0.27.3", "@esbuild/linux-mips64el": "0.27.3", "@esbuild/linux-ppc64": "0.27.3", "@esbuild/linux-riscv64": "0.27.3", "@esbuild/linux-s390x": "0.27.3", "@esbuild/linux-x64": "0.27.3", "@esbuild/netbsd-arm64": "0.27.3", "@esbuild/netbsd-x64": "0.27.3", "@esbuild/openbsd-arm64": "0.27.3", "@esbuild/openbsd-x64": "0.27.3", "@esbuild/openharmony-arm64": "0.27.3", "@esbuild/sunos-x64": "0.27.3", "@esbuild/win32-arm64": "0.27.3", "@esbuild/win32-ia32": "0.27.3", "@esbuild/win32-x64": "0.27.3" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg=="],
|
||||
|
||||
"escalade": ["[email protected]", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
||||
|
||||
"escape-string-regexp": ["escape-string-regexp@5.0.0", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="],
|
||||
"escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="],
|
||||
|
||||
"estree-util-is-identifier-name": ["[email protected]", "", {}, "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg=="],
|
||||
|
||||
@@ -439,18 +544,58 @@
|
||||
|
||||
"extend": ["[email protected]", "", {}, "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="],
|
||||
|
||||
"extract-zip": ["[email protected]", "", { "dependencies": { "debug": "^4.1.1", "get-stream": "^5.1.0", "yauzl": "^2.10.0" }, "optionalDependencies": { "@types/yauzl": "^2.9.1" }, "bin": { "extract-zip": "cli.js" } }, "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg=="],
|
||||
|
||||
"fd-slicer": ["[email protected]", "", { "dependencies": { "pend": "~1.2.0" } }, "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g=="],
|
||||
|
||||
"fdir": ["[email protected]", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
|
||||
|
||||
"fill-range": ["[email protected]", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
|
||||
|
||||
"fix-dts-default-cjs-exports": ["[email protected]", "", { "dependencies": { "magic-string": "^0.30.17", "mlly": "^1.7.4", "rollup": "^4.34.8" } }, "sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg=="],
|
||||
|
||||
"follow-redirects": ["[email protected]", "", {}, "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
|
||||
|
||||
"form-data": ["[email protected]", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
|
||||
|
||||
"fs-extra": ["[email protected]", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } }, "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g=="],
|
||||
|
||||
"fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"function-bind": ["[email protected]", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
|
||||
|
||||
"gensync": ["[email protected]", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
|
||||
|
||||
"get-caller-file": ["[email protected]", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
|
||||
|
||||
"get-intrinsic": ["[email protected]", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||
|
||||
"get-proto": ["[email protected]", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
|
||||
|
||||
"get-stream": ["[email protected]", "", { "dependencies": { "pump": "^3.0.0" } }, "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA=="],
|
||||
|
||||
"get-tsconfig": ["[email protected]", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-shZT/QMiSHc/YBLxxOkMtgSid5HFoauqCE3/exfsEcwg1WkeqjG+V40yBbBrsD+jW2HDXcs28xOfcbm2jI8Ddw=="],
|
||||
|
||||
"global-agent": ["[email protected]", "", { "dependencies": { "boolean": "^3.0.1", "es6-error": "^4.1.1", "matcher": "^3.0.0", "roarr": "^2.15.3", "semver": "^7.3.2", "serialize-error": "^7.0.1" } }, "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q=="],
|
||||
|
||||
"globalthis": ["[email protected]", "", { "dependencies": { "define-properties": "^1.2.1", "gopd": "^1.0.1" } }, "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ=="],
|
||||
|
||||
"gopd": ["[email protected]", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"got": ["[email protected]", "", { "dependencies": { "@sindresorhus/is": "^4.0.0", "@szmarczak/http-timer": "^4.0.5", "@types/cacheable-request": "^6.0.1", "@types/responselike": "^1.0.0", "cacheable-lookup": "^5.0.3", "cacheable-request": "^7.0.2", "decompress-response": "^6.0.0", "http2-wrapper": "^1.0.0-beta.5.2", "lowercase-keys": "^2.0.0", "p-cancelable": "^2.0.0", "responselike": "^2.0.0" } }, "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g=="],
|
||||
|
||||
"graceful-fs": ["[email protected]", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
|
||||
|
||||
"has-flag": ["[email protected]", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
|
||||
|
||||
"has-property-descriptors": ["[email protected]", "", { "dependencies": { "es-define-property": "^1.0.0" } }, "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg=="],
|
||||
|
||||
"has-symbols": ["[email protected]", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||
|
||||
"has-tostringtag": ["[email protected]", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
|
||||
|
||||
"hasown": ["[email protected]", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
||||
|
||||
"hast-util-is-element": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g=="],
|
||||
|
||||
"hast-util-to-jsx-runtime": ["[email protected]", "", { "dependencies": { "@types/estree": "^1.0.0", "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "comma-separated-tokens": "^2.0.0", "devlop": "^1.0.0", "estree-util-is-identifier-name": "^3.0.0", "hast-util-whitespace": "^3.0.0", "mdast-util-mdx-expression": "^2.0.0", "mdast-util-mdx-jsx": "^3.0.0", "mdast-util-mdxjs-esm": "^2.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "style-to-js": "^1.0.0", "unist-util-position": "^5.0.0", "vfile-message": "^4.0.0" } }, "sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg=="],
|
||||
@@ -463,6 +608,12 @@
|
||||
|
||||
"html-url-attributes": ["[email protected]", "", {}, "sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ=="],
|
||||
|
||||
"http-cache-semantics": ["[email protected]", "", {}, "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ=="],
|
||||
|
||||
"http2-wrapper": ["[email protected]", "", { "dependencies": { "quick-lru": "^5.1.1", "resolve-alpn": "^1.0.0" } }, "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg=="],
|
||||
|
||||
"import-from": ["[email protected]", "", { "dependencies": { "resolve-from": "^5.0.0" } }, "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ=="],
|
||||
|
||||
"inline-style-parser": ["[email protected]", "", {}, "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA=="],
|
||||
|
||||
"is-alphabetical": ["[email protected]", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="],
|
||||
@@ -471,20 +622,40 @@
|
||||
|
||||
"is-decimal": ["[email protected]", "", {}, "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="],
|
||||
|
||||
"is-docker": ["[email protected]", "", { "bin": { "is-docker": "cli.js" } }, "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ=="],
|
||||
|
||||
"is-fullwidth-code-point": ["[email protected]", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="],
|
||||
|
||||
"is-hexadecimal": ["[email protected]", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="],
|
||||
|
||||
"is-inside-container": ["[email protected]", "", { "dependencies": { "is-docker": "^3.0.0" }, "bin": { "is-inside-container": "cli.js" } }, "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA=="],
|
||||
|
||||
"is-number": ["[email protected]", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
|
||||
|
||||
"is-plain-obj": ["[email protected]", "", {}, "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="],
|
||||
|
||||
"is-wsl": ["[email protected]", "", { "dependencies": { "is-inside-container": "^1.0.0" } }, "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw=="],
|
||||
|
||||
"jiti": ["[email protected]", "", { "bin": { "jiti": "bin/jiti.js" } }, "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A=="],
|
||||
|
||||
"joi": ["[email protected]", "", { "dependencies": { "@hapi/address": "^5.1.1", "@hapi/formula": "^3.0.2", "@hapi/hoek": "^11.0.7", "@hapi/pinpoint": "^2.0.1", "@hapi/tlds": "^1.1.1", "@hapi/topo": "^6.0.2", "@standard-schema/spec": "^1.0.0" } }, "sha512-RuCOQMIt78LWnktPoeBL0GErkNaJPTBGcYuyaBvUOQSpcpcLfWrHPPihYdOGbV5pam9VTWbeoF7TsGiHugcjGA=="],
|
||||
|
||||
"joycon": ["[email protected]", "", {}, "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw=="],
|
||||
|
||||
"js-tokens": ["[email protected]", "", {}, "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ=="],
|
||||
|
||||
"jsesc": ["[email protected]", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="],
|
||||
|
||||
"json-buffer": ["[email protected]", "", {}, "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="],
|
||||
|
||||
"json-stringify-safe": ["[email protected]", "", {}, "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="],
|
||||
|
||||
"json5": ["[email protected]", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="],
|
||||
|
||||
"jsonfile": ["[email protected]", "", { "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg=="],
|
||||
|
||||
"keyv": ["[email protected]", "", { "dependencies": { "json-buffer": "3.0.1" } }, "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw=="],
|
||||
|
||||
"lightningcss": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.30.2", "lightningcss-darwin-arm64": "1.30.2", "lightningcss-darwin-x64": "1.30.2", "lightningcss-freebsd-x64": "1.30.2", "lightningcss-linux-arm-gnueabihf": "1.30.2", "lightningcss-linux-arm64-gnu": "1.30.2", "lightningcss-linux-arm64-musl": "1.30.2", "lightningcss-linux-x64-gnu": "1.30.2", "lightningcss-linux-x64-musl": "1.30.2", "lightningcss-win32-arm64-msvc": "1.30.2", "lightningcss-win32-x64-msvc": "1.30.2" } }, "sha512-utfs7Pr5uJyyvDETitgsaqSyjCb2qNRAtuqUeWIAKztsOYdcACf2KtARYXg2pSvhkt+9NfoaNY7fxjl6nuMjIQ=="],
|
||||
|
||||
"lightningcss-android-arm64": ["[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A=="],
|
||||
@@ -515,10 +686,16 @@
|
||||
|
||||
"load-tsconfig": ["[email protected]", "", {}, "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg=="],
|
||||
|
||||
"lodash": ["[email protected]", "", {}, "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w=="],
|
||||
|
||||
"lodash.difference": ["[email protected]", "", {}, "sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA=="],
|
||||
|
||||
"longest-streak": ["[email protected]", "", {}, "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g=="],
|
||||
|
||||
"loupe": ["[email protected]", "", {}, "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ=="],
|
||||
|
||||
"lowercase-keys": ["[email protected]", "", {}, "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="],
|
||||
|
||||
"lowlight": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "devlop": "^1.0.0", "highlight.js": "~11.11.0" } }, "sha512-0JNhgFoPvP6U6lE/UdVsSq99tn6DhjjpAj5MxG49ewd2mOBVtwWYIT8ClyABhq198aXXODMU6Ox8DrGy/CpTZQ=="],
|
||||
|
||||
"lru-cache": ["[email protected]", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
||||
@@ -529,6 +706,10 @@
|
||||
|
||||
"markdown-table": ["[email protected]", "", {}, "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw=="],
|
||||
|
||||
"matcher": ["[email protected]", "", { "dependencies": { "escape-string-regexp": "^4.0.0" } }, "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng=="],
|
||||
|
||||
"math-intrinsics": ["[email protected]", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
||||
|
||||
"mdast-util-find-and-replace": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "escape-string-regexp": "^5.0.0", "unist-util-is": "^6.0.0", "unist-util-visit-parents": "^6.0.0" } }, "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg=="],
|
||||
|
||||
"mdast-util-from-markdown": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA=="],
|
||||
@@ -615,6 +796,16 @@
|
||||
|
||||
"micromark-util-types": ["[email protected]", "", {}, "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA=="],
|
||||
|
||||
"micromatch": ["[email protected]", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
|
||||
|
||||
"mime-db": ["[email protected]", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
|
||||
|
||||
"mime-types": ["[email protected]", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
|
||||
|
||||
"mimic-response": ["[email protected]", "", {}, "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="],
|
||||
|
||||
"minimist": ["[email protected]", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
|
||||
|
||||
"mlly": ["[email protected]", "", { "dependencies": { "acorn": "^8.15.0", "pathe": "^2.0.3", "pkg-types": "^1.3.1", "ufo": "^1.6.1" } }, "sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g=="],
|
||||
|
||||
"ms": ["[email protected]", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
@@ -623,28 +814,40 @@
|
||||
|
||||
"nanoid": ["[email protected]", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||
|
||||
"node-addon-api": ["[email protected]", "", {}, "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ=="],
|
||||
|
||||
"node-pty": ["[email protected]", "", { "dependencies": { "node-addon-api": "^7.1.0" } }, "sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg=="],
|
||||
|
||||
"node-releases": ["[email protected]", "", {}, "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA=="],
|
||||
|
||||
"normalize-path": ["[email protected]", "", { "dependencies": { "remove-trailing-separator": "^1.0.1" } }, "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w=="],
|
||||
|
||||
"normalize-url": ["[email protected]", "", {}, "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A=="],
|
||||
|
||||
"object-assign": ["[email protected]", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
||||
|
||||
"object-keys": ["[email protected]", "", {}, "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="],
|
||||
|
||||
"once": ["[email protected]", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
||||
|
||||
"open": ["[email protected]", "", { "dependencies": { "default-browser": "^5.2.1", "define-lazy-prop": "^3.0.0", "is-inside-container": "^1.0.0", "wsl-utils": "^0.1.0" } }, "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA=="],
|
||||
|
||||
"oxfmt": ["[email protected]", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/darwin-arm64": "0.28.0", "@oxfmt/darwin-x64": "0.28.0", "@oxfmt/linux-arm64-gnu": "0.28.0", "@oxfmt/linux-arm64-musl": "0.28.0", "@oxfmt/linux-x64-gnu": "0.28.0", "@oxfmt/linux-x64-musl": "0.28.0", "@oxfmt/win32-arm64": "0.28.0", "@oxfmt/win32-x64": "0.28.0" }, "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-3+hhBqPE6Kp22KfJmnstrZbl+KdOVSEu1V0ABaFIg1rYLtrMgrupx9znnHgHLqKxAVHebjTdiCJDk30CXOt6cw=="],
|
||||
|
||||
"oxlint": ["[email protected]", "", { "optionalDependencies": { "@oxlint/darwin-arm64": "1.43.0", "@oxlint/darwin-x64": "1.43.0", "@oxlint/linux-arm64-gnu": "1.43.0", "@oxlint/linux-arm64-musl": "1.43.0", "@oxlint/linux-x64-gnu": "1.43.0", "@oxlint/linux-x64-musl": "1.43.0", "@oxlint/win32-arm64": "1.43.0", "@oxlint/win32-x64": "1.43.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.11.2" }, "optionalPeers": ["oxlint-tsgolint"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-xiqTCsKZch+R61DPCjyqUVP2MhkQlRRYxLRBeBDi+dtQJ90MOgdcjIktvDCgXz0bgtx94EQzHEndsizZjMX2OA=="],
|
||||
|
||||
"p-cancelable": ["[email protected]", "", {}, "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg=="],
|
||||
|
||||
"parse-entities": ["[email protected]", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="],
|
||||
|
||||
"pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
||||
|
||||
"pathval": ["[email protected]", "", {}, "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ=="],
|
||||
|
||||
"pend": ["[email protected]", "", {}, "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg=="],
|
||||
|
||||
"picocolors": ["[email protected]", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||
|
||||
"picomatch": ["[email protected]", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
|
||||
|
||||
"pify": ["[email protected]", "", {}, "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="],
|
||||
|
||||
"pirates": ["[email protected]", "", {}, "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA=="],
|
||||
|
||||
"pkg-types": ["[email protected]", "", { "dependencies": { "confbox": "^0.1.8", "mlly": "^1.7.4", "pathe": "^2.0.1" } }, "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ=="],
|
||||
@@ -653,8 +856,16 @@
|
||||
|
||||
"postcss-load-config": ["[email protected]", "", { "dependencies": { "lilconfig": "^3.1.1" }, "peerDependencies": { "jiti": ">=1.21.0", "postcss": ">=8.0.9", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["jiti", "postcss", "tsx", "yaml"] }, "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g=="],
|
||||
|
||||
"progress": ["[email protected]", "", {}, "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA=="],
|
||||
|
||||
"property-information": ["[email protected]", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="],
|
||||
|
||||
"proxy-from-env": ["[email protected]", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
|
||||
|
||||
"pump": ["[email protected]", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA=="],
|
||||
|
||||
"quick-lru": ["[email protected]", "", {}, "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA=="],
|
||||
|
||||
"react": ["[email protected]", "", {}, "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ=="],
|
||||
|
||||
"react-dom": ["[email protected]", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.4" } }, "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ=="],
|
||||
@@ -675,16 +886,38 @@
|
||||
|
||||
"remark-stringify": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "mdast-util-to-markdown": "^2.0.0", "unified": "^11.0.0" } }, "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw=="],
|
||||
|
||||
"remove-trailing-separator": ["[email protected]", "", {}, "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw=="],
|
||||
|
||||
"require-directory": ["[email protected]", "", {}, "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="],
|
||||
|
||||
"resolve-alpn": ["[email protected]", "", {}, "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g=="],
|
||||
|
||||
"resolve-from": ["[email protected]", "", {}, "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw=="],
|
||||
|
||||
"resolve-pkg-maps": ["[email protected]", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
|
||||
|
||||
"responselike": ["[email protected]", "", { "dependencies": { "lowercase-keys": "^2.0.0" } }, "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw=="],
|
||||
|
||||
"roarr": ["[email protected]", "", { "dependencies": { "boolean": "^3.0.1", "detect-node": "^2.0.4", "globalthis": "^1.0.1", "json-stringify-safe": "^5.0.1", "semver-compare": "^1.0.0", "sprintf-js": "^1.1.2" } }, "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A=="],
|
||||
|
||||
"rollup": ["[email protected]", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.57.1", "@rollup/rollup-android-arm64": "4.57.1", "@rollup/rollup-darwin-arm64": "4.57.1", "@rollup/rollup-darwin-x64": "4.57.1", "@rollup/rollup-freebsd-arm64": "4.57.1", "@rollup/rollup-freebsd-x64": "4.57.1", "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", "@rollup/rollup-linux-arm-musleabihf": "4.57.1", "@rollup/rollup-linux-arm64-gnu": "4.57.1", "@rollup/rollup-linux-arm64-musl": "4.57.1", "@rollup/rollup-linux-loong64-gnu": "4.57.1", "@rollup/rollup-linux-loong64-musl": "4.57.1", "@rollup/rollup-linux-ppc64-gnu": "4.57.1", "@rollup/rollup-linux-ppc64-musl": "4.57.1", "@rollup/rollup-linux-riscv64-gnu": "4.57.1", "@rollup/rollup-linux-riscv64-musl": "4.57.1", "@rollup/rollup-linux-s390x-gnu": "4.57.1", "@rollup/rollup-linux-x64-gnu": "4.57.1", "@rollup/rollup-linux-x64-musl": "4.57.1", "@rollup/rollup-openbsd-x64": "4.57.1", "@rollup/rollup-openharmony-arm64": "4.57.1", "@rollup/rollup-win32-arm64-msvc": "4.57.1", "@rollup/rollup-win32-ia32-msvc": "4.57.1", "@rollup/rollup-win32-x64-gnu": "4.57.1", "@rollup/rollup-win32-x64-msvc": "4.57.1", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A=="],
|
||||
|
||||
"run-applescript": ["[email protected]", "", {}, "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q=="],
|
||||
|
||||
"runtime-required": ["[email protected]", "", {}, "sha512-yX97f5E0WfNpcQnfVjap6vzQcvErkYYCx6eTK4siqGEdC8lglwypUFgZVTX7ShvIlgfkC4XGFl9O1KTYcff0pw=="],
|
||||
|
||||
"rxjs": ["[email protected]", "", { "dependencies": { "tslib": "^2.1.0" } }, "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA=="],
|
||||
|
||||
"scheduler": ["[email protected]", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
|
||||
|
||||
"semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
||||
|
||||
"semver-compare": ["[email protected]", "", {}, "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow=="],
|
||||
|
||||
"serialize-error": ["[email protected]", "", { "dependencies": { "type-fest": "^0.13.1" } }, "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw=="],
|
||||
|
||||
"shell-quote": ["[email protected]", "", {}, "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw=="],
|
||||
|
||||
"siginfo": ["[email protected]", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
|
||||
|
||||
"source-map": ["[email protected]", "", {}, "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ=="],
|
||||
@@ -693,12 +926,18 @@
|
||||
|
||||
"space-separated-tokens": ["[email protected]", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="],
|
||||
|
||||
"sprintf-js": ["[email protected]", "", {}, "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA=="],
|
||||
|
||||
"stackback": ["[email protected]", "", {}, "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw=="],
|
||||
|
||||
"std-env": ["[email protected]", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="],
|
||||
|
||||
"string-width": ["[email protected]", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
|
||||
|
||||
"stringify-entities": ["[email protected]", "", { "dependencies": { "character-entities-html4": "^2.0.0", "character-entities-legacy": "^3.0.0" } }, "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg=="],
|
||||
|
||||
"strip-ansi": ["[email protected]", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
||||
|
||||
"strip-literal": ["[email protected]", "", { "dependencies": { "js-tokens": "^9.0.1" } }, "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg=="],
|
||||
|
||||
"style-to-js": ["[email protected]", "", { "dependencies": { "style-to-object": "1.0.14" } }, "sha512-RjQetxJrrUJLQPHbLku6U/ocGtzyjbJMP9lCNK7Ag0CNh690nSH8woqWH9u16nMjYBAok+i7JO1NP2pOy8IsPQ=="],
|
||||
@@ -707,6 +946,12 @@
|
||||
|
||||
"sucrase": ["[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.2", "commander": "^4.0.0", "lines-and-columns": "^1.1.6", "mz": "^2.7.0", "pirates": "^4.0.1", "tinyglobby": "^0.2.11", "ts-interface-checker": "^0.1.9" }, "bin": { "sucrase": "bin/sucrase", "sucrase-node": "bin/sucrase-node" } }, "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw=="],
|
||||
|
||||
"sumchecker": ["[email protected]", "", { "dependencies": { "debug": "^4.1.0" } }, "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg=="],
|
||||
|
||||
"supports-color": ["[email protected]", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q=="],
|
||||
|
||||
"t3": ["t3@workspace:apps/server"],
|
||||
|
||||
"tailwindcss": ["[email protected]", "", {}, "sha512-4+Z+0yiYyEtUVCScyfHCxOYP06L5Ne+JiHhY2IjR2KWMIWhJOYZKLSGZaP5HkZ8+bY0cxfzwDE5uOmzFXyIwxw=="],
|
||||
|
||||
"tapable": ["[email protected]", "", {}, "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg=="],
|
||||
@@ -727,6 +972,8 @@
|
||||
|
||||
"tinyspy": ["[email protected]", "", {}, "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q=="],
|
||||
|
||||
"to-regex-range": ["[email protected]", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
||||
|
||||
"tree-kill": ["[email protected]", "", { "bin": { "tree-kill": "cli.js" } }, "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="],
|
||||
|
||||
"trim-lines": ["[email protected]", "", {}, "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="],
|
||||
@@ -735,6 +982,8 @@
|
||||
|
||||
"ts-interface-checker": ["[email protected]", "", {}, "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="],
|
||||
|
||||
"tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||
|
||||
"tsup": ["[email protected]", "", { "dependencies": { "bundle-require": "^5.1.0", "cac": "^6.7.14", "chokidar": "^4.0.3", "consola": "^3.4.0", "debug": "^4.4.0", "esbuild": "^0.27.0", "fix-dts-default-cjs-exports": "^1.0.0", "joycon": "^3.1.1", "picocolors": "^1.1.1", "postcss-load-config": "^6.0.1", "resolve-from": "^5.0.0", "rollup": "^4.34.8", "source-map": "^0.7.6", "sucrase": "^3.35.0", "tinyexec": "^0.3.2", "tinyglobby": "^0.2.11", "tree-kill": "^1.2.2" }, "peerDependencies": { "@microsoft/api-extractor": "^7.36.0", "@swc/core": "^1", "postcss": "^8.4.12", "typescript": ">=4.5.0" }, "optionalPeers": ["@microsoft/api-extractor", "@swc/core", "postcss", "typescript"], "bin": { "tsup": "dist/cli-default.js", "tsup-node": "dist/cli-node.js" } }, "sha512-xtgkqwdhpKWr3tKPmCkvYmS9xnQK3m3XgxZHwSUjvfTjp7YfXe5tT3GgWi0F2N+ZSMsOeWeZFh7ZZFg5iPhing=="],
|
||||
|
||||
"tsx": ["[email protected]", "", { "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "bin": { "tsx": "dist/cli.mjs" } }, "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw=="],
|
||||
@@ -753,6 +1002,8 @@
|
||||
|
||||
"turbo-windows-arm64": ["[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-afTUGKBRmOJU1smQSBnFGcbq0iabAPwh1uXu2BVk7BREg30/1gMnJh9DFEQTah+UD3n3ru8V55J83RQNFfqoyw=="],
|
||||
|
||||
"type-fest": ["[email protected]", "", {}, "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg=="],
|
||||
|
||||
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
"ufo": ["[email protected]", "", {}, "sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q=="],
|
||||
@@ -773,6 +1024,10 @@
|
||||
|
||||
"unist-util-visit-parents": ["[email protected]", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0" } }, "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ=="],
|
||||
|
||||
"universalify": ["[email protected]", "", {}, "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="],
|
||||
|
||||
"unixify": ["[email protected]", "", { "dependencies": { "normalize-path": "^2.1.1" } }, "sha512-6bc58dPYhCMHHuwxldQxO3RRNZ4eCogZ/st++0+fcC1nr0jiGUtAdBJ2qzmLQWSxbtz42pWt4QQMiZ9HvZf5cg=="],
|
||||
|
||||
"update-browserslist-db": ["[email protected]", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w=="],
|
||||
|
||||
"vfile": ["[email protected]", "", { "dependencies": { "@types/unist": "^3.0.0", "vfile-message": "^4.0.0" } }, "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q=="],
|
||||
@@ -785,12 +1040,30 @@
|
||||
|
||||
"vitest": ["[email protected]", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.4", "@vitest/mocker": "3.2.4", "@vitest/pretty-format": "^3.2.4", "@vitest/runner": "3.2.4", "@vitest/snapshot": "3.2.4", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "debug": "^4.4.1", "expect-type": "^1.2.1", "magic-string": "^0.30.17", "pathe": "^2.0.3", "picomatch": "^4.0.2", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", "tinyglobby": "^0.2.14", "tinypool": "^1.1.1", "tinyrainbow": "^2.0.0", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", "vite-node": "3.2.4", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "@vitest/browser": "3.2.4", "@vitest/ui": "3.2.4", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@types/debug", "@types/node", "@vitest/browser", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "vitest.mjs" } }, "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A=="],
|
||||
|
||||
"wait-on": ["[email protected]", "", { "dependencies": { "axios": "^1.12.1", "joi": "^18.0.1", "lodash": "^4.17.21", "minimist": "^1.2.8", "rxjs": "^7.8.2" }, "bin": { "wait-on": "bin/wait-on" } }, "sha512-J3WlS0txVHkhLRb2FsmRg3dkMTCV1+M6Xra3Ho7HzZDHpE7DCOnoSoCJsZotrmW3uRMhvIJGSKUKrh/MeF4iag=="],
|
||||
|
||||
"watchboy": ["[email protected]", "", { "dependencies": { "lodash.difference": "^4.5.0", "micromatch": "^4.0.2", "pify": "^4.0.1", "unixify": "^1.0.0" } }, "sha512-GHs1HxwvxSMBsqd/WfTOZhj5gBdMqf5HQpfgtKxDfZRxrlYPDdVLRB61LCeRzJaWANmvSIMlfmRVDwVmJFgAKA=="],
|
||||
|
||||
"why-is-node-running": ["[email protected]", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": { "why-is-node-running": "cli.js" } }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="],
|
||||
|
||||
"wrap-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q=="],
|
||||
|
||||
"wrappy": ["[email protected]", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
|
||||
|
||||
"ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
|
||||
|
||||
"wsl-utils": ["[email protected]", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="],
|
||||
|
||||
"y18n": ["[email protected]", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="],
|
||||
|
||||
"yallist": ["[email protected]", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
|
||||
|
||||
"yargs": ["[email protected]", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w=="],
|
||||
|
||||
"yargs-parser": ["[email protected]", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="],
|
||||
|
||||
"yauzl": ["[email protected]", "", { "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } }, "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g=="],
|
||||
|
||||
"zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"zwitch": ["[email protected]", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
|
||||
@@ -811,12 +1084,28 @@
|
||||
|
||||
"@tailwindcss/oxide-wasm32-wasi/tslib": ["[email protected]", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||
|
||||
"chalk/supports-color": ["[email protected]", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="],
|
||||
|
||||
"clone-response/mimic-response": ["[email protected]", "", {}, "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="],
|
||||
|
||||
"electron/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-Rs1bVAIdBs5gbTIKza/tgpMuG1k3U/UMJLWecIMxNdJFDMzcM5LOiLVRYh3PilWEYDIeUDv7bpiHPLPsbydGcw=="],
|
||||
|
||||
"electronmon/chalk": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg=="],
|
||||
|
||||
"global-agent/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
|
||||
|
||||
"mdast-util-find-and-replace/escape-string-regexp": ["[email protected]", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="],
|
||||
|
||||
"micromatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"parse-entities/@types/unist": ["@types/[email protected]", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="],
|
||||
|
||||
"vite/esbuild": ["[email protected]", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.12", "@esbuild/android-arm": "0.25.12", "@esbuild/android-arm64": "0.25.12", "@esbuild/android-x64": "0.25.12", "@esbuild/darwin-arm64": "0.25.12", "@esbuild/darwin-x64": "0.25.12", "@esbuild/freebsd-arm64": "0.25.12", "@esbuild/freebsd-x64": "0.25.12", "@esbuild/linux-arm": "0.25.12", "@esbuild/linux-arm64": "0.25.12", "@esbuild/linux-ia32": "0.25.12", "@esbuild/linux-loong64": "0.25.12", "@esbuild/linux-mips64el": "0.25.12", "@esbuild/linux-ppc64": "0.25.12", "@esbuild/linux-riscv64": "0.25.12", "@esbuild/linux-s390x": "0.25.12", "@esbuild/linux-x64": "0.25.12", "@esbuild/netbsd-arm64": "0.25.12", "@esbuild/netbsd-x64": "0.25.12", "@esbuild/openbsd-arm64": "0.25.12", "@esbuild/openbsd-x64": "0.25.12", "@esbuild/openharmony-arm64": "0.25.12", "@esbuild/sunos-x64": "0.25.12", "@esbuild/win32-arm64": "0.25.12", "@esbuild/win32-ia32": "0.25.12", "@esbuild/win32-x64": "0.25.12" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg=="],
|
||||
|
||||
"vitest/tinypool": ["[email protected]", "", {}, "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg=="],
|
||||
|
||||
"electronmon/chalk/supports-color": ["[email protected]", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="],
|
||||
|
||||
"vite/esbuild/@esbuild/aix-ppc64": ["@esbuild/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA=="],
|
||||
|
||||
"vite/esbuild/@esbuild/android-arm": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg=="],
|
||||
|
||||
+11
-19
@@ -1,34 +1,26 @@
|
||||
{
|
||||
"name": "t3",
|
||||
"version": "0.1.0",
|
||||
"private": false,
|
||||
"bin": {
|
||||
"t3": "apps/t3/dist/cli.js"
|
||||
},
|
||||
"files": [
|
||||
"apps/t3/dist/**",
|
||||
"apps/renderer/dist/**",
|
||||
"README.md"
|
||||
],
|
||||
"name": "ct-round-5",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"apps/*",
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "bun run build:contracts && bun run --cwd apps/t3 dev",
|
||||
"build": "bun run build:contracts && bun run --cwd apps/renderer build && bun run --cwd apps/t3 build",
|
||||
"dev": "CODETHING_LOG_WS_EVENTS=1 VITE_WS_URL=ws://localhost:3773 turbo run dev --ui=tui --filter=@acme/contracts --filter=@acme/renderer --filter=t3 --parallel",
|
||||
"dev:server": "bun run build:contracts && bun run --cwd apps/server dev",
|
||||
"dev:web": "VITE_WS_URL=ws://localhost:3773 bun run --cwd apps/renderer dev",
|
||||
"dev:desktop": "bun run --cwd apps/desktop dev",
|
||||
"start": "node apps/server/dist/index.js",
|
||||
"start:desktop": "bun run --cwd apps/desktop start",
|
||||
"build": "turbo run build",
|
||||
"build:desktop": "bun run build:contracts && bun run --cwd apps/renderer build && bun run --cwd apps/server build && bun run --cwd apps/desktop build",
|
||||
"typecheck": "turbo run typecheck",
|
||||
"lint": "oxlint --report-unused-disable-directives",
|
||||
"test": "turbo run test",
|
||||
"smoke-test": "bun run --cwd apps/t3 smoke-test",
|
||||
"test:desktop-smoke": "bun run --cwd apps/desktop smoke-test",
|
||||
"fmt": "oxfmt",
|
||||
"prepack": "node scripts/prepack.mjs",
|
||||
"build:contracts": "bun run --cwd packages/contracts build"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": "^8.18.0",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"oxfmt": "^0.28.0",
|
||||
"oxlint": "^1.43.0",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"import": "./src/index.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { agentConfigSchema, agentExitSchema, agentWriteInputSchema, outputChunkSchema } from "./agent";
|
||||
|
||||
describe("agentConfigSchema", () => {
|
||||
it("accepts valid agent configs", () => {
|
||||
const parsed = agentConfigSchema.parse({
|
||||
command: "bash",
|
||||
args: ["-lc", "echo hi"],
|
||||
cwd: "/workspace",
|
||||
usePty: false,
|
||||
});
|
||||
|
||||
expect(parsed.command).toBe("bash");
|
||||
});
|
||||
|
||||
it("rejects unexpected config properties", () => {
|
||||
expect(() =>
|
||||
agentConfigSchema.parse({
|
||||
command: "bash",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("outputChunkSchema", () => {
|
||||
it("accepts stdout/stderr output chunks", () => {
|
||||
expect(
|
||||
outputChunkSchema.parse({
|
||||
sessionId: "agent-1",
|
||||
stream: "stdout",
|
||||
data: "hello",
|
||||
}).stream,
|
||||
).toBe("stdout");
|
||||
});
|
||||
|
||||
it("rejects unexpected output properties", () => {
|
||||
expect(() =>
|
||||
outputChunkSchema.parse({
|
||||
sessionId: "agent-1",
|
||||
stream: "stdout",
|
||||
data: "hello",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects empty output session ids", () => {
|
||||
expect(() =>
|
||||
outputChunkSchema.parse({
|
||||
sessionId: "",
|
||||
stream: "stdout",
|
||||
data: "hello",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("agentWriteInputSchema", () => {
|
||||
it("accepts valid write payloads", () => {
|
||||
const parsed = agentWriteInputSchema.parse({
|
||||
sessionId: "agent-1",
|
||||
data: "ping\n",
|
||||
});
|
||||
|
||||
expect(parsed.sessionId).toBe("agent-1");
|
||||
});
|
||||
|
||||
it("rejects invalid write payloads", () => {
|
||||
expect(() =>
|
||||
agentWriteInputSchema.parse({
|
||||
sessionId: "",
|
||||
data: "ping\n",
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
agentWriteInputSchema.parse({
|
||||
sessionId: "agent-1",
|
||||
data: "ping\n",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("agentExitSchema", () => {
|
||||
it("accepts exit payloads", () => {
|
||||
const parsed = agentExitSchema.parse({
|
||||
sessionId: "agent-1",
|
||||
code: 0,
|
||||
signal: null,
|
||||
});
|
||||
|
||||
expect(parsed.code).toBe(0);
|
||||
});
|
||||
|
||||
it("rejects unexpected exit properties", () => {
|
||||
expect(() =>
|
||||
agentExitSchema.parse({
|
||||
sessionId: "agent-1",
|
||||
code: 0,
|
||||
signal: null,
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects empty exit session ids", () => {
|
||||
expect(() =>
|
||||
agentExitSchema.parse({
|
||||
sessionId: "",
|
||||
code: 0,
|
||||
signal: null,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -8,28 +8,20 @@ export const agentConfigSchema = z.object({
|
||||
cwd: z.string().optional(),
|
||||
env: z.record(z.string()).optional(),
|
||||
usePty: z.boolean().optional(),
|
||||
}).strict();
|
||||
|
||||
export const agentWriteInputSchema = z
|
||||
.object({
|
||||
sessionId: z.string().min(1),
|
||||
data: z.string(),
|
||||
})
|
||||
.strict();
|
||||
});
|
||||
|
||||
export const outputChunkSchema = z.object({
|
||||
sessionId: agentSessionIdSchema,
|
||||
sessionId: z.string(),
|
||||
stream: z.enum(["stdout", "stderr"]),
|
||||
data: z.string(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const agentExitSchema = z.object({
|
||||
sessionId: agentSessionIdSchema,
|
||||
sessionId: z.string(),
|
||||
code: z.number().nullable(),
|
||||
signal: z.string().nullable(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export type AgentConfig = z.infer<typeof agentConfigSchema>;
|
||||
export type AgentWriteInput = z.infer<typeof agentWriteInputSchema>;
|
||||
export type OutputChunk = z.infer<typeof outputChunkSchema>;
|
||||
export type AgentExit = z.infer<typeof agentExitSchema>;
|
||||
@@ -5,3 +5,4 @@ export * from "./terminal";
|
||||
export * from "./provider";
|
||||
export * from "./model";
|
||||
export * from "./ws";
|
||||
export * from "./project";
|
||||
@@ -1,208 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
appBootstrapResultSchema,
|
||||
appHealthResultSchema,
|
||||
dialogsPickFolderResultSchema,
|
||||
editorIdSchema,
|
||||
shellOpenInEditorInputSchema,
|
||||
WS_NATIVE_API_METHODS,
|
||||
wsNativeApiMethodSchema,
|
||||
} from "./ipc";
|
||||
|
||||
describe("appBootstrapResultSchema", () => {
|
||||
it("accepts valid bootstrap payloads", () => {
|
||||
const parsed = appBootstrapResultSchema.parse({
|
||||
launchCwd: "/workspace",
|
||||
projectName: "workspace",
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
session: {
|
||||
sessionId: "sess-1",
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
cwd: "/workspace",
|
||||
model: "gpt-5-codex",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
updatedAt: "2026-02-01T00:00:00.000Z",
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.provider).toBe("codex");
|
||||
});
|
||||
|
||||
it("rejects invalid bootstrap payloads", () => {
|
||||
expect(() =>
|
||||
appBootstrapResultSchema.parse({
|
||||
launchCwd: "/workspace",
|
||||
projectName: "",
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
session: {
|
||||
sessionId: "sess-1",
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
updatedAt: "2026-02-01T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects empty bootstrap errors", () => {
|
||||
expect(() =>
|
||||
appBootstrapResultSchema.parse({
|
||||
launchCwd: "/workspace",
|
||||
projectName: "workspace",
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
session: {
|
||||
sessionId: "sess-1",
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
updatedAt: "2026-02-01T00:00:00.000Z",
|
||||
},
|
||||
bootstrapError: "",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected bootstrap payload properties", () => {
|
||||
expect(() =>
|
||||
appBootstrapResultSchema.parse({
|
||||
launchCwd: "/workspace",
|
||||
projectName: "workspace",
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
session: {
|
||||
sessionId: "sess-1",
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
updatedAt: "2026-02-01T00:00:00.000Z",
|
||||
},
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("appHealthResultSchema", () => {
|
||||
it("accepts valid health payloads", () => {
|
||||
const parsed = appHealthResultSchema.parse({
|
||||
status: "ok",
|
||||
launchCwd: "/workspace",
|
||||
sessionCount: 2,
|
||||
activeClientConnected: true,
|
||||
});
|
||||
|
||||
expect(parsed.status).toBe("ok");
|
||||
});
|
||||
|
||||
it("rejects invalid health payloads", () => {
|
||||
expect(() =>
|
||||
appHealthResultSchema.parse({
|
||||
status: "ok",
|
||||
launchCwd: "/workspace",
|
||||
sessionCount: -1,
|
||||
activeClientConnected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects non-integer session counts", () => {
|
||||
expect(() =>
|
||||
appHealthResultSchema.parse({
|
||||
status: "ok",
|
||||
launchCwd: "/workspace",
|
||||
sessionCount: 1.5,
|
||||
activeClientConnected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected health payload properties", () => {
|
||||
expect(() =>
|
||||
appHealthResultSchema.parse({
|
||||
status: "ok",
|
||||
launchCwd: "/workspace",
|
||||
sessionCount: 1,
|
||||
activeClientConnected: true,
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("dialogsPickFolderResultSchema", () => {
|
||||
it("accepts null and string folder selections", () => {
|
||||
expect(dialogsPickFolderResultSchema.parse(null)).toBeNull();
|
||||
expect(dialogsPickFolderResultSchema.parse("/workspace")).toBe("/workspace");
|
||||
});
|
||||
|
||||
it("rejects non-string non-null selections", () => {
|
||||
expect(() => dialogsPickFolderResultSchema.parse(123)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("editor and shell-open schemas", () => {
|
||||
it("accepts known editor ids", () => {
|
||||
expect(editorIdSchema.parse("cursor")).toBe("cursor");
|
||||
expect(editorIdSchema.parse("file-manager")).toBe("file-manager");
|
||||
});
|
||||
|
||||
it("rejects unknown editor ids", () => {
|
||||
expect(() => editorIdSchema.parse("vscode")).toThrow();
|
||||
});
|
||||
|
||||
it("accepts valid shell.openInEditor payloads", () => {
|
||||
const parsed = shellOpenInEditorInputSchema.parse({
|
||||
cwd: "/workspace",
|
||||
editor: "cursor",
|
||||
});
|
||||
|
||||
expect(parsed.cwd).toBe("/workspace");
|
||||
expect(parsed.editor).toBe("cursor");
|
||||
});
|
||||
|
||||
it("rejects invalid shell.openInEditor payloads", () => {
|
||||
expect(() =>
|
||||
shellOpenInEditorInputSchema.parse({
|
||||
cwd: "",
|
||||
editor: "cursor",
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
shellOpenInEditorInputSchema.parse({
|
||||
cwd: "/workspace",
|
||||
editor: "vscode",
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
shellOpenInEditorInputSchema.parse({
|
||||
cwd: "/workspace",
|
||||
editor: "cursor",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("wsNativeApiMethodSchema", () => {
|
||||
it("accepts every declared websocket native API method", () => {
|
||||
for (const method of WS_NATIVE_API_METHODS) {
|
||||
expect(wsNativeApiMethodSchema.parse(method)).toBe(method);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects unknown websocket native API methods", () => {
|
||||
expect(() => wsNativeApiMethodSchema.parse("providers.abortTurn")).toThrow();
|
||||
});
|
||||
|
||||
it("keeps declared websocket native API methods unique", () => {
|
||||
expect(new Set(WS_NATIVE_API_METHODS).size).toBe(WS_NATIVE_API_METHODS.length);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import type { AgentConfig, AgentExit, OutputChunk } from "./agent";
|
||||
import { providerKindSchema, providerSessionSchema } from "./provider";
|
||||
import type {
|
||||
ProviderEvent,
|
||||
ProviderInterruptTurnInput,
|
||||
@@ -11,6 +9,12 @@ import type {
|
||||
ProviderStopSessionInput,
|
||||
ProviderTurnStartResult,
|
||||
} from "./provider";
|
||||
import type {
|
||||
ProjectAddInput,
|
||||
ProjectAddResult,
|
||||
ProjectListResult,
|
||||
ProjectRemoveInput,
|
||||
} from "./project";
|
||||
import type { TerminalCommandInput, TerminalCommandResult } from "./terminal";
|
||||
import type { NewTodoInput, Todo } from "./todo";
|
||||
|
||||
@@ -19,64 +23,9 @@ export const EDITORS = [
|
||||
{ id: "file-manager", label: "File Manager", command: null },
|
||||
] as const;
|
||||
|
||||
export const WS_NATIVE_API_METHODS = [
|
||||
"app.bootstrap",
|
||||
"app.health",
|
||||
"todos.list",
|
||||
"todos.add",
|
||||
"todos.toggle",
|
||||
"todos.remove",
|
||||
"dialogs.pickFolder",
|
||||
"terminal.run",
|
||||
"agent.spawn",
|
||||
"agent.kill",
|
||||
"agent.write",
|
||||
"providers.startSession",
|
||||
"providers.sendTurn",
|
||||
"providers.interruptTurn",
|
||||
"providers.respondToRequest",
|
||||
"providers.stopSession",
|
||||
"providers.listSessions",
|
||||
"shell.openInEditor",
|
||||
] as const;
|
||||
|
||||
export type WsNativeApiMethod = (typeof WS_NATIVE_API_METHODS)[number];
|
||||
export const wsNativeApiMethodSchema = z.enum(WS_NATIVE_API_METHODS);
|
||||
|
||||
export type EditorId = (typeof EDITORS)[number]["id"];
|
||||
export const editorIdSchema = z.enum(EDITORS.map((entry) => entry.id) as [EditorId, ...EditorId[]]);
|
||||
|
||||
export const appBootstrapResultSchema = z.object({
|
||||
launchCwd: z.string().min(1),
|
||||
projectName: z.string().min(1),
|
||||
provider: providerKindSchema,
|
||||
model: z.string().min(1),
|
||||
session: providerSessionSchema,
|
||||
bootstrapError: z.string().min(1).optional(),
|
||||
}).strict();
|
||||
|
||||
export const appHealthResultSchema = z.object({
|
||||
status: z.literal("ok"),
|
||||
launchCwd: z.string().min(1),
|
||||
sessionCount: z.number().int().min(0),
|
||||
activeClientConnected: z.boolean(),
|
||||
}).strict();
|
||||
export const dialogsPickFolderResultSchema = z.string().nullable();
|
||||
export const shellOpenInEditorInputSchema = z
|
||||
.object({
|
||||
cwd: z.string().min(1),
|
||||
editor: editorIdSchema,
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type AppBootstrapResult = z.infer<typeof appBootstrapResultSchema>;
|
||||
export type AppHealthResult = z.infer<typeof appHealthResultSchema>;
|
||||
|
||||
export interface NativeApi {
|
||||
app: {
|
||||
bootstrap: () => Promise<AppBootstrapResult>;
|
||||
health: () => Promise<AppHealthResult>;
|
||||
};
|
||||
todos: {
|
||||
list: () => Promise<Todo[]>;
|
||||
add: (input: NewTodoInput) => Promise<Todo[]>;
|
||||
@@ -105,6 +54,11 @@ export interface NativeApi {
|
||||
listSessions: () => Promise<ProviderSession[]>;
|
||||
onEvent: (callback: (event: ProviderEvent) => void) => () => void;
|
||||
};
|
||||
projects: {
|
||||
list: () => Promise<ProjectListResult>;
|
||||
add: (input: ProjectAddInput) => Promise<ProjectAddResult>;
|
||||
remove: (input: ProjectRemoveInput) => Promise<void>;
|
||||
};
|
||||
shell: {
|
||||
openInEditor: (cwd: string, editor: EditorId) => Promise<void>;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
projectAddInputSchema,
|
||||
projectAddResultSchema,
|
||||
projectListResultSchema,
|
||||
projectRemoveInputSchema,
|
||||
} from "./project";
|
||||
|
||||
describe("project contracts", () => {
|
||||
it("parses project list result", () => {
|
||||
const result = projectListResultSchema.parse([
|
||||
{
|
||||
id: "project-1",
|
||||
cwd: "/tmp/project",
|
||||
name: "project",
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
]);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]?.id).toBe("project-1");
|
||||
});
|
||||
|
||||
it("trims add input cwd", () => {
|
||||
const parsed = projectAddInputSchema.parse({ cwd: " /tmp/project " });
|
||||
expect(parsed.cwd).toBe("/tmp/project");
|
||||
});
|
||||
|
||||
it("requires add result created flag", () => {
|
||||
const parsed = projectAddResultSchema.parse({
|
||||
project: {
|
||||
id: "project-1",
|
||||
cwd: "/tmp/project",
|
||||
name: "project",
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
created: true,
|
||||
});
|
||||
expect(parsed.created).toBe(true);
|
||||
});
|
||||
|
||||
it("parses remove input", () => {
|
||||
const parsed = projectRemoveInputSchema.parse({ id: "project-1" });
|
||||
expect(parsed.id).toBe("project-1");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const projectRecordSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
cwd: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
createdAt: z.string().datetime(),
|
||||
updatedAt: z.string().datetime(),
|
||||
});
|
||||
|
||||
export const projectListResultSchema = z.array(projectRecordSchema);
|
||||
|
||||
export const projectAddInputSchema = z.object({
|
||||
cwd: z.string().trim().min(1),
|
||||
});
|
||||
|
||||
export const projectAddResultSchema = z.object({
|
||||
project: projectRecordSchema,
|
||||
created: z.boolean(),
|
||||
});
|
||||
|
||||
export const projectRemoveInputSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
});
|
||||
|
||||
export type ProjectRecord = z.infer<typeof projectRecordSchema>;
|
||||
export type ProjectListResult = z.infer<typeof projectListResultSchema>;
|
||||
export type ProjectAddInput = z.input<typeof projectAddInputSchema>;
|
||||
export type ProjectAddResult = z.infer<typeof projectAddResultSchema>;
|
||||
export type ProjectRemoveInput = z.input<typeof projectRemoveInputSchema>;
|
||||
@@ -29,15 +29,6 @@ describe("providerSessionStartInputSchema", () => {
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected startSession input properties", () => {
|
||||
expect(() =>
|
||||
providerSessionStartInputSchema.parse({
|
||||
provider: "codex",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("providerSendTurnInputSchema", () => {
|
||||
@@ -52,16 +43,6 @@ describe("providerSendTurnInputSchema", () => {
|
||||
expect(parsed.model).toBe("gpt-5.2-codex");
|
||||
expect(parsed.effort).toBe("high");
|
||||
});
|
||||
|
||||
it("rejects unexpected sendTurn properties", () => {
|
||||
expect(() =>
|
||||
providerSendTurnInputSchema.parse({
|
||||
sessionId: "sess_1",
|
||||
input: "hello",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("providerEventSchema", () => {
|
||||
@@ -95,22 +76,6 @@ describe("providerEventSchema", () => {
|
||||
expect(parsed.requestId).toBe("req_123");
|
||||
expect(parsed.requestKind).toBe("command");
|
||||
});
|
||||
|
||||
it("rejects unexpected event properties", () => {
|
||||
expect(() =>
|
||||
providerEventSchema.parse({
|
||||
id: "evt_2",
|
||||
kind: "request",
|
||||
provider: "codex",
|
||||
sessionId: "sess_1",
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
method: "item/commandExecution/requestApproval",
|
||||
requestId: "req_123",
|
||||
requestKind: "command",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("providerRespondToRequestInputSchema", () => {
|
||||
@@ -132,15 +97,4 @@ describe("providerRespondToRequestInputSchema", () => {
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected respondToRequest properties", () => {
|
||||
expect(() =>
|
||||
providerRespondToRequestInputSchema.parse({
|
||||
sessionId: "sess_1",
|
||||
requestId: "req_1",
|
||||
decision: "accept",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -43,9 +43,7 @@ export const providerSessionSchema = z.object({
|
||||
createdAt: z.string().datetime(),
|
||||
updatedAt: z.string().datetime(),
|
||||
lastError: z.string().min(1).optional(),
|
||||
}).strict();
|
||||
|
||||
export const providerSessionListSchema = z.array(providerSessionSchema);
|
||||
});
|
||||
|
||||
export const providerSessionStartInputSchema = z.object({
|
||||
provider: providerKindSchema.default("codex"),
|
||||
@@ -54,7 +52,7 @@ export const providerSessionStartInputSchema = z.object({
|
||||
resumeThreadId: z.string().trim().min(1).optional(),
|
||||
approvalPolicy: providerApprovalPolicySchema.default("never"),
|
||||
sandboxMode: providerSandboxModeSchema.default("workspace-write"),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const PROVIDER_SEND_TURN_MAX_INPUT_CHARS = 120_000;
|
||||
|
||||
@@ -63,29 +61,34 @@ export const providerSendTurnInputSchema = z.object({
|
||||
input: z.string().trim().min(1).max(PROVIDER_SEND_TURN_MAX_INPUT_CHARS),
|
||||
model: z.string().trim().min(1).optional(),
|
||||
effort: z.string().trim().min(1).optional(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const providerTurnStartResultSchema = z.object({
|
||||
threadId: z.string().min(1),
|
||||
turnId: z.string().min(1),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const providerInterruptTurnInputSchema = z.object({
|
||||
sessionId: z.string().min(1),
|
||||
turnId: z.string().min(1).optional(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const providerStopSessionInputSchema = z.object({
|
||||
sessionId: z.string().min(1),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const providerRespondToRequestInputSchema = z.object({
|
||||
sessionId: z.string().min(1),
|
||||
requestId: z.string().min(1),
|
||||
decision: providerApprovalDecisionSchema,
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const providerEventKindSchema = z.enum(["session", "notification", "request", "error"]);
|
||||
export const providerEventKindSchema = z.enum([
|
||||
"session",
|
||||
"notification",
|
||||
"request",
|
||||
"error",
|
||||
]);
|
||||
|
||||
export const providerEventSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
@@ -102,20 +105,30 @@ export const providerEventSchema = z.object({
|
||||
requestKind: providerRequestKindSchema.optional(),
|
||||
textDelta: z.string().optional(),
|
||||
payload: z.unknown().optional(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export type ProviderKind = z.infer<typeof providerKindSchema>;
|
||||
export type ProviderApprovalPolicy = z.infer<typeof providerApprovalPolicySchema>;
|
||||
export type ProviderSandboxMode = z.infer<typeof providerSandboxModeSchema>;
|
||||
export type ProviderRequestKind = z.infer<typeof providerRequestKindSchema>;
|
||||
export type ProviderApprovalDecision = z.infer<typeof providerApprovalDecisionSchema>;
|
||||
export type ProviderApprovalDecision = z.infer<
|
||||
typeof providerApprovalDecisionSchema
|
||||
>;
|
||||
export type ProviderSessionStatus = z.infer<typeof providerSessionStatusSchema>;
|
||||
export type ProviderSession = z.infer<typeof providerSessionSchema>;
|
||||
export type ProviderSessionStartInput = z.input<typeof providerSessionStartInputSchema>;
|
||||
export type ProviderSendTurnInput = z.input<typeof providerSendTurnInputSchema>;
|
||||
export type ProviderTurnStartResult = z.infer<typeof providerTurnStartResultSchema>;
|
||||
export type ProviderInterruptTurnInput = z.input<typeof providerInterruptTurnInputSchema>;
|
||||
export type ProviderStopSessionInput = z.input<typeof providerStopSessionInputSchema>;
|
||||
export type ProviderRespondToRequestInput = z.input<typeof providerRespondToRequestInputSchema>;
|
||||
export type ProviderTurnStartResult = z.infer<
|
||||
typeof providerTurnStartResultSchema
|
||||
>;
|
||||
export type ProviderInterruptTurnInput = z.input<
|
||||
typeof providerInterruptTurnInputSchema
|
||||
>;
|
||||
export type ProviderStopSessionInput = z.input<
|
||||
typeof providerStopSessionInputSchema
|
||||
>;
|
||||
export type ProviderRespondToRequestInput = z.input<
|
||||
typeof providerRespondToRequestInputSchema
|
||||
>;
|
||||
export type ProviderEventKind = z.infer<typeof providerEventKindSchema>;
|
||||
export type ProviderEvent = z.infer<typeof providerEventSchema>;
|
||||
@@ -21,12 +21,4 @@ describe("terminalCommandInputSchema", () => {
|
||||
const result = terminalCommandInputSchema.safeParse({ command: " " });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects unexpected command properties", () => {
|
||||
const result = terminalCommandInputSchema.safeParse({
|
||||
command: "echo hello",
|
||||
unexpected: true,
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@ export const terminalCommandInputSchema = z.object({
|
||||
command: z.string().trim().min(1).max(4000),
|
||||
cwd: z.string().min(1).optional(),
|
||||
timeoutMs: z.number().int().positive().max(120_000).optional(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const terminalCommandResultSchema = z.object({
|
||||
stdout: z.string(),
|
||||
@@ -12,7 +12,7 @@ export const terminalCommandResultSchema = z.object({
|
||||
code: z.number().nullable(),
|
||||
signal: z.string().nullable(),
|
||||
timedOut: z.boolean(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export type TerminalCommandInput = z.infer<typeof terminalCommandInputSchema>;
|
||||
export type TerminalCommandResult = z.infer<typeof terminalCommandResultSchema>;
|
||||
@@ -32,17 +32,6 @@ describe("todoSchema", () => {
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects todos with unexpected properties", () => {
|
||||
const result = todoSchema.safeParse({
|
||||
id: "abc-123",
|
||||
title: "Buy milk",
|
||||
completed: false,
|
||||
createdAt: "2025-01-01T00:00:00.000Z",
|
||||
unexpected: true,
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("newTodoInputSchema", () => {
|
||||
@@ -60,12 +49,4 @@ describe("newTodoInputSchema", () => {
|
||||
const result = newTodoInputSchema.safeParse({ title: " " });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects unexpected input properties", () => {
|
||||
const result = newTodoInputSchema.safeParse({
|
||||
title: "Buy milk",
|
||||
unexpected: true,
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -5,13 +5,13 @@ export const todoSchema = z.object({
|
||||
title: z.string().min(1).max(280),
|
||||
completed: z.boolean(),
|
||||
createdAt: z.string().datetime(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const todoListSchema = z.array(todoSchema);
|
||||
|
||||
export const newTodoInputSchema = z.object({
|
||||
title: z.string().trim().min(1).max(280),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
export const todoIdSchema = z.string().min(1);
|
||||
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
WS_CLOSE_CODES,
|
||||
WS_CLOSE_REASONS,
|
||||
WS_ERROR_CODE_MAX_CHARS,
|
||||
WS_ERROR_MESSAGE_MAX_CHARS,
|
||||
WS_EVENT_CHANNELS,
|
||||
WS_METHOD_MAX_CHARS,
|
||||
WS_REQUEST_ID_MAX_CHARS,
|
||||
wsClientMessageSchema,
|
||||
wsServerMessageSchema,
|
||||
} from "./ws";
|
||||
|
||||
describe("wsClientMessageSchema", () => {
|
||||
it("accepts request messages", () => {
|
||||
const parsed = wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: "providers.startSession",
|
||||
params: { provider: "codex" },
|
||||
});
|
||||
|
||||
expect(parsed.method).toBe("providers.startSession");
|
||||
});
|
||||
|
||||
it("rejects empty request ids", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "",
|
||||
method: "providers.startSession",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects whitespace-only request ids", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: " ",
|
||||
method: "providers.startSession",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects empty request methods", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: "",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects whitespace-only request methods", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: " ",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects overly long request ids", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "r".repeat(WS_REQUEST_ID_MAX_CHARS + 1),
|
||||
method: "providers.startSession",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts request ids at max length", () => {
|
||||
const parsed = wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "r".repeat(WS_REQUEST_ID_MAX_CHARS),
|
||||
method: "providers.startSession",
|
||||
});
|
||||
|
||||
expect(parsed.id).toHaveLength(WS_REQUEST_ID_MAX_CHARS);
|
||||
});
|
||||
|
||||
it("rejects overly long request methods", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: "m".repeat(WS_METHOD_MAX_CHARS + 1),
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts request methods at max length", () => {
|
||||
const parsed = wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: "m".repeat(WS_METHOD_MAX_CHARS),
|
||||
});
|
||||
|
||||
expect(parsed.method).toHaveLength(WS_METHOD_MAX_CHARS);
|
||||
});
|
||||
|
||||
it("rejects unexpected request properties", () => {
|
||||
expect(() =>
|
||||
wsClientMessageSchema.parse({
|
||||
type: "request",
|
||||
id: "req-1",
|
||||
method: "providers.listSessions",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("wsServerMessageSchema", () => {
|
||||
it("accepts successful response messages", () => {
|
||||
const parsed = wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: true,
|
||||
result: { sessionId: "sess-1" },
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("response");
|
||||
});
|
||||
|
||||
it("requires errors for failed responses", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts response errors at max field lengths", () => {
|
||||
const parsed = wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "c".repeat(WS_ERROR_CODE_MAX_CHARS),
|
||||
message: "m".repeat(WS_ERROR_MESSAGE_MAX_CHARS),
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("response");
|
||||
});
|
||||
|
||||
it("rejects overlong response error fields", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "c".repeat(WS_ERROR_CODE_MAX_CHARS + 1),
|
||||
message: "valid",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "request_failed",
|
||||
message: "m".repeat(WS_ERROR_MESSAGE_MAX_CHARS + 1),
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("requires result for successful responses", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects errors for successful responses", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: true,
|
||||
result: { status: "ok" },
|
||||
error: {
|
||||
code: "unexpected",
|
||||
message: "should-not-be-present",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects result payloads for failed responses", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
result: { status: "unexpected" },
|
||||
error: {
|
||||
code: "request_failed",
|
||||
message: "expected-failure",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected response properties", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: true,
|
||||
result: { status: "ok" },
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects overly long response ids", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "r".repeat(WS_REQUEST_ID_MAX_CHARS + 1),
|
||||
ok: true,
|
||||
result: {},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts response ids at max length", () => {
|
||||
const parsed = wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "r".repeat(WS_REQUEST_ID_MAX_CHARS),
|
||||
ok: true,
|
||||
result: {},
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("response");
|
||||
});
|
||||
|
||||
it("rejects whitespace-only response ids", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: " ",
|
||||
ok: true,
|
||||
result: {},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects whitespace-only response error fields", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: " ",
|
||||
message: "valid",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "request_failed",
|
||||
message: " ",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts typed event channels", () => {
|
||||
const parsed = wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.providerEvent,
|
||||
payload: {
|
||||
id: "evt-1",
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: "sess-1",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
method: "turn/started",
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("event");
|
||||
});
|
||||
|
||||
it("accepts typed agent output and exit events", () => {
|
||||
const output = wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.agentOutput,
|
||||
payload: {
|
||||
sessionId: "agent-1",
|
||||
stream: "stdout",
|
||||
data: "hello",
|
||||
},
|
||||
});
|
||||
const exit = wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.agentExit,
|
||||
payload: {
|
||||
sessionId: "agent-1",
|
||||
code: 0,
|
||||
signal: null,
|
||||
},
|
||||
});
|
||||
|
||||
expect(output.type).toBe("event");
|
||||
expect(exit.type).toBe("event");
|
||||
});
|
||||
|
||||
it("rejects unknown event channels", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: "provider:unknown",
|
||||
payload: {
|
||||
id: "evt-1",
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: "sess-1",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
method: "turn/started",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects malformed payloads for typed channels", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.providerEvent,
|
||||
payload: {
|
||||
sessionId: "sess-1",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.agentOutput,
|
||||
payload: {
|
||||
sessionId: "agent-1",
|
||||
stream: "invalid-stream",
|
||||
data: "oops",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.agentExit,
|
||||
payload: {
|
||||
sessionId: "agent-1",
|
||||
code: "0",
|
||||
signal: null,
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects agent events with empty session ids", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.agentOutput,
|
||||
payload: {
|
||||
sessionId: "",
|
||||
stream: "stdout",
|
||||
data: "hello",
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.agentExit,
|
||||
payload: {
|
||||
sessionId: "",
|
||||
code: 0,
|
||||
signal: null,
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected event properties", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "event",
|
||||
channel: WS_EVENT_CHANNELS.providerEvent,
|
||||
payload: {
|
||||
id: "evt-1",
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: "sess-1",
|
||||
createdAt: "2026-02-01T00:00:00.000Z",
|
||||
method: "turn/started",
|
||||
},
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected response error properties", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "response",
|
||||
id: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "request_failed",
|
||||
message: "boom",
|
||||
unexpected: true,
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts hello server messages", () => {
|
||||
const parsed = wsServerMessageSchema.parse({
|
||||
type: "hello",
|
||||
version: 1,
|
||||
launchCwd: "/workspace",
|
||||
});
|
||||
|
||||
expect(parsed.type).toBe("hello");
|
||||
});
|
||||
|
||||
it("rejects hello messages with unsupported versions", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "hello",
|
||||
version: 2,
|
||||
launchCwd: "/workspace",
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects unexpected hello properties", () => {
|
||||
expect(() =>
|
||||
wsServerMessageSchema.parse({
|
||||
type: "hello",
|
||||
version: 1,
|
||||
launchCwd: "/workspace",
|
||||
unexpected: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ws close metadata", () => {
|
||||
it("exposes stable unauthorized close semantics", () => {
|
||||
expect(WS_CLOSE_CODES.unauthorized).toBe(4001);
|
||||
expect(WS_CLOSE_REASONS.unauthorized).toBe("unauthorized");
|
||||
});
|
||||
|
||||
it("exposes stable replacement close semantics", () => {
|
||||
expect(WS_CLOSE_CODES.replacedByNewClient).toBe(4000);
|
||||
expect(WS_CLOSE_REASONS.replacedByNewClient).toBe("replaced-by-new-client");
|
||||
});
|
||||
|
||||
it("keeps close codes and reasons unique", () => {
|
||||
expect(
|
||||
new Set([WS_CLOSE_CODES.unauthorized, WS_CLOSE_CODES.replacedByNewClient]).size,
|
||||
).toBe(2);
|
||||
expect(
|
||||
new Set([WS_CLOSE_REASONS.unauthorized, WS_CLOSE_REASONS.replacedByNewClient]).size,
|
||||
).toBe(2);
|
||||
});
|
||||
});
|
||||
+61
-122
@@ -1,139 +1,78 @@
|
||||
import { z } from "zod";
|
||||
import { agentExitSchema, outputChunkSchema } from "./agent";
|
||||
import { providerEventSchema } from "./provider";
|
||||
|
||||
export const WS_EVENT_CHANNELS = {
|
||||
providerEvent: "provider:event",
|
||||
agentOutput: "agent:output",
|
||||
agentExit: "agent:exit",
|
||||
// ── WebSocket RPC Method Names ───────────────────────────────────────
|
||||
|
||||
export const WS_METHODS = {
|
||||
// Provider methods (mirrors NativeApi.providers)
|
||||
providersStartSession: "providers.startSession",
|
||||
providersSendTurn: "providers.sendTurn",
|
||||
providersInterruptTurn: "providers.interruptTurn",
|
||||
providersRespondToRequest: "providers.respondToRequest",
|
||||
providersStopSession: "providers.stopSession",
|
||||
providersListSessions: "providers.listSessions",
|
||||
|
||||
// Project registry methods
|
||||
projectsList: "projects.list",
|
||||
projectsAdd: "projects.add",
|
||||
projectsRemove: "projects.remove",
|
||||
|
||||
// Shell methods
|
||||
shellOpenInEditor: "shell.openInEditor",
|
||||
|
||||
// Server meta
|
||||
serverGetConfig: "server.getConfig",
|
||||
} as const;
|
||||
|
||||
export const WS_CLOSE_CODES = {
|
||||
replacedByNewClient: 4000,
|
||||
unauthorized: 4001,
|
||||
// ── Push Event Channels ──────────────────────────────────────────────
|
||||
|
||||
export const WS_CHANNELS = {
|
||||
providerEvent: "providers.event",
|
||||
serverWelcome: "server.welcome",
|
||||
} as const;
|
||||
|
||||
export const WS_CLOSE_REASONS = {
|
||||
replacedByNewClient: "replaced-by-new-client",
|
||||
unauthorized: "unauthorized",
|
||||
} as const;
|
||||
// ── Client → Server (request) ────────────────────────────────────────
|
||||
|
||||
export const WS_REQUEST_ID_MAX_CHARS = 256;
|
||||
export const WS_METHOD_MAX_CHARS = 256;
|
||||
export const WS_ERROR_CODE_MAX_CHARS = 128;
|
||||
export const WS_ERROR_MESSAGE_MAX_CHARS = 8_192;
|
||||
|
||||
const wsRequestIdSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(WS_REQUEST_ID_MAX_CHARS)
|
||||
.refine((value) => value.trim().length > 0, {
|
||||
message: "request.id must not be blank",
|
||||
});
|
||||
const wsMethodSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(WS_METHOD_MAX_CHARS)
|
||||
.refine((value) => value.trim().length > 0, {
|
||||
message: "request.method must not be blank",
|
||||
});
|
||||
const wsErrorCodeSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(WS_ERROR_CODE_MAX_CHARS)
|
||||
.refine((value) => value.trim().length > 0, {
|
||||
message: "response.error.code must not be blank",
|
||||
});
|
||||
const wsErrorMessageSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(WS_ERROR_MESSAGE_MAX_CHARS)
|
||||
.refine((value) => value.trim().length > 0, {
|
||||
message: "response.error.message must not be blank",
|
||||
});
|
||||
|
||||
const wsRequestSchema = z.object({
|
||||
type: z.literal("request"),
|
||||
id: wsRequestIdSchema,
|
||||
method: wsMethodSchema,
|
||||
export const wsRequestSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
method: z.string().min(1),
|
||||
params: z.unknown().optional(),
|
||||
}).strict();
|
||||
});
|
||||
|
||||
const wsResponseErrorSchema = z.object({
|
||||
code: wsErrorCodeSchema,
|
||||
message: wsErrorMessageSchema,
|
||||
}).strict();
|
||||
export type WsRequest = z.infer<typeof wsRequestSchema>;
|
||||
|
||||
const wsResponseSchema = z
|
||||
.object({
|
||||
type: z.literal("response"),
|
||||
id: wsRequestIdSchema,
|
||||
ok: z.boolean(),
|
||||
result: z.unknown().optional(),
|
||||
error: wsResponseErrorSchema.optional(),
|
||||
})
|
||||
.strict()
|
||||
.superRefine((value, ctx) => {
|
||||
if (value.ok && value.error) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "response.error must be undefined when ok=true",
|
||||
});
|
||||
}
|
||||
// ── Server → Client (response to request) ────────────────────────────
|
||||
|
||||
if (value.ok && value.result === undefined) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "response.result is required when ok=true",
|
||||
});
|
||||
}
|
||||
export const wsResponseSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
result: z.unknown().optional(),
|
||||
error: z
|
||||
.object({
|
||||
message: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
if (!value.ok && !value.error) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "response.error is required when ok=false",
|
||||
});
|
||||
}
|
||||
export type WsResponse = z.infer<typeof wsResponseSchema>;
|
||||
|
||||
if (!value.ok && value.result !== undefined) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "response.result must be undefined when ok=false",
|
||||
});
|
||||
}
|
||||
});
|
||||
// ── Server → Client (push event) ─────────────────────────────────────
|
||||
|
||||
const wsEventSchema = z.union([
|
||||
z.object({
|
||||
type: z.literal("event"),
|
||||
channel: z.literal(WS_EVENT_CHANNELS.providerEvent),
|
||||
payload: providerEventSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
type: z.literal("event"),
|
||||
channel: z.literal(WS_EVENT_CHANNELS.agentOutput),
|
||||
payload: outputChunkSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
type: z.literal("event"),
|
||||
channel: z.literal(WS_EVENT_CHANNELS.agentExit),
|
||||
payload: agentExitSchema,
|
||||
}).strict(),
|
||||
]);
|
||||
export const wsPushSchema = z.object({
|
||||
type: z.literal("push"),
|
||||
channel: z.string().min(1),
|
||||
data: z.unknown(),
|
||||
});
|
||||
|
||||
const wsHelloSchema = z.object({
|
||||
type: z.literal("hello"),
|
||||
version: z.literal(1),
|
||||
launchCwd: z.string().min(1),
|
||||
}).strict();
|
||||
export type WsPush = z.infer<typeof wsPushSchema>;
|
||||
|
||||
export const wsClientMessageSchema = wsRequestSchema;
|
||||
export const wsServerMessageSchema = z.union([wsResponseSchema, wsEventSchema, wsHelloSchema]);
|
||||
// ── Union of all server → client messages ─────────────────────────────
|
||||
|
||||
export type WsEventChannel = z.infer<typeof wsEventSchema>["channel"];
|
||||
export type WsRequestMessage = z.infer<typeof wsRequestSchema>;
|
||||
export type WsResponseMessage = z.infer<typeof wsResponseSchema>;
|
||||
export type WsEventMessage = z.infer<typeof wsEventSchema>;
|
||||
export type WsHelloMessage = z.infer<typeof wsHelloSchema>;
|
||||
export type WsClientMessage = z.infer<typeof wsClientMessageSchema>;
|
||||
export type WsServerMessage = z.infer<typeof wsServerMessageSchema>;
|
||||
export type WsServerMessage = WsResponse | WsPush;
|
||||
|
||||
// ── Server welcome payload ───────────────────────────────────────────
|
||||
|
||||
export const wsWelcomePayloadSchema = z.object({
|
||||
cwd: z.string().min(1),
|
||||
projectName: z.string().min(1),
|
||||
});
|
||||
|
||||
export type WsWelcomePayload = z.infer<typeof wsWelcomePayloadSchema>;
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "@acme/runtime-core",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"import": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@acme/contracts": "workspace:*",
|
||||
"node-pty": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export * from "./processManager";
|
||||
export * from "./todoStore";
|
||||
export * from "./providerManager";
|
||||
export * from "./codexAppServerManager";
|
||||
@@ -1,48 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ProcessManager } from "./processManager";
|
||||
|
||||
describe("ProcessManager", () => {
|
||||
it("can be instantiated", () => {
|
||||
const pm = new ProcessManager();
|
||||
expect(pm).toBeInstanceOf(ProcessManager);
|
||||
});
|
||||
|
||||
it("spawns a process and receives output", async () => {
|
||||
const pm = new ProcessManager();
|
||||
const chunks: string[] = [];
|
||||
|
||||
const done = new Promise<void>((resolve) => {
|
||||
pm.on("output", (chunk) => {
|
||||
chunks.push(chunk.data);
|
||||
});
|
||||
pm.on("exit", () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const sessionId = pm.spawn({ command: "echo", args: ["hello"] });
|
||||
expect(typeof sessionId).toBe("string");
|
||||
expect(sessionId.length).toBeGreaterThan(0);
|
||||
|
||||
await done;
|
||||
|
||||
expect(chunks.join("").trim()).toBe("hello");
|
||||
});
|
||||
|
||||
it("can kill a spawned process", async () => {
|
||||
const pm = new ProcessManager();
|
||||
|
||||
const exited = new Promise<number | null>((resolve) => {
|
||||
pm.on("exit", (exit) => {
|
||||
resolve(exit.code);
|
||||
});
|
||||
});
|
||||
|
||||
const sessionId = pm.spawn({ command: "sleep", args: ["10"] });
|
||||
pm.kill(sessionId);
|
||||
|
||||
const code = await exited;
|
||||
expect(code).not.toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -1,144 +0,0 @@
|
||||
import { type ChildProcess, spawn } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { EventEmitter } from "node:events";
|
||||
|
||||
import {
|
||||
type AgentConfig,
|
||||
type AgentExit,
|
||||
type OutputChunk,
|
||||
agentConfigSchema,
|
||||
} from "@acme/contracts";
|
||||
import type { IPty } from "node-pty";
|
||||
|
||||
export interface ProcessManagerEvents {
|
||||
output: [chunk: OutputChunk];
|
||||
exit: [exit: AgentExit];
|
||||
}
|
||||
|
||||
export class ProcessManager extends EventEmitter<ProcessManagerEvents> {
|
||||
private sessions = new Map<string, ChildProcess>();
|
||||
private ptySessions = new Map<string, IPty>();
|
||||
|
||||
spawn(raw: AgentConfig): string {
|
||||
const config = agentConfigSchema.parse(raw);
|
||||
const sessionId = randomUUID();
|
||||
|
||||
if (config.usePty) {
|
||||
return this.spawnPty(sessionId, config);
|
||||
}
|
||||
|
||||
return this.spawnProcess(sessionId, config);
|
||||
}
|
||||
|
||||
private spawnProcess(sessionId: string, config: AgentConfig): string {
|
||||
const child = spawn(config.command, config.args, {
|
||||
cwd: config.cwd,
|
||||
env: config.env ? { ...process.env, ...config.env } : process.env,
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
this.sessions.set(sessionId, child);
|
||||
|
||||
child.stdout?.on("data", (data: Buffer) => {
|
||||
this.emit("output", {
|
||||
sessionId,
|
||||
stream: "stdout",
|
||||
data: data.toString(),
|
||||
});
|
||||
});
|
||||
|
||||
child.stderr?.on("data", (data: Buffer) => {
|
||||
this.emit("output", {
|
||||
sessionId,
|
||||
stream: "stderr",
|
||||
data: data.toString(),
|
||||
});
|
||||
});
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
this.sessions.delete(sessionId);
|
||||
this.emit("exit", {
|
||||
sessionId,
|
||||
code: code ?? null,
|
||||
signal: signal ?? null,
|
||||
});
|
||||
});
|
||||
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
private spawnPty(sessionId: string, config: AgentConfig): string {
|
||||
const pty = require("node-pty") as typeof import("node-pty");
|
||||
|
||||
const ptyProcess = pty.spawn(config.command, config.args, {
|
||||
name: "xterm-256color",
|
||||
cols: 120,
|
||||
rows: 30,
|
||||
cwd: config.cwd ?? process.cwd(),
|
||||
env: (config.env ? { ...process.env, ...config.env } : process.env) as Record<string, string>,
|
||||
});
|
||||
|
||||
this.ptySessions.set(sessionId, ptyProcess);
|
||||
|
||||
ptyProcess.onData((data) => {
|
||||
this.emit("output", {
|
||||
sessionId,
|
||||
stream: "stdout",
|
||||
data,
|
||||
});
|
||||
});
|
||||
|
||||
ptyProcess.onExit(({ exitCode, signal }) => {
|
||||
this.ptySessions.delete(sessionId);
|
||||
this.emit("exit", {
|
||||
sessionId,
|
||||
code: exitCode,
|
||||
signal: signal !== undefined ? String(signal) : null,
|
||||
});
|
||||
});
|
||||
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
write(sessionId: string, data: string): void {
|
||||
const child = this.sessions.get(sessionId);
|
||||
if (child) {
|
||||
child.stdin?.write(data);
|
||||
return;
|
||||
}
|
||||
|
||||
const pty = this.ptySessions.get(sessionId);
|
||||
if (pty) {
|
||||
pty.write(data);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`No session: ${sessionId}`);
|
||||
}
|
||||
|
||||
kill(sessionId: string): void {
|
||||
const child = this.sessions.get(sessionId);
|
||||
if (child) {
|
||||
child.kill();
|
||||
return;
|
||||
}
|
||||
|
||||
const pty = this.ptySessions.get(sessionId);
|
||||
if (pty) {
|
||||
pty.kill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
killAll(): void {
|
||||
for (const child of this.sessions.values()) {
|
||||
child.kill();
|
||||
}
|
||||
this.sessions.clear();
|
||||
|
||||
for (const pty of this.ptySessions.values()) {
|
||||
pty.kill();
|
||||
}
|
||||
this.ptySessions.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
import { rmSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { ProviderEvent } from "@acme/contracts";
|
||||
import { createFakeCodexAppServerBinary } from "../../../test-support/fakeCodexAppServer";
|
||||
import { ProviderManager } from "./providerManager";
|
||||
|
||||
async function waitForProviderEvent(
|
||||
events: ProviderEvent[],
|
||||
matcher: (event: ProviderEvent) => boolean,
|
||||
timeoutMs = 5_000,
|
||||
) {
|
||||
return new Promise<ProviderEvent>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
clearInterval(poll);
|
||||
reject(new Error("Timed out waiting for provider event."));
|
||||
}, timeoutMs);
|
||||
|
||||
const poll = setInterval(() => {
|
||||
const match = events.find((event) => matcher(event));
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(timeout);
|
||||
clearInterval(poll);
|
||||
resolve(match);
|
||||
}, 10);
|
||||
});
|
||||
}
|
||||
|
||||
describe("ProviderManager integration with fake codex app-server", () => {
|
||||
it(
|
||||
"supports start/send/respond/interrupt/stop lifecycle",
|
||||
async () => {
|
||||
const fakeCodex = createFakeCodexAppServerBinary("runtime-core-fake-codex-");
|
||||
const originalPath = process.env.PATH;
|
||||
process.env.PATH = `${fakeCodex.tempDir}${path.delimiter}${originalPath ?? ""}`;
|
||||
|
||||
const manager = new ProviderManager();
|
||||
const events: ProviderEvent[] = [];
|
||||
manager.on("event", (event) => {
|
||||
events.push(event);
|
||||
});
|
||||
|
||||
try {
|
||||
const session = await manager.startSession({
|
||||
provider: "codex",
|
||||
});
|
||||
expect(session.provider).toBe("codex");
|
||||
expect(session.status).toBe("ready");
|
||||
expect(session.threadId).toBe("thread-fake");
|
||||
expect(session.sessionId.length).toBeGreaterThan(0);
|
||||
|
||||
const turn = await manager.sendTurn({
|
||||
sessionId: session.sessionId,
|
||||
input: "hello fake codex",
|
||||
});
|
||||
expect(turn.threadId).toBe("thread-fake");
|
||||
expect(turn.turnId).toBe("turn-1");
|
||||
|
||||
const approvalEvent = await waitForProviderEvent(
|
||||
events,
|
||||
(event) =>
|
||||
event.kind === "request" &&
|
||||
event.method === "item/commandExecution/requestApproval" &&
|
||||
event.sessionId === session.sessionId &&
|
||||
event.requestKind === "command" &&
|
||||
typeof event.requestId === "string" &&
|
||||
event.requestId.length > 0,
|
||||
);
|
||||
const requestId = approvalEvent.requestId;
|
||||
if (!requestId) {
|
||||
throw new Error("Expected command approval request id.");
|
||||
}
|
||||
|
||||
await manager.respondToRequest({
|
||||
sessionId: session.sessionId,
|
||||
requestId,
|
||||
decision: "accept",
|
||||
});
|
||||
|
||||
await manager.interruptTurn({
|
||||
sessionId: session.sessionId,
|
||||
turnId: turn.turnId,
|
||||
});
|
||||
|
||||
expect(manager.listSessions().some((entry) => entry.sessionId === session.sessionId)).toBe(
|
||||
true,
|
||||
);
|
||||
|
||||
manager.stopSession({
|
||||
sessionId: session.sessionId,
|
||||
});
|
||||
expect(manager.listSessions().some((entry) => entry.sessionId === session.sessionId)).toBe(
|
||||
false,
|
||||
);
|
||||
} finally {
|
||||
manager.dispose();
|
||||
process.env.PATH = originalPath;
|
||||
rmSync(fakeCodex.tempDir, { recursive: true, force: true });
|
||||
}
|
||||
},
|
||||
20_000,
|
||||
);
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const SOURCE_FILES = [
|
||||
"index.ts",
|
||||
"processManager.ts",
|
||||
"todoStore.ts",
|
||||
"providerManager.ts",
|
||||
"codexAppServerManager.ts",
|
||||
] as const;
|
||||
|
||||
describe("runtime-core architecture boundaries", () => {
|
||||
for (const fileName of SOURCE_FILES) {
|
||||
it(`${fileName} does not reach into app-layer paths`, () => {
|
||||
const filePath = path.resolve(import.meta.dirname, fileName);
|
||||
const source = fs.readFileSync(filePath, "utf8");
|
||||
|
||||
expect(source).not.toContain("../apps/");
|
||||
expect(source).not.toContain("../../apps/");
|
||||
expect(source).not.toContain("../../../apps/");
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,60 +0,0 @@
|
||||
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { TodoStore } from "./todoStore";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(
|
||||
tempDirs.splice(0, tempDirs.length).map(async (dir) => {
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
async function createStore() {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), "runtime-core-todos-"));
|
||||
tempDirs.push(dir);
|
||||
const filePath = path.join(dir, "todos.json");
|
||||
const store = new TodoStore(filePath);
|
||||
await store.init();
|
||||
return { store, filePath };
|
||||
}
|
||||
|
||||
describe("TodoStore", () => {
|
||||
it("initializes an empty todo file", async () => {
|
||||
const { store, filePath } = await createStore();
|
||||
|
||||
expect(await store.list()).toEqual([]);
|
||||
|
||||
const raw = await readFile(filePath, "utf8");
|
||||
expect(JSON.parse(raw)).toEqual([]);
|
||||
});
|
||||
|
||||
it("adds, toggles, removes, and persists todos", async () => {
|
||||
const { store, filePath } = await createStore();
|
||||
|
||||
const afterAdd = await store.add({ title: "ship runtime core" });
|
||||
expect(afterAdd).toHaveLength(1);
|
||||
const added = afterAdd[0];
|
||||
expect(added?.title).toBe("ship runtime core");
|
||||
expect(added?.completed).toBe(false);
|
||||
|
||||
if (!added) {
|
||||
throw new Error("Expected todo to be created.");
|
||||
}
|
||||
|
||||
const afterToggle = await store.toggle(added.id);
|
||||
expect(afterToggle[0]?.completed).toBe(true);
|
||||
|
||||
const reloaded = new TodoStore(filePath);
|
||||
await reloaded.init();
|
||||
expect((await reloaded.list())[0]?.completed).toBe(true);
|
||||
|
||||
const afterRemove = await reloaded.remove(added.id);
|
||||
expect(afterRemove).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,106 +0,0 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import {
|
||||
type NewTodoInput,
|
||||
type Todo,
|
||||
newTodoInputSchema,
|
||||
todoIdSchema,
|
||||
todoListSchema,
|
||||
} from "@acme/contracts";
|
||||
|
||||
export class TodoStore {
|
||||
private todos: Todo[] = [];
|
||||
private queue: Promise<void> = Promise.resolve();
|
||||
|
||||
public constructor(private readonly filePath: string) {}
|
||||
|
||||
public async init(): Promise<void> {
|
||||
return this.runExclusive(async () => {
|
||||
await fs.mkdir(path.dirname(this.filePath), { recursive: true });
|
||||
|
||||
try {
|
||||
const raw = await fs.readFile(this.filePath, "utf8");
|
||||
const parsed = todoListSchema.safeParse(JSON.parse(raw));
|
||||
|
||||
if (parsed.success) {
|
||||
this.todos = parsed.data;
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
if (!isNotFoundError(error)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
this.todos = [];
|
||||
await this.persist();
|
||||
});
|
||||
}
|
||||
|
||||
public async list(): Promise<Todo[]> {
|
||||
return this.runExclusive(async () => [...this.todos]);
|
||||
}
|
||||
|
||||
public async add(input: NewTodoInput): Promise<Todo[]> {
|
||||
return this.runExclusive(async () => {
|
||||
const { title } = newTodoInputSchema.parse(input);
|
||||
const todo: Todo = {
|
||||
id: randomUUID(),
|
||||
title,
|
||||
completed: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
this.todos = [todo, ...this.todos];
|
||||
await this.persist();
|
||||
return [...this.todos];
|
||||
});
|
||||
}
|
||||
|
||||
public async toggle(id: string): Promise<Todo[]> {
|
||||
return this.runExclusive(async () => {
|
||||
const parsedId = todoIdSchema.parse(id);
|
||||
this.todos = this.todos.map((todo) =>
|
||||
todo.id === parsedId ? { ...todo, completed: !todo.completed } : todo,
|
||||
);
|
||||
|
||||
await this.persist();
|
||||
return [...this.todos];
|
||||
});
|
||||
}
|
||||
|
||||
public async remove(id: string): Promise<Todo[]> {
|
||||
return this.runExclusive(async () => {
|
||||
const parsedId = todoIdSchema.parse(id);
|
||||
this.todos = this.todos.filter((todo) => todo.id !== parsedId);
|
||||
|
||||
await this.persist();
|
||||
return [...this.todos];
|
||||
});
|
||||
}
|
||||
|
||||
private async persist(): Promise<void> {
|
||||
await fs.writeFile(this.filePath, JSON.stringify(this.todos, null, 2), "utf8");
|
||||
}
|
||||
|
||||
private async runExclusive<T>(operation: () => Promise<T>): Promise<T> {
|
||||
const next = this.queue.then(operation, operation);
|
||||
this.queue = next.then(
|
||||
() => undefined,
|
||||
() => undefined,
|
||||
);
|
||||
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
||||
function isNotFoundError(error: unknown): boolean {
|
||||
return (
|
||||
typeof error === "object" &&
|
||||
error !== null &&
|
||||
"code" in error &&
|
||||
(error as { code?: string }).code === "ENOENT"
|
||||
);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
function canExecute(command) {
|
||||
const result = spawnSync(command, ["--version"], {
|
||||
stdio: "ignore",
|
||||
shell: false,
|
||||
});
|
||||
return result.status === 0;
|
||||
}
|
||||
|
||||
function resolveBunPath() {
|
||||
const candidates = [
|
||||
process.env.BUN_BIN,
|
||||
"bun",
|
||||
path.join(os.homedir(), ".bun", "bin", "bun"),
|
||||
path.join(os.homedir(), ".bun", "bin", "bun.exe"),
|
||||
].filter(Boolean);
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (canExecute(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Bun is required for prepack. Install from https://bun.sh and ensure bun is available.",
|
||||
);
|
||||
}
|
||||
|
||||
const bunPath = resolveBunPath();
|
||||
const buildSteps = [
|
||||
["run", "--cwd", "packages/contracts", "build"],
|
||||
["run", "--cwd", "apps/renderer", "build"],
|
||||
["run", "--cwd", "apps/t3", "build"],
|
||||
];
|
||||
|
||||
for (const step of buildSteps) {
|
||||
const result = spawnSync(bunPath, step, {
|
||||
stdio: "inherit",
|
||||
shell: false,
|
||||
env: process.env,
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
export function createFakeCodexAppServerBinary(prefix) {
|
||||
const tempDir = mkdtempSync(path.join(os.tmpdir(), prefix));
|
||||
const binaryPath = path.join(tempDir, "codex");
|
||||
const script = `#!/usr/bin/env node
|
||||
const readline = require("node:readline");
|
||||
const rl = readline.createInterface({ input: process.stdin });
|
||||
let turnCount = 0;
|
||||
const send = (message) => process.stdout.write(\`\${JSON.stringify(message)}\\n\`);
|
||||
|
||||
rl.on("line", (line) => {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(line);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parsed || typeof parsed !== "object") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!("id" in parsed) || typeof parsed.method !== "string") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "initialize") {
|
||||
send({ id: parsed.id, result: {} });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "thread/start") {
|
||||
send({ id: parsed.id, result: { thread: { id: "thread-fake" } } });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "thread/resume") {
|
||||
const threadId =
|
||||
parsed.params &&
|
||||
typeof parsed.params === "object" &&
|
||||
typeof parsed.params.threadId === "string"
|
||||
? parsed.params.threadId
|
||||
: "thread-fake";
|
||||
send({ id: parsed.id, result: { thread: { id: threadId } } });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "turn/start") {
|
||||
turnCount += 1;
|
||||
send({ id: parsed.id, result: { turn: { id: \`turn-\${turnCount}\` } } });
|
||||
setTimeout(() => {
|
||||
send({
|
||||
id: \`approval-\${turnCount}\`,
|
||||
method: "item/commandExecution/requestApproval",
|
||||
params: {
|
||||
threadId: "thread-fake",
|
||||
turnId: \`turn-\${turnCount}\`,
|
||||
itemId: \`item-\${turnCount}\`,
|
||||
},
|
||||
});
|
||||
}, 25);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "turn/interrupt") {
|
||||
send({ id: parsed.id, result: {} });
|
||||
return;
|
||||
}
|
||||
|
||||
send({
|
||||
id: parsed.id,
|
||||
error: {
|
||||
code: -32601,
|
||||
message: \`Unsupported fake codex method: \${parsed.method}\`,
|
||||
},
|
||||
});
|
||||
});
|
||||
`;
|
||||
writeFileSync(binaryPath, script, { encoding: "utf8", mode: 0o755 });
|
||||
|
||||
return {
|
||||
tempDir,
|
||||
binaryPath,
|
||||
};
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
export function createFakeCodexAppServerBinary(prefix: string) {
|
||||
const tempDir = mkdtempSync(path.join(os.tmpdir(), prefix));
|
||||
const binaryPath = path.join(tempDir, "codex");
|
||||
const script = `#!/usr/bin/env node
|
||||
const readline = require("node:readline");
|
||||
const rl = readline.createInterface({ input: process.stdin });
|
||||
let turnCount = 0;
|
||||
const send = (message) => process.stdout.write(\`\${JSON.stringify(message)}\\n\`);
|
||||
|
||||
rl.on("line", (line) => {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(line);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parsed || typeof parsed !== "object") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!("id" in parsed) || typeof parsed.method !== "string") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "initialize") {
|
||||
send({ id: parsed.id, result: {} });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "thread/start") {
|
||||
send({ id: parsed.id, result: { thread: { id: "thread-fake" } } });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "thread/resume") {
|
||||
const threadId =
|
||||
parsed.params &&
|
||||
typeof parsed.params === "object" &&
|
||||
typeof parsed.params.threadId === "string"
|
||||
? parsed.params.threadId
|
||||
: "thread-fake";
|
||||
send({ id: parsed.id, result: { thread: { id: threadId } } });
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "turn/start") {
|
||||
turnCount += 1;
|
||||
send({ id: parsed.id, result: { turn: { id: \`turn-\${turnCount}\` } } });
|
||||
setTimeout(() => {
|
||||
send({
|
||||
id: \`approval-\${turnCount}\`,
|
||||
method: "item/commandExecution/requestApproval",
|
||||
params: {
|
||||
threadId: "thread-fake",
|
||||
turnId: \`turn-\${turnCount}\`,
|
||||
itemId: \`item-\${turnCount}\`,
|
||||
},
|
||||
});
|
||||
}, 25);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.method === "turn/interrupt") {
|
||||
send({ id: parsed.id, result: {} });
|
||||
return;
|
||||
}
|
||||
|
||||
send({
|
||||
id: parsed.id,
|
||||
error: {
|
||||
code: -32601,
|
||||
message: \`Unsupported fake codex method: \${parsed.method}\`,
|
||||
},
|
||||
});
|
||||
});
|
||||
`;
|
||||
writeFileSync(binaryPath, script, { encoding: "utf8", mode: 0o755 });
|
||||
|
||||
return {
|
||||
tempDir,
|
||||
binaryPath,
|
||||
};
|
||||
}
|
||||
+14
-2
@@ -1,12 +1,24 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"globalEnv": ["T3_BACKEND_PORT", "T3_WEB_PORT"],
|
||||
"globalEnv": [
|
||||
"PORT",
|
||||
"VITE_WS_URL",
|
||||
"VITE_DEV_SERVER_URL",
|
||||
"CODETHING_LOG_WS_EVENTS",
|
||||
"CODETHING_MODE",
|
||||
"CODETHING_PORT",
|
||||
"CODETHING_NO_BROWSER",
|
||||
"CODETHING_STATE_DIR",
|
||||
"CODETHING_AUTH_TOKEN",
|
||||
"CODETHING_DESKTOP_WS_URL"
|
||||
],
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["dist/**"]
|
||||
"outputs": ["dist/**", "dist-electron/**"]
|
||||
},
|
||||
"dev": {
|
||||
"dependsOn": ["@acme/contracts#build"],
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user