π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
β¬οΈ refactor: upgrade Zod to v4 (#16998)
Arvin Xu20238b7b0272
diff --git a/.agents/skills/agent-testing/SKILL.md b/.agents/skills/agent-testing/SKILL.mdindex f7b5477fa1b..5deb7a51220 100644--- a/.agents/skills/agent-testing/SKILL.md+++ b/.agents/skills/agent-testing/SKILL.md@@ -15,14 +15,23 @@ description: ># Agent Testing (Agentic End-to-End Verification)One skill for all agentic end-to-end testing β local-first today, designed to-also run as full cloud automation. Every test session follows the same-contract:+also run as full cloud automation. Every test session follows three phases:```text-Step -2: Read the two living logs β Step -1: Plan approval β Step 0: Env + Auth β Step 1: Pick surface β Step 2: Run β Step 3: Structured report β Step 4: Publish to LobeHub β Step 5: Teardown+PLAN (Steps 0β2) β EXECUTE (Steps 3β6) β FINISH (Step 7)```-## Step -2 β Read the two living logs (mandatory, before every run)+Do not enter Execute until Plan has confirmed both the environment state and the+execution plan. Treat Steps 3β6 as one continuous execution phase: select the+surface, run the cases, produce the report, and publish it. Always end with+Finish unless the user explicitly asks to keep the environment running.++## Phase 1 β Plan++Confirm what will run and whether the environment is ready before changing or+starting anything.++### Step 0 β Read the two living logs (mandatory, before every run)Before doing anything else, read both of these in full and hold them in mind forthis run:@@ -54,31 +63,24 @@ this run:superproject's own skills/notes instead, and genericize anything worthkeeping here.-## Step -1 β Plan approval for non-trivial tests+### Step 1 β Prepare the execution plan-Skip directly to Step 0 if: the test is a single re-run after a fix, the plan+Skip directly to Step 2 if: the test is a single re-run after a fix, the planwas already agreed on, or the user gave exact commands.-Otherwise, propose a test plan (surface, cases, expected evidence, assumptions)-and use the runtime structured question tool (`request_user_input` /-ask-user-question equivalent) with two fixed choices:--1. `Start (Recommended)` β the plan looks good, begin executing-2. `Discuss first` β the plan has issues, let's talk it over first+Prepare the proposed surface, cases, expected evidence, assumptions, and report+deliverable. Do not ask for approval yet: Step 2 must establish the real+environment state first so the user can approve one complete, evidence-backed+plan instead of separate plan and environment prompts.-(Match the button labels to the user's conversation language at runtime, but-keep this skill file in English.)+### Step 2 β Confirm environment state and auth (mandatory)-Wait for the user's choice before proceeding.--## Step 0 β Environment setup + auth check (mandatory)--Step 0 is about getting the environment ready: **dependencies are healthy**+Step 2 is about getting the environment ready: **dependencies are healthy**and **auth is green**. A test run that dies halfway on a missing dependency ora login wall wastes the whole session β clear both gates BEFORE writing asingle test step.-### 0.0 Resolve the current test environment+#### 2.0 Resolve the current test environmentBefore starting a dev server, checking auth, opening agent-browser, or writingtest steps, print and confirm the current local test environment:@@ -108,7 +110,7 @@ eval "$(./.agents/skills/agent-testing/scripts/test-env.sh --exports)"Do not rely on hard-coded port tables. If the printed values do not match therunning dev server, fix/export the env first, then continue.-### 0.1 Dependencies are installed β root AND standalone apps+#### 2.1 Dependencies are installed β root AND standalone appsThe root pnpm workspace does **NOT** cover every app: `pnpm-workspace.yaml`lists `packages/**`, `e2e`, `apps/server`, and only `apps/desktop/src/main` β@@ -126,7 +128,7 @@ Symptom of a stale standalone install: the build/launch fails to resolve arecently added workspace package β `Rolldown failed to resolve import"@lobechat/<pkg>"` (Electron) or `Cannot find module '@lobechat/<pkg>'` (CLI).-### 0.2 Run scripts from the repo root+#### 2.2 Run scripts from the repo rootAll paths in this skill (`./.agents/skills/agent-testing/...`) arerepo-root-relative, and background commands inherit the current working@@ -134,7 +136,7 @@ directory β a script launched while `cwd` is `apps/desktop` fails with`No such file or directory`. Verify `pwd` is the repo root before launchinglong-running scripts.-### 0.3 Init local dev env without `.env`+#### 2.3 Init local dev env without `.env`For Web smoke against local code, start a **normal local dev environment**.First check the repo root for `.env`:@@ -256,7 +258,7 @@ eval "$(../.agents/skills/agent-testing/scripts/init-dev-env.sh env)"BASE_URL=http://localhost:3010 HEADLESS=true bun run test:smoke```-### 0.4 Auth is green for the selected surface+#### 2.4 Auth is green for the selected surface**Auth is the gate for automated testing, but the gate is surface-scoped.**Pick the intended surface first when it is already clear from the task, then@@ -288,7 +290,7 @@ do not open a login page; verify agent-browser first, then request the Network`Cookie:` header only if that verification fails. Full background and failure modes:[references/auth.md](./references/auth.md).-### 0.5 β Screen-recording preflight (OS-capture surfaces only)+#### 2.5 β Screen-recording preflight (OS-capture surfaces only)macOS `screencapture` / osascript / bot-channel captures come out **entirelyblack** when Screen Recording (TCC) permission is missing OR β just as often β@@ -314,7 +316,29 @@ the display can sleep mid-run, keep it awake for the whole capture session:caffeinate -dimsu & # prevent display/idle sleep for the test run; kill when done```-## Step 1 β Pick the surface by change scope+#### Phase 1 approval gate β report environment + plan to the user++At the end of Step 2, always send one user-facing Plan feedback before entering+Execute. Read and follow [references/plan.md](./references/plan.md). It requires:++- an overall environment verdict with concrete checks and evidence;+- the proposed execution plan, cases, and expected evidence;+- every unresolved prerequisite, clearly assigned to Codex or the user;+- an explicit statement that nothing is needed from the user when that is true;+- one structured confirmation question after the feedback.++Resolve safe, agent-owned environment mechanics before presenting the gate. Ask+the user only for prerequisites that genuinely require their authority, secret,+device action, or product decision. Do not enter Phase 2 until the user approves+the plan and all blocking user-owned prerequisites are satisfied.++## Phase 2 β Execute++Carry the approved plan through surface selection, verification, reporting, and+publication without reopening environment decisions unless observed state+invalidates the plan.++### Step 3 β Pick the surface by change scope| Change scope | Default surface | Why | Guide || ------------------------------------------------------- | ------------------------------------ | ----------------------------------------------------------------- | ---------------------------------- |@@ -336,7 +360,7 @@ a server `agent_operations` row, the QStash `/api/agent/run` steps, or server-onlog lines. If the UI won't take the server path, drive it directly (call theserver TRPC mutation / endpoint) so the server runtime actually executes.-### Environment support (local macOS vs cloud Linux)+#### Environment support (local macOS vs cloud Linux)The decisive constraint per surface is **how evidence (screenshots) iscaptured**: CDP-based capture (`agent-browser screenshot`) renders from the@@ -353,7 +377,7 @@ osascript) is macOS-only.When a test must stay cloud-portable, prefer CDP-based evidence overOS-level capture wherever both exist.-### Bot platforms+#### Bot platforms| Platform | Guide | Quick switcher || ------------- | ------------------------------------------------ | --------------------- |@@ -378,7 +402,7 @@ New to osascript automation? ReadmacOS-automation asset (activate, type, paste, screenshot, accessibility reads,gotchas), not bot-specific.-## Step 2 β Run+### Step 4 β RunSurface guides above carry the detailed workflows. Shared infrastructure:@@ -390,7 +414,7 @@ Surface guides above carry the detailed workflows. Shared infrastructure:| Local gateway closed loop + probing | [references/agent-gateway.md](./references/agent-gateway.md) || Screen recording | [references/record-app-screen.md](./references/record-app-screen.md) |-### Scripts+#### ScriptsAll under `.agents/skills/agent-testing/scripts/`:@@ -403,7 +427,7 @@ All under `.agents/skills/agent-testing/scripts/`:| `agent-browser-klm.mjs` | Wrap `agent-browser`, run the real action, and append a GOMS-KLM interaction atom JSONL || `agent-browser-klm-analyze.mjs` | Summarize interaction JSONL into `result.json.interactionCost` / markdown cost output || `record-gif.sh` | Frame-sequence β GIF for time-based behavior (streaming, timers, animations) |-| `report-init.sh` | Scaffold a structured test report (Step 3) |+| `report-init.sh` | Scaffold a structured test report (Step 5) || `check-screen-recording.sh` | Preflight: OS screen-capture works (macOS Screen Recording + display awake) || `electron-dev.sh` | Manage Electron dev env (start/stop/status/restart, CDP 9222) || `cdp-screenshot.sh` | Electron/Chrome screenshot via RAW CDP (bypasses agent-browser daemon); `--check` preflight |@@ -418,7 +442,7 @@ current route, running operations, and `goto <path>` quick navigationjump straight to the state under test instead of clicking through the UI. See[ui/electron.md](./ui/electron.md#lobehub-probes--quick-navigation) for usage.-### Agent-browser interaction-cost tracing+#### Agent-browser interaction-cost tracingFor UI verification runs, drive cost-bearing browser actions through the KLMwrapper so the same action also records a user-equivalent interaction atom:@@ -452,7 +476,7 @@ This writes `result.json.interactionCost`; `verify ingest-report` stores it onthe verify run metadata so the report can render a separate interaction-costsection.-## Step 3 β Structured report (mandatory deliverable)+### Step 5 β Structured report (mandatory deliverable)Every automated test session ends with a structured, evidence-backed report βnot a chat-only summary. Scaffold it up front and fill it as you test:@@ -504,7 +528,7 @@ Two hard rules worth front-loading:animations), record it with `scripts/record-gif.sh` and attach the GIF as thatcase's `evidence` β a static screenshot cannot prove the behavior.-## Step 4 β Publish to LobeHub (mandatory)+### Step 6 β Publish to LobeHub (mandatory)The local report under `.records/reports/` is the working artifact; the**deliverable is the report opened in LobeHub**. Do not stop at local files β@@ -554,7 +578,7 @@ inline screenshot/text evidence). On production that resolves to`https://app.lobehub.com/verify/<verifyRunId>`. **Include that full productionlink in the final chat reply** alongside the local report dir.-### Re-verifying the same case updates the report in place (don't spawn a new one)+#### Re-verifying the same case updates the report in place (don't spawn a new one)When you iterate on one change β fix β re-verify β fix again β **keep reusing thesame report dir (`$DIR`)**. `ingest-report` records the session it created in a@@ -591,7 +615,11 @@ Notes:report. If the evidence must appear, publish against an env with real storage(e.g. production) or attach it inline with `verify evidence upload --content`.-## Step 5 β Teardown (default: stop what you started)+## Phase 3 β Finish++Close the run cleanly and leave behind only intentional, auditable artifacts.++### Step 7 β Teardown and handoff (default: stop what you started)A test run leaves processes and code edits behind. Clean them up by default oncethe report is published β a dev server left listening or an injection left in a@@ -604,8 +632,10 @@ service file silently corrupts the next run (and the next agent's mental model)../.agents/skills/agent-testing/scripts/init-dev-env.sh clean # stop dev server; keep DB/Redis```- `clean` stops the Next + Vite processes on the resolved `SERVER_PORT` / `SPA_PORT`- and the `bun run dev` supervisor, and **leaves the managed Postgres/Redis+ `clean` stops only the recorded dev-server PID tree after verifying its PID+ start time, command, and working directory. It never uses a global process-name+ match and never kills an arbitrary listener merely because it owns a persisted+ port. It **leaves the managed Postgres/Rediscontainers running** (they are idempotently reused across runs β `setup-db` is ano-op when they're up). Use `clean-db` only when you deliberately want thecontainers gone, or `stop-dev` for just the server with no note. If the userdiff --git a/.agents/skills/agent-testing/references/auth.md b/.agents/skills/agent-testing/references/auth.mdindex 0f68308a263..0858a68bc6d 100644--- a/.agents/skills/agent-testing/references/auth.md+++ b/.agents/skills/agent-testing/references/auth.md@@ -1,7 +1,7 @@# Auth Setup for Local Agent Testing**Auth is the gate for all automated testing.** Complete-[Step 0.0](../SKILL.md#00-resolve-the-current-test-environment) first so+[Step 2.0](../SKILL.md#20-resolve-the-current-test-environment) first so`SERVER_URL` and ports are resolved, then verify auth before writing any teststep.diff --git a/.agents/skills/agent-testing/references/dev-server.md b/.agents/skills/agent-testing/references/dev-server.mdindex bb9de3f702b..85409be86f0 100644--- a/.agents/skills/agent-testing/references/dev-server.md+++ b/.agents/skills/agent-testing/references/dev-server.md@@ -6,7 +6,7 @@ surfaces (CLI, Electron, Web) hit.## Resolve ports firstRun `test-env.sh` as described in-[SKILL.md Step 0.0](../SKILL.md#00-resolve-the-current-test-environment)+[SKILL.md Step 2.0](../SKILL.md#20-resolve-the-current-test-environment)before starting or probing any local test surface.## Ports & modes@@ -64,11 +64,10 @@ AGENT_RUNTIME_MODE=queue bun run dev# Local QStash. Run in a separate terminal only when testing workflow paths../.agents/skills/agent-testing/scripts/init-dev-env.sh qstash-# Restart β required to pick up server-side code changes-lsof -ti:"$PORT" | xargs kill-pnpm run dev:next-# or, when no root .env exists:-# ./.agents/skills/agent-testing/scripts/init-dev-env.sh dev-next+# Restart β required to pick up server-side code changes.+# For a no-.env server started by init-dev-env.sh, stop only its owned process tree:+./.agents/skills/agent-testing/scripts/init-dev-env.sh stop-dev+./.agents/skills/agent-testing/scripts/init-dev-env.sh dev-next```## When a server restart is needed@@ -87,14 +86,14 @@ in doubt.## Troubleshooting-| Issue | Solution |-| ------------------------- | --------------------------------------------------------------------------------------------- |-| `ECONNREFUSED` | Server not running β start it |-| `EADDRINUSE` on the port | Already running β `lsof -ti:<port> \| xargs kill` first |-| Stale data / old behavior | Server needs a restart to pick up code changes |-| Agent call runs inline | Set `AGENT_RUNTIME_MODE=queue`, make sure `REDIS_URL` is configured, then restart the server |-| Queue mode needs Redis | Run `init-dev-env.sh setup-db`, or provide `REDIS_URL=redis://...` for an existing Redis |-| QStash workflow failures | Start `init-dev-env.sh qstash` and make sure dev server inherited the script's `QSTASH_*` env |+| Issue | Solution |+| ------------------------- | ----------------------------------------------------------------------------------------------- |+| `ECONNREFUSED` | Server not running β start it |+| `EADDRINUSE` on the port | Inspect the listener; stop it only if this run owns it. Never kill an unknown PID by port alone |+| Stale data / old behavior | Server needs a restart to pick up code changes |+| Agent call runs inline | Set `AGENT_RUNTIME_MODE=queue`, make sure `REDIS_URL` is configured, then restart the server |+| Queue mode needs Redis | Run `init-dev-env.sh setup-db`, or provide `REDIS_URL=redis://...` for an existing Redis |+| QStash workflow failures | Start `init-dev-env.sh qstash` and make sure dev server inherited the script's `QSTASH_*` env |Marketplace/community endpoints are not part of the local agent-testing authgate. Do not block local product-chain verification on marketplace API authdiff --git a/.agents/skills/agent-testing/references/multi-instance.md b/.agents/skills/agent-testing/references/multi-instance.mdindex 22c33e77116..64620b85b48 100644--- a/.agents/skills/agent-testing/references/multi-instance.md+++ b/.agents/skills/agent-testing/references/multi-instance.md@@ -25,7 +25,7 @@ sink an `electron-dev.sh start <id>` on a fresh worktree before it will even mou'FloatingPanel'`) and the app hung on the loading screen (`#root` empty,`__LOBE_STORES` undefined) **even though raw-CDP screenshots still showed a paintedframe** from before the crash. Fix: real `pnpm install` in the worktree **root** _and_- `apps/desktop` (standalone install, per Step 0.1) before `start`. (`type-check` warns+ `apps/desktop` (standalone install, per Step 2.1) before `start`. (`type-check` warnsof the same skew: cross-root `packages/*` dual-identity errors when `node_modules` issymlinked across worktree roots.)- **First cold Vite load can `ECONNRESET` under resource contention.** Two fulldiff --git a/.agents/skills/agent-testing/references/plan.md b/.agents/skills/agent-testing/references/plan.mdnew file mode 100644index 00000000000..91259942268--- /dev/null+++ b/.agents/skills/agent-testing/references/plan.md@@ -0,0 +1,83 @@+# Phase 1 Plan Feedback++Use this template at the end of Phase 1. Match the user's conversation language.+Keep it concrete and compact: report observed state, not generic readiness claims.++## Readiness verdicts++- **Ready**: every prerequisite for the proposed run is verified.+- **Ready with warnings**: execution can proceed; list non-blocking limitations and+ their effect on evidence or scope.+- **Blocked**: execution cannot start until one or more prerequisites are resolved.++Fix safe environment mechanics yourself before reporting. Separate remaining+items by owner:++- **Codex-owned**: dependencies, processes, ports, generated local env, seeded+ fixtures, navigation, retries, and other work possible within the task's scope.+- **User-owned**: secrets the user must supply, device/2FA approval, permissions+ only the user can grant, destructive authorization, or an unresolved product+ choice that materially changes the plan.++Never put a Codex-owned item under βNeeded from you.β If none remain, write+`None` explicitly.++## Template++```markdown+Verification plan β Environment: <Ready | Ready with warnings | Blocked>++Environment++| Check | Status | Observed state |+| ------------------ | ----------------------- | --------------------------------------------------- |+| Workspace / branch | <Ready/Warning/Blocked> | <path, branch/worktree, relevant dirty-state note> |+| Dependencies | <Ready/Warning/Blocked> | <root and selected standalone app status> |+| Runtime / ports | <Ready/Warning/Blocked> | <resolved URLs/ports and ownership or availability> |+| Required services | <Ready/Warning/Blocked> | <DB, Redis, QStash, dev serverβonly those in scope> |+| Auth | <Ready/Warning/Blocked> | <selected surface and verified signed-in state> |+| Evidence capture | <Ready/Warning/Blocked> | <CDP or OS capture readiness> |++Execution plan++1. <Surface and entry point>+2. <Case 1: behavior β expected result β evidence>+3. <Case 2: behavior β expected result β evidence>+4. <Report and publication deliverable>++Scope and assumptions++- In scope: <what this run proves>+- Out of scope: <intentional exclusions, or None>+- Assumptions / warnings: <items that may affect interpretation, or None>++Needed before execution++- Codex will resolve: <remaining non-blocking or in-progress agent-owned work, or None>+- Needed from you: <exact user-owned prerequisite and why it is required, or None>+```++Do not include irrelevant environment rows. Add a row when the run has another+hard prerequisite, such as a native bot app, gateway, fixture repository, or+specific external account.++## Confirmation behavior++After the feedback, use the runtime structured question tool+(`request_user_input` / ask-user-question equivalent). Do not bury the question+inside the template text.++When the verdict is **Ready** or **Ready with warnings**, use:++1. `Start (Recommended)` β approve the displayed environment and plan; enter Execute.+2. `Discuss first` β revise scope, cases, assumptions, or environment handling.++When the verdict is **Blocked**, do not offer Start. Use:++1. `I'll provide it (Recommended)` β the user will supply or complete the listed+ user-owned prerequisite.+2. `Revise the plan` β change the scope or approach to remove the blocker.++Match button labels to the user's language. Wait for the user's response. If the+user resolves a blocker, re-check the affected environment item and present an+updated gate; do not rely only on the user's statement that it is fixed.diff --git a/.agents/skills/agent-testing/scripts/init-dev-env.sh b/.agents/skills/agent-testing/scripts/init-dev-env.shindex e12a98f6e79..4d73e060c94 100755--- a/.agents/skills/agent-testing/scripts/init-dev-env.sh+++ b/.agents/skills/agent-testing/scripts/init-dev-env.sh@@ -25,6 +25,7 @@## Overrides:# SERVER_PORT=3010 DB_PORT=5433 DB_CONTAINER=lobehub-agent-testing-postgres REDIS_PORT=6380 REDIS_CONTAINER=lobehub-agent-testing-redis QSTASH_DEV_PORT=8080+# AGENT_TESTING_DEV_STATE_FILE=.records/runtime/agent-testing-dev.stateset -euo pipefail@@ -50,6 +51,7 @@ fi# seed-user, dev, web-seed) and test-env.sh all agree on the same port. Delete# the ports file (or pass SERVER_PORT=... explicitly) to re-allocate.PORTS_FILE="${AGENT_TESTING_PORTS_FILE:-$WORKSPACE_ROOT/.records/env/agent-testing-ports.env}"+DEV_STATE_FILE="${AGENT_TESTING_DEV_STATE_FILE:-$WORKSPACE_ROOT/.records/runtime/agent-testing-dev.state}"_port_in_use() { lsof -iTCP:"$1" -sTCP:LISTEN > /dev/null 2>&1; }_pick_free_port() {@@ -539,6 +541,85 @@ cmd_qstash() {exec pnpm run qstash -- -port "$QSTASH_DEV_PORT"}+process_start() {+ ps -p "$1" -o lstart= 2>/dev/null | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'+}++process_cwd() {+ lsof -a -p "$1" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p' | head -1+}++write_dev_state() {+ local mode="$1" start+ start="$(process_start "$$")"+ mkdir -p "$(dirname "$DEV_STATE_FILE")"+ {+ printf 'PID=%q\n' "$$"+ printf 'PROCESS_START=%q\n' "$start"+ printf 'MODE=%q\n' "$mode"+ printf 'REPO_ROOT=%q\n' "$REPO_ROOT"+ printf 'SERVER_PORT=%q\n' "$SERVER_PORT"+ printf 'SPA_PORT=%q\n' "$SPA_PORT"+ } > "$DEV_STATE_FILE"+ note "recorded dev server ownership: $DEV_STATE_FILE (pid $$)"+}++prepare_dev_state() {+ local PID PROCESS_START MODE REPO_ROOT SERVER_PORT SPA_PORT+ [[ -f "$DEV_STATE_FILE" ]] || return 0+ # shellcheck disable=SC1090+ source "$DEV_STATE_FILE"+ if state_owns_process "$PID" "$PROCESS_START" "$REPO_ROOT" "$MODE"; then+ bad "an owned $MODE dev server is already running (pid $PID)"+ note "stop it first with: $0 stop-dev"+ return 1+ fi+ note "replacing stale dev ownership state: $DEV_STATE_FILE"+ rm -f "$DEV_STATE_FILE"+}++collect_descendants() {+ local parent="$1" child+ while IFS= read -r child; do+ [[ -n "$child" ]] || continue+ collect_descendants "$child"+ printf '%s\n' "$child"+ done < <(pgrep -P "$parent" 2>/dev/null || true)+}++state_owns_process() {+ local pid="$1" expected_start="$2" expected_root="$3" mode="$4"+ local actual_start actual_cwd command+ kill -0 "$pid" 2>/dev/null || return 1+ actual_start="$(process_start "$pid")"+ [[ -n "$actual_start" && "$actual_start" == "$expected_start" ]] || return 1+ actual_cwd="$(process_cwd "$pid")"+ [[ "$actual_cwd" == "$expected_root" || "$actual_cwd" == "$expected_root/"* ]] || return 1+ command="$(ps -p "$pid" -o command= 2>/dev/null || true)"+ case "$mode" in+ dev) [[ "$command" == *"bun"* && "$command" == *"run dev"* ]] ;;+ dev-next) [[ "$command" == *"next"* && "$command" == *"dev"* ]] ;;+ *) return 1 ;;+ esac+}++stop_owned_process_tree() {+ local root_pid="$1" descendants pid+ descendants="$(collect_descendants "$root_pid")"+ for pid in $descendants; do+ kill -TERM "$pid" 2>/dev/null || true+ done+ kill -TERM "$root_pid" 2>/dev/null || true+ for _ in $(seq 1 20); do+ kill -0 "$root_pid" 2>/dev/null || return 0+ sleep 0.1+ done+ for pid in $descendants; do+ kill -KILL "$pid" 2>/dev/null || true+ done+ kill -KILL "$root_pid" 2>/dev/null || true+}+cmd_dev_next() {apply_envcd "$REPO_ROOT"@@ -547,12 +628,16 @@ cmd_dev_next() {# SERVER_PORT was auto-allocated to something else. apply_env already exported# every env this needs (there is no .env to load in this mode), so invoking# next directly is equivalent and port-correct in both cloud and submodule.+ prepare_dev_state+ write_dev_state dev-nextexec pnpm exec next dev -p "$SERVER_PORT"}cmd_dev() {apply_envcd "$REPO_ROOT"+ prepare_dev_state+ write_dev_state devexec bun run dev}@@ -579,27 +664,22 @@ cmd_clean_db() {}cmd_stop_dev() {- apply_env- local any=0 pids port- for port in "$SERVER_PORT" "$SPA_PORT"; do- pids="$(lsof -ti "tcp:$port" -sTCP:LISTEN 2>/dev/null || true)"- if [[ -n "$pids" ]]; then- # shellcheck disable=SC2086- kill $pids 2>/dev/null || true- note "stopped listener(s) on :$port ($(echo "$pids" | tr '\n' ' '))"- any=1- fi- done- # `bun run dev` supervises Next + Vite; kill the parent too so neither respawns.- if pkill -f "bun run dev" 2>/dev/null; then- note "stopped 'bun run dev' supervisor"- any=1+ local PID PROCESS_START MODE REPO_ROOT SERVER_PORT SPA_PORT+ if [[ ! -f "$DEV_STATE_FILE" ]]; then+ note "no owned dev server state found: $DEV_STATE_FILE"+ return 0fi- if [[ "$any" == 1 ]]; then- ok "dev server stopped"- else- note "no dev server running on :$SERVER_PORT / :$SPA_PORT"+ # shellcheck disable=SC1090+ source "$DEV_STATE_FILE"+ if ! state_owns_process "$PID" "$PROCESS_START" "$REPO_ROOT" "$MODE"; then+ bad "refusing to stop PID $PID: ownership metadata no longer matches the live process"+ note "stale state removed; inspect listeners manually if cleanup is still needed"+ rm -f "$DEV_STATE_FILE"+ return 1fi+ stop_owned_process_tree "$PID"+ rm -f "$DEV_STATE_FILE"+ ok "stopped owned $MODE process tree (root pid $PID)"}cmd_clean() {diff --git a/.agents/skills/agent-testing/scripts/init-dev-env.test.sh b/.agents/skills/agent-testing/scripts/init-dev-env.test.shnew file mode 100755index 00000000000..3821221d54f--- /dev/null+++ b/.agents/skills/agent-testing/scripts/init-dev-env.test.sh@@ -0,0 +1,87 @@+#!/usr/bin/env bash+set -euo pipefail++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+SCRIPT="$SCRIPT_DIR/init-dev-env.sh"+TMP="$(mktemp -d)"+PIDS=()++cleanup() {+ local pid+ for pid in "${PIDS[@]:-}"; do+ kill -TERM "$pid" 2>/dev/null || true+ done+ rm -rf "$TMP"+}+trap cleanup EXIT++mkdir -p "$TMP/bin"+cat > "$TMP/bin/bun" <<'SH'+#!/usr/bin/env bash+sleep 300 &+wait+SH+chmod +x "$TMP/bin/bun"++start_fixture() {+ local state="$1" server_port="$2" spa_port="$3"+ PATH="$TMP/bin:$PATH" \+ AGENT_TESTING_DEV_STATE_FILE="$state" \+ SERVER_PORT="$server_port" SPA_PORT="$spa_port" \+ "$SCRIPT" dev > "$state.log" 2>&1 &+ local pid=$!+ PIDS+=("$pid")+ for _ in $(seq 1 50); do+ [[ -f "$state" ]] && break+ sleep 0.1+ done+ [[ -f "$state" ]]+ kill -0 "$pid"+ LAST_PID="$pid"+}++STATE_A="$TMP/a.state"+STATE_B="$TMP/b.state"+start_fixture "$STATE_A" 41001 41002+PID_A="$LAST_PID"+start_fixture "$STATE_B" 42001 42002+PID_B="$LAST_PID"++if PATH="$TMP/bin:$PATH" AGENT_TESTING_DEV_STATE_FILE="$STATE_A" \+ SERVER_PORT=41001 SPA_PORT=41002 "$SCRIPT" dev > "$TMP/duplicate-a.log" 2>&1; then+ echo "duplicate start unexpectedly replaced an active ownership record" >&2+ exit 1+fi+if ! kill -0 "$PID_A" 2>/dev/null; then+ echo "duplicate start disturbed the active owned process" >&2+ exit 1+fi++AGENT_TESTING_DEV_STATE_FILE="$STATE_A" "$SCRIPT" clean > "$TMP/clean-a.log"+for _ in $(seq 1 30); do+ kill -0 "$PID_A" 2>/dev/null || break+ sleep 0.1+done+if kill -0 "$PID_A" 2>/dev/null; then+ echo "owned process A survived clean" >&2+ exit 1+fi+if ! kill -0 "$PID_B" 2>/dev/null; then+ echo "sibling process B was killed by cleaning A" >&2+ exit 1+fi++STATE_C="$TMP/c.state"+start_fixture "$STATE_C" 43001 43002+PID_C="$LAST_PID"+sed -i.bak 's/^PROCESS_START=.*/PROCESS_START=stale/' "$STATE_C"+if AGENT_TESTING_DEV_STATE_FILE="$STATE_C" "$SCRIPT" clean > "$TMP/clean-c.log" 2>&1; then+ echo "stale ownership metadata unexpectedly succeeded" >&2+ exit 1+fi+if ! kill -0 "$PID_C" 2>/dev/null; then+ echo "stale ownership metadata killed an unverified process" >&2+ exit 1+fi++echo "init-dev-env ownership tests passed"diff --git a/.agents/skills/agent-testing/ui/electron.md b/.agents/skills/agent-testing/ui/electron.mdindex 450abc31e5a..531407cac1c 100644--- a/.agents/skills/agent-testing/ui/electron.md+++ b/.agents/skills/agent-testing/ui/electron.md@@ -58,7 +58,7 @@ instead of hand-rolling `__LOBE_STORES` eval snippets** for these common needs:```bashPROBE=".agents/skills/agent-testing/scripts/app-probe.sh"-$PROBE auth # login check (Step 0.3) β { isSignedIn, userId }+$PROBE auth # login check (Step 2.4) β { isSignedIn, userId }$PROBE route # current SPA route$PROBE ops # running chat operations (type / startTime)$PROBE goto /settings # jump the SPA straight to a route (full reload)diff --git a/.agents/skills/agent-testing/ui/web.md b/.agents/skills/agent-testing/ui/web.mdindex 4a59d8946f1..39be53f00ca 100644--- a/.agents/skills/agent-testing/ui/web.md+++ b/.agents/skills/agent-testing/ui/web.md@@ -10,7 +10,7 @@ backend-only changes prefer [../cli/index.md](../cli/index.md).## Prerequisites-- Complete [Step 0.0](../SKILL.md#00-resolve-the-current-test-environment) (resolve ports) and [Step -1](../SKILL.md#step--1--plan-approval-for-non-trivial-tests) (plan approval) first.+- Complete [Step 2.0](../SKILL.md#20-resolve-the-current-test-environment) (resolve ports) and the [Phase 1 approval gate](../SKILL.md#phase-1-approval-gate--report-environment--plan-to-the-user) first.- Local dev server running β [../references/dev-server.md](../references/dev-server.md)- Web auth verified in agent-browser β prefer `setup-auth.sh web-seed`, see [auth decision flow](../references/auth.md#web--decision-flow).diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex a57522a9f63..87dc682ec8e 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -113,7 +113,7 @@"uuid": "^14.0.1","vite": "8.0.14","vitest": "3.2.6",- "zod": "^3.25.76"+ "zod": "^4.4.3"},"optionalDependencies": {"node-mac-permissions": "^2.5.0"diff --git a/apps/server/src/routers/lambda/__tests__/aiChat.test.ts b/apps/server/src/routers/lambda/__tests__/aiChat.test.tsindex 3a2cc3ae22f..3264e268dbc 100644--- a/apps/server/src/routers/lambda/__tests__/aiChat.test.ts+++ b/apps/server/src/routers/lambda/__tests__/aiChat.test.ts@@ -1306,7 +1306,7 @@ describe('aiChatRouter', () => {generateObject: mockGenerateObject,} as any);- const callerSuppliedId = '00000000-0000-0000-0000-000000000001';+ const callerSuppliedId = '00000000-0000-4000-8000-000000000001';const caller = aiChatRouter.createCaller({ ...mockCtx, serverDB: {} } as any);const result = await caller.outputJSON({messages: [],diff --git a/apps/server/src/routers/lambda/__tests__/llmGenerationTracing.test.ts b/apps/server/src/routers/lambda/__tests__/llmGenerationTracing.test.tsindex bfe2189b86f..b5d4aa536a4 100644--- a/apps/server/src/routers/lambda/__tests__/llmGenerationTracing.test.ts+++ b/apps/server/src/routers/lambda/__tests__/llmGenerationTracing.test.ts@@ -28,7 +28,7 @@ describe('llmGenerationTracingRouter.recordFeedback', () => {recordFeedback.mockClear();recordFeedback.mockResolvedValueOnce(undefined);const caller = llmGenerationTracingRouter.createCaller(mockCtx as any);- const tracingId = '00000000-0000-0000-0000-000000000001';+ const tracingId = '00000000-0000-4000-8000-000000000001';const result = await caller.recordFeedback({data: { accepted_text: 'hello' },@@ -62,7 +62,7 @@ describe('llmGenerationTracingRouter.recordFeedback', () => {await caller.recordFeedback({signal: 'positive',source: 'explicit_thumbs',- tracingId: '00000000-0000-0000-0000-000000000001',+ tracingId: '00000000-0000-4000-8000-000000000001',});throw new Error('expected mutation to reject');} catch (err) {@@ -81,7 +81,7 @@ describe('llmGenerationTracingRouter.recordFeedback', () => {await caller.recordFeedback({signal: 'positive',source: 'explicit_thumbs',- tracingId: '00000000-0000-0000-0000-000000000001',+ tracingId: '00000000-0000-4000-8000-000000000001',});throw new Error('expected mutation to reject');} catch (err) {@@ -96,7 +96,7 @@ describe('llmGenerationTracingRouter.recordFeedback', () => {caller.recordFeedback({signal: 'meh' as any,source: 'explicit_thumbs',- tracingId: '00000000-0000-0000-0000-000000000001',+ tracingId: '00000000-0000-4000-8000-000000000001',}),).rejects.toThrow();});@@ -119,7 +119,7 @@ describe('llmGenerationTracingRouter.recordFeedback', () => {score: 2,signal: 'positive',source: 'explicit_thumbs',- tracingId: '00000000-0000-0000-0000-000000000001',+ tracingId: '00000000-0000-4000-8000-000000000001',}),).rejects.toThrow();});diff --git a/apps/server/src/routers/lambda/_schema/documentHistory.ts b/apps/server/src/routers/lambda/_schema/documentHistory.tsindex c3e922bccca..3ac9d04dcd0 100644--- a/apps/server/src/routers/lambda/_schema/documentHistory.ts+++ b/apps/server/src/routers/lambda/_schema/documentHistory.ts@@ -42,7 +42,7 @@ export const updateDocumentInputSchema = z.object({fileType: z.string().optional(),id: z.string(),lockOwnerId: z.string().optional(),- metadata: z.record(z.any()).optional(),+ metadata: z.record(z.string(), z.any()).optional(),parentId: z.string().nullish(),restoreFromHistoryId: z.string().optional(),saveSource: documentHistorySaveSourceSchema.optional(),diff --git a/apps/server/src/routers/lambda/agentBotProvider.ts b/apps/server/src/routers/lambda/agentBotProvider.tsindex 12496de85f1..2c86d5c7bbe 100644--- a/apps/server/src/routers/lambda/agentBotProvider.ts+++ b/apps/server/src/routers/lambda/agentBotProvider.ts@@ -74,10 +74,10 @@ export const agentBotProviderRouter = router({z.object({agentId: z.string(),applicationId: z.string(),- credentials: z.record(z.string()),+ credentials: z.record(z.string(), z.string()),enabled: z.boolean().optional(),platform: z.string(),- settings: z.record(z.unknown()).optional(),+ settings: z.record(z.string(), z.unknown()).optional(),}),).mutation(async ({ input, ctx }) => {@@ -311,11 +311,11 @@ export const agentBotProviderRouter = router({.input(z.object({applicationId: z.string().optional(),- credentials: z.record(z.string()).optional(),+ credentials: z.record(z.string(), z.string()).optional(),enabled: z.boolean().optional(),id: z.string(),platform: z.string().optional(),- settings: z.record(z.unknown()).optional(),+ settings: z.record(z.string(), z.unknown()).optional(),}),).mutation(async ({ input, ctx }) => {diff --git a/apps/server/src/routers/lambda/agentEval.ts b/apps/server/src/routers/lambda/agentEval.tsindex c88dd154a4c..f2883746dfe 100644--- a/apps/server/src/routers/lambda/agentEval.ts+++ b/apps/server/src/routers/lambda/agentEval.ts@@ -88,7 +88,7 @@ export const agentEvalRouter = router({description: z.string().optional(),rubrics: z.array(z.any()).optional().default([]), // EvalBenchmarkRubric[]referenceUrl: z.string().optional(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),isSystem: z.boolean().default(false),}),)@@ -141,7 +141,7 @@ export const agentEvalRouter = router({description: z.string().optional(),rubrics: z.array(z.any()).optional(),referenceUrl: z.string().optional(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),}),).mutation(async ({ input, ctx }) => {@@ -189,7 +189,7 @@ export const agentEvalRouter = router({description: z.string().optional(),evalMode: rubricTypeSchema.optional(),evalConfig: evalConfigSchema.optional(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),}),).mutation(async ({ input, ctx }) => {@@ -248,7 +248,7 @@ export const agentEvalRouter = router({description: z.string().optional(),evalMode: rubricTypeSchema.nullish(),evalConfig: evalConfigSchema.nullish(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),}),).mutation(async ({ input, ctx }) => {@@ -335,7 +335,7 @@ export const agentEvalRouter = router({expectedDelimiter: z.string().optional(),choices: z.string().optional(),category: z.string().optional(),- metadata: z.record(z.string()).optional(),+ metadata: z.record(z.string(), z.string()).optional(),sortOrder: z.string().optional(),}),}),@@ -450,7 +450,7 @@ export const agentEvalRouter = router({}),evalMode: rubricTypeSchema.optional(),evalConfig: evalConfigSchema.optional(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),sortOrder: z.number().optional(),}),)@@ -491,7 +491,7 @@ export const agentEvalRouter = router({choices: z.array(z.string()).optional(),category: z.string().optional(),}),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),sortOrder: z.number().optional(),}),),@@ -533,7 +533,7 @@ export const agentEvalRouter = router({.optional(),evalMode: rubricTypeSchema.nullish(),evalConfig: evalConfigSchema.nullish(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),sortOrder: z.number().optional(),}),)@@ -979,7 +979,7 @@ export const agentEvalRouter = router({averageScore: z.number(),passRate: z.number(),duration: z.number().optional(),- rubricScores: z.record(z.number()).optional(),+ rubricScores: z.record(z.string(), z.number()).optional(),}),}),)diff --git a/apps/server/src/routers/lambda/agentEvalExternal.ts b/apps/server/src/routers/lambda/agentEvalExternal.tsindex 60570552eed..c9ee1e6435a 100644--- a/apps/server/src/routers/lambda/agentEvalExternal.ts+++ b/apps/server/src/routers/lambda/agentEvalExternal.ts@@ -30,7 +30,7 @@ const runStatusSchema = z.enum([const reportResultItemSchema = z.object({correct: z.boolean(),- result: z.record(z.unknown()).optional(),+ result: z.record(z.string(), z.unknown()).optional(),score: z.number(),threadId: z.string().optional(),topicId: z.string(),@@ -350,7 +350,7 @@ export const agentEvalExternalRouter = router({.input(z.object({correct: z.boolean(),- result: z.record(z.unknown()).optional(),+ result: z.record(z.string(), z.unknown()).optional(),runId: z.string(),score: z.number(),threadId: z.string().optional(),@@ -463,7 +463,7 @@ export const agentEvalExternalRouter = router({.input(z.object({correct: z.boolean(),- result: z.record(z.unknown()).optional(),+ result: z.record(z.string(), z.unknown()).optional(),runId: z.string(),score: z.number(),threadId: z.string().optional(),diff --git a/apps/server/src/routers/lambda/aiAgent.ts b/apps/server/src/routers/lambda/aiAgent.tsindex 83dafdf13be..70b38210d8f 100644--- a/apps/server/src/routers/lambda/aiAgent.ts+++ b/apps/server/src/routers/lambda/aiAgent.ts@@ -209,7 +209,7 @@ const ExecAgentSchema = z/** ID of the pending `role='tool'` message this result targets. */parentMessageId: z.string(),/** Optional plugin state to persist on the tool message. */- pluginState: z.record(z.unknown()).optional(),+ pluginState: z.record(z.string(), z.unknown()).optional(),/** tool_call_id of the pending tool call being answered. */toolCallId: z.string(),})diff --git a/apps/server/src/routers/lambda/botMessage.ts b/apps/server/src/routers/lambda/botMessage.tsindex 87030143cbb..fa9efa25a11 100644--- a/apps/server/src/routers/lambda/botMessage.ts+++ b/apps/server/src/routers/lambda/botMessage.ts@@ -306,7 +306,7 @@ export const botMessageRouter = router({botId: z.string().optional(),channelId: z.string(),content: z.string(),- embeds: z.array(z.record(z.unknown())).optional(),+ embeds: z.array(z.record(z.string(), z.unknown())).optional(),messengerInstallationId: z.string().optional(),replyTo: z.string().optional(),})diff --git a/apps/server/src/routers/lambda/brief.ts b/apps/server/src/routers/lambda/brief.tsindex a2e1992376f..11e82ce58ed 100644--- a/apps/server/src/routers/lambda/brief.ts+++ b/apps/server/src/routers/lambda/brief.ts@@ -17,7 +17,7 @@ const briefWriteProcedure = briefProcedure.use(withScopedPermission('task:updateconst idInput = z.object({ id: z.string() });const createSchema = z.object({- actions: z.array(z.record(z.unknown())).optional(),+ actions: z.array(z.record(z.string(), z.unknown())).optional(),agentId: z.string().optional(),artifacts: z.array(z.string()).optional(),cronJobId: z.string().optional(),diff --git a/apps/server/src/routers/lambda/connector.ts b/apps/server/src/routers/lambda/connector.tsindex 8c3d47787b6..3bfae09dd74 100644--- a/apps/server/src/routers/lambda/connector.ts+++ b/apps/server/src/routers/lambda/connector.ts@@ -64,7 +64,7 @@ const oidcConfigSchema = z.object({const connectorCredentialsInputSchema = z.discriminatedUnion('type', [z.object({ token: z.string().min(1), type: z.literal('bearer') }),z.object({ apiKey: z.string().min(1), type: z.literal('apikey') }),- z.object({ headers: z.record(z.string()), type: z.literal('header') }),+ z.object({ headers: z.record(z.string(), z.string()), type: z.literal('header') }),]);const createConnectorSchema = z.object({@@ -83,10 +83,10 @@ const createConnectorSchema = z.object({.object({args: z.array(z.string()).optional(),command: z.string(),- env: z.record(z.string()).optional(),+ env: z.record(z.string(), z.string()).optional(),}).optional(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),name: z.string().min(1).max(255),oidcConfig: oidcConfigSchema.optional(),sourceType: z.enum([@@ -415,7 +415,7 @@ export const connectorRouter = router({tools: z.array(z.object({description: z.string().optional(),- inputSchema: z.record(z.unknown()).optional(),+ inputSchema: z.record(z.string(), z.unknown()).optional(),toolName: z.string(),}),),diff --git a/apps/server/src/routers/lambda/document.ts b/apps/server/src/routers/lambda/document.tsindex 8ee075c16aa..40d3af66da8 100644--- a/apps/server/src/routers/lambda/document.ts+++ b/apps/server/src/routers/lambda/document.ts@@ -53,7 +53,7 @@ export const documentRouter = router({editorData: z.string().optional(),fileType: z.string().optional(),knowledgeBaseId: z.string().optional(),- metadata: z.record(z.any()).optional(),+ metadata: z.record(z.string(), z.any()).optional(),parentId: z.string().optional(),slug: z.string().optional(),title: z.string(),@@ -92,7 +92,7 @@ export const documentRouter = router({editorData: z.string(),fileType: z.string().optional(),knowledgeBaseId: z.string().optional(),- metadata: z.record(z.any()).optional(),+ metadata: z.record(z.string(), z.any()).optional(),parentId: z.string().optional(),slug: z.string().optional(),title: z.string(),diff --git a/apps/server/src/routers/lambda/market/agent.ts b/apps/server/src/routers/lambda/market/agent.tsindex b799fdf8404..c5af0343577 100644--- a/apps/server/src/routers/lambda/market/agent.ts+++ b/apps/server/src/routers/lambda/market/agent.ts@@ -276,22 +276,22 @@ const createAgentVersionSchema = z.object({avatar: z.string().optional(),category: z.string().optional(),changelog: z.string().optional(),- config: z.record(z.any()).optional(),+ config: z.record(z.string(), z.any()).optional(),defaultInputModes: z.array(z.string()).optional(),defaultOutputModes: z.array(z.string()).optional(),description: z.string().optional(),documentationUrl: z.string().optional(),- extensions: z.array(z.record(z.any())).optional(),+ extensions: z.array(z.record(z.string(), z.any())).optional(),hasPushNotifications: z.boolean().optional(),hasStateTransitionHistory: z.boolean().optional(),hasStreaming: z.boolean().optional(),identifier: z.string(),- interfaces: z.array(z.record(z.any())).optional(),+ interfaces: z.array(z.record(z.string(), z.any())).optional(),name: z.string().optional(),preferredTransport: z.string().optional(),providerId: z.number().optional(),- securityRequirements: z.array(z.record(z.any())).optional(),- securitySchemes: z.record(z.any()).optional(),+ securityRequirements: z.array(z.record(z.string(), z.any())).optional(),+ securitySchemes: z.record(z.string(), z.any()).optional(),setAsCurrent: z.boolean().optional(),summary: z.string().optional(),supportsAuthenticatedExtendedCard: z.boolean().optional(),@@ -314,11 +314,11 @@ const publishOrCreateSchema = z.object({changelog: z.string().optional(),- config: z.record(z.any()).optional(),+ config: z.record(z.string(), z.any()).optional(),description: z.string().optional(),- editorData: z.record(z.any()).optional(),+ editorData: z.record(z.string(), z.any()).optional(),// Agent basic infoidentifier: z.string().nullish(),diff --git a/apps/server/src/routers/lambda/market/agentGroup.ts b/apps/server/src/routers/lambda/market/agentGroup.tsindex 6e646631666..f08ea44a67a 100644--- a/apps/server/src/routers/lambda/market/agentGroup.ts+++ b/apps/server/src/routers/lambda/market/agentGroup.ts@@ -135,7 +135,7 @@ const agentGroupWriteProcedure = agentGroupProcedure.use(withScopedPermission('aconst memberAgentSchema = z.object({avatar: z.string().nullish(),category: z.string().optional(),- config: z.record(z.any()),+ config: z.record(z.string(), z.any()),description: z.string(),displayOrder: z.number().optional(),identifier: z.string(),diff --git a/apps/server/src/routers/lambda/market/creds.ts b/apps/server/src/routers/lambda/market/creds.tsindex 5ce5c472034..6dda9122363 100644--- a/apps/server/src/routers/lambda/market/creds.ts+++ b/apps/server/src/routers/lambda/market/creds.ts@@ -95,7 +95,7 @@ export const credsRouter = router({key: z.string().min(1).max(100),name: z.string().min(1).max(255),type: z.enum(['kv-env', 'kv-header']),- values: z.record(z.string()),+ values: z.record(z.string(), z.string()),}),).mutation(async ({ ctx, input }) => {@@ -510,7 +510,7 @@ export const credsRouter = router({description: z.string().optional(),id: z.number(),name: z.string().optional(),- values: z.record(z.string()).optional(),+ values: z.record(z.string(), z.string()).optional(),}),).mutation(async ({ ctx, input }) => {diff --git a/apps/server/src/routers/lambda/market/index.ts b/apps/server/src/routers/lambda/market/index.tsindex 83ae254bfe3..5f5f9b68e3c 100644--- a/apps/server/src/routers/lambda/market/index.ts+++ b/apps/server/src/routers/lambda/market/index.ts@@ -777,7 +777,7 @@ export const marketRouter = router({errorMessage: z.string().optional(),identifier: z.string(),isCustomPlugin: z.boolean().optional(),- metadata: z.record(z.any()).optional(),+ metadata: z.record(z.string(), z.any()).optional(),methodName: z.string(),methodType: z.enum(['tool', 'prompt', 'resource']),platform: z.string().optional(),diff --git a/apps/server/src/routers/lambda/message.ts b/apps/server/src/routers/lambda/message.tsindex 0f9d70bc3b8..ecbe969a6d7 100644--- a/apps/server/src/routers/lambda/message.ts+++ b/apps/server/src/routers/lambda/message.ts@@ -643,7 +643,7 @@ export const messageRouter = router({z.object({toolCallId: z.string(),- value: z.union([z.string(), z.record(z.unknown())]),+ value: z.union([z.string(), z.record(z.string(), z.unknown())]),}).extend(basicContextSchema.shape),)diff --git a/apps/server/src/routers/lambda/plugin.ts b/apps/server/src/routers/lambda/plugin.tsindex efa9cb228ff..871990e15ac 100644--- a/apps/server/src/routers/lambda/plugin.ts+++ b/apps/server/src/routers/lambda/plugin.ts@@ -21,10 +21,10 @@ export const pluginRouter = router({.use(withScopedPermission('agent:update')).input(z.object({- customParams: z.any(),+ customParams: z.any().optional(),identifier: z.string(),manifest: z.any(),- settings: z.any(),+ settings: z.any().optional(),type: z.enum(['plugin', 'customPlugin']),}),)@@ -52,9 +52,9 @@ export const pluginRouter = router({.use(withScopedPermission('agent:update')).input(z.object({- customParams: z.any(),+ customParams: z.any().optional(),identifier: z.string(),- manifest: z.any(),+ manifest: z.any().optional(),type: z.enum(['plugin', 'customPlugin']),}),)diff --git a/apps/server/src/routers/lambda/ragEval.ts b/apps/server/src/routers/lambda/ragEval.tsindex f65cb647cac..97dc573f3d9 100644--- a/apps/server/src/routers/lambda/ragEval.ts+++ b/apps/server/src/routers/lambda/ragEval.ts@@ -98,7 +98,7 @@ export const ragEvalRouter = router({question: z.string(),ideal: z.string().optional(),referenceFiles: z.array(z.string()).optional(),- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),}),).mutation(async ({ input, ctx }) => {@@ -127,7 +127,7 @@ export const ragEvalRouter = router({question: z.string(),ideal: z.string(),referenceFiles: z.array(z.string()),- metadata: z.record(z.unknown()),+ metadata: z.record(z.string(), z.unknown()),}).partial(),}),diff --git a/apps/server/src/routers/lambda/task.ts b/apps/server/src/routers/lambda/task.tsindex 4fb38151868..6f0ecd613cb 100644--- a/apps/server/src/routers/lambda/task.ts+++ b/apps/server/src/routers/lambda/task.ts@@ -76,8 +76,8 @@ const updateSchema = z.object({assigneeAgentId: z.string().nullish(),assigneeUserId: z.string().nullish(),automationMode: z.enum(['heartbeat', 'schedule']).nullish(),- config: z.record(z.unknown()).optional(),- context: z.record(z.unknown()).optional(),+ config: z.record(z.string(), z.unknown()).optional(),+ context: z.record(z.string(), z.unknown()).optional(),description: z.string().optional(),editorData: z.unknown().optional(),// 0 clears the interval (disables heartbeat); any positive value must be@@ -884,8 +884,8 @@ export const taskRouter = router({maxIterations: z.number().min(1).max(10).default(3),rubrics: z.array(z.object({- config: z.record(z.unknown()),- extractor: z.record(z.unknown()).optional(),+ config: z.record(z.string(), z.unknown()),+ extractor: z.record(z.string(), z.unknown()).optional(),id: z.string(),name: z.string(),threshold: z.number().min(0).max(1).optional(),@@ -1195,7 +1195,7 @@ export const taskRouter = router({}),updateConfig: taskProcedureWrite- .input(idInput.merge(z.object({ config: z.record(z.unknown()) })))+ .input(idInput.merge(z.object({ config: z.record(z.string(), z.unknown()) }))).mutation(async ({ input, ctx }) => {const { id, config } = input;try {diff --git a/apps/server/src/routers/lambda/topic.ts b/apps/server/src/routers/lambda/topic.tsindex 686fc0b721b..15f621a316f 100644--- a/apps/server/src/routers/lambda/topic.ts+++ b/apps/server/src/routers/lambda/topic.ts@@ -648,7 +648,7 @@ export const topicRouter = router({metadata: z.object({boundDeviceId: z.string().optional(),heteroSessionId: z.string().optional(),- heteroSessionIdByWorkingDirectory: z.record(z.string()).optional(),+ heteroSessionIdByWorkingDirectory: z.record(z.string(), z.string()).optional(),model: z.string().optional(),onboardingFeedback: z.object({diff --git a/apps/server/src/routers/lambda/verify.ts b/apps/server/src/routers/lambda/verify.tsindex 89c0ceb4b70..03827555f7c 100644--- a/apps/server/src/routers/lambda/verify.ts+++ b/apps/server/src/routers/lambda/verify.ts@@ -90,7 +90,7 @@ const checkItemSchema = z.object({sourceCriterionId: z.string().nullish(),sourceRubricId: z.string().nullish(),title: z.string(),- verifierConfig: z.record(z.unknown()),+ verifierConfig: z.record(z.string(), z.unknown()),verifierType: verifierTypeSchema,});@@ -126,7 +126,7 @@ const runContextSchema = z.object({testedAt: z.string().optional(),});-const runMetadataSchema = z.record(z.unknown());+const runMetadataSchema = z.record(z.string(), z.unknown());const updateRunInputSchema = verifyRunIdInputSchema.extend({// Every field optional β a re-ingest may refresh only the context/goal while@@ -232,7 +232,7 @@ export const verifyRouter = router({onFail: onFailSchema.optional(),required: z.boolean().optional(),title: z.string(),- verifierConfig: z.record(z.unknown()).optional(),+ verifierConfig: z.record(z.string(), z.unknown()).optional(),verifierType: verifierTypeSchema,}),)@@ -254,7 +254,7 @@ export const verifyRouter = router({onFail: onFailSchema.optional(),required: z.boolean().optional(),title: z.string().optional(),- verifierConfig: z.record(z.unknown()).optional(),+ verifierConfig: z.record(z.string(), z.unknown()).optional(),verifierType: verifierTypeSchema.optional(),}),}),@@ -361,7 +361,7 @@ export const verifyRouter = router({onFail: onFailSchema.optional(),required: z.boolean().optional(),title: z.string().min(1),- verifierConfig: z.record(z.unknown()).optional(),+ verifierConfig: z.record(z.string(), z.unknown()).optional(),verifierType: verifierTypeSchema.optional(),}),),diff --git a/apps/server/src/routers/tools/composio.ts b/apps/server/src/routers/tools/composio.tsindex 0bd7550b0ac..4ace05f8be1 100644--- a/apps/server/src/routers/tools/composio.ts+++ b/apps/server/src/routers/tools/composio.ts@@ -20,7 +20,7 @@ export const composioToolsRouter = router({.input(z.object({identifier: z.string(),- toolArgs: z.record(z.unknown()).optional(),+ toolArgs: z.record(z.string(), z.unknown()).optional(),toolSlug: z.string(),}),)diff --git a/apps/server/src/routers/tools/market.ts b/apps/server/src/routers/tools/market.tsindex 89a9dc7ce21..0e5c675922f 100644--- a/apps/server/src/routers/tools/market.ts+++ b/apps/server/src/routers/tools/market.ts@@ -119,7 +119,7 @@ const metaSchema = z// Schema for sandbox tool execution requestconst execInSandboxSchema = z.object({- params: z.record(z.any()),+ params: z.record(z.string(), z.any()),toolName: z.string(),topicId: z.string(),userId: z.string().optional(), // Optional: fallback to ctx.userId if not provided@@ -134,7 +134,7 @@ const exportAndUploadFileSchema = z.object({// Schema for cloud MCP endpoint callconst callCloudMcpEndpointSchema = z.object({- apiParams: z.record(z.any()),+ apiParams: z.record(z.string(), z.any()),identifier: z.string(),meta: metaSchema,toolName: z.string(),@@ -408,7 +408,7 @@ export const marketRouter = router({connectCallTool: lobehubSkillAuthProcedure.input(z.object({- args: z.record(z.any()).optional(),+ args: z.record(z.string(), z.any()).optional(),provider: z.string(),toolName: z.string(),topicId: z.string().optional(),diff --git a/apps/server/src/routers/tools/mcp.ts b/apps/server/src/routers/tools/mcp.tsindex 53b8fa1cab5..b99a860e415 100644--- a/apps/server/src/routers/tools/mcp.ts+++ b/apps/server/src/routers/tools/mcp.ts@@ -22,7 +22,7 @@ import { scheduleToolCallReport } from './_helpers';// Define Zod schemas for MCP Client parametersconst httpParamsSchema = z.object({auth: StreamableHTTPAuthSchema,- headers: z.record(z.string()).optional(),+ headers: z.record(z.string(), z.string()).optional(),name: z.string().min(1),type: z.literal('http'),url: z.string().url(),diff --git a/apps/server/src/services/agentSignal/policies/analyzeIntent/skillIntentRecord.ts b/apps/server/src/services/agentSignal/policies/analyzeIntent/skillIntentRecord.tsindex 52fcb932b1b..436c5dbdd32 100644--- a/apps/server/src/services/agentSignal/policies/analyzeIntent/skillIntentRecord.ts+++ b/apps/server/src/services/agentSignal/policies/analyzeIntent/skillIntentRecord.ts@@ -35,7 +35,7 @@ const PendingSkillSynthesisSchema = z.object({.optional(),evidence: z.array(z.object({ cue: z.string(), excerpt: z.string() })).optional(),message: z.string(),- sourceHints: z.record(z.unknown()).optional(),+ sourceHints: z.record(z.string(), z.unknown()).optional(),threadId: z.string().optional(),topicId: z.string().optional(),});diff --git a/package.json b/package.jsonindex 33f5e2ecfea..affa4dbf51e 100644--- a/package.json+++ b/package.json@@ -348,7 +348,7 @@"diff": "^8.0.4","discord-api-types": "^0.38.49","drizzle-orm": "^0.45.2",- "drizzle-zod": "^0.5.1",+ "drizzle-zod": "^0.8.3","epub2": "^3.0.2","es-toolkit": "^1.49.0","expo-server-sdk": "^6.1.0",@@ -452,8 +452,7 @@"xast-util-to-xml": "^4.0.0","xastscript": "^4.0.0","yaml": "^2.9.0",- "zod": "^3.25.76",- "zod-to-json-schema": "^3.25.2",+ "zod": "^4.4.3","zustand": "5.0.4","zustand-utils": "^2.1.1"},diff --git a/packages/app-config/package.json b/packages/app-config/package.jsonindex 9ce05dad770..15623bc7f7d 100644--- a/packages/app-config/package.json+++ b/packages/app-config/package.json@@ -15,7 +15,7 @@"@t3-oss/env-nextjs": "^0.13.11","debug": "^4.4.3","lucide-react": "^1.22.0",- "zod": "^3.25.76"+ "zod": "^4.4.3"},"devDependencies": {"vite-tsconfig-paths": "^6.1.1"diff --git a/packages/builtin-tool-web-onboarding/package.json b/packages/builtin-tool-web-onboarding/package.jsonindex 9cb07dc943d..50d3f86c458 100644--- a/packages/builtin-tool-web-onboarding/package.json+++ b/packages/builtin-tool-web-onboarding/package.json@@ -15,7 +15,7 @@"@lobechat/const": "workspace:*","@lobechat/markdown-patch": "workspace:*","@lobechat/prompts": "workspace:*",- "zod": "^3.25.76"+ "zod": "^4.4.3"},"devDependencies": {"@lobechat/types": "workspace:*"diff --git a/packages/builtin-tools/package.json b/packages/builtin-tools/package.jsonindex 1ccb991b28f..8f8b94acdb2 100644--- a/packages/builtin-tools/package.json+++ b/packages/builtin-tools/package.json@@ -54,7 +54,7 @@},"devDependencies": {"@lobechat/types": "workspace:*",- "zod": "^3.25.76"+ "zod": "^4.4.3"},"peerDependencies": {"@lobehub/ui": "^5",diff --git a/packages/database/package.json b/packages/database/package.jsonindex e02e2cf2dc0..c3e3078d1fc 100644--- a/packages/database/package.json+++ b/packages/database/package.json@@ -37,6 +37,6 @@"drizzle-zod": "*","nanoid": "*","pg": "*",- "zod": "^3.25.76"+ "zod": "^4.4.3"}}diff --git a/packages/database/src/models/userMemory/__tests__/model.test.ts b/packages/database/src/models/userMemory/__tests__/model.test.tsindex 519034527e1..163bdefcbdd 100644--- a/packages/database/src/models/userMemory/__tests__/model.test.ts+++ b/packages/database/src/models/userMemory/__tests__/model.test.ts@@ -1759,7 +1759,7 @@ describe('UserMemoryModel', () => {preferenceTypes: ['ui'],};const params = {- include: ['categories'],+ include: ['categories' as const],q: 'productivity',};const querySpy = vidiff --git a/packages/env/package.json b/packages/env/package.jsonindex d2fb81cbb7e..f7f006b6f1f 100644--- a/packages/env/package.json+++ b/packages/env/package.json@@ -13,6 +13,6 @@"@lobechat/const": "workspace:*","@lobechat/types": "workspace:*","@t3-oss/env-core": "^0.13.11",- "zod": "^3.25.76"+ "zod": "^4.4.3"}}diff --git a/packages/heterogeneous-agents/package.json b/packages/heterogeneous-agents/package.jsonindex 1f63167d097..97f5d9550eb 100644--- a/packages/heterogeneous-agents/package.json+++ b/packages/heterogeneous-agents/package.json@@ -23,7 +23,7 @@"@lobehub/icons": "^5.10.0","@modelcontextprotocol/sdk": "^1.29.0","diff": "^8.0.4",- "zod": "^4.0.0"+ "zod": "^4.4.3"},"devDependencies": {"@lobechat/types": "workspace:*"diff --git a/packages/memory-user-memory/package.json b/packages/memory-user-memory/package.jsonindex 8ca6e1d0c5a..3f6e632964b 100644--- a/packages/memory-user-memory/package.json+++ b/packages/memory-user-memory/package.json@@ -26,8 +26,7 @@"ora": "^9.4.1","unist-builder": "^4.0.0","xast-util-to-xml": "^4.0.0",- "xastscript": "^4.0.0",- "zod-to-json-schema": "^3.25.2"+ "xastscript": "^4.0.0"},"devDependencies": {"@types/json-schema": "^7.0.15",@@ -36,6 +35,6 @@"tsx": "^4.22.4"},"peerDependencies": {- "zod": "^3.25.76"+ "zod": "^4.4.3"}}diff --git a/packages/memory-user-memory/src/extractors/base.ts b/packages/memory-user-memory/src/extractors/base.tsindex 8757ea9a28c..111b57f335b 100644--- a/packages/memory-user-memory/src/extractors/base.ts+++ b/packages/memory-user-memory/src/extractors/base.ts@@ -62,7 +62,7 @@ export abstract class BaseMemoryExtractor<protected getPromptName(): string {return this.agent;}- protected abstract getResultSchema(): z.ZodType<TOutput, z.ZodTypeDef, unknown> | undefined;+ protected abstract getResultSchema(): z.ZodType<TOutput, unknown> | undefined;protected getSchema(_options: TExtractorTemplateProps): GenerateObjectSchema | undefined {const schema = this.getResultSchema();diff --git a/packages/memory-user-memory/src/schemas/activity.ts b/packages/memory-user-memory/src/schemas/activity.tsindex 98b3668f629..18d4d25fc3a 100644--- a/packages/memory-user-memory/src/schemas/activity.ts+++ b/packages/memory-user-memory/src/schemas/activity.ts@@ -26,7 +26,7 @@ export const WithActivitySchema = z.object({associatedSubjects: z.array(ActivityAssociationSchema).nullish(),endsAt: z.string().nullish(),feedback: z.string().nullish(),- metadata: z.record(z.unknown()).nullish(),+ metadata: z.record(z.string(), z.unknown()).nullish(),narrative: z.string(),notes: z.string().nullish(),startsAt: z.string().nullish(),diff --git a/packages/memory-user-memory/src/utils/zod.ts b/packages/memory-user-memory/src/utils/zod.tsindex 53e84e3421b..36726a983e9 100644--- a/packages/memory-user-memory/src/utils/zod.ts+++ b/packages/memory-user-memory/src/utils/zod.ts@@ -1,6 +1,5 @@import type { GenerateObjectSchema } from '@lobechat/model-runtime';-import type { z } from 'zod';-import { zodToJsonSchema } from 'zod-to-json-schema';+import { z } from 'zod';export interface BuildSchemaOptions {description?: string;@@ -23,7 +22,7 @@ export const buildGenerateObjectSchema = (schema: z.ZodTypeAny,options: BuildSchemaOptions,): GenerateObjectSchema => {- const fullSchema = zodToJsonSchema(schema, options.name);+ const fullSchema = z.toJSONSchema(schema, { target: 'draft-7' });const jsonSchema = pickMainSchema(fullSchema, options.name);if (jsonSchema.type === 'object') {diff --git a/packages/model-bank/package.json b/packages/model-bank/package.jsonindex 3bd1bda3804..5140979a576 100644--- a/packages/model-bank/package.json+++ b/packages/model-bank/package.json@@ -104,6 +104,6 @@"typescript": "^6.0.3"},"peerDependencies": {- "zod": "^3.25.76"+ "zod": "^4.4.3"}}diff --git a/packages/model-runtime/package.json b/packages/model-runtime/package.jsonindex 2db3fdbeb2f..a70b2cfd506 100644--- a/packages/model-runtime/package.json+++ b/packages/model-runtime/package.json@@ -43,6 +43,6 @@"@lobechat/types": "workspace:*"},"peerDependencies": {- "zod": "^3.25.76"+ "zod": "^4.4.3"}}diff --git a/packages/model-runtime/src/helpers/parseToolCalls.test.ts b/packages/model-runtime/src/helpers/parseToolCalls.test.tsindex cffb2846697..9d324b1b8c4 100644--- a/packages/model-runtime/src/helpers/parseToolCalls.test.ts+++ b/packages/model-runtime/src/helpers/parseToolCalls.test.ts@@ -258,9 +258,7 @@ describe('parseToolCalls', () => {{code: 'invalid_type',expected: 'object',- received: 'undefined',path: ['function'],- message: 'Required',},]);}diff --git a/packages/openapi/package.json b/packages/openapi/package.jsonindex a413b7b5314..f1cd06c402a 100644--- a/packages/openapi/package.json+++ b/packages/openapi/package.json@@ -17,7 +17,7 @@"js-sha256": "^0.11.1","lodash": "^4.18.1","url-join": "^5.0.0",- "zod": "^3.25.76"+ "zod": "^4.4.3"},"devDependencies": {"@types/formidable": "^3.5.1"diff --git a/packages/openapi/src/types/agent.type.ts b/packages/openapi/src/types/agent.type.tsindex f801e0dbb8b..a6d277dc8bb 100644--- a/packages/openapi/src/types/agent.type.ts+++ b/packages/openapi/src/types/agent.type.ts@@ -47,7 +47,7 @@ export const CreateAgentRequestSchema = z.object({.nullish(),description: z.string().nullish(),model: z.string().nullish(),- params: z.record(z.unknown()).nullish(),+ params: z.record(z.string(), z.unknown()).nullish(),provider: z.string().nullish(),systemRole: z.string().nullish(),title: z.string().min(1, 'Title cannot be empty'),diff --git a/packages/openapi/src/types/chat.type.ts b/packages/openapi/src/types/chat.type.tsindex 5ac497caca1..e1a90c10bb3 100644--- a/packages/openapi/src/types/chat.type.ts+++ b/packages/openapi/src/types/chat.type.ts@@ -26,7 +26,7 @@ export const ChatServiceParamsSchema = z.object({z.object({content: z.string().min(1, 'Message content cannot be empty'),role: z.enum(['user', 'assistant', 'system'], {- required_error: 'Role must be user, assistant, or system',+ error: 'Role must be user, assistant, or system',}),}),)diff --git a/packages/openapi/src/types/message.type.ts b/packages/openapi/src/types/message.type.tsindex 0ee1000ce75..2b7be59d6f1 100644--- a/packages/openapi/src/types/message.type.ts+++ b/packages/openapi/src/types/message.type.ts@@ -123,7 +123,7 @@ export interface MessagesCreateRequest {export const MessagesCreateRequestSchema = z.object({content: z.string().min(1, 'Message content cannot be empty'),- role: z.enum(['user', 'system', 'assistant', 'tool'], { required_error: 'Invalid role type' }),+ role: z.enum(['user', 'system', 'assistant', 'tool'], { error: 'Invalid role type' }),// AI-related fieldsmodel: z.string().nullish(), // Model used@@ -158,7 +158,7 @@ export const MessagesCreateRequestSchema = z.object({});export const MessagesCreateWithReplyRequestSchema = MessagesCreateRequestSchema.extend({- role: z.literal('user', { errorMap: () => ({ message: 'Role must be user when creating an AI reply' }) }),+ role: z.literal('user', { error: 'Role must be user when creating an AI reply' }),});export type MessagesCreateWithReplyRequest = z.infer<typeof MessagesCreateWithReplyRequestSchema>;diff --git a/packages/openapi/src/types/model.type.ts b/packages/openapi/src/types/model.type.tsindex 5ad385a0d9d..64f32affd12 100644--- a/packages/openapi/src/types/model.type.ts+++ b/packages/openapi/src/types/model.type.ts@@ -53,15 +53,15 @@ export type GetModelsResponse = PaginationQueryResponse<{export type ModelDetailResponse = AiModelSelectItem;const ModelPayloadBaseSchema = z.object({- abilities: z.record(z.unknown()).nullish(),- config: z.record(z.unknown()).nullish(),+ abilities: z.record(z.string(), z.unknown()).nullish(),+ config: z.record(z.string(), z.unknown()).nullish(),contextWindowTokens: z.number().int().nullish(),description: z.string().nullish(),displayName: z.string().min(1, 'Model display name cannot be empty'),enabled: z.boolean().nullish(),organization: z.string().nullish(),- parameters: z.record(z.unknown()).nullish(),- pricing: z.record(z.unknown()).nullish(),+ parameters: z.record(z.string(), z.unknown()).nullish(),+ pricing: z.record(z.string(), z.unknown()).nullish(),releasedAt: z.string().nullish(),sort: z.number().int().nullish(),source: z.enum(['remote', 'custom', 'builtin']).nullish(),diff --git a/packages/openapi/src/types/provider.type.ts b/packages/openapi/src/types/provider.type.tsindex ce57c4188a6..5d15ab9690e 100644--- a/packages/openapi/src/types/provider.type.ts+++ b/packages/openapi/src/types/provider.type.ts@@ -54,14 +54,14 @@ export type ProviderListQuerySchemaType = z.infer<typeof ProviderListQuerySchemaconst ProviderPayloadBaseSchema = z.object({checkModel: z.string().nullish(),- config: z.record(z.unknown()).optional(),+ config: z.record(z.string(), z.unknown()).optional(),description: z.string().nullish(),enabled: z.boolean().optional(),fetchOnClient: z.boolean().nullish(),- keyVaults: z.record(z.string()).optional(),+ keyVaults: z.record(z.string(), z.string()).optional(),logo: z.string().nullish(),name: z.string().min(1, 'Provider name cannot be empty').nullish(),- settings: z.record(z.unknown()).optional(),+ settings: z.record(z.string(), z.unknown()).optional(),sort: z.number().int().nullish(),source: z.enum(['builtin', 'custom']).optional(),});@@ -71,7 +71,7 @@ export const CreateProviderRequestSchema = ProviderPayloadBaseSchema.extend({});export const UpdateProviderRequestSchema = ProviderPayloadBaseSchema.extend({- keyVaults: z.record(z.string()).nullish(),+ keyVaults: z.record(z.string(), z.string()).nullish(),});export type CreateProviderRequestSchemaType = z.infer<typeof CreateProviderRequestSchema>;diff --git a/packages/openapi/src/types/responses.type.ts b/packages/openapi/src/types/responses.type.tsindex e908d4b2f8e..5be19e4924c 100644--- a/packages/openapi/src/types/responses.type.ts+++ b/packages/openapi/src/types/responses.type.ts@@ -108,7 +108,7 @@ export type InputItem = z.infer<typeof InputItemSchema>;export const FunctionToolSchema = z.object({description: z.string().optional(),name: z.string(),- parameters: z.record(z.any()).optional(),+ parameters: z.record(z.string(), z.any()).optional(),strict: z.boolean().optional(),type: z.literal('function'),});@@ -175,7 +175,7 @@ export const CreateResponseRequestSchema = zinput: z.union([z.string(), z.array(InputItemSchema)]),instructions: z.string().nullish(),max_output_tokens: z.number().int().positive().nullish(),- metadata: z.record(z.string()).nullish(),+ metadata: z.record(z.string(), z.string()).nullish(),model: z.string(),parallel_tool_calls: z.boolean().nullish(),previous_response_id: z.string().nullish(),diff --git a/packages/types/package.json b/packages/types/package.jsonindex dffd70f995f..242058a0cd3 100644--- a/packages/types/package.json+++ b/packages/types/package.json@@ -20,6 +20,6 @@"peerDependencies": {"@lobehub/ui": "^5","react": "*",- "zod": "^3.25.76"+ "zod": "^4.4.3"}}diff --git a/packages/types/src/agent/graph.ts b/packages/types/src/agent/graph.tsindex 532ac6fa1e3..bc44bd0398f 100644--- a/packages/types/src/agent/graph.ts+++ b/packages/types/src/agent/graph.ts@@ -76,7 +76,7 @@ const AgentGraphNodeSchema = z.discriminatedUnion('type', [const AgentGraphFieldSchema = z.object({desc: z.string().min(1),- schema: z.record(z.unknown()),+ schema: z.record(z.string(), z.unknown()),});const AgentGraphFieldRefSchema = z.object({@@ -92,7 +92,7 @@ const AgentGraphInputFieldSchema = AgentGraphFieldRefSchema.extend({const AgentGraphOutputFieldSchema = AgentGraphFieldRefSchema;const AgentGraphEdgeSchema = z.object({- condition: z.record(z.unknown()).optional(),+ condition: z.record(z.string(), z.unknown()).optional(),from: z.string(),input: z.object({@@ -139,10 +139,10 @@ const findSchemaDescriptionPath = (export const ReasoningGraphSchema: z.ZodType<ReasoningGraph> = z.object({description: z.string().optional(),- fields: z.record(AgentGraphFieldSchema),+ fields: z.record(z.string(), AgentGraphFieldSchema),maxInstructionCount: z.number().int().positive().optional(),name: z.string().min(1),- nodes: z.record(AgentGraphNodeSchema),+ nodes: z.record(z.string(), AgentGraphNodeSchema),terminal: z.string().min(1),edges: z.array(AgentGraphEdgeSchema),})diff --git a/packages/types/src/agent/item.ts b/packages/types/src/agent/item.tsindex d2125501c11..5a9276ccbc9 100644--- a/packages/types/src/agent/item.ts+++ b/packages/types/src/agent/item.ts@@ -118,7 +118,7 @@ export const CreateAgentSchema = z.object({model: z.string().nullish(),openingMessage: z.string().nullish(),openingQuestions: z.array(z.string()).optional(),- params: z.record(z.unknown()).optional(),+ params: z.record(z.string(), z.unknown()).optional(),plugins: z.array(AgentPluginEntrySchema).optional(),provider: z.string().nullish(),sessionGroupId: z.string().nullish(),diff --git a/packages/types/src/agentHook.ts b/packages/types/src/agentHook.tsindex 18b277260da..d8952857192 100644--- a/packages/types/src/agentHook.ts+++ b/packages/types/src/agentHook.ts@@ -9,7 +9,7 @@ import { z } from 'zod';* persisted hook back casts up to it.*/export const agentHookWebhookSchema = z.object({- body: z.record(z.unknown()).optional(),+ body: z.record(z.string(), z.unknown()).optional(),delivery: z.enum(['fetch', 'qstash']).optional(),eventFields: z.array(z.string()).optional(),url: z.string(),diff --git a/packages/types/src/aiChat.ts b/packages/types/src/aiChat.tsindex 83b2413a409..8df8d9b2e36 100644--- a/packages/types/src/aiChat.ts+++ b/packages/types/src/aiChat.ts@@ -131,7 +131,7 @@ export const AiSendMessageServerSchema = z.object({agentId: z.string().optional(),groupId: z.string().optional(),newAssistantMessage: z.object({- metadata: z.record(z.unknown()).optional(),+ metadata: z.record(z.string(), z.unknown()).optional(),model: z.string().optional(),provider: z.string().optional(),}),@@ -148,7 +148,7 @@ export const AiSendMessageServerSchema = z.object({newUserMessage: z.object({content: z.string(),contextSelections: z.array(ContextSelectionSchema).optional(),- editorData: z.record(z.unknown()).optional(),+ editorData: z.record(z.string(), z.unknown()).optional(),files: z.array(z.string()).optional(),metadata: MessageMetadataSchema.optional(),pageSelections: z.array(PageSelectionSchema).optional(),diff --git a/packages/types/src/message/db/params.ts b/packages/types/src/message/db/params.tsindex 7a9dc1ad55e..df32e322f70 100644--- a/packages/types/src/message/db/params.ts+++ b/packages/types/src/message/db/params.ts@@ -126,7 +126,7 @@ export interface NewMessageQueryParams {export const UpdateMessageParamsSchema = z.object({content: z.string().optional(),- editorData: z.record(z.any()).nullish(),+ editorData: z.record(z.string(), z.any()).nullish(),error: ChatMessageErrorSchema.nullish(),imageList: z.array(ChatImageItemSchema).optional(),metadata: MessageMetadataSchema.optional(),diff --git a/packages/types/src/plugins/mcp.ts b/packages/types/src/plugins/mcp.tsindex 2af502f152e..faaa1d85075 100644--- a/packages/types/src/plugins/mcp.ts+++ b/packages/types/src/plugins/mcp.ts@@ -241,7 +241,7 @@ export const StreamableHTTPAuthSchema = z*/export const GetStreamableMcpServerManifestInputSchema = z.object({auth: StreamableHTTPAuthSchema,- headers: z.record(z.string()).optional(),+ headers: z.record(z.string(), z.string()).optional(),identifier: z.string(),metadata: z.object({diff --git a/packages/types/src/userMemory/identity.ts b/packages/types/src/userMemory/identity.tsindex 0d31d7a8379..86836a51f4f 100644--- a/packages/types/src/userMemory/identity.ts+++ b/packages/types/src/userMemory/identity.ts@@ -77,7 +77,7 @@ export const CreateUserMemoryIdentitySchema = z.object({description: z.string().optional(),episodicDate: z.string().optional(),extractedLabels: z.array(z.string()).optional(),- labels: z.record(z.any()).optional(),+ labels: z.record(z.string(), z.any()).optional(),relationship: z.string().optional(),role: z.string().optional(),type: IdentityTypeSchema.optional(),@@ -88,7 +88,7 @@ export const UpdateUserMemoryIdentitySchema = z.object({description: z.string().optional(),episodicDate: z.string().optional(),extractedLabels: z.array(z.string()).optional(),- labels: z.record(z.any()).optional(),+ labels: z.record(z.string(), z.any()).optional(),relationship: z.string().optional(),role: z.string().optional(),type: IdentityTypeSchema.optional(),diff --git a/packages/types/src/userMemory/tools.ts b/packages/types/src/userMemory/tools.tsindex dba047c2ebc..124cd30644e 100644--- a/packages/types/src/userMemory/tools.ts+++ b/packages/types/src/userMemory/tools.ts@@ -14,9 +14,8 @@ const stringArrayFieldSchema = z.preprocess(z.array(z.string().trim().min(1)),);-const enumArrayFieldSchema = <T extends z.EnumLike>(- schema: z.ZodNativeEnum<T> | z.ZodEnum<[string, ...string[]]>,-) => z.preprocess((value) => (typeof value === 'string' ? [value] : value), z.array(schema));+const enumArrayFieldSchema = <TSchema extends z.ZodType>(schema: TSchema) =>+ z.preprocess((value) => (typeof value === 'string' ? [value] : value), z.array(schema));const searchMemoryTimeFieldSchema = z.enum(['capturedAt',