@zackbart/connecta 0.12.2 → 0.13.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 (50) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +4 -1
  3. package/dist/catalog-service.d.ts +41 -0
  4. package/dist/catalog-service.d.ts.map +1 -1
  5. package/dist/catalog-service.js +94 -5
  6. package/dist/catalog-service.js.map +1 -1
  7. package/dist/connectors/api.d.ts +5 -4
  8. package/dist/connectors/api.d.ts.map +1 -1
  9. package/dist/connectors/api.js.map +1 -1
  10. package/dist/connectors/remote-mcp.d.ts +5 -4
  11. package/dist/connectors/remote-mcp.d.ts.map +1 -1
  12. package/dist/connectors/remote-mcp.js.map +1 -1
  13. package/dist/execute.d.ts.map +1 -1
  14. package/dist/execute.js +12 -10
  15. package/dist/execute.js.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/meta-tools.d.ts.map +1 -1
  20. package/dist/meta-tools.js +5 -4
  21. package/dist/meta-tools.js.map +1 -1
  22. package/dist/providers/mixpanel.d.ts +21 -0
  23. package/dist/providers/mixpanel.d.ts.map +1 -0
  24. package/dist/providers/mixpanel.js +183 -0
  25. package/dist/providers/mixpanel.js.map +1 -0
  26. package/dist/skills.d.ts +7 -9
  27. package/dist/skills.d.ts.map +1 -1
  28. package/dist/skills.js +58 -24
  29. package/dist/skills.js.map +1 -1
  30. package/dist/types.d.ts +26 -6
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/version.d.ts +1 -1
  33. package/dist/version.js +1 -1
  34. package/documentation/code-mode.md +6 -6
  35. package/documentation/connectors.md +116 -4
  36. package/documentation/meta-tools.md +80 -8
  37. package/documentation/mixpanel.md +72 -0
  38. package/ethos.md +8 -3
  39. package/package.json +5 -1
  40. package/src/catalog-service.ts +139 -4
  41. package/src/connectors/api.ts +5 -3
  42. package/src/connectors/remote-mcp.ts +5 -3
  43. package/src/execute.ts +18 -10
  44. package/src/index.ts +1 -0
  45. package/src/meta-tools.ts +10 -4
  46. package/src/providers/mixpanel.ts +220 -0
  47. package/src/skills.ts +64 -23
  48. package/src/types.ts +27 -6
  49. package/src/version.ts +1 -1
  50. package/templates/node/package.json +1 -1
package/src/skills.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { Connector } from "./types.js";
2
2
 
3
3
  export const CONNECTA_INSTRUCTIONS =
4
- 'Connecta exposes seven meta-tools. execute_code is primary: use connecta.search, describe, call, and batch for discovery, multiple or dependent calls, loops, joins, and result reduction. connecta.ui(html) is a guest function inside execute_code, never a connector address or search_tools result; pass one HTML string for display-only, or bind named read-only refresh/drill-down calls in its optional reads argument, and return the same initial summary data the HTML renders. For one read at an unknown address, search_tools with 2–4 distinctive action/object terms and includeSchemas="compact", then one call_tool — a lone cold call is cheaper direct than a program. Use call_destructive_tool individually for unannotated, write-capable, or destructive tools; authorize_connector follows auth_required; get_result follows truncation. If this routing is unfamiliar, fetch skills({ name: "usage" }).';
4
+ 'Connecta exposes seven meta-tools. For one read at an unknown address, search_tools with 2–4 distinctive action/object terms and includeSchemas="compact", then one call_tool — a lone cold call is cheaper direct than a program. For read-only reduction, multiple or dependent calls, loops, joins, or branches, do not call top-level search_tools: make one execute_code call whose program searches, selects, calls, and reduces; never return discovery for another call. connecta.ui(html) is a guest function inside execute_code, never a connector address or search_tools result; pass one HTML string for display-only, or bind named read-only refresh/drill-down calls in its optional reads argument, and return the same initial summary data the HTML renders. Unannotated, write-capable, or destructive tools stay top level: search_tools, then call_destructive_tool; authorize_connector follows auth_required; get_result follows truncation. If this routing is unfamiliar, fetch skills({ name: "usage" }).';
5
5
 
