Repository navigation
fix(val,mcp): Standard Schema v1 compat + packed-ELF record drops (cutils#27) - #80
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Deploying chttpjs with
|
| Latest commit: |
846487c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://00be6f1d.chttpjs.pages.dev |
| Branch Preview URL: | https://devin-1792347973-mcp-val-std.chttpjs.pages.dev |
… (cutils#27)
StdProps.version is the literal 1 so val schemas assign to StandardSchemaV1
instead of failing TS2345/TS2739; each concrete schema class merges a
StdTyped<I, O> interface so InferInput/InferOutput resolve real input/output
types in consumers like @chttp/mcp tool(); toJsonSchema/toOpenApiSchema accept
the {"~standard": unknown} structural minimum so a consumer's emitJsonSchema
adapter can feed any standard schema; factories return concrete class types
so inference reaches the merged interfaces.
…owering
Scriptc drops member writes that expand a non-empty record literal once the
package is lowered from its tsc dist, so resultResponse/errorResponse and the
tools/resources/prompts/initialize listing records now start from {} open
records or single full literals — packed tarballs returned bare {jsonrpc,id}
envelopes before this (cutils#27).
Packs @chttp/mcp alongside router+val, type-checks a consumer app mounting a val schema through tool()/emitJsonSchema under tsc, builds it to an ELF, and serves tools/list + tools/call (valid and invalid args) through Server.handleRequest.
f09f4b5 to
846487c
Compare
|
Follow-up on the known gap documented in Reproduced with a minimal standalone scriptc program (no chttp deps — a package class whose Upstream issue (retroactive report + regression coverage): vercel-labs/scriptc#1314 So the pack-smoke workaround can be retired once the repo's scriptc floor is |
Summary
Fixes sigilco/cutils#27 — the
@chttp/mcp×@chttp/valpairing failed to type-check under the published tarballs, and the packed ELF dropped response fields. Note: the issue is filed on cutils, but@chttp/valnow lives inpackages/valhere and@chttp/mcponly exists on this branch — so the fix lands stacked on the move-auth-mcp branch.Type compatibility (val):
StdProps.versionwidened tonumbermade every val schema refuseStandardSchemaV1(TS2345/TS2739). It is now the literal1.v.toJsonSchema/v.toOpenApiSchemarequired aVSchema, so a consumer'semitJsonSchemaadapter receivingStandardSchemaV1rejected it. They now take the{"~standard": unknown}structural minimum and validateinstanceof VSchemaat runtime.tool()handlerinputstayedunknown(TS18046) becauseInferInput/InferOutputfound no~standard.typesslot and factories erased concrete classes toVSchema. Each schema class now merges aStdTyped<I, O>interface (type-level only — the runtime field staysStdProps, keeping scriptc lowering at 100%), and factories return the concrete classes (string(): VStr, …).Packed-ELF record drops (mcp):
scriptcdrops member writes that expand a non-empty record literal when the package is compiled from its tsc dist JS — packed tarballs returned bare{"jsonrpc":"2.0","id":N}for every method.resultResponse,errorResponse,progressNotificationparams, and the initialize/tools/resources/prompts listing records now use single full literals or{}open records.Smoke coverage:
pnpm smoke:packnow packs@chttp/mcp, type-checkstests/pack-smoke/mcp-app.ts(the issue's repro: val schema intotool()+emitJsonSchemaarrow + inferred handler input) under tsc, builds it to an ELF, and servestools/list+tools/call(valid + invalid args) throughServer.handleRequest.Known limitation documented in the script: an
error-member response crossing the package call boundary still loses the member under scriptc's stringify — invalid-args returns the envelope{"jsonrpc","id":3}(dispatch reacheserrorResponsecorrectly; JS runtimes emit the fullINVALID_PARAMSbody). This looks like a compiler-side tagged-union/serialization gap worth its own issue.Test plan
pnpm test— all workspace tests incl.packages/mcpelf.test: passpnpm -r build: passpnpm smoke:pack: pass (incl. new mcp+val section)bash scripts/scriptc-gate.sh: 100% on all eight gatespnpm lint: warnings only (pre-existing)pnpm docs:build: passLink to Devin session: https://app.devin.ai/sessions/3f418b516b064c8ea1c69ecc54752ba9
Open in Devin Desktop: https://app.devin.ai/desktop/session/3f418b516b064c8ea1c69ecc54752ba9?variant=devin
Requested by: @espetro