@zackbart/connecta 0.32.0 → 0.34.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 (158) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +95 -116
  3. package/SECURITY.md +1 -1
  4. package/bin/connecta.mjs +24 -6
  5. package/bin/version.mjs +1 -1
  6. package/dist/access-tokens.d.ts +167 -23
  7. package/dist/access-tokens.js +676 -140
  8. package/dist/activity.d.ts +3 -0
  9. package/dist/agent-identity.js +47 -0
  10. package/dist/auth/cloudflare-access.js +13 -5
  11. package/dist/branding.d.ts +7 -0
  12. package/dist/branding.js +76 -9
  13. package/dist/call-admission-context.js +15 -0
  14. package/dist/call-admission.js +30 -43
  15. package/dist/call-recovery.js +6 -2
  16. package/dist/catalog-service.js +15 -1
  17. package/dist/config-value-sources.js +16 -9
  18. package/dist/config.d.ts +48 -75
  19. package/dist/config.js +144 -36
  20. package/dist/connector-access.d.ts +4 -34
  21. package/dist/connector-access.js +15 -99
  22. package/dist/connector-caller.d.ts +7 -1
  23. package/dist/connector-caller.js +4 -2
  24. package/dist/connectors/api-connector.d.ts +27 -4
  25. package/dist/connectors/api-connector.js +2 -0
  26. package/dist/connectors/remote-mcp.js +2 -0
  27. package/dist/describe-config.d.ts +31 -7
  28. package/dist/describe-config.js +8 -17
  29. package/dist/execute.js +1 -11
  30. package/dist/fix-prompt.js +2 -2
  31. package/dist/index.d.ts +4 -3
  32. package/dist/index.js +30 -10
  33. package/dist/invocation.js +5 -3
  34. package/dist/membership.d.ts +53 -0
  35. package/dist/membership.js +121 -0
  36. package/dist/module-contracts.d.ts +23 -6
  37. package/dist/oauth-callback-outcome.js +2 -2
  38. package/dist/operator-record.d.ts +2 -2
  39. package/dist/operator-record.js +2 -4
  40. package/dist/operator-ui/agents.d.ts +74 -0
  41. package/dist/operator-ui/agents.js +104 -0
  42. package/dist/operator-ui/config-summary.js +562 -0
  43. package/dist/operator-ui/connection-map.js +375 -0
  44. package/dist/operator-ui/contract.d.ts +149 -28
  45. package/dist/operator-ui/endpoints.js +221 -0
  46. package/dist/operator-ui/fix-prompts.js +5 -5
  47. package/dist/operator-ui/generated.js +5 -4
  48. package/dist/operator-ui/member-page.js +97 -0
  49. package/dist/operator-ui/model.d.ts +14 -6
  50. package/dist/operator-ui/overview.js +134 -0
  51. package/dist/operator-ui/view.d.ts +107 -37
  52. package/dist/operator-ui/view.js +163 -86
  53. package/dist/page-styles.js +5 -3
  54. package/dist/provider.d.ts +61 -8
  55. package/dist/provider.js +46 -7
  56. package/dist/providers/_shared/google/workspace.d.ts +56 -17
  57. package/dist/providers/_shared/google/workspace.js +34 -8
  58. package/dist/providers/_shared/rest/tools.js +2 -2
  59. package/dist/providers/_shared/rest/value-safety.d.ts +50 -0
  60. package/dist/providers/_shared/rest/value-safety.js +699 -7
  61. package/dist/providers/ccb/index.js +2 -2
  62. package/dist/providers/cloudflare/index.js +3 -3
  63. package/dist/providers/cloudflare/rest.js +25 -3
  64. package/dist/providers/cloudflare/skill.generated.js +1 -1
  65. package/dist/providers/cloudflare/value-safety.js +32 -0
  66. package/dist/providers/docs/index.js +4 -4
  67. package/dist/providers/docs/skill.generated.js +2 -2
  68. package/dist/providers/drive/index.js +4 -4
  69. package/dist/providers/drive/skill.generated.js +2 -2
  70. package/dist/providers/forms/index.js +4 -4
  71. package/dist/providers/forms/skill.generated.js +2 -2
  72. package/dist/providers/gmail/index.js +11 -9
  73. package/dist/providers/gmail/skill.generated.js +2 -2
  74. package/dist/providers/mixpanel/index.js +1 -1
  75. package/dist/providers/mixpanel/skill.generated.js +3 -3
  76. package/dist/providers/notion/index.d.ts +7 -0
  77. package/dist/providers/notion/index.js +100 -11
  78. package/dist/providers/notion/rest.js +45 -5
  79. package/dist/providers/notion/skill.generated.js +2 -2
  80. package/dist/providers/notion/value-safety.js +30 -5
  81. package/dist/providers/overflow/index.js +2 -2
  82. package/dist/providers/overflow/skill.generated.js +2 -2
  83. package/dist/providers/planning-center/index.js +2 -2
  84. package/dist/providers/planning-center/skill.generated.js +4 -4
  85. package/dist/providers/revenuecat/skill.generated.js +2 -2
  86. package/dist/providers/sheets/index.d.ts +3 -0
  87. package/dist/providers/sheets/index.js +7 -4
  88. package/dist/providers/sheets/skill.generated.js +2 -2
  89. package/dist/providers/slides/index.js +4 -4
  90. package/dist/providers/slides/skill.generated.js +2 -2
  91. package/dist/providers/stripe/rest.js +9 -2
  92. package/dist/providers/stripe/skill.generated.js +1 -1
  93. package/dist/providers/stripe/value-safety.js +22 -0
  94. package/dist/providers/tithely/index.js +1 -1
  95. package/dist/providers/vercel/index.js +1 -1
  96. package/dist/providers/vercel/rest.js +20 -2
  97. package/dist/providers/vercel/skill.generated.js +2 -2
  98. package/dist/providers/vercel/value-safety.js +22 -0
  99. package/dist/registry.d.ts +2 -3
  100. package/dist/registry.js +23 -9
  101. package/dist/routes/access-tokens.js +82 -75
  102. package/dist/routes/activity-disclosure.js +17 -18
  103. package/dist/routes/activity.js +34 -54
  104. package/dist/routes/actor-labels.js +33 -4
  105. package/dist/routes/agent-path.js +43 -0
  106. package/dist/routes/connect.js +16 -12
  107. package/dist/routes/credentials.js +16 -40
  108. package/dist/routes/mcp.js +161 -104
  109. package/dist/routes/oauth-management.js +11 -5
  110. package/dist/routes/oauth.js +5 -11
  111. package/dist/routes/operator.js +24 -23
  112. package/dist/routes/shared.d.ts +60 -20
  113. package/dist/routes/shared.js +187 -96
  114. package/dist/routes/ui-config.js +437 -97
  115. package/dist/routes/ui-data.js +2 -2
  116. package/dist/routes/ui.js +9 -16
  117. package/dist/runtime/call-admission.js +9 -0
  118. package/dist/server.js +5 -0
  119. package/dist/skills.js +10 -0
  120. package/dist/storage/keys.js +9 -1
  121. package/dist/storage/sql.js +5 -1
  122. package/dist/types.d.ts +29 -7
  123. package/dist/ui.d.ts +1 -1
  124. package/dist/ui.js +23 -16
  125. package/dist/usage-guide.js +1 -1
  126. package/dist/version.d.ts +1 -1
  127. package/dist/version.js +1 -1
  128. package/dist/workspace-address.js +9 -0
  129. package/dist/workspace-subject.js +23 -0
  130. package/documentation/README.md +47 -23
  131. package/documentation/architecture.md +371 -61
  132. package/documentation/auth.md +897 -249
  133. package/documentation/code-mode.md +37 -16
  134. package/documentation/deploying.md +126 -25
  135. package/documentation/integrating.md +97 -23
  136. package/documentation/meta-tools.md +50 -31
  137. package/documentation/migration-0.33.md +352 -0
  138. package/documentation/migration-0.34.md +67 -0
  139. package/documentation/operating.md +3 -1
  140. package/documentation/operator-tests.md +147 -34
  141. package/documentation/operator-ui.md +519 -64
  142. package/documentation/provider-auth-migration.md +37 -23
  143. package/documentation/provider-migration-0.29.md +2 -2
  144. package/examples/worker/AGENTS.md +37 -9
  145. package/examples/worker/README.md +127 -61
  146. package/examples/worker/src/connecta.config.ts +40 -23
  147. package/examples/worker/wrangler.jsonc +4 -1
  148. package/package.json +19 -18
  149. package/templates/node/.env.example +3 -0
  150. package/templates/node/AGENTS.md +33 -6
  151. package/templates/node/Dockerfile +2 -2
  152. package/templates/node/README.md +80 -52
  153. package/templates/node/docker-compose.yml +3 -2
  154. package/templates/node/package.json +4 -3
  155. package/templates/node/src/adopt-token.ts +23 -0
  156. package/templates/node/src/connecta.config.ts +28 -12
  157. package/templates/node/src/rotate-token.ts +17 -0
  158. package/templates/node/src/provision-token.ts +0 -17
@@ -1,38 +1,182 @@
1
- import type { IdentityReference, InboundAuth, KVStorage } from "./types.js";
1
+ import type { InboundAuth, KVStorage } from "./types.js";
2
2
  import type { AccessTokensModule } from "./module-contracts.js";
3
- export interface AccessTokenMetadata {
4
- id: string;
3
+ /**
4
+ * One declared agent's token slot as management sees it. Never secret
5
+ * material. `revision` is opaque: it changes on every commit to the slot and
6
+ * is what `expect` names to make an operation conditional on this view.
7
+ */
8
+ export type AgentTokenSlot = {
5
9
  name: string;
6
- tokenPrefix: string;
7
- createdAt: string;
8
- revokedAt?: string;
9
- }
10
- export interface CreatedAccessToken {
10
+ state: "none";
11
+ revision: string;
12
+ } | {
13
+ name: string;
14
+ state: "issued";
15
+ issuedAt: string;
16
+ revision: string;
17
+ } | {
18
+ name: string;
19
+ state: "revoked";
20
+ revokedAt: string;
21
+ revision: string;
22
+ };
23
+ /** A newly issued secret, returned once, and the slot that now admits it. */
24
+ export interface IssuedAgentToken {
11
25
  token: string;
12
- accessToken: AccessTokenMetadata;
26
+ agent: AgentTokenSlot;
13
27
  }
28
+ /** Why a token operation was refused, for routes and provisioning scripts. */
29
+ export declare class AccessTokenError extends Error {
30
+ readonly code: "unknown_agent" | "conflict" | "slot_changed" | "not_adoptable" | "aborted" | "outcome_unknown";
31
+ readonly name = "AccessTokenError";
32
+ constructor(code: "unknown_agent" | "conflict" | "slot_changed" | "not_adoptable" | "aborted" | "outcome_unknown", message: string);
33
+ }
34
+ /** Options every token mutation takes. */
35
+ export interface AccessTokenOperationOptions {
36
+ /**
37
+ * The request this operation serves. Checked before the commit point, the
38
+ * slot's compare-and-set: an abort before it publishes nothing. An abort
39
+ * after a rotation commits revokes the slot, since the secret cannot be
40
+ * delivered.
41
+ */
42
+ signal?: AbortSignal;
43
+ /**
44
+ * The request's own deadline, in epoch milliseconds, when it has one. The
45
+ * operation ends at the earlier of this and `OPERATION_WINDOW_MS` after it
46
+ * starts.
47
+ */
48
+ deadline?: number;
49
+ /**
50
+ * The slot `revision` the caller decided from. When set, the operation
51
+ * refuses with `slot_changed` before minting or writing anything if the
52
+ * slot's current revision differs, and its commit compare-and-sets from
53
+ * exactly the slot with that revision, so a change that lands between the
54
+ * read and the commit refuses the same way instead of being overwritten.
55
+ */
56
+ expect?: string;
57
+ }
58
+ /** Whether `value` has the shape of a slot revision. */
59
+ export declare function isSlotRevision(value: unknown): value is string;
14
60
  /**
15
- * Deployment-scoped personal access tokens. Secret material is never
61
+ * Agent tokens: one slot per agent declared in code. Secret material is never
16
62
  * recoverable: authentication indexes a SHA-256 digest of a random 256-bit
17
- * token, while separately enumerable metadata powers operator management.
63
+ * token, and only that digest persists. A token admits only while its record
64
+ * is bound to a currently declared agent and that agent's slot names it.
18
65
  */
19
66
  export declare class AccessTokenManager {
20
67
  private readonly storage;
21
68
  readonly auth: InboundAuth;
22
- private readonly maxActive;
69
+ private readonly agents;
70
+ private readonly agentOrder;
23
71
  constructor(storage: KVStorage, options?: {
24
- maxActive?: number;
72
+ agents?: readonly string[];
25
73
  });
74
+ private declared;
26
75
  private read;
27
- list(): Promise<AccessTokenMetadata[]>;
28
- create(name: unknown, createdBy: string | IdentityReference): Promise<CreatedAccessToken>;
29
- rename(id: string, name: unknown): Promise<AccessTokenMetadata | null>;
30
- revoke(id: string, revokedBy: string): Promise<AccessTokenMetadata | null>;
31
- private updateRecord;
32
- private updateActive;
76
+ private readSlot;
77
+ /** One slot per declared agent, in declaration order. */
78
+ list(): Promise<AgentTokenSlot[]>;
79
+ /**
80
+ * Issue the agent's first token, or replace its current one.
81
+ *
82
+ * 1. The slot is read. With `expect`, a slot whose revision differs refuses
83
+ * with `slot_changed` before any secret is minted.
84
+ * 2. The new record and its lookup are written. They are inert: admission
85
+ * requires the slot to name the record.
86
+ * 3. `signal` is checked.
87
+ * 4. One compare-and-set of the slot, from exactly what was read to
88
+ * `issued` with the new record, is the only commit point. From it the
89
+ * new secret admits and the previous one refuses. Of concurrent
90
+ * rotations exactly one commits; the others publish nothing and refuse
91
+ * with `slot_changed` when they named `expect`, a conflict otherwise.
92
+ * 5. If the request has ended once the commit is decided, the secret cannot
93
+ * be delivered, so the slot moves forward to `revoked`. Everything after
94
+ * the commit runs inside one `OperationWindow`; if it cannot settle in
95
+ * time this rejects with `outcome_unknown` ("rotate again"), never success.
96
+ *
97
+ * Nothing is ever deleted except this call's own record and lookup, while
98
+ * they are known to be uncommitted. The previous record and lookup stay
99
+ * behind, inert, because the slot no longer names them.
100
+ */
101
+ rotate(name: string, issuedBy?: string, options?: AccessTokenOperationOptions): Promise<IssuedAgentToken>;
102
+ /** Whether the agent's slot names `tokenId`, read back inside the window. */
103
+ private slotNames;
104
+ /**
105
+ * Move the slot forward to `revoked` if it still names `tokenId`, inside the
106
+ * window. An unsettled outcome is reported, never swallowed.
107
+ */
108
+ private revokeIfNamed;
109
+ /**
110
+ * Revoke the agent's token. One compare-and-set of the slot to `revoked` is
111
+ * the commit; `signal` is checked after the read and before it. The record
112
+ * and lookup stay behind, inert. With `expect`, a slot whose revision
113
+ * differs refuses with `slot_changed` before anything is written, and so
114
+ * does a slot that changes between the read and the commit; without it,
115
+ * whatever the slot names by then is revoked instead.
116
+ */
117
+ revoke(name: string, options?: AccessTokenOperationOptions): Promise<AgentTokenSlot>;
118
+ /**
119
+ * Settle a conditional revocation whose commit went unanswered, inside the
120
+ * window. Only a slot carrying this call's own `revocationId` is its
121
+ * success. A slot still as read is revoked again from exactly that slot,
122
+ * with the same id; anything else is `slot_changed`.
123
+ */
124
+ private settleRevocation;
125
+ /**
126
+ * Trusted provisioning: let a declared agent keep using a machine token
127
+ * issued before agents. The legacy record is never changed.
128
+ *
129
+ * 1. A write-once claim, `access-token:v1:adopted:<legacy id>`, is set from
130
+ * absent to the agent's name. It is never deleted: once any adoption has
131
+ * started, the legacy token belongs to that agent forever, even after it
132
+ * is revoked or rotated away, so a retired secret can never be adopted
133
+ * again. It is inert to admission; an abort after it leaves the token
134
+ * adoptable only by the same agent.
135
+ * 2. A new record carrying `agent` and the legacy digest is written; it is
136
+ * inert until the slot names it.
137
+ * 3. `signal` is checked.
138
+ * 4. One compare-and-set of the slot from none to `issued` with the new
139
+ * record is the commit. Adopt delivers no secret, so once committed it is
140
+ * completed even if the request ended.
141
+ * 5. The digest's lookup is moved from the legacy record to the new one by
142
+ * compare-and-set; from then the existing secret admits as the agent.
143
+ *
144
+ * The commit and everything after it run inside one `OperationWindow`.
145
+ * Retrying an adoption whose slot already names a record with this digest
146
+ * completes step 5 and succeeds. With `expect`, a slot whose revision
147
+ * differs refuses with `slot_changed` before the claim, and so does a
148
+ * commit that loses its compare-and-set. Human-bound, revoked, and claimed tokens are
149
+ * refused, as is an agent whose slot names anything else.
150
+ */
151
+ adopt(tokenId: string, name: string, options?: AccessTokenOperationOptions): Promise<AgentTokenSlot>;
152
+ /**
153
+ * Step 4 of adoption, idempotent and inside the window: point the digest's
154
+ * lookup at the record the slot names. If another agent's adoption took the
155
+ * lookup first, this slot can never admit, so it moves forward to `revoked`
156
+ * and this refuses.
157
+ */
158
+ private completeAdoption;
159
+ /** The declared agent whose issued slot names a record with this digest, if any, read inside the window. */
160
+ private agentCarrying;
161
+ /**
162
+ * Trusted provisioning: the legacy records `adopt` can take, oldest first:
163
+ * unbound, unrevoked, never claimed by an adoption, still the owner of their
164
+ * digest's lookup, and with a digest no declared agent's slot carries. Ids, names and creation times
165
+ * only; never secret material.
166
+ */
167
+ unboundTokens(): Promise<Array<{
168
+ id: string;
169
+ name: string;
170
+ createdAt: string;
171
+ }>>;
33
172
  private authorize;
34
173
  }
35
- /** Opt in using the same storage namespace that held the v0.23 records. */
36
- export declare function accessTokens(storage: KVStorage, options?: {
37
- maxActive?: number;
38
- }): AccessTokensModule;
174
+ /** accessTokens() takes no options: the agents declared in code bound its slots. */
175
+ type AccessTokensOptions = Record<never, never>;
176
+ /**
177
+ * Agent token authentication and management over the deployment's storage.
178
+ * Reuse the storage that held earlier tokens so their records stay readable;
179
+ * `createConnecta` binds the module to `agents`.
180
+ */
181
+ export declare function accessTokens(storage: KVStorage, options?: AccessTokensOptions): AccessTokensModule;
182
+ export {};