stitchkit 0.124.2 → 0.124.4

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
  3. package/dist/entrypoints/agent-runtime/harness.js +5 -5
  4. package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
  5. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  6. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  7. package/dist/entrypoints/agent-runtime/testing.js +6 -6
  8. package/dist/entrypoints/agent-runtime.js +12 -12
  9. package/dist/entrypoints/cli.js +7 -7
  10. package/dist/entrypoints/server.js +1 -1
  11. package/dist/entrypoints/telegram/screens.d.ts +1 -1
  12. package/dist/entrypoints/telegram/screens.d.ts.map +1 -1
  13. package/dist/entrypoints/telegram/screens.js +196 -83
  14. package/dist/entrypoints/testing.js +2 -2
  15. package/dist/entrypoints/tools/agent.js +7 -7
  16. package/dist/entrypoints/tools/connections.js +6 -5
  17. package/dist/entrypoints/tools/invoker.js +5 -5
  18. package/dist/entrypoints/tools/mcp.js +7 -7
  19. package/dist/entrypoints/tools/toolkit.js +9 -9
  20. package/dist/entrypoints/tools.js +8 -8
  21. package/dist/{index-s512scra.js → index-1wz4y15d.js} +1 -1
  22. package/dist/{index-yebkpytc.js → index-2ds89z96.js} +4 -4
  23. package/dist/{index-jkjh7zw4.js → index-3n8k175r.js} +5 -5
  24. package/dist/index-5dmk54h9.js +256 -0
  25. package/dist/{index-8pwwd6rp.js → index-6fmg17bg.js} +1 -1
  26. package/dist/{index-hzk4ydpy.js → index-a3ekss9t.js} +19 -6
  27. package/dist/{index-7177dxjn.js → index-afc3mtah.js} +1 -1
  28. package/dist/{index-0d3sm0m9.js → index-cm07qz01.js} +1 -1
  29. package/dist/{index-qsm899qp.js → index-en2xqhty.js} +1 -1
  30. package/dist/{index-782qtc24.js → index-p9saezh1.js} +1 -1
  31. package/dist/{index-993vtv1w.js → index-q7s1yr9g.js} +3 -3
  32. package/dist/{index-6k47xdtt.js → index-r7v5xz0g.js} +1 -1
  33. package/dist/{index-tynna0n4.js → index-rk7m4j7r.js} +3 -94
  34. package/dist/{index-qc7tq0za.js → index-x68eyh6y.js} +2 -2
  35. package/dist/{index-enkc9pem.js → index-xaem29dc.js} +1 -1
  36. package/dist/{index-96yjwwgf.js → index-z2z67tnv.js} +3 -3
  37. package/dist/json-schema/dialect.d.ts +6 -0
  38. package/dist/json-schema/dialect.d.ts.map +1 -1
  39. package/dist/json-schema/json-schema.d.ts.map +1 -1
  40. package/dist/json-schema/string-format.d.ts +36 -0
  41. package/dist/json-schema/string-format.d.ts.map +1 -0
  42. package/dist/telegram/screens/dispatch.d.ts.map +1 -1
  43. package/dist/telegram/screens/display.d.ts +2 -1
  44. package/dist/telegram/screens/display.d.ts.map +1 -1
  45. package/dist/telegram/screens/execute.d.ts +12 -4
  46. package/dist/telegram/screens/execute.d.ts.map +1 -1
  47. package/dist/telegram/screens/render.d.ts +5 -1
  48. package/dist/telegram/screens/render.d.ts.map +1 -1
  49. package/dist/telegram/screens/runtime.d.ts +5 -1
  50. package/dist/telegram/screens/runtime.d.ts.map +1 -1
  51. package/dist/telegram/screens/state.d.ts +3 -0
  52. package/dist/telegram/screens/state.d.ts.map +1 -1
  53. package/dist/telegram/screens/test-chat-telegram.d.ts.map +1 -1
  54. package/dist/telegram/screens/view.d.ts +14 -5
  55. package/dist/telegram/screens/view.d.ts.map +1 -1
  56. package/dist/tools/cli/help.d.ts.map +1 -1
  57. package/dist/tools/connections/runtime.d.ts.map +1 -1
  58. package/llms/cli.txt +11 -0
  59. package/llms/telegram-screens.txt +59 -4
  60. package/llms-full.txt +70 -4
  61. package/llms.txt +2 -2
  62. package/package.json +1 -1
  63. package/dist/index-ct75c3at.js +0 -46
