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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { calledBy } from "./provider.js";
|
|
2
2
|
import { adapterFor, resolve } from "./choice.js";
|
|
3
|
-
import { used } from "./use.js";
|
|
3
|
+
import { mayUse, used } from "./use.js";
|
|
4
4
|
import { measure } from "./telemetry.js";
|
|
5
5
|
/** The models a choice names, in order, each checked. */
|
|
6
6
|
export function transcribers(ctx, model) {
|
|
@@ -13,6 +13,12 @@ export function transcribers(ctx, model) {
|
|
|
13
13
|
export async function transcribe(ctx, request) {
|
|
14
14
|
const choices = transcribers(ctx, request.model);
|
|
15
15
|
for (const [i, m] of choices.entries()) {
|
|
16
|
+
// Whoever listens to model use may refuse it first (a web line's budget, spent): for good.
|
|
17
|
+
await mayUse(ctx, {
|
|
18
|
+
meter: "transcription",
|
|
19
|
+
subject: m.id,
|
|
20
|
+
...(request.tags ? { tags: request.tags } : {}),
|
|
21
|
+
});
|
|
16
22
|
const call = measure(ctx.metrics, m, "transcription");
|
|
17
23
|
try {
|
|
18
24
|
const { options } = m.settings;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Model use: after every call, the models plugin tells whoever plugs into
|
|
3
|
-
* its `modelUse` resource what was used (the usage ledger records it, rated)
|
|
3
|
+
* its `modelUse` resource what was used (the usage ledger records it, rated);
|
|
4
|
+
* before one, a listener may refuse it (`may`: a budget spent).
|
|
4
5
|
* It's called in the job that made the call, so what a listener records
|
|
5
6
|
* (`ctx.record`) rides that job's next write and is kept even if the job
|
|
6
7
|
* fails. Models' own metrics (tokens, time) are its telemetry.
|
|
@@ -31,10 +32,23 @@ export type UseContext = Pick<Context, "resources"> & {
|
|
|
31
32
|
record?: Context["record"];
|
|
32
33
|
metrics?: Context["metrics"];
|
|
33
34
|
};
|
|
34
|
-
/** A
|
|
35
|
+
/** A model call about to be made: which port, which model, and whom it's for. */
|
|
36
|
+
export type ModelCall = Pick<ModelUse, "meter" | "subject" | "tags">;
|
|
37
|
+
/**
|
|
38
|
+
* A `modelUse` resource: hears every model call's use; and may say, before
|
|
39
|
+
* one, whether it may go (`may`: one that throws refuses it, and its turn
|
|
40
|
+
* stops there: a budget spent).
|
|
41
|
+
*/
|
|
35
42
|
export type UseListener = {
|
|
36
43
|
used(ctx: UseContext, use: ModelUse): void | Promise<void>;
|
|
44
|
+
may?(ctx: UseContext, call: ModelCall): void | Promise<void>;
|
|
37
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Asks every `modelUse` listener that says whether a call may go (`may`):
|
|
48
|
+
* one that refuses (throws) refuses it, for good (`final`: trying again, or
|
|
49
|
+
* another model, won't help).
|
|
50
|
+
*/
|
|
51
|
+
export declare function mayUse(ctx: UseContext, call: ModelCall): Promise<void>;
|
|
38
52
|
/**
|
|
39
53
|
* Tells every `modelUse` listener about a use, and waits for them: what one
|
|
40
54
|
* records has to go with the job that made the call, and a job's last write
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asks every `modelUse` listener that says whether a call may go (`may`):
|
|
3
|
+
* one that refuses (throws) refuses it, for good (`final`: trying again, or
|
|
4
|
+
* another model, won't help).
|
|
5
|
+
*/
|
|
6
|
+
export async function mayUse(ctx, call) {
|
|
7
|
+
const listeners = Object.values((ctx.resources.modelUse ?? {}));
|
|
8
|
+
for (const listener of listeners) {
|
|
9
|
+
if (!listener.may)
|
|
10
|
+
continue;
|
|
11
|
+
try {
|
|
12
|
+
await listener.may(ctx, call);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
throw Object.assign(error instanceof Error ? error : new Error(String(error)), {
|
|
16
|
+
final: true,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
22
|
* Tells every `modelUse` listener about a use, and waits for them: what one
|
|
3
23
|
* records has to go with the job that made the call, and a job's last write
|
package/runtime/browsers.d.ts
CHANGED
|
@@ -11,12 +11,43 @@
|
|
|
11
11
|
* one session stream per connection. A read is watched by observing a View
|
|
12
12
|
* that makes it, as the person: what the rules read to know their reach is
|
|
13
13
|
* followed too, so being let in shows at once.
|
|
14
|
+
* - **How much:** a browser is its worker id: an actor has 16 at most, each
|
|
15
|
+
* on two connections at most (one coming while the last goes); each
|
|
16
|
+
* connection 512 reads watched (one more is refused, `too_many`, and
|
|
17
|
+
* those watched keep working; a read asked again is the same one); and 16
|
|
18
|
+
* resume credentials, each for a day (a new one drops their oldest). What's
|
|
19
|
+
* past its day is dropped as it passes (see expiring.ts).
|
|
20
|
+
* - **Counted from admission:** a connection takes its place when it's let
|
|
21
|
+
* in (`take`, at Welcome) and keeps it until it goes (`gone`), Ready or
|
|
22
|
+
* not: connections let in together can't pass a limit by not being ready
|
|
23
|
+
* yet. One that isn't ready soon enough is closed (the owner's ready
|
|
24
|
+
* timeout).
|
|
25
|
+
* - **Coming back:** a resume credential works once, for the browser (worker
|
|
26
|
+
* id) it was given to; each admission gives a new one.
|
|
27
|
+
* - **Contacts** (outsiders, anyone with a browser on a web line) hold far
|
|
28
|
+
* less: 2 browsers each, 32 reads watched on each connection; and
|
|
29
|
+
* together, 16 connections from each network they came from (`actor.from`,
|
|
30
|
+
* its tags: as many times that as the network counts, `scaleOf`), 300 on
|
|
31
|
+
* each web line (`actor.web`), 400 in all: well under what a listener
|
|
32
|
+
* holds (`LISTENER`, Oxian's), so people always find room. Runtimes on one
|
|
33
|
+
* listener (the orgs host's orgs) count their contacts together too, with
|
|
34
|
+
* one `contactsPool()` given to each. People's connections never count
|
|
35
|
+
* against those. A contact reads a collection directly only with `find`,
|
|
36
|
+
* `findOne` or `count`, its filter and options (or a query's params) 2 KB
|
|
37
|
+
* of JSON at most, as the rules let it (`direct`: they refuse a read that
|
|
38
|
+
* doesn't name what of its own it reads, a chat), so what it watches runs
|
|
39
|
+
* again only when what it named changes. And it's told only the words of
|
|
40
|
+
* a failure meant for anyone (`public`), as a model outside the app is:
|
|
41
|
+
* never a provider's, a store's or the runtime's.
|
|
42
|
+
* - **Ended** (signed out, erased: `end`): an actor's connections close, its
|
|
43
|
+
* resume credentials go, and a connection let in before is never ready.
|
|
14
44
|
*/
|
|
15
45
|
import type { JsonObject, WorkInput } from "oxianjs";
|
|
16
46
|
import type { ViewContext } from "./define.js";
|
|
17
47
|
import type { Observers } from "./observe.js";
|
|
18
48
|
import type { ReadOp } from "./ops.js";
|
|
19
|
-
import type { Actor } from "./store.js";
|
|
49
|
+
import type { Actor, Filter } from "./store.js";
|
|
50
|
+
import { type Failure } from "./wire.js";
|
|
20
51
|
/** A browser connection's provider id, set at admission. */
|
|
21
52
|
export declare const BROWSER = "core.browser";
|
|
22
53
|
/** What a browser asks: reads (watched), reads no longer needed, Actions, events. */
|
|
@@ -56,38 +87,143 @@ export type Push = {
|
|
|
56
87
|
} & Answer;
|
|
57
88
|
/** Makes the read it's given, as whoever observes it. */
|
|
58
89
|
export declare function readView(remote: Remote, ctx: ViewContext): unknown;
|
|
90
|
+
/**
|
|
91
|
+
* A failure as a browser is told it: a person, all of it; a contact, its
|
|
92
|
+
* words only when they're for anyone (`public`), else that it failed, and
|
|
93
|
+
* its code.
|
|
94
|
+
*/
|
|
95
|
+
export declare function toldTo(actor: Actor | undefined, error: unknown): Failure;
|
|
96
|
+
/**
|
|
97
|
+
* One read, answered as an actor outside any connection (a widget's, through the app's MCP
|
|
98
|
+
* line; a snapshot of what a View reads): a query they may run (its `allow`, under the rules,
|
|
99
|
+
* without private fields), its failure as they may be told it. A direct read of a collection is
|
|
100
|
+
* refused: from there, an actor reads through queries.
|
|
101
|
+
*/
|
|
102
|
+
export declare function answeredAs(runtime: {
|
|
103
|
+
query(name: string, params: unknown, options: {
|
|
104
|
+
actor: Actor;
|
|
105
|
+
}): Promise<unknown>;
|
|
106
|
+
}, actor: Actor, key: string, read: Remote): Promise<{
|
|
107
|
+
key: string;
|
|
108
|
+
} & Answer>;
|
|
109
|
+
/**
|
|
110
|
+
* The most WebSockets one listener holds (Oxian's Node adapter's budget):
|
|
111
|
+
* people, contacts, routes' sockets and, on the orgs host, every org's.
|
|
112
|
+
*/
|
|
113
|
+
export declare const LISTENER: number;
|
|
114
|
+
/** The most bytes of JSON a contact's read says: its filter and options, or a query's params. */
|
|
115
|
+
export declare const CONTACT_READ = 2048;
|
|
116
|
+
/**
|
|
117
|
+
* Contacts' connections counted across runtimes that share a listener (the
|
|
118
|
+
* orgs host's orgs), as many as `most` (400 unless said): `contactsPool()`,
|
|
119
|
+
* given to each runtime (`browsers: { pool }`).
|
|
120
|
+
*/
|
|
121
|
+
export type ContactsPool = {
|
|
122
|
+
readonly held: Set<object>;
|
|
123
|
+
readonly most: number;
|
|
124
|
+
};
|
|
125
|
+
/** A pool of contacts' connections for runtimes on one listener (see `ContactsPool`). */
|
|
126
|
+
export declare const contactsPool: (most?: number) => ContactsPool;
|
|
127
|
+
/** How much a browser may hold: see the module's header. */
|
|
128
|
+
export type BrowserLimits = {
|
|
129
|
+
/** Each actor's browsers (worker ids). */
|
|
130
|
+
sockets?: number;
|
|
131
|
+
/** Reads watched on each connection. */
|
|
132
|
+
watches?: number;
|
|
133
|
+
resumes?: number;
|
|
134
|
+
/** Each contact's browsers, and reads watched on each connection. */
|
|
135
|
+
contact?: {
|
|
136
|
+
sockets?: number;
|
|
137
|
+
watches?: number;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Contacts' connections together: from one network (as many times as it
|
|
141
|
+
* counts), one web line, all of this runtime's.
|
|
142
|
+
*/
|
|
143
|
+
network?: number;
|
|
144
|
+
line?: number;
|
|
145
|
+
contacts?: number;
|
|
146
|
+
/** Contacts' connections counted with other runtimes' on the same listener. */
|
|
147
|
+
pool?: ContactsPool;
|
|
148
|
+
};
|
|
149
|
+
/** What's wrong with browser limits, if anything (checked as the runtime starts). */
|
|
150
|
+
export declare function limitsProblem(limits: BrowserLimits | undefined): string | undefined;
|
|
59
151
|
export declare function createBrowsers(env: {
|
|
60
152
|
observers: Pick<Observers, "observe">;
|
|
61
|
-
/**
|
|
62
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Whether a rule speaks for an actor's reads of a collection: a browser
|
|
155
|
+
* reads nothing else directly. Asked with the read's filter (`direct`, for
|
|
156
|
+
* the rules): one that won't be watched as asked is refused (thrown).
|
|
157
|
+
*/
|
|
158
|
+
ruled(actor: Actor, collection: string, filter?: Filter): Promise<boolean>;
|
|
63
159
|
/** Whether a query lets an actor run it (its `allow`). */
|
|
64
160
|
askable(actor: Actor, collection: string, query: string, params: unknown): boolean;
|
|
65
161
|
call(action: string, input: unknown, actor: Actor): Promise<unknown>;
|
|
66
162
|
emit(type: string, data: Record<string, unknown>, actor: Actor): Promise<void>;
|
|
67
163
|
dispatch(input: WorkInput): Promise<unknown>;
|
|
164
|
+
limits?: BrowserLimits;
|
|
68
165
|
}): {
|
|
69
|
-
/** How many browsers are connected. */
|
|
166
|
+
/** How many browsers are connected (ready). */
|
|
70
167
|
count: () => number;
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Ends every browser's session stream (closing the runtime doesn't wait
|
|
170
|
+
* them out), gives back every place (a pool shared with other runtimes
|
|
171
|
+
* keeps none of this one's), and forgets every resume credential.
|
|
172
|
+
*/
|
|
173
|
+
close: () => void;
|
|
174
|
+
/**
|
|
175
|
+
* How many times someone was ended so far: a browser coming in now is
|
|
176
|
+
* let in after those (`since`), and an end after refuses it.
|
|
177
|
+
*/
|
|
178
|
+
ends: () => number;
|
|
179
|
+
/** A connection's provider config at admission: who it is, and when it came in (`ends`). */
|
|
180
|
+
config: (actor: Actor, since: number) => JsonObject;
|
|
181
|
+
/**
|
|
182
|
+
* Refuses (thrown) a browser coming in as `actor` on `workerId` now: as
|
|
183
|
+
* many browsers as they may (`too_many`), a pool it's in full; or ended since it began coming in
|
|
184
|
+
* (`forbidden`). Only checks: `take` takes its place.
|
|
185
|
+
*/
|
|
186
|
+
room: (actor: Actor, workerId: string, since: number) => void;
|
|
187
|
+
/**
|
|
188
|
+
* Oxian's handshake hook, as a browser is let in (before Welcome): it
|
|
189
|
+
* takes its place, or is refused as `room` says (thrown). It keeps it
|
|
190
|
+
* until it goes (`gone`), ready or not.
|
|
191
|
+
*/
|
|
192
|
+
take: (workerId: string, via: string, config: JsonObject) => void;
|
|
193
|
+
/**
|
|
194
|
+
* A resume credential for a browser just admitted on `workerId`: it works
|
|
195
|
+
* once, on that worker id. A new one drops their oldest past 16.
|
|
196
|
+
*/
|
|
197
|
+
resume: (actor: Actor, workerId: string) => {
|
|
77
198
|
credential: {
|
|
78
199
|
kind: "resume";
|
|
79
200
|
capability: string;
|
|
80
201
|
};
|
|
81
202
|
expiresAtMs: number;
|
|
82
203
|
};
|
|
83
|
-
/** Who a resume credential is, while it lasts. */
|
|
84
|
-
resumed: (secret: string) => Actor | undefined;
|
|
85
|
-
/** Oxian's ready hook, for a browser's connection (`via`, the transport connection it came on). */
|
|
86
|
-
ready: (workerId: string, config: JsonObject, via: string) => void;
|
|
87
204
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
205
|
+
* Who a resume credential is, shown by `workerId`, once: it's used up
|
|
206
|
+
* either way, and someone else's (another worker id) is no one.
|
|
207
|
+
*/
|
|
208
|
+
resumed: (secret: string, workerId: string) => Actor | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Ends an actor's browsers (signed out, erased): their resume credentials
|
|
211
|
+
* go; each ready connection, by worker id, is given to `drain`, which
|
|
212
|
+
* ends it; one let in but not yet ready is refused when it says it is. A
|
|
213
|
+
* browser comes back only with a new ticket, which only a cookie that's
|
|
214
|
+
* still someone gets. How many connections it had.
|
|
215
|
+
*/
|
|
216
|
+
end: (actor: Actor, drain: (workerId: string) => void) => number;
|
|
217
|
+
/**
|
|
218
|
+
* Oxian's ready hook, for a browser's connection (`via`, the transport
|
|
219
|
+
* connection it came on): refused (thrown) when it wasn't let in here, or
|
|
220
|
+
* its actor was ended since.
|
|
221
|
+
*/
|
|
222
|
+
ready: (workerId: string, via: string) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Oxian's disconnect hook: its place is given back, and its reads stop
|
|
225
|
+
* being watched. Only the connection that went: a browser back on a new
|
|
226
|
+
* one before the old one is noticed gone keeps its new stream.
|
|
91
227
|
*/
|
|
92
228
|
gone: (workerId: string, via: string) => void;
|
|
93
229
|
/** Oxian's admission for a worker's calls outside any job: a browser's, as its person. */
|