@zackbart/connecta 0.7.8 → 0.8.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 (187) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +67 -144
  3. package/dist/activity.d.ts +1 -1
  4. package/dist/activity.d.ts.map +1 -1
  5. package/dist/activity.js.map +1 -1
  6. package/dist/auth/bearer.d.ts +1 -1
  7. package/dist/auth/bearer.js +4 -4
  8. package/dist/auth/bearer.js.map +1 -1
  9. package/dist/auth/clerk.d.ts +1 -1
  10. package/dist/auth/clerk.js +1 -1
  11. package/dist/call-admission.d.ts +81 -0
  12. package/dist/call-admission.d.ts.map +1 -0
  13. package/dist/call-admission.js +345 -0
  14. package/dist/call-admission.js.map +1 -0
  15. package/dist/catalog-fingerprint.d.ts +20 -0
  16. package/dist/catalog-fingerprint.d.ts.map +1 -0
  17. package/dist/catalog-fingerprint.js +34 -0
  18. package/dist/catalog-fingerprint.js.map +1 -0
  19. package/dist/catalog-limits.d.ts +10 -0
  20. package/dist/catalog-limits.d.ts.map +1 -0
  21. package/dist/catalog-limits.js +10 -0
  22. package/dist/catalog-limits.js.map +1 -0
  23. package/dist/catalog-service.d.ts +138 -0
  24. package/dist/catalog-service.d.ts.map +1 -0
  25. package/dist/catalog-service.js +407 -0
  26. package/dist/catalog-service.js.map +1 -0
  27. package/dist/catalog.js +2 -2
  28. package/dist/catalog.js.map +1 -1
  29. package/dist/concurrency.d.ts +4 -0
  30. package/dist/concurrency.d.ts.map +1 -0
  31. package/dist/concurrency.js +31 -0
  32. package/dist/concurrency.js.map +1 -0
  33. package/dist/connectors/api.d.ts +3 -1
  34. package/dist/connectors/api.d.ts.map +1 -1
  35. package/dist/connectors/api.js +22 -11
  36. package/dist/connectors/api.js.map +1 -1
  37. package/dist/connectors/remote-mcp.d.ts +3 -1
  38. package/dist/connectors/remote-mcp.d.ts.map +1 -1
  39. package/dist/connectors/remote-mcp.js +44 -18
  40. package/dist/connectors/remote-mcp.js.map +1 -1
  41. package/dist/credential-health.d.ts +0 -22
  42. package/dist/credential-health.d.ts.map +1 -1
  43. package/dist/credential-health.js +14 -10
  44. package/dist/credential-health.js.map +1 -1
  45. package/dist/credentials.d.ts +3 -2
  46. package/dist/credentials.d.ts.map +1 -1
  47. package/dist/errors.d.ts +1 -1
  48. package/dist/errors.d.ts.map +1 -1
  49. package/dist/errors.js.map +1 -1
  50. package/dist/execute.d.ts +9 -8
  51. package/dist/execute.d.ts.map +1 -1
  52. package/dist/execute.js +144 -291
  53. package/dist/execute.js.map +1 -1
  54. package/dist/executor-result.d.ts +0 -3
  55. package/dist/executor-result.d.ts.map +1 -1
  56. package/dist/executor-result.js +2 -2
  57. package/dist/executor-result.js.map +1 -1
  58. package/dist/executors/quickjs-child.js +3 -3
  59. package/dist/executors/quickjs-child.js.map +1 -1
  60. package/dist/executors/quickjs-protocol.d.ts +4 -1
  61. package/dist/executors/quickjs-protocol.d.ts.map +1 -1
  62. package/dist/executors/quickjs-runtime.d.ts.map +1 -1
  63. package/dist/executors/quickjs-runtime.js +7 -2
  64. package/dist/executors/quickjs-runtime.js.map +1 -1
  65. package/dist/executors/quickjs.d.ts.map +1 -1
  66. package/dist/executors/quickjs.js +4 -1
  67. package/dist/executors/quickjs.js.map +1 -1
  68. package/dist/favicon.js +2 -2
  69. package/dist/favicon.js.map +1 -1
  70. package/dist/index.d.ts +6 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +45 -17
  73. package/dist/index.js.map +1 -1
  74. package/dist/invocation.d.ts +96 -0
  75. package/dist/invocation.d.ts.map +1 -0
  76. package/dist/invocation.js +369 -0
  77. package/dist/invocation.js.map +1 -0
  78. package/dist/meta-tools.d.ts +11 -86
  79. package/dist/meta-tools.d.ts.map +1 -1
  80. package/dist/meta-tools.js +145 -485
  81. package/dist/meta-tools.js.map +1 -1
  82. package/dist/operator-ui/generated.d.ts +3 -0
  83. package/dist/operator-ui/generated.d.ts.map +1 -0
  84. package/dist/operator-ui/generated.js +5 -0
  85. package/dist/operator-ui/generated.js.map +1 -0
  86. package/dist/operator-ui/model.d.ts +94 -0
  87. package/dist/operator-ui/model.d.ts.map +1 -0
  88. package/dist/operator-ui/model.js +28 -0
  89. package/dist/operator-ui/model.js.map +1 -0
  90. package/dist/registry.d.ts +47 -6
  91. package/dist/registry.d.ts.map +1 -1
  92. package/dist/registry.js +356 -35
  93. package/dist/registry.js.map +1 -1
  94. package/dist/routes/activity.d.ts +3 -0
  95. package/dist/routes/activity.d.ts.map +1 -0
  96. package/dist/routes/activity.js +173 -0
  97. package/dist/routes/activity.js.map +1 -0
  98. package/dist/routes/credentials.d.ts +3 -0
  99. package/dist/routes/credentials.d.ts.map +1 -0
  100. package/dist/routes/credentials.js +181 -0
  101. package/dist/routes/credentials.js.map +1 -0
  102. package/dist/routes/mcp.d.ts +8 -0
  103. package/dist/routes/mcp.d.ts.map +1 -0
  104. package/dist/routes/mcp.js +383 -0
  105. package/dist/routes/mcp.js.map +1 -0
  106. package/dist/routes/oauth.d.ts +4 -0
  107. package/dist/routes/oauth.d.ts.map +1 -0
  108. package/dist/routes/oauth.js +268 -0
  109. package/dist/routes/oauth.js.map +1 -0
  110. package/dist/routes/shared.d.ts +97 -0
  111. package/dist/routes/shared.d.ts.map +1 -0
  112. package/dist/routes/shared.js +199 -0
  113. package/dist/routes/shared.js.map +1 -0
  114. package/dist/routes/ui.d.ts +3 -0
  115. package/dist/routes/ui.d.ts.map +1 -0
  116. package/dist/routes/ui.js +122 -0
  117. package/dist/routes/ui.js.map +1 -0
  118. package/dist/server.d.ts +9 -40
  119. package/dist/server.d.ts.map +1 -1
  120. package/dist/server.js +67 -1292
  121. package/dist/server.js.map +1 -1
  122. package/dist/skills.d.ts +0 -15
  123. package/dist/skills.d.ts.map +1 -1
  124. package/dist/skills.js +6 -5
  125. package/dist/skills.js.map +1 -1
  126. package/dist/storage/file.d.ts.map +1 -1
  127. package/dist/storage/file.js +3 -1
  128. package/dist/storage/file.js.map +1 -1
  129. package/dist/storage/memory.d.ts.map +1 -1
  130. package/dist/storage/memory.js +3 -1
  131. package/dist/storage/memory.js.map +1 -1
  132. package/dist/toolkits.d.ts +0 -22
  133. package/dist/toolkits.d.ts.map +1 -1
  134. package/dist/toolkits.js +2 -2
  135. package/dist/toolkits.js.map +1 -1
  136. package/dist/types.d.ts +64 -2
  137. package/dist/types.d.ts.map +1 -1
  138. package/dist/ui.d.ts +3 -93
  139. package/dist/ui.d.ts.map +1 -1
  140. package/dist/ui.js +26 -1389
  141. package/dist/ui.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +15 -8
  145. package/src/activity.ts +5 -1
  146. package/src/auth/bearer.ts +4 -4
  147. package/src/auth/clerk.ts +1 -1
  148. package/src/call-admission.ts +522 -0
  149. package/src/catalog-fingerprint.ts +52 -0
  150. package/src/catalog-limits.ts +11 -0
  151. package/src/catalog-service.ts +601 -0
  152. package/src/catalog.ts +2 -2
  153. package/src/concurrency.ts +39 -0
  154. package/src/connectors/api.ts +25 -11
  155. package/src/connectors/remote-mcp.ts +55 -21
  156. package/src/credential-health.ts +13 -10
  157. package/src/credentials.ts +2 -2
  158. package/src/errors.ts +1 -1
  159. package/src/execute.ts +194 -377
  160. package/src/executor-result.ts +2 -2
  161. package/src/executors/quickjs-child.ts +8 -4
  162. package/src/executors/quickjs-protocol.ts +1 -1
  163. package/src/executors/quickjs-runtime.ts +5 -1
  164. package/src/executors/quickjs.ts +11 -8
  165. package/src/favicon.ts +2 -2
  166. package/src/index.ts +54 -17
  167. package/src/invocation.ts +527 -0
  168. package/src/meta-tools.ts +369 -797
  169. package/src/operator-ui/browser.css +413 -0
  170. package/src/operator-ui/browser.ts +1121 -0
  171. package/src/operator-ui/generated.ts +4 -0
  172. package/src/operator-ui/model.ts +127 -0
  173. package/src/registry.ts +489 -44
  174. package/src/routes/activity.ts +220 -0
  175. package/src/routes/credentials.ts +266 -0
  176. package/src/routes/mcp.ts +485 -0
  177. package/src/routes/oauth.ts +328 -0
  178. package/src/routes/shared.ts +330 -0
  179. package/src/routes/ui.ts +153 -0
  180. package/src/server.ts +70 -1702
  181. package/src/skills.ts +6 -5
  182. package/src/storage/file.ts +3 -1
  183. package/src/storage/memory.ts +3 -1
  184. package/src/toolkits.ts +2 -2
  185. package/src/types.ts +70 -2
  186. package/src/ui.ts +52 -1489
  187. package/src/version.ts +1 -1
