@zackbart/connecta 0.18.3 → 0.19.0

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 (69) hide show
  1. package/CHANGELOG.md +73 -4
  2. package/dist/catalog-service.d.ts +16 -13
  3. package/dist/catalog-service.js +106 -115
  4. package/dist/catalog.js +29 -46
  5. package/dist/connector-scope.js +2 -7
  6. package/dist/connectors/api.d.ts +4 -16
  7. package/dist/connectors/api.js +19 -46
  8. package/dist/connectors/guarded-fetch.d.ts +9 -23
  9. package/dist/connectors/guarded-fetch.js +38 -76
  10. package/dist/connectors/remote-mcp.js +36 -79
  11. package/dist/errors.d.ts +6 -27
  12. package/dist/errors.js +8 -5
  13. package/dist/execute.d.ts +24 -22
  14. package/dist/execute.js +98 -145
  15. package/dist/executor-result.d.ts +1 -0
  16. package/dist/executor-result.js +4 -11
  17. package/dist/executors/quickjs-child.js +1 -3
  18. package/dist/executors/quickjs-runtime.js +1 -3
  19. package/dist/executors/quickjs.js +1 -3
  20. package/dist/index.js +27 -57
  21. package/dist/invocation.js +113 -183
  22. package/dist/meta-tools.d.ts +15 -28
  23. package/dist/meta-tools.js +33 -89
  24. package/dist/providers/cloudflare.d.ts +2 -18
  25. package/dist/providers/cloudflare.js +1460 -2451
  26. package/dist/providers/linear.d.ts +4 -41
  27. package/dist/providers/linear.js +8 -39
  28. package/dist/providers/mixpanel.d.ts +3 -25
  29. package/dist/providers/mixpanel.js +7 -22
  30. package/dist/providers/notion.d.ts +1 -15
  31. package/dist/providers/notion.js +44 -173
  32. package/dist/providers/revenuecat.d.ts +4 -57
  33. package/dist/providers/revenuecat.js +10 -93
  34. package/dist/providers/stripe.d.ts +1 -12
  35. package/dist/providers/stripe.js +7 -45
  36. package/dist/registry.d.ts +9 -34
  37. package/dist/registry.js +9 -103
  38. package/dist/routes/mcp.js +1 -1
  39. package/dist/routes/oauth.js +3 -3
  40. package/dist/routes/shared.d.ts +15 -15
  41. package/dist/routes/shared.js +1 -3
  42. package/dist/timeout.d.ts +8 -7
  43. package/dist/timeout.js +47 -38
  44. package/dist/types.d.ts +3 -3
  45. package/dist/ui.d.ts +1 -25
  46. package/dist/ui.js +18 -45
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/documentation/call-admission.md +1 -1
  50. package/documentation/cloudflare.md +1 -1
  51. package/documentation/code-mode.md +7 -7
  52. package/documentation/connectors.md +24 -1
  53. package/documentation/linear.md +1 -1
  54. package/documentation/mixpanel.md +1 -1
  55. package/documentation/notion.md +1 -1
  56. package/documentation/operations.md +18 -14
  57. package/documentation/provider-conventions.md +1 -1
  58. package/documentation/revenuecat.md +1 -1
  59. package/documentation/stripe.md +1 -1
  60. package/documentation/upgrading.md +13 -4
  61. package/ethos.md +75 -121
  62. package/package.json +3 -4
  63. package/templates/node/package.json +1 -1
  64. package/documentation/code-first-exploration.md +0 -292
  65. package/documentation/mcp-2026-07-28.md +0 -46
  66. package/documentation/mcp-ui-design.md +0 -382
  67. package/documentation/program-ui-read-calls.md +0 -213
  68. package/documentation/provider-audit.md +0 -198
  69. package/documentation/rich-output-design.md +0 -211
