stitchkit 0.124.1 → 0.124.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts +7 -2
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +1 -1
- package/dist/entrypoints/cli/publish.js +1 -1
- package/dist/entrypoints/cli.js +2 -2
- package/dist/entrypoints/http.js +2 -2
- package/dist/entrypoints/index.js +3 -3
- package/dist/entrypoints/node.js +1 -1
- package/dist/entrypoints/process.js +1 -1
- package/dist/entrypoints/remote.js +1 -1
- package/dist/entrypoints/server.js +2 -2
- package/dist/entrypoints/telegram/screens.d.ts +1 -1
- package/dist/entrypoints/telegram/screens.d.ts.map +1 -1
- package/dist/entrypoints/telegram/screens.js +196 -83
- package/dist/entrypoints/testing.js +1 -1
- package/dist/entrypoints/tools/connections.js +1 -1
- package/dist/entrypoints/tools/toolkit.js +1 -1
- package/dist/entrypoints/tools.js +2 -2
- package/dist/{index-e1x6vze4.js → index-7rq5p3hk.js} +29 -1
- package/dist/{index-03qrr49d.js → index-b2sey031.js} +1 -1
- package/dist/{index-x0769xt9.js → index-btjwc7xr.js} +1 -1
- package/dist/{index-6qrspvxp.js → index-gbj964dt.js} +1 -1
- package/dist/{index-45dyex0j.js → index-m9hb9wnk.js} +1 -1
- package/dist/{index-zbzagr9k.js → index-ne4j9998.js} +16 -15
- package/dist/{index-cjbn98zt.js → index-ss67fxhj.js} +21 -3
- package/dist/{index-5efrpfmj.js → index-wxadzdb7.js} +1 -1
- package/dist/internal/stream-chunks.d.ts +10 -0
- package/dist/internal/stream-chunks.d.ts.map +1 -1
- package/dist/telegram/screens/dispatch.d.ts.map +1 -1
- package/dist/telegram/screens/display.d.ts +2 -1
- package/dist/telegram/screens/display.d.ts.map +1 -1
- package/dist/telegram/screens/execute.d.ts +12 -4
- package/dist/telegram/screens/execute.d.ts.map +1 -1
- package/dist/telegram/screens/render.d.ts +5 -1
- package/dist/telegram/screens/render.d.ts.map +1 -1
- package/dist/telegram/screens/runtime.d.ts +5 -1
- package/dist/telegram/screens/runtime.d.ts.map +1 -1
- package/dist/telegram/screens/state.d.ts +3 -0
- package/dist/telegram/screens/state.d.ts.map +1 -1
- package/dist/telegram/screens/test-chat-telegram.d.ts.map +1 -1
- package/dist/telegram/screens/view.d.ts +14 -5
- package/dist/telegram/screens/view.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/llms/cli.txt +8 -0
- package/llms/stitchkit.2.txt +6 -0
- package/llms/stitchkit.3.txt +1 -1
- package/llms/telegram-screens.txt +59 -4
- package/llms-full.txt +74 -5
- package/llms.txt +3 -3
- package/package.json +6 -6
package/llms-full.txt
CHANGED
|
@@ -3753,6 +3753,12 @@ body until it ends or is cancelled. This is the same for a Fetch-config client,
|
|
|
3753
3753
|
Unix transport. Cancelling a quiet stream therefore releases its server source
|
|
3754
3754
|
and transport connection instead of only settling the local iterator.
|
|
3755
3755
|
|
|
3756
|
+
A stream is read from any response whose `body` has `getReader()`, not only from
|
|
3757
|
+
the global `Response` class: a `fetch` of another runtime — `expo/fetch` in
|
|
3758
|
+
React Native, which answers with its own `FetchResponse` — streams the same way.
|
|
3759
|
+
A response without a readable body is refused with `Streaming endpoint did not
|
|
3760
|
+
return a Response`.
|
|
3761
|
+
|
|
3756
3762
|
An established NDJSON protocol may keep its item schema as the complete wire
|
|
3757
3763
|
frame. This mode requires a terminal item because an unwrapped response has no
|
|
3758
3764
|
separate safe error/end envelope:
|
|
@@ -11062,6 +11068,14 @@ type, not a bound, so a bare integer prints `<integer>`, `.min(1)` prints `>=1`
|
|
|
11062
11068
|
`.positive()` prints `>0`. Unbounded fields keep just their type and description. Bounds on an array's items are not bounds
|
|
11063
11069
|
on the array itself.
|
|
11064
11070
|
|
|
11071
|
+
A string says what shape it must have, before its bounds. A format JSON Schema
|
|
11072
|
+
defines is said by name — `<string> [uuid]`, `[email]`, `[uri]`, `[date-time]` —
|
|
11073
|
+
and the expression it is checked with is not printed. Any other shape is said
|
|
11074
|
+
by its pattern between slashes, `<string> [pattern /^[a-z]+$/, length >=2]`, and
|
|
11075
|
+
by its format's name only when the schema carries no pattern. A schema that
|
|
11076
|
+
composes two patterns prints both under `all of:`, a named format among them
|
|
11077
|
+
included: there the schema no longer carries the name.
|
|
11078
|
+
|
|
11065
11079
|
Composed schemas retain their meaning: `any of:` and `one of:` separate
|
|
11066
11080
|
alternative branches with `|`, while `all of:` joins constraints with `&`.
|
|
11067
11081
|
For example, a nullable bounded string renders
|
|
@@ -17544,6 +17558,37 @@ bot.catch((error) => logger.error('update failed', { error }))
|
|
|
17544
17558
|
message is sent with `parse_mode: 'HTML'` set explicitly, so an application's
|
|
17545
17559
|
own `parse_mode` transformer changes nothing.
|
|
17546
17560
|
|
|
17561
|
+
### Uploading a rich preview
|
|
17562
|
+
|
|
17563
|
+
For a local photo, a message is `richUpload`: a `contentKey` and a `build` function. The key
|
|
17564
|
+
identifies the complete rich payload. Change it when the file bytes, text or
|
|
17565
|
+
order of blocks changes. The outer message `key` identifies the Telegram
|
|
17566
|
+
message that can be edited in place.
|
|
17567
|
+
|
|
17568
|
+
```ts
|
|
17569
|
+
import { InputFile } from 'grammy'
|
|
17570
|
+
import type { RichUploadViewMessage } from 'stitchkit/telegram/screens'
|
|
17571
|
+
|
|
17572
|
+
function preview(path: string, revision: string): RichUploadViewMessage {
|
|
17573
|
+
return {
|
|
17574
|
+
richUpload: {
|
|
17575
|
+
contentKey: revision,
|
|
17576
|
+
build: () => ({
|
|
17577
|
+
blocks: [{ type: 'photo', photo: { type: 'photo', media: new InputFile(path) } }],
|
|
17578
|
+
}),
|
|
17579
|
+
},
|
|
17580
|
+
}
|
|
17581
|
+
}
|
|
17582
|
+
```
|
|
17583
|
+
|
|
17584
|
+
`richUpload` is a content of its own, like `text` or `photo`: a message has it
|
|
17585
|
+
or `rich`, never both, and `rich` stays the Bot API's inline type. The runtime
|
|
17586
|
+
calls `build` for each send or content edit. It can return a
|
|
17587
|
+
promise. A resend needs a fresh file if its stream was consumed. A render
|
|
17588
|
+
with the same content key skips the upload, including when it edits the
|
|
17589
|
+
keyboard. Storage holds the fingerprint. For a URL or a Telegram `file_id`,
|
|
17590
|
+
pass the Bot API rich object as `rich`.
|
|
17591
|
+
|
|
17547
17592
|
## Outcomes
|
|
17548
17593
|
|
|
17549
17594
|
A load, an action and an input handler answer with an outcome, built by
|
|
@@ -17600,6 +17645,15 @@ When Telegram refuses a step:
|
|
|
17600
17645
|
renders. The next update repairs the rest. A receipt or a remark Telegram
|
|
17601
17646
|
refuses stops the update the same way, with the view already drawn recorded.
|
|
17602
17647
|
|
|
17648
|
+
If Telegram refuses the first send, the previous menu keeps its message IDs,
|
|
17649
|
+
buttons and input routing. When an edit has an uncertain result, the next
|
|
17650
|
+
render checks that message again. If repeated interrupted transitions would
|
|
17651
|
+
exceed the chat record's recovery limit, the runtime cleans up the latest
|
|
17652
|
+
failed attempt's new sends. A later press can retry the full transition.
|
|
17653
|
+
One case the record cannot hold: a send Telegram carried out but whose answer
|
|
17654
|
+
was lost has no id to record, so that message stays in the chat until the user
|
|
17655
|
+
removes it.
|
|
17656
|
+
|
|
17603
17657
|
A view is checked before anything is sent: at most 100 messages, keys of 1 to
|
|
17604
17658
|
64 characters, at most 100 buttons whose address is kept in the record. A view
|
|
17605
17659
|
past these fails in the handler's place, with the chat untouched.
|
|
@@ -17653,7 +17707,9 @@ Called from inside a handler of the same chat, it runs at once rather than
|
|
|
17653
17707
|
waiting behind the update that called it, and the screen it opened stands: the
|
|
17654
17708
|
handler may still answer the press with a toast, and returning a navigation or
|
|
17655
17709
|
a notice as well is an error — drawn after it, the handler's own outcome would
|
|
17656
|
-
put the record back on the screen the chat left.
|
|
17710
|
+
put the record back on the screen the chat left. An open that fails inside a
|
|
17711
|
+
handler rejects there: the failure is the handler's, and `onError` hears it
|
|
17712
|
+
once, with the handler's trigger.
|
|
17657
17713
|
|
|
17658
17714
|
## State and concurrency
|
|
17659
17715
|
|
|
@@ -17680,7 +17736,7 @@ refused halfway too.
|
|
|
17680
17736
|
| `callbackPrefix` | `~` | what every screen button's `callback_data` starts with |
|
|
17681
17737
|
| `chats` | `'private'` | `'all'` answers in groups too, where any member can press or type |
|
|
17682
17738
|
| `onStale(c)` | answered silently | a press nothing can answer, with its `reason`; its outcome is shown |
|
|
17683
|
-
| `onError(error, c)` | none | a load, action or
|
|
17739
|
+
| `onError(error, c)` | none | a load, action, input or display that threw. Its outcome is shown. |
|
|
17684
17740
|
| `onEvent(event)` | none | `transition`, `state-discarded`, `message-kept`, `sweep-failed` (a remark's timer could not delete it) — never message text |
|
|
17685
17741
|
| `clock` | `Date.now` | the time expiring remarks are measured by |
|
|
17686
17742
|
|
|
@@ -17689,6 +17745,19 @@ Without `onError` the press is answered silently and the error reaches
|
|
|
17689
17745
|
timers on the way down; a remark left behind is removed on the chat's next
|
|
17690
17746
|
update.
|
|
17691
17747
|
|
|
17748
|
+
A view Telegram refused is not drawn again by the report of its refusal:
|
|
17749
|
+
after a failed display `stay()` leaves the chat as its record says and only
|
|
17750
|
+
delivers the toast and the notices, so the refused request is sent once and
|
|
17751
|
+
the next press retries it. `go()` and `back()` are followed as usual. A
|
|
17752
|
+
handler that threw changed nothing in the chat, so after it `stay()` loads
|
|
17753
|
+
and draws its screen anew.
|
|
17754
|
+
|
|
17755
|
+
A press is answered before its view is drawn, so a toast for a failed display
|
|
17756
|
+
comes too late to be the answer. In a private chat it is said as a remark of
|
|
17757
|
+
the screen — escaped text under the menu that leaves with the next view sent,
|
|
17758
|
+
or after 30 seconds. In a group it is an ephemeral message only the user who
|
|
17759
|
+
pressed receives.
|
|
17760
|
+
|
|
17692
17761
|
## Security
|
|
17693
17762
|
|
|
17694
17763
|
- **A group's `load` checks access** for every screen, action and input under
|
|
@@ -17727,7 +17796,7 @@ refuse a call, `deleteByUser`, `pressData` for a forged press and
|
|
|
17727
17796
|
|
|
17728
17797
|
## Not included
|
|
17729
17798
|
|
|
17730
|
-
Reply keyboards, inline mode,
|
|
17799
|
+
Reply keyboards, inline mode, uploads for standalone media messages, showing a
|
|
17731
17800
|
screen without an update (use `screens.button` in a notification), converting
|
|
17732
17801
|
an incoming message to HTML, and a history stack.
|
|
17733
17802
|
|
|
@@ -23440,7 +23509,7 @@ The browser-and-server entrypoint. Re-exports everything from
|
|
|
23440
23509
|
| `parseNDJSON` | function | parse bounded fatal-UTF-8 NDJSON from a `Response`, a `ReadableStream<Uint8Array>` or an `AsyncIterable<Uint8Array>` (a child's stdout); blank keep-alives are skipped, `finalLine: 'require-newline'` makes the delimiter mandatory and `signal` cancels the source — [guide](../guide/client.md#any-byte-source) |
|
|
23441
23510
|
| `createNDJSONDecoder` / `NDJSONDecoder` | function / _type_ | the same bounded NDJSON reading driven by `push(chunk)` / `end()`, for a socket `data` callback |
|
|
23442
23511
|
| `readBoundedBody` / `BoundedBodyOptions` | function / _type_ | the whole body of a `ReadableStream<Uint8Array>` or async byte iterable as bytes, never reading past `maxBytes` plus one chunk; `limitError(observedBytes)` and `abortError(reason)` choose the two errors, the source is cancelled on both, a `null` body is empty — [guide](../guide/client.md#reading-a-body-up-to-a-byte-limit) |
|
|
23443
|
-
| `StreamByteSource` | _type_ | `Response \| ReadableStream<Uint8Array> \| AsyncIterable<Uint8Array>`, what the NDJSON and SSE readers accept |
|
|
23512
|
+
| `StreamByteSource` | _type_ | `Response \| ReadableStream<Uint8Array> \| AsyncIterable<Uint8Array>`, what the NDJSON and SSE readers accept; each is recognised by its shape, not its class — a reader, `Symbol.asyncIterator`, else the response's `body` — so another runtime's fetch response (`expo/fetch`) reads like the global `Response` |
|
|
23444
23513
|
| `StreamLineLimitError` / `StreamTruncatedLineError` | class | a line past `maxLineBytes` (`limitBytes`, `lineBytes`; a `RangeError`) and a source ended inside a line under `require-newline` (`lineBytes`; a `SyntaxError`) |
|
|
23445
23514
|
| `resumableIterator` | function | re-open a long-lived stream from the last delivered cursor, with jittered backoff, a caller-owned terminal item and prompt abort — [guide](../guide/client.md#resumable-streams) |
|
|
23446
23515
|
| `createBackoff` | function | exponential backoff with subtractive jitter as a value: `next()` / `reset()` |
|
|
@@ -25613,7 +25682,7 @@ the whole dependency. → ADR 0211 — [guide](../guide/telegram-screens.md)
|
|
|
25613
25682
|
| `ScreenInputKind` / `ScreenInputOptions` | _type_ | `text` `rich` `photo` `video` `animation` `document` `audio` `voice` `video_note` `sticker` `location` `contact`; `keepMessage` leaves the user's message (default: deleted before the handler) |
|
|
25614
25683
|
| `ScreenHandlerResult` / `ScreenOutcome` / `ScreenOutcomeBuilders` / `ScreenInputOutcomeBuilders` | _type_ / class | what a load, action or input answers: `stay()`, `go(screen, params?)`, `back()`, `toast(text, { alert? })` (≤ 200 characters), `notice(content, { expiresInMs? })`; `void` is `stay()`; after input there is no press, so no `toast` |
|
|
25615
25684
|
| `ScreenNavigation` / `ScreenToast` / `ScreenNotice` / `NoticeOptions` | _type_ | the parts of an outcome; a notice without `expiresInMs` is a receipt the screen moves below, with it a remark under the screen that removes itself |
|
|
25616
|
-
| `ViewMessage` / `ScreenViewResult` / `TextViewMessage` / `RichViewMessage` / `PhotoViewMessage` / `VideoViewMessage` / `AnimationViewMessage` / `DocumentViewMessage` / `AudioViewMessage` / `ScreenMediaKind` | _type_ | one message or several; exactly one content (`text`, `rich`, or a media file id or URL with `caption`), plus `keyboard`, `key` and `linkPreview` |
|
|
25685
|
+
| `ViewMessage` / `ScreenViewResult` / `TextViewMessage` / `RichViewMessage` / `RichUploadViewMessage` / `PhotoViewMessage` / `VideoViewMessage` / `AnimationViewMessage` / `DocumentViewMessage` / `AudioViewMessage` / `ScreenMediaKind` | _type_ | one message or several; exactly one content (`text`, `rich`, `richUpload`, or a media file id or URL with `caption`), plus `keyboard`, `key` and `linkPreview`; `richUpload` is `{ contentKey, build }` — `build` returns a grammY `InputRichMessage` with its files for each send or content edit |
|
|
25617
25686
|
| `link` / `back` / `ScreenButton` | function / class | a button to a screen with its params; a button to the parent screen |
|
|
25618
25687
|
| `Keyboard` / `KeyboardRow` / `KeyboardButton` / `PlainKeyboardButton` / `ButtonLabel` | _type_ | rows of screen buttons and plain Telegram buttons without `callback_data`; `false`, `null` and `undefined` are skipped; a label is text or `{ text, style?, icon_custom_emoji_id? }` |
|
|
25619
25688
|
| `html` / `TelegramHtml` / `HtmlTag` / `HtmlValue` / `TelegramText` | function / class / _type_ | Telegram HTML with every interpolation escaped; `html.raw()` for markup already safe, `html.join()`; a plain string is always escaped (`escapeTelegramHtml` is `stitchkit/telegram/html`'s) |
|
package/llms.txt
CHANGED
|
@@ -9,7 +9,7 @@ Build with stitchkit: define a contract once, then `implement` it and serve it (
|
|
|
9
9
|
Load the slice for each entrypoint your code imports — `import … from 'stitchkit/server'` → `llms/server.txt`; the root `stitchkit` import → `llms/stitchkit.txt`. A slice holds that entrypoint's API reference section and the guide pages whose home it is; every guide lives in exactly one slice, and a slice that needs another's guide names it under "Also read". Each file is at most 50.0 KB; a longer one continues in numbered parts, each naming the next at its top. Moving across versions: load `llms/upgrading.txt` and the range slices it lists between your version and the target. `llms-full.txt` inlines everything; it is far larger than a context window, so do not read it whole.
|
|
10
10
|
|
|
11
11
|
## Entrypoint slices
|
|
12
|
-
- **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 45.2 KB → [llms/stitchkit.2.txt](llms/stitchkit.2.txt)
|
|
12
|
+
- **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 45.2 KB → [llms/stitchkit.2.txt](llms/stitchkit.2.txt) 31.2 KB → [llms/stitchkit.3.txt](llms/stitchkit.3.txt) 19.3 KB
|
|
13
13
|
- **stitchkit/live**: [llms/live.txt](llms/live.txt) 21.2 KB
|
|
14
14
|
- **stitchkit/react**: [llms/react.txt](llms/react.txt) 8.7 KB
|
|
15
15
|
- **stitchkit/react/keyboard**: [llms/react-keyboard.txt](llms/react-keyboard.txt) 22.7 KB
|
|
@@ -21,7 +21,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
21
21
|
- **stitchkit/tools/contract**: [llms/tools-contract.txt](llms/tools-contract.txt) 0.2 KB
|
|
22
22
|
- **stitchkit/tools/invoker**: [llms/tools-invoker.txt](llms/tools-invoker.txt) 0.2 KB
|
|
23
23
|
- **stitchkit/tools/connections**: [llms/tools-connections.txt](llms/tools-connections.txt) 4.9 KB
|
|
24
|
-
- **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 44.
|
|
24
|
+
- **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 44.6 KB → [llms/cli.2.txt](llms/cli.2.txt) 42.9 KB
|
|
25
25
|
- **stitchkit/cli/publish**: [llms/cli-publish.txt](llms/cli-publish.txt) 1.5 KB
|
|
26
26
|
- **stitchkit/remote**: [llms/remote.txt](llms/remote.txt) 1.0 KB
|
|
27
27
|
- **stitchkit/contract**: [llms/contract.txt](llms/contract.txt) 34.1 KB
|
|
@@ -49,7 +49,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
49
49
|
- **stitchkit/telegram/grammy**: [llms/telegram-grammy.txt](llms/telegram-grammy.txt) 2.3 KB
|
|
50
50
|
- **stitchkit/telegram/html**: [llms/telegram-html.txt](llms/telegram-html.txt) 2.7 KB
|
|
51
51
|
- **stitchkit/telegram/voice**: [llms/telegram-voice.txt](llms/telegram-voice.txt) 1.9 KB
|
|
52
|
-
- **stitchkit/telegram/screens**: [llms/telegram-screens.txt](llms/telegram-screens.txt)
|
|
52
|
+
- **stitchkit/telegram/screens**: [llms/telegram-screens.txt](llms/telegram-screens.txt) 23.9 KB
|
|
53
53
|
- **stitchkit/tracking**: [llms/tracking.txt](llms/tracking.txt) 22.3 KB
|
|
54
54
|
- **stitchkit/release**: [llms/release.txt](llms/release.txt) 8.9 KB
|
|
55
55
|
- **stitchkit/tracking/contract**: [llms/tracking-contract.txt](llms/tracking-contract.txt) 2.8 KB
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stitchkit",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.3",
|
|
4
4
|
"description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -409,20 +409,20 @@
|
|
|
409
409
|
"@modelcontextprotocol/server": "^2.4.0",
|
|
410
410
|
"@openrouter/ai-sdk-provider": "^3.1.0",
|
|
411
411
|
"@opentelemetry/api": "^1.10.0",
|
|
412
|
-
"@seriousme/openapi-schema-validator": "^2.
|
|
412
|
+
"@seriousme/openapi-schema-validator": "^2.12.0",
|
|
413
413
|
"@socket.io/bun-engine": "^0.1.2",
|
|
414
414
|
"@socket.io/component-emitter": "^3.1.2",
|
|
415
|
-
"@tanstack/react-query": "5.
|
|
415
|
+
"@tanstack/react-query": "5.108.0",
|
|
416
416
|
"@types/bun": "^1.4.4",
|
|
417
417
|
"@types/json-schema": "^7.0.15",
|
|
418
418
|
"@types/react": "^19.3.0",
|
|
419
419
|
"@types/react-dom": "^19.3.0",
|
|
420
420
|
"@typescript/typescript6": "^6.0.2",
|
|
421
|
-
"ai": "^7.0.
|
|
421
|
+
"ai": "^7.0.173",
|
|
422
422
|
"ajv": "^8.20.0",
|
|
423
423
|
"exceljs": "^4.4.0",
|
|
424
|
-
"fake-indexeddb": "^6.2.
|
|
425
|
-
"google-auth-library": "^11.3.
|
|
424
|
+
"fake-indexeddb": "^6.2.8",
|
|
425
|
+
"google-auth-library": "^11.3.4",
|
|
426
426
|
"grammy": "^1.46.0",
|
|
427
427
|
"react": "^19.3.1",
|
|
428
428
|
"react-dom": "^19.3.1",
|