@camelai/agent-runtime 0.3.0 → 0.5.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.
@@ -1,15 +1,66 @@
1
1
  import type { AgentMessage, ThinkingLevel } from "@earendil-works/pi-agent-core";
2
2
  import type { Api, ImageContent, Model } from "@earendil-works/pi-ai";
3
3
  import { Type, type TSchema, type Static } from "typebox";
4
- import { type Outcome, type RequestMethod, type SessionCredentials, type SessionState } from "../shared/client-protocol.ts";
4
+ import { type RequestMethod, type SessionCredentials, type SessionState } from "../shared/client-protocol.ts";
5
5
  export { Type as schema };
6
6
  export type { SessionCredentials, SessionState };
7
+ /**
8
+ * Who a tool call is for, as the runtime says: from its signed identity token when the tools are
9
+ * served over HTTP (`serveTools`), or from the call itself when they are attached to the agent.
10
+ * Authorize as `user`, within `tenant` and `context`.
11
+ */
12
+ export interface RuntimeIdentity {
13
+ /** Who is acting: the turn's actor (a prompt's `actor`, or its `from.id`), else the agent's subject. */
14
+ user: string;
15
+ /** Whom the agent acts for, as its creator set it (`createAgent({ subject })`); the agent's id if none. */
16
+ subject: string;
17
+ /** Who is acting in this turn, if the prompt named someone. */
18
+ actor?: string;
19
+ /** The runtime tenant that owns the agent. */
20
+ tenant: string;
21
+ agent: string;
22
+ definition?: string;
23
+ /** Claims the agent's creator attached (`createAgent({ context })`), e.g. `{ org, workspace }`. */
24
+ context: Record<string, unknown>;
25
+ /** Where the turn came from, e.g. `{ channel, conversationId, sender }` for a channel message. */
26
+ origin?: Record<string, unknown>;
27
+ /** The call was approved by a person: which input, who (their ids), and when. */
28
+ approval?: {
29
+ input: string;
30
+ by: Record<string, unknown>;
31
+ at: number;
32
+ };
33
+ }
34
+ /** A runtime identity from its claims (a verified token's payload, or an attached call's `_meta`). */
35
+ export declare function identityFromClaims(claims: Record<string, any>): RuntimeIdentity;
7
36
  export interface ToolContext {
8
37
  signal: AbortSignal;
9
38
  callId: string;
10
39
  toolCallId?: string;
11
40
  /** Set by the runtime, e.g. `{ channel, conversationId, sender }` for a turn a channel message started. */
12
41
  origin?: Record<string, unknown>;
42
+ /** Who the call is for: always set by `serveTools`; set for attached tools by runtimes that send it. */
43
+ identity?: RuntimeIdentity;
44
+ /**
45
+ * Ask the user, and get their answer. The call ends here and the agent's turn waits, for days if need
46
+ * be; once they answer, the runtime calls the tool again with the same arguments, and this returns
47
+ * the answer. So everything before an ask runs again on that call: ask first, act after.
48
+ * `confirm`: whether they said yes. `ask`: what they filled in (a flat object schema), or undefined
49
+ * if they declined. `requireUrl`: whether they say they have done what the https page asks.
50
+ */
51
+ confirm(message: string): Promise<boolean>;
52
+ ask<T extends Record<string, unknown> = Record<string, unknown>>(message: string, schema: Record<string, unknown>): Promise<T | undefined>;
53
+ requireUrl(url: string, message: string): Promise<boolean>;
54
+ }
55
+ /** Thrown by a ToolContext's asks: the call answers MCP's `input_required`, and runs again once the user answers. */
56
+ export declare class InputRequired extends Error {
57
+ readonly inputRequests: Record<string, {
58
+ method: string;
59
+ params: Record<string, unknown>;
60
+ }>;
61
+ /** The answers so far, which the runtime hands back on the next call (MCP's `requestState`). */
62
+ readonly requestState?: string;
63
+ constructor(inputRequests: InputRequired["inputRequests"], requestState?: string);
13
64
  }