@@ -1,382 +0,0 @@
1
- # MCP UI from programs — design record
2
-
3
- The decision record for
4
- [#266](https://github.com/zackbart/connecta/issues/266): whether and how an
5
- `execute_code` program may deliver a *rendered view* to the client, and what a
6
- program is allowed to hand the host in order to get one. The verdicts live in
7
- [`ethos.md`](../ethos.md); this document carries the argument, the contract
8
- precisely enough to implement, and the shapes that were considered, refused, or
9
- gated.
10
-
11
- It extends the [rich-output design record](./rich-output-design.md)
12
- ([#267](https://github.com/zackbart/connecta/issues/267)) rather than restating
13
- it. That record's contract clauses (`M1`–`M10`, now normative in
14
- [`code-mode.md`](./code-mode.md)'s "Emitted output" section) are cited here,
15
- not repeated; where the two overlap — provider-bridge delivery, budgets,
16
- success-only delivery, payload-free diagnostics — this record follows the
17
- precedent instead of inventing a parallel one. The implementation landed via
18
- [#277](https://github.com/zackbart/connecta/issues/277): the clauses below
19
- (`U1`–`U11`) are now normative in [`code-mode.md`](./code-mode.md)'s "Rendered
20
- output" section, which wins where the two disagree. This document remains the
21
- argument and the record of rejected shapes.
22
-
23
- ## The problem
24
-
25
- `connecta.emit` gave programs pixels. It did not give them a *view*. A program
26
- that assembles a comparison table, a chart, or a diffed record can emit it as
27
- text the model re-reads, or as an image it can no longer inspect; what it
28
- cannot do is hand the client something the human looks at directly while the
29
- model keeps its cheap textual summary. That is a real gap for the surface
30
- connecta calls primary: the program is where composition already happens, and
31
- composed output is exactly the output worth rendering.
32
-
33
- MCP grew an answer to this, and the ethos anticipated it. The gated row for
34
- guest-emitted `resource` / `resource_link` blocks reserved MCP UI as the one
35
- possible carve-out, with the constraint written in advance: *programs supply
36
- only content, connecta mints the `ui://` address outside the sandbox.* The
37
- lure defense is the whole reason for the gate — a guest-minted URI is an
38
- address a helpful client may dereference, and generated code mints nothing.
39
-
40
- ### The spec moved
41
-
42
- The gate was drafted against the shape mcp-ui had at the time: the server mints
43
- a per-request `ui://` URI and embeds a `UIResource` block inline in the tool
44
- result. That shape is now the *legacy* path, explicitly superseded upstream and
45
- still rendered by hosts that also support the official path — Goose, Postman,
46
- MCPJam — plus a few that do not: Nanobot, LibreChat. The claim that matters is
47
- narrower and unaffected: Claude.ai, ChatGPT, and VS Code Copilot render only
48
- the official shape.
49
-
50
- The official replacement is the **MCP Apps extension**
51
- (`io.modelcontextprotocol/ui`, launched 2026-01-26,
52
- [specification](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx),
53
- [overview](https://modelcontextprotocol.io/extensions/apps/overview)), and it
54
- inverts the delivery model in a way that happens to suit a stateless
55
- aggregator:
56
-
57
- - A tool **pre-declares a static UI template** through tool metadata,
58
- `_meta.ui.resourceUri`, pointing at a `ui://` URI. (The flat form
59
- `_meta["ui/resourceUri"]` is deprecated.)
60
- - The template's mimeType MUST be `text/html;profile=mcp-app` and its body MUST
61
- be a valid HTML5 document. External URLs (`text/uri-list`) are the one type on
62
- the spec's deferred list; remote-DOM was never adopted into the official spec
63
- at all.
64
- - The host MUST use `resources/read` to fetch the referenced URI, and MAY
65
- prefetch and cache it. A permission the spec hands hosts is a permission to
66
- assume they use, so a template change means a new URI — version the address.
67
- - Servers MAY omit UI-only resources from `resources/list` entirely — the
68
- omission is from the *listing*, not from the method. A handler that answers
69
- exactly one static URI and lists nothing needs no state: the URI reaches the
70
- host through tool metadata, so the listing has nothing to carry and there is
71
- no session to keep.
72
- - Per-call data reaches the rendered view over postMessage: the host delivers
73
- the full tool result to the view via `ui/notifications/tool-result`. Result
74
- `_meta` is delivered to the view and, per the spec's best practices, is data
75
- "not intended for model context" — the established Apps convention, and how
76
- ChatGPT's Apps SDK behaves too. It is guidance, not a MUST.
77
- - Rendering is sandboxed by the host. Hosts MUST render in sandboxed iframes,
78
- and a template that declares no CSP domains gets the host's restrictive
79
- default: `default-src 'none'`, `connect-src 'none'`, `frame-src 'none'`. An
80
- undeclared template has no network, and no nested frame it could load by URL.
81
- - The extension MUST be explicitly negotiated. Servers declare it in their
82
- capability declaration, and per the client matrix a client acts on an
83
- extension only when both sides have declared it.
84
- - Support for the official shape spans Claude.ai, Claude Desktop, ChatGPT, VS
85
- Code Copilot, M365 Copilot, Goose, Postman, and Cursor, among others
86
- ([client matrix](https://modelcontextprotocol.io/extensions/client-matrix)).
87
-
88
- So the gate's premise dissolved on both ends. The shape it envisioned is the
89
- one nobody renders, and the shape everyone renders does not require connecta to
90
- mint anything per request — which turns out to be a *stricter* posture than the
91
- gate asked for, not a looser one.
92
-
93
- ## The shape: `connecta.ui(html)` and one static shell
94
-
95
- One new provider function, `connecta.ui(html)`, plus one static, connecta-
96
- authored MCP Apps shell template. The program supplies HTML content and nothing
97
- else. The only `ui://` URI anywhere in the system is connecta's shell, minted
98
- at build time and identical for every deployment and every request; the
99
- program's HTML never becomes a URI at all. It rides the tool result in `_meta`,
100
- which hosts keep out of model context, and the shell renders it inside the
101
- client's sandboxed iframe.
102
-
103
- That is the whole design, and it satisfies the gate's constraint more strongly
104
- than the gate's own sketch did. The gate would have allowed connecta to mint an
105
- address per request from program-supplied bytes; here the program's content
106
- never becomes addressable at all. Nothing a client could dereference is derived
107
- from anything a program said.
108
-
109
- Two structural consequences follow, both borrowed rather than invented. First,
110
- `connecta.ui` is a provider function in the same `fns` object as
111
- `connecta.emit`, so `ExecuteResult` stays `{ result, error?, logs? }` and the
112
- `Executor` contract is untouched — the parity guarantee `M8` describes applies
113
- verbatim. Second, the shell ships as a build-time string constant in core, not
114
- a file read at startup: import-graph purity means no `node:fs`, and the same
115
- bytes have to serve on Workers.
116
-
117
- ### Contract (drafts for code-mode.md)
118
-
119
- **U1.** `connecta.ui(html)` accepts exactly one argument: a non-empty string of
120
- HTML. Anything else — a non-string, an empty string, an options bag, an MCP
121
- block object — throws a catchable error and nothing is accepted. There is no
122
- options parameter and no sugar form, for `M1`'s reason: sugar is how a
123
- one-shape contract grows hair.
124
-
125
- **U2.** At most one payload per run. A second `connecta.ui` call throws
126
- catchably, naming the constraint; the first accepted payload stands. One tool
127
- result renders one view, and last-wins would silently discard a payload the
128
- program deliberately supplied.
129
-
130
- **U3.** The payload is delivered on success only, and out of model context: the
131
- tool result gains `_meta["connecta/ui"] = { html }`, and the JSON envelope
132
- gains `ui: true` so the model learns a view rendered without seeing its bytes.
133
- `_meta` is where the Apps spec's best practices put data "not intended for
134
- model context", and it is how shipped hosts behave — guidance plus observed
135
- behavior, not a protocol property; nothing in the spec makes it a MUST.
136
- `structuredContent` remains the envelope alone. The wire key is a plain
137
- single-label prefix rather than the reverse-DNS form MCP's SHOULD prefers, and
138
- that is a choice: connecta has no domain to reverse, and fabricating one to
139
- satisfy a SHOULD would be a worse answer than the single-label prefix the key
140
- format's MUST already permits. A program that never calls `connecta.ui`
141
- produces today's byte-for-byte response (`R6`). A program that ends in an error
142
- delivers no payload; the error envelope reports `uiDiscarded: true` only when a
143
- payload had been accepted — a field on the structured envelope, a trailing line
144
- on the plain-text paths — and it coexists with `emittedDiscarded: N` when one
145
- failure discards both.
146
-
147
- **U4.** The payload spends the existing aggregate emit byte budget
148
- (`ConnectaConfig.execute.maxEmittedBytes`, default 4,000,000), measured at the
149
- call as the serialized bytes of `{ html }` — the same measurement `M5` applies
150
- to a block. Over budget throws catchably, naming the budget and the room
151
- remaining, with nothing partially accepted. It does not spend the block-count
152
- budget (`maxEmittedBlocks`) — it is not a block — and it does not spend the
153
- host-call budget (`L4`). One transport bound covers everything rich a program
154
- delivers; no new knob.
155
-
156
- **U5.** One static shell: a connecta-authored HTML5 document at
157
- `ui://connecta/program-ui/v1`, mimeType `text/html;profile=mcp-app`, declared
158
- on `execute_code` via `_meta.ui.resourceUri` together with an explicit
159
- `_meta.ui.visibility: ["model"]`, and served by a `resources/read` handler that
160
- answers exactly that URI and fails on any other. The handler registers on the
161
- `McpServer` in `src/routes/mcp.ts`, which is what puts the `resources`
162
- capability into the discovery response — so `resources/list` is served too, and
163
- returns an empty list. That is the Apps spec's permitted omission of UI-only
164
- resources from listing, taken exactly: the capability stays honest because the
165
- method answers, and nothing downstream is ever listed or aggregated.
166
- `visibility` is declared rather than left to default because the default
167
- `["model","app"]` would tell hosts the view may call `execute_code` over
168
- `tools/call` — the thing the view-initiated-calls gate defers. The version
169
- segment bumps whenever the shell's bytes change, because hosts cache templates
170
- by URI.
171
-
172
- **U6.** The shell is display-only. It renders the payload in a nested iframe
173
- (`srcdoc`, `sandbox="allow-scripts"`, no `allow-same-origin`) and declares no
174
- CSP domains, so the host applies its restrictive default. That default includes
175
- `frame-src 'none'`, which forbids nested frames loaded from a *URL* — which is
176
- exactly why the payload frame is `srcdoc` and not an address. `about:srcdoc` is
177
- not matched by `frame-src`; it inherits the embedding document's policy
178
- instead. So the inner frame is *permitted* by the documented behavior of the
179
- directive that would otherwise forbid it, and *offline* by the same
180
- inheritance: it gets the shell's `default-src 'none'; connect-src 'none'`.
181
- Program UI therefore gets scripts and local interactivity and nothing else: no
182
- network, no tool calls, no conversation messages, no host-mediated links. The
183
- shell participates in the Apps lifecycle — initialize, tool-result,
184
- size-changed — and forwards no channel whatsoever from the inner frame to the
185
- host.
186
-
187
- **U7.** Structural executor parity, per `M8`. `connecta.ui` is a provider
188
- function; `ExecuteResult` and the `Executor` interface are unchanged; QuickJS
189
- and the Dynamic Worker get it through the bridge they already have, without
190
- modification.
191
-
192
- **U8.** Request-local and unstreamed, per `M9`. The payload exists only in the
193
- finished response, and `connecta.ui` resolving means "accepted," never
194
- "rendered."
195
-
196
- **U9.** With `diagnostics: true` the diagnostics block gains a distinct `ui`
197
- aggregate carrying the payload's byte size — a number, nothing else — present
198
- only when a payload was accepted. UI bytes are not folded into the `emitted`
199
- aggregate `M10` describes: that one pairs a block count with the bytes those
200
- blocks cost, and adding bytes without a block would desync the pair. Activity
201
- stays payload-free by construction (`R8`, `M10`).
202
-
203
- **U10.** `_meta.ui.resourceUri` is declared on `execute_code` unconditionally.
204
- A host without the extension ignores unknown `_meta` and sees the ordinary
205
- envelope, which *is* the text fallback the Apps spec mandates. `connecta.ui`
206
- never fails because a client cannot render: a stateless aggregator cannot
207
- reliably know, and connecta is not a nanny.
208
-
209
- **U11.** connecta declares `io.modelcontextprotocol/ui` in its server
210
- capability declaration — `capabilities.extensions` on the `initialize` path,
211
- the `server/discover` response on the 2026-07-28 one — and that is the one
212
- extension it advertises. The Apps extension must be explicitly negotiated, and
213
- a conforming client acts on an extension only when both sides declare it: with
214
- no declaration from connecta, no host reads `_meta.ui.resourceUri`, no host
215
- fetches the shell, and the whole design is inert. The declaration is part of
216
- the contract, not an implementation option.
217
-
218
- Negotiation runs in two directions, and this design takes one and refuses the
219
- other. **Declaring** is required — `U11` — and it is what makes the
220
- [revision inventory](./mcp-2026-07-28.md)'s decline of the versioned extensions
221
- framework a decline of that framework *as a general surface*, not a blanket
222
- refusal to name an extension. **Reading the client's** declaration in order to
223
- register tool metadata conditionally stays refused ("Capability-conditional
224
- tool metadata", below), and that refusal declines a spec SHOULD — servers
225
- SHOULD check client capabilities before registering UI-enabled tools — which is
226
- worth saying out loud rather than eliding. A per-request stateless aggregator
227
- has no dependable place to hold the check; unknown `_meta` is ignored by spec;
228
- and `U10`'s envelope is already the fallback the spec mandates. The SHOULD
229
- would buy a guarantee the protocol gives away.
230
-
231
- ## Sizing rationale
232
-
233
- The [rich-output record](./rich-output-design.md#sizing-rationale) draws the
234
- line that matters here: the 24,000-character return bound is a *context*
235
- budget, and the emit byte budget is a *transport* bound. A UI payload is
236
- transport in the purest form yet — it rides `_meta`, which hosts deliver to the
237
- view and, following the spec's best-practice guidance, keep out of the model's
238
- window. On a host that behaves that way, the `ui: true` marker is the entire
239
- context cost of a rendered view: one boolean.
240
-
241
- Which is why it does not get its own budget. The reason `emit` has one is
242
- transport, not context, and a UI payload competes for the same wire; giving
243
- it a second knob would ask operators to reason about a distinction that does
244
- not exist downstream of the response body. It spends the aggregate and leaves
245
- the block count alone, because a payload that is not a block should not consume
246
- a block.
247
-
248
- ## Security posture
249
-
250
- - **Nothing is minted — more strictly than the gate demanded.** The gate would
251
- have permitted connecta to mint a per-request URI over program bytes. Here
252
- the program's content never becomes an addressable resource at all. The one
253
- `ui://` URI in the system is a build-time constant with no program input in
254
- it, so there is no address a program can influence and nothing for a client
255
- to dereference on a program's behalf.
256
- - **No bridge means no capability path.** `U6`'s shell forwards nothing from
257
- the inner frame to the host. A program-authored UI cannot call tools, reach
258
- the network, post conversation messages, or open host-mediated links, so
259
- hostile emitted HTML is inert beyond its own pixels. The invariant holds by
260
- construction rather than by validation: there is no channel to abuse.
261
- - **The restrictive default CSP is the offline guarantee, and the inner frame
262
- lives inside it rather than around it.** Declaring no CSP domains means
263
- `default-src 'none'`, `connect-src 'none'`, and `frame-src 'none'` — that
264
- last directive forbids the nested frame the design depends on if the frame
265
- has a URL, which is why it has none. `about:srcdoc` is not matched by
266
- `frame-src` and inherits the embedding document's policy, so the payload
267
- frame is permitted and offline by the same rule. That is a dependency on
268
- documented behavior, not something connecta enforces: hosts MAY tighten
269
- further, and MAY override the inner `sandbox` attribute, either of which
270
- could close the gap the shell rides through. If one does, the `v1` segment in
271
- the shell URI is the escape hatch — a new shell at a new address is a version
272
- bump, not a redesign. Program UI is offline because the host makes it
273
- offline, not because connecta scanned the HTML for `fetch`.
274
- - **Model-invisibility is host behavior, not a protocol guarantee.** The spec's
275
- only statement on it is a non-normative best practice — `_meta` carries data
276
- "not intended for model context" — with no MUST and no enforcement. Shipped
277
- hosts honor it. A host that does not receives up to the full byte budget of
278
- program-authored HTML as model context, which is an expensive turn rather
279
- than a capability leak, but it is the honest failure mode of `U3` and the
280
- reason the sizing argument rests on transport rather than on a promise of
281
- free context.
282
- - **HTML-borne injection is the existing class.** Hostile text inside a
283
- rendered view is the same hazard as hostile text inside an emitted
284
- screenshot (`M6`, and `call_tool`'s block passthrough before it). All program
285
- output is untrusted input to the client; connecta claims no provenance and
286
- adds no claim otherwise.
287
- - **The lure defense stands.** Guest emission of `resource` and
288
- `resource_link` blocks becomes refused — it was gated on exactly this
289
- carve-out, and the carve-out did not need it. This design is not the
290
- exception that opens that door; it is the demonstration that the door was not
291
- needed.
292
-
293
- ## Considered, refused, and gated
294
-
295
- **Legacy embedded `UIResource` delivery** (a per-request minted `ui://` URI
296
- plus an inline resource block). Refused. It is superseded upstream and
297
- unrendered by Claude.ai, ChatGPT, and VS Code Copilot — the clients connecta
298
- deployments actually face — so it buys reach only with hosts that also support
299
- the official path. It also fights the caching model: per-request URIs are
300
- precisely what hosts are told they may prefetch and cache by URI. Building the
301
- carve-out the gate imagined would mean minting addresses from guest content in
302
- order to reach fewer clients.
303
-
304
- **Extending `connecta.emit` with a `{ type: "ui", html }` shape.** Refused.
305
- `M1` would need an asterisk (not an MCP block type), `M2` another (not appended
306
- to `content`, delivered through `_meta` instead), and `M5` a third (its own
307
- multiplicity, its own share of the budgets). Three exceptions to a settled
308
- contract to avoid one new function is a bad trade; a separate function leaves
309
- `M1`–`M10` exactly as they are.
310
-
311
- **Guest-supplied external URL frames** (`text/uri-list`). Refused. A
312
- guest-supplied URL is precisely the lure the gate exists to prevent — a program
313
- choosing what the client loads is a program minting an address by another
314
- route. The official spec deferred the type anyway, so the refusal costs
315
- nothing today and would cost the whole posture tomorrow.
316
-
317
- **Remote-DOM payloads.** Refused. Legacy-path-only, and never adopted into the
318
- official spec at all — it survives there as background prose, not as a deferred
319
- item with a queue position. Adopting a payload format the official spec never
320
- took, on the path the official spec superseded, is two bets on one square.
321
-
322
- **View-initiated tool calls from program UI.** This original gate was split by
323
- [#287](https://github.com/zackbart/connecta/issues/287) on 2026-08-02. Bounded
324
- refresh, pagination, and drill-down reads are accepted through named bindings
325
- and the existing `call_tool`; mutations remain gated. The evidence, threat
326
- trace, and boundary between live reads and Executor's artifact product live in
327
- [`program-ui-read-calls.md`](./program-ui-read-calls.md). The normative contract
328
- is `V1`–`V8` in [`code-mode.md`](./code-mode.md); it supersedes this record's
329
- display-only clauses where they disagree.
330
-
331
- **Downstream MCP Apps template passthrough** (downstream connectors declaring
332
- their own `ui://` templates, proxied through connecta's `resources/read`).
333
- Gated. It is a coherent shape, and it earns its way in when a downstream
334
- connector actually ships Apps templates. Until then it would be aggregation
335
- machinery for a population of zero — and `U5`'s narrow handler is deliberately
336
- narrow so that widening it later is a decision, not a diff.
337
-
338
- **Delivering UI from failed programs.** Refused, for `M4`'s argument: a view
339
- assembled before the failure may describe a world the error contradicts.
340
- Failure delivers the error, the logs, and an honest `uiDiscarded: true`.
341
-
342
- **Capability-conditional tool metadata** (declaring `_meta.ui.resourceUri` only
343
- when the client negotiated the extension). Refused, and knowingly against a
344
- spec SHOULD. Per-request statelessness makes the check unreliable, unknown
345
- `_meta` is ignored by spec, and the JSON envelope is already the fallback the
346
- Apps spec mandates. Conditional metadata would add a negotiation dependency to
347
- buy a guarantee the protocol already gives away.
348
-
349
- ## Verification sketch
350
-
351
- - Parity: one `connecta.ui` program through both vitest projects, identical
352
- `_meta` payload and envelope.
353
- - Validation: non-string, empty string, options bag, and a second call each
354
- throw catchably and accept nothing.
355
- - Budget: an over-budget payload fails at the call, naming the budget; emitted
356
- blocks and the UI payload draw on one aggregate.
357
- - Byte-for-byte: a program that never calls `connecta.ui` produces today's
358
- exact response.
359
- - Discard: a throwing program that had an accepted payload yields the error
360
- envelope with `uiDiscarded: true` and no `_meta` payload; a throwing program
361
- that never called `connecta.ui` reports no `uiDiscarded` at all.
362
- - Diagnostics: an accepted payload adds a `ui` byte aggregate distinct from
363
- `emitted`, and no aggregate appears when nothing was accepted.
364
- - Independence: a truncated return value, emitted blocks, and a UI payload
365
- coexist in one response.
366
- - `resources/read` serves exactly the shell URI with the correct mimeType and a
367
- valid HTML5 body, and fails on every other URI; `resources/list` is served
368
- and returns an empty list.
369
- - The server capability declaration carries exactly one extension identifier,
370
- `io.modelcontextprotocol/ui`.
371
- - `execute_code`'s metadata declares `_meta.ui.resourceUri` pointing at the
372
- shell URI and `_meta.ui.visibility: ["model"]`.
373
- - The shell renders payload HTML in a sandboxed inner frame and exposes no
374
- bridge — asserted however the implementation can, at minimum that the shell
375
- source carries the `srcdoc` and sandbox attributes and contains no
376
- message-forwarding path from the inner frame to the host.
377
- - `U1`–`U11` fold into `code-mode.md`, the `execute_code` description documents
378
- `connecta.ui`, and the suite takes its row in the
379
- [test map](./operations.md#the-test-map).
380
- - `npm run check` passes.
381
-
382
- The implementation issue (#277) carries these as acceptance criteria.
@@ -1,213 +0,0 @@
1
- # Bounded reads from program UI — evidence and decision
2
-
3
- Decision note for [#287](https://github.com/zackbart/connecta/issues/287),
4
- 2026-08-02. The implementation contract is [#289](https://github.com/zackbart/connecta/issues/289)
5
- and the normative clauses are `V1`–`V8` in [code-mode.md](./code-mode.md).
6
-
7
- ## Verdict
8
-
9
- Accept explicitly bound, host-mediated **read-only** calls for refresh,
10
- pagination, and drill-down. Keep mutations gated. Keep the one-string
11
- `connecta.ui(html)` call display-only.
12
-
13
- This is not an acceptance of interactive applications in general. It adds no
14
- persistence, artifact catalog, sharing, component runtime, generated-code
15
- library, deep link, direct network, conversation channel, or write path. One
16
- successful program still delivers one request-local view and one ordinary text
17
- result.
18
-
19
- ## What display-only could not do
20
-
21
- The current shell and the read-bound browser fixture were walked through with
22
- the same three shapes. In the display-only arm, local JavaScript could sort,
23
- filter, chart, expand already-delivered fields, and rerender indefinitely; every
24
- attempt to obtain bytes not present in the original HTML stopped at the nested
25
- frame. The read-bound arm exercised the same-origin-free nested frame, two
26
- concurrent refreshes, fixed and view-supplied arguments, a refused fabricated
27
- binding, a refused extra argument, and a host error.
28
-
29
- | Workflow | Display-only attempt | Is a fresh program run adequate? | Decision |
30
- | --- | --- | --- | --- |
31
- | Refresh a current status or metrics view | A button can repaint only the original snapshot. Putting a timer around it changes no data. | No. It spends another model turn, reruns composition, and creates another view merely to repeat the same read. | Accept an exact named read with optional filter or cursor keys. |
32
- | Page a cursor-backed list | The initial program can include the known next cursor, but the view cannot exchange it for the next page. Fetching every page up front defeats projection and can cross call/result budgets. | No. The model is an expensive pagination controller and has to reconstruct UI state it did not need. | Accept a binding whose declared `viewArgs` includes the cursor field. |
33
- | Drill from a projected list into one record | Local expansion can show only fields prefetched for every row. Prefetching every detail multiplies calls and payload for records the human never opens. | Usually no. A new prompt can fetch the record, but loses the direct row selection and creates a second result instead of filling the existing view. | Accept a binding whose declared `viewArgs` includes the record identifier. |
34
- | Sort, filter, chart, compare, or expand delivered data | Local HTML/JavaScript completes the interaction. | Yes; usually no new run is needed at all. | No call capability earned. |
35
- | Change, delete, approve, send, or deploy | Display-only correctly cannot act. | Yes. The ordinary `call_destructive_tool` path keeps the proposed effect and host approval in the transcript. | Remain gated. A click is not approval, and this decision adds no mutation bridge. |
36
-
37
- The accepted utility is therefore *live reads*, not “interactivity.” Local
38
- interactivity already existed.
39
-
40
- ## Executor comparison
41
-
42
- Executor's inspected revision demonstrates a useful separation:
43
-
44
- - its generated iframe disables direct `fetch`, XHR, WebSocket, EventSource,
45
- workers, and related network primitives;
46
- - declarative `tools.*` operations become one proxy-shaped call through a
47
- trusted shell and an app-only action tool;
48
- - integration roles resolve against server-owned saved bindings, and writes
49
- can pause for shell-owned interaction handling.
50
-
51
- That is evidence that a narrow bridge can keep untrusted markup away from raw
52
- network and credentials. It is not evidence for Executor's React runtime,
53
- saved artifacts, editing, previews, persistence, or deep-link fallback; those
54
- features provide longevity and authoring ergonomics, not the refresh,
55
- pagination, or drill-down read itself.
56
-
57
- Connecta takes the smaller shape. The trusted shell maps names to the already
58
- existing `call_tool`; bindings live in the completed result, not a database;
59
- and the ordinary fail-closed read path remains the authority. No app-only tool
60
- or eighth meta-tool is needed.
61
-
62
- Inspected Executor sources:
63
-
64
- - [artifact and app-only action registration](https://github.com/UsefulSoftwareCo/executor/blob/837e404acbebdf32924059d6b76f715565329307/packages/hosts/mcp/src/tool-server.ts#L1906-L2157)
65
- - [single proxy-shaped action grammar](https://github.com/UsefulSoftwareCo/executor/blob/837e404acbebdf32924059d6b76f715565329307/packages/hosts/mcp-apps-shell/src/shell/proxy.ts#L38-L140)
66
- - [disabled direct network primitives](https://github.com/UsefulSoftwareCo/executor/blob/837e404acbebdf32924059d6b76f715565329307/packages/hosts/mcp-apps-shell/src/shell/inner-renderer.tsx#L84-L131)
67
-
68
- ## Contract in one pass
69
-
70
- ```js
71
- await connecta.ui(html, {
72
- reads: {
73
- refresh: {
74
- address: "metrics.current",
75
- fixedArgs: { service: "api" },
76
- viewArgs: ["window", "cursor"],
77
- },
78
- detail: {
79
- address: "incidents.get",
80
- viewArgs: ["id"],
81
- },
82
- },
83
- });
84
- ```
85
-
86
- Program markup calls `await connecta.read("detail", { id })`. It never receives
87
- the address table. The outer shell checks the frame source, resolves `detail`,
88
- rejects keys other than `id`, merges the arguments, and asks the host to call
89
- the existing `call_tool` with `resultMode: "value"`.
90
-
91
- The declaration-time catalog lookup proves the view was not born broken or
92
- write-capable. The use-time `call_tool` lookup proves it is still read-only now.
93
-
94
- ## Normative contract
95
-
96
- **V1. Manifest.** The second argument is exactly
97
- `{ reads: { name: { address, fixedArgs?, viewArgs? } } }`: 1–32 names matching
98
- `[A-Za-z][A-Za-z0-9_-]{0,63}`, one non-empty address per name, optional fixed
99
- arguments, and at most 32 distinct view-supplied keys. Extra fields, unsafe
100
- control names (`__proto__`, `constructor`, `prototype`), a view key colliding
101
- with a fixed key, and non-serializable content throw before acceptance.
102
-
103
- **V2. Declaration admission.** Every address resolves through the request-local
104
- catalog and passes the fail-closed `isExplicitlyReadOnly` classification before
105
- the payload is accepted. The lookup dispatches nothing and spends no host-call
106
- budget. `call_tool` repeats resolution and classification at use time.
107
-
108
- **V3. Delivery.** Bindings ride beside `html` under `_meta["connecta/ui"]`,
109
- share the existing emitted-byte aggregate, appear on success only, and never
110
- enter `content` or `structuredContent`. The one-string payload stays exactly
111
- `{ html }`.
112
-
113
- **V4. Inner bridge.** A manifest alone installs `connecta.read(name, args?)`.
114
- The outer shell accepts only its nested frame's exact `WindowProxy`, rejects an
115
- unknown name, non-object arguments, undeclared keys, and more than eight
116
- concurrent reads, then merges supplied keys into a null-prototype copy of fixed
117
- arguments. The inner frame receives no address table or raw JSON-RPC.
118
-
119
- **V5. Seven-tool boundary.** The shell calls only existing `call_tool` with
120
- `resultMode: "value"`. That tool alone is app-visible; the other six are
121
- explicitly model-only. No new MCP tool exists and the view cannot reach the
122
- destructive boundary.
123
-
124
- **V6. Ordinary admission.** A view read is a new MCP request crossing inbound
125
- auth, request admission, current catalog and credentials, fail-closed safety,
126
- connector admission, timeout, retry, result-size, and payload-free activity
127
- exactly as ordinary `call_tool` does. No server-side grant or pending promise
128
- survives the originating request.
129
-
130
- **V7. Stale and replayed views.** A stale view retains no frozen authority:
131
- removed tools, changed annotations, revoked credentials, lost inbound auth, and
132
- new policy fail current admission. Replay repeats a read and may spend rate
133
- limits, but cannot write. Cross-caller use is admitted as the current caller on
134
- the host's originating connection; deployment remains the audience boundary.
135
-
136
- **V8. Context, fallback, and parity.** Reads update only the human-visible view;
137
- the return summarizes the initial snapshot and refreshed data must be labelled
138
- as such. A host without app server tools keeps the ordinary result and initial
139
- view while a read fails locally. The existing provider bridge carries the
140
- manifest identically on both executors without changing `ExecuteResult`.
141
-
142
- ## Threat and consent trace
143
-
144
- 1. **Untrusted program declaration.** The guest supplies HTML and a strictly
145
- shaped read manifest. The host rejects extra fields, unsafe control names,
146
- fixed/view collisions, overlarge lists, unknown addresses, and anything not
147
- explicitly read-only. This lookup executes nothing.
148
- 2. **Result delivery.** On successful program completion only, HTML and
149
- bindings ride result `_meta` under the existing aggregate byte budget. A
150
- failed program delivers neither. The model sees only `ui: true` and the
151
- program's initial summary.
152
- 3. **Nested-frame request.** Only the exact payload `WindowProxy` may send the
153
- `connecta/read` dialect to the trusted shell. A fabricated name fails before
154
- a host call. Fabricated or prototype-shaped argument keys fail unless they
155
- are explicitly declared; fixed keys cannot be overridden. Direct JSON-RPC
156
- from the nested frame is ignored.
157
- 4. **Host mediation.** The shell checks that the host advertised server-tool
158
- calls, caps concurrent work, and emits one `tools/call` for `call_tool`.
159
- `execute_code`, discovery, authorization, result paging, and the destructive
160
- tool are model-only. The Apps host accepts calls only on the originating MCP
161
- server connection.
162
- 5. **Connecta admission.** The app call is a new authenticated request with a
163
- fresh request scope. It crosses request admission, current catalog and
164
- credential resolution, fail-closed read classification, connector call
165
- admission, timeout, retry policy, result-size handling, and payload-free
166
- activity recording. There is no UI bypass below the shell.
167
- 6. **Result delivery.** The shell unwraps the ordinary value result and settles
168
- only the matching inner-frame promise. Protocol errors and tool errors
169
- reject it. It sends no result to model or conversation context.
170
-
171
- ### Named failures
172
-
173
- - **Fabricated address:** markup cannot submit an address; raw JSON-RPC is not
174
- forwarded. A declaration-time invented address fails catalog resolution.
175
- - **Fabricated binding name:** rejected by own-property lookup in the shell.
176
- - **Fabricated argument:** an undeclared key or non-object argument is rejected;
177
- a declared value still faces the downstream input schema and policy.
178
- - **Stale view:** the later request reauthenticates and re-resolves the catalog.
179
- A removed tool, newly unsafe annotation, revoked credential, or changed
180
- admission policy fails current checks. No frozen grant exists server-side.
181
- - **Replay:** it repeats a read and may consume rate limits, but cannot cross to
182
- a write. The view should disable duplicate controls while its promise is
183
- pending; the shell also bounds concurrency.
184
- - **Cross-caller use:** the later request is admitted as the caller behind the
185
- host's current originating connection. Connecta does not use identity to
186
- scope tools inside one deployment; separate audiences remain separate
187
- deployments. A copied manifest is no credential and grants nothing outside
188
- ordinary inbound auth.
189
- - **Destructive call:** the shell names only `call_tool`, and that handler
190
- refuses missing, false, or contradictory read-only annotation. The
191
- destructive meta-tool is not app-visible. No human gesture is interpreted as
192
- write consent.
193
-
194
- ## Invariants and parity
195
-
196
- - **Seven tools:** unchanged; metadata makes one existing tool app-callable and
197
- makes the other six explicitly model-only.
198
- - **Stateless request scope:** binding state survives only in the client's
199
- completed result and trusted shell. The server stores no grant or pending
200
- promise.
201
- - **Import-graph purity:** the shell remains a build-time string using browser
202
- and Web APIs only.
203
- - **Workers/Node parity:** the second argument crosses the existing provider
204
- bridge, leaving `Executor` and `ExecuteResult` unchanged; the same contract
205
- case runs on both executors and both Vitest projects.
206
- - **Payload-free activity:** later reads use ordinary `call_tool` events, whose
207
- schema has no arguments or results.
208
- - **Fallback:** hosts without Apps keep the ordinary result; Apps hosts without
209
- server-tool calls keep the initial view and fail a read locally.
210
-
211
- The remaining gate is intentionally crisp: a mutation proposal needs real
212
- workflow evidence plus a host-tested consent and replay story. Read utility is
213
- not permission to smuggle that decision into this bridge.