Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

http: ToolContracts arm duplicates HttpInput inline — named references now expand on the wire

Aperta
#100 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
66/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
tooling

Direzione di ricerca

Start in plugins/http/src/index.ts: move the HttpInput interface above the declare module block and point the http arm at it. Before editing, record the params text from ToolTypeIndex.wireContracts(), then confirm it matches after the change. Read expandNamed in plugins/tool-types/src/build-dts.ts to see how a named reference is expanded. Done means the wire text is unchanged and the inline copy is gone; the sweep of other arms is a separate step.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

future-enhancement

plugins/http/src/index.ts declares the http contract with its params written inline, and describes the same shape again in a local HttpInput interface, which the executor casts its input to:

// params are inlined structurally (not a `HttpInput` reference) so the derived wire text shows real fields.
declare module '@matatbread/matbot-plugin-api' {
  interface ToolContracts {
    http: ToolContract<unknown, { url: string; method?: string; headers?: Record<string, string>; body?: string; responseType?: 'text' | 'json' }>;
  }
}

interface HttpInput { url: string; method?: string; headers?: Record<string, string>; body?: string; responseType?: 'text' | 'json' }

The comment's reason no longer applies. When this was written (360b7cc), wire text was the arm's source text verbatim, so a named reference would have reached the model as params: HttpInput. Since c6685bc both consumers handle a reference:

  • Wire text: expandNamed (plugins/tool-types/src/build-dts.ts) expands workspace interfaces and aliases into their fields, up to WIRE_DEPTH (2).
  • Generated dts: a referenced plugin-local interface or alias is bundled next to the reference (classify → bundle), exported or not.

The inline literal is therefore a second copy of the shape. That goes against the single-source rule for tool contracts, and a field added to only one copy goes unnoticed.

Fix

Move HttpInput above the declare module block, declare http: ToolContract<unknown, HttpInput>, and drop the comment. Check that ToolTypeIndex.wireContracts() produces the same params text for http before and after.

Sweep the other tools for the same case

27 source files declare at least one arm with inline object-literal params. An inline literal isn't a problem in itself. Look for an arm whose inline shape is also described by a local interface/type, or by an input as { … } cast in the executor, and point the arm at that one declaration.

Out of scope: plugins/tool-store/src/index.ts (~L280). That contract is a runtime toolContract string, resolved by a second Program that holds only plugin-api, so a plugin-local name cannot resolve there. Inlining is still required in that case.

Lingua principale
TypeScript
Stelle
5
Fork
2
Merge medio
1g 2h
PR unite (30g)
12

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MatAtBread/matbot

Tutte le issue di MatAtBread/matbot

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.