copilotz 1.0.0-rc.23 → 1.0.0-rc.24

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 (108) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +26 -20
  3. package/hosts/terminal/contract.d.ts +1 -1
  4. package/hosts/terminal/host.js +1 -1
  5. package/hosts/web/host.js +1 -1
  6. package/hosts/web/lazy.js +1 -1
  7. package/hosts/web/palette/sources.js +1 -1
  8. package/hosts/web/routes.d.ts +3 -3
  9. package/hosts/web/routes.js +4 -4
  10. package/hosts/web/server.d.ts +2 -2
  11. package/hosts/web/server.js +1 -1
  12. package/hosts/web/widget.js +1 -1
  13. package/hosts/web/widgets.js +1 -1
  14. package/package.json +2 -2
  15. package/plugins/access/accounts/actions/callback.js +1 -1
  16. package/plugins/access/accounts/web.js +3 -3
  17. package/plugins/access/contacts/mod.js +1 -1
  18. package/plugins/access/contacts/views/contact.js +1 -1
  19. package/plugins/access/spaces/mod.js +2 -2
  20. package/plugins/access/spaces/resources/commands.js +1 -1
  21. package/plugins/access/spaces/terminal.js +1 -1
  22. package/plugins/access/spaces/web.js +14 -14
  23. package/plugins/agents/chat/actions/say.js +1 -1
  24. package/plugins/agents/chat/collections/shown.d.ts +1 -1
  25. package/plugins/agents/chat/collections/shown.js +1 -1
  26. package/plugins/agents/chat/collections/thread.js +1 -1
  27. package/plugins/agents/chat/mod.d.ts +2 -2
  28. package/plugins/agents/chat/mod.js +7 -7
  29. package/plugins/agents/chat/processors/turn.js +1 -1
  30. package/plugins/agents/chat/resources/commands.js +4 -1
  31. package/plugins/agents/chat/shared/tools.js +1 -1
  32. package/plugins/agents/chat/shared/types.d.ts +5 -5
  33. package/plugins/agents/chat/terminal.js +6 -6
  34. package/plugins/agents/chat/views/history.js +1 -1
  35. package/plugins/agents/chat/views/terminal/conversation.js +2 -2
  36. package/plugins/agents/chat/views/web/conversation.js +2 -2
  37. package/plugins/agents/chat/web.js +9 -9
  38. package/plugins/agents/history/mod.js +3 -3
  39. package/plugins/agents/history/resources/tools.js +1 -1
  40. package/plugins/agents/history/shared/weight.js +1 -1
  41. package/plugins/agents/history/views/history.js +1 -1
  42. package/plugins/agents/memory/mod.js +1 -1
  43. package/plugins/agents/memory/resources/commands.js +1 -1
  44. package/plugins/agents/memory/terminal.js +1 -1
  45. package/plugins/agents/memory/views/context.d.ts +3 -9
  46. package/plugins/agents/memory/views/context.js +41 -47
  47. package/plugins/agents/memory/web.js +3 -3
  48. package/plugins/agents/routines/web.js +5 -5
  49. package/plugins/agents/skills/mod.js +1 -1
  50. package/plugins/agents/skills/web.js +5 -5
  51. package/plugins/agents/team/web.js +4 -4
  52. package/plugins/agents/tiers/web.js +3 -3
  53. package/plugins/billing/credits/web.js +2 -2
  54. package/plugins/billing/usage/terminal.js +1 -1
  55. package/plugins/billing/usage/web.js +1 -1
  56. package/plugins/compute/apps/web.js +3 -3
  57. package/plugins/compute/cloud/web.js +2 -2
  58. package/plugins/compute/computers/program/version.d.ts +1 -1
  59. package/plugins/compute/computers/program/version.js +1 -1
  60. package/plugins/compute/computers/resources/downloads.js +1 -1
  61. package/plugins/compute/computers/terminal.js +1 -1
  62. package/plugins/compute/computers/views/context.d.ts +1 -3
  63. package/plugins/compute/computers/views/context.js +75 -77
  64. package/plugins/compute/computers/web.js +8 -8
  65. package/plugins/interfaces/api/shared/server.d.ts +2 -2
  66. package/plugins/interfaces/api/shared/server.js +2 -3
  67. package/plugins/interfaces/api/web.js +1 -1
  68. package/plugins/interfaces/mcp/actions/call.js +2 -2
  69. package/plugins/interfaces/mcp/mod.d.ts +1 -1
  70. package/plugins/interfaces/mcp/mod.js +2 -2
  71. package/plugins/interfaces/mcp/resources/tools.js +3 -3
  72. package/plugins/interfaces/mcp/views/offered.d.ts +1 -2
  73. package/plugins/interfaces/terminal/terminal.js +3 -3
  74. package/plugins/interfaces/terminal/views/shell.js +8 -3
  75. package/plugins/interfaces/voice/contract.d.ts +1 -1
  76. package/plugins/interfaces/voice/mod.d.ts +2 -2
  77. package/plugins/interfaces/voice/mod.js +6 -6
  78. package/plugins/interfaces/voice/resources/relay.js +1 -1
  79. package/plugins/interfaces/voice/views/call.d.ts +2 -2
  80. package/plugins/interfaces/voice/views/call.js +1 -1
  81. package/plugins/interfaces/voice/views/message.d.ts +2 -2
  82. package/plugins/interfaces/web/mod.d.ts +1 -1
  83. package/plugins/interfaces/web/mod.js +5 -5
  84. package/plugins/interfaces/web/views/default.d.ts +2 -2
  85. package/plugins/interfaces/web/views/default.js +3 -2
  86. package/plugins/interfaces/web/views/shell.js +6 -1
  87. package/plugins/interfaces/whatsapp/contract.d.ts +1 -1
  88. package/plugins/interfaces/whatsapp/contract.js +1 -1
  89. package/plugins/interfaces/whatsapp/mod.d.ts +2 -2
  90. package/plugins/interfaces/whatsapp/mod.js +4 -4
  91. package/plugins/interfaces/whatsapp/processors/reply.d.ts +1 -1
  92. package/plugins/interfaces/whatsapp/processors/reply.js +3 -3
  93. package/plugins/interfaces/whatsapp/shared/parts.js +1 -1
  94. package/plugins/interfaces/whatsapp/views/message.d.ts +2 -2
  95. package/plugins/interfaces/whatsapp/web.js +2 -2
  96. package/runtime/actor.d.ts +24 -7
  97. package/runtime/browsers.d.ts +0 -1
  98. package/runtime/browsers.js +1 -2
  99. package/runtime/define.d.ts +17 -18
  100. package/runtime/executor.js +1 -1
  101. package/runtime/observe.d.ts +2 -2
  102. package/runtime/observe.js +22 -22
  103. package/runtime/owner.d.ts +6 -7
  104. package/runtime/owner.js +7 -8
  105. package/runtime/registry.js +1 -3
  106. package/runtime/views.d.ts +1 -3
  107. package/runtime/views.js +7 -10
  108. package/runtime/wire.d.ts +1 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.0.0-rc.24 — 2026-11-06