package/src/skills.ts CHANGED
@@ -75,13 +75,13 @@ export function hasConnectorGuides(connectors: readonly Connector[]): boolean {
75
75
  }
76
76
 
77
77
  /** The built-in usage guide, plus the guides section when there is one to point at. */
78
- export function usageSkill(connectors: readonly Connector[]): string {
78
+ function usageSkill(connectors: readonly Connector[]): string {
79
79
  return hasConnectorGuides(connectors)
80
80
  ? USAGE_SKILL + CONNECTOR_GUIDES_SECTION
81
81
  : USAGE_SKILL;
82
82
  }
83
83
 
84
- export const AVAILABLE_SKILLS = [
84
+ const AVAILABLE_SKILLS = [
85
85
  {
86
86
  name: "usage",
87
87
  description:
@@ -97,7 +97,7 @@ export const AVAILABLE_SKILLS = [
97
97
  * The prefixed form is the ONLY way to reach a connector guide: a bare
98
98
  * connector id is never resolved, so nothing shadows anything silently.
99
99
  */
100
- export const CONNECTOR_SKILL_PREFIX = "connector:";
100
+ const CONNECTOR_SKILL_PREFIX = "connector:";
101
101
 
102
102
  /** The skill name that fetches `connector`'s guide. */
103
103
  export function connectorSkillName(connectorId: string): string {
@@ -128,8 +128,9 @@ const NOT_SUMMARY_RE = /^\s*(?:<!--|\|)|^\s*(?:-{3,}|\*{3,}|_{3,})\s*$/;
128
128
  /** Drop a leading YAML frontmatter block — metadata, not summary text. */
129
129
  function withoutFrontmatter(lines: string[]): string[] {
130
130
  let start = 0;
131
- while (start < lines.length && lines[start].trim() === "") start++;
132
- if (start >= lines.length || !RULE_RE.test(lines[start])) return lines;
131
+ while (start < lines.length && (lines[start] ?? "").trim() === "") start++;
132
+ const openingRule = lines[start];
133
+ if (openingRule === undefined || !RULE_RE.test(openingRule)) return lines;
133
134
  const close = lines.findIndex((line, i) => i > start && RULE_RE.test(line));
134
135
  return close === -1 ? lines : lines.slice(close + 1);
135
136
  }
@@ -104,7 +104,9 @@ export function fileStorage(
104
104
  async set(key, value, opts) {
105
105
  data[key] = {
106
106
  value,
107
- exp: opts?.ttlSeconds ? Date.now() + opts.ttlSeconds * 1000 : undefined,
107
+ ...(opts?.ttlSeconds
108
+ ? { exp: Date.now() + opts.ttlSeconds * 1000 }
109
+ : {}),
108
110
  };
109
111
  persist();
110
112
  },
@@ -24,7 +24,9 @@ export function memoryStorage(): KVStorage {
24
24
  async set(key, value, opts) {
25
25
  map.set(key, {
26
26
  value,
27
- exp: opts?.ttlSeconds ? Date.now() + opts.ttlSeconds * 1000 : undefined,
27
+ ...(opts?.ttlSeconds
28
+ ? { exp: Date.now() + opts.ttlSeconds * 1000 }
29
+ : {}),
28
30
  });
29
31
  },
30
32
  async delete(key) {
package/src/toolkits.ts CHANGED
@@ -137,7 +137,7 @@ function toolFilter(
137
137
  * an allowlist is a scope the operator did not write, and a scope nobody wrote
138
138
  * is not one an operator can reason about. (A definition scopes visibility only;
139
139
  * WHICH identity may select it is the separate binding below — see the module
140
- * header and docs/toolkits.md.) Tool names are checked only for connectors that expose
140
+ * header and documentation/toolkits.md.) Tool names are checked only for connectors that expose
141
141
  * `staticTools` (i.e. `api()`); a remote connector's catalog is fetched lazily
142
142
  * over the network and is unknown at construction time.
143
143
  */
@@ -331,7 +331,7 @@ export function resolveToolkitBinding(
331
331
  * Returns a frozen, deduplicated copy: nothing downstream can be mutated by the
332
332
  * adapter after the check, and every name is known to fit the grammar.
333
333
  */
334
- export function normalizeToolkitBinding(value: unknown): ToolkitBinding | null {
334
+ function normalizeToolkitBinding(value: unknown): ToolkitBinding | null {
335
335
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
336
336
  return null;
337
337
  }
package/src/types.ts CHANGED
@@ -44,6 +44,61 @@ export interface ToolAnnotations extends Record<string, unknown> {
44
44
  openWorldHint?: boolean;
45
45
  }
46
46
 
47
+ /** Inputs a connector may reduce to a non-secret admission partition key. */
48
+ export interface ConnectorCallAdmissionInput {
49
+ toolName: string;
50
+ args: unknown;
51
+ }
52
+
53
+ /** Exact sliding-window budget for one connector-call partition. */
54
+ export interface ConnectorRollingWindowBudget {
55
+ kind: "rolling-window";
56
+ /** Calls admitted during `windowMs` before another is proactively refused. */
57
+ maxCalls: number;
58
+ /** Width of the rolling window in milliseconds. */
59
+ windowMs: number;
60
+ }
61
+
62
+ /**
63
+ * One connector-level downstream call-admission rule.
64
+ *
65
+ * This release accepts the plural `rules` container below but enforces exactly
66
+ * one rule. That keeps the public shape ready for providers whose concurrency
67
+ * and budget limits eventually need different partition dimensions without
68
+ * pretending multi-rule admission is already atomic.
69
+ */
70
+ export interface ConnectorCallAdmissionRule {
71
+ /** Maximum simultaneous Connector.callTool attempts in one partition. */
72
+ maxConcurrency?: number;
73
+ /** Callers allowed to wait behind the concurrency bound. Default 32. */
74
+ maxQueueSize?: number;
75
+ /** Maximum concurrency-queue wait in milliseconds. Default 5,000. */
76
+ queueTimeoutMs?: number;
77
+ /** Retry hint for concurrency overloads. Default 1,000. */
78
+ retryAfterMs?: number;
79
+ /** Optional exact rolling-window call-start budget. */
80
+ budget?: ConnectorRollingWindowBudget;
81
+ /**
82
+ * Derive a bounded, non-secret partition key from the tool call. Omit for
83
+ * one connector-wide partition. Connecta retains the returned key only; it
84
+ * never copies arguments into limiter state.
85
+ */
86
+ partitionKey?(
87
+ input: Readonly<ConnectorCallAdmissionInput>,
88
+ ): string;
89
+ }
90
+
91
+ /** Optional downstream call-admission policy declared by one connector. */
92
+ export interface ConnectorCallAdmissionPolicy {
93
+ /**
94
+ * Plural-ready policy container. Exactly one rule is supported in this
95
+ * release; empty or multi-rule policies fail construction.
96
+ */
97
+ rules: readonly ConnectorCallAdmissionRule[];
98
+ /** Maximum simultaneously retained partition states. Default 1,024. */
99
+ maxPartitions?: number;
100
+ }
101
+
47
102
  export type ConnectorCredentialValues = Record<string, string>;
48
103
 
49
104
  /** Read-only access to the credentials assigned to one connector. */
@@ -145,6 +200,12 @@ export interface Connector {
145
200
  * the connector inherits the deployment-wide cap.
146
201
  */
147
202
  maxResultBytes?: number;
203
+ /**
204
+ * Optional per-runtime admission policy for downstream tool calls. It covers
205
+ * call_tool, every batch_call child, and execute_code host calls, but not
206
+ * catalog/status/auth operations.
207
+ */
208
+ callAdmission?: ConnectorCallAdmissionPolicy;
148
209
  /**
149
210
  * Optional agent-facing usage guide (markdown) for this connector — preferred
150
211
  * tools, address quirks, pagination conventions, rate-limit etiquette, good
@@ -259,6 +320,13 @@ export interface ExecuteResult {
259
320
  export interface ExecutorProvider {
260
321
  name: string;
261
322
  fns: Record<string, (...args: unknown[]) => Promise<unknown>>;
323
+ /**
324
+ * Optional trusted sandbox-side setup run after provider globals exist.
325
+ * Connecta uses this to install lazy connector namespace proxies without
326
+ * materializing one host closure per tool. This is host-authored code, never
327
+ * model input.
328
+ */
329
+ prelude?: string;
262
330
  }
263
331
 
264
332
  /**
@@ -318,7 +386,7 @@ export interface ExecutorLease {
318
386
 
319
387
  /**
320
388
  * Which toolkits one inbound identity may open — the membership half of the
321
- * deployment=org / toolkit=team framing (docs/toolkits.md). A mapping, never a
389
+ * deployment=org / toolkit=team framing (documentation/toolkits.md). A mapping, never a
322
390
  * policy engine: one identity → the toolkit names it may select, plus whether
323
391
  * it may connect with no `?toolkit=` at all.
324
392
  *
@@ -461,7 +529,7 @@ export interface InboundAuth {
461
529
  uiAuth?: UiAuthConfig;
462
530
  /**
463
531
  * Optional toolkit binding for every identity this provider admits
464
- * (docs/toolkits.md). Declared statically so `createConnecta` can validate the
532
+ * (documentation/toolkits.md). Declared statically so `createConnecta` can validate the
465
533
  * names against `ConnectaConfig.toolkits` and throw on a typo — a binding
466
534
  * nobody wrote is not one an operator can reason about. An `authorize` result
467
535
  * may narrow it per identity with its own `toolkitBinding`.