palbase 0.6.2 → 0.8.0
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/dist/ai/index.js +2 -14
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +9 -9
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/5VTGMNPL.js +20 -0
- package/dist/chunks/{SXH5AIQX.js → BO5KR2EQ.js} +2 -2
- package/dist/chunks/{AYY4J3B2.js → BRBCWPR3.js} +1 -1
- package/dist/chunks/DB3SIBKB.js +2 -0
- package/dist/chunks/EGNEXFTZ.js +2 -0
- package/dist/chunks/{VP7V7YRH.js → FZ3MQOVA.js} +2 -2
- package/dist/chunks/{A3CDCPXX.js → JSJVV43D.js} +1 -1
- package/dist/chunks/K6RRNI23.js +4 -0
- package/dist/chunks/{SUX2BJG4.js → KDWDPSL2.js} +1 -1
- package/dist/chunks/P4Z5E6ZI.js +2 -0
- package/dist/chunks/PDOHT46N.js +2 -0
- package/dist/chunks/PGPQGKH2.js +18 -0
- package/dist/chunks/{DRTZ33XF.js → RBA6V3UO.js} +2 -2
- package/dist/chunks/{KLANM6M6.js → RO5Y5YU4.js} +1 -1
- package/dist/chunks/{53FS342F.js → TUGRIOFX.js} +2 -2
- package/dist/chunks/WEI32SAJ.js +13 -0
- package/dist/chunks/{GVFZM4BI.js → WINBISC2.js} +3 -3
- package/dist/chunks/Z5JVQNAZ.js +2 -0
- package/dist/cli.js +140 -139
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +2 -2
- package/types/ai/src/ai.d.ts +46 -19
- package/types/ai/src/chats.d.ts +478 -18
- package/types/ai/src/index.d.ts +4 -4
- package/types/ai/src/tools.d.ts +161 -29
- package/types/backend/src/bootstrap.d.ts +8 -0
- package/types/backend/src/container.d.ts +11 -2
- package/types/backend/src/database.d.ts +17 -2
- package/types/backend/src/engine.d.ts +3 -4
- package/types/backend/src/gateways.d.ts +269 -0
- package/types/backend/src/index.d.ts +3 -2
- package/types/backend/src/openapi.d.ts +3 -6
- package/types/backend/src/runtime.d.ts +51 -2
- package/types/backend/src/testing/unit.d.ts +3 -1
- package/types/internal/src/chat.d.ts +168 -35
- package/types/internal/src/modules/ai.d.ts +1826 -545
- package/types/internal/src/modules/auth.d.ts +14 -2
- package/types/internal/src/modules/events.d.ts +2 -2
- package/types/internal/src/modules/machines.d.ts +57 -1
- package/types/internal/src/modules/notify.d.ts +6 -6
- package/types/internal/src/modules/purchases.d.ts +357 -13
- package/types/internal/src/modules/realtime.d.ts +45 -1
- package/types/internal/src/modules/stores.d.ts +259 -22
- package/types/internal/src/transport.d.ts +5 -0
- package/types/server/src/auth/jwt.d.ts +1 -6
- package/types/web/src/auth.d.ts +15 -4
- package/types/web/src/backends.d.ts +20 -13
- package/types/web/src/chat.d.ts +329 -0
- package/types/web/src/client.d.ts +28 -3
- package/types/web/src/gateways.d.ts +90 -0
- package/types/web/src/index.d.ts +5 -4
- package/types/web/src/session.d.ts +11 -1
- package/types/web/src/socket.d.ts +18 -2
- package/types/web/src/voice.d.ts +36 -0
- package/dist/chunks/2RG3I7LX.js +0 -6
- package/dist/chunks/A76UZBAF.js +0 -2
- package/dist/chunks/AD5LBZAB.js +0 -4
- package/dist/chunks/DRGYTL6T.js +0 -20
- package/dist/chunks/IVEAUFGE.js +0 -13
- package/dist/chunks/IYCW6PWG.js +0 -2
- package/dist/chunks/KL7FIRII.js +0 -2
- package/dist/chunks/U4OZ4HOF.js +0 -2
- package/types/backend/src/channels.d.ts +0 -81
- package/types/backend/src/rooms.d.ts +0 -178
- package/types/web/src/ai.d.ts +0 -224
- package/types/web/src/rooms.d.ts +0 -61
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
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
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';
|
|
5
4
|
export { Upload, UploadedObject, type UploadConfig } from './upload.js';
|
|
6
|
-
export {
|
|
5
|
+
export { Authorize, ChatPart, Gateway, GatewayRefusal, OnConnect, OnDisconnect, OnEmpty, OnFirst, Subscribe, type GatewayAuthorizeContext, type GatewayContext, type GatewayEvents, type GatewayGrant, type GatewayMessageContext, type GatewayOptions, type GatewayUser, type PipeSource, } from './gateways.js';
|
|
6
|
+
export type { GatewaysApi, GatewayTarget } from './runtime.js';
|
|
7
|
+
export type { AgentContext, ToolContext, TurnDefinition, TurnMessage } from '../../ai/src/index.js';
|
|
7
8
|
export { getWebhookManifest, type WebhookEventHandler, type WebhookMeta } from './webhooks.js';
|
|
8
9
|
export { DiError, type DiErrorKind } from './container.js';
|
|
9
10
|
export { BadRequest, Conflict, DeadlockDetected, Forbidden, HttpError, NotFound, PalError, SerializationFailure, TooManyRequests, Unauthorized, UniqueViolation, defineError, type DefinedError, type DefinedErrorWithData, type Envelope, type FieldIssue, } from './errors.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { RateLimitConfig, StandardSchemaV1 } from './decorators.js';
|
|
2
2
|
import type { RegisteredError } from './errors.js';
|
|
3
|
-
import type
|
|
4
|
-
import type { RoomDeclaration } from './rooms.js';
|
|
3
|
+
import { type GatewayDeclaration } from './gateways.js';
|
|
5
4
|
import type { Route } from './router.js';
|
|
6
5
|
/** Where the platform delivers the project's events to the app. */
|
|
7
6
|
export declare const PLATFORM_EVENTS_PATH = "/webhooks/palbase";
|
|
@@ -33,10 +32,8 @@ export interface ContractOptions {
|
|
|
33
32
|
routes?: (route: Route) => RouteContract | undefined;
|
|
34
33
|
/** The release's errors by wire code (defineError's registry): what a thrown code is typed as. */
|
|
35
34
|
errors?: ReadonlyMap<string, RegisteredError>;
|
|
36
|
-
/** The app's @
|
|
37
|
-
|
|
38
|
-
/** The owner and public channels defineChannels declares, in its order: x-palbase-channels, decided by realtime itself. */
|
|
39
|
-
channels?: readonly ChannelRow[];
|
|
35
|
+
/** The app's @Gateway classes, as their decorators declare them. */
|
|
36
|
+
gateways?: readonly GatewayDeclaration[];
|
|
40
37
|
}
|
|
41
38
|
/** What a route answers and throws, as its source declares. */
|
|
42
39
|
export interface RouteContract {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type AI } from '../../ai/src/index.js';
|
|
2
3
|
import type { PalbaseServer } from '../../server/src/index.js';
|
|
3
4
|
import type { AtomicDatabase as AtomicOf, EnvTypedDatabase } from 'palgres';
|
|
4
5
|
import type { Schemas, Tables } from './db-env.js';
|
|
@@ -29,8 +30,55 @@ export declare function scoped<T extends object>(name: string, impl: T): T;
|
|
|
29
30
|
*/
|
|
30
31
|
export declare function serviceOf<T extends object>(name: string, key: PropertyKey, impl: T): T;
|
|
31
32
|
export declare const requestScope: AsyncLocalStorage<RequestScope>;
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
type GatewayEventsOf<G> = G extends {
|
|
34
|
+
readonly events: infer E;
|
|
35
|
+
} ? E : Record<never, never>;
|
|
36
|
+
type GatewayPayloadOf<S> = S extends {
|
|
37
|
+
readonly '~standard': {
|
|
38
|
+
readonly types?: {
|
|
39
|
+
readonly input: infer I;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
} ? I : unknown;
|
|
43
|
+
/** A gateway's channel, to send its events to (Palbase.gateways.to). */
|
|
44
|
+
export interface GatewayTarget<G> {
|
|
45
|
+
/**
|
|
46
|
+
* `event` to every member of the channel, its payload as the gateway's
|
|
47
|
+
* static events type it. Sent in the order emitted, never thrown: what could
|
|
48
|
+
* not be sent is in the app's log. A durable gateway keeps it.
|
|
49
|
+
*/
|
|
50
|
+
emit<K extends keyof GatewayEventsOf<G> & string>(event: K, payload: GatewayPayloadOf<GatewayEventsOf<G>[K]>): void;
|
|
51
|
+
/** The platform writes `source` into the channel from now on: a chat's stream (Palbase.ai.chats.events(id)). */
|
|
52
|
+
pipe(source: {
|
|
53
|
+
pipe(topic: string): Promise<void>;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Who may be on the channel is decided again now, on every replica of realtime — a decision the gateway made may no
|
|
57
|
+
* longer hold: a member taken out of a chat, a team changed. A member it would no longer let in (its access, its
|
|
58
|
+
* @Authorize) is dropped, their client told the channel closed; their rejoin is decided on the merits. Params may
|
|
59
|
+
* leave captures out: every channel of the gateway with the values given. user: only that user's membership. end:
|
|
60
|
+
* the channel is over — every member dropped without being asked, its log forgotten (one channel, no user).
|
|
61
|
+
*/
|
|
62
|
+
revalidate(options?: {
|
|
63
|
+
user?: string;
|
|
64
|
+
end?: boolean;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/** The app's gateways, from any service: Palbase.gateways.to(ChatGateway, { chatId }).emit('token', { text }). */
|
|
68
|
+
export interface GatewaysApi {
|
|
69
|
+
/** A gateway's channel, by its pattern's values — some left out, for revalidate alone: the gateway's channels of the values given. */
|
|
70
|
+
to<G extends Function>(gateway: G, params: Readonly<Record<string, string>>): GatewayTarget<G>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The project as the app's server reaches it: its modules — auth, storage, notify, secrets, flags, analytics,
|
|
74
|
+
* realtime, machines — its models and agents (Palbase.ai: ask, generate, stream, embed, tools, agents, chats), and
|
|
75
|
+
* the app's gateways (Palbase.gateways).
|
|
76
|
+
*/
|
|
77
|
+
export type PalbaseApp = Omit<PalbaseServer, 'ai'> & {
|
|
78
|
+
readonly ai: AI;
|
|
79
|
+
readonly gateways: GatewaysApi;
|
|
80
|
+
};
|
|
81
|
+
export declare const Palbase: PalbaseApp;
|
|
34
82
|
/**
|
|
35
83
|
* The request's database, as v2's: `Database.public.<table>`, `$query`,
|
|
36
84
|
* `$transaction`, `$atomic`, `$asService()`. It is the request's own
|
|
@@ -54,3 +102,4 @@ export declare const Log: {
|
|
|
54
102
|
warn: (message: string, fields?: Record<string, unknown>) => void;
|
|
55
103
|
error: (message: string, fields?: Record<string, unknown>) => void;
|
|
56
104
|
};
|
|
105
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { type FakeClient, type RecordedQuery } from 'palgres/testing';
|
|
|
4
4
|
import type { CacheClient } from '../cache.js';
|
|
5
5
|
import type { Schemas, Tables } from '../db-env.js';
|
|
6
6
|
import type { Token } from '../decorators.js';
|
|
7
|
-
import { type Logger } from '../runtime.js';
|
|
7
|
+
import { type GatewaysApi, type Logger } from '../runtime.js';
|
|
8
8
|
import type { Flags, Notifications, Realtime, Secrets, StorageService } from '../services.js';
|
|
9
9
|
import { type StringsTable } from '../i18n.js';
|
|
10
10
|
export type { RecordedQuery };
|
|
@@ -18,6 +18,8 @@ export interface RuntimeServices {
|
|
|
18
18
|
Notifications: typeof Notifications;
|
|
19
19
|
Flags: typeof Flags;
|
|
20
20
|
Realtime: typeof Realtime;
|
|
21
|
+
/** Palbase.gateways: what a service sends a gateway's channel through (to(Gateway, params).emit, .pipe). */
|
|
22
|
+
Gateways: GatewaysApi;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Runs `fn` with these stand-ins: Database is the client given (its typed
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import type { ChatMessage } from './modules/ai.js';
|
|
1
|
+
import type { ChatMessage, MessageAttachment } from './modules/ai.js';
|
|
2
2
|
export type TurnStatus = 'running' | 'waiting' | 'completed' | 'failed' | 'canceled' | 'timed_out' | 'budget_exceeded';
|
|
3
3
|
export type WaitingReason = 'approval' | 'tool_output' | 'subagents' | 'message';
|
|
4
4
|
export type ToolStatus = 'running' | 'awaiting_output' | 'awaiting_approval' | 'approved' | 'denied' | 'expired' | 'completed' | 'failed' | 'canceled';
|
|
5
|
+
/** How a turn ended, in the chat's words — as its event (ai.response.completed / failed) says it. */
|
|
6
|
+
export type TurnEnd = 'completed' | 'failed' | 'stopped' | 'budget_exceeded';
|
|
7
|
+
/**
|
|
8
|
+
* A push, a pull request or a merge the agent asked for (a tool part named push, pull_request or merge), and what a
|
|
9
|
+
* person decides it by: the repository, the branch it writes, the base it targets, the commit it carries.
|
|
10
|
+
*/
|
|
11
|
+
export interface Publication {
|
|
12
|
+
/** The engine's word: push_branch, open_pull_request, merge_pull_request. */
|
|
13
|
+
operation: string;
|
|
14
|
+
/** owner/name. */
|
|
15
|
+
repository: string;
|
|
16
|
+
/** The remote as the engine names it. */
|
|
17
|
+
remote: string;
|
|
18
|
+
branch: string;
|
|
19
|
+
/** The branch a pull request targets, or a merge goes into ('' for a push). */
|
|
20
|
+
base: string;
|
|
21
|
+
/** The commit it carries. */
|
|
22
|
+
commit: string;
|
|
23
|
+
/** The engine's own sentence of it. */
|
|
24
|
+
display: string;
|
|
25
|
+
}
|
|
5
26
|
/** A member's (or the server's) message, as the agent got it. */
|
|
6
27
|
export interface MessageEvent {
|
|
7
28
|
type: 'message';
|
|
@@ -19,7 +40,16 @@ export interface TurnEvent {
|
|
|
19
40
|
/** On running and waiting: the chat has had one member all its life, as it is now (once a second has been added, never again). */
|
|
20
41
|
solo?: boolean;
|
|
21
42
|
status: TurnStatus;
|
|
22
|
-
/**
|
|
43
|
+
/** A turn the chat's goal opened: the goal, the turn's role (work, or verify: the check of a claimed completion) and its number. */
|
|
44
|
+
goal?: {
|
|
45
|
+
goal_id: string;
|
|
46
|
+
role: 'work' | 'verify' | (string & {});
|
|
47
|
+
seq: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Why it waits, and where in its answer — and, for a tool call, which: null unless status is waiting. A publication
|
|
51
|
+
* waiting on a person's yes names its part (tool_call_id, tool_name push|pull_request|merge) and what it does.
|
|
52
|
+
*/
|
|
23
53
|
waiting: {
|
|
24
54
|
reason: WaitingReason;
|
|
25
55
|
text_offset: number;
|
|
@@ -27,8 +57,17 @@ export interface TurnEvent {
|
|
|
27
57
|
tool_call_id?: string;
|
|
28
58
|
tool_name?: string;
|
|
29
59
|
input?: unknown;
|
|
60
|
+
expires_at?: string;
|
|
61
|
+
publication?: Publication;
|
|
30
62
|
} | null;
|
|
63
|
+
/** How it ended, once it has: completed, failed, stopped (a member or the server, or the chat went), budget_exceeded. */
|
|
64
|
+
end?: TurnEnd | (string & {});
|
|
65
|
+
/** Why, when it did not complete and was not stopped — and whether asking again may go otherwise. */
|
|
31
66
|
error: {
|
|
67
|
+
code: string;
|
|
68
|
+
message: string;
|
|
69
|
+
retryable: boolean;
|
|
70
|
+
} | {
|
|
32
71
|
code?: string;
|
|
33
72
|
message?: string;
|
|
34
73
|
} | string | null;
|
|
@@ -47,6 +86,92 @@ export interface ResetEvent {
|
|
|
47
86
|
response_id: string;
|
|
48
87
|
offset: number;
|
|
49
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* The model's reasoning as it thinks, when the agent shows it (thinking: visible): a window of a step's at a time,
|
|
91
|
+
* each after the one before — the turn's own, never a subagent's.
|
|
92
|
+
*/
|
|
93
|
+
export interface ThinkingEvent {
|
|
94
|
+
type: 'thinking';
|
|
95
|
+
seq: number;
|
|
96
|
+
response_id: string;
|
|
97
|
+
run_id: string;
|
|
98
|
+
/** The model step it is of: its windows go together, its reasoning before what the step writes. */
|
|
99
|
+
step_id?: string;
|
|
100
|
+
text: string;
|
|
101
|
+
/**
|
|
102
|
+
* The model's provider would not give its reasoning (an OpenAI organization not verified for reasoning
|
|
103
|
+
* summaries): said once for the turn, with the model and the provider's reason — and no text.
|
|
104
|
+
*/
|
|
105
|
+
unavailable?: true;
|
|
106
|
+
model?: string;
|
|
107
|
+
reason?: string;
|
|
108
|
+
}
|
|
109
|
+
export type GoalKind = 'set' | 'updated' | 'turn_started' | 'judged' | 'verified' | 'status_changed' | 'cleared';
|
|
110
|
+
/** A word of the chat's goal: set, changed, a turn of it begun, a turn judged, a claimed completion checked, its status, cleared. */
|
|
111
|
+
export interface GoalEvent {
|
|
112
|
+
type: 'goal';
|
|
113
|
+
/** The journal's sequence. */
|
|
114
|
+
seq: number;
|
|
115
|
+
goal_id: string;
|
|
116
|
+
kind: GoalKind | (string & {});
|
|
117
|
+
/** set and updated: the goal as it is now. */
|
|
118
|
+
goal?: {
|
|
119
|
+
objective: string;
|
|
120
|
+
rubric: string;
|
|
121
|
+
status: string;
|
|
122
|
+
stop_code: string;
|
|
123
|
+
stop_reason: string;
|
|
124
|
+
phase: string;
|
|
125
|
+
max_turns?: number | null;
|
|
126
|
+
max_cost_usd?: number | null;
|
|
127
|
+
};
|
|
128
|
+
/** updated: what changed. */
|
|
129
|
+
changed?: unknown;
|
|
130
|
+
/** turn_started: the turn's role (work, verify), its number among the goal's turns (the part's seq), its response. */
|
|
131
|
+
role?: string;
|
|
132
|
+
turn?: number;
|
|
133
|
+
response_id?: string;
|
|
134
|
+
run_id?: string;
|
|
135
|
+
/** judged and verified: the evaluator's word, and why; verified: what is missing. */
|
|
136
|
+
verdict?: string;
|
|
137
|
+
reason?: string;
|
|
138
|
+
missing?: unknown;
|
|
139
|
+
/** status_changed: from what to what, and the stop's code (cleared: reason too). */
|
|
140
|
+
from?: string;
|
|
141
|
+
to?: string;
|
|
142
|
+
code?: string;
|
|
143
|
+
}
|
|
144
|
+
/** One message or answer of what a fork began with. */
|
|
145
|
+
export interface HistoryItem {
|
|
146
|
+
/** user: a member's message, or the server's; assistant: the agent's answer. */
|
|
147
|
+
role: 'user' | 'assistant';
|
|
148
|
+
message_id?: string;
|
|
149
|
+
client_id?: string;
|
|
150
|
+
author?: string | null;
|
|
151
|
+
author_name?: string;
|
|
152
|
+
text: string;
|
|
153
|
+
metadata?: Record<string, string>;
|
|
154
|
+
created_at?: string;
|
|
155
|
+
/** An answer's response, in the chat it was forked from. */
|
|
156
|
+
response_id?: string;
|
|
157
|
+
/** Its text here is the first of a longer one: the fork's model read it whole. */
|
|
158
|
+
text_truncated?: boolean;
|
|
159
|
+
/** A message's pictures and files ([] or absent for none), as the chat it was forked from had them. */
|
|
160
|
+
attachments?: MessageAttachment[];
|
|
161
|
+
}
|
|
162
|
+
/** What a fork began with: the chat's messages and its agent's answers before the message it was cut before, a few to a part — written first in the fork's channel. */
|
|
163
|
+
export interface HistoryEvent {
|
|
164
|
+
type: 'history';
|
|
165
|
+
/** The chat it was forked from, and the message it was cut before. */
|
|
166
|
+
forked_from: {
|
|
167
|
+
chat_id: string;
|
|
168
|
+
before_message: string;
|
|
169
|
+
} | null;
|
|
170
|
+
/** This part's place among the history's parts, and how many there are. */
|
|
171
|
+
part: number;
|
|
172
|
+
parts: number;
|
|
173
|
+
items: HistoryItem[];
|
|
174
|
+
}
|
|
50
175
|
/** A tool call, each time its state changes. */
|
|
51
176
|
export interface ToolEvent {
|
|
52
177
|
type: 'tool';
|
|
@@ -68,6 +193,16 @@ export interface ToolEvent {
|
|
|
68
193
|
is_error?: boolean;
|
|
69
194
|
/** The subagent's response that made the call, when one did. */
|
|
70
195
|
agent_response_id?: string | null;
|
|
196
|
+
/** A publication's part (named push, pull_request or merge, its call_id the publication's id): what it does and where. */
|
|
197
|
+
publication?: Publication;
|
|
198
|
+
/** When its approval lapses, while it waits for one. */
|
|
199
|
+
expires_at?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Its answer is shown by its end (output: its last 16 KiB): how many bytes before it were left out, and that the
|
|
202
|
+
* part was cut to fit the channel — the whole answer is read by its call (chatToolCall).
|
|
203
|
+
*/
|
|
204
|
+
omittedBytes: number;
|
|
205
|
+
outputTruncated: boolean;
|
|
71
206
|
[field: string]: unknown;
|
|
72
207
|
}
|
|
73
208
|
/** A subagent at work — or one the agent asked for and was refused (status denied, with its reason). */
|
|
@@ -88,46 +223,44 @@ export interface AgentEvent {
|
|
|
88
223
|
reason?: string;
|
|
89
224
|
[field: string]: unknown;
|
|
90
225
|
}
|
|
91
|
-
/** The chat's live voice: what
|
|
226
|
+
/** The chat's live voice began, or ended: whose it is, what becomes of what is asked of it, how long it lasted, why it ended. */
|
|
92
227
|
export interface VoiceEvent {
|
|
93
228
|
type: 'voice';
|
|
229
|
+
/** The journal's sequence of its start; 0 for its end, told from the module's record under the voice's id. */
|
|
94
230
|
seq: number;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
task?: string;
|
|
103
|
-
reason?: string;
|
|
231
|
+
voice_id: string;
|
|
232
|
+
/** Its member; null: the server's own. */
|
|
233
|
+
user_id: string | null;
|
|
234
|
+
/** chat: what the person asks for is a turn of the chat; events: the backend's to do (ai.voice.delegated). */
|
|
235
|
+
delegation: 'chat' | 'events' | (string & {});
|
|
236
|
+
status: 'started' | 'closed' | (string & {});
|
|
237
|
+
/** On closed: how long it lasted, and why it ended (close_requested, member_removed, chat_deleted, replaced, lost, …). */
|
|
104
238
|
seconds?: number;
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
export type ChatEvent = MessageEvent | TurnEvent | TextEvent | ResetEvent | ToolEvent | AgentEvent | VoiceEvent;
|
|
108
|
-
/** Where a reader is: what it hands the stream to go on from there. */
|
|
109
|
-
export interface ChatPosition {
|
|
110
|
-
/** The id of the last journal event held. */
|
|
111
|
-
after?: number;
|
|
112
|
-
/** The response whose answer is being read, and the bytes of it held. */
|
|
113
|
-
response?: string;
|
|
114
|
-
offset?: number;
|
|
115
|
-
}
|
|
116
|
-
export interface FollowChatOptions extends ChatPosition {
|
|
117
|
-
signal?: AbortSignal;
|
|
118
|
-
/** How long a stream that keeps being cut is followed again before the reader is told (default 2 minutes). */
|
|
119
|
-
resumeFor?: number;
|
|
120
|
-
/** A stream with no byte for this long is taken for cut (default 45 s; the module's heartbeat is more often). */
|
|
121
|
-
idleFor?: number;
|
|
239
|
+
close_reason?: string;
|
|
122
240
|
}
|
|
123
|
-
/**
|
|
124
|
-
export interface
|
|
125
|
-
|
|
241
|
+
/** A line said in the chat's voice — the person's (user) or the voice's (assistant): a message of kind voice of its history. */
|
|
242
|
+
export interface TranscriptEvent {
|
|
243
|
+
type: 'transcript';
|
|
244
|
+
seq: number;
|
|
245
|
+
/** The line's id: its message's in the chat's history. */
|
|
246
|
+
id: string;
|
|
247
|
+
voice_id: string;
|
|
248
|
+
role: 'user' | 'assistant' | (string & {});
|
|
249
|
+
/** The member who said it; null: the voice. */
|
|
250
|
+
user_id: string | null;
|
|
251
|
+
author_name: string;
|
|
252
|
+
text: string;
|
|
253
|
+
final: boolean;
|
|
254
|
+
created_at: string;
|
|
126
255
|
}
|
|
127
|
-
|
|
128
|
-
export type OpenChatStream = (query: ChatPosition, signal: AbortSignal) => Promise<globalThis.Response>;
|
|
256
|
+
export type ChatEvent = MessageEvent | TurnEvent | TextEvent | ResetEvent | ThinkingEvent | ToolEvent | AgentEvent | GoalEvent | HistoryEvent | VoiceEvent | TranscriptEvent;
|
|
129
257
|
/** A chat refusal of the module's, said in words its caller can act on; anything else (or one said already) as it was. */
|
|
130
258
|
export declare function chatRefusal(e: unknown): unknown;
|
|
131
259
|
/** The same promise, its chat refusals said as chatRefusal says them. */
|
|
132
260
|
export declare function told<T>(p: Promise<T>): Promise<T>;
|
|
133
|
-
|
|
261
|
+
/**
|
|
262
|
+
* One part of a chat's channel (the payload of its "chat" event) as a chat
|
|
263
|
+
* event — undefined for one this runtime does not read: a newer module's
|
|
264
|
+
* part, or one that is not a part at all.
|
|
265
|
+
*/
|
|
266
|
+
export declare function chatPart(payload: unknown): ChatEvent | undefined;
|