4
+
5
+ **Upgrading from rc.23** (two breaking renames; no aliases, no data moves):
6
+
7
+ 1. **Views are found by name alone; the medium is gone.** Flatten `views`:
8
+ `{ "booking.panel": { web: BookingPanel } }` becomes `{ "booking.panel": BookingPanel }` (`Views`
9
+ is `Record<string, View>`). `render(medium, name, item, options)` and
10
+ `observe(medium, name, item, options)` lose their first argument:
11
+ `ctx.render("llm", "thread", t)` is `ctx.render("llm.thread", t)`,
12
+ `client.observe("web", "booking.panel", item)` is `client.observe("booking.panel", item)`.
13
+ `ViewContext` loses `medium`, and its `kind` is now `name`. `ctx.show(name, item)` shows exactly
14
+ the View it names: there is no inheritance by place. The `"*"` fallback is gone; the hosts ask
15
+ for their own default (`web.default`, `terminal.default`) when a name has no View.
16
+ `runtime.describe().views` is the list of names. `GET /api/views/<name>` takes the name
17
+ (`llm.thread`) and no longer reads `?medium=`; API keys that list a View by `thread` or `message`
18
+ list `llm.thread` or `llm.message`. An MCP widget's `_meta` names the View without a medium.
19
+ Where the same thing is shown in several places the name takes the place as a prefix; seven kinds
20
+ were renamed:
21
+ | Was | Is |
22
+ | ------------------------- | ------------------------------------------------------------------------------------------- |
23
+ | `message` | `llm.message`, `web.message`, `terminal.message`, `whatsapp.message`, `voice.message` |
24
+ | `thread` | `llm.thread`, `web.thread`, `terminal.thread` |
25
+ | `memory` | `llm.memory`, `terminal.memory` |
26
+ | `live`, `shell`, `spaces` | `web.live`, `web.shell`, `web.spaces`; `terminal.live`, `terminal.shell`, `terminal.spaces` |
27
+ | `*` | `web.default`, `terminal.default` |
28
+
29
+ Every other name stays (`tool:<name>`, `context:<name>`, `addition:<name>`, `mcp:offered`, and
30
+ the rest). The last plugin to register a name still wins, so an app replaces WhatsApp's message
31
+ with its own `whatsapp.message`. A page's address still names its View as before
32
+ (`/thread/<id>`): the web shell looks for that name, then `web.<name>`, then `web.default` (hint
33
+ `of` names the address's kind); the terminal's `open` does the same with `terminal.`.
34
+ 2. **The anonymous actor is `anonymous`, not `visitor`:** a request nobody is signed in to is
35
+ `{ kind: "anonymous", id: "" }` (`VISITOR` is `ANONYMOUS` in `copilotz/web/server`). Rules that
36
+ named `visitor` name `anonymous` (identity's `callback` allows `person` or `anonymous`). The
37
+ `visitor` entrance and its cookie keep their names. `runtime/actor.ts` now lists all six kinds
38
+ (person, agent, contact, system, maintenance, anonymous); `routine` is an origin and `space` a
39
+ kind of member, not actors.
40
+
41
+ - **Oxian 0.23.4:** its adapters await an asynchronous `prepare`, so a front serving several
42
+ runtimes behind one listener can open the right one before deciding a socket upgrade.
43
+
3
44
  ## 1.0.0-rc.23 — 2026-11-05
4
45
 
5
46
  **Upgrading from rc.22** (three renames and one host change; nothing else needs doing):
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.23"`),
25
+ On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.24"`),
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 web host on Node, `@electric-sql/pglite` for PostgreSQL in the
28
28
  process, and `@types/react` for the front ends' types.
@@ -74,8 +74,9 @@ The runtime knows only these, and plugins are made of them:
74
74
  id, and everything it causes is its caller's.
75
75
  - **Processors:** what happens when events happen: ordered per key, at least once, from a durable
76
76
  cursor, idempotent by deterministic ids.
77
- - **Views:** a plugin's front end, per medium: text for `llm` (the agents' prompt is a View), Ink
78
- elements for `terminal`, React for `web`. Observed Views run again when what they read changes.
77
+ - **Views:** a plugin's front end, found by name: text for the model (`llm.thread`, the agents'
78
+ prompt, is a View), Ink elements for the terminal, React for the web. Observed Views run again
79
+ when what they read changes.
79
80
  - **Resources:** configuration as named plain objects, by kind (`agents`, `tools`, `provider`,
80
81
  `theme`…): a later plugin patches an earlier one's (JSON Merge Patch), so an app changes one
