@truefoundry/assistant-ui-runtime 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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, x as CreateSessionRequest, B as ListSessionsParams, S as Session, d as Turn, a7 as TurnState, a as AgentChatServer, ae as UpdateSessionRequest, ag as AgentSelectorEntry, ah as ConnectorSelectorEntry, ai as ModelSelectorEntry, aj as SkillSelectorEntry, f as AgentBuilderServer } from '../../types-Bb8Kaf1h.js';
3
+ import { A as AgentSpec, K as CreateSessionRequest, W as ListSessionsParams, S as Session, d as Turn, ax as TurnState, a as AgentChatServer, aF as UpdateSessionRequest, i as AgentSelectorEntry, E as ConnectorSelectorEntry, a5 as ModelSelectorEntry, as as SkillSelectorEntry, g as AgentBuilderServer } from '../../types-CSRQSnHu.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 minimal bases (SkillMount = {id,name}, McpServerMount =
10
- * {id,name}, AgentSpec.config = unknown, etc.) that hosts extend via generics.
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.
@@ -7,7 +7,7 @@ import {
7
7
  isTfyMcpToolInfo,
8
8
  isTfySystemToolInfo,
9
9
  isTfyToolInfo
10
- } from "../../chunk-6ZOGBD7E.js";
10
+ } from "../../chunk-2NLIAJJX.js";
11
11
  export {
12
12
  createTrueFoundryAgentUIServer,
13
13
  createTrueFoundryChatServer,
@@ -1,5 +1,5 @@
1
- import { aa as TurnStreamingEvent, ak as DeltaEvents, T as TurnEvent } from '../types-Bb8Kaf1h.js';
2
- export { al as ActionRequiredEvent, f as AgentBuilderServer, a as AgentChatServer, am as AgentInfo, an as AgentParent, ag as AgentSelectorEntry, A as AgentSpec, g as AgentUIServerPort, ao as ApprovalDecision, C as CatalogServer, ap as ChunkDeltaToolCall, h as ConnectorAuth, i as ConnectorAuthApiKey, j as ConnectorAuthNone, k as ConnectorAuthOAuth, l as ConnectorAuthPublic, m as ConnectorAuthPublicApiKey, n as ConnectorAuthPublicNone, o as ConnectorAuthPublicOAuth, p as ConnectorAuthType, q as ConnectorBase, r as ConnectorCatalogEntry, s as ConnectorCatalogServer, t as ConnectorConfigBase, ah as ConnectorSelectorEntry, u as CreateConnectorRequest, v as CreateModelProviderRequest, w as CreateSandboxRequest, x as CreateSessionRequest, y as CreateSkillRequest, z as CreateSkillRequestBase, D as DefinedSkill, G as GithubSkill, I as ImportGithubSkillRequest, L as ListResult, aq as ListSessionsOrder, B as ListSessionsParams, M as McpAuthRequiredEvent, ar as McpInitializeEvent, as as McpServerAuthInfo, at as McpServerMount, au as Model, E as ModelCatalogServer, F as ModelEntry, av as ModelMessageContentPart, aw as ModelMessageDeltaEvent, H as ModelMessageEvent, ax as ModelParams, J as ModelProviderBase, K as ModelProviderCatalogEntry, N as ModelProviderConfigBase, ai as ModelSelectorEntry, ay as PageParams, P as PreviousTurnIdInput, O as ProviderType, R as RegistrySkill, Q as SandboxBase, V as SandboxCatalogEntry, W as SandboxCatalogServer, X as SandboxConfig, Y as SandboxCreatedEvent, az as SearchAgentSelectorParams, Z as SelectRegistrySkillRequest, S as Session, _ as SessionEventItem, $ as SkillBase, a0 as SkillCatalogEntry, a1 as SkillCatalogServer, a2 as SkillConfigBase, aA as SkillMount, aj as SkillSelectorEntry, b as ThreadCreatedEvent, aB as ThreadDoneEvent, a3 as ToolApprovalRequiredEvent, a4 as ToolBase, a5 as ToolCall, aC as ToolCallFunction, aD as ToolCallRef, aE as ToolInfo, aF as ToolResponseEvent, a6 as ToolResponseRequiredEvent, d as Turn, aG as TurnCreatedEvent, aH as TurnDoneEvent, e as TurnInputItem, a7 as TurnState, aI as TurnStateCancelled, a8 as TurnStateDone, aJ as TurnStateError, aK as TurnStateRunning, a9 as TurnStreamData, ab as UpdateConnectorRequest, ac as UpdateModelProviderRequest, ad as UpdateSandboxRequest, ae as UpdateSessionRequest, af as UserMessage, aL as UserMessageContent, c as UserToolApprovalEvent, U as UserToolResponseEvent } from '../types-Bb8Kaf1h.js';
1
+ import { aA as TurnStreamingEvent, aH as DeltaEvents, T as TurnEvent } from '../types-CSRQSnHu.js';
2
+ export { aI as ActionRequiredEvent, f as AgentBuilderCapabilitiesResponse, g as AgentBuilderServer, a as AgentChatServer, aJ as AgentInfo, h as AgentLibraryEntry, aK 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, aL 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, aM as McpInitializeEvent, aN as McpServerAuthInfo, X as McpServerMount, Y as Model, Z as ModelCatalogServer, _ as ModelEntry, aO as ModelMessageContentPart, aP as ModelMessageDeltaEvent, $ as ModelMessageEvent, a0 as ModelParams, a1 as ModelProviderBase, a2 as ModelProviderCatalogEntry, a3 as ModelProviderConfigBase, a4 as ModelSelection, a5 as ModelSelectorEntry, a6 as PageParams, a7 as PreviousTurnIdInput, a8 as ProviderType, a9 as RegistrySkill, aa as SandboxBase, ab as SandboxCatalogEntry, ac as SandboxCatalogServer, ad as SandboxConfig, ae as SandboxCreatedEvent, af as SandboxProviderBase, ag as SandboxProviderCatalogEntry, ah as SandboxProviderConfig, ai as SaveAgentRequest, aj as SearchAgentSelectorParams, ak as SearchAgentsParams, al as SelectRegistrySkillRequest, S as Session, am as SessionEventItem, an as SkillBase, ao as SkillCatalogEntry, ap as SkillCatalogServer, aq as SkillConfigBase, ar as SkillMount, as as SkillSelectorEntry, b as ThreadCreatedEvent, aQ as ThreadDoneEvent, at as ToolApprovalRequiredEvent, au as ToolBase, av as ToolCall, aR as ToolCallFunction, aS as ToolCallRef, aT as ToolInfo, aU as ToolResponseEvent, aw as ToolResponseRequiredEvent, d as Turn, aV as TurnCreatedEvent, aW as TurnDoneEvent, e as TurnInputItem, ax as TurnState, aX as TurnStateCancelled, ay as TurnStateDone, aY as TurnStateError, aZ as TurnStateRunning, az as TurnStreamData, aB as UpdateConnectorRequest, aC as UpdateModelProviderRequest, aD as UpdateSandboxProviderRequest, aE as UpdateSandboxRequest, aF as UpdateSessionRequest, aG as UserMessage, a_ as UserMessageContent, c as UserToolApprovalEvent, U as UserToolResponseEvent } from '../types-CSRQSnHu.js';
3
3
 
4
4
  /**
5
5
  * Local implementations of streaming delta helpers.
@@ -232,6 +232,8 @@ interface ModelSelectorEntry {
232
232
  name: string;
233
233
  provider: string;
234
234
  reasoningEfforts?: string[];
235
+ /** Provider logo URL from the model catalog; selector falls back to a monogram when omitted. */
236
+ providerLogo?: string;
235
237
  }
