Commit 4b86b72
authored
feat(P060): rename REMOVE_FIELDS->DELETE_FIELDS and DELETE_PAGE->DELETE_PAGES (array) (#33)
## Background
Cleanup pass on the copilot bridge + LLM-tool adapter. Pairs with the
matching top-level repo PR
([SimplePDF/simple-pdf#196](SimplePDF/simple-pdf#196))
which carries the editor / e2e changes.
The bridge now owns the iframe contract end-to-end (Zod schemas +
descriptions + parsing). The adapter is a one-line-per-tool router.
## Changes
**Bridge owns the contract**
- New `embed-bridge/schemas.ts` — single source of truth: one Zod schema
per iframe operation, each with `.describe()`. Snake_case keys
throughout (matches the wire).
- `IframeBridge` methods accept `unknown` and validate internally via
`parseAndSend(Schema, 'EVENT', args)`. Bad input → `bad_input` without a
postMessage round-trip.
- `BridgeResult.error.code` is now a typed union with autocomplete for
bridge-owned codes.
**Adapter is thin**
- `dispatch.ts`, `safeDispatch`, `client-tools/schemas.ts`, and the
redundant `isClientToolName` runtime narrow are gone.
- New `tools.ts` enumerates LLM tool names and pulls descriptions
verbatim from the bridge schemas (no duplicated text).
- `factory.ts` switch terminus is pure routing — every arm is one line;
`satisfies never` keeps it exhaustive.
- `chat.ts` and `transport.ts` drop ~50 lines each: tool registration is
now `tools: withFinalisationTool(LLM_STATIC_TOOLS)`.
**Dead code pruned**
- `bridge.createField` + `CreateFieldArgs` removed (no LLM tool, no
other consumer).
- `chat.toolInvocation.names.create_field` i18n key dropped from all 23
locales.
- `createLlmFieldBaselineMiddleware` + `markFieldAsKnown` plumbing
removed (the `create_field` tool was never registered).
**Iframe contract rename** (also part of this PR)
- `REMOVE_FIELDS` → `DELETE_FIELDS` (response `removed_count` →
`deleted_count`).
- `DELETE_PAGE { page }` → `DELETE_PAGES { pages: number[] }`.
**React SDK (BREAKING)**
- `actions.removeFields` → `actions.deleteFields`; `removed_count` →
`deleted_count`. Major-version changeset added.
Net: `+388 / -674` lines on `copilot/`. Adding a new bridge operation is
now: schema in `schemas.ts`, method on `IframeBridge`, `parseAndSend`
line in `bridge.ts`. Exposing it to the LLM: one entry in
`LLM_STATIC_TOOLS`, one switch arm in `factory.ts`. The `satisfies
never` exhaustiveness catches drift at compile time.1 parent 6a2ab0a commit 4b86b72
46 files changed
Lines changed: 470 additions & 717 deletions
File tree
- .changeset
- copilot/src
- components/chat
- hooks
- lib
- byok
- embed-bridge-adapters/client-tools
- embed-bridge
- locales
- routes/api
- server
- documentation
- react
- src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | 327 | | |
347 | 328 | | |
348 | 329 | | |
| |||
550 | 531 | | |
551 | 532 | | |
552 | 533 | | |
553 | | - | |
| 534 | + | |
554 | 535 | | |
555 | 536 | | |
556 | 537 | | |
| |||
640 | 621 | | |
641 | 622 | | |
642 | 623 | | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
647 | 628 | | |
648 | 629 | | |
649 | | - | |
| 630 | + | |
650 | 631 | | |
651 | 632 | | |
652 | 633 | | |
| |||
665 | 646 | | |
666 | 647 | | |
667 | 648 | | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | 649 | | |
674 | 650 | | |
675 | 651 | | |
| |||
684 | 660 | | |
685 | 661 | | |
686 | 662 | | |
687 | | - | |
| 663 | + | |
688 | 664 | | |
689 | 665 | | |
690 | 666 | | |
| |||
Lines changed: 2 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 33 | | |
39 | 34 | | |
40 | 35 | | |
| |||
53 | 48 | | |
54 | 49 | | |
55 | 50 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 51 | | |
65 | 52 | | |
66 | 53 | | |
67 | 54 | | |
68 | 55 | | |
69 | 56 | | |
70 | 57 | | |
71 | | - | |
| 58 | + | |
72 | 59 | | |
73 | 60 | | |
74 | 61 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 62 | | |
82 | 63 | | |
83 | 64 | | |
| |||
145 | 126 | | |
146 | 127 | | |
147 | 128 | | |
148 | | - | |
149 | | - | |
150 | 129 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 5 | + | |
16 | 6 | | |
17 | 7 | | |
18 | 8 | | |
| |||
93 | 83 | | |
94 | 84 | | |
95 | 85 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 86 | + | |
148 | 87 | | |
149 | 88 | | |
150 | 89 | | |
| |||
Lines changed: 0 additions & 155 deletions
This file was deleted.
0 commit comments