81
82
  agent's `effort` without redefining it.
@@ -288,8 +289,9 @@ await web({ root, plugins: [siteShell, chatWeb], arrive: { line: "site" } });
288
289
  An app people use on WhatsApp or on the phone needs no page: `serve` without `code` (or `tickets`)
289
290
  serves its plugins' routes alone (`routes` resources: Meta's webhook, Twilio's), `GET /health` for
290
291
  whatever watches it, and 404 for anything else, whatever else its plugins declare. Nobody signs in
291
- there: a route's Action is called as a visitor, and its `allow` decides (a webhook checks the
292
- request's signature, then acts for the person it's from with `ctx.as`). Deno and Bun run it too.
292
+ there: a route's Action is called as anonymous (`{ kind: "anonymous", id: "" }`), and its `allow`
293
+ decides (a webhook checks the request's signature, then acts for the person it's from with
294
+ `ctx.as`). Deno and Bun run it too.
293
295
 
294
296
  ```ts
295
297
  import { createRuntime } from "copilotz";
@@ -335,7 +337,7 @@ and an app serves it from there by default:
335
337
  import { computerDownloads } from "copilotz/plugins/compute/downloads";
336
338
 
337
339
  plugins: [...plugins, await computerDownloads()], // this Copilotz's release
338
- plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.23" })], // its own: /computer/download/
340
+ plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.24" })], // its own: /computer/download/
339
341
  plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
340
342
  ```
341
343
 
@@ -475,7 +477,7 @@ name, never by importing its code.
475
477
  come with it. `chat.open` opens an empty chat in a space; `chat.say` has an agent say a fixed
476
478
  message there without a turn (trusted code only: a payment confirmed), which goes out like any
477
479
  of its answers.
478
- - **After an answer:** a medium that can (WhatsApp) shows features' additions
480
+ - **After an answer:** a place that can (WhatsApp) shows features' additions
479
481
  (`resources.additions.<name> = { order?, agents? }` and an `addition:<name>` View there), each
480
482
  once per chat per key, recorded in `shown`; the model is told what went (`[then shown: …]`). A
481
483
  message tapped from a button carries `tap: { id, title, key }`, and agents read the id.
@@ -617,9 +619,9 @@ filled by the front ends through resources).
617
619
  server-sent events, as that person, in that space only.
618
620
  - **`whatsapp`**: people talk to their agents from WhatsApp, through Meta's Cloud API. A space's
619
621
  managers connect a number; a person links their phone with a code; what they send becomes their
