palbase 0.4.0 → 0.5.1

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 (61) hide show
  1. package/dist/ai/index.js +10 -10
  2. package/dist/backend/engine.js +2 -2
  3. package/dist/backend/env.js +1 -1
  4. package/dist/backend/index.js +8 -8
  5. package/dist/backend/stack.js +1 -1
  6. package/dist/backend/test.js +2 -2
  7. package/dist/chunks/{TRHIZOIS.js → 32RCJNOH.js} +3 -3
  8. package/dist/chunks/{BJL2FT5W.js → 3AUBDHV2.js} +1 -1
  9. package/dist/chunks/{IVDNNHII.js → 7BA7LGEM.js} +2 -2
  10. package/dist/chunks/A7EL6JKQ.js +20 -0
  11. package/dist/chunks/AWHTWL65.js +2 -0
  12. package/dist/chunks/{2AT72FFB.js → B45UFKBR.js} +2 -2
  13. package/dist/chunks/{ST2NZ4TZ.js → DNHDO6AJ.js} +1 -1
  14. package/dist/chunks/{BHT2IHBE.js → EHJKMDP3.js} +2 -2
  15. package/dist/chunks/{3OIKIBMG.js → FSXD7MN3.js} +2 -2
  16. package/dist/chunks/{SUNHFMDO.js → KSJ6AMCG.js} +2 -2
  17. package/dist/chunks/PALOWH6U.js +6 -0
  18. package/dist/chunks/{RKNVSAGY.js → PFSUOVTB.js} +1 -1
  19. package/dist/chunks/{6JO3UVPT.js → QIN2NQPN.js} +2 -2
  20. package/dist/chunks/{FS222NNP.js → R43DXJZE.js} +2 -2
  21. package/dist/chunks/{ODFLUINN.js → TTZRGQWF.js} +1 -1
  22. package/dist/chunks/{UNTTPATW.js → ZXYDN6NA.js} +1 -1
  23. package/dist/cli.js +133 -129
  24. package/dist/refuse/ai.js +1 -1
  25. package/dist/refuse/backend.js +1 -1
  26. package/dist/refuse/server.js +1 -1
  27. package/dist/server/index.js +2 -2
  28. package/dist/server/testing.js +2 -2
  29. package/dist/web/index.js +2 -2
  30. package/dist/web/palbe.js +2 -2
  31. package/dist/web/paywall.js +2 -2
  32. package/dist/web/vite.js +2 -2
  33. package/package.json +2 -2
  34. package/types/ai/src/ai.d.ts +20 -2
  35. package/types/ai/src/chats.d.ts +75 -1
  36. package/types/ai/src/index.d.ts +2 -2
  37. package/types/ai/src/tools.d.ts +35 -0
  38. package/types/backend/src/channels.d.ts +81 -0
  39. package/types/backend/src/container.d.ts +4 -2
  40. package/types/backend/src/decorators.d.ts +32 -17
  41. package/types/backend/src/engine.d.ts +12 -4
  42. package/types/backend/src/env.d.ts +1 -1
  43. package/types/backend/src/index.d.ts +4 -2
  44. package/types/backend/src/openapi.d.ts +3 -0
  45. package/types/backend/src/rooms.d.ts +10 -0
  46. package/types/backend/src/tasks.d.ts +168 -0
  47. package/types/internal/src/chat.d.ts +17 -1
  48. package/types/internal/src/modules/ai.d.ts +314 -0
  49. package/types/internal/src/modules/auth.d.ts +64 -47
  50. package/types/internal/src/modules/machines.d.ts +320 -79
  51. package/types/internal/src/modules/notify.d.ts +3 -3
  52. package/types/internal/src/modules/purchases.d.ts +562 -3
  53. package/types/internal/src/modules/storage.d.ts +32 -3
  54. package/types/web/src/ai.d.ts +25 -2
  55. package/types/web/src/client.d.ts +7 -0
  56. package/types/web/src/index.d.ts +1 -1
  57. package/types/web/src/paywall/placement.d.ts +2 -0
  58. package/types/web/src/purchases.d.ts +3 -1
  59. package/dist/chunks/CY6B75KF.js +0 -6
  60. package/dist/chunks/EGRDFD5C.js +0 -20
  61. package/dist/chunks/ZFX4BFQR.js +0 -2
