copilotz 1.0.0-rc.35 → 1.0.0-rc.37
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 +57 -0
- package/README.md +1 -1
- package/hosts/web/host.js +18 -17
- package/hosts/web/session.d.ts +27 -1
- package/hosts/web/session.js +34 -0
- package/package.json +1 -1
- package/plugins/access/email/shared/people.d.ts +2 -1
- package/plugins/access/email/shared/people.js +3 -2
- package/plugins/access/google/actions/sign-in.js +2 -1
- package/plugins/access/identity/actions/person.d.ts +7 -0
- package/plugins/access/identity/actions/person.js +38 -2
- package/plugins/access/identity/collections/person.d.ts +9 -0
- package/plugins/access/identity/collections/person.js +2 -0
- package/plugins/access/identity/mod.d.ts +3 -1
- package/plugins/access/identity/mod.js +5 -2
- package/plugins/access/spaces/shared/labels.d.ts +7 -0
- package/plugins/access/spaces/shared/labels.js +6 -1
- package/plugins/access/spaces/shared/reach.d.ts +8 -0
- package/plugins/access/spaces/shared/reach.js +23 -5
- package/plugins/access/spaces/views/elsewhere.d.ts +3 -2
- package/plugins/access/spaces/views/elsewhere.js +5 -3
- package/plugins/agents/chat/contract.d.ts +5 -0
- package/plugins/agents/chat/contract.js +5 -0
- package/plugins/agents/chat/mod.d.ts +4 -0
- package/plugins/agents/chat/mod.js +7 -0
- package/plugins/agents/chat/resources/tools.d.ts +3 -0
- package/plugins/agents/chat/resources/tools.js +112 -0
- package/plugins/agents/chat/shared/send.js +83 -6
- package/plugins/agents/chat/shared/where.d.ts +20 -0
- package/plugins/agents/chat/shared/where.js +18 -0
- package/plugins/agents/chat/views/web/home.js +2 -1
- package/plugins/agents/routines/resources/tools.js +37 -19
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/resources/downloads.js +1 -1
- package/plugins/interfaces/web/mod.d.ts +3 -1
- package/plugins/interfaces/web/mod.js +3 -1
- package/plugins/interfaces/web/shared/style.d.ts +3 -2
- package/plugins/interfaces/web/shared/style.js +9 -2
- package/plugins/interfaces/web/views/frame.d.ts +4 -2
- package/plugins/interfaces/web/views/frame.js +2 -2
- package/plugins/interfaces/web/views/me.d.ts +15 -7
- package/plugins/interfaces/web/views/me.js +83 -22
- package/plugins/interfaces/web/views/shell.js +2 -1
- package/plugins/interfaces/web/views/words.d.ts +1 -1
- package/plugins/interfaces/web/views/words.js +10 -1
- package/runtime/define.d.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
## 1.0.0-rc.37 — 2026-11-10
|
|
2
|
+
|
|
3
|
+
**Upgrading.** The web shell says nine new words, which an app in another language gives under
|
|
4
|
+
`shell.<key>` (its words test names any it lacks): `yourName` ("Your name"), `addYourName` ("Add
|
|
5
|
+
your name"), `nameAbout` ("How people and agents here see you."), `nameLabel` ("Name"), `nameEmpty`
|
|
6
|
+
("Leave it empty to go by your email."), `nameNotSaved` ("Your name wasn't saved. {reason}"),
|
|
7
|
+
`nameTryAgain` ("Your name wasn't saved. Try again in a moment."), `cancel` ("Cancel") and `save`
|
|
8
|
+
("Save").
|
|
9
|
+
|
|
10
|
+
- **A person names themselves** (`person.rename` `{ name }`, identity's). Only a person, for
|
|
11
|
+
themselves, in person: never a contact, a key, an agent or a routine, and there's no one else to
|
|
12
|
+
name. The name is one line (spaces, tabs and breaks in a row are one space), trimmed, 80
|
|
13
|
+
characters at most (said plainly past that); empty, it's cleared, and they have none. It's what
|
|
14
|
+
everyone sees of them: their menu, home's greeting, the people beside them in a space, agents'
|
|
15
|
+
prompts (the spaces plugin's profile follows it, else their email's name, as before).
|
|
16
|
+
- **Sign-ins keep the name a person chose,** or their having none: Google's sign-in, email's, and
|
|
17
|
+
the system's `person.set` (a directory's handoff into an org) no longer set it back. Until a
|
|
18
|
+
person chooses (their record's `named`: when they last did), sign-ins keep their name current as
|
|
19
|
+
before.
|
|
20
|
+
- **The person's menu opens with their name,** "Your name" ("Add your name" with none), in a dialog:
|
|
21
|
+
the field holds it, selected, so typing replaces it; Enter saves; a live preview shows how they'll
|
|
22
|
+
appear; while it saves the field waits; a refusal is said under it and the dialog stays. So the
|
|
23
|
+
menu is always a menu now, with or without front ends' entries.
|
|
24
|
+
- **The new name shows at once, everywhere, without reloading:** in this tab and their others. The
|
|
25
|
+
web host keeps the page's viewer as the person's own record says (it watches it: their name and
|
|
26
|
+
email), and draws again when it changes; Views read it as before (`ctx.viewer.label`).
|
|
27
|
+
- **No name, no id:** with none, the menu shows the person's email (`ctx.viewer.email`, new, from
|
|
28
|
+
identity's `/me`), and home greets them plainly ("Good morning"). An app whose ids aren't names
|
|
29
|
+
(`01JD3X…`) showed the id in both.
|
|
30
|
+
|
|
31
|
+
## 1.0.0-rc.36 — 2026-11-10
|
|
32
|
+
|
|
33
|
+
**Upgrading.** Chat has two tools of its own, `list_conversations` and `read_conversation`, for the
|
|
34
|
+
agents that list them in their `tools`. An app that made its own tools under those names drops them
|
|
35
|
+
and lists chat's, which do the same and take a space. A Personal space's agents now write elsewhere
|
|
36
|
+
for their person without labels from there (below): an app that relied on that refusal says so in
|
|
37
|
+
its own rules.
|
|
38
|
+
|
|
39
|
+
- **Agents work under the authority of whoever asked** ([design](design/work.md), "Authority"). In a
|
|
40
|
+
person's own Personal space, where only they read the answers, their agents reach every space they
|
|
41
|
+
do, and now act there too. That makes the Personal chat a chief of staff:
|
|
42
|
+
- **Tools take a space** (`in`, its id, which the `elsewhere` context lists): `list_conversations`
|
|
43
|
+
and `read_conversation` (new, chat's own), boards (`list_boards`, `read_board`, `create_board`,
|
|
44
|
+
`create_card`, `update_card`, `move_card`), documents (`list_documents`, `read_document`,
|
|
45
|
+
`write_document`, `append_document`, `edit_document`), routines (`schedule_routine`,
|
|
46
|
+
`list_routines`, `cancel_routine`: a routine kept elsewhere starts a new conversation there each
|
|
47
|
+
run) and `recall`, as before. From a shared space they work only there and in what it draws on,
|
|
48
|
+
and say so (`workIn`, in the agents' contract, for apps' tools).
|
|
49
|
+
- **`send_message` takes `thread`:** a conversation that's there already, in this space or any
|
|
50
|
+
other the person can write in. Who answers there gets it (`to`, or the conversation's own
|
|
51
|
+
agent), it says where it came from, and the answer comes back, as a hand-over's does.
|
|
52
|
+
- **What they write elsewhere is the person's:** work for someone from their own Personal space
|
|
53
|
+
takes no labels from there (`labels.write`, `ownPersonal`). Before, everything an agent wrote
|
|
54
|
+
from Personal into a space others see was refused (`needs_share`), even a card the person asked
|
|
55
|
+
for. What's written in the Personal space itself keeps its marks (its conversation may move),
|
|
56
|
+
and labels guard shared spaces and contacts' chats as before.
|
|
57
|
+
|
|
1
58
|
## 1.0.0-rc.35 — 2026-11-09
|
|
2
59
|
|
|
3
60
|
**Fixed: a retried call's nested calls.** A call run again under its id (a retry after a failure or
|
package/README.md
CHANGED
|
@@ -162,7 +162,7 @@ OPENAI_API_KEY=sk-… node salon.ts # or bun salon.ts, or deno run -A salon.t
|
|
|
162
162
|
```
|
|
163
163
|
|
|
164
164
|
On Deno, map the name `copilotz` in `deno.json`
|
|
165
|
-
(`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
165
|
+
(`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.37"`) so the imports read the same everywhere.
|
|
166
166
|
Copilotz runs on Node, Deno and Bun, and it's built on web standards for Cloudflare Workers and the
|
|
167
167
|
browser.
|
|
168
168
|
|
package/hosts/web/host.js
CHANGED
|
@@ -8,6 +8,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
* React, each part a component redrawn on its own. Where you are is the address: links are
|
|
9
9
|
* followed without reloading, back and forward work, two tabs differ. The
|
|
10
10
|
* connection is kept for `LazyView`, which observes a View on demand.
|
|
11
|
+
* Whom Views are shown to (`ctx.viewer`) is the person, by their name and
|
|
12
|
+
* email (identity's `GET /me`, asked while the ticket is), kept as their own
|
|
13
|
+
* record says: they rename themselves, here or in another tab, and the page
|
|
14
|
+
* draws again with the new name, without reloading.
|
|
11
15
|
*
|
|
12
16
|
* The page takes the app's theme from the first (signing in included): the
|
|
13
17
|
* front ends' `theme` resources merged over the defaults, as CSS variables
|
|
@@ -27,7 +31,7 @@ import { createRoot } from "react-dom/client";
|
|
|
27
31
|
import { connect } from "../../runtime/client.js";
|
|
28
32
|
import { registerWorker } from "./install.js";
|
|
29
33
|
import { Part } from "./part.js";
|
|
30
|
-
import { session } from "./session.js";
|
|
34
|
+
import { followViewer, session, viewerOf } from "./session.js";
|
|
31
35
|
import { SignIn } from "./signin.js";
|
|
32
36
|
import { inviteOf } from "./signin-email.js";
|
|
33
37
|
import { signInPageOf } from "./signin-words.js";
|
|
@@ -91,13 +95,12 @@ async function ticket() {
|
|
|
91
95
|
return undefined;
|
|
92
96
|
return await answered(response, "couldntConnect");
|
|
93
97
|
}
|
|
94
|
-
/** What the person signed in is shown as
|
|
95
|
-
async function
|
|
98
|
+
/** What identity's `/me` says the person signed in is shown as; nothing, for anyone else. */
|
|
99
|
+
async function shownOf() {
|
|
96
100
|
const response = await fetch(`${config().base ?? ""}/me`).catch(() => undefined);
|
|
97
101
|
if (!response?.ok)
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
return typeof me?.name === "string" && me.name ? me.name : undefined;
|
|
102
|
+
return {};
|
|
103
|
+
return await response.json().catch(() => null) ?? {};
|
|
101
104
|
}
|
|
102
105
|
/**
|
|
103
106
|
* The ways to sign in the app has, by what its routes answer: Google's, with
|
|
@@ -155,15 +158,15 @@ export async function web(options) {
|
|
|
155
158
|
}
|
|
156
159
|
if (options.arrive)
|
|
157
160
|
await arriving(options.arrive);
|
|
158
|
-
// Their name, asked while the ticket is: a person's, as they signed in.
|
|
159
|
-
const named = options.arrive ? Promise.resolve(
|
|
161
|
+
// Their name and email, asked while the ticket is: a person's, as they signed in.
|
|
162
|
+
const named = options.arrive ? Promise.resolve({}) : shownOf();
|
|
160
163
|
const first = await ticket();
|
|
161
164
|
if (!first) {
|
|
162
165
|
draw(_jsx(SignIn, { signIn: await waysToSignIn(), page: signInPageOf(options.plugins) }));
|
|
163
166
|
return undefined;
|
|
164
167
|
}
|
|
165
168
|
const person = first.actor.kind === "person";
|
|
166
|
-
const
|
|
169
|
+
const me = person ? await named : {};
|
|
167
170
|
let fresh = first.ticket;
|
|
168
171
|
const url = options.url ??
|
|
169
172
|
`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${config().base ?? ""}/oxian`;
|
|
@@ -183,14 +186,9 @@ export async function web(options) {
|
|
|
183
186
|
plugins: options.plugins,
|
|
184
187
|
});
|
|
185
188
|
await client.ready;
|
|
186
|
-
// Who they are (a person by their id; a contact as messages name it),
|
|
187
|
-
const viewer = {
|
|
188
|
-
kind: first.actor.kind,
|
|
189
|
-
name: person ? first.actor.id : `${first.actor.kind}:${first.actor.id}`,
|
|
190
|
-
...(name ? { label: name } : {}),
|
|
191
|
-
};
|
|
189
|
+
// Who they are (a person by their id; a contact as messages name it), their name and email.
|
|
192
190
|
session.client = client;
|
|
193
|
-
session.viewer =
|
|
191
|
+
session.viewer = viewerOf(first.actor, me);
|
|
194
192
|
let space = (await options.start?.(client, first.actor))?.space;
|
|
195
193
|
let shown;
|
|
196
194
|
const show = () => {
|
|
@@ -208,7 +206,7 @@ export async function web(options) {
|
|
|
208
206
|
const [kind, ...rest] = location.pathname.split("/").filter(Boolean).map(decodeURIComponent);
|
|
209
207
|
const here = kind === "space" && rest.length ? rest.join("/") : space;
|
|
210
208
|
const shell = client.observe("web.shell", where, {
|
|
211
|
-
viewer,
|
|
209
|
+
viewer: session.viewer,
|
|
212
210
|
...(here ? { actor: { ...first.actor, in: here } } : {}),
|
|
213
211
|
part: (part, key) => _jsx(Part, { part: part }, key),
|
|
214
212
|
});
|
|
@@ -234,5 +232,8 @@ export async function web(options) {
|
|
|
234
232
|
go(link.pathname + link.search);
|
|
235
233
|
});
|
|
236
234
|
show();
|
|
235
|
+
// Renamed (here, or in another tab), every View draws again with their name as it is now.
|
|
236
|
+
if (person)
|
|
237
|
+
followViewer(client, first.actor, show);
|
|
237
238
|
return client;
|
|
238
239
|
}
|
package/hosts/web/session.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The page's connection, once `web()` has made it: the client, and whom it
|
|
3
|
-
* shows Views to. What `LazyView` observes with.
|
|
3
|
+
* shows Views to. What `LazyView` observes with. A person's viewer is kept as
|
|
4
|
+
* their own record says (`followViewer`): their name, or none, and their
|
|
5
|
+
* email.
|
|
4
6
|
*/
|
|
5
7
|
import type { Client } from "../../runtime/client.js";
|
|
6
8
|
import type { Viewer } from "../../runtime/mod.js";
|
|
@@ -8,3 +10,27 @@ export declare const session: {
|
|
|
8
10
|
client?: Client;
|
|
9
11
|
viewer?: Viewer;
|
|
10
12
|
};
|
|
13
|
+
/** What someone signed in is shown as: their name and email, as far as known. */
|
|
14
|
+
export type Shown = {
|
|
15
|
+
name?: unknown;
|
|
16
|
+
email?: unknown;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Whom Views are shown to: a person by their id, with their name and email;
|
|
20
|
+
* a contact as messages name it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function viewerOf(actor: {
|
|
23
|
+
kind: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}, shown?: Shown): Viewer;
|
|
26
|
+
/**
|
|
27
|
+
* Keeps the page's viewer (`session.viewer`) as a person's own record says
|
|
28
|
+
* (identity's `person`: their name and email), and says when it changes
|
|
29
|
+
* (`changed`: the page draws again): they renamed themselves, here or in
|
|
30
|
+
* another tab. Its first answer is what the page knew already. It returns
|
|
31
|
+
* how to stop.
|
|
32
|
+
*/
|
|
33
|
+
export declare function followViewer(client: Client, person: {
|
|
34
|
+
kind: string;
|
|
35
|
+
id: string;
|
|
36
|
+
}, changed: () => void): () => void;
|
package/hosts/web/session.js
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
1
|
export const session = {};
|
|
2
|
+
/**
|
|
3
|
+
* Whom Views are shown to: a person by their id, with their name and email;
|
|
4
|
+
* a contact as messages name it.
|
|
5
|
+
*/
|
|
6
|
+
export function viewerOf(actor, shown = {}) {
|
|
7
|
+
const text = (value) => typeof value === "string" && value ? value : undefined;
|
|
8
|
+
const label = text(shown.name);
|
|
9
|
+
const email = text(shown.email);
|
|
10
|
+
return {
|
|
11
|
+
kind: actor.kind,
|
|
12
|
+
name: actor.kind === "person" ? actor.id : `${actor.kind}:${actor.id}`,
|
|
13
|
+
...(label ? { label } : {}),
|
|
14
|
+
...(email ? { email } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Keeps the page's viewer (`session.viewer`) as a person's own record says
|
|
19
|
+
* (identity's `person`: their name and email), and says when it changes
|
|
20
|
+
* (`changed`: the page draws again): they renamed themselves, here or in
|
|
21
|
+
* another tab. Its first answer is what the page knew already. It returns
|
|
22
|
+
* how to stop.
|
|
23
|
+
*/
|
|
24
|
+
export function followViewer(client, person, changed) {
|
|
25
|
+
return client.db.collection("person").watch({ _id: person.id }, { projection: { name: 1, email: 1 } }, ([now], error) => {
|
|
26
|
+
if (error || !now)
|
|
27
|
+
return;
|
|
28
|
+
const next = viewerOf(person, now);
|
|
29
|
+
const was = session.viewer;
|
|
30
|
+
if (next.label === was?.label && next.email === was?.email)
|
|
31
|
+
return;
|
|
32
|
+
session.viewer = next;
|
|
33
|
+
changed();
|
|
34
|
+
});
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,8 @@ export declare function personFor(ctx: Context, email: string, login: Login | nu
|
|
|
16
16
|
/**
|
|
17
17
|
* Keeps what a sign-in proved about a person: their email (identity's
|
|
18
18
|
* `person.email`, what invitations find people by), the name they gave when
|
|
19
|
-
* they have none
|
|
19
|
+
* they have none (and never chose one: `person.rename`), and when they came
|
|
20
|
+
* (`at`, kept from before; an import's).
|
|
20
21
|
*/
|
|
21
22
|
export declare function keepPerson(ctx: Context, person: string, given: {
|
|
22
23
|
email: string;
|
|
@@ -13,7 +13,8 @@ export async function personFor(ctx, email, login, chosen) {
|
|
|
13
13
|
/**
|
|
14
14
|
* Keeps what a sign-in proved about a person: their email (identity's
|
|
15
15
|
* `person.email`, what invitations find people by), the name they gave when
|
|
16
|
-
* they have none
|
|
16
|
+
* they have none (and never chose one: `person.rename`), and when they came
|
|
17
|
+
* (`at`, kept from before; an import's).
|
|
17
18
|
*/
|
|
18
19
|
export async function keepPerson(ctx, person, given) {
|
|
19
20
|
const people = ctx.as().db.collection("person");
|
|
@@ -22,7 +23,7 @@ export async function keepPerson(ctx, person, given) {
|
|
|
22
23
|
await people.updateOne({ _id: person }, {
|
|
23
24
|
$set: {
|
|
24
25
|
email: given.email,
|
|
25
|
-
...(name && !known?.name ? { name } : {}),
|
|
26
|
+
...(name && !known?.name && !known?.named ? { name } : {}),
|
|
26
27
|
at: known?.at ?? given.at ?? new Date().toISOString(),
|
|
27
28
|
},
|
|
28
29
|
}, { upsert: true });
|
|
@@ -30,7 +30,8 @@ export const signInAction = defineAction({
|
|
|
30
30
|
$set: {
|
|
31
31
|
"accounts.google": claims.sub,
|
|
32
32
|
...(claims.email ? { email: claims.email } : {}),
|
|
33
|
-
|
|
33
|
+
// A name they chose themselves (`person.rename`) stays.
|
|
34
|
+
...(claims.name && !known?.named ? { name: claims.name } : {}),
|
|
34
35
|
...(claims.picture ? { picture: claims.picture } : {}),
|
|
35
36
|
at: known?.at ?? new Date().toISOString(),
|
|
36
37
|
},
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export declare const setPerson: import("../../../../runtime/define.js").ActionDef;
|
|
2
|
+
/**
|
|
3
|
+
* `person.rename` `{ name }`: the name a person goes by, which everyone sees
|
|
4
|
+
* (their menu, home's greeting, the people beside them, agents). Theirs
|
|
5
|
+
* alone: always their own, never through a key or an agent. One line (runs
|
|
6
|
+
* of spaces, tabs and breaks are one space), trimmed; empty, they have none.
|
|
7
|
+
*/
|
|
8
|
+
export declare const renamePerson: import("../../../../runtime/define.js").ActionDef;
|
|
2
9
|
export declare const emailOf: import("../../../../runtime/define.js").ActionDef;
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
* verified about someone (their email, their name), and `person.email` says
|
|
4
4
|
* the email someone proved, for plugins that match people by it (an
|
|
5
5
|
* invitation). Both are the system's: a person never sets their own email.
|
|
6
|
+
* Their name is theirs, though (`person.rename`): once they've chosen it (or
|
|
7
|
+
* chosen none), sign-ins keep it as they left it.
|
|
6
8
|
*/
|
|
7
|
-
import { defineAction } from "../../../../runtime/mod.js";
|
|
9
|
+
import { defineAction, failure, inPerson } from "../../../../runtime/mod.js";
|
|
10
|
+
/** The longest name someone gives themselves, in characters, once it's one line. */
|
|
11
|
+
const LONGEST = 80;
|
|
8
12
|
export const setPerson = defineAction({
|
|
9
13
|
description: "Keeps what a sign-in verified about a person: their email, their name",
|
|
10
14
|
input: {
|
|
@@ -24,7 +28,8 @@ export const setPerson = defineAction({
|
|
|
24
28
|
await people.updateOne({ _id: input.person }, {
|
|
25
29
|
$set: {
|
|
26
30
|
...(input.email ? { email: input.email.trim().toLowerCase() } : {}),
|
|
27
|
-
|
|
31
|
+
// A name they chose themselves stays.
|
|
32
|
+
...(input.name && !known?.named ? { name: input.name } : {}),
|
|
28
33
|
...(input.picture ? { picture: input.picture } : {}),
|
|
29
34
|
at: known?.at ?? new Date().toISOString(),
|
|
30
35
|
},
|
|
@@ -32,6 +37,37 @@ export const setPerson = defineAction({
|
|
|
32
37
|
return { new: !known };
|
|
33
38
|
},
|
|
34
39
|
});
|
|
40
|
+
/**
|
|
41
|
+
* `person.rename` `{ name }`: the name a person goes by, which everyone sees
|
|
42
|
+
* (their menu, home's greeting, the people beside them, agents). Theirs
|
|
43
|
+
* alone: always their own, never through a key or an agent. One line (runs
|
|
44
|
+
* of spaces, tabs and breaks are one space), trimmed; empty, they have none.
|
|
45
|
+
*/
|
|
46
|
+
export const renamePerson = defineAction({
|
|
47
|
+
description: "Sets the name you go by; an empty one clears it",
|
|
48
|
+
input: {
|
|
49
|
+
type: "object",
|
|
50
|
+
// Room for the spaces around it; the name itself is checked below, in words people read.
|
|
51
|
+
properties: { name: { type: "string", maxLength: 200 } },
|
|
52
|
+
required: ["name"],
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
},
|
|
55
|
+
allow: inPerson,
|
|
56
|
+
run: async (ctx, input) => {
|
|
57
|
+
const name = input.name.replace(/[\s\p{Cc}]+/gu, " ").trim();
|
|
58
|
+
if ([...name].length > LONGEST) {
|
|
59
|
+
throw failure("invalid", `A name is at most ${LONGEST} characters.`, { public: true });
|
|
60
|
+
}
|
|
61
|
+
const people = ctx.as().db.collection("person");
|
|
62
|
+
const known = await people.findOne({ _id: ctx.actor.id });
|
|
63
|
+
const now = new Date().toISOString();
|
|
64
|
+
await people.updateOne({ _id: ctx.actor.id }, {
|
|
65
|
+
$set: { ...(name ? { name } : {}), named: now, at: known?.at ?? now },
|
|
66
|
+
...(name ? {} : { $unset: { name: "" } }),
|
|
67
|
+
}, { upsert: true });
|
|
68
|
+
return { name: name || null };
|
|
69
|
+
},
|
|
70
|
+
});
|
|
35
71
|
export const emailOf = defineAction({
|
|
36
72
|
description: "The email a person proved when they signed in, if any",
|
|
37
73
|
input: {
|
|
@@ -19,6 +19,10 @@ declare const personSchema: {
|
|
|
19
19
|
readonly type: "string";
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
/** When they last chose their name, or none (`person.rename`): sign-ins leave it so. */
|
|
23
|
+
readonly named: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
};
|
|
22
26
|
readonly at: {
|
|
23
27
|
readonly type: "string";
|
|
24
28
|
};
|
|
@@ -45,6 +49,10 @@ export declare const person: {
|
|
|
45
49
|
readonly type: "string";
|
|
46
50
|
};
|
|
47
51
|
};
|
|
52
|
+
/** When they last chose their name, or none (`person.rename`): sign-ins leave it so. */
|
|
53
|
+
readonly named: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
};
|
|
48
56
|
readonly at: {
|
|
49
57
|
readonly type: "string";
|
|
50
58
|
};
|
|
@@ -61,6 +69,7 @@ export declare const person: {
|
|
|
61
69
|
name?: string | undefined;
|
|
62
70
|
picture?: string | undefined;
|
|
63
71
|
email?: string | undefined;
|
|
72
|
+
named?: string | undefined;
|
|
64
73
|
accounts?: {
|
|
65
74
|
[x: string]: string;
|
|
66
75
|
} | undefined;
|
|
@@ -8,6 +8,8 @@ const personSchema = {
|
|
|
8
8
|
picture: { type: "string" },
|
|
9
9
|
/** Where each sign-in method knows them: `{ google: "1234" }`. */
|
|
10
10
|
accounts: { type: "object", additionalProperties: { type: "string" } },
|
|
11
|
+
/** When they last chose their name, or none (`person.rename`): sign-ins leave it so. */
|
|
12
|
+
named: { type: "string" },
|
|
11
13
|
at: { type: "string" },
|
|
12
14
|
},
|
|
13
15
|
required: ["at"],
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
*
|
|
23
23
|
* A sign-in method keeps what it verified about someone (`person.set`: their
|
|
24
24
|
* email), and plugins that match people by email ask for it (`person.email`).
|
|
25
|
-
*
|
|
25
|
+
* A person sets the name they go by themselves (`person.rename`), or clears
|
|
26
|
+
* it; sign-ins then leave it so. Each person reads only their own: nobody
|
|
27
|
+
* learns who else has an account.
|
|
26
28
|
*/
|
|
27
29
|
import { type Plugin } from "../../../runtime/mod.js";
|
|
28
30
|
export * from "./contract.js";
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
*
|
|
23
23
|
* A sign-in method keeps what it verified about someone (`person.set`: their
|
|
24
24
|
* email), and plugins that match people by email ask for it (`person.email`).
|
|
25
|
-
*
|
|
25
|
+
* A person sets the name they go by themselves (`person.rename`), or clears
|
|
26
|
+
* it; sign-ins then leave it so. Each person reads only their own: nobody
|
|
27
|
+
* learns who else has an account.
|
|
26
28
|
*/
|
|
27
29
|
import { definePlugin, failure } from "../../../runtime/mod.js";
|
|
28
|
-
import { emailOf, setPerson } from "./actions/person.js";
|
|
30
|
+
import { emailOf, renamePerson, setPerson } from "./actions/person.js";
|
|
29
31
|
import { endSession, revokeCredentials, startSession } from "./actions/session.js";
|
|
30
32
|
import { credential } from "./collections/credential.js";
|
|
31
33
|
import { person } from "./collections/person.js";
|
|
@@ -41,6 +43,7 @@ export const identity = definePlugin({
|
|
|
41
43
|
"session.end": endSession,
|
|
42
44
|
"credential.revoke": revokeCredentials,
|
|
43
45
|
"person.set": setPerson,
|
|
46
|
+
"person.rename": renamePerson,
|
|
44
47
|
"person.email": emailOf,
|
|
45
48
|
},
|
|
46
49
|
// A request is the person its session cookie proves. The cookie is the host's alone
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
* to choose to show it there. Documents that are members (agents people
|
|
11
11
|
* make, contacts) carry nothing: they're meant for whoever they work with.
|
|
12
12
|
*
|
|
13
|
+
* What's written elsewhere for someone from their own Personal space carries
|
|
14
|
+
* nothing either: only they see what's said there, and what their agents do
|
|
15
|
+
* there for them, anywhere they may, is theirs, as if they'd done it (an
|
|
16
|
+
* assistant they asked in private), for whoever sees where it goes. The record
|
|
17
|
+
* says who did it, for whom, and from where. What's written in the Personal
|
|
18
|
+
* space itself keeps its marks, for the day its conversation moves.
|
|
19
|
+
*
|
|
13
20
|
* A document that may be shared on its own (a chat: other collections'
|
|
14
21
|
* documents are its parts) labels as itself, and so do its parts (a chat's
|
|
15
22
|
* messages), so a write into one shared with someone outside its space (a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { docKey, homeOf, reachOf } from "./reach.js";
|
|
1
|
+
import { docKey, homeOf, ownPersonal, reachOf } from "./reach.js";
|
|
2
2
|
import { nameOf, namesOf, PROFILE } from "./names.js";
|
|
3
3
|
/** The `shared` resource; an entry is a collection's own key, never what objects inherit. */
|
|
4
4
|
const sharedOf = (ctx) => (ctx.resources.shared ?? {});
|
|
@@ -92,6 +92,11 @@ export const labels = {
|
|
|
92
92
|
const foreign = [...found];
|
|
93
93
|
if (!foreign.length)
|
|
94
94
|
return doc;
|
|
95
|
+
// Done elsewhere for someone from their own Personal space: theirs, as if they'd written it,
|
|
96
|
+
// for whoever sees where it goes (on the record as who did it, for them, from there). What's
|
|
97
|
+
// written in Personal itself keeps its marks: the conversation may move.
|
|
98
|
+
if (space !== actor.in && await ownPersonal(actor, ctx))
|
|
99
|
+
return doc;
|
|
95
100
|
// Where it works (`in`): an agent writing elsewhere what not everyone there can see is refused.
|
|
96
101
|
const elsewhere = typeof actor.in === "string" && actor.in !== space;
|
|
97
102
|
if (actor.kind === "agent" && (elsewhere || !shared.labels)) {
|
|
@@ -89,6 +89,14 @@ export declare function reachOf(actor: Actor, ctx: ReadContext): Promise<Reach>;
|
|
|
89
89
|
* isn't narrowed, so it's the same on every page).
|
|
90
90
|
*/
|
|
91
91
|
export declare function reachKey(actor: Actor): string;
|
|
92
|
+
/**
|
|
93
|
+
* Whether an actor's work is done for someone from their own Personal space
|
|
94
|
+
* (an agent's working for them there, a routine of theirs kept there): theirs,
|
|
95
|
+
* as if they'd done it, wherever it writes (see labels.ts). Only they see what's
|
|
96
|
+
* said there, so what they asked for there is theirs to have done anywhere they
|
|
97
|
+
* may.
|
|
98
|
+
*/
|
|
99
|
+
export declare function ownPersonal(actor: Actor, ctx: ReadContext): Promise<boolean>;
|
|
92
100
|
/**
|
|
93
101
|
* The space a document shared on its own lives in, by its key (`thread:t1`):
|
|
94
102
|
* its shared collection's field says. Undefined for anything else.
|
|
@@ -170,12 +170,8 @@ async function reaching(actor, ctx) {
|
|
|
170
170
|
* there.
|
|
171
171
|
*/
|
|
172
172
|
async function narrowed(reach, space, principal, ctx) {
|
|
173
|
-
|
|
174
|
-
_id: space,
|
|
175
|
-
});
|
|
176
|
-
if (found?.kind === PERSONAL && principal.kind === "person" && found.owner === principal.id) {
|
|
173
|
+
if (await personalOf(space, principal, ctx))
|
|
177
174
|
return reach;
|
|
178
|
-
}
|
|
179
175
|
const drawn = await reachOf({ kind: "space", id: space }, ctx);
|
|
180
176
|
const all = new Set(ALL);
|
|
181
177
|
const within = new Map();
|
|
@@ -192,6 +188,28 @@ async function narrowed(reach, space, principal, ctx) {
|
|
|
192
188
|
}
|
|
193
189
|
return within;
|
|
194
190
|
}
|
|
191
|
+
/** Whether `space` is `principal`'s own Personal space, which nobody else sees. */
|
|
192
|
+
async function personalOf(space, principal, ctx) {
|
|
193
|
+
if (principal.kind !== "person")
|
|
194
|
+
return false;
|
|
195
|
+
const found = await ctx.db.collection("space").findOne({
|
|
196
|
+
_id: space,
|
|
197
|
+
});
|
|
198
|
+
return found?.kind === PERSONAL && found.owner === principal.id;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Whether an actor's work is done for someone from their own Personal space
|
|
202
|
+
* (an agent's working for them there, a routine of theirs kept there): theirs,
|
|
203
|
+
* as if they'd done it, wherever it writes (see labels.ts). Only they see what's
|
|
204
|
+
* said there, so what they asked for there is theirs to have done anywhere they
|
|
205
|
+
* may.
|
|
206
|
+
*/
|
|
207
|
+
export async function ownPersonal(actor, ctx) {
|
|
208
|
+
const where = whereOf(actor);
|
|
209
|
+
if (where === undefined || !narrows(actor))
|
|
210
|
+
return false;
|
|
211
|
+
return await personalOf(where, worksFor(actor) ?? actor, ctx);
|
|
212
|
+
}
|
|
195
213
|
/** Whom an actor works for: an agent, whoever it acts for (`for`); a key, the person whose it is. */
|
|
196
214
|
const worksFor = (actor) => actor.for ??
|
|
197
215
|
(keyOf(actor) !== undefined ? { kind: "person", id: actor.id } : undefined);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Elsewhere, for agents (the chat plugin's `elsewhere` context, each turn):
|
|
3
|
-
* the other spaces an agent can
|
|
4
|
-
* knows where to look (a tool given a space,
|
|
3
|
+
* the other spaces an agent can work in for the person it works for, so it
|
|
4
|
+
* knows where to look and act (a tool given a space, `in`: chats, boards,
|
|
5
|
+
* documents, routines, `recall`; a chat there, send_message's `thread`)
|
|
5
6
|
* when what it needs isn't here, and the spaces it can hand work to, with who
|
|
6
7
|
* answers there. An agent reaches only where it works and what that draws on
|
|
7
8
|
* (design/work.md), so the other spaces it can read are listed only in its
|
|
@@ -33,9 +33,11 @@ export const elsewhereView = (thread, ctx) => {
|
|
|
33
33
|
return [
|
|
34
34
|
...(others.length
|
|
35
35
|
? [
|
|
36
|
-
`Other spaces you can
|
|
37
|
-
`
|
|
38
|
-
`
|
|
36
|
+
`Other spaces you can work in for ${who}, as they can: tools that take a space ` +
|
|
37
|
+
`(\`in\`) read and change what's there (list_conversations and read_conversation, boards, documents, ` +
|
|
38
|
+
`routines, recall), and send_message's \`thread\` says something in a chat there, ` +
|
|
39
|
+
`whose answer comes back here. What you read in one marks your answer: here, only ` +
|
|
40
|
+
`those who can see that space read it, until ${who} shares it.`,
|
|
39
41
|
...others.slice(0, LISTED).map(line),
|
|
40
42
|
...(others.length > LISTED ? [`- and ${others.length - LISTED} more`] : []),
|
|
41
43
|
]
|
|
@@ -29,6 +29,11 @@ export { tool } from "./shared/types.js";
|
|
|
29
29
|
*/
|
|
30
30
|
export { runTool, type ToolAt, type ToolRun, toolText } from "./shared/tools.js";
|
|
31
31
|
export { type Origin, originKey, originOf } from "./shared/origin.js";
|
|
32
|
+
/**
|
|
33
|
+
* Where a tool works: the space its call names (`in`), when the agent's work
|
|
34
|
+
* reaches it, else where its conversation is; or, in words, why it can't.
|
|
35
|
+
*/
|
|
36
|
+
export { workIn, type WorkVerb } from "./shared/where.js";
|
|
32
37
|
export type { AgentModel, AgentSource, Roster, RosterSource, Team } from "./shared/agents.js";
|
|
33
38
|
export { CONTACT_TEXT, MEDIA_TYPE, MEDIA_TYPE_LENGTH } from "./actions/send.js";
|
|
34
39
|
export type { ContactSend } from "./shared/contact-send.js";
|
|
@@ -8,6 +8,11 @@ export { tool } from "./shared/types.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export { runTool, toolText } from "./shared/tools.js";
|
|
10
10
|
export { originKey, originOf } from "./shared/origin.js";
|
|
11
|
+
/**
|
|
12
|
+
* Where a tool works: the space its call names (`in`), when the agent's work
|
|
13
|
+
* reaches it, else where its conversation is; or, in words, why it can't.
|
|
14
|
+
*/
|
|
15
|
+
export { workIn } from "./shared/where.js";
|
|
11
16
|
export { CONTACT_TEXT, MEDIA_TYPE, MEDIA_TYPE_LENGTH } from "./actions/send.js";
|
|
12
17
|
/**
|
|
13
18
|
* The app's agents (`agentsOf`), who of them answer new conversations
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* - An agent that sent messages expecting replies stops, leaving a `wait`
|
|
14
14
|
* document. Each reply checks itself off; the last one resumes the agent
|
|
15
15
|
* with every reply in its history. Waiting holds nothing open.
|
|
16
|
+
* - Agents read other conversations (`list_conversations`, `read_conversation`)
|
|
17
|
+
* and say something in one that's there already (send_message's `thread`):
|
|
18
|
+
* in their space, or, from their person's Personal space, in any space the
|
|
19
|
+
* person reaches, as that person may (design/work.md, "Authority").
|
|
16
20
|
* - People are reached the same way: a question to a person waits until they
|
|
17
21
|
* reply to it. So does a tool that needs a person's answer to go on (a yes
|
|
18
22
|
* to run a command, `ctx.ask`): its turn waits with the step's other
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* - An agent that sent messages expecting replies stops, leaving a `wait`
|
|
14
14
|
* document. Each reply checks itself off; the last one resumes the agent
|
|
15
15
|
* with every reply in its history. Waiting holds nothing open.
|
|
16
|
+
* - Agents read other conversations (`list_conversations`, `read_conversation`)
|
|
17
|
+
* and say something in one that's there already (send_message's `thread`):
|
|
18
|
+
* in their space, or, from their person's Personal space, in any space the
|
|
19
|
+
* person reaches, as that person may (design/work.md, "Authority").
|
|
16
20
|
* - People are reached the same way: a question to a person waits until they
|
|
17
21
|
* reply to it. So does a tool that needs a person's answer to go on (a yes
|
|
18
22
|
* to run a command, `ctx.ask`): its turn waits with the step's other
|
|
@@ -111,6 +115,7 @@ import { historyView } from "./views/history.js";
|
|
|
111
115
|
import { messageView } from "./views/message.js";
|
|
112
116
|
import { participants } from "./views/participants.js";
|
|
113
117
|
import { prompt } from "./views/prompt.js";
|
|
118
|
+
import { chatTools } from "./resources/tools.js";
|
|
114
119
|
export * from "./contract.js";
|
|
115
120
|
export { lineage } from "./shared/lineage.js";
|
|
116
121
|
/** Chat's collections, changed only through its Actions. */
|
|
@@ -162,6 +167,8 @@ export const chat = definePlugin({
|
|
|
162
167
|
// Files uploaded to send that no message sent within a day go.
|
|
163
168
|
schedules: { "chat.prune": { every: "1h", call: "chat.prune", input: {} } },
|
|
164
169
|
resources: {
|
|
170
|
+
// Agents' own: the latest chats where they work (or another space they reach), and reading one.
|
|
171
|
+
tools: chatTools,
|
|
165
172
|
// Conversations by title on Usage.
|
|
166
173
|
usageNames: { thread: { tag: "tags.thread", collection: "thread", field: "title" } },
|
|
167
174
|
// With the access plugin, chats live in spaces, and what's in a chat comes with it when it's
|