Skip to content

feat(m7.1): TypeScript port — types, Model, FakeModel - #27

Merged
shamspias merged 1 commit into
mainfrom
build/m7.1-ts-types
Jul 5, 2026
Merged

feat(m7.1): TypeScript port — types, Model, FakeModel#27
shamspias merged 1 commit into
mainfrom
build/m7.1-ts-types

Conversation

@shamspias

Copy link
Copy Markdown
Owner

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).

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).
@shamspias
shamspias merged commit 702f27a into main Jul 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant