@mitralab.io/sdk-core 0.3.10 → 0.3.12
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/CHANGELOG.md +111 -0
- package/README.md +12 -5
- package/contracts/README.md +12 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.3.11/sdk-parity.json +2902 -0
- package/contracts/v0.3.12/sdk-parity.json +2902 -0
- package/dist/index.cjs +339 -84
- package/dist/index.d.cts +302 -9
- package/dist/index.d.ts +302 -9
- package/dist/index.js +338 -84
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -543,6 +543,17 @@ interface AgentMessageListOptions extends PageOptions {
|
|
|
543
543
|
include?: "plan";
|
|
544
544
|
/** Id of a message: only the rows recorded before it, so the next page back holds still. */
|
|
545
545
|
before?: string;
|
|
546
|
+
/**
|
|
547
|
+
* `root` asks only for the rows of the chat itself, with every kind, and the page counts only
|
|
548
|
+
* them: a subagent's rows no longer push the chat out of the newest page. A Copilot without it
|
|
549
|
+
* ignores it and answers every thread.
|
|
550
|
+
*/
|
|
551
|
+
thread?: "root";
|
|
552
|
+
/**
|
|
553
|
+
* The `toolId` of the tool call that spawned a subagent: only that subagent's rows. A Copilot
|
|
554
|
+
* without it ignores it and answers every thread.
|
|
555
|
+
*/
|
|
556
|
+
parentToolId?: string;
|
|
546
557
|
}
|
|
547
558
|
type AppColor = {
|
|
548
559
|
type: "SOLID";
|
|
@@ -1126,7 +1137,7 @@ interface IntegrationExecution {
|
|
|
1126
1137
|
source: string | null;
|
|
1127
1138
|
createdAt: string;
|
|
1128
1139
|
}
|
|
1129
|
-
type CopilotProvider = "ANTHROPIC" | "OPENAI" | (string & {});
|
|
1140
|
+
type CopilotProvider = "ANTHROPIC" | "OPENAI" | "GOOGLE" | (string & {});
|
|
1130
1141
|
/** Execution runtime a chat is born on. Absent means the Copilot server default. */
|
|
1131
1142
|
type AgentTaskRuntime = "T3" | "RUNNER";
|
|
1132
1143
|
/** Credential scope a call or a chat resolves against. Absent means the Copilot server default. */
|
|
@@ -1151,6 +1162,26 @@ interface AgentTaskCreateInput {
|
|
|
1151
1162
|
* agent holding a connection; mutually exclusive with `userId`.
|
|
1152
1163
|
*/
|
|
1153
1164
|
autonomous?: boolean;
|
|
1165
|
+
/**
|
|
1166
|
+
* The chat's own instructions, added to the agent's, at most 32,768 characters. They are set
|
|
1167
|
+
* at creation: a chat opened without them (or with blank text) can never get them later, and
|
|
1168
|
+
* `agentTasks.setInstructions` refuses it with 409 `TASK_INSTRUCTIONS_NEED_A_NEW_CHAT`, unless
|
|
1169
|
+
* it was created with a `folderKey`. To give a chat instructions later, open it with some text
|
|
1170
|
+
* or with a `folderKey`.
|
|
1171
|
+
*/
|
|
1172
|
+
instructions?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* Names the chat's folder on the box: 1 to 64 characters of `[A-Za-z0-9_-]`, refused with 400
|
|
1175
|
+
* otherwise, and fixed once the chat exists. Chats created with the same key for the same app,
|
|
1176
|
+
* agent and owner share one folder and one set of instructions: `instructions` sent here
|
|
1177
|
+
* replaces the text of all of them, and a chat created without `instructions` takes the text
|
|
1178
|
+
* the others have. The files are shared only among the chats that run on the same box (same
|
|
1179
|
+
* person, app, provider harness and credential profile): chats with the same key on different
|
|
1180
|
+
* boxes share the instructions but not the files. A chat with a key always has its own folder,
|
|
1181
|
+
* so its `instructions` come back `""` when there is no text and `agentTasks.setInstructions`
|
|
1182
|
+
* accepts it. An ownerless chat shares with no other.
|
|
1183
|
+
*/
|
|
1184
|
+
folderKey?: string;
|
|
1154
1185
|
}
|
|
1155
1186
|
interface AgentTask {
|
|
1156
1187
|
id: string;
|
|
@@ -1165,6 +1196,64 @@ interface AgentTask {
|
|
|
1165
1196
|
archived: boolean;
|
|
1166
1197
|
createdAt: string | null;
|
|
1167
1198
|
updatedAt: string;
|
|
1199
|
+
/**
|
|
1200
|
+
* Where the chat's turn stands. Only `get` carries it, and only for a chat on an agent box:
|
|
1201
|
+
* absent from the listing, from the writes, from a chat on another runtime and from a Copilot
|
|
1202
|
+
* that predates it.
|
|
1203
|
+
*/
|
|
1204
|
+
turn?: AgentTaskTurn | null;
|
|
1205
|
+
/**
|
|
1206
|
+
* The chat's own instructions. Absent on a chat created without them, which never has them,
|
|
1207
|
+
* unless it was created with a `folderKey`: that one always carries them, `""` or the text its
|
|
1208
|
+
* folder already had. Also absent from the listing and from a Copilot that predates them. `""`
|
|
1209
|
+
* on a chat whose text was cleared, which can get text again. A value that is not text is left
|
|
1210
|
+
* out, with no error. Absent from the `rename` answer too, even on a chat that has them.
|
|
1211
|
+
*/
|
|
1212
|
+
instructions?: string;
|
|
1213
|
+
/**
|
|
1214
|
+
* The folder key the chat was created with, which never changes. Absent on a chat created
|
|
1215
|
+
* without one and from a Copilot that predates it; the listing may leave it out. A value that
|
|
1216
|
+
* is not text is left out, with no error.
|
|
1217
|
+
*/
|
|
1218
|
+
folderKey?: string;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Where a chat's turn stands, as the Copilot reads it without the live session. The two readings
|
|
1222
|
+
* behind it are not of the same instant: a turn that ends between them can show as `RUNNING` and
|
|
1223
|
+
* as `lastTurn` in one answer, and the next read is right.
|
|
1224
|
+
*/
|
|
1225
|
+
interface AgentTaskTurn {
|
|
1226
|
+
/**
|
|
1227
|
+
* `RUNNING` with a box holding a message, `QUEUED` with messages waiting and none running,
|
|
1228
|
+
* `IDLE` otherwise. Open to other strings so a state the Copilot adds later still compiles.
|
|
1229
|
+
*/
|
|
1230
|
+
state: "RUNNING" | "QUEUED" | "IDLE" | (string & {});
|
|
1231
|
+
/** The message that opened the turn that runs; null outside `RUNNING`. */
|
|
1232
|
+
currentTurnId: string | null;
|
|
1233
|
+
/** Messages waiting for a box to take them. */
|
|
1234
|
+
queuedCount: number;
|
|
1235
|
+
/** The turn that last reached a final state; null when none did, or after the retention took it. */
|
|
1236
|
+
lastTurn: AgentTaskLastTurn | null;
|
|
1237
|
+
}
|
|
1238
|
+
interface AgentTaskLastTurn {
|
|
1239
|
+
/** The message that opened the turn. */
|
|
1240
|
+
turnId: string;
|
|
1241
|
+
/** Every message the turn closed, oldest first: more than one when it took steers. */
|
|
1242
|
+
messageIds: string[];
|
|
1243
|
+
status: "COMPLETED" | "INTERRUPTED" | "FAILED" | "REJECTED" | "EXPIRED" | "LOST" | (string & {});
|
|
1244
|
+
/** The reason the box closed the turn with; null on a turn that ended with an error or never ran. */
|
|
1245
|
+
finishReason: string | null;
|
|
1246
|
+
/** Not a closed set: an unknown value is a generic error. Null on an end without an error. */
|
|
1247
|
+
errorCode: string | null;
|
|
1248
|
+
/** ISO instant a box took the turn's first message; null for a message no box took. */
|
|
1249
|
+
startedAt: string | null;
|
|
1250
|
+
/** ISO instant; null on a turn that ended before the Copilot recorded it. */
|
|
1251
|
+
endedAt: string | null;
|
|
1252
|
+
}
|
|
1253
|
+
/** One chat of `agentTasks.turnStates`; `turn` is null for a chat that does not run on an agent box. */
|
|
1254
|
+
interface AgentTaskTurnStateEntry {
|
|
1255
|
+
taskId: string;
|
|
1256
|
+
turn: AgentTaskTurn | null;
|
|
1168
1257
|
}
|
|
1169
1258
|
interface AgentTaskListOptions extends PageOptions {
|
|
1170
1259
|
/** Include archived chats. Defaults to false. */
|
|
@@ -1309,6 +1398,19 @@ interface AgentTurnUsage {
|
|
|
1309
1398
|
*/
|
|
1310
1399
|
contextWindow?: number;
|
|
1311
1400
|
}
|
|
1401
|
+
/** One time the provider compacted the conversation's context during a turn, as the box sent it. */
|
|
1402
|
+
interface AgentTurnCompaction {
|
|
1403
|
+
/**
|
|
1404
|
+
* `manual` when the person asked for it, `auto` when the provider did it because the context
|
|
1405
|
+
* filled up. Open to other strings so a trigger the box adds later still compiles.
|
|
1406
|
+
*/
|
|
1407
|
+
trigger: "auto" | "manual" | (string & {});
|
|
1408
|
+
/** The context's size before it, in tokens; null when the provider reports none. */
|
|
1409
|
+
tokensBefore: number | null;
|
|
1410
|
+
tokensAfter: number | null;
|
|
1411
|
+
/** ISO instant the compaction finished; null when the box did not say. */
|
|
1412
|
+
at: string | null;
|
|
1413
|
+
}
|
|
1312
1414
|
interface AgentMessage {
|
|
1313
1415
|
id: string;
|
|
1314
1416
|
sender: string;
|
|
@@ -1689,6 +1791,29 @@ interface AgentTasksModule {
|
|
|
1689
1791
|
* modules keep compiling; a module without it never takes the direct channel.
|
|
1690
1792
|
*/
|
|
1691
1793
|
channel?(id: string): Promise<AgentTaskChannel | null>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Reads where the turn of each chat stands without opening a session, with
|
|
1796
|
+
* `GET /api/v1/tasks/turn-states?taskIds=a,b`. One entry per chat the
|
|
1797
|
+
* caller may read, in the order asked: an id it may not read, or that does not exist, is left
|
|
1798
|
+
* out with no error. An id that is not a UUID is left out before the request, because the
|
|
1799
|
+
* Copilot refuses the whole request for one. `turn` is null for a chat that does not run on an
|
|
1800
|
+
* agent box. No ids, no request. Above 100 ids it asks in requests of 100, and one that fails rejects the whole call:
|
|
1801
|
+
* no partial answer. Optional so hand-written modules keep compiling.
|
|
1802
|
+
*/
|
|
1803
|
+
turnStates?(ids: string[]): Promise<AgentTaskTurnStateEntry[]>;
|
|
1804
|
+
/**
|
|
1805
|
+
* Replaces the chat's own instructions with `PUT /api/v1/tasks/{id}/instructions`, at most
|
|
1806
|
+
* 32,768 characters, and answers the task. `null` or blank text clears them (`instructions`
|
|
1807
|
+
* comes back `""`) and the chat can get text again. Only a chat created with instructions
|
|
1808
|
+
* or with a `folderKey` accepts it: one created without either is refused with 409
|
|
1809
|
+
* `TASK_INSTRUCTIONS_NEED_A_NEW_CHAT`, and needs a new chat. Who may rename a chat may change
|
|
1810
|
+
* them. The box gets the new text before the chat's next turn, but the conversation under way
|
|
1811
|
+
* only uses it after a compaction (or in a new conversation), as with the agent's
|
|
1812
|
+
* instructions; to apply it at once, set it and send `/compact`. On a chat created with a
|
|
1813
|
+
* `folderKey` the text belongs to the folder: it changes for every chat of the same app, agent
|
|
1814
|
+
* and owner created with that key. Optional so hand-written modules keep compiling.
|
|
1815
|
+
*/
|
|
1816
|
+
setInstructions?(id: string, instructions: string | null): Promise<AgentTask>;
|
|
1692
1817
|
}
|
|
1693
1818
|
declare function createAgentTasksModule(transport: Transport, errors?: SdkCoreErrorFactory): AgentTasksModule;
|
|
1694
1819
|
|
|
@@ -2317,7 +2442,9 @@ type AgentFetch = (url: string, init: {
|
|
|
2317
2442
|
|
|
2318
2443
|
declare class AgentTaskTurnError extends Error {
|
|
2319
2444
|
readonly code: string | undefined;
|
|
2320
|
-
|
|
2445
|
+
/** The compactions of a turn the box closed with an error; empty when it reported none. */
|
|
2446
|
+
readonly compactions: readonly AgentTurnCompaction[];
|
|
2447
|
+
constructor(message: string, code?: string, compactions?: readonly AgentTurnCompaction[]);
|
|
2321
2448
|
}
|
|
2322
2449
|
|
|
2323
2450
|
interface AgentTaskEventObserver {
|
|
@@ -2365,6 +2492,13 @@ interface NewAgentTaskSessionOptions {
|
|
|
2365
2492
|
interface ExistingAgentTaskSessionOptions {
|
|
2366
2493
|
taskId: string;
|
|
2367
2494
|
transport?: AgentSessionTransport;
|
|
2495
|
+
/**
|
|
2496
|
+
* With the session open for this task in `error`, closes it and opens a new one, as a "try
|
|
2497
|
+
* again" does. A session in any other status is returned as is. Without it a failed session
|
|
2498
|
+
* keeps being returned until it is closed, so a screen that asks for the session on every
|
|
2499
|
+
* render does not reopen it in a loop.
|
|
2500
|
+
*/
|
|
2501
|
+
reopen?: boolean;
|
|
2368
2502
|
}
|
|
2369
2503
|
type AgentTaskSessionOptions = NewAgentTaskSessionOptions | ExistingAgentTaskSessionOptions;
|
|
2370
2504
|
interface AgentSendOptions {
|
|
@@ -2377,6 +2511,12 @@ interface AgentSendOptions {
|
|
|
2377
2511
|
* `resumeQueue`. With no turn running the message starts one.
|
|
2378
2512
|
*/
|
|
2379
2513
|
mode?: "queue" | "steer";
|
|
2514
|
+
/**
|
|
2515
|
+
* The id to send the message with, in place of a new one: for a layer that held the message
|
|
2516
|
+
* before it reached the session and already showed the person this id. It must not have gone
|
|
2517
|
+
* out before, since the Copilot does not dedupe by it.
|
|
2518
|
+
*/
|
|
2519
|
+
clientMessageId?: string;
|
|
2380
2520
|
}
|
|
2381
2521
|
interface AgentSendAndWaitOptions extends AgentSendOptions {
|
|
2382
2522
|
signal?: AbortSignal;
|
|
@@ -2396,7 +2536,7 @@ interface AgentBackgroundTask {
|
|
|
2396
2536
|
/** The subagent's own thread, when it has one. */
|
|
2397
2537
|
childThreadId?: string;
|
|
2398
2538
|
}
|
|
2399
|
-
interface AgentQueueItem extends AgentSendOptions {
|
|
2539
|
+
interface AgentQueueItem extends Omit<AgentSendOptions, "clientMessageId"> {
|
|
2400
2540
|
/** The `clientMessageId` the message went out with: what `send` returned for it. */
|
|
2401
2541
|
id: string;
|
|
2402
2542
|
text: string;
|
|
@@ -2574,6 +2714,12 @@ type AgentTimelineItem = ({
|
|
|
2574
2714
|
/** On the tool call that spawned a subagent: its last state, as the box's `subagentUpdate`. */
|
|
2575
2715
|
subagent?: Partial<AgentSubagentFrame>;
|
|
2576
2716
|
} & AgentTimelineItemIdentity);
|
|
2717
|
+
interface AgentSubagentHistory {
|
|
2718
|
+
items: readonly AgentTimelineItem[];
|
|
2719
|
+
hasOlder: boolean;
|
|
2720
|
+
/** The oldest row read, to pass as `before` for the page before this one; absent on none. */
|
|
2721
|
+
before?: string;
|
|
2722
|
+
}
|
|
2577
2723
|
interface AgentTurnResult {
|
|
2578
2724
|
task: AgentTask;
|
|
2579
2725
|
content: string;
|
|
@@ -2584,6 +2730,13 @@ interface AgentTurnResult {
|
|
|
2584
2730
|
sequence?: number;
|
|
2585
2731
|
/** The `lifecycle.turnId` of that `stepFinish`. */
|
|
2586
2732
|
turnId?: string;
|
|
2733
|
+
/**
|
|
2734
|
+
* The times the provider compacted the context during the turn, oldest first, as the box listed
|
|
2735
|
+
* them on the frame that ended it; a subagent's own compactions are not among them. The session
|
|
2736
|
+
* always sets it, empty for a turn that compacted nothing, for a box that does not report it and
|
|
2737
|
+
* for a turn closed from the history. Optional so a result built by hand keeps compiling.
|
|
2738
|
+
*/
|
|
2739
|
+
compactions?: AgentTurnCompaction[];
|
|
2587
2740
|
}
|
|
2588
2741
|
interface AgentTaskSessionEventMap {
|
|
2589
2742
|
statusChange: {
|
|
@@ -2628,6 +2781,17 @@ interface AgentTaskSessionEventMap {
|
|
|
2628
2781
|
* that does not wait for the answer can close it or return.
|
|
2629
2782
|
*/
|
|
2630
2783
|
accepted: Record<string, never>;
|
|
2784
|
+
/**
|
|
2785
|
+
* A message this session sent did not reach the server within `deliveryDelayMs` of the send
|
|
2786
|
+
* (the network is down, or the server does not answer): `delayed`, then `sent` when it gets
|
|
2787
|
+
* there or `failed` when it cannot go, which also comes as `error`. Only a delayed message has
|
|
2788
|
+
* this event. A delayed message is not dropped and goes out once, so it must not be sent again:
|
|
2789
|
+
* the Copilot does not dedupe by `clientMessageId`, and a second send is a second message.
|
|
2790
|
+
*/
|
|
2791
|
+
delivery: {
|
|
2792
|
+
clientMessageId: string;
|
|
2793
|
+
state: "delayed" | "sent" | "failed";
|
|
2794
|
+
};
|
|
2631
2795
|
cancelled: Record<string, never>;
|
|
2632
2796
|
/** T3's queue of the chat changed: a message entered it, moved, or left it. */
|
|
2633
2797
|
queueChange: {
|
|
@@ -2672,10 +2836,23 @@ interface AgentTaskSessionEventMap {
|
|
|
2672
2836
|
subagentTool: AgentToolEvent & {
|
|
2673
2837
|
parentToolId: string;
|
|
2674
2838
|
};
|
|
2839
|
+
/**
|
|
2840
|
+
* `compactions` comes on the error that ended a turn, and there the session always sets it, as
|
|
2841
|
+
* on `turnEnd`: the list the box sent with the error, empty when it sent none. An error that
|
|
2842
|
+
* ended no turn (a refused steer, a failure to open or to send) has no such field.
|
|
2843
|
+
*/
|
|
2675
2844
|
error: {
|
|
2676
2845
|
code?: string;
|
|
2677
2846
|
error: string;
|
|
2678
2847
|
sequence?: number;
|
|
2848
|
+
compactions?: AgentTurnCompaction[];
|
|
2849
|
+
};
|
|
2850
|
+
/**
|
|
2851
|
+
* The provider compacted the conversation's context. On a subagent's own thread, `parentToolId`
|
|
2852
|
+
* is the tool call that spawned it, and the compaction is not in the turn's `compactions`.
|
|
2853
|
+
*/
|
|
2854
|
+
contextCompacted: AgentTurnCompaction & AgentPieceIdentity & {
|
|
2855
|
+
parentToolId?: string;
|
|
2679
2856
|
};
|
|
2680
2857
|
/**
|
|
2681
2858
|
* The subscription window the chat's harness reported during a turn. It comes only on the
|
|
@@ -2728,12 +2905,26 @@ interface AgentTaskSession {
|
|
|
2728
2905
|
*/
|
|
2729
2906
|
readonly hasOlder: boolean;
|
|
2730
2907
|
/**
|
|
2731
|
-
* Reads the page before the oldest row `history` holds, with
|
|
2732
|
-
* puts it before `history`, in the box's order.
|
|
2733
|
-
*
|
|
2734
|
-
*
|
|
2908
|
+
* Reads the page before the oldest row `history` holds, with `limit` or else the size
|
|
2909
|
+
* `loadHistory` used, and puts it before `history`, in the box's order. A page that starts in
|
|
2910
|
+
* the middle of a turn is read on back to the person's message that opened it, so `history`
|
|
2911
|
+
* never starts inside a turn. Resolves with the items it added (none when there is nothing
|
|
2912
|
+
* older) and emits `historyLoaded`. A read still running when `history` is replaced resolves
|
|
2913
|
+
* with nothing.
|
|
2914
|
+
*/
|
|
2915
|
+
loadOlder(options?: {
|
|
2916
|
+
limit?: number;
|
|
2917
|
+
}): Promise<readonly AgentTimelineItem[]>;
|
|
2918
|
+
/**
|
|
2919
|
+
* Reads the pieces of the subagent the tool call `toolId` spawned, which `history` leaves out:
|
|
2920
|
+
* the newest `limit` rows (the Copilot's page size without it), or the ones before `before`.
|
|
2921
|
+
* Resolves with them in the box's order, whether there are older ones, and the `before` that
|
|
2922
|
+
* reads the page before this one.
|
|
2735
2923
|
*/
|
|
2736
|
-
|
|
2924
|
+
loadSubagent(toolId: string, options?: {
|
|
2925
|
+
limit?: number;
|
|
2926
|
+
before?: string;
|
|
2927
|
+
}): Promise<AgentSubagentHistory>;
|
|
2737
2928
|
/** Changes the text of a queued message (T3's `queued-run.edit`); only the box channel takes it. */
|
|
2738
2929
|
editQueueItem(id: string, text: string): void;
|
|
2739
2930
|
/** Takes a message out of the queue (T3's `queued-run.cancel`); only the box channel takes it. */
|
|
@@ -2769,11 +2960,113 @@ interface AgentTaskSessionManagerOptions {
|
|
|
2769
2960
|
eventSource: AgentTaskEventSource;
|
|
2770
2961
|
/** Where the box channel may live and how to dial it outside a browser. */
|
|
2771
2962
|
directChannel?: AgentDirectChannelOptions;
|
|
2963
|
+
/**
|
|
2964
|
+
* How long a message may take to reach the server before the session emits `delivery` with
|
|
2965
|
+
* `delayed`. 20 s by default: past a cold box, whose channel takes 5 to 10 s to open.
|
|
2966
|
+
*/
|
|
2967
|
+
deliveryDelayMs?: number;
|
|
2772
2968
|
}
|
|
2773
2969
|
declare function toAgentTimelineItem(message: AgentMessage): AgentTimelineItem;
|
|
2774
2970
|
declare function createAgentTaskSessionManager(options: AgentTaskSessionManagerOptions): AgentTaskSessionManager;
|
|
2775
2971
|
declare function withAgentTaskSessions(tasks: AgentTasksModule, manager: AgentTaskSessionManager): AgentTasksWithSessions;
|
|
2776
2972
|
|
|
2973
|
+
/**
|
|
2974
|
+
* What the Server Function of an app's agent turn hook receives as `event`: the start or the end
|
|
2975
|
+
* of an agent turn of a chat on an agent box, as `mitra-functions` hands it over. Every field is
|
|
2976
|
+
* always there and one without a value is null, so both types have the same shape.
|
|
2977
|
+
*
|
|
2978
|
+
* Delivery is at least once and out of order: the function must be idempotent by `eventId`, and
|
|
2979
|
+
* tell start from end by `type` and `turnId`, never by arrival. It runs as whoever configured the
|
|
2980
|
+
* hook, not as `userId`, who owns the chat.
|
|
2981
|
+
*/
|
|
2982
|
+
type AgentTurnEvent = AgentTurnStartedEvent | AgentTurnEndedEvent;
|
|
2983
|
+
interface AgentTurnEventBase {
|
|
2984
|
+
/** The same start or end always carries the same id. */
|
|
2985
|
+
eventId: string;
|
|
2986
|
+
appId: string | null;
|
|
2987
|
+
/** The chat. */
|
|
2988
|
+
taskId: string;
|
|
2989
|
+
agentId: string | null;
|
|
2990
|
+
/** The owner of the chat; null for a chat nobody owns (autonomous agent). */
|
|
2991
|
+
userId: string | null;
|
|
2992
|
+
/**
|
|
2993
|
+
* The message that opened the turn. A message that never ran (refused, expired, failed before
|
|
2994
|
+
* any box, cancelled in the queue) is a turn of its own.
|
|
2995
|
+
*/
|
|
2996
|
+
turnId: string;
|
|
2997
|
+
/** The id the client sent the opening message with, when it sent one. */
|
|
2998
|
+
clientMessageId: string | null;
|
|
2999
|
+
/** ISO-8601 in UTC, always with milliseconds (`2026-11-11T10:00:42.000Z`), as every date here. */
|
|
3000
|
+
occurredAt: string;
|
|
3001
|
+
}
|
|
3002
|
+
interface AgentTurnStartedEvent extends AgentTurnEventBase {
|
|
3003
|
+
type: "STARTED";
|
|
3004
|
+
status: null;
|
|
3005
|
+
finishReason: null;
|
|
3006
|
+
errorCode: null;
|
|
3007
|
+
messageIds: string[];
|
|
3008
|
+
startedAt: null;
|
|
3009
|
+
endedAt: null;
|
|
3010
|
+
usage: null;
|
|
3011
|
+
taskStateAfter: null;
|
|
3012
|
+
supersedes: false;
|
|
3013
|
+
/** Absent from a `mitra-functions` that predates it. */
|
|
3014
|
+
compactions?: AgentTurnEventCompaction[];
|
|
3015
|
+
}
|
|
3016
|
+
interface AgentTurnEndedEvent extends AgentTurnEventBase {
|
|
3017
|
+
type: "ENDED";
|
|
3018
|
+
/**
|
|
3019
|
+
* `UNKNOWN` is a status the publisher added after `mitra-functions` last read the schema. Open
|
|
3020
|
+
* to other strings so one the schema gains later still compiles.
|
|
3021
|
+
*/
|
|
3022
|
+
status: "COMPLETED" | "INTERRUPTED" | "FAILED" | "REJECTED" | "EXPIRED" | "LOST" | "UNKNOWN" | (string & {});
|
|
3023
|
+
/** The reason the box closed the turn with; null on an end with an error or a message that never ran. */
|
|
3024
|
+
finishReason: string | null;
|
|
3025
|
+
/** Not a closed set: an unknown value is a generic error. Null on an end without an error. */
|
|
3026
|
+
errorCode: string | null;
|
|
3027
|
+
/** Every message this end closes, oldest first. */
|
|
3028
|
+
messageIds: string[];
|
|
3029
|
+
/** When a box took the first message of the turn; null for a message that never ran. */
|
|
3030
|
+
startedAt: string | null;
|
|
3031
|
+
endedAt: string | null;
|
|
3032
|
+
usage: AgentTurnEventUsage | null;
|
|
3033
|
+
/** Where the chat stands once this end is written. */
|
|
3034
|
+
taskStateAfter: "IDLE" | "QUEUED" | "RUNNING" | "UNKNOWN" | (string & {}) | null;
|
|
3035
|
+
/** True on the end of a turn already announced as `LOST` that the box answered after all. */
|
|
3036
|
+
supersedes: boolean;
|
|
3037
|
+
/**
|
|
3038
|
+
* The compactions of the turn, oldest first; empty for a turn that compacted nothing and for an
|
|
3039
|
+
* end no box closed. Absent from a `mitra-functions` that predates it.
|
|
3040
|
+
*/
|
|
3041
|
+
compactions?: AgentTurnEventCompaction[];
|
|
3042
|
+
}
|
|
3043
|
+
/** What the turn consumed. A null field is one the provider did not report, never zero. */
|
|
3044
|
+
interface AgentTurnEventUsage {
|
|
3045
|
+
inputTokens: number | null;
|
|
3046
|
+
outputTokens: number | null;
|
|
3047
|
+
cacheReadTokens: number | null;
|
|
3048
|
+
cacheCreationTokens: number | null;
|
|
3049
|
+
model: string | null;
|
|
3050
|
+
/** A decimal as text, so no precision is lost. */
|
|
3051
|
+
costUsd: string | null;
|
|
3052
|
+
contextTokens: number | null;
|
|
3053
|
+
contextWindow: number | null;
|
|
3054
|
+
}
|
|
3055
|
+
interface AgentTurnEventCompaction {
|
|
3056
|
+
/** When the compaction finished; null when the box did not say. */
|
|
3057
|
+
at: string | null;
|
|
3058
|
+
/** `MANUAL` is the person asking for it, `AUTO` the provider doing it because the context filled up. */
|
|
3059
|
+
trigger: "AUTO" | "MANUAL" | "UNKNOWN" | (string & {});
|
|
3060
|
+
/** The size of the context before it, in tokens; null when the provider did not report it. */
|
|
3061
|
+
tokensBefore: number | null;
|
|
3062
|
+
tokensAfter: number | null;
|
|
3063
|
+
}
|
|
3064
|
+
/**
|
|
3065
|
+
* Whether a Server Function's input is an agent turn event: it checks the fields that identify
|
|
3066
|
+
* one, not every field of the shape.
|
|
3067
|
+
*/
|
|
3068
|
+
declare function isAgentTurnEvent(value: unknown): value is AgentTurnEvent;
|
|
3069
|
+
|
|
2777
3070
|
type FileTransferStep = "send" | "confirm" | "download";
|
|
2778
3071
|
interface FileTransferErrorDetails {
|
|
2779
3072
|
fileId: string;
|
|
@@ -2860,4 +3153,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
2860
3153
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
2861
3154
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
2862
3155
|
|
|
2863
|
-
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 AgentNotification, type AgentPieceIdentity, type AgentPlan, type AgentPlanStep, 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 AiProviders, type AiProvidersModule, 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 FileCreator, type FileDownloadOptions, type FileKind, type FileMetadata, type FileReadUrl, type FileReadUrlItem, type FileReadUrlOptions, type FileReadUrls, type FileStatus, FileTransferError, type FileTransferErrorDetails, type FileTransferStep, type FileUpload, type FileUploadInput, type FileUploadOptions, type FileVisibility, type FilesFetch, type FilesFetchResponse, type FilesModule, type FilesModuleOptions, 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 IncludedAiQuota, type IncludedAiQuotaWindow, 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 ManagedAiProfile, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type OpencodeAiProvider, 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, createAiProvidersModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFilesModule, 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 };
|
|
3156
|
+
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 AgentNotification, type AgentPieceIdentity, type AgentPlan, type AgentPlanStep, type AgentProviderUsage, type AgentQueueItem, type AgentReadyProvider, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentSubagent, type AgentSubagentFrame, type AgentSubagentHistory, type AgentSubagentStatus, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskLastTurn, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, type AgentTaskTurn, AgentTaskTurnError, type AgentTaskTurnStateEntry, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentTimelineItemIdentity, type AgentToolEvent, type AgentTurnCompaction, type AgentTurnEndedEvent, type AgentTurnEvent, type AgentTurnEventCompaction, type AgentTurnEventUsage, type AgentTurnResult, type AgentTurnStartedEvent, type AgentTurnUsage, type AgentTurnUsageRequest, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type AiProviders, type AiProvidersModule, 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 FileCreator, type FileDownloadOptions, type FileKind, type FileMetadata, type FileReadUrl, type FileReadUrlItem, type FileReadUrlOptions, type FileReadUrls, type FileStatus, FileTransferError, type FileTransferErrorDetails, type FileTransferStep, type FileUpload, type FileUploadInput, type FileUploadOptions, type FileVisibility, type FilesFetch, type FilesFetchResponse, type FilesModule, type FilesModuleOptions, 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 IncludedAiQuota, type IncludedAiQuotaWindow, 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 ManagedAiProfile, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type OpencodeAiProvider, 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, createAiProvidersModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFilesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isAgentTurnEvent, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|