@@ -83,7 +83,8 @@ export declare const INJECTABLE: unique symbol;
83
83
  export declare const MODULE: unique symbol;
84
84
  export declare const EVENTS: unique symbol;
85
85
  export declare const WEBHOOK: unique symbol;
86
- export declare const JOBS: unique symbol;
86
+ export declare const CRONS: unique symbol;
87
+ export declare const TASKS: unique symbol;
87
88
  export declare function declared(): Set<Function>;
88
89
  export declare const RESERVED: Set<string>;
89
90
  export declare function Controller(basePath: string, options?: ControllerOptions): ClassDecorator;
@@ -179,49 +180,63 @@ export declare const isFileEvent: (event: string) => boolean;
179
180
  * offers, and each types its handler (EventHandler).
180
181
  */
181
182
  export declare function On<E extends EventType | (string & {})>(event: E, options?: OnOptions): <F extends EventHandler<E>>(target: object, key: string | symbol, descriptor: TypedPropertyDescriptor<F>) => void;
182
- export interface JobOptions {
183
+ export interface CronOptions {
183
184
  /**
184
185
  * What its runs are kept under (Studio, the CLI) and the platform calls it
185
186
  * by: letters, digits, '.', '_' and '-', at most 64. Renaming it starts a
186
- * new job.
187
+ * new cron.
187
188
  */
188
189
  name: string;
189
- /** Five fields of cron's — minute hour day-of-month month day-of-week — in UTC, like "0 3 * * *". */
190
+ /** Five fields of cron's — minute hour day-of-month month day-of-week — like "0 3 * * *", on the clocks of timeZone. */
190
191
  schedule: string;
191
- /** Seconds one run may take before it is a failed attempt: 1–300 (30). */
192
+ /**
193
+ * The time zone whose clocks the schedule is on, by its IANA name
194
+ * ("Europe/Istanbul", "America/New_York"): UTC when none. Where its clocks
195
+ * change, a time they skip is not run, and a time they show twice is run
196
+ * the first time only.
197
+ */
198
+ timeZone?: string;
199
+ /** Seconds one run may take before it is a failed attempt: 1–900 (30). */
192
200
  timeout?: number;
193
201
  /** Attempts after a failed one, 10 s, 20 s, … five minutes apart: 0–10 (5). */
194
202
  retry?: number;
195
203
  }
196
- export interface JobDeclaration {
204
+ export interface CronDeclaration {
197
205
  name: string;
198
206
  schedule: string;
207
+ timeZone: string;
199
208
  timeout: number;
200
209
  retries: number;
201
210
  }
202
- /** One run of a job, as the platform calls it: what its run(meta) is given. */
203
- export interface JobMeta {
211
+ /** One run of a cron, as the platform calls it: what its run(meta) is given. */
212
+ export interface CronMeta {
204
213
  /** The app's environment variables, as it started (its keys left out). */
205
214
  env: Record<string, string>;
206
215
  /** The project the app belongs to (its id). */
207
216
  environmentId: string;
208
- job: string;
209
- /** The run's id: the same for each attempt of one run — what a job keys its work on to do it once. */
217
+ /** The cron's name. */
218
+ cron: string;
219
+ /** The run's id: the same for each attempt of one run — what a cron keys its work on to do it once. */
210
220
  runId: string;
211
- /** The minute it was due. */
221
+ /** The minute it was due (or was asked to run now). */
212
222
  scheduledAt: Date;
213
223
  /** 1 for the first, then one more each time a failed attempt is made again. */
214
224
  attempt: number;
215
225
  }
226
+ export declare const PLATFORM_NAME: RegExp;
227
+ /** Why a time zone is not one the platform reads its clocks of, or undefined when it is. */
228
+ export declare function zoneProblem(zone: string): string | undefined;
216
229
  /**
217
- * A provider the platform runs on `schedule` — five fields of cron's, in UTC
218
- * — by calling its run(meta), on the machine: woken for it if asleep, one of
219
- * its copies called, one run of a job at a time. A throw is a failed attempt,
220
- * made again; a return is done. It runs in a transaction of its own, as the
230
+ * A provider the platform runs on `schedule` — five fields of cron's, on the
231
+ * clocks of its time zone (UTC unless it names one) — by calling its
232
+ * run(meta), on the machine: woken for it if asleep, one of its copies
233
+ * called, one run of a cron at a time. A throw is a failed attempt, made
234
+ * again; a return is done. It runs in a transaction of its own, as the
221
235
  * service role: no one called it but the app. Off the platform nothing calls
222
- * it. Its module lists it in its providers, as any other.
236
+ * it. Its module lists it in its providers, as any other. Studio and the CLI
237
+ * pause it, resume it and run it now.
223
238
  */
224
- export declare function Job(options: JobOptions): ClassDecorator;
239
+ export declare function Cron(options: CronOptions): ClassDecorator;
225
240
  /** The senders whose signing scheme is known by name. */
226
241
  export type WebhookProvider = 'stripe' | 'github' | 'twilio' | 'sendgrid' | 'slack' | 'discord' | 'livekit';
227
242
  /** A signature scheme spelled out, for a sender with no preset: an HMAC of `signs`, in `header`. */
@@ -1,6 +1,7 @@
1
1
  import { type PalbaseServer, type TokenUser, type TokenVerifier, type WebhookEvent } from '../../server/src/index.js';
2
2
  import { type AuthSpec, type RateLimitConfig } from './decorators.js';
3
3
  import { type ContractOptions } from './openapi.js';
4
+ import { type ChannelsDef } from './channels.js';
4
5
  import { type StringsTable } from './i18n.js';
5
6
  import type { RequestTelemetry } from './requests.js';
6
7
  /** The signed-in user, as @User() gives it. */
@@ -62,6 +63,8 @@ export interface AppOptions {
62
63
  cors?: CorsOptions;
63
64
  /** The framework's own handlers of the platform's events (user.deleted → forget), run before the app's @On. */
64
65
  events?: Record<string, ((event: WebhookEvent) => Promise<unknown>)[]>;
66
+ /** The app's channels; the ones defineChannels declared in this process unless given (a test's own). */
67
+ channels?: ChannelsDef;
65
68
  /** The app's database: each request (and each delivery) one transaction, as its caller or as the service role. */
66
69
  database?: {
67
70
  app: RequestDatabases;
@@ -91,10 +94,15 @@ export interface AppOptions {
91
94
  * missing_signature, malformed_signature, stale_timestamp or
92
95
  * signature_mismatch. The factory gives it the machine's
93
96
  * PALBASE_PLATFORM_SECRET; unset here, none is served (404). They are:
94
- * - the app's @Job classes: GET /_palbase/jobs lists them (the platform asks
95
- * once a version is up), POST /_palbase/jobs/<name> runs one — its body
96
- * {job, run_id, scheduled_at, attempt} is what the signature covers —
97
- * and answers 204, or the failure the platform tries again;
97
+ * - the app's @Cron classes: GET /_palbase/crons lists them (the platform
98
+ * asks once a version is up), POST /_palbase/crons/<name> runs one — its
99
+ * body {cron, run_id, scheduled_at, attempt} is what the signature covers
100
+ * — and answers 204, or the failure the platform tries again;
101
+ * - its @Task classes: GET /_palbase/tasks lists them (asked with the
102
+ * crons), POST /_palbase/tasks/<name> runs one attempt of a task — {task,
103
+ * id, attempt, payload, created_at} — and answers 204, 422 for a task
104
+ * never to be done (TaskFailure, or a payload its schema refuses), or the
105
+ * failure the platform tries again;
98
106
  * - its @Upload routes' two steps, from storage (upload.ts), and its
99
107
  * @Room classes' joins, messages and moments, from realtime (rooms.ts):
100
108
  * platform-calls.ts;
@@ -11,7 +11,7 @@ export interface PalbaseConnection {
11
11
  * The key the platform signs its own calls to this machine with —
12
12
  * PALBASE_PLATFORM_SECRET, which the platform starts every machine with.
13
13
  * Off the platform there is none, and what only the platform calls (the
14
- * app's jobs, /_palbase/jobs) is not served.
14
+ * app's crons and tasks, /_palbase/crons and /_palbase/tasks) is not served.
15
15
  */
16
16
  platformSecret?: string;
17
17
  }
@@ -1,5 +1,7 @@
1
1
  import 'reflect-metadata';
2
- export { Body, Client, Controller, Delete, Get, getRegisteredControllers, getRoutes, Headers, Injectable, Job, Module, On, OptionalUser, Param, Patch, Post, Put, Query, QueryParams, Req, RequestId, Resolve, TraceId, User, Webhook, type AuthConfig, type AuthSpec, type ControllerOptions, type EventHandler, type JobMeta, type JobOptions, type ModuleDef, type OnOptions, type ParamResolver, type RateLimitConfig, type ResolveContext, type RouteInfo, type RouteOptions, type SignatureSpec, type StandardSchemaV1, type Token, type WebhookOptions, type WebhookProvider, } from './decorators.js';
2
+ export { Body, Client, Controller, Delete, Get, getRegisteredControllers, getRoutes, Headers, Cron, Injectable, Module, On, OptionalUser, Param, Patch, Post, Put, Query, QueryParams, Req, RequestId, Resolve, TraceId, User, Webhook, type AuthConfig, type AuthSpec, type ControllerOptions, type EventHandler, type CronMeta, type CronOptions, type ModuleDef, type OnOptions, type ParamResolver, type RateLimitConfig, type ResolveContext, type RouteInfo, type RouteOptions, type SignatureSpec, type StandardSchemaV1, type Token, type WebhookOptions, type WebhookProvider, } from './decorators.js';
3
+ export { Task, TaskFailure, Tasks, type EnqueueOptions, type PayloadOf, type QueuedTask, type TaskClass, type TaskMeta, type TaskOptions, type TasksService } from './tasks.js';
4
+ export { defineChannels, ownerOnly, publicChannel, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput } from './channels.js';
3
5
  export { Upload, UploadedObject, type UploadConfig } from './upload.js';
4
6
  export { OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, Room, type RoomAuthorizeContext, type RoomContext, type RoomGrant, type RoomMessageContext, type RoomOptions, type RoomUser, } from './rooms.js';
5
7
  export { getWebhookManifest, type WebhookEventHandler, type WebhookMeta } from './webhooks.js';
@@ -9,7 +11,7 @@ export { createApp, MAX_BODY_BYTES, type App, type AppOptions, type AppTokens, t
9
11
  export { ContractRunEnded, MigrationRunEnded, PalbaseFactory, type AppConfig, type PalbaseApplication } from './bootstrap.js';
10
12
  export { SchemaNotPushed } from './database.js';
11
13
  export type { DatabaseConfig } from './database.js';
12
- export { bigint, boolean, check, date, defineSchema, defineTable, enumType, foreignKey, index, integer, jsonb, numeric, ownedByUser, policy, raw, sqlType, text, timestamp, userRef, uuid, type AnyColumn, type ColumnMap, type PolicyExprCtx, type SchemaDef, type TableDef, type TableHandle, type TableRef, } from 'palgres/dsl';
14
+ export { bigint, boolean, check, date, defineSchema, defineTable, enumType, foreignKey, index, integer, jsonb, numeric, ownedByUser, policy, raw, sqlType, text, timestamp, userRef, uuid, type AnyColumn, type ColumnKey, type ColumnMap, type PolicyExprCtx, type SchemaDef, type TableDef, type TableHandle, type TableKeys, type TableRef, } from 'palgres/dsl';
13
15
  export type { Embed, TablesOf } from 'palgres';
14
16
  export { increment, now } from 'palgres';
15
17
  export type { WhereFilter } from 'palgres';
@@ -1,5 +1,6 @@
1
1
  import type { RateLimitConfig, StandardSchemaV1 } from './decorators.js';
2
2
  import type { RegisteredError } from './errors.js';
3
+ import type { ChannelRow } from './channels.js';
3
4
  import type { RoomDeclaration } from './rooms.js';
4
5
  import type { Route } from './router.js';
5
6
  /** Where the platform delivers the project's events to the app. */
@@ -34,6 +35,8 @@ export interface ContractOptions {
34
35
  errors?: ReadonlyMap<string, RegisteredError>;
35
36
  /** The app's @Room classes, as their decorators declare them. */
36
37
  rooms?: readonly RoomDeclaration[];
38
+ /** The owner and public channels defineChannels declares, in its order: x-palbase-channels, decided by realtime itself. */
39
+ channels?: readonly ChannelRow[];
37
40
  }
38
41
  /** What a route answers and throws, as its source declares. */
39
42
  export interface RouteContract {
@@ -89,6 +89,16 @@ export interface RoomContext {
89
89
  export interface RoomMessageContext<P = unknown> extends RoomContext {
90
90
  payload: P;
91
91
  }
92
+ /** v2 held a room a minute after its last member: twice the slowest client's heartbeat, and margin. */
93
+ export declare const DEFAULT_GRACE_MS = 60000;
94
+ /**
95
+ * Why `pattern` is no room's, or undefined. A pattern is a channel's: ':'
96
+ * segments, a "{name}" segment taking exactly one — and realtime takes a
97
+ * pattern it cannot decide for no room at all, silently: the room would
98
+ * compile, ship and never be joined. So everything it would not take is
99
+ * refused here, by name, while someone is looking.
100
+ */
101
+ export declare function patternProblem(pattern: string): string | undefined;
92
102
  /**
93
103
  * A class whose methods manage the room `pattern` names. It is a provider a
94
104
  * module lists (its constructor injected as any provider's), built once: what
@@ -0,0 +1,168 @@
1
+ import { type StandardSchemaV1 } from './decorators.js';
2
+ export interface TaskOptions {
3
+ /**
4
+ * The task's type: what its tasks are put on the queue under, kept under
5
+ * (Studio, the CLI) and called by — letters, digits, '.', '_' and '-', at
6
+ * most 64.
7
+ */
8
+ name: string;
9
+ /** Seconds one attempt may take before it is a failed one: 1–900 (60). */
10
+ timeout?: number;
11
+ /** Attempts after a failed one, 10 s, 20 s, … an hour apart at most: 0–20 (5). */
12
+ retry?: number;
13
+ /** How many of its tasks the machine runs at once, however many copies it has: 1–50 (5). */
14
+ concurrency?: number;
15
+ /**
16
+ * What a task carries, checked before run() is called: a task that does
17
+ * not hold to it can never be done, and fails at once — it is not tried
18
+ * again. run() is given what the schema gives.
19
+ */
20
+ payload?: StandardSchemaV1;
21
+ }
22
+ export interface TaskDeclaration {
23
+ name: string;
24
+ timeout: number;
25
+ retries: number;
26
+ concurrency: number;
27
+ payload?: StandardSchemaV1;
28
+ }
29
+ /** One attempt of a task, as the platform calls it: what its run(payload, meta) is given beside what it carries. */
30
+ export interface TaskMeta {
31
+ /** The app's environment variables, as it started (its keys left out). */
32
+ env: Record<string, string>;
33
+ /** The project the app belongs to (its id). */
34
+ environmentId: string;
35
+ /** The task's type. */
36
+ task: string;
37
+ /** The task's id: the same for each of its attempts — what it keys its work on to do it once. */
38
+ id: string;
39
+ /** 1 for the first, then one more each time a failed attempt is made again. */
40
+ attempt: number;
41
+ /** When it was put on the queue. */
42
+ createdAt: Date;
43
+ }
44
+ /**
45
+ * Thrown by a task's run(): the task can never be done — what it carries is
46
+ * not what it needs, the thing it works on is gone — and fails now, not to
47
+ * be tried again. Any other throw is an attempt that failed, made again.
48
+ */
49
+ export declare class TaskFailure extends Error {
50
+ constructor(message: string, options?: {
51
+ cause?: unknown;
52
+ });
53
+ }
54
+ /**
55
+ * A provider whose run(payload, meta) does tasks of its type: put on the
56
+ * queue with Tasks.enqueue(TheClass, payload), each run once its time
57
+ * comes — on the platform, which wakes the machine for it; off it, in this
58
+ * process. A return is done; a throw an attempt that failed, made again
59
+ * later (a TaskFailure: failed for good). It runs in a transaction of its
60
+ * own, as the service role: no one called it but the app. Its module lists
61
+ * it in its providers, as any other.
62
+ */
63
+ export declare function Task(options: TaskOptions): ClassDecorator;
64
+ /** A @Task class: its constructor takes what it was written to take, its run() a payload and the meta. */
65
+ export type TaskClass = abstract new (...args: never[]) => {
66
+ run(payload: never, meta: TaskMeta): unknown;
67
+ };
68
+ /** What a @Task class's run() takes as its payload. */
69
+ export type PayloadOf<C> = C extends abstract new (...args: never[]) => {
70
+ run(payload: infer P, ...rest: never[]): unknown;
71
+ } ? P : never;
72
+ export interface EnqueueOptions {
73
+ /** Due this many seconds from now (30 days at most). */
74
+ delay?: number;
75
+ /** Due at this time (30 days from now at most; a time past is now). */
76
+ runAt?: Date;
77
+ /**
78
+ * Put once under this key: another task of its type under the same key,
79
+ * while the first is held — until a day after it is over — is not put,
80
+ * and the first is answered (duplicate: true).
81
+ */
82
+ key?: string;
83
+ }
84
+ /** A task on the queue, as it was put. */
85
+ export interface QueuedTask {
86
+ id: string;
87
+ task: string;
88
+ state: 'waiting' | 'running' | 'succeeded' | 'failed' | 'cancelled';
89
+ attempt: number;
90
+ /** When it is due (RFC 3339): JSON as it is, so a handler can answer with the task. */
91
+ runAt: string;
92
+ key?: string;
93
+ reason?: string;
94
+ /** Put already under its key: this is that task, and nothing new was put. */
95
+ duplicate: boolean;
96
+ }
97
+ /** The queue the app puts its tasks on: the platform's, or its own off the platform. */
98
+ export interface TaskQueue {
99
+ enqueue(task: string, payload: unknown, options: EnqueueOptions & {
100
+ machine?: string;
101
+ }): Promise<QueuedTask>;
102
+ cancel(id: string, machine?: string): Promise<QueuedTask>;
103
+ get(id: string, machine?: string): Promise<QueuedTask>;
104
+ }
105
+ export interface TasksService {
106
+ /**
107
+ * Put a task of this @Task class on the machine's queue, carrying payload
108
+ * — what its run() takes, checked as it is written.
109
+ */
110
+ enqueue<C extends TaskClass>(task: C, payload: PayloadOf<C>, options?: EnqueueOptions): Promise<QueuedTask>;
111
+ /** Put a task of a type by its name — of another of the project's machines, with machine. */
112
+ enqueue(task: string, payload?: unknown, options?: EnqueueOptions & {
113
+ machine?: string;
114
+ }): Promise<QueuedTask>;
115
+ /** Take a task that is waiting off the queue: it is not run. */
116
+ cancel(id: string, options?: {
117
+ machine?: string;
118
+ }): Promise<QueuedTask>;
119
+ /** A task on the queue, as it is now. */
120
+ get(id: string, options?: {
121
+ machine?: string;
122
+ }): Promise<QueuedTask>;
123
+ }
124
+ /** The machine's task queue. */
125
+ export declare const Tasks: TasksService;
126
+ /** The platform's queue of the machine this app runs on (PALBASE_MACHINE), or of another of the project's. */
127
+ export declare function platformQueue(machine: string | undefined): TaskQueue;
128
+ /** How the app does one attempt of a task: what the platform's call would answer. */
129
+ export type RunTask = (call: {
130
+ task: string;
131
+ id: string;
132
+ attempt: number;
133
+ payload: unknown;
134
+ createdAt: Date;
135
+ }, signal: AbortSignal) => Promise<{
136
+ status: number;
137
+ message?: string;
138
+ }>;
139
+ /**
140
+ * The app's own queue, off the platform: its tasks run in this process, as
141
+ * the platform would run them — when due, each type no more at once than its
142
+ * concurrency, an attempt that failed made again later, a key held a day
143
+ * after its task is over. Nothing of it outlives the process.
144
+ */
145
+ export declare class LocalQueue implements TaskQueue {
146
+ private readonly types;
147
+ private readonly run;
148
+ private readonly now;
149
+ private readonly tasks;
150
+ private readonly running;
151
+ private readonly idle;
152
+ constructor(types: ReadonlyMap<string, TaskDeclaration>, run: RunTask, now?: () => number);
153
+ enqueue(task: string, payload: unknown, o: EnqueueOptions & {
154
+ machine?: string;
155
+ }): Promise<QueuedTask>;
156
+ cancel(id: string): Promise<QueuedTask>;
157
+ get(id: string): Promise<QueuedTask>;
158
+ /** Resolves once no task is waiting to run now, nor running: what a test waits for after putting one. */
159
+ settled(): Promise<void>;
160
+ private quiet;
161
+ private known;
162
+ private view;
163
+ private schedule;
164
+ private pump;
165
+ private attempt;
166
+ private finish;
167
+ private wake;
168
+ }
@@ -88,7 +88,23 @@ export interface AgentEvent {
88
88
  reason?: string;
89
89
  [field: string]: unknown;
90
90
  }
91
- export type ChatEvent = MessageEvent | TurnEvent | TextEvent | ResetEvent | ToolEvent | AgentEvent;
91
+ /** The chat's live voice: what was said either way (transcript), when it began and ended, and a task it handed over. */
92
+ export interface VoiceEvent {
93
+ type: 'voice';
94
+ seq: number;
95
+ voice_session_id: string;
96
+ kind: 'transcript' | 'started' | 'closed' | 'delegated';
97
+ /** A transcript's: the member speaking (user) or the voice answering (assistant). */
98
+ role?: 'user' | 'assistant';
99
+ text?: string;
100
+ /** A delegated task's: answer it with the voice's speak and this id. */
101
+ delegation_id?: string;
102
+ task?: string;
103
+ reason?: string;
104
+ seconds?: number;
105
+ [field: string]: unknown;
106
+ }
107
+ export type ChatEvent = MessageEvent | TurnEvent | TextEvent | ResetEvent | ToolEvent | AgentEvent | VoiceEvent;
92
108
  /** Where a reader is: what it hands the stream to go on from there. */
93
109
  export interface ChatPosition {
94
110
  /** The id of the last journal event held. */