@@ -138,6 +138,37 @@ bot.catch((error) => logger.error('update failed', { error }))
138
138
  message is sent with `parse_mode: 'HTML'` set explicitly, so an application's
139
139
  own `parse_mode` transformer changes nothing.
140
140
 
141
+ ### Uploading a rich preview
142
+
143
+ For a local photo, a message is `richUpload`: a `contentKey` and a `build` function. The key
144
+ identifies the complete rich payload. Change it when the file bytes, text or
145
+ order of blocks changes. The outer message `key` identifies the Telegram
146
+ message that can be edited in place.
147
+
148
+ ```ts
149
+ import { InputFile } from 'grammy'
150
+ import type { RichUploadViewMessage } from 'stitchkit/telegram/screens'
151
+
152
+ function preview(path: string, revision: string): RichUploadViewMessage {
153
+ return {
154
+ richUpload: {
155
+ contentKey: revision,
156
+ build: () => ({
157
+ blocks: [{ type: 'photo', photo: { type: 'photo', media: new InputFile(path) } }],
158
+ }),
159
+ },
160
+ }
161
+ }
162
+ ```
163
+
164
+ `richUpload` is a content of its own, like `text` or `photo`: a message has it
165
+ or `rich`, never both, and `rich` stays the Bot API's inline type. The runtime
166
+ calls `build` for each send or content edit. It can return a
167
+ promise. A resend needs a fresh file if its stream was consumed. A render
168
+ with the same content key skips the upload, including when it edits the
169
+ keyboard. Storage holds the fingerprint. For a URL or a Telegram `file_id`,
170
+ pass the Bot API rich object as `rich`.
171
+
141
172
  ## Outcomes
142
173
 
143
174
  A load, an action and an input handler answer with an outcome, built by
@@ -194,6 +225,15 @@ When Telegram refuses a step:
194
225
  renders. The next update repairs the rest. A receipt or a remark Telegram
195
226
  refuses stops the update the same way, with the view already drawn recorded.
196
227
 
228
+ If Telegram refuses the first send, the previous menu keeps its message IDs,
229
+ buttons and input routing. When an edit has an uncertain result, the next
230
+ render checks that message again. If repeated interrupted transitions would
231
+ exceed the chat record's recovery limit, the runtime cleans up the latest
232
+ failed attempt's new sends. A later press can retry the full transition.
233
+ One case the record cannot hold: a send Telegram carried out but whose answer
234
+ was lost has no id to record, so that message stays in the chat until the user
235
+ removes it.
236
+
197
237
  A view is checked before anything is sent: at most 100 messages, keys of 1 to
198
238
  64 characters, at most 100 buttons whose address is kept in the record. A view
199
239
  past these fails in the handler's place, with the chat untouched.
@@ -247,7 +287,9 @@ Called from inside a handler of the same chat, it runs at once rather than
247
287
  waiting behind the update that called it, and the screen it opened stands: the
248
288
  handler may still answer the press with a toast, and returning a navigation or
249
289
  a notice as well is an error — drawn after it, the handler's own outcome would
250
- put the record back on the screen the chat left.
290
+ put the record back on the screen the chat left. An open that fails inside a
291
+ handler rejects there: the failure is the handler's, and `onError` hears it
292
+ once, with the handler's trigger.
251
293
 
252
294
  ## State and concurrency
253
295
 
@@ -274,7 +316,7 @@ refused halfway too.
274
316
  | `callbackPrefix` | `~` | what every screen button's `callback_data` starts with |
275
317
  | `chats` | `'private'` | `'all'` answers in groups too, where any member can press or type |
276
318
  | `onStale(c)` | answered silently | a press nothing can answer, with its `reason`; its outcome is shown |