620
- messages, and what agents say to them goes back, a long answer in several messages. It's a medium
621
- for Views (medium `whatsapp`, parts built with its toolkit: text, buttons, a list, a carousel, an
622
- image, a document, each checked against Meta's limits): after an answer, features show more
622
+ messages, and what agents say to them goes back, a long answer in several messages. It has Views
623
+ of its own (`whatsapp.message`, parts built with its toolkit: text, buttons, a list, a carousel,
624
+ an image, a document, each checked against Meta's limits): after an answer, features show more
623
625
  (`additions`: a carousel of trips, buttons to pay), once per chat per key, the answer's text in
624
626
  the same message when there's room, a fallback when Meta refuses one; taps come back with their
625
627
  ids. Pictures and files go as public links, signed links to the app's routes or files (the `links`
@@ -635,7 +637,7 @@ filled by the front ends through resources).
635
637
  signature, a call is taken within its caller's limits and the line's (calls at once, a day: else
636
638
  busy, nothing spent) and opens the line's socket with a one-time ticket. A caller is a contact in
637
639
  a chat of their own, the same one when they call back only if Twilio verified their number; what
638
- the agent writes for them is said as it writes it (a medium for Views: `voice`), a caller speaking
640
+ the agent writes for them is said as it writes it (`voice.message`, a View), a caller speaking
639
641
  over it cuts it there (the agent is told what was heard), a failed or slow answer says a short
640
642
  line in the line's language, and silence, a call too long or too many prompts, or the agent's
641
643
  `end_call` end it. Managers block a caller (`voice.block`). Its socket needs a host that takes a
@@ -1174,12 +1176,16 @@ Copilotz runs on Node (first), Deno and Bun, and is built for Cloudflare Workers
1174
1176
  `ctx.db.collection("message").query("history", params)`. They never write. An actor calling from
1175
1177
  outside runs only those that let them (`{ allow, run }`, as Actions); a bare function is the
1176
1178
  system's.
1177
- - **Views** are each plugin's front end, per medium (see [design/views.md](design/views.md)): text
1178
- for `llm`, Ink elements for `terminal`, React for `web`. A View for kind `"*"` is a medium's
1179
- default for kinds without one. `runtime.render(medium, kind, item)` renders one once (an agent's
1180
- prompt); `runtime.observe(medium, kind, item, { part })` keeps one live: it runs again when a
1181
- commit changes a document it read, and each View it shows (`ctx.show`) is a part that runs again
1182
- on its own. Views call Actions from their handlers (`ctx.call`, `ctx.emit`).
1179
+ - **Views** are each plugin's front end, found by name (see [design/views.md](design/views.md)):
1180
+ `views: { "booking.panel": BookingPanel }`. A name says what the View shows; where the same thing
1181
+ is shown in several places it takes the place as a prefix (`llm.message`, `web.message`,
1182
+ `terminal.message`, `whatsapp.message`, `voice.message`; likewise `thread`, `memory`, `live`,
1183
+ `shell` and `spaces`), and `ctx.show("web.message", m)` shows exactly the View it names. A host
1184
+ asks for its own default (`web.default`, `terminal.default`) when a name has no View.
1185
+ `runtime.render(name, item)` renders one once (an agent's prompt);
1186
+ `runtime.observe(name, item, { part })` keeps one live: it runs again when a commit changes a
1187
+ document it read, and each View it shows (`ctx.show`) is a part that runs again on its own. Views
1188
+ call Actions from their handlers (`ctx.call`, `ctx.emit`).
1183
1189
  - **A feature's front end is its own:** chat, memory and usage each have a `terminal.ts`
1184
1190
  (`chatTerminal`…) with their terminal Views and commands, added only where the terminal draws;
1185
1191
  chat, team, memory, spaces and computers a `web.tsx` (`chatWeb`…), loaded only by the browser. The
@@ -1299,9 +1305,9 @@ examples/ terminal-agent (an app: its plugins and resources, run in the te
1299
1305
  Each layer imports only what it may (`testing/boundaries.test.ts` fails otherwise): the runtime
1300
1306
  nothing outside it; stores, exporters and hosts the runtime; a plugin the runtime, the hosts'
1301
1307
  toolkits (the web's through `hosts/web/mod.ts` only), its own files and other plugins'
1302
- `contract.ts`. A **host** runs the app in a medium and uses the runtime's public API only; a
1303
- **shell** is the medium's root View, a plugin; a feature's **front end** for a medium is its own
1304
- Views and commands there.
1308
+ `contract.ts`. A **host** runs the app in a place (the web, the terminal) and uses the runtime's
1309
+ public API only; a **shell** is that place's root View (`web.shell`, `terminal.shell`), a plugin; a
1310
+ feature's **front end** there is its own Views and commands.
1305
1311
 
1306
1312
  ## Designs
1307
1313
 
@@ -2,7 +2,7 @@
2
2
  * What the terminal's pieces share: where a person is, what commands get,
3
3
  * and the styles text prints in.
4
4
  *
5
- * - **The screen** is the `shell` View (medium `terminal`): what's open,
5
+ * - **The screen** is the `terminal.shell` View: what's open,
6
6
  * what commands printed, and where you type. Terminal Views return Ink
7
7
  * elements (`<Text>`, `<Box>`), or plain text.
8
8
  * - **Scrollback**: what's done (messages, printed output) prints once, in
@@ -133,7 +133,7 @@ async function session(options, { me, actor, space }, { first, interactive, line
133
133
  const state = await runtime.query("shell.mine", { person: me });
134
134
  if (space && !state.space)
135
135
  await runtime.call("shell.set", { person: me, space });
136
- const screen = runtime.observe("terminal", "shell", { person: me }, {
136
+ const screen = runtime.observe("terminal.shell", { person: me }, {
137
137
  ...as,
138
138
  viewer: { name: me, kind: "person" },
139
139
  // What was printed before they sat down is already on the screen.
package/hosts/web/host.js CHANGED
@@ -146,7 +146,7 @@ export async function web(options) {
146
146
  ...(space ? { space } : {}),
147
147
  ...(query ? { query } : {}),
148
148
  };
149
- const shell = client.observe("web", "shell", where, {
149
+ const shell = client.observe("web.shell", where, {
150
150
  viewer,
151
151
  part: (part, key) => _jsx(Part, { part: part }, key),
152
152
  });
package/hosts/web/lazy.js CHANGED
@@ -23,7 +23,7 @@ export function LazyView({ kind, item = {}, hints = {}, fallback = _jsx(Loading,
23
23
  const { client, viewer } = session;
24
24
  if (!client)
25
25
  return;
26
- const next = client.observe("web", kind, item, {
26
+ const next = client.observe(kind, item, {
27
27
  ...(viewer ? { viewer } : {}),
28
28
  hints,
29
29
  part: (part, key) => _jsx(Part, { part: part }, key),
@@ -31,7 +31,7 @@ export function useOutputs(sources) {
31
31
  if (slot.key === key || slot.next?.key === key)
32
32
  return;
33
33
  slot.next?.observation.close();
34
- const observation = client.observe("web", source.kind, source.item ?? {}, {
34
+ const observation = client.observe(source.kind, source.item ?? {}, {
35
35
  ...(viewer ? { viewer } : {}),
36
36
  hints: source.hints ?? {},
37
37
  });
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * - `{ path, action }`: the request becomes a call to that Action (its input
6
6
  * an `HttpRequest`), as whoever the request is (the app's entrances say:
7
- * the person its session signs in, a web line's visitor), or else a
8
- * visitor (`{ kind: "visitor", id: "" }`): the Action's `allow` decides.
7
+ * the person its session signs in, a web line's visitor), or else
8
+ * anonymous (`{ kind: "anonymous", id: "" }`): the Action's `allow` decides.
9
9
  * It answers with an `HttpAnswer`. Webhooks, OAuth callbacks, an API.
10
10
  * - `{ path, serve }`: a function that answers the request itself, here in
11
11
  * the host's process: files as they are (downloads), or an API that must
@@ -145,7 +145,7 @@ export type HttpAnswer = {
145
145
  redirect?: string;
146
146
  };
147
147
  /** Who calls when nobody's signed in. */
148
- export declare const VISITOR: Actor;
148
+ export declare const ANONYMOUS: Actor;
149
149
  /**
150
150
  * A request's body, `most` bytes at most: undefined past it, said by its
151
151
  * `content-length` before anything is read, or found while reading, which
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * - `{ path, action }`: the request becomes a call to that Action (its input
6
6
  * an `HttpRequest`), as whoever the request is (the app's entrances say:
7
- * the person its session signs in, a web line's visitor), or else a
8
- * visitor (`{ kind: "visitor", id: "" }`): the Action's `allow` decides.
7
+ * the person its session signs in, a web line's visitor), or else
8
+ * anonymous (`{ kind: "anonymous", id: "" }`): the Action's `allow` decides.
9
9
  * It answers with an `HttpAnswer`. Webhooks, OAuth callbacks, an API.
10
10
  * - `{ path, serve }`: a function that answers the request itself, here in
11
11
  * the host's process: files as they are (downloads), or an API that must
@@ -94,7 +94,7 @@ export const httpRequest = {
94
94
  additionalProperties: false,
95
95
  };
96
96
  /** Who calls when nobody's signed in. */
97
- export const VISITOR = { kind: "visitor", id: "" };
97
+ export const ANONYMOUS = { kind: "anonymous", id: "" };
98
98
  /** Paths the web host answers itself. */
99
99
  const OWN = ["/app/", "/assets/", "/files/", "/oxian", "/connect", "/signin", "/signout"];
100
100
  /** Bodies larger than this are refused (10 MB): a 413 once that's known, the rest never read. */
@@ -235,7 +235,7 @@ async function answered(runtime, name, route, request, url, served) {
235
235
  const asked = await read(request, url);
236
236
  if (asked instanceof Response)
237
237
  return asked;
238
- const actor = (await served.whom().catch(() => null)) ?? VISITOR;
238
+ const actor = (await served.whom().catch(() => null)) ?? ANONYMOUS;
239
239
  try {
240
240
  return answer(await runtime.call(route.action, asked, { actor }));
241
241
  }
@@ -43,7 +43,7 @@
43
43
  * audio; `?download=1` saves it (see `files.ts`).
44
44
  * - Plugins' own paths, their `routes` resource: a webhook, an OAuth callback,
45
45
  * an API, a download, a socket of their own (see `routes.ts`), called as
46
- * whoever the request is, else a visitor. A request to a host a route takes
46
+ * whoever the request is, else anonymous. A request to a host a route takes
47
47
  * (a preview's) is that route's alone, whatever its path: never the page,
48
48
  * the code or the socket.
49
49
  * - `GET /manifest.webmanifest` and `GET /sw.js`: the app, installable: its
@@ -157,7 +157,7 @@ export type { Asset };
157
157
  export { type SnapshotOptions, type Widgets, widgetsOf, type WidgetsOptions } from "./widgets.js";
158
158
  export { clientAddress, setClientAddress } from "./address.js";
159
159
  export { type Arrived, cookieOf, type Door, type Entrance, hostCookie, setCookie, type SignIn, siteOf, type Whom, whomOf, } from "./entrances.js";
160
- export { type Front, hostMatches, hostOf, type HttpAnswer, type HttpRequest, httpRequest, type Route, type RouteSocket, type Served, VISITOR, } from "./routes.js";
160
+ export { ANONYMOUS, type Front, hostMatches, hostOf, type HttpAnswer, type HttpRequest, httpRequest, type Route, type RouteSocket, type Served, } from "./routes.js";
161
161
  /**
162
162
  * Bundled code: its files by name (`deno bundle --code-splitting --outdir`'s),
163
163
  * the entry and the chunks it imports by relative path, and which one the
@@ -12,7 +12,7 @@ import { pictureOf } from "./theme/picture.js";
12
12
  export { widgetsOf } from "./widgets.js";
13
13
  export { clientAddress, setClientAddress } from "./address.js";
14
14
  export { cookieOf, hostCookie, setCookie, siteOf, whomOf, } from "./entrances.js";
15
- export { hostMatches, hostOf, httpRequest, VISITOR, } from "./routes.js";
15
+ export { ANONYMOUS, hostMatches, hostOf, httpRequest, } from "./routes.js";
16
16
  /** Where the code is served. */
17
17
  const CODE = "/app/";
18
18
  /** How long a session a sign-in starts is kept in its cookie: 30 days. */
@@ -373,7 +373,7 @@ export async function widget(options) {
373
373
  });
374
374
  let shown;
375
375
  const show = () => {
376
- const observed = client.observe("web", meta.view, meta.item, {
376
+ const observed = client.observe(meta.view, meta.item, {
377
377
  viewer: meta.viewer,
378
378
  hints: { ...meta.hints, mode, surface: "widget" },
379
379
  part: (part, key) => _jsx(Part, { part: part }, key),
@@ -93,7 +93,7 @@ ${preloadsOf(theme).map(({ href, type }) => `<link rel="preload" href="${quoted(
93
93
  call: () => Promise.reject(invalid("A snapshot calls nothing")),
94
94
  },
95
95
  });
96
- const seen = client.observe("web", asked.view, asked.item, {
96
+ const seen = client.observe(asked.view, asked.item, {
97
97
  viewer: asked.viewer,
98
98
  hints: asked.hints,
99
99
  part: () => null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilotz",
3
- "version": "1.0.0-rc.23",
3
+ "version": "1.0.0-rc.24",
4
4
  "description": "Copilotz: one runtime for Node, Deno, Bun, Cloudflare Workers and the browser.",
5
5
  "keywords": [
6
6
  "agents",
@@ -188,7 +188,7 @@
188
188
  "ink": "8.0.0",
189
189
  "json-schema-to-ts": "3.1.1",
190
190
  "ominipg": "0.11.2",
191
- "oxianjs": "0.23.3",
191
+ "oxianjs": "0.23.4",
192
192
  "pg": "8.23.1",
193
193
  "temml": "0.14.0"
194
194
  },
@@ -31,7 +31,7 @@ export const callbackAction = defineAction({
31
31
  },
32
32
  required: ["path", "query"],
33
33
  },
34
- allow: (actor) => actor.kind === "person" || actor.kind === "visitor",
34
+ allow: (actor) => actor.kind === "person" || actor.kind === "anonymous",
35
35
  run: async (ctx, input) => {
36
36
  const name = named(input.path.slice(CALLBACK.length).split("/")[0] ?? "");
37
37
  const back = (said) => ({
@@ -23,9 +23,9 @@ export const accountsWeb = definePlugin({
23
23
  name: "accounts-web",
24
24
  requires: ["accounts", "web-shell"],
25
25
  views: {
26
- accounts: { web: accountsView },
27
- "accounts.palette": { web: accountsPaletteView },
28
- "accounts.uses": { web: accountsUsesView },
26
+ accounts: accountsView,
27
+ "accounts.palette": accountsPaletteView,
28
+ "accounts.uses": accountsUsesView,
29
29
  },
30
30
  resources: {
31
31
  palette: { accounts: { view: "accounts.palette", order: 90 } },
@@ -41,7 +41,7 @@ export const contacts = definePlugin({
41
41
  "contact.chat": chatAction,
42
42
  "contact.forget": forgetAction,
43
43
  },
44
- views: { "context:contact": { llm: contactView } },
44
+ views: { "context:contact": contactView },
45
45
  resources: {
46
46
  // A contact's record lives in its line's space; only trusted code changes it. A contact is a
47
47
  // member (of its chats, and of its own record): reading it labels nothing, as for an agent.
@@ -5,7 +5,7 @@
5
5
  * for anyone else's turn. Their name is theirs to choose, so it's data.
6
6
  */
7
7
  import { principalOf } from "../../../../runtime/mod.js";
8
- /** How each medium's contacts talk, as an agent is told it. */
8
+ /** How each kind of contact talks, as an agent is told it. */
9
9
  const FROM = {
10
10
  whatsapp: "writing on WhatsApp",
11
11
  voice: "on a phone call: they hear what you write, read aloud. The number they call from " +
@@ -119,8 +119,8 @@ export const spaces = definePlugin({
119
119
  // Where a conversation is, in agents' prompts (with the chat plugin), and
120
120
  // each turn, where else they can read for their person.
121
121
  views: {
122
- "context:where": { llm: whereView },
123
- "context:elsewhere": { llm: elsewhereView },
122
+ "context:where": whereView,
123
+ "context:elsewhere": elsewhereView,
124
124
  },
125
125
  resources: {
126
126
  context: { where: { place: "system" }, elsewhere: { place: "turn" } },
@@ -22,7 +22,7 @@ export const commands = {
22
22
  if (!spaces.length)
23
23
  return await term.print(dim("No spaces yet; /space <name> makes one."));
24
24
  const { space } = await term.state();
25
- await term.show("spaces", { spaces, ...(space ? { here: space } : {}) });
25
+ await term.show("terminal.spaces", { spaces, ...(space ? { here: space } : {}) });
26
26
  await term.print(dim("/work <n> works in one; new conversations go there."));
27
27
  },
28
28
  }),
@@ -9,6 +9,6 @@ import { spacesView } from "./views/terminal/spaces.js";
9
9
  export const accessTerminal = definePlugin({
10
10
  name: "spaces-terminal",
11
11
  requires: ["spaces", "terminal-shell"],
12
- views: { spaces: { terminal: spacesView } },
12
+ views: { "terminal.spaces": spacesView },
13
13
  resources: { commands },
14
14
  });
@@ -47,26 +47,26 @@ export const spacesWeb = definePlugin({
47
47
  name: "spaces-web",
48
48
  requires: ["spaces", "web-shell"],
49
49
  views: {
50
- spaces: { web: spacesView },
51
- space: { web: spaceView },
52
- "space.panel": { web: spacePanelView },
53
- "space.members": { web: membersView },
54
- "space.settings": { web: settingsView },
55
- "space.invite": { web: invitingView },
56
- "space.pick": { web: spacePickView },
57
- "spaces.palette": { web: spacesPaletteView },
58
- invitations: { web: invitationsView },
59
- "invitations.home": { web: invitedView },
60
- "space.not-here": { web: notHereView },
61
- "org.about": { web: orgAboutView },
62
- "org.members": { web: orgMembersView },
50
+ "web.spaces": spacesView,
51
+ space: spaceView,
52
+ "space.panel": spacePanelView,
53
+ "space.members": membersView,
54
+ "space.settings": settingsView,
55
+ "space.invite": invitingView,
56
+ "space.pick": spacePickView,
57
+ "spaces.palette": spacesPaletteView,
58
+ invitations: invitationsView,
59
+ "invitations.home": invitedView,
60
+ "space.not-here": notHereView,
61
+ "org.about": orgAboutView,
62
+ "org.members": orgMembersView,
63
63
  },
64
64
  resources: {
65
65
  // Where people's names are, for Views here too: a browser loads only front ends.
66
66
  names: { people: { collection: PROFILE } },
67
67
  sidebar: {
68
68
  invitations: { view: "invitations", order: 3 },
69
- spaces: { title: "Spaces", view: "spaces", order: 10 },
69
+ spaces: { title: "Spaces", view: "web.spaces", order: 10 },
70
70
  },
71
71
  spaceTabs: {
72
72
  // Settings: the space itself ("General"), then its sections, in a menu beside them.
@@ -3,7 +3,7 @@
3
3
  * it, no model call and no turn: a fixed message trusted code decides on (a
4
4
  * payment confirmed). It goes to `to` (people by id, contacts as
5
5
  * `contact:<id>`), else to whoever last wrote there who isn't an agent, and
6
- * out through the chat's medium (WhatsApp) like any of its answers. It's
6
+ * out through the chat's place (WhatsApp) like any of its answers. It's
7
7
  * said to people, never to agents, so it starts no turn, by an agent that
8
8
  * answers there. Its `id` comes from what caused it (a payment's): saying it
9
9
  * again in that chat sends nothing (the message is `<thread>:say:<id>`). Only
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * What went out after agents' answers, beyond what they wrote (additions: a
3
3
  * carousel of trips, buttons to pay): each addition once per chat per key
4
- * (`<thread>:<key>`), with the answer it followed, the medium it went by, a
4
+ * (`<thread>:<key>`), with the answer it followed, the place it went by (`medium`), a
5
5
  * line for the model (`note`), and whether its fallback went instead
6
6
  * (`fallback`: Meta refused the carousel, its text list went). A ledger: no
7
7
  * events, and writing one again changes nothing, so a retried delivery
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * What went out after agents' answers, beyond what they wrote (additions: a
3
3
  * carousel of trips, buttons to pay): each addition once per chat per key
4
- * (`<thread>:<key>`), with the answer it followed, the medium it went by, a
4
+ * (`<thread>:<key>`), with the answer it followed, the place it went by (`medium`), a
5
5
  * line for the model (`note`), and whether its fallback went instead
6
6
  * (`fallback`: Meta refused the carousel, its text list went). A ledger: no
7
7
  * events, and writing one again changes nothing, so a retried delivery
@@ -50,7 +50,7 @@ export const thread = defineCollection({
50
50
  run: async (threads, params, ctx) => {
51
51
  const thread = await threads.findOne({ _id: params.thread });
52
52
  return thread
53
- ? await ctx.render("llm", "thread", thread, {
53
+ ? await ctx.render("llm.thread", thread, {
54
54
  viewer: { kind: "agent", name: params.agent },
55
55
  })
56
56
  : null;
@@ -32,7 +32,7 @@
32
32
  * has an agent say a fixed message in one without a turn (`chat.say`: a
33
33
  * payment confirmed), and erases one with everything in it (`chat.erase`:
34
34
  * someone's data, gone).
35
- * - After an agent's answer, a medium may show more (additions: a carousel
35
+ * - After an agent's answer, the place it goes to may show more (additions: a carousel
36
36
  * of trips after the answer that found them), each once per chat per key,
37
37
  * recorded in `shown` (`chat.shown`), and told to the model after that
38
38
  * answer (`[then shown: …]`). A choice tapped comes with its id (`tap`).
@@ -65,7 +65,7 @@
65
65
  * files }` in (each file's name, type and size); it refuses, or answers
66
66
  * `{ thread?, transcribe?: false }` (see actions/send.ts);
67
67
  * - `additions`: { order?, agents? }, each with an `addition:<name>` View in
68
- * the medium that shows it, given `{ thread, answer }` (see `Addition`).
68
+ * the place that shows it, given `{ thread, answer }` (see `Addition`).
69
69
  */
70
70
  import { type Plugin } from "../../../runtime/mod.js";
71
71
  export * from "./contract.js";
@@ -32,7 +32,7 @@
32
32
  * has an agent say a fixed message in one without a turn (`chat.say`: a
33
33
  * payment confirmed), and erases one with everything in it (`chat.erase`:
34
34
  * someone's data, gone).
35
- * - After an agent's answer, a medium may show more (additions: a carousel
35
+ * - After an agent's answer, the place it goes to may show more (additions: a carousel
36
36
  * of trips after the answer that found them), each once per chat per key,
37
37
  * recorded in `shown` (`chat.shown`), and told to the model after that
38
38
  * answer (`[then shown: …]`). A choice tapped comes with its id (`tap`).
@@ -65,7 +65,7 @@
65
65
  * files }` in (each file's name, type and size); it refuses, or answers
66
66
  * `{ thread?, transcribe?: false }` (see actions/send.ts);
67
67
  * - `additions`: { order?, agents? }, each with an `addition:<name>` View in
68
- * the medium that shows it, given `{ thread, answer }` (see `Addition`).
68
+ * the place that shows it, given `{ thread, answer }` (see `Addition`).
69
69
  */
70
70
  import { definePlugin } from "../../../runtime/mod.js";
71
71
  import { eraseAction } from "./actions/erase.js";
@@ -100,11 +100,11 @@ export const chat = definePlugin({
100
100
  requires: ["models"],
101
101
  collections: { thread, message, wait, live, file, intent, shown },
102
102
  views: {
103
- thread: { llm: prompt },
104
- participants: { llm: participants },
105
- context: { llm: contextView },
106
- history: { llm: historyView },
107
- message: { llm: messageView },
103
+ "llm.thread": prompt,
104
+ participants: participants,
105
+ context: contextView,
106
+ history: historyView,
107
+ "llm.message": messageView,
108
108
  },
109
109
  // Every agent's model can be called as configured (the models plugin says); a window by age
110
110
  // is in ms.
@@ -89,7 +89,7 @@ const turn = async (ctx, event) => {
89
89
  if (event.type === "turn.requested" && t.hops === 0 && step === 0 && !open &&
90
90
  current.latest !== t.trigger && await answered(ctx, t))
91
91
  return;
92
- const composed = await ctx.render("llm", "thread", current, { viewer });
92
+ const composed = await ctx.render("llm.thread", current, { viewer });
93
93
  const instructions = composed.system.join("\n\n");
94
94
  // The conversation up to here repeats in the next calls: a cache point, before what's new each turn.
95
95
  const history = composed.history.map((m, i, all) => i === all.length - 1 ? { ...m, cache: true } : m);
@@ -200,7 +200,10 @@ export const commands = {
200
200
  });
201
201
  let n = 0;
202
202
  for (const m of messages) {
203
- await term.show("message", m, { thread: here, ...(m.toolCalls ? {} : { n: ++n }) });
203
+ await term.show("terminal.message", m, {
204
+ thread: here,
205
+ ...(m.toolCalls ? {} : { n: ++n }),
206
+ });
204
207
  }
205
208
  },
206
209
  }),
@@ -23,6 +23,6 @@ export async function runTool(ctx, name, input, at) {
23
23
  }
24
24
  /** What a call's result reads as to a model (`viewer`): its tool's View, else its output. */
25
25
  export async function toolText(ctx, call, viewer) {
26
- const shown = await ctx.render("llm", `tool:${call.name}`, call, { viewer });
26
+ const shown = await ctx.render(`tool:${call.name}`, call, { viewer });
27
27
  return typeof shown === "string" ? shown : call.output;
28
28
  }
@@ -239,9 +239,9 @@ export type ContextEntry = {
239
239
  };
240
240
  /**
241
241
  * An `additions` resource: what a feature shows after an agent's final
242
- * answer, in a medium that can (WhatsApp: a carousel of trips after the
243
- * answer that found them). Its content is a View, `addition:<name>`, in that
244
- * medium, given `{ thread, answer }`: it returns an `Addition`, several, or
242
+ * answer, in a place that can (WhatsApp: a carousel of trips after the
243
+ * answer that found them). Its content is a View, `addition:<name>`, which
244
+ * that place looks up, given `{ thread, answer }`: it returns an `Addition`, several, or
245
245
  * nothing. Lowest `order` first; only after the answers of `agents`, when it
246
246
  * names them.
247
247
  */
@@ -251,8 +251,8 @@ export type AdditionEntry = {
251
251
  };
252
252
  /**
253
253
  * What an `addition:<name>` View returns: the parts to show (each in the
254
- * medium's own terms), once per chat per `key` (at most 120 of `[\w:.-]`:
255
- * `trips:9f2a`), what goes instead when the medium refuses a part
254
+ * place's own terms), once per chat per `key` (at most 120 of `[\w:.-]`:
255
+ * `trips:9f2a`), what goes instead when the place refuses a part
256
256
  * (`fallback`: the trips as a text list), and a line the model is told after
257
257
  * that answer (`note`: "6 trips as a carousel").
258
258
  */
@@ -19,12 +19,12 @@ export const chatTerminal = definePlugin({
19
19
  name: "chat-terminal",
20
20
  requires: ["chat", "terminal-shell"],
21
21
  views: {
22
- thread: { terminal: conversationView },
23
- message: { terminal: messageLine },
24
- author: { terminal: authorView },
25
- live: { terminal: liveView },
26
- threads: { terminal: threadsView },
27
- "agent.prompt": { terminal: agentPromptView },
22
+ "terminal.thread": conversationView,
23
+ "terminal.message": messageLine,
24
+ author: authorView,
25
+ "terminal.live": liveView,
26
+ threads: threadsView,
27
+ "agent.prompt": agentPromptView,
28
28
  },
29
29
  resources: { commands },
30
30
  });