@zackbart/connecta 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +113 -0
- package/CHANGELOG.md +83 -0
- package/README.md +62 -12
- package/bin/connecta.mjs +272 -0
- package/dist/access-tokens.d.ts +32 -0
- package/dist/access-tokens.d.ts.map +1 -0
- package/dist/access-tokens.js +225 -0
- package/dist/access-tokens.js.map +1 -0
- package/dist/catalog-service.d.ts +39 -1
- package/dist/catalog-service.d.ts.map +1 -1
- package/dist/catalog-service.js +133 -11
- package/dist/catalog-service.js.map +1 -1
- package/dist/catalog.d.ts +17 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +113 -13
- package/dist/catalog.js.map +1 -1
- package/dist/execute.d.ts +45 -1
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +265 -68
- package/dist/execute.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/invocation.d.ts.map +1 -1
- package/dist/invocation.js +1 -5
- package/dist/invocation.js.map +1 -1
- package/dist/meta-tools.d.ts +1 -0
- package/dist/meta-tools.d.ts.map +1 -1
- package/dist/meta-tools.js +410 -12
- package/dist/meta-tools.js.map +1 -1
- package/dist/operator-ui/generated.d.ts +2 -2
- package/dist/operator-ui/generated.d.ts.map +1 -1
- package/dist/operator-ui/generated.js +2 -2
- package/dist/operator-ui/generated.js.map +1 -1
- package/dist/operator-ui/model.d.ts +2 -0
- package/dist/operator-ui/model.d.ts.map +1 -1
- package/dist/operator-ui/model.js.map +1 -1
- package/dist/routes/access-tokens.d.ts +7 -0
- package/dist/routes/access-tokens.d.ts.map +1 -0
- package/dist/routes/access-tokens.js +84 -0
- package/dist/routes/access-tokens.js.map +1 -0
- package/dist/routes/shared.d.ts +3 -0
- package/dist/routes/shared.d.ts.map +1 -1
- package/dist/routes/shared.js.map +1 -1
- package/dist/routes/ui.d.ts.map +1 -1
- package/dist/routes/ui.js +9 -1
- package/dist/routes/ui.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +5 -0
- package/dist/server.js.map +1 -1
- package/dist/skills.d.ts +1 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +1 -1
- package/dist/storage/file.d.ts.map +1 -1
- package/dist/storage/file.js +5 -0
- package/dist/storage/file.js.map +1 -1
- package/dist/storage/memory.d.ts.map +1 -1
- package/dist/storage/memory.js +8 -0
- package/dist/storage/memory.js.map +1 -1
- package/dist/tool-safety.d.ts +10 -0
- package/dist/tool-safety.d.ts.map +1 -0
- package/dist/tool-safety.js +12 -0
- package/dist/tool-safety.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui.d.ts +4 -4
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +44 -1
- package/dist/ui.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/documentation/architecture.md +7 -0
- package/documentation/auth.md +58 -0
- package/documentation/call-admission.md +7 -0
- package/documentation/code-first-exploration.md +292 -0
- package/documentation/code-mode.md +697 -0
- package/documentation/connector-guides.md +7 -0
- package/documentation/connectors.md +63 -0
- package/documentation/mcp-2026-07-28.md +46 -0
- package/documentation/meta-tools.md +167 -0
- package/documentation/operations.md +7 -0
- package/documentation/operator-ui.md +7 -0
- package/documentation/request-admission.md +7 -0
- package/documentation/storage-and-credentials.md +54 -0
- package/ethos.md +132 -0
- package/examples/node/README.md +53 -0
- package/examples/node/src/index.ts +73 -0
- package/examples/worker/README.md +160 -0
- package/examples/worker/src/cloudflare-kv.ts +43 -0
- package/examples/worker/src/d1-activity-row.ts +100 -0
- package/examples/worker/src/d1-activity.ts +144 -0
- package/examples/worker/src/index.ts +136 -0
- package/examples/worker/wrangler.jsonc +26 -0
- package/package.json +11 -1
- package/src/access-tokens.ts +289 -0
- package/src/catalog-service.ts +177 -15
- package/src/catalog.ts +143 -12
- package/src/execute.ts +372 -96
- package/src/index.ts +33 -1
- package/src/invocation.ts +1 -8
- package/src/meta-tools.ts +504 -11
- package/src/operator-ui/browser.css +63 -0
- package/src/operator-ui/browser.ts +288 -2
- package/src/operator-ui/generated.ts +2 -2
- package/src/operator-ui/model.ts +6 -0
- package/src/routes/access-tokens.ts +115 -0
- package/src/routes/shared.ts +3 -0
- package/src/routes/ui.ts +9 -0
- package/src/server.ts +5 -0
- package/src/skills.ts +1 -1
- package/src/storage/file.ts +5 -0
- package/src/storage/memory.ts +8 -0
- package/src/tool-safety.ts +15 -0
- package/src/types.ts +5 -0
- package/src/ui.ts +50 -1
- package/src/version.ts +1 -1
- package/templates/node/.env.example +5 -0
- package/templates/node/AGENTS.md +19 -0
- package/templates/node/README.md +33 -0
- package/templates/node/package.json +23 -0
- package/templates/node/src/index.ts +43 -0
- package/templates/node/tsconfig.json +12 -0
|
@@ -0,0 +1,292 @@
|
|
|
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`](../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.
|
|
42
|
+
|
|
43
|
+
This was an exploratory spike, not a production implementation. The next agent
|
|
44
|
+
should use these findings as a design brief rather than porting the prototype
|
|
45
|
+
wholesale.
|
|
46
|
+
|
|
47
|
+
## What we were testing
|
|
48
|
+
|
|
49
|
+
The central question was:
|
|
50
|
+
|
|
51
|
+
> Can a model use ordinary JavaScript against typed Connecta capabilities as
|
|
52
|
+
> its default tool interface, while preserving Connecta's safety boundaries and
|
|
53
|
+
> improving context efficiency?
|
|
54
|
+
|
|
55
|
+
The prototype made `execute_code` the normal path for reads and composition.
|
|
56
|
+
Generated code could discover tools, call read-only connector operations,
|
|
57
|
+
parallelize work, join results, retry transient failures, and project large
|
|
58
|
+
responses before returning anything to the model.
|
|
59
|
+
|
|
60
|
+
High-consequence operations did not move into the sandbox. Writes still had to
|
|
61
|
+
cross the explicit destructive-call boundary, where policy and human approval
|
|
62
|
+
remain visible.
|
|
63
|
+
|
|
64
|
+
We compared this with the existing surface using the same in-memory connectors
|
|
65
|
+
and scenarios. We also gave the code-first interface to a pinned Terra model
|
|
66
|
+
with no conversation history to test whether the interface was legible without
|
|
67
|
+
the context of the experiment.
|
|
68
|
+
|
|
69
|
+
## What we observed
|
|
70
|
+
|
|
71
|
+
### 1. The model-facing surface became smaller
|
|
72
|
+
|
|
73
|
+
The prototype reduced the visible surface from 10 tools to 7 and reduced
|
|
74
|
+
serialized tool definitions by about 32%.
|
|
75
|
+
|
|
76
|
+
That reduction matters beyond the raw token count. It removes overlapping
|
|
77
|
+
routing choices between direct calls, batches, discovery, and execution. The
|
|
78
|
+
model decides what program to write; JavaScript handles the deterministic
|
|
79
|
+
control flow between capabilities.
|
|
80
|
+
|
|
81
|
+
This is likely the largest long-term simplification. New connectors can expand
|
|
82
|
+
the typed capability catalog without expanding the always-loaded top-level
|
|
83
|
+
toolbox at the same rate.
|
|
84
|
+
|
|
85
|
+
### 2. Composition is where code mode clearly wins
|
|
86
|
+
|
|
87
|
+
The most compelling results came from tasks where intermediate data did not
|
|
88
|
+
need to return to the model:
|
|
89
|
+
|
|
90
|
+
- Discovery performed inside a workflow used one MCP call instead of two and
|
|
91
|
+
returned about 77% fewer bytes.
|
|
92
|
+
- Projecting a large event export down to three identifiers returned about 93%
|
|
93
|
+
fewer bytes.
|
|
94
|
+
- A dependent account-and-usage join reduced three MCP calls to two.
|
|
95
|
+
- Parallel fan-out and repeated warm reads returned fewer bytes while keeping
|
|
96
|
+
orchestration deterministic inside one execution.
|
|
97
|
+
|
|
98
|
+
These are not merely transport savings. They also reduce the number of points
|
|
99
|
+
where the model must inspect an intermediate result and decide the next action.
|
|
100
|
+
|
|
101
|
+
### 3. Simple calls do not become intrinsically cheaper
|
|
102
|
+
|
|
103
|
+
A single cold lookup returned more bytes and took longer through code mode than
|
|
104
|
+
through a direct tool call. A retry scenario showed the same tradeoff.
|
|
105
|
+
|
|
106
|
+
This does not undermine code-first as the model-facing abstraction. It does
|
|
107
|
+
mean we should not confuse a simpler interface with a universally faster
|
|
108
|
+
execution path. Connecta can preserve one code-shaped interface while
|
|
109
|
+
optimizing simple calls beneath it later, if measurement shows that is useful.
|
|
110
|
+
|
|
111
|
+
### 4. Perceived user speed should be effectively unchanged
|
|
112
|
+
|
|
113
|
+
With the built package, the first QuickJS execution was roughly 63–67 ms.
|
|
114
|
+
Later executions in the same child were generally 1.6–2.8 ms. QuickJS/WASM
|
|
115
|
+
initialization itself was only about 6 ms; most cold cost came from starting
|
|
116
|
+
the Node child, loading modules, and IPC.
|
|
117
|
+
|
|
118
|
+
That overhead is real but normally small compared with model inference and
|
|
119
|
+
network-bound connector calls. Users are unlikely to perceive it as a distinct
|
|
120
|
+
delay. Optimizing the child lifecycle may eventually be worthwhile, but it
|
|
121
|
+
should not block the product direction.
|
|
122
|
+
|
|
123
|
+
### 5. A cold-start model could use the interface successfully
|
|
124
|
+
|
|
125
|
+
The pinned Terra sample completed all 10 behavioral scenarios. It made no
|
|
126
|
+
invalid top-level tool selections, and every ordinary first program was valid
|
|
127
|
+
JavaScript that ran without repair. The one repair was deliberately induced by
|
|
128
|
+
giving it malformed discovery arguments.
|
|
129
|
+
|
|
130
|
+
The scenarios covered:
|
|
131
|
+
|
|
132
|
+
- a simple lookup;
|
|
133
|
+
- parallel fan-out;
|
|
134
|
+
- a dependent join;
|
|
135
|
+
- discovery within execution;
|
|
136
|
+
- projection of a large result;
|
|
137
|
+
- a safely retried read;
|
|
138
|
+
- colliding connector names addressed canonically;
|
|
139
|
+
- typed batch failures;
|
|
140
|
+
- malformed-argument repair; and
|
|
141
|
+
- discovery of a destructive operation followed by sandbox refusal.
|
|
142
|
+
|
|
143
|
+
This is encouraging evidence of interface legibility, not a statistical model
|
|
144
|
+
benchmark. It was one sample from one pinned model.
|
|
145
|
+
|
|
146
|
+
### 6. The safety boundary belongs below generated code
|
|
147
|
+
|
|
148
|
+
The experiment reinforced that sandboxing alone is not the security model.
|
|
149
|
+
Generated code must remain unable to grant itself capabilities.
|
|
150
|
+
|
|
151
|
+
Connecta's durable boundary should continue to provide:
|
|
152
|
+
|
|
153
|
+
- short-lived, brokered credentials rather than raw secrets;
|
|
154
|
+
- request-scoped capability and connector policy;
|
|
155
|
+
- read-only identities and narrowly scoped OAuth grants;
|
|
156
|
+
- controlled network egress;
|
|
157
|
+
- an explicit path for destructive or irreversible operations;
|
|
158
|
+
- complete traces of programs, calls, outputs, and policy decisions; and
|
|
159
|
+
- retry semantics appropriate to each operation.
|
|
160
|
+
|
|
161
|
+
The sandbox should be treated as an additional containment layer. Admission,
|
|
162
|
+
authorization, credentials, and destructive-action policy remain authoritative
|
|
163
|
+
outside it.
|
|
164
|
+
|
|
165
|
+
### 7. QuickJS remains the right default runtime for now
|
|
166
|
+
|
|
167
|
+
We compared the available Bellard QuickJS and QuickJS-NG variants. Both
|
|
168
|
+
initialized in roughly 6 ms, and their local transformation performance was
|
|
169
|
+
effectively equivalent for this use case. The comparison provided no reason to
|
|
170
|
+
switch engines.
|
|
171
|
+
|
|
172
|
+
QuickJS remains a good Node default because it provides explicit memory, stack,
|
|
173
|
+
and interrupt limits behind a small host interface. Running it in a child
|
|
174
|
+
process also contains interpreter and WASM failure. Cloudflare deployments
|
|
175
|
+
should continue using the platform-native Dynamic Worker executor.
|
|
176
|
+
|
|
177
|
+
The current binding can be upgraded and re-evaluated separately. Changing the
|
|
178
|
+
engine is not the solution to child-process startup cost.
|
|
179
|
+
|
|
180
|
+
## What the experiment proved—and what it did not
|
|
181
|
+
|
|
182
|
+
The evidence is strong enough to treat code-first as Connecta's intended
|
|
183
|
+
product direction. It showed that the interface can be smaller, that a capable
|
|
184
|
+
model can understand it cold, that composition and projection produce large
|
|
185
|
+
context savings, and that the explicit write boundary can remain intact.
|
|
186
|
+
|
|
187
|
+
It did not establish:
|
|
188
|
+
|
|
189
|
+
- success rates across repeated prompt variations;
|
|
190
|
+
- behavior across multiple model families and versions;
|
|
191
|
+
- performance against a large real-world connector catalog;
|
|
192
|
+
- production reliability under concurrency and partial failure;
|
|
193
|
+
- the best final guest API; or
|
|
194
|
+
- whether direct connector shortcut namespaces are worth their additional
|
|
195
|
+
complexity.
|
|
196
|
+
|
|
197
|
+
The existing surface should therefore remain available during the transition
|
|
198
|
+
as a compatibility mode, rollback path, and experimental control.
|
|
199
|
+
|
|
200
|
+
## Recommended product shape
|
|
201
|
+
|
|
202
|
+
The smallest promising surface is:
|
|
203
|
+
|
|
204
|
+
1. `execute_code` as the default read, discovery, transformation, and
|
|
205
|
+
composition interface.
|
|
206
|
+
2. A canonical in-program API such as `connecta.search`,
|
|
207
|
+
`connecta.describe`, `connecta.call`, and `connecta.batch`.
|
|
208
|
+
3. An explicit destructive-call tool for writes and irreversible actions.
|
|
209
|
+
4. Explicit authorization and deferred-result tools where those boundaries
|
|
210
|
+
cannot safely live inside execution.
|
|
211
|
+
5. Skills that teach domain playbooks without adding more always-loaded verbs.
|
|
212
|
+
|
|
213
|
+
Canonical addressing should remain available even if ergonomic connector
|
|
214
|
+
shortcuts are offered. It prevents sanitized-name collisions and gives
|
|
215
|
+
generated programs a stable escape hatch.
|
|
216
|
+
|
|
217
|
+
## Suggested implementation sequence
|
|
218
|
+
|
|
219
|
+
### Phase 1: establish the evaluation gate
|
|
220
|
+
|
|
221
|
+
Turn the exploratory scenarios into a repeatable evaluation suite before
|
|
222
|
+
changing the default surface. Run at least 20 independent samples per task and
|
|
223
|
+
model, with prompt variation.
|
|
224
|
+
|
|
225
|
+
That suite now exists as
|
|
226
|
+
[`eval/code-first-gate`](../eval/code-first-gate/README.md): these ten scenarios
|
|
227
|
+
as versioned tasks with three phrasings each, the classic nine-tool surface as
|
|
228
|
+
the control arm, and a per-model report that ends in a flip/hold verdict without
|
|
229
|
+
flipping anything.
|
|
230
|
+
|
|
231
|
+
Capture:
|
|
232
|
+
|
|
233
|
+
- task success;
|
|
234
|
+
- invalid tool selection;
|
|
235
|
+
- syntax and runtime failures;
|
|
236
|
+
- repair turns;
|
|
237
|
+
- MCP calls;
|
|
238
|
+
- request, response, and total transcript tokens;
|
|
239
|
+
- time to first correct answer; and
|
|
240
|
+
- attempted safety-boundary violations.
|
|
241
|
+
|
|
242
|
+
Keep results separated by model and version. The model's ability to write and
|
|
243
|
+
repair code is the independent variable, so blended scores would hide the
|
|
244
|
+
signal we care about.
|
|
245
|
+
|
|
246
|
+
### Phase 2: define the code-first contract
|
|
247
|
+
|
|
248
|
+
Specify the guest API, error shapes, projection behavior, retry semantics,
|
|
249
|
+
canonical addressing, cancellation, limits, and audit events before optimizing
|
|
250
|
+
the runtime.
|
|
251
|
+
|
|
252
|
+
The current architecture already has useful foundations: request-local
|
|
253
|
+
catalogs, centralized invocation, admission control, and lazy connector
|
|
254
|
+
capabilities. Build the new surface on those rather than recreating parallel
|
|
255
|
+
logic in the executor.
|
|
256
|
+
|
|
257
|
+
### Phase 3: ship behind an explicit surface choice
|
|
258
|
+
|
|
259
|
+
Offer code-first and classic modes initially. Executor-backed deployments can
|
|
260
|
+
opt into code-first while deployments without a safe executor remain classic.
|
|
261
|
+
Keep consequential writes outside the sandbox in both modes.
|
|
262
|
+
|
|
263
|
+
Once the repeated model eval and production telemetry are healthy, make
|
|
264
|
+
code-first the executor-backed default. Avoid adding new top-level read tools
|
|
265
|
+
unless a measured case cannot be expressed safely or clearly through the
|
|
266
|
+
programmable 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.
|