copilotz 1.0.0-rc.25 → 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 +18 -0
- package/README.md +3 -3
- package/package.json +1 -1
- package/plugins/access/directory/mod.d.ts +2 -2
- package/plugins/access/directory/mod.js +3 -3
- package/plugins/access/directory/routes/forward.d.ts +1 -1
- package/plugins/access/directory/routes/forward.js +1 -1
- package/plugins/access/directory/shared/member.js +1 -1
- 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 +1 -1
- package/runtime/fetch.d.ts +1 -1
- package/runtime/site.d.ts +7 -5
- package/runtime/site.js +20 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
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
|
+
|
|
3
21
|
## 1.0.0-rc.25 — 2026-11-06
|
|
4
22
|
|
|
5
23
|
**Upgrading from rc.24.** The runtime now answers HTTP itself. `runtime.fetch(request)` is a fetch
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ bun add copilotz # Bun
|
|
|
22
22
|
deno add jsr:@copilotz/copilotz # Deno (or `deno add npm:copilotz`)
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
25
|
+
On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.26"`),
|
|
26
26
|
and the imports below are the same everywhere. Some pieces need a package of their own, installed
|
|
27
27
|
beside it: `esbuild` to bundle the page's code on Node (`bundle`), `@electric-sql/pglite` for
|
|
28
28
|
PostgreSQL in the process, and `@types/react` for the front ends' types.
|
|
@@ -353,7 +353,7 @@ const server = await listen(dir.fetch, { port: 8080 }); // or Deno.serve(dir.fet
|
|
|
353
353
|
Each org's runtime gets from `directory.member` which org it is (`resources.org`), where it's served
|
|
354
354
|
(`page.base`: `/o/<org>`), its cookies' names (`s_<org>` for its session, `<name>_<org>` for the
|
|
355
355
|
rest), and the directory's hooks (invitations, leaving, renaming). Name the app's own hosts
|
|
356
|
-
(`hosts: {
|
|
356
|
+
(`hosts: { "app.example.com": true }`) and any other host is an org's claimed one, answered by its
|
|
357
357
|
host routes alone. Whatever has one address for every org lives in the directory's runtime: Stripe's
|
|
358
358
|
webhook (`stripeWebhook`, with the `stripe` resource's `orgs`), the cloud pool's socket. The whole
|
|
359
359
|
example is `examples/web-node/orgs.ts` (in memory), and `examples/terminal-agent/orgs.ts` on Deno
|
|
@@ -531,7 +531,7 @@ and an app serves it from there by default:
|
|
|
531
531
|
import { computerDownloads } from "copilotz/plugins/compute/downloads";
|
|
532
532
|
|
|
533
533
|
plugins: [...plugins, await computerDownloads()], // this Copilotz's release
|
|
534
|
-
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.
|
|
534
|
+
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.26" })], // its own: /computer/download/
|
|
535
535
|
plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
|
|
536
536
|
```
|
|
537
537
|
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* - anything else: the org the browser is in (its `org` cookie), going in
|
|
20
20
|
* first when a page needs it to; for someone signed in nowhere, the
|
|
21
21
|
* lobby (`directory.lobby`: the sign-in page);
|
|
22
|
-
* - a host an org claimed (with the app's own named, `hosts
|
|
22
|
+
* - a host an org claimed (with the app's own named, `hosts`): that
|
|
23
23
|
* org's routes by host alone; `GET /__copilotz/hosts/resolve` says whose
|
|
24
24
|
* a host is, for the app's front.
|
|
25
25
|
*
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* const dir = await createRuntime({ store, plugins: [identity, googleSignIn, directory,
|
|
37
37
|
* definePlugin({ name: "d", resources: {
|
|
38
38
|
* directory: { staff: ["you@example.com"], orgs, lobby },
|
|
39
|
-
* hosts: {
|
|
39
|
+
* hosts: { "app.example.com": true },
|
|
40
40
|
* } })] });
|
|
41
41
|
* const orgs = runtimes(async (id) => {
|
|
42
42
|
* const org = await dir.query("org.info", { org: id });
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* - anything else: the org the browser is in (its `org` cookie), going in
|
|
20
20
|
* first when a page needs it to; for someone signed in nowhere, the
|
|
21
21
|
* lobby (`directory.lobby`: the sign-in page);
|
|
22
|
-
* - a host an org claimed (with the app's own named, `hosts
|
|
22
|
+
* - a host an org claimed (with the app's own named, `hosts`): that
|
|
23
23
|
* org's routes by host alone; `GET /__copilotz/hosts/resolve` says whose
|
|
24
24
|
* a host is, for the app's front.
|
|
25
25
|
*
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* const dir = await createRuntime({ store, plugins: [identity, googleSignIn, directory,
|
|
37
37
|
* definePlugin({ name: "d", resources: {
|
|
38
38
|
* directory: { staff: ["you@example.com"], orgs, lobby },
|
|
39
|
-
* hosts: {
|
|
39
|
+
* hosts: { "app.example.com": true },
|
|
40
40
|
* } })] });
|
|
41
41
|
* const orgs = runtimes(async (id) => {
|
|
42
42
|
* const org = await dir.query("org.info", { org: id });
|
|
@@ -104,7 +104,7 @@ const plugin = definePlugin({
|
|
|
104
104
|
"/o/:org": addressedRoute,
|
|
105
105
|
"/o/:org/*": addressedRoute,
|
|
106
106
|
"/*": currentRoute,
|
|
107
|
-
// Every host but the app's own (`hosts
|
|
107
|
+
// Every host but the app's own (`hosts`): those orgs claimed.
|
|
108
108
|
"*://*:*/*": claimedRoute,
|
|
109
109
|
},
|
|
110
110
|
// Its session is identity's, in today's cookie: `dir` (`__Host-dir` wherever it's Secure).
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* (302). Anything else with no org is the lobby's (the sign-in page, the
|
|
17
17
|
* app's settings), as is everything for someone signed in nowhere.
|
|
18
18
|
* - **Hosts orgs claimed** (`*` for every host but the app's own, which the
|
|
19
|
-
* app names: `resources.hosts
|
|
19
|
+
* app names: `resources.hosts`): the org that claimed it, for its
|
|
20
20
|
* routes by host alone (its runtime has the app's hosts too); a host
|
|
21
21
|
* nobody claimed, a 404.
|
|
22
22
|
* - `GET /__copilotz/hosts/resolve?host=<h>`: whose a host is, `{ org,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* (302). Anything else with no org is the lobby's (the sign-in page, the
|
|
17
17
|
* app's settings), as is everything for someone signed in nowhere.
|
|
18
18
|
* - **Hosts orgs claimed** (`*` for every host but the app's own, which the
|
|
19
|
-
* app names: `resources.hosts
|
|
19
|
+
* app names: `resources.hosts`): the org that claimed it, for its
|
|
20
20
|
* routes by host alone (its runtime has the app's hosts too); a host
|
|
21
21
|
* nobody claimed, a 404.
|
|
22
22
|
* - `GET /__copilotz/hosts/resolve?host=<h>`: whose a host is, `{ org,
|
|
@@ -34,7 +34,7 @@ export function member(dir, org) {
|
|
|
34
34
|
org: { id: org.id, name: org.name, kind: org.kind, base },
|
|
35
35
|
page: { base },
|
|
36
36
|
cookies: { names: { session: sessionOf(org.id) }, suffix: `_${org.id}` },
|
|
37
|
-
...(hosts
|
|
37
|
+
...(hosts ? { hosts } : {}),
|
|
38
38
|
directory: {
|
|
39
39
|
invite: (invite) => ask("invite.send", invite).then(() => { }),
|
|
40
40
|
invites: () => ask("invite.org").then((r) => r.invites),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The computer program's version, as `computer.info` and `--version` say it, and its builds are named. */
|
|
2
|
-
export declare const VERSION = "1.0.0-rc.
|
|
2
|
+
export declare const VERSION = "1.0.0-rc.26";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The computer program's version, as `computer.info` and `--version` say it, and its builds are named. */
|
|
2
|
-
export const VERSION = "1.0.0-rc.
|
|
2
|
+
export const VERSION = "1.0.0-rc.26";
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
16
|
* plugins: [...plugins, await computerDownloads()]
|
|
17
|
-
* plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.
|
|
17
|
+
* plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.26" })]
|
|
18
18
|
* plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })]
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
package/runtime/fetch.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* site.ts), and under the app's base (`resources.page.base`: `/o/<org>/x`
|
|
13
13
|
* is `/x`). Routes are given the request as that.
|
|
14
14
|
* - **Routes with a host** (a preview's): every request to a host they take.
|
|
15
|
-
* With the app's own hosts named (`resources.hosts
|
|
15
|
+
* With the app's own hosts named (`resources.hosts`, see site.ts), a
|
|
16
16
|
* request to any other host is theirs alone (a 404 when none takes it),
|
|
17
17
|
* and the app's own hosts are never theirs.
|
|
18
18
|
* - **The socket** (`/oxian`, and `<base>/oxian`): Oxian's worker protocol,
|
package/runtime/site.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export declare const vouched: (request: Request, secret: string | undefined) =>
|
|
|
8
8
|
* is for a public host, though it reaches the app at a private address.
|
|
9
9
|
*/
|
|
10
10
|
export declare function siteOf(request: Request, secret: string | undefined): URL;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The `hosts` resource: the app's own hosts, an entry each (a pattern, see
|
|
13
|
+
* `hostMatches`): `{ "app.example.com": true, "*.run.app": true }`. A later
|
|
14
|
+
* plugin adds one, or takes one away with `null`, as with any resource.
|
|
15
|
+
*/
|
|
16
|
+
export type HostsSettings = Record<string, true>;
|
|
15
17
|
/** What's wrong with the app's `hosts` resource, if anything (checked at start). */
|
|
16
|
-
export declare function hostsProblem(
|
|
18
|
+
export declare function hostsProblem(hosts: unknown): string | undefined;
|
|
17
19
|
/**
|
|
18
20
|
* Whether a host matches a pattern: exactly, or `*<suffix>` for any one
|
|
19
21
|
* first label then the suffix (`*.run.app`: `x.run.app`, not `a.b.run.app`).
|
package/runtime/site.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - **The site** (`siteOf`): the address as the browser asked for it, on the
|
|
14
14
|
* host the front says. Routes match it, and cookies are named and secured
|
|
15
15
|
* by it.
|
|
16
|
-
* - **The app's own hosts** (`resources.hosts
|
|
16
|
+
* - **The app's own hosts** (`resources.hosts`, patterns: `app.example.com`,
|
|
17
17
|
* `*.run.app`): when the app names them, a request to any other host is
|
|
18
18
|
* answered only by routes that take its host (a preview's, or `*` for
|
|
19
19
|
* every other host: the hosts a directory's orgs claimed), never by the
|
|
@@ -69,19 +69,24 @@ export function siteOf(request, secret) {
|
|
|
69
69
|
}
|
|
70
70
|
/** A host pattern: a host (and maybe a port), or `*` then the rest of one (`*.run.app`). */
|
|
71
71
|
const HOST = /^\*?[a-z0-9.-]+(:\d{1,5})?$/;
|
|
72
|
+
const HOSTS_EXAMPLE = '{ "app.example.com": true, "*.run.app": true }';
|
|
72
73
|
/** What's wrong with the app's `hosts` resource, if anything (checked at start). */
|
|
73
|
-
export function hostsProblem(
|
|
74
|
-
if (
|
|
74
|
+
export function hostsProblem(hosts) {
|
|
75
|
+
if (hosts === undefined)
|
|
75
76
|
return undefined;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
if (typeof hosts !== "object" || hosts === null || Array.isArray(hosts) ||
|
|
78
|
+
!Object.keys(hosts).length) {
|
|
79
|
+
return `hosts names the app's own hosts, an entry each: ${HOSTS_EXAMPLE}`;
|
|
80
|
+
}
|
|
81
|
+
for (const [pattern, own] of Object.entries(hosts)) {
|
|
82
|
+
if (own !== true) {
|
|
83
|
+
return `hosts: "${pattern}" is true, one of the app's own hosts (not ${JSON.stringify(own)}): ${HOSTS_EXAMPLE}`;
|
|
84
|
+
}
|
|
85
|
+
if (!HOST.test(pattern)) {
|
|
86
|
+
return `hosts: "${pattern}" isn't a host (app.example.com), nor * and the rest of one (*.run.app)`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
85
90
|
}
|
|
86
91
|
/**
|
|
87
92
|
* Whether a host matches a pattern: exactly, or `*<suffix>` for any one
|
|
@@ -103,8 +108,9 @@ export function hostMatches(pattern, host) {
|
|
|
103
108
|
* undefined when it names none (every host is then the app's).
|
|
104
109
|
*/
|
|
105
110
|
export function ownHost(hosts, host) {
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
if (!hosts || typeof hosts !== "object")
|
|
112
|
+
return undefined;
|
|
113
|
+
return Object.keys(hosts).some((pattern) => hostMatches(pattern, host));
|
|
108
114
|
}
|
|
109
115
|
/** Whether a host name is this machine's own: `localhost`, 127.0.0.0/8, `::1`. */
|
|
110
116
|
export const loopback = (hostname) => hostname.toLowerCase() === "localhost" || loopbackAddress(hostname);
|