@mitralab.io/sdk-core 0.3.0-beta.2 → 0.3.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/dist/index.d.ts CHANGED
@@ -529,6 +529,16 @@ interface PageOptions {
529
529
  /** Spring sort expression, for example `createdAt,desc`. */
530
530
  sort?: string;
531
531
  }
532
+ interface AgentMessageListOptions extends PageOptions {
533
+ /**
534
+ * `all` asks for every row the Copilot recorded from the box, one per piece: also `REASONING`,
535
+ * `SUBAGENT_TEXT`, `APPROVAL`, `USER_INPUT_REQUEST` and a subagent's tools. Without it the Copilot answers only `TEXT`, `ERROR`
536
+ * and `TOOL_USE` rows of the chat itself, as before.
537
+ */
538
+ kinds?: "all";
539
+ /** Id of a message: only the rows recorded before it, so the next page back holds still. */
540
+ before?: string;
541
+ }
532
542
  type AppColor = {
533
543
  type: "SOLID";
534
544
  hex: string;
@@ -1090,10 +1100,17 @@ type AgentTaskInput = {
1090
1100
  agentType?: string;
1091
1101
  reasoningEffort?: string;
1092
1102
  /**
1093
- * `steer` takes the message into the running turn; a box given none puts it in T3's queue.
1094
- * The session always sends `steer`. The Copilot does not take the field.
1103
+ * With a turn running, as T3's composer: `queue` puts the message in T3's queue behind it and
1104
+ * `steer` takes it into the running turn. A box given none lets T3 decide. The Copilot does
1105
+ * not take the field.
1106
+ */
1107
+ mode?: "queue" | "steer";
1108
+ /**
1109
+ * The id the box echoes on the frames that take the message (`stepStart`, `steer`,
1110
+ * `messageQueued`) and the history item of the question carries. The session sends the one
1111
+ * `send` returned, to the box and to the Copilot, which keeps it and hands it to the box.
1095
1112
  */
1096
- mode?: "steer";
1113
+ clientMessageId?: string;
1097
1114
  } | {
1098
1115
  type: "interrupt";
1099
1116
  } | {
@@ -1114,6 +1131,26 @@ type AgentTaskInput = {
1114
1131
  | {
1115
1132
  type: "subagent.stop";
1116
1133
  subagentId: string;
1134
+ }
1135
+ /** Takes a message out of T3's queue, named by its `clientMessageId`; only the box takes it. */
1136
+ | {
1137
+ type: "queued-run.cancel";
1138
+ clientMessageId: string;
1139
+ }
1140
+ /** Changes the text of a message in T3's queue; only the box channel takes it. */
1141
+ | {
1142
+ type: "queued-run.edit";
1143
+ clientMessageId: string;
1144
+ text: string;
1145
+ }
1146
+ /** Moves a message from T3's queue into the running turn, as T3's own Steer on a queued message. */
1147
+ | {
1148
+ type: "queued-message.promote-to-steer";
1149
+ clientMessageId: string;
1150
+ }
1151
+ /** Lets T3's queue go on after a Stop held it, as T3's own `queue.resume`. */
1152
+ | {
1153
+ type: "queue.resume";
1117
1154
  };
1118
1155
  interface AgentTaskEvent {
1119
1156
  /** Event names are open and can grow without a client release. */
@@ -1129,6 +1166,11 @@ interface AgentTaskChannel {
1129
1166
  wsUrl: string;
1130
1167
  /** Last sequence in the box log, 0 when the box reported none. */
1131
1168
  lastSequence: number;
1169
+ /**
1170
+ * Which box log the chat is on now, counted by the Copilot: a box that comes up without the
1171
+ * log starts a new one. The `boxLog` of the history items. Absent from an older Copilot.
1172
+ */
1173
+ boxLog?: number;
1132
1174
  }
1133
1175
  /** One call to the provider inside a turn, or one model's total when the source gives only that. */
1134
1176
  interface AgentTurnUsageRequest {
@@ -1188,11 +1230,49 @@ interface AgentTurnUsage {
1188
1230
  interface AgentMessage {
1189
1231
  id: string;
1190
1232
  sender: string;
1233
+ /**
1234
+ * `TEXT`, `ERROR`, `TOOL_USE`; asked with `kinds: "all"`, also `REASONING`, `SUBAGENT_TEXT`,
1235
+ * `APPROVAL` and `USER_INPUT_REQUEST`.
1236
+ */
1191
1237
  type: string;
1192
1238
  content: string;
1193
1239
  createdAt: string;
1194
1240
  /** Present on the Agent message that closed a turn, when the Copilot recorded its usage. */
1195
1241
  usage?: AgentTurnUsage;
1242
+ /**
1243
+ * The box log's sequence of the row's first chunk, the same as its live event; absent on older
1244
+ * rows.
1245
+ */
1246
+ sequence?: number;
1247
+ /** The box log's sequence of the row's last chunk, only when the row came in more than one. */
1248
+ lastSequence?: number;
1249
+ /** Which box log `sequence` counts in; absent on older rows. */
1250
+ boxLog?: number;
1251
+ /** T3's id of the item the row holds. */
1252
+ itemId?: string;
1253
+ /** On a subagent's own reasoning, text or tool: the tool call that spawned the subagent. */
1254
+ parentToolId?: string;
1255
+ /** On the person's message: the `clientMessageId` it went out with. */
1256
+ clientMessageId?: string;
1257
+ /** On a tool call that spawned a subagent: its last state, as the box sent it. */
1258
+ subagent?: Partial<AgentSubagentFrame>;
1259
+ /** On the row that closed a turn: the reason the box ended it with. */
1260
+ reason?: string;
1261
+ }
1262
+ /**
1263
+ * A subagent's state as the box sends it in a `subagentUpdate` frame. The Copilot keeps the last
1264
+ * one on the rows of the tool call that spawned the subagent.
1265
+ */
1266
+ interface AgentSubagentFrame {
1267
+ /** The tool call that spawned the subagent. */
1268
+ toolId: string;
1269
+ subagentId: string;
1270
+ status: string;
1271
+ progress?: string;
1272
+ /** As the box sent it: epoch milliseconds or an ISO string. */
1273
+ startedAt?: number | string;
1274
+ endedAt?: number | string;
1275
+ childThreadId?: string;
1196
1276
  }
1197
1277
  interface AgentModel {
1198
1278
  model: string;
@@ -1203,6 +1283,22 @@ interface AgentModel {
1203
1283
  /** Name the person chose for a custom provider; null on built-in models. Absent on an older Copilot. */
1204
1284
  providerName?: string | null;
1205
1285
  }
1286
+ /**
1287
+ * A provider the next turn can run on, with the models the catalog offers on it and the last
1288
+ * subscription reading of the person's login.
1289
+ */
1290
+ interface AgentReadyProvider {
1291
+ provider: CopilotProvider;
1292
+ /** Name the person chose for a custom provider; null on a built-in one. */
1293
+ providerName: string | null;
1294
+ /** The catalog's models of this provider, in the catalog's order. */
1295
+ models: AgentModel[];
1296
+ /**
1297
+ * The same reading `usage(provider)` answers; null on an API key, before a turn reported a
1298
+ * window, on a custom provider, which has no subscription, and when the Copilot could not read it.
1299
+ */
1300
+ usage: CredentialUsage | null;
1301
+ }
1206
1302
  interface CredentialStatus {
1207
1303
  provider: CopilotProvider;
1208
1304
  connected: boolean;
@@ -1323,6 +1419,108 @@ interface SendEmailInput {
1323
1419
  /** Plain-text alternative for clients that do not render HTML. */
1324
1420
  text?: string;
1325
1421
  }
1422
+ /**
1423
+ * The account emails an app may rewrite with its own token. Messenger sends them from the app's
1424
+ * sender settings or the brand, so a template never picks its sender.
1425
+ */
1426
+ type EmailTemplateType = "SIGN_IN" | "SSO_GUIDANCE" | "APP_USER_INVITED" | "APP_ACCESS_REQUIRED";
1427
+ interface EmailTemplate {
1428
+ id: string;
1429
+ /**
1430
+ * An `EmailTemplateType` with an app token. Kept as a string because a console token also
1431
+ * lists the platform's other types, and a type Messenger opens later must not break the list.
1432
+ */
1433
+ type: string;
1434
+ /** Always null for these types: their sender comes from the app settings or the brand. */
1435
+ senderIdentityId: string | null;
1436
+ subject: string;
1437
+ htmlBody: string;
1438
+ textBody: string | null;
1439
+ /** True on a platform row. The list returns it next to the app's own row when the app rewrote the type. */
1440
+ platformDefault: boolean;
1441
+ createdAt: string;
1442
+ updatedAt: string;
1443
+ }
1444
+ interface EmailTemplateVariable {
1445
+ /** Referenced in a template as `$name`. */
1446
+ name: string;
1447
+ /** A required variable must appear in the subject or the HTML body. */
1448
+ required: boolean;
1449
+ description: string | null;
1450
+ /** Sample value used to render the preview. */
1451
+ preview: string | null;
1452
+ }
1453
+ interface EmailTemplateTypeCatalog {
1454
+ type: string;
1455
+ variables: EmailTemplateVariable[];
1456
+ }
1457
+ /** Replaces the app's version of the template as a whole. */
1458
+ interface EmailTemplateInput {
1459
+ subject: string;
1460
+ htmlBody: string;
1461
+ /** Left out, the plain-text version saved before is cleared. */
1462
+ textBody?: string;
1463
+ }
1464
+ /** The template rendered with the preview values of its variables. */
1465
+ interface EmailTemplatePreview {
1466
+ subject: string;
1467
+ htmlBody: string;
1468
+ textBody: string | null;
1469
+ }
1470
+ interface EmailTemplateUpsertResult {
1471
+ template: EmailTemplate;
1472
+ /** Null when only the preview failed; the template is saved all the same. */
1473
+ preview: EmailTemplatePreview | null;
1474
+ /** The transport or response error of the preview, unchanged, when `preview` is null. */
1475
+ previewError?: unknown;
1476
+ }
1477
+ /** An address of a person, available as a sender in the app's workspace. */
1478
+ interface EmailSender {
1479
+ id: string;
1480
+ email: string;
1481
+ displayName: string;
1482
+ /**
1483
+ * `PENDING`, `VERIFIED` or `FAILED`. Kept as a string so a status Messenger adds later does not
1484
+ * break the list. Only a `VERIFIED` address signs the app's emails.
1485
+ */
1486
+ status: string;
1487
+ sharedWithCurrentWorkspace: boolean;
1488
+ /** True until the person confirms the 6-digit code Messenger sent to the address. */
1489
+ ownerConfirmationPending: boolean;
1490
+ createdAt: string;
1491
+ updatedAt: string;
1492
+ }
1493
+ interface EmailSenderInput {
1494
+ email: string;
1495
+ /** Name of the address; the app settings may override it in the From header. */
1496
+ displayName: string;
1497
+ }
1498
+ /** The From the app's emails use now, which falls back to the brand while the app sender cannot sign. */
1499
+ interface EffectiveEmailSender {
1500
+ email: string;
1501
+ displayName: string | null;
1502
+ /** `APP_SENDER` or `BRAND_DEFAULT`, as a string for the same reason as `EmailSender.status`. */
1503
+ source: string;
1504
+ /** Why the brand signs: `NO_SETTINGS`, `IDENTITY_NOT_VERIFIED` or `IDENTITY_NOT_SHARED`. */
1505
+ reason: string | null;
1506
+ }
1507
+ interface EmailSettings {
1508
+ appId: string;
1509
+ senderIdentityId: string | null;
1510
+ displayName: string | null;
1511
+ replyTo: string | null;
1512
+ effectiveSender: EffectiveEmailSender;
1513
+ /** True when the app's own templates go out even while the brand signs. */
1514
+ ownTemplateSendsFromBrand: boolean;
1515
+ }
1516
+ /** Replaces the app's settings as a whole: a field left out or null is cleared. */
1517
+ interface EmailSettingsInput {
1518
+ /** An `EmailSender.id` from `listEmailSenders`; without it the app sends from the brand. */
1519
+ senderIdentityId?: string | null;
1520
+ /** Single line, shown in the From header. */
1521
+ displayName?: string | null;
1522
+ replyTo?: string | null;
1523
+ }
1326
1524
  interface AppContext {
1327
1525
  appId: string;
1328
1526
  app: AppDefinition;
@@ -1383,6 +1581,14 @@ interface AgentCredentialsModule {
1383
1581
  list(options?: AgentCredentialOptions): Promise<CredentialStatus[]>;
1384
1582
  /** Lists models backed by a usable credential, optionally through a business agent connection. */
1385
1583
  listModels(agentId?: string, options?: AgentCredentialOptions): Promise<AgentModel[]>;
1584
+ /**
1585
+ * The providers the next turn can run on, as the Copilot assembles them in one call: one entry
1586
+ * per built-in provider and per custom provider of `listModels(agentId)`, in the catalog's order,
1587
+ * each with its models and, for the built-in ones, the reading `usage(provider)` answers. A
1588
+ * reading the Copilot cannot get comes as null. With an `agentId` the models are the agent
1589
+ * connection's, and the reading is still the person's own login.
1590
+ */
1591
+ providers(agentId?: string, options?: AgentCredentialOptions): Promise<AgentReadyProvider[]>;
1386
1592
  /**
1387
1593
  * The last subscription window a chat on this credential reported, readable with no chat open.
1388
1594
  * Resolves to null until a turn on the provider's subscription login has reported one; an API
@@ -1452,7 +1658,7 @@ interface AgentTasksModule {
1452
1658
  */
1453
1659
  sendInput(id: string, input: AgentTaskInput): Promise<void>;
1454
1660
  /** Lists persisted messages. Defaults: page 0, size 50, sort createdAt. */
1455
- listMessages(id: string, options?: PageOptions): Promise<Page<AgentMessage>>;
1661
+ listMessages(id: string, options?: AgentMessageListOptions): Promise<Page<AgentMessage>>;
1456
1662
  /**
1457
1663
  * Asks the Copilot where the chat is served. It holds the request while the box boots and
1458
1664
  * answers with the box socket, or null (202) when it offers none. Optional so hand-written
@@ -1815,8 +2021,48 @@ interface MessengerModule {
1815
2021
  notify(content: string): Promise<MessageAccepted>;
1816
2022
  /** Sends an email from the app's sender; only the app's backend token may send. */
1817
2023
  sendEmail(input: SendEmailInput): Promise<MessageAccepted>;
1818
- }
1819
- declare function createMessengerModule(transport: Transport, errors?: SdkCoreErrorFactory): MessengerModule;
2024
+ /**
2025
+ * Lists the current app's email templates: the platform row (`platformDefault: true`) of every
2026
+ * type and, beside it, the app's row for each type the app has rewritten.
2027
+ */
2028
+ listEmailTemplates(): Promise<EmailTemplate[]>;
2029
+ /** Gets the variables a type accepts, referenced as `$name` in the subject and HTML body. */
2030
+ getEmailTemplateType(type: EmailTemplateType): Promise<EmailTemplateTypeCatalog>;
2031
+ /** Gets the current app's version of a template, or the platform text when it has none. */
2032
+ getEmailTemplate(type: EmailTemplateType): Promise<EmailTemplate>;
2033
+ /**
2034
+ * Replaces the current app's version of a template and renders its preview. Every required
2035
+ * variable must appear in the subject or the HTML body.
2036
+ */
2037
+ upsertEmailTemplate(type: EmailTemplateType, input: EmailTemplateInput): Promise<EmailTemplateUpsertResult>;
2038
+ /**
2039
+ * Renders the app's saved template, or the platform one, with the catalog's sample values. It
2040
+ * does not prove which HTML goes out: the sender and the brand policy decide that at send time.
2041
+ */
2042
+ previewEmailTemplate(type: EmailTemplateType): Promise<EmailTemplatePreview>;
2043
+ /** Deletes the current app's version of a template, so the platform text applies again. */
2044
+ deleteEmailTemplate(type: EmailTemplateType): Promise<void>;
2045
+ /** Lists the addresses available as senders in the workspace of the token. */
2046
+ listEmailSenders(): Promise<EmailSender[]>;
2047
+ /**
2048
+ * Registers an address in the name of the person in the token and makes it available in the
2049
+ * app's workspace. An address the person already owns comes back as saved, made available too.
2050
+ * Messenger mails a verification link and a 6-digit code to the address.
2051
+ */
2052
+ registerEmailSender(input: EmailSenderInput): Promise<EmailSender>;
2053
+ /**
2054
+ * Mails the AWS link again while AWS has not verified the address, and a new code only while
2055
+ * the person has not confirmed one yet.
2056
+ */
2057
+ resendEmailSenderVerification(senderId: string): Promise<EmailSender>;
2058
+ /** Confirms the 6-digit code the person read in the mailbox of the address. */
2059
+ confirmEmailSender(senderId: string, code: string): Promise<EmailSender>;
2060
+ /** Gets the current app's sender settings and the From its emails use now. */
2061
+ getEmailSettings(): Promise<EmailSettings>;
2062
+ /** Replaces the current app's sender settings; a field left out is cleared. */
2063
+ updateEmailSettings(input: EmailSettingsInput): Promise<EmailSettings>;
2064
+ }
2065
+ declare function createMessengerModule(transport: Transport, errors?: SdkCoreErrorFactory, getAppId?: () => string | undefined): MessengerModule;
1820
2066
 
1821
2067
  interface PublicFunctionsModule {
1822
2068
  /**
@@ -1888,7 +2134,7 @@ interface SdkCoreTransports {
1888
2134
  codeStudio?: Transport;
1889
2135
  /** Copilot transport for tasks, credentials, models, and app connections. */
1890
2136
  copilot?: Transport;
1891
- /** Messenger transport for current-user notifications. */
2137
+ /** Messenger transport for current-user notifications, app emails, and their templates. */
1892
2138
  messenger?: Transport;
1893
2139
  /**
1894
2140
  * Anonymous Functions transport. It must not add Authorization or X-App-Id headers.
@@ -2005,7 +2251,16 @@ interface AgentTaskEventConnection {
2005
2251
  * its box offers no direct channel. The direct channel itself is Core's.
2006
2252
  */
2007
2253
  interface AgentTaskEventSource {
2008
- open(taskId: string, observer: AgentTaskEventObserver, signal?: AbortSignal, transport?: AgentSessionTransport): Promise<AgentTaskEventConnection>;
2254
+ open(taskId: string, observer: AgentTaskEventObserver, signal?: AbortSignal, transport?: AgentSessionTransport, historyCursor?: AgentHistoryCursor): Promise<AgentTaskEventConnection>;
2255
+ }
2256
+ /**
2257
+ * How far the history the session loaded goes in the box log: the highest `sequence` of the
2258
+ * newest box log it holds. A chat opened with it gets the box's replay from there, so what the
2259
+ * history has not recorded yet still reaches the session.
2260
+ */
2261
+ interface AgentHistoryCursor {
2262
+ sequence: number;
2263
+ boxLog?: number;
2009
2264
  }
2010
2265
  type AgentSessionTransport = "auto" | "websocket" | "http";
2011
2266
  interface NewAgentTaskSessionOptions {
@@ -2034,17 +2289,46 @@ type AgentTaskSessionOptions = NewAgentTaskSessionOptions | ExistingAgentTaskSes
2034
2289
  interface AgentSendOptions {
2035
2290
  agentType?: string;
2036
2291
  reasoningEffort?: string;
2292
+ /**
2293
+ * With a turn running: with none, T3 decides as its composer does (into the running turn when the
2294
+ * provider takes a steer, in its queue otherwise); `steer` asks for the running turn, which T3
2295
+ * refuses while the turn is not running yet; `queue` waits in T3's queue, held by a Stop until
2296
+ * `resumeQueue`. With no turn running the message starts one.
2297
+ */
2298
+ mode?: "queue" | "steer";
2037
2299
  }
2038
2300
  interface AgentSendAndWaitOptions extends AgentSendOptions {
2039
2301
  signal?: AbortSignal;
2040
2302
  timeoutMs?: number;
2041
2303
  }
2042
2304
  type AgentTaskSessionStatus = "opening" | "idle" | "streaming" | "cancelled" | "error" | "closed";
2043
- /** @deprecated Messages are no longer held by the session; the queue is always empty. */
2305
+ /**
2306
+ * A message in T3's queue of the chat, as the box reports it: not taken into a turn yet. Any
2307
+ * client's message, not only this session's.
2308
+ */
2309
+ /** One piece of work the provider keeps going in the background, as T3's roster names it. */
2310
+ interface AgentBackgroundTask {
2311
+ taskId: string;
2312
+ /** `command`, `monitor`, `subagent` or `background_task`, as T3 names it. */
2313
+ kind: string;
2314
+ description?: string;
2315
+ /** The subagent's own thread, when it has one. */
2316
+ childThreadId?: string;
2317
+ }
2044
2318
  interface AgentQueueItem extends AgentSendOptions {
2319
+ /** The `clientMessageId` the message went out with: what `send` returned for it. */
2045
2320
  id: string;
2046
2321
  text: string;
2322
+ /** Epoch milliseconds of the box frame that first reported it in the queue. */
2047
2323
  createdAt: number;
2324
+ /** Its place in T3's queue, as the box sent it. */
2325
+ position?: number;
2326
+ /** T3 holds the queue: nothing in it runs until the hold is lifted. */
2327
+ queueHeld?: boolean;
2328
+ /** The `sequence` of the last box frame that reported it. */
2329
+ sequence?: number;
2330
+ /** The message's own turn id: the `id` of its history item. */
2331
+ turnId?: string;
2048
2332
  }
2049
2333
  /** T3's subagent statuses; a status this version does not know comes through as it was sent. */
2050
2334
  type AgentSubagentStatus = "idle" | "pending" | "running" | "waiting" | "completed" | "failed" | "cancelled" | "interrupted";
@@ -2062,7 +2346,19 @@ interface AgentSubagent {
2062
2346
  /** T3's thread for the subagent's own conversation, when the provider exposes one. */
2063
2347
  childThreadId?: string;
2064
2348
  }
2065
- interface AgentToolEvent {
2349
+ /**
2350
+ * Where a piece of the conversation goes, as the box sent it on the frame: the same `sequence` and
2351
+ * `itemId` the history item of that piece carries. Absent when the frame did not carry it.
2352
+ */
2353
+ interface AgentPieceIdentity {
2354
+ /** The box log's sequence of the frame: the order of the conversation. */
2355
+ sequence?: number;
2356
+ /** T3's id of the item the frame belongs to (one stretch of text, one tool, one subagent). */
2357
+ itemId?: string;
2358
+ /** The `lifecycle.turnId` of the frame. */
2359
+ turnId?: string;
2360
+ }
2361
+ interface AgentToolEvent extends AgentPieceIdentity {
2066
2362
  tool: string;
2067
2363
  toolId?: string;
2068
2364
  /** On a tool a subagent called: the `toolId` of the tool call that spawned the subagent. */
@@ -2072,25 +2368,76 @@ interface AgentToolEvent {
2072
2368
  content?: unknown;
2073
2369
  timestamp?: number;
2074
2370
  }
2075
- type AgentTimelineItem = {
2371
+ /**
2372
+ * What the Copilot recorded from the box for a history item, read as it came. Absent on items
2373
+ * written before the Copilot recorded them, or from a box that did not send them.
2374
+ */
2375
+ interface AgentTimelineItemIdentity {
2376
+ /** The box log's sequence of the item: the same number its live frame carried. */
2377
+ sequence?: number;
2378
+ /** The box log's sequence of the item's last chunk, only when it came in more than one. */
2379
+ lastSequence?: number;
2380
+ /** Which box log the sequence counts in: a box that came up without the log starts again. */
2381
+ boxLog?: number;
2382
+ /** T3's id of the item: the `itemId` of its live frames. */
2383
+ itemId?: string;
2384
+ /** Only on the item that closed a turn: the reason the box ended it with. */
2385
+ reason?: string;
2386
+ }
2387
+ type AgentTimelineItem = ({
2076
2388
  id: string;
2077
2389
  kind: "user" | "agent";
2078
2390
  text: string;
2079
2391
  at: string;
2080
2392
  /** Only on the `agent` item that closed a turn, when the Copilot recorded its usage. */
2081
2393
  usage?: AgentTurnUsage;
2082
- } | {
2394
+ /** On a `user` item: the id `send` returned for that message. */
2395
+ clientMessageId?: string;
2396
+ /** On a subagent's own text (a `SUBAGENT_TEXT` row): the tool call that spawned it. */
2397
+ parentToolId?: string;
2398
+ } & AgentTimelineItemIdentity) | ({
2399
+ id: string;
2400
+ /** A stretch of the agent's reasoning, as the box sent it: the `thinking` pieces of one item. */
2401
+ kind: "reasoning";
2402
+ text: string;
2403
+ at: string;
2404
+ /** On a subagent's own reasoning: the tool call that spawned the subagent. */
2405
+ parentToolId?: string;
2406
+ } & AgentTimelineItemIdentity) | ({
2407
+ id: string;
2408
+ /**
2409
+ * An approval T3 asked for (`APPROVAL` row) or a question it asked the person mid-turn
2410
+ * (`USER_INPUT_REQUEST` row): the payload of the box's `approval` or `user_input_request`
2411
+ * frame, as it came, the same that reached the session live as a `raw` event.
2412
+ */
2413
+ kind: "approval";
2414
+ payload: Record<string, unknown>;
2415
+ at: string;
2416
+ parentToolId?: string;
2417
+ } & AgentTimelineItemIdentity) | ({
2418
+ id: string;
2419
+ kind: "userInputRequest";
2420
+ payload: Record<string, unknown>;
2421
+ at: string;
2422
+ parentToolId?: string;
2423
+ } & AgentTimelineItemIdentity) | ({
2083
2424
  id: string;
2084
2425
  kind: "tool";
2085
2426
  tool: AgentToolEvent;
2086
2427
  at: string;
2087
- };
2428
+ /** On the tool call that spawned a subagent: its last state, as the box's `subagentUpdate`. */
2429
+ subagent?: Partial<AgentSubagentFrame>;
2430
+ } & AgentTimelineItemIdentity);
2088
2431
  interface AgentTurnResult {
2089
2432
  task: AgentTask;
2090
2433
  content: string;
2091
2434
  reason: string;
2092
2435
  /** What the turn consumed, from the box's `stepFinish`; absent when the turn reported none. */
2093
2436
  usage?: AgentTurnUsage;
2437
+ /** The `sequence` of the box's `stepFinish` that ended the turn, when it carried one. */
2438
+ sequence?: number;
2439
+ /** The `lifecycle.turnId` of that `stepFinish`. */
2440
+ turnId?: string;
2094
2441
  }
2095
2442
  interface AgentTaskSessionEventMap {
2096
2443
  statusChange: {
@@ -2102,15 +2449,31 @@ interface AgentTaskSessionEventMap {
2102
2449
  taskCreated: {
2103
2450
  task: AgentTask;
2104
2451
  };
2105
- turnStart: Record<string, never>;
2452
+ /**
2453
+ * A turn started. When the box's `stepStart` opened it, the fields it carried: the `text` and
2454
+ * `clientMessageId` of the message whose turn it is, and the frame's `sequence`, `itemId` and
2455
+ * `turnId`. The place to show that question, also when the history does not have it yet.
2456
+ */
2457
+ turnStart: {
2458
+ text?: string;
2459
+ clientMessageId?: string;
2460
+ } & AgentPieceIdentity;
2461
+ /**
2462
+ * On a subagent's own text, `parentToolId` is the tool call that spawned it. `itemDelta` is the
2463
+ * box frame's piece of its item: the same as `delta` except on the first piece of a text item
2464
+ * that follows another, where `delta` starts with the `"\n\n"` that 0.2.13 joined them with.
2465
+ */
2106
2466
  delta: {
2107
2467
  delta: string;
2108
2468
  kind: "text" | "thinking";
2109
- };
2469
+ parentToolId?: string;
2470
+ itemDelta?: string;
2471
+ } & AgentPieceIdentity;
2110
2472
  tool: AgentToolEvent;
2111
2473
  workspace: {
2112
2474
  payload: unknown;
2113
2475
  timestamp: number;
2476
+ sequence?: number;
2114
2477
  };
2115
2478
  turnEnd: AgentTurnResult;
2116
2479
  /**
@@ -2120,10 +2483,14 @@ interface AgentTaskSessionEventMap {
2120
2483
  */
2121
2484
  accepted: Record<string, never>;
2122
2485
  cancelled: Record<string, never>;
2123
- /** @deprecated Never emitted: every message is sent at once, so there is no queue to change. */
2486
+ /** T3's queue of the chat changed: a message entered it, moved, or left it. */
2124
2487
  queueChange: {
2125
2488
  queue: readonly AgentQueueItem[];
2126
2489
  };
2490
+ /** The provider's background work changed: the roster as T3 shows it waiting. */
2491
+ backgroundTasks: {
2492
+ tasks: readonly AgentBackgroundTask[];
2493
+ };
2127
2494
  /**
2128
2495
  * The box took a message into the running turn at this point, with no turn of its own: the
2129
2496
  * place the app shows it in that turn. The turn's `turnEnd` answers it.
@@ -2131,25 +2498,34 @@ interface AgentTaskSessionEventMap {
2131
2498
  steered: {
2132
2499
  text: string;
2133
2500
  messageId: string;
2501
+ /** The steered message's own turn id: the `id` of its history item. */
2502
+ turnId?: string;
2503
+ sequence?: number;
2504
+ /** The id `send` returned for that message. */
2505
+ clientMessageId?: string;
2134
2506
  };
2135
2507
  /** A subagent's status, progress or child thread changed. */
2136
- subagent: AgentSubagent;
2508
+ subagent: AgentSubagent & {
2509
+ sequence?: number;
2510
+ };
2137
2511
  /**
2138
- * Text of a subagent's own thread. It never reaches `delta` or `content`: the chat's answer
2139
- * stays the parent's.
2512
+ * Text of a subagent's own thread. It also reaches `delta` and `content`, as in 0.2.13; this
2513
+ * event tells it apart from the parent's.
2140
2514
  */
2141
2515
  subagentDelta: {
2142
2516
  parentToolId: string;
2143
2517
  delta: string;
2144
2518
  kind: "text" | "thinking";
2145
- };
2146
- /** A tool a subagent called, in its own thread. */
2519
+ itemDelta?: string;
2520
+ } & AgentPieceIdentity;
2521
+ /** A tool a subagent called, in its own thread. It also comes as `tool`, as in 0.2.13. */
2147
2522
  subagentTool: AgentToolEvent & {
2148
2523
  parentToolId: string;
2149
2524
  };
2150
2525
  error: {
2151
2526
  code?: string;
2152
2527
  error: string;
2528
+ sequence?: number;
2153
2529
  };
2154
2530
  /**
2155
2531
  * The subscription window the chat's harness reported during a turn. It comes only on the
@@ -2169,11 +2545,19 @@ interface AgentTaskSession {
2169
2545
  readonly status: AgentTaskSessionStatus;
2170
2546
  readonly history: readonly AgentTimelineItem[];
2171
2547
  readonly content: string;
2172
- /** @deprecated Always empty: a message sent while a turn runs goes to the box at once. */
2548
+ /**
2549
+ * T3's queue of the chat as the box reports it, in the order it reported the messages. A
2550
+ * message leaves when it is taken into a turn, or when it ends before running.
2551
+ */
2173
2552
  readonly queue: readonly AgentQueueItem[];
2174
2553
  /** Every subagent the box reported on this session, in the order first seen. */
2175
2554
  readonly subagents: readonly AgentSubagent[];
2176
- send(prompt: string, options?: AgentSendOptions): void;
2555
+ /**
2556
+ * Sends the message at once and returns the id it goes out with: the `clientMessageId` the box
2557
+ * echoes when it takes the message (in `steered`, in `queue` and in the history item of the
2558
+ * question). Undefined for a blank prompt, which is not sent.
2559
+ */
2560
+ send(prompt: string, options?: AgentSendOptions): string | undefined;
2177
2561
  sendAndWait(prompt: string, options?: AgentSendAndWaitOptions): Promise<AgentTurnResult>;
2178
2562
  cancel(): Promise<void>;
2179
2563
  respondApproval(approved: boolean): void;
@@ -2182,12 +2566,39 @@ interface AgentTaskSession {
2182
2566
  loadHistory(options?: {
2183
2567
  limit?: number;
2184
2568
  }): Promise<readonly AgentTimelineItem[]>;
2185
- /** @deprecated No effect: the queue is always empty. */
2569
+ /**
2570
+ * Whether the Copilot has rows older than the oldest row `history` holds, as the last page read
2571
+ * said. False until a history was loaded.
2572
+ */
2573
+ readonly hasOlder: boolean;
2574
+ /**
2575
+ * Reads the page before the oldest row `history` holds, with the size `loadHistory` used, and
2576
+ * puts it before `history`, in the box's order. Resolves with the items it added (none when
2577
+ * there is nothing older) and emits `historyLoaded`. A read still running when `history` is
2578
+ * replaced resolves with nothing.
2579
+ */
2580
+ loadOlder(): Promise<readonly AgentTimelineItem[]>;
2581
+ /** Changes the text of a queued message (T3's `queued-run.edit`); only the box channel takes it. */
2186
2582
  editQueueItem(id: string, text: string): void;
2187
- /** @deprecated No effect: the queue is always empty. */
2583
+ /** Takes a message out of the queue (T3's `queued-run.cancel`); only the box channel takes it. */
2188
2584
  removeQueueItem(id: string): void;
2189
- /** @deprecated No effect: the queue is always empty. */
2585
+ /** Takes every message in `queue` out, one `queued-run.cancel` each. */
2190
2586
  clearQueue(): void;
2587
+ /**
2588
+ * Moves a queued message into the running turn (T3's `queued-message.promote-to-steer`); only the
2589
+ * box channel takes it. It leaves `queue` and enters the history where the turn takes it.
2590
+ */
2591
+ steerQueueItem(id: string): void;
2592
+ /**
2593
+ * Lets the queue go on after a Stop held it (T3's `queue.resume`): T3's Stop ends the running
2594
+ * turn and holds what waits, each item with `queueHeld`. Only the box channel takes it.
2595
+ */
2596
+ resumeQueue(): void;
2597
+ /**
2598
+ * The work the provider keeps going in the background as T3 shows it waiting (a background
2599
+ * command, a Monitor, a subagent), as the box last reported it. State, not history.
2600
+ */
2601
+ readonly backgroundTasks: readonly AgentBackgroundTask[];
2191
2602
  /** Stops one subagent and leaves the turn running (T3's `subagent.stop`). */
2192
2603
  stopSubagent(subagentId: string): void;
2193
2604
  on<K extends keyof AgentTaskSessionEventMap>(event: K, handler: (payload: AgentTaskSessionEventMap[K]) => void): () => void;
@@ -2261,4 +2672,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
2261
2672
  declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
2262
2673
  declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
2263
2674
 
2264
- export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentSubagent, type AgentSubagentStatus, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SendEmailInput, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
2675
+ export { API_KEY_EXCHANGE_PATH, type AgentBackgroundTask, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentHistoryCursor, type AgentInput, type AgentMessage, type AgentMessageListOptions, type AgentModel, type AgentPieceIdentity, type AgentProviderUsage, type AgentQueueItem, type AgentReadyProvider, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentSubagent, type AgentSubagentFrame, type AgentSubagentStatus, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentTimelineItemIdentity, type AgentToolEvent, type AgentTurnResult, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EffectiveEmailSender, type EmailSender, type EmailSenderInput, type EmailSettings, type EmailSettingsInput, type EmailTemplate, type EmailTemplateInput, type EmailTemplatePreview, type EmailTemplateType, type EmailTemplateTypeCatalog, type EmailTemplateUpsertResult, type EmailTemplateVariable, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SendEmailInput, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };