@clawscarf/cli 0.1.0-alpha.1

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 (197) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/THIRD_PARTY_NOTICES.md +102 -0
  4. package/deploy/execution/browser/LICENSE.playwright +202 -0
  5. package/deploy/execution/browser/seccomp.json +640 -0
  6. package/deploy/execution/browser-node/configuration.js +85 -0
  7. package/deploy/execution/browser-node/operator.js +167 -0
  8. package/deploy/execution/network/node-ingress.cfg +35 -0
  9. package/deploy/models/catalog.json +275 -0
  10. package/deploy/openshell/policy.yaml +24 -0
  11. package/generated/http/LICENSE.md +21 -0
  12. package/generated/http/client/client.gen.d.ts +2 -0
  13. package/generated/http/client/client.gen.js +216 -0
  14. package/generated/http/client/index.d.ts +10 -0
  15. package/generated/http/client/index.js +6 -0
  16. package/generated/http/client/types.gen.d.ts +120 -0
  17. package/generated/http/client/types.gen.js +2 -0
  18. package/generated/http/client/utils.gen.d.ts +37 -0
  19. package/generated/http/client/utils.gen.js +228 -0
  20. package/generated/http/core/auth.gen.d.ts +25 -0
  21. package/generated/http/core/auth.gen.js +14 -0
  22. package/generated/http/core/bodySerializer.gen.d.ts +25 -0
  23. package/generated/http/core/bodySerializer.gen.js +57 -0
  24. package/generated/http/core/params.gen.d.ts +43 -0
  25. package/generated/http/core/params.gen.js +109 -0
  26. package/generated/http/core/pathSerializer.gen.d.ts +33 -0
  27. package/generated/http/core/pathSerializer.gen.js +106 -0
  28. package/generated/http/core/queryKeySerializer.gen.d.ts +18 -0
  29. package/generated/http/core/queryKeySerializer.gen.js +92 -0
  30. package/generated/http/core/serverSentEvents.gen.d.ts +71 -0
  31. package/generated/http/core/serverSentEvents.gen.js +132 -0
  32. package/generated/http/core/types.gen.d.ts +83 -0
  33. package/generated/http/core/types.gen.js +2 -0
  34. package/generated/http/core/utils.gen.d.ts +19 -0
  35. package/generated/http/core/utils.gen.js +87 -0
  36. package/package.json +37 -0
  37. package/packs/README.md +130 -0
  38. package/packs/research-team/pack.json +20 -0
  39. package/packs/research-team/researcher/CLAW.md +19 -0
  40. package/packs/research-team/researcher/package.json +8 -0
  41. package/packs/research-team/researcher/profiles/openclaw.yml +6 -0
  42. package/packs/research-team/reviewer/CLAW.md +19 -0
  43. package/packs/research-team/reviewer/package.json +8 -0
  44. package/packs/research-team/reviewer/profiles/openclaw.yml +6 -0
  45. package/pnpm-lock.yaml +7158 -0
  46. package/recipes/README.md +37 -0
  47. package/recipes/team-server/recipe.json +28 -0
  48. package/release/README.md +137 -0
  49. package/release/components.json +29 -0
  50. package/release/operator.md +63 -0
  51. package/runtime/configuration.js +135 -0
  52. package/runtime/connections-configuration.js +70 -0
  53. package/runtime/model-contract.js +92 -0
  54. package/runtime/releases/0.1.0-alpha.1.json +37 -0
  55. package/scripts/clawscarf.js +92 -0
  56. package/scripts/cloud/login.js +134 -0
  57. package/scripts/cloud/registration.js +232 -0
  58. package/scripts/cloud/url.js +9 -0
  59. package/scripts/connections.js +193 -0
  60. package/scripts/controller.js +143 -0
  61. package/scripts/deployment/browser-node-compose.js +81 -0
  62. package/scripts/deployment/browser-node-helper.js +9 -0
  63. package/scripts/deployment/browser-node-pairing.js +165 -0
  64. package/scripts/deployment/browser-node.js +154 -0
  65. package/scripts/deployment/browser.js +143 -0
  66. package/scripts/deployment/certificates.js +76 -0
  67. package/scripts/deployment/compose.js +191 -0
  68. package/scripts/deployment/configuration.js +275 -0
  69. package/scripts/deployment/connection-policy.js +80 -0
  70. package/scripts/deployment/connection-settings.js +60 -0
  71. package/scripts/deployment/connections-runtime.js +31 -0
  72. package/scripts/deployment/connections.js +213 -0
  73. package/scripts/deployment/controller-compose.js +59 -0
  74. package/scripts/deployment/database.js +199 -0
  75. package/scripts/deployment/entrypoint.js +7 -0
  76. package/scripts/deployment/images.js +17 -0
  77. package/scripts/deployment/initial-services.js +53 -0
  78. package/scripts/deployment/launch.js +177 -0
  79. package/scripts/deployment/logs.js +15 -0
  80. package/scripts/deployment/model-gateway-compose.js +74 -0
  81. package/scripts/deployment/model-gateway.js +125 -0
  82. package/scripts/deployment/models.js +82 -0
  83. package/scripts/deployment/networks.js +354 -0
  84. package/scripts/deployment/policy.js +56 -0
  85. package/scripts/deployment/preflight.js +124 -0
  86. package/scripts/deployment/prepare.js +205 -0
  87. package/scripts/deployment/process.js +70 -0
  88. package/scripts/deployment/relay.js +58 -0
  89. package/scripts/deployment/runtime-binding.js +100 -0
  90. package/scripts/deployment/runtime.js +232 -0
  91. package/scripts/deployment/state.js +154 -0
  92. package/scripts/deployment/team.js +76 -0
  93. package/scripts/deployment/upgrade-rpc.py +148 -0
  94. package/scripts/deployment/upgrade-state.js +47 -0
  95. package/scripts/deployment/upgrade.js +298 -0
  96. package/scripts/deployment/volumes.js +24 -0
  97. package/scripts/errors.js +9 -0
  98. package/scripts/installation/administrator.js +23 -0
  99. package/scripts/installation/command.js +176 -0
  100. package/scripts/installation/configuration.js +104 -0
  101. package/scripts/installation/configure.js +122 -0
  102. package/scripts/installation/delete.js +111 -0
  103. package/scripts/installation/doctor.js +8 -0
  104. package/scripts/installation/errors.js +8 -0
  105. package/scripts/installation/files.js +51 -0
  106. package/scripts/installation/installer/cloud.js +22 -0
  107. package/scripts/installation/installer/collect.js +245 -0
  108. package/scripts/installation/installer/inputs.js +59 -0
  109. package/scripts/installation/installer/menu.js +49 -0
  110. package/scripts/installation/installer/prompts.js +139 -0
  111. package/scripts/installation/installer/run.js +251 -0
  112. package/scripts/installation/installer/secrets.js +16 -0
  113. package/scripts/installation/installer/sections/access.js +69 -0
  114. package/scripts/installation/installer/sections/certificates.js +18 -0
  115. package/scripts/installation/installer/sections/connections.js +4 -0
  116. package/scripts/installation/installer/sections/external-models.js +35 -0
  117. package/scripts/installation/installer/sections/models.js +119 -0
  118. package/scripts/installation/installer/sections/packs.js +82 -0
  119. package/scripts/installation/installer/sections/resources.js +10 -0
  120. package/scripts/installation/installer/settings.js +192 -0
  121. package/scripts/installation/installer/summary.js +44 -0
  122. package/scripts/installation/lifecycle.js +127 -0
  123. package/scripts/installation/location.js +3 -0
  124. package/scripts/installation/models.js +42 -0
  125. package/scripts/installation/options.js +360 -0
  126. package/scripts/installation/packs.js +150 -0
  127. package/scripts/installation/plan.js +121 -0
  128. package/scripts/installation/prerequisites.js +170 -0
  129. package/scripts/installation/recipes/catalog.js +55 -0
  130. package/scripts/installation/recipes/definition.js +32 -0
  131. package/scripts/installation/reconfigure.js +255 -0
  132. package/scripts/installation/requirements.js +23 -0
  133. package/scripts/installation/resolve.js +217 -0
  134. package/scripts/installation/runtime.js +87 -0
  135. package/scripts/installation/save.js +95 -0
  136. package/scripts/installation/setup.js +91 -0
  137. package/scripts/models/catalog.js +9 -0
  138. package/scripts/models/configuration.js +184 -0
  139. package/scripts/models/credentials.js +132 -0
  140. package/scripts/models/runtime.js +87 -0
  141. package/scripts/output.js +34 -0
  142. package/scripts/packs/connections.js +95 -0
  143. package/scripts/packs/lifecycle.js +125 -0
  144. package/scripts/packs/model.js +66 -0
  145. package/scripts/packs/native.js +69 -0
  146. package/scripts/packs/openshell.js +148 -0
  147. package/scripts/packs/policy.js +189 -0
  148. package/scripts/packs/requirements.in +1 -0
  149. package/scripts/packs/requirements.js +11 -0
  150. package/scripts/packs/requirements.txt +116 -0
  151. package/scripts/packs/source.js +90 -0
  152. package/scripts/packs/transport.py +68 -0
  153. package/scripts/people.js +52 -0
  154. package/scripts/release/create.js +62 -0
  155. package/scripts/release/definition.js +51 -0
  156. package/scripts/session.js +27 -0
  157. package/services/access/generated/client.gen.d.ts +12 -0
  158. package/services/access/generated/client.gen.js +3 -0
  159. package/services/access/generated/fastify.gen.d.ts +49 -0
  160. package/services/access/generated/fastify.gen.js +2 -0
  161. package/services/access/generated/index.d.ts +2 -0
  162. package/services/access/generated/index.js +2 -0
  163. package/services/access/generated/sdk.gen.d.ts +28 -0
  164. package/services/access/generated/sdk.gen.js +107 -0
  165. package/services/access/generated/types.gen.d.ts +349 -0
  166. package/services/access/generated/types.gen.js +2 -0
  167. package/services/access/migrations/001_access.sql +39 -0
  168. package/services/access/migrations/002_administrator_setup.sql +16 -0
  169. package/services/access/migrations/003_local_login_completion.sql +5 -0
  170. package/services/access/migrations/004_invitations.sql +21 -0
  171. package/services/access/repo/postgres.js +341 -0
  172. package/services/access/repo/session-logout.js +28 -0
  173. package/services/access/types/credential.js +2 -0
  174. package/services/access/types/errors.js +7 -0
  175. package/services/access/types/ingress.js +1 -0
  176. package/services/access/types/model.js +1 -0
  177. package/services/access/types/native-errors.js +7 -0
  178. package/services/access/types/native.js +1 -0
  179. package/services/cloud/generated/client.gen.d.ts +12 -0
  180. package/services/cloud/generated/client.gen.js +3 -0
  181. package/services/cloud/generated/index.d.ts +2 -0
  182. package/services/cloud/generated/index.js +2 -0
  183. package/services/cloud/generated/sdk.gen.d.ts +145 -0
  184. package/services/cloud/generated/sdk.gen.js +488 -0
  185. package/services/cloud/generated/types.gen.d.ts +2034 -0
  186. package/services/cloud/generated/types.gen.js +2 -0
  187. package/services/connections/cloud/generated/client.gen.d.ts +12 -0
  188. package/services/connections/cloud/generated/client.gen.js +3 -0
  189. package/services/connections/cloud/generated/fastify.gen.d.ts +68 -0
  190. package/services/connections/cloud/generated/fastify.gen.js +2 -0
  191. package/services/connections/cloud/generated/index.d.ts +2 -0
  192. package/services/connections/cloud/generated/index.js +2 -0
  193. package/services/connections/cloud/generated/sdk.gen.d.ts +95 -0
  194. package/services/connections/cloud/generated/sdk.gen.js +210 -0
  195. package/services/connections/cloud/generated/types.gen.d.ts +1044 -0
  196. package/services/connections/cloud/generated/types.gen.js +2 -0
  197. package/services/connections/migrations/001_connections.sql +220 -0
