Fix sanitizeOptionalJson return type

This commit is contained in:
Mohamed Boudra
2025-12-25 12:30:27 +07:00
parent 8261910c37
commit c771fd986d
2 changed files with 11 additions and 19 deletions

View File

@@ -195,7 +195,14 @@ function sanitizeOptionalJson(value: unknown): JsonValue | undefined {
}
return Object.keys(result).length ? result : undefined;
}
return value;
if (
typeof value === "string" ||
typeof value === "number" ||
typeof value === "boolean"
) {
return value;
}
return undefined;
}
function isJsonObject(

21
plan.md
View File

@@ -622,30 +622,15 @@ Build a new Codex MCP provider sidebyside with the existing Codex SDK prov
- Be specific: "missing X" or "Y test fails because Z"
- **Done (2025-12-25 11:49)**: WHAT: ran server test suite and typecheck, captured results in `test-output-live-audit.txt:1`, and documented go-live audit findings in `REPORT-codex-mcp-go-live-audit.md:1`; inserted follow-up fix tasks in `plan.md:620`. RESULT: Codex MCP is not ready to ship as default due to 4 failing MCP tests (mapping, tool IO timeout, error timeline, persistence), 1 failing + 1 skipped Codex SDK test, Claude SDK watcher errors, and typecheck failures. EVIDENCE: `npm run test --workspace=@paseo/server 2>&1 | tee test-output-live-audit.txt` (interrupted after stall; failures logged) and `npm run typecheck --workspace=@paseo/server` (TS2322 errors in `src/server/agent/agent-projections.ts:198:3` and `src/server/agent/providers/claude-agent.ts:343:5`).
- [ ] **Fix**: Codex MCP thread/item mapping failure in `codex-mcp-agent.test.ts` (file change, MCP tool, web search, todo list assertions).
- [] **Fix**: Codex MCP thread/item mapping failure in `codex-mcp-agent.test.ts` (file change, MCP tool, web search, todo list assertions).
- [ ] **Fix**: Codex MCP tool call input/output capture test timeout in `codex-mcp-agent.test.ts` (test timed out at 240000ms).
- [ ] **Fix**: Codex MCP missing error timeline item on failed turns (`codex-mcp-agent.test.ts` expects >0).
- [ ] **Fix**: Codex MCP persistence/resume metadata mismatch in `codex-mcp-agent.test.ts` (missing tool outputs/metadata and conversation id mismatch).
- [ ] **Fix**: Codex SDK persisted shell_command hydration test failure in `codex-agent.test.ts` (`expected undefined to be truthy`).
- [ ] **Fix**: Codex SDK permission test skip in `codex-agent.test.ts` (remove skip or implement missing permission flow).
- [ ] **Fix**: Claude SDK tests emit FS watcher errors (`UNKNOWN: unknown error, watch '/var/folders/.../vscode-git-*.sock'`) causing `claude-agent.test.ts` instability.
- [ ] **Fix**: Codex API network errors during tests (`https://chatgpt.com/backend-api/codex/responses`) - make tests deterministic or handle unavailable endpoint.
- [ ] **Test (E2E)**: Rerun `npm run test --workspace=@paseo/server` and verify zero failures/skips; store full output.
- [ ] **Fix**: Typecheck error in `agent-projections.ts:198` - {} not assignable to JsonValue.
- [x] **Fix**: Typecheck error in `agent-projections.ts:198` - {} not assignable to JsonValue.
- Error: TS2322 at `src/server/agent/agent-projections.ts:198:3`
- Issue: `{}` is not assignable to `JsonValue | undefined`
- Fix the type to match expected JsonValue type
- Run `npm run typecheck --workspace=@paseo/server` to verify fix
- **Done (2025-12-25 12:30)**: WHAT: constrained `sanitizeOptionalJson` to return only JSON primitives or undefined in `packages/server/src/server/agent/agent-projections.ts:198`. RESULT: TS2322 for `agent-projections.ts:198` no longer appears in typecheck output; remaining failures are in `claude-agent.ts` and `codex-mcp-agent.ts`. EVIDENCE: `npm run typecheck --workspace=@paseo/server` (errors listed for `src/server/agent/providers/claude-agent.ts:343:5` and multiple `codex-mcp-agent.ts` lines only).
- [ ] **Fix**: Typecheck error in `claude-agent.ts:343` - AgentSessionConfig not assignable to ClaudeAgentConfig.