@muhkoo/connect 0.2.0-alpha.2 → 0.4.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.
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # @muhkoo/connect
2
2
 
3
3
  Client SDK for the Muhkoo Accelerator. The headline surface is a single
4
- **`Client`** that hangs everything off four namespaces —
5
- `client.auth` / `client.storage` / `client.message` / `client.space` — backed by
6
- end-to-end-encrypted messaging (fan-out group channels with history, plus
7
- Double Ratchet + ECDH P-384 for direct messages), ZK identity + personal/shared
8
- spaces, and a Cloudflare-Workers-compatible Groth16 verifier — all bundled from
9
- a single TypeScript source tree.
4
+ **`Client`** that hangs everything off its namespaces —
5
+ `client.auth` / `client.kv` / `client.storage` / `client.message` /
6
+ `client.space` / `client.agents` / `client.functions` — backed by
7
+ end-to-end-encrypted messaging (fan-out group channels with history, plus Double
8
+ Ratchet + ECDH P-384 for direct messages), ZK identity + personal/shared spaces,
9
+ server-side Programmable Agents, developer-authored serverless functions, and a
10
+ Cloudflare-Workers-compatible Groth16 verifier — all bundled from a single
11
+ TypeScript source tree.
12
+
13
+ See [`CHANGELOG.md`](./CHANGELOG.md) for what's new.
10
14
 
11
15
  > Status: alpha. The library is consumed in tree by `../accelerator` and the
12
16
  > `../web` SPA.
@@ -163,6 +167,69 @@ blind (it only ever sees opaque, ECIES-wrapped key blobs). The space handle was
163
167
  once `Room`; that name is still exported as an alias, and `client.message.room()`
164
168
  returns the same handle.
165
169
 
170
+ **Shareable invite links + member roles.** A private Space (`createChannel(name,
171
+ { private: true })`) admits only allowlisted members. Instead of inviting
172
+ people one username at a time, mint a **capability link** anyone can redeem —
173
+ the keeper admits them on redemption. Members carry a **role** (`viewer` /
174
+ `editor`) the owner controls; apps use roles to gate delegated management (e.g.
175
+ who can edit an app's config).
176
+
177
+ ```typescript
178
+ // Owner: mint a shareable invite (optionally time-/use-bounded, with a role).
179
+ const { token } = await client.space.createInviteLink(space.id, { role: "viewer", maxUses: 10 });
180
+ const url = `https://yourapp.com/join?space=${space.id}&token=${token}`;
181
+ await client.space.listInviteLinks(space.id); // owner: active links
182
+ await client.space.revokeInviteLink(space.id, token);
183
+
184
+ // Recipient: redeem the link → admitted by the keeper, group key wrapped for them.
185
+ const joined = await client.space.joinByInvite(space.id, token);
186
+
187
+ // Owner: see members + roles, and promote/demote.
188
+ await client.space.members(space.id); // [{ memberId, role }]
189
+ await client.space.setMemberRole(space.id, "alice", "editor");
190
+ await client.space.roster(space.id); // member identity pubkeys
191
+ ```
192
+
193
+ **Programmable Agents (`client.agents`).** Server-side "virtual users" backed by
194
+ Cloudflare Workers AI: an app editor gives an agent a persona (system prompt), a
195
+ model, and **triggers** (e.g. reply on @-mention), then enables it per-Space;
196
+ members chat with it inside that Space. Management is session-authed (owner or
197
+ Space editor) and **paid-tier-only**. Enabling an agent on a Space makes that
198
+ Space readable by the app's keeper (per-Space opt-in); every other Space stays
199
+ blind.
200
+
201
+ ```typescript
202
+ const { config } = await client.agents.create(appId, {
203
+ handle: "@assistant",
204
+ displayName: "Assistant",
205
+ model: "@cf/meta/llama-3.1-8b-instruct",
206
+ systemPrompt: "You are a concise, friendly teammate in this Space.",
207
+ triggers: [{ type: "mention" }],
208
+ });
209
+ await client.agents.enable(appId, config.agentId, space.id); // per-Space opt-in
210
+ // list / update / delete / disable also available.
211
+ ```
212
+
213
+ **Serverless Functions (`client.functions`).** Deploy your own code that runs on
214
+ the accelerator. A function is an untrusted single-module ES worker
215
+ (`export default { fetch }`) with two triggers: **HTTP** (reachable at its own
216
+ `<name>--<slug>.fns.<zone>` subdomain) and **Space-bound** (invoked on Space
217
+ messages, like an agent). Source is encrypted at rest and uploaded just-in-time
218
+ on invocation. Management is session-authed (owner / Space editor) and
219
+ **paid-tier-only**.
220
+
221
+ ```typescript
222
+ const { config } = await client.functions.deploy(appId, {
223
+ name: "hello",
224
+ displayName: "Hello",
225
+ code: `export default { fetch: () => new Response("hi from Muhkoo!") }`,
226
+ triggers: { http: { enabled: true } },
227
+ });
228
+ // → reachable at https://hello--<app-slug>.fns.<zone>/
229
+ await client.functions.enable(appId, config.functionId, space.id); // Space-bound
230
+ // list / get / code / update / delete / disable also available.
231
+ ```
232
+
166
233
  Auth lifecycle:
167
234
 
168
235
  ```typescript