copilotz 1.0.0-rc.20 → 1.0.0-rc.21
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 +417 -0
- package/README.md +295 -19
- package/hosts/orgs/mod.d.ts +4 -1
- package/hosts/orgs/mod.js +2 -2
- package/hosts/web/files.d.ts +6 -2
- package/hosts/web/files.js +36 -3
- package/hosts/web/node/mod.d.ts +1 -1
- package/hosts/web/node/mod.js +1 -1
- package/hosts/web/node/serve.d.ts +26 -0
- package/hosts/web/node/serve.js +23 -1
- package/hosts/web/routes.d.ts +28 -1
- package/hosts/web/routes.js +65 -10
- package/hosts/web/server.d.ts +5 -4
- package/hosts/web/server.js +1 -1
- package/package.json +2 -2
- package/plugins/access/accounts/collections/account.d.ts +2 -2
- package/plugins/access/contacts/actions/chat.d.ts +1 -0
- package/plugins/access/contacts/actions/chat.js +45 -0
- package/plugins/access/contacts/actions/forget.d.ts +1 -0
- package/plugins/access/contacts/actions/forget.js +56 -0
- package/plugins/access/contacts/actions/start.d.ts +1 -0
- package/plugins/access/contacts/actions/start.js +50 -0
- package/plugins/access/contacts/collections/contact.d.ts +81 -0
- package/plugins/access/contacts/collections/contact.js +58 -0
- package/plugins/access/contacts/contract.d.ts +10 -0
- package/plugins/access/contacts/contract.js +10 -0
- package/plugins/access/contacts/mod.d.ts +27 -0
- package/plugins/access/contacts/mod.js +49 -0
- package/plugins/access/contacts/views/contact.d.ts +8 -0
- package/plugins/access/contacts/views/contact.js +25 -0
- package/plugins/access/contacts/web.d.ts +7 -0
- package/plugins/access/contacts/web.js +11 -0
- package/plugins/access/directory/collections/credit-code.d.ts +1 -1
- package/plugins/access/directory/collections/invite.d.ts +1 -1
- package/plugins/access/identity/mod.js +8 -6
- package/plugins/access/mod.d.ts +7 -1
- package/plugins/access/mod.js +7 -2
- package/plugins/access/spaces/actions/agents.js +12 -6
- package/plugins/access/spaces/actions/create.js +10 -1
- package/plugins/access/spaces/actions/invitation.js +5 -2
- package/plugins/access/spaces/actions/keep.d.ts +1 -0
- package/plugins/access/spaces/actions/keep.js +55 -0
- package/plugins/access/spaces/actions/member.js +17 -4
- package/plugins/access/spaces/actions/rename.js +4 -0
- package/plugins/access/spaces/collections/member.d.ts +1 -1
- package/plugins/access/spaces/collections/request.d.ts +1 -1
- package/plugins/access/spaces/collections/space.d.ts +9 -0
- package/plugins/access/spaces/collections/space.js +2 -0
- package/plugins/access/spaces/contract.d.ts +4 -3
- package/plugins/access/spaces/contract.js +1 -1
- package/plugins/access/spaces/mod.d.ts +7 -1
- package/plugins/access/spaces/mod.js +8 -1
- package/plugins/access/spaces/resources/tools.d.ts +0 -5
- package/plugins/access/spaces/resources/tools.js +11 -1
- package/plugins/access/spaces/shared/agents.js +2 -2
- package/plugins/access/spaces/shared/can.d.ts +18 -3
- package/plugins/access/spaces/shared/can.js +32 -5
- package/plugins/access/spaces/shared/declared.d.ts +21 -0
- package/plugins/access/spaces/shared/declared.js +8 -0
- package/plugins/access/spaces/shared/labels.d.ts +7 -1
- package/plugins/access/spaces/shared/labels.js +56 -8
- package/plugins/access/spaces/shared/managers.js +2 -2
- package/plugins/access/spaces/shared/names.d.ts +9 -5
- package/plugins/access/spaces/shared/names.js +36 -19
- package/plugins/access/spaces/shared/reach.d.ts +20 -6
- package/plugins/access/spaces/shared/reach.js +62 -20
- package/plugins/access/spaces/shared/rules.d.ts +10 -5
- package/plugins/access/spaces/shared/rules.js +35 -10
- package/plugins/access/spaces/shared/seat.d.ts +3 -2
- package/plugins/access/spaces/shared/seat.js +9 -2
- package/plugins/access/spaces/views/where.d.ts +4 -2
- package/plugins/access/spaces/views/where.js +9 -0
- package/plugins/access/spaces/web.js +1 -1
- package/plugins/access/web.d.ts +1 -0
- package/plugins/access/web.js +1 -0
- package/plugins/agents/chat/actions/erase.d.ts +1 -0
- package/plugins/agents/chat/actions/erase.js +51 -0
- package/plugins/agents/chat/actions/open.d.ts +1 -0
- package/plugins/agents/chat/actions/open.js +49 -0
- package/plugins/agents/chat/actions/quiet.d.ts +1 -0
- package/plugins/agents/chat/actions/quiet.js +33 -0
- package/plugins/agents/chat/actions/say.d.ts +1 -0
- package/plugins/agents/chat/actions/say.js +82 -0
- package/plugins/agents/chat/actions/send.js +57 -19
- package/plugins/agents/chat/actions/shown.d.ts +1 -0
- package/plugins/agents/chat/actions/shown.js +35 -0
- package/plugins/agents/chat/collections/intent.d.ts +124 -0
- package/plugins/agents/chat/collections/intent.js +52 -0
- package/plugins/agents/chat/collections/message.d.ts +74 -1
- package/plugins/agents/chat/collections/message.js +23 -1
- package/plugins/agents/chat/collections/shown.d.ts +105 -0
- package/plugins/agents/chat/collections/shown.js +34 -0
- package/plugins/agents/chat/contract.d.ts +15 -7
- package/plugins/agents/chat/contract.js +7 -1
- package/plugins/agents/chat/mod.d.ts +20 -2
- package/plugins/agents/chat/mod.js +43 -4
- package/plugins/agents/chat/processors/failed.js +15 -5
- package/plugins/agents/chat/processors/turn.d.ts +1 -1
- package/plugins/agents/chat/processors/turn.js +95 -35
- package/plugins/agents/chat/shared/delivery.d.ts +16 -2
- package/plugins/agents/chat/shared/delivery.js +62 -7
- package/plugins/agents/chat/shared/send.d.ts +1 -3
- package/plugins/agents/chat/shared/send.js +2 -9
- package/plugins/agents/chat/shared/tools.d.ts +33 -0
- package/plugins/agents/chat/shared/tools.js +28 -0
- package/plugins/agents/chat/shared/types.d.ts +59 -1
- package/plugins/agents/chat/views/message.d.ts +4 -2
- package/plugins/agents/chat/views/message.js +22 -4
- package/plugins/agents/chat/views/prompt.js +38 -4
- package/plugins/agents/history/collections/outline.d.ts +1 -1
- package/plugins/agents/history/collections/summary.d.ts +1 -1
- package/plugins/agents/history/mod.js +2 -1
- package/plugins/agents/history/processors/erase.d.ts +3 -0
- package/plugins/agents/history/processors/erase.js +11 -0
- package/plugins/agents/memory/mod.js +2 -1
- package/plugins/agents/memory/processors/extract.d.ts +1 -1
- package/plugins/agents/memory/processors/extract.js +5 -0
- package/plugins/agents/memory/resources/tools.js +1 -1
- package/plugins/agents/memory/shared/settings.d.ts +7 -2
- package/plugins/agents/memory/shared/settings.js +9 -1
- package/plugins/agents/routines/collections/routine.d.ts +1 -1
- package/plugins/agents/routines/collections/run.d.ts +1 -1
- package/plugins/compute/apps/collections/app.d.ts +2 -2
- package/plugins/compute/cloud/resources/tools.js +3 -3
- package/plugins/compute/computers/collections/approval.d.ts +2 -2
- package/plugins/compute/computers/collections/grant.d.ts +1 -1
- package/plugins/compute/computers/collections/preview.d.ts +2 -2
- 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/compute/computers/shared/wake.d.ts +1 -1
- package/plugins/compute/computers/shared/wake.js +17 -0
- package/plugins/interfaces/api/collections/key.d.ts +1 -1
- package/plugins/interfaces/api/shared/events.js +5 -4
- package/plugins/interfaces/maintenance/actions/read.d.ts +4 -0
- package/plugins/interfaces/maintenance/actions/read.js +76 -0
- package/plugins/interfaces/maintenance/actions/write.d.ts +4 -0
- package/plugins/interfaces/maintenance/actions/write.js +64 -0
- package/plugins/interfaces/maintenance/contract.d.ts +60 -0
- package/plugins/interfaces/maintenance/contract.js +2 -0
- package/plugins/interfaces/maintenance/mod.d.ts +52 -0
- package/plugins/interfaces/maintenance/mod.js +66 -0
- package/plugins/interfaces/maintenance/resources/routes.d.ts +71 -0
- package/plugins/interfaces/maintenance/resources/routes.js +457 -0
- package/plugins/interfaces/maintenance/shared/ops.d.ts +4 -0
- package/plugins/interfaces/maintenance/shared/ops.js +19 -0
- package/plugins/interfaces/mcp/actions/call.d.ts +11 -0
- package/plugins/interfaces/mcp/actions/call.js +304 -0
- package/plugins/interfaces/mcp/actions/prune.d.ts +1 -0
- package/plugins/interfaces/mcp/actions/prune.js +18 -0
- package/plugins/interfaces/mcp/collections/closed.d.ts +23 -0
- package/plugins/interfaces/mcp/collections/closed.js +17 -0
- package/plugins/interfaces/mcp/collections/rate.d.ts +27 -0
- package/plugins/interfaces/mcp/collections/rate.js +18 -0
- package/plugins/interfaces/mcp/collections/receipt.d.ts +46 -0
- package/plugins/interfaces/mcp/collections/receipt.js +46 -0
- package/plugins/interfaces/mcp/contract.d.ts +9 -0
- package/plugins/interfaces/mcp/contract.js +9 -0
- package/plugins/interfaces/mcp/mod.d.ts +84 -0
- package/plugins/interfaces/mcp/mod.js +122 -0
- package/plugins/interfaces/mcp/processors/closed.d.ts +13 -0
- package/plugins/interfaces/mcp/processors/closed.js +16 -0
- package/plugins/interfaces/mcp/resources/running.d.ts +21 -0
- package/plugins/interfaces/mcp/resources/running.js +36 -0
- package/plugins/interfaces/mcp/resources/server.d.ts +54 -0
- package/plugins/interfaces/mcp/resources/server.js +423 -0
- package/plugins/interfaces/mcp/resources/tools.d.ts +114 -0
- package/plugins/interfaces/mcp/resources/tools.js +324 -0
- package/plugins/interfaces/mcp/shared/caller.d.ts +45 -0
- package/plugins/interfaces/mcp/shared/caller.js +99 -0
- package/plugins/interfaces/mcp/shared/keys.d.ts +50 -0
- package/plugins/interfaces/mcp/shared/keys.js +53 -0
- package/plugins/interfaces/mcp/shared/settings.d.ts +187 -0
- package/plugins/interfaces/mcp/shared/settings.js +176 -0
- package/plugins/interfaces/mcp/views/offered.d.ts +20 -0
- package/plugins/interfaces/mcp/views/offered.js +20 -0
- package/plugins/interfaces/mod.d.ts +5 -1
- package/plugins/interfaces/mod.js +5 -1
- package/plugins/interfaces/terminal/actions/print.js +1 -1
- package/plugins/interfaces/terminal/actions/set.js +1 -1
- package/plugins/interfaces/terminal/collections/output.d.ts +1 -1
- package/plugins/interfaces/terminal/collections/shell.js +1 -1
- package/plugins/interfaces/voice/actions/block.d.ts +2 -0
- package/plugins/interfaces/voice/actions/block.js +74 -0
- package/plugins/interfaces/voice/actions/call.d.ts +19 -0
- package/plugins/interfaces/voice/actions/call.js +253 -0
- package/plugins/interfaces/voice/actions/hook.d.ts +5 -0
- package/plugins/interfaces/voice/actions/hook.js +225 -0
- package/plugins/interfaces/voice/actions/prune.d.ts +1 -0
- package/plugins/interfaces/voice/actions/prune.js +35 -0
- package/plugins/interfaces/voice/collections/blocked.d.ts +87 -0
- package/plugins/interfaces/voice/collections/blocked.js +34 -0
- package/plugins/interfaces/voice/collections/call.d.ts +279 -0
- package/plugins/interfaces/voice/collections/call.js +77 -0
- package/plugins/interfaces/voice/collections/phone.d.ts +74 -0
- package/plugins/interfaces/voice/collections/phone.js +26 -0
- package/plugins/interfaces/voice/contract.d.ts +14 -0
- package/plugins/interfaces/voice/contract.js +2 -0
- package/plugins/interfaces/voice/mod.d.ts +57 -0
- package/plugins/interfaces/voice/mod.js +118 -0
- package/plugins/interfaces/voice/processors/forget.d.ts +13 -0
- package/plugins/interfaces/voice/processors/forget.js +27 -0
- package/plugins/interfaces/voice/resources/relay.d.ts +77 -0
- package/plugins/interfaces/voice/resources/relay.js +428 -0
- package/plugins/interfaces/voice/resources/tools.d.ts +1 -0
- package/plugins/interfaces/voice/resources/tools.js +25 -0
- package/plugins/interfaces/voice/shared/caller.d.ts +27 -0
- package/plugins/interfaces/voice/shared/caller.js +38 -0
- package/plugins/interfaces/voice/shared/settings.d.ts +136 -0
- package/plugins/interfaces/voice/shared/settings.js +121 -0
- package/plugins/interfaces/voice/shared/signature.d.ts +11 -0
- package/plugins/interfaces/voice/shared/signature.js +34 -0
- package/plugins/interfaces/voice/views/call.d.ts +41 -0
- package/plugins/interfaces/voice/views/call.js +30 -0
- package/plugins/interfaces/voice/views/context.d.ts +9 -0
- package/plugins/interfaces/voice/views/context.js +14 -0
- package/plugins/interfaces/voice/views/message.d.ts +17 -0
- package/plugins/interfaces/voice/views/message.js +41 -0
- package/plugins/interfaces/whatsapp/actions/connect.js +3 -0
- package/plugins/interfaces/whatsapp/actions/disconnect.js +4 -1
- package/plugins/interfaces/whatsapp/actions/hook.js +27 -11
- package/plugins/interfaces/whatsapp/actions/set.d.ts +8 -0
- package/plugins/interfaces/whatsapp/actions/set.js +121 -0
- package/plugins/interfaces/whatsapp/collections/blocked.d.ts +29 -0
- package/plugins/interfaces/whatsapp/collections/blocked.js +22 -0
- package/plugins/interfaces/whatsapp/collections/code.d.ts +1 -1
- package/plugins/interfaces/whatsapp/collections/number.d.ts +90 -4
- package/plugins/interfaces/whatsapp/collections/number.js +36 -4
- package/plugins/interfaces/whatsapp/collections/phone.d.ts +13 -3
- package/plugins/interfaces/whatsapp/collections/phone.js +9 -3
- package/plugins/interfaces/whatsapp/collections/rate.d.ts +27 -0
- package/plugins/interfaces/whatsapp/collections/rate.js +13 -0
- package/plugins/interfaces/whatsapp/collections/sent.d.ts +24 -12
- package/plugins/interfaces/whatsapp/collections/sent.js +11 -7
- package/plugins/interfaces/whatsapp/collections/thread.d.ts +14 -6
- package/plugins/interfaces/whatsapp/collections/thread.js +7 -5
- package/plugins/interfaces/whatsapp/collections/typing.d.ts +70 -0
- package/plugins/interfaces/whatsapp/collections/typing.js +21 -0
- package/plugins/interfaces/whatsapp/contract.d.ts +27 -4
- package/plugins/interfaces/whatsapp/contract.js +34 -1
- package/plugins/interfaces/whatsapp/events/undelivered.d.ts +8 -0
- package/plugins/interfaces/whatsapp/events/undelivered.js +17 -0
- package/plugins/interfaces/whatsapp/mod.d.ts +28 -2
- package/plugins/interfaces/whatsapp/mod.js +65 -6
- package/plugins/interfaces/whatsapp/processors/forget.d.ts +6 -0
- package/plugins/interfaces/whatsapp/processors/forget.js +11 -0
- package/plugins/interfaces/whatsapp/processors/receive.d.ts +17 -3
- package/plugins/interfaces/whatsapp/processors/receive.js +264 -81
- package/plugins/interfaces/whatsapp/processors/reply.d.ts +25 -5
- package/plugins/interfaces/whatsapp/processors/reply.js +216 -20
- package/plugins/interfaces/whatsapp/processors/typing.d.ts +8 -0
- package/plugins/interfaces/whatsapp/processors/typing.js +25 -0
- package/plugins/interfaces/whatsapp/shared/customers.d.ts +13 -0
- package/plugins/interfaces/whatsapp/shared/customers.js +16 -0
- package/plugins/interfaces/whatsapp/shared/graph.d.ts +31 -6
- package/plugins/interfaces/whatsapp/shared/graph.js +117 -10
- package/plugins/interfaces/whatsapp/shared/media.d.ts +23 -0
- package/plugins/interfaces/whatsapp/shared/media.js +46 -0
- package/plugins/interfaces/whatsapp/shared/number.d.ts +19 -8
- package/plugins/interfaces/whatsapp/shared/number.js +64 -7
- package/plugins/interfaces/whatsapp/shared/parts.d.ts +94 -0
- package/plugins/interfaces/whatsapp/shared/parts.js +184 -0
- package/plugins/interfaces/whatsapp/shared/payload.d.ts +27 -1
- package/plugins/interfaces/whatsapp/shared/payload.js +36 -1
- package/plugins/interfaces/whatsapp/shared/settings.d.ts +49 -1
- package/plugins/interfaces/whatsapp/shared/settings.js +11 -0
- package/plugins/interfaces/whatsapp/views/message.d.ts +13 -0
- package/plugins/interfaces/whatsapp/views/message.js +13 -0
- package/plugins/interfaces/whatsapp/views/web/line.d.ts +24 -0
- package/plugins/interfaces/whatsapp/views/web/line.js +44 -0
- package/plugins/interfaces/whatsapp/views/web/space.d.ts +7 -5
- package/plugins/interfaces/whatsapp/views/web/space.js +17 -10
- package/plugins/interfaces/whatsapp/views/web/style.d.ts +1 -1
- package/plugins/interfaces/whatsapp/views/web/style.js +8 -0
- package/plugins/models/adapters/llm/anthropic.d.ts +1 -1
- package/plugins/models/adapters/llm/anthropic.js +28 -15
- package/plugins/models/adapters/llm/gemini.d.ts +1 -1
- package/plugins/models/adapters/llm/gemini.js +2 -1
- package/plugins/models/adapters/llm/openai-compatible.d.ts +1 -1
- package/plugins/models/adapters/llm/openai-compatible.js +2 -1
- package/plugins/models/adapters/llm/openai.d.ts +1 -1
- package/plugins/models/adapters/llm/openai.js +16 -4
- package/plugins/models/shared/types.d.ts +8 -0
- package/plugins/models/shared/types.js +10 -0
- package/runtime/actor.d.ts +6 -0
- package/runtime/actor.js +9 -4
- package/runtime/aggregate.js +8 -2
- package/runtime/blobs.d.ts +15 -12
- package/runtime/blobs.js +58 -11
- package/runtime/cache.d.ts +6 -0
- package/runtime/cache.js +19 -1
- package/runtime/define.d.ts +10 -0
- package/runtime/errors.d.ts +20 -2
- package/runtime/errors.js +7 -1
- package/runtime/executor.js +27 -11
- package/runtime/links.d.ts +31 -0
- package/runtime/links.js +60 -0
- package/runtime/maintain.d.ts +88 -0
- package/runtime/maintain.js +120 -0
- package/runtime/memory.js +7 -4
- package/runtime/mod.d.ts +6 -4
- package/runtime/mod.js +5 -2
- package/runtime/mongo.d.ts +13 -0
- package/runtime/mongo.js +39 -8
- package/runtime/observe.d.ts +2 -0
- package/runtime/observe.js +14 -10
- package/runtime/ops.d.ts +5 -0
- package/runtime/ops.js +10 -1
- package/runtime/owner.d.ts +18 -1
- package/runtime/owner.js +127 -61
- package/runtime/presence.d.ts +18 -0
- package/runtime/presence.js +25 -0
- package/runtime/registry.d.ts +5 -0
- package/runtime/registry.js +18 -0
- package/runtime/runtime.js +9 -3
- package/runtime/store.d.ts +48 -1
- package/runtime/wire.d.ts +1 -0
- package/runtime/wire.js +3 -1
- package/stores/blobs/files/mod.js +4 -2
- package/stores/blobs/gcs/mod.d.ts +3 -0
- package/stores/blobs/gcs/mod.js +6 -5
- package/stores/blobs/http/mod.d.ts +1 -1
- package/stores/blobs/http/mod.js +2 -1
- package/stores/latency/mod.js +5 -1
- package/stores/sql/postgres/maintenance.d.ts +24 -0
- package/stores/sql/postgres/maintenance.js +258 -0
- package/stores/sql/postgres/mod.d.ts +20 -4
- package/stores/sql/postgres/mod.js +363 -96
- package/stores/sql/postgres/update.js +3 -1
- package/stores/sql/shared/capped.d.ts +2 -0
- package/stores/sql/shared/capped.js +22 -0
- package/stores/sql/shared/rows.d.ts +14 -0
- package/stores/sql/shared/rows.js +29 -0
- package/stores/sql/shared/statement.d.ts +12 -0
- package/stores/sql/shared/statement.js +244 -0
- package/stores/sql/sqlite/apart.d.ts +11 -0
- package/stores/sql/sqlite/apart.js +219 -0
- package/stores/sql/sqlite/mod.d.ts +16 -2
- package/stores/sql/sqlite/mod.js +246 -51
- package/testing/mod.js +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who an agent is talking with, when it works for a contact (the chat
|
|
3
|
+
* plugin's `contact` context, in the system text): their name, where they
|
|
4
|
+
* write from, and that the chat is theirs and the line's people's. Nothing
|
|
5
|
+
* for anyone else's turn. Their name is theirs to choose, so it's data.
|
|
6
|
+
*/
|
|
7
|
+
import { type ViewContext } from "../../../../runtime/mod.js";
|
|
8
|
+
export declare const contactView: (_thread: unknown, ctx: ViewContext<string>) => string | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who an agent is talking with, when it works for a contact (the chat
|
|
3
|
+
* plugin's `contact` context, in the system text): their name, where they
|
|
4
|
+
* write from, and that the chat is theirs and the line's people's. Nothing
|
|
5
|
+
* for anyone else's turn. Their name is theirs to choose, so it's data.
|
|
6
|
+
*/
|
|
7
|
+
import { principalOf } from "../../../../runtime/mod.js";
|
|
8
|
+
/** How each medium's contacts talk, as an agent is told it. */
|
|
9
|
+
const FROM = {
|
|
10
|
+
whatsapp: "writing on WhatsApp",
|
|
11
|
+
voice: "on a phone call: they hear what you write, read aloud. The number they call from " +
|
|
12
|
+
"isn't proof of who they are",
|
|
13
|
+
};
|
|
14
|
+
export const contactView = (_thread, ctx) => {
|
|
15
|
+
const principal = principalOf(ctx.actor);
|
|
16
|
+
if (principal?.kind !== "contact")
|
|
17
|
+
return undefined;
|
|
18
|
+
const found = ctx.db.collection("contact").findOne({ _id: principal.id }).value;
|
|
19
|
+
if (!found)
|
|
20
|
+
return undefined;
|
|
21
|
+
const who = found.name ? `${found.name}, a customer` : "a customer (their name isn't known)";
|
|
22
|
+
const from = FROM[found.via] ?? `writing through ${found.via}`;
|
|
23
|
+
return `You're talking with ${who}, ${from}. They see only this conversation; ` +
|
|
24
|
+
`the people of the business running this line can read it too.`;
|
|
25
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contacts on the web: their names, wherever a page shows who wrote
|
|
3
|
+
* (spaces' `names` resource, for the browser): "Ana", not "someone".
|
|
4
|
+
*/
|
|
5
|
+
import { type Plugin } from "../../../runtime/mod.js";
|
|
6
|
+
export declare const contactsWeb: Plugin;
|
|
7
|
+
export default contactsWeb;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contacts on the web: their names, wherever a page shows who wrote
|
|
3
|
+
* (spaces' `names` resource, for the browser): "Ana", not "someone".
|
|
4
|
+
*/
|
|
5
|
+
import { definePlugin } from "../../../runtime/mod.js";
|
|
6
|
+
import { CONTACT } from "./contract.js";
|
|
7
|
+
export const contactsWeb = definePlugin({
|
|
8
|
+
name: "contacts-web",
|
|
9
|
+
resources: { names: { contact: { collection: "contact", prefix: CONTACT } } },
|
|
10
|
+
});
|
|
11
|
+
export default contactsWeb;
|
|
@@ -93,8 +93,8 @@ export declare const creditCode: {
|
|
|
93
93
|
private?: string[];
|
|
94
94
|
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
95
95
|
[x: string]: unknown;
|
|
96
|
-
until?: string | undefined;
|
|
97
96
|
person?: string | undefined;
|
|
97
|
+
until?: string | undefined;
|
|
98
98
|
note?: string | undefined;
|
|
99
99
|
org?: string | undefined;
|
|
100
100
|
expires?: string | undefined;
|
|
@@ -37,10 +37,12 @@ export const identity = definePlugin({
|
|
|
37
37
|
"person.set": setPerson,
|
|
38
38
|
"person.email": emailOf,
|
|
39
39
|
},
|
|
40
|
-
// Each person sees only themselves, and their own credentials.
|
|
41
|
-
guard: (actor, { collection }) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
:
|
|
40
|
+
// Each person sees only themselves, and their own credentials: nobody else does, whatever their id.
|
|
41
|
+
guard: (actor, { collection }) => {
|
|
42
|
+
if (collection !== "credential" && collection !== "person")
|
|
43
|
+
return undefined;
|
|
44
|
+
if (actor.kind !== "person")
|
|
45
|
+
return { _id: { $in: [] } };
|
|
46
|
+
return collection === "credential" ? { person: actor.id } : { _id: actor.id };
|
|
47
|
+
},
|
|
46
48
|
});
|
package/plugins/access/mod.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* - `spaces`: spaces, members, reach, and the rules every collection that
|
|
5
5
|
* shares its documents keeps to;
|
|
6
6
|
* - `identity`: people, sessions and keys, and who a secret proves;
|
|
7
|
+
* - `contacts`: people outside the org who talk to its agents (a WhatsApp
|
|
8
|
+
* customer), each in chats shared with them alone;
|
|
7
9
|
* - `googleSignIn`: sign-in with a Google ID token (the `google` resource
|
|
8
10
|
* names your client);
|
|
9
11
|
* - `accounts`: outside accounts people connect for their agents to use (a
|
|
@@ -17,8 +19,12 @@
|
|
|
17
19
|
import type { Plugin } from "../../runtime/mod.js";
|
|
18
20
|
export * from "./spaces/mod.js";
|
|
19
21
|
export * from "./identity/mod.js";
|
|
22
|
+
export * from "./contacts/mod.js";
|
|
20
23
|
export * from "./google/mod.js";
|
|
21
24
|
export * from "./accounts/mod.js";
|
|
22
25
|
export * from "./directory/mod.js";
|
|
23
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Spaces, identity and contacts, which every app with people has; Google
|
|
28
|
+
* sign-in is added beside them.
|
|
29
|
+
*/
|
|
24
30
|
export declare const access: Plugin[];
|
package/plugins/access/mod.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { contacts } from "./contacts/mod.js";
|
|
1
2
|
import { identity } from "./identity/mod.js";
|
|
2
3
|
import { spaces } from "./spaces/mod.js";
|
|
3
4
|
export * from "./spaces/mod.js";
|
|
4
5
|
export * from "./identity/mod.js";
|
|
6
|
+
export * from "./contacts/mod.js";
|
|
5
7
|
export * from "./google/mod.js";
|
|
6
8
|
export * from "./accounts/mod.js";
|
|
7
9
|
export * from "./directory/mod.js";
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Spaces, identity and contacts, which every app with people has; Google
|
|
12
|
+
* sign-in is added beside them.
|
|
13
|
+
*/
|
|
14
|
+
export const access = [spaces, identity, contacts];
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* answering there answers its new chats (its managers choose); `space.roster`
|
|
4
4
|
* says who answers there, for chat (its `roster` resource): the agents
|
|
5
5
|
* that are editors there, and that one. As the asker: a space they don't
|
|
6
|
-
* reach has nobody for them
|
|
6
|
+
* reach has nobody for them, unless they're present there through a document
|
|
7
|
+
* of it (a contact, in its chat): who answers isn't content, and only agents
|
|
8
|
+
* are listed, so it's read for them as the system.
|
|
7
9
|
*/
|
|
8
10
|
import { defineAction, people } from "../../../../runtime/mod.js";
|
|
9
11
|
import { rosterIn } from "../shared/agents.js";
|
|
10
|
-
import { must } from "../shared/can.js";
|
|
12
|
+
import { must, present } from "../shared/can.js";
|
|
11
13
|
export const agentAction = defineAction({
|
|
12
14
|
description: "Chooses the agent that answers a space's new chats: one working there",
|
|
13
15
|
input: {
|
|
@@ -39,12 +41,16 @@ export const rosterAction = defineAction({
|
|
|
39
41
|
},
|
|
40
42
|
record: false,
|
|
41
43
|
run: async (ctx, input) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
let reader = ctx;
|
|
45
|
+
const find = () => reader.db.collection("space").findOne({ _id: input.space });
|
|
46
|
+
let space = await find();
|
|
47
|
+
if (!space && await present(ctx, input.space)) {
|
|
48
|
+
reader = ctx.as();
|
|
49
|
+
space = await find();
|
|
50
|
+
}
|
|
45
51
|
if (!space)
|
|
46
52
|
return { agents: [] };
|
|
47
|
-
const agents = await rosterIn(
|
|
53
|
+
const agents = await rosterIn(reader, input.space);
|
|
48
54
|
const answers = space.agent && agents.includes(space.agent) ? space.agent : agents[0];
|
|
49
55
|
return { agents, ...(answers ? { default: answers } : {}) };
|
|
50
56
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `space.create`: a new space (shared by default), managed by whoever makes
|
|
3
|
-
* it, with the app's default agents working there.
|
|
3
|
+
* it, with the app's default agents working there. Not one the app declares
|
|
4
|
+
* (see shared/declared.ts): those are the app's, made by `space.keep`.
|
|
4
5
|
*/
|
|
5
6
|
import { defineAction, people } from "../../../../runtime/mod.js";
|
|
6
7
|
import { seat } from "../shared/agents.js";
|
|
8
|
+
import { declaredOf } from "../shared/declared.js";
|
|
7
9
|
import { memberKey, orgRoleOf } from "../shared/reach.js";
|
|
8
10
|
export const createAction = defineAction({
|
|
9
11
|
description: "Makes a space (a shared one, an org…); its maker manages it",
|
|
@@ -20,6 +22,13 @@ export const createAction = defineAction({
|
|
|
20
22
|
code: "forbidden",
|
|
21
23
|
});
|
|
22
24
|
}
|
|
25
|
+
// A space the app declares is the app's (`space.keep` makes it): made first by a person,
|
|
26
|
+
// they would manage it, and the app's customers with it.
|
|
27
|
+
if (input.id !== undefined && declaredOf(ctx, input.id)) {
|
|
28
|
+
throw Object.assign(new Error(`Space "${input.id}" is the app's own.`), {
|
|
29
|
+
code: "forbidden",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
23
32
|
const id = input.id ?? crypto.randomUUID();
|
|
24
33
|
const who = memberKey(ctx.actor);
|
|
25
34
|
// Nobody reaches a space before it exists: it's made as the system, for them.
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import { defineAction, people } from "../../../../runtime/mod.js";
|
|
9
9
|
import { joinable } from "../shared/personal.js";
|
|
10
10
|
import { may, must } from "../shared/can.js";
|
|
11
|
-
import { memberKey, orgRoleOf,
|
|
11
|
+
import { memberKey, orgRoleOf, rolesOf } from "../shared/reach.js";
|
|
12
|
+
import { checkRole } from "../shared/seat.js";
|
|
12
13
|
import { namesFor } from "../shared/names.js";
|
|
13
14
|
/** An email address, as invitations hold it. */
|
|
14
15
|
const EMAIL = /^[^\s@]+@[^\s@]+$/;
|
|
@@ -44,7 +45,7 @@ export const sendInvitationAction = defineAction({
|
|
|
44
45
|
if (!EMAIL.test(email))
|
|
45
46
|
throw refused("invalid", "That isn't an email address.");
|
|
46
47
|
const role = input.role ?? "editor";
|
|
47
|
-
if (!(role in
|
|
48
|
+
if (!(role in rolesOf(ctx))) {
|
|
48
49
|
throw refused("invalid", `No role "${role}".`);
|
|
49
50
|
}
|
|
50
51
|
await must(ctx, "manage", input.space, `You don't manage "${input.space}".`);
|
|
@@ -95,6 +96,8 @@ export const acceptInvitationAction = defineAction({
|
|
|
95
96
|
if (!found.mine)
|
|
96
97
|
throw refused("forbidden", "No such invitation for you.");
|
|
97
98
|
const key = memberKey(ctx.actor);
|
|
99
|
+
// An invitation stored before roles were checked by their own names only is checked here.
|
|
100
|
+
checkRole(ctx, key, found.role);
|
|
98
101
|
await ctx.as().transaction(async (tx) => {
|
|
99
102
|
const id = `${found.space}|${key}`;
|
|
100
103
|
const members = tx.db.collection("member");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const keepAction: import("../../../../runtime/define.js").ActionDef;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `space.keep`: a space the app declares (see shared/declared.ts), made, or
|
|
3
|
+
* kept, as declared: its name, and its agents as editors (the first
|
|
4
|
+
* answering its new chats). Nothing changes when it's as declared already;
|
|
5
|
+
* a space the app doesn't declare is left alone. Trusted code calls it when
|
|
6
|
+
* it needs the space (a line the app declares, before its first chat).
|
|
7
|
+
*
|
|
8
|
+
* A space with that id that the app didn't make (a person's, made before the
|
|
9
|
+
* app declared it) is refused, not adopted: its members would get what the
|
|
10
|
+
* app keeps there. Give the declared space another id, or archive that one.
|
|
11
|
+
*/
|
|
12
|
+
import { defineAction } from "../../../../runtime/mod.js";
|
|
13
|
+
import { declaredOf } from "../shared/declared.js";
|
|
14
|
+
export const keepAction = defineAction({
|
|
15
|
+
description: "Makes or keeps a space the app declares, as declared",
|
|
16
|
+
input: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: { id: { type: "string", minLength: 1 } },
|
|
19
|
+
required: ["id"],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
run: async (ctx, input) => {
|
|
23
|
+
const declared = declaredOf(ctx, input.id);
|
|
24
|
+
if (!declared)
|
|
25
|
+
return { space: null };
|
|
26
|
+
const system = ctx.as();
|
|
27
|
+
const agents = declared.agents ?? [];
|
|
28
|
+
const [space, members] = await Promise.all([
|
|
29
|
+
system.db.collection("space").findOne({ _id: input.id }),
|
|
30
|
+
system.db.collection("member").find({ space: input.id, on: { $exists: false } }),
|
|
31
|
+
]);
|
|
32
|
+
if (space && !space.declared) {
|
|
33
|
+
throw Object.assign(new Error(`Space "${input.id}" was made by a person, so it can't be the app's: declare another id.`), { code: "conflict" });
|
|
34
|
+
}
|
|
35
|
+
const seated = (agent) => members.some((m) => m.member === `agent:${agent}` && m.role === "editor");
|
|
36
|
+
const answers = space?.agent && agents.includes(space.agent) ? space.agent : agents[0];
|
|
37
|
+
if (space?.declared && space.name === declared.name && space.agent === answers &&
|
|
38
|
+
agents.every(seated))
|
|
39
|
+
return { space: input.id };
|
|
40
|
+
await system.transaction(async (tx) => {
|
|
41
|
+
await tx.db.collection("space").updateOne({ _id: input.id }, {
|
|
42
|
+
$set: {
|
|
43
|
+
name: declared.name,
|
|
44
|
+
kind: "shared",
|
|
45
|
+
declared: true,
|
|
46
|
+
...(answers ? { agent: answers } : {}),
|
|
47
|
+
},
|
|
48
|
+
}, { upsert: true });
|
|
49
|
+
for (const agent of agents.filter((a) => !seated(a))) {
|
|
50
|
+
await tx.db.collection("member").replaceOne({ _id: `${input.id}|agent:${agent}` }, { member: `agent:${agent}`, space: input.id, role: "editor" }, { upsert: true });
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return { space: input.id };
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* role. Only those who manage a space change its members. A member is a
|
|
4
4
|
* person or an agent (`{ kind, id }`), or another space (`{ kind: "space",
|
|
5
5
|
* id }`), which then draws on this one. A document shared on its own is the
|
|
6
|
-
* space, `on` its collection; managing its space manages its sharing.
|
|
6
|
+
* space, `on` its collection; managing its space manages its sharing. A
|
|
7
|
+
* contact (someone outside the org) is a member of documents only: its chat.
|
|
7
8
|
* People join a space by accepting an invitation (`invitation.send`) or a
|
|
8
9
|
* request they made: here, a person who's in already only changes role.
|
|
9
10
|
* An agent joins at once, as a viewer or an editor, if the manager adding
|
|
@@ -15,6 +16,7 @@ import { keepsAManager } from "../shared/managers.js";
|
|
|
15
16
|
import { joinable } from "../shared/personal.js";
|
|
16
17
|
import { may, must } from "../shared/can.js";
|
|
17
18
|
import { checkRole, seat } from "../shared/seat.js";
|
|
19
|
+
import { declaredAgent } from "../shared/declared.js";
|
|
18
20
|
import { docKey, memberKey, ORG } from "../shared/reach.js";
|
|
19
21
|
const who = {
|
|
20
22
|
type: "object",
|
|
@@ -30,17 +32,24 @@ async function manages(ctx, space, on) {
|
|
|
30
32
|
await must(ctx, "manage", space, `You don't manage "${space}".`);
|
|
31
33
|
return space;
|
|
32
34
|
}
|
|
33
|
-
const
|
|
35
|
+
const all = (ctx.resources.shared ?? {});
|
|
36
|
+
const shared = Object.hasOwn(all, on) ? all[on] : undefined;
|
|
34
37
|
const doc = shared ? await ctx.as().db.collection(on).findOne({ _id: space }) : null;
|
|
35
|
-
if (!doc)
|
|
38
|
+
if (!doc || !shared)
|
|
36
39
|
throw forbidden(`No ${on} "${space}".`);
|
|
37
40
|
const key = docKey(on, space);
|
|
38
41
|
const home = String(doc[shared.field ?? "in"]);
|
|
39
|
-
if (!await may(ctx, "manage",
|
|
42
|
+
if (!await may(ctx, "manage", space, on)) {
|
|
40
43
|
await must(ctx, "manage", home, `You don't manage "${home}".`);
|
|
41
44
|
}
|
|
42
45
|
return key;
|
|
43
46
|
}
|
|
47
|
+
/** Throws unless `member` may leave or change role in `space`: the app's own agents there stay. */
|
|
48
|
+
function appsOwn(ctx, space, member) {
|
|
49
|
+
if (member.kind === "agent" && declaredAgent(ctx, space, member.id)) {
|
|
50
|
+
throw forbidden(`${member.id} works here as the app declares: its settings keep it.`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
export const setMemberAction = defineAction({
|
|
45
54
|
description: "Makes someone a member of a space, with a role",
|
|
46
55
|
input: {
|
|
@@ -61,6 +70,8 @@ export const setMemberAction = defineAction({
|
|
|
61
70
|
const place = await manages(ctx, input.space, input.on);
|
|
62
71
|
const key = memberKey(input.member);
|
|
63
72
|
checkRole(ctx, key, input.role);
|
|
73
|
+
if (!input.on && input.role !== "editor")
|
|
74
|
+
appsOwn(ctx, input.space, input.member);
|
|
64
75
|
if (!input.on) {
|
|
65
76
|
joinable(await ctx.as().db.collection("space").findOne({ _id: input.space }), key);
|
|
66
77
|
if (input.member.kind === "agent")
|
|
@@ -93,6 +104,8 @@ export const removeMemberAction = defineAction({
|
|
|
93
104
|
if (input.space === ORG)
|
|
94
105
|
throw forbidden("People leave the org with org.remove.");
|
|
95
106
|
const place = await manages(ctx, input.space, input.on);
|
|
107
|
+
if (!input.on)
|
|
108
|
+
appsOwn(ctx, input.space, input.member);
|
|
96
109
|
if (!input.on)
|
|
97
110
|
await keepsAManager(ctx, input.space, memberKey(input.member));
|
|
98
111
|
await ctx.as().db.collection("member").deleteOne({
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* space keeps its name: it's what everyone's own is called.
|
|
4
4
|
*/
|
|
5
5
|
import { defineAction, people } from "../../../../runtime/mod.js";
|
|
6
|
+
import { declaredOf } from "../shared/declared.js";
|
|
6
7
|
import { PERSONAL } from "../shared/personal.js";
|
|
7
8
|
import { may } from "../shared/can.js";
|
|
8
9
|
const refuse = (message, code = "forbidden") => Object.assign(new Error(message), { code });
|
|
@@ -29,6 +30,9 @@ export const renameAction = defineAction({
|
|
|
29
30
|
}
|
|
30
31
|
if (found.kind === PERSONAL)
|
|
31
32
|
throw refuse("A Personal space keeps its name.", "invalid");
|
|
33
|
+
if (declaredOf(ctx, input.space)) {
|
|
34
|
+
throw refuse("This space is the app's own: its name is in its settings.", "invalid");
|
|
35
|
+
}
|
|
32
36
|
await system.db.collection("space").updateOne({ _id: input.space }, { $set: { name } });
|
|
33
37
|
return { space: input.space, name };
|
|
34
38
|
},
|
|
@@ -27,6 +27,10 @@ declare const spaceSchema: {
|
|
|
27
27
|
readonly agent: {
|
|
28
28
|
readonly type: "string";
|
|
29
29
|
};
|
|
30
|
+
/** The app's own (its `spaces` resource): its name and agents are as the app declares. */
|
|
31
|
+
readonly declared: {
|
|
32
|
+
readonly type: "boolean";
|
|
33
|
+
};
|
|
30
34
|
};
|
|
31
35
|
readonly required: readonly ["name", "kind"];
|
|
32
36
|
};
|
|
@@ -53,6 +57,10 @@ export declare const space: {
|
|
|
53
57
|
readonly agent: {
|
|
54
58
|
readonly type: "string";
|
|
55
59
|
};
|
|
60
|
+
/** The app's own (its `spaces` resource): its name and agents are as the app declares. */
|
|
61
|
+
readonly declared: {
|
|
62
|
+
readonly type: "boolean";
|
|
63
|
+
};
|
|
56
64
|
};
|
|
57
65
|
readonly required: readonly ["name", "kind"];
|
|
58
66
|
};
|
|
@@ -64,6 +72,7 @@ export declare const space: {
|
|
|
64
72
|
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
65
73
|
[x: string]: unknown;
|
|
66
74
|
owner?: string | undefined;
|
|
75
|
+
declared?: boolean | undefined;
|
|
67
76
|
agent?: string | undefined;
|
|
68
77
|
archived?: string | undefined;
|
|
69
78
|
kind: string;
|
|
@@ -18,6 +18,8 @@ const spaceSchema = {
|
|
|
18
18
|
archived: { type: "string" },
|
|
19
19
|
/** The agent that answers its new chats (`space.agent`): one working here. */
|
|
20
20
|
agent: { type: "string" },
|
|
21
|
+
/** The app's own (its `spaces` resource): its name and agents are as the app declares. */
|
|
22
|
+
declared: { type: "boolean" },
|
|
21
23
|
},
|
|
22
24
|
required: ["name", "kind"],
|
|
23
25
|
};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `invitation`, `profile`), its queries `space.reached` (each space with what the asker
|
|
10
10
|
* may do there) and `invitation.mine` (those to the asker's email), and its
|
|
11
11
|
* Actions (`space.create`, `space.personal`, `space.rename`, `space.can`,
|
|
12
|
-
* `space.leave`, `space.archive`, `space.agent`, `member.set`,
|
|
12
|
+
* `space.leave`, `space.archive`, `space.agent`, `space.keep`, `member.set`,
|
|
13
13
|
* `member.remove`, `invitation.send`, `invitation.accept`,
|
|
14
14
|
* `invitation.decline`, `request.grant`, `request.deny`).
|
|
15
15
|
*
|
|
@@ -59,9 +59,10 @@ export type { Member } from "./collections/member.js";
|
|
|
59
59
|
export type { Invitation } from "./collections/invitation.js";
|
|
60
60
|
export type { Request } from "./collections/request.js";
|
|
61
61
|
export type { Verb } from "./shared/reach.js";
|
|
62
|
+
export type { DeclaredSpace } from "./shared/declared.js";
|
|
62
63
|
export type { Profile } from "./collections/profile.js";
|
|
63
|
-
export { idsIn, nameOf, namesFor, namesIn, namesOf, type NamesResource, picturesIn, PROFILE, withNames, } from "./shared/names.js";
|
|
64
|
-
export { may, must, mustOwnOr } from "./shared/can.js";
|
|
64
|
+
export { idsIn, nameOf, namesFor, namesIn, namesOf, type NamesResource, type NamesSource, picturesIn, PROFILE, withNames, } from "./shared/names.js";
|
|
65
|
+
export { may, must, mustOwnOr, present, sharedWith } from "./shared/can.js";
|
|
65
66
|
export { ORG, runsOrg } from "./shared/reach.js";
|
|
66
67
|
export { PERSONAL } from "./shared/personal.js";
|
|
67
68
|
export { AGENT_ROLES } from "./views/web/who.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { idsIn, nameOf, namesFor, namesIn, namesOf, picturesIn, PROFILE, withNames, } from "./shared/names.js";
|
|
2
|
-
export { may, must, mustOwnOr } from "./shared/can.js";
|
|
2
|
+
export { may, must, mustOwnOr, present, sharedWith } from "./shared/can.js";
|
|
3
3
|
export { ORG, runsOrg } from "./shared/reach.js";
|
|
4
4
|
export { PERSONAL } from "./shared/personal.js";
|
|
5
5
|
export { AGENT_ROLES } from "./views/web/who.js";
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
* and each turn, the other spaces they can read for their person
|
|
37
37
|
* (`elsewhere` context), to look in when what they need isn't here.
|
|
38
38
|
*
|
|
39
|
+
* - **The app's own spaces** (the `spaces` resource, by id: a name and its
|
|
40
|
+
* agents) are made and kept by the system when something needs them
|
|
41
|
+
* (`space.keep`), owned by no person; people neither rename them nor take
|
|
42
|
+
* their agents out.
|
|
43
|
+
*
|
|
39
44
|
* Collections opt in through the `shared` resource:
|
|
40
45
|
*
|
|
41
46
|
* ```ts
|
|
@@ -51,8 +56,9 @@ export type { Member } from "./collections/member.js";
|
|
|
51
56
|
export type { Reached, Space } from "./collections/space.js";
|
|
52
57
|
export type { SpaceAgents, SpaceInvite, SpaceSidebar, SpaceTab } from "./contract.js";
|
|
53
58
|
export type { Request } from "./collections/request.js";
|
|
54
|
-
export { idsIn, nameOf, namesFor, namesIn, namesOf, type NamesResource, picturesIn, PROFILE, withNames, } from "./shared/names.js";
|
|
59
|
+
export { idsIn, nameOf, namesFor, namesIn, namesOf, type NamesResource, type NamesSource, picturesIn, PROFILE, withNames, } from "./shared/names.js";
|
|
55
60
|
export { memberKey, ORG, ORG_ROLES, type OrgRole, orgRoleOf, type Reach, reachOf, ROLES, type Verb, } from "./shared/reach.js";
|
|
56
61
|
export type { Shared } from "./shared/rules.js";
|
|
62
|
+
export type { DeclaredSpace } from "./shared/declared.js";
|
|
57
63
|
export declare const spaces: Plugin;
|
|
58
64
|
export default spaces;
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
* and each turn, the other spaces they can read for their person
|
|
37
37
|
* (`elsewhere` context), to look in when what they need isn't here.
|
|
38
38
|
*
|
|
39
|
+
* - **The app's own spaces** (the `spaces` resource, by id: a name and its
|
|
40
|
+
* agents) are made and kept by the system when something needs them
|
|
41
|
+
* (`space.keep`), owned by no person; people neither rename them nor take
|
|
42
|
+
* their agents out.
|
|
43
|
+
*
|
|
39
44
|
* Collections opt in through the `shared` resource:
|
|
40
45
|
*
|
|
41
46
|
* ```ts
|
|
@@ -47,6 +52,7 @@
|
|
|
47
52
|
import { definePlugin } from "../../../runtime/mod.js";
|
|
48
53
|
import { agentAction, rosterAction } from "./actions/agents.js";
|
|
49
54
|
import { createAction } from "./actions/create.js";
|
|
55
|
+
import { keepAction } from "./actions/keep.js";
|
|
50
56
|
import { archiveAction } from "./actions/archive.js";
|
|
51
57
|
import { canAction } from "./actions/can.js";
|
|
52
58
|
import { leaveAction } from "./actions/leave.js";
|
|
@@ -80,6 +86,7 @@ export const spaces = definePlugin({
|
|
|
80
86
|
collections: { space, member, request, invitation, profile },
|
|
81
87
|
actions: {
|
|
82
88
|
"space.create": createAction,
|
|
89
|
+
"space.keep": keepAction,
|
|
83
90
|
"space.personal": personalAction,
|
|
84
91
|
"space.rename": renameAction,
|
|
85
92
|
"space.can": canAction,
|
|
@@ -121,7 +128,7 @@ export const spaces = definePlugin({
|
|
|
121
128
|
// Who works in a space, for chat: its agents.
|
|
122
129
|
roster: { spaces: { action: "space.roster" } },
|
|
123
130
|
// Where people's names are, for whatever shows a person (pages, agents' prompts).
|
|
124
|
-
names: { collection: PROFILE },
|
|
131
|
+
names: { people: { collection: PROFILE } },
|
|
125
132
|
// Spaces by name on Usage (a Personal space says whose it is).
|
|
126
133
|
usageNames: {
|
|
127
134
|
space: { tag: "tags.space", collection: "space", field: "name", owner: "owner" },
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `request_access`, for agents: asks the managers of a space the agent (or
|
|
3
|
-
* its person) can't reach to let them in, with a reason. They decide; it
|
|
4
|
-
* doesn't wait.
|
|
5
|
-
*/
|
|
6
1
|
import type { Tool } from "../../../agents/chat/contract.js";
|
|
7
2
|
export declare const tools: Record<string, Tool>;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `request_access`, for agents: asks the managers of a space the agent (or
|
|
3
|
+
* its person) can't reach to let them in, with a reason. They decide; it
|
|
4
|
+
* doesn't wait. Not for an agent working for a contact: a contact is let
|
|
5
|
+
* into its chat alone.
|
|
6
|
+
*/
|
|
7
|
+
import { principalOf } from "../../../../runtime/mod.js";
|
|
1
8
|
import { PERSONAL } from "../shared/personal.js";
|
|
2
9
|
import { memberKey } from "../shared/reach.js";
|
|
3
10
|
import { nameOf, namesFor } from "../shared/names.js";
|
|
4
11
|
export const tools = {
|
|
5
12
|
request_access: {
|
|
6
|
-
offer:
|
|
13
|
+
offer: (_agent, _thread, ctx) => principalOf(ctx.actor)?.kind !== "contact",
|
|
7
14
|
description: "Ask the managers of a space you can't see to let the person you work for in, " +
|
|
8
15
|
"saying why. Use it when what you need is somewhere you aren't allowed.",
|
|
9
16
|
input: {
|
|
@@ -16,6 +23,9 @@ export const tools = {
|
|
|
16
23
|
const who = (ctx.actor?.for ?? ctx.actor);
|
|
17
24
|
if (!who)
|
|
18
25
|
return "Nobody to ask for.";
|
|
26
|
+
if (principalOf(ctx.actor)?.kind === "contact") {
|
|
27
|
+
return "Not here: someone outside the org is let into this conversation alone.";
|
|
28
|
+
}
|
|
19
29
|
// Found by name, whoever can see it: the person named it. Nobody asks into a Personal space.
|
|
20
30
|
const system = ctx.as();
|
|
21
31
|
const found = (await system.db.collection("space")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rolesOf } from "./reach.js";
|
|
2
2
|
/** The app's agents that join new spaces: its defaults, or the first it declares. */
|
|
3
3
|
export function startingAgents(ctx) {
|
|
4
4
|
const declared = (ctx.resources.agents ?? {});
|
|
@@ -74,7 +74,7 @@ export async function unseat(system, id, spaces) {
|
|
|
74
74
|
* defaults first, then by name.
|
|
75
75
|
*/
|
|
76
76
|
export async function rosterIn(ctx, space) {
|
|
77
|
-
const roles =
|
|
77
|
+
const roles = rolesOf(ctx);
|
|
78
78
|
const starting = startingAgents(ctx);
|
|
79
79
|
const members = await ctx.db.collection("member").find({ space });
|
|
80
80
|
return members
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Whether the caller may do something in a space (`read`, `write`, `manage`):
|
|
3
|
-
* what reach says, with every limit on them
|
|
4
|
-
*
|
|
3
|
+
* what reach says, with every limit on them; and whether they're there at all
|
|
4
|
+
* (`present`: the space, or a document in it, such as a contact's chat).
|
|
5
|
+
* Trusted code asks here before it goes on as the system, and no one else
|
|
6
|
+
* works this out.
|
|
5
7
|
*/
|
|
6
8
|
import { type Context } from "../../../../runtime/mod.js";
|
|
7
9
|
import { type Verb } from "./reach.js";
|
|
8
|
-
export declare function may(ctx: Context, verb: Verb, space: string
|
|
10
|
+
export declare function may(ctx: Context, verb: Verb, space: string,
|
|
11
|
+
/** A document of this collection, its id `space`, shared on its own: asked about as itself. */
|
|
12
|
+
on?: string): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the caller is in `space` at all: they reach it, or a document in it
|
|
15
|
+
* on its own (a contact, its chat there). What's said to anyone there (who
|
|
16
|
+
* answers in it) is said to them too.
|
|
17
|
+
*/
|
|
18
|
+
export declare function present(ctx: Context, space: string): Promise<boolean>;
|
|
9
19
|
/** Throws `forbidden`, with `message`, unless the caller may. */
|
|
10
20
|
export declare function must(ctx: Context, verb: Verb, space: string, message?: string): Promise<void>;
|
|
11
21
|
/** Throws `forbidden`, with `message`, unless it's the caller's own (`owner`), or the caller may. */
|
|
12
22
|
export declare function mustOwnOr(ctx: Context, owner: string, verb: Verb, space: string, message: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Who a document is shared with on its own (a chat's contacts:
|
|
25
|
+
* `contact:c1`), read as the system: none for one that isn't.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sharedWith(ctx: Pick<Context, "as">, on: string, id: string): Promise<string[]>;
|