277
- | `onError(error, c)` | none | a load, action or input that threw; its outcome is shown |
319
+ | `onError(error, c)` | none | a load, action, input or display that threw. Its outcome is shown. |
278
320
  | `onEvent(event)` | none | `transition`, `state-discarded`, `message-kept`, `sweep-failed` (a remark's timer could not delete it) — never message text |
279
321
  | `clock` | `Date.now` | the time expiring remarks are measured by |
280
322
 
@@ -283,6 +325,19 @@ Without `onError` the press is answered silently and the error reaches
283
325
  timers on the way down; a remark left behind is removed on the chat's next
284
326
  update.
285
327
 
328
+ A view Telegram refused is not drawn again by the report of its refusal:
329
+ after a failed display `stay()` leaves the chat as its record says and only
330
+ delivers the toast and the notices, so the refused request is sent once and
331
+ the next press retries it. `go()` and `back()` are followed as usual. A
332
+ handler that threw changed nothing in the chat, so after it `stay()` loads
333
+ and draws its screen anew.
334
+
335
+ A press is answered before its view is drawn, so a toast for a failed display
336
+ comes too late to be the answer. In a private chat it is said as a remark of
337
+ the screen — escaped text under the menu that leaves with the next view sent,
338
+ or after 30 seconds. In a group it is an ephemeral message only the user who
339
+ pressed receives.
340
+
286
341
  ## Security
287
342
 
288
343
  - **A group's `load` checks access** for every screen, action and input under
@@ -321,7 +376,7 @@ refuse a call, `deleteByUser`, `pressData` for a forged press and
321
376
 
322
377
  ## Not included
323
378
 
324
- Reply keyboards, inline mode, media uploads (`InputFile`) in a view, showing a
379
+ Reply keyboards, inline mode, uploads for standalone media messages, showing a
325
380
  screen without an update (use `screens.button` in a notification), converting
326
381
  an incoming message to HTML, and a history stack.
327
382
 
@@ -350,7 +405,7 @@ the whole dependency. → ADR 0211 — [guide](../guide/telegram-screens.md)
350
405
  | `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) |
351
406
  | `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` |
352
407
  | `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 |
353
- | `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` |
408
+ | `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 |
354
409
  | `link` / `back` / `ScreenButton` | function / class | a button to a screen with its params; a button to the parent screen |
355
410
  | `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? }` |
356
411
  | `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-full.txt CHANGED
@@ -11068,6 +11068,17 @@ type, not a bound, so a bare integer prints `<integer>`, `.min(1)` prints `>=1`
11068
11068
  `.positive()` prints `>0`. Unbounded fields keep just their type and description. Bounds on an array's items are not bounds
11069
11069
  on the array itself.
11070
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 named format
11076
+ keeps its name with a pattern beside it — `z.uuid().regex(…)`, or a discovered
11077
+ server's `"format": "uuid"` with its own `"pattern"` — and prints `[uuid]`. A
11078
+ discovered argument prints the format its server declared, whichever it is:
11079
+ `[time]`, `[uri-reference]`, `[idn-email]`. A string that composes two patterns
11080
+ under no standard format prints both under `all of:`.
11081
+
11071
11082
  Composed schemas retain their meaning: `any of:` and `one of:` separate
11072
11083
  alternative branches with `|`, while `all of:` joins constraints with `&`.
11073
11084
  For example, a nullable bounded string renders
@@ -17550,6 +17561,37 @@ bot.catch((error) => logger.error('update failed', { error }))
17550
17561
  message is sent with `parse_mode: 'HTML'` set explicitly, so an application's
17551
17562
  own `parse_mode` transformer changes nothing.
17552
17563
 
