@zackbart/connecta 0.24.4 → 0.26.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 (155) hide show
  1. package/AGENTS.md +43 -12
  2. package/CHANGELOG.md +524 -0
  3. package/README.md +32 -15
  4. package/SECURITY.md +6 -5
  5. package/bin/connecta.mjs +5 -1
  6. package/dist/activity.d.ts +10 -3
  7. package/dist/activity.js +10 -1
  8. package/dist/advertised-schema.js +53 -0
  9. package/dist/artifacts/connector.d.ts +55 -0
  10. package/dist/artifacts/connector.js +724 -0
  11. package/dist/artifacts/document.js +76 -0
  12. package/dist/artifacts/guide.js +140 -0
  13. package/dist/artifacts/html-scan.js +329 -0
  14. package/dist/artifacts/json.js +68 -0
  15. package/dist/artifacts/kv-store.d.ts +20 -0
  16. package/dist/artifacts/kv-store.js +140 -0
  17. package/dist/artifacts/markdown.js +449 -0
  18. package/dist/artifacts/module.d.ts +37 -0
  19. package/dist/artifacts/module.js +60 -0
  20. package/dist/artifacts/operations.d.ts +195 -0
  21. package/dist/artifacts/operations.js +944 -0
  22. package/dist/artifacts/refresh.d.ts +53 -0
  23. package/dist/artifacts/refresh.js +235 -0
  24. package/dist/artifacts/routes.js +194 -0
  25. package/dist/artifacts/types.d.ts +214 -0
  26. package/dist/artifacts/types.js +22 -0
  27. package/dist/artifacts/validate.d.ts +62 -0
  28. package/dist/artifacts/validate.js +652 -0
  29. package/dist/artifacts.d.ts +6 -0
  30. package/dist/artifacts.js +9 -0
  31. package/dist/auth/downstream-oauth.js +490 -106
  32. package/dist/call-admission.js +139 -113
  33. package/dist/catalog-service.js +152 -106
  34. package/dist/catalog.js +297 -38
  35. package/dist/concurrency.js +24 -23
  36. package/dist/connector-access.d.ts +18 -4
  37. package/dist/connector-access.js +65 -20
  38. package/dist/connector-caller.d.ts +8 -0
  39. package/dist/connector-caller.js +19 -0
  40. package/dist/connector-scope.js +6 -37
  41. package/dist/connectors/api.d.ts +2 -2
  42. package/dist/connectors/remote-mcp.d.ts +6 -5
  43. package/dist/connectors/remote-mcp.js +330 -240
  44. package/dist/credential-contract.d.ts +9 -0
  45. package/dist/credential-rules.js +2 -2
  46. package/dist/credentials.d.ts +6 -1
  47. package/dist/credentials.js +45 -3
  48. package/dist/errors.d.ts +16 -1
  49. package/dist/errors.js +28 -0
  50. package/dist/execute.js +745 -282
  51. package/dist/executor-admission.d.ts +11 -1
  52. package/dist/executor-admission.js +145 -63
  53. package/dist/executors/quickjs-runtime.js +4 -2
  54. package/dist/executors/quickjs.js +255 -212
  55. package/dist/fix-prompt.js +37 -0
  56. package/dist/index.d.ts +72 -7
  57. package/dist/index.js +281 -26
  58. package/dist/invocation.js +371 -286
  59. package/dist/meta-tools.js +213 -94
  60. package/dist/module-contracts.d.ts +21 -1
  61. package/dist/oauth-callback-outcome.js +94 -0
  62. package/dist/oauth-sealing.js +29 -0
  63. package/dist/operator-ui/fix-prompts.js +87 -0
  64. package/dist/operator-ui/generated.js +2 -2
  65. package/dist/operator-ui/model.d.ts +103 -1
  66. package/dist/operator-ui/setup-commands.js +53 -0
  67. package/dist/operator-ui/view.js +128 -3
  68. package/dist/program-source.js +321 -0
  69. package/dist/providers/notion.js +2 -2
  70. package/dist/providers/revenuecat.js +32 -5
  71. package/dist/providers/stripe.d.ts +3 -2
  72. package/dist/providers/vercel.js +1 -1
  73. package/dist/registry.d.ts +43 -7
  74. package/dist/registry.js +434 -288
  75. package/dist/resumable.js +1291 -0
  76. package/dist/routes/activity.js +74 -154
  77. package/dist/routes/actor-labels.js +114 -0
  78. package/dist/routes/credentials.js +196 -163
  79. package/dist/routes/mcp.js +228 -112
  80. package/dist/routes/oauth-management.js +73 -71
  81. package/dist/routes/oauth.js +44 -16
  82. package/dist/routes/operator.js +83 -0
  83. package/dist/routes/shared.d.ts +25 -1
  84. package/dist/routes/shared.js +20 -2
  85. package/dist/routes/ui-data.js +211 -0
  86. package/dist/routes/ui.js +76 -35
  87. package/dist/run-journal.js +347 -0
  88. package/dist/runtime/admission.js +43 -0
  89. package/dist/runtime/call-admission.js +67 -0
  90. package/dist/runtime/connector-scope.js +72 -0
  91. package/dist/runtime/run.js +174 -0
  92. package/dist/runtime/services.js +130 -0
  93. package/dist/runtime/shared-read.js +106 -0
  94. package/dist/runtime/storage.js +66 -0
  95. package/dist/server.js +137 -89
  96. package/dist/skills.js +28 -9
  97. package/dist/storage/file.js +39 -2
  98. package/dist/storage/memory.js +28 -16
  99. package/dist/timeout.js +39 -43
  100. package/dist/tool-safety.d.ts +27 -1
  101. package/dist/tool-safety.js +31 -0
  102. package/dist/types.d.ts +45 -7
  103. package/dist/ui.d.ts +25 -4
  104. package/dist/ui.js +77 -167
  105. package/dist/url-safety.js +157 -0
  106. package/dist/version.d.ts +1 -1
  107. package/dist/version.js +1 -1
  108. package/documentation/architecture.md +367 -16
  109. package/documentation/auth.md +163 -2
  110. package/documentation/code-mode.md +274 -56
  111. package/documentation/meta-tools.md +200 -44
  112. package/ethos.md +46 -47
  113. package/examples/worker/AGENTS.md +6 -0
  114. package/examples/worker/README.md +224 -14
  115. package/examples/worker/src/d1-activity-row.ts +14 -2
  116. package/examples/worker/src/d1-activity.ts +4 -2
  117. package/examples/worker/src/d1-storage.ts +116 -0
  118. package/examples/worker/src/index.ts +42 -7
  119. package/examples/worker/src/r2-artifact-blobs.ts +29 -0
  120. package/examples/worker/wrangler.jsonc +21 -5
  121. package/package.json +16 -4
  122. package/templates/node/AGENTS.md +9 -2
  123. package/templates/node/README.md +31 -3
  124. package/templates/node/package.json +1 -1
  125. package/templates/node/src/index.ts +27 -0
  126. package/dist/auth/downstream-oauth.d.ts +0 -200
  127. package/dist/catalog-fingerprint.d.ts +0 -19
  128. package/dist/catalog-limits.d.ts +0 -9
  129. package/dist/catalog-service.d.ts +0 -263
  130. package/dist/catalog.d.ts +0 -87
  131. package/dist/concurrency.d.ts +0 -3
  132. package/dist/connectors/guarded-fetch.d.ts +0 -96
  133. package/dist/credential-rules.d.ts +0 -85
  134. package/dist/execute.d.ts +0 -154
  135. package/dist/executor-result.d.ts +0 -10
  136. package/dist/executors/quickjs-child.d.ts +0 -1
  137. package/dist/executors/quickjs-protocol.d.ts +0 -67
  138. package/dist/favicon.d.ts +0 -1
  139. package/dist/identity.d.ts +0 -4
  140. package/dist/invocation.d.ts +0 -74
  141. package/dist/mcp-result.d.ts +0 -8
  142. package/dist/meta-tools.d.ts +0 -129
  143. package/dist/operator-ui/generated.d.ts +0 -2
  144. package/dist/operator-ui/view.d.ts +0 -188
  145. package/dist/result-shapes.d.ts +0 -13
  146. package/dist/retired-toolkits.d.ts +0 -2
  147. package/dist/routes/activity.d.ts +0 -2
  148. package/dist/routes/credentials.d.ts +0 -2
  149. package/dist/routes/mcp.d.ts +0 -10
  150. package/dist/routes/oauth-management.d.ts +0 -2
  151. package/dist/routes/oauth.d.ts +0 -2
  152. package/dist/routes/ui.d.ts +0 -2
  153. package/dist/server.d.ts +0 -9
  154. package/dist/skills.d.ts +0 -44
  155. package/dist/timeout.d.ts +0 -21
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Contexts the registry built with a sealing vault. Internal on purpose: the
3
+ * public ConnectorContext type does not change, and a connector cannot hand
4
+ * itself a sealer another connector's context carries.
5
+ */
6
+ const sealers = new WeakMap();
7
+ /** A sealer over the vault, or undefined when the vault cannot seal. */
8
+ export function vaultOAuthSealer(vault, connectorId, owner, logger) {
9
+ const { seal, open } = vault;
10
+ if (typeof seal !== "function" || typeof open !== "function")
11
+ return undefined;
12
+ return {
13
+ seal: (physicalKey, plaintext) => seal.call(vault, connectorId, physicalKey, plaintext, owner),
14
+ open: (physicalKey, sealed) => open.call(vault, connectorId, physicalKey, sealed, owner),
15
+ warn: (message) => logger.warn(message),
16
+ };
17
+ }
18
+ export function attachOAuthSealer(ctx, sealer) {
19
+ if (sealer)
20
+ sealers.set(ctx, sealer);
21
+ return ctx;
22
+ }
23
+ export function oauthSealerFor(ctx) {
24
+ return sealers.get(ctx);
25
+ }
26
+ /** Carry the sealer onto a context derived by spreading another. */
27
+ export function inheritOAuthSealer(from, to) {
28
+ return attachOAuthSealer(to, sealers.get(from));
29
+ }
@@ -0,0 +1,87 @@
1
+ import { renderFixPrompt } from "../fix-prompt.js";
2
+ const CATALOGUE = {
3
+ connector_unavailable: {
4
+ problem: "A connector is unavailable: its status check or catalog load failed, or did not finish before the operator page's deadline.",
5
+ steps: [
6
+ "Confirm the connector's downstream URL or API base in the deployment config, and that the deployment can reach it from where it runs.",
7
+ "Check the credentials or headers the connector sends; a rejected credential often surfaces as a failed status rather than as an authorization prompt.",
8
+ "If the downstream is slow rather than down, review the connector's timeouts and the deployment's discovery.probeTimeoutMs.",
9
+ ],
10
+ },
11
+ oauth_required: {
12
+ problem: "A downstream OAuth connector needs authorization: no grant is stored, or the stored grant expired or was revoked and could not be refreshed.",
13
+ steps: [
14
+ "Reauthorize from the operator page (Connect account or Reconnect OAuth) or with authorize_connector; this needs no code change if the grant simply lapsed.",
15
+ "If it needs reauthorizing again soon after, check that the OAuth client requests offline access or a refresh token, and that the storage holding OAuth tokens persists across restarts and is shared by every instance.",
16
+ "If authorization cannot start at all, check the connector's OAuth client configuration and the deployment's publicUrl, which forms the /oauth/callback/<connector id> redirect URI.",
17
+ ],
18
+ },
19
+ credential_required: {
20
+ problem: "A connector with an operator-managed credential slot has no usable credential stored.",
21
+ steps: [
22
+ "An operator with credential administration can add the credential on the operator page; that needs no code change.",
23
+ "If nobody can, grant credential administration through the deployment's identity config (credentialAdministration for shared auth, personalConnection for personal auth), which is denied by default.",
24
+ "Check that the connector's credential declaration (label and fields) matches what the downstream actually needs.",
25
+ ],
26
+ },
27
+ auth_required: {
28
+ problem: "A connector reports that it needs authorization, and its secret lives in deployment configuration rather than in an operator-managed slot.",
29
+ steps: [
30
+ "Find where the connector's secret is read (usually an environment variable or Worker secret passed into the connector config) and confirm it is set in the running environment.",
31
+ "Rotate the secret at the provider if it expired or was revoked, then update the deployment's environment, not its source.",
32
+ "If operators should manage this secret from the page instead, declare a credential slot on the connector and configure a credential vault.",
33
+ ],
34
+ },
35
+ credential_mismatch: {
36
+ problem: "The credential stored for a connector does not match the fields the connector currently declares, so it cannot be used.",
37
+ steps: [
38
+ "If the connector's credential fields changed on purpose, re-enter the credential on the operator page so the stored fields match.",
39
+ "If they changed by accident, restore the previous field names in the connector's credential declaration.",
40
+ ],
41
+ },
42
+ credential_unreadable: {
43
+ problem: "A stored credential exists but could not be read or decrypted.",
44
+ steps: [
45
+ "Check that the credential vault's encryption key in the deployment environment is the one the credential was stored with; a rotated or missing key makes every stored value unreadable.",
46
+ "Check the storage adapter backing the vault is reachable from the deployment.",
47
+ "If the key was lost, remove and re-add the credential on the operator page; the old value cannot be recovered.",
48
+ ],
49
+ },
50
+ credential_test_failed: {
51
+ problem: "The test for a stored connector credential failed: the downstream rejected it, or the test could not reach the downstream.",
52
+ steps: [
53
+ "Confirm the stored value is current at the provider (not rotated, revoked, or scoped too narrowly), and replace it on the operator page if not.",
54
+ "Check that the connector's credential test targets the same API base and auth scheme its tool calls use.",
55
+ ],
56
+ },
57
+ oauth_action_failed: {
58
+ problem: "Restarting or disconnecting a connector's downstream OAuth from the operator page failed.",
59
+ steps: [
60
+ "Check that the connector implements startAuth and disconnectAuth, and that the storage holding its OAuth state is writable.",
61
+ "Check the connector's OAuth client configuration, including the authorization server it discovers or is given.",
62
+ "Confirm the operator has the config-derived permission for this action (credentialAdministration for shared auth, personalConnection for personal auth).",
63
+ ],
64
+ },
65
+ catalog_failed: {
66
+ problem: "A connector reports itself connected, but loading its tool catalog failed, so none of its tools are being served.",
67
+ steps: [
68
+ "Check that the downstream still serves a complete tools list; connecta refuses a partial catalog rather than serving part of it.",
69
+ "Check for tools the connector cannot accept: invalid schemas, missing descriptions, or names that collide.",
70
+ "Pin or upgrade the @zackbart/connecta version if a maintained provider's catalog changed shape underneath it.",
71
+ ],
72
+ },
73
+ catalog_drift: {
74
+ problem: "A hosted provider's live catalog differs from the reviewed manifest shipped with connecta: new unclassified tools, unserved tools, annotation conflicts, or schema changes.",
75
+ steps: [
76
+ "Unclassified tools are withheld until a release classifies them. Check whether a newer @zackbart/connecta release has, and upgrade if so.",
77
+ "If a tool the deployment depends on is now unserved or changed shape, review callers of it before upgrading.",
78
+ "Report drift the release does not cover as an issue on the connecta repository, naming the provider and the kinds of drift but no tool data.",
79
+ ],
80
+ },
81
+ };
82
+ /** The clipboard text for one failure. Fixed by kind; see `CATALOGUE`. */
83
+ export function fixPrompt(kind, connectorId) {
84
+ return renderFixPrompt(CATALOGUE[kind], connectorId);
85
+ }
86
+ /** Every kind, so a test can walk the whole catalogue. */
87
+ export const FIX_PROMPT_KINDS = Object.keys(CATALOGUE);