@zackbart/connecta 0.7.9 → 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 (180) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +67 -144
  3. package/dist/auth/bearer.d.ts +1 -1
  4. package/dist/auth/bearer.js +4 -4
  5. package/dist/auth/bearer.js.map +1 -1
  6. package/dist/auth/clerk.d.ts +1 -1
  7. package/dist/auth/clerk.js +1 -1
  8. package/dist/call-admission.d.ts.map +1 -1
  9. package/dist/call-admission.js +9 -3
  10. package/dist/call-admission.js.map +1 -1
  11. package/dist/catalog-fingerprint.d.ts +20 -0
  12. package/dist/catalog-fingerprint.d.ts.map +1 -0
  13. package/dist/catalog-fingerprint.js +34 -0
  14. package/dist/catalog-fingerprint.js.map +1 -0
  15. package/dist/catalog-limits.d.ts +10 -0
  16. package/dist/catalog-limits.d.ts.map +1 -0
  17. package/dist/catalog-limits.js +10 -0
  18. package/dist/catalog-limits.js.map +1 -0
  19. package/dist/catalog-service.d.ts +138 -0
  20. package/dist/catalog-service.d.ts.map +1 -0
  21. package/dist/catalog-service.js +407 -0
  22. package/dist/catalog-service.js.map +1 -0
  23. package/dist/catalog.js +2 -2
  24. package/dist/catalog.js.map +1 -1
  25. package/dist/concurrency.d.ts +4 -0
  26. package/dist/concurrency.d.ts.map +1 -0
  27. package/dist/concurrency.js +31 -0
  28. package/dist/concurrency.js.map +1 -0
  29. package/dist/connectors/api.d.ts.map +1 -1
  30. package/dist/connectors/api.js +22 -12
  31. package/dist/connectors/api.js.map +1 -1
  32. package/dist/connectors/remote-mcp.d.ts.map +1 -1
  33. package/dist/connectors/remote-mcp.js +44 -19
  34. package/dist/connectors/remote-mcp.js.map +1 -1
  35. package/dist/credential-health.d.ts +0 -22
  36. package/dist/credential-health.d.ts.map +1 -1
  37. package/dist/credential-health.js +14 -10
  38. package/dist/credential-health.js.map +1 -1
  39. package/dist/credentials.d.ts +3 -2
  40. package/dist/credentials.d.ts.map +1 -1
  41. package/dist/errors.d.ts +1 -1
  42. package/dist/errors.d.ts.map +1 -1
  43. package/dist/errors.js.map +1 -1
  44. package/dist/execute.d.ts +9 -8
  45. package/dist/execute.d.ts.map +1 -1
  46. package/dist/execute.js +144 -321
  47. package/dist/execute.js.map +1 -1
  48. package/dist/executor-result.d.ts +0 -3
  49. package/dist/executor-result.d.ts.map +1 -1
  50. package/dist/executor-result.js +2 -2
  51. package/dist/executor-result.js.map +1 -1
  52. package/dist/executors/quickjs-child.js +3 -3
  53. package/dist/executors/quickjs-child.js.map +1 -1
  54. package/dist/executors/quickjs-protocol.d.ts +4 -1
  55. package/dist/executors/quickjs-protocol.d.ts.map +1 -1
  56. package/dist/executors/quickjs-runtime.d.ts.map +1 -1
  57. package/dist/executors/quickjs-runtime.js +7 -2
  58. package/dist/executors/quickjs-runtime.js.map +1 -1
  59. package/dist/executors/quickjs.d.ts.map +1 -1
  60. package/dist/executors/quickjs.js +4 -1
  61. package/dist/executors/quickjs.js.map +1 -1
  62. package/dist/favicon.js +2 -2
  63. package/dist/favicon.js.map +1 -1
  64. package/dist/index.d.ts +5 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +44 -17
  67. package/dist/index.js.map +1 -1
  68. package/dist/invocation.d.ts +96 -0
  69. package/dist/invocation.d.ts.map +1 -0
  70. package/dist/invocation.js +369 -0
  71. package/dist/invocation.js.map +1 -0
  72. package/dist/meta-tools.d.ts +8 -86
  73. package/dist/meta-tools.d.ts.map +1 -1
  74. package/dist/meta-tools.js +145 -583
  75. package/dist/meta-tools.js.map +1 -1
  76. package/dist/operator-ui/generated.d.ts +3 -0
  77. package/dist/operator-ui/generated.d.ts.map +1 -0
  78. package/dist/operator-ui/generated.js +5 -0
  79. package/dist/operator-ui/generated.js.map +1 -0
  80. package/dist/operator-ui/model.d.ts +94 -0
  81. package/dist/operator-ui/model.d.ts.map +1 -0
  82. package/dist/operator-ui/model.js +28 -0
  83. package/dist/operator-ui/model.js.map +1 -0
  84. package/dist/registry.d.ts +22 -6
  85. package/dist/registry.d.ts.map +1 -1
  86. package/dist/registry.js +328 -35
  87. package/dist/registry.js.map +1 -1
  88. package/dist/routes/activity.d.ts +3 -0
  89. package/dist/routes/activity.d.ts.map +1 -0
  90. package/dist/routes/activity.js +173 -0
  91. package/dist/routes/activity.js.map +1 -0
  92. package/dist/routes/credentials.d.ts +3 -0
  93. package/dist/routes/credentials.d.ts.map +1 -0
  94. package/dist/routes/credentials.js +181 -0
  95. package/dist/routes/credentials.js.map +1 -0
  96. package/dist/routes/mcp.d.ts +8 -0
  97. package/dist/routes/mcp.d.ts.map +1 -0
  98. package/dist/routes/mcp.js +383 -0
  99. package/dist/routes/mcp.js.map +1 -0
  100. package/dist/routes/oauth.d.ts +4 -0
  101. package/dist/routes/oauth.d.ts.map +1 -0
  102. package/dist/routes/oauth.js +268 -0
  103. package/dist/routes/oauth.js.map +1 -0
  104. package/dist/routes/shared.d.ts +97 -0
  105. package/dist/routes/shared.d.ts.map +1 -0
  106. package/dist/routes/shared.js +199 -0
  107. package/dist/routes/shared.js.map +1 -0
  108. package/dist/routes/ui.d.ts +3 -0
  109. package/dist/routes/ui.d.ts.map +1 -0
  110. package/dist/routes/ui.js +122 -0
  111. package/dist/routes/ui.js.map +1 -0
  112. package/dist/server.d.ts +9 -40
  113. package/dist/server.d.ts.map +1 -1
  114. package/dist/server.js +63 -1293
  115. package/dist/server.js.map +1 -1
  116. package/dist/skills.d.ts +0 -15
  117. package/dist/skills.d.ts.map +1 -1
  118. package/dist/skills.js +6 -5
  119. package/dist/skills.js.map +1 -1
  120. package/dist/storage/file.d.ts.map +1 -1
  121. package/dist/storage/file.js +3 -1
  122. package/dist/storage/file.js.map +1 -1
  123. package/dist/storage/memory.d.ts.map +1 -1
  124. package/dist/storage/memory.js +3 -1
  125. package/dist/storage/memory.js.map +1 -1
  126. package/dist/toolkits.d.ts +0 -22
  127. package/dist/toolkits.d.ts.map +1 -1
  128. package/dist/toolkits.js +2 -2
  129. package/dist/toolkits.js.map +1 -1
  130. package/dist/types.d.ts +9 -2
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/ui.d.ts +3 -93
  133. package/dist/ui.d.ts.map +1 -1
  134. package/dist/ui.js +26 -1393
  135. package/dist/ui.js.map +1 -1
  136. package/dist/version.d.ts +1 -1
  137. package/dist/version.js +1 -1
  138. package/package.json +15 -8
  139. package/src/auth/bearer.ts +4 -4
  140. package/src/auth/clerk.ts +1 -1
  141. package/src/call-admission.ts +8 -5
  142. package/src/catalog-fingerprint.ts +52 -0
  143. package/src/catalog-limits.ts +11 -0
  144. package/src/catalog-service.ts +601 -0
  145. package/src/catalog.ts +2 -2
  146. package/src/concurrency.ts +39 -0
  147. package/src/connectors/api.ts +22 -12
  148. package/src/connectors/remote-mcp.ts +52 -22
  149. package/src/credential-health.ts +13 -10
  150. package/src/credentials.ts +2 -2
  151. package/src/errors.ts +1 -1
  152. package/src/execute.ts +194 -409
  153. package/src/executor-result.ts +2 -2
  154. package/src/executors/quickjs-child.ts +8 -4
  155. package/src/executors/quickjs-protocol.ts +1 -1
  156. package/src/executors/quickjs-runtime.ts +5 -1
  157. package/src/executors/quickjs.ts +11 -8
  158. package/src/favicon.ts +2 -2
  159. package/src/index.ts +49 -17
  160. package/src/invocation.ts +527 -0
  161. package/src/meta-tools.ts +366 -906
  162. package/src/operator-ui/browser.css +413 -0
  163. package/src/operator-ui/browser.ts +1121 -0
  164. package/src/operator-ui/generated.ts +4 -0
  165. package/src/operator-ui/model.ts +127 -0
  166. package/src/registry.ts +434 -44
  167. package/src/routes/activity.ts +220 -0
  168. package/src/routes/credentials.ts +266 -0
  169. package/src/routes/mcp.ts +485 -0
  170. package/src/routes/oauth.ts +328 -0
  171. package/src/routes/shared.ts +330 -0
  172. package/src/routes/ui.ts +153 -0
  173. package/src/server.ts +66 -1703
  174. package/src/skills.ts +6 -5
  175. package/src/storage/file.ts +3 -1
  176. package/src/storage/memory.ts +3 -1
  177. package/src/toolkits.ts +2 -2
  178. package/src/types.ts +9 -2
  179. package/src/ui.ts +52 -1493
  180. 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
@@ -320,6 +320,13 @@ export interface ExecuteResult {
320
320
  export interface ExecutorProvider {
321
321
  name: string;
322
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;
323
330
  }
324
331
 
325
332
  /**
@@ -379,7 +386,7 @@ export interface ExecutorLease {
379
386
 
380
387
  /**
381
388
  * Which toolkits one inbound identity may open — the membership half of the
382
- * 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
383
390
  * policy engine: one identity → the toolkit names it may select, plus whether
384
391
  * it may connect with no `?toolkit=` at all.
385
392
  *
@@ -522,7 +529,7 @@ export interface InboundAuth {
522
529
  uiAuth?: UiAuthConfig;
523
530
  /**
524
531
  * Optional toolkit binding for every identity this provider admits
525
- * (docs/toolkits.md). Declared statically so `createConnecta` can validate the
532
+ * (documentation/toolkits.md). Declared statically so `createConnecta` can validate the
526
533
  * names against `ConnectaConfig.toolkits` and throw on a typo — a binding
527
534
  * nobody wrote is not one an operator can reason about. An `authorize` result
528
535
  * may narrow it per identity with its own `toolkitBinding`.