copilotz 1.0.0-rc.24 → 1.0.0-rc.26
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/CHANGELOG.md +556 -0
- package/README.md +454 -240
- package/hosts/web/assets.d.ts +14 -11
- package/hosts/web/assets.js +16 -13
- package/hosts/web/host.d.ts +9 -5
- package/hosts/web/host.js +62 -27
- package/hosts/web/mod.d.ts +3 -5
- package/hosts/web/mod.js +3 -6
- package/hosts/web/node/bundle.js +1 -1
- package/hosts/web/node/mod.d.ts +17 -21
- package/hosts/web/node/mod.js +17 -21
- package/hosts/web/node/serve.d.ts +4 -59
- package/hosts/web/node/serve.js +12 -42
- package/hosts/web/server.d.ts +44 -146
- package/hosts/web/server.js +169 -262
- package/hosts/web/signin.d.ts +11 -5
- package/hosts/web/signin.js +5 -5
- package/hosts/web/theme/css.d.ts +1 -1
- package/hosts/web/theme/css.js +1 -1
- package/hosts/web/theme/default.d.ts +1 -1
- package/hosts/web/theme/files/mod.d.ts +1 -1
- package/hosts/web/widgets.js +2 -1
- package/package.json +2 -10
- package/plugins/access/accounts/actions/callback.d.ts +0 -1
- package/plugins/access/accounts/actions/callback.js +19 -33
- package/plugins/access/accounts/actions/disconnect.js +6 -4
- package/plugins/access/accounts/contract.d.ts +1 -1
- package/plugins/access/accounts/mod.d.ts +2 -2
- package/plugins/access/accounts/mod.js +6 -4
- package/plugins/access/accounts/routes/callback.d.ts +10 -0
- package/plugins/access/accounts/routes/callback.js +33 -0
- package/plugins/access/accounts/shared/flow.js +1 -1
- package/plugins/access/accounts/shared/oauth.d.ts +2 -2
- package/plugins/access/accounts/shared/oauth.js +2 -2
- package/plugins/access/accounts/shared/renew.js +4 -1
- package/plugins/access/accounts/shared/rules.d.ts +4 -2
- package/plugins/access/accounts/shared/rules.js +20 -5
- package/plugins/access/contacts/mod.js +8 -1
- package/plugins/access/dev/mod.d.ts +4 -4
- package/plugins/access/dev/mod.js +6 -5
- package/plugins/access/dev/routes/sign-in.d.ts +8 -0
- package/plugins/access/dev/routes/sign-in.js +25 -0
- package/plugins/access/dev/shared/here.d.ts +4 -0
- package/plugins/access/dev/shared/here.js +32 -0
- package/plugins/access/directory/actions/host.js +4 -3
- package/plugins/access/directory/actions/invite.js +2 -2
- package/plugins/access/directory/actions/org.d.ts +0 -1
- package/plugins/access/directory/actions/org.js +5 -24
- package/plugins/access/directory/collections/credit-code.d.ts +1 -1
- package/plugins/access/directory/collections/org-host.d.ts +4 -3
- package/plugins/access/directory/collections/org-host.js +4 -3
- package/plugins/access/directory/collections/org.d.ts +1 -1
- package/plugins/access/directory/collections/org.js +23 -1
- package/plugins/access/directory/contract.d.ts +8 -0
- package/plugins/access/directory/contract.js +8 -0
- package/plugins/access/directory/mod.d.ts +53 -13
- package/plugins/access/directory/mod.js +77 -14
- package/plugins/access/directory/routes/console.d.ts +26 -0
- package/plugins/access/directory/routes/console.js +129 -0
- package/plugins/access/directory/routes/enter.d.ts +18 -0
- package/plugins/access/directory/routes/enter.js +47 -0
- package/plugins/access/directory/routes/forward.d.ts +35 -0
- package/plugins/access/directory/routes/forward.js +119 -0
- package/plugins/access/directory/routes/orgs.d.ts +25 -0
- package/plugins/access/directory/routes/orgs.js +113 -0
- package/plugins/access/directory/routes/signout.d.ts +11 -0
- package/plugins/access/directory/routes/signout.js +36 -0
- package/plugins/access/directory/shared/enter.d.ts +36 -0
- package/plugins/access/directory/shared/enter.js +82 -0
- package/plugins/access/directory/shared/http.d.ts +42 -0
- package/plugins/access/directory/shared/http.js +77 -0
- package/plugins/access/directory/shared/member.d.ts +21 -0
- package/plugins/access/directory/shared/member.js +73 -0
- package/plugins/access/directory/shared/settings.d.ts +36 -4
- package/plugins/access/directory/shared/state.d.ts +74 -0
- package/plugins/access/directory/shared/state.js +101 -0
- package/{hosts/web/orgs.js → plugins/access/directory/web.js} +11 -7
- package/plugins/access/google/actions/sign-in.js +1 -1
- package/plugins/access/google/adapters/keys.d.ts +4 -4
- package/plugins/access/google/adapters/keys.js +2 -2
- package/plugins/access/google/mod.d.ts +3 -3
- package/plugins/access/google/mod.js +5 -14
- package/plugins/access/google/routes/sign-in.d.ts +12 -0
- package/plugins/access/google/routes/sign-in.js +36 -0
- package/plugins/access/identity/actions/session.js +3 -1
- package/plugins/access/identity/collections/credential.d.ts +8 -18
- package/plugins/access/identity/collections/credential.js +10 -25
- package/plugins/access/identity/contract.d.ts +16 -2
- package/plugins/access/identity/contract.js +18 -1
- package/plugins/access/identity/mod.d.ts +13 -8
- package/plugins/access/identity/mod.js +30 -25
- package/plugins/access/identity/routes/session.d.ts +17 -0
- package/plugins/access/identity/routes/session.js +35 -0
- package/plugins/access/mod.d.ts +5 -5
- package/plugins/access/spaces/actions/create.js +5 -2
- package/plugins/access/spaces/actions/member.js +8 -2
- package/plugins/access/spaces/actions/org.d.ts +2 -2
- package/plugins/access/spaces/actions/personal.js +2 -1
- package/plugins/access/spaces/contract.d.ts +15 -1
- package/plugins/access/spaces/mod.d.ts +1 -1
- package/plugins/access/spaces/shared/personal.d.ts +3 -2
- package/plugins/access/spaces/shared/personal.js +5 -3
- package/plugins/access/spaces/shared/reach.d.ts +18 -6
- package/plugins/access/spaces/shared/reach.js +20 -13
- package/plugins/access/spaces/shared/rules.d.ts +2 -0
- package/plugins/access/spaces/shared/rules.js +9 -3
- package/plugins/access/spaces/shared/seat.d.ts +3 -3
- package/plugins/access/spaces/shared/seat.js +6 -3
- package/plugins/access/spaces/views/web/members.d.ts +2 -1
- package/plugins/access/spaces/views/web/members.js +10 -4
- package/plugins/access/spaces/views/web/org-about.js +2 -1
- package/plugins/access/spaces/views/web/tree.js +2 -1
- package/plugins/access/spaces/views/web/who.d.ts +4 -1
- package/plugins/access/spaces/views/web/who.js +5 -6
- package/plugins/access/web.d.ts +1 -0
- package/plugins/access/web.js +2 -0
- package/plugins/agents/chat/collections/intent.d.ts +1 -1
- package/plugins/agents/chat/collections/message.d.ts +3 -3
- package/plugins/agents/chat/collections/shown.d.ts +1 -1
- package/plugins/agents/chat/mod.js +16 -1
- package/{hosts/web → plugins/agents/chat/routes}/files.d.ts +7 -10
- package/plugins/agents/chat/routes/files.js +107 -0
- package/plugins/agents/history/collections/outline.d.ts +2 -2
- package/plugins/agents/history/collections/summary.d.ts +1 -1
- package/plugins/agents/memory/mod.js +10 -1
- package/plugins/agents/openapi/actions/operation.js +1 -1
- package/plugins/agents/openapi/contract.d.ts +0 -2
- package/plugins/agents/openapi/mod.js +0 -3
- package/plugins/agents/routines/mod.js +9 -1
- package/plugins/agents/skills/mod.js +10 -1
- package/plugins/agents/team/mod.js +8 -1
- package/plugins/billing/credits/collections/plan.d.ts +1 -1
- package/plugins/billing/credits/views/web/composer.js +2 -1
- package/plugins/billing/stripe/actions/checkout.js +3 -3
- package/plugins/billing/stripe/actions/fact.d.ts +1 -0
- package/plugins/billing/stripe/actions/fact.js +39 -0
- package/plugins/billing/stripe/mod.d.ts +15 -3
- package/plugins/billing/stripe/mod.js +22 -3
- package/plugins/billing/stripe/routes/webhook.d.ts +16 -0
- package/plugins/billing/stripe/routes/webhook.js +56 -0
- package/plugins/billing/stripe/shared/api.d.ts +1 -1
- package/plugins/billing/stripe/shared/api.js +1 -1
- package/plugins/billing/stripe/shared/settings.d.ts +8 -3
- package/plugins/compute/apps/mod.js +8 -1
- package/plugins/compute/apps/shared/claims.d.ts +1 -1
- package/plugins/compute/cloud/collections/cloud-computer.d.ts +1 -1
- package/plugins/compute/cloud/collections/pool-want.d.ts +1 -1
- package/plugins/compute/cloud/contract.d.ts +6 -0
- package/plugins/compute/cloud/contract.js +6 -0
- package/plugins/compute/cloud/mod.d.ts +2 -2
- package/plugins/compute/cloud/mod.js +17 -5
- package/plugins/compute/computers/collections/approval.d.ts +2 -2
- package/plugins/compute/computers/collections/computer.d.ts +1 -1
- package/plugins/compute/computers/collections/grant.d.ts +1 -1
- package/plugins/compute/computers/mod.js +14 -5
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/resources/downloads.js +11 -13
- package/plugins/compute/computers/resources/previews.d.ts +6 -25
- package/plugins/compute/computers/resources/previews.js +30 -16
- package/plugins/interfaces/api/actions/create.js +50 -24
- package/plugins/interfaces/api/actions/revoke.js +18 -8
- package/plugins/interfaces/api/collections/key.d.ts +123 -53
- package/plugins/interfaces/api/collections/key.js +35 -36
- package/plugins/interfaces/api/contract.d.ts +11 -11
- package/plugins/interfaces/api/contract.js +1 -1
- package/plugins/interfaces/api/mod.d.ts +18 -13
- package/plugins/interfaces/api/mod.js +22 -15
- package/plugins/interfaces/api/processors/left.d.ts +3 -2
- package/plugins/interfaces/api/processors/left.js +11 -4
- package/plugins/interfaces/api/resources/presets.d.ts +3 -2
- package/plugins/interfaces/api/resources/presets.js +5 -3
- package/plugins/interfaces/api/shared/actor.d.ts +22 -8
- package/plugins/interfaces/api/shared/actor.js +34 -2
- package/plugins/interfaces/api/shared/end.d.ts +9 -0
- package/plugins/interfaces/api/shared/end.js +10 -0
- package/plugins/interfaces/api/shared/rules.d.ts +7 -4
- package/plugins/interfaces/api/shared/rules.js +17 -5
- package/plugins/interfaces/api/views/web/create.d.ts +7 -5
- package/plugins/interfaces/api/views/web/create.js +38 -33
- package/plugins/interfaces/api/views/web/keys.d.ts +21 -4
- package/plugins/interfaces/api/views/web/keys.js +22 -19
- package/plugins/interfaces/api/views/web/members.d.ts +13 -0
- package/plugins/interfaces/api/views/web/members.js +35 -0
- package/plugins/interfaces/api/views/web/reference.d.ts +6 -6
- package/plugins/interfaces/api/views/web/reference.js +17 -7
- package/plugins/interfaces/api/views/web/snippet.d.ts +18 -13
- package/plugins/interfaces/api/views/web/snippet.js +27 -16
- package/plugins/interfaces/api/views/web/style.d.ts +4 -3
- package/plugins/interfaces/api/views/web/style.js +31 -2
- package/plugins/interfaces/api/web.d.ts +5 -4
- package/plugins/interfaces/api/web.js +8 -5
- package/plugins/interfaces/maintenance/mod.js +2 -4
- package/plugins/interfaces/maintenance/resources/routes.d.ts +4 -14
- package/plugins/interfaces/maintenance/resources/routes.js +6 -11
- package/plugins/interfaces/mcp/actions/call.js +3 -3
- package/plugins/interfaces/mcp/contract.d.ts +5 -6
- package/plugins/interfaces/mcp/contract.js +4 -5
- package/plugins/interfaces/mcp/mod.d.ts +17 -17
- package/plugins/interfaces/mcp/mod.js +24 -24
- package/plugins/interfaces/mcp/resources/running.d.ts +1 -1
- package/plugins/interfaces/mcp/resources/running.js +1 -1
- package/plugins/interfaces/mcp/resources/server.d.ts +6 -13
- package/plugins/interfaces/mcp/resources/server.js +19 -24
- package/plugins/interfaces/mcp/resources/tools.d.ts +6 -8
- package/plugins/interfaces/mcp/resources/tools.js +2 -3
- package/plugins/interfaces/mcp/resources/widgets.d.ts +8 -8
- package/plugins/interfaces/mcp/resources/widgets.js +1 -1
- package/plugins/interfaces/mcp/shared/keys.d.ts +1 -1
- package/plugins/interfaces/mcp/shared/settings.d.ts +47 -68
- package/plugins/interfaces/mcp/shared/settings.js +27 -43
- package/plugins/interfaces/voice/actions/call.js +4 -4
- package/plugins/interfaces/voice/actions/prune.js +25 -17
- package/plugins/interfaces/voice/actions/{hook.d.ts → ring.d.ts} +2 -1
- package/plugins/interfaces/voice/actions/ring.js +165 -0
- package/plugins/interfaces/voice/collections/blocked.d.ts +1 -1
- package/plugins/interfaces/voice/collections/call.d.ts +2 -2
- package/plugins/interfaces/voice/contract.d.ts +2 -2
- package/plugins/interfaces/voice/mod.d.ts +13 -14
- package/plugins/interfaces/voice/mod.js +39 -33
- package/plugins/interfaces/voice/routes/hook.d.ts +21 -0
- package/plugins/interfaces/voice/routes/hook.js +114 -0
- package/plugins/interfaces/voice/routes/relay.d.ts +20 -0
- package/plugins/interfaces/voice/{resources → routes}/relay.js +63 -15
- package/plugins/interfaces/voice/shared/settings.d.ts +29 -42
- package/plugins/interfaces/voice/shared/settings.js +16 -22
- package/plugins/interfaces/voice/views/call.d.ts +1 -1
- package/plugins/interfaces/web/actions/arrive.js +18 -34
- package/plugins/interfaces/web/actions/sending.js +2 -2
- package/plugins/interfaces/web/actions/spent.js +2 -2
- package/plugins/interfaces/web/collections/visitor.d.ts +2 -2
- package/plugins/interfaces/web/collections/visitor.js +13 -12
- package/plugins/interfaces/web/contract.d.ts +2 -2
- package/plugins/interfaces/web/lines.d.ts +17 -18
- package/plugins/interfaces/web/lines.js +28 -23
- package/plugins/interfaces/web/mod.d.ts +1 -1
- package/plugins/interfaces/web/mod.js +1 -1
- package/plugins/interfaces/web/resources/spend.js +3 -3
- package/plugins/interfaces/web/routes/arrive.d.ts +20 -0
- package/plugins/interfaces/web/routes/arrive.js +92 -0
- package/plugins/interfaces/web/shared/codes.d.ts +1 -1
- package/plugins/interfaces/web/shared/lines.d.ts +43 -54
- package/plugins/interfaces/web/shared/lines.js +33 -42
- package/plugins/interfaces/web/shared/secret.d.ts +1 -1
- package/plugins/interfaces/web/views/console-codes.d.ts +1 -1
- package/plugins/interfaces/web/views/console-codes.js +2 -1
- package/plugins/interfaces/web/views/console.js +2 -1
- package/plugins/interfaces/web/views/frame.js +2 -1
- package/plugins/interfaces/web/views/org.js +2 -1
- package/plugins/interfaces/web/views/orgs.d.ts +2 -1
- package/plugins/interfaces/web/views/orgs.js +2 -1
- package/plugins/interfaces/whatsapp/actions/connect.js +2 -2
- package/plugins/interfaces/whatsapp/actions/hook.d.ts +8 -1
- package/plugins/interfaces/whatsapp/actions/hook.js +91 -70
- package/plugins/interfaces/whatsapp/actions/link.js +2 -2
- package/plugins/interfaces/whatsapp/collections/number.d.ts +2 -2
- package/plugins/interfaces/whatsapp/collections/number.js +1 -1
- package/plugins/interfaces/whatsapp/contract.d.ts +1 -1
- package/plugins/interfaces/whatsapp/mod.d.ts +8 -6
- package/plugins/interfaces/whatsapp/mod.js +21 -16
- package/plugins/interfaces/whatsapp/processors/receive.js +2 -2
- package/plugins/interfaces/whatsapp/routes/hook.d.ts +16 -0
- package/plugins/interfaces/whatsapp/routes/hook.js +52 -0
- package/plugins/interfaces/whatsapp/shared/graph.d.ts +2 -1
- package/plugins/interfaces/whatsapp/shared/graph.js +5 -3
- package/plugins/interfaces/whatsapp/shared/media.d.ts +2 -1
- package/plugins/interfaces/whatsapp/shared/media.js +6 -4
- package/plugins/interfaces/whatsapp/shared/number.d.ts +1 -1
- package/plugins/interfaces/whatsapp/shared/number.js +21 -21
- package/plugins/interfaces/whatsapp/shared/rules.d.ts +3 -1
- package/plugins/interfaces/whatsapp/shared/rules.js +7 -2
- package/plugins/interfaces/whatsapp/shared/settings.d.ts +19 -33
- package/plugins/interfaces/whatsapp/shared/settings.js +8 -20
- package/runtime/actor.d.ts +39 -2
- package/runtime/actor.js +40 -0
- package/{hosts/web → runtime}/address.js +10 -8
- package/runtime/api.d.ts +49 -0
- package/runtime/api.js +670 -0
- package/runtime/body.d.ts +16 -0
- package/runtime/body.js +57 -0
- package/runtime/browsers.d.ts +27 -15
- package/runtime/browsers.js +18 -20
- package/runtime/caller.d.ts +18 -9
- package/runtime/caller.js +20 -9
- package/runtime/client.d.ts +110 -11
- package/runtime/client.js +201 -12
- package/runtime/collection.d.ts +2 -0
- package/runtime/collection.js +2 -1
- package/runtime/cookies.d.ts +72 -0
- package/runtime/cookies.js +125 -0
- package/runtime/define.d.ts +88 -6
- package/runtime/executor.d.ts +2 -0
- package/runtime/executor.js +12 -3
- package/runtime/fetch.d.ts +97 -0
- package/runtime/fetch.js +404 -0
- package/runtime/links.d.ts +2 -2
- package/runtime/mod.d.ts +8 -2
- package/runtime/mod.js +8 -2
- package/runtime/ops.d.ts +9 -1
- package/runtime/ops.js +103 -0
- package/runtime/owner.d.ts +19 -10
- package/runtime/owner.js +273 -33
- package/runtime/reads.d.ts +3 -3
- package/runtime/reads.js +8 -6
- package/runtime/registry.d.ts +15 -3
- package/runtime/registry.js +14 -2
- package/runtime/rest.d.ts +10 -0
- package/runtime/rest.js +247 -0
- package/runtime/routes.d.ts +51 -0
- package/runtime/routes.js +79 -0
- package/runtime/runtime.d.ts +6 -9
- package/runtime/runtime.js +9 -7
- package/runtime/runtimes.d.ts +43 -0
- package/runtime/runtimes.js +86 -0
- package/runtime/site.d.ts +47 -0
- package/runtime/site.js +170 -0
- package/runtime/tickets.d.ts +15 -0
- package/{hosts/web → runtime}/tickets.js +25 -4
- package/testing/mod.d.ts +16 -0
- package/testing/mod.js +31 -2
- package/hosts/orgs/mod.d.ts +0 -128
- package/hosts/orgs/mod.js +0 -741
- package/hosts/web/entrances.d.ts +0 -250
- package/hosts/web/entrances.js +0 -362
- package/hosts/web/files.js +0 -116
- package/hosts/web/routes.d.ts +0 -179
- package/hosts/web/routes.js +0 -312
- package/hosts/web/tickets.d.ts +0 -33
- package/plugins/access/identity/actions/key.d.ts +0 -2
- package/plugins/access/identity/actions/key.js +0 -48
- package/plugins/billing/stripe/webhook.d.ts +0 -17
- package/plugins/billing/stripe/webhook.js +0 -45
- package/plugins/interfaces/api/shared/events.d.ts +0 -26
- package/plugins/interfaces/api/shared/events.js +0 -143
- package/plugins/interfaces/api/shared/http.d.ts +0 -28
- package/plugins/interfaces/api/shared/http.js +0 -93
- package/plugins/interfaces/api/shared/reference.d.ts +0 -48
- package/plugins/interfaces/api/shared/reference.js +0 -37
- package/plugins/interfaces/api/shared/server.d.ts +0 -34
- package/plugins/interfaces/api/shared/server.js +0 -176
- package/plugins/interfaces/voice/actions/hook.js +0 -225
- package/plugins/interfaces/voice/resources/relay.d.ts +0 -79
- package/plugins/interfaces/web/resources/entrance.d.ts +0 -47
- package/plugins/interfaces/web/resources/entrance.js +0 -83
- package/plugins/interfaces/whatsapp/shared/http.d.ts +0 -47
- package/plugins/interfaces/whatsapp/shared/http.js +0 -22
- /package/{hosts/web/orgs.d.ts → plugins/access/directory/web.d.ts} +0 -0
- /package/{hosts/web → runtime}/address.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,561 @@
|
|
|
1
1
|
## Unreleased
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.26 — 2026-11-06
|
|
4
|
+
|
|
5
|
+
**Upgrading from rc.25.** The `hosts` resource names the app's own hosts an entry each, without the
|
|
6
|
+
`own` key it had alone. An app that names its hosts changes one line; one that doesn't changes
|
|
7
|
+
nothing. The shape before is refused at start, saying what's expected.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// rc.25
|
|
11
|
+
resources: { hosts: { own: ["app.example.com", "*.run.app"] } }
|
|
12
|
+
// now
|
|
13
|
+
resources: { hosts: { "app.example.com": true, "*.run.app": true } }
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- **`resources.hosts` is an entry per host** (`{ "app.example.com": true }`), in place of
|
|
17
|
+
`{ own: [...] }`, like every other resource: a later plugin adds a host, or takes one away with
|
|
18
|
+
`null`, without restating the rest. What it does is unchanged: with the app's hosts named, any
|
|
19
|
+
other host is answered only by routes that take it. `HostsSettings` is `Record<string, true>`.
|
|
20
|
+
|
|
21
|
+
## 1.0.0-rc.25 — 2026-11-06
|
|
22
|
+
|
|
23
|
+
**Upgrading from rc.24.** The runtime now answers HTTP itself. `runtime.fetch(request)` is a fetch
|
|
24
|
+
handler (a function from a web-standard `Request` to a `Response`) that every host calls; plugins
|
|
25
|
+
declare their HTTP as `routes` (plain functions by URL pattern) and say who a request is with `who`
|
|
26
|
+
(a function from a request to an actor, or nothing); the runtime names and sets every cookie; the
|
|
27
|
+
page is a plugin (`webPage`); and many orgs are the directory's routes, forwarding each request to
|
|
28
|
+
its org's runtime. Every URL, webhook path and cookie name stays as it was, so nobody signs in
|
|
29
|
+
again. Developer keys made before stop working: make them again (step 7). The steps, in order:
|
|
30
|
+
|
|
31
|
+
1. **Composition: the page is a plugin, and the runtime takes no browser options.** Drop
|
|
32
|
+
`transports: [socket]` and `admit: tickets.admit`: the runtime keeps its own one-time tickets and
|
|
33
|
+
takes its own socket at `/oxian`. Add `webPage` (from `copilotz/web/server`) with a `page`
|
|
34
|
+
resource. What `serve` and `webServer` took as options are resources now: `code`, `title`,
|
|
35
|
+
`lang`, `assets` and `base` go in `page`; `theme` in `theme`; `front: { secret }` is the `caller`
|
|
36
|
+
resource's `front` (beside its `header`); `widgets` go in `widgets`. `code` may be a function
|
|
37
|
+
that bundles once, on the page's first request.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// rc.24
|
|
41
|
+
const tickets = createTickets(); // copilotz/web/tickets
|
|
42
|
+
const runtime = await createRuntime({
|
|
43
|
+
store,
|
|
44
|
+
plugins: [...plugins, devSignIn],
|
|
45
|
+
transports: [socket], // copilotz/web/server
|
|
46
|
+
admit: tickets.admit,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// now
|
|
50
|
+
const runtime = await createRuntime({
|
|
51
|
+
store,
|
|
52
|
+
plugins: [
|
|
53
|
+
...plugins,
|
|
54
|
+
devSignIn,
|
|
55
|
+
webPage,
|
|
56
|
+
definePlugin({
|
|
57
|
+
name: "page",
|
|
58
|
+
resources: {
|
|
59
|
+
page: { title: "Notes", code: () => bundle(new URL("./browser.tsx", import.meta.url)) },
|
|
60
|
+
theme: themeOf([]),
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **Serving: a listener calls `runtime.fetch`.** On Node and Bun, `listen(runtime.fetch, options)`
|
|
68
|
+
from `copilotz/web/node` replaces `serve({ runtime, tickets, code, … })`. It answers a
|
|
69
|
+
`Listener`, whose `shutdown()` stops listening, and you close the runtime yourself
|
|
70
|
+
(`runtime.close({ drain })`). On Deno, `Deno.serve(runtime.fetch)` replaces serving
|
|
71
|
+
`webServer({ …, upgrade })` with Oxian's Deno handler, and needs no `setClientAddress`: the
|
|
72
|
+
runtime reads the socket's address from what `Deno.serve` hands it. On workerd,
|
|
73
|
+
`export default { fetch: runtime.fetch }`. Bun's own `Bun.serve({ fetch: runtime.fetch })` serves
|
|
74
|
+
requests but not the runtime's socket, so use `listen` there.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
// rc.24
|
|
78
|
+
const server = await serve({ runtime, tickets, code, theme, port: 8080 });
|
|
79
|
+
process.once("SIGTERM", () => server.close({ drain: 8_000 }));
|
|
80
|
+
|
|
81
|
+
// now
|
|
82
|
+
const server = await listen(runtime.fetch, { port: 8080 });
|
|
83
|
+
process.once("SIGTERM", async () => {
|
|
84
|
+
await server.shutdown();
|
|
85
|
+
await runtime.close({ drain: 8_000 });
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3. **Settings: flat named entries, one `caller`, and `ctx.fetch`.** Each interface plugin's resource
|
|
90
|
+
is a map of what the app declares, by name, with no `lines` key. `web.caller` and `mcp.caller`
|
|
91
|
+
are one `caller` resource. `caller.exempt` is the MCP server's own `exempt`, `voice.keep` each
|
|
92
|
+
number's `keep`, and `mcp.atOnce` each server's `limits.atOnce`; `whatsapp.codeMinutes` and
|
|
93
|
+
`whatsapp.maxFileMb` are constants now, and a declared entry's `org` is gone (each org's runtime
|
|
94
|
+
declares its own). Types: `WhatsAppLine` is `DeclaredNumber`, `VoiceLine` `DeclaredVoiceNumber`,
|
|
95
|
+
`McpLine` `DeclaredServer`, `WebLine` `DeclaredSite`, and `McpCaller` `CallerSettings`. Plugin
|
|
96
|
+
code calls outside services through `ctx.fetch` (step 10), so the `whatsapp.graph` setting,
|
|
97
|
+
Stripe's `settings.fetch`, `googleKeys(fetcher)`'s argument and openapi's `fetch` setting are
|
|
98
|
+
gone.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// rc.24
|
|
102
|
+
resources: {
|
|
103
|
+
web: {
|
|
104
|
+
caller: { header: "cf-connecting-ip", front },
|
|
105
|
+
lines: { site: { in: "visitors", agent: "guide" } },
|
|
106
|
+
},
|
|
107
|
+
whatsapp: {
|
|
108
|
+
lines: { vendas: { in: "customers", phoneId, token, secret, verify, agent: "mobi" } },
|
|
109
|
+
},
|
|
110
|
+
mcp: { atOnce: 4, lines: { chatgpt: { in: "customers", tools } } },
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// now
|
|
114
|
+
resources: {
|
|
115
|
+
caller: { header: "cf-connecting-ip", front },
|
|
116
|
+
web: { site: { in: "visitors", agent: "guide" } },
|
|
117
|
+
whatsapp: { vendas: { in: "customers", phoneId, token, secret, verify, agent: "mobi" } },
|
|
118
|
+
mcp: { chatgpt: { in: "customers", tools } },
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
4. **Routes: plain functions on a plugin.** The `routes` resource goes, with its three shapes
|
|
123
|
+
(`{ path, action }`, `{ path, serve }`, `{ host, serve }`), `methods`, `HttpRequest`,
|
|
124
|
+
`HttpAnswer` and `Served`. A plugin's `routes` field maps a `URLPattern` pathname to a `Route`:
|
|
125
|
+
`(request, { runtime, actor, params, cookies }) => Response`. A path that took everything under
|
|
126
|
+
it (`"/hooks/"`) is `"/hooks/*"`; a host route is a whole URL pattern (`"*://*-preview.*:*/*"`);
|
|
127
|
+
a route checks its own method. `host.runtime` is `ctx.runtime`, `await host.whom()` is
|
|
128
|
+
`ctx.actor`, `host.host` is the request's own URL (already the site the browser asked for),
|
|
129
|
+
`host.upgrade()` is Oxian's `upgradeWebSocket(request)`, and `host.widgets` is the `widgets`
|
|
130
|
+
resource. A route calls Actions as trusted code, as the system unless it names an actor
|
|
131
|
+
(`runtime.call(name, input, { actor })`): an Action that took an `HttpRequest` behind
|
|
132
|
+
`{ path, action }` takes plain data now, and one only a route calls needs no `allow`.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// rc.24
|
|
136
|
+
resources: {
|
|
137
|
+
routes: {
|
|
138
|
+
ping: {
|
|
139
|
+
path: "/hooks/ping",
|
|
140
|
+
methods: ["POST"],
|
|
141
|
+
serve: async (request, host) =>
|
|
142
|
+
Response.json(await host.runtime.call("relay.ping", { body: await request.text() })),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
// now
|
|
148
|
+
routes: {
|
|
149
|
+
"/hooks/ping": async (request, { runtime }) => {
|
|
150
|
+
if (request.method !== "POST") return new Response("Only POST", { status: 405 });
|
|
151
|
+
return Response.json(await runtime.call("relay.ping", { body: await request.text() }));
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
5. **Sign-in: plugins' routes, `who`, and the runtime's cookies.** The `entrances` and `signIn`
|
|
157
|
+
resources go. Apps on `googleSignIn` and `devSignIn` change nothing: their routes are
|
|
158
|
+
`POST /signin/google` (with `GET /google` for the button's client id) and `/signin/dev`, which
|
|
159
|
+
the page already used. A sign-in method of your own is a plugin built on identity whose route
|
|
160
|
+
calls its Action and answers with identity's `signedIn` (from `copilotz/plugins/access`), which
|
|
161
|
+
sets the session's cookie. A credential of your own (an entrance's `cookie` and `query`) is a
|
|
162
|
+
plugin's `who`, and its cookie is set and cleared with `ctx.cookies`: no plugin writes
|
|
163
|
+
`Set-Cookie`. Identity's `POST /signout` ends the session, disconnects its browsers and clears
|
|
164
|
+
its cookie; its `GET /me` says whom the page shows.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
// rc.24
|
|
168
|
+
resources: {
|
|
169
|
+
signIn: { mine: { action: "mine.sign-in" } },
|
|
170
|
+
entrances: { badge: { cookie: "badge", query: "badge.actor" } },
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
// now
|
|
174
|
+
definePlugin({
|
|
175
|
+
name: "mine-sign-in",
|
|
176
|
+
requires: ["identity"],
|
|
177
|
+
actions: { "mine.sign-in": signInAction }, // answers { person, session }, as before
|
|
178
|
+
routes: {
|
|
179
|
+
"/signin/mine": async (request, { runtime, cookies }) =>
|
|
180
|
+
signedIn(cookies, await runtime.call("mine.sign-in", await request.json())),
|
|
181
|
+
},
|
|
182
|
+
who: (_request, { cookies, query }) => {
|
|
183
|
+
const secret = cookies.get("badge");
|
|
184
|
+
return secret ? query("badge.actor", { secret }) : null;
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
6. **The site chat: its own route.** `web({ arrive: { line } })` is `web({ arrive: { name } })`. The
|
|
190
|
+
page posts to the site chat's route, `POST /web/<name>` (with `{ challenge }` when it has one),
|
|
191
|
+
before it connects, and `/connect` takes no JSON. `contact.arrive` loses its `secret` input. The
|
|
192
|
+
cookie (`visitor`) and the limits are the same.
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
// rc.24
|
|
196
|
+
await web({ root, plugins: [siteShell, chatWeb], arrive: { line: "site", challenge: token } });
|
|
197
|
+
|
|
198
|
+
// now
|
|
199
|
+
await web({ root, plugins: [siteShell, chatWeb], arrive: { name: "site", challenge: token } });
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
7. **Keys: members of their space, with a scope.** Every key is the api plugin's, and every key has
|
|
203
|
+
a scope: `api_key.create` takes `scope` (`call`, `query`, `view`, `read`, `write`) in place of
|
|
204
|
+
`actions`, `queries` and `views`, and `apiPresets` are `{ title, description, scope }`. An Action
|
|
205
|
+
that takes a space gets no default from a key: the key names `in`. Identity's unscoped keys
|
|
206
|
+
(`key.create`, `key.revoke`, `credential.keys`) are gone. Keys made before stop working: make
|
|
207
|
+
them again.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
// rc.24
|
|
211
|
+
await runtime.call("api_key.create", {
|
|
212
|
+
in: space,
|
|
213
|
+
name: "Bot",
|
|
214
|
+
actions: ["chat.send"],
|
|
215
|
+
queries: ["thread.recent"],
|
|
216
|
+
}, { actor });
|
|
217
|
+
|
|
218
|
+
// now
|
|
219
|
+
await runtime.call("api_key.create", {
|
|
220
|
+
in: space,
|
|
221
|
+
name: "Bot",
|
|
222
|
+
scope: { call: ["chat.send"], query: ["thread.recent"] },
|
|
223
|
+
}, { actor });
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
8. **REST and the client.** `/api/` is the runtime's own now (the api plugin's `serveApi` is gone),
|
|
227
|
+
answered for whoever `who` says: a key, a session from the app's own page, or anonymous. Its
|
|
228
|
+
paths are unchanged, with more beside them (below). A View over `/api/` asked with `?follow=1` is
|
|
229
|
+
asked with `Accept: text/event-stream`, and `?id=` is `?item=` (the item, as JSON). A script
|
|
230
|
+
connects with the client instead of hand-made requests, over the socket or over HTTP, and its
|
|
231
|
+
collections are spelled as plugin code's.
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
// rc.24
|
|
235
|
+
const headers = { authorization: `Bearer ${key}`, "content-type": "application/json" };
|
|
236
|
+
await fetch(`${app}/api/actions/booking.cancel`, {
|
|
237
|
+
method: "POST",
|
|
238
|
+
headers,
|
|
239
|
+
body: '{"id":"42"}',
|
|
240
|
+
});
|
|
241
|
+
await fetch(`${app}/api/views/booking.panel?id=42&follow=1`, { headers });
|
|
242
|
+
|
|
243
|
+
// now
|
|
244
|
+
const client = await connect(app, { key }); // the socket; { key, over: "http" } for the REST API
|
|
245
|
+
await client.call("booking.cancel", { id: "42" });
|
|
246
|
+
const stop = client.db.collection("booking").watch({ _id: "42" }, (rows) => show(rows));
|
|
247
|
+
// by hand: GET /api/views/booking.panel?item={"_id":"42"}, with Accept: text/event-stream
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
9. **Many orgs: the directory's routes.** `orgsHost` (`copilotz/orgs`) goes. The directory's runtime
|
|
251
|
+
is the app's `fetch`, and its plugin's routes forward each request, untouched and sockets
|
|
252
|
+
included, to its org's runtime. Its `directory` resource takes the orgs' runtimes as a pool
|
|
253
|
+
(`orgs`: `runtimes(open)`, from `copilotz`) and a `lobby` for someone signed in nowhere (a
|
|
254
|
+
runtime with the page), beside `staff` and `operations`; `hosts` is the `hosts` resource's `own`.
|
|
255
|
+
Each org's runtime gets `directory.member(dir, org)`, in place of what `open` was given
|
|
256
|
+
(`plugins`, `admit`, `transports`) and of `here(org)`. `listen(dir.fetch)` carries sockets too:
|
|
257
|
+
no `hypervisor` picker. `org.get` is the `org.info` query, and front ends import the orgs'
|
|
258
|
+
browser half (`useOrgs`, `enterOrg`…) from `copilotz/plugins/access/web`. Stripe's webhook is the
|
|
259
|
+
`stripeWebhook` plugin, in the directory's runtime with the pool as the `stripe` resource's
|
|
260
|
+
`orgs` (below).
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
// rc.24
|
|
264
|
+
const host = orgsHost({
|
|
265
|
+
directory: await createRuntime({ store, plugins: [identity, directory, devSignIn] }),
|
|
266
|
+
open: async (org, given) =>
|
|
267
|
+
await createRuntime({
|
|
268
|
+
store: storeOf(org),
|
|
269
|
+
plugins: [...plugins, ...given.plugins],
|
|
270
|
+
transports: given.transports,
|
|
271
|
+
admit: given.admit,
|
|
272
|
+
browsers: given.browsers,
|
|
273
|
+
}),
|
|
274
|
+
upgrade: () => new Response("Connect again", { status: 503 }),
|
|
275
|
+
code,
|
|
276
|
+
theme,
|
|
277
|
+
});
|
|
278
|
+
await listen({ fetch: host.serve, hypervisor: (r) => host.openRuntime(r)?.hypervisor, port });
|
|
279
|
+
|
|
280
|
+
// now
|
|
281
|
+
const orgs = runtimes(async (id) => {
|
|
282
|
+
const org = await dir.query<OrgInfo | null>("org.info", { org: id });
|
|
283
|
+
if (!org) return undefined;
|
|
284
|
+
return await createRuntime({
|
|
285
|
+
store: await storeOf(org),
|
|
286
|
+
plugins: [...plugins, ...page, directory.member(dir, org)], // page: webPage and its resource
|
|
287
|
+
browsers: { pool: visitors }, // const visitors = contactsPool()
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
const lobby = await createRuntime({ store: memoryStore(), plugins: page });
|
|
291
|
+
const dir: Runtime = await createRuntime({
|
|
292
|
+
store,
|
|
293
|
+
plugins: [
|
|
294
|
+
identity,
|
|
295
|
+
directory,
|
|
296
|
+
devSignIn,
|
|
297
|
+
definePlugin({
|
|
298
|
+
name: "directory-settings",
|
|
299
|
+
resources: { directory: { orgs, lobby } },
|
|
300
|
+
}),
|
|
301
|
+
],
|
|
302
|
+
});
|
|
303
|
+
await listen(dir.fetch, { port });
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
10. **Tests: `testWho`, `ticketFor`, `runtime.fetch` and `createRuntime({ fetch })`.** A test that
|
|
307
|
+
made browsers with `createRuntime({ admit })` adds `testWho` (from `copilotz/testing`: a `who`
|
|
308
|
+
that believes the `x-test-actor` header, for tests alone) and takes each ticket from the
|
|
309
|
+
runtime's `/connect` with `ticketFor(runtime, actor)`. HTTP needs no listener:
|
|
310
|
+
`await runtime.fetch(new Request(url, init))`. A fake outside service (Meta's Graph API, Stripe,
|
|
311
|
+
Google's keys) is the `fetch` the runtime gives plugin code, as `clock` is replaced.
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
// rc.24
|
|
315
|
+
const tickets = new Map<string, Actor>();
|
|
316
|
+
const runtime = await createRuntime({
|
|
317
|
+
store,
|
|
318
|
+
plugins: [
|
|
319
|
+
...plugins,
|
|
320
|
+
definePlugin({ name: "t", resources: { whatsapp: { graph: fake.url } } }),
|
|
321
|
+
],
|
|
322
|
+
transports: [transport],
|
|
323
|
+
admit: (secret) => tickets.get(secret),
|
|
324
|
+
});
|
|
325
|
+
const ticket = () => {
|
|
326
|
+
const secret = crypto.randomUUID();
|
|
327
|
+
tickets.set(secret, ana);
|
|
328
|
+
return Promise.resolve(secret);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// now
|
|
332
|
+
const runtime = await createRuntime({
|
|
333
|
+
store,
|
|
334
|
+
plugins: [...plugins, testWho],
|
|
335
|
+
transports: [transport],
|
|
336
|
+
fetch: fakeMeta,
|
|
337
|
+
});
|
|
338
|
+
const ticket = () => ticketFor(runtime, ana);
|
|
339
|
+
const hook = await runtime.fetch(new Request("http://localhost/hooks/whatsapp/vendas", init));
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**What changes, and what goes:**
|
|
343
|
+
|
|
344
|
+
- **`runtime.fetch(request, info?)`** answers every request: a route with a host first (a host it
|
|
345
|
+
takes is that route's alone); the socket (`/oxian`, and `<base>/oxian`); then requests from other
|
|
346
|
+
sites are refused; `POST /connect`; the REST API (`/api/`); plugins' routes; `GET /health` when no
|
|
347
|
+
route takes it (`ok`); else a 404. What a listener passes beside the request (Deno's `info`, Bun's
|
|
348
|
+
server) says the socket's address. Another runtime's route may forward a request to it
|
|
349
|
+
(`other.fetch(request)`), sockets included: a socket `Deno.serve` gave stays Deno's to accept. The
|
|
350
|
+
runtime accepts its own socket: Deno's upgrade under `Deno.serve`, a `WebSocketPair` on workerd
|
|
351
|
+
(not tested yet), else Oxian's route upgrade, whose decision `listen` takes directly (Oxian
|
|
352
|
+
0.23.4's asynchronous `prepare`).
|
|
353
|
+
- **The site** is decided once, before anything else: the address the browser asked for, on the host
|
|
354
|
+
the app's front says when the request carries the front's secret (`x-copilotz-front`, the `caller`
|
|
355
|
+
resource's `front`; then `x-forwarded-host`), and under the app's base (`resources.page.base`: a
|
|
356
|
+
route sees `/o/acme/x` as `/x`). Routes are matched, and cookies named and secured, by it. Without
|
|
357
|
+
the secret, forwarded headers are ignored.
|
|
358
|
+
- **Requests from other sites are refused** (403), in one rule in place of the web host's
|
|
359
|
+
`fromPage`: a request that may change something (anything but GET, HEAD and OPTIONS), whose
|
|
360
|
+
`Sec-Fetch-Site` isn't `same-origin` (or `none`) or whose `Origin` isn't the site's own, unless it
|
|
361
|
+
carries `Authorization`. It holds for every route, not only `/connect`; a sibling host under the
|
|
362
|
+
same domain is another site; webhooks send no `Origin`, and pass. So an MCP server's `origins`
|
|
363
|
+
lets a browser's call through only with `Authorization`.
|
|
364
|
+
- **`resources.hosts`** (`{ own: ["app.example.com", "*.run.app"] }`): the app's own hosts. With
|
|
365
|
+
them named, a request to any other host is answered only by routes that take its host (a 404 when
|
|
366
|
+
none does), never by the runtime's paths, its socket or `/connect`; and the app's own hosts are
|
|
367
|
+
never a host route's. A host route for every host (`*`) takes only hosts that aren't the app's
|
|
368
|
+
own: with none named, none.
|
|
369
|
+
- **`who`** (`Plugin.who`, the `Who` and `WhoContext` types): asked in plugin order, once per
|
|
370
|
+
request and when `/connect` issues a ticket; the first answer wins, and none is anonymous
|
|
371
|
+
(`{ kind: "anonymous", id: "" }`). A `who` can't answer the system. What it queries is kept five
|
|
372
|
+
seconds per query and params, and dropped when the actor is disconnected. `WhoContext` has
|
|
373
|
+
`resources`, `query` and `call` (as the system: the api plugin notes a key's last use) and
|
|
374
|
+
`cookies.get`. A request with both a session cookie and a key is whoever the first plugin in order
|
|
375
|
+
says (usually the cookie). A store's failure while asking is a 500, never anonymous.
|
|
376
|
+
- **Routes** (`Plugin.routes`, the `Route` and `RouteContext` types): matched more specific first,
|
|
377
|
+
segment by segment (a literal before a parameter before a wildcard, deeper before shallower), `/*`
|
|
378
|
+
last, and among patterns alike in plugin order; a later plugin's route replaces an earlier one of
|
|
379
|
+
the same pattern, and `null` removes it. A route that isn't a pattern, or takes `/connect`,
|
|
380
|
+
`/oxian`, `/api` or anything under `/api/`, stops the runtime from starting. What a route throws
|
|
381
|
+
answers by its code: `invalid` 400, `unauthorized` 401, `forbidden` 403, `not_found` 404,
|
|
382
|
+
`too_many` 429 (with `retry-after`), anything else 500 (logged), its words only when they're
|
|
383
|
+
public.
|
|
384
|
+
- **Cookies** (`ctx.cookies`, the `Cookies` type): `get(name)`,
|
|
385
|
+
`set(name, secret, { days, sameSite })` and `clear(name, { sameSite })`, by the plain name; the
|
|
386
|
+
runtime puts them on the route's response. Every cookie is httpOnly, `Path=/`, with no `Domain`;
|
|
387
|
+
`Secure` and named `__Host-<name>` anywhere but plain http to this machine or one on its network;
|
|
388
|
+
`SameSite=Lax` (30 days) unless said. A value is 1 to 512 cookie-safe characters (letters, digits
|
|
389
|
+
and `._~+/=-`): a short one is fine where it's no secret; a cookie holding anything else reads as
|
|
390
|
+
none. A response that sets or clears one is `no-store`. A name is the first plugin's to set;
|
|
391
|
+
another may only when one builds on the other (`requires`), or both on the same one (Google's and
|
|
392
|
+
dev sign-in's, and the directory's sign-out, all set identity's session); anything else is a
|
|
393
|
+
plugin's mistake, and a 500. The `cookies` resource (`{ names, suffix }`, the `CookieSettings`
|
|
394
|
+
type) renames them: `names` maps a name to the one it goes by, and `suffix` follows every other.
|
|
395
|
+
- **Cookies the web host kept, and no longer does:** a leftover plain `session` cookie beside
|
|
396
|
+
`__Host-session` is no longer cleared (it's ignored); a cookie that proves no one (forged, ended)
|
|
397
|
+
is no longer cleared, and reads as nobody; `POST /signout` clears identity's `session` only (a
|
|
398
|
+
site visitor's cookie stays).
|
|
399
|
+
- **Tickets are the runtime's** (`runtime/tickets.ts`): one works once, for a minute; an actor has
|
|
400
|
+
30 a minute (`browsers.tickets`), past which `/connect` is a 429 with `retry-after`. Disconnecting
|
|
401
|
+
an actor ends its tickets not yet used; a person's key has its own, apart from its person's.
|
|
402
|
+
`createRuntime`'s `admit` is gone, and the runtime always has a key for remote executors (a new
|
|
403
|
+
one each start, unless given).
|
|
404
|
+
- **`POST /connect`** (POST only: else 405) answers `{ ticket, actor: { kind, id } }` (no `name`:
|
|
405
|
+
the page asks `GET /me`), 401 for anonymous, and reads no body: arriving at a site chat is
|
|
406
|
+
`POST /web/<name>`.
|
|
407
|
+
- **Checked at start:** routes' patterns, `page.base` (a path with no trailing slash), the `cookies`
|
|
408
|
+
and `hosts` resources, and the `links` secret (too short to sign with stops the start, rather than
|
|
409
|
+
failing each link).
|
|
410
|
+
- **New in `copilotz`:** `runtimes` and `Runtimes`; `connect` and the client's types
|
|
411
|
+
(`ClientCollection`, `RemoteOptions`, `Watcher`…); `inScope` and `Scope`; `clientAddress`,
|
|
412
|
+
`setClientAddress` and `loopbackAddress` (were in `copilotz/web/server`); `bodyOf` and `jsonOf`;
|
|
413
|
+
`cookieSafe` and `CookieSettings`; `hostMatches`, `HostsSettings`, `ownHost`, `vouched`,
|
|
414
|
+
`loopback` and `nearby`; `callerOf` and `exemptProblem`; and the `Route`, `RouteContext`, `Who`,
|
|
415
|
+
`WhoContext` and `Cookies` types.
|
|
416
|
+
- **`runtimes(open, { idleMs })`:** runtimes by id, each opened on its first `get`, the same one
|
|
417
|
+
after (a failed opening is tried again), closed once idle (no browsers, nothing pending, 30
|
|
418
|
+
minutes unless said) and opened again on its next use; `peek(id)` and `entries()` never open one;
|
|
419
|
+
`close(id)` closes one now, and a `get` meanwhile opens another only once it has closed, so one id
|
|
420
|
+
never has two writers; `close()` closes them all.
|
|
421
|
+
- **`listen(fetch, { hostname, port, signal })`** (was `listen({ fetch, hypervisor, … })`) serves
|
|
422
|
+
any fetch handler on Node, Bun and Deno through Oxian's Node adapter, sockets included, and
|
|
423
|
+
answers a `Listener` (`url`, `finished`, `shutdown()`). `serve`, `ServeOptions` and `Server` are
|
|
424
|
+
gone.
|
|
425
|
+
- **The page plugin** (`webPage`, `copilotz/web/server`): `/app/*` (the code; the entry `no-cache`,
|
|
426
|
+
chunks kept a year), `/assets/*`, `/manifest.webmanifest`, `/sw.js`, and `/*` for GET navigations
|
|
427
|
+
only (`Sec-Fetch-Mode: navigate`, or an `Accept` with HTML, `*/*` or none): a script's `fetch`
|
|
428
|
+
there is a 404, not the page. Its `/*` takes `GET /health` too, so the runtime's `ok` answers only
|
|
429
|
+
an app without a page (with a page, `/health` was the page before as well). It refuses to start
|
|
430
|
+
without `page.code`. The page tells its code the base (`appBase()`), and its `/connect` and socket
|
|
431
|
+
follow it.
|
|
432
|
+
- **The page in the browser:** `web()` posts to `/web/<name>` first when it arrives as a visitor
|
|
433
|
+
(`arrive: { name, challenge? }`), asks identity's `GET /me` for the person's name while it takes
|
|
434
|
+
its ticket, and finds the ways to sign in by asking `GET /google` and `GET /signin/dev`.
|
|
435
|
+
- **Sign-in and sign-out are plugins' routes:** identity's `POST /signout` (ends the session,
|
|
436
|
+
disconnects whoever it was, clears the cookie) and `GET /me` (401 for anyone but a person), and
|
|
437
|
+
its contract's `signedIn` (sets the session's cookie, `SameSite=Lax` so an OAuth redirect back
|
|
438
|
+
carries it, and answers `{ person }`); Google's `POST /signin/google` (`{ idToken }`) and
|
|
439
|
+
`GET /google` (the first client id, cached five minutes); dev sign-in's `/signin/dev` (GET says
|
|
440
|
+
it's there, POST `{ name }` signs in), from this machine only, as before. Nothing refuses to start
|
|
441
|
+
with a recorded sign-in Action any more (the web host did): keep yours `record: false`, since its
|
|
442
|
+
answer is the session's secret. `credential.revoke` (taking someone out of an org) disconnects
|
|
443
|
+
their browsers and drops what `who` kept for them, so their next request is nobody at once.
|
|
444
|
+
- **Webhooks and other plugins' HTTP are routes; their URLs are unchanged:**
|
|
445
|
+
- WhatsApp: `/hooks/whatsapp/*` does Meta's handshake and checks the signature, then calls
|
|
446
|
+
`whatsapp.receive` with `{ number, payload }`; `whatsapp.number` finds a number by its path.
|
|
447
|
+
Both are the system's (no `allow`); `whatsapp.hook` is gone. `hookRoute` is exported, for a
|
|
448
|
+
number's own path.
|
|
449
|
+
- Voice: `/hooks/voice/<name>` and `/hooks/voice/<name>/over` check Twilio's signature and call
|
|
450
|
+
`voice.ring` and `voice.hangup` (`voice.hook` is gone); `/hooks/voice/<name>/relay` takes the
|
|
451
|
+
call's socket with Oxian's `upgradeWebSocket`.
|
|
452
|
+
- MCP: `/mcp/*`, finding the app's widgets in the `widgets` resource (was
|
|
453
|
+
`webServer({ widgets })`).
|
|
454
|
+
- Maintenance: `/maintenance/*`; an org's runtime (`resources.org`) still never serves it.
|
|
455
|
+
- Chat: `GET /files/<id>` is chat's route (was the web host's), read as whoever the request is, or
|
|
456
|
+
by a link signed for the file.
|
|
457
|
+
- Connected accounts: `GET /accounts/callback/<provider>` calls `account.callback` with
|
|
458
|
+
`{ provider, code, state, error? }` as the session's person, and sends them back to Connected
|
|
459
|
+
accounts.
|
|
460
|
+
- Computers: previews are one route for every host shaped like a preview's
|
|
461
|
+
(`*://*-preview.*:*/*`), answering only for the app's `previews.domain`, with the grant at
|
|
462
|
+
`/__copilotz/previews/grant`; a release's downloads (`computerDownloads({ dir })`) are
|
|
463
|
+
`/computer/download/*`.
|
|
464
|
+
- Stripe: `stripeWebhook` is a plugin (was a function the app routed to by hand),
|
|
465
|
+
`POST /__stripe/<seller>`: it checks the signature on the raw text, reads the event as facts
|
|
466
|
+
(`stripe.fact`, asking Stripe for a dispute's charge through `ctx.fetch`), and hands them to the
|
|
467
|
+
org's runtime as `billing.apply` under the event's id. Which runtime is the org's: the `stripe`
|
|
468
|
+
resource's `orgs` (the directory's pool), or without them this runtime, when the event is for
|
|
469
|
+
its org. The plan an org goes back to is the `billing` resource's `start` ("free" unless said),
|
|
470
|
+
not a `start` option. What can be tried again answers 500; what never can, 200.
|
|
471
|
+
- The cloud pool: its VMs' socket (`/__pool/oxian`) is `cloudPool`'s route, answered by its
|
|
472
|
+
runtime's own socket.
|
|
473
|
+
- **The site chat:** `POST /web/<name>` limits newcomers by address, runs the site's challenge,
|
|
474
|
+
calls `contact.arrive` and sets the visitor cookie (`SameSite=Strict`); the site chat's `who`
|
|
475
|
+
reads it. `contact_visitor.actor` now answers a visitor that hasn't spoken yet too.
|
|
476
|
+
- **`ctx.fetch`** (`Context.fetch`, `ReadContext.fetch`): what plugin code calls outside services
|
|
477
|
+
with, in Actions, Processors and queries, remote executors included; the platform's `fetch` unless
|
|
478
|
+
`createRuntime({ fetch })` gives another. Adapters stay for real ports (model providers).
|
|
479
|
+
- **The REST API is the runtime's own** (`/api/`, answered by `runtime.fetch` for whoever `who`
|
|
480
|
+
says): collections (`GET /api/collections/<name>?filter=…`, `…/<id>`; `POST`, `PATCH`, `PUT`,
|
|
481
|
+
`DELETE`), Actions by the caller's own call id (`Idempotency-Key`), queries (`GET ?params=` or
|
|
482
|
+
`POST`), Views, emits (`POST /api/events/<type>`), the events stream, and the reference
|
|
483
|
+
(`GET /api/`); any GET with `Accept: text/event-stream` is a watch. A credential that proves
|
|
484
|
+
nobody is a 401, and so is a refusal to anonymous. Any origin may call it with a key; with a
|
|
485
|
+
session's cookie, only the app's own page. Streams end at once when their actor is disconnected,
|
|
486
|
+
and at each ping (every 20 s, on the runtime's clock) when `who` says someone else. The api
|
|
487
|
+
plugin's `serveApi`, `Served`, its own HTTP, events and reference, and its `api_key.see` and
|
|
488
|
+
`api_key.get` queries are gone; the reference says `actor` (no `key` record).
|
|
489
|
+
- **Direct writes from outside** (REST, and the socket's new `core.write`): only where a rule speaks
|
|
490
|
+
for the collection's writes (`Guard`'s operation gains `direct`), never `sys.*`, never a private
|
|
491
|
+
field (nor a filter, sort or update that names one, over the socket too; a replacement keeps
|
|
492
|
+
them), within the caller's reach, schema-checked, and recorded as the caller's events.
|
|
493
|
+
**Breaking:** plugins' records change through their Actions: their rules refuse direct writes for
|
|
494
|
+
spaces, memberships, invitations and requests; identity's people and sessions; keys; contacts;
|
|
495
|
+
chat's messages, `live`, threads, files and what was shown (`shown`); memories; skills and their
|
|
496
|
+
files; routines and their runs; the computers plugin's records; apps; cloud computers; agents;
|
|
497
|
+
accounts; WhatsApp's phones and numbers; and voice blocks. Still writable directly, each under its
|
|
498
|
+
rule: apps' own collections (an app guards its own the same way when its rules assume its
|
|
499
|
+
Actions). Following events or watching a read holds a request open: an anonymous caller gets 401.
|
|
500
|
+
The events stream follows the rules: a change is sent when the reader's rule matches the event's
|
|
501
|
+
document.
|
|
502
|
+
- **Identity: only a session proves someone.** `credential.actor` asks for `kind: "session"`: a key
|
|
503
|
+
identity made before (`kind: "key"`, unscoped) proves nobody.
|
|
504
|
+
- **The client** (`connect`, from `copilotz` and `copilotz/web`): `client.db.collection(name)`
|
|
505
|
+
(`find` with `.toArray()`, `findOne`, `countDocuments`, `insertOne`, `updateOne`, `replaceOne`,
|
|
506
|
+
`deleteOne`, `query`, `watch(filter, options?, onChange)`), `client.call(action, input, { id })`,
|
|
507
|
+
and `connect(url, { key, over: "socket" | "http", plugins?, fetch? })` for scripts, beside the
|
|
508
|
+
page's `connect({ transport, ticket, plugins })`. The socket gains a call's own id.
|
|
509
|
+
- **Developer keys** are members of their space, with a scope. A key's actor is
|
|
510
|
+
`{ kind: "person", id, key, scope }` (`within` is gone): `people` still lets it in and `inPerson`
|
|
511
|
+
keeps it out. It's a member of its space (`key:<id>`), an editor when its scope calls or writes,
|
|
512
|
+
else a viewer, never more than its person may be there, and reaches what both its membership and
|
|
513
|
+
its person reach, with no org role (an admin's key reaches only its space). Its `scope` (exact
|
|
514
|
+
names, no wildcards) is checked by the runtime (`inScope`) only where a call from outside comes
|
|
515
|
+
in: calls, queries, Views rendered for it, direct reads and writes; a scoped actor emits nothing.
|
|
516
|
+
Never inside a job: an Action it may call writes as usual. `api_key` records keep `scope` and
|
|
517
|
+
`role`; their id is the start of the secret's hash (`hash` is private); they live in their space
|
|
518
|
+
(`shared`), where its members see them in the Members tab and its managers revoke them.
|
|
519
|
+
`api_key.actor` answers the actor; `api_key.revoke` (its person, or a manager) ends the key, its
|
|
520
|
+
membership and its connections, and so does its person leaving the space or the org;
|
|
521
|
+
`ctx.disconnect` of a key ends only its own. Spaces add `spaceMembers` (a section of the Members
|
|
522
|
+
tab). A key's default space is gone: the runtime knows no spaces, and REST and the socket must
|
|
523
|
+
behave the same.
|
|
524
|
+
- **Identity makes no keys:** `key.create`, `key.revoke` and `credential.keys` are gone, and a
|
|
525
|
+
credential is a session. People and sessions change only through identity's Actions.
|
|
526
|
+
- **Many orgs, by forwarding** (see design/tenancy.md): the directory's routes forward `/o/<org>/…`
|
|
527
|
+
to that org (404 for none, 403 when suspended), `/*` to the org the browser is in (a page asked
|
|
528
|
+
for without a session there goes in first, to the org they were in, else their last, else their
|
|
529
|
+
own, made now, then 302s back), and a host an org claimed to that org's host routes; anything else
|
|
530
|
+
for someone signed in nowhere is the lobby's (without one, a 401). Entering an org (`POST /orgs`,
|
|
531
|
+
`/orgs/enter`, `/orgs/invites/answer`, and a page's way in) is `org.enter`, then a signed handoff,
|
|
532
|
+
a minute long and never out of the process, to the org's own `POST /enter`, which keeps who they
|
|
533
|
+
are, joins them the first time, starts its session and sets its cookie (`s_<org>`). The
|
|
534
|
+
directory's own: `GET /orgs`, `POST /signout` out of every org it holds a session for (each ended
|
|
535
|
+
where its org is open; signing out never opens one), staff's `/console/orgs…` and
|
|
536
|
+
`/console/codes…`, and the front's `/__copilotz/hosts/resolve` on any host. `directory.member`
|
|
537
|
+
gives each org's runtime `resources.org` (id, name, kind, address), `page.base`, its cookies'
|
|
538
|
+
names (`{ names: { session: "s_<org>" }, suffix: "_<org>" }`), the app's own hosts, the
|
|
539
|
+
directory's hooks (invitations, leaving, renaming, claiming and releasing hosts, gift codes) and
|
|
540
|
+
its `/enter`. The directory's session is still `__Host-dir` (the directory plugin's `cookies`
|
|
541
|
+
resource), and which org a browser is in, `__Host-org`. `org.info` (a query, in place of the
|
|
542
|
+
`org.get` Action) is kept 10 seconds, hosts' claims a minute, each forgotten at once when the
|
|
543
|
+
directory changes it. The orgs host's tests are ported (`plugins/access/tests/orgs*.test.ts`).
|
|
544
|
+
- **Removed entry points and exports:** `copilotz/web/tickets` (`createTickets`) and `copilotz/orgs`
|
|
545
|
+
(`orgsHost`). From `copilotz/web/server`: `webServer`, `WebServerOptions`, `socket`, `Entrance`,
|
|
546
|
+
`SignIn`, `Arrived`, `Door`, `Whom`, `whomOf`, `cookieOf`, `hostCookie`, `setCookie`, `siteOf`,
|
|
547
|
+
`ANONYMOUS` (write `{ kind: "anonymous", id: "" }`), `Front`, `hostOf`, `HttpRequest`,
|
|
548
|
+
`HttpAnswer`, `httpRequest`, `Route` (now the runtime's, a function), `RouteSocket` and `Served`;
|
|
549
|
+
`clientAddress`, `setClientAddress` and `hostMatches` moved to `copilotz`. From `copilotz/web`:
|
|
550
|
+
the orgs' browser half (now `copilotz/plugins/access/web`). From `copilotz/web/node`: `serve`,
|
|
551
|
+
`ServeOptions` and `Server`. From `copilotz/plugins/interfaces`: `serveApi`, `WebLine` and the
|
|
552
|
+
other `*Line` types. The `entrances`, `signIn` and `routes` resources; `createRuntime`'s `admit`;
|
|
553
|
+
the actor's `within`; `whatsapp.hook` and `voice.hook`.
|
|
554
|
+
|
|
555
|
+
- **Oxian 0.23.5:** the Node adapter keeps an error listener on each request and response for their
|
|
556
|
+
whole life, so a client leaving mid-response (a server-sent stream it stops) never reaches the
|
|
557
|
+
process as an unhandled error (it did under Bun).
|
|
558
|
+
|
|
3
559
|
## 1.0.0-rc.24 — 2026-11-06
|
|
4
560
|
|
|
5
561
|
**Upgrading from rc.23** (two breaking renames; no aliases, no data moves):
|