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.
Files changed (211) hide show
  1. package/CHANGELOG.md +320 -1
  2. package/README.md +217 -87
  3. package/hosts/orgs/mod.d.ts +33 -13
  4. package/hosts/orgs/mod.js +183 -84
  5. package/hosts/web/address.d.ts +11 -0
  6. package/hosts/web/address.js +46 -0
  7. package/hosts/web/assets.js +11 -5
  8. package/hosts/web/entrances.d.ts +250 -0
  9. package/hosts/web/entrances.js +362 -0
  10. package/hosts/web/host.d.ts +15 -3
  11. package/hosts/web/host.js +31 -18
  12. package/hosts/web/mod.d.ts +4 -2
  13. package/hosts/web/mod.js +6 -0
  14. package/hosts/web/node/bundle.d.ts +5 -0
  15. package/hosts/web/node/bundle.js +1 -1
  16. package/hosts/web/node/mod.d.ts +6 -4
  17. package/hosts/web/node/mod.js +6 -4
  18. package/hosts/web/node/serve.d.ts +20 -23
  19. package/hosts/web/node/serve.js +10 -21
  20. package/hosts/web/routes.d.ts +23 -17
  21. package/hosts/web/routes.js +56 -32
  22. package/hosts/web/server.d.ts +89 -44
  23. package/hosts/web/server.js +208 -108
  24. package/hosts/web/signin.d.ts +7 -10
  25. package/hosts/web/signin.js +6 -3
  26. package/hosts/web/surface.d.ts +20 -0
  27. package/hosts/web/surface.js +42 -0
  28. package/hosts/web/theme/css.d.ts +2 -1
  29. package/hosts/web/theme/css.js +9 -2
  30. package/hosts/web/tickets.d.ts +14 -1
  31. package/hosts/web/tickets.js +30 -7
  32. package/hosts/web/widget.d.ts +31 -0
  33. package/hosts/web/widget.js +429 -0
  34. package/hosts/web/widgets.d.ts +43 -0
  35. package/hosts/web/widgets.js +117 -0
  36. package/package.json +5 -1
  37. package/plugins/access/contacts/actions/forget.js +3 -1
  38. package/plugins/access/contacts/actions/start.js +18 -8
  39. package/plugins/access/contacts/collections/contact.d.ts +2 -2
  40. package/plugins/access/contacts/collections/contact.js +1 -1
  41. package/plugins/access/contacts/contract.d.ts +5 -5
  42. package/plugins/access/contacts/contract.js +5 -5
  43. package/plugins/access/contacts/mod.d.ts +4 -0
  44. package/plugins/access/contacts/mod.js +4 -0
  45. package/plugins/access/contacts/views/contact.js +1 -0
  46. package/plugins/access/dev/actions/sign-in.d.ts +1 -0
  47. package/plugins/access/dev/actions/sign-in.js +38 -0
  48. package/plugins/access/dev/mod.d.ts +17 -0
  49. package/plugins/access/dev/mod.js +31 -0
  50. package/plugins/access/dev/shared/nearby.d.ts +2 -0
  51. package/plugins/access/dev/shared/nearby.js +27 -0
  52. package/plugins/access/directory/actions/invite.js +2 -2
  53. package/plugins/access/directory/actions/org.js +11 -8
  54. package/plugins/access/directory/collections/credit-code.d.ts +1 -1
  55. package/plugins/access/google/actions/sign-in.js +2 -0
  56. package/plugins/access/google/mod.d.ts +4 -2
  57. package/plugins/access/google/mod.js +15 -2
  58. package/plugins/access/identity/actions/session.js +5 -3
  59. package/plugins/access/identity/mod.d.ts +4 -2
  60. package/plugins/access/identity/mod.js +17 -2
  61. package/plugins/access/mod.d.ts +7 -0
  62. package/plugins/access/mod.js +1 -0
  63. package/plugins/access/spaces/shared/declared.d.ts +1 -1
  64. package/plugins/access/spaces/shared/rules.d.ts +16 -5
  65. package/plugins/access/spaces/shared/rules.js +74 -6
  66. package/plugins/agents/chat/actions/send.d.ts +21 -0
  67. package/plugins/agents/chat/actions/send.js +72 -13
  68. package/plugins/agents/chat/collections/file.d.ts +15 -0
  69. package/plugins/agents/chat/collections/file.js +12 -3
  70. package/plugins/agents/chat/collections/live.d.ts +11 -0
  71. package/plugins/agents/chat/collections/live.js +11 -1
  72. package/plugins/agents/chat/collections/message.d.ts +1 -1
  73. package/plugins/agents/chat/collections/wait.d.ts +1 -1
  74. package/plugins/agents/chat/contract.d.ts +3 -2
  75. package/plugins/agents/chat/contract.js +1 -0
  76. package/plugins/agents/chat/mod.d.ts +9 -3
  77. package/plugins/agents/chat/mod.js +28 -7
  78. package/plugins/agents/chat/processors/failed.js +8 -3
  79. package/plugins/agents/chat/processors/turn.js +6 -3
  80. package/plugins/agents/chat/shared/agents.js +11 -2
  81. package/plugins/agents/chat/shared/live.d.ts +4 -2
  82. package/plugins/agents/chat/shared/live.js +2 -1
  83. package/plugins/agents/chat/shared/types.d.ts +8 -0
  84. package/plugins/agents/history/collections/outline.d.ts +2 -2
  85. package/plugins/agents/openapi/shared/files.js +2 -0
  86. package/plugins/agents/routines/collections/routine.d.ts +1 -1
  87. package/plugins/billing/credits/collections/plan.d.ts +2 -2
  88. package/plugins/billing/credits/collections/room.d.ts +1 -1
  89. package/plugins/billing/usage/collections/rollup.d.ts +2 -2
  90. package/plugins/billing/usage/collections/usage.d.ts +2 -2
  91. package/plugins/compute/cloud/actions/pool.js +2 -0
  92. package/plugins/compute/cloud/actions/remote.js +4 -2
  93. package/plugins/compute/cloud/actions/vms.js +2 -0
  94. package/plugins/compute/cloud/collections/pool-vm.d.ts +1 -1
  95. package/plugins/compute/computers/actions/admit.js +2 -0
  96. package/plugins/compute/computers/actions/code.js +2 -0
  97. package/plugins/compute/computers/actions/enrollment.js +2 -0
  98. package/plugins/compute/computers/actions/work.js +3 -0
  99. package/plugins/compute/computers/program/version.d.ts +1 -1
  100. package/plugins/compute/computers/program/version.js +1 -1
  101. package/plugins/compute/computers/resources/downloads.js +1 -1
  102. package/plugins/compute/computers/resources/previews.js +5 -2
  103. package/plugins/interfaces/maintenance/mod.d.ts +3 -1
  104. package/plugins/interfaces/maintenance/mod.js +3 -1
  105. package/plugins/interfaces/mcp/actions/call.d.ts +4 -0
  106. package/plugins/interfaces/mcp/actions/call.js +120 -18
  107. package/plugins/interfaces/mcp/actions/conversation.d.ts +1 -0
  108. package/plugins/interfaces/mcp/actions/conversation.js +49 -0
  109. package/plugins/interfaces/mcp/actions/prune.js +5 -3
  110. package/plugins/interfaces/mcp/collections/opening.d.ts +24 -0
  111. package/plugins/interfaces/mcp/collections/opening.js +28 -0
  112. package/plugins/interfaces/mcp/mod.d.ts +27 -3
  113. package/plugins/interfaces/mcp/mod.js +42 -7
  114. package/plugins/interfaces/mcp/resources/server.d.ts +13 -4
  115. package/plugins/interfaces/mcp/resources/server.js +163 -21
  116. package/plugins/interfaces/mcp/resources/tools.d.ts +88 -12
  117. package/plugins/interfaces/mcp/resources/tools.js +113 -19
  118. package/plugins/interfaces/mcp/resources/widgets.d.ts +161 -0
  119. package/plugins/interfaces/mcp/resources/widgets.js +246 -0
  120. package/plugins/interfaces/mcp/shared/keys.d.ts +25 -19
  121. package/plugins/interfaces/mcp/shared/keys.js +55 -9
  122. package/plugins/interfaces/mcp/shared/settings.d.ts +70 -37
  123. package/plugins/interfaces/mcp/shared/settings.js +64 -39
  124. package/plugins/interfaces/mcp/views/offered.d.ts +1 -1
  125. package/plugins/interfaces/mod.d.ts +2 -1
  126. package/plugins/interfaces/mod.js +2 -1
  127. package/plugins/interfaces/voice/collections/blocked.d.ts +2 -2
  128. package/plugins/interfaces/voice/collections/call.d.ts +3 -3
  129. package/plugins/interfaces/voice/contract.d.ts +1 -1
  130. package/plugins/interfaces/voice/mod.d.ts +3 -3
  131. package/plugins/interfaces/voice/mod.js +3 -3
  132. package/plugins/interfaces/voice/resources/relay.d.ts +5 -3
  133. package/plugins/interfaces/voice/resources/relay.js +17 -6
  134. package/plugins/interfaces/voice/resources/tools.js +2 -0
  135. package/plugins/interfaces/voice/shared/settings.d.ts +5 -0
  136. package/plugins/interfaces/voice/views/call.d.ts +18 -11
  137. package/plugins/interfaces/voice/views/call.js +15 -3
  138. package/plugins/interfaces/voice/views/message.d.ts +1 -1
  139. package/plugins/interfaces/web/actions/arrive.d.ts +1 -0
  140. package/plugins/interfaces/web/actions/arrive.js +120 -0
  141. package/plugins/interfaces/web/actions/prune.d.ts +1 -0
  142. package/plugins/interfaces/web/actions/prune.js +51 -0
  143. package/plugins/interfaces/web/actions/sending.d.ts +1 -0
  144. package/plugins/interfaces/web/actions/sending.js +222 -0
  145. package/plugins/interfaces/web/actions/spent.d.ts +2 -0
  146. package/plugins/interfaces/web/actions/spent.js +59 -0
  147. package/plugins/interfaces/web/collections/rate.d.ts +122 -0
  148. package/plugins/interfaces/web/collections/rate.js +37 -0
  149. package/plugins/interfaces/web/collections/visitor.d.ts +110 -0
  150. package/plugins/interfaces/web/collections/visitor.js +64 -0
  151. package/plugins/interfaces/web/contract.d.ts +4 -0
  152. package/plugins/interfaces/web/contract.js +1 -0
  153. package/plugins/interfaces/web/lines.d.ts +36 -0
  154. package/plugins/interfaces/web/lines.js +78 -0
  155. package/plugins/interfaces/web/processors/forget.d.ts +10 -0
  156. package/plugins/interfaces/web/processors/forget.js +14 -0
  157. package/plugins/interfaces/web/resources/entrance.d.ts +47 -0
  158. package/plugins/interfaces/web/resources/entrance.js +83 -0
  159. package/plugins/interfaces/web/resources/spend.d.ts +2 -0
  160. package/plugins/interfaces/web/resources/spend.js +62 -0
  161. package/plugins/interfaces/web/shared/budget.d.ts +65 -0
  162. package/plugins/interfaces/web/shared/budget.js +134 -0
  163. package/plugins/interfaces/web/shared/lines.d.ts +158 -0
  164. package/plugins/interfaces/web/shared/lines.js +156 -0
  165. package/plugins/interfaces/web/shared/secret.d.ts +33 -0
  166. package/plugins/interfaces/web/shared/secret.js +86 -0
  167. package/plugins/interfaces/whatsapp/collections/phone.d.ts +1 -1
  168. package/plugins/interfaces/whatsapp/mod.d.ts +1 -1
  169. package/plugins/interfaces/whatsapp/mod.js +1 -1
  170. package/plugins/interfaces/whatsapp/views/message.d.ts +1 -1
  171. package/plugins/models/contract.d.ts +1 -1
  172. package/plugins/models/shared/generate.js +13 -4
  173. package/plugins/models/shared/transcribe.js +7 -1
  174. package/plugins/models/shared/use.d.ts +16 -2
  175. package/plugins/models/shared/use.js +20 -0
  176. package/runtime/browsers.d.ts +153 -17
  177. package/runtime/browsers.js +336 -30
  178. package/runtime/cache.js +25 -5
  179. package/runtime/caller.d.ts +117 -0
  180. package/runtime/caller.js +215 -0
  181. package/runtime/client.d.ts +47 -3
  182. package/runtime/client.js +132 -42
  183. package/runtime/define.d.ts +30 -9
  184. package/runtime/executor.js +7 -6
  185. package/runtime/expiring.d.ts +23 -0
  186. package/runtime/expiring.js +64 -0
  187. package/runtime/links.d.ts +27 -4
  188. package/runtime/links.js +49 -11
  189. package/runtime/memory.js +102 -15
  190. package/runtime/mod.d.ts +3 -1
  191. package/runtime/mod.js +3 -1
  192. package/runtime/mongo.d.ts +12 -0
  193. package/runtime/mongo.js +44 -0
  194. package/runtime/observe.js +82 -9
  195. package/runtime/ops.d.ts +9 -1
  196. package/runtime/owner.d.ts +14 -1
  197. package/runtime/owner.js +78 -23
  198. package/runtime/reads.js +2 -2
  199. package/runtime/registry.js +9 -3
  200. package/runtime/runtime.d.ts +7 -0
  201. package/runtime/runtime.js +1 -0
  202. package/runtime/timers.js +2 -0
  203. package/runtime/views.d.ts +1 -1
  204. package/runtime/views.js +2 -2
  205. package/runtime/wire.d.ts +1 -1
  206. package/stores/sql/postgres/maintenance.d.ts +8 -1
  207. package/stores/sql/postgres/maintenance.js +76 -9
  208. package/stores/sql/postgres/mod.d.ts +12 -4
  209. package/stores/sql/postgres/mod.js +21 -8
  210. package/plugins/interfaces/mcp/shared/caller.d.ts +0 -45
  211. 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 `modelUse` resource: hears every model call's use. */
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
@@ -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
- /** Whether a rule speaks for an actor's reads of a collection: a browser reads nothing else directly. */
62
- ruled(actor: Actor, collection: string): Promise<boolean>;
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
- /** Ends every browser's session stream: closing the runtime doesn't wait them out. */
72
- closeAll: () => void;
73
- /** A connection's provider config at admission: who it is. */
74
- config: (actor: Actor) => JsonObject;
75
- /** A resume credential for a browser just admitted. */
76
- resume: (actor: Actor) => {
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
- * Oxian's disconnect hook: its reads stop being watched. Only the
89
- * connection that went: a browser back on a new one before the old one
90
- * is noticed gone keeps its new stream.
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. */