@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.
- package/CHANGELOG.md +40 -0
- package/dist/{chunk-6ZOGBD7E.js → chunk-XYGEKRA2.js} +12 -5
- package/dist/chunk-XYGEKRA2.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/plugins/truefoundry-agent-server-adapter/index.d.ts +3 -4
- package/dist/plugins/truefoundry-agent-server-adapter/index.js +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/{types-Bb8Kaf1h.d.ts → types-BE-F3vCD.d.ts} +150 -81
- package/package.json +1 -1
- package/src/convertTurnMessages.test.ts +123 -0
- package/src/convertTurnMessages.ts +8 -2
- package/src/draft/truefoundryDraftThreadListAdapter.test.ts +3 -2
- package/src/index.ts +29 -0
- package/src/plugins/truefoundry-agent-server-adapter/cp.test.ts +9 -6
- package/src/plugins/truefoundry-agent-server-adapter/cp.ts +3 -4
- package/src/plugins/truefoundry-agent-server-adapter/createTrueFoundryAgentUIServer.ts +7 -0
- package/src/plugins/truefoundry-agent-server-adapter/types.ts +2 -2
- package/src/server/index.ts +17 -0
- package/src/server/types.ts +458 -386
- package/src/sessionThreadMetadata.ts +5 -2
- package/src/truefoundryOwnedSessionsThreadListAdapter.test.ts +2 -1
- package/src/truefoundryThreadListAdapter.test.ts +1 -1
- package/dist/chunk-6ZOGBD7E.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AgentSessionClient } from 'truefoundry-gateway-sdk/agents';
|
|
2
2
|
import { PrivateAgentSessionClient } from 'truefoundry-gateway-sdk/agents/private';
|
|
3
|
-
import { A as AgentSpec,
|
|
3
|
+
import { A as AgentSpec, K as CreateSessionRequest, W as ListSessionsParams, S as Session, d as Turn, az as TurnState, a as AgentChatServer, aH as UpdateSessionRequest, i as AgentSelectorEntry, E as ConnectorSelectorEntry, a6 as ModelSelectorEntry, au as SkillSelectorEntry, g as AgentBuilderServer } from '../../types-BE-F3vCD.js';
|
|
4
4
|
import { TruefoundryGatewayApi } from 'truefoundry-gateway-sdk';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* TrueFoundry-specific type extensions over the runtime's generic bases.
|
|
8
8
|
*
|
|
9
|
-
* The runtime defines
|
|
10
|
-
*
|
|
9
|
+
* The runtime defines opaque mount bases (`SkillMount` / `McpServerMount` =
|
|
10
|
+
* `object`) that hosts intersect with gateway shapes via generics.
|
|
11
11
|
*
|
|
12
12
|
* This file builds the concrete TrueFoundry types by:
|
|
13
13
|
* - Importing the runtime's AgentSpec as the base to extend.
|
|
@@ -121,7 +121,6 @@ interface TfyModelSelectorEntry extends ModelSelectorEntry {
|
|
|
121
121
|
apiModel: string;
|
|
122
122
|
modelId: string;
|
|
123
123
|
providerAccount?: string;
|
|
124
|
-
id?: string;
|
|
125
124
|
}
|
|
126
125
|
interface TfySkillSelectorEntry extends SkillSelectorEntry {
|
|
127
126
|
/** Version FQN — mount as RegisteredSkillMount.fqn. */
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { aC as TurnStreamingEvent, aJ as DeltaEvents, T as TurnEvent } from '../types-BE-F3vCD.js';
|
|
2
|
+
export { aK as ActionRequiredEvent, f as AgentBuilderCapabilitiesResponse, g as AgentBuilderServer, a as AgentChatServer, aL as AgentInfo, h as AgentLibraryEntry, aM as AgentParent, i as AgentSelectorEntry, j as AgentSkill, A as AgentSpec, k as AgentUIServer, l as AgentUIServerPort, m as ApprovalDecision, n as AuthenticateConnectorRequest, C as CatalogServer, aN as ChunkDeltaToolCall, o as ConnectorAuth, p as ConnectorAuthApiKey, q as ConnectorAuthNone, r as ConnectorAuthOAuth, s as ConnectorAuthPublic, t as ConnectorAuthPublicApiKey, u as ConnectorAuthPublicNone, v as ConnectorAuthPublicOAuth, w as ConnectorAuthType, x as ConnectorAuthenticationResult, y as ConnectorBase, z as ConnectorCatalogEntry, B as ConnectorCatalogServer, D as ConnectorConfigBase, E as ConnectorSelectorEntry, F as ConnectorState, G as CreateConnectorRequest, H as CreateModelProviderRequest, I as CreateSandboxProviderRequest, J as CreateSandboxRequest, K as CreateSessionRequest, L as CreateSkillRequest, N as CreateSkillRequestBase, O as DefinedSkill, P as GithubSkill, Q as ImportGithubSkillRequest, R as ListResult, V as ListSessionsOrder, W as ListSessionsParams, M as McpAuthRequiredEvent, aO as McpInitializeEvent, aP as McpServerAuthInfo, X as McpServerMount, Y as Model, Z as ModelCatalogServer, _ as ModelEntry, aQ as ModelMessageContentPart, aR as ModelMessageDeltaEvent, $ as ModelMessageEvent, a0 as ModelParams, a1 as ModelProperties, a2 as ModelProviderBase, a3 as ModelProviderCatalogEntry, a4 as ModelProviderConfigBase, a5 as ModelSelection, a6 as ModelSelectorEntry, a7 as PageParams, a8 as PreviousTurnIdInput, a9 as ProviderEntry, aa as ProviderType, ab as RegistrySkill, ac as SandboxBase, ad as SandboxCatalogEntry, ae as SandboxCatalogServer, af as SandboxConfig, ag as SandboxCreatedEvent, ah as SandboxProviderBase, ai as SandboxProviderCatalogEntry, aj as SandboxProviderConfig, ak as SaveAgentRequest, al as SearchAgentSelectorParams, am as SearchAgentsParams, an as SelectRegistrySkillRequest, S as Session, ao as SessionEventItem, ap as SkillBase, aq as SkillCatalogEntry, ar as SkillCatalogServer, as as SkillConfigBase, at as SkillMount, au as SkillSelectorEntry, b as ThreadCreatedEvent, aS as ThreadDoneEvent, av as ToolApprovalRequiredEvent, aw as ToolBase, ax as ToolCall, aT as ToolCallFunction, aU as ToolCallRef, aV as ToolInfo, aW as ToolResponseEvent, ay as ToolResponseRequiredEvent, d as Turn, aX as TurnCreatedEvent, aY as TurnDoneEvent, e as TurnInputItem, az as TurnState, aZ as TurnStateCancelled, aA as TurnStateDone, a_ as TurnStateError, a$ as TurnStateRunning, aB as TurnStreamData, aD as UpdateConnectorRequest, aE as UpdateModelProviderRequest, aF as UpdateSandboxProviderRequest, aG as UpdateSandboxRequest, aH as UpdateSessionRequest, aI as UserMessage, b0 as UserMessageContent, c as UserToolApprovalEvent, U as UserToolResponseEvent } from '../types-BE-F3vCD.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Local implementations of streaming delta helpers.
|
|
@@ -227,12 +227,20 @@ type DeltaEvents = ModelMessageDeltaEvent;
|
|
|
227
227
|
* No dependency on truefoundry-gateway-sdk.
|
|
228
228
|
*/
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
interface ModelSelectorEntry {
|
|
230
|
+
interface ProviderEntry {
|
|
232
231
|
name: string;
|
|
233
|
-
|
|
232
|
+
logo?: string;
|
|
233
|
+
}
|
|
234
|
+
interface ModelProperties {
|
|
234
235
|
reasoningEfforts?: string[];
|
|
235
236
|
}
|
|
237
|
+
/** Model selector row. Host extends for apiModel, modelId, pricing, etc. */
|
|
238
|
+
interface ModelSelectorEntry<TProvider extends ProviderEntry = ProviderEntry, TProperties extends ModelProperties = ModelProperties> {
|
|
239
|
+
name: string;
|
|
240
|
+
id: string;
|
|
241
|
+
provider: TProvider;
|
|
242
|
+
properties: TProperties;
|
|
243
|
+
}
|
|
236
244
|
/** Skill selector row. Host extends for fqn, preload, etc. */
|
|
237
245
|
interface SkillSelectorEntry {
|
|
238
246
|
id: string;
|
|
@@ -244,6 +252,10 @@ interface ConnectorSelectorEntry {
|
|
|
244
252
|
id: string;
|
|
245
253
|
name: string;
|
|
246
254
|
description?: string;
|
|
255
|
+
/** When true, the connector must be authenticated before use. Omitted when the host does not report auth. */
|
|
256
|
+
requiresAuth?: boolean;
|
|
257
|
+
/** When true, the connector is already authenticated. Omitted when the host does not report auth. */
|
|
258
|
+
authenticated?: boolean;
|
|
247
259
|
}
|
|
248
260
|
/** Agent selector row. Host extends for metadata; `agentSpec` enables Edit. */
|
|
249
261
|
interface AgentSelectorEntry {
|
|
@@ -259,19 +271,19 @@ type SearchAgentSelectorParams = {
|
|
|
259
271
|
offset?: number;
|
|
260
272
|
};
|
|
261
273
|
/**
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
* Mounts written to AgentSpec.skills[] / AgentSpec.mcpServers[].
|
|
275
|
+
*
|
|
276
|
+
* These are opaque to the runtime — it stores and forwards them but never reads
|
|
277
|
+
* a field, and the backend owns the shape (the gateway identifies a skill by
|
|
278
|
+
* `fqn`, with no `id` or `name` anywhere). So the base constrains only that a
|
|
279
|
+
* mount is an object; hosts intersect their concrete mount type over it, as
|
|
280
|
+
* `TfySkillMount` / `TfyMcpServerMount` do in the gateway adapter.
|
|
281
|
+
*
|
|
282
|
+
* Naming a field here would not just be unread, it would be wrong: a base with
|
|
283
|
+
* required fields rejects the backend's own payloads, and one with only optional
|
|
284
|
+
* fields is a weak type, which TypeScript rejects for a source that shares no
|
|
285
|
+
* property with it — the gateway's registry skill shares none.
|
|
286
|
+
*/
|
|
275
287
|
type SkillMount = object;
|
|
276
288
|
type McpServerMount = object;
|
|
277
289
|
interface ModelParams {
|
|
@@ -283,10 +295,10 @@ interface Model {
|
|
|
283
295
|
params?: ModelParams;
|
|
284
296
|
}
|
|
285
297
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
298
|
+
* SDK-owned agent definition — fields the FE reads/writes.
|
|
299
|
+
* Host widens `model` / `skills` / `mcpServers` via type params, and adds
|
|
300
|
+
* extra fields via `TSpec extends AgentSpec<...>`.
|
|
301
|
+
*/
|
|
290
302
|
interface AgentSpec<TModel extends Model = Model, TSkill extends SkillMount = SkillMount, TMcp extends McpServerMount = McpServerMount> {
|
|
291
303
|
model: TModel;
|
|
292
304
|
skills?: TSkill[];
|
|
@@ -330,7 +342,7 @@ interface ListSessionsParams extends PageParams {
|
|
|
330
342
|
/** Host-specific filter (e.g. TFY startTimestamp). */
|
|
331
343
|
startTimestamp?: string;
|
|
332
344
|
}
|
|
333
|
-
type PreviousTurnIdInput = "auto" | string;
|
|
345
|
+
type PreviousTurnIdInput = "auto" | "none" | string;
|
|
334
346
|
type UserMessageContent = string | Array<{
|
|
335
347
|
type: "text";
|
|
336
348
|
text: string;
|
|
@@ -392,11 +404,11 @@ interface Turn {
|
|
|
392
404
|
createdAt: string;
|
|
393
405
|
}
|
|
394
406
|
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
407
|
+
* Chat / session port — the runtime calls these.
|
|
408
|
+
*
|
|
409
|
+
* All session ops are flat (sessionId param). No gateway client dependency.
|
|
410
|
+
* `createTrueFoundryServer` is one possible implementation (TFY adapter).
|
|
411
|
+
*/
|
|
400
412
|
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> {
|
|
401
413
|
createSession(req: TCreate): Promise<TSession>;
|
|
402
414
|
listSessions(req?: TList): Promise<ListResult<TSession>>;
|
|
@@ -459,43 +471,63 @@ interface AgentChatServer<TSpec extends AgentSpec = AgentSpec, TSession extends
|
|
|
459
471
|
path: string;
|
|
460
472
|
}): Promise<Blob>;
|
|
461
473
|
}
|
|
474
|
+
/** Request body for `AgentBuilderServer.saveAgent`. */
|
|
475
|
+
interface SaveAgentRequest<TSpec extends AgentSpec = AgentSpec> {
|
|
476
|
+
agentName: string;
|
|
477
|
+
agentSpec: TSpec;
|
|
478
|
+
}
|
|
462
479
|
/**
|
|
463
|
-
* Builder
|
|
464
|
-
* Passed separately from the runtime's chat server.
|
|
480
|
+
* Builder feature flags — atoms gate sandbox / skill / settings surfaces on these.
|
|
465
481
|
*/
|
|
466
|
-
interface
|
|
482
|
+
interface AgentBuilderCapabilitiesResponse {
|
|
483
|
+
data: {
|
|
484
|
+
sandbox: {
|
|
485
|
+
enabled: boolean;
|
|
486
|
+
};
|
|
487
|
+
skill: {
|
|
488
|
+
enabled: boolean;
|
|
489
|
+
reason?: string;
|
|
490
|
+
};
|
|
491
|
+
settings?: {
|
|
492
|
+
enabled: boolean;
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Builder catalog + persist port — atoms call these.
|
|
498
|
+
* Passed separately from the runtime's chat server.
|
|
499
|
+
*/
|
|
500
|
+
interface AgentBuilderServer<TSpec extends AgentSpec = AgentSpec, TModel extends ModelSelectorEntry = ModelSelectorEntry, TSkill extends SkillSelectorEntry = SkillSelectorEntry, TMcp extends ConnectorSelectorEntry = ConnectorSelectorEntry, TAgent extends AgentSelectorEntry = AgentSelectorEntry, TSave = unknown, TCapabilities extends AgentBuilderCapabilitiesResponse = AgentBuilderCapabilitiesResponse> {
|
|
501
|
+
getCapabilities(): Promise<TCapabilities>;
|
|
467
502
|
getModels(): Promise<TModel[]>;
|
|
468
503
|
getSkills(): Promise<TSkill[]>;
|
|
469
504
|
getMcp(): Promise<TMcp[]>;
|
|
470
505
|
searchAgents(req?: SearchAgentSelectorParams): Promise<TAgent[]>;
|
|
471
|
-
saveAgent(req:
|
|
472
|
-
agentName: string;
|
|
473
|
-
agentSpec: TSpec;
|
|
474
|
-
}): Promise<TSave>;
|
|
506
|
+
saveAgent(req: SaveAgentRequest<TSpec>): Promise<TSave>;
|
|
475
507
|
deleteAgent?(req: {
|
|
476
508
|
agentName: string;
|
|
477
509
|
}): Promise<void>;
|
|
478
510
|
}
|
|
479
511
|
/**
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
512
|
+
* Provider type id. Reserved literal: `"custom"` for user-defined providers;
|
|
513
|
+
* any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
|
|
514
|
+
*
|
|
515
|
+
* Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
|
|
516
|
+
* so this stays `string` and `"custom"` is a documented convention.
|
|
517
|
+
*/
|
|
486
518
|
type ProviderType = string;
|
|
487
519
|
/**
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
520
|
+
* Model row — form "Model ID" + "Display name".
|
|
521
|
+
* Host extends for properties, etc.
|
|
522
|
+
*/
|
|
491
523
|
interface ModelEntry {
|
|
492
524
|
id: string;
|
|
493
525
|
name: string;
|
|
494
526
|
}
|
|
495
527
|
/**
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
528
|
+
* Write config for create/update (custom form + catalog "Save key").
|
|
529
|
+
* Host extends. `baseUrl` present iff `type === "custom"`.
|
|
530
|
+
*/
|
|
499
531
|
interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
|
|
500
532
|
type: ProviderType;
|
|
501
533
|
name: string;
|
|
@@ -505,9 +537,9 @@ interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
|
|
|
505
537
|
models: TModel[];
|
|
506
538
|
}
|
|
507
539
|
/**
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
540
|
+
* Configured provider card (list/read). No raw `apiKey`.
|
|
541
|
+
* Host extends for apiKeySet, timestamps, etc.
|
|
542
|
+
*/
|
|
511
543
|
interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
|
|
512
544
|
id: string;
|
|
513
545
|
type: ProviderType;
|
|
@@ -517,14 +549,16 @@ interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
|
|
|
517
549
|
models: TModel[];
|
|
518
550
|
}
|
|
519
551
|
/**
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
552
|
+
* Discovery-only catalog provider (AVAILABLE list).
|
|
553
|
+
* `type` must not be `"custom"` — custom providers use the custom form.
|
|
554
|
+
* Host extends for richer model rows.
|
|
555
|
+
*/
|
|
524
556
|
interface ModelProviderCatalogEntry<TModel extends ModelEntry = ModelEntry> {
|
|
525
557
|
type: ProviderType;
|
|
526
558
|
name: string;
|
|
527
559
|
models: TModel[];
|
|
560
|
+
supportedReasoningEfforts?: string[];
|
|
561
|
+
logo?: string;
|
|
528
562
|
}
|
|
529
563
|
/** Create — no `id`; server assigns it. Catalog path = entry + apiKey. */
|
|
530
564
|
type CreateModelProviderRequest<TModel extends ModelEntry = ModelEntry> = ModelProviderConfigBase<TModel>;
|
|
@@ -565,7 +599,7 @@ type ConnectorAuthNone = {
|
|
|
565
599
|
type ConnectorAuth = ConnectorAuthOAuth | ConnectorAuthApiKey | ConnectorAuthNone;
|
|
566
600
|
type ConnectorAuthPublicOAuth = {
|
|
567
601
|
type: "dcr";
|
|
568
|
-
authUrl
|
|
602
|
+
authUrl?: string;
|
|
569
603
|
};
|
|
570
604
|
type ConnectorAuthPublicApiKey = {
|
|
571
605
|
type: "header";
|
|
@@ -576,18 +610,19 @@ type ConnectorAuthPublicNone = {
|
|
|
576
610
|
};
|
|
577
611
|
type ConnectorAuthPublic = ConnectorAuthPublicOAuth | ConnectorAuthPublicApiKey | ConnectorAuthPublicNone;
|
|
578
612
|
/**
|
|
579
|
-
|
|
580
|
-
|
|
613
|
+
* MCP / connector create-edit config. Host extends for extra fields, etc.
|
|
614
|
+
*/
|
|
581
615
|
interface ConnectorConfigBase<TAuth extends ConnectorAuth = ConnectorAuth> {
|
|
582
616
|
name: string;
|
|
583
617
|
url: string;
|
|
584
618
|
auth: TAuth;
|
|
585
619
|
}
|
|
586
620
|
/**
|
|
587
|
-
* Connected connector row (settings/connectors). No raw `apiKey
|
|
621
|
+
* Connected connector row (settings/connectors). No raw `apiKey` or tools.
|
|
622
|
+
* Tools are fetched separately with `getToolsByConnectorId`.
|
|
588
623
|
* Host extends.
|
|
589
624
|
*/
|
|
590
|
-
interface ConnectorBase<
|
|
625
|
+
interface ConnectorBase<TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
|
|
591
626
|
id: string;
|
|
592
627
|
name: string;
|
|
593
628
|
description: string;
|
|
@@ -596,7 +631,6 @@ interface ConnectorBase<TTool extends ToolBase = ToolBase, TAuth extends Connect
|
|
|
596
631
|
/** When true, UI should not show Disconnect. */
|
|
597
632
|
requiresAuth: boolean;
|
|
598
633
|
authenticated: boolean;
|
|
599
|
-
tools: TTool[];
|
|
600
634
|
}
|
|
601
635
|
/** Discovery catalog entry for "+ Add MCP server". Host extends. */
|
|
602
636
|
interface ConnectorCatalogEntry<TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
|
|
@@ -605,6 +639,7 @@ interface ConnectorCatalogEntry<TAuth extends ConnectorAuthPublic = ConnectorAut
|
|
|
605
639
|
description?: string;
|
|
606
640
|
url: string;
|
|
607
641
|
auth: TAuth;
|
|
642
|
+
logo?: string;
|
|
608
643
|
}
|
|
609
644
|
/** Create connector — no `id`; server assigns it. Host extends. */
|
|
610
645
|
type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = ConnectorConfigBase<TAuth>;
|
|
@@ -612,21 +647,36 @@ type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = Conne
|
|
|
612
647
|
type UpdateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = ConnectorConfigBase<TAuth> & {
|
|
613
648
|
id: string;
|
|
614
649
|
};
|
|
615
|
-
interface
|
|
650
|
+
interface AuthenticateConnectorRequest {
|
|
651
|
+
id: string;
|
|
652
|
+
/** OAuth callback page owned by the host application. */
|
|
653
|
+
redirectURL?: string;
|
|
654
|
+
}
|
|
655
|
+
interface ConnectorAuthenticationResult<TConnector extends ConnectorBase = ConnectorBase> {
|
|
656
|
+
connector?: TConnector;
|
|
657
|
+
status?: string;
|
|
658
|
+
authorization_endpoint?: string | undefined;
|
|
659
|
+
}
|
|
660
|
+
interface ConnectorCatalogServer<TTool extends ToolBase = ToolBase, TAuthWrite extends ConnectorAuth = ConnectorAuth, TAuthPublic extends ConnectorAuthPublic = ConnectorAuthPublic, TConnector extends ConnectorBase<TAuthPublic> = ConnectorBase<TAuthPublic>, TCatalogEntry extends ConnectorCatalogEntry<TAuthPublic> = ConnectorCatalogEntry<TAuthPublic>, TCreate extends CreateConnectorRequest<TAuthWrite> = CreateConnectorRequest<TAuthWrite>, TUpdate extends UpdateConnectorRequest<TAuthWrite> = UpdateConnectorRequest<TAuthWrite>> {
|
|
616
661
|
getConnectorCatalog(): Promise<TCatalogEntry[]>;
|
|
662
|
+
getConnector(req: {
|
|
663
|
+
id: string;
|
|
664
|
+
}): Promise<TConnector>;
|
|
617
665
|
listConnectors(req?: {
|
|
618
666
|
query?: string;
|
|
619
667
|
}): Promise<TConnector[]>;
|
|
668
|
+
getToolsByConnectorId(req: {
|
|
669
|
+
id: string;
|
|
670
|
+
}): Promise<TTool[]>;
|
|
620
671
|
createConnector(req: TCreate): Promise<TConnector>;
|
|
621
672
|
/** Full replace update keyed by connector `id`. */
|
|
622
673
|
updateConnector(req: TUpdate): Promise<TConnector>;
|
|
623
674
|
/**
|
|
624
675
|
* Start connector auth (e.g. OAuth).
|
|
625
|
-
*
|
|
676
|
+
* May return a connector (already authenticated / with `auth.authUrl`) or a
|
|
677
|
+
* result carrying `authorization_endpoint` for the popup flow.
|
|
626
678
|
*/
|
|
627
|
-
authenticateConnector(req:
|
|
628
|
-
id: string;
|
|
629
|
-
}): Promise<TConnector>;
|
|
679
|
+
authenticateConnector(req: AuthenticateConnectorRequest): Promise<TConnector | ConnectorAuthenticationResult<TConnector>>;
|
|
630
680
|
/** Clear connector auth. */
|
|
631
681
|
disconnectConnector(req: {
|
|
632
682
|
id: string;
|
|
@@ -679,7 +729,7 @@ interface SkillCatalogServer<TSkill extends SkillBase = SkillBase, TCatalogEntry
|
|
|
679
729
|
id: string;
|
|
680
730
|
}): Promise<void>;
|
|
681
731
|
}
|
|
682
|
-
/** Mutable sandbox settings shared by catalog rows, create, and update. */
|
|
732
|
+
/** Mutable sandbox provider settings shared by catalog rows, create, and update. */
|
|
683
733
|
interface SandboxConfig {
|
|
684
734
|
snapshotName: string;
|
|
685
735
|
execTimeoutMs: number;
|
|
@@ -692,14 +742,18 @@ interface SandboxCatalogEntry extends SandboxConfig {
|
|
|
692
742
|
name: string;
|
|
693
743
|
type: string;
|
|
694
744
|
}
|
|
695
|
-
|
|
745
|
+
/**
|
|
746
|
+
* Connected sandbox provider row (settings/sandboxes). No raw `apiKey`.
|
|
747
|
+
* Includes last-saved config so update forms can show previous values.
|
|
748
|
+
*/
|
|
749
|
+
interface SandboxBase extends SandboxConfig {
|
|
696
750
|
id: string;
|
|
697
751
|
name: string;
|
|
698
752
|
catalogId: string;
|
|
699
753
|
isConnected: boolean;
|
|
700
754
|
}
|
|
701
755
|
interface CreateSandboxRequest extends SandboxConfig {
|
|
702
|
-
/** `SandboxCatalogEntry.id` used to create this sandbox. */
|
|
756
|
+
/** `SandboxCatalogEntry.id` used to create this sandbox provider. */
|
|
703
757
|
catalogId: string;
|
|
704
758
|
name: string;
|
|
705
759
|
type: string;
|
|
@@ -707,24 +761,37 @@ interface CreateSandboxRequest extends SandboxConfig {
|
|
|
707
761
|
}
|
|
708
762
|
interface UpdateSandboxRequest extends SandboxConfig {
|
|
709
763
|
id: string;
|
|
710
|
-
|
|
764
|
+
/** Omit to keep the existing key; send a value to rotate. */
|
|
765
|
+
apiKey?: string;
|
|
711
766
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
767
|
+
/** Host-facing aliases (trueforge-ui public names). */
|
|
768
|
+
type SandboxProviderConfig = SandboxConfig;
|
|
769
|
+
type SandboxProviderCatalogEntry = SandboxCatalogEntry;
|
|
770
|
+
type SandboxProviderBase = SandboxBase;
|
|
771
|
+
type CreateSandboxProviderRequest = CreateSandboxRequest;
|
|
772
|
+
type UpdateSandboxProviderRequest = UpdateSandboxRequest;
|
|
773
|
+
interface SandboxCatalogServer<TProvider extends SandboxBase = SandboxBase, TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry, TCreate extends CreateSandboxRequest = CreateSandboxRequest, TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest> {
|
|
774
|
+
getSandboxProviderCatalog(): Promise<TCatalogEntry[]>;
|
|
775
|
+
listSandboxProviders(req?: {
|
|
715
776
|
query?: string;
|
|
716
|
-
}): Promise<
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
777
|
+
}): Promise<TProvider[]>;
|
|
778
|
+
createSandboxProvider(req: TCreate): Promise<TProvider>;
|
|
779
|
+
updateSandboxProvider(req: TUpdate): Promise<TProvider>;
|
|
780
|
+
deleteSandboxProvider?(req: {
|
|
720
781
|
id: string;
|
|
721
782
|
}): Promise<void>;
|
|
722
783
|
}
|
|
784
|
+
/** Host-facing selector / compose aliases (trueforge-ui public names). */
|
|
785
|
+
type ModelSelection = ModelSelectorEntry;
|
|
786
|
+
type AgentSkill = SkillSelectorEntry;
|
|
787
|
+
type ConnectorState = ConnectorSelectorEntry;
|
|
788
|
+
type AgentLibraryEntry = AgentSelectorEntry;
|
|
789
|
+
type SearchAgentsParams = SearchAgentSelectorParams;
|
|
723
790
|
/**
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
791
|
+
* Settings management aggregate — modelCatalog + connectorCatalog + optional
|
|
792
|
+
* skill and sandbox catalogs.
|
|
793
|
+
* Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
|
|
794
|
+
*/
|
|
728
795
|
interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogServer, TConnectorCatalog extends ConnectorCatalogServer = ConnectorCatalogServer, TSkillCatalog extends SkillCatalogServer = SkillCatalogServer, TSandboxCatalog extends SandboxCatalogServer = SandboxCatalogServer> {
|
|
729
796
|
modelCatalog: TModelCatalog;
|
|
730
797
|
connectorCatalog: TConnectorCatalog;
|
|
@@ -735,15 +802,17 @@ interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogS
|
|
|
735
802
|
}
|
|
736
803
|
/**
|
|
737
804
|
* Composed host port: chat + builder + optional settings catalog.
|
|
738
|
-
* Agent-ui's `AgentUIServer` mirrors this shape; named differently here to
|
|
739
|
-
* avoid colliding with that package's local type name.
|
|
740
805
|
*
|
|
741
806
|
* `catalog` is optional — if the host passes it, settings UI can call
|
|
742
807
|
* `useCatalogServer()` / show modelCatalog, connectorCatalog, and skillCatalog;
|
|
743
808
|
* if omitted, those surfaces stay hidden.
|
|
809
|
+
*
|
|
810
|
+
* trueforge-ui re-exports this as `AgentUIServer`.
|
|
744
811
|
*/
|
|
745
812
|
type AgentUIServerPort<TChat extends AgentChatServer = AgentChatServer, TBuilder extends AgentBuilderServer = AgentBuilderServer, TCatalog extends CatalogServer = CatalogServer> = TChat & TBuilder & {
|
|
746
813
|
catalog?: TCatalog;
|
|
747
814
|
};
|
|
815
|
+
/** Host-facing alias used by trueforge-ui. */
|
|
816
|
+
type AgentUIServer = AgentUIServerPort;
|
|
748
817
|
|
|
749
|
-
export type {
|
|
818
|
+
export type { ModelMessageEvent as $, AgentSpec as A, ConnectorCatalogServer as B, CatalogServer as C, ConnectorConfigBase as D, ConnectorSelectorEntry as E, ConnectorState as F, CreateConnectorRequest as G, CreateModelProviderRequest as H, CreateSandboxProviderRequest as I, CreateSandboxRequest as J, CreateSessionRequest as K, CreateSkillRequest as L, McpAuthRequiredEvent as M, CreateSkillRequestBase as N, DefinedSkill as O, GithubSkill as P, ImportGithubSkillRequest as Q, ListResult as R, Session as S, TurnEvent as T, UserToolResponseEvent as U, ListSessionsOrder as V, ListSessionsParams as W, McpServerMount as X, Model as Y, ModelCatalogServer as Z, ModelEntry as _, AgentChatServer as a, TurnStateRunning as a$, ModelParams as a0, ModelProperties as a1, ModelProviderBase as a2, ModelProviderCatalogEntry as a3, ModelProviderConfigBase as a4, ModelSelection as a5, ModelSelectorEntry as a6, PageParams as a7, PreviousTurnIdInput as a8, ProviderEntry as a9, TurnStateDone as aA, TurnStreamData as aB, TurnStreamingEvent as aC, UpdateConnectorRequest as aD, UpdateModelProviderRequest as aE, UpdateSandboxProviderRequest as aF, UpdateSandboxRequest as aG, UpdateSessionRequest as aH, UserMessage as aI, DeltaEvents as aJ, ActionRequiredEvent as aK, AgentInfo as aL, AgentParent as aM, ChunkDeltaToolCall as aN, McpInitializeEvent as aO, McpServerAuthInfo as aP, ModelMessageContentPart as aQ, ModelMessageDeltaEvent as aR, ThreadDoneEvent as aS, ToolCallFunction as aT, ToolCallRef as aU, ToolInfo as aV, ToolResponseEvent as aW, TurnCreatedEvent as aX, TurnDoneEvent as aY, TurnStateCancelled as aZ, TurnStateError as a_, ProviderType as aa, RegistrySkill as ab, SandboxBase as ac, SandboxCatalogEntry as ad, SandboxCatalogServer as ae, SandboxConfig as af, SandboxCreatedEvent as ag, SandboxProviderBase as ah, SandboxProviderCatalogEntry as ai, SandboxProviderConfig as aj, SaveAgentRequest as ak, SearchAgentSelectorParams as al, SearchAgentsParams as am, SelectRegistrySkillRequest as an, SessionEventItem as ao, SkillBase as ap, SkillCatalogEntry as aq, SkillCatalogServer as ar, SkillConfigBase as as, SkillMount as at, SkillSelectorEntry as au, ToolApprovalRequiredEvent as av, ToolBase as aw, ToolCall as ax, ToolResponseRequiredEvent as ay, TurnState as az, ThreadCreatedEvent as b, UserMessageContent as b0, UserToolApprovalEvent as c, Turn as d, TurnInputItem as e, AgentBuilderCapabilitiesResponse as f, AgentBuilderServer as g, AgentLibraryEntry as h, AgentSelectorEntry as i, AgentSkill as j, AgentUIServer as k, AgentUIServerPort as l, ApprovalDecision as m, AuthenticateConnectorRequest as n, ConnectorAuth as o, ConnectorAuthApiKey as p, ConnectorAuthNone as q, ConnectorAuthOAuth as r, ConnectorAuthPublic as s, ConnectorAuthPublicApiKey as t, ConnectorAuthPublicNone as u, ConnectorAuthPublicOAuth as v, ConnectorAuthType as w, ConnectorAuthenticationResult as x, ConnectorBase as y, ConnectorCatalogEntry as z };
|
package/package.json
CHANGED
|
@@ -472,6 +472,7 @@ describe("convertTurnMessages", () => {
|
|
|
472
472
|
it("advances the turn id when a continuation reuses the existing message", () => {
|
|
473
473
|
const existing = turnStreamUpdateToAssistantMessage("turn-1", {
|
|
474
474
|
content: [{ type: "text", text: "first" }],
|
|
475
|
+
metadata: { custom: { sandboxId: "sbx-123" } },
|
|
475
476
|
});
|
|
476
477
|
const updated = turnStreamUpdateToAssistantMessage(
|
|
477
478
|
"turn-2",
|
|
@@ -480,6 +481,7 @@ describe("convertTurnMessages", () => {
|
|
|
480
481
|
);
|
|
481
482
|
expect(updated.id).toBe("turn-1-assistant");
|
|
482
483
|
expect(updated.metadata.custom.turnId).toBe("turn-2");
|
|
484
|
+
expect(updated.metadata.custom.sandboxId).toBe("sbx-123");
|
|
483
485
|
});
|
|
484
486
|
});
|
|
485
487
|
|
|
@@ -625,6 +627,127 @@ describe("convertTurnMessages", () => {
|
|
|
625
627
|
expect(assistant.metadata.custom.turnId).toBe("turn-2");
|
|
626
628
|
});
|
|
627
629
|
|
|
630
|
+
it("keeps the sandboxId when an ask-user continuation is merged", async () => {
|
|
631
|
+
const firstTurn = mockTurn({
|
|
632
|
+
id: "turn-1",
|
|
633
|
+
createdAt,
|
|
634
|
+
input: [{ type: "user.message", content: "create a file" }],
|
|
635
|
+
events: [
|
|
636
|
+
sandboxCreated({ id: "sandbox-evt", sandboxId: "sbx-123" }),
|
|
637
|
+
modelMessage({
|
|
638
|
+
id: "m1",
|
|
639
|
+
threadId: ROOT_THREAD_ID,
|
|
640
|
+
content: "Which format?",
|
|
641
|
+
}),
|
|
642
|
+
],
|
|
643
|
+
});
|
|
644
|
+
const continuationTurn = mockTurn({
|
|
645
|
+
id: "turn-2",
|
|
646
|
+
createdAt,
|
|
647
|
+
input: [
|
|
648
|
+
{
|
|
649
|
+
type: "user.tool_response",
|
|
650
|
+
threadId: ROOT_THREAD_ID,
|
|
651
|
+
toolCallId: "ask-1",
|
|
652
|
+
content: "Markdown",
|
|
653
|
+
},
|
|
654
|
+
],
|
|
655
|
+
events: [
|
|
656
|
+
modelMessage({
|
|
657
|
+
id: "m2",
|
|
658
|
+
threadId: ROOT_THREAD_ID,
|
|
659
|
+
content: "Done",
|
|
660
|
+
}),
|
|
661
|
+
],
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
const result = await convertTurnsToThreadMessages(
|
|
665
|
+
mockServerWithTurns([continuationTurn, firstTurn]),
|
|
666
|
+
SESSION_ID,
|
|
667
|
+
);
|
|
668
|
+
|
|
669
|
+
expect(result.messages[1]).toMatchObject({
|
|
670
|
+
role: "assistant",
|
|
671
|
+
metadata: {
|
|
672
|
+
custom: {
|
|
673
|
+
sandboxId: "sbx-123",
|
|
674
|
+
turnId: "turn-2",
|
|
675
|
+
},
|
|
676
|
+
},
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
it("clears pendingMcpAuth when an MCP auth continuation is merged", async () => {
|
|
681
|
+
const mcpServers = [
|
|
682
|
+
{
|
|
683
|
+
id: "github-auth",
|
|
684
|
+
name: "github",
|
|
685
|
+
authUrl: "https://example.com/auth",
|
|
686
|
+
},
|
|
687
|
+
];
|
|
688
|
+
const pausedTurn = mockTurn({
|
|
689
|
+
id: "turn-1",
|
|
690
|
+
createdAt,
|
|
691
|
+
input: [{ type: "user.message", content: "use github" }],
|
|
692
|
+
state: {
|
|
693
|
+
status: "done",
|
|
694
|
+
output: undefined,
|
|
695
|
+
requiredActions: [
|
|
696
|
+
{
|
|
697
|
+
type: "mcp.auth_required",
|
|
698
|
+
id: "mcp-auth",
|
|
699
|
+
createdAt,
|
|
700
|
+
mcpServers,
|
|
701
|
+
},
|
|
702
|
+
] as never,
|
|
703
|
+
completedAt: createdAt,
|
|
704
|
+
},
|
|
705
|
+
events: [
|
|
706
|
+
sandboxCreated({ id: "sandbox-evt", sandboxId: "sbx-123" }),
|
|
707
|
+
modelMessage({
|
|
708
|
+
id: "m1",
|
|
709
|
+
threadId: ROOT_THREAD_ID,
|
|
710
|
+
content: "Need auth",
|
|
711
|
+
}),
|
|
712
|
+
{
|
|
713
|
+
type: "mcp.auth_required",
|
|
714
|
+
id: "mcp-auth",
|
|
715
|
+
createdAt,
|
|
716
|
+
mcpServers,
|
|
717
|
+
},
|
|
718
|
+
],
|
|
719
|
+
});
|
|
720
|
+
const continuationTurn = mockTurn({
|
|
721
|
+
id: "turn-2",
|
|
722
|
+
createdAt,
|
|
723
|
+
input: [],
|
|
724
|
+
events: [
|
|
725
|
+
modelMessage({
|
|
726
|
+
id: "m2",
|
|
727
|
+
threadId: ROOT_THREAD_ID,
|
|
728
|
+
content: "Authorized",
|
|
729
|
+
}),
|
|
730
|
+
],
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
const result = await convertTurnsToThreadMessages(
|
|
734
|
+
mockServerWithTurns([continuationTurn, pausedTurn]),
|
|
735
|
+
SESSION_ID,
|
|
736
|
+
);
|
|
737
|
+
|
|
738
|
+
const assistant = result.messages[1];
|
|
739
|
+
expect(assistant?.role).toBe("assistant");
|
|
740
|
+
if (assistant?.role !== "assistant") {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
expect(assistant.status).toEqual({ type: "complete", reason: "stop" });
|
|
744
|
+
expect(assistant.metadata.custom).toEqual({
|
|
745
|
+
sandboxId: "sbx-123",
|
|
746
|
+
turnId: "turn-2",
|
|
747
|
+
});
|
|
748
|
+
expect(assistant.metadata.custom.pendingMcpAuth).toBeUndefined();
|
|
749
|
+
});
|
|
750
|
+
|
|
628
751
|
it("preserves requires-action on reload when a turn ends awaiting tool approval", async () => {
|
|
629
752
|
const pausedTurn = mockTurn({
|
|
630
753
|
id: "turn-approval",
|