@zackbart/connecta 0.18.2 → 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 (75) hide show
  1. package/CHANGELOG.md +100 -4
  2. package/README.md +4 -0
  3. package/dist/catalog-service.d.ts +20 -13
  4. package/dist/catalog-service.js +123 -116
  5. package/dist/catalog.js +29 -46
  6. package/dist/connector-scope.js +2 -7
  7. package/dist/connectors/api.d.ts +4 -16
  8. package/dist/connectors/api.js +19 -46
  9. package/dist/connectors/guarded-fetch.d.ts +9 -23
  10. package/dist/connectors/guarded-fetch.js +38 -76
  11. package/dist/connectors/remote-mcp.js +36 -79
  12. package/dist/errors.d.ts +6 -27
  13. package/dist/errors.js +8 -5
  14. package/dist/execute.d.ts +24 -22
  15. package/dist/execute.js +98 -145
  16. package/dist/executor-result.d.ts +1 -0
  17. package/dist/executor-result.js +4 -11
  18. package/dist/executors/quickjs-child.js +1 -3
  19. package/dist/executors/quickjs-runtime.js +1 -3
  20. package/dist/executors/quickjs.js +1 -3
  21. package/dist/index.js +27 -57
  22. package/dist/invocation.js +114 -178
  23. package/dist/meta-tools.d.ts +15 -28
  24. package/dist/meta-tools.js +33 -89
  25. package/dist/providers/cloudflare.d.ts +2 -18
  26. package/dist/providers/cloudflare.js +1460 -2451
  27. package/dist/providers/linear.d.ts +4 -41
  28. package/dist/providers/linear.js +8 -39
  29. package/dist/providers/mixpanel.d.ts +3 -25
  30. package/dist/providers/mixpanel.js +7 -22
  31. package/dist/providers/notion.d.ts +1 -15
  32. package/dist/providers/notion.js +44 -173
  33. package/dist/providers/revenuecat.d.ts +4 -57
  34. package/dist/providers/revenuecat.js +10 -93
  35. package/dist/providers/stripe.d.ts +1 -12
  36. package/dist/providers/stripe.js +7 -45
  37. package/dist/registry.d.ts +16 -34
  38. package/dist/registry.js +18 -103
  39. package/dist/result-shapes.d.ts +13 -0
  40. package/dist/result-shapes.js +331 -0
  41. package/dist/routes/mcp.js +1 -1
  42. package/dist/routes/oauth.js +3 -3
  43. package/dist/routes/shared.d.ts +15 -15
  44. package/dist/routes/shared.js +1 -3
  45. package/dist/skills.js +3 -3
  46. package/dist/timeout.d.ts +8 -7
  47. package/dist/timeout.js +47 -38
  48. package/dist/types.d.ts +3 -3
  49. package/dist/ui.d.ts +1 -25
  50. package/dist/ui.js +18 -45
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/documentation/architecture.md +5 -2
  54. package/documentation/call-admission.md +1 -1
  55. package/documentation/cloudflare.md +1 -1
  56. package/documentation/code-mode.md +13 -13
  57. package/documentation/connectors.md +34 -1
  58. package/documentation/linear.md +1 -1
  59. package/documentation/meta-tools.md +17 -3
  60. package/documentation/mixpanel.md +1 -1
  61. package/documentation/notion.md +1 -1
  62. package/documentation/operations.md +20 -15
  63. package/documentation/provider-conventions.md +1 -1
  64. package/documentation/revenuecat.md +1 -1
  65. package/documentation/stripe.md +1 -1
  66. package/documentation/upgrading.md +24 -4
  67. package/ethos.md +74 -120
  68. package/package.json +3 -4
  69. package/templates/node/package.json +1 -1
  70. package/documentation/code-first-exploration.md +0 -292
  71. package/documentation/mcp-2026-07-28.md +0 -46
  72. package/documentation/mcp-ui-design.md +0 -382
  73. package/documentation/program-ui-read-calls.md +0 -213
  74. package/documentation/provider-audit.md +0 -198
  75. package/documentation/rich-output-design.md +0 -211
