@teable/agent-gateway 0.0.0-stage → 1.0.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.
@@ -0,0 +1,53 @@
1
+ import type { Platform } from "./platform.js";
2
+ /** How often things happen; tests shorten them. */
3
+ interface Timing {
4
+ reconnectMinMs: number;
5
+ reconnectMaxMs: number;
6
+ /** How often the gateway checks the socket is alive, and how long it waits for the answer. */
7
+ pingEveryMs: number;
8
+ pongWithinMs: number;
9
+ /** How often the sandbox is touched while a turn runs. */
10
+ touchEveryMs: number;
11
+ /** How long before a model token expires the gateway replaces it, and retries if that fails. */
12
+ refreshBeforeMs: number;
13
+ refreshRetryMs: number;
14
+ /** How long an agent with no turn running is kept; session/load brings it back. */
15
+ idleMs: number;
16
+ /** How long the agent may take to answer initialize, session/new and session/load. */
17
+ startMs: number;
18
+ }
19
+ export interface GatewayOptions {
20
+ /** TEABLE_NEXT_AGENT_URL. */
21
+ hubUrl: string;
22
+ /** TEABLE_NEXT_GATEWAY_TOKEN. */
23
+ token: string;
24
+ platform: Pick<Platform, "modelKey" | "touch">;
25
+ /** The person's home: apps are checked out in `apps/<appId>` under it. */
26
+ home: string;
27
+ /** Where the gateway keeps its files: agents' state, model tokens. */
28
+ stateDir: string;
29
+ /** The environment agents and the CLI start with (the gateway's own, less its token). */
30
+ env: NodeJS.ProcessEnv;
31
+ /** The package's version, for the hello. */
32
+ version: string;
33
+ log(line: string): void;
34
+ /**
35
+ * The gateway stopped for good: a newer gateway replaced it, or the hub
36
+ * refused it (`refused`: its token, refused or expired, or its protocol).
37
+ * A refused gateway can do nothing until it is started with a fresh token.
38
+ */
39
+ onStop?(stop: {
40
+ reason: string;
41
+ refused: boolean;
42
+ }): void;
43
+ timing?: Partial<Timing>;
44
+ }
45
+ export declare class Gateway {
46
+ #private;
47
+ readonly instance: `${string}-${string}-${string}-${string}-${string}`;
48
+ constructor(options: GatewayOptions);
49
+ start(): void;
50
+ /** Stop: the socket, every agent, every timer. */
51
+ stop(): void;
52
+ }
53
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The old platform's two routes the gateway calls (ADR 0006 §6), with the
3
+ * person's own temporary token (TEABLE_TOKEN):
4
+ *
5
+ * - `POST /api/teable-next/agent/model-key` with `{ baseId }`: an AI proxy
6
+ * token for this person and that project (the session's app), valid for
7
+ * an hour, whose credits go to the project's space; 403 without
8
+ * membership or teable-next, 404 for a project not in teable-next;
9
+ * - `POST /api/teable-next/agent/sandbox/touch`: keeps the sandbox up while a
10
+ * turn runs.
11
+ */
12
+ /** A model token, and where and what it reaches. */
13
+ export interface ModelKey {
14
+ token: string;
15
+ /** In milliseconds since the epoch. */
16
+ expiresAt: number;
17
+ /** The model the old platform's settings choose. */
18
+ model: string;
19
+ /** The AI proxy as an OpenAI client's base URL takes it. */
20
+ openaiBaseUrl: string;
21
+ /** The AI proxy as an Anthropic client's base URL takes it. */
22
+ anthropicBaseUrl: string;
23
+ }
24
+ /**
25
+ * When a token expires: an ISO 8601 date, or a number of milliseconds (or
26
+ * of seconds, if it is too small to be milliseconds) since the epoch.
27
+ */
28
+ export declare function expiryOf(value: unknown): number | undefined;
29
+ export declare class Platform {
30
+ #private;
31
+ constructor(endpoint: string, token: string);
32
+ /** A model token for the project `baseId` (an app's id). */
33
+ modelKey(baseId: string): Promise<ModelKey>;
34
+ touch(): Promise<void>;
35
+ }
@@ -0,0 +1,554 @@
1
+ /**
2
+ * The agent protocol (ADR 0012): what travels between the agent gateway in a
3
+ * person's sandbox, their hub (`AgentHub` in apps/runtime, one per person)
4
+ * and the builder's agent panel, over two WebSockets.
5
+ *
6
+ * gateway ⇄ hub GET GATEWAY_PATH, with `Authorization: Bearer <gateway
7
+ * token>`. ACP's JSON-RPC messages, unchanged, in
8
+ * `{ session, acp }` frames; and control frames, which
9
+ * have a `type`: the hub asks the gateway to open and
10
+ * close sessions, the gateway says what it runs.
11
+ * tab ⇄ hub GET `${APPS_PATH}/:appId/agent?since=<seq>` (APPS_PATH
12
+ * from @teable/app/protocol), with the identity cookie.
13
+ * The hub sends a snapshot, then each stored event after
14
+ * `since` as `{ type: "event", seq, session, at, event }`,
15
+ * then live ones; the tab sends commands `{ id, session,
16
+ * op }`, each acknowledged once by its `id`. Everything the
17
+ * hub sends a tab has a `type`.
18
+ *
19
+ * Every message is one JSON text frame, except the keep-alive: either side
20
+ * of a hub socket may send PING, which the hub answers with PONG.
21
+ *
22
+ * It imports nothing: the gateway runs it in Node and Bun, the runtime in
23
+ * workerd, and the panel imports its types.
24
+ */
25
+ /** The gateway's socket, on the runtime's hosts (under /api/v4, as APPS_PATH is). */
26
+ export declare const GATEWAY_PATH = "/api/v4/agent/gateway";
27
+ /**
28
+ * This protocol's version, which the gateway says in its hello. The hub
29
+ * closes the socket of a gateway that speaks another (GATEWAY_CLOSE.unsupported).
30
+ */
31
+ export declare const AGENT_PROTOCOL = 1;
32
+ /** The keep-alive: sent as a text frame, answered by the hub without waking it. */
33
+ export declare const PING = "ping";
34
+ export declare const PONG = "pong";
35
+ /**
36
+ * Why the hub closed the gateway's socket, when the gateway must not dial
37
+ * again: a newer gateway of the same person connected (one gateway per
38
+ * person, the newest wins), the gateway token expired, or the gateway
39
+ * speaks another AGENT_PROTOCOL. The old platform starts a gateway with a
40
+ * fresh token when the panel asks for the sandbox.
41
+ */
42
+ export declare const GATEWAY_CLOSE: {
43
+ readonly replaced: 4000;
44
+ readonly expired: 4001;
45
+ readonly unsupported: 4002;
46
+ };
47
+ /** Session ids, made by the hub: `ses` and 16 letters or digits. */
48
+ export declare const SESSION_ID: RegExp;
49
+ /** A JSON-RPC request id. */
50
+ export type JsonRpcId = string | number;
51
+ export interface AcpRequest {
52
+ jsonrpc: "2.0";
53
+ id: JsonRpcId;
54
+ method: string;
55
+ params?: unknown;
56
+ result?: never;
57
+ error?: never;
58
+ }
59
+ export interface AcpNotification {
60
+ jsonrpc: "2.0";
61
+ method: string;
62
+ params?: unknown;
63
+ id?: never;
64
+ result?: never;
65
+ error?: never;
66
+ }
67
+ export interface AcpResponse {
68
+ jsonrpc: "2.0";
69
+ id: JsonRpcId;
70
+ result?: unknown;
71
+ error?: AcpError;
72
+ method?: never;
73
+ params?: never;
74
+ }
75
+ export interface AcpError {
76
+ code: number;
77
+ message: string;
78
+ data?: unknown;
79
+ }
80
+ export type AcpMessage = AcpRequest | AcpNotification | AcpResponse;
81
+ /** The ACP methods the hub and the gateway send or read. */
82
+ export declare const ACP: {
83
+ readonly initialize: "initialize";
84
+ readonly newSession: "session/new";
85
+ readonly loadSession: "session/load";
86
+ readonly prompt: "session/prompt";
87
+ readonly cancel: "session/cancel";
88
+ readonly update: "session/update";
89
+ readonly requestPermission: "session/request_permission";
90
+ };
91
+ /** Content in prompts and updates (ACP's ContentBlock, from MCP). */
92
+ export type AcpContentBlock = {
93
+ type: "text";
94
+ text: string;
95
+ } | {
96
+ type: "image";
97
+ data: string;
98
+ mimeType: string;
99
+ uri?: string | null;
100
+ } | {
101
+ type: "audio";
102
+ data: string;
103
+ mimeType: string;
104
+ } | {
105
+ type: "resource_link";
106
+ uri: string;
107
+ name: string;
108
+ title?: string | null;
109
+ description?: string | null;
110
+ mimeType?: string | null;
111
+ size?: number | null;
112
+ } | {
113
+ type: "resource";
114
+ resource: AcpEmbeddedResource;
115
+ };
116
+ export type AcpEmbeddedResource = {
117
+ uri: string;
118
+ mimeType?: string | null;
119
+ text: string;
120
+ } | {
121
+ uri: string;
122
+ mimeType?: string | null;
123
+ blob: string;
124
+ };
125
+ export type AcpToolKind = "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
126
+ export type AcpToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
127
+ /** What a tool call shows: content, a file's diff, or a terminal. */
128
+ export type AcpToolCallContent = {
129
+ type: "content";
130
+ content: AcpContentBlock;
131
+ } | {
132
+ type: "diff";
133
+ path: string;
134
+ oldText?: string | null;
135
+ newText: string;
136
+ } | {
137
+ type: "terminal";
138
+ terminalId: string;
139
+ };
140
+ export interface AcpToolCallLocation {
141
+ path: string;
142
+ line?: number | null;
143
+ }
144
+ /** A tool call's fields: a `tool_call` sets them, a `tool_call_update` changes those it carries. */
145
+ export interface AcpToolCallUpdate {
146
+ toolCallId: string;
147
+ title?: string | null;
148
+ kind?: AcpToolKind | null;
149
+ status?: AcpToolCallStatus | null;
150
+ content?: AcpToolCallContent[] | null;
151
+ locations?: AcpToolCallLocation[] | null;
152
+ rawInput?: unknown;
153
+ rawOutput?: unknown;
154
+ }
155
+ export interface AcpPlanEntry {
156
+ content: string;
157
+ priority: "high" | "medium" | "low";
158
+ status: "pending" | "in_progress" | "completed";
159
+ }
160
+ export interface AcpAvailableCommand {
161
+ name: string;
162
+ description: string;
163
+ input?: {
164
+ hint: string;
165
+ } | null;
166
+ }
167
+ /**
168
+ * What a `session/update` reports, in `params.update`, by `sessionUpdate`.
169
+ * Agents may send kinds not listed here; show what you know, skip the rest.
170
+ */
171
+ export type AcpSessionUpdate = {
172
+ sessionUpdate: "user_message_chunk";
173
+ content: AcpContentBlock;
174
+ } | {
175
+ sessionUpdate: "agent_message_chunk";
176
+ content: AcpContentBlock;
177
+ } | {
178
+ sessionUpdate: "agent_thought_chunk";
179
+ content: AcpContentBlock;
180
+ } | ({
181
+ sessionUpdate: "tool_call";
182
+ title: string;
183
+ } & AcpToolCallUpdate) | ({
184
+ sessionUpdate: "tool_call_update";
185
+ } & AcpToolCallUpdate) | {
186
+ sessionUpdate: "plan";
187
+ entries: AcpPlanEntry[];
188
+ } | {
189
+ sessionUpdate: "available_commands_update";
190
+ availableCommands: AcpAvailableCommand[];
191
+ } | {
192
+ sessionUpdate: "current_mode_update";
193
+ currentModeId: string;
194
+ } | {
195
+ sessionUpdate: "session_info_update";
196
+ title?: string | null;
197
+ updatedAt?: string | null;
198
+ };
199
+ /** `session/update` (agent → client), a notification: what the agent did, as it happens. */
200
+ export interface AcpSessionNotification {
201
+ sessionId: string;
202
+ update: AcpSessionUpdate;
203
+ }
204
+ export interface AcpPermissionOption {
205
+ optionId: string;
206
+ name: string;
207
+ kind: "allow_once" | "allow_always" | "reject_once" | "reject_always";
208
+ }
209
+ /**
210
+ * `session/request_permission` (agent → client), a request: may the agent
211
+ * go ahead with this tool call? Its result is `{ outcome: AcpPermissionOutcome }`.
212
+ */
213
+ export interface AcpPermissionRequest {
214
+ sessionId: string;
215
+ toolCall: AcpToolCallUpdate;
216
+ options: AcpPermissionOption[];
217
+ }
218
+ /** The answer to a permission request: one of its options, or cancelled with its turn. */
219
+ export type AcpPermissionOutcome = {
220
+ outcome: "cancelled";
221
+ } | {
222
+ outcome: "selected";
223
+ optionId: string;
224
+ };
225
+ /** `session/prompt` (client → agent), a request: a person's message; answered when the turn ends. */
226
+ export interface AcpPromptRequest {
227
+ sessionId: string;
228
+ prompt: AcpContentBlock[];
229
+ }
230
+ /** Why a turn ended, as the agent says in its answer to `session/prompt`. */
231
+ export type AcpStopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
232
+ /** What the agent says it is and can do, in its answer to `initialize`. */
233
+ export interface AcpInitializeResult {
234
+ protocolVersion: number;
235
+ agentCapabilities?: {
236
+ loadSession?: boolean;
237
+ promptCapabilities?: {
238
+ image?: boolean;
239
+ audio?: boolean;
240
+ embeddedContext?: boolean;
241
+ };
242
+ mcpCapabilities?: {
243
+ http?: boolean;
244
+ sse?: boolean;
245
+ };
246
+ };
247
+ authMethods?: {
248
+ id: string;
249
+ name: string;
250
+ description?: string | null;
251
+ }[];
252
+ agentInfo?: {
253
+ name: string;
254
+ title?: string | null;
255
+ version: string;
256
+ } | null;
257
+ }
258
+ /** What the agent's answer to `session/new` or `session/load` offers besides the id. */
259
+ export interface AcpSessionSetup {
260
+ modes?: unknown;
261
+ models?: unknown;
262
+ configOptions?: unknown;
263
+ }
264
+ export declare function isAcpRequest(message: AcpMessage): message is AcpRequest;
265
+ export declare function isAcpNotification(message: AcpMessage): message is AcpNotification;
266
+ export declare function isAcpResponse(message: AcpMessage): message is AcpResponse;
267
+ /** The agents a gateway starts: grok-build first; Codex and Claude Code follow (ADR 0012). */
268
+ export declare const AGENT_NAMES: readonly ["grok"];
269
+ export type AgentName = (typeof AGENT_NAMES)[number];
270
+ /**
271
+ * What an agent can do, as the hub and the panel need to know it: data, so
272
+ * neither branches on which agent it is. The gateway's registry holds each
273
+ * agent's record and sends them all in its hello.
274
+ */
275
+ export interface AgentCapabilities {
276
+ agent: AgentName;
277
+ /** Its name, for people. */
278
+ title: string;
279
+ /**
280
+ * What happens to a message sent with `steer` while a turn runs: "steer"
281
+ * puts it into the running turn; "interrupt" stops the turn and sends it next.
282
+ */
283
+ steering: "steer" | "interrupt";
284
+ /** Whether it asks before acting (`session/request_permission`). */
285
+ approvals: boolean;
286
+ /** Whether it reports its plan (`plan` updates). */
287
+ plans: boolean;
288
+ /** Whether it runs background tasks that outlive a turn. */
289
+ backgroundTasks: boolean;
290
+ /** Whether a session survives a restart of the agent or the sandbox (`session/load`). */
291
+ resume: boolean;
292
+ }
293
+ /**
294
+ * ACP for one session, both ways: relayed unchanged between the hub and the
295
+ * session's agent. The gateway answers a request for a session whose agent
296
+ * does not run with an error, and keeps vendor extensions (methods starting
297
+ * with `_`) to its per-agent shims: the hub sees standard ACP.
298
+ */
299
+ export interface AcpFrame {
300
+ session: string;
301
+ acp: AcpMessage;
302
+ }
303
+ /** What the hub asks of the gateway. */
304
+ export type HubControl =
305
+ /**
306
+ * Start the session's agent in the app's checkout: resume the agent's own
307
+ * session with `session/load` when it has one (`acpSessionId`), else start
308
+ * one. Answered with `opened` or `failed`; opening an open session answers
309
+ * `opened` again.
310
+ */
311
+ {
312
+ type: "open";
313
+ session: string;
314
+ agent: AgentName;
315
+ appId: string;
316
+ spaceId: string;
317
+ acpSessionId: string | null;
318
+ }
319
+ /** Stop the session's agent. Answered with `closed`. */
320
+ | {
321
+ type: "close";
322
+ session: string;
323
+ };
324
+ /** The hub sends nothing before the gateway's hello. */
325
+ export type HubToGateway = AcpFrame | HubControl;
326
+ /** A session the gateway runs an agent for. */
327
+ export interface GatewaySession {
328
+ session: string;
329
+ /** The agent's own session id; null while the agent starts. */
330
+ acpSessionId: string | null;
331
+ /** The ids of the `session/prompt` requests its agent has not answered yet. */
332
+ prompts: JsonRpcId[];
333
+ }
334
+ /** What the gateway tells the hub. */
335
+ export type GatewayControl =
336
+ /**
337
+ * Sent on every connection, after what the gateway kept while it was
338
+ * disconnected: the protocol it speaks, which gateway process this is
339
+ * (`instance`) and its package version, its agents, and the sessions it
340
+ * runs now. A session it does not list has no agent.
341
+ */
342
+ {
343
+ type: "hello";
344
+ protocol: number;
345
+ instance: string;
346
+ version: string;
347
+ agents: AgentCapabilities[];
348
+ sessions: GatewaySession[];
349
+ }
350
+ /**
351
+ * The session's agent runs: it resumed the agent's session (`resumed`), or
352
+ * started a new one, which knows nothing of the conversation before.
353
+ */
354
+ | {
355
+ type: "opened";
356
+ session: string;
357
+ acpSessionId: string;
358
+ resumed: boolean;
359
+ initialize: AcpInitializeResult;
360
+ setup: AcpSessionSetup;
361
+ }
362
+ /** The session's agent could not start. */
363
+ | {
364
+ type: "failed";
365
+ session: string;
366
+ message: string;
367
+ }
368
+ /** The session's agent stopped: it exited, was closed, or sat idle. */
369
+ | {
370
+ type: "closed";
371
+ session: string;
372
+ message: string;
373
+ };
374
+ export type GatewayToHub = AcpFrame | GatewayControl;
375
+ /**
376
+ * A command from a tab. `id` names it: any string the tab makes up, unique
377
+ * among the person's commands, so that sending it again (after a reconnect)
378
+ * gets the same acknowledgement and does nothing twice.
379
+ */
380
+ export interface TabCommand {
381
+ id: string;
382
+ /** The session it is for; null for `new`. */
383
+ session: string | null;
384
+ op: TabOp;
385
+ }
386
+ /**
387
+ * What a command does. Starting a session, prompting and answering
388
+ * permission requests need a creator or owner of the app's space, as
389
+ * publishing does; any member may connect, read their own sessions and cancel.
390
+ */
391
+ export type TabOp =
392
+ /** Start a session about the tab's app, with `prompt` as its first message, if given. */
393
+ {
394
+ type: "new";
395
+ agent: AgentName;
396
+ prompt?: AcpContentBlock[];
397
+ }
398
+ /**
399
+ * Send a message. While a turn runs it waits in the queue; with `steer`
400
+ * it goes to the running turn instead, as the agent's `steering` says.
401
+ */
402
+ | {
403
+ type: "prompt";
404
+ prompt: AcpContentBlock[];
405
+ steer?: boolean;
406
+ }
407
+ /** Stop a turn: the running one, or a queued one by its number. */
408
+ | {
409
+ type: "cancel";
410
+ turn?: number;
411
+ }
412
+ /** Answer a permission request, named by the `seq` of the event that asked. The first answer wins. */
413
+ | {
414
+ type: "permission";
415
+ request: number;
416
+ outcome: AcpPermissionOutcome;
417
+ };
418
+ /** Why a command was refused: malformed, not allowed, nothing to act on, or too late. */
419
+ export type AgentErrorCode = "BAD_INPUT" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT";
420
+ export interface AgentError {
421
+ code: AgentErrorCode;
422
+ message: string;
423
+ }
424
+ /** The answer to a command, sent once per command id to the tab that sent it. */
425
+ export type Ack = {
426
+ type: "ack";
427
+ id: string;
428
+ ok: true;
429
+ session: string;
430
+ turn: number | null;
431
+ } | {
432
+ type: "ack";
433
+ id: string;
434
+ ok: false;
435
+ error: AgentError;
436
+ };
437
+ /** Whether the person's gateway is connected, and the agents it last said it has. */
438
+ export interface GatewayStatus {
439
+ connected: boolean;
440
+ agents: AgentCapabilities[];
441
+ }
442
+ /** idle: nothing to do; queued: messages wait to run (for the gateway, perhaps); running: a turn runs. */
443
+ export type SessionState = "idle" | "queued" | "running";
444
+ /** A session as it is now: one row of the hub's. */
445
+ export interface SessionInfo {
446
+ session: string;
447
+ appId: string;
448
+ spaceId: string;
449
+ agent: AgentName;
450
+ createdBy: string;
451
+ createdAt: number;
452
+ /** The agent's title for it, else the start of its first message. */
453
+ title: string | null;
454
+ state: SessionState;
455
+ /** The running turn. */
456
+ turn: number | null;
457
+ /** The turns waiting, in the order they will run. */
458
+ queued: number[];
459
+ /** The permission requests waiting for an answer, by the `seq` of the event that asked. */
460
+ permissions: number[];
461
+ lastSeq: number;
462
+ }
463
+ /** Something that happened in a session: stored, numbered and sent to every tab of its app. */
464
+ export type SessionEvent = {
465
+ type: "created";
466
+ appId: string;
467
+ spaceId: string;
468
+ agent: AgentName;
469
+ by: string;
470
+ }
471
+ /** A person's message, numbered `turn` in the session; it waits until it can run. */
472
+ | {
473
+ type: "prompt";
474
+ turn: number;
475
+ by: string;
476
+ prompt: AcpContentBlock[];
477
+ steer: boolean;
478
+ }
479
+ /** The turn went to the agent. */
480
+ | {
481
+ type: "turn_started";
482
+ turn: number;
483
+ }
484
+ /**
485
+ * A message from the agent, unchanged: `session/update` notifications and
486
+ * `session/request_permission` requests, during `turn` (null between turns).
487
+ */
488
+ | {
489
+ type: "acp";
490
+ turn: number | null;
491
+ acp: AcpMessage;
492
+ }
493
+ /** A permission request (the `seq` of its event) was answered, by `by`; null when it was cancelled. */
494
+ | {
495
+ type: "permission_answered";
496
+ request: number;
497
+ outcome: AcpPermissionOutcome;
498
+ by: string | null;
499
+ }
500
+ /** Someone asked to stop the turn; it ends with `turn_ended`. */
501
+ | {
502
+ type: "cancel_requested";
503
+ turn: number;
504
+ by: string;
505
+ }
506
+ /** The turn ended: the agent's stop reason, or, when it could not finish, why. */
507
+ | {
508
+ type: "turn_ended";
509
+ turn: number;
510
+ stopReason: AcpStopReason | null;
511
+ error: string | null;
512
+ }
513
+ /** The session's agent started: it resumed its session, or started a new one (`resumed` false). */
514
+ | {
515
+ type: "agent_started";
516
+ resumed: boolean;
517
+ initialize: AcpInitializeResult;
518
+ setup: AcpSessionSetup;
519
+ }
520
+ /** The session's agent stopped, or could not start. */
521
+ | {
522
+ type: "agent_stopped";
523
+ message: string;
524
+ };
525
+ /** A stored event: `seq` numbers every event of the person's, in the order the hub took them. */
526
+ export interface TabEvent {
527
+ type: "event";
528
+ seq: number;
529
+ session: string;
530
+ /** When the hub stored it, in milliseconds since the epoch. */
531
+ at: number;
532
+ event: SessionEvent;
533
+ }
534
+ export type HubToTab = TabEvent | Ack
535
+ /**
536
+ * First on every connection: this app's sessions as they are, whether a
537
+ * gateway is connected, whether this person may start sessions, prompt
538
+ * and answer permission requests here (`canPrompt`), and the latest `seq`
539
+ * (of any app's). Events after the tab's `since` follow, up to that `seq`,
540
+ * then live ones. Reconnect with `since` the larger of that `seq` and the
541
+ * last event's.
542
+ */
543
+ | {
544
+ type: "snapshot";
545
+ seq: number;
546
+ canPrompt: boolean;
547
+ gateway: GatewayStatus;
548
+ sessions: SessionInfo[];
549
+ }
550
+ /** The gateway connected or went away. */
551
+ | {
552
+ type: "gateway";
553
+ gateway: GatewayStatus;
554
+ };
@@ -0,0 +1,26 @@
1
+ import {
2
+ ACP,
3
+ AGENT_NAMES,
4
+ AGENT_PROTOCOL,
5
+ GATEWAY_CLOSE,
6
+ GATEWAY_PATH,
7
+ PING,
8
+ PONG,
9
+ SESSION_ID,
10
+ isAcpNotification,
11
+ isAcpRequest,
12
+ isAcpResponse
13
+ } from "./chunks/5YARUI7L.js";
14
+ export {
15
+ ACP,
16
+ AGENT_NAMES,
17
+ AGENT_PROTOCOL,
18
+ GATEWAY_CLOSE,
19
+ GATEWAY_PATH,
20
+ PING,
21
+ PONG,
22
+ SESSION_ID,
23
+ isAcpNotification,
24
+ isAcpRequest,
25
+ isAcpResponse
26
+ };
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@teable/agent-gateway",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "The agent gateway in a person's Teable sandbox: starts an ACP agent for each session and relays it to the person's hub",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/teableio/teable-next.git",
9
+ "directory": "packages/agent-gateway"
10
+ },
11
+ "type": "module",
12
+ "exports": {
13
+ "./protocol": {
14
+ "types": "./dist/protocol.d.ts",
15
+ "default": "./dist/protocol.js"
16
+ }
17
+ },
18
+ "bin": {
19
+ "teable-agent-gateway": "./dist/cli.js"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "engines": {
25
+ "node": ">=22.4",
26
+ "bun": ">=1.2"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "provenance": true
31
+ }
32
+ }