@zackbart/connecta 0.10.6 → 0.11.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 (80) hide show
  1. package/AGENTS.md +8 -6
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +5 -4
  4. package/bin/connecta.mjs +0 -7
  5. package/dist/activity.d.ts.map +1 -1
  6. package/dist/activity.js.map +1 -1
  7. package/dist/catalog-service.d.ts +2 -17
  8. package/dist/catalog-service.d.ts.map +1 -1
  9. package/dist/catalog-service.js +4 -6
  10. package/dist/catalog-service.js.map +1 -1
  11. package/dist/connectors/api.d.ts +2 -2
  12. package/dist/connectors/remote-mcp.d.ts +1 -1
  13. package/dist/errors.d.ts +1 -3
  14. package/dist/errors.d.ts.map +1 -1
  15. package/dist/errors.js +1 -1
  16. package/dist/errors.js.map +1 -1
  17. package/dist/execute.d.ts +1 -3
  18. package/dist/execute.d.ts.map +1 -1
  19. package/dist/execute.js +7 -28
  20. package/dist/execute.js.map +1 -1
  21. package/dist/index.d.ts +15 -31
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +23 -37
  24. package/dist/index.js.map +1 -1
  25. package/dist/invocation.js +2 -2
  26. package/dist/invocation.js.map +1 -1
  27. package/dist/meta-tools.d.ts +19 -58
  28. package/dist/meta-tools.d.ts.map +1 -1
  29. package/dist/meta-tools.js +34 -431
  30. package/dist/meta-tools.js.map +1 -1
  31. package/dist/registry.d.ts +1 -10
  32. package/dist/registry.d.ts.map +1 -1
  33. package/dist/registry.js +3 -15
  34. package/dist/registry.js.map +1 -1
  35. package/dist/routes/mcp.d.ts.map +1 -1
  36. package/dist/routes/mcp.js +19 -30
  37. package/dist/routes/mcp.js.map +1 -1
  38. package/dist/routes/shared.d.ts +5 -11
  39. package/dist/routes/shared.d.ts.map +1 -1
  40. package/dist/routes/shared.js.map +1 -1
  41. package/dist/server.js +5 -4
  42. package/dist/server.js.map +1 -1
  43. package/dist/skills.d.ts +8 -18
  44. package/dist/skills.d.ts.map +1 -1
  45. package/dist/skills.js +13 -60
  46. package/dist/skills.js.map +1 -1
  47. package/dist/types.d.ts +6 -20
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/documentation/code-first-exploration.md +16 -16
  52. package/documentation/code-mode.md +21 -35
  53. package/documentation/connectors.md +1 -1
  54. package/documentation/meta-tools.md +30 -43
  55. package/documentation/rich-output-design.md +4 -4
  56. package/examples/node/README.md +1 -2
  57. package/examples/node/src/index.ts +1 -3
  58. package/examples/worker/README.md +8 -13
  59. package/examples/worker/src/index.ts +6 -14
  60. package/examples/worker/wrangler.jsonc +3 -6
  61. package/package.json +1 -1
  62. package/src/activity.ts +5 -0
  63. package/src/catalog-service.ts +6 -26
  64. package/src/connectors/api.ts +2 -2
  65. package/src/connectors/remote-mcp.ts +1 -1
  66. package/src/errors.ts +2 -2
  67. package/src/execute.ts +7 -36
  68. package/src/index.ts +40 -69
  69. package/src/invocation.ts +2 -2
  70. package/src/meta-tools.ts +38 -565
  71. package/src/registry.ts +2 -33
  72. package/src/routes/mcp.ts +19 -30
  73. package/src/routes/shared.ts +4 -11
  74. package/src/server.ts +7 -7
  75. package/src/skills.ts +11 -74
  76. package/src/types.ts +6 -21
  77. package/src/version.ts +1 -1
  78. package/templates/node/README.md +2 -1
  79. package/templates/node/package.json +1 -1
  80. package/templates/node/src/index.ts +1 -1