@@ -1,292 +0,0 @@
1
- # Code-first Connecta: exploration findings
2
-
3
- > **Read as a record, not as current policy.** This is the exploration that
4
- > started the arc, kept as written. Two of its conclusions have since been
5
- > overtaken, and [`ethos.md`](../ethos.md)'s decisions table is the authority
6
- > where they disagree:
7
- >
8
- > - **The ~32% definition-size reduction was an estimate.** The shipped fold
9
- > measures **19.6%** on the same 10-tools-to-7 comparison (10,675B → 8,587B).
10
- > The prototype's seven descriptions were thinner than the ones connecta
11
- > actually ships.
12
- > - **The "require repeated pinned-model evaluation before changing the default"
13
- > constraint below was dropped.** The owner decided the default directly on
14
- > 2026-07-30 and [#224](https://github.com/zackbart/connecta/issues/224)
15
- > shipped it; the ethos records the eval-as-gate as `removed` and
16
- > [`eval/code-first-gate`](https://github.com/zackbart/connecta/blob/main/eval/code-first-gate/README.md) continues as
17
- > measurement that nothing waits on.
18
-
19
- ## Executive summary
20
-
21
- We explored whether Connecta should make code execution the primary interface
22
- for connector work instead of exposing a growing collection of top-level
23
- meta-tools.
24
-
25
- The experiment supports that direction.
26
-
27
- A code-first surface was easier for a cold-start model to use than expected,
28
- materially reduced fixed tool-schema context, and was especially effective for
29
- workflows involving discovery, fan-out, joins, retries, and large-result
30
- projection. QuickJS added measurable runtime overhead, but not enough to be
31
- meaningful beside model generation and downstream service latency in normal
32
- agent work.
33
-
34
- The recommendation is to evolve Connecta toward:
35
-
36
- - one programmable, read-oriented execution surface;
37
- - a very small set of explicit tools for consequential writes, authorization,
38
- and result retrieval;
39
- - policy, credentials, egress, and auditing enforced below generated code; and
40
- - the current tool surface retained as a compatibility path and evaluation
41
- control while the new path matures — a retention that ended with #273, which
42
- made the executor mandatory and deleted the classic surface outright.
43
-
44
- This was an exploratory spike, not a production implementation. The next agent
45
- should use these findings as a design brief rather than porting the prototype
46
- wholesale.
47
-
48
- ## What we were testing
49
-
50
- The central question was:
51
-
52
- > Can a model use ordinary JavaScript against typed Connecta capabilities as
53
- > its default tool interface, while preserving Connecta's safety boundaries and
54
- > improving context efficiency?
55
-
56
- The prototype made `execute_code` the normal path for reads and composition.
57
- Generated code could discover tools, call read-only connector operations,
58
- parallelize work, join results, retry transient failures, and project large
59
- responses before returning anything to the model.
60
-
61
- High-consequence operations did not move into the sandbox. Writes still had to
62
- cross the explicit destructive-call boundary, where policy and human approval
63
- remain visible.
64
-
65
- We compared this with the existing surface using the same in-memory connectors
66
- and scenarios. We also gave the code-first interface to a pinned Terra model
67
- with no conversation history to test whether the interface was legible without
68
- the context of the experiment.
69
-
70
- ## What we observed
71
-
72
- ### 1. The model-facing surface became smaller
73
-
74
- The prototype reduced the visible surface from 10 tools to 7 and reduced
75
- serialized tool definitions by about 32%.
76
-
77
- That reduction matters beyond the raw token count. It removes overlapping
78
- routing choices between direct calls, batches, discovery, and execution. The
79
- model decides what program to write; JavaScript handles the deterministic
80
- control flow between capabilities.
81
-
82
- This is likely the largest long-term simplification. New connectors can expand
83
- the typed capability catalog without expanding the always-loaded top-level
84
- toolbox at the same rate.
85
-
86
- ### 2. Composition is where code mode clearly wins
87
-
88
- The most compelling results came from tasks where intermediate data did not
89
- need to return to the model:
90
-
91
- - Discovery performed inside a workflow used one MCP call instead of two and
92
- returned about 77% fewer bytes.
93
- - Projecting a large event export down to three identifiers returned about 93%
94
- fewer bytes.
95
- - A dependent account-and-usage join reduced three MCP calls to two.
96
- - Parallel fan-out and repeated warm reads returned fewer bytes while keeping
97
- orchestration deterministic inside one execution.
98
-
99
- These are not merely transport savings. They also reduce the number of points
100
- where the model must inspect an intermediate result and decide the next action.
101
-
102
- ### 3. Simple calls do not become intrinsically cheaper
103
-
104
- A single cold lookup returned more bytes and took longer through code mode than
105
- through a direct tool call. A retry scenario showed the same tradeoff.
106
-
107
- This does not undermine code-first as the model-facing abstraction. It does
108
- mean we should not confuse a simpler interface with a universally faster
109
- execution path. Connecta can preserve one code-shaped interface while
110
- optimizing simple calls beneath it later, if measurement shows that is useful.
111
-
112
- ### 4. Perceived user speed should be effectively unchanged
113
-
114
- With the built package, the first QuickJS execution was roughly 63–67 ms.
115
- Later executions in the same child were generally 1.6–2.8 ms. QuickJS/WASM
116
- initialization itself was only about 6 ms; most cold cost came from starting
117
- the Node child, loading modules, and IPC.
118
-
119
- That overhead is real but normally small compared with model inference and
120
- network-bound connector calls. Users are unlikely to perceive it as a distinct
121
- delay. Optimizing the child lifecycle may eventually be worthwhile, but it
122
- should not block the product direction.
123
-
124
- ### 5. A cold-start model could use the interface successfully
125
-
126
- The pinned Terra sample completed all 10 behavioral scenarios. It made no
127
- invalid top-level tool selections, and every ordinary first program was valid
128
- JavaScript that ran without repair. The one repair was deliberately induced by
129
- giving it malformed discovery arguments.
130
-
131
- The scenarios covered:
132
-
133
- - a simple lookup;
134
- - parallel fan-out;
135
- - a dependent join;
136
- - discovery within execution;
137
- - projection of a large result;
138
- - a safely retried read;
139
- - colliding connector names addressed canonically;
140
- - typed batch failures;
141
- - malformed-argument repair; and
142
- - discovery of a destructive operation followed by sandbox refusal.
143
-
144
- This is encouraging evidence of interface legibility, not a statistical model
145
- benchmark. It was one sample from one pinned model.
146
-
147
- ### 6. The safety boundary belongs below generated code
148
-
149
- The experiment reinforced that sandboxing alone is not the security model.
150
- Generated code must remain unable to grant itself capabilities.
151
-
152
- Connecta's durable boundary should continue to provide:
153
-
154
- - short-lived, brokered credentials rather than raw secrets;
155
- - request-scoped capability and connector policy;
156
- - read-only identities and narrowly scoped OAuth grants;
157
- - controlled network egress;
158
- - an explicit path for destructive or irreversible operations;
159
- - complete traces of programs, calls, outputs, and policy decisions; and
160
- - retry semantics appropriate to each operation.
161
-
162
- The sandbox should be treated as an additional containment layer. Admission,
163
- authorization, credentials, and destructive-action policy remain authoritative
164
- outside it.
165
-
166
- ### 7. QuickJS remains the right default runtime for now
167
-
168
- We compared the available Bellard QuickJS and QuickJS-NG variants. Both
169
- initialized in roughly 6 ms, and their local transformation performance was
170
- effectively equivalent for this use case. The comparison provided no reason to
171
- switch engines.
172
-
173
- QuickJS remains a good Node default because it provides explicit memory, stack,
174
- and interrupt limits behind a small host interface. Running it in a child
175
- process also contains interpreter and WASM failure. Cloudflare deployments
176
- should continue using the platform-native Dynamic Worker executor.
177
-
178
- The current binding can be upgraded and re-evaluated separately. Changing the
179
- engine is not the solution to child-process startup cost.
180
-
181
- ## What the experiment proved—and what it did not
182
-
183
- The evidence is strong enough to treat code-first as Connecta's intended
184
- product direction. It showed that the interface can be smaller, that a capable
185
- model can understand it cold, that composition and projection produce large
186
- context savings, and that the explicit write boundary can remain intact.
187
-
188
- It did not establish:
189
-
190
- - success rates across repeated prompt variations;
191
- - behavior across multiple model families and versions;
192
- - performance against a large real-world connector catalog;
193
- - production reliability under concurrency and partial failure;
194
- - the best final guest API; or
195
- - whether direct connector shortcut namespaces are worth their additional
196
- complexity.
197
-
198
- The existing surface should therefore remain available during the transition
199
- as a compatibility mode, rollback path, and experimental control. It was, and
200
- then it was not: #224 made code-first the default and #273 removed the second
201
- shape entirely. The open questions above outlived the control arm rather than
202
- being settled by it.
203
-
204
- ## Recommended product shape
205
-
206
- The smallest promising surface is:
207
-
208
- 1. `execute_code` as the default read, discovery, transformation, and
209
- composition interface.
210
- 2. A canonical in-program API such as `connecta.search`,
211
- `connecta.describe`, `connecta.call`, and `connecta.batch`.
212
- 3. An explicit destructive-call tool for writes and irreversible actions.
213
- 4. Explicit authorization and deferred-result tools where those boundaries
214
- cannot safely live inside execution.
215
- 5. Skills that teach domain playbooks without adding more always-loaded verbs.
216
-
217
- Canonical addressing should remain available even if ergonomic connector
218
- shortcuts are offered. It prevents sanitized-name collisions and gives
219
- generated programs a stable escape hatch.
220
-
221
- ## Suggested implementation sequence
222
-
223
- ### Phase 1: establish the evaluation gate
224
-
225
- Turn the exploratory scenarios into a repeatable evaluation suite before
226
- changing the default surface. Run at least 20 independent samples per task and
227
- model, with prompt variation.
228
-
229
- That suite was built under
230
- [`eval/code-first-gate`](https://github.com/zackbart/connecta/blob/main/eval/code-first-gate/README.md). Its recorded results
231
- remain as measurement history; the runnable comparison was retired when #273
232
- removed the alternate deployment shapes.
233
-
234
- Capture:
235
-
236
- - task success;
237
- - invalid tool selection;
238
- - syntax and runtime failures;
239
- - repair turns;
240
- - MCP calls;
241
- - request, response, and total transcript tokens;
242
- - time to first correct answer; and
243
- - attempted safety-boundary violations.
244
-
245
- Keep results separated by model and version. The model's ability to write and
246
- repair code is the independent variable, so blended scores would hide the
247
- signal we care about.
248
-
249
- ### Phase 2: define the code-first contract
250
-
251
- Specify the guest API, error shapes, projection behavior, retry semantics,
252
- canonical addressing, cancellation, limits, and audit events before optimizing
253
- the runtime.
254
-
255
- The current architecture already has useful foundations: request-local
256
- catalogs, centralized invocation, admission control, and lazy connector
257
- capabilities. Build the new surface on those rather than recreating parallel
258
- logic in the executor.
259
-
260
- ### Phase 3: consolidate the surface
261
-
262
- This phase is complete: code-first became the default in #224, then #273 made
263
- the executor mandatory and removed the deployment choice. Consequential writes
264
- remain outside the sandbox. New top-level read tools still require a measured
265
- case that cannot be expressed safely or clearly through the programmable
266
- surface.
267
-
268
- ### Phase 4: stabilize successful workflows
269
-
270
- When an agent repeatedly discovers the same successful program, allow it to
271
- become a versioned script, test, or skill. Run that stabilized workflow
272
- deterministically and bring the model back only when inputs or interfaces
273
- change.
274
-
275
- This progression—tool mode to code mode to stabilized mode—is where the
276
- largest reliability and cost gains are likely to emerge.
277
-
278
- ## Decision
279
-
280
- Proceed with code-first as the next direction for Connecta, with three
281
- constraints:
282
-
283
- 1. Treat the current evidence as a strong exploratory result, not a completed
284
- production validation.
285
- 2. Preserve explicit external governance for writes and other consequential
286
- actions.
287
- 3. Require repeated pinned-model evaluation before changing the default for
288
- users.
289
-
290
- The next implementation should optimize for a coherent, minimal contract and
291
- measurable behavior—not for preserving every detail of the exploratory
292
- prototype.
@@ -1,46 +0,0 @@
1
- # MCP 2026-07-28 revision inventory
2
-
3
- This is Connecta's disposition of every change in the 2026-07-28 MCP revision.
4
- It records what SDK v2 owns, what Connecta implements, and what remains
5
- deliberately gated. The migration is tracked in
6
- [#176](https://github.com/zackbart/connecta/issues/176).
7
-
8
- | # | Change | Verdict | Connecta action |
9
- | --- | --- | --- | --- |
10
- | 1 | Sessions and `Mcp-Session-Id` removed | adopt inbound; retain outbound legacy support | `/mcp` stays stateless. Keep `mcp-session-id` CORS compatibility and explicit DELETE for stateful legacy downstreams; v2 `Client.close()` does not terminate those sessions. |
11
- | 2 | `initialize` removed; version and capabilities move to per-request `_meta` | adopt via SDK | Modern clients use the v2 envelope; legacy initialize remains served indefinitely. |
12
- | 3 | `server/discover` required | adopt via SDK | The fetch-native handler serves discovery and the outbound client uses it for negotiation. |
13
- | 4 | `subscriptions/listen` server push | decline | Connecta emits no notifications and remains request-scoped. |
14
- | 5 | Multi-round-trip results on Connecta's own surface | decline | Credential recovery remains the accepted `auth_required` tool-result flow. |
15
- | 6 | Downstream `resultType: "input_required"` | handle; gate passthrough | Return the structured non-retryable `input_required_unsupported` failure through direct, batch, and code-mode invocation. |
16
- | 7 | `resultType` required on results | adopt via SDK | Modern results are stamped `complete`; legacy results without the field remain accepted. |
17
- | 8 | `ttlMs` and `cacheScope` on cacheable lists | adopt | `tools/list` returns `ttlMs: 3_600_000` and `cacheScope: "private"`. |
18
- | 9 | Honor downstream list cache hints | gated | Keep the fixed five-minute TTL plus fingerprint until refresh-churn evidence warrants complexity ([#206](https://github.com/zackbart/connecta/issues/206)). |
19
- | 10 | Native Tasks extension | refuse | Tasks address duration, while `get_result` addresses response size. Polling plus paging would add round trips without replacing the stash. |
20
- | 11 | Extensions capability framework | decline | Decline as a general surface. The one extension Connecta declares is `io.modelcontextprotocol/ui`, which the MCP Apps extension requires before a host will use the program-UI shell template at all ([#266](https://github.com/zackbart/connecta/issues/266)). |
21
- | 12 | `Mcp-Method` and `Mcp-Name` POST headers | adopt | SDK v2 handles the headers; CORS allows `mcp-method, mcp-name`. |
22
- | 13 | RFC 9207 `iss` validation and `application_type` | adopt via SDK | The callback preserves all query parameters for SDK validation. |
23
- | 14 | Credentials keyed to issuer; re-register when AS changes | adopt | Version-2 credential envelopes store issuer; mismatch advances the generation epoch and invalidates registration and tokens. |
24
- | 15 | Client ID Metadata Documents replace DCR | gated | DCR is grandfathered. Publishing deployment-specific CIMD remains [#207](https://github.com/zackbart/connecta/issues/207). |
25
- | 16 | Full JSON Schema 2020-12 and arbitrary `structuredContent` | verify | Exotic-keyword schemas pass through compact discovery and the 2020-12 input validator. |
26
- | 17 | Protocol error-code updates | adopt via SDK | Connecta has no source-level dependency on protocol error numbers. |
27
- | 18 | Roots, Sampling, Logging, and HTTP+SSE deprecated | no-op | Connecta does not aggregate or initiate these surfaces. |
28
-
29
- ## Compatibility decisions
30
-
31
- The inbound handler serves both revisions from one endpoint. The outbound
32
- client automatically negotiates modern service and falls back to legacy
33
- initialize. The legacy session termination test proves that explicit
34
- `terminateSession` remains necessary: SDK v2 closes the client transport but
35
- does not send the downstream's session DELETE.
36
-
37
- MRTR passthrough is gated rather than permanently refused. A stateless relay
38
- could carry `requestState`, but Connecta has no host contract for exposing the
39
- embedded input request, no downstream adoption evidence, and no annotation
40
- model for the resumed call. Until those arrive, a loud typed failure is safer
41
- than discarding the intermediate result or hanging.
42
-
43
- Native Tasks and downstream cache hints do not replace existing mechanisms.
44
- `get_result` pages oversized completed data; Tasks poll unfinished work.
45
- Connecta's fingerprinted catalog cache already produces roughly 3 ms reads, so
46
- downstream hint handling must earn its complexity with measured churn.