copilotz 1.0.0-rc.21 → 1.0.0-rc.23
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 +320 -1
- package/README.md +217 -87
- package/hosts/orgs/mod.d.ts +33 -13
- package/hosts/orgs/mod.js +183 -84
- package/hosts/web/address.d.ts +11 -0
- package/hosts/web/address.js +46 -0
- package/hosts/web/assets.js +11 -5
- package/hosts/web/entrances.d.ts +250 -0
- package/hosts/web/entrances.js +362 -0
- package/hosts/web/host.d.ts +15 -3
- package/hosts/web/host.js +31 -18
- package/hosts/web/mod.d.ts +4 -2
- package/hosts/web/mod.js +6 -0
- package/hosts/web/node/bundle.d.ts +5 -0
- package/hosts/web/node/bundle.js +1 -1
- package/hosts/web/node/mod.d.ts +6 -4
- package/hosts/web/node/mod.js +6 -4
- package/hosts/web/node/serve.d.ts +20 -23
- package/hosts/web/node/serve.js +10 -21
- package/hosts/web/routes.d.ts +23 -17
- package/hosts/web/routes.js +56 -32
- package/hosts/web/server.d.ts +89 -44
- package/hosts/web/server.js +208 -108
- package/hosts/web/signin.d.ts +7 -10
- package/hosts/web/signin.js +6 -3
- package/hosts/web/surface.d.ts +20 -0
- package/hosts/web/surface.js +42 -0
- package/hosts/web/theme/css.d.ts +2 -1
- package/hosts/web/theme/css.js +9 -2
- package/hosts/web/tickets.d.ts +14 -1
- package/hosts/web/tickets.js +30 -7
- package/hosts/web/widget.d.ts +31 -0
- package/hosts/web/widget.js +429 -0
- package/hosts/web/widgets.d.ts +43 -0
- package/hosts/web/widgets.js +117 -0
- package/package.json +5 -1
- package/plugins/access/contacts/actions/forget.js +3 -1
- package/plugins/access/contacts/actions/start.js +18 -8
- package/plugins/access/contacts/collections/contact.d.ts +2 -2
- package/plugins/access/contacts/collections/contact.js +1 -1
- package/plugins/access/contacts/contract.d.ts +5 -5
- package/plugins/access/contacts/contract.js +5 -5
- package/plugins/access/contacts/mod.d.ts +4 -0
- package/plugins/access/contacts/mod.js +4 -0
- package/plugins/access/contacts/views/contact.js +1 -0
- package/plugins/access/dev/actions/sign-in.d.ts +1 -0
- package/plugins/access/dev/actions/sign-in.js +38 -0
- package/plugins/access/dev/mod.d.ts +17 -0
- package/plugins/access/dev/mod.js +31 -0
- package/plugins/access/dev/shared/nearby.d.ts +2 -0
- package/plugins/access/dev/shared/nearby.js +27 -0
- package/plugins/access/directory/actions/invite.js +2 -2
- package/plugins/access/directory/actions/org.js +11 -8
- package/plugins/access/directory/collections/credit-code.d.ts +1 -1
- package/plugins/access/google/actions/sign-in.js +2 -0
- package/plugins/access/google/mod.d.ts +4 -2
- package/plugins/access/google/mod.js +15 -2
- package/plugins/access/identity/actions/session.js +5 -3
- package/plugins/access/identity/mod.d.ts +4 -2
- package/plugins/access/identity/mod.js +17 -2
- package/plugins/access/mod.d.ts +7 -0
- package/plugins/access/mod.js +1 -0
- package/plugins/access/spaces/shared/declared.d.ts +1 -1
- package/plugins/access/spaces/shared/rules.d.ts +16 -5
- package/plugins/access/spaces/shared/rules.js +74 -6
- package/plugins/agents/chat/actions/send.d.ts +21 -0
- package/plugins/agents/chat/actions/send.js +72 -13
- package/plugins/agents/chat/collections/file.d.ts +15 -0
- package/plugins/agents/chat/collections/file.js +12 -3
- package/plugins/agents/chat/collections/live.d.ts +11 -0
- package/plugins/agents/chat/collections/live.js +11 -1
- package/plugins/agents/chat/collections/message.d.ts +1 -1
- package/plugins/agents/chat/collections/wait.d.ts +1 -1
- package/plugins/agents/chat/contract.d.ts +3 -2
- package/plugins/agents/chat/contract.js +1 -0
- package/plugins/agents/chat/mod.d.ts +9 -3
- package/plugins/agents/chat/mod.js +28 -7
- package/plugins/agents/chat/processors/failed.js +8 -3
- package/plugins/agents/chat/processors/turn.js +6 -3
- package/plugins/agents/chat/shared/agents.js +11 -2
- package/plugins/agents/chat/shared/live.d.ts +4 -2
- package/plugins/agents/chat/shared/live.js +2 -1
- package/plugins/agents/chat/shared/types.d.ts +8 -0
- package/plugins/agents/history/collections/outline.d.ts +2 -2
- package/plugins/agents/openapi/shared/files.js +2 -0
- package/plugins/agents/routines/collections/routine.d.ts +1 -1
- package/plugins/billing/credits/collections/plan.d.ts +2 -2
- package/plugins/billing/credits/collections/room.d.ts +1 -1
- package/plugins/billing/usage/collections/rollup.d.ts +2 -2
- package/plugins/billing/usage/collections/usage.d.ts +2 -2
- package/plugins/compute/cloud/actions/pool.js +2 -0
- package/plugins/compute/cloud/actions/remote.js +4 -2
- package/plugins/compute/cloud/actions/vms.js +2 -0
- package/plugins/compute/cloud/collections/pool-vm.d.ts +1 -1
- package/plugins/compute/computers/actions/admit.js +2 -0
- package/plugins/compute/computers/actions/code.js +2 -0
- package/plugins/compute/computers/actions/enrollment.js +2 -0
- package/plugins/compute/computers/actions/work.js +3 -0
- 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/resources/previews.js +5 -2
- package/plugins/interfaces/maintenance/mod.d.ts +3 -1
- package/plugins/interfaces/maintenance/mod.js +3 -1
- package/plugins/interfaces/mcp/actions/call.d.ts +4 -0
- package/plugins/interfaces/mcp/actions/call.js +120 -18
- package/plugins/interfaces/mcp/actions/conversation.d.ts +1 -0
- package/plugins/interfaces/mcp/actions/conversation.js +49 -0
- package/plugins/interfaces/mcp/actions/prune.js +5 -3
- package/plugins/interfaces/mcp/collections/opening.d.ts +24 -0
- package/plugins/interfaces/mcp/collections/opening.js +28 -0
- package/plugins/interfaces/mcp/mod.d.ts +27 -3
- package/plugins/interfaces/mcp/mod.js +42 -7
- package/plugins/interfaces/mcp/resources/server.d.ts +13 -4
- package/plugins/interfaces/mcp/resources/server.js +163 -21
- package/plugins/interfaces/mcp/resources/tools.d.ts +88 -12
- package/plugins/interfaces/mcp/resources/tools.js +113 -19
- package/plugins/interfaces/mcp/resources/widgets.d.ts +161 -0
- package/plugins/interfaces/mcp/resources/widgets.js +246 -0
- package/plugins/interfaces/mcp/shared/keys.d.ts +25 -19
- package/plugins/interfaces/mcp/shared/keys.js +55 -9
- package/plugins/interfaces/mcp/shared/settings.d.ts +70 -37
- package/plugins/interfaces/mcp/shared/settings.js +64 -39
- package/plugins/interfaces/mcp/views/offered.d.ts +1 -1
- package/plugins/interfaces/mod.d.ts +2 -1
- package/plugins/interfaces/mod.js +2 -1
- package/plugins/interfaces/voice/collections/blocked.d.ts +2 -2
- package/plugins/interfaces/voice/collections/call.d.ts +3 -3
- package/plugins/interfaces/voice/contract.d.ts +1 -1
- package/plugins/interfaces/voice/mod.d.ts +3 -3
- package/plugins/interfaces/voice/mod.js +3 -3
- package/plugins/interfaces/voice/resources/relay.d.ts +5 -3
- package/plugins/interfaces/voice/resources/relay.js +17 -6
- package/plugins/interfaces/voice/resources/tools.js +2 -0
- package/plugins/interfaces/voice/shared/settings.d.ts +5 -0
- package/plugins/interfaces/voice/views/call.d.ts +18 -11
- package/plugins/interfaces/voice/views/call.js +15 -3
- package/plugins/interfaces/voice/views/message.d.ts +1 -1
- package/plugins/interfaces/web/actions/arrive.d.ts +1 -0
- package/plugins/interfaces/web/actions/arrive.js +120 -0
- package/plugins/interfaces/web/actions/prune.d.ts +1 -0
- package/plugins/interfaces/web/actions/prune.js +51 -0
- package/plugins/interfaces/web/actions/sending.d.ts +1 -0
- package/plugins/interfaces/web/actions/sending.js +222 -0
- package/plugins/interfaces/web/actions/spent.d.ts +2 -0
- package/plugins/interfaces/web/actions/spent.js +59 -0
- package/plugins/interfaces/web/collections/rate.d.ts +122 -0
- package/plugins/interfaces/web/collections/rate.js +37 -0
- package/plugins/interfaces/web/collections/visitor.d.ts +110 -0
- package/plugins/interfaces/web/collections/visitor.js +64 -0
- package/plugins/interfaces/web/contract.d.ts +4 -0
- package/plugins/interfaces/web/contract.js +1 -0
- package/plugins/interfaces/web/lines.d.ts +36 -0
- package/plugins/interfaces/web/lines.js +78 -0
- package/plugins/interfaces/web/processors/forget.d.ts +10 -0
- package/plugins/interfaces/web/processors/forget.js +14 -0
- package/plugins/interfaces/web/resources/entrance.d.ts +47 -0
- package/plugins/interfaces/web/resources/entrance.js +83 -0
- package/plugins/interfaces/web/resources/spend.d.ts +2 -0
- package/plugins/interfaces/web/resources/spend.js +62 -0
- package/plugins/interfaces/web/shared/budget.d.ts +65 -0
- package/plugins/interfaces/web/shared/budget.js +134 -0
- package/plugins/interfaces/web/shared/lines.d.ts +158 -0
- package/plugins/interfaces/web/shared/lines.js +156 -0
- package/plugins/interfaces/web/shared/secret.d.ts +33 -0
- package/plugins/interfaces/web/shared/secret.js +86 -0
- package/plugins/interfaces/whatsapp/collections/phone.d.ts +1 -1
- package/plugins/interfaces/whatsapp/mod.d.ts +1 -1
- package/plugins/interfaces/whatsapp/mod.js +1 -1
- package/plugins/interfaces/whatsapp/views/message.d.ts +1 -1
- package/plugins/models/contract.d.ts +1 -1
- package/plugins/models/shared/generate.js +13 -4
- package/plugins/models/shared/transcribe.js +7 -1
- package/plugins/models/shared/use.d.ts +16 -2
- package/plugins/models/shared/use.js +20 -0
- package/runtime/browsers.d.ts +153 -17
- package/runtime/browsers.js +336 -30
- package/runtime/cache.js +25 -5
- package/runtime/caller.d.ts +117 -0
- package/runtime/caller.js +215 -0
- package/runtime/client.d.ts +47 -3
- package/runtime/client.js +132 -42
- package/runtime/define.d.ts +30 -9
- package/runtime/executor.js +7 -6
- package/runtime/expiring.d.ts +23 -0
- package/runtime/expiring.js +64 -0
- package/runtime/links.d.ts +27 -4
- package/runtime/links.js +49 -11
- package/runtime/memory.js +102 -15
- package/runtime/mod.d.ts +3 -1
- package/runtime/mod.js +3 -1
- package/runtime/mongo.d.ts +12 -0
- package/runtime/mongo.js +44 -0
- package/runtime/observe.js +82 -9
- package/runtime/ops.d.ts +9 -1
- package/runtime/owner.d.ts +14 -1
- package/runtime/owner.js +78 -23
- package/runtime/reads.js +2 -2
- package/runtime/registry.js +9 -3
- package/runtime/runtime.d.ts +7 -0
- package/runtime/runtime.js +1 -0
- package/runtime/timers.js +2 -0
- package/runtime/views.d.ts +1 -1
- package/runtime/views.js +2 -2
- package/runtime/wire.d.ts +1 -1
- package/stores/sql/postgres/maintenance.d.ts +8 -1
- package/stores/sql/postgres/maintenance.js +76 -9
- package/stores/sql/postgres/mod.d.ts +12 -4
- package/stores/sql/postgres/mod.js +21 -8
- package/plugins/interfaces/mcp/shared/caller.d.ts +0 -45
- package/plugins/interfaces/mcp/shared/caller.js +0 -99
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
12
|
* A browser keeps its session in an httpOnly, Secure cookie its host sets
|
|
13
|
-
* from
|
|
14
|
-
*
|
|
13
|
+
* from a sign-in's session (`session`: the web host's entrance this plugin
|
|
14
|
+
* declares, which `credential.actor` reads and `session.end` ends on sign
|
|
15
|
+
* out); a key goes in an Authorization header. Secrets are kept only as
|
|
16
|
+
* hashes; deleting a credential revokes it.
|
|
15
17
|
*
|
|
16
18
|
* A sign-in method keeps what it verified about someone (`person.set`: their
|
|
17
19
|
* email), and plugins that match people by email ask for it (`person.email`).
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
12
|
* A browser keeps its session in an httpOnly, Secure cookie its host sets
|
|
13
|
-
* from
|
|
14
|
-
*
|
|
13
|
+
* from a sign-in's session (`session`: the web host's entrance this plugin
|
|
14
|
+
* declares, which `credential.actor` reads and `session.end` ends on sign
|
|
15
|
+
* out); a key goes in an Authorization header. Secrets are kept only as
|
|
16
|
+
* hashes; deleting a credential revokes it.
|
|
15
17
|
*
|
|
16
18
|
* A sign-in method keeps what it verified about someone (`person.set`: their
|
|
17
19
|
* email), and plugins that match people by email ask for it (`person.email`).
|
|
@@ -37,6 +39,19 @@ export const identity = definePlugin({
|
|
|
37
39
|
"person.set": setPerson,
|
|
38
40
|
"person.email": emailOf,
|
|
39
41
|
},
|
|
42
|
+
// A browser is the person its session cookie proves (the web host's entrances), first of all.
|
|
43
|
+
// The cookie is the host's alone (`__Host-session` wherever it's Secure): no other host under
|
|
44
|
+
// the domain (a preview's) can put a session of its choosing in its place.
|
|
45
|
+
resources: {
|
|
46
|
+
entrances: {
|
|
47
|
+
session: {
|
|
48
|
+
cookie: "session",
|
|
49
|
+
query: "credential.actor",
|
|
50
|
+
end: "session.end",
|
|
51
|
+
hostOnly: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
40
55
|
// Each person sees only themselves, and their own credentials: nobody else does, whatever their id.
|
|
41
56
|
guard: (actor, { collection }) => {
|
|
42
57
|
if (collection !== "credential" && collection !== "person")
|
package/plugins/access/mod.d.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* customer), each in chats shared with them alone;
|
|
9
9
|
* - `googleSignIn`: sign-in with a Google ID token (the `google` resource
|
|
10
10
|
* names your client);
|
|
11
|
+
* - `devSignIn`: sign-in by name, from this machine only, for trying things
|
|
12
|
+
* out;
|
|
11
13
|
* - `accounts`: outside accounts people connect for their agents to use (a
|
|
12
14
|
* ChatGPT plan, as a model provider); its front end is `accountsWeb`
|
|
13
15
|
* (accounts/web.tsx);
|
|
@@ -15,12 +17,17 @@
|
|
|
15
17
|
* serve many orgs (`hosts/orgs`; see design/tenancy.md).
|
|
16
18
|
*
|
|
17
19
|
* plugins: [...access, googleSignIn, { name: "app", resources: { shared: { note: {} } } }]
|
|
20
|
+
*
|
|
21
|
+
* Who a browser is comes from here too: identity's session (a person), and
|
|
22
|
+
* the web interface's lines (`webLines`: a visitor), the web host's `entrances`; and how
|
|
23
|
+
* people sign in, Google's and dev sign-in's `signIn`.
|
|
18
24
|
*/
|
|
19
25
|
import type { Plugin } from "../../runtime/mod.js";
|
|
20
26
|
export * from "./spaces/mod.js";
|
|
21
27
|
export * from "./identity/mod.js";
|
|
22
28
|
export * from "./contacts/mod.js";
|
|
23
29
|
export * from "./google/mod.js";
|
|
30
|
+
export * from "./dev/mod.js";
|
|
24
31
|
export * from "./accounts/mod.js";
|
|
25
32
|
export * from "./directory/mod.js";
|
|
26
33
|
/**
|
package/plugins/access/mod.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the app's, so people neither rename it nor take its agents out.
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
|
-
* resources: { spaces: { line: { name: "
|
|
9
|
+
* resources: { spaces: { line: { name: "Viação Azul", agents: ["booking"] } } }
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
12
|
import type { Context } from "../../../../runtime/mod.js";
|
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
* field): an actor reads those in spaces they may read, and writes those in
|
|
5
5
|
* spaces they may write (or manage, for some), plus documents shared with
|
|
6
6
|
* them on their own and those documents' parts (a chat's messages come with
|
|
7
|
-
* it)
|
|
7
|
+
* it), a contact only what its collection lets one read (a chat's messages,
|
|
8
|
+
* not its agents' private steps); documents that are members (agents) are
|
|
9
|
+
* read where they work too. A
|
|
8
10
|
* query that names a space, or a document it reaches, needs nothing more:
|
|
9
11
|
* it goes to the store as it is. Spaces and memberships are readable where reached and
|
|
10
|
-
* changed only by those who manage them
|
|
11
|
-
*
|
|
12
|
+
* changed only by those who manage them (and a contact's own memberships read by
|
|
13
|
+
* its own key: where its chats are); invitations are their
|
|
14
|
+
* managers', and read by whom they're to (by the email they signed in with).
|
|
15
|
+
* A contact's own read from its browser (`direct`) names what of its own it
|
|
16
|
+
* reads, 32 ids at most: its chats or documents, or its memberships by its key.
|
|
12
17
|
*/
|
|
13
|
-
import type
|
|
18
|
+
import { type Filter, type Guard } from "../../../../runtime/mod.js";
|
|
14
19
|
import { type Verb } from "./reach.js";
|
|
15
20
|
/**
|
|
16
21
|
* The `shared` resource: collections whose documents live in spaces, the
|
|
@@ -21,7 +26,10 @@ import { type Verb } from "./reach.js";
|
|
|
21
26
|
* readable too where they're members, and whether each is part of a document
|
|
22
27
|
* of another shared collection (`part`: that collection, which its field of
|
|
23
28
|
* the same name names: a message's `thread`), reached with it when that
|
|
24
|
-
* document is shared on its own
|
|
29
|
+
* document is shared on its own, and what of it a contact reads (`contact`:
|
|
30
|
+
* a filter its documents must match too, for a contact acting itself, never
|
|
31
|
+
* the agent working for it: a chat's messages without its agents' private
|
|
32
|
+
* steps).
|
|
25
33
|
*/
|
|
26
34
|
export type Shared = Record<string, {
|
|
27
35
|
field?: string;
|
|
@@ -29,5 +37,8 @@ export type Shared = Record<string, {
|
|
|
29
37
|
write?: Verb;
|
|
30
38
|
member?: string;
|
|
31
39
|
part?: string;
|
|
40
|
+
contact?: Filter;
|
|
32
41
|
}>;
|
|
42
|
+
/** The most ids a contact's own read names (each its own: a chat, a document). */
|
|
43
|
+
export declare const NAMED = 32;
|
|
33
44
|
export declare const rules: Guard;
|
|
@@ -1,14 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules, as filters (the runtime's `guard`). A shared collection's
|
|
3
|
+
* documents live `in` a space (the `shared` resource names them and their
|
|
4
|
+
* field): an actor reads those in spaces they may read, and writes those in
|
|
5
|
+
* spaces they may write (or manage, for some), plus documents shared with
|
|
6
|
+
* them on their own and those documents' parts (a chat's messages come with
|
|
7
|
+
* it), a contact only what its collection lets one read (a chat's messages,
|
|
8
|
+
* not its agents' private steps); documents that are members (agents) are
|
|
9
|
+
* read where they work too. A
|
|
10
|
+
* query that names a space, or a document it reaches, needs nothing more:
|
|
11
|
+
* it goes to the store as it is. Spaces and memberships are readable where reached and
|
|
12
|
+
* changed only by those who manage them (and a contact's own memberships read by
|
|
13
|
+
* its own key: where its chats are); invitations are their
|
|
14
|
+
* managers', and read by whom they're to (by the email they signed in with).
|
|
15
|
+
* A contact's own read from its browser (`direct`) names what of its own it
|
|
16
|
+
* reads, 32 ids at most: its chats or documents, or its memberships by its key.
|
|
17
|
+
*/
|
|
18
|
+
import { failure } from "../../../../runtime/mod.js";
|
|
1
19
|
import { membersOf } from "./agents.js";
|
|
2
20
|
import { homeOf, memberKey, reachOf, where } from "./reach.js";
|
|
3
21
|
/** The documents of `on` reached on their own with `verb`: each id, and the space it lives in. */
|
|
4
22
|
const held = (reach, verb, on) => [...reach].flatMap(([key, r]) => r.on === on && r.home && r.can.has(verb)
|
|
5
23
|
? [[key.slice(on.length + 1), r.home]]
|
|
6
24
|
: []);
|
|
7
|
-
|
|
25
|
+
/** The ids a filter's condition names by equality (a string, `$eq`, `$in` of strings); else none. */
|
|
26
|
+
const idsIn = (condition) => {
|
|
27
|
+
if (typeof condition === "string")
|
|
28
|
+
return [condition];
|
|
29
|
+
if (!condition || typeof condition !== "object")
|
|
30
|
+
return undefined;
|
|
31
|
+
const { $eq, $in, ...rest } = condition;
|
|
32
|
+
if (Object.keys(rest).length)
|
|
33
|
+
return undefined;
|
|
34
|
+
if (typeof $eq === "string" && $in === undefined)
|
|
35
|
+
return [$eq];
|
|
36
|
+
if (Array.isArray($in) && $eq === undefined && $in.every((id) => typeof id === "string")) {
|
|
37
|
+
return $in;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
/** The most ids a contact's own read names (each its own: a chat, a document). */
|
|
42
|
+
export const NAMED = 32;
|
|
43
|
+
/** Refuses a contact's own read that doesn't name what of its own it reads. */
|
|
44
|
+
const unnamed = (collection, what) => failure("forbidden", `A contact reads "${collection}" naming what of its own it reads: ${what}`, {
|
|
45
|
+
public: true,
|
|
46
|
+
});
|
|
47
|
+
export const rules = async (actor, { collection, access, filter, direct }, ctx) => {
|
|
8
48
|
const shared = (ctx.resources.shared ?? {});
|
|
9
49
|
const own = ["space", "member", "request", "invitation"];
|
|
10
50
|
if (!Object.hasOwn(shared, collection) && !own.includes(collection))
|
|
11
51
|
return undefined;
|
|
52
|
+
// A contact's own read from its browser names what of its own it reads (anything wider would
|
|
53
|
+
// run again on every change to the collection): of these, only its memberships, by its key.
|
|
54
|
+
const mineOnly = direct && actor.kind === "contact";
|
|
55
|
+
if (mineOnly && own.includes(collection)) {
|
|
56
|
+
if (collection !== "member" || filter?.member !== memberKey(actor)) {
|
|
57
|
+
throw unnamed(collection, "its memberships, by its own key (member)");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
12
60
|
const reach = await reachOf(actor, ctx);
|
|
13
61
|
if (collection === "invitation") {
|
|
14
62
|
const managed = { space: { $in: where(reach, "manage") } };
|
|
@@ -29,6 +77,11 @@ export const rules = async (actor, { collection, access, filter }, ctx) => {
|
|
|
29
77
|
const spaces = where(by, access === "read" ? "read" : "manage");
|
|
30
78
|
if (collection === "space")
|
|
31
79
|
return { _id: { $in: spaces } };
|
|
80
|
+
// Where a contact is a member, asked by its own key: it finds its chats so. (Anyone else
|
|
81
|
+
// reads memberships as far as they reach, as below: a key `within` a space, that space.)
|
|
82
|
+
if (access === "read" && actor.kind === "contact" && filter?.member === memberKey(actor)) {
|
|
83
|
+
return { member: memberKey(actor) };
|
|
84
|
+
}
|
|
32
85
|
// Who a document of a space is shared with on its own (a contact, in a chat), asked by its key.
|
|
33
86
|
const named = filter?.space;
|
|
34
87
|
if (access === "read" && typeof named === "string" && !spaces.includes(named)) {
|
|
@@ -38,13 +91,16 @@ export const rules = async (actor, { collection, access, filter }, ctx) => {
|
|
|
38
91
|
}
|
|
39
92
|
return { space: { $in: spaces } };
|
|
40
93
|
}
|
|
41
|
-
const { field = "in", labels, write = "write", member, part } = shared[collection];
|
|
94
|
+
const { field = "in", labels, write = "write", member, part, contact } = shared[collection];
|
|
42
95
|
const verb = access === "read" ? "read" : write;
|
|
43
96
|
const spaces = where(reach, verb);
|
|
44
|
-
// A labelled document needs its sources reached too, to read or change it
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
:
|
|
97
|
+
// A labelled document needs its sources reached too, to read or change it; a contact acting
|
|
98
|
+
// itself, what its collection lets a contact reach of it (not an agent's private steps).
|
|
99
|
+
const also = [
|
|
100
|
+
...(labels ? [{ sources: { $not: { $elemMatch: { $nin: where(reach, "read") } } } }] : []),
|
|
101
|
+
...(contact && actor.kind === "contact" ? [contact] : []),
|
|
102
|
+
];
|
|
103
|
+
const sourced = also.length > 1 ? { $and: also } : also[0];
|
|
48
104
|
const named = filter?.[field];
|
|
49
105
|
if (typeof named === "string" && spaces.includes(named))
|
|
50
106
|
return sourced ?? true;
|
|
@@ -53,6 +109,18 @@ export const rules = async (actor, { collection, access, filter }, ctx) => {
|
|
|
53
109
|
// each only where it lives, so nothing written as one of them lands in another space.
|
|
54
110
|
const docs = held(reach, verb, collection);
|
|
55
111
|
const wholes = part ? held(reach, verb, part) : [];
|
|
112
|
+
// A contact's own read from its browser names what of its own it reads: documents it holds, or
|
|
113
|
+
// its chats' parts. Anything wider would run again on every change to the collection.
|
|
114
|
+
if (mineOnly) {
|
|
115
|
+
// So many at most (a name said again counts again): what's watched is matched against
|
|
116
|
+
// every change it might see.
|
|
117
|
+
const mine = (ids, of) => !!ids?.length && ids.length <= NAMED &&
|
|
118
|
+
[...new Set(ids)].every((id) => of.some(([held]) => held === id));
|
|
119
|
+
if (!mine(idsIn(filter?._id), docs) && !(part && mine(idsIn(filter?.[part]), wholes))) {
|
|
120
|
+
throw unnamed(collection, `${part ? `a ${part} of its own (${part})` : "a document of its own (_id)"}, ` +
|
|
121
|
+
`${NAMED} at most`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
56
124
|
const whole = part ? filter?.[part] : undefined;
|
|
57
125
|
const asked = wholes.find(([id]) => id === whole);
|
|
58
126
|
if (asked)
|
|
@@ -1 +1,22 @@
|
|
|
1
|
+
/** The most a contact's message says: WhatsApp's own most, 4,096 characters. */
|
|
2
|
+
export declare const CONTACT_TEXT = 4096;
|
|
3
|
+
/** The longest media type a file may say it is (RFC 6838's longest type or subtype name). */
|
|
4
|
+
export declare const MEDIA_TYPE_LENGTH = 127;
|
|
5
|
+
/**
|
|
6
|
+
* What a file's media type looks like: `type/subtype`, then parameters
|
|
7
|
+
* (`audio/ogg; codecs=opus`, as WhatsApp sends voice notes), on one line:
|
|
8
|
+
* an agent is told it (`[file a.bin: <type>, …]`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const MEDIA_TYPE: RegExp;
|
|
11
|
+
/**
|
|
12
|
+
* A `contactSend` resource: the Action that lets a contact's message in,
|
|
13
|
+
* asked as the contact before anything's sent, with where it goes (`thread`,
|
|
14
|
+
* when it names one) and what it carries (each file's name, media type and
|
|
15
|
+
* size). It refuses it (a limit), or answers where it goes when it names no
|
|
16
|
+
* chat (`thread`: the contact's own) and `transcribe: false` when its audio
|
|
17
|
+
* goes untranscribed.
|
|
18
|
+
*/
|
|
19
|
+
export type ContactSend = {
|
|
20
|
+
action: string;
|
|
21
|
+
};
|
|
1
22
|
export declare const sendAction: import("../../../../runtime/define.js").ActionDef;
|
|
@@ -15,13 +15,52 @@
|
|
|
15
15
|
* commit, so its first turn already has them. `tap` says it was a choice
|
|
16
16
|
* tapped (a button), not typed. With `quiet`, agents answer once the sender
|
|
17
17
|
* has been quiet that long (a burst of short messages, answered together).
|
|
18
|
+
*
|
|
19
|
+
* A contact's message says at most `CONTACT_TEXT` characters, says nothing
|
|
20
|
+
* of what sent it (`via`: never "a routine"), never titles its chat nor
|
|
21
|
+
* lets an agent rename it (`title`, `renamable`: what its people see), and
|
|
22
|
+
* is let in by the app's `contactSend` hooks first (the web lines': a
|
|
23
|
+
* web line's limits, the files it takes, its visitor's own chat, made with
|
|
24
|
+
* its first message, where it goes when it names none). A hook refuses it,
|
|
25
|
+
* or says where it goes and that its audio goes untranscribed (`transcribe:
|
|
26
|
+
* false`).
|
|
27
|
+
* People's messages go as ever.
|
|
18
28
|
*/
|
|
19
|
-
import { defineAction, peopleOrContacts } from "../../../../runtime/mod.js";
|
|
29
|
+
import { defineAction, failure, peopleOrContacts, } from "../../../../runtime/mod.js";
|
|
20
30
|
import { agentsNamed, mentions, NO_ANSWER, now, rosterOf } from "../shared/agents.js";
|
|
21
31
|
import { delivery } from "../shared/delivery.js";
|
|
22
32
|
import { movedBy, startedWith } from "../shared/summary.js";
|
|
23
33
|
import { settingsOf } from "../shared/types.js";
|
|
24
34
|
const names = { type: "array", items: { type: "string" } };
|
|
35
|
+
/** The most a contact's message says: WhatsApp's own most, 4,096 characters. */
|
|
36
|
+
export const CONTACT_TEXT = 4_096;
|
|
37
|
+
/** The longest media type a file may say it is (RFC 6838's longest type or subtype name). */
|
|
38
|
+
export const MEDIA_TYPE_LENGTH = 127;
|
|
39
|
+
/**
|
|
40
|
+
* What a file's media type looks like: `type/subtype`, then parameters
|
|
41
|
+
* (`audio/ogg; codecs=opus`, as WhatsApp sends voice notes), on one line:
|
|
42
|
+
* an agent is told it (`[file a.bin: <type>, …]`).
|
|
43
|
+
*/
|
|
44
|
+
export const MEDIA_TYPE = /^[A-Za-z0-9][\w!#$&^.+-]*\/[A-Za-z0-9][\w!#$&^.+-]*(?: *; *[\w!#$&^.+-]+=(?:[\w!#$&^.+-]+|"[ !#-\[\]-~]*"))* *$/;
|
|
45
|
+
/** What the app's `contactSend` hooks say of a contact's message, each in turn. */
|
|
46
|
+
async function letIn(ctx, asked) {
|
|
47
|
+
const hooks = Object.values((ctx.resources.contactSend ?? {}));
|
|
48
|
+
let said = {};
|
|
49
|
+
for (const hook of hooks) {
|
|
50
|
+
const answer = await ctx.call(hook.action, {
|
|
51
|
+
...(asked.thread ? { thread: asked.thread } : {}),
|
|
52
|
+
files: asked.files,
|
|
53
|
+
});
|
|
54
|
+
said = {
|
|
55
|
+
...said,
|
|
56
|
+
...(typeof answer?.thread === "string" && !said.thread ? { thread: answer.thread } : {}),
|
|
57
|
+
...(answer?.transcribe === false ? { transcribe: false } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return said;
|
|
61
|
+
}
|
|
62
|
+
/** How large a file sent as base64 is, in bytes. */
|
|
63
|
+
const sizeOf = (data) => Math.floor(data.replace(/=+$/, "").length * 3 / 4);
|
|
25
64
|
/** Who a message is from, pinned to whoever sends it: a person by id, a contact as `contact:<id>`. */
|
|
26
65
|
const fromOf = (actor) => actor?.kind === "person"
|
|
27
66
|
? actor.id
|
|
@@ -48,7 +87,8 @@ export const sendAction = defineAction({
|
|
|
48
87
|
type: "object",
|
|
49
88
|
properties: {
|
|
50
89
|
name: { type: "string", minLength: 1 },
|
|
51
|
-
type
|
|
90
|
+
// A media type, as the model is told it: `type/subtype`, with parameters at most.
|
|
91
|
+
type: { type: "string", maxLength: MEDIA_TYPE_LENGTH, pattern: MEDIA_TYPE.source },
|
|
52
92
|
data: { type: "string", maxLength: 14_000_000 },
|
|
53
93
|
/** A recording's length (ms) and its loudness over time, for its player. */
|
|
54
94
|
voice: {
|
|
@@ -119,9 +159,28 @@ export const sendAction = defineAction({
|
|
|
119
159
|
code: "invalid",
|
|
120
160
|
});
|
|
121
161
|
}
|
|
162
|
+
// A contact talks with whom its chat is with: what it says names nobody else, and the app
|
|
163
|
+
// lets it in first (its line's limits, the files it takes, its own chat).
|
|
164
|
+
const contact = ctx.actor?.kind === "contact";
|
|
165
|
+
if (contact && said.length > CONTACT_TEXT) {
|
|
166
|
+
throw failure("invalid", `A message says ${CONTACT_TEXT} characters at most.`, {
|
|
167
|
+
public: true,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const allowed = contact
|
|
171
|
+
? await letIn(ctx, {
|
|
172
|
+
...(input.thread ? { thread: input.thread } : {}),
|
|
173
|
+
files: (input.files ?? []).map((f) => ({
|
|
174
|
+
name: f.name,
|
|
175
|
+
...(f.type ? { type: f.type } : {}),
|
|
176
|
+
size: sizeOf(f.data),
|
|
177
|
+
})),
|
|
178
|
+
})
|
|
179
|
+
: {};
|
|
122
180
|
const threads = ctx.db.collection("thread");
|
|
123
|
-
const
|
|
124
|
-
const
|
|
181
|
+
const named = input.thread ?? allowed.thread;
|
|
182
|
+
const threadId = named ?? crypto.randomUUID();
|
|
183
|
+
const existing = named ? await threads.findOne({ _id: threadId }) : null;
|
|
125
184
|
// What it answers: a message the sender reads, in this conversation (else it answers nothing).
|
|
126
185
|
const found = input.replyTo
|
|
127
186
|
? await ctx.db.collection("message").findOne({ _id: input.replyTo })
|
|
@@ -130,8 +189,6 @@ export const sendAction = defineAction({
|
|
|
130
189
|
const where = existing ? existing.in : input.in;
|
|
131
190
|
const roster = await rosterOf(ctx, where);
|
|
132
191
|
const members = existing ? existing.agents ?? [] : roster.default;
|
|
133
|
-
// A contact talks with whom its chat is with: what it says names nobody else.
|
|
134
|
-
const contact = ctx.actor?.kind === "contact";
|
|
135
192
|
const mentioned = contact ? [] : mentions(said);
|
|
136
193
|
const asked = (contact ? undefined : input.to) ??
|
|
137
194
|
(mentioned.length ? mentioned : replied ? [replied.from] : members);
|
|
@@ -145,12 +202,14 @@ export const sendAction = defineAction({
|
|
|
145
202
|
}
|
|
146
203
|
const to = asked.filter((name) => !away.includes(name));
|
|
147
204
|
// A new thread is with whom it was started with: the agents named, or the space's.
|
|
148
|
-
const
|
|
149
|
-
const joined = existing ? members :
|
|
205
|
+
const chosen = to.filter((name) => agents[name]);
|
|
206
|
+
const joined = existing ? members : chosen.length ? chosen : members;
|
|
150
207
|
const id = crypto.randomUUID();
|
|
151
208
|
// What audio says, before anything is sent: agents read it.
|
|
152
209
|
const transcripts = await Promise.all((input.files ?? []).map(async (f) => {
|
|
153
|
-
if (input.transcribe === false ||
|
|
210
|
+
if (input.transcribe === false || allowed.transcribe === false)
|
|
211
|
+
return undefined;
|
|
212
|
+
if (!f.type?.startsWith("audio/"))
|
|
154
213
|
return undefined;
|
|
155
214
|
try {
|
|
156
215
|
const heard = await ctx.call("transcription.transcribe", {
|
|
@@ -170,7 +229,7 @@ export const sendAction = defineAction({
|
|
|
170
229
|
_id: `${id}:file.${i}`,
|
|
171
230
|
name: f.name,
|
|
172
231
|
type: f.type ?? "application/octet-stream",
|
|
173
|
-
size:
|
|
232
|
+
size: sizeOf(f.data),
|
|
174
233
|
data: f.data,
|
|
175
234
|
...(f.voice ? { voice: f.voice } : {}),
|
|
176
235
|
...(transcripts[i] !== undefined ? { transcript: transcripts[i] } : {}),
|
|
@@ -199,7 +258,7 @@ export const sendAction = defineAction({
|
|
|
199
258
|
text: said,
|
|
200
259
|
hops: 0,
|
|
201
260
|
...(replied ? { replyTo: replied._id } : {}),
|
|
202
|
-
...(input.via ? { via: input.via } : {}),
|
|
261
|
+
...(input.via && !contact ? { via: input.via } : {}),
|
|
203
262
|
...(input.tap ? { tap: input.tap } : {}),
|
|
204
263
|
at: now(),
|
|
205
264
|
};
|
|
@@ -214,8 +273,8 @@ export const sendAction = defineAction({
|
|
|
214
273
|
_id: threadId,
|
|
215
274
|
agents: joined,
|
|
216
275
|
...(where ? { in: where } : {}),
|
|
217
|
-
...(input.title ? { title: input.title } : {}),
|
|
218
|
-
...(input.renamable ? { renamable: true } : {}),
|
|
276
|
+
...(input.title && !contact ? { title: input.title } : {}),
|
|
277
|
+
...(input.renamable && !contact ? { renamable: true } : {}),
|
|
219
278
|
...startedWith(sent),
|
|
220
279
|
at: sent.at,
|
|
221
280
|
});
|
|
@@ -50,6 +50,13 @@ declare const fileSchema: {
|
|
|
50
50
|
readonly in: {
|
|
51
51
|
readonly type: "string";
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* A tool's, from what it was given (an API's response), as an agent's
|
|
55
|
+
* step is: those in the conversation from outside (a contact) never read it.
|
|
56
|
+
*/
|
|
57
|
+
readonly private: {
|
|
58
|
+
readonly type: "boolean";
|
|
59
|
+
};
|
|
53
60
|
readonly at: {
|
|
54
61
|
readonly type: "string";
|
|
55
62
|
};
|
|
@@ -103,6 +110,13 @@ export declare const file: {
|
|
|
103
110
|
readonly in: {
|
|
104
111
|
readonly type: "string";
|
|
105
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* A tool's, from what it was given (an API's response), as an agent's
|
|
115
|
+
* step is: those in the conversation from outside (a contact) never read it.
|
|
116
|
+
*/
|
|
117
|
+
readonly private: {
|
|
118
|
+
readonly type: "boolean";
|
|
119
|
+
};
|
|
106
120
|
readonly at: {
|
|
107
121
|
readonly type: "string";
|
|
108
122
|
};
|
|
@@ -116,6 +130,7 @@ export declare const file: {
|
|
|
116
130
|
private?: string[];
|
|
117
131
|
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
118
132
|
[x: string]: unknown;
|
|
133
|
+
private?: boolean | undefined;
|
|
119
134
|
in?: string | undefined;
|
|
120
135
|
voice?: {
|
|
121
136
|
[x: string]: unknown;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* blob, by the hash of what it holds: the same file attached twice is stored
|
|
4
4
|
* once, and a store's blobs can live elsewhere (a directory, a bucket).
|
|
5
5
|
*/
|
|
6
|
-
import { defineCollection,
|
|
6
|
+
import { defineCollection, peopleOrContacts } from "../../../../runtime/mod.js";
|
|
7
7
|
const fileSchema = {
|
|
8
8
|
type: "object",
|
|
9
9
|
properties: {
|
|
@@ -28,6 +28,11 @@ const fileSchema = {
|
|
|
28
28
|
thread: { type: "string" },
|
|
29
29
|
/** The space its thread is in. */
|
|
30
30
|
in: { type: "string" },
|
|
31
|
+
/**
|
|
32
|
+
* A tool's, from what it was given (an API's response), as an agent's
|
|
33
|
+
* step is: those in the conversation from outside (a contact) never read it.
|
|
34
|
+
*/
|
|
35
|
+
private: { type: "boolean" },
|
|
31
36
|
at: { type: "string" },
|
|
32
37
|
},
|
|
33
38
|
required: ["name", "type", "size", "data", "thread", "at"],
|
|
@@ -35,9 +40,13 @@ const fileSchema = {
|
|
|
35
40
|
export const file = defineCollection({
|
|
36
41
|
schema: fileSchema,
|
|
37
42
|
queries: {
|
|
38
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* One file, content and all, as its reader reaches it: what the web serves
|
|
45
|
+
* at `/files/<id>`. A contact reaches those of its own chat (what was sent
|
|
46
|
+
* there), never a tool's.
|
|
47
|
+
*/
|
|
39
48
|
content: {
|
|
40
|
-
allow:
|
|
49
|
+
allow: peopleOrContacts,
|
|
41
50
|
run: (files, params) => files.findOne({ _id: params.id }),
|
|
42
51
|
},
|
|
43
52
|
},
|
|
@@ -58,6 +58,15 @@ export declare const live: {
|
|
|
58
58
|
};
|
|
59
59
|
readonly required: readonly ["attempt", "at", "reason"];
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Its turn offers no tools, so every step is an answer: its words may
|
|
63
|
+
* show to a contact as they're written. Without it, a step being written
|
|
64
|
+
* may turn out private (its tools' calls, what it says before them): a
|
|
65
|
+
* contact sees only that the agent is at work, never the words.
|
|
66
|
+
*/
|
|
67
|
+
readonly open: {
|
|
68
|
+
readonly type: "boolean";
|
|
69
|
+
};
|
|
61
70
|
/** Its thread's space (with the access plugin): who may read it is who may read the thread. */
|
|
62
71
|
readonly in: {
|
|
63
72
|
readonly type: "string";
|
|
@@ -81,6 +90,7 @@ export declare const live: {
|
|
|
81
90
|
attempt: number;
|
|
82
91
|
reason: string;
|
|
83
92
|
} | undefined;
|
|
93
|
+
open?: boolean | undefined;
|
|
84
94
|
in?: string | undefined;
|
|
85
95
|
at: string;
|
|
86
96
|
text: string;
|
|
@@ -119,6 +129,7 @@ export type Live = {
|
|
|
119
129
|
at: string;
|
|
120
130
|
reason: string;
|
|
121
131
|
};
|
|
132
|
+
open?: true;
|
|
122
133
|
in?: string;
|
|
123
134
|
at: string;
|
|
124
135
|
};
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* What agents are writing right now: one document per running turn, its
|
|
3
3
|
* current step's answer so far and the tools it is calling. Kept in memory
|
|
4
4
|
* only. It goes in the same commit that writes what it became (the step, or
|
|
5
|
-
* the reply), so a View never shows both, or neither.
|
|
5
|
+
* the reply), so a View never shows both, or neither. A contact reads one
|
|
6
|
+
* only while it shows nothing private: no tool call, no broken call's
|
|
7
|
+
* reason, and words only when its turn offers no tools (`open`: every step
|
|
8
|
+
* an answer); else, only that the agent is at work.
|
|
6
9
|
*/
|
|
7
10
|
import { defineCollection } from "../../../../runtime/mod.js";
|
|
8
11
|
const liveSchema = {
|
|
@@ -42,6 +45,13 @@ const liveSchema = {
|
|
|
42
45
|
},
|
|
43
46
|
required: ["attempt", "at", "reason"],
|
|
44
47
|
},
|
|
48
|
+
/**
|
|
49
|
+
* Its turn offers no tools, so every step is an answer: its words may
|
|
50
|
+
* show to a contact as they're written. Without it, a step being written
|
|
51
|
+
* may turn out private (its tools' calls, what it says before them): a
|
|
52
|
+
* contact sees only that the agent is at work, never the words.
|
|
53
|
+
*/
|
|
54
|
+
open: { type: "boolean" },
|
|
45
55
|
/** Its thread's space (with the access plugin): who may read it is who may read the thread. */
|
|
46
56
|
in: { type: "string" },
|
|
47
57
|
at: { type: "string" },
|
|
@@ -448,6 +448,7 @@ export declare const message: {
|
|
|
448
448
|
kind: string;
|
|
449
449
|
name: string;
|
|
450
450
|
} | undefined;
|
|
451
|
+
hops?: number | undefined;
|
|
451
452
|
text?: string | undefined;
|
|
452
453
|
state?: {
|
|
453
454
|
[x: string]: unknown;
|
|
@@ -469,7 +470,6 @@ export declare const message: {
|
|
|
469
470
|
replyTo?: string | undefined;
|
|
470
471
|
expectReply?: boolean | undefined;
|
|
471
472
|
subthread?: string | undefined;
|
|
472
|
-
hops?: number | undefined;
|
|
473
473
|
turn?: string | undefined;
|
|
474
474
|
in?: string | undefined;
|
|
475
475
|
sources?: string[] | undefined;
|
|
@@ -79,8 +79,8 @@ export declare const wait: {
|
|
|
79
79
|
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
80
80
|
[x: string]: unknown;
|
|
81
81
|
at: string;
|
|
82
|
-
thread: string;
|
|
83
82
|
hops: number;
|
|
83
|
+
thread: string;
|
|
84
84
|
agent: string;
|
|
85
85
|
waitingFor: string[];
|
|
86
86
|
trigger: string;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* The chat plugin's contract: what plugins built on chat (memory, history,
|
|
3
3
|
* spaces, computers) may import from it: the shapes of its documents and of
|
|
4
4
|
* the resource kinds it reads (`agents`, `tools`, `context`, `additions`,
|
|
5
|
-
* `roster`, `agentSources`, `agentModel`; on the web,
|
|
6
|
-
* `refusals` and `composerNotes`),
|
|
5
|
+
* `roster`, `agentSources`, `agentModel`, `contactSend`; on the web,
|
|
6
|
+
* `conversation`, `home`, `toolViews`, `refusals` and `composerNotes`),
|
|
7
7
|
* `tool()` to declare a tool, its runner (`runTool`, `toolText`: how a turn
|
|
8
8
|
* runs one, for interfaces that run them for a model outside), and what
|
|
9
9
|
* knowing agents takes (`agentsOf`, `defaults`, `modelOf`, `agentsNamed`,
|
|
@@ -30,6 +30,7 @@ export { tool } from "./shared/types.js";
|
|
|
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
32
|
export type { AgentModel, AgentSource, Roster, RosterSource, Team } from "./shared/agents.js";
|
|
33
|
+
export { CONTACT_TEXT, type ContactSend, MEDIA_TYPE, MEDIA_TYPE_LENGTH } from "./actions/send.js";
|
|
33
34
|
/**
|
|
34
35
|
* The app's agents (`agentsOf`), who of them answer new conversations
|
|
35
36
|
* (`defaults`), an agent's model (`modelOf`), which names are agents and
|
|
@@ -8,6 +8,7 @@ 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
|
+
export { CONTACT_TEXT, MEDIA_TYPE, MEDIA_TYPE_LENGTH } from "./actions/send.js";
|
|
11
12
|
/**
|
|
12
13
|
* The app's agents (`agentsOf`), who of them answer new conversations
|
|
13
14
|
* (`defaults`), an agent's model (`modelOf`), which names are agents and
|
|
@@ -26,9 +26,12 @@
|
|
|
26
26
|
* everything in it; not while an agent is writing in it.
|
|
27
27
|
* - A chat can be opened empty (`chat.open`), to share it with a contact
|
|
28
28
|
* (someone outside the org, who then writes there with `chat.send` and
|
|
29
|
-
* reaches only it
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* reaches only it, never its agents' private steps); a contact's message
|
|
30
|
+
* is let in first by the app's `contactSend` hooks (a web visitor's
|
|
31
|
+
* limits, and its own chat, opened with its first message); trusted code
|
|
32
|
+
* has an agent say a fixed message in one without a turn (`chat.say`: a
|
|
33
|
+
* payment confirmed), and erases one with everything in it (`chat.erase`:
|
|
34
|
+
* someone's data, gone).
|
|
32
35
|
* - After an agent's answer, a medium may show more (additions: a carousel
|
|
33
36
|
* of trips after the answer that found them), each once per chat per key,
|
|
34
37
|
* recorded in `shown` (`chat.shown`), and told to the model after that
|
|
@@ -58,6 +61,9 @@
|
|
|
58
61
|
* - `agentSources`: { action }: `{ names }` in, the definitions of those the asker meets out;
|
|
59
62
|
* - `roster`: { action }: `{ space }` in, `{ agents, default? }` out;
|
|
60
63
|
* - `agentModel`: { action }: `{ agent, space? }` in, a model or null out;
|
|
64
|
+
* - `contactSend`: { action }: asked as a contact about to send, `{ thread?,
|
|
65
|
+
* files }` in (each file's name, type and size); it refuses, or answers
|
|
66
|
+
* `{ thread?, transcribe?: false }` (see actions/send.ts);
|
|
61
67
|
* - `additions`: { order?, agents? }, each with an `addition:<name>` View in
|
|
62
68
|
* the medium that shows it, given `{ thread, answer }` (see `Addition`).
|
|
63
69
|
*/
|