@teable/agent-gateway 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -31,6 +31,9 @@ Apps are checked out in `~/apps/<appId>` with `teable-next clone`
31
31
  gateway keeps its own files in `~/.teable-agent-gateway`. Its agent today is
32
32
  grok-build (`grok agent --always-approve stdio`), configured to reach nothing
33
33
  but Teable's AI proxy, with a model token per session that the gateway renews.
34
+ It acts without asking, but when it asks the person a question, or to approve
35
+ its plan, the gateway puts that to them in Teable's builder and gives the
36
+ answer back.
34
37
 
35
38
  `@teable/agent-gateway/protocol` holds the types of what travels between the
36
39
  gateway, the hub and the builder.
package/dist/agent.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type AcpMessage, type JsonRpcId } from "./protocol.js";
2
+ import type { AskShim } from "./shims.js";
2
3
  interface AgentStart {
3
4
  command: string;
4
5
  args: string[];
@@ -9,6 +10,8 @@ interface AgentStart {
9
10
  /** The process ended, and why. */
10
11
  onExit(message: string): void;
11
12
  log(line: string): void;
13
+ /** The vendor requests with which the agent asks the person, by method (shims.ts). */
14
+ asks?: Readonly<Record<string, AskShim>>;
12
15
  }
13
16
  export declare class AgentProcess {
14
17
  #private;
@@ -20,7 +23,7 @@ export declare class AgentProcess {
20
23
  request(method: string, params: unknown, timeoutMs: number): Promise<unknown>;
21
24
  /** A request whose replayed updates the hub must not see again: `session/load`. */
22
25
  load(params: unknown, timeoutMs: number): Promise<unknown>;
23
- /** Relay the hub's message to the agent, unchanged. */
26
+ /** Relay the hub's message to the agent: unchanged, but an answer to what a shim asked, in the agent's words. */
24
27
  send(message: AcpMessage): void;
25
28
  /** Stop reading what the agent says (its writes then wait), and read on. */
26
29
  pause(): void;
package/dist/agents.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ModelKey } from "./platform.js";
2
2
  import type { AgentCapabilities, AgentName } from "./protocol.js";
3
+ import { type AskShim } from "./shims.js";
3
4
  /** What a session's agent is prepared with. */
4
5
  interface AgentContext {
5
6
  /** The gateway's own directory: agents keep their state under it. */
@@ -14,6 +15,8 @@ interface AgentDefinition {
14
15
  args: string[];
15
16
  /** Write the agent's configuration for a session; the environment to start it with. */
16
17
  prepare(context: AgentContext): Record<string, string>;
18
+ /** Its vendor requests that ask the person, by method, and the shims that relay them (shims.ts). */
19
+ asks?: Readonly<Record<string, AskShim>>;
17
20
  }
18
21
  /** Write a file whole or not at all: an agent starting meanwhile reads the old one or the new one. */
19
22
  export declare function writeAtomically(path: string, text: string, mode?: number): void;
@@ -14,6 +14,12 @@ var ACP = {
14
14
  update: "session/update",
15
15
  requestPermission: "session/request_permission"
16
16
  };
17
+ var ASK = {
18
+ /** Questions for the person (AgentQuestionRequest), answered with an AgentQuestionOutcome. */
19
+ question: "_teable/question",
20
+ /** A plan for the person to approve before the agent acts on it (AgentPlanRequest), answered with an AgentPlanOutcome. */
21
+ plan: "_teable/plan"
22
+ };
17
23
  function isAcpRequest(message) {
18
24
  return "method" in message && "id" in message;
19
25
  }
@@ -33,6 +39,7 @@ export {
33
39
  GATEWAY_CLOSE,
34
40
  SESSION_ID,
35
41
  ACP,
42
+ ASK,
36
43
  isAcpRequest,
37
44
  isAcpNotification,
38
45
  isAcpResponse,
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  ACP,
4
4
  AGENT_NAMES,
5
5
  AGENT_PROTOCOL,
6
+ ASK,
6
7
  GATEWAY_CLOSE,
7
8
  PING,
8
9
  PONG,
@@ -10,7 +11,7 @@ import {
10
11
  isAcpNotification,
11
12
  isAcpRequest,
12
13
  isAcpResponse
13
- } from "./chunks/5YARUI7L.js";
14
+ } from "./chunks/CYVXAHGU.js";
14
15
 
15
16
  // src/cli.ts
16
17
  import { readFileSync } from "node:fs";
@@ -26,6 +27,7 @@ import { join as join3 } from "node:path";
26
27
  import { spawn } from "node:child_process";
27
28
  import { createInterface } from "node:readline";
28
29
  var METHOD_NOT_FOUND = -32601;
30
+ var INVALID_PARAMS = -32602;
29
31
  var STDERR_LINES = 20;
30
32
  var AgentProcess = class {
31
33
  #child;
@@ -33,6 +35,8 @@ var AgentProcess = class {
33
35
  #pending = /* @__PURE__ */ new Map();
34
36
  /** The hub's `session/prompt` requests the agent has not answered. */
35
37
  #prompts = /* @__PURE__ */ new Set();
38
+ /** The agent's requests that ask the person, relayed by a shim, until the hub answers them. */
39
+ #asked = /* @__PURE__ */ new Map();
36
40
  #stderr = [];
37
41
  #nextId = 1;
38
42
  #loading = false;
@@ -99,11 +103,29 @@ var AgentProcess = class {
99
103
  this.#loading = false;
100
104
  }
101
105
  }
102
- /** Relay the hub's message to the agent, unchanged. */
106
+ /** Relay the hub's message to the agent: unchanged, but an answer to what a shim asked, in the agent's words. */
103
107
  send(message) {
104
108
  if (isAcpRequest(message) && message.method === ACP.prompt) this.#prompts.add(message.id);
109
+ const asked = isAcpResponse(message) ? this.#asked.get(message.id) : void 0;
110
+ if (asked && isAcpResponse(message)) {
111
+ this.#asked.delete(message.id);
112
+ if (message.error === void 0) {
113
+ this.#write(this.#answer(message.id, asked, message.result));
114
+ return;
115
+ }
116
+ }
105
117
  this.#write(message);
106
118
  }
119
+ /** The hub's answer to what a shim asked, in the agent's words. */
120
+ #answer(id, asked, answer) {
121
+ try {
122
+ return { jsonrpc: "2.0", id, result: asked.shim.result(answer, asked.params) };
123
+ } catch (error) {
124
+ const why = error instanceof Error ? error.message : String(error);
125
+ this.#start.log(`the hub's answer to ${asked.shim.method} could not be given: ${why}`);
126
+ return { jsonrpc: "2.0", id, error: { code: INVALID_PARAMS, message: why } };
127
+ }
128
+ }
107
129
  /** Stop reading what the agent says (its writes then wait), and read on. */
108
130
  pause() {
109
131
  this.#child.stdout?.pause();
@@ -146,16 +168,37 @@ var AgentProcess = class {
146
168
  }
147
169
  this.#prompts.delete(message.id);
148
170
  } else if (message.method.startsWith("_")) {
149
- if (isAcpRequest(message)) {
150
- const error = { code: METHOD_NOT_FOUND, message: `${message.method} is not supported` };
151
- this.#write({ jsonrpc: "2.0", id: message.id, error });
152
- }
171
+ if (isAcpRequest(message)) this.#vendorRequest(message);
153
172
  return;
154
173
  } else if (this.#loading && isAcpNotification(message) && message.method === ACP.update) {
155
174
  return;
156
175
  }
157
176
  this.#start.onMessage(message);
158
177
  }
178
+ /** A vendor request: what the agent asks the person goes to the hub as the protocol's; the rest is unknown. */
179
+ #vendorRequest(message) {
180
+ const shim = this.#start.asks?.[message.method];
181
+ if (!shim) {
182
+ const error = { code: METHOD_NOT_FOUND, message: `${message.method} is not supported` };
183
+ this.#write({ jsonrpc: "2.0", id: message.id, error });
184
+ return;
185
+ }
186
+ let params;
187
+ try {
188
+ params = shim.request(message.params);
189
+ } catch (error) {
190
+ const why = error instanceof Error ? error.message : String(error);
191
+ this.#start.log(`the agent's ${message.method} could not be read: ${why}`);
192
+ this.#write({
193
+ jsonrpc: "2.0",
194
+ id: message.id,
195
+ error: { code: INVALID_PARAMS, message: `${message.method}: ${why}` }
196
+ });
197
+ return;
198
+ }
199
+ this.#asked.set(message.id, { shim, params: message.params });
200
+ this.#start.onMessage({ jsonrpc: "2.0", id: message.id, method: shim.method, params });
201
+ }
159
202
  #exit(message) {