6
- export const USAGE_SKILL = `# Connecta usage
6
+ const USAGE_SKILL_BASE = `# Connecta usage
7
7
 
8
8
  ## The surface
9
9
 
@@ -23,7 +23,7 @@ Use exact addresses from discovery; never invent one. Search 2–4 distinctive a
23
23
 
24
24
  One async arrow function. The only capabilities are one global per connector (\`<connectorId>.<toolName>(args)\`), the \`connecta\` functions, and \`console.log\`.
25
25
 
26
- - \`connecta.search({})\` browses every catalog; \`safety: "readOnly"\` narrows to calls a program can execute, \`connector: "<id>"\` to one. This filters results, not authority; matches carry \`address\` and annotations.
26
+ - \`connecta.search({})\` loads all catalogs; pass \`connector: "<id>"\` when obvious to load one. \`safety: "readOnly"\` keeps executable calls. Neither grants authority. Matches carry \`address\` and annotations.
27
27
  - Exact schemas: \`connecta.describe({ address: "connector.tool" })\` for one, \`{ addresses: [...] }\` for many; \`format: "json"\` only for exact constraints.
28
28
  - Two to ten independent calls: \`connecta.batch([...])\`. Each outcome is \`{ address, ok: true, data }\` or \`{ address, ok: false, error, errorDetails: { code, retryable } }\` — how a program tells a policy refusal from a transient failure.
29
29
  - Search inside the run, not before it; return only the reduction the answer needs, never raw payloads.
@@ -35,18 +35,16 @@ One async arrow function. The only capabilities are one global per connector (\`
35
35
 
36
36
  `;
37
37
 
38
- /**
39
- * Appended to USAGE_SKILL only when the deployment actually has at least one
40
- * connector guide. A deployment with none — every deployment that has not
41
- * adopted the feature — keeps the base guide byte-for-byte, rather than paying
42
- * context for an instruction to fetch guides that do not exist.
43
- */
44
- export const CONNECTOR_GUIDES_SECTION = `
38
+ /** Deployment-scoped guide routing appended to the shared usage guide. */
39
+ const CONNECTOR_GUIDES_SECTION = `
45
40
  ## Per-connector guides
46
41
 
47
- Some connectors here ship their own usage guide preferred tools, address quirks, pagination conventions, rate-limit etiquette, query patterns. \`skills({})\` lists each one as \`connector:<connectorId>\`; fetch it with \`skills({ name: "connector:<connectorId>" })\`. \`search_tools\`, \`connecta.search\`, and \`connecta.describe\` set \`guide\` on matches whose connector has one. Read a connector's guide before working with it for the first time in a task.
42
+ When a connector here ships a deployment-scoped usage guide, \`skills({})\` and discovery return the exact \`guide\` name plus a bounded \`guideSummary\` saying what it covers. Fetch only a listed or carried name with \`skills({ name: <guide> })\`; never infer one from a connector id. \`guideRequired: true\` is a hard stop: fetch before calling. \`guideRequiredReasons\` says why — \`connector_required\` and \`approval_required\` stand however you expand the schema; \`schema_truncated\` clears once describe returns the exact one. Otherwise fetch when the summary names a connector-specific sequence, unit, pagination rule, alias, or generic API convention relevant to the task. A read-only call whose compact schema is complete and unambiguous may proceed without fetching an otherwise irrelevant guide. Connector guides do not replace the shared Connecta usage guide and never apply to another deployment implicitly.
48
43
  `;
49
44
 
45
+ /** Shared Connecta routing guidance, byte-identical across deployments. */
46
+ export const USAGE_SKILL = USAGE_SKILL_BASE + CONNECTOR_GUIDES_SECTION;
47
+
50
48
  /** The always-loaded MCP `instructions` string. */
51
49
  export function instructionsFor(): string {
52
50
  return CONNECTA_INSTRUCTIONS;
@@ -59,10 +57,14 @@ export function hasConnectorGuides(connectors: readonly Connector[]): boolean {
59
57
  );
60
58
  }
61
59
 
62
- /** The built-in usage guide, plus the guides section when there is one to point at. */
63
- function usageSkill(connectors: readonly Connector[]): string {
64
- if (!hasConnectorGuides(connectors)) return USAGE_SKILL;
65
- return USAGE_SKILL + CONNECTOR_GUIDES_SECTION;
60
+ /**
61
+ * The built-in usage guide is byte-identical across deployments, so an agent
62
+ * that has read it once in a task never needs an equivalent deployment-local
63
+ * copy. Guide-free deployments still pay no fixed tool-description cost: the
64
+ * conditional notes in meta-tools.ts remain absent.
65
+ */
66
+ function usageSkill(_connectors: readonly Connector[]): string {
67
+ return USAGE_SKILL;
66
68
  }
67
69
 
68
70
  const AVAILABLE_SKILLS = [
@@ -91,7 +93,8 @@ export function connectorSkillName(connectorId: string): string {
91
93
  /** The connector's guide, or undefined when it declares none (or a blank one). */
92
94
  export function connectorGuide(connector: Connector): string | undefined {
93
95
  const guide = connector.usageGuide;
94
- return guide && guide.trim() !== "" ? guide : undefined;
96
+ const content = typeof guide === "string" ? guide : guide?.content;
97
+ return content && content.trim() !== "" ? content : undefined;
95
98
  }
96
99
 
97
100
  const SUMMARY_LENGTH = 120;
@@ -125,8 +128,17 @@ function withoutFrontmatter(lines: string[]): string[] {
125
128
  * the connector's own description when the guide opens with nothing but
126
129
  * markup.
127
130
  */
131
+ function boundedSummary(summary: string): string | undefined {
132
+ const line = summary.replace(/\s+/g, " ").trim();
133
+ if (line === "") return undefined;
134
+ return line.length <= SUMMARY_LENGTH
135
+ ? line
136
+ : `${line.slice(0, SUMMARY_LENGTH - 1).trimEnd()}…`;
137
+ }
138
+
128
139
  function summarizeGuide(connector: Connector, guide: string): string {
129
140
  let inFence = false;
141
+ let headingFallback: string | undefined;
130
142
  for (const raw of withoutFrontmatter(guide.split("\n"))) {
131
143
  if (FENCE_RE.test(raw)) {
132
144
  inFence = !inFence;
@@ -134,6 +146,7 @@ function summarizeGuide(connector: Connector, guide: string): string {
134
146
  }
135
147
  if (inFence) continue;
136
148
  if (raw.trim() === "" || NOT_SUMMARY_RE.test(raw)) continue;
149
+ const heading = /^\s*#{1,6}/.test(raw);
137
150
  const line = raw
138
151
  // `\s*` (not `\s+`) so a bare `#` strips to nothing and is skipped, and
139
152
  // an unspaced `#Heading` is still read as a heading.
@@ -142,11 +155,37 @@ function summarizeGuide(connector: Connector, guide: string): string {
142
155
  .replace(/\s+/g, " ")
143
156
  .trim();
144
157
  if (line === "") continue;
145
- return line.length <= SUMMARY_LENGTH
146
- ? line
147
- : `${line.slice(0, SUMMARY_LENGTH - 1).trimEnd()}…`;
158
+ if (heading) {
159
+ headingFallback ??= boundedSummary(line);
160
+ continue;
161
+ }
162
+ return boundedSummary(line) ?? line;
148
163
  }
149
- return connector.description ?? `Usage guide for "${connector.id}".`;
164
+ if (headingFallback) return headingFallback;
165
+ const fallback = connector.description ?? `Usage guide for "${connector.id}".`;
166
+ return boundedSummary(fallback) ?? `Usage guide for "${connector.id}".`;
167
+ }
168
+
169
+ /** Bounded, decision-useful discovery summary for a connector guide. */
170
+ export function connectorGuideSummary(
171
+ connector: Connector,
172
+ ): string | undefined {
173
+ const guide = connectorGuide(connector);
174
+ if (!guide) return undefined;
175
+ const configured =
176
+ typeof connector.usageGuide === "object"
177
+ ? boundedSummary(connector.usageGuide.summary ?? "")
178
+ : undefined;
179
+ return configured ?? summarizeGuide(connector, guide);
180
+ }
181
+
182
+ /** Whether correct use always depends on conventions outside the tool schema. */
183
+ export function connectorGuideRequired(connector: Connector): boolean {
184
+ return (
185
+ connectorGuide(connector) !== undefined &&
186
+ typeof connector.usageGuide === "object" &&
187
+ connector.usageGuide.required === true
188
+ );
150
189
  }
151
190
 
152
191
  export interface SkillListing {
@@ -165,11 +204,13 @@ export function listSkills(connectors: readonly Connector[]): SkillListing[] {
165
204
  description: skill.description,
166
205
  }));
167
206
  for (const connector of connectors) {
168
- const guide = connectorGuide(connector);
169
- if (!guide) continue;
207
+ // Undefined here means "no guide" and nothing else: a connector that has
208
+ // one always summarizes to a non-empty line, configured or derived.
209
+ const summary = connectorGuideSummary(connector);
210
+ if (!summary) continue;
170
211
  listing.push({
171
212
  name: connectorSkillName(connector.id),
172
- description: summarizeGuide(connector, guide),
213
+ description: summary,
173
214
  });
174
215
  }
175
216
  return listing;
package/src/types.ts CHANGED
@@ -212,13 +212,17 @@ export interface Connector {
212
212
  */
213
213
  callAdmission?: ConnectorCallAdmissionPolicy;
214
214
  /**
215
- * Optional agent-facing usage guide (markdown) for this connector preferred
216
- * tools, address quirks, pagination conventions, rate-limit etiquette, good
217
- * query patterns. Listed by the `skills` meta-tool as `connector:<id>` and
218
- * returned verbatim by `skills({ name: "connector:<id>" })`. Keep it concise
219
- * and imperative; it is read by agents, not operators.
215
+ * Optional agent-facing usage guide for this connector. A string preserves
216
+ * the original markdown-only contract. The structured form can add a short
217
+ * discovery summary and require review when even a complete compact schema
218
+ * cannot describe correct use (for example a generic API wrapper or a
219
+ * cross-operation sequencing rule).
220
+ *
221
+ * Listed by `skills` as `connector:<id>` and returned verbatim by
222
+ * `skills({ name: "connector:<id>" })`. The guide remains deployment-owned
223
+ * configuration; no runtime registration or shared mutable copy exists.
220
224
  */
221
- usageGuide?: string;
225
+ usageGuide?: string | ConnectorUsageGuide;
222
226
  /** Optional operator-managed credential slot rendered on /credentials. */
223
227
  credential?: ConnectorCredentialConfig;
224
228
  /** Optional server-side check used by /credentials' Test action. */
@@ -309,6 +313,23 @@ export interface Connector {
309
313
  ): Promise<Response | null>;
310
314
  }
311
315
 
316
+ export interface ConnectorUsageGuide {
317
+ /** Markdown returned verbatim by `skills({ name: "connector:<id>" })`. */
318
+ content: string;
319
+ /**
320
+ * Bounded discovery hint describing the conventions the guide covers. When
321
+ * omitted, Connecta derives a summary from the guide's first meaningful line.
322
+ */
323
+ summary?: string;
324
+ /**
325
+ * Require review before every operation on this connector. Reserve this for
326
+ * cases whose correct arguments or sequence cannot be expressed by the
327
+ * downstream tool schema; mutations and truncated schemas are required
328
+ * automatically and do not need this flag.
329
+ */
330
+ required?: boolean;
331
+ }
332
+
312
333
  /** Result of one sandboxed code execution. */
313
334
  export interface ExecuteResult {
314
335
  result: unknown;
package/src/version.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * a bump that forgets this file fails the build rather than shipping a stale
5
5
  * version to `/health` and to downstream MCP handshakes.
6
6
  */
7
- export const CONNECTA_VERSION = "0.12.2";
7
+ export const CONNECTA_VERSION = "0.13.0";
@@ -12,7 +12,7 @@
12
12
  "typecheck": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@zackbart/connecta": "0.12.2",
15
+ "@zackbart/connecta": "0.13.0",
16
16
  "quickjs-emscripten": "0.32.0"
17
17
  },
18
18
  "devDependencies": {