copilotz 1.0.0-rc.30 → 1.0.0-rc.32

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 (154) hide show
  1. package/CHANGELOG.md +85 -1
  2. package/README.md +53 -31
  3. package/hosts/terminal/host.js +12 -4
  4. package/hosts/web/host.js +5 -0
  5. package/package.json +1 -1
  6. package/plugins/access/accounts/actions/callback.js +2 -2
  7. package/plugins/access/accounts/actions/complete.js +2 -2
  8. package/plugins/access/accounts/actions/connect.js +2 -2
  9. package/plugins/access/accounts/actions/disconnect.js +2 -2
  10. package/plugins/access/accounts/collections/account.js +2 -2
  11. package/plugins/access/contacts/collections/contact.d.ts +1 -1
  12. package/plugins/access/contacts/collections/contact.js +2 -2
  13. package/plugins/access/identity/actions/session.js +2 -2
  14. package/plugins/access/spaces/actions/can.js +2 -2
  15. package/plugins/access/spaces/actions/create.js +2 -2
  16. package/plugins/access/spaces/actions/invitation.js +4 -4
  17. package/plugins/access/spaces/actions/leave.js +2 -2
  18. package/plugins/access/spaces/actions/member.js +3 -3
  19. package/plugins/access/spaces/actions/org.js +6 -6
  20. package/plugins/access/spaces/actions/personal.js +9 -6
  21. package/plugins/access/spaces/actions/request.js +3 -3
  22. package/plugins/access/spaces/actions/share.js +2 -2
  23. package/plugins/access/spaces/collections/invitation.js +6 -4
  24. package/plugins/access/spaces/collections/profile.js +3 -3
  25. package/plugins/access/spaces/collections/space.d.ts +1 -1
  26. package/plugins/access/spaces/collections/space.js +2 -1
  27. package/plugins/access/spaces/shared/labels.js +2 -1
  28. package/plugins/access/spaces/shared/reach.d.ts +31 -3
  29. package/plugins/access/spaces/shared/reach.js +120 -9
  30. package/plugins/access/spaces/shared/rules.js +8 -3
  31. package/plugins/access/spaces/views/elsewhere.d.ts +5 -2
  32. package/plugins/access/spaces/views/web/words.d.ts +1 -1
  33. package/plugins/agents/chat/actions/attach.js +3 -3
  34. package/plugins/agents/chat/actions/move.js +2 -2
  35. package/plugins/agents/chat/actions/send.js +4 -4
  36. package/plugins/agents/chat/collections/file.d.ts +10 -1
  37. package/plugins/agents/chat/collections/file.js +7 -0
  38. package/plugins/agents/chat/collections/intent.d.ts +1 -1
  39. package/plugins/agents/chat/collections/live.d.ts +2 -2
  40. package/plugins/agents/chat/collections/message.d.ts +1 -1
  41. package/plugins/agents/chat/collections/shown.d.ts +1 -1
  42. package/plugins/agents/chat/collections/thread.d.ts +1 -1
  43. package/plugins/agents/chat/collections/wait.d.ts +1 -1
  44. package/plugins/agents/chat/processors/turn.js +13 -13
  45. package/plugins/agents/chat/shared/delivery.d.ts +1 -1
  46. package/plugins/agents/chat/shared/delivery.js +4 -1
  47. package/plugins/agents/chat/shared/send.js +2 -1
  48. package/plugins/agents/memory/collections/memory.d.ts +1 -1
  49. package/plugins/agents/memory/mod.js +2 -2
  50. package/plugins/agents/memory/shared/scope.d.ts +4 -1
  51. package/plugins/agents/memory/shared/scope.js +6 -6
  52. package/plugins/agents/openapi/shared/files.js +2 -2
  53. package/plugins/agents/routines/collections/routine.d.ts +2 -2
  54. package/plugins/agents/routines/resources/tools.js +11 -9
  55. package/plugins/agents/routines/shared/fire.d.ts +3 -1
  56. package/plugins/agents/routines/shared/fire.js +4 -2
  57. package/plugins/agents/skills/collections/skill.d.ts +1 -1
  58. package/plugins/agents/skills/resources/tools.js +1 -1
  59. package/plugins/agents/skills/shared/skills.d.ts +2 -2
  60. package/plugins/agents/skills/shared/skills.js +3 -6
  61. package/plugins/agents/team/actions/agent.js +4 -4
  62. package/plugins/agents/team/collections/agent.d.ts +1 -1
  63. package/plugins/billing/usage/collections/usage.js +4 -3
  64. package/plugins/billing/usage/views/web/words.d.ts +1 -1
  65. package/plugins/compute/apps/actions/list.js +2 -2
  66. package/plugins/compute/apps/actions/publish.js +2 -2
  67. package/plugins/compute/apps/resources/tools.js +7 -7
  68. package/plugins/compute/cloud/actions/create.js +5 -2
  69. package/plugins/compute/cloud/resources/tools.js +10 -9
  70. package/plugins/compute/computers/actions/allowed.js +1 -1
  71. package/plugins/compute/computers/actions/code.js +2 -2
  72. package/plugins/compute/computers/actions/env.js +5 -2
  73. package/plugins/compute/computers/actions/work.js +2 -2
  74. package/plugins/compute/computers/collections/approval.d.ts +6 -6
  75. package/plugins/compute/computers/collections/desk.d.ts +1 -1
  76. package/plugins/compute/computers/collections/desk.js +2 -2
  77. package/plugins/compute/computers/collections/enrollment.d.ts +1 -1
  78. package/plugins/compute/computers/collections/grant.d.ts +1 -1
  79. package/plugins/compute/computers/collections/grant.js +1 -1
  80. package/plugins/compute/computers/program/version.d.ts +1 -1
  81. package/plugins/compute/computers/program/version.js +1 -1
  82. package/plugins/compute/computers/resources/downloads.js +1 -1
  83. package/plugins/compute/computers/resources/tools.js +3 -5
  84. package/plugins/compute/computers/shared/grants.js +2 -0
  85. package/plugins/compute/computers/shared/wake.d.ts +4 -4
  86. package/plugins/compute/computers/shared/wake.js +7 -9
  87. package/plugins/compute/computers/shared/where.d.ts +4 -4
  88. package/plugins/compute/computers/shared/where.js +9 -10
  89. package/plugins/interfaces/api/collections/key.d.ts +7 -4
  90. package/plugins/interfaces/api/collections/key.js +5 -1
  91. package/plugins/interfaces/api/shared/actor.d.ts +1 -0
  92. package/plugins/interfaces/mcp/actions/call.js +5 -1
  93. package/plugins/interfaces/mcp/mod.d.ts +15 -9
  94. package/plugins/interfaces/mcp/mod.js +16 -10
  95. package/plugins/interfaces/mcp/resources/server.js +3 -3
  96. package/plugins/interfaces/mcp/resources/tools.d.ts +4 -9
  97. package/plugins/interfaces/mcp/resources/tools.js +7 -20
  98. package/plugins/interfaces/mcp/resources/widgets.js +2 -1
  99. package/plugins/interfaces/mcp/shared/settings.d.ts +2 -2
  100. package/plugins/interfaces/mcp/shared/settings.js +5 -1
  101. package/plugins/interfaces/voice/collections/blocked.d.ts +1 -1
  102. package/plugins/interfaces/voice/collections/call.d.ts +1 -1
  103. package/plugins/interfaces/voice/routes/relay.js +6 -5
  104. package/plugins/interfaces/web/actions/arrive.js +1 -1
  105. package/plugins/interfaces/web/collections/visitor.js +8 -4
  106. package/plugins/interfaces/web/resources/spend.js +9 -3
  107. package/plugins/interfaces/whatsapp/collections/number.d.ts +1 -1
  108. package/plugins/interfaces/whatsapp/processors/receive.js +7 -4
  109. package/plugins/models/shared/use.d.ts +6 -8
  110. package/plugins/work/boards/actions/create-board.js +2 -2
  111. package/plugins/work/boards/actions/create-card.js +2 -4
  112. package/plugins/work/boards/actions/delete-board.js +2 -2
  113. package/plugins/work/boards/actions/delete-card.js +2 -2
  114. package/plugins/work/boards/actions/move-card.js +2 -2
  115. package/plugins/work/boards/actions/update-board.js +2 -2
  116. package/plugins/work/boards/actions/update-card.js +2 -2
  117. package/plugins/work/boards/collections/board.d.ts +1 -1
  118. package/plugins/work/boards/collections/card.d.ts +1 -1
  119. package/plugins/work/boards/resources/tools.js +6 -8
  120. package/plugins/work/documents/actions/create.js +2 -2
  121. package/plugins/work/documents/actions/delete.js +2 -2
  122. package/plugins/work/documents/actions/presence.js +2 -2
  123. package/plugins/work/documents/actions/rename.js +2 -2
  124. package/plugins/work/documents/actions/restore.js +2 -2
  125. package/plugins/work/documents/actions/save.js +2 -2
  126. package/plugins/work/documents/collections/document-presence.d.ts +1 -1
  127. package/plugins/work/documents/collections/document-version.d.ts +1 -1
  128. package/plugins/work/documents/collections/document-version.js +2 -2
  129. package/plugins/work/documents/collections/document.d.ts +1 -1
  130. package/plugins/work/documents/collections/document.js +3 -3
  131. package/plugins/work/documents/resources/tools.js +4 -6
  132. package/runtime/actor.d.ts +37 -0
  133. package/runtime/actor.js +39 -0
  134. package/runtime/browsers.d.ts +11 -1
  135. package/runtime/browsers.js +20 -3
  136. package/runtime/client.d.ts +10 -2
  137. package/runtime/client.js +19 -5
  138. package/runtime/define.d.ts +39 -5
  139. package/runtime/errors.d.ts +16 -6
  140. package/runtime/errors.js +20 -7
  141. package/runtime/executor.js +26 -4
  142. package/runtime/kept.d.ts +22 -0
  143. package/runtime/kept.js +128 -0
  144. package/runtime/mod.d.ts +1 -1
  145. package/runtime/mod.js +1 -1
  146. package/runtime/observe.d.ts +6 -1
  147. package/runtime/observe.js +2 -1
  148. package/runtime/owner.d.ts +5 -1
  149. package/runtime/owner.js +109 -24
  150. package/runtime/reads.d.ts +3 -1
  151. package/runtime/reads.js +8 -1
  152. package/runtime/registry.js +9 -0
  153. package/runtime/store.d.ts +3 -1
  154. package/runtime/views.js +1 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,88 @@