14
65
  export interface Tool<T = any> {
15
66
  description: string;
@@ -18,12 +69,72 @@ export interface Tool<T = any> {
18
69
  executionMode?: "sequential" | "parallel";
19
70
  input: Record<string, unknown>;
20
71
  execute: (args: T, context: ToolContext) => unknown | Promise<unknown>;
72
+ /**
73
+ * Ask the user to approve each call before it runs (or only the calls this says need it). The runtime
74
+ * shows them the real call; the tool is declared to the model directly, as code cannot wait for a person.
75
+ */
76
+ needsApproval?: boolean | ((args: T, context: ToolContext) => boolean | Promise<boolean>);
21
77
  }
22
78
  /** Infer callback arguments from the schema; no manually duplicated argument type. */
23
79
  export declare function tool<S extends TSchema>(definition: Omit<Tool<Static<S>>, "input"> & {
24
80
  input: S;
25
81
  }): Tool<Static<S>>;
26
82
  export type Tools = Record<string, Tool>;
83
+ /** A tool as an MCP server lists it (`tools/list`). Runtime options ride in `_meta` under "agent-runtime/". */
84
+ export interface McpTool {
85
+ name: string;
86
+ title?: string;
87
+ description?: string;
88
+ inputSchema: Record<string, unknown>;
89
+ annotations?: Record<string, unknown>;
90
+ _meta?: Record<string, unknown>;
91
+ }
92
+ /** An MCP `tools/call` result: complete, or (MCP's multi round-trip requests) asking for input to retry with. */
93
+ export type CallToolResult = {
94
+ content: Array<Record<string, unknown>>;
95
+ structuredContent?: Record<string, unknown>;
96
+ isError?: boolean;
97
+ resultType?: "complete";
98
+ } | {
99
+ resultType: "input_required";
100
+ inputRequests?: Record<string, {
101
+ method: string;
102
+ params?: Record<string, unknown>;
103
+ }>;
104
+ requestState?: string;
105
+ content?: never;
106
+ };
107
+ /**
108
+ * The MCP server an application attaches to its agent: the SDK relays the runtime's
109
+ * `tools/list` and `tools/call` to it over the agent's connection. Throw from `callTool`
110
+ * only when the call could not be answered; a tool's own failure is an `isError` result.
111
+ */
112
+ export interface ToolServer {
113
+ listTools(): McpTool[] | Promise<McpTool[]>;
114
+ callTool(name: string, args: Record<string, unknown>, context: ToolContext): Promise<CallToolResult>;
115
+ }
116
+ /**
117
+ * A call's context from its params: ids, origin, and the identity the runtime sent in `_meta` (or
118
+ * `identity`, from a verified token); its asks answer from the retry's `inputResponses`, by position.
119
+ */
120
+ export declare function toolContext(params: Record<string, any>, fallbackId: string, signal: AbortSignal, identity?: RuntimeIdentity): ToolContext;
121
+ /**
122
+ * Answer one MCP JSON-RPC request as a tool server: initialize, ping, tools/list and tools/call.
123
+ * Both an attached server (answering over the agent's connection) and `serveTools` (over HTTP) use it.
124
+ */
125
+ export declare function answerMcp(message: Record<string, any>, server: ToolServer, context: (params: Record<string, any>) => ToolContext, info?: {
126
+ name: string;
127
+ version: string;
128
+ }): Promise<{
129
+ result: unknown;
130
+ } | {
131
+ error: {
132
+ code: number;
133
+ message: string;
134
+ };
135
+ }>;
136
+ /** `tool({...})` definitions as an attached MCP server: JSON results become a text block (and structured content for objects). */
137
+ export declare function toolServer(tools: Tools): ToolServer;
27
138
  export interface RuntimeOptions {
28
139
  url?: string;
29
140
  apiKey?: string;
@@ -31,18 +142,73 @@ export interface RuntimeOptions {
31
142
  journalStore?: JournalStore;
32
143
  /** Injectable for tests, observability, or an application's HTTP stack. */
33
144
  fetch?: typeof globalThis.fetch;
145
+ /** Opens a local file to attach by its path; set by the Node entry (`@camelai/agent-runtime/node`). */
146
+ openFile?: (path: string) => Promise<Blob>;
147
+ /** How often a request still waiting for its result asks for its status, in case the result's event was lost. Default 30 s. */
148
+ pollMs?: number;
34
149
  }
35
150
  export interface AgentOptions {
36
- tools: Tools;
151
+ /** The application's tools, served to the agent as an attached MCP server. */
152
+ tools?: Tools;
153
+ /** Or an MCP server of the application's own (see `clients/mcp.ts` for MCP SDK servers). */
154
+ mcp?: ToolServer;
37
155
  onEvent?: (event: any, requestId?: string) => unknown | Promise<unknown>;
156
+ /**
157
+ * A question, approval or setup step the agent's turn now waits on. Return an answer to give it
158
+ * at once, or nothing to answer later with `agent.answer` (from any process, via connectAgent).
159
+ */
160
+ onInput?: (input: AgentInput, requestId?: string) => InputAnswer | void | Promise<InputAnswer | void>;
38
161
  onConnection?: (connected: boolean) => void;
39
162
  onError?: (error: Error) => void;
40
163
  }
164
+ /**
165
+ * Human input a suspended turn waits on (its run ends with `stopped: "input_required"` and these in
166
+ * `inputs`): the model's questions (ask_user), approvals, and a tool's form or URL step.
167
+ */
168
+ export interface AgentInput {
169
+ id: string;
170
+ agent: string;
171
+ requestId: string;
172
+ toolCallId: string;
173
+ kind: "question" | "approval" | "form" | "url";
174
+ message: string;
175
+ /** question: { questions }; approval: { tool, source, arguments, argumentsHash }; form: { requestedSchema }; url: { url, origin }. */
176
+ detail: Record<string, any>;
177
+ responders: {
178
+ audience?: string[];
179
+ };
180
+ state: "pending" | "answered" | "declined" | "cancelled" | "expired" | "superseded";
181
+ answer?: {
182
+ action: string;
183
+ content?: unknown;
184
+ by: Record<string, unknown>;
185
+ at: number;
186
+ };
187
+ createdAt: number;
188
+ expiresAt: number;
189
+ }
190
+ /** An answer. `content`: for a question, { answers: { "<question>": "<label>" | ["<label>"] | "<own words>" } }; for a form, its fields. `from`/`actor`: who answers, checked against who may. */
191
+ export interface InputAnswer {
192
+ action: "accept" | "decline" | "cancel";
193
+ content?: unknown;
194
+ from?: Sender;
195
+ actor?: string;
196
+ }
41
197
  export type { ThinkingLevel };
42
198
  export interface CreateAgentOptions extends AgentOptions {
43
199
  idempotencyKey?: string;
200
+ /**
201
+ * Make the agent from a definition (GET /v1/definitions): it supplies the model, system
202
+ * prompt, thinking level and tool sources, so leave those out. `tools` (or `mcp`) are added
203
+ * as the agent's attached server.
204
+ */
205
+ definition?: string;
44
206
  /** Agent lifetime in seconds (60 to 366 days), or null to keep the agent until it is deleted. Default one day. */
45
207
  ttlSeconds?: number | null;
208
+ /** Who the agent acts for (a user id in your app): `sub` in the identity tokens its tool servers get. Set only at creation. */
209
+ subject?: string;
210
+ /** Claims your tool servers need (org, workspace, thread…): `ctx` in its identity tokens. Set only at creation. */
211
+ context?: Record<string, unknown>;
46
212
  systemPrompt?: string;
47
213
  name?: string;
48
214
  type?: string;
@@ -58,6 +224,83 @@ export interface CreateAgentOptions extends AgentOptions {
58
224
  mounts?: Mount[];
59
225
  }
60
226
  /** A volume the agent's file tools see at `path`; `notify` prompts the agent when others change files there. */
227
+ /** How a tool source is authenticated: a stored bearer token, or identity tokens the runtime signs for each request. */
228
+ export type SourceAuth = {
229
+ type: "bearer";
230
+ token: string;
231
+ } | {
232
+ type: "runtime";
233
+ };
234
+ /** Options every tool source takes. `exposure` defaults to both for a source of up to 10 tools, else codemode. */
235
+ interface SourceOptions {
236
+ name: string;
237
+ headers?: Record<string, string>;
238
+ auth?: SourceAuth;
239
+ audience?: string;
240
+ allowTools?: string[];
241
+ denyTools?: string[];
242
+ exposure?: "direct" | "codemode" | "both";
243
+ timeoutMs?: number;
244
+ }
245
+ export interface DefinitionInput {
246
+ name: string;
247
+ model?: string;
248
+ systemPrompt?: string;
249
+ thinkingLevel?: ThinkingLevel;
250
+ limits?: {
251
+ ttlSeconds?: number | null;
252
+ };
253
+ mounts?: unknown[];
254
+ builtins?: ("web_fetch" | "web_search" | "schedule")[];
255
+ /** The search providers web_search tries, in order, instead of the runtime's. */
256
+ webSearch?: {
257
+ providers: ("exa" | "brave" | "parallel")[];
258
+ };
259
+ mcpServers?: (SourceOptions & {
260
+ url: string;
261
+ })[];
262
+ openApi?: (SourceOptions & {
263
+ spec?: string | Record<string, unknown>;
264
+ baseUrl?: string;
265
+ })[];
266
+ }
267
+ /** What applying a definition's revision did to one agent; poll a queued one's request for its outcome. */
268
+ export interface ApplyResult {
269
+ agent: string;
270
+ requestId: string;
271
+ status: "updated" | "queued" | "failed";
272
+ error?: string;
273
+ }
274
+ /** A definition as the runtime returns it: credentials are never included. */
275
+ export interface Definition extends Omit<DefinitionInput, "mcpServers" | "openApi"> {
276
+ id: string;
277
+ revision: number;
278
+ createdAt: number;
279
+ updatedAt: number;
280
+ mcpServers?: Record<string, unknown>[];
281
+ openApi?: Record<string, unknown>[];
282
+ applied?: ApplyResult[];
283
+ }
284
+ /** One source of an agent's tools; `excluded` says why the model does not get a tool, when it does not. */
285
+ export interface ToolSource {
286
+ kind: "channel" | "application" | "files" | "builtin" | "mcp" | "openapi";
287
+ name: string;
288
+ /** unlisted: an MCP server the runtime has not listed yet; error: listing it failed. */
289
+ status: "listed" | "unlisted" | "error";
290
+ error?: string;
291
+ listedAt?: number;
292
+ connected?: boolean;
293
+ url?: string;
294
+ exposure?: "direct" | "codemode" | "both";
295
+ tools: {
296
+ name: string;
297
+ description: string;
298
+ exposure?: "direct" | "codemode" | "both";
299
+ executionMode?: "sequential" | "parallel";
300
+ parameters?: Record<string, unknown>;
301
+ excluded?: string;
302
+ }[];
303
+ }
61
304
  export interface Mount {
62
305
  volumeId: string;
63
306
  path: string;
@@ -84,6 +327,7 @@ export interface VolumeFile {
84
327
  size: number;
85
328
  updatedAt: number;
86
329
  by?: string;
330
+ contentType: string;
87
331
  }
88
332
  export interface VolumeSnapshot {
89
333
  id: string;
@@ -107,9 +351,46 @@ export interface VolumeChanges {
107
351
  }[];
108
352
  gap?: boolean;
109
353
  }
354
+ /** A signed URL for one file: send `method` to `url` with no Authorization header, until `expiresAt`. */
355
+ export interface FileLink {
356
+ url: string;
357
+ method: "GET" | "PUT";
358
+ path: string;
359
+ expiresAt: number;
360
+ maxBytes?: number;
361
+ contentType?: string;
362
+ }
363
+ /** A link's options: `expiresIn` seconds (default 900, at most 86400); for PUT, the largest upload and its content type. */
364
+ export interface LinkOptions {
365
+ method?: "GET" | "PUT";
366
+ expiresIn?: number;
367
+ maxBytes?: number;
368
+ contentType?: string;
369
+ }
110
370
  export interface AgentHistory {
111
371
  messages: AgentMessage[];
112
372
  }
373
+ /**
374
+ * A file to attach to a message: bytes or a Blob (a File keeps its name and type), `{ name, data,
375
+ * contentType? }`, a local path (Node entry), or `{ path }` for a file already in the agent's mounts.
376
+ * The SDK uploads each to the agent's workspace (uploads/<request>/<name>) before sending the message.
377
+ */
378
+ export type Attachment = Uint8Array | Blob | string | {
379
+ name?: string;
380
+ data: Uint8Array | Blob;
381
+ contentType?: string;
382
+ } | {
383
+ path: string;
384
+ };
385
+ /** A file in the agent's mounts, at the path the agent sees it. */
386
+ export interface AgentFile {
387
+ path: string;
388
+ version: number;
389
+ size: number;
390
+ updatedAt: number;
391
+ by?: string;
392
+ contentType: string;
393
+ }
113
394
  export interface Schedule {
114
395
  id: string;
115
396
  agent: string;
@@ -123,9 +404,17 @@ export interface RequestOptions {
123
404
  idempotencyKey?: string;
124
405
  timeoutMs?: number;
125
406
  }
407
+ /** Who sent a message: `id` is yours and the model may rely on it; the names are the sender's own. */
408
+ export interface Sender {
409
+ id: string;
410
+ name?: string;
411
+ username?: string;
412
+ }
126
413
  export declare class AgentError extends Error {
127
414
  status: number;
128
415
  requestId?: string;
416
+ /** Milliseconds the runtime asked to wait before retrying (its Retry-After), for 429 and 503. */
417
+ retryAfterMs?: number;
129
418
  constructor(message: string, status?: number, requestId?: string);
130
419
  }
131
420
  declare class Transport {
@@ -133,12 +422,16 @@ declare class Transport {
133
422
  readonly fetcher: typeof globalThis.fetch;
134
423
  constructor(options: RuntimeOptions);
135
424
  json(path: string, token: string, method?: string, body?: unknown, retry?: boolean, headers?: Record<string, string>): Promise<any>;
136
- /** A request with a raw body or response (volume file contents). */
425
+ /**
426
+ * A request with a raw body or response (file contents). It fails once nothing arrives for 30 s
427
+ * (an upload has the runtime's 15 minutes to be sent), so a stalled transfer never hangs its caller.
428
+ */
137
429
  raw(path: string, token: string, init?: {
138
430
  method?: string;
139
- body?: Uint8Array;
431
+ body?: Uint8Array | Blob;
140
432
  headers?: Record<string, string>;
141
433
  }): Promise<Response>;
434
+ private transfer;
142
435
  }
143
436
  /** Trusted-backend SDK. Only createAgent needs the operator key. */
144
437
  export declare class AgentRuntime {
@@ -154,9 +447,34 @@ export declare class AgentRuntime {
154
447
  listVolumes(): Promise<Volume[]>;
155
448
  /** A handle on one volume's files, snapshots and forks. */
156
449
  volume(id: string): VolumeHandle;
450
+ /**
451
+ * Definitions: reusable agent configurations with their tool sources (MCP servers, OpenAPI
452
+ * specs, built-ins). Make agents from one with `createAgent({ definition: id })`.
453
+ */
454
+ createDefinition(input: DefinitionInput): Promise<Definition>;
455
+ /** Replace the fields given (null removes one); `apply: "all"` also reconfigures its live agents between their turns. */
456
+ updateDefinition(id: string, input: Partial<DefinitionInput> & {
457
+ revision?: number;
458
+ apply?: "all";
459
+ }): Promise<Definition>;
460
+ definition(id: string): Promise<Definition>;
461
+ definitions(): Promise<Definition[]>;
462
+ deleteDefinition(id: string): Promise<{
463
+ deleted: boolean;
464
+ }>;
157
465
  mounts(agentId: string): Promise<Mount[]>;
158
466
  /** Replace an agent's mounts; an idle agent restarts so its tools describe them. */
159
467
  setMounts(agentId: string, mounts: Mount[]): Promise<Mount[]>;
468
+ /**
469
+ * Every source of an agent's tools (its application, file tools, built-ins, MCP servers, OpenAPI
470
+ * specs) and what each offers the model. `schemas` includes input schemas; `refresh` lists MCP servers now.
471
+ */
472
+ /** Inputs waiting on someone across all the tenant's agents (`pending` ones, say), newest first. */
473
+ inbox(state?: AgentInput["state"]): Promise<AgentInput[]>;
474
+ toolSources(agentId: string, options?: {
475
+ schemas?: boolean;
476
+ refresh?: boolean;
477
+ }): Promise<ToolSource[]>;
160
478
  }
161
479
  /** Files are versioned: pass `version` to write or remove only if nobody changed the file since (0: must not exist). */
162
480
  export declare class VolumeHandle {
@@ -188,8 +506,10 @@ export declare class VolumeHandle {
188
506
  files: VolumeFile[];
189
507
  next?: string;
190
508
  }>;
509
+ /** Without `contentType`, the runtime sniffs it from the file's first bytes and name. */
191
510
  write(path: string, data: string | Uint8Array, options?: {
192
511
  version?: number;
512
+ contentType?: string;
193
513
  }): Promise<VolumeFile>;
194
514
  /** A file's bytes, or `range` of them ([start, end) in bytes). */
195
515
  read(path: string, options?: {
@@ -197,19 +517,19 @@ export declare class VolumeHandle {
197
517
  }): Promise<{
198
518
  data: Uint8Array;
199
519
  version: number;
520
+ contentType: string;
200
521
  }>;
201
522
  readText(path: string): Promise<string>;
523
+ /** A signed URL to download (GET) or upload (PUT) one file without a token. */
524
+ link(path: string, options?: LinkOptions): Promise<FileLink>;
202
525
  remove(path: string, options?: {
203
526
  version?: number;
204
527
  }): Promise<any>;
205
528
  }
529
+ /** The client's event cursor, saved so a restarted client resumes where it was. */
206
530
  export type Journal = {
207
531
  version: 1;
208
532
  cursor: number;
209
- calls: Record<string, {
210
- state: "started" | "done";
211
- outcome?: Outcome;
212
- }>;
213
533
  };
214
534
  /** Stores must resolve only once the complete snapshot is committed. Use one active client per agent. */
215
535
  export interface JournalStore {
@@ -217,18 +537,56 @@ export interface JournalStore {
217
537
  save(sessionId: string, journal: Journal): Promise<void>;
218
538
  }
219
539
  export declare function memoryJournalStore(): JournalStore;
540
+ /**
541
+ * The agent's files, at the paths it sees them (`/workspace/report.pdf`), with the agent's own
542
+ * token: what it wrote during a run (a run's outcome lists `files`), and links to hand them on.
543
+ */
544
+ export declare class AgentFiles {
545
+ private readonly transport;
546
+ private readonly token;
547
+ private readonly base;
548
+ constructor(transport: Transport, token: string, base: string);
549
+ /** Files under `path` (default: the first mount), in path order, a page at a time. */
550
+ list(options?: {
551
+ path?: string;
552
+ glob?: string;
553
+ after?: string;
554
+ limit?: number;
555
+ }): Promise<{
556
+ files: AgentFile[];
557
+ next?: string;
558
+ }>;
559
+ download(path: string): Promise<{
560
+ data: Uint8Array;
561
+ contentType: string;
562
+ version: number;
563
+ }>;
564
+ /** Write a file into a writable mount; without `contentType` the runtime sniffs it. */
565
+ upload(path: string, data: Uint8Array | Blob | string, options?: {
566
+ contentType?: string;
567
+ }): Promise<AgentFile>;
568
+ /** A signed URL to download (GET) or upload (PUT) one file without a token, e.g. for a browser or another service. */
569
+ link(path: string, options?: LinkOptions): Promise<FileLink>;
570
+ }
220
571
  export declare class AgentClient {
221
572
  readonly session: SessionCredentials;
222
573
  readonly tools: Tools;
574
+ private server;
223
575
  private readonly transport;
224
576
  private readonly store;
225
577
  private journal;
226
578
  private loaded?;
227
579
  private saving;
228
580
  private readonly options;
581
+ private readonly openFile?;
582
+ private readonly pollMs;
583
+ /** The agent's files: list, download, upload and link. */
584
+ readonly files: AgentFiles;
229
585
  private readonly pending;
586
+ /** Tool calls running, by JSON-RPC id, so the runtime can cancel them. */
230
587
  private readonly active;
231
- private readonly delivered;
588
+ /** The event stream's connection, named in the MCP messages this client sends back. */
589
+ private connection?;
232
590
  private stream?;
233
591
  private loop?;
234
592
  private closed;
@@ -249,31 +607,63 @@ export declare class AgentClient {
249
607
  }): Promise<any>;
250
608
  private receive;
251
609
  private settle;
610
+ /**
611
+ * A request's result arrives as an event; a reconnect also settles from /state. As a last resort,
612
+ * ask for its status now and then, so an event lost on the way can never strand the caller.
613
+ */
614
+ private outcome;
252
615
  private sync;
253
- private dispatch;
254
- private runTool;
616
+ /**
617
+ * Answer the runtime's JSON-RPC messages as the agent's attached MCP server: initialize,
618
+ * ping, tools/list and tools/call, and cancellation. The runtime runs a call once; a call
619
+ * whose answer is lost with the connection ends for the agent as "outcome unknown".
620
+ */
621
+ private mcp;
255
622
  request(method: RequestMethod, params?: Record<string, unknown>, options?: RequestOptions): Promise<any>;
256
623
  /** Observe an already accepted request. This never submits or re-executes work. */
257
624
  waitForRequest(id: string, options?: {
258
625
  timeoutMs?: number;
259
626
  }): Promise<any>;
627
+ /**
628
+ * `from` says who sent the message: the model sees it in a block only the runtime can write, and
629
+ * `from.id` is the turn's actor. `actor` names someone else acting (`act` in identity tokens) without telling the model.
630
+ */
260
631
  prompt(text: string, options?: RequestOptions & {
632
+ files?: Attachment[];
261
633
  images?: ImageContent[];
634
+ actor?: string;
635
+ from?: Sender;
262
636
  }): Promise<any>;
637
+ /**
638
+ * Send a message with its files: each is uploaded to the agent's workspace under the request's
639
+ * id first, then attached by path. `images` (base64 blocks) are sent inline and saved as files.
640
+ */
641
+ private message;
642
+ private attach;
263
643
  history(): Promise<AgentHistory>;
264
- continue(options?: RequestOptions): Promise<any>;
265
- steer(text: string): Promise<any>;
266
- followUp(text: string): Promise<any>;
644
+ continue(options?: RequestOptions & {
645
+ actor?: string;
646
+ }): Promise<any>;
647
+ steer(text: string, options?: {
648
+ from?: Sender;
649
+ files?: Attachment[];
650
+ }): Promise<any>;
651
+ followUp(text: string, options?: {
652
+ from?: Sender;
653
+ files?: Attachment[];
654
+ }): Promise<any>;
267
655
  /** Change the prompt, thinking level, tools, or model ("provider/model-id") between runs. */
268
656
  configure(options: {
269
657
  systemPrompt?: string;
270
658
  thinkingLevel?: ThinkingLevel;
271
659
  tools?: Tools;
660
+ mcp?: ToolServer;
272
661
  model?: string;
273
662
  }): Promise<any>;
274
663
  execute(code: string, options?: RequestOptions & {
275
664
  timeoutMs?: number;
276
665
  executionTimeoutMs?: number;
666
+ actor?: string;
277
667
  }): Promise<any>;
278
668
  /**
279
669
  * Wake this agent later: with `text` it gets a prompt, with `code` it runs sandboxed
@@ -291,6 +681,13 @@ export declare class AgentClient {
291
681
  status(): Promise<any>;
292
682
  abort(): Promise<any>;
293
683
  requestStatus(id: string): Promise<any>;
684
+ /** Answer an input the agent waits on. `request` is the run resuming its turn, once its last input is answered. */
685
+ answer(inputId: string, answer: InputAnswer): Promise<{
686
+ input: AgentInput;
687
+ request: any | null;
688
+ }>;
689
+ /** The agent's inputs, newest first: `pending` ones, say. */
690
+ inputs(state?: AgentInput["state"]): Promise<AgentInput[]>;
294
691
  outcomes(): Promise<SessionState>;
295
692
  close(): Promise<void>;
296
693
  destroy(): Promise<void>;