160
203
  if (this.#exited) return;
161
204
  this.#exited = true;
@@ -168,10 +211,98 @@ var AgentProcess = class {
168
211
  // src/agents.ts
169
212
  import { chmodSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
170
213
  import { dirname, join } from "node:path";
171
- function writeAtomically(path, text, mode = 384) {
214
+
215
+ // src/shims.ts
216
+ function fields(value, what) {
217
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
218
+ throw new Error(`${what} is not an object`);
219
+ }
220
+ return value;
221
+ }
222
+ function text(value, what) {
223
+ if (typeof value !== "string") throw new Error(`${what} is not a string`);
224
+ return value;
225
+ }
226
+ var textOrNull = (value) => typeof value === "string" ? value : null;
227
+ function list(value, what) {
228
+ if (!Array.isArray(value)) throw new Error(`${what} is not a list`);
229
+ return value;
230
+ }
231
+ var grokQuestions = {
232
+ method: ASK.question,
233
+ request(params) {
234
+ const asked = fields(params, "ask_user_question's params");
235
+ const questions = list(asked.questions, "questions").map((value, index) => {
236
+ const question = fields(value, `question ${index}`);
237
+ return {
238
+ question: text(question.question, `question ${index}'s text`),
239
+ options: list(question.options, `question ${index}'s options`).map((option, at) => {
240
+ const choice = fields(option, `question ${index}'s option ${at}`);
241
+ return {
242
+ label: text(choice.label, `question ${index}'s option ${at}'s label`),
243
+ description: textOrNull(choice.description),
244
+ preview: textOrNull(choice.preview)
245
+ };
246
+ }),
247
+ multiSelect: question.multiSelect === true,
248
+ freeText: true
249
+ };
250
+ });
251
+ return {
252
+ sessionId: text(asked.sessionId, "sessionId"),
253
+ toolCallId: textOrNull(asked.toolCallId),
254
+ questions
255
+ };
256
+ },
257
+ result(answer, params) {
258
+ const given = fields(answer, "the answer");
259
+ if (given.outcome !== "answered") return { outcome: "cancelled" };
260
+ const questions = list(fields(params, "the params").questions, "questions");
261
+ const answers = list(given.answers, "answers");
262
+ return {
263
+ outcome: "accepted",
264
+ answers: Object.fromEntries(
265
+ questions.map((value, index) => {
266
+ const { picked, text: own } = fields(answers[index] ?? {}, `answer ${index}`);
267
+ const words = [...Array.isArray(picked) ? picked : [], ...own ? [own] : []];
268
+ return [
269
+ text(fields(value, `question ${index}`).question, "a question"),
270
+ words.join(", ")
271
+ ];
272
+ })
273
+ ),
274
+ annotations: {}
275
+ };
276
+ }
277
+ };
278
+ var grokPlan = {
279
+ method: ASK.plan,
280
+ request(params) {
281
+ const asked = fields(params, "exit_plan_mode's params");
282
+ return {
283
+ sessionId: text(asked.sessionId, "sessionId"),
284
+ toolCallId: textOrNull(asked.toolCallId),
285
+ plan: typeof asked.planContent === "string" ? asked.planContent : ""
286
+ };
287
+ },
288
+ result(answer) {
289
+ const given = fields(answer, "the answer");
290
+ if (given.outcome === "approved") return { outcome: "approved" };
291
+ if (given.outcome !== "rejected") return { outcome: "cancelled" };
292
+ const feedback = textOrNull(given.feedback);
293
+ return { outcome: "requested_changes", ...feedback ? { feedback } : {} };
294
+ }
295
+ };
296
+ var GROK_ASKS = {
297
+ "_x.ai/ask_user_question": grokQuestions,
298
+ "_x.ai/exit_plan_mode": grokPlan
299
+ };
300
+
301
+ // src/agents.ts
302
+ function writeAtomically(path, text2, mode = 384) {
172
303
  mkdirSync(dirname(path), { recursive: true, mode: 448 });
173
304
  const temporary = `${path}.${process.pid}.${Math.random().toString(36).slice(2)}`;
174
- writeFileSync(temporary, text, { mode });
305
+ writeFileSync(temporary, text2, { mode });
175
306
  renameSync(temporary, path);
176
307
  }
177
308
  function writeTokenHelper(stateDir) {
@@ -230,6 +361,11 @@ voice_mode = false
230
361
  trace_upload = false
231
362
  mixpanel_enabled = false
232
363
 
364
+ # A question waits for the person's answer, as a permission request does
365
+ # (by default it gives up after 30 minutes and the agent guesses).
366
+ [toolset.ask_user_question]
367
+ timeout_enabled = false
368
+
233
369
  [endpoints]
234
370
  cli_chat_proxy_base_url = "http://127.0.0.1:9/v1"
235
371
  xai_api_base_url = "http://127.0.0.1:9/v1"
@@ -281,14 +417,18 @@ var AGENTS = {
281
417
  title: "Grok Build",
282
418
  // Its own steering is a vendor extension; until a shim speaks it, the hub interrupts.
283
419
  steering: "interrupt",
284
- // Started with --always-approve: it acts without asking.
420
+ // Started with --always-approve: it acts without asking,
285
421
  approvals: false,
422
+ // but it may still ask the person questions, and to approve a plan.
423
+ questions: true,
424
+ planApproval: true,
286
425
  plans: true,
287
426
  backgroundTasks: false,
288
427
  resume: true
289
428
  },
290
429
  command: "grok",
291
430
  args: ["agent", "--always-approve", "stdio"],
431
+ asks: GROK_ASKS,
292
432
  prepare({ stateDir, key, tokenFile }) {
293
433
  const home2 = join(stateDir, "grok");
294
434
  writeAtomically(join(home2, "config.toml"), grokConfig(key, writeTokenHelper(stateDir)));
@@ -656,7 +796,8 @@ var Gateway = class {
656
796
  onMessage: (message) => this.#fromAgent(session, message),
657
797
  // Before it says it runs, an agent that exits has failed to start.
658
798
  onExit: (message) => this.#end(session, message, session.opened ? "closed" : "failed"),
659
- log: (line) => log2(`${id}: ${line}`)
799
+ log: (line) => log2(`${id}: ${line}`),
800
+ asks: definition.asks
660
801
  });
661
802
  session.process = child;
662
803
  const initialize = await child.request(
@@ -870,15 +1011,15 @@ var Platform = class {
870
1011
  body: body === void 0 ? void 0 : JSON.stringify(body),
871
1012
  signal: AbortSignal.timeout(3e4)
872
1013
  });
873
- const text = await response.text();
1014
+ const text2 = await response.text();
874
1015
  if (!response.ok) {
875
- throw new Error(`Teable answered ${response.status} to ${path}: ${text.slice(0, 300)}`);
1016
+ throw new Error(`Teable answered ${response.status} to ${path}: ${text2.slice(0, 300)}`);
876
1017
  }
877
- if (text.trim() === "") return void 0;
1018
+ if (text2.trim() === "") return void 0;
878
1019
  try {
879
- return JSON.parse(text);
1020
+ return JSON.parse(text2);
880
1021
  } catch {
881
- throw new Error(`Teable's answer to ${path} is not JSON: ${text.slice(0, 300)}`);
1022
+ throw new Error(`Teable's answer to ${path} is not JSON: ${text2.slice(0, 300)}`);
882
1023
  }
883
1024
  }
884
1025
  };
@@ -5,9 +5,11 @@
5
5
  *
6
6
  * gateway ⇄ hub GET GATEWAY_PATH, with `Authorization: Bearer <gateway
7
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.
8
+ * `{ session, acp }` frames, with what agents ask the
9
+ * person beyond ACP in one agent-neutral form (ASK); and
10
+ * control frames, which have a `type`: the hub asks the
11
+ * gateway to open and close sessions, the gateway says
12
+ * what it runs.
11
13
  * tab ⇄ hub GET `${APPS_PATH}/:appId/agent?since=<seq>` (APPS_PATH
12
14
  * from @teable/app/protocol), with the identity cookie.
13
15
  * The hub sends a snapshot, then each stored event after
@@ -261,6 +263,63 @@ export interface AcpSessionSetup {
261
263
  models?: unknown;
262
264
  configOptions?: unknown;
263
265
  }
266
+ export declare const ASK: {
267
+ /** Questions for the person (AgentQuestionRequest), answered with an AgentQuestionOutcome. */
268
+ readonly question: "_teable/question";
269
+ /** A plan for the person to approve before the agent acts on it (AgentPlanRequest), answered with an AgentPlanOutcome. */
270
+ readonly plan: "_teable/plan";
271
+ };
272
+ /** A question: the person picks an option, or several, or answers in their own words. */
273
+ export interface AgentQuestion {
274
+ /** The question, as a full sentence. */
275
+ question: string;
276
+ options: AgentQuestionOption[];
277
+ /** Whether more than one option may be picked. */
278
+ multiSelect: boolean;
279
+ /** Whether the person may answer in their own words instead of an option. */
280
+ freeText: boolean;
281
+ }
282
+ export interface AgentQuestionOption {
283
+ label: string;
284
+ /** What picking it means. */
285
+ description: string | null;
286
+ /** What to show while it is considered: a sketch, a snippet. */
287
+ preview: string | null;
288
+ }
289
+ export interface AgentQuestionRequest {
290
+ sessionId: string;
291
+ /** The agent's tool call that asks, when it says. */
292
+ toolCallId: string | null;
293
+ questions: AgentQuestion[];
294
+ }
295
+ /** The answer to questions: for each, in order, the labels picked and the person's own words; or none. */
296
+ export type AgentQuestionOutcome = {
297
+ outcome: "answered";
298
+ answers: {
299
+ picked: string[];
300
+ text: string | null;
301
+ }[];
302
+ } | {
303
+ outcome: "cancelled";
304
+ };
305
+ export interface AgentPlanRequest {
306
+ sessionId: string;
307
+ /** The agent's tool call that asks, when it says. */
308
+ toolCallId: string | null;
309
+ /** The plan, in Markdown. */
310
+ plan: string;
311
+ }
312
+ /** The answer to a plan: approved, or rejected with what to change; or none. */
313
+ export type AgentPlanOutcome = {
314
+ outcome: "approved";
315
+ } | {
316
+ outcome: "rejected";
317
+ feedback: string | null;
318
+ } | {
319
+ outcome: "cancelled";
320
+ };
321
+ /** An answer to anything the agent asks the person: a permission, questions, a plan. */
322
+ export type AgentAnswer = AcpPermissionOutcome | AgentQuestionOutcome | AgentPlanOutcome;
264
323
  export declare function isAcpRequest(message: AcpMessage): message is AcpRequest;
265
324
  export declare function isAcpNotification(message: AcpMessage): message is AcpNotification;
266
325
  export declare function isAcpResponse(message: AcpMessage): message is AcpResponse;
@@ -283,6 +342,10 @@ export interface AgentCapabilities {
283
342
  steering: "steer" | "interrupt";
284
343
  /** Whether it asks before acting (`session/request_permission`). */
285
344
  approvals: boolean;
345
+ /** Whether it asks the person questions (ASK.question). */
346
+ questions: boolean;
347
+ /** Whether it asks the person to approve its plan before it acts on it (ASK.plan). */
348
+ planApproval: boolean;
286
349
  /** Whether it reports its plan (`plan` updates). */
287
350
  plans: boolean;
288
351
  /** Whether it runs background tasks that outlive a turn. */
@@ -294,7 +357,8 @@ export interface AgentCapabilities {
294
357
  * ACP for one session, both ways: relayed unchanged between the hub and the
295
358
  * session's agent. The gateway answers a request for a session whose agent
296
359
  * does not run with an error, and keeps vendor extensions (methods starting
297
- * with `_`) to its per-agent shims: the hub sees standard ACP.
360
+ * with `_`) to its per-agent shims: the hub sees standard ACP, and the
361
+ * requests the shims make of agents' own (ASK).
298
362
  */
299
363
  export interface AcpFrame {
300
364
  session: string;
@@ -384,9 +448,9 @@ export interface TabCommand {
384
448
  op: TabOp;
385
449
  }
386
450
  /**
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.
451
+ * What a command does. Starting a session, prompting and answering what the
452
+ * agent asks need a creator or owner of the app's space, as publishing does;
453
+ * any member may connect, read their own sessions and cancel.
390
454
  */
391
455
  export type TabOp =
392
456
  /** Start a session about the tab's app, with `prompt` as its first message, if given. */
@@ -409,11 +473,16 @@ export type TabOp =
409
473
  type: "cancel";
410
474
  turn?: number;
411
475
  }
412
- /** Answer a permission request, named by the `seq` of the event that asked. The first answer wins. */
476
+ /**
477
+ * Answer what the agent asks the person (a permission, questions, a plan),
478
+ * named by the `seq` of the event that asked, with the outcome its kind
479
+ * takes. The first answer wins. While the gateway is away the answer waits
480
+ * for it, since the agent waits too.
481
+ */
413
482
  | {
414
- type: "permission";
483
+ type: "answer";
415
484
  request: number;
416
- outcome: AcpPermissionOutcome;
485
+ outcome: AgentAnswer;
417
486
  };
418
487
  /** Why a command was refused: malformed, not allowed, nothing to act on, or too late. */
419
488
  export type AgentErrorCode = "BAD_INPUT" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT";
@@ -456,8 +525,8 @@ export interface SessionInfo {
456
525
  turn: number | null;
457
526
  /** The turns waiting, in the order they will run. */
458
527
  queued: number[];
459
- /** The permission requests waiting for an answer, by the `seq` of the event that asked. */
460
- permissions: number[];
528
+ /** What the agent asks the person and waits for an answer to, by the `seq` of the event that asked. */
529
+ requests: number[];
461
530
  lastSeq: number;
462
531
  }
463
532
  /** Something that happened in a session: stored, numbered and sent to every tab of its app. */
@@ -482,20 +551,34 @@ export type SessionEvent = {
482
551
  turn: number;
483
552
  }
484
553
  /**
485
- * A message from the agent, unchanged: `session/update` notifications and
486
- * `session/request_permission` requests, during `turn` (null between turns).
554
+ * A message from the agent, unchanged: `session/update` notifications, and
555
+ * what it asks the person (`session/request_permission` requests, and ASK's),
556
+ * during `turn` (null between turns).
487
557
  */
488
558
  | {
489
559
  type: "acp";
490
560
  turn: number | null;
491
561
  acp: AcpMessage;
492
562
  }
493
- /** A permission request (the `seq` of its event) was answered, by `by`; null when it was cancelled. */
563
+ /**
564
+ * What the agent asked (the `seq` of its event) was answered, by `by`. The
565
+ * answer reaches the agent at once, or when its gateway is back, unless
566
+ * the request expires first.
567
+ */
568
+ | {
569
+ type: "answered";
570
+ request: number;
571
+ outcome: AgentAnswer;
572
+ by: string;
573
+ }
574
+ /**
575
+ * What the agent asked can no longer be answered: its turn was stopped or
576
+ * ended, or its agent stopped, before an answer reached it. An answer given
577
+ * meanwhile went nowhere.
578
+ */
494
579
  | {
495
- type: "permission_answered";
580
+ type: "expired";
496
581
  request: number;
497
- outcome: AcpPermissionOutcome;
498
- by: string | null;
499
582
  }
500
583
  /** Someone asked to stop the turn; it ends with `turn_ended`. */
501
584
  | {
@@ -535,7 +618,7 @@ export type HubToTab = TabEvent | Ack
535
618
  /**
536
619
  * First on every connection: this app's sessions as they are, whether a
537
620
  * gateway is connected, whether this person may start sessions, prompt
538
- * and answer permission requests here (`canPrompt`), and the latest `seq`
621
+ * and answer what the agent asks here (`canPrompt`), and the latest `seq`
539
622
  * (of any app's). Events after the tab's `since` follow, up to that `seq`,
540
623
  * then live ones. Reconnect with `since` the larger of that `seq` and the
541
624
  * last event's.
package/dist/protocol.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  ACP,
3
3
  AGENT_NAMES,
4
4
  AGENT_PROTOCOL,
5
+ ASK,
5
6
  GATEWAY_CLOSE,
6
7
  GATEWAY_PATH,
7
8
  PING,
@@ -10,11 +11,12 @@ import {
10
11
  isAcpNotification,
11
12
  isAcpRequest,
12
13
  isAcpResponse
13
- } from "./chunks/5YARUI7L.js";
14
+ } from "./chunks/CYVXAHGU.js";
14
15
  export {
15
16
  ACP,
16
17
  AGENT_NAMES,
17
18
  AGENT_PROTOCOL,
19
+ ASK,
18
20
  GATEWAY_CLOSE,
19
21
  GATEWAY_PATH,
20
22
  PING,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The per-agent shims (ADR 0012): what an agent does in words of its own
3
+ * that the protocol has one word for. Each agent's record (agents.ts) names
4
+ * its shims; this is the only code that knows an agent's vendor extensions.
5
+ */
6
+ import { type AgentPlanRequest, type AgentQuestionRequest, ASK } from "./protocol.js";
7
+ /**
8
+ * A vendor request with which an agent asks the person: relayed to the hub
9
+ * as the protocol's request (ASK), under the agent's own id, and the answer,
10
+ * the request's result, given back in the agent's words.
11
+ */
12
+ export interface AskShim {
13
+ method: (typeof ASK)[keyof typeof ASK];
14
+ /** The protocol's request, from the agent's params; throws when they are not the agent's. */
15
+ request(params: unknown): AgentQuestionRequest | AgentPlanRequest;
16
+ /** The agent's result, from the answer and the params it asked with. */
17
+ result(answer: unknown, params: unknown): unknown;
18
+ }
19
+ /** grok-build's requests that ask the person, by method. */
20
+ export declare const GROK_ASKS: Readonly<Record<string, AskShim>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teable/agent-gateway",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
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
5
  "license": "MIT",
6
6
  "repository": {