@truefoundry/assistant-ui-runtime 0.1.5 → 0.1.6-rc.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.
- package/README.md +374 -190
- package/dist/index.d.ts +32 -29
- package/dist/index.js +330 -236
- package/dist/index.js.map +1 -1
- package/dist/plugins/truefoundry-agent-server-adapter/index.d.ts +30 -0
- package/dist/plugins/truefoundry-agent-server-adapter/index.js +198 -0
- package/dist/plugins/truefoundry-agent-server-adapter/index.js.map +1 -0
- package/dist/types-VUBzoJT2.d.ts +462 -0
- package/package.json +10 -2
- package/src/askUserQuestion.ts +3 -3
- package/src/buildEditedUserMessageContent.test.ts +2 -2
- package/src/collectPending.ts +1 -1
- package/src/convertTurnMessages.test.ts +141 -196
- package/src/convertTurnMessages.ts +130 -76
- package/src/createSubAgent.ts +1 -1
- package/src/draftAgentConfig.test.ts +26 -29
- package/src/extractTurnUserText.ts +1 -1
- package/src/foldPeerThreads.test.ts +1 -1
- package/src/foldPeerThreads.ts +3 -2
- package/src/index.ts +39 -4
- package/src/listPages.ts +21 -0
- package/src/loadSessionSnapshot.test.ts +9 -8
- package/src/loadSessionSnapshot.ts +9 -14
- package/src/mcpAuth.ts +6 -3
- package/src/messageCustomMetadata.ts +1 -1
- package/src/modelMessageContent.ts +1 -1
- package/src/modelMessageImageContent.test.ts +1 -1
- package/src/modelMessageImageContent.ts +7 -6
- package/src/plugins/truefoundry-agent-server-adapter/index.ts +285 -0
- package/src/private/agentSpec.ts +8 -3
- package/src/private/draftSessionBridge.ts +14 -13
- package/src/private/truefoundryDraftThreadListAdapter.test.ts +44 -49
- package/src/private/truefoundryDraftThreadListAdapter.ts +22 -16
- package/src/requiredActionInputs.ts +1 -1
- package/src/requiredActionsFromActiveUpdate.test.ts +1 -1
- package/src/server/eventUtils.ts +120 -0
- package/src/server/events.ts +246 -0
- package/src/server/index.ts +66 -0
- package/src/server/types.ts +313 -0
- package/src/sessionSnapshot.ts +1 -1
- package/src/sessions.ts +5 -21
- package/src/streamTurn.test.ts +172 -155
- package/src/streamTurn.ts +51 -48
- package/src/toolApproval.ts +4 -4
- package/src/toolResponse.ts +4 -4
- package/src/truefoundryExtras.ts +1 -1
- package/src/truefoundryOwnedSessionsThreadListAdapter.test.ts +26 -29
- package/src/truefoundryOwnedSessionsThreadListAdapter.ts +18 -23
- package/src/truefoundryThreadListAdapter.test.ts +16 -18
- package/src/truefoundryThreadListAdapter.ts +7 -7
- package/src/turnEventHelpers.ts +1 -1
- package/src/types.ts +2 -16
- package/src/useTrueFoundryAgentMessages.test.tsx +38 -70
- package/src/useTrueFoundryAgentMessages.ts +32 -44
- package/src/useTrueFoundryAgentRuntime.ts +11 -28
- package/src/private/bindDraftAgentSession.test.ts +0 -54
- package/src/private/bindDraftAgentSession.ts +0 -28
- package/src/private/getGatewayFromPrivateClient.ts +0 -13
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime-owned turn/stream event protocol.
|
|
3
|
+
*
|
|
4
|
+
* Hosts must emit events matching these shapes. The TFY adapter maps
|
|
5
|
+
* truefoundry-gateway-sdk events 1:1 onto these types.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface ToolCallFunction {
|
|
9
|
+
name: string;
|
|
10
|
+
arguments: string;
|
|
11
|
+
}
|
|
12
|
+
type ToolInfo = {
|
|
13
|
+
type: "truefoundry-system";
|
|
14
|
+
name: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: "mcp";
|
|
17
|
+
serverId: string;
|
|
18
|
+
serverName: string;
|
|
19
|
+
name: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
interface ToolCall {
|
|
26
|
+
id: string;
|
|
27
|
+
type: "function";
|
|
28
|
+
function: ToolCallFunction;
|
|
29
|
+
toolInfo?: ToolInfo;
|
|
30
|
+
providerSpecificFields?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/** Ref used by approval/response-required events. */
|
|
33
|
+
interface ToolCallRef {
|
|
34
|
+
id: string;
|
|
35
|
+
sourceEventId: string;
|
|
36
|
+
}
|
|
37
|
+
interface ChunkDeltaToolCall {
|
|
38
|
+
index: number;
|
|
39
|
+
id?: string;
|
|
40
|
+
type?: "function";
|
|
41
|
+
function?: {
|
|
42
|
+
name?: string;
|
|
43
|
+
arguments?: string;
|
|
44
|
+
};
|
|
45
|
+
toolInfo?: ToolInfo;
|
|
46
|
+
providerSpecificFields?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
type ModelMessageContentPart = {
|
|
49
|
+
type: "text";
|
|
50
|
+
text: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: "refusal";
|
|
53
|
+
refusal: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: "image_url";
|
|
56
|
+
image_url: {
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
interface ModelMessageEvent {
|
|
61
|
+
type: "model.message";
|
|
62
|
+
id: string;
|
|
63
|
+
threadId: string;
|
|
64
|
+
content?: string | ModelMessageContentPart[] | null;
|
|
65
|
+
name?: string;
|
|
66
|
+
refusal?: string | null;
|
|
67
|
+
reasoningContent?: string;
|
|
68
|
+
toolCalls?: ToolCall[];
|
|
69
|
+
finishReason?: string | null;
|
|
70
|
+
createdAt: string;
|
|
71
|
+
usage?: unknown;
|
|
72
|
+
}
|
|
73
|
+
interface ModelMessageDeltaEvent {
|
|
74
|
+
type: "model.message.delta";
|
|
75
|
+
id: string;
|
|
76
|
+
threadId: string;
|
|
77
|
+
content?: string | null;
|
|
78
|
+
refusal?: string | null;
|
|
79
|
+
reasoningContent?: string;
|
|
80
|
+
toolCalls?: ChunkDeltaToolCall[];
|
|
81
|
+
finishReason?: string | null;
|
|
82
|
+
createdAt?: string;
|
|
83
|
+
usage?: unknown;
|
|
84
|
+
/** Extended content-block deltas (image streaming). */
|
|
85
|
+
contentBlocks?: Array<{
|
|
86
|
+
index: number;
|
|
87
|
+
delta: {
|
|
88
|
+
type: "text";
|
|
89
|
+
text?: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: "image_url";
|
|
92
|
+
image_url?: {
|
|
93
|
+
url?: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}>;
|
|
97
|
+
content_blocks?: Array<{
|
|
98
|
+
index: number;
|
|
99
|
+
delta: {
|
|
100
|
+
type: "text";
|
|
101
|
+
text?: string;
|
|
102
|
+
} | {
|
|
103
|
+
type: "image_url";
|
|
104
|
+
image_url?: {
|
|
105
|
+
url?: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
110
|
+
interface ToolResponseEvent {
|
|
111
|
+
type: "tool.response";
|
|
112
|
+
id: string;
|
|
113
|
+
threadId: string;
|
|
114
|
+
toolCallId: string;
|
|
115
|
+
content: string;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
}
|
|
118
|
+
interface ToolApprovalRequiredEvent {
|
|
119
|
+
type: "tool.approval_required";
|
|
120
|
+
id: string;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
threadId: string;
|
|
123
|
+
toolCalls: ToolCallRef[];
|
|
124
|
+
}
|
|
125
|
+
interface ToolResponseRequiredEvent {
|
|
126
|
+
type: "tool.response_required";
|
|
127
|
+
id: string;
|
|
128
|
+
createdAt: string;
|
|
129
|
+
threadId: string;
|
|
130
|
+
toolCalls: ToolCallRef[];
|
|
131
|
+
}
|
|
132
|
+
interface AgentInfo {
|
|
133
|
+
type?: string;
|
|
134
|
+
name: string;
|
|
135
|
+
input: string;
|
|
136
|
+
model?: string;
|
|
137
|
+
}
|
|
138
|
+
interface AgentParent {
|
|
139
|
+
threadId: string;
|
|
140
|
+
toolCallId: string;
|
|
141
|
+
}
|
|
142
|
+
interface ThreadCreatedEvent {
|
|
143
|
+
type: "thread.created";
|
|
144
|
+
id: string;
|
|
145
|
+
threadId: string;
|
|
146
|
+
title: string;
|
|
147
|
+
agentInfo: AgentInfo;
|
|
148
|
+
parent: AgentParent;
|
|
149
|
+
createdAt: string;
|
|
150
|
+
}
|
|
151
|
+
interface ThreadDoneEvent {
|
|
152
|
+
type: "thread.done";
|
|
153
|
+
id: string;
|
|
154
|
+
threadId: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
createdAt: string;
|
|
157
|
+
state?: unknown;
|
|
158
|
+
}
|
|
159
|
+
interface McpServerAuthInfo {
|
|
160
|
+
id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
authUrl: string;
|
|
163
|
+
}
|
|
164
|
+
interface McpAuthRequiredEvent {
|
|
165
|
+
type: "mcp.auth_required";
|
|
166
|
+
id: string;
|
|
167
|
+
createdAt: string;
|
|
168
|
+
threadId?: string | null;
|
|
169
|
+
mcpServers: McpServerAuthInfo[];
|
|
170
|
+
}
|
|
171
|
+
interface SandboxCreatedEvent {
|
|
172
|
+
type: "sandbox.created";
|
|
173
|
+
id: string;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
sandboxId: string;
|
|
176
|
+
threadId: string | null;
|
|
177
|
+
}
|
|
178
|
+
interface McpInitializeEvent {
|
|
179
|
+
type: "mcp.initialize";
|
|
180
|
+
id: string;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
threadId: string | null;
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
interface TurnCreatedEvent {
|
|
186
|
+
type: "turn.created";
|
|
187
|
+
id: string;
|
|
188
|
+
turnId: string;
|
|
189
|
+
previousTurnId?: string | null;
|
|
190
|
+
input?: TurnInputItem[];
|
|
191
|
+
state?: {
|
|
192
|
+
status: "running";
|
|
193
|
+
};
|
|
194
|
+
createdAt: string;
|
|
195
|
+
threadId?: string | null;
|
|
196
|
+
}
|
|
197
|
+
interface TurnDoneEvent {
|
|
198
|
+
type: "turn.done";
|
|
199
|
+
id: string;
|
|
200
|
+
state: Exclude<TurnState, {
|
|
201
|
+
status: "running";
|
|
202
|
+
}>;
|
|
203
|
+
createdAt: string;
|
|
204
|
+
threadId?: string | null;
|
|
205
|
+
}
|
|
206
|
+
/** Events stored in fold buckets (non-delta, non-turn-lifecycle). */
|
|
207
|
+
type TurnEvent = ModelMessageEvent | ToolResponseEvent | ThreadCreatedEvent | ThreadDoneEvent | McpAuthRequiredEvent | McpInitializeEvent | SandboxCreatedEvent | ToolApprovalRequiredEvent | ToolResponseRequiredEvent;
|
|
208
|
+
/** Full streaming event union (includes deltas + turn lifecycle). */
|
|
209
|
+
type TurnStreamingEvent = TurnEvent | ModelMessageDeltaEvent | TurnCreatedEvent | TurnDoneEvent;
|
|
210
|
+
type ActionRequiredEvent = ToolApprovalRequiredEvent | ToolResponseRequiredEvent | McpAuthRequiredEvent;
|
|
211
|
+
interface TurnStreamData<TStreamEvent extends TurnStreamingEvent = TurnStreamingEvent> {
|
|
212
|
+
sequenceNumber: number;
|
|
213
|
+
event: TStreamEvent;
|
|
214
|
+
}
|
|
215
|
+
/** Session-level event item from `listEvents`. */
|
|
216
|
+
interface SessionEventItem {
|
|
217
|
+
turnId: string;
|
|
218
|
+
event: TurnCreatedEvent | TurnDoneEvent | TurnEvent;
|
|
219
|
+
}
|
|
220
|
+
type DeltaEvents = ModelMessageDeltaEvent;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* FE-owned AgentUIServer contract.
|
|
224
|
+
*
|
|
225
|
+
* Rule: only methods/fields the runtime or UI invokes.
|
|
226
|
+
* Hosts extend via `T extends Base` for system-specific extras.
|
|
227
|
+
* No dependency on truefoundry-gateway-sdk.
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
/** Model selector row. Host extends for apiModel, modelId, pricing, etc. */
|
|
231
|
+
interface ModelSelectorEntry {
|
|
232
|
+
name: string;
|
|
233
|
+
provider: string;
|
|
234
|
+
}
|
|
235
|
+
/** Skill selector row. Host extends for fqn, preload, etc. */
|
|
236
|
+
interface SkillSelectorEntry {
|
|
237
|
+
id: string;
|
|
238
|
+
name: string;
|
|
239
|
+
description?: string;
|
|
240
|
+
}
|
|
241
|
+
/** MCP connector selector row. Host extends for type, enableTools, url, etc. */
|
|
242
|
+
interface ConnectorSelectorEntry {
|
|
243
|
+
id: string;
|
|
244
|
+
name: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
}
|
|
247
|
+
/** Agent selector row — UI shows name only. Host extends for metadata. */
|
|
248
|
+
interface AgentSelectorEntry {
|
|
249
|
+
name: string;
|
|
250
|
+
}
|
|
251
|
+
type SearchAgentSelectorParams = {
|
|
252
|
+
query?: string;
|
|
253
|
+
limit?: number;
|
|
254
|
+
offset?: number;
|
|
255
|
+
};
|
|
256
|
+
/** Skill mount base written to AgentSpec.skills[]. Host extends for fqn, preload, etc. */
|
|
257
|
+
interface SkillMount {
|
|
258
|
+
id: string;
|
|
259
|
+
name: string;
|
|
260
|
+
}
|
|
261
|
+
/** MCP server mount base written to AgentSpec.mcpServers[]. Host extends for type, enableTools, etc. */
|
|
262
|
+
interface McpServerMount {
|
|
263
|
+
id: string;
|
|
264
|
+
name: string;
|
|
265
|
+
}
|
|
266
|
+
interface ModelParams {
|
|
267
|
+
maxTokens?: number;
|
|
268
|
+
reasoningEffort?: string;
|
|
269
|
+
}
|
|
270
|
+
interface Model {
|
|
271
|
+
name: string;
|
|
272
|
+
params?: ModelParams;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* SDK-owned agent definition — fields the FE reads/writes.
|
|
276
|
+
* Host adds additional fields via `TSpec extends AgentSpec`.
|
|
277
|
+
*/
|
|
278
|
+
interface AgentSpec {
|
|
279
|
+
model: Model;
|
|
280
|
+
skills?: SkillMount[];
|
|
281
|
+
mcpServers?: McpServerMount[];
|
|
282
|
+
instructions?: string;
|
|
283
|
+
messages?: unknown[];
|
|
284
|
+
variables?: Record<string, string>;
|
|
285
|
+
responseFormat?: unknown;
|
|
286
|
+
config?: unknown;
|
|
287
|
+
}
|
|
288
|
+
interface Session<TSpec extends AgentSpec = AgentSpec> {
|
|
289
|
+
id: string;
|
|
290
|
+
title?: string | null;
|
|
291
|
+
agentName?: string | null;
|
|
292
|
+
agentSpec?: TSpec;
|
|
293
|
+
/** true → mutable builder + updateSession(spec) allowed. */
|
|
294
|
+
isMutable: boolean;
|
|
295
|
+
createdAt: string;
|
|
296
|
+
updatedAt: string;
|
|
297
|
+
}
|
|
298
|
+
interface CreateSessionRequest<TSpec extends AgentSpec = AgentSpec> {
|
|
299
|
+
agentName?: string;
|
|
300
|
+
agentSpec?: TSpec;
|
|
301
|
+
title?: string;
|
|
302
|
+
}
|
|
303
|
+
interface UpdateSessionRequest<TSpec extends AgentSpec = AgentSpec> {
|
|
304
|
+
sessionId: string;
|
|
305
|
+
agentSpec?: TSpec;
|
|
306
|
+
title?: string;
|
|
307
|
+
}
|
|
308
|
+
interface ListResult<T> {
|
|
309
|
+
data: T[];
|
|
310
|
+
nextPageToken?: string;
|
|
311
|
+
}
|
|
312
|
+
type ListSessionsOrder = "asc" | "desc";
|
|
313
|
+
type PageParams = {
|
|
314
|
+
limit?: number;
|
|
315
|
+
order?: ListSessionsOrder;
|
|
316
|
+
pageToken?: string;
|
|
317
|
+
};
|
|
318
|
+
interface ListSessionsParams extends PageParams {
|
|
319
|
+
agentName?: string;
|
|
320
|
+
/** Host-specific filter (e.g. TFY startTimestamp). */
|
|
321
|
+
startTimestamp?: string;
|
|
322
|
+
}
|
|
323
|
+
type PreviousTurnIdInput = "auto" | string;
|
|
324
|
+
type UserMessageContent = string | Array<{
|
|
325
|
+
type: "text";
|
|
326
|
+
text: string;
|
|
327
|
+
} | {
|
|
328
|
+
type: "file";
|
|
329
|
+
name: string;
|
|
330
|
+
data: string;
|
|
331
|
+
}>;
|
|
332
|
+
interface UserMessage {
|
|
333
|
+
type: "user.message";
|
|
334
|
+
content: UserMessageContent;
|
|
335
|
+
}
|
|
336
|
+
type ApprovalDecision = {
|
|
337
|
+
status: "allow";
|
|
338
|
+
} | {
|
|
339
|
+
status: "deny";
|
|
340
|
+
reason?: string;
|
|
341
|
+
};
|
|
342
|
+
interface UserToolApprovalEvent {
|
|
343
|
+
type: "user.tool_approval";
|
|
344
|
+
threadId: string;
|
|
345
|
+
toolCallId: string;
|
|
346
|
+
approval: ApprovalDecision;
|
|
347
|
+
}
|
|
348
|
+
interface UserToolResponseEvent {
|
|
349
|
+
type: "user.tool_response";
|
|
350
|
+
threadId: string;
|
|
351
|
+
toolCallId: string;
|
|
352
|
+
content: string;
|
|
353
|
+
}
|
|
354
|
+
type TurnInputItem = UserMessage | UserToolApprovalEvent | UserToolResponseEvent;
|
|
355
|
+
type TurnStateRunning = {
|
|
356
|
+
status: "running";
|
|
357
|
+
};
|
|
358
|
+
type TurnStateDone = {
|
|
359
|
+
status: "done";
|
|
360
|
+
output?: unknown;
|
|
361
|
+
requiredActions?: ActionRequiredEvent[];
|
|
362
|
+
completedAt: string;
|
|
363
|
+
};
|
|
364
|
+
type TurnStateCancelled = {
|
|
365
|
+
status: "cancelled";
|
|
366
|
+
reason: string;
|
|
367
|
+
completedAt: string;
|
|
368
|
+
};
|
|
369
|
+
type TurnStateError = {
|
|
370
|
+
status: "error";
|
|
371
|
+
message: string;
|
|
372
|
+
completedAt: string;
|
|
373
|
+
};
|
|
374
|
+
type TurnState = TurnStateRunning | TurnStateDone | TurnStateCancelled | TurnStateError;
|
|
375
|
+
/** Plain turn DTO — no methods. */
|
|
376
|
+
interface Turn {
|
|
377
|
+
id: string;
|
|
378
|
+
sessionId: string;
|
|
379
|
+
previousTurnId?: string | null;
|
|
380
|
+
input?: TurnInputItem[];
|
|
381
|
+
state: TurnState;
|
|
382
|
+
createdAt: string;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Chat / session port — the runtime calls these.
|
|
386
|
+
*
|
|
387
|
+
* All session ops are flat (sessionId param). No gateway client dependency.
|
|
388
|
+
* `createTrueFoundryServer` is one possible implementation (TFY adapter).
|
|
389
|
+
*/
|
|
390
|
+
interface AgentChatServer<TSpec extends AgentSpec = AgentSpec, TSession extends Session<TSpec> = Session<TSpec>, TCreate extends CreateSessionRequest<TSpec> = CreateSessionRequest<TSpec>, TList extends ListSessionsParams = ListSessionsParams, TUpdate extends UpdateSessionRequest<TSpec> = UpdateSessionRequest<TSpec>, TTurn extends Turn = Turn> {
|
|
391
|
+
createSession(req: TCreate): Promise<TSession>;
|
|
392
|
+
listSessions(req?: TList): Promise<ListResult<TSession>>;
|
|
393
|
+
getSession(req: {
|
|
394
|
+
sessionId: string;
|
|
395
|
+
}): Promise<TSession>;
|
|
396
|
+
updateSession(req: TUpdate): Promise<TSession>;
|
|
397
|
+
prepareAndExecuteTurn(req: {
|
|
398
|
+
sessionId: string;
|
|
399
|
+
input?: TurnInputItem[];
|
|
400
|
+
previousTurnId?: PreviousTurnIdInput;
|
|
401
|
+
abortSignal?: AbortSignal;
|
|
402
|
+
headers?: Record<string, string>;
|
|
403
|
+
}): AsyncIterable<TurnStreamData>;
|
|
404
|
+
cancelSession(req: {
|
|
405
|
+
sessionId: string;
|
|
406
|
+
}): Promise<void>;
|
|
407
|
+
deleteSession?(req: {
|
|
408
|
+
sessionId: string;
|
|
409
|
+
}): Promise<void>;
|
|
410
|
+
listTurns(req: {
|
|
411
|
+
sessionId: string;
|
|
412
|
+
limit?: number;
|
|
413
|
+
pageToken?: string;
|
|
414
|
+
order?: ListSessionsOrder;
|
|
415
|
+
}): Promise<ListResult<TTurn>>;
|
|
416
|
+
getTurn(req: {
|
|
417
|
+
sessionId: string;
|
|
418
|
+
turnId: string;
|
|
419
|
+
}): Promise<TTurn>;
|
|
420
|
+
listEvents(req: {
|
|
421
|
+
sessionId: string;
|
|
422
|
+
pageToken?: string;
|
|
423
|
+
lastTurnId?: string;
|
|
424
|
+
limit?: number;
|
|
425
|
+
}): Promise<ListResult<SessionEventItem>>;
|
|
426
|
+
/** Optional per-turn event listing (hydrate in-flight turn content). */
|
|
427
|
+
listTurnEvents?(req: {
|
|
428
|
+
sessionId: string;
|
|
429
|
+
turnId: string;
|
|
430
|
+
limit?: number;
|
|
431
|
+
pageToken?: string;
|
|
432
|
+
order?: ListSessionsOrder;
|
|
433
|
+
}): Promise<ListResult<TurnEvent>>;
|
|
434
|
+
subscribeToTurn?(req: {
|
|
435
|
+
sessionId: string;
|
|
436
|
+
turnId: string;
|
|
437
|
+
afterSequenceNumber?: number;
|
|
438
|
+
abortSignal?: AbortSignal;
|
|
439
|
+
}): AsyncIterable<TurnStreamData>;
|
|
440
|
+
downloadSandboxFile?(sandboxId: string, req: {
|
|
441
|
+
path: string;
|
|
442
|
+
}): Promise<Blob>;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Builder catalog + persist port — atoms call these.
|
|
446
|
+
* Passed separately from the runtime's chat server.
|
|
447
|
+
*/
|
|
448
|
+
interface AgentBuilderServer<TSpec extends AgentSpec = AgentSpec, TModel extends ModelSelectorEntry = ModelSelectorEntry, TSkill extends SkillSelectorEntry = SkillSelectorEntry, TMcp extends ConnectorSelectorEntry = ConnectorSelectorEntry, TAgent extends AgentSelectorEntry = AgentSelectorEntry, TSave = unknown> {
|
|
449
|
+
getModels(): Promise<TModel[]>;
|
|
450
|
+
getSkills(): Promise<TSkill[]>;
|
|
451
|
+
getMcp(): Promise<TMcp[]>;
|
|
452
|
+
searchAgents(req?: SearchAgentSelectorParams): Promise<TAgent[]>;
|
|
453
|
+
saveAgent(req: {
|
|
454
|
+
agentName: string;
|
|
455
|
+
agentSpec: TSpec;
|
|
456
|
+
}): Promise<TSave>;
|
|
457
|
+
deleteAgent?(req: {
|
|
458
|
+
agentName: string;
|
|
459
|
+
}): Promise<void>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export type { AgentSpec as A, CreateSessionRequest as C, DeltaEvents as D, ListResult as L, McpAuthRequiredEvent as M, PreviousTurnIdInput as P, Session as S, TurnStreamingEvent as T, UserToolResponseEvent as U, AgentChatServer as a, TurnEvent as b, ThreadCreatedEvent as c, UserToolApprovalEvent as d, Turn as e, TurnInputItem as f, AgentBuilderServer as g, ListSessionsParams as h, ModelMessageEvent as i, SandboxCreatedEvent as j, SessionEventItem as k, ToolApprovalRequiredEvent as l, ToolCall as m, ToolResponseRequiredEvent as n, TurnState as o, TurnStateDone as p, TurnStreamData as q, UpdateSessionRequest as r, UserMessage as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truefoundry/assistant-ui-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6-rc.0",
|
|
4
4
|
"description": "TrueFoundry Gateway agent runtime adapter for assistant-ui",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"import": "./dist/index.js",
|
|
28
28
|
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./plugins/truefoundry-agent-server-adapter": {
|
|
31
|
+
"types": "./dist/plugins/truefoundry-agent-server-adapter/index.d.ts",
|
|
32
|
+
"import": "./dist/plugins/truefoundry-agent-server-adapter/index.js",
|
|
33
|
+
"default": "./dist/plugins/truefoundry-agent-server-adapter/index.js"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"main": "./dist/index.js",
|
|
@@ -55,6 +60,9 @@
|
|
|
55
60
|
"peerDependenciesMeta": {
|
|
56
61
|
"@types/react": {
|
|
57
62
|
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"truefoundry-gateway-sdk": {
|
|
65
|
+
"optional": true
|
|
58
66
|
}
|
|
59
67
|
},
|
|
60
68
|
"devDependencies": {
|
|
@@ -66,6 +74,6 @@
|
|
|
66
74
|
"truefoundry-gateway-sdk": "0.4.0-rc.5",
|
|
67
75
|
"tsup": "^8.5.0",
|
|
68
76
|
"typescript": "^5.9.3",
|
|
69
|
-
"vitest": "
|
|
77
|
+
"vitest": "4.1.9"
|
|
70
78
|
}
|
|
71
79
|
}
|
package/src/askUserQuestion.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ToolCall } from "
|
|
1
|
+
import type { ToolCall } from "./server/index.js";
|
|
2
2
|
|
|
3
3
|
export function isAskUserQuestionToolCall(
|
|
4
4
|
toolCall: Pick<ToolCall, "toolInfo">,
|
|
5
5
|
): boolean {
|
|
6
6
|
return (
|
|
7
|
-
toolCall.toolInfo
|
|
8
|
-
toolCall.toolInfo
|
|
7
|
+
toolCall.toolInfo?.type === "truefoundry-system" &&
|
|
8
|
+
toolCall.toolInfo?.name === "ask_user_question"
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -12,11 +12,11 @@ describe("user message branch helpers", () => {
|
|
|
12
12
|
expect(parseTurnIdFromMessageId("turn-abc-user")).toBe("turn-abc");
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it("resolveBranchPreviousTurnId returns
|
|
15
|
+
it("resolveBranchPreviousTurnId returns null for the first turn", () => {
|
|
16
16
|
const turns: SessionTurnRecord[] = [
|
|
17
17
|
{ id: "a", createdAt: "", state: { status: "done", requiredActions: [], completedAt: "" } },
|
|
18
18
|
];
|
|
19
|
-
expect(resolveBranchPreviousTurnId(turns, "a")).
|
|
19
|
+
expect(resolveBranchPreviousTurnId(turns, "a")).toBeNull();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it("resolveBranchPreviousTurnId returns the prior turn id", () => {
|
package/src/collectPending.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ThreadAssistantMessagePart, ThreadMessage } from "@assistant-ui/core";
|
|
2
|
-
import type { McpAuthRequiredEvent } from "
|
|
2
|
+
import type { McpAuthRequiredEvent } from "./server/index.js";
|
|
3
3
|
|
|
4
4
|
import { ROOT_THREAD_ID } from "./constants.js";
|
|
5
5
|
import type { TrueFoundryMessageCustomMetadata } from "./messageCustomMetadata.js";
|