@@ -0,0 +1,341 @@
1
+ import { randomUUID, createCipheriv, createDecipheriv, randomBytes, } from "node:crypto";
2
+ import { z } from "zod";
3
+ import { SessionLogoutProtection } from "./session-logout.js";
4
+ import { AccessError } from "../types/errors.js";
5
+ import { hash } from "../types/credential.js";
6
+ const loginSchema = z
7
+ .object({
8
+ state: z.string(),
9
+ nonce: z.string(),
10
+ codeVerifier: z.string(),
11
+ returnTo: z.string(),
12
+ setupTokenHash: z.string().optional(),
13
+ invitationTokenHash: z.string().optional(),
14
+ })
15
+ .strict();
16
+ const user = (row) => ({
17
+ id: row.id,
18
+ identity: `clawscarf:${row.id}`,
19
+ email: row.email,
20
+ name: row.name.trim() || row.email,
21
+ });
22
+ /** Durable sessions and enrollment for one team server. */
23
+ export class PostgresAccessStore {
24
+ pool;
25
+ key;
26
+ administrator;
27
+ client;
28
+ logoutProtection;
29
+ constructor(pool, key, administrator, client) {
30
+ this.pool = pool;
31
+ this.key = key;
32
+ this.administrator = administrator;
33
+ this.client = client;
34
+ if (key.length !== 32)
35
+ throw Error("Access encryption key must contain 32 bytes.");
36
+ this.logoutProtection = new SessionLogoutProtection(key);
37
+ }
38
+ async transaction(work) {
39
+ const client = this.client ?? (await this.pool.connect());
40
+ try {
41
+ await client.query("BEGIN");
42
+ const result = await work(client);
43
+ await client.query("COMMIT");
44
+ return result;
45
+ }
46
+ catch (error) {
47
+ await client.query("ROLLBACK");
48
+ throw error;
49
+ }
50
+ finally {
51
+ if (!this.client)
52
+ client.release();
53
+ }
54
+ }
55
+ async withEnrollmentLock(work) {
56
+ const client = await this.pool.connect();
57
+ let locked = false;
58
+ try {
59
+ const result = await client.query("SELECT pg_try_advisory_lock(174992004) AS locked");
60
+ locked = result.rows[0]?.locked === true;
61
+ if (!locked)
62
+ throw new AccessError("rate_limited", "Another membership change is in progress. Try again.");
63
+ return await work(new PostgresAccessStore(this.pool, this.key, this.administrator, client));
64
+ }
65
+ finally {
66
+ try {
67
+ if (locked)
68
+ await client.query("SELECT pg_advisory_unlock(174992004)");
69
+ }
70
+ finally {
71
+ client.release();
72
+ }
73
+ }
74
+ }
75
+ async invitations() {
76
+ const result = await (this.client ?? this.pool).query(`SELECT id,email,expires_at::text AS "expiresAt",
77
+ CASE WHEN revoked_at IS NOT NULL THEN 'revoked' WHEN accepted_at IS NOT NULL THEN 'accepted'
78
+ WHEN expires_at<=clock_timestamp() THEN 'expired' ELSE 'pending' END AS status
79
+ FROM clawscarf_access.invitations ORDER BY expires_at DESC LIMIT 1000`);
80
+ return result.rows.map((row) => ({
81
+ ...row,
82
+ expiresAt: new Date(row.expiresAt).toISOString(),
83
+ }));
84
+ }
85
+ async createInvitation(sponsorId, email, tokenHash) {
86
+ const result = await (this.client ?? this.pool).query(`INSERT INTO clawscarf_access.invitations(id,token_hash,email,sponsor_id,sponsor_revision)
87
+ SELECT $1,$2,$3,id,revision FROM clawscarf_access.users WHERE id=$4 AND admitted
88
+ AND (SELECT count(*) FROM clawscarf_access.invitations WHERE accepted_at IS NULL AND revoked_at IS NULL AND expires_at>now())<1000
89
+ RETURNING id,email,expires_at`, [randomUUID(), tokenHash, email.toLowerCase(), sponsorId]);
90
+ const row = result.rows[0];
91
+ if (!row)
92
+ throw new AccessError("rate_limited", "Cannot create another invitation.");
93
+ return {
94
+ id: row.id,
95
+ email: row.email,
96
+ expiresAt: row.expires_at.toISOString(),
97
+ status: "pending",
98
+ };
99
+ }
100
+ async revokeInvitation(id) {
101
+ await (this.client ?? this.pool).query("UPDATE clawscarf_access.invitations SET revoked_at=clock_timestamp() WHERE id=$1 AND accepted_at IS NULL", [id]);
102
+ }
103
+ async bindInvitation(digest, identity, credentialHash) {
104
+ if (!identity.emailVerified)
105
+ throw new AccessError("email_unverified", "Use a verified email address.");
106
+ return this.transaction(async (client) => {
107
+ const result = await client.query(`UPDATE clawscarf_access.invitations i SET subject=$2 FROM clawscarf_access.users u
108
+ WHERE i.token_hash=$1 AND i.sponsor_id=u.id AND u.admitted AND u.revision=i.sponsor_revision
109
+ AND u.issuer=$3 AND i.email=$4 AND (i.subject IS NULL OR i.subject=$2)
110
+ AND i.accepted_at IS NULL AND i.revoked_at IS NULL AND i.expires_at>clock_timestamp()
111
+ RETURNING u.*`, [
112
+ digest,
113
+ identity.subject,
114
+ identity.issuer,
115
+ identity.email.toLowerCase(),
116
+ ]);
117
+ const sponsor = result.rows[0];
118
+ if (!sponsor)
119
+ throw new AccessError("invalid_authorization", "Invitation expired, was used, or belongs to another account.");
120
+ await client.query(`INSERT INTO clawscarf_access.browser_sessions(hash,purpose,user_id,admission_revision,csrf,expires_at)
121
+ VALUES($1,'invitation',$2,$3,'',clock_timestamp()+interval '3 minutes')`, [credentialHash, sponsor.id, sponsor.revision]);
122
+ return { hash: credentialHash, user: user(sponsor), csrfToken: "" };
123
+ });
124
+ }
125
+ async finishInvitation(digest, userId, sessionHash, csrf, logoutUrl) {
126
+ await this.transaction(async (client) => {
127
+ const result = await client.query(`UPDATE clawscarf_access.invitations i SET accepted_at=clock_timestamp()
128
+ FROM clawscarf_access.users sponsor,clawscarf_access.users target
129
+ WHERE i.token_hash=$1 AND target.id=$2 AND target.subject=i.subject AND target.email=i.email
130
+ AND sponsor.id=i.sponsor_id AND sponsor.admitted AND sponsor.revision=i.sponsor_revision
131
+ AND target.issuer=sponsor.issuer AND NOT target.admitted
132
+ AND i.accepted_at IS NULL AND i.revoked_at IS NULL AND i.expires_at>clock_timestamp()`, [digest, userId]);
133
+ if (result.rowCount !== 1)
134
+ throw new AccessError("invalid_authorization", "Invitation is no longer available.");
135
+ await client.query("UPDATE clawscarf_access.users SET admitted=true,revision=revision+1 WHERE id=$1", [userId]);
136
+ await this.insertSession(client, userId, sessionHash, csrf, logoutUrl);
137
+ });
138
+ }
139
+ async eligibleIdentities() {
140
+ const result = await (this.client ?? this.pool).query("SELECT id FROM clawscarf_access.users WHERE admitted ORDER BY id");
141
+ return result.rows.map((row) => `clawscarf:${row.id}`);
142
+ }
143
+ async people() {
144
+ const result = await (this.client ?? this.pool).query("SELECT id, email, name, revision, admitted FROM clawscarf_access.users WHERE admitted ORDER BY name, id LIMIT 1000");
145
+ return result.rows.map(user);
146
+ }
147
+ async person(id) {
148
+ const result = await (this.client ?? this.pool).query("SELECT * FROM clawscarf_access.users WHERE id=$1", [id]);
149
+ return result.rows[0] ? user(result.rows[0]) : null;
150
+ }
151
+ async initialize() {
152
+ return this.transaction(async (client) => {
153
+ await client.query("SELECT pg_advisory_xact_lock(174992001)");
154
+ const existing = await client.query("SELECT u.*,s.id AS server_id FROM clawscarf_access.server s JOIN clawscarf_access.users u ON u.id=s.administrator_id");
155
+ const row = existing.rows[0];
156
+ if (row) {
157
+ if (row.issuer !== this.administrator.issuer ||
158
+ (!this.administrator.claimRequired &&
159
+ row.subject !== this.administrator.subject))
160
+ throw Error("Configured initial identity differs from this server database.");
161
+ return { serverId: row.server_id, administrator: user(row) };
162
+ }
163
+ const id = randomUUID(), serverId = randomUUID(), a = this.administrator;
164
+ const inserted = await client.query("INSERT INTO clawscarf_access.users(id,issuer,subject,email,name,admitted) VALUES($1,$2,$3,$4,$5,$6) RETURNING *", [id, a.issuer, a.subject, a.email, a.name, !a.claimRequired]);
165
+ const created = inserted.rows[0];
166
+ if (!created)
167
+ throw Error("Administrator initialization failed.");
168
+ await client.query("INSERT INTO clawscarf_access.server(id,administrator_id,setup_complete) VALUES($1,$2,$3)", [serverId, id, !a.claimRequired]);
169
+ return { serverId, administrator: user(created) };
170
+ });
171
+ }
172
+ seal(value) {
173
+ const iv = randomBytes(12), cipher = createCipheriv("aes-256-gcm", this.key, iv);
174
+ const payload = Buffer.concat([
175
+ cipher.update(JSON.stringify(value)),
176
+ cipher.final(),
177
+ ]);
178
+ return Buffer.concat([iv, cipher.getAuthTag(), payload]).toString("base64url");
179
+ }
180
+ open(value) {
181
+ const bytes = Buffer.from(value, "base64url"), cipher = createDecipheriv("aes-256-gcm", this.key, bytes.subarray(0, 12));
182
+ cipher.setAuthTag(bytes.subarray(12, 28));
183
+ return loginSchema.parse(JSON.parse(Buffer.concat([
184
+ cipher.update(bytes.subarray(28)),
185
+ cipher.final(),
186
+ ]).toString()));
187
+ }
188
+ async beginLogin(cookieHash, value) {
189
+ await this.transaction(async (client) => {
190
+ await client.query("SELECT pg_advisory_xact_lock(174992002)");
191
+ await client.query("DELETE FROM clawscarf_access.login_transactions WHERE expires_at<=now()");
192
+ const count = await client.query("SELECT count(*)::int AS count FROM clawscarf_access.login_transactions");
193
+ if ((count.rows[0]?.count ?? 1000) >= 1000)
194
+ throw new AccessError("rate_limited", "Too many pending logins. Try again later.");
195
+ await client.query("INSERT INTO clawscarf_access.login_transactions(cookie_hash,state_hash,payload) VALUES($1,$2,$3)", [cookieHash, hash(value.state), this.seal(value)]);
196
+ });
197
+ }
198
+ async consumeLogin(cookieHash, state) {
199
+ const result = await (this.client ?? this.pool).query("DELETE FROM clawscarf_access.login_transactions WHERE cookie_hash=$1 AND state_hash=$2 AND expires_at>now() RETURNING payload", [cookieHash, hash(state)]);
200
+ return result.rows[0] ? this.open(result.rows[0].payload) : null;
201
+ }
202
+ async admitIdentity(identity) {
203
+ const result = await (this.client ?? this.pool).query("UPDATE clawscarf_access.users SET email=$3,name=$4 WHERE issuer=$1 AND subject=$2 AND admitted RETURNING *", [
204
+ identity.issuer,
205
+ identity.subject,
206
+ identity.email.toLowerCase(),
207
+ identity.name,
208
+ ]);
209
+ const row = result.rows[0];
210
+ if (!row)
211
+ throw new AccessError("forbidden", "This account has not been admitted to this server.");
212
+ return user(row);
213
+ }
214
+ async createSession(userId, digest, csrfToken, logoutUrl) {
215
+ await this.insertSession(this.client ?? this.pool, userId, digest, csrfToken, logoutUrl);
216
+ }
217
+ async insertSession(client, userId, digest, csrfToken, logoutUrl) {
218
+ const result = await client.query("INSERT INTO clawscarf_access.browser_sessions(hash,user_id,admission_revision,csrf,logout_redirect) SELECT $1,id,revision,$3,$4 FROM clawscarf_access.users WHERE id=$2 AND admitted", [
219
+ digest,
220
+ userId,
221
+ csrfToken,
222
+ logoutUrl === null
223
+ ? null
224
+ : this.logoutProtection.seal(digest, logoutUrl),
225
+ ]);
226
+ if (result.rowCount !== 1)
227
+ throw new AccessError("forbidden", "This account is not admitted.");
228
+ }
229
+ async authenticateSession(digest) {
230
+ const result = await (this.client ?? this.pool).query("SELECT u.*,s.csrf FROM clawscarf_access.browser_sessions s JOIN clawscarf_access.users u ON u.id=s.user_id WHERE s.hash=$1 AND s.expires_at>clock_timestamp() AND (u.admitted OR s.purpose='enrollment' OR (s.purpose='setup' AND EXISTS(SELECT 1 FROM clawscarf_access.server initial WHERE initial.administrator_id=u.id AND NOT initial.setup_complete AND initial.setup_expires_at>clock_timestamp()))) AND s.admission_revision=u.revision AND (s.parent_hash IS NULL OR EXISTS(SELECT 1 FROM clawscarf_access.browser_sessions parent JOIN clawscarf_access.users parent_user ON parent_user.id=parent.user_id WHERE parent.hash=s.parent_hash AND parent.parent_hash IS NULL AND parent.expires_at>clock_timestamp() AND parent_user.admitted AND parent_user.revision=parent.admission_revision))", [digest]);
231
+ return result.rows[0]
232
+ ? {
233
+ hash: digest,
234
+ user: user(result.rows[0]),
235
+ csrfToken: result.rows[0].csrf,
236
+ }
237
+ : null;
238
+ }
239
+ async createDelegation(parentHash, digest) {
240
+ const result = await (this.client ?? this.pool).query(`INSERT INTO clawscarf_access.browser_sessions(hash,purpose,parent_hash,user_id,admission_revision,csrf,expires_at)
241
+ SELECT $1,'management',s.hash,s.user_id,s.admission_revision,s.csrf,LEAST(s.expires_at,clock_timestamp()+interval '3 minutes')
242
+ FROM clawscarf_access.browser_sessions s JOIN clawscarf_access.users u ON u.id=s.user_id
243
+ WHERE s.hash=$2 AND s.parent_hash IS NULL AND s.expires_at>clock_timestamp() AND u.admitted AND s.admission_revision=u.revision`, [digest, parentHash]);
244
+ if (result.rowCount !== 1)
245
+ throw new AccessError("unauthenticated", "Sign in to continue.");
246
+ }
247
+ async createEnrollmentDelegation(parentHash, userId, digest) {
248
+ const result = await (this.client ?? this.pool).query(`INSERT INTO clawscarf_access.browser_sessions(hash,purpose,parent_hash,user_id,admission_revision,csrf,expires_at)
249
+ SELECT $1,'enrollment',s.hash,target.id,target.revision,s.csrf,LEAST(s.expires_at,clock_timestamp()+interval '3 minutes')
250
+ FROM clawscarf_access.browser_sessions s JOIN clawscarf_access.users actor ON actor.id=s.user_id
251
+ CROSS JOIN clawscarf_access.users target
252
+ WHERE s.hash=$2 AND s.parent_hash IS NULL AND s.expires_at>clock_timestamp() AND actor.admitted AND actor.revision=s.admission_revision AND target.id=$3 AND NOT target.admitted`, [digest, parentHash, userId]);
253
+ if (result.rowCount !== 1)
254
+ throw new AccessError("forbidden", "Enrollment is unavailable.");
255
+ }
256
+ async prepareEnrollment(identity) {
257
+ const result = await (this.client ?? this.pool).query(`INSERT INTO clawscarf_access.users(id,issuer,subject,email,name)
258
+ VALUES($1,$2,$3,$4,$5) ON CONFLICT(issuer,subject) DO UPDATE SET email=excluded.email,name=excluded.name
259
+ WHERE NOT clawscarf_access.users.admitted RETURNING *`, [
260
+ randomUUID(),
261
+ identity.issuer,
262
+ identity.subject,
263
+ identity.email,
264
+ identity.name,
265
+ ]);
266
+ const row = result.rows[0];
267
+ if (!row)
268
+ throw new AccessError("invalid_request", "This person is already admitted.");
269
+ return user(row);
270
+ }
271
+ async activateEnrollment(id) {
272
+ await (this.client ?? this.pool).query("UPDATE clawscarf_access.users SET admitted=true,revision=revision+1 WHERE id=$1 AND NOT admitted", [id]);
273
+ }
274
+ async removeEnrollment(id) {
275
+ await (this.client ?? this.pool).query("UPDATE clawscarf_access.users SET admitted=false,revision=revision+1 WHERE id=$1", [id]);
276
+ }
277
+ async revokeDelegation(digest) {
278
+ await (this.client ?? this.pool).query("DELETE FROM clawscarf_access.browser_sessions WHERE hash=$1 AND (parent_hash IS NOT NULL OR purpose IN ('setup','invitation'))", [digest]);
279
+ }
280
+ async revokeSession(digest) {
281
+ const result = await (this.client ?? this.pool).query("DELETE FROM clawscarf_access.browser_sessions WHERE hash=$1 RETURNING logout_redirect", [digest]);
282
+ const row = result.rows[0];
283
+ if (!row)
284
+ throw new AccessError("unauthenticated", "Sign in to continue.");
285
+ return row.logout_redirect === null
286
+ ? null
287
+ : this.logoutProtection.open(digest, row.logout_redirect);
288
+ }
289
+ async administratorSetup() {
290
+ const result = await (this.client ?? this.pool).query("SELECT setup_complete,setup_expires_at FROM clawscarf_access.server");
291
+ const row = result.rows[0];
292
+ if (!row)
293
+ throw new AccessError("dependency_unavailable", "Server identity is unavailable.");
294
+ return {
295
+ complete: row.setup_complete,
296
+ expiresAt: row.setup_expires_at?.toISOString() ?? null,
297
+ };
298
+ }
299
+ async beginAdministratorSetup(digest) {
300
+ await this.transaction(async (client) => {
301
+ const result = await client.query("UPDATE clawscarf_access.server SET setup_token_hash=$1,setup_expires_at=clock_timestamp()+interval '15 minutes' WHERE NOT setup_complete", [digest]);
302
+ if (result.rowCount !== 1)
303
+ throw new AccessError("forbidden", "Administrator setup is already complete.");
304
+ await client.query("DELETE FROM clawscarf_access.browser_sessions WHERE purpose='setup'");
305
+ });
306
+ }
307
+ async bindAdministrator(digest, identity, sessionHash) {
308
+ if (!identity.emailVerified)
309
+ throw new AccessError("email_unverified", "Use a verified email address.");
310
+ return this.transaction(async (client) => {
311
+ const claim = await client.query(`UPDATE clawscarf_access.server SET setup_subject=$2
312
+ WHERE NOT setup_complete AND setup_token_hash=$1 AND setup_expires_at>clock_timestamp()
313
+ AND (setup_subject IS NULL OR setup_subject=$2) RETURNING administrator_id`, [digest, identity.subject]);
314
+ const id = claim.rows[0]?.administrator_id;
315
+ if (!id)
316
+ throw new AccessError("invalid_authorization", "Setup expired, was already used, or belongs to another account.");
317
+ const result = await client.query("UPDATE clawscarf_access.users SET subject=$2,email=$3,name=$4 WHERE id=$1 AND issuer=$5 AND NOT admitted RETURNING *", [
318
+ id,
319
+ identity.subject,
320
+ identity.email.toLowerCase(),
321
+ identity.name,
322
+ identity.issuer,
323
+ ]);
324
+ const person = result.rows[0];
325
+ if (!person)
326
+ throw new AccessError("forbidden", "This identity cannot claim the server.");
327
+ await client.query("INSERT INTO clawscarf_access.browser_sessions(hash,purpose,user_id,admission_revision,csrf,expires_at) SELECT $1,'setup',id,revision,'',clock_timestamp()+interval '3 minutes' FROM clawscarf_access.users WHERE id=$2", [sessionHash, id]);
328
+ return user(person);
329
+ });
330
+ }
331
+ async finishAdministratorSetup(digest, userId, sessionHash, csrfToken, logoutUrl) {
332
+ await this.transaction(async (client) => {
333
+ const claimed = await client.query("UPDATE clawscarf_access.server SET setup_complete=true,setup_token_hash=NULL,setup_expires_at=NULL WHERE NOT setup_complete AND setup_token_hash=$1 AND administrator_id=$2 AND setup_subject IS NOT NULL AND setup_expires_at>clock_timestamp() RETURNING id", [digest, userId]);
334
+ if (claimed.rowCount !== 1)
335
+ throw new AccessError("invalid_authorization", "Setup expired or was already used.");
336
+ await client.query("UPDATE clawscarf_access.users SET admitted=true,revision=revision+1 WHERE id=$1", [userId]);
337
+ await client.query("DELETE FROM clawscarf_access.browser_sessions WHERE purpose='setup' AND user_id=$1", [userId]);
338
+ await this.insertSession(client, userId, sessionHash, csrfToken, logoutUrl);
339
+ });
340
+ }
341
+ }
@@ -0,0 +1,28 @@
1
+ import { createCipheriv, createDecipheriv, hkdfSync, randomBytes, } from "node:crypto";
2
+ /** Logout hints can contain ID tokens. Bind encrypted storage to one browser session. */
3
+ export class SessionLogoutProtection {
4
+ key;
5
+ constructor(key) {
6
+ this.key = Buffer.from(hkdfSync("sha256", key, "clawscarf", "browser-session-logout", 32));
7
+ }
8
+ seal(sessionHash, url) {
9
+ const nonce = randomBytes(12);
10
+ const cipher = createCipheriv("aes-256-gcm", this.key, nonce);
11
+ cipher.setAAD(Buffer.from(sessionHash));
12
+ const ciphertext = Buffer.concat([
13
+ cipher.update(url, "utf8"),
14
+ cipher.final(),
15
+ ]);
16
+ return Buffer.concat([nonce, cipher.getAuthTag(), ciphertext]).toString("base64url");
17
+ }
18
+ open(sessionHash, sealed) {
19
+ const packed = Buffer.from(sealed, "base64url");
20
+ const decipher = createDecipheriv("aes-256-gcm", this.key, packed.subarray(0, 12));
21
+ decipher.setAAD(Buffer.from(sessionHash));
22
+ decipher.setAuthTag(packed.subarray(12, 28));
23
+ return Buffer.concat([
24
+ decipher.update(packed.subarray(28)),
25
+ decipher.final(),
26
+ ]).toString("utf8");
27
+ }
28
+ }
@@ -0,0 +1,2 @@
1
+ import { createHash } from "node:crypto";
2
+ export const hash = (value) => createHash("sha256").update(value).digest("hex");
@@ -0,0 +1,7 @@
1
+ export class AccessError extends Error {
2
+ code;
3
+ constructor(code, message) {
4
+ super(message);
5
+ this.code = code;
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export class NativeFailure extends Error {
2
+ code;
3
+ constructor(code) {
4
+ super(code);
5
+ this.code = code;
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { type Client, type ClientOptions, type Config } from '../../../generated/http/client/index.js';
2
+ import type { ClientOptions as ClientOptions2 } from './types.gen.js';
3
+ /**
4
+ * The `createClientConfig()` function will be called on client initialization
5
+ * and the returned object will become the client's initial configuration.
6
+ *
7
+ * You may want to initialize your client this way instead of calling
8
+ * `setConfig()`. This is useful for example if you're using Next.js
9
+ * to ensure your client always has the correct values.
10
+ */
11
+ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
12
+ export declare const client: Client;
@@ -0,0 +1,3 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { createClient, createConfig } from '../../../generated/http/client/index.js';
3
+ export const client = createClient(createConfig({ baseUrl: 'services' }));
@@ -0,0 +1,2 @@
1
+ export { beginConnectionSetupBrowser, callConnectorRuntime, cancelConnectionSetup, completeConnectionSetup, createConnection, describeConnectorRuntime, disconnectConnection, getAccount, getCliIdentity, getConnection, getConnectionSetup, getConnectionUsage, getConnector, getConnectorRuntimeInvocation, getConnectorRuntimeResultPage, getInstallation, getInstallationCredentials, getInstallationIdentity, getProvisioner, getRuntimeScope, getSession, health, listConnections, listConnectors, listInstallations, lookupConnectorRuntimeInvocation, maintainConnections, type Options, refreshConnection, registerInstallation, returnConnectionCallback, revokeInstallationCredential, revokeProvisioner, rotateInstallationCredential, rotateProvisioner, searchConnectorRuntime, startConnectionSetup, updateConnection } from './sdk.gen.js';
2
+ export type { AdministratorAssertion, BeginConnectionSetupBrowserData, BeginConnectionSetupBrowserError, BeginConnectionSetupBrowserErrors, BeginConnectionSetupBrowserResponse, BeginConnectionSetupBrowserResponses, CallConnectorRuntimeData, CallConnectorRuntimeError, CallConnectorRuntimeErrors, CallConnectorRuntimeResponse, CallConnectorRuntimeResponses, CancelConnectionSetupData, CancelConnectionSetupError, CancelConnectionSetupErrors, CancelConnectionSetupResponse, CancelConnectionSetupResponses, ClientOptions, CompleteConnectionSetupData, CompleteConnectionSetupError, CompleteConnectionSetupErrors, CompleteConnectionSetupResponse, CompleteConnectionSetupResponses, Connection, ConnectionFailure, ConnectionId, ConnectionInvocation, ConnectionInvocationId, ConnectionList, ConnectionProblem, ConnectionReturnDestination, ConnectionRevision, ConnectionSetup, ConnectionSetupContinuation, ConnectionSetupId, ConnectionUsage, Connector, ConnectorActionDetail, ConnectorActionSummary, ConnectorAgentGrant, ConnectorId, ConnectorList, ConnectorResultPage, ConnectorResultReference, ConnectorResultUnavailable, ConnectorRuntimeCall, ConnectorRuntimeContext, ConnectorRuntimeDescribe, ConnectorRuntimeDescription, ConnectorRuntimeInvocation, ConnectorRuntimeInvocationLookup, ConnectorRuntimeMatch, ConnectorRuntimeResultPage, ConnectorRuntimeSearch, ConnectorRuntimeSearchGuidance, ConnectorRuntimeSearchResult, CreateConnection, CreateConnectionData, CreateConnectionError, CreateConnectionErrors, CreateConnectionResponse, CreateConnectionResponses, DescribeConnectorRuntimeData, DescribeConnectorRuntimeError, DescribeConnectorRuntimeErrors, DescribeConnectorRuntimeResponse, DescribeConnectorRuntimeResponses, DisconnectConnectionData, DisconnectConnectionError, DisconnectConnectionErrors, DisconnectConnectionResponse, DisconnectConnectionResponses, GetAccountData, GetAccountError, GetAccountErrors, GetAccountResponse, GetAccountResponses, GetCliIdentityData, GetCliIdentityError, GetCliIdentityErrors, GetCliIdentityResponse, GetCliIdentityResponses, GetConnectionData, GetConnectionError, GetConnectionErrors, GetConnectionResponse, GetConnectionResponses, GetConnectionSetupData, GetConnectionSetupError, GetConnectionSetupErrors, GetConnectionSetupResponse, GetConnectionSetupResponses, GetConnectionUsageData, GetConnectionUsageError, GetConnectionUsageErrors, GetConnectionUsageResponse, GetConnectionUsageResponses, GetConnectorData, GetConnectorError, GetConnectorErrors, GetConnectorResponse, GetConnectorResponses, GetConnectorRuntimeInvocationData, GetConnectorRuntimeInvocationError, GetConnectorRuntimeInvocationErrors, GetConnectorRuntimeInvocationResponse, GetConnectorRuntimeInvocationResponses, GetConnectorRuntimeResultPageData, GetConnectorRuntimeResultPageError, GetConnectorRuntimeResultPageErrors, GetConnectorRuntimeResultPageResponse, GetConnectorRuntimeResultPageResponses, GetInstallationCredentialsData, GetInstallationCredentialsError, GetInstallationCredentialsErrors, GetInstallationCredentialsResponse, GetInstallationCredentialsResponses, GetInstallationData, GetInstallationError, GetInstallationErrors, GetInstallationIdentityData, GetInstallationIdentityError, GetInstallationIdentityErrors, GetInstallationIdentityResponse, GetInstallationIdentityResponses, GetInstallationResponse, GetInstallationResponses, GetProvisionerData, GetProvisionerError, GetProvisionerErrors, GetProvisionerResponse, GetProvisionerResponses, GetRuntimeScopeData, GetRuntimeScopeError, GetRuntimeScopeErrors, GetRuntimeScopeResponse, GetRuntimeScopeResponses, GetSessionData, GetSessionError, GetSessionErrors, GetSessionResponse, GetSessionResponses, HealthData, HealthResponse, HealthResponses, Id, IdempotencyKey, Installation, ListConnectionsData, ListConnectionsError, ListConnectionsErrors, ListConnectionsResponse, ListConnectionsResponses, ListConnectorsData, ListConnectorsError, ListConnectorsErrors, ListConnectorsResponse, ListConnectorsResponses, ListInstallationsData, ListInstallationsError, ListInstallationsErrors, ListInstallationsResponse, ListInstallationsResponses, LookupConnectorRuntimeInvocationData, LookupConnectorRuntimeInvocationError, LookupConnectorRuntimeInvocationErrors, LookupConnectorRuntimeInvocationResponse, LookupConnectorRuntimeInvocationResponses, MaintainConnectionsData, MaintainConnectionsError, MaintainConnectionsErrors, MaintainConnectionsResponse, MaintainConnectionsResponses, Problem, RefreshConnectionData, RefreshConnectionError, RefreshConnectionErrors, RefreshConnectionResponse, RefreshConnectionResponses, RegisterInstallationData, RegisterInstallationError, RegisterInstallationErrors, RegisterInstallationResponse, RegisterInstallationResponses, RetryGuidance, ReturnConnectionCallbackData, ReturnConnectionCallbackError, ReturnConnectionCallbackErrors, ReturnConnectionCallbackResponse, ReturnConnectionCallbackResponses, RevokeInstallationCredentialData, RevokeInstallationCredentialError, RevokeInstallationCredentialErrors, RevokeInstallationCredentialResponse, RevokeInstallationCredentialResponses, RevokeProvisionerData, RevokeProvisionerError, RevokeProvisionerErrors, RevokeProvisionerResponse, RevokeProvisionerResponses, RotateInstallationCredentialData, RotateInstallationCredentialError, RotateInstallationCredentialErrors, RotateInstallationCredentialResponse, RotateInstallationCredentialResponses, RotateProvisionerData, RotateProvisionerError, RotateProvisionerErrors, RotateProvisionerResponse, RotateProvisionerResponses, SearchConnectorRuntimeData, SearchConnectorRuntimeError, SearchConnectorRuntimeErrors, SearchConnectorRuntimeResponse, SearchConnectorRuntimeResponses, StartConnectionSetup, StartConnectionSetupData, StartConnectionSetupError, StartConnectionSetupErrors, StartConnectionSetupResponse, StartConnectionSetupResponses, UpdateConnection, UpdateConnectionData, UpdateConnectionError, UpdateConnectionErrors, UpdateConnectionResponse, UpdateConnectionResponses } from './types.gen.js';
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export { beginConnectionSetupBrowser, callConnectorRuntime, cancelConnectionSetup, completeConnectionSetup, createConnection, describeConnectorRuntime, disconnectConnection, getAccount, getCliIdentity, getConnection, getConnectionSetup, getConnectionUsage, getConnector, getConnectorRuntimeInvocation, getConnectorRuntimeResultPage, getInstallation, getInstallationCredentials, getInstallationIdentity, getProvisioner, getRuntimeScope, getSession, health, listConnections, listConnectors, listInstallations, lookupConnectorRuntimeInvocation, maintainConnections, refreshConnection, registerInstallation, returnConnectionCallback, revokeInstallationCredential, revokeProvisioner, rotateInstallationCredential, rotateProvisioner, searchConnectorRuntime, startConnectionSetup, updateConnection } from './sdk.gen.js';
@@ -0,0 +1,145 @@
1
+ import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from '../../../generated/http/client/index.js';
2
+ import type { BeginConnectionSetupBrowserData, BeginConnectionSetupBrowserErrors, BeginConnectionSetupBrowserResponses, CallConnectorRuntimeData, CallConnectorRuntimeErrors, CallConnectorRuntimeResponses, CancelConnectionSetupData, CancelConnectionSetupErrors, CancelConnectionSetupResponses, CompleteConnectionSetupData, CompleteConnectionSetupErrors, CompleteConnectionSetupResponses, CreateConnectionData, CreateConnectionErrors, CreateConnectionResponses, DescribeConnectorRuntimeData, DescribeConnectorRuntimeErrors, DescribeConnectorRuntimeResponses, DisconnectConnectionData, DisconnectConnectionErrors, DisconnectConnectionResponses, GetAccountData, GetAccountErrors, GetAccountResponses, GetCliIdentityData, GetCliIdentityErrors, GetCliIdentityResponses, GetConnectionData, GetConnectionErrors, GetConnectionResponses, GetConnectionSetupData, GetConnectionSetupErrors, GetConnectionSetupResponses, GetConnectionUsageData, GetConnectionUsageErrors, GetConnectionUsageResponses, GetConnectorData, GetConnectorErrors, GetConnectorResponses, GetConnectorRuntimeInvocationData, GetConnectorRuntimeInvocationErrors, GetConnectorRuntimeInvocationResponses, GetConnectorRuntimeResultPageData, GetConnectorRuntimeResultPageErrors, GetConnectorRuntimeResultPageResponses, GetInstallationCredentialsData, GetInstallationCredentialsErrors, GetInstallationCredentialsResponses, GetInstallationData, GetInstallationErrors, GetInstallationIdentityData, GetInstallationIdentityErrors, GetInstallationIdentityResponses, GetInstallationResponses, GetProvisionerData, GetProvisionerErrors, GetProvisionerResponses, GetRuntimeScopeData, GetRuntimeScopeErrors, GetRuntimeScopeResponses, GetSessionData, GetSessionErrors, GetSessionResponses, HealthData, HealthResponses, ListConnectionsData, ListConnectionsErrors, ListConnectionsResponses, ListConnectorsData, ListConnectorsErrors, ListConnectorsResponses, ListInstallationsData, ListInstallationsErrors, ListInstallationsResponses, LookupConnectorRuntimeInvocationData, LookupConnectorRuntimeInvocationErrors, LookupConnectorRuntimeInvocationResponses, MaintainConnectionsData, MaintainConnectionsErrors, MaintainConnectionsResponses, RefreshConnectionData, RefreshConnectionErrors, RefreshConnectionResponses, RegisterInstallationData, RegisterInstallationErrors, RegisterInstallationResponses, ReturnConnectionCallbackData, ReturnConnectionCallbackErrors, ReturnConnectionCallbackResponses, RevokeInstallationCredentialData, RevokeInstallationCredentialErrors, RevokeInstallationCredentialResponses, RevokeProvisionerData, RevokeProvisionerErrors, RevokeProvisionerResponses, RotateInstallationCredentialData, RotateInstallationCredentialErrors, RotateInstallationCredentialResponses, RotateProvisionerData, RotateProvisionerErrors, RotateProvisionerResponses, SearchConnectorRuntimeData, SearchConnectorRuntimeErrors, SearchConnectorRuntimeResponses, StartConnectionSetupData, StartConnectionSetupErrors, StartConnectionSetupResponses, UpdateConnectionData, UpdateConnectionErrors, UpdateConnectionResponses } from './types.gen.js';
3
+ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
4
+ /**
5
+ * You can provide a client instance returned by `createClient()` instead of
6
+ * individual options. This might be also useful if you want to implement a
7
+ * custom client.
8
+ */
9
+ client?: Client;
10
+ /**
11
+ * You can pass arbitrary values through the `meta` object. This can be
12
+ * used to access values that aren't defined as part of the SDK function.
13
+ */
14
+ meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
15
+ };
16
+ export declare const health: <ThrowOnError extends boolean = false>(options?: Options<HealthData, ThrowOnError>) => RequestResult<HealthResponses, unknown, ThrowOnError>;
17
+ export declare const getSession: <ThrowOnError extends boolean = false>(options?: Options<GetSessionData, ThrowOnError>) => RequestResult<GetSessionResponses, GetSessionErrors, ThrowOnError>;
18
+ export declare const listInstallations: <ThrowOnError extends boolean = false>(options?: Options<ListInstallationsData, ThrowOnError>) => RequestResult<ListInstallationsResponses, ListInstallationsErrors, ThrowOnError>;
19
+ export declare const registerInstallation: <ThrowOnError extends boolean = false>(options: Options<RegisterInstallationData, ThrowOnError>) => RequestResult<RegisterInstallationResponses, RegisterInstallationErrors, ThrowOnError>;
20
+ export declare const getInstallation: <ThrowOnError extends boolean = false>(options: Options<GetInstallationData, ThrowOnError>) => RequestResult<GetInstallationResponses, GetInstallationErrors, ThrowOnError>;
21
+ export declare const getInstallationIdentity: <ThrowOnError extends boolean = false>(options: Options<GetInstallationIdentityData, ThrowOnError>) => RequestResult<GetInstallationIdentityResponses, GetInstallationIdentityErrors, ThrowOnError>;
22
+ export declare const revokeInstallationCredential: <ThrowOnError extends boolean = false>(options: Options<RevokeInstallationCredentialData, ThrowOnError>) => RequestResult<RevokeInstallationCredentialResponses, RevokeInstallationCredentialErrors, ThrowOnError>;
23
+ export declare const rotateInstallationCredential: <ThrowOnError extends boolean = false>(options: Options<RotateInstallationCredentialData, ThrowOnError>) => RequestResult<RotateInstallationCredentialResponses, RotateInstallationCredentialErrors, ThrowOnError>;
24
+ export declare const revokeProvisioner: <ThrowOnError extends boolean = false>(options?: Options<RevokeProvisionerData, ThrowOnError>) => RequestResult<RevokeProvisionerResponses, RevokeProvisionerErrors, ThrowOnError>;
25
+ export declare const getProvisioner: <ThrowOnError extends boolean = false>(options?: Options<GetProvisionerData, ThrowOnError>) => RequestResult<GetProvisionerResponses, GetProvisionerErrors, ThrowOnError>;
26
+ export declare const rotateProvisioner: <ThrowOnError extends boolean = false>(options: Options<RotateProvisionerData, ThrowOnError>) => RequestResult<RotateProvisionerResponses, RotateProvisionerErrors, ThrowOnError>;
27
+ export declare const getRuntimeScope: <ThrowOnError extends boolean = false>(options?: Options<GetRuntimeScopeData, ThrowOnError>) => RequestResult<GetRuntimeScopeResponses, GetRuntimeScopeErrors, ThrowOnError>;
28
+ export declare const getInstallationCredentials: <ThrowOnError extends boolean = false>(options: Options<GetInstallationCredentialsData, ThrowOnError>) => RequestResult<GetInstallationCredentialsResponses, GetInstallationCredentialsErrors, ThrowOnError>;
29
+ export declare const getCliIdentity: <ThrowOnError extends boolean = false>(options?: Options<GetCliIdentityData, ThrowOnError>) => RequestResult<GetCliIdentityResponses, GetCliIdentityErrors, ThrowOnError>;
30
+ export declare const getAccount: <ThrowOnError extends boolean = false>(options?: Options<GetAccountData, ThrowOnError>) => RequestResult<GetAccountResponses, GetAccountErrors, ThrowOnError>;
31
+ /**
32
+ * Browse available connectors
33
+ *
34
+ * Selected connector contract. Unavailable until the complete service and customer journey are wired and qualified.
35
+ */
36
+ export declare const listConnectors: <ThrowOnError extends boolean = false>(options: Options<ListConnectorsData, ThrowOnError>) => RequestResult<ListConnectorsResponses, ListConnectorsErrors, ThrowOnError>;
37
+ /**
38
+ * Read connector metadata
39
+ *
40
+ * Selected connector contract. Unavailable until the complete service and customer journey are wired and qualified.
41
+ */
42
+ export declare const getConnector: <ThrowOnError extends boolean = false>(options: Options<GetConnectorData, ThrowOnError>) => RequestResult<GetConnectorResponses, GetConnectorErrors, ThrowOnError>;
43
+ /**
44
+ * List server connections
45
+ *
46
+ * Return connection metadata and setup status after verifying current native administrator authority. Credentials and setup continuation URLs are excluded. A failed read never establishes an empty collection.
47
+ */
48
+ export declare const listConnections: <ThrowOnError extends boolean = false>(options: Options<ListConnectionsData, ThrowOnError>) => RequestResult<ListConnectionsResponses, ListConnectionsErrors, ThrowOnError>;
49
+ /**
50
+ * Create a named connection
51
+ *
52
+ * Create a named server-owned connection after verifying current native administrator authority. This neither authorizes a provider account nor starts external authentication. Agent grants are checked before activation. Identical authorized retries return the same record.
53
+ */
54
+ export declare const createConnection: <ThrowOnError extends boolean = false>(options: Options<CreateConnectionData, ThrowOnError>) => RequestResult<CreateConnectionResponses, CreateConnectionErrors, ThrowOnError>;
55
+ /**
56
+ * Disconnect an account
57
+ *
58
+ * Revoke local use immediately and cancel pending setup. Provider cleanup is durable and may complete later. Never continue granting local use because provider deletion failed. Retain receipts and exact cleanup references.
59
+ */
60
+ export declare const disconnectConnection: <ThrowOnError extends boolean = false>(options: Options<DisconnectConnectionData, ThrowOnError>) => RequestResult<DisconnectConnectionResponses, DisconnectConnectionErrors, ThrowOnError>;
61
+ /**
62
+ * Read a connection
63
+ *
64
+ * Read a named connection's agent grant, state, revision, setup and cleanup status, and safe failure summary. Recheck effective native administrator authority before reading. Credentials and setup continuation URLs are never included.
65
+ */
66
+ export declare const getConnection: <ThrowOnError extends boolean = false>(options: Options<GetConnectionData, ThrowOnError>) => RequestResult<GetConnectionResponses, GetConnectionErrors, ThrowOnError>;
67
+ /**
68
+ * Replace connection name and agent grant
69
+ *
70
+ * Replace both editable fields against the quoted current connection revision. Revocation and selected-agent changes take effect at the next broker boundary, including already pending operations.
71
+ */
72
+ export declare const updateConnection: <ThrowOnError extends boolean = false>(options: Options<UpdateConnectionData, ThrowOnError>) => RequestResult<UpdateConnectionResponses, UpdateConnectionErrors, ThrowOnError>;
73
+ /**
74
+ * Start connection or reconnection
75
+ *
76
+ * Persist one setup attempt before requesting its hosted authentication link. Admission and permission checks use ClawScarf state; setup performs no native management. Clients poll the returned setup and navigate to its continuation URL as soon as available. Account use remains disabled until callback identity, effective native administrator authority and selected agents are verified. Only its initiating user may continue. Reconnection keeps the current active account until the exact replacement is verified. A changed retry payload conflicts; uncertain setup creation is not blindly replayed. New attempts and provider preparation/allocation require the current published catalog. Authentication preparation has its own durable receipt; an uncertain preparation or allocation blocks replacement until resolved.
77
+ */
78
+ export declare const startConnectionSetup: <ThrowOnError extends boolean = false>(options: Options<StartConnectionSetupData, ThrowOnError>) => RequestResult<StartConnectionSetupResponses, StartConnectionSetupErrors, ThrowOnError>;
79
+ /**
80
+ * Cancel a setup attempt
81
+ *
82
+ * Idempotently cancel this exact setup attempt and schedule provider cleanup. A late callback cannot activate it. Completed setup cannot be cancelled; disconnect the connection explicitly.
83
+ */
84
+ export declare const cancelConnectionSetup: <ThrowOnError extends boolean = false>(options: Options<CancelConnectionSetupData, ThrowOnError>) => RequestResult<CancelConnectionSetupResponses, CancelConnectionSetupErrors, ThrowOnError>;
85
+ /**
86
+ * Read or continue a setup attempt
87
+ *
88
+ * Return current setup and its unexpired continuation URL only to the initiating user with current native administrator authority. This read never redeems a callback, creates an account or restarts expired setup.
89
+ */
90
+ export declare const getConnectionSetup: <ThrowOnError extends boolean = false>(options: Options<GetConnectionSetupData, ThrowOnError>) => RequestResult<GetConnectionSetupResponses, GetConnectionSetupErrors, ThrowOnError>;
91
+ /**
92
+ * Refresh connection status
93
+ *
94
+ * Observe the exact bound provider account after verifying native administrator authority and current revision. The initiator may finish an unexpired setup from a durably recorded identity receipt. Never redeem the callback again or infer identity from account status alone.
95
+ */
96
+ export declare const refreshConnection: <ThrowOnError extends boolean = false>(options: Options<RefreshConnectionData, ThrowOnError>) => RequestResult<RefreshConnectionResponses, RefreshConnectionErrors, ThrowOnError>;
97
+ /**
98
+ * Connector search
99
+ *
100
+ * Installation credential and trusted native agent context select currently permitted exact connections. Human cookies and CLI credentials are not accepted. No server identity is accepted in the payload.
101
+ */
102
+ export declare const searchConnectorRuntime: <ThrowOnError extends boolean = false>(options: Options<SearchConnectorRuntimeData, ThrowOnError>) => RequestResult<SearchConnectorRuntimeResponses, SearchConnectorRuntimeErrors, ThrowOnError>;
103
+ /**
104
+ * Connector describe
105
+ *
106
+ * Installation credential and trusted native agent context select currently permitted exact connections. Human cookies and CLI credentials are not accepted. No server identity is accepted in the payload.
107
+ */
108
+ export declare const describeConnectorRuntime: <ThrowOnError extends boolean = false>(options: Options<DescribeConnectorRuntimeData, ThrowOnError>) => RequestResult<DescribeConnectorRuntimeResponses, DescribeConnectorRuntimeErrors, ThrowOnError>;
109
+ /**
110
+ * Connector call
111
+ *
112
+ * Durable invocation identity is scoped to server credential, native session and toolCallId. Identical replay returns the existing receipt; changed arguments conflict. Never automatically redispatch an uncertain call. Exact connection generation must still be current. New dispatch also requires the published catalog and current action version; authorized receipt replay does not require retired catalog metadata.
113
+ */
114
+ export declare const callConnectorRuntime: <ThrowOnError extends boolean = false>(options: Options<CallConnectorRuntimeData, ThrowOnError>) => RequestResult<CallConnectorRuntimeResponses, CallConnectorRuntimeErrors, ThrowOnError>;
115
+ /**
116
+ * Recover an invocation result
117
+ *
118
+ * Read an existing result under the current server credential and matching agent grant. Never dispatch the operation again. Revoked connection generations do not regain access after native state restoration.
119
+ */
120
+ export declare const getConnectorRuntimeInvocation: <ThrowOnError extends boolean = false>(options: Options<GetConnectorRuntimeInvocationData, ThrowOnError>) => RequestResult<GetConnectorRuntimeInvocationResponses, GetConnectorRuntimeInvocationErrors, ThrowOnError>;
121
+ /**
122
+ * Read a bounded page of retained result JSON
123
+ *
124
+ * Read an existing result under the current server credential and matching agent grant. Never dispatch the operation again. Revoked connection generations do not regain access after native state restoration.
125
+ */
126
+ export declare const getConnectorRuntimeResultPage: <ThrowOnError extends boolean = false>(options: Options<GetConnectorRuntimeResultPageData, ThrowOnError>) => RequestResult<GetConnectorRuntimeResultPageResponses, GetConnectorRuntimeResultPageErrors, ThrowOnError>;
127
+ /**
128
+ * Find a receipt from its original native call identity
129
+ *
130
+ * Read an existing result under the current server credential and matching agent grant. Never dispatch the operation again. Revoked connection generations do not regain access after native state restoration.
131
+ */
132
+ export declare const lookupConnectorRuntimeInvocation: <ThrowOnError extends boolean = false>(options: Options<LookupConnectorRuntimeInvocationData, ThrowOnError>) => RequestResult<LookupConnectorRuntimeInvocationResponses, LookupConnectorRuntimeInvocationErrors, ThrowOnError>;
133
+ /**
134
+ * Submit the receipt from the returning browser after checking its current installation identity and native authority. Polling a setup cannot activate it.
135
+ */
136
+ export declare const completeConnectionSetup: <ThrowOnError extends boolean = false>(options: Options<CompleteConnectionSetupData, ThrowOnError>) => RequestResult<CompleteConnectionSetupResponses, CompleteConnectionSetupErrors, ThrowOnError>;
137
+ export declare const maintainConnections: <ThrowOnError extends boolean = false>(options?: Options<MaintainConnectionsData, ThrowOnError>) => RequestResult<MaintainConnectionsResponses, MaintainConnectionsErrors, ThrowOnError>;
138
+ export declare const returnConnectionCallback: <ThrowOnError extends boolean = false>(options: Options<ReturnConnectionCallbackData, ThrowOnError>) => RequestResult<ReturnConnectionCallbackResponses, ReturnConnectionCallbackErrors, ThrowOnError>;
139
+ export declare const beginConnectionSetupBrowser: <ThrowOnError extends boolean = false>(options: Options<BeginConnectionSetupBrowserData, ThrowOnError>) => RequestResult<BeginConnectionSetupBrowserResponses, BeginConnectionSetupBrowserErrors, ThrowOnError>;
140
+ /**
141
+ * Read current execution allowance
142
+ *
143
+ * Current account and installation allowance for this installation. Shared provider budgets are private.
144
+ */
145
+ export declare const getConnectionUsage: <ThrowOnError extends boolean = false>(options: Options<GetConnectionUsageData, ThrowOnError>) => RequestResult<GetConnectionUsageResponses, GetConnectionUsageErrors, ThrowOnError>;