package/src/index.ts CHANGED
@@ -18,7 +18,6 @@ import type { ActivityReadGate, ActivityStore } from "./activity.js";
18
18
  import type {
19
19
  Connector,
20
20
  ConnectaBranding,
21
- ConnectaSurface,
22
21
  Executor,
23
22
  InboundAuth,
24
23
  KVStorage,
@@ -77,10 +76,11 @@ export interface ConnectaDiscoveryConfig {
77
76
  staleCatalogSeconds?: number;
78
77
  /**
79
78
  * Deadline (ms) for each downstream probe/catalog call fanned out by
80
- * `list_connectors`, `search_tools`, and `describe_tools`. Defaults to
81
- * 30_000. A timed-out connector degrades independently; this does not apply
82
- * to tool calls. Catalog walks receive the same cancellation signal, which
83
- * aborts an in-flight page where supported and prevents another from starting.
79
+ * `search_tools` and by `connecta.search`/`connecta.describe` inside
80
+ * `execute_code`. Defaults to 30_000. A timed-out connector degrades
81
+ * independently; this does not apply to tool calls. Catalog walks receive the
82
+ * same cancellation signal, which aborts an in-flight page where supported and
83
+ * prevents another from starting.
84
84
  */
85
85
  probeTimeoutMs?: number;
86
86
  }
@@ -88,9 +88,9 @@ export interface ConnectaDiscoveryConfig {
88
88
  /** Deployment-wide call deadlines and inline-result paging thresholds. */
89
89
  export interface ConnectaCallsConfig {
90
90
  /**
91
- * Deadline (ms) for `call_tool`/`batch_call` calls that pass no `timeoutMs`.
92
- * An explicit per-call value wins. Opt-in: unset by default, so existing
93
- * long-running calls gain no surprise deadline.
91
+ * Deadline (ms) for `call_tool`/`call_destructive_tool` calls that pass no
92
+ * `timeoutMs`. An explicit per-call value wins. Opt-in: unset by default, so
93
+ * existing long-running calls gain no surprise deadline.
94
94
  *
95
95
  * This bounds one attempt, not all retries. `execute_code` host calls are
96
96
  * unaffected because they already carry their own bound.
@@ -102,13 +102,6 @@ export interface ConnectaCallsConfig {
102
102
  * 50_000. Connectors may override it individually.
103
103
  */
104
104
  maxResultBytes?: number;
105
- /**
106
- * Max serialized `batch_call` envelope size (bytes) before the full batch is
107
- * stashed for `get_result` and only an ordered outcome summary is returned
108
- * inline. Must be a finite whole number >= 1; invalid values warn and fall
109
- * back to 100_000. This cap is independent of per-connector child caps.
110
- */
111
- maxBatchResultBytes?: number;
112
105
  }
113
106
 
114
107
  /** Budgets for rich output emitted by execute_code programs (`connecta.emit`). */
@@ -197,22 +190,12 @@ export interface ConnectaConfig {
197
190
  /** Deployment metadata exposed by /health (for example a Worker version). */
198
191
  deploymentInfo?: Record<string, unknown>;
199
192
  /**
200
- * Sandbox for `execute_code`, and the switch that decides the surface: with
201
- * an executor a model sees the seven code-first tools, without one the nine
202
- * classic ones. Workers: `new DynamicWorkerExecutor({ loader: env.LOADER })`
203
- * from `@cloudflare/codemode`. Node: `quickJsExecutor()` from
204
- * "@zackbart/connecta/quickjs".
193
+ * Required sandbox for `execute_code`. Workers use
194
+ * `new DynamicWorkerExecutor({ loader: env.LOADER })` from
195
+ * `@cloudflare/codemode`; Node uses `quickJsExecutor()` from
196
+ * `@zackbart/connecta/quickjs`.
205
197
  */
206
- executor?: Executor;
207
- /**
208
- * Override the surface the `executor` implies. The only reason to set it is
209
- * `"classic"` alongside an executor — ten tools, the shape the eval gate's
210
- * *incremental* arm measures ("does adding `execute_code` to classic help on
211
- * its own?"). The gate's control arm is executor-free classic, which needs no
212
- * override. `"code-first"` is the default wherever an executor exists and
213
- * throws without one.
214
- */
215
- surface?: ConnectaSurface;
198
+ executor: Executor;
216
199
  }
217
200
 
218
201
  export interface Connecta {
@@ -306,6 +289,20 @@ function assertNoLegacyConfig(config: ConnectaConfig): void {
306
289
  "issue #179. Credentials now fail at use; see ethos.md.",
307
290
  );
308
291
  }
292
+ const calls = candidate.calls;
293
+ if (
294
+ typeof calls === "object" &&
295
+ calls !== null &&
296
+ hasOwn(calls, "maxBatchResultBytes")
297
+ ) {
298
+ throw new Error(
299
+ "`calls.maxBatchResultBytes` was removed in issue #273 along with " +
300
+ "batch_call. Remove it; a program's batching is bounded by " +
301
+ "execute_code's own limits — connecta.batch's per-run call ceiling " +
302
+ "and the executor result cap — while each call inside it still honours " +
303
+ "calls.maxResultBytes and any per-connector override.",
304
+ );
305
+ }
309
306
  const found: Array<readonly [string, string]> = [];
310
307
  if (hasOwn(candidate, "activity")) {
311
308
  const activity = candidate.activity;
@@ -444,43 +441,22 @@ function warnInsecureConfig(
444
441
  }
445
442
  }
446
443
 
447
- /**
448
- * The advertised surface: the executor is the switch. Configure one and the
449
- * deployment serves the seven-tool code-first surface; omit it and there is no
450
- * program to fold discovery and batching into, so it serves classic.
451
- *
452
- * Two mistakes are structural rather than recoverable, so neither is warned
453
- * past: a surface name connecta does not implement, which would otherwise
454
- * resolve to something the operator did not ask for; and `code-first` without
455
- * an executor, which would advertise six tools and no program surface.
456
- */
457
- function resolveSurface(config: ConnectaConfig): ConnectaSurface {
458
- const surface = config.surface;
459
- if (surface === undefined) {
460
- return config.executor ? "code-first" : "classic";
461
- }
462
- if (surface !== "classic" && surface !== "code-first") {
444
+ export function createConnecta(config: ConnectaConfig): Connecta {
445
+ assertNoLegacyConfig(config);
446
+ if (Object.prototype.hasOwnProperty.call(config, "surface")) {
463
447
  throw new Error(
464
- `ConnectaConfig.surface must be "classic" or "code-first", not ` +
465
- `${JSON.stringify(surface)}.`,
448
+ "ConnectaConfig.surface was removed in issue #273. Remove it; connecta " +
449
+ "now serves one seven-tool surface.",
466
450
  );
467
451
  }
468
- if (surface === "code-first" && !config.executor) {
452
+ if (!config.executor) {
469
453
  throw new Error(
470
- 'ConnectaConfig.surface "code-first" requires an executor: it folds ' +
471
- "list_connectors, describe_tools, and batch_call into connecta.search, " +
472
- "connecta.describe, and connecta.batch inside execute_code, so without " +
473
- "an executor there is nothing left to reach them through. Configure " +
474
- "one (quickJsExecutor() from \"@zackbart/connecta/quickjs\" on Node, " +
475
- "new DynamicWorkerExecutor({ loader: env.LOADER }) on Workers).",
454
+ "ConnectaConfig.executor is required. Configure quickJsExecutor() from " +
455
+ '"@zackbart/connecta/quickjs" on Node, or ' +
456
+ "new DynamicWorkerExecutor({ loader: env.LOADER }) from " +
457
+ '"@cloudflare/codemode" on Workers.',
476
458
  );
477
459
  }
478
- return surface;
479
- }
480
-
481
- export function createConnecta(config: ConnectaConfig): Connecta {
482
- assertNoLegacyConfig(config);
483
- const surface = resolveSurface(config);
484
460
  const storage = config.storage ?? memoryStorage();
485
461
  const logger = config.logger ?? defaultLogger();
486
462
  const credentialConnectors = config.connectors.filter((c) => c.credential);
@@ -524,9 +500,6 @@ export function createConnecta(config: ConnectaConfig): Connecta {
524
500
  ...(config.calls?.maxResultBytes !== undefined
525
501
  ? { maxResultBytes: config.calls.maxResultBytes }
526
502
  : {}),
527
- ...(config.calls?.maxBatchResultBytes !== undefined
528
- ? { maxBatchResultBytes: config.calls.maxBatchResultBytes }
529
- : {}),
530
503
  });
531
504
  const inboundAuth = normalizeAuth(
532
505
  accessTokens ? [accessTokens.auth, ...configuredAuth] : configuredAuth,
@@ -542,10 +515,10 @@ export function createConnecta(config: ConnectaConfig): Connecta {
542
515
  );
543
516
  let codeAdmission: AdmissionController | undefined;
544
517
  let executor = config.executor;
545
- if (executor && !isAdmittingExecutor(executor)) {
518
+ if (!isAdmittingExecutor(executor)) {
546
519
  codeAdmission = configuredCodeAdmission;
547
520
  executor = withExecutorAdmission(executor, codeAdmission);
548
- } else if (executor && config.admission?.code) {
521
+ } else if (config.admission?.code) {
549
522
  logger.warn(
550
523
  "[connecta] admission.code is ignored because the configured executor " +
551
524
  "implements acquire() and owns its admission pool; configure that " +
@@ -571,8 +544,7 @@ export function createConnecta(config: ConnectaConfig): Connecta {
571
544
  ...(config.activity?.deploymentId !== undefined
572
545
  ? { activityDeploymentId: config.activity.deploymentId }
573
546
  : {}),
574
- ...(executor !== undefined ? { executor } : {}),
575
- surface,
547
+ executor,
576
548
  requestAdmission,
577
549
  ...(config.calls?.defaultTimeoutMs !== undefined
578
550
  ? { defaultToolTimeoutMs: config.calls.defaultTimeoutMs }
@@ -653,7 +625,6 @@ export type {
653
625
  ConnectorCallAdmissionRule,
654
626
  ConnectorRollingWindowBudget,
655
627
  ConnectaBranding,
656
- ConnectaSurface,
657
628
  ConnectorCredentialAccess,
658
629
  ConnectorCredentialConfig,
659
630
  ConnectorCredentialFieldConfig,
package/src/invocation.ts CHANGED
@@ -395,8 +395,8 @@ export class InvocationService {
395
395
  // A connector whose catalog cannot be fetched is as unusable as one
396
396
  // whose execution fails, so it feeds health accounting the same way the
397
397
  // attempt catch below does — otherwise a connector every call fails
398
- // against (a revoked downstream grant, say) still reads clean from the
399
- // cheap `list_connectors({ probe: false })` signal.
398
+ // against (a revoked downstream grant, say) still reads clean in the
399
+ // deployment's health log.
400
400
  //
401
401
  // Recorded HERE rather than inside the registry's catalog fetch because
402
402
  // a cache hit that avoids a live listTools call records nothing — it is