@truefoundry/assistant-ui-runtime 0.1.10 → 0.1.13

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.
@@ -7,50 +7,66 @@
7
7
  */
8
8
 
9
9
  import type {
10
- ActionRequiredEvent,
11
- SessionEventItem,
12
- TurnEvent,
13
- TurnStreamData
10
+ ActionRequiredEvent,
11
+ SessionEventItem,
12
+ TurnEvent,
13
+ TurnStreamData
14
14
  } from "./events.js";
15
15
 
16
16
  // ---------------------------------------------------------------------------
17
17
  // Catalog — selector rows (SDK-minimal; host extends via generics)
18
18
  // ---------------------------------------------------------------------------
19
+ export interface ProviderEntry {
20
+ name: string;
21
+ logo?: string;
22
+ }
23
+
24
+ export interface ModelProperties {
25
+ reasoningEfforts?: string[];
26
+ }
19
27
 
20
28
  /** Model selector row. Host extends for apiModel, modelId, pricing, etc. */
21
- export interface ModelSelectorEntry {
22
- name: string;
23
- provider: string;
24
- reasoningEfforts?: string[];
29
+ export interface ModelSelectorEntry<
30
+ TProvider extends ProviderEntry = ProviderEntry,
31
+ TProperties extends ModelProperties = ModelProperties,
32
+ > {
33
+ name: string;
34
+ id: string;
35
+ provider: TProvider;
36
+ properties: TProperties;
25
37
  }
26
38
 
27
39
  /** Skill selector row. Host extends for fqn, preload, etc. */
28
40
  export interface SkillSelectorEntry {
29
- id: string;
30
- name: string;
31
- description?: string;
41
+ id: string;
42
+ name: string;
43
+ description?: string;
32
44
  }
33
45
 
34
46
  /** MCP connector selector row. Host extends for type, enableTools, url, etc. */
35
47
  export interface ConnectorSelectorEntry {
36
- id: string;
37
- name: string;
38
- description?: string;
48
+ id: string;
49
+ name: string;
50
+ description?: string;
51
+ /** When true, the connector must be authenticated before use. Omitted when the host does not report auth. */
52
+ requiresAuth?: boolean;
53
+ /** When true, the connector is already authenticated. Omitted when the host does not report auth. */
54
+ authenticated?: boolean;
39
55
  }
40
56
 
41
57
  /** Agent selector row. Host extends for metadata; `agentSpec` enables Edit. */
42
58
  export interface AgentSelectorEntry {
43
- name: string;
44
- /** Stable id when distinct from display `name`. Falls back to `name` when omitted. */
45
- agentId?: string;
46
- /** Published agent spec — required for Edit; optional for Try-only hosts. */
47
- agentSpec?: AgentSpec;
59
+ name: string;
60
+ /** Stable id when distinct from display `name`. Falls back to `name` when omitted. */
61
+ agentId?: string;
62
+ /** Published agent spec — required for Edit; optional for Try-only hosts. */
63
+ agentSpec?: AgentSpec;
48
64
  }
49
65
 
50
66
  export type SearchAgentSelectorParams = {
51
- query?: string;
52
- limit?: number;
53
- offset?: number;
67
+ query?: string;
68
+ limit?: number;
69
+ offset?: number;
54
70
  };
55
71
 
56
72
  // ---------------------------------------------------------------------------
@@ -58,19 +74,19 @@ export type SearchAgentSelectorParams = {
58
74
  // ---------------------------------------------------------------------------
59
75
 
60
76
  /**
61
- * Mounts written to AgentSpec.skills[] / AgentSpec.mcpServers[].
62
- *
63
- * These are opaque to the runtime — it stores and forwards them but never reads
64
- * a field, and the backend owns the shape (the gateway identifies a skill by
65
- * `fqn`, with no `id` or `name` anywhere). So the base constrains only that a
66
- * mount is an object; hosts intersect their concrete mount type over it, as
67
- * `TfySkillMount` / `TfyMcpServerMount` do in the gateway adapter.
68
- *
69
- * Naming a field here would not just be unread, it would be wrong: a base with
70
- * required fields rejects the backend's own payloads, and one with only optional
71
- * fields is a weak type, which TypeScript rejects for a source that shares no
72
- * property with it — the gateway's registry skill shares none.
73
- */
77
+ * Mounts written to AgentSpec.skills[] / AgentSpec.mcpServers[].
78
+ *
79
+ * These are opaque to the runtime — it stores and forwards them but never reads
80
+ * a field, and the backend owns the shape (the gateway identifies a skill by
81
+ * `fqn`, with no `id` or `name` anywhere). So the base constrains only that a
82
+ * mount is an object; hosts intersect their concrete mount type over it, as
83
+ * `TfySkillMount` / `TfyMcpServerMount` do in the gateway adapter.
84
+ *
85
+ * Naming a field here would not just be unread, it would be wrong: a base with
86
+ * required fields rejects the backend's own payloads, and one with only optional
87
+ * fields is a weak type, which TypeScript rejects for a source that shares no
88
+ * property with it — the gateway's registry skill shares none.
89
+ */
74
90
  export type SkillMount = object;
75
91
 
76
92
  export type McpServerMount = object;
@@ -80,30 +96,30 @@ export type McpServerMount = object;
80
96
  // ---------------------------------------------------------------------------
81
97
 
82
98
  export interface ModelParams {
83
- maxTokens?: number;
84
- reasoningEffort?: string;
99
+ maxTokens?: number;
100
+ reasoningEffort?: string;
85
101
  }
86
102
 
87
103
  export interface Model {
88
- name: string;
89
- params?: ModelParams;
104
+ name: string;
105
+ params?: ModelParams;
90
106
  }
91
107
 
92
108
  /**
93
- * SDK-owned agent definition — fields the FE reads/writes.
94
- * Host widens `model` / `skills` / `mcpServers` via type params, and adds
95
- * extra fields via `TSpec extends AgentSpec<...>`.
96
- */
109
+ * SDK-owned agent definition — fields the FE reads/writes.
110
+ * Host widens `model` / `skills` / `mcpServers` via type params, and adds
111
+ * extra fields via `TSpec extends AgentSpec<...>`.
112
+ */
97
113
  export interface AgentSpec<
98
- TModel extends Model = Model,
99
- TSkill extends SkillMount = SkillMount,
100
- TMcp extends McpServerMount = McpServerMount,
114
+ TModel extends Model = Model,
115
+ TSkill extends SkillMount = SkillMount,
116
+ TMcp extends McpServerMount = McpServerMount,
101
117
  > {
102
- model: TModel;
103
- skills?: TSkill[];
104
- mcpServers?: TMcp[];
105
- instructions?: string;
106
- variables?: Record<string, string>;
118
+ model: TModel;
119
+ skills?: TSkill[];
120
+ mcpServers?: TMcp[];
121
+ instructions?: string;
122
+ variables?: Record<string, string>;
107
123
  }
108
124
 
109
125
  // ---------------------------------------------------------------------------
@@ -111,26 +127,26 @@ export interface AgentSpec<
111
127
  // ---------------------------------------------------------------------------
112
128
 
113
129
  export interface Session<TSpec extends AgentSpec = AgentSpec> {
114
- id: string;
115
- title?: string | null;
116
- agentName?: string | null;
117
- agentSpec?: TSpec;
118
- /** true → mutable builder + updateSession(spec) allowed. */
119
- isMutable: boolean;
120
- createdAt: string;
121
- updatedAt: string;
130
+ id: string;
131
+ title?: string | null;
132
+ agentName?: string | null;
133
+ agentSpec?: TSpec;
134
+ /** true → mutable builder + updateSession(spec) allowed. */
135
+ isMutable: boolean;
136
+ createdAt: string;
137
+ updatedAt: string;
122
138
  }
123
139
 
124
140
  export interface CreateSessionRequest<TSpec extends AgentSpec = AgentSpec> {
125
- agentName?: string;
126
- agentSpec?: TSpec;
127
- title?: string;
141
+ agentName?: string;
142
+ agentSpec?: TSpec;
143
+ title?: string;
128
144
  }
129
145
 
130
146
  export interface UpdateSessionRequest<TSpec extends AgentSpec = AgentSpec> {
131
- sessionId: string;
132
- agentSpec?: TSpec;
133
- title?: string;
147
+ sessionId: string;
148
+ agentSpec?: TSpec;
149
+ title?: string;
134
150
  }
135
151
 
136
152
  // ---------------------------------------------------------------------------
@@ -138,98 +154,98 @@ export interface UpdateSessionRequest<TSpec extends AgentSpec = AgentSpec> {
138
154
  // ---------------------------------------------------------------------------
139
155
 
140
156
  export interface ListResult<T> {
141
- data: T[];
142
- nextPageToken?: string;
157
+ data: T[];
158
+ nextPageToken?: string;
143
159
  }
144
160
 
145
161
  export type ListSessionsOrder = "asc" | "desc";
146
162
 
147
163
  export type PageParams = {
148
- limit?: number;
149
- order?: ListSessionsOrder;
150
- pageToken?: string;
164
+ limit?: number;
165
+ order?: ListSessionsOrder;
166
+ pageToken?: string;
151
167
  };
152
168
 
153
169
  export interface ListSessionsParams extends PageParams {
154
- /** Host-owned agent identity filter. Hosts that key agents by name pass that name here. */
155
- agentId?: string;
156
- /** Host-specific filter (e.g. TFY startTimestamp). */
157
- startTimestamp?: string;
170
+ /** Host-owned agent identity filter. Hosts that key agents by name pass that name here. */
171
+ agentId?: string;
172
+ /** Host-specific filter (e.g. TFY startTimestamp). */
173
+ startTimestamp?: string;
158
174
  }
159
175
 
160
- export type PreviousTurnIdInput = "auto" | string;
176
+ export type PreviousTurnIdInput = "auto" | "none" | string;
161
177
 
162
178
  // ---------------------------------------------------------------------------
163
179
  // Turn input / state — what runtime sends and reads
164
180
  // ---------------------------------------------------------------------------
165
181
 
166
182
  export type UserMessageContent =
167
- | string
168
- | Array<{ type: "text"; text: string } | { type: "file"; name: string; data: string }>;
183
+ | string
184
+ | Array<{ type: "text"; text: string } | { type: "file"; name: string; data: string }>;
169
185
 
170
186
  export interface UserMessage {
171
- type: "user.message";
172
- content: UserMessageContent;
187
+ type: "user.message";
188
+ content: UserMessageContent;
173
189
  }
174
190
 
175
191
  export type ApprovalDecision =
176
- | { status: "allow" }
177
- | { status: "deny"; reason?: string };
192
+ | { status: "allow" }
193
+ | { status: "deny"; reason?: string };
178
194
 
179
195
  export interface UserToolApprovalEvent {
180
- type: "user.tool_approval";
181
- threadId: string;
182
- toolCallId: string;
183
- approval: ApprovalDecision;
196
+ type: "user.tool_approval";
197
+ threadId: string;
198
+ toolCallId: string;
199
+ approval: ApprovalDecision;
184
200
  }
185
201
 
186
202
  export interface UserToolResponseEvent {
187
- type: "user.tool_response";
188
- threadId: string;
189
- toolCallId: string;
190
- content: string;
203
+ type: "user.tool_response";
204
+ threadId: string;
205
+ toolCallId: string;
206
+ content: string;
191
207
  }
192
208
 
193
209
  export type TurnInputItem =
194
- | UserMessage
195
- | UserToolApprovalEvent
196
- | UserToolResponseEvent;
210
+ | UserMessage
211
+ | UserToolApprovalEvent
212
+ | UserToolResponseEvent;
197
213
 
198
214
  export type TurnStateRunning = { status: "running" };
199
215
 
200
216
  export type TurnStateDone = {
201
- status: "done";
202
- output?: unknown;
203
- requiredActions?: ActionRequiredEvent[];
204
- completedAt: string;
217
+ status: "done";
218
+ output?: unknown;
219
+ requiredActions?: ActionRequiredEvent[];
220
+ completedAt: string;
205
221
  };
206
222
 
207
223
  export type TurnStateCancelled = {
208
- status: "cancelled";
209
- reason: string;
210
- completedAt: string;
224
+ status: "cancelled";
225
+ reason: string;
226
+ completedAt: string;
211
227
  };
212
228
 
213
229
  export type TurnStateError = {
214
- status: "error";
215
- message: string;
216
- completedAt: string;
230
+ status: "error";
231
+ message: string;
232
+ completedAt: string;
217
233
  };
218
234
 
219
235
  export type TurnState =
220
- | TurnStateRunning
221
- | TurnStateDone
222
- | TurnStateCancelled
223
- | TurnStateError;
236
+ | TurnStateRunning
237
+ | TurnStateDone
238
+ | TurnStateCancelled
239
+ | TurnStateError;
224
240
 
225
241
  /** Plain turn DTO — no methods. */
226
242
  export interface Turn {
227
- id: string;
228
- sessionId: string;
229
- previousTurnId?: string | null;
230
- input?: TurnInputItem[];
231
- state: TurnState;
232
- createdAt: string;
243
+ id: string;
244
+ sessionId: string;
245
+ previousTurnId?: string | null;
246
+ input?: TurnInputItem[];
247
+ state: TurnState;
248
+ createdAt: string;
233
249
  }
234
250
 
235
251
  // ---------------------------------------------------------------------------
@@ -237,99 +253,115 @@ export interface Turn {
237
253
  // ---------------------------------------------------------------------------
238
254
 
239
255
  /**
240
- * Chat / session port — the runtime calls these.
241
- *
242
- * All session ops are flat (sessionId param). No gateway client dependency.
243
- * `createTrueFoundryServer` is one possible implementation (TFY adapter).
244
- */
256
+ * Chat / session port — the runtime calls these.
257
+ *
258
+ * All session ops are flat (sessionId param). No gateway client dependency.
259
+ * `createTrueFoundryServer` is one possible implementation (TFY adapter).
260
+ */
245
261
  export interface AgentChatServer<
246
- TSpec extends AgentSpec = AgentSpec,
247
- TSession extends Session<TSpec> = Session<TSpec>,
248
- TCreate extends CreateSessionRequest<TSpec> = CreateSessionRequest<TSpec>,
249
- TList extends ListSessionsParams = ListSessionsParams,
250
- TUpdate extends UpdateSessionRequest<TSpec> = UpdateSessionRequest<TSpec>,
251
- TTurn extends Turn = Turn,
262
+ TSpec extends AgentSpec = AgentSpec,
263
+ TSession extends Session<TSpec> = Session<TSpec>,
264
+ TCreate extends CreateSessionRequest<TSpec> = CreateSessionRequest<TSpec>,
265
+ TList extends ListSessionsParams = ListSessionsParams,
266
+ TUpdate extends UpdateSessionRequest<TSpec> = UpdateSessionRequest<TSpec>,
267
+ TTurn extends Turn = Turn,
252
268
  > {
253
- createSession(req: TCreate): Promise<TSession>;
254
- listSessions(req?: TList): Promise<ListResult<TSession>>;
255
- getSession(req: { sessionId: string }): Promise<TSession>;
256
- updateSession(req: TUpdate): Promise<TSession>;
257
-
258
- createTurn(req: {
259
- sessionId: string;
260
- input?: TurnInputItem[];
261
- previousTurnId?: PreviousTurnIdInput;
262
- abortSignal?: AbortSignal;
263
- headers?: Record<string, string>;
264
- }): AsyncIterable<TurnStreamData>;
265
-
266
- cancelSession(req: { sessionId: string }): Promise<void>;
267
- deleteSession?(req: { sessionId: string }): Promise<void>;
268
-
269
- listTurns(req: {
270
- sessionId: string;
271
- limit?: number;
272
- pageToken?: string;
273
- order?: ListSessionsOrder;
274
- }): Promise<ListResult<TTurn>>;
275
- getTurn(req: { sessionId: string; turnId: string }): Promise<TTurn>;
276
- listEvents(req: {
277
- sessionId: string;
278
- pageToken?: string;
279
- lastTurnId?: string;
280
- limit?: number;
281
- }): Promise<ListResult<SessionEventItem>>;
282
-
283
- /** Optional per-turn event listing (hydrate in-flight turn content). */
284
- listTurnEvents?(req: {
285
- sessionId: string;
286
- turnId: string;
287
- limit?: number;
288
- pageToken?: string;
289
- order?: ListSessionsOrder;
290
- }): Promise<ListResult<TurnEvent>>;
291
-
292
- subscribeToTurn?(req: {
293
- sessionId: string;
294
- turnId: string;
295
- afterSequenceNumber?: number;
296
- abortSignal?: AbortSignal;
297
- }): AsyncIterable<TurnStreamData>;
298
-
299
- /**
300
- * Reads a file the agent wrote inside its sandbox. Hosts whose download route is scoped to a
301
- * turn resolve the sandbox from `turnId` and ignore `sandboxId`; hosts addressing sandboxes
302
- * directly use `sandboxId`.
303
- */
304
- downloadSandboxFile?(req: {
305
- sessionId: string;
306
- turnId: string;
307
- sandboxId: string;
308
- path: string;
309
- }): Promise<Blob>;
269
+ createSession(req: TCreate): Promise<TSession>;
270
+ listSessions(req?: TList): Promise<ListResult<TSession>>;
271
+ getSession(req: { sessionId: string }): Promise<TSession>;
272
+ updateSession(req: TUpdate): Promise<TSession>;
273
+
274
+ createTurn(req: {
275
+ sessionId: string;
276
+ input?: TurnInputItem[];
277
+ previousTurnId?: PreviousTurnIdInput;
278
+ abortSignal?: AbortSignal;
279
+ headers?: Record<string, string>;
280
+ }): AsyncIterable<TurnStreamData>;
281
+
282
+ cancelSession(req: { sessionId: string }): Promise<void>;
283
+ deleteSession?(req: { sessionId: string }): Promise<void>;
284
+
285
+ listTurns(req: {
286
+ sessionId: string;
287
+ limit?: number;
288
+ pageToken?: string;
289
+ order?: ListSessionsOrder;
290
+ }): Promise<ListResult<TTurn>>;
291
+ getTurn(req: { sessionId: string; turnId: string }): Promise<TTurn>;
292
+ listEvents(req: {
293
+ sessionId: string;
294
+ pageToken?: string;
295
+ lastTurnId?: string;
296
+ limit?: number;
297
+ }): Promise<ListResult<SessionEventItem>>;
298
+
299
+ /** Optional per-turn event listing (hydrate in-flight turn content). */
300
+ listTurnEvents?(req: {
301
+ sessionId: string;
302
+ turnId: string;
303
+ limit?: number;
304
+ pageToken?: string;
305
+ order?: ListSessionsOrder;
306
+ }): Promise<ListResult<TurnEvent>>;
307
+
308
+ subscribeToTurn?(req: {
309
+ sessionId: string;
310
+ turnId: string;
311
+ afterSequenceNumber?: number;
312
+ abortSignal?: AbortSignal;
313
+ }): AsyncIterable<TurnStreamData>;
314
+
315
+ /**
316
+ * Reads a file the agent wrote inside its sandbox. Hosts whose download route is scoped to a
317
+ * turn resolve the sandbox from `turnId` and ignore `sandboxId`; hosts addressing sandboxes
318
+ * directly use `sandboxId`.
319
+ */
320
+ downloadSandboxFile?(req: {
321
+ sessionId: string;
322
+ turnId: string;
323
+ sandboxId: string;
324
+ path: string;
325
+ }): Promise<Blob>;
326
+ }
327
+
328
+ /** Request body for `AgentBuilderServer.saveAgent`. */
329
+ export interface SaveAgentRequest<TSpec extends AgentSpec = AgentSpec> {
330
+ agentName: string;
331
+ agentSpec: TSpec;
310
332
  }
311
333
 
312
334
  /**
313
- * Builder catalog + persist port — atoms call these.
314
- * Passed separately from the runtime's chat server.
335
+ * Builder feature flags — atoms gate sandbox / skill / settings surfaces on these.
315
336
  */
337
+ export interface AgentBuilderCapabilitiesResponse {
338
+ data: {
339
+ sandbox: { enabled: boolean };
340
+ skill: { enabled: boolean; reason?: string };
341
+ settings?: { enabled: boolean };
342
+ };
343
+ }
344
+
345
+ /**
346
+ * Builder catalog + persist port — atoms call these.
347
+ * Passed separately from the runtime's chat server.
348
+ */
316
349
  export interface AgentBuilderServer<
317
- TSpec extends AgentSpec = AgentSpec,
318
- TModel extends ModelSelectorEntry = ModelSelectorEntry,
319
- TSkill extends SkillSelectorEntry = SkillSelectorEntry,
320
- TMcp extends ConnectorSelectorEntry = ConnectorSelectorEntry,
321
- TAgent extends AgentSelectorEntry = AgentSelectorEntry,
322
- TSave = unknown,
350
+ TSpec extends AgentSpec = AgentSpec,
351
+ TModel extends ModelSelectorEntry = ModelSelectorEntry,
352
+ TSkill extends SkillSelectorEntry = SkillSelectorEntry,
353
+ TMcp extends ConnectorSelectorEntry = ConnectorSelectorEntry,
354
+ TAgent extends AgentSelectorEntry = AgentSelectorEntry,
355
+ TSave = unknown,
356
+ TCapabilities extends AgentBuilderCapabilitiesResponse = AgentBuilderCapabilitiesResponse,
323
357
  > {
324
- getModels(): Promise<TModel[]>;
325
- getSkills(): Promise<TSkill[]>;
326
- getMcp(): Promise<TMcp[]>;
327
- searchAgents(req?: SearchAgentSelectorParams): Promise<TAgent[]>;
328
- saveAgent(req: {
329
- agentName: string;
330
- agentSpec: TSpec;
331
- }): Promise<TSave>;
332
- deleteAgent?(req: { agentName: string }): Promise<void>;
358
+ getCapabilities(): Promise<TCapabilities>;
359
+ getModels(): Promise<TModel[]>;
360
+ getSkills(): Promise<TSkill[]>;
361
+ getMcp(): Promise<TMcp[]>;
362
+ searchAgents(req?: SearchAgentSelectorParams): Promise<TAgent[]>;
363
+ saveAgent(req: SaveAgentRequest<TSpec>): Promise<TSave>;
364
+ deleteAgent?(req: { agentName: string }): Promise<void>;
333
365
  }
334
366
 
335
367
  // ---------------------------------------------------------------------------
@@ -337,88 +369,90 @@ export interface AgentBuilderServer<
337
369
  // ---------------------------------------------------------------------------
338
370
 
339
371
  /**
340
- * Provider type id. Reserved literal: `"custom"` for user-defined providers;
341
- * any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
342
- *
343
- * Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
344
- * so this stays `string` and `"custom"` is a documented convention.
345
- */
372
+ * Provider type id. Reserved literal: `"custom"` for user-defined providers;
373
+ * any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
374
+ *
375
+ * Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
376
+ * so this stays `string` and `"custom"` is a documented convention.
377
+ */
346
378
  export type ProviderType = string;
347
379
 
348
380
  /**
349
- * Model row — form "Model ID" + "Display name".
350
- * Host extends for properties, etc.
351
- */
381
+ * Model row — form "Model ID" + "Display name".
382
+ * Host extends for properties, etc.
383
+ */
352
384
  export interface ModelEntry {
353
- id: string;
354
- name: string;
385
+ id: string;
386
+ name: string;
355
387
  }
356
388
 
357
389
  /**
358
- * Write config for create/update (custom form + catalog "Save key").
359
- * Host extends. `baseUrl` present iff `type === "custom"`.
360
- */
390
+ * Write config for create/update (custom form + catalog "Save key").
391
+ * Host extends. `baseUrl` present iff `type === "custom"`.
392
+ */
361
393
  export interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
362
- type: ProviderType;
363
- name: string;
364
- /** Present iff `type === "custom"`. */
365
- baseUrl?: string;
366
- apiKey: string;
367
- models: TModel[];
394
+ type: ProviderType;
395
+ name: string;
396
+ /** Present iff `type === "custom"`. */
397
+ baseUrl?: string;
398
+ apiKey: string;
399
+ models: TModel[];
368
400
  }
369
401
 
370
402
  /**
371
- * Configured provider card (list/read). No raw `apiKey`.
372
- * Host extends for apiKeySet, timestamps, etc.
373
- */
403
+ * Configured provider card (list/read). No raw `apiKey`.
404
+ * Host extends for apiKeySet, timestamps, etc.
405
+ */
374
406
  export interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
375
- id: string;
376
- type: ProviderType;
377
- name: string;
378
- /** Present iff `type === "custom"`. */
379
- baseUrl?: string;
380
- models: TModel[];
407
+ id: string;
408
+ type: ProviderType;
409
+ name: string;
410
+ /** Present iff `type === "custom"`. */
411
+ baseUrl?: string;
412
+ models: TModel[];
381
413
  }
382
414
 
383
415
  /**
384
- * Discovery-only catalog provider (AVAILABLE list).
385
- * `type` must not be `"custom"` — custom providers use the custom form.
386
- * Host extends for richer model rows.
387
- */
416
+ * Discovery-only catalog provider (AVAILABLE list).
417
+ * `type` must not be `"custom"` — custom providers use the custom form.
418
+ * Host extends for richer model rows.
419
+ */
388
420
  export interface ModelProviderCatalogEntry<TModel extends ModelEntry = ModelEntry> {
389
- type: ProviderType;
390
- name: string;
391
- models: TModel[];
421
+ type: ProviderType;
422
+ name: string;
423
+ models: TModel[];
424
+ supportedReasoningEfforts?: string[];
425
+ logo?: string;
392
426
  }
393
427
 
394
428
  /** Create — no `id`; server assigns it. Catalog path = entry + apiKey. */
395
429
  export type CreateModelProviderRequest<TModel extends ModelEntry = ModelEntry> =
396
- ModelProviderConfigBase<TModel>;
430
+ ModelProviderConfigBase<TModel>;
397
431
 
398
432
  /** Update — `id` required. */
399
433
  export type UpdateModelProviderRequest<TModel extends ModelEntry = ModelEntry> =
400
- ModelProviderConfigBase<TModel> & { id: string };
434
+ ModelProviderConfigBase<TModel> & { id: string };
401
435
 
402
436
  export interface ModelCatalogServer<
403
- TModel extends ModelEntry = ModelEntry,
404
- TProvider extends ModelProviderBase<TModel> = ModelProviderBase<TModel>,
405
- TCatalogProvider extends ModelProviderCatalogEntry<TModel> = ModelProviderCatalogEntry<TModel>,
406
- TCreate extends CreateModelProviderRequest<TModel> = CreateModelProviderRequest<TModel>,
407
- TUpdate extends UpdateModelProviderRequest<TModel> = UpdateModelProviderRequest<TModel>,
437
+ TModel extends ModelEntry = ModelEntry,
438
+ TProvider extends ModelProviderBase<TModel> = ModelProviderBase<TModel>,
439
+ TCatalogProvider extends ModelProviderCatalogEntry<TModel> = ModelProviderCatalogEntry<TModel>,
440
+ TCreate extends CreateModelProviderRequest<TModel> = CreateModelProviderRequest<TModel>,
441
+ TUpdate extends UpdateModelProviderRequest<TModel> = UpdateModelProviderRequest<TModel>,
408
442
  > {
409
- getModelProviderCatalog(): Promise<TCatalogProvider[]>;
410
- listModelProviders(): Promise<TProvider[]>;
411
- createModelProvider(req: TCreate): Promise<TProvider>;
412
- /** Full replace update keyed by provider `id`. */
413
- updateModelProvider(req: TUpdate): Promise<TProvider>;
414
- deleteModelProvider?(req: { id: string }): Promise<void>;
443
+ getModelProviderCatalog(): Promise<TCatalogProvider[]>;
444
+ listModelProviders(): Promise<TProvider[]>;
445
+ createModelProvider(req: TCreate): Promise<TProvider>;
446
+ /** Full replace update keyed by provider `id`. */
447
+ updateModelProvider(req: TUpdate): Promise<TProvider>;
448
+ deleteModelProvider?(req: { id: string }): Promise<void>;
415
449
  }
416
450
 
417
451
  /** Tool row on a connector detail. Host extends for schemas, etc. */
418
452
  export interface ToolBase {
419
- id: string;
420
- name: string;
421
- description: string;
453
+ id: string;
454
+ name: string;
455
+ description: string;
422
456
  }
423
457
 
424
458
  /** Strict auth type id. Hosts widen branches via intersection + re-union. */
@@ -427,105 +461,121 @@ export type ConnectorAuthType = "dcr" | "header" | "none";
427
461
  // Write (create/update) — export branches so hosts can intersect extras
428
462
  export type ConnectorAuthOAuth = { type: "dcr"; authUrl?: string };
429
463
  export type ConnectorAuthApiKey = {
430
- type: "header";
431
- apiKey?: string;
432
- headerName?: string;
464
+ type: "header";
465
+ apiKey?: string;
466
+ headerName?: string;
433
467
  };
434
468
  export type ConnectorAuthNone = { type: "none" };
435
469
  export type ConnectorAuth =
436
- | ConnectorAuthOAuth
437
- | ConnectorAuthApiKey
438
- | ConnectorAuthNone;
470
+ | ConnectorAuthOAuth
471
+ | ConnectorAuthApiKey
472
+ | ConnectorAuthNone;
439
473
 
440
- // Public (list/detail) — no secrets; dcr requires authUrl
441
- export type ConnectorAuthPublicOAuth = { type: "dcr"; authUrl: string };
474
+ // Public (list/detail) — no secrets
475
+ export type ConnectorAuthPublicOAuth = { type: "dcr"; authUrl?: string };
442
476
  export type ConnectorAuthPublicApiKey = {
443
- type: "header";
444
- headerName?: string;
477
+ type: "header";
478
+ headerName?: string;
445
479
  };
446
480
  export type ConnectorAuthPublicNone = { type: "none" };
447
481
  export type ConnectorAuthPublic =
448
- | ConnectorAuthPublicOAuth
449
- | ConnectorAuthPublicApiKey
450
- | ConnectorAuthPublicNone;
482
+ | ConnectorAuthPublicOAuth
483
+ | ConnectorAuthPublicApiKey
484
+ | ConnectorAuthPublicNone;
451
485
 
452
486
  /**
453
- * MCP / connector create-edit config. Host extends for extra fields, etc.
454
- */
487
+ * MCP / connector create-edit config. Host extends for extra fields, etc.
488
+ */
455
489
  export interface ConnectorConfigBase<
456
- TAuth extends ConnectorAuth = ConnectorAuth,
490
+ TAuth extends ConnectorAuth = ConnectorAuth,
457
491
  > {
458
- name: string;
459
- url: string;
460
- auth: TAuth;
492
+ name: string;
493
+ url: string;
494
+ auth: TAuth;
461
495
  }
462
496
 
463
497
  /**
464
- * Connected connector row (settings/connectors). No raw `apiKey`.
498
+ * Connected connector row (settings/connectors). No raw `apiKey` or tools.
499
+ * Tools are fetched separately with `getToolsByConnectorId`.
465
500
  * Host extends.
466
501
  */
467
502
  export interface ConnectorBase<
468
- TTool extends ToolBase = ToolBase,
469
- TAuth extends ConnectorAuthPublic = ConnectorAuthPublic,
503
+ TAuth extends ConnectorAuthPublic = ConnectorAuthPublic,
470
504
  > {
471
- id: string;
472
- name: string;
473
- description: string;
474
- url: string;
475
- auth: TAuth;
476
- /** When true, UI should not show Disconnect. */
477
- requiresAuth: boolean;
478
- authenticated: boolean;
479
- tools: TTool[];
505
+ id: string;
506
+ name: string;
507
+ description: string;
508
+ url: string;
509
+ auth: TAuth;
510
+ /** When true, UI should not show Disconnect. */
511
+ requiresAuth: boolean;
512
+ authenticated: boolean;
480
513
  }
481
514
 
482
515
  /** Discovery catalog entry for "+ Add MCP server". Host extends. */
483
516
  export interface ConnectorCatalogEntry<
484
- TAuth extends ConnectorAuthPublic = ConnectorAuthPublic,
517
+ TAuth extends ConnectorAuthPublic = ConnectorAuthPublic,
485
518
  > {
486
- id: string;
487
- name: string;
488
- description?: string;
489
- url: string;
490
- auth: TAuth;
519
+ id: string;
520
+ name: string;
521
+ description?: string;
522
+ url: string;
523
+ auth: TAuth;
524
+ logo?: string;
491
525
  }
492
526
 
493
527
  /** Create connector — no `id`; server assigns it. Host extends. */
494
528
  export type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> =
495
- ConnectorConfigBase<TAuth>;
529
+ ConnectorConfigBase<TAuth>;
496
530
 
497
531
  /** Update connector — `id` required. Host extends. */
498
532
  export type UpdateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> =
499
- ConnectorConfigBase<TAuth> & { id: string };
533
+ ConnectorConfigBase<TAuth> & { id: string };
534
+
535
+ export interface AuthenticateConnectorRequest {
536
+ id: string;
537
+ /** OAuth callback page owned by the host application. */
538
+ redirectURL?: string;
539
+ }
540
+
541
+ export interface ConnectorAuthenticationResult<
542
+ TConnector extends ConnectorBase = ConnectorBase,
543
+ > {
544
+ connector?: TConnector;
545
+ status?: string;
546
+ authorization_endpoint?: string | undefined;
547
+ }
500
548
 
501
549
  export interface ConnectorCatalogServer<
502
- TTool extends ToolBase = ToolBase,
503
- TAuthWrite extends ConnectorAuth = ConnectorAuth,
504
- TAuthPublic extends ConnectorAuthPublic = ConnectorAuthPublic,
505
- TConnector extends ConnectorBase<TTool, TAuthPublic> = ConnectorBase<
506
- TTool,
507
- TAuthPublic
508
- >,
509
- TCatalogEntry extends ConnectorCatalogEntry<TAuthPublic> =
510
- ConnectorCatalogEntry<TAuthPublic>,
511
- TCreate extends CreateConnectorRequest<TAuthWrite> =
512
- CreateConnectorRequest<TAuthWrite>,
513
- TUpdate extends UpdateConnectorRequest<TAuthWrite> =
514
- UpdateConnectorRequest<TAuthWrite>,
550
+ TTool extends ToolBase = ToolBase,
551
+ TAuthWrite extends ConnectorAuth = ConnectorAuth,
552
+ TAuthPublic extends ConnectorAuthPublic = ConnectorAuthPublic,
553
+ TConnector extends ConnectorBase<TAuthPublic> = ConnectorBase<TAuthPublic>,
554
+ TCatalogEntry extends ConnectorCatalogEntry<TAuthPublic> =
555
+ ConnectorCatalogEntry<TAuthPublic>,
556
+ TCreate extends CreateConnectorRequest<TAuthWrite> =
557
+ CreateConnectorRequest<TAuthWrite>,
558
+ TUpdate extends UpdateConnectorRequest<TAuthWrite> =
559
+ UpdateConnectorRequest<TAuthWrite>,
515
560
  > {
516
- getConnectorCatalog(): Promise<TCatalogEntry[]>;
517
- listConnectors(req?: { query?: string }): Promise<TConnector[]>;
518
- createConnector(req: TCreate): Promise<TConnector>;
519
- /** Full replace update keyed by connector `id`. */
520
- updateConnector(req: TUpdate): Promise<TConnector>;
521
- /**
522
- * Start connector auth (e.g. OAuth).
523
- * For oauth, the returned connector's `auth.authUrl` is the authorize URL.
524
- */
525
- authenticateConnector(req: { id: string }): Promise<TConnector>;
526
- /** Clear connector auth. */
527
- disconnectConnector(req: { id: string }): Promise<TConnector>;
528
- deleteConnector?(req: { id: string }): Promise<void>;
561
+ getConnectorCatalog(): Promise<TCatalogEntry[]>;
562
+ getConnector(req: { id: string }): Promise<TConnector>;
563
+ listConnectors(req?: { query?: string }): Promise<TConnector[]>;
564
+ getToolsByConnectorId(req: { id: string }): Promise<TTool[]>;
565
+ createConnector(req: TCreate): Promise<TConnector>;
566
+ /** Full replace update keyed by connector `id`. */
567
+ updateConnector(req: TUpdate): Promise<TConnector>;
568
+ /**
569
+ * Start connector auth (e.g. OAuth).
570
+ * May return a connector (already authenticated / with `auth.authUrl`) or a
571
+ * result carrying `authorization_endpoint` for the popup flow.
572
+ */
573
+ authenticateConnector(
574
+ req: AuthenticateConnectorRequest,
575
+ ): Promise<TConnector | ConnectorAuthenticationResult<TConnector>>;
576
+ /** Clear connector auth. */
577
+ disconnectConnector(req: { id: string }): Promise<TConnector>;
578
+ deleteConnector?(req: { id: string }): Promise<void>;
529
579
  }
530
580
 
531
581
  // ---------------------------------------------------------------------------
@@ -534,14 +584,14 @@ export interface ConnectorCatalogServer<
534
584
 
535
585
  /** Skill row shown in settings/skills (list + delete). Host extends for fqn, etc. */
536
586
  export interface SkillBase {
537
- id: string;
538
- name: string;
539
- description: string;
587
+ id: string;
588
+ name: string;
589
+ description: string;
540
590
  }
541
591
 
542
592
  export interface RegistrySkill extends SkillBase {
543
- /** `SkillCatalogEntry.id` this skill was created from. */
544
- catalogId: string;
593
+ /** `SkillCatalogEntry.id` this skill was created from. */
594
+ catalogId: string;
545
595
  }
546
596
 
547
597
  export interface GithubSkill extends SkillBase {}
@@ -550,124 +600,146 @@ export type DefinedSkill = RegistrySkill | GithubSkill;
550
600
 
551
601
  /** Git source fields shared by catalog entries and create requests. */
552
602
  export interface SkillConfigBase {
553
- name: string;
554
- description: string;
555
- repoURL: string;
556
- path: string;
557
- ref: string;
603
+ name: string;
604
+ description: string;
605
+ repoURL: string;
606
+ path: string;
607
+ ref: string;
558
608
  }
559
609
 
560
610
  export interface SkillCatalogEntry extends SkillConfigBase {
561
- id: string;
611
+ id: string;
562
612
  }
563
613
 
564
614
  /** Create-skill base. Hosts may intersect extra fields and re-union. */
565
615
  export interface CreateSkillRequestBase extends SkillConfigBase {}
566
616
 
567
617
  export interface SelectRegistrySkillRequest extends CreateSkillRequestBase {
568
- /** `SkillCatalogEntry.id`, persisted so the created skill links back to it. */
569
- catalogId: string;
618
+ /** `SkillCatalogEntry.id`, persisted so the created skill links back to it. */
619
+ catalogId: string;
570
620
  }
571
621
 
572
622
  export interface ImportGithubSkillRequest extends CreateSkillRequestBase {}
573
623
 
574
624
  export type CreateSkillRequest =
575
- | SelectRegistrySkillRequest
576
- | ImportGithubSkillRequest;
625
+ | SelectRegistrySkillRequest
626
+ | ImportGithubSkillRequest;
577
627
 
578
628
  export interface SkillCatalogServer<
579
- TSkill extends SkillBase = SkillBase,
580
- TCatalogEntry extends SkillCatalogEntry = SkillCatalogEntry,
581
- TCreate extends CreateSkillRequest = CreateSkillRequest,
629
+ TSkill extends SkillBase = SkillBase,
630
+ TCatalogEntry extends SkillCatalogEntry = SkillCatalogEntry,
631
+ TCreate extends CreateSkillRequest = CreateSkillRequest,
582
632
  > {
583
- getSkillCatalog(): Promise<TCatalogEntry[]>;
584
- listSkills(req?: { query?: string }): Promise<TSkill[]>;
585
- createSkill(req: TCreate): Promise<TSkill>;
586
- deleteSkill?(req: { id: string }): Promise<void>;
633
+ getSkillCatalog(): Promise<TCatalogEntry[]>;
634
+ listSkills(req?: { query?: string }): Promise<TSkill[]>;
635
+ createSkill(req: TCreate): Promise<TSkill>;
636
+ deleteSkill?(req: { id: string }): Promise<void>;
587
637
  }
588
638
 
589
639
  // ---------------------------------------------------------------------------
590
- // Sandboxes catalog — public rows omit credentials; writes accept them
640
+ // Sandbox providers catalog — public rows omit credentials; writes accept them
591
641
  // ---------------------------------------------------------------------------
592
642
 
593
- /** Mutable sandbox settings shared by catalog rows, create, and update. */
643
+ /** Mutable sandbox provider settings shared by catalog rows, create, and update. */
594
644
  export interface SandboxConfig {
595
- snapshotName: string;
596
- execTimeoutMs: number;
597
- autoStopIntervalInMinutes: number;
598
- autoArchiveIntervalInMinutes: number;
599
- autoDeleteIntervalInMinutes: number;
645
+ snapshotName: string;
646
+ execTimeoutMs: number;
647
+ autoStopIntervalInMinutes: number;
648
+ autoArchiveIntervalInMinutes: number;
649
+ autoDeleteIntervalInMinutes: number;
600
650
  }
601
651
 
602
652
  export interface SandboxCatalogEntry extends SandboxConfig {
603
- id: string;
604
- name: string;
605
- type: string;
653
+ id: string;
654
+ name: string;
655
+ type: string;
606
656
  }
607
657
 
608
- export interface SandboxBase {
609
- id: string;
610
- name: string;
611
- catalogId: string;
612
- isConnected: boolean;
658
+ /**
659
+ * Connected sandbox provider row (settings/sandboxes). No raw `apiKey`.
660
+ * Includes last-saved config so update forms can show previous values.
661
+ */
662
+ export interface SandboxBase extends SandboxConfig {
663
+ id: string;
664
+ name: string;
665
+ catalogId: string;
666
+ isConnected: boolean;
613
667
  }
614
668
 
615
669
  export interface CreateSandboxRequest extends SandboxConfig {
616
- /** `SandboxCatalogEntry.id` used to create this sandbox. */
617
- catalogId: string;
618
- name: string;
619
- type: string;
620
- apiKey: string;
670
+ /** `SandboxCatalogEntry.id` used to create this sandbox provider. */
671
+ catalogId: string;
672
+ name: string;
673
+ type: string;
674
+ apiKey: string;
621
675
  }
622
676
 
623
677
  export interface UpdateSandboxRequest extends SandboxConfig {
624
- id: string;
625
- apiKey: string;
678
+ id: string;
679
+ /** Omit to keep the existing key; send a value to rotate. */
680
+ apiKey?: string;
626
681
  }
627
682
 
683
+ /** Host-facing aliases (trueforge-ui public names). */
684
+ export type SandboxProviderConfig = SandboxConfig;
685
+ export type SandboxProviderCatalogEntry = SandboxCatalogEntry;
686
+ export type SandboxProviderBase = SandboxBase;
687
+ export type CreateSandboxProviderRequest = CreateSandboxRequest;
688
+ export type UpdateSandboxProviderRequest = UpdateSandboxRequest;
689
+
628
690
  export interface SandboxCatalogServer<
629
- TSandbox extends SandboxBase = SandboxBase,
630
- TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry,
631
- TCreate extends CreateSandboxRequest = CreateSandboxRequest,
632
- TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest,
691
+ TProvider extends SandboxBase = SandboxBase,
692
+ TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry,
693
+ TCreate extends CreateSandboxRequest = CreateSandboxRequest,
694
+ TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest,
633
695
  > {
634
- getSandboxCatalog(): Promise<TCatalogEntry[]>;
635
- listSandboxes(req?: { query?: string }): Promise<TSandbox[]>;
636
- createSandbox(req: TCreate): Promise<TSandbox>;
637
- updateSandbox(req: TUpdate): Promise<TSandbox>;
638
- deleteSandbox(req: { id: string }): Promise<void>;
696
+ getSandboxProviderCatalog(): Promise<TCatalogEntry[]>;
697
+ listSandboxProviders(req?: { query?: string }): Promise<TProvider[]>;
698
+ createSandboxProvider(req: TCreate): Promise<TProvider>;
699
+ updateSandboxProvider(req: TUpdate): Promise<TProvider>;
700
+ deleteSandboxProvider?(req: { id: string }): Promise<void>;
639
701
  }
640
702
 
703
+ /** Host-facing selector / compose aliases (trueforge-ui public names). */
704
+ export type ModelSelection = ModelSelectorEntry;
705
+ export type AgentSkill = SkillSelectorEntry;
706
+ export type ConnectorState = ConnectorSelectorEntry;
707
+ export type AgentLibraryEntry = AgentSelectorEntry;
708
+ export type SearchAgentsParams = SearchAgentSelectorParams;
709
+
641
710
  /**
642
- * Settings management aggregate — modelCatalog + connectorCatalog + optional
643
- * skill and sandbox catalogs.
644
- * Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
645
- */
711
+ * Settings management aggregate — modelCatalog + connectorCatalog + optional
712
+ * skill and sandbox catalogs.
713
+ * Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
714
+ */
646
715
  export interface CatalogServer<
647
- TModelCatalog extends ModelCatalogServer = ModelCatalogServer,
648
- TConnectorCatalog extends ConnectorCatalogServer = ConnectorCatalogServer,
649
- TSkillCatalog extends SkillCatalogServer = SkillCatalogServer,
650
- TSandboxCatalog extends SandboxCatalogServer = SandboxCatalogServer,
716
+ TModelCatalog extends ModelCatalogServer = ModelCatalogServer,
717
+ TConnectorCatalog extends ConnectorCatalogServer = ConnectorCatalogServer,
718
+ TSkillCatalog extends SkillCatalogServer = SkillCatalogServer,
719
+ TSandboxCatalog extends SandboxCatalogServer = SandboxCatalogServer,
651
720
  > {
652
- modelCatalog: TModelCatalog;
653
- connectorCatalog: TConnectorCatalog;
654
- /** Optional — omit when the host has no skills settings surface. */
655
- skillCatalog?: TSkillCatalog;
656
- /** Optional — omit when the host has no sandboxes settings surface. */
657
- sandboxCatalog?: TSandboxCatalog;
721
+ modelCatalog: TModelCatalog;
722
+ connectorCatalog: TConnectorCatalog;
723
+ /** Optional — omit when the host has no skills settings surface. */
724
+ skillCatalog?: TSkillCatalog;
725
+ /** Optional — omit when the host has no sandboxes settings surface. */
726
+ sandboxCatalog?: TSandboxCatalog;
658
727
  }
659
728
 
660
729
  /**
661
730
  * Composed host port: chat + builder + optional settings catalog.
662
- * Agent-ui's `AgentUIServer` mirrors this shape; named differently here to
663
- * avoid colliding with that package's local type name.
664
731
  *
665
732
  * `catalog` is optional — if the host passes it, settings UI can call
666
733
  * `useCatalogServer()` / show modelCatalog, connectorCatalog, and skillCatalog;
667
734
  * if omitted, those surfaces stay hidden.
735
+ *
736
+ * trueforge-ui re-exports this as `AgentUIServer`.
668
737
  */
669
738
  export type AgentUIServerPort<
670
- TChat extends AgentChatServer = AgentChatServer,
671
- TBuilder extends AgentBuilderServer = AgentBuilderServer,
672
- TCatalog extends CatalogServer = CatalogServer,
739
+ TChat extends AgentChatServer = AgentChatServer,
740
+ TBuilder extends AgentBuilderServer = AgentBuilderServer,
741
+ TCatalog extends CatalogServer = CatalogServer,
673
742
  > = TChat & TBuilder & { catalog?: TCatalog };
743
+
744
+ /** Host-facing alias used by trueforge-ui. */
745
+ export type AgentUIServer = AgentUIServerPort;