feat(m7.1): TypeScript port — types, Model, FakeModel - #27
Merged
Conversation
Starts Phase 7. The TS package mirrors the Python and Go verbs and will pass the same shared conformance suite (spec/conformance) by M7.5. - packages/js (package "reins", ESM + NodeNext), strict TypeScript: strict + noUncheckedIndexedAccess + verbatimModuleSyntax — the tsc equivalent of the Python mypy --strict bar. - src/types.ts: the core value types (Message, ToolCall, ModelResponse, Usage, FinishReason, Access, Capability, ToolSpec, CapabilityResult, Context, RunResult, RunState, TableInfo, SchemaIndex, TraceEvent, ModelParams). Fields are snake_case to match the contract wire format and mainstream LLM APIs (OpenAI's own JSON uses finish_reason / tool_calls / input_schema), so JSON serialization is identity and every conformance case maps straight on with no renaming. toolSpec() extracts the intent surface — policy metadata (access/confirm/scope) never crosses to the model (§2.5). - src/errors.ts: ReinsError carrying a → hint (§2.19), instanceof-safe. - src/model.ts: the Model interface (async — real adapters do network I/O; the loop awaits) and the scriptable, deterministic FakeModel (finalResponse / callResponse / programResponse), recording every call's inputs and rejecting with a hinted error once the script is exhausted — the determinism boundary made concrete. - tests (vitest): toolSpec strips policy metadata, JSON round-trips, result helpers, and FakeModel ordering / input-snapshotting / exhaustion / builder shapes. - make js-check (prettier + tsc --noEmit + vitest) as the TS gate + a separate js CI job (Node 20); package-lock.json committed for reproducible installs. Verified: make js-check green (format, typecheck, 13 tests) and the built dist imports cleanly as ESM from Node (VERSION 0.1.0a1, matching the other packages).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Starts Phase 7. The TS package mirrors the Python and Go verbs and will pass the same shared conformance suite (spec/conformance) by M7.5.
Verified: make js-check green (format, typecheck, 13 tests) and the built dist imports cleanly as ESM from Node (VERSION 0.1.0a1, matching the other packages).