copilotz 1.0.0-rc.6 → 1.0.0-rc.8
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 +112 -0
- package/README.md +2 -2
- package/hosts/web/toolkit/time.js +2 -1
- package/package.json +1 -1
- package/plugins/access/accounts/collections/account.d.ts +1 -1
- package/plugins/access/directory/collections/org.d.ts +3 -3
- package/plugins/access/spaces/actions/invitation.js +4 -1
- package/plugins/access/spaces/actions/org.js +5 -2
- package/plugins/access/spaces/actions/personal.js +3 -0
- package/plugins/access/spaces/collections/profile.d.ts +61 -0
- package/plugins/access/spaces/collections/profile.js +41 -0
- package/plugins/access/spaces/contract.d.ts +6 -2
- package/plugins/access/spaces/contract.js +1 -0
- package/plugins/access/spaces/mod.d.ts +5 -0
- package/plugins/access/spaces/mod.js +13 -2
- package/plugins/access/spaces/processors/profile.d.ts +7 -0
- package/plugins/access/spaces/processors/profile.js +10 -0
- package/plugins/access/spaces/resources/commands.js +14 -4
- package/plugins/access/spaces/resources/tools.js +3 -1
- package/plugins/access/spaces/shared/labels.js +23 -3
- package/plugins/access/spaces/shared/names.d.ts +61 -0
- package/plugins/access/spaces/shared/names.js +77 -0
- package/plugins/access/spaces/shared/profile.d.ts +21 -0
- package/plugins/access/spaces/shared/profile.js +27 -0
- package/plugins/access/spaces/views/elsewhere.js +7 -3
- package/plugins/access/spaces/views/web/header.d.ts +3 -1
- package/plugins/access/spaces/views/web/header.js +5 -5
- package/plugins/access/spaces/views/web/invitation.d.ts +3 -1
- package/plugins/access/spaces/views/web/invitation.js +2 -2
- package/plugins/access/spaces/views/web/invitations.js +3 -1
- package/plugins/access/spaces/views/web/invited.js +3 -1
- package/plugins/access/spaces/views/web/inviting.js +5 -3
- package/plugins/access/spaces/views/web/members.js +25 -15
- package/plugins/access/spaces/views/web/org-members.d.ts +1 -1
- package/plugins/access/spaces/views/web/org-members.js +8 -7
- package/plugins/access/spaces/views/web/palette.js +8 -3
- package/plugins/access/spaces/views/web/panel.js +5 -4
- package/plugins/access/spaces/views/web/pending.d.ts +3 -1
- package/plugins/access/spaces/views/web/pending.js +5 -5
- package/plugins/access/spaces/views/web/space.js +9 -3
- package/plugins/access/spaces/views/web/spaces.js +3 -2
- package/plugins/access/spaces/views/web/tree.d.ts +3 -1
- package/plugins/access/spaces/views/web/tree.js +10 -9
- package/plugins/access/spaces/views/web/who.d.ts +14 -5
- package/plugins/access/spaces/views/web/who.js +25 -10
- package/plugins/access/spaces/views/where.js +9 -3
- package/plugins/agents/chat/collections/message.d.ts +45 -0
- package/plugins/agents/chat/collections/message.js +14 -0
- package/plugins/agents/chat/processors/turn.js +8 -2
- package/plugins/agents/chat/shared/delivery.d.ts +2 -1
- package/plugins/agents/chat/shared/delivery.js +2 -0
- package/plugins/agents/chat/shared/types.d.ts +13 -2
- package/plugins/agents/chat/views/message.d.ts +4 -1
- package/plugins/agents/chat/views/message.js +17 -4
- package/plugins/agents/chat/views/participants.js +7 -1
- package/plugins/agents/chat/views/prompt.d.ts +3 -1
- package/plugins/agents/chat/views/prompt.js +12 -4
- package/plugins/agents/chat/views/terminal/agent-prompt.js +2 -2
- package/plugins/agents/chat/views/terminal/author.js +5 -1
- package/plugins/agents/chat/views/web/conversation.js +10 -2
- package/plugins/agents/chat/views/web/message.d.ts +1 -1
- package/plugins/agents/chat/views/web/message.js +4 -2
- package/plugins/agents/history/collections/outline.d.ts +15 -0
- package/plugins/agents/history/collections/outline.js +2 -0
- package/plugins/agents/history/collections/summary.d.ts +1 -1
- package/plugins/agents/history/mod.d.ts +8 -6
- package/plugins/agents/history/mod.js +8 -6
- package/plugins/agents/history/processors/compact.d.ts +1 -1
- package/plugins/agents/history/processors/compact.js +53 -28
- package/plugins/agents/history/resources/tools.js +4 -1
- package/plugins/agents/history/shared/lines.d.ts +5 -2
- package/plugins/agents/history/shared/lines.js +9 -2
- package/plugins/agents/history/views/history.js +5 -1
- package/plugins/agents/memory/collections/memory.js +15 -4
- package/plugins/agents/memory/processors/extract.js +7 -3
- package/plugins/agents/memory/resources/context.d.ts +9 -1
- package/plugins/agents/memory/resources/context.js +7 -1
- package/plugins/agents/memory/resources/tools.js +11 -8
- package/plugins/agents/memory/shared/scope.d.ts +12 -3
- package/plugins/agents/memory/shared/scope.js +25 -6
- package/plugins/agents/memory/shared/search.d.ts +3 -1
- package/plugins/agents/memory/shared/search.js +10 -2
- package/plugins/agents/memory/views/context.d.ts +4 -1
- package/plugins/agents/memory/views/context.js +27 -11
- package/plugins/agents/memory/views/memory.d.ts +1 -0
- package/plugins/agents/memory/views/memory.js +4 -2
- package/plugins/agents/memory/views/terminal/memory.d.ts +4 -1
- package/plugins/agents/memory/views/terminal/memory.js +7 -2
- package/plugins/agents/memory/views/web/card.d.ts +4 -2
- package/plugins/agents/memory/views/web/card.js +4 -3
- package/plugins/agents/memory/views/web/list.d.ts +3 -1
- package/plugins/agents/memory/views/web/list.js +20 -9
- package/plugins/agents/memory/views/web/memories.js +5 -1
- package/plugins/agents/memory/views/web/pick.js +8 -5
- package/plugins/agents/routines/resources/tools.js +8 -5
- package/plugins/agents/routines/shared/fire.js +3 -1
- package/plugins/agents/routines/shared/routines.js +3 -1
- package/plugins/agents/routines/views/web/page.js +7 -4
- package/plugins/agents/routines/views/web/step.js +3 -1
- package/plugins/agents/skills/views/web/page.js +7 -3
- package/plugins/billing/usage/collections/rollup.d.ts +1 -1
- package/plugins/billing/usage/views/web/org.js +5 -4
- package/plugins/compute/apps/actions/build.js +7 -1
- package/plugins/compute/apps/actions/configure.d.ts +1 -0
- package/plugins/compute/apps/actions/configure.js +74 -0
- package/plugins/compute/apps/actions/publish.js +3 -1
- package/plugins/compute/apps/actions/remove.js +3 -1
- package/plugins/compute/apps/adapters/cloudrun.d.ts +5 -5
- package/plugins/compute/apps/adapters/cloudrun.js +28 -16
- package/plugins/compute/apps/adapters/front.d.ts +24 -0
- package/plugins/compute/apps/adapters/front.js +131 -0
- package/plugins/compute/apps/collections/app.d.ts +8 -1
- package/plugins/compute/apps/collections/app.js +2 -0
- package/plugins/compute/apps/contract.d.ts +4 -2
- package/plugins/compute/apps/mod.js +2 -0
- package/plugins/compute/apps/resources/tools.js +21 -4
- package/plugins/compute/apps/shared/environment.d.ts +8 -0
- package/plugins/compute/apps/shared/environment.js +15 -0
- package/plugins/compute/apps/shared/publish.d.ts +2 -0
- package/plugins/compute/apps/shared/publish.js +3 -0
- package/plugins/compute/apps/views/web/env.d.ts +54 -0
- package/plugins/compute/apps/views/web/env.js +195 -0
- package/plugins/compute/apps/views/web/space.d.ts +5 -4
- package/plugins/compute/apps/views/web/space.js +22 -10
- package/plugins/compute/apps/views/web/style.d.ts +4 -3
- package/plugins/compute/apps/views/web/style.js +55 -2
- package/plugins/compute/apps/web.d.ts +3 -2
- package/plugins/compute/apps/web.js +6 -2
- package/plugins/compute/cloud/collections/cloud-computer.d.ts +1 -1
- package/plugins/compute/computers/actions/allowed.js +3 -1
- package/plugins/compute/computers/actions/env.d.ts +3 -0
- package/plugins/compute/computers/actions/env.js +134 -0
- package/plugins/compute/computers/actions/preview.js +35 -12
- package/plugins/compute/computers/actions/provision.js +3 -1
- package/plugins/compute/computers/actions/scope.js +27 -11
- package/plugins/compute/computers/actions/work.js +6 -0
- package/plugins/compute/computers/collections/computer.d.ts +1 -1
- package/plugins/compute/computers/collections/env-var.d.ts +122 -0
- package/plugins/compute/computers/collections/env-var.js +51 -0
- package/plugins/compute/computers/collections/preview.d.ts +1 -1
- package/plugins/compute/computers/contract.d.ts +14 -3
- package/plugins/compute/computers/contract.js +4 -3
- package/plugins/compute/computers/mod.d.ts +4 -1
- package/plugins/compute/computers/mod.js +11 -3
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/resources/commands.js +15 -8
- package/plugins/compute/computers/resources/downloads.js +1 -1
- package/plugins/compute/computers/resources/tools.d.ts +11 -5
- package/plugins/compute/computers/resources/tools.js +62 -16
- package/plugins/compute/computers/shared/ask.js +7 -3
- package/plugins/compute/computers/shared/asks.d.ts +2 -2
- package/plugins/compute/computers/shared/asks.js +3 -2
- package/plugins/compute/computers/shared/env.d.ts +20 -0
- package/plugins/compute/computers/shared/env.js +50 -0
- package/plugins/compute/computers/shared/jobs.d.ts +13 -0
- package/plugins/compute/computers/shared/jobs.js +16 -0
- package/plugins/compute/computers/shared/seal.d.ts +4 -0
- package/plugins/compute/computers/shared/seal.js +60 -0
- package/plugins/compute/computers/shared/settings.d.ts +5 -1
- package/plugins/compute/computers/shared/settings.js +1 -0
- package/plugins/compute/computers/shared/wake.d.ts +4 -4
- package/plugins/compute/computers/shared/wake.js +12 -10
- package/plugins/compute/computers/shared/where.d.ts +28 -7
- package/plugins/compute/computers/shared/where.js +76 -10
- package/plugins/compute/computers/shared/workloads.d.ts +4 -0
- package/plugins/compute/computers/views/context.d.ts +6 -3
- package/plugins/compute/computers/views/context.js +74 -6
- package/plugins/compute/computers/views/terminal/approvals.js +3 -1
- package/plugins/compute/computers/views/web/calls.js +2 -1
- package/plugins/compute/computers/views/web/computer.js +9 -1
- package/plugins/compute/computers/views/web/desks.d.ts +6 -3
- package/plugins/compute/computers/views/web/desks.js +21 -14
- package/plugins/compute/computers/views/web/env.d.ts +32 -0
- package/plugins/compute/computers/views/web/env.js +154 -0
- package/plugins/compute/computers/views/web/environment.d.ts +23 -0
- package/plugins/compute/computers/views/web/environment.js +47 -0
- package/plugins/compute/computers/views/web/jobs.d.ts +7 -4
- package/plugins/compute/computers/views/web/jobs.js +28 -13
- package/plugins/compute/computers/views/web/kinds.d.ts +11 -1
- package/plugins/compute/computers/views/web/kinds.js +1 -0
- package/plugins/compute/computers/views/web/names.d.ts +3 -2
- package/plugins/compute/computers/views/web/names.js +5 -3
- package/plugins/compute/computers/views/web/page.d.ts +3 -1
- package/plugins/compute/computers/views/web/page.js +2 -2
- package/plugins/compute/computers/views/web/serve.d.ts +3 -1
- package/plugins/compute/computers/views/web/serve.js +4 -4
- package/plugins/compute/computers/views/web/space-tab.d.ts +1 -1
- package/plugins/compute/computers/views/web/space-tab.js +13 -6
- package/plugins/compute/computers/views/web/step.js +7 -1
- package/plugins/compute/computers/views/web/style.d.ts +1 -1
- package/plugins/compute/computers/views/web/style.js +54 -0
- package/plugins/compute/computers/views/web/workspace.d.ts +4 -2
- package/plugins/compute/computers/views/web/workspace.js +2 -2
- package/plugins/compute/computers/web.d.ts +6 -4
- package/plugins/compute/computers/web.js +9 -4
- package/plugins/interfaces/whatsapp/collections/phone.d.ts +1 -1
- package/plugins/models/adapters/llm/openai.js +57 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
+
## 1.0.0-rc.8 — 2026-10-31
|
|
2
|
+
|
|
3
|
+
- **Agents' prompts only grow, so the prompt cache keeps them whole.** A turn context (the
|
|
4
|
+
computers', the spaces elsewhere, memories, an app's) is sent after the conversation only when it
|
|
5
|
+
says something new: when its text isn't what the agent was last told there. The turn's first
|
|
6
|
+
message keeps what it was told (`told`, `[{ name, text }]`, a private field: people's reads come
|
|
7
|
+
without it), and later turns are sent it there. So each model call starts with the whole call
|
|
8
|
+
before it, tool steps and earlier contexts included, where before a turn's context, dropped the
|
|
9
|
+
next turn, cut the cached prefix at the turn's start. `Prompt.turn` is now `{ name, text }[]`:
|
|
10
|
+
what's new this turn.
|
|
11
|
+
- **OpenAI's newer models keep the prefix where told.** Since GPT-5.6, OpenAI caches only at
|
|
12
|
+
breakpoints: its implicit one falls at the end of the latest user message, the turn's context,
|
|
13
|
+
which the next turn didn't send, so a conversation reused only its system text. The Responses
|
|
14
|
+
adapter now marks a message with `cache` (the end of the history) with an explicit
|
|
15
|
+
`prompt_cache_breakpoint`, on the user's or tool's input at or before it. A model that refuses
|
|
16
|
+
breakpoints (earlier ones, other servers) is asked again without, and never again. What OpenAI
|
|
17
|
+
wrote to the cache is metered as `cacheWrite` (billed at a premium by models that report it).
|
|
18
|
+
- **Memory: the system text says how to remember; what's remembered is told.** The `memory` context
|
|
19
|
+
(system) is the guide alone, the same in every conversation, so the system text is cached across
|
|
20
|
+
all of an agent's conversations in a space. Core memories about who's here are the new
|
|
21
|
+
`remembered` turn context: those learned before the conversation began, told at its start and kept
|
|
22
|
+
there. Core memories learned since come up in `recall` when relevant (query `relevant` takes
|
|
23
|
+
`since`; `core` takes `before`), so a memory learned mid-conversation never rewrites its prompt.
|
|
24
|
+
- **History summarizes a message when it leaves the tail**, not when it comes: only then is its line
|
|
25
|
+
read (in the outline, or by `zoom`). A conversation that stays within the tail never calls the
|
|
26
|
+
summarizer; a longer one builds the same tree, in batches, as its tail shrinks. The outline keeps
|
|
27
|
+
the tail's message ids (`tailIds`); threads summarized before keep the lines they have.
|
|
28
|
+
- Measured on Compass's own plugins with real OpenAI calls (gpt-6.1-sol; a 12-turn conversation,
|
|
29
|
+
then a 4-turn one with tool steps, the same agent in the same space): the agent's calls read 95.5%
|
|
30
|
+
of their input from the prompt cache, up from 59.3%, and every model call in the run (memory
|
|
31
|
+
extraction included) 92.4%, up from 44.4%, with no summarizer call (101 before). A 24-turn
|
|
32
|
+
conversation that outgrew its tail: 92.4% for the agent, its one miss when the outline arrives
|
|
33
|
+
(the prompt is new from there).
|
|
34
|
+
|
|
35
|
+
## 1.0.0-rc.7 — 2026-10-30
|
|
36
|
+
|
|
37
|
+
- **Agents choose among a space's computers.** Every computer tool (the terminal, jobs, files, the
|
|
38
|
+
browser, web search, `preview`, and the apps' `publish`) takes `computer`: one of the space's
|
|
39
|
+
computers by its name (any case, or part of it when only one has it) or its id; the space's
|
|
40
|
+
default otherwise. An unknown or ambiguous name, or a computer that's offline, is told with the
|
|
41
|
+
ones to choose from; naming a cloud computer that's asleep wakes it. Each turn, an agent's context
|
|
42
|
+
lists the space's computers (whose, a cloud computer or a machine, how it is now, its system, what
|
|
43
|
+
it asks first, the default marked) when there are several; one stays as it was. In a space with
|
|
44
|
+
several, an answer says the computer it came from (`computer`), and the web's tool steps show it.
|
|
45
|
+
- **A job is found on whichever computer runs it:** `computer.preview` and `computer.scope` (and so
|
|
46
|
+
`app.publish` and the agents' `preview` and `publish`) take a job without a computer and look for
|
|
47
|
+
it on the space's computers that are online, the default first. `computer.preview`,
|
|
48
|
+
`computer.scope`, `computer.allowed` and `app.publish` take `computer` (a name or an id).
|
|
49
|
+
- **The default computer** is named so on the web (a "Default" badge, "Make it the default") and in
|
|
50
|
+
`/computers`.
|
|
51
|
+
- **Apps: what serves a preview serves the app.** A folder with no Dockerfile is built into an image
|
|
52
|
+
made for it (no more buildpacks, which found nothing to build in a plain folder): the computer's
|
|
53
|
+
system (Debian 12) with Node.js 24 and Python, the folder as it was sent, its dependencies
|
|
54
|
+
installed again (npm, pnpm, yarn; `requirements.txt`) and its `build` script run, then its job's
|
|
55
|
+
command behind a front that passes the platform's port on to the job's port on localhost,
|
|
56
|
+
WebSockets included. A job bound to `127.0.0.1` (as previews allow) is served all the same; the
|
|
57
|
+
job is given its own port as `PORT`. `AppHost.build` answers the port its image serves on. Without
|
|
58
|
+
a Dockerfile, an app is published from its job (its command).
|
|
59
|
+
- **A space's environment: variables and secrets.** Each space has its own (collection `envVar`,
|
|
60
|
+
`{ name, value, secret, computers, by, at }`, names like `API_URL`). Its managers change it
|
|
61
|
+
(`env.set` `{ in, name, value?, secret?, computers? }`, `env.unset`); its members read names and
|
|
62
|
+
the values of variables. A secret is sealed at rest (AES-GCM, with the new `computers: { key }`
|
|
63
|
+
resource, else kept as given) and never read back by anyone: people see only that it's there (and
|
|
64
|
+
a long one's last 4 characters), agents only its name. Every job and shell started in the space,
|
|
65
|
+
from the web or by an agent, gets the variables with `computers` (true unless said), under its own
|
|
66
|
+
`env` (`jobs.start` and `terminal` take `env`; the `start_job` tool too); a job kept running keeps
|
|
67
|
+
its env on the computer's disk and starts again with it. A secret given to computers can be read
|
|
68
|
+
by any process there, and the web says so where it's given. Agents' computer context lists the
|
|
69
|
+
names they have (`$NAME`), never a value.
|
|
70
|
+
- **Apps get the space's environment.** An app is deployed with all of its space's variables and
|
|
71
|
+
secrets, and its own over them (`envVar` with `app`; queries `here` and `apps`), passed to Cloud
|
|
72
|
+
Run as its env. `app.configure` `{ app, env? }` (its publisher, or the space's managers) changes
|
|
73
|
+
its own and deploys its image again with them, without a build (the port the image serves is kept
|
|
74
|
+
as `served`). A change to the space's environment doesn't redeploy anything: it reaches an app
|
|
75
|
+
when it's published again, or at once with "Apply to apps". Taking an app down removes its own
|
|
76
|
+
environment (`env.unset` `{ in, app }`).
|
|
77
|
+
- **Web: Environment.** A space's Environment tab lists its variables (a secret masked, whether its
|
|
78
|
+
computers get it, who set it and when); its managers add, change and remove them, with the honest
|
|
79
|
+
limit shown beside a secret given to computers. Under it, its live apps and "Apply to apps"
|
|
80
|
+
(through computers' new `envActions` resource). An app's row opens its environment: the space's
|
|
81
|
+
shown, its own edited, saved with a redeploy. The job start form takes its own environment
|
|
82
|
+
(`NAME=value` lines). The toolkit's `Time` also draws on a server.
|
|
83
|
+
- **People by name, everywhere:** agents' prompts, notes, the terminal and the web show a person's
|
|
84
|
+
name where they showed their id (`google:1139…`). The spaces plugin keeps each person's profile
|
|
85
|
+
(collection `profile`: their name as sign-in verified it, else their email's name, and picture;
|
|
86
|
+
never their email), from the identity plugin's `person` as it changes, at `org.join`, and on
|
|
87
|
+
`space.personal` (each page load), so people known before it get one the next time they come.
|
|
88
|
+
Anyone in the org reads names through the query `profile.names` `{ ids }` (a browser reads
|
|
89
|
+
profiles only through it); two people of one name stay apart ("Ana (2762)"). The new `names`
|
|
90
|
+
resource says where names are (`{ collection: "profile" }`), and the spaces contract (and
|
|
91
|
+
`copilotz/plugins/access`) gives `nameOf`, `namesOf`, `namesIn` (Views), `namesFor` (Actions,
|
|
92
|
+
Processors, tools), `withNames`, `idsIn` and `PROFILE`. A sign-in's id is never shown as a name:
|
|
93
|
+
without a profile, it's "someone".
|
|
94
|
+
- **Agents' prompts:** others' messages read "Ana Lima: …", "People here:" names people, a
|
|
95
|
+
conversation's space is "Ana Lima's Personal space", the computers context says whose computer it
|
|
96
|
+
is and who says yes by name, as do waiting asks, routines (who made one, whom it runs as), history
|
|
97
|
+
summaries and zoom, and recall. Memory extraction writes names, and `remember`'s `about` takes a
|
|
98
|
+
person by name.
|
|
99
|
+
- **Notes and summaries written before names:** a memory or a summary that says someone's id
|
|
100
|
+
(`google:1139…'s cloud computer…`) reads with their name wherever it shows (prompts, recall, the
|
|
101
|
+
Memories page, the terminal), substituted when it's shown: nothing stored is changed, and nothing
|
|
102
|
+
needs migrating.
|
|
103
|
+
- **The web:** the Members tab (people, requests to join, invitations), the space header's faces,
|
|
104
|
+
other people's Personal spaces ("Ana Lima's Personal"), invitations ("Ana Lima invited you"), chat
|
|
105
|
+
messages and the conversation's people, memories (grouped, by whom, search), routines, skills
|
|
106
|
+
("Made by"), apps ("by"), computers (whose each is, who asks first, who started a job or made a
|
|
107
|
+
preview), usage and the org's people show names. **The terminal:** `/computers`, `/approvals`,
|
|
108
|
+
`/requests`, `/grant`, `/invitations`, memories and messages, likewise; `/remove` takes a person's
|
|
109
|
+
id with a colon (`google:1139…`).
|
|
110
|
+
- **Share refusals** name the spaces a write would reveal ("Ana Lima's Personal space"), not their
|
|
111
|
+
ids. An org invitation made by a space invitation says who invited them.
|
|
112
|
+
|
|
1
113
|
## 1.0.0-rc.6 — 2026-10-30
|
|
2
114
|
|
|
3
115
|
- **Computer program:** an app on another machine over plain `ws:` (an `http://` address that isn't
|
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.8"`), and
|
|
26
26
|
the imports below are the same everywhere. Some pieces need a package of their own, installed beside
|
|
27
27
|
it: `esbuild` to bundle the web host on Node, `@electric-sql/pglite` for PostgreSQL in the process,
|
|
28
28
|
and `@types/react` for the front ends' types.
|
|
@@ -204,7 +204,7 @@ and an app serves it from there by default:
|
|
|
204
204
|
import { computerDownloads } from "copilotz/plugins/compute/downloads";
|
|
205
205
|
|
|
206
206
|
plugins: [...plugins, await computerDownloads()], // this Copilotz's release
|
|
207
|
-
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.
|
|
207
|
+
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.8" })], // its own: /computer/download/
|
|
208
208
|
plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
|
|
209
209
|
```
|
|
210
210
|
|
|
@@ -29,7 +29,8 @@ const subscribe = (listener) => {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
export function Time({ at, long, className }) {
|
|
32
|
-
|
|
32
|
+
// Drawn on a server too (the time as it is then).
|
|
33
|
+
useSyncExternalStore(subscribe, () => tick, () => tick);
|
|
33
34
|
const date = new Date(at);
|
|
34
35
|
if (Number.isNaN(date.getTime()))
|
|
35
36
|
return null;
|
package/package.json
CHANGED
|
@@ -93,8 +93,8 @@ export declare const account: {
|
|
|
93
93
|
private?: string[];
|
|
94
94
|
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
95
95
|
[x: string]: unknown;
|
|
96
|
-
problem?: string | undefined;
|
|
97
96
|
rev?: number | undefined;
|
|
97
|
+
problem?: string | undefined;
|
|
98
98
|
expires?: string | undefined;
|
|
99
99
|
plan?: string | undefined;
|
|
100
100
|
refreshed?: string | undefined;
|
|
@@ -114,16 +114,16 @@ export declare const org: {
|
|
|
114
114
|
private?: string[];
|
|
115
115
|
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
116
116
|
[x: string]: unknown;
|
|
117
|
+
suspended?: boolean | undefined;
|
|
117
118
|
summary?: {
|
|
118
119
|
[x: string]: unknown;
|
|
119
120
|
at?: string | undefined;
|
|
120
|
-
people?: number | undefined;
|
|
121
121
|
spaces?: number | undefined;
|
|
122
122
|
active?: string | undefined;
|
|
123
|
+
people?: number | undefined;
|
|
123
124
|
} | undefined;
|
|
124
|
-
suspended?: boolean | undefined;
|
|
125
125
|
at: string;
|
|
126
|
-
kind: "
|
|
126
|
+
kind: "personal" | "team";
|
|
127
127
|
by: string;
|
|
128
128
|
name: string;
|
|
129
129
|
placement: {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { defineAction } from "../../../../runtime/mod.js";
|
|
9
9
|
import { joinable } from "../shared/personal.js";
|
|
10
10
|
import { memberKey, orgRoleOf, reachOf, ROLES } from "../shared/reach.js";
|
|
11
|
+
import { namesFor } from "../shared/names.js";
|
|
11
12
|
/** An email address, as invitations hold it. */
|
|
12
13
|
const EMAIL = /^[^\s@]+@[^\s@]+$/;
|
|
13
14
|
const refused = (code, message) => Object.assign(new Error(message), { code });
|
|
@@ -79,7 +80,9 @@ async function joinsTheOrg(ctx, email) {
|
|
|
79
80
|
return;
|
|
80
81
|
if ((await directory.invites()).some((waiting) => waiting.email === email))
|
|
81
82
|
return;
|
|
82
|
-
|
|
83
|
+
// Who invited them, by name: what the org's invitation says.
|
|
84
|
+
const [from] = Object.values(await namesFor(ctx, [ctx.actor.id]));
|
|
85
|
+
await directory.invite({ email, role: "guest", by: ctx.actor.id, ...(from ? { from } : {}) });
|
|
83
86
|
}
|
|
84
87
|
export const acceptInvitationAction = defineAction({
|
|
85
88
|
description: "Joins the space an invitation to your email is for",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { defineAction } from "../../../../runtime/mod.js";
|
|
11
11
|
import { ORG, ORG_ROLES, orgRoleOf } from "../shared/reach.js";
|
|
12
12
|
import { ROLES } from "../shared/reach.js";
|
|
13
|
+
import { keepProfileOf } from "../shared/profile.js";
|
|
13
14
|
const forbidden = (message) => Object.assign(new Error(message), { code: "forbidden" });
|
|
14
15
|
const invalid = (message) => Object.assign(new Error(message), { code: "invalid" });
|
|
15
16
|
const role = { type: "string", enum: [...ORG_ROLES] };
|
|
@@ -45,6 +46,8 @@ export const joinOrgAction = defineAction({
|
|
|
45
46
|
run: async (ctx, input) => {
|
|
46
47
|
const held = await orgRoleOf({ kind: "person", id: input.person }, ctx.as());
|
|
47
48
|
// The role given is for joining: coming back keeps the role they have (`org.role` changes it).
|
|
49
|
+
// How they show, kept (people from before profiles, too).
|
|
50
|
+
await keepProfileOf(ctx, input.person);
|
|
48
51
|
if (held)
|
|
49
52
|
return { role: held };
|
|
50
53
|
await join(ctx, input.person, input.role ?? "member");
|
|
@@ -64,7 +67,7 @@ export const orgRoleAction = defineAction({
|
|
|
64
67
|
const mine = await runs(ctx);
|
|
65
68
|
const theirs = await orgRoleOf({ kind: "person", id: input.person }, ctx.as());
|
|
66
69
|
if (!theirs)
|
|
67
|
-
throw invalid(
|
|
70
|
+
throw invalid("They aren't in this org.");
|
|
68
71
|
if ((input.role === "owner" || theirs === "owner") && mine !== "owner" && mine !== "staff") {
|
|
69
72
|
throw forbidden("Only owners make or unmake owners.");
|
|
70
73
|
}
|
|
@@ -87,7 +90,7 @@ export const removeFromOrgAction = defineAction({
|
|
|
87
90
|
const mine = await runs(ctx);
|
|
88
91
|
const theirs = await orgRoleOf({ kind: "person", id: input.person }, ctx.as());
|
|
89
92
|
if (!theirs)
|
|
90
|
-
throw invalid(
|
|
93
|
+
throw invalid("They aren't in this org.");
|
|
91
94
|
if (theirs === "owner" && mine !== "owner" && mine !== "staff") {
|
|
92
95
|
throw forbidden("Only owners take an owner out.");
|
|
93
96
|
}
|
|
@@ -3,6 +3,7 @@ import { defineAction } from "../../../../runtime/mod.js";
|
|
|
3
3
|
import { PERSONAL } from "../shared/personal.js";
|
|
4
4
|
import { seat } from "../shared/agents.js";
|
|
5
5
|
import { memberKey } from "../shared/reach.js";
|
|
6
|
+
import { keepProfileOf } from "../shared/profile.js";
|
|
6
7
|
export const personalAction = defineAction({
|
|
7
8
|
description: "Your Personal space, where what you make alone lives",
|
|
8
9
|
input: { type: "object", additionalProperties: false },
|
|
@@ -29,6 +30,8 @@ export const personalAction = defineAction({
|
|
|
29
30
|
});
|
|
30
31
|
});
|
|
31
32
|
}
|
|
33
|
+
// Pages ask this as they open: how they show is kept (from before profiles, too).
|
|
34
|
+
await keepProfileOf(ctx, ctx.actor.id);
|
|
32
35
|
return { space: id };
|
|
33
36
|
},
|
|
34
37
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How people show, to everyone in the org (people and agents alike): their
|
|
3
|
+
* name, and picture (collection `profile`, its `_id` the person's id). Kept
|
|
4
|
+
* from what sign-in verified (the identity plugin's `person`, whose emails
|
|
5
|
+
* stay their own): a person's id is what everything they do records, and
|
|
6
|
+
* this is what's shown in its place, in pages and in agents' prompts. Only
|
|
7
|
+
* the system writes it.
|
|
8
|
+
*/
|
|
9
|
+
import { type Infer } from "../../../../runtime/mod.js";
|
|
10
|
+
declare const profileSchema: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly properties: {
|
|
13
|
+
/** Their name as they signed in; else their email's name (before the `@`). */
|
|
14
|
+
readonly name: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
};
|
|
17
|
+
readonly picture: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
};
|
|
20
|
+
readonly at: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly required: readonly ["at"];
|
|
25
|
+
};
|
|
26
|
+
export declare const profile: {
|
|
27
|
+
schema: {
|
|
28
|
+
readonly type: "object";
|
|
29
|
+
readonly properties: {
|
|
30
|
+
/** Their name as they signed in; else their email's name (before the `@`). */
|
|
31
|
+
readonly name: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
};
|
|
34
|
+
readonly picture: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
};
|
|
37
|
+
readonly at: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly required: readonly ["at"];
|
|
42
|
+
};
|
|
43
|
+
events?: boolean;
|
|
44
|
+
records?: boolean;
|
|
45
|
+
durable?: false;
|
|
46
|
+
indexes?: string[][];
|
|
47
|
+
private?: string[];
|
|
48
|
+
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
49
|
+
[x: string]: unknown;
|
|
50
|
+
name?: string | undefined;
|
|
51
|
+
picture?: string | undefined;
|
|
52
|
+
at: string;
|
|
53
|
+
} & {
|
|
54
|
+
_id: string;
|
|
55
|
+
}>> | undefined;
|
|
56
|
+
vectors?: string[];
|
|
57
|
+
};
|
|
58
|
+
export type Profile = Infer<typeof profileSchema> & {
|
|
59
|
+
_id: string;
|
|
60
|
+
};
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How people show, to everyone in the org (people and agents alike): their
|
|
3
|
+
* name, and picture (collection `profile`, its `_id` the person's id). Kept
|
|
4
|
+
* from what sign-in verified (the identity plugin's `person`, whose emails
|
|
5
|
+
* stay their own): a person's id is what everything they do records, and
|
|
6
|
+
* this is what's shown in its place, in pages and in agents' prompts. Only
|
|
7
|
+
* the system writes it.
|
|
8
|
+
*/
|
|
9
|
+
import { defineCollection } from "../../../../runtime/mod.js";
|
|
10
|
+
import { namesOf, peopleIn } from "../shared/names.js";
|
|
11
|
+
const profileSchema = {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
/** Their name as they signed in; else their email's name (before the `@`). */
|
|
15
|
+
name: { type: "string" },
|
|
16
|
+
picture: { type: "string" },
|
|
17
|
+
at: { type: "string" },
|
|
18
|
+
},
|
|
19
|
+
required: ["at"],
|
|
20
|
+
};
|
|
21
|
+
export const profile = defineCollection({
|
|
22
|
+
schema: profileSchema,
|
|
23
|
+
queries: {
|
|
24
|
+
/**
|
|
25
|
+
* Names by id (`{ ids }`, a member key `person:<id>` too): what shows
|
|
26
|
+
* people, wherever (Views, pages, a terminal's commands); a browser reads
|
|
27
|
+
* profiles only through it.
|
|
28
|
+
*/
|
|
29
|
+
names: {
|
|
30
|
+
allow: (actor) => actor.kind === "person" || actor.kind === "agent",
|
|
31
|
+
run: async (profiles, params) => {
|
|
32
|
+
const given = Array.isArray(params?.ids) ? params.ids : [];
|
|
33
|
+
const ids = peopleIn(given.filter((id) => typeof id === "string"))
|
|
34
|
+
.slice(0, 500);
|
|
35
|
+
if (!ids.length)
|
|
36
|
+
return {};
|
|
37
|
+
return namesOf(await profiles.find({ _id: { $in: ids } }));
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The spaces plugin's contract: what plugins built on spaces may import from
|
|
3
3
|
* it: the shapes of its documents (a space, a membership, a request to join,
|
|
4
|
-
* an invitation) and of the resource kinds its web front
|
|
4
|
+
* an invitation, a person's profile) and of the resource kinds its web front
|
|
5
|
+
* end reads, and how people show by name (`PROFILE`, `nameOf`, `namesOf`,
|
|
6
|
+
* `withNames`: wherever a person's id would show, their name does). They
|
|
5
7
|
* reach the rest by name: its collections (`space`, `member`, `request`,
|
|
6
|
-
* `invitation`), its queries `space.reached` (each space with what the asker
|
|
8
|
+
* `invitation`, `profile`), its queries `space.reached` (each space with what the asker
|
|
7
9
|
* may do there) and `invitation.mine` (those to the asker's email), and its
|
|
8
10
|
* Actions (`space.create`, `space.personal`, `space.rename`, `space.can`,
|
|
9
11
|
* `space.leave`, `space.archive`, `space.agent`, `member.set`,
|
|
@@ -43,6 +45,8 @@ export type { Member } from "./collections/member.js";
|
|
|
43
45
|
export type { Invitation } from "./collections/invitation.js";
|
|
44
46
|
export type { Request } from "./collections/request.js";
|
|
45
47
|
export type { Verb } from "./shared/reach.js";
|
|
48
|
+
export type { Profile } from "./collections/profile.js";
|
|
49
|
+
export { idsIn, nameOf, namesFor, namesIn, namesOf, type NamesResource, PROFILE, withNames, } from "./shared/names.js";
|
|
46
50
|
export { PERSONAL } from "./shared/personal.js";
|
|
47
51
|
export { AGENT_ROLES } from "./views/web/who.js";
|
|
48
52
|
/** A `spaceTabs` resource: a tab on a space's page and in its side panel. */
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
* a collection with `labels: true`), and only those who reach them all
|
|
28
28
|
* read it until someone who does `share`s it. An agent writing it
|
|
29
29
|
* anywhere else is refused (`needs_share`).
|
|
30
|
+
* - **People by name:** each person's profile (collection `profile`: their
|
|
31
|
+
* name and picture, as sign-in verified them, kept as it changes), which
|
|
32
|
+
* anyone in the org reads; wherever an id would show, the name does
|
|
33
|
+
* (`nameOf`, `withNames` in the contract).
|
|
30
34
|
* - **Where you are:** with the chat plugin, agents are told the space a
|
|
31
35
|
* conversation is in, its members and what it draws on (`where` context),
|
|
32
36
|
* and each turn, the other spaces they can read for their person
|
|
@@ -47,6 +51,7 @@ export type { Member } from "./collections/member.js";
|
|
|
47
51
|
export type { Reached, Space } from "./collections/space.js";
|
|
48
52
|
export type { SpaceInvite, SpaceSidebar, SpaceTab } from "./contract.js";
|
|
49
53
|
export type { Request } from "./collections/request.js";
|
|
54
|
+
export { idsIn, nameOf, namesFor, namesIn, namesOf, type NamesResource, PROFILE, withNames, } from "./shared/names.js";
|
|
50
55
|
export { memberKey, ORG, ORG_ROLES, type OrgRole, orgRoleOf, type Reach, reachOf, ROLES, type Verb, } from "./shared/reach.js";
|
|
51
56
|
export type { Shared } from "./shared/rules.js";
|
|
52
57
|
export declare const spaces: Plugin;
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
* a collection with `labels: true`), and only those who reach them all
|
|
28
28
|
* read it until someone who does `share`s it. An agent writing it
|
|
29
29
|
* anywhere else is refused (`needs_share`).
|
|
30
|
+
* - **People by name:** each person's profile (collection `profile`: their
|
|
31
|
+
* name and picture, as sign-in verified them, kept as it changes), which
|
|
32
|
+
* anyone in the org reads; wherever an id would show, the name does
|
|
33
|
+
* (`nameOf`, `withNames` in the contract).
|
|
30
34
|
* - **Where you are:** with the chat plugin, agents are told the space a
|
|
31
35
|
* conversation is in, its members and what it draws on (`where` context),
|
|
32
36
|
* and each turn, the other spaces they can read for their person
|
|
@@ -61,14 +65,19 @@ import { tools } from "./resources/tools.js";
|
|
|
61
65
|
import { space } from "./collections/space.js";
|
|
62
66
|
import { rules } from "./shared/rules.js";
|
|
63
67
|
import { agentGoneProcessor } from "./processors/agent-gone.js";
|
|
68
|
+
import { profileProcessor } from "./processors/profile.js";
|
|
69
|
+
import { profile } from "./collections/profile.js";
|
|
70
|
+
import { PROFILE } from "./shared/names.js";
|
|
64
71
|
import { elsewhereView } from "./views/elsewhere.js";
|
|
65
72
|
import { whereView } from "./views/where.js";
|
|
73
|
+
// People by name, wherever an id would show (see shared/names.ts).
|
|
74
|
+
export { idsIn, nameOf, namesFor, namesIn, namesOf, PROFILE, withNames, } from "./shared/names.js";
|
|
66
75
|
export { memberKey, ORG, ORG_ROLES, orgRoleOf, reachOf, ROLES, } from "./shared/reach.js";
|
|
67
76
|
export const spaces = definePlugin({
|
|
68
77
|
name: "spaces",
|
|
69
78
|
// Invitations match people by the email they signed in with.
|
|
70
79
|
requires: ["identity"],
|
|
71
|
-
collections: { space, member, request, invitation },
|
|
80
|
+
collections: { space, member, request, invitation, profile },
|
|
72
81
|
actions: {
|
|
73
82
|
"space.create": createAction,
|
|
74
83
|
"space.personal": personalAction,
|
|
@@ -110,7 +119,9 @@ export const spaces = definePlugin({
|
|
|
110
119
|
tools,
|
|
111
120
|
// Who works in a space, for chat: its agents.
|
|
112
121
|
roster: { spaces: { action: "space.roster" } },
|
|
122
|
+
// Where people's names are, for whatever shows a person (pages, agents' prompts).
|
|
123
|
+
names: { collection: PROFILE },
|
|
113
124
|
},
|
|
114
|
-
processors: { "spaces.agentGone": agentGoneProcessor },
|
|
125
|
+
processors: { "spaces.agentGone": agentGoneProcessor, "spaces.profile": profileProcessor },
|
|
115
126
|
});
|
|
116
127
|
export default spaces;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A person's profile follows what sign-in verified about them (the identity
|
|
3
|
+
* plugin's `person`, as a sign-in or an org's door sets it): their name,
|
|
4
|
+
* their picture. In order, per person.
|
|
5
|
+
*/
|
|
6
|
+
import type { ProcessorDef } from "../../../../runtime/mod.js";
|
|
7
|
+
export declare const profileProcessor: ProcessorDef;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { keepProfile } from "../shared/profile.js";
|
|
2
|
+
export const profileProcessor = {
|
|
3
|
+
on: ["person.created", "person.updated"],
|
|
4
|
+
key: (event) => String(event.data._id),
|
|
5
|
+
run: async (ctx, event) => {
|
|
6
|
+
const doc = event.data.doc;
|
|
7
|
+
if (doc?._id)
|
|
8
|
+
await keepProfile(ctx, doc);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* Maya: what it does` makes one here, `/default maya` has it answer new chats.
|
|
9
9
|
*/
|
|
10
10
|
import { command, dim } from "../../../../hosts/terminal/mod.js";
|
|
11
|
+
import { nameOf } from "../shared/names.js";
|
|
12
|
+
/** People by name, as their profiles say. */
|
|
13
|
+
const namesOf = (term, ids) => ids.length
|
|
14
|
+
? term.runtime.query("profile.names", { ids })
|
|
15
|
+
: Promise.resolve({});
|
|
11
16
|
export const commands = {
|
|
12
17
|
"/spaces": command({
|
|
13
18
|
description: "The spaces you reach (● where you work)",
|
|
@@ -53,7 +58,8 @@ export const commands = {
|
|
|
53
58
|
await term.set({ listed: open.map((r) => r._id) });
|
|
54
59
|
if (!open.length)
|
|
55
60
|
return await term.print(dim("No requests."));
|
|
56
|
-
await term
|
|
61
|
+
const names = await namesOf(term, open.flatMap((r) => [r.member, ...(r.by ? [r.by] : [])]));
|
|
62
|
+
await term.print(open.map((r, i) => `${dim(`[${i + 1}]`)} ${nameOf(r.member, names)} → ${r.space} ${dim(`(${r.by ? nameOf(r.by, names) : "themselves"}: ${r.reason ?? "no reason given"})`)}`).join("\n") + `\n${dim("/grant <n> [role] lets them in; /deny <n> doesn't.")}`);
|
|
57
63
|
},
|
|
58
64
|
}),
|
|
59
65
|
"/grant": command({
|
|
@@ -68,7 +74,7 @@ export const commands = {
|
|
|
68
74
|
id,
|
|
69
75
|
...(role ? { role } : {}),
|
|
70
76
|
});
|
|
71
|
-
await term.print(dim(`${granted
|
|
77
|
+
await term.print(dim(`${nameOf(granted, await namesOf(term, [granted]))} is in.`));
|
|
72
78
|
},
|
|
73
79
|
}),
|
|
74
80
|
"/deny": command({
|
|
@@ -108,7 +114,10 @@ export const commands = {
|
|
|
108
114
|
const who = rest.trim();
|
|
109
115
|
if (!who || !space)
|
|
110
116
|
return await term.print(dim("Usage: /remove agent:<name>, in a space."));
|
|
111
|
-
|
|
117
|
+
// A person's own id may have a colon too (`google:1139…`).
|
|
118
|
+
const [kind, id] = who.startsWith("agent:") || who.startsWith("person:")
|
|
119
|
+
? [who.slice(0, who.indexOf(":")), who.slice(who.indexOf(":") + 1)]
|
|
120
|
+
: ["person", who];
|
|
112
121
|
await term.runtime.call("member.remove", { space, member: { kind, id } });
|
|
113
122
|
await term.print(dim(`${id} is out of this space.`));
|
|
114
123
|
},
|
|
@@ -171,7 +180,8 @@ export const commands = {
|
|
|
171
180
|
await term.set({ listed: mine.map((i) => i._id) });
|
|
172
181
|
if (!mine.length)
|
|
173
182
|
return await term.print(dim("No invitations."));
|
|
174
|
-
await term
|
|
183
|
+
const names = await namesOf(term, mine.map((i) => i.by));
|
|
184
|
+
await term.print(mine.map((i, n) => `${dim(`[${n + 1}]`)} ${i.name} ${dim(`(${i.role}, from ${nameOf(i.by, names)})`)}`).join("\n") + `\n${dim("/accept <n> joins; /decline <n> doesn't.")}`);
|
|
175
185
|
},
|
|
176
186
|
}),
|
|
177
187
|
"/accept": command({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PERSONAL } from "../shared/personal.js";
|
|
2
2
|
import { memberKey } from "../shared/reach.js";
|
|
3
|
+
import { nameOf, namesFor } from "../shared/names.js";
|
|
3
4
|
export const tools = {
|
|
4
5
|
request_access: {
|
|
5
6
|
offer: true,
|
|
@@ -31,7 +32,8 @@ export const tools = {
|
|
|
31
32
|
at: new Date().toISOString(),
|
|
32
33
|
},
|
|
33
34
|
}, { upsert: true });
|
|
34
|
-
|
|
35
|
+
const named = who.kind === "person" ? nameOf(who.id, await namesFor(ctx, [who.id])) : who.id;
|
|
36
|
+
return `Asked ${found.name}'s managers to let ${named} in. They'll decide; nothing ` +
|
|
35
37
|
"changes until they do.";
|
|
36
38
|
},
|
|
37
39
|
},
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { reachOf } from "./reach.js";
|
|
2
|
+
import { nameOf, namesOf, PROFILE } from "./names.js";
|
|
2
3
|
const sharedOf = (ctx) => (ctx.resources.shared ?? {});
|
|
3
|
-
const needsShare = (from) => Object.assign(new Error(`That would show what came from ${
|
|
4
|
+
const needsShare = (from, named) => Object.assign(new Error(`That would show what came from ${named.join(", ")} to people who can't see it: ` +
|
|
4
5
|
"a person who can has to share it."), { code: "needs_share", sources: from });
|
|
6
|
+
/** Spaces as people say them: by name; a Personal space as its owner's (by their name). */
|
|
7
|
+
async function described(ids, ctx) {
|
|
8
|
+
const spaces = await ctx.db.collection("space").find({ _id: { $in: ids } });
|
|
9
|
+
const owners = spaces.flatMap((s) => s.kind === "personal" && s.owner ? [s.owner] : []);
|
|
10
|
+
const names = owners.length
|
|
11
|
+
? namesOf(await ctx.db.collection(PROFILE).find({
|
|
12
|
+
_id: { $in: owners },
|
|
13
|
+
}))
|
|
14
|
+
: {};
|
|
15
|
+
return ids.map((id) => {
|
|
16
|
+
const space = spaces.find((s) => s._id === id);
|
|
17
|
+
if (!space)
|
|
18
|
+
return "another space";
|
|
19
|
+
return space.kind === "personal" && space.owner
|
|
20
|
+
? `${nameOf(space.owner, names)}'s Personal space`
|
|
21
|
+
: space.name;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
5
24
|
/** What a space's members all see, besides it: the spaces it draws on. */
|
|
6
25
|
const covered = async (space, ctx) => new Set([space, ...(await reachOf({ kind: "space", id: space }, ctx)).keys()]);
|
|
7
26
|
export const labels = {
|
|
@@ -26,8 +45,9 @@ export const labels = {
|
|
|
26
45
|
if (!foreign.length)
|
|
27
46
|
return doc;
|
|
28
47
|
const elsewhere = typeof actor.at === "string" && actor.at !== space;
|
|
29
|
-
if (actor.kind === "agent" && (elsewhere || !shared.labels))
|
|
30
|
-
throw needsShare(foreign);
|
|
48
|
+
if (actor.kind === "agent" && (elsewhere || !shared.labels)) {
|
|
49
|
+
throw needsShare(foreign, await described(foreign, ctx));
|
|
50
|
+
}
|
|
31
51
|
if (!shared.labels)
|
|
32
52
|
return doc;
|
|
33
53
|
const sources = [...new Set([...(doc.sources ?? []), ...foreign])].sort();
|