1
- ## Unreleased
1
+ ## 1.0.0-rc.32 — 2026-11-09
2
+
3
+ **Upgrading.** `people` now lets in an agent working for a person, and an Action's `allow` is asked
4
+ of code acting for someone too (a tool's `ctx.call`, a Processor's, another Action's), not only of
5
+ outside callers. Go through your Actions:
6
+
7
+ - Say `inPerson` for what only the person decides (consent, keys, who's in a space, money,
8
+ publishing): it never lets in an agent, a key or a routine's work. Say `people` for the rest. An
9
+ `allow` written as `(actor) => actor.kind === "person"` keeps your own tools' agents out: say
10
+ `people`.
11
+ - An Action whose run takes `ctx.actor.id` for a person's id, or checks something only when
12
+ `ctx.actor.kind === "person"`, reads `personOf(ctx.actor)` instead (an agent's id isn't its
13
+ person's).
14
+ - A tool calling an Action its agent's person couldn't is refused (`forbidden`): let them in, or go
15
+ beyond on purpose with a named grant, `ctx.as(grant("<why>"))`.
16
+ - An agent's work reaches only where it is (its chat's space) and what that space draws on: a tool
17
+ that read across its person's spaces from a shared chat finds less. Have the space draw on the
18
+ other (`member.set` of a space), work from the person's Personal space, or hand the work over.
19
+ - Tools read where they are from `ctx.in`, not their chat's `in`.
20
+ - A developer key no longer calls what's now `inPerson` (`space.create`, `member.*`, `invitation.*`,
21
+ `share`, `chat.move`, `agent.create`…), even listed in its scope.
22
+ - An MCP line listing a tool without its `tool:<name>` View doesn't start: add the View.
23
+
24
+ ```ts
25
+ import { grant, inPerson, people, personOf } from "@copilotz/copilotz";
26
+
27
+ "invoice.send": defineAction({ allow: inPerson, … }), // only the person decides
28
+ "invoice.draft": defineAction({ allow: people, run: (ctx) => draft(personOf(ctx.actor)) }),
29
+ // a tool, in its chat's space; going beyond its person on purpose, on the record:
30
+ run: async (input, ctx) => await ctx.as(grant("availability")).call("slots.all", { in: ctx.in }),
31
+ ```
32
+
33
+ - **Who, for whom, where** ([design](design/work.md)). All work runs as an actor, for whom it's done
34
+ (`for`) and where (`in`, an opaque id: a space, to the access plugin), which the runtime carries
35
+ as it carries the actor: into nested calls, tools, the Processors a call's events wake, its timers
36
+ and the Views observed for it; every event records it; `guard` and `allow` see it; contexts say it
37
+ (`ctx.in`, on Actions, Processors, tools, queries and Views). `ctx.as` stays where the work is
38
+ unless told where. Every way in says it: a browser's calls (its page's space;
39
+ `client.call(…,
40
+ { in })`), the terminal (where its person works), a key (its space), WhatsApp,
41
+ voice, web and MCP lines (theirs), routines (theirs), a chat's turn (its chat's).
42
+ - **An agent's work reaches only where it is.** Reach for work done for someone is the person's
43
+ reach ∩ the agent's memberships ∩ its space and what that draws on, at the role it draws on it
44
+ with; in the person's own Personal space, all they reach. North working for Ana in a shared space
45
+ reached every space of Ana's (the core agents are members of all of them), and only labels kept
46
+ Finance from Launch's members: now it reads Launch and its sources. A person acting themselves
47
+ isn't narrowed; a tool or routine acting as them is. An agent actor's `at` is `in`.
48
+ - **`allow` is asked wherever someone acts:** from outside as before, and from code acting for an
49
+ actor (`ctx.call`, a timer, a read's unrecorded calls); for an agent, of whom it works for too
50
+ (`allows`). Actions without one stay internal. Going beyond is a named grant (`grant`), on the
51
+ record as the grant, `via` whose work it was, and counted (`copilotz.elevated.ops`).
52
+ - **Copilotz's own Actions say which:** `inPerson` for sessions, connected accounts, who's in a
53
+ space or the org, `share`, `chat.move`, `memory.move`, `agent.create/update/delete`,
54
+ `computer.code`, `computer.work` and `app.publish`, beside those that were; `people` for the rest,
55
+ boards and documents included (their agents' own tools couldn't call them). `chat.send` and
56
+ `chat.attach` let in people and contacts writing as themselves, never an agent. Code that took the
57
+ actor's id for its person's (`space.personal`, invitations, accounts, desks, cloud computers,
58
+ usage) asks `personOf`; an environment changes only by its space's managers, whoever asks.
59
+ - **Reach is kept in the owner** per who, for whom and where, until a commit changes a membership or
60
+ a space it read (`ReadContext.kept`: what rules work out from reads, let go exactly when what they
61
+ read changes; `cache.kept`, 1,000). An agent's turn works out its reach once, not on every op.
62
+ With narrowing, an agent's work for a person in one of 1,000 spaces (`examples/work-bench.ts`)
63
+ takes a fifth of the time: a turn's 13 ops, 4.4 ms median (21.5 before), 5.3 ms at p95 (22.9); the
64
+ person's own, 4.7 ms (11.7). Nothing measured got slower.
65
+ - **Tools know where they are** (`ctx.in`): documents, boards, computers, cloud computers, apps,
66
+ memory, skills, routines and an API's files no longer read their chat to find its space. What's
67
+ learned stays where it's learned.
68
+ - **Handing work to another space** writes under its grant (`chat.hand-over`, and `chat.hand-back`
69
+ for the answer), for the same person, in the new space; its check is the person's, anywhere.
70
+ - **mcp:** a listed tool without its `tool:<name>` View stops the app from starting (it was left
71
+ out, said once in the log). A line's contact, its widgets and its tools work in its space.
72
+ - **Model-use listeners** get `as` in a job; a web line's budget prices its visitors' use as its
73
+ grant (`web.budget`).
74
+ - **Startup checks** see the Views' names (`merged.views`).
75
+
76
+ ## 1.0.0-rc.31 — 2026-11-08
77
+
78
+ - **A write the rules refuse in a transaction no longer holds up every write.** Refused before it
79
+ reached its transaction, it left the transaction open, holding the store's writer: the Action's
80
+ failure and every other write in the app waited 30 s, until it was rolled back as idle. Now it
81
+ ends its transaction at once, as an op that fails in one does: it rolls back, and its later ops
82
+ fail ("The transaction is closed."), even when the error is caught. Code that caught a failed op
83
+ and wrote on used to commit what came after it. A transaction with no op for 5 s (30 s before)
84
+ rolls back, and `copilotz.transaction.duration` measures how long each one held the writer.
85
+ - **Boards** no longer read a new card back inside its transaction: one round trip less per card.
2
86
 
3
87
  ## 1.0.0-rc.30 — 2026-11-08
4
88
 
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.30"`),
25
+ On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.32"`),
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.
@@ -70,8 +70,9 @@ The runtime knows only these, and plugins are made of them:
70
70
  (`ctx.db.collection("note").insertOne(…)`, `find`, `updateOne` with `$set`…), with named queries,
71
71
  vector fields and indexes. Every write records an event in the same commit.
72
72
  - **Actions:** what can be done, with a JSON Schema input and an `allow(actor, input)` saying who
73
- may call them. Every call is on the record (`action.started`, `action.completed`), retryable by
74
- id, and everything it causes is its caller's.
73
+ may call them, from outside and from code acting for someone. Every call is on the record
74
+ (`action.started`, `action.completed`), retryable by id, and everything it causes is its caller's,
75
+ where its caller is (`in`).
75
76
  - **Processors:** what happens when events happen: ordered per key, at least once, from a durable
76
77
  cursor, idempotent by deterministic ids.
77
78
  - **Views:** a plugin's front end, found by name: text for the model (`llm.thread`, the agents'
@@ -631,7 +632,7 @@ and an app serves it from there by default:
631
632
  import { computerDownloads } from "copilotz/plugins/compute/downloads";
632
633
 
633
634
  plugins: [...plugins, await computerDownloads()], // this Copilotz's release
634
- plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.30" })], // its own: /computer/download/
635
+ plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.32" })], // its own: /computer/download/
635
636
  plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
636
637
  ```
637
638
 
@@ -770,6 +771,9 @@ name, never by importing its code.
770
771
  last four hours of a conversation, back from its newest message (summaries too, with `history`);
771
772
  what's older stays in the chat. The start moves in steps of a tenth of `maxAge`, so prompts keep
772
773
  hitting the provider's cache ([design](design/views.md#history-as-views)).
774
+ - **Tools know where they are:** a turn works where its chat is, so a tool's `ctx.in` is its
775
+ conversation's space (with the access plugin, all it reaches there), beside `ctx.agent`,
776
+ `ctx.thread` and `ctx.trigger`.
773
777
  - **A tool call runs once:** before a step's tools run, the step's calls are written (an
774
778
  `intent`), and what each returns as soon as it does. A retried turn (it failed after its tools
775
779
  ran, its executor died, the runtime restarted) goes on with those calls instead of asking its
@@ -927,19 +931,22 @@ name, never by importing its code.
927
931
  agents, other spaces) and roles; collections named in the `shared` resource keep to what each
928
932
  actor reaches. People join by accepting an invitation to the email they signed in with; sending
929
933
  one never says whether the address has an account. Agents are members too, each working only where
930
- it's one; a new space has the app's default agents. An answer drawn from a space not everyone in
931
- the conversation can see shows only to those who see both, marked, until someone shares it.
934
+ it's one; a new space has the app's default agents. An agent's work for someone reaches only where
935
+ it is (`in`) and what that space draws on (in the person's own Personal space, all they reach),
936
+ kept in the owner per who, for whom and where. An answer drawn from a space not everyone in the
937
+ conversation can see shows only to those who see both, marked, until someone shares it.
932
938
  - **`identity`**: people and their sessions, and who a session's secret proves: its `who` reads the
933
939
  session cookie (`credential.actor`); `POST /signout` ends the session, and `GET /me` says whom the
934
940
  page shows. Sign-in plugins set the cookie with its contract's `signedIn`.
935
941
  - **`contacts`**: people outside the org who talk to its agents (a WhatsApp customer). A contact is
936
942
  its own kind of actor (`{ kind: "contact", id }`), never a person: every Action and query stays
937
- shut to it unless it says otherwise (`peopleOrContacts`, as `chat.send` does). Its chat lives in
938
- the line's space and is shared with it on its own: it reaches that chat, what's said and filed
939
- there, and nothing else; the space's people reach it as any chat there, and the agent working for
940
- the contact reaches exactly that chat, never its agents' private steps. Agents are told whom
941
- they're talking with. The web interface's site chats (`webLines`, `web.<name>`) let a browser that
942
- isn't anyone in as a visitor, a contact once it speaks (see "Visitors").
943
+ shut to it unless it says otherwise (`peopleOrContacts`; `chat.send` lets in people and contacts
944
+ writing as themselves, never an agent). Its chat lives in the line's space and is shared with it
945
+ on its own: it reaches that chat, what's said and filed there, and nothing else; the space's
946
+ people reach it as any chat there, and the agent working for the contact reaches exactly that
947
+ chat, never its agents' private steps. Agents are told whom they're talking with. The web
948
+ interface's site chats (`webLines`, `web.<name>`) let a browser that isn't anyone in as a visitor,
949
+ a contact once it speaks (see "Visitors"). A contact works in its line's space (`in`).
943
950
  - **`googleSignIn`**: sign-in with a Google ID token (the `google` resource names your client). Its
944
951
  routes: `POST /signin/google`, which Google's button posts its token to, sets the session's
945
952
  cookie; `GET /google` gives the page the client id for its button.
@@ -1093,17 +1100,18 @@ filled by the front ends through resources).
1093
1100
  webhook (`/hooks/voice/<name>`) and the call's socket (`/hooks/voice/<name>/relay`), which
1094
1101
  `listen` and `Deno.serve(runtime.fetch)` carry.
1095
1102
  - **`mcp`**: models outside the app (ChatGPT, Claude, any MCP client) call its tools. A server the
1096
- app declares (`mcp.<name>`: its space, the tools it lists, each with its `tool:<name>` View, how
1097
- each is shown, who calls, its limits) is an MCP server at `POST /mcp/<name>`: Streamable HTTP,
1098
- JSON-RPC 2.0, no session, MCP 2026-07-28 and the versions with a handshake. Each conversation
1099
- (ChatGPT's `openai/session`, or a `chat` handle the app gives a client that names none) is a
1100
- contact in a chat of its own in the server's space, its ids an HMAC with the `links` secret. A
1101
- call runs the tool through chat's runner as that contact, is written there as a step, and answers
1102
- what the app's agents read of it (only public errors say their words); a request sent again to a
1103
- tool that changes things is answered from the first, and the server's limits (calls at once, a
1104
- minute, new conversations an hour, by conversation, user, caller's address and in all) refuse the
1105
- rest. **Widgets** (MCP Apps, ChatGPT's Apps SDK): a tool's calls shown through a web View of the
1106
- app's (`tools.<name>.widget`), drawn inside the assistant by the widget host
1103
+ app declares (`mcp.<name>`: its space, the tools it lists, each with its `tool:<name>` View,
1104
+ without which the app doesn't start, how each is shown, who calls, its limits) is an MCP server at
1105
+ `POST /mcp/<name>`: Streamable HTTP, JSON-RPC 2.0, no session, MCP 2026-07-28 and the versions
1106
+ with a handshake. Each conversation (ChatGPT's `openai/session`, or a `chat` handle the app gives
1107
+ a client that names none) is a contact in a chat of its own in the server's space, its ids an HMAC
1108
+ with the `links` secret. A call runs the tool through chat's runner as that contact, where its
1109
+ chat is (the Actions it calls asked their `allow` for the contact), is written there as a step,
1110
+ and answers what the app's agents read of it (only public errors say their words); a request sent
1111
+ again to a tool that changes things is answered from the first, and the server's limits (calls at
1112
+ once, a minute, new conversations an hour, by conversation, user, caller's address and in all)
1113
+ refuse the rest. **Widgets** (MCP Apps, ChatGPT's Apps SDK): a tool's calls shown through a web
1114
+ View of the app's (`tools.<name>.widget`), drawn inside the assistant by the widget host
1107
1115
  (`copilotz/web/widget`) in a template made from the app's `widgets` resource
1108
1116
  (`widgets: widgetsOf({ code, plugins })`, from `copilotz/web/server`), seeded with what the View
1109
1117
  reads, answered on the server as the conversation's contact (its first paint asks nothing). What
@@ -1125,7 +1133,8 @@ add: each plugin instruments itself.
1125
1133
  to `createRuntime({ metrics })` (and to remote executors); plugin code records with `ctx.metrics`.
1126
1134
  Recorded:
1127
1135
  - the runtime: `copilotz.job.duration` (by kind, name, outcome), `copilotz.op.duration` and
1128
- `copilotz.op.roundtrip`, `copilotz.commit.duration`, `copilotz.events`,
1136
+ `copilotz.op.roundtrip`, `copilotz.commit.duration`, `copilotz.transaction.duration` (how long
1137
+ each transaction held open kept the writer, by outcome), `copilotz.events`,
1129
1138
  `copilotz.processor.lag`, `copilotz.executors`, `copilotz.cache.reads`;
1130
1139
  - model calls, by OpenTelemetry's GenAI conventions: `gen_ai.client.operation.duration`,
1131
1140
  `gen_ai.client.token.usage`, and `copilotz.llm.time_to_first_token`;
@@ -1734,20 +1743,33 @@ Copilotz runs on Node (first), Deno and Bun, and is built for Cloudflare Workers
1734
1743
  is the record already kept, so sending twice is safe.
1735
1744
  - **One writer per store:** each write auto-commits as one short transaction, and
1736
1745
  `ctx.transaction(tx => …)` makes several writes and their events atomic. Slow I/O, such as model
1737
- calls, never holds the writer.
1746
+ calls, never holds the writer. An op in a transaction that fails, a write the rules refuse
1747
+ included, ends it: it rolls back, and its later ops fail, even when the error is caught. One with
1748
+ no op for 5 seconds rolls back too.
1738
1749
  - **Stream-first:** committed events and live frames go to subscribers immediately, and observed
1739
1750
  Views run again as soon as what they read commits.
1740
- - **Who acts:** an outside call may bind an actor (`runtime.call(action, input, { actor })`, and
1741
- `query`, `emit`, `observe` likewise). Everything it causes is theirs: nested calls, writes, the
1742
- events they record (`event.actor`: the log is the audit trail), Processors handling those events,
1743
- and timers it sets. Without one, the system acts.
1744
- - **Actions say whom they let call them** (`allow(actor, input)`); without `allow`, actors can't.
1751
+ - **Who acts, for whom, where:** an outside call may bind an actor
1752
+ (`runtime.call(action, input,
1753
+ { actor })`, and `query`, `emit`, `observe` likewise): who acts,
1754
+ for whom an agent works (`for`), and where the work is (`in`, an opaque id: a space, to the access
1755
+ plugin). Everything it causes is theirs, there: nested calls, writes, the events they record
1756
+ (`event.actor`: the log is the audit trail), Processors handling those events, timers it sets,
1757
+ Views observed for it; contexts say where (`ctx.in`). Without one, the system acts
1758
+ ([design](design/work.md)).
1759
+ - **Actions say whom they let call them** (`allow(actor, input)`), asked from outside and of code
1760
+ acting for someone (`ctx.call` in a tool, a Processor, another Action); for an agent, of whom it
1761
+ works for too. Without `allow`, an Action is internal: code calls it, actors from outside can't.
1762
+ The runtime's `people` lets in people, their keys and an agent working for one; `inPerson` only
1763
+ the person themselves (never a key, an agent or a routine's work), for what only they decide;
1764
+ `peopleOrContacts` contacts too.
1745
1765
  - **Rules are filters** (a plugin's `guard(actor, { collection, filter }, ctx)`): reads, updates
1746
1766
  and deletes reach only what matches; inserts, and what updates leave, must match. The owner
1747
1767
  applies them to every op an actor's work makes; the access plugin declares them for the
1748
1768
  collections it shares.
1749
1769
  - **Trusted code acts as someone else, on the record:** `ctx.as(person)`, or `ctx.as()` for the
1750
- system, which no rule restricts; its events say `via` whom.
1770
+ system, which no rule restricts, or a named grant of the system's (`ctx.as(grant("hand-over"))`,
1771
+ counted as `copilotz.elevated.ops`); its events say `via` whom, and stay where the work is
1772
+ unless it says where.
1751
1773
  - Remote executors prove the deployment key, compared in constant time.
1752
1774
  - **Private fields** (`private: ["token"]` on a collection): what an actor's queries and Views
1753
1775
  read comes without them; Actions and Processors acting for them still read them. No event holds
@@ -35,13 +35,16 @@ export async function terminal(options) {
35
35
  /** One person at the terminal, until they leave (undefined) or `/as` makes someone else type. */
36
36
  async function session(options, { me, actor, space }, { first, interactive, lines }) {
37
37
  const as = actor ? { actor } : {};
38
- // The runtime as this person: everything commands do is theirs.
38
+ // Where they work (`/space` moves them), which their calls say (`in`).
39
+ let here = space;
40
+ const placed = () => ({ ...actor, ...(here ? { in: here } : {}) });
41
+ // The runtime as this person: everything commands do is theirs, where they work.
39
42
  const runtime = actor
40
43
  ? {
41
44
  ...options.runtime,
42
- call: (action, input, o = {}) => options.runtime.call(action, input, { ...o, actor }),
45
+ call: (action, input, o = {}) => options.runtime.call(action, input, { ...o, actor: placed() }),
43
46
  query: (name, params, o = {}) => options.runtime.query(name, params, { ...o, actor }),
44
- emit: (type, data, o = {}) => options.runtime.emit(type, data, { ...o, actor }),
47
+ emit: (type, data, o = {}) => options.runtime.emit(type, data, { ...o, actor: placed() }),
45
48
  }
46
49
  : options.runtime;
47
50
  const stdout = options.stdout ?? process.stdout;
@@ -50,7 +53,11 @@ async function session(options, { me, actor, space }, { first, interactive, line
50
53
  me,
51
54
  runtime,
52
55
  state: () => runtime.query("shell.mine", { person: me }),
53
- set: async (fields) => void await runtime.call("shell.set", { person: me, ...fields }),
56
+ set: async (fields) => {
57
+ if (typeof fields.space === "string")
58
+ here = fields.space;
59
+ await runtime.call("shell.set", { person: me, ...fields });
60
+ },
54
61
  show: async (kind, item, hints) => {
55
62
  for (const one of Array.isArray(item) ? item : [item]) {
56
63
  await runtime.call("shell.print", {
@@ -133,6 +140,7 @@ async function session(options, { me, actor, space }, { first, interactive, line
133
140
  const state = await runtime.query("shell.mine", { person: me });
134
141
  if (space && !state.space)
135
142
  await runtime.call("shell.set", { person: me, space });
143
+ here = state.space ?? space;
136
144
  const screen = runtime.observe("terminal.shell", { person: me }, {
137
145
  ...as,
138
146
  viewer: { name: me, kind: "person" },
package/hosts/web/host.js CHANGED
@@ -203,8 +203,13 @@ export async function web(options) {
203
203
  ...(space ? { space } : {}),
204
204
  ...(query ? { query } : {}),
205
205
  };
206
+ // Where the page is: a space's page is in that space, any other where the person works. What
207
+ // its Views call is done there (`in`, the work's), as the shell says (`hints.in`).
208
+ const [kind, ...rest] = location.pathname.split("/").filter(Boolean).map(decodeURIComponent);
209
+ const here = kind === "space" && rest.length ? rest.join("/") : space;
206
210
  const shell = client.observe("web.shell", where, {
207
211
  viewer,
212
+ ...(here ? { actor: { ...first.actor, in: here } } : {}),
208
213
  part: (part, key) => _jsx(Part, { part: part }, key),
209
214
  });
210
215
  draw(_jsx(Part, { part: shell }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilotz",
3
- "version": "1.0.0-rc.30",
3
+ "version": "1.0.0-rc.32",
4
4
  "description": "Copilotz: one runtime for Node, Deno, Bun, Cloudflare Workers and the browser.",
5
5
  "keywords": [
6
6
  "agents",
@@ -6,7 +6,7 @@
6
6
  * said), which the route sends them to Connected accounts with. Unrecorded:
7
7
  * the code stays out of the log.
8
8
  */
9
- import { defineAction } from "../../../../runtime/mod.js";
9
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
10
10
  import { codeOf } from "../shared/errors.js";
11
11
  import { finish } from "../shared/flow.js";
12
12
  export const callbackAction = defineAction({
@@ -24,7 +24,7 @@ export const callbackAction = defineAction({
24
24
  required: ["provider"],
25
25
  additionalProperties: false,
26
26
  },
27
- allow: (actor) => actor.kind === "person",
27
+ allow: inPerson,
28
28
  run: async (ctx, input) => {
29
29
  const { provider, code, state, error } = input;
30
30
  try {
@@ -5,7 +5,7 @@
5
5
  * which must be the person's own sign-in, there, in time. Unrecorded: the
6
6
  * code stays out of the log. It answers the account, as its person sees it.
7
7
  */
8
- import { defineAction, people } from "../../../../runtime/mod.js";
8
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
9
9
  import { invalid } from "../shared/errors.js";
10
10
  import { finish, where } from "../shared/flow.js";
11
11
  import { providerOf } from "../shared/settings.js";
@@ -18,7 +18,7 @@ export const completeAction = defineAction({
18
18
  required: ["provider", "address"],
19
19
  additionalProperties: false,
20
20
  },
21
- allow: people,
21
+ allow: inPerson,
22
22
  run: (ctx, input) => {
23
23
  const { title } = providerOf(ctx, input.provider);
24
24
  let url;
@@ -7,7 +7,7 @@
7
7
  * Unrecorded: its answer carries the sign-in's state, which stays out of
8
8
  * the log.
9
9
  */
10
- import { defineAction, people } from "../../../../runtime/mod.js";
10
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
11
11
  import { start } from "../shared/flow.js";
12
12
  export const connectAction = defineAction({
13
13
  description: "Starts connecting one of your accounts: where to sign in",
@@ -18,6 +18,6 @@ export const connectAction = defineAction({
18
18
  required: ["provider"],
19
19
  additionalProperties: false,
20
20
  },
21
- allow: people,
21
+ allow: inPerson,
22
22
  run: (ctx, input) => start(ctx, input.provider, input.origin),
23
23
  });
@@ -5,7 +5,7 @@
5
5
  * timer, saying `account.changed`. Agents working for them then use the
6
6
  * app's own models, where it has them.
7
7
  */
8
- import { defineAction, people } from "../../../../runtime/mod.js";
8
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
9
9
  import { revoke } from "../shared/oauth.js";
10
10
  import { unseal } from "../shared/seal.js";
11
11
  import { accountId, providerOf, settingsOf, timerOf } from "../shared/settings.js";
@@ -17,7 +17,7 @@ export const disconnectAction = defineAction({
17
17
  required: ["provider"],
18
18
  additionalProperties: false,
19
19
  },
20
- allow: people,
20
+ allow: inPerson,
21
21
  run: async (ctx, input) => {
22
22
  const person = ctx.actor.id;
23
23
  const provider = providerOf(ctx, input.provider);
@@ -10,7 +10,7 @@
10
10
  * Queries, for people: `account.providers`, what can be connected and how;
11
11
  * `account.uses`, which of some models would run on the asker's accounts.
12
12
  */
13
- import { defineCollection, people } from "../../../../runtime/mod.js";
13
+ import { defineCollection, people, personOf, } from "../../../../runtime/mod.js";
14
14
  import { providersOf } from "../shared/settings.js";
15
15
  import { usesOf } from "../shared/uses.js";
16
16
  const accountSchema = {
@@ -52,7 +52,7 @@ export const account = defineCollection({
52
52
  /** For each agent's model, the asker's account it would run on (or one to reconnect). */
53
53
  uses: {
54
54
  allow: people,
55
- run: async (accounts, params, ctx) => usesOf(ctx, await accounts.find({ person: ctx.actor.id }), params),
55
+ run: async (accounts, params, ctx) => usesOf(ctx, await accounts.find({ person: personOf(ctx.actor) ?? "" }), params),
56
56
  },
57
57
  },
58
58
  });
@@ -62,8 +62,8 @@ export declare const contact: {
62
62
  [x: string]: unknown;
63
63
  name?: string | undefined;
64
64
  at: string;
65
- via: string;
66
65
  in: string;
66
+ via: string;
67
67
  } & {
68
68
  _id: string;
69
69
  }>> | undefined;
@@ -7,7 +7,7 @@
7
7
  * the agent working for them (it's shared with them on its own, as their
8
8
  * chats are), and no one else's.
9
9
  */
10
- import { defineCollection, principalOf } from "../../../../runtime/mod.js";
10
+ import { defineCollection, people, principalOf, } from "../../../../runtime/mod.js";
11
11
  import { namesOf } from "../../spaces/contract.js";
12
12
  const contactSchema = {
13
13
  type: "object",
@@ -32,7 +32,7 @@ export const contact = defineCollection({
32
32
  * the spaces' `names` resource asks here for ids that start so.
33
33
  */
34
34
  names: {
35
- allow: (actor) => actor.kind === "person" || actor.kind === "agent",
35
+ allow: people,
36
36
  run: async (contacts, params) => {
37
37
  const given = Array.isArray(params?.ids) ? params.ids : [];
38
38
  const ids = [
@@ -3,7 +3,7 @@
3
3
  * verified (the system calls it: a sign-in plugin's Action, never a person);
4
4
  * `session.end` ends the one a person shows.
5
5
  */
6
- import { defineAction, people } from "../../../../runtime/mod.js";
6
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
7
7
  import { hash, secret } from "../collections/credential.js";
8
8
  /** How long a session lasts unless its sign-in says (30 days). */
9
9
  const LASTS = 30 * 86_400_000;
@@ -43,7 +43,7 @@ export const endSession = defineAction({
43
43
  required: ["secret"],
44
44
  additionalProperties: false,
45
45
  },
46
- allow: people,
46
+ allow: inPerson,
47
47
  run: async (ctx, input) => {
48
48
  const ended = await ctx.as().db.collection("credential").deleteOne({
49
49
  _id: await hash(input.secret),
@@ -4,7 +4,7 @@
4
4
  * what's shared there). For other plugins and front ends, which reach spaces
5
5
  * only by name: computers check it before someone uses a space's computer.
6
6
  */
7
- import { defineAction } from "../../../../runtime/mod.js";
7
+ import { defineAction, people } from "../../../../runtime/mod.js";
8
8
  import { may } from "../shared/can.js";
9
9
  export const canAction = defineAction({
10
10
  description: "Whether you may read, write in or manage a space",
@@ -19,7 +19,7 @@ export const canAction = defineAction({
19
19
  },
20
20
  // A question, asked on every preview request: it records nothing.
21
21
  record: false,
22
- allow: (actor) => actor.kind === "person" || actor.kind === "agent",
22
+ allow: people,
23
23
  run: async (ctx, input) => {
24
24
  return { can: await may(ctx, input.verb, input.space) };
25
25
  },
@@ -3,7 +3,7 @@
3
3
  * it, with the app's default agents working there. Not one the app declares
4
4
  * (see shared/declared.ts): those are the app's, made by `space.keep`.
5
5
  */
6
- import { defineAction, people } from "../../../../runtime/mod.js";
6
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
7
7
  import { seat } from "../shared/agents.js";
8
8
  import { declaredOf } from "../shared/declared.js";
9
9
  import { memberKey, orgRoleOf } from "../shared/reach.js";
@@ -15,7 +15,7 @@ export const createAction = defineAction({
15
15
  required: ["name"],
16
16
  additionalProperties: false,
17
17
  },
18
- allow: people,
18
+ allow: inPerson,
19
19
  run: async (ctx, input) => {
20
20
  // A guest's, through a key of theirs too: the person's role says.
21
21
  const person = { kind: ctx.actor.kind, id: ctx.actor.id };
@@ -5,7 +5,7 @@
5
5
  * in keeps their role) or turns it down. Its managers take one back the same
6
6
  * way. Sending answers the same whether the address has an account or not.
7
7
  */
8
- import { defineAction, people } from "../../../../runtime/mod.js";
8
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
9
9
  import { joinable } from "../shared/personal.js";
10
10
  import { may, must } from "../shared/can.js";
11
11
  import { memberKey, orgRoleOf, rolesOf } from "../shared/reach.js";
@@ -39,7 +39,7 @@ export const sendInvitationAction = defineAction({
39
39
  required: ["space", "email"],
40
40
  additionalProperties: false,
41
41
  },
42
- allow: people,
42
+ allow: inPerson,
43
43
  run: async (ctx, input) => {
44
44
  const email = input.email.trim().toLowerCase();
45
45
  if (!EMAIL.test(email))
@@ -90,7 +90,7 @@ export const acceptInvitationAction = defineAction({
90
90
  required: ["invitation"],
91
91
  additionalProperties: false,
92
92
  },
93
- allow: people,
93
+ allow: inPerson,
94
94
  run: async (ctx, input) => {
95
95
  const found = await answerable(ctx, input.invitation);
96
96
  if (!found.mine)
@@ -117,7 +117,7 @@ export const declineInvitationAction = defineAction({
117
117
  required: ["invitation"],
118
118
  additionalProperties: false,
119
119
  },
120
- allow: people,
120
+ allow: inPerson,
121
121
  run: async (ctx, input) => {
122
122
  const found = await answerable(ctx, input.invitation);
123
123
  await ctx.as().db.collection("invitation").deleteOne({ _id: found._id });
@@ -3,7 +3,7 @@
3
3
  * which is yours; and not as its only manager: make someone else one first.
4
4
  * What you added there stays, the space's.
5
5
  */
6
- import { defineAction, people } from "../../../../runtime/mod.js";
6
+ import { defineAction, inPerson } from "../../../../runtime/mod.js";
7
7
  import { keepsAManager } from "../shared/managers.js";
8
8
  import { PERSONAL } from "../shared/personal.js";
9
9
  import { memberKey } from "../shared/reach.js";
@@ -15,7 +15,7 @@ export const leaveAction = defineAction({
15
15
  required: ["space"],
16
16
  additionalProperties: false,
17
17
  },
18
- allow: people,
18
+ allow: inPerson,
19
19
  run: async (ctx, input) => {
20
20
  const db = ctx.as().db;
21
21
  const found = await db.collection("space").findOne({ _id: input.space });
@@ -12,7 +12,7 @@
12
12
  * key (`{ kind: "key", id }`) is seated by the plugin that made it, with
13
13
  * the role what it may do says; its managers take it out (which revokes it).
14
14
  */
15
- import { defineAction, forbidden, invalid, people } from "../../../../runtime/mod.js";
15
+ import { defineAction, forbidden, inPerson, invalid, } from "../../../../runtime/mod.js";
16
16
  import { mustKnow, unseat } from "../shared/agents.js";
17
17
  import { keepsAManager } from "../shared/managers.js";
18
18
  import { joinable } from "../shared/personal.js";
@@ -65,7 +65,7 @@ export const setMemberAction = defineAction({
65
65
  required: ["space", "member", "role"],
66
66
  additionalProperties: false,
67
67
  },
68
- allow: people,
68
+ allow: inPerson,
69
69
  run: async (ctx, input) => {
70
70
  if (input.space === ORG)
71
71
  throw forbidden("Org roles change with org.role.");
@@ -105,7 +105,7 @@ export const removeMemberAction = defineAction({
105
105
  required: ["space", "member"],
106
106
  additionalProperties: false,
107
107
  },
108
- allow: people,
108
+ allow: inPerson,
109
109
  run: async (ctx, input) => {
110
110
  if (input.space === ORG)
111
111
  throw forbidden("People leave the org with org.remove.");
@@ -7,7 +7,7 @@
7
7
  * only they managed to someone who stays; their Personal space stays, where
8
8
  * the org's admins still reach it.
9
9
  */
10
- import { defineAction, forbidden, invalid, people } from "../../../../runtime/mod.js";
10
+ import { defineAction, forbidden, inPerson, invalid, people, } from "../../../../runtime/mod.js";
11
11
  import { ORG, ORG_ROLES, orgRoleOf, rolesOf, runsOrg } from "../shared/reach.js";
12
12
  import { keepProfileOf } from "../shared/profile.js";
13
13
  const role = { type: "string", enum: [...ORG_ROLES] };
@@ -59,7 +59,7 @@ export const orgRoleAction = defineAction({
59
59
  required: ["person", "role"],
60
60
  additionalProperties: false,
61
61
  },
62
- allow: people,
62
+ allow: inPerson,
63
63
  run: async (ctx, input) => {
64
64
  const mine = await runs(ctx);
65
65
  const theirs = await orgRoleOf({ kind: "person", id: input.person }, ctx.as());
@@ -82,7 +82,7 @@ export const removeFromOrgAction = defineAction({
82
82
  required: ["person"],
83
83
  additionalProperties: false,
84
84
  },
85
- allow: people,
85
+ allow: inPerson,
86
86
  run: async (ctx, input) => {
87
87
  const mine = await runs(ctx);
88
88
  const theirs = await orgRoleOf({ kind: "person", id: input.person }, ctx.as());
@@ -161,7 +161,7 @@ export const inviteToOrgAction = defineAction({
161
161
  required: ["email"],
162
162
  additionalProperties: false,
163
163
  },
164
- allow: people,
164
+ allow: inPerson,
165
165
  run: async (ctx, input) => {
166
166
  const mine = await runs(ctx);
167
167
  void mine;
@@ -193,7 +193,7 @@ export const uninviteAction = defineAction({
193
193
  required: ["email"],
194
194
  additionalProperties: false,
195
195
  },
196
- allow: people,
196
+ allow: inPerson,
197
197
  run: async (ctx, input) => {
198
198
  await runs(ctx);
199
199
  await directoryOf(ctx).cancel(input.email.toLowerCase());
@@ -250,7 +250,7 @@ export const renameOrgAction = defineAction({
250
250
  required: ["name"],
251
251
  additionalProperties: false,
252
252
  },
253
- allow: people,
253
+ allow: inPerson,
254
254
  run: async (ctx, input) => {
255
255
  const mine = await standing(ctx);
256
256
  if (mine !== "owner" && mine !== "staff")