236
238
  /** Skill selector row. Host extends for fqn, preload, etc. */
237
239
  interface SkillSelectorEntry {
@@ -244,6 +246,10 @@ interface ConnectorSelectorEntry {
244
246
  id: string;
245
247
  name: string;
246
248
  description?: string;
249
+ /** When true, the connector must be authenticated before use. Omitted when the host does not report auth. */
250
+ requiresAuth?: boolean;
251
+ /** When true, the connector is already authenticated. Omitted when the host does not report auth. */
252
+ authenticated?: boolean;
247
253
  }
248
254
  /** Agent selector row. Host extends for metadata; `agentSpec` enables Edit. */
249
255
  interface AgentSelectorEntry {
@@ -259,19 +265,19 @@ type SearchAgentSelectorParams = {
259
265
  offset?: number;
260
266
  };
261
267
  /**
262
- * Mounts written to AgentSpec.skills[] / AgentSpec.mcpServers[].
263
- *
264
- * These are opaque to the runtime — it stores and forwards them but never reads
265
- * a field, and the backend owns the shape (the gateway identifies a skill by
266
- * `fqn`, with no `id` or `name` anywhere). So the base constrains only that a
267
- * mount is an object; hosts intersect their concrete mount type over it, as
268
- * `TfySkillMount` / `TfyMcpServerMount` do in the gateway adapter.
269
- *
270
- * Naming a field here would not just be unread, it would be wrong: a base with
271
- * required fields rejects the backend's own payloads, and one with only optional
272
- * fields is a weak type, which TypeScript rejects for a source that shares no
273
- * property with it — the gateway's registry skill shares none.
274
- */
268
+ * Mounts written to AgentSpec.skills[] / AgentSpec.mcpServers[].
269
+ *
270
+ * These are opaque to the runtime — it stores and forwards them but never reads
271
+ * a field, and the backend owns the shape (the gateway identifies a skill by
272
+ * `fqn`, with no `id` or `name` anywhere). So the base constrains only that a
273
+ * mount is an object; hosts intersect their concrete mount type over it, as
274
+ * `TfySkillMount` / `TfyMcpServerMount` do in the gateway adapter.
275
+ *
276
+ * Naming a field here would not just be unread, it would be wrong: a base with
277
+ * required fields rejects the backend's own payloads, and one with only optional
278
+ * fields is a weak type, which TypeScript rejects for a source that shares no
279
+ * property with it — the gateway's registry skill shares none.
280
+ */
275
281
  type SkillMount = object;
276
282
  type McpServerMount = object;
277
283
  interface ModelParams {
@@ -283,10 +289,10 @@ interface Model {
283
289
  params?: ModelParams;
284
290
  }
285
291
  /**
286
- * SDK-owned agent definition — fields the FE reads/writes.
287
- * Host widens `model` / `skills` / `mcpServers` via type params, and adds
288
- * extra fields via `TSpec extends AgentSpec<...>`.
289
- */
292
+ * SDK-owned agent definition — fields the FE reads/writes.
293
+ * Host widens `model` / `skills` / `mcpServers` via type params, and adds
294
+ * extra fields via `TSpec extends AgentSpec<...>`.
295
+ */
290
296
  interface AgentSpec<TModel extends Model = Model, TSkill extends SkillMount = SkillMount, TMcp extends McpServerMount = McpServerMount> {
291
297
  model: TModel;
292
298
  skills?: TSkill[];
@@ -330,7 +336,7 @@ interface ListSessionsParams extends PageParams {
330
336
  /** Host-specific filter (e.g. TFY startTimestamp). */
331
337
  startTimestamp?: string;
332
338
  }
333
- type PreviousTurnIdInput = "auto" | string;
339
+ type PreviousTurnIdInput = "auto" | "none" | string;
334
340
  type UserMessageContent = string | Array<{
335
341
  type: "text";
336
342
  text: string;
@@ -392,11 +398,11 @@ interface Turn {
392
398
  createdAt: string;
393
399
  }
394
400
  /**
395
- * Chat / session port — the runtime calls these.
396
- *
397
- * All session ops are flat (sessionId param). No gateway client dependency.
398
- * `createTrueFoundryServer` is one possible implementation (TFY adapter).
399
- */
401
+ * Chat / session port — the runtime calls these.
402
+ *
403
+ * All session ops are flat (sessionId param). No gateway client dependency.
404
+ * `createTrueFoundryServer` is one possible implementation (TFY adapter).
405
+ */
400
406
  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
407
  createSession(req: TCreate): Promise<TSession>;
402
408
  listSessions(req?: TList): Promise<ListResult<TSession>>;
@@ -459,43 +465,63 @@ interface AgentChatServer<TSpec extends AgentSpec = AgentSpec, TSession extends
459
465
  path: string;
460
466
  }): Promise<Blob>;
461
467
  }
468
+ /** Request body for `AgentBuilderServer.saveAgent`. */
469
+ interface SaveAgentRequest<TSpec extends AgentSpec = AgentSpec> {
470
+ agentName: string;
471
+ agentSpec: TSpec;
472
+ }
462
473
  /**
463
- * Builder catalog + persist port — atoms call these.
464
- * Passed separately from the runtime's chat server.
474
+ * Builder feature flags — atoms gate sandbox / skill / settings surfaces on these.
465
475
  */
466
- interface AgentBuilderServer<TSpec extends AgentSpec = AgentSpec, TModel extends ModelSelectorEntry = ModelSelectorEntry, TSkill extends SkillSelectorEntry = SkillSelectorEntry, TMcp extends ConnectorSelectorEntry = ConnectorSelectorEntry, TAgent extends AgentSelectorEntry = AgentSelectorEntry, TSave = unknown> {
476
+ interface AgentBuilderCapabilitiesResponse {
477
+ data: {
478
+ sandbox: {
479
+ enabled: boolean;
480
+ };
481
+ skill: {
482
+ enabled: boolean;
483
+ reason?: string;
484
+ };
485
+ settings?: {
486
+ enabled: boolean;
487
+ };
488
+ };
489
+ }
490
+ /**
491
+ * Builder catalog + persist port — atoms call these.
492
+ * Passed separately from the runtime's chat server.
493
+ */
494
+ 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> {
495
+ getCapabilities(): Promise<TCapabilities>;
467
496
  getModels(): Promise<TModel[]>;
468
497
  getSkills(): Promise<TSkill[]>;
469
498
  getMcp(): Promise<TMcp[]>;
470
499
  searchAgents(req?: SearchAgentSelectorParams): Promise<TAgent[]>;
471
- saveAgent(req: {
472
- agentName: string;
473
- agentSpec: TSpec;
474
- }): Promise<TSave>;
500
+ saveAgent(req: SaveAgentRequest<TSpec>): Promise<TSave>;
475
501
  deleteAgent?(req: {
476
502
  agentName: string;
477
503
  }): Promise<void>;
478
504
  }
479
505
  /**
480
- * Provider type id. Reserved literal: `"custom"` for user-defined providers;
481
- * any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
482
- *
483
- * Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
484
- * so this stays `string` and `"custom"` is a documented convention.
485
- */
506
+ * Provider type id. Reserved literal: `"custom"` for user-defined providers;
507
+ * any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
508
+ *
509
+ * Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
510
+ * so this stays `string` and `"custom"` is a documented convention.
511
+ */
486
512
  type ProviderType = string;
487
513
  /**
488
- * Model row — form "Model ID" + "Display name".
489
- * Host extends for properties, etc.
490
- */
514
+ * Model row — form "Model ID" + "Display name".
515
+ * Host extends for properties, etc.
516
+ */
491
517
  interface ModelEntry {
492
518
  id: string;
493
519
  name: string;
494
520
  }
495
521
  /**
496
- * Write config for create/update (custom form + catalog "Save key").
497
- * Host extends. `baseUrl` present iff `type === "custom"`.
498
- */
522
+ * Write config for create/update (custom form + catalog "Save key").
523
+ * Host extends. `baseUrl` present iff `type === "custom"`.
524
+ */
499
525
  interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
500
526
  type: ProviderType;
501
527
  name: string;
@@ -505,9 +531,9 @@ interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
505
531
  models: TModel[];
506
532
  }
507
533
  /**
508
- * Configured provider card (list/read). No raw `apiKey`.
509
- * Host extends for apiKeySet, timestamps, etc.
510
- */
534
+ * Configured provider card (list/read). No raw `apiKey`.
535
+ * Host extends for apiKeySet, timestamps, etc.
536
+ */
511
537
  interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
512
538
  id: string;
513
539
  type: ProviderType;
@@ -517,14 +543,16 @@ interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
517
543
  models: TModel[];
518
544
  }
519
545
  /**
520
- * Discovery-only catalog provider (AVAILABLE list).
521
- * `type` must not be `"custom"` — custom providers use the custom form.
522
- * Host extends for richer model rows.
523
- */
546
+ * Discovery-only catalog provider (AVAILABLE list).
547
+ * `type` must not be `"custom"` — custom providers use the custom form.
548
+ * Host extends for richer model rows.
549
+ */
524
550
  interface ModelProviderCatalogEntry<TModel extends ModelEntry = ModelEntry> {
525
551
  type: ProviderType;
526
552
  name: string;
527
553
  models: TModel[];
554
+ supportedReasoningEfforts?: string[];
555
+ logo?: string;
528
556
  }
529
557
  /** Create — no `id`; server assigns it. Catalog path = entry + apiKey. */
530
558
  type CreateModelProviderRequest<TModel extends ModelEntry = ModelEntry> = ModelProviderConfigBase<TModel>;
@@ -565,7 +593,7 @@ type ConnectorAuthNone = {
565
593
  type ConnectorAuth = ConnectorAuthOAuth | ConnectorAuthApiKey | ConnectorAuthNone;
566
594
  type ConnectorAuthPublicOAuth = {
567
595
  type: "dcr";
568
- authUrl: string;
596
+ authUrl?: string;
569
597
  };
570
598
  type ConnectorAuthPublicApiKey = {
571
599
  type: "header";
@@ -576,18 +604,19 @@ type ConnectorAuthPublicNone = {
576
604
  };
577
605
  type ConnectorAuthPublic = ConnectorAuthPublicOAuth | ConnectorAuthPublicApiKey | ConnectorAuthPublicNone;
578
606
  /**
579
- * MCP / connector create-edit config. Host extends for extra fields, etc.
580
- */
607
+ * MCP / connector create-edit config. Host extends for extra fields, etc.
608
+ */
581
609
  interface ConnectorConfigBase<TAuth extends ConnectorAuth = ConnectorAuth> {
582
610
  name: string;
583
611
  url: string;
584
612
  auth: TAuth;
585
613
  }
586
614
  /**
587
- * Connected connector row (settings/connectors). No raw `apiKey`.
615
+ * Connected connector row (settings/connectors). No raw `apiKey` or tools.
616
+ * Tools are fetched separately with `getToolsByConnectorId`.
588
617
  * Host extends.
589
618
  */
590
- interface ConnectorBase<TTool extends ToolBase = ToolBase, TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
619
+ interface ConnectorBase<TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
591
620
  id: string;
592
621
  name: string;
593
622
  description: string;
@@ -596,7 +625,6 @@ interface ConnectorBase<TTool extends ToolBase = ToolBase, TAuth extends Connect
596
625
  /** When true, UI should not show Disconnect. */
597
626
  requiresAuth: boolean;
598
627
  authenticated: boolean;
599
- tools: TTool[];
600
628
  }
601
629
  /** Discovery catalog entry for "+ Add MCP server". Host extends. */
602
630
  interface ConnectorCatalogEntry<TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
@@ -605,6 +633,7 @@ interface ConnectorCatalogEntry<TAuth extends ConnectorAuthPublic = ConnectorAut
605
633
  description?: string;
606
634
  url: string;
607
635
  auth: TAuth;
636
+ logo?: string;
608
637
  }
609
638
  /** Create connector — no `id`; server assigns it. Host extends. */
610
639
  type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = ConnectorConfigBase<TAuth>;
@@ -612,21 +641,36 @@ type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = Conne
612
641
  type UpdateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = ConnectorConfigBase<TAuth> & {
613
642
  id: string;
614
643
  };
615
- interface ConnectorCatalogServer<TTool extends ToolBase = ToolBase, TAuthWrite extends ConnectorAuth = ConnectorAuth, TAuthPublic extends ConnectorAuthPublic = ConnectorAuthPublic, TConnector extends ConnectorBase<TTool, TAuthPublic> = ConnectorBase<TTool, TAuthPublic>, TCatalogEntry extends ConnectorCatalogEntry<TAuthPublic> = ConnectorCatalogEntry<TAuthPublic>, TCreate extends CreateConnectorRequest<TAuthWrite> = CreateConnectorRequest<TAuthWrite>, TUpdate extends UpdateConnectorRequest<TAuthWrite> = UpdateConnectorRequest<TAuthWrite>> {
644
+ interface AuthenticateConnectorRequest {
645
+ id: string;
646
+ /** OAuth callback page owned by the host application. */
647
+ redirectURL?: string;
648
+ }
649
+ interface ConnectorAuthenticationResult<TConnector extends ConnectorBase = ConnectorBase> {
650
+ connector?: TConnector;
651
+ status?: string;
652
+ authorization_endpoint?: string | undefined;
653
+ }
654
+ 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
655
  getConnectorCatalog(): Promise<TCatalogEntry[]>;
656
+ getConnector(req: {
657
+ id: string;
658
+ }): Promise<TConnector>;
617
659
  listConnectors(req?: {
618
660
  query?: string;
619
661
  }): Promise<TConnector[]>;
662
+ getToolsByConnectorId(req: {
663
+ id: string;
664
+ }): Promise<TTool[]>;
620
665
  createConnector(req: TCreate): Promise<TConnector>;
621
666
  /** Full replace update keyed by connector `id`. */
622
667
  updateConnector(req: TUpdate): Promise<TConnector>;
623
668
  /**
624
669
  * Start connector auth (e.g. OAuth).
625
- * For oauth, the returned connector's `auth.authUrl` is the authorize URL.
670
+ * May return a connector (already authenticated / with `auth.authUrl`) or a
671
+ * result carrying `authorization_endpoint` for the popup flow.
626
672
  */
627
- authenticateConnector(req: {
628
- id: string;
629
- }): Promise<TConnector>;
673
+ authenticateConnector(req: AuthenticateConnectorRequest): Promise<TConnector | ConnectorAuthenticationResult<TConnector>>;
630
674
  /** Clear connector auth. */
631
675
  disconnectConnector(req: {
632
676
  id: string;
@@ -679,7 +723,7 @@ interface SkillCatalogServer<TSkill extends SkillBase = SkillBase, TCatalogEntry
679
723
  id: string;
680
724
  }): Promise<void>;
681
725
  }
682
- /** Mutable sandbox settings shared by catalog rows, create, and update. */
726
+ /** Mutable sandbox provider settings shared by catalog rows, create, and update. */
683
727
  interface SandboxConfig {
684
728
  snapshotName: string;
685
729
  execTimeoutMs: number;
@@ -692,14 +736,18 @@ interface SandboxCatalogEntry extends SandboxConfig {
692
736
  name: string;
693
737
  type: string;
694
738
  }
695
- interface SandboxBase {
739
+ /**
740
+ * Connected sandbox provider row (settings/sandboxes). No raw `apiKey`.
741
+ * Includes last-saved config so update forms can show previous values.
742
+ */
743
+ interface SandboxBase extends SandboxConfig {
696
744
  id: string;
697
745
  name: string;
698
746
  catalogId: string;
699
747
  isConnected: boolean;
700
748
  }
701
749
  interface CreateSandboxRequest extends SandboxConfig {
702
- /** `SandboxCatalogEntry.id` used to create this sandbox. */
750
+ /** `SandboxCatalogEntry.id` used to create this sandbox provider. */
703
751
  catalogId: string;
704
752
  name: string;
705
753
  type: string;
@@ -707,24 +755,37 @@ interface CreateSandboxRequest extends SandboxConfig {
707
755
  }
708
756
  interface UpdateSandboxRequest extends SandboxConfig {
709
757
  id: string;
710
- apiKey: string;
758
+ /** Omit to keep the existing key; send a value to rotate. */
759
+ apiKey?: string;
711
760
  }
712
- interface SandboxCatalogServer<TSandbox extends SandboxBase = SandboxBase, TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry, TCreate extends CreateSandboxRequest = CreateSandboxRequest, TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest> {
713
- getSandboxCatalog(): Promise<TCatalogEntry[]>;
714
- listSandboxes(req?: {
761
+ /** Host-facing aliases (trueforge-ui public names). */
762
+ type SandboxProviderConfig = SandboxConfig;
763
+ type SandboxProviderCatalogEntry = SandboxCatalogEntry;
764
+ type SandboxProviderBase = SandboxBase;
765
+ type CreateSandboxProviderRequest = CreateSandboxRequest;
766
+ type UpdateSandboxProviderRequest = UpdateSandboxRequest;
767
+ interface SandboxCatalogServer<TProvider extends SandboxBase = SandboxBase, TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry, TCreate extends CreateSandboxRequest = CreateSandboxRequest, TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest> {
768
+ getSandboxProviderCatalog(): Promise<TCatalogEntry[]>;
769
+ listSandboxProviders(req?: {
715
770
  query?: string;
716
- }): Promise<TSandbox[]>;
717
- createSandbox(req: TCreate): Promise<TSandbox>;
718
- updateSandbox(req: TUpdate): Promise<TSandbox>;
719
- deleteSandbox(req: {
771
+ }): Promise<TProvider[]>;
772
+ createSandboxProvider(req: TCreate): Promise<TProvider>;
773
+ updateSandboxProvider(req: TUpdate): Promise<TProvider>;
774
+ deleteSandboxProvider?(req: {
720
775
  id: string;
721
776
  }): Promise<void>;
722
777
  }
778
+ /** Host-facing selector / compose aliases (trueforge-ui public names). */
779
+ type ModelSelection = ModelSelectorEntry;
780
+ type AgentSkill = SkillSelectorEntry;
781
+ type ConnectorState = ConnectorSelectorEntry;
782
+ type AgentLibraryEntry = AgentSelectorEntry;
783
+ type SearchAgentsParams = SearchAgentSelectorParams;
723
784
  /**
724
- * Settings management aggregate — modelCatalog + connectorCatalog + optional
725
- * skill and sandbox catalogs.
726
- * Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
727
- */
785
+ * Settings management aggregate — modelCatalog + connectorCatalog + optional
786
+ * skill and sandbox catalogs.
787
+ * Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
788
+ */
728
789
  interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogServer, TConnectorCatalog extends ConnectorCatalogServer = ConnectorCatalogServer, TSkillCatalog extends SkillCatalogServer = SkillCatalogServer, TSandboxCatalog extends SandboxCatalogServer = SandboxCatalogServer> {
729
790
  modelCatalog: TModelCatalog;
730
791
  connectorCatalog: TConnectorCatalog;
@@ -735,15 +796,17 @@ interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogS
735
796
  }
736
797
  /**
737
798
  * 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
799
  *
741
800
  * `catalog` is optional — if the host passes it, settings UI can call
742
801
  * `useCatalogServer()` / show modelCatalog, connectorCatalog, and skillCatalog;
743
802
  * if omitted, those surfaces stay hidden.
803
+ *
804
+ * trueforge-ui re-exports this as `AgentUIServer`.
744
805
  */
745
806
  type AgentUIServerPort<TChat extends AgentChatServer = AgentChatServer, TBuilder extends AgentBuilderServer = AgentBuilderServer, TCatalog extends CatalogServer = CatalogServer> = TChat & TBuilder & {
746
807
  catalog?: TCatalog;
747
808
  };
809
+ /** Host-facing alias used by trueforge-ui. */
810
+ type AgentUIServer = AgentUIServerPort;
748
811
 
749
- export type { SkillBase as $, AgentSpec as A, ListSessionsParams as B, CatalogServer as C, DefinedSkill as D, ModelCatalogServer as E, ModelEntry as F, GithubSkill as G, ModelMessageEvent as H, ImportGithubSkillRequest as I, ModelProviderBase as J, ModelProviderCatalogEntry as K, ListResult as L, McpAuthRequiredEvent as M, ModelProviderConfigBase as N, ProviderType as O, PreviousTurnIdInput as P, SandboxBase as Q, RegistrySkill as R, Session as S, TurnEvent as T, UserToolResponseEvent as U, SandboxCatalogEntry as V, SandboxCatalogServer as W, SandboxConfig as X, SandboxCreatedEvent as Y, SelectRegistrySkillRequest as Z, SessionEventItem as _, AgentChatServer as a, SkillCatalogEntry as a0, SkillCatalogServer as a1, SkillConfigBase as a2, ToolApprovalRequiredEvent as a3, ToolBase as a4, ToolCall as a5, ToolResponseRequiredEvent as a6, TurnState as a7, TurnStateDone as a8, TurnStreamData as a9, SkillMount as aA, ThreadDoneEvent as aB, ToolCallFunction as aC, ToolCallRef as aD, ToolInfo as aE, ToolResponseEvent as aF, TurnCreatedEvent as aG, TurnDoneEvent as aH, TurnStateCancelled as aI, TurnStateError as aJ, TurnStateRunning as aK, UserMessageContent as aL, TurnStreamingEvent as aa, UpdateConnectorRequest as ab, UpdateModelProviderRequest as ac, UpdateSandboxRequest as ad, UpdateSessionRequest as ae, UserMessage as af, AgentSelectorEntry as ag, ConnectorSelectorEntry as ah, ModelSelectorEntry as ai, SkillSelectorEntry as aj, DeltaEvents as ak, ActionRequiredEvent as al, AgentInfo as am, AgentParent as an, ApprovalDecision as ao, ChunkDeltaToolCall as ap, ListSessionsOrder as aq, McpInitializeEvent as ar, McpServerAuthInfo as as, McpServerMount as at, Model as au, ModelMessageContentPart as av, ModelMessageDeltaEvent as aw, ModelParams as ax, PageParams as ay, SearchAgentSelectorParams as az, ThreadCreatedEvent as b, UserToolApprovalEvent as c, Turn as d, TurnInputItem as e, AgentBuilderServer as f, AgentUIServerPort as g, ConnectorAuth as h, ConnectorAuthApiKey as i, ConnectorAuthNone as j, ConnectorAuthOAuth as k, ConnectorAuthPublic as l, ConnectorAuthPublicApiKey as m, ConnectorAuthPublicNone as n, ConnectorAuthPublicOAuth as o, ConnectorAuthType as p, ConnectorBase as q, ConnectorCatalogEntry as r, ConnectorCatalogServer as s, ConnectorConfigBase as t, CreateConnectorRequest as u, CreateModelProviderRequest as v, CreateSandboxRequest as w, CreateSessionRequest as x, CreateSkillRequest as y, CreateSkillRequestBase as z };
812
+ 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, ModelParams as a0, ModelProviderBase as a1, ModelProviderCatalogEntry as a2, ModelProviderConfigBase as a3, ModelSelection as a4, ModelSelectorEntry as a5, PageParams as a6, PreviousTurnIdInput as a7, ProviderType as a8, RegistrySkill as a9, TurnStreamingEvent as aA, UpdateConnectorRequest as aB, UpdateModelProviderRequest as aC, UpdateSandboxProviderRequest as aD, UpdateSandboxRequest as aE, UpdateSessionRequest as aF, UserMessage as aG, DeltaEvents as aH, ActionRequiredEvent as aI, AgentInfo as aJ, AgentParent as aK, ChunkDeltaToolCall as aL, McpInitializeEvent as aM, McpServerAuthInfo as aN, ModelMessageContentPart as aO, ModelMessageDeltaEvent as aP, ThreadDoneEvent as aQ, ToolCallFunction as aR, ToolCallRef as aS, ToolInfo as aT, ToolResponseEvent as aU, TurnCreatedEvent as aV, TurnDoneEvent as aW, TurnStateCancelled as aX, TurnStateError as aY, TurnStateRunning as aZ, UserMessageContent as a_, SandboxBase as aa, SandboxCatalogEntry as ab, SandboxCatalogServer as ac, SandboxConfig as ad, SandboxCreatedEvent as ae, SandboxProviderBase as af, SandboxProviderCatalogEntry as ag, SandboxProviderConfig as ah, SaveAgentRequest as ai, SearchAgentSelectorParams as aj, SearchAgentsParams as ak, SelectRegistrySkillRequest as al, SessionEventItem as am, SkillBase as an, SkillCatalogEntry as ao, SkillCatalogServer as ap, SkillConfigBase as aq, SkillMount as ar, SkillSelectorEntry as as, ToolApprovalRequiredEvent as at, ToolBase as au, ToolCall as av, ToolResponseRequiredEvent as aw, TurnState as ax, TurnStateDone as ay, TurnStreamData as az, ThreadCreatedEvent as b, 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truefoundry/assistant-ui-runtime",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "TrueFoundry Gateway agent runtime adapter for assistant-ui",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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",
@@ -1029,10 +1029,12 @@ function projectHistoryTurns(
1029
1029
  const messages: ThreadMessage[] = [];
1030
1030
  let lastAssistantIndex: number | undefined;
1031
1031
  let groupRootIds: string[] = [];
1032
+ let sandboxId: string | undefined;
1032
1033
 
1033
1034
  for (let turnIndex = 0; turnIndex < snapshot.turns.length; turnIndex++) {
1034
1035
  const record = snapshot.turns[turnIndex]!;
1035
1036
  const turnRootIds = record.rootModelMessageIds ?? [];
1037
+ sandboxId = record.sandboxId ?? sandboxId;
1036
1038
 
1037
1039
  if (record.userText) {
1038
1040
  groupRootIds = [...turnRootIds];
@@ -1080,7 +1082,7 @@ function projectHistoryTurns(
1080
1082
  const custom = {
1081
1083
  ...baseCustom,
1082
1084
  turnId: record.id,
1083
- ...(record.sandboxId != null ? { sandboxId: record.sandboxId } : {}),
1085
+ ...(sandboxId != null ? { sandboxId } : {}),
1084
1086
  };
1085
1087
 
1086
1088
  if (record.userText) {
@@ -1738,7 +1740,11 @@ export function turnStreamUpdateToAssistantMessage(
1738
1740
  unstable_annotations: [],
1739
1741
  unstable_data: [],
1740
1742
  steps: [],
1741
- custom: { ...update.metadata?.custom, turnId },
1743
+ custom: {
1744
+ ...(existing?.role === "assistant" ? existing.metadata.custom : {}),
1745
+ ...update.metadata?.custom,
1746
+ turnId,
1747
+ },
1742
1748
  },
1743
1749
  };
1744
1750
  }