17564
+ ### Uploading a rich preview
17565
+
17566
+ For a local photo, a message is `richUpload`: a `contentKey` and a `build` function. The key
17567
+ identifies the complete rich payload. Change it when the file bytes, text or
17568
+ order of blocks changes. The outer message `key` identifies the Telegram
17569
+ message that can be edited in place.
17570
+
17571
+ ```ts
17572
+ import { InputFile } from 'grammy'
17573
+ import type { RichUploadViewMessage } from 'stitchkit/telegram/screens'
17574
+
17575
+ function preview(path: string, revision: string): RichUploadViewMessage {
17576
+ return {
17577
+ richUpload: {
17578
+ contentKey: revision,
17579
+ build: () => ({
17580
+ blocks: [{ type: 'photo', photo: { type: 'photo', media: new InputFile(path) } }],
17581
+ }),
17582
+ },
17583
+ }
17584
+ }
17585
+ ```
17586
+
17587
+ `richUpload` is a content of its own, like `text` or `photo`: a message has it
17588
+ or `rich`, never both, and `rich` stays the Bot API's inline type. The runtime
17589
+ calls `build` for each send or content edit. It can return a
17590
+ promise. A resend needs a fresh file if its stream was consumed. A render
17591
+ with the same content key skips the upload, including when it edits the
17592
+ keyboard. Storage holds the fingerprint. For a URL or a Telegram `file_id`,
17593
+ pass the Bot API rich object as `rich`.
17594
+
17553
17595
  ## Outcomes
17554
17596
 
17555
17597
  A load, an action and an input handler answer with an outcome, built by
@@ -17606,6 +17648,15 @@ When Telegram refuses a step:
17606
17648
  renders. The next update repairs the rest. A receipt or a remark Telegram
17607
17649
  refuses stops the update the same way, with the view already drawn recorded.
17608
17650
 
17651
+ If Telegram refuses the first send, the previous menu keeps its message IDs,
17652
+ buttons and input routing. When an edit has an uncertain result, the next
17653
+ render checks that message again. If repeated interrupted transitions would
17654
+ exceed the chat record's recovery limit, the runtime cleans up the latest
17655
+ failed attempt's new sends. A later press can retry the full transition.
17656
+ One case the record cannot hold: a send Telegram carried out but whose answer
17657
+ was lost has no id to record, so that message stays in the chat until the user
17658
+ removes it.
17659
+
17609
17660
  A view is checked before anything is sent: at most 100 messages, keys of 1 to
17610
17661
  64 characters, at most 100 buttons whose address is kept in the record. A view
17611
17662
  past these fails in the handler's place, with the chat untouched.
@@ -17659,7 +17710,9 @@ Called from inside a handler of the same chat, it runs at once rather than
17659
17710
  waiting behind the update that called it, and the screen it opened stands: the
17660
17711
  handler may still answer the press with a toast, and returning a navigation or
17661
17712
  a notice as well is an error — drawn after it, the handler's own outcome would
17662
- put the record back on the screen the chat left.
17713
+ put the record back on the screen the chat left. An open that fails inside a
17714
+ handler rejects there: the failure is the handler's, and `onError` hears it
17715
+ once, with the handler's trigger.
17663
17716
 
17664
17717
  ## State and concurrency
17665
17718
 
@@ -17686,7 +17739,7 @@ refused halfway too.
17686
17739
  | `callbackPrefix` | `~` | what every screen button's `callback_data` starts with |
17687
17740
  | `chats` | `'private'` | `'all'` answers in groups too, where any member can press or type |
17688
17741
  | `onStale(c)` | answered silently | a press nothing can answer, with its `reason`; its outcome is shown |
