module-client
/module-client
Tworzy pakiet klienta modułu z typowanymi hookami tRPC, dzięki którym przeglądarka odczytuje dane innego modułu LangWatch.
- Autor
- langwatch ↗
- Repozytorium
- langwatch ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Tworzy pakiet klienta modułu z typowanymi hookami tRPC, dzięki którym przeglądarka odczytuje dane innego modułu LangWatch.
Wyzwalacze z opisu
Argumenty
/module-client <module name or data question>
Oryginalny opis (EN)
Create or use a <name>-client package (modules/<name>/client): the typed tRPC hooks another module's browser reads. Use when someone says 'read another module's data in the browser', 'prompt-client', 'dataset-client', 'a client package', 'createModuleApi', 'ContractApiMap', 'derived tRPC client', 'browser wire', 'httpLink', 'request batching', 'the tRPC client in the browser', 'AppRouter in the UI', or 'can my screen call another module's procedure'. Teaches the record (ARCHITECTURE.md section 2 wire row, 3.4, 10).
Jak działa
- The wire, in one picture
- Rules that matter
- Worked example
- Traps
Podgląd SKILL.md
---
name: module-client
description: "Create or use a <name>-client package (modules/<name>/client): the typed tRPC hooks another module's browser reads. Use when someone says 'read another module's data in the browser', 'prompt-client', 'dataset-client', 'a client package', 'createModuleApi', 'ContractApiMap', 'derived tRPC client', 'browser wire', 'httpLink', 'request batching', 'the tRPC client in the browser', 'AppRouter in the UI', or 'can my screen call another module's procedure'. Teaches the record (ARCHITECTURE.md section 2 wire row, 3.4, 10)."
user-invocable: true
argument-hint: "<module name or data question>"
---
# `<name>-client`: modules share data, not code
Read `dev/docs/ARCHITECTURE.md` §2 (the Web row), §3.4 ("No kits; data through
clients") and §10 (the cache and wire rulings). Exemplars:
`modules/dataset/client` (about 30 lines of source) and `modules/prompt/client` (the same
derived client plus lent drawers and prompt-studio tokens). A module with tRPC procedures gets `modules/<name>/client`, package
`@langwatch/<name>-client`. A module nothing else reads has none
(integration, §3).
## The wire, in one picture
```
contract (<name>Trpc) --ContractApiMap--> createModuleApi() --> hooks (useQuery, useMutation, useUtils)
|
@langwatch/browser owns the one browser client: httpLink + SSE link + query client
```
- `@langwatch/api/web` derives the typed client from the contract's declarations.
- `@langwatch/browser` owns the transport (one client per application,
`packages/browser/src/wire/transport.ts`), the SSE subscription link and the
query client. Only a client package and a screen's `behavior/` import it.
A design-system component fetches nothing.
- The browser calls no REST.
## Rules that matter
Each rule lives in the record or an ADR; this table only points at it.
| Rule | Source |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
| Derived from `ContractApiMap<typeof <name>Trpc>`, never hand-written, never `AppRouter` | ADR-130 (`130-the-api-router-type-is-declared`) |
| Holds the derived hooks plus a few thin ones and the owner's lent tokens, never a component | §3.4, §10.1 |
| Imports its own contract, `@langwatch/module` (for the tokens it lends), `@langwatch/api/web`, `@langwatch/browser-host` and React only; a two-module hook lives in the screen | §2, §3.4 |
| Read only by browser packages and apps/ui; the linters' `client` role refuses any other reader | §2, §17 |
| One call per request over `httpLink`; no batching, the server refuses it | §10 |
| Every read is mirrored to disk by default (`UI_QUERY_MIRROR_EXCLUDED` names the exceptions); no per-read `staleTime`; no credential in a query | §10, §10.2 |
| One entity, one key: opaque id plus tenant scope; hints never enter a key | §10.2 |
| A procedure another module owns sits in a `BorrowedProcedures` type: debt, not a pattern | (convention; the record is silent) |
## Worked example
```ts
// modules/prompt/client/src/prompt-client.ts
import {
type ContractApiMap,
createModuleApi,
type ModuleApi,
type OutputsFromMap,
} from "@langwatch/api/web";
import type { promptTagTrpc, promptTrpc } from "@langwatch/prompt-contract";
type PromptApiMap = ContractApiMap<typeof promptTagTrpc> & ContractApiMap<typeof promptTrpc>;
export const promptClient: ModuleApi<PromptApiMap> = createModuleApi<PromptApiMap>();
export type PromptOutputs = OutputsFromMap<PromptApiMap>; // PromptInputs likewise
```
The minimal `src/index.ts` (dataset's) re-exports the client and its output and input types and
nothing else. Prompt's also exports its lent drawers and prompt-studio tokens, so its
`package.json` adds `@langwatch/module` to `@langwatch/api` and `@langwatch/prompt-contract`. Each
has `main` and one `exports["."]`. A consuming browser package lists
`@langwatch/prompt-client` and calls `promptClient.<proc>.useQuery(...)`
inside its own `behavior/` hook; its declaration still names its own api
(`.withApi(...)`, §10). There is no per-contract cache policy: every read is
mirrored by default (§10.2), and `TrpcCachePolicy` is deleted (§15).
To add one: copy `modules/dataset/client`, rename, point `ContractApiMap` at
every `*Trpc` object the contract exports, run `pnpm sync:references`
(new workspace package) and `pnpm generate:modules` if the catalogue changed.
Not every module with a contract has a client. There are about thirty across core and
Enterprise modules; find one with `ls modules/*/client enterprise/modules/*/client`, and a
module's page in `modules/README.md` says whether it has one.
## Traps
- **Importing another module's `-browser` package for its hook.** It is closed.
Use its client.
- **Putting a component in a client** because two modules want it. It goes to
`design-system` taking props or a query result, or the owner lends it by a token
declared in its client (§10.1).
- **Copying server data into `useState` or a store.** It stays in React Query
(`query-data-in-state` lint, ADR-169).
- **Calling a procedure by path from a typed hook's key.** A surface too wide
for a typed hook uses the shell's `UiRpc`; never re-enter the cache under the
key being resolved (§10).
- Host-service wiring, lending and entitlement are not here: §3.3, §10.1 and
the `frontend` skill. Where the hook is used: `browser-module`.
Wersje
W bazie nie ma innych skilli o nazwie module-client.
Migawka bazy z 13.11.2026 · wersja paczki 0ad7251cced0 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100cross-package-types
Opisuje przepływ typów w monorepo z tRPC i Prisma, w tym wnioskowanie AppRouter między pakietami shared, server i client. - 85tRPC
Prowadzi przez tRPC: konfigurację routerów, procedury, middleware, kontekst, konfigurację klienta i integrację z Next.js, dla typowanych API z pełną inferencją TypeScript. - 100browser-module
Pomaga pisać i zmieniać przeglądarkową część modułu (modules/nazwa/browser): ekran, szufladę, hook, fragment stanu, cache odczytu i pobieranie danych w interfejsie. - 90trpc
Opisuje konwencje Esposter dla tRPC: układ, nazewnictwo i zabezpieczanie routerów oraz procedur, ich wejść, testów i wywołań z klienta. - 100contract
Pisze lub zmienia pakiet kontraktu modułu: interfejs *Api i token moduleApi, schematy Zod, podklasy HandledError z kodami, deklaracje tRPC przez defineTrpcContract, schematy REST i czasowniki metod. - 100trpc
Buduje typowane end-to-end API w TypeScript bez schematów i generowania kodu: serwer definiuje procedury, a klient wywołuje je z pełną inferencją typów, w tym z Next.js.