17689
- | `onError(error, c)` | none | a load, action or input that threw; its outcome is shown |
17742
+ | `onError(error, c)` | none | a load, action, input or display that threw. Its outcome is shown. |
17690
17743
  | `onEvent(event)` | none | `transition`, `state-discarded`, `message-kept`, `sweep-failed` (a remark's timer could not delete it) — never message text |
17691
17744
  | `clock` | `Date.now` | the time expiring remarks are measured by |
17692
17745
 
@@ -17695,6 +17748,19 @@ Without `onError` the press is answered silently and the error reaches
17695
17748
  timers on the way down; a remark left behind is removed on the chat's next
17696
17749
  update.
17697
17750
 
17751
+ A view Telegram refused is not drawn again by the report of its refusal:
17752
+ after a failed display `stay()` leaves the chat as its record says and only
17753
+ delivers the toast and the notices, so the refused request is sent once and
17754
+ the next press retries it. `go()` and `back()` are followed as usual. A
17755
+ handler that threw changed nothing in the chat, so after it `stay()` loads
17756
+ and draws its screen anew.
17757
+
17758
+ A press is answered before its view is drawn, so a toast for a failed display
17759
+ comes too late to be the answer. In a private chat it is said as a remark of
17760
+ the screen — escaped text under the menu that leaves with the next view sent,
17761
+ or after 30 seconds. In a group it is an ephemeral message only the user who
17762
+ pressed receives.
17763
+
17698
17764
  ## Security
17699
17765
 
17700
17766
  - **A group's `load` checks access** for every screen, action and input under
@@ -17733,7 +17799,7 @@ refuse a call, `deleteByUser`, `pressData` for a forged press and
17733
17799
 
17734
17800
  ## Not included
17735
17801
 
17736
- Reply keyboards, inline mode, media uploads (`InputFile`) in a view, showing a
17802
+ Reply keyboards, inline mode, uploads for standalone media messages, showing a
17737
17803
  screen without an update (use `screens.button` in a notification), converting
17738
17804
  an incoming message to HTML, and a history stack.
17739
17805
 
@@ -25619,7 +25685,7 @@ the whole dependency. → ADR 0211 — [guide](../guide/telegram-screens.md)
25619
25685
  | `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) |
25620
25686
  | `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` |
25621
25687
  | `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 |
25622
- | `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` |
25688
+ | `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 |
25623
25689
  | `link` / `back` / `ScreenButton` | function / class | a button to a screen with its params; a button to the parent screen |
25624
25690
  | `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? }` |
25625
25691
  | `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
@@ -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.1 KB → [llms/cli.2.txt](llms/cli.2.txt) 42.9 KB
24
+ - **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 44.9 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) 21.2 KB
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.2",
3
+ "version": "0.124.4",
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",
@@ -1,46 +0,0 @@
1
- // src/json-schema/json-schema.ts
2
- import { z } from "zod";
3
- function toJsonSchema(schema, io, unrepresentable = "throw", target = "draft-2020-12") {
4
- return z.toJSONSchema(schema, {
5
- io,
6
- target,
7
- unrepresentable,
8
- cycles: "ref"
9
- });
10
- }
11
- function isObjectNode(value) {
12
- return typeof value === "object" && value !== null && !Array.isArray(value);
13
- }
14
- function jsonSchemaFields(jsonSchema) {
15
- const properties = jsonSchema.properties;
16
- if (!isObjectNode(properties)) {
17
- const conjunctive = Array.isArray(jsonSchema.allOf);
18
- const members = conjunctive ? jsonSchema.allOf : Array.isArray(jsonSchema.oneOf) ? jsonSchema.oneOf : Array.isArray(jsonSchema.anyOf) ? jsonSchema.anyOf : [];
19
- const byName = new Map;
20
- for (const member of Array.isArray(members) ? members : []) {
21
- if (!isObjectNode(member))
22
- continue;
23
- for (const field of jsonSchemaFields(member)) {
24
- const existing = byName.get(field.name);
25
- const required = existing ? conjunctive ? existing.required || field.required : existing.required && field.required : field.required;
26
- byName.set(field.name, existing ? { ...field, required } : field);
27
- }
28
- }
29
- return [...byName.values()];
30
- }
31
- const required = new Set(Array.isArray(jsonSchema.required) ? jsonSchema.required.filter((k) => typeof k === "string") : []);
32
- const fields = [];
33
- for (const [name, raw] of Object.entries(properties)) {
34
- const schema = isObjectNode(raw) ? raw : {};
35
- const description = typeof schema.description === "string" ? schema.description : undefined;
36
- fields.push({
37
- name,
38
- schema,
39
- required: required.has(name),
40
- ...description && { description }
41
- });
42
- }
43
- return fields;
44
- }
45
-
46
- export { toJsonSchema, jsonSchemaFields };