@truefoundry/assistant-ui-runtime 0.1.16 → 0.1.18
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 +13 -0
- package/README.md +4 -2
- package/dist/{chunk-S4SH2KT2.js → chunk-N6LJ3LR2.js} +160 -21
- package/dist/chunk-N6LJ3LR2.js.map +1 -0
- package/dist/index.d.ts +26 -5
- package/dist/index.js +147 -58
- package/dist/index.js.map +1 -1
- package/dist/plugins/truefoundry-agent-server-adapter/index.d.ts +6 -2
- package/dist/plugins/truefoundry-agent-server-adapter/index.js +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/{types-VU3Fc17W.d.ts → types-BRrQpoVy.d.ts} +62 -54
- package/package.json +2 -2
- package/src/hooks.ts +19 -19
- package/src/index.ts +7 -1
- package/src/plugins/truefoundry-agent-server-adapter/README.md +1 -1
- package/src/plugins/truefoundry-agent-server-adapter/cp.test.ts +3 -3
- package/src/plugins/truefoundry-agent-server-adapter/cp.ts +51 -10
- package/src/plugins/truefoundry-agent-server-adapter/modelReasoningEffort.test.ts +171 -0
- package/src/plugins/truefoundry-agent-server-adapter/modelReasoningEffort.ts +145 -0
- package/src/plugins/truefoundry-agent-server-adapter/normalizeAgentSpec.test.ts +85 -4
- package/src/plugins/truefoundry-agent-server-adapter/normalizeAgentSpec.ts +67 -17
- package/src/server/index.ts +2 -0
- package/src/server/types.ts +117 -90
- package/src/truefoundryExtras.test.ts +161 -0
- package/src/truefoundryExtras.ts +136 -1
- package/dist/chunk-S4SH2KT2.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentSessionClient } from 'truefoundry-gateway-sdk/agents';
|
|
2
2
|
import { PrivateAgentSessionClient } from 'truefoundry-gateway-sdk/agents/private';
|
|
3
|
-
import { A as AgentSpec, N as CreateSessionRequest, Y as ListSessionsParams, S as Session, d as Turn,
|
|
3
|
+
import { A as AgentSpec, N as CreateSessionRequest, Y as ListSessionsParams, S as Session, d as Turn, aE as TurnState, a as AgentChatServer, aM as UpdateSessionRequest, k as AgentSelectorEntry, G as ConnectorSelectorEntry, a8 as ModelSelectorEntry, az as SkillSelectorEntry, g as AgentBuilderServer } from '../../types-BRrQpoVy.js';
|
|
4
4
|
import { TruefoundryGatewayApi } from 'truefoundry-gateway-sdk';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -116,7 +116,11 @@ declare function createTrueFoundryChatServer<TSpec extends TfyAgentSpec = TfyAge
|
|
|
116
116
|
*/
|
|
117
117
|
|
|
118
118
|
interface TfyModelSelectorEntry extends ModelSelectorEntry {
|
|
119
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* model_fqn for AgentSpec.model.name.
|
|
121
|
+
* Same value as {@link ModelSelectorEntry.name} / `id` — trueforge-ui writes
|
|
122
|
+
* `name` into the spec; keep this alias for hosts that still read `apiModel`.
|
|
123
|
+
*/
|
|
120
124
|
apiModel: string;
|
|
121
125
|
modelId: string;
|
|
122
126
|
providerAccount?: string;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { aH as TurnStreamingEvent, aO as DeltaEvents, T as TurnEvent } from '../types-BRrQpoVy.js';
|
|
2
|
+
export { aP as ActionRequiredEvent, f as AgentBuilderCapabilitiesResponse, g as AgentBuilderServer, h as AgentCapabilityConfig, a as AgentChatServer, aQ as AgentInfo, i as AgentLibraryEntry, aR as AgentParent, j as AgentRuntimeConfig, k as AgentSelectorEntry, l as AgentSkill, A as AgentSpec, m as AgentUIServer, n as AgentUIServerPort, o as ApprovalDecision, p as AuthenticateConnectorRequest, C as CatalogServer, aS as ChunkDeltaToolCall, q as ConnectorAuth, r as ConnectorAuthApiKey, s as ConnectorAuthNone, t as ConnectorAuthOAuth, u as ConnectorAuthPublic, v as ConnectorAuthPublicApiKey, w as ConnectorAuthPublicNone, x as ConnectorAuthPublicOAuth, y as ConnectorAuthType, z as ConnectorAuthenticationResult, B as ConnectorBase, D as ConnectorCatalogEntry, E as ConnectorCatalogServer, F as ConnectorConfigBase, G as ConnectorSelectorEntry, H as ConnectorState, I as CreateConnectorRequest, J as CreateModelProviderRequest, K as CreateSandboxProviderRequest, L as CreateSandboxRequest, N as CreateSessionRequest, O as CreateSkillRequest, P as CreateSkillRequestBase, Q as DefinedSkill, R as GithubSkill, V as ImportGithubSkillRequest, W as ListResult, X as ListSessionsOrder, Y as ListSessionsParams, M as McpAuthRequiredEvent, aT as McpInitializeEvent, aU as McpServerAuthInfo, Z as McpServerMount, _ as Model, $ as ModelCatalogServer, a0 as ModelEntry, aV as ModelMessageContentPart, aW as ModelMessageDeltaEvent, a1 as ModelMessageEvent, a2 as ModelParams, a3 as ModelProperties, a4 as ModelProviderBase, a5 as ModelProviderCatalogEntry, a6 as ModelProviderConfigBase, a7 as ModelSelection, a8 as ModelSelectorEntry, a9 as PageParams, aa as PreviousTurnIdInput, ab as ProviderEntry, ac as ProviderType, ad as RegistrySkill, ae as SandboxBase, af as SandboxCatalogEntry, ag as SandboxCatalogServer, ah as SandboxConfig, ai as SandboxCreatedEvent, aj as SandboxProviderBase, ak as SandboxProviderCatalogEntry, al as SandboxProviderConfig, am as SandboxProviderListEntry, an as SandboxSnapshotSyncStatus, ao as SaveAgentRequest, ap as SaveAgentResult, aq as SearchAgentSelectorParams, ar as SearchAgentsParams, as as SelectRegistrySkillRequest, S as Session, at as SessionEventItem, au as SkillBase, av as SkillCatalogEntry, aw as SkillCatalogServer, ax as SkillConfigBase, ay as SkillMount, az as SkillSelectorEntry, b as ThreadCreatedEvent, aX as ThreadDoneEvent, aA as ToolApprovalRequiredEvent, aB as ToolBase, aC as ToolCall, aY as ToolCallFunction, aZ as ToolCallRef, a_ as ToolInfo, a$ as ToolResponseEvent, aD as ToolResponseRequiredEvent, d as Turn, b0 as TurnCreatedEvent, b1 as TurnDoneEvent, e as TurnInputItem, aE as TurnState, b2 as TurnStateCancelled, aF as TurnStateDone, b3 as TurnStateError, b4 as TurnStateRunning, aG as TurnStreamData, aI as UpdateConnectorRequest, aJ as UpdateModelProviderRequest, aK as UpdateSandboxProviderRequest, aL as UpdateSandboxRequest, aM as UpdateSessionRequest, aN as UserMessage, b5 as UserMessageContent, c as UserToolApprovalEvent, U as UserToolResponseEvent } from '../types-BRrQpoVy.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Local implementations of streaming delta helpers.
|
|
@@ -271,19 +271,19 @@ type SearchAgentSelectorParams = {
|
|
|
271
271
|
offset?: number;
|
|
272
272
|
};
|
|
273
273
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
287
287
|
type SkillMount = object;
|
|
288
288
|
type McpServerMount = object;
|
|
289
289
|
interface ModelParams {
|
|
@@ -303,10 +303,10 @@ interface AgentRuntimeConfig {
|
|
|
303
303
|
askUserQuestions?: AgentCapabilityConfig;
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
|
-
* SDK-owned agent definition — fields the FE reads/writes.
|
|
307
|
-
* Host widens `model` / `skills` / `mcpServers` / `config` via type params,
|
|
308
|
-
* and adds extra fields via `TSpec extends AgentSpec<...>`.
|
|
309
|
-
*/
|
|
306
|
+
* SDK-owned agent definition — fields the FE reads/writes.
|
|
307
|
+
* Host widens `model` / `skills` / `mcpServers` / `config` via type params,
|
|
308
|
+
* and adds extra fields via `TSpec extends AgentSpec<...>`.
|
|
309
|
+
*/
|
|
310
310
|
interface AgentSpec<TModel extends Model = Model, TSkill extends SkillMount = SkillMount, TMcp extends McpServerMount = McpServerMount, TConfig extends AgentRuntimeConfig = AgentRuntimeConfig> {
|
|
311
311
|
model: TModel;
|
|
312
312
|
skills?: TSkill[];
|
|
@@ -413,11 +413,11 @@ interface Turn {
|
|
|
413
413
|
createdAt: string;
|
|
414
414
|
}
|
|
415
415
|
/**
|
|
416
|
-
* Chat / session port — the runtime calls these.
|
|
417
|
-
*
|
|
418
|
-
* All session ops are flat (sessionId param). No gateway client dependency.
|
|
419
|
-
* `createTrueFoundryServer` is one possible implementation (TFY adapter).
|
|
420
|
-
*/
|
|
416
|
+
* Chat / session port — the runtime calls these.
|
|
417
|
+
*
|
|
418
|
+
* All session ops are flat (sessionId param). No gateway client dependency.
|
|
419
|
+
* `createTrueFoundryServer` is one possible implementation (TFY adapter).
|
|
420
|
+
*/
|
|
421
421
|
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> {
|
|
422
422
|
createSession(req: TCreate): Promise<TSession>;
|
|
423
423
|
listSessions(req?: TList): Promise<ListResult<TSession>>;
|
|
@@ -512,9 +512,9 @@ interface AgentBuilderCapabilitiesResponse {
|
|
|
512
512
|
};
|
|
513
513
|
}
|
|
514
514
|
/**
|
|
515
|
-
* Builder catalog + persist port — atoms call these.
|
|
516
|
-
* Passed separately from the runtime's chat server.
|
|
517
|
-
*/
|
|
515
|
+
* Builder catalog + persist port — atoms call these.
|
|
516
|
+
* Passed separately from the runtime's chat server.
|
|
517
|
+
*/
|
|
518
518
|
interface AgentBuilderServer<TSpec extends AgentSpec = AgentSpec, TModel extends ModelSelectorEntry = ModelSelectorEntry, TSkill extends SkillSelectorEntry = SkillSelectorEntry, TMcp extends ConnectorSelectorEntry = ConnectorSelectorEntry, TAgent extends AgentSelectorEntry = AgentSelectorEntry, TSave = SaveAgentResult, TCapabilities extends AgentBuilderCapabilitiesResponse = AgentBuilderCapabilitiesResponse> {
|
|
519
519
|
getCapabilities(): Promise<TCapabilities>;
|
|
520
520
|
getModels(): Promise<TModel[]>;
|
|
@@ -527,25 +527,25 @@ interface AgentBuilderServer<TSpec extends AgentSpec = AgentSpec, TModel extends
|
|
|
527
527
|
}): Promise<void>;
|
|
528
528
|
}
|
|
529
529
|
/**
|
|
530
|
-
* Provider type id. Reserved literal: `"custom"` for user-defined providers;
|
|
531
|
-
* any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
|
|
532
|
-
*
|
|
533
|
-
* Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
|
|
534
|
-
* so this stays `string` and `"custom"` is a documented convention.
|
|
535
|
-
*/
|
|
530
|
+
* Provider type id. Reserved literal: `"custom"` for user-defined providers;
|
|
531
|
+
* any other string is a builtin (e.g. `"openai"`, `"anthropic"`).
|
|
532
|
+
*
|
|
533
|
+
* Note: `string | "custom"` is useless in TypeScript (`"custom"` ⊆ `string`),
|
|
534
|
+
* so this stays `string` and `"custom"` is a documented convention.
|
|
535
|
+
*/
|
|
536
536
|
type ProviderType = string;
|
|
537
537
|
/**
|
|
538
|
-
* Model row — form "Model ID" + "Display name".
|
|
539
|
-
* Host extends for properties, etc.
|
|
540
|
-
*/
|
|
538
|
+
* Model row — form "Model ID" + "Display name".
|
|
539
|
+
* Host extends for properties, etc.
|
|
540
|
+
*/
|
|
541
541
|
interface ModelEntry {
|
|
542
542
|
id: string;
|
|
543
543
|
name: string;
|
|
544
544
|
}
|
|
545
545
|
/**
|
|
546
|
-
* Write config for create/update (custom form + catalog "Save key").
|
|
547
|
-
* Host extends. `baseUrl` present iff `type === "custom"`.
|
|
548
|
-
*/
|
|
546
|
+
* Write config for create/update (custom form + catalog "Save key").
|
|
547
|
+
* Host extends. `baseUrl` present iff `type === "custom"`.
|
|
548
|
+
*/
|
|
549
549
|
interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
|
|
550
550
|
type: ProviderType;
|
|
551
551
|
name: string;
|
|
@@ -555,9 +555,9 @@ interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
|
|
|
555
555
|
models: TModel[];
|
|
556
556
|
}
|
|
557
557
|
/**
|
|
558
|
-
* Configured provider card (list/read). No raw `apiKey`.
|
|
559
|
-
* Host extends for apiKeySet, timestamps, etc.
|
|
560
|
-
*/
|
|
558
|
+
* Configured provider card (list/read). No raw `apiKey`.
|
|
559
|
+
* Host extends for apiKeySet, timestamps, etc.
|
|
560
|
+
*/
|
|
561
561
|
interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
|
|
562
562
|
id: string;
|
|
563
563
|
type: ProviderType;
|
|
@@ -567,10 +567,10 @@ interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
|
|
|
567
567
|
models: TModel[];
|
|
568
568
|
}
|
|
569
569
|
/**
|
|
570
|
-
* Discovery-only catalog provider (AVAILABLE list).
|
|
571
|
-
* `type` must not be `"custom"` — custom providers use the custom form.
|
|
572
|
-
* Host extends for richer model rows.
|
|
573
|
-
*/
|
|
570
|
+
* Discovery-only catalog provider (AVAILABLE list).
|
|
571
|
+
* `type` must not be `"custom"` — custom providers use the custom form.
|
|
572
|
+
* Host extends for richer model rows.
|
|
573
|
+
*/
|
|
574
574
|
interface ModelProviderCatalogEntry<TModel extends ModelEntry = ModelEntry> {
|
|
575
575
|
type: ProviderType;
|
|
576
576
|
name: string;
|
|
@@ -628,10 +628,11 @@ type ConnectorAuthPublicNone = {
|
|
|
628
628
|
};
|
|
629
629
|
type ConnectorAuthPublic = ConnectorAuthPublicOAuth | ConnectorAuthPublicApiKey | ConnectorAuthPublicNone;
|
|
630
630
|
/**
|
|
631
|
-
* MCP / connector create-edit config. Host extends for extra fields, etc.
|
|
632
|
-
*/
|
|
631
|
+
* MCP / connector create-edit config. Host extends for extra fields, etc.
|
|
632
|
+
*/
|
|
633
633
|
interface ConnectorConfigBase<TAuth extends ConnectorAuth = ConnectorAuth> {
|
|
634
634
|
name: string;
|
|
635
|
+
description: string;
|
|
635
636
|
url: string;
|
|
636
637
|
auth: TAuth;
|
|
637
638
|
}
|
|
@@ -749,7 +750,6 @@ interface SkillCatalogServer<TSkill extends SkillBase = SkillBase, TCatalogEntry
|
|
|
749
750
|
}
|
|
750
751
|
/** Mutable sandbox provider settings shared by catalog rows, create, and update. */
|
|
751
752
|
interface SandboxConfig {
|
|
752
|
-
snapshotName: string;
|
|
753
753
|
execTimeoutMs: number;
|
|
754
754
|
autoStopIntervalInMinutes: number;
|
|
755
755
|
autoArchiveIntervalInMinutes: number;
|
|
@@ -770,6 +770,14 @@ interface SandboxBase extends SandboxConfig {
|
|
|
770
770
|
catalogId: string;
|
|
771
771
|
isConnected: boolean;
|
|
772
772
|
}
|
|
773
|
+
type SandboxSnapshotSyncStatus = {
|
|
774
|
+
status: "pending" | "ready" | "failed";
|
|
775
|
+
statusReason?: string | null;
|
|
776
|
+
};
|
|
777
|
+
interface SandboxProviderListEntry<TSandbox extends SandboxBase = SandboxBase> {
|
|
778
|
+
data: TSandbox;
|
|
779
|
+
snapshotSyncStatus: SandboxSnapshotSyncStatus;
|
|
780
|
+
}
|
|
773
781
|
interface CreateSandboxRequest extends SandboxConfig {
|
|
774
782
|
/** `SandboxCatalogEntry.id` used to create this sandbox provider. */
|
|
775
783
|
catalogId: string;
|
|
@@ -788,11 +796,11 @@ type SandboxProviderCatalogEntry = SandboxCatalogEntry;
|
|
|
788
796
|
type SandboxProviderBase = SandboxBase;
|
|
789
797
|
type CreateSandboxProviderRequest = CreateSandboxRequest;
|
|
790
798
|
type UpdateSandboxProviderRequest = UpdateSandboxRequest;
|
|
791
|
-
interface SandboxCatalogServer<TProvider extends SandboxBase = SandboxBase, TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry, TCreate extends CreateSandboxRequest = CreateSandboxRequest, TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest> {
|
|
799
|
+
interface SandboxCatalogServer<TProvider extends SandboxBase = SandboxBase, TCatalogEntry extends SandboxCatalogEntry = SandboxCatalogEntry, TCreate extends CreateSandboxRequest = CreateSandboxRequest, TUpdate extends UpdateSandboxRequest = UpdateSandboxRequest, TListEntry extends SandboxProviderListEntry<TProvider> = SandboxProviderListEntry<TProvider>> {
|
|
792
800
|
getSandboxProviderCatalog(): Promise<TCatalogEntry[]>;
|
|
793
801
|
listSandboxProviders(req?: {
|
|
794
802
|
query?: string;
|
|
795
|
-
}): Promise<
|
|
803
|
+
}): Promise<TListEntry[]>;
|
|
796
804
|
createSandboxProvider(req: TCreate): Promise<TProvider>;
|
|
797
805
|
updateSandboxProvider(req: TUpdate): Promise<TProvider>;
|
|
798
806
|
deleteSandboxProvider?(req: {
|
|
@@ -806,10 +814,10 @@ type ConnectorState = ConnectorSelectorEntry;
|
|
|
806
814
|
type AgentLibraryEntry = AgentSelectorEntry;
|
|
807
815
|
type SearchAgentsParams = SearchAgentSelectorParams;
|
|
808
816
|
/**
|
|
809
|
-
* Settings management aggregate — modelCatalog + connectorCatalog + optional
|
|
810
|
-
* skill and sandbox catalogs.
|
|
811
|
-
* Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
|
|
812
|
-
*/
|
|
817
|
+
* Settings management aggregate — modelCatalog + connectorCatalog + optional
|
|
818
|
+
* skill and sandbox catalogs.
|
|
819
|
+
* Hosts may pass the whole object to an app shell, or a focused sub-port to a page.
|
|
820
|
+
*/
|
|
813
821
|
interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogServer, TConnectorCatalog extends ConnectorCatalogServer = ConnectorCatalogServer, TSkillCatalog extends SkillCatalogServer = SkillCatalogServer, TSandboxCatalog extends SandboxCatalogServer = SandboxCatalogServer> {
|
|
814
822
|
modelCatalog: TModelCatalog;
|
|
815
823
|
connectorCatalog: TConnectorCatalog;
|
|
@@ -833,4 +841,4 @@ type AgentUIServerPort<TChat extends AgentChatServer = AgentChatServer, TBuilder
|
|
|
833
841
|
/** Host-facing alias used by trueforge-ui. */
|
|
834
842
|
type AgentUIServer = AgentUIServerPort;
|
|
835
843
|
|
|
836
|
-
export type { ModelCatalogServer as $, AgentSpec as A, ConnectorBase as B, CatalogServer as C, ConnectorCatalogEntry as D, ConnectorCatalogServer as E, ConnectorConfigBase as F, ConnectorSelectorEntry as G, ConnectorState as H, CreateConnectorRequest as I, CreateModelProviderRequest as J, CreateSandboxProviderRequest as K, CreateSandboxRequest as L, McpAuthRequiredEvent as M, CreateSessionRequest as N, CreateSkillRequest as O, CreateSkillRequestBase as P, DefinedSkill as Q, GithubSkill as R, Session as S, TurnEvent as T, UserToolResponseEvent as U, ImportGithubSkillRequest as V, ListResult as W, ListSessionsOrder as X, ListSessionsParams as Y, McpServerMount as Z, Model as _, AgentChatServer as a,
|
|
844
|
+
export type { ModelCatalogServer as $, AgentSpec as A, ConnectorBase as B, CatalogServer as C, ConnectorCatalogEntry as D, ConnectorCatalogServer as E, ConnectorConfigBase as F, ConnectorSelectorEntry as G, ConnectorState as H, CreateConnectorRequest as I, CreateModelProviderRequest as J, CreateSandboxProviderRequest as K, CreateSandboxRequest as L, McpAuthRequiredEvent as M, CreateSessionRequest as N, CreateSkillRequest as O, CreateSkillRequestBase as P, DefinedSkill as Q, GithubSkill as R, Session as S, TurnEvent as T, UserToolResponseEvent as U, ImportGithubSkillRequest as V, ListResult as W, ListSessionsOrder as X, ListSessionsParams as Y, McpServerMount as Z, Model as _, AgentChatServer as a, ToolResponseEvent as a$, ModelEntry as a0, ModelMessageEvent as a1, ModelParams as a2, ModelProperties as a3, ModelProviderBase as a4, ModelProviderCatalogEntry as a5, ModelProviderConfigBase as a6, ModelSelection as a7, ModelSelectorEntry as a8, PageParams as a9, ToolApprovalRequiredEvent as aA, ToolBase as aB, ToolCall as aC, ToolResponseRequiredEvent as aD, TurnState as aE, TurnStateDone as aF, TurnStreamData as aG, TurnStreamingEvent as aH, UpdateConnectorRequest as aI, UpdateModelProviderRequest as aJ, UpdateSandboxProviderRequest as aK, UpdateSandboxRequest as aL, UpdateSessionRequest as aM, UserMessage as aN, DeltaEvents as aO, ActionRequiredEvent as aP, AgentInfo as aQ, AgentParent as aR, ChunkDeltaToolCall as aS, McpInitializeEvent as aT, McpServerAuthInfo as aU, ModelMessageContentPart as aV, ModelMessageDeltaEvent as aW, ThreadDoneEvent as aX, ToolCallFunction as aY, ToolCallRef as aZ, ToolInfo as a_, PreviousTurnIdInput as aa, ProviderEntry as ab, ProviderType as ac, RegistrySkill as ad, SandboxBase as ae, SandboxCatalogEntry as af, SandboxCatalogServer as ag, SandboxConfig as ah, SandboxCreatedEvent as ai, SandboxProviderBase as aj, SandboxProviderCatalogEntry as ak, SandboxProviderConfig as al, SandboxProviderListEntry as am, SandboxSnapshotSyncStatus as an, SaveAgentRequest as ao, SaveAgentResult as ap, SearchAgentSelectorParams as aq, SearchAgentsParams as ar, SelectRegistrySkillRequest as as, SessionEventItem as at, SkillBase as au, SkillCatalogEntry as av, SkillCatalogServer as aw, SkillConfigBase as ax, SkillMount as ay, SkillSelectorEntry as az, ThreadCreatedEvent as b, TurnCreatedEvent as b0, TurnDoneEvent as b1, TurnStateCancelled as b2, TurnStateError as b3, TurnStateRunning as b4, UserMessageContent as b5, UserToolApprovalEvent as c, Turn as d, TurnInputItem as e, AgentBuilderCapabilitiesResponse as f, AgentBuilderServer as g, AgentCapabilityConfig as h, AgentLibraryEntry as i, AgentRuntimeConfig as j, AgentSelectorEntry as k, AgentSkill as l, AgentUIServer as m, AgentUIServerPort as n, ApprovalDecision as o, AuthenticateConnectorRequest as p, ConnectorAuth as q, ConnectorAuthApiKey as r, ConnectorAuthNone as s, ConnectorAuthOAuth as t, ConnectorAuthPublic as u, ConnectorAuthPublicApiKey as v, ConnectorAuthPublicNone as w, ConnectorAuthPublicOAuth as x, ConnectorAuthType as y, ConnectorAuthenticationResult as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truefoundry/assistant-ui-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "TrueFoundry Gateway agent runtime adapter for assistant-ui",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -81,4 +81,4 @@
|
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
82
|
"vitest": "4.1.9"
|
|
83
83
|
}
|
|
84
|
-
}
|
|
84
|
+
}
|
package/src/hooks.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { useAui, useAuiState } from "@assistant-ui/store";
|
|
|
6
6
|
import type { TrueFoundryMessageCustomMetadata } from "./messageCustomMetadata.js";
|
|
7
7
|
import {
|
|
8
8
|
EMPTY_DRAFT_EXTRAS,
|
|
9
|
-
|
|
9
|
+
getTrueFoundryExtras,
|
|
10
|
+
useTrueFoundryRuntimeExtras,
|
|
10
11
|
type TrueFoundryDraftRuntimeExtras,
|
|
11
12
|
} from "./truefoundryExtras.js";
|
|
12
13
|
import type { RespondToToolApprovalOptions } from "./toolApproval.js";
|
|
@@ -14,7 +15,7 @@ import type { RespondToToolResponseOptions } from "./toolResponse.js";
|
|
|
14
15
|
|
|
15
16
|
/** Pending tool approvals plus a respond action. */
|
|
16
17
|
export const useTrueFoundryApprovals = () => {
|
|
17
|
-
const extras =
|
|
18
|
+
const extras = useTrueFoundryRuntimeExtras();
|
|
18
19
|
|
|
19
20
|
return useMemo(
|
|
20
21
|
() => ({
|
|
@@ -31,7 +32,7 @@ export const useTrueFoundryApprovals = () => {
|
|
|
31
32
|
|
|
32
33
|
/** Pending ask-user tool responses plus a respond action. */
|
|
33
34
|
export const useTrueFoundryToolResponses = () => {
|
|
34
|
-
const extras =
|
|
35
|
+
const extras = useTrueFoundryRuntimeExtras();
|
|
35
36
|
|
|
36
37
|
return useMemo(
|
|
37
38
|
() => ({
|
|
@@ -48,7 +49,7 @@ export const useTrueFoundryToolResponses = () => {
|
|
|
48
49
|
|
|
49
50
|
/** Pending MCP OAuth plus a resume action. */
|
|
50
51
|
export const useTrueFoundryMcpAuth = () => {
|
|
51
|
-
const extras =
|
|
52
|
+
const extras = useTrueFoundryRuntimeExtras();
|
|
52
53
|
|
|
53
54
|
return useMemo(
|
|
54
55
|
() => ({
|
|
@@ -67,25 +68,25 @@ export const useTrueFoundryMcpAuth = () => {
|
|
|
67
68
|
export const useTrueFoundryRespondToToolApproval = () => {
|
|
68
69
|
const aui = useAui();
|
|
69
70
|
return (response: RespondToToolApprovalOptions) =>
|
|
70
|
-
|
|
71
|
+
getTrueFoundryExtras(aui).respondToToolApproval(response);
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
/** Returns a function to respond to a pending tool response from any render context. */
|
|
74
75
|
export const useTrueFoundryRespondToToolResponse = () => {
|
|
75
76
|
const aui = useAui();
|
|
76
77
|
return (response: RespondToToolResponseOptions) =>
|
|
77
|
-
|
|
78
|
+
getTrueFoundryExtras(aui).respondToToolResponse(response);
|
|
78
79
|
};
|
|
79
80
|
|
|
80
81
|
/** Returns a function to resume after MCP OAuth from any render context. */
|
|
81
82
|
export const useTrueFoundryResumeMcpAuth = () => {
|
|
82
83
|
const aui = useAui();
|
|
83
|
-
return () =>
|
|
84
|
+
return () => getTrueFoundryExtras(aui).resumeMcpAuth();
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
/** Current sandboxId for this session, if a sandbox has been created. */
|
|
87
88
|
export const useTrueFoundrySandboxId = (): string | undefined =>
|
|
88
|
-
|
|
89
|
+
useTrueFoundryRuntimeExtras()?.sandboxId;
|
|
89
90
|
|
|
90
91
|
/** Turn that produced the message being rendered. Only defined inside a message scope. */
|
|
91
92
|
export const useTrueFoundryTurnId = (): string | undefined =>
|
|
@@ -108,25 +109,25 @@ export const useTrueFoundryDownloadSandboxFile = () => {
|
|
|
108
109
|
"Downloading a sandbox file requires a message scope to resolve its turn.",
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
|
-
return
|
|
112
|
+
return getTrueFoundryExtras(aui).downloadSandboxFile({ turnId, path });
|
|
112
113
|
};
|
|
113
114
|
};
|
|
114
115
|
|
|
115
116
|
/** Returns a function to cancel the current run from any render context. */
|
|
116
117
|
export const useTrueFoundryCancel = () => {
|
|
117
118
|
const aui = useAui();
|
|
118
|
-
return () =>
|
|
119
|
+
return () => getTrueFoundryExtras(aui).cancel();
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
/** Returns a function to reload (retry) the current session from any render context. */
|
|
122
123
|
export const useTrueFoundryReload = () => {
|
|
123
124
|
const aui = useAui();
|
|
124
|
-
return () =>
|
|
125
|
+
return () => getTrueFoundryExtras(aui).reload();
|
|
125
126
|
};
|
|
126
127
|
|
|
127
128
|
/** Older history pagination state plus a load-more action for scroll-up. */
|
|
128
129
|
export const useTrueFoundryHistoryPagination = () => {
|
|
129
|
-
const extras =
|
|
130
|
+
const extras = useTrueFoundryRuntimeExtras();
|
|
130
131
|
|
|
131
132
|
return useMemo(
|
|
132
133
|
() => ({
|
|
@@ -147,17 +148,17 @@ export const useTrueFoundryHistoryPagination = () => {
|
|
|
147
148
|
* arrive in this client. Falls back to `false` on runtimes that predate the flag.
|
|
148
149
|
*/
|
|
149
150
|
export const useTrueFoundryResumeUnavailable = () =>
|
|
150
|
-
|
|
151
|
+
useTrueFoundryRuntimeExtras()?.resumeUnavailable ?? false;
|
|
151
152
|
|
|
152
153
|
/** Returns a function to reset (re-submit) a user turn from any render context. */
|
|
153
154
|
export const useTrueFoundryResetFromTurn = () => {
|
|
154
155
|
const aui = useAui();
|
|
155
|
-
return (turnId: string) =>
|
|
156
|
+
return (turnId: string) => getTrueFoundryExtras(aui).resetFromTurn(turnId);
|
|
156
157
|
};
|
|
157
158
|
|
|
158
159
|
/** Current draft agent spec and sync state (draft mode only). */
|
|
159
160
|
export const useTrueFoundryAgentSpec = () => {
|
|
160
|
-
const extras =
|
|
161
|
+
const extras = useTrueFoundryRuntimeExtras()?.draft ?? null;
|
|
161
162
|
|
|
162
163
|
return useMemo(
|
|
163
164
|
() => ({ ...EMPTY_DRAFT_EXTRAS, ...extras }),
|
|
@@ -169,14 +170,14 @@ export const useTrueFoundryAgentSpec = () => {
|
|
|
169
170
|
export const useTrueFoundryUpdateAgentSpec = () => {
|
|
170
171
|
const aui = useAui();
|
|
171
172
|
return (update: Parameters<TrueFoundryDraftRuntimeExtras["updateAgentSpec"]>[0]) =>
|
|
172
|
-
|
|
173
|
+
getTrueFoundryExtras(aui).draft?.updateAgentSpec(update);
|
|
173
174
|
};
|
|
174
175
|
|
|
175
176
|
/** Flushes any pending draft-spec synchronization before a coordinated write. */
|
|
176
177
|
export const useTrueFoundryFlushAgentSpec = () => {
|
|
177
178
|
const aui = useAui();
|
|
178
179
|
return () =>
|
|
179
|
-
|
|
180
|
+
getTrueFoundryExtras(aui).draft?.flushAgentSpec() ?? Promise.resolve();
|
|
180
181
|
};
|
|
181
182
|
|
|
182
183
|
/** Adopts a spec already persisted by another server operation without syncing again. */
|
|
@@ -184,6 +185,5 @@ export const useTrueFoundryAdoptAgentSpec = () => {
|
|
|
184
185
|
const aui = useAui();
|
|
185
186
|
return (
|
|
186
187
|
request: Parameters<TrueFoundryDraftRuntimeExtras["adoptAgentSpec"]>[0],
|
|
187
|
-
) =>
|
|
188
|
+
) => getTrueFoundryExtras(aui).draft?.adoptAgentSpec(request);
|
|
188
189
|
};
|
|
189
|
-
|
package/src/index.ts
CHANGED
|
@@ -42,7 +42,11 @@ export type {
|
|
|
42
42
|
} from "./messageCustomMetadata.js";
|
|
43
43
|
export type { PendingApproval, PendingToolResponse } from "./collectPending.js";
|
|
44
44
|
export type { TrueFoundryRuntimeExtras } from "./truefoundryExtras.js";
|
|
45
|
-
export {
|
|
45
|
+
export {
|
|
46
|
+
trueFoundryExtras,
|
|
47
|
+
getTrueFoundryExtras,
|
|
48
|
+
tryGetTrueFoundryExtras,
|
|
49
|
+
} from "./truefoundryExtras.js";
|
|
46
50
|
export {
|
|
47
51
|
useTrueFoundryApprovals,
|
|
48
52
|
useTrueFoundryToolResponses,
|
|
@@ -143,6 +147,8 @@ export type {
|
|
|
143
147
|
SandboxConfig,
|
|
144
148
|
SandboxCatalogEntry,
|
|
145
149
|
SandboxBase,
|
|
150
|
+
SandboxSnapshotSyncStatus,
|
|
151
|
+
SandboxProviderListEntry,
|
|
146
152
|
CreateSandboxRequest,
|
|
147
153
|
UpdateSandboxRequest,
|
|
148
154
|
SandboxProviderConfig,
|
|
@@ -89,7 +89,7 @@ Implemented against Control Plane HTTP (not the gateway SDK):
|
|
|
89
89
|
|
|
90
90
|
| Method | CP path |
|
|
91
91
|
| ------ | ------- |
|
|
92
|
-
| `getModels` | `GET /api/svc/v1/llm-gateway/model/enabled` |
|
|
92
|
+
| `getModels` | `GET /api/svc/v1/llm-gateway/model/enabled` (+ `GET /api/svc/v1/provider-accounts/providers` for `properties.reasoningEfforts`) |
|
|
93
93
|
| `getSkills` | `GET /api/ml/v1/agent-skills?include_empty_agent_skills=false` |
|
|
94
94
|
| `getMcp` | `GET /api/svc/v1/mcp-servers` |
|
|
95
95
|
| `searchAgents` | `GET /api/svc/v1/agents?type=truefoundry-agent&…` |
|
|
@@ -150,7 +150,7 @@ describe("normalizeEnabledModels", () => {
|
|
|
150
150
|
expect(rows).toEqual([
|
|
151
151
|
{
|
|
152
152
|
id: "openai-main/gpt-4.1",
|
|
153
|
-
name: "gpt-4.1",
|
|
153
|
+
name: "openai-main/gpt-4.1",
|
|
154
154
|
provider: { name: "openai" },
|
|
155
155
|
properties: {},
|
|
156
156
|
apiModel: "openai-main/gpt-4.1",
|
|
@@ -159,7 +159,7 @@ describe("normalizeEnabledModels", () => {
|
|
|
159
159
|
},
|
|
160
160
|
{
|
|
161
161
|
id: "anthropic-prod/claude-sonnet-4-6",
|
|
162
|
-
name: "claude-sonnet-4-6",
|
|
162
|
+
name: "anthropic-prod/claude-sonnet-4-6",
|
|
163
163
|
provider: { name: "anthropic" },
|
|
164
164
|
properties: {},
|
|
165
165
|
apiModel: "anthropic-prod/claude-sonnet-4-6",
|
|
@@ -186,7 +186,7 @@ describe("normalizeEnabledModels", () => {
|
|
|
186
186
|
expect(rows).toEqual([
|
|
187
187
|
{
|
|
188
188
|
id: "virtual-main/router",
|
|
189
|
-
name: "router",
|
|
189
|
+
name: "virtual-main/router",
|
|
190
190
|
provider: { name: "virtual-model" },
|
|
191
191
|
properties: {},
|
|
192
192
|
apiModel: "virtual-main/router",
|
|
@@ -13,6 +13,11 @@ import type {
|
|
|
13
13
|
SearchAgentSelectorParams,
|
|
14
14
|
SkillSelectorEntry,
|
|
15
15
|
} from "../../server/types.js";
|
|
16
|
+
import {
|
|
17
|
+
buildMetadataMap,
|
|
18
|
+
metadataKey,
|
|
19
|
+
reasoningEffortsForModel,
|
|
20
|
+
} from "./modelReasoningEffort.js";
|
|
16
21
|
import { normalizeAgentSpecForGateway } from "./normalizeAgentSpec.js";
|
|
17
22
|
import type { TfyAgentSpec } from "./types.js";
|
|
18
23
|
|
|
@@ -21,7 +26,11 @@ import type { TfyAgentSpec } from "./types.js";
|
|
|
21
26
|
// ---------------------------------------------------------------------------
|
|
22
27
|
|
|
23
28
|
export interface TfyModelSelectorEntry extends ModelSelectorEntry {
|
|
24
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* model_fqn for AgentSpec.model.name.
|
|
31
|
+
* Same value as {@link ModelSelectorEntry.name} / `id` — trueforge-ui writes
|
|
32
|
+
* `name` into the spec; keep this alias for hosts that still read `apiModel`.
|
|
33
|
+
*/
|
|
25
34
|
apiModel: string;
|
|
26
35
|
modelId: string;
|
|
27
36
|
providerAccount?: string;
|
|
@@ -158,15 +167,17 @@ function isChatModel(row: RawEnabledModel): boolean {
|
|
|
158
167
|
|
|
159
168
|
function toModelEntry(row: RawEnabledModel): TfyModelSelectorEntry | null {
|
|
160
169
|
if (!isChatModel(row)) return null;
|
|
170
|
+
// Gateway AgentSpec.model.name must be model_fqn (e.g. account/model-id).
|
|
171
|
+
// trueforge-ui DraftModelSelector writes ModelSelectorEntry.name into that
|
|
172
|
+
// field, so `name` is the FQN — not the CP short display label.
|
|
161
173
|
const apiModel = row.model_fqn ?? row.id;
|
|
162
|
-
|
|
163
|
-
if (apiModel == null || apiModel === "" || name == null || name === "") {
|
|
174
|
+
if (apiModel == null || apiModel === "") {
|
|
164
175
|
return null;
|
|
165
176
|
}
|
|
166
|
-
const modelId = row.model_id ?? name;
|
|
177
|
+
const modelId = row.model_id ?? row.name ?? apiModel;
|
|
167
178
|
return {
|
|
168
179
|
id: apiModel,
|
|
169
|
-
name,
|
|
180
|
+
name: apiModel,
|
|
170
181
|
provider: { name: row.provider ?? "unknown" },
|
|
171
182
|
properties: {},
|
|
172
183
|
apiModel,
|
|
@@ -219,14 +230,44 @@ export function normalizeEnabledModels(raw: unknown): TfyModelSelectorEntry[] {
|
|
|
219
230
|
return out;
|
|
220
231
|
}
|
|
221
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Attach `properties.reasoningEfforts` from provider-account metadata when the
|
|
235
|
+
* model supports thinking. Pure — used by {@link listEnabledModels} and tests.
|
|
236
|
+
*/
|
|
237
|
+
export function enrichModelsWithReasoningEfforts(
|
|
238
|
+
models: TfyModelSelectorEntry[],
|
|
239
|
+
providerMetadataRaw: unknown,
|
|
240
|
+
): TfyModelSelectorEntry[] {
|
|
241
|
+
const map = buildMetadataMap(providerMetadataRaw);
|
|
242
|
+
if (map.size === 0) return models;
|
|
243
|
+
return models.map((model) => {
|
|
244
|
+
const meta = map.get(metadataKey(model.provider.name, model.modelId));
|
|
245
|
+
const reasoningEfforts = reasoningEffortsForModel(
|
|
246
|
+
meta,
|
|
247
|
+
model.provider.name,
|
|
248
|
+
);
|
|
249
|
+
if (reasoningEfforts == null) return model;
|
|
250
|
+
return {
|
|
251
|
+
...model,
|
|
252
|
+
properties: { ...model.properties, reasoningEfforts },
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
222
257
|
export async function listEnabledModels(
|
|
223
258
|
opts: CpCredentials,
|
|
224
259
|
): Promise<TfyModelSelectorEntry[]> {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
"/api/svc/v1/llm-gateway/model/enabled",
|
|
228
|
-
|
|
229
|
-
|
|
260
|
+
// Parallel: providers is enrichment-only; soft-fail keeps models usable.
|
|
261
|
+
const [raw, providers] = await Promise.all([
|
|
262
|
+
cpFetch<unknown>(opts, "/api/svc/v1/llm-gateway/model/enabled"),
|
|
263
|
+
cpFetch<unknown>(
|
|
264
|
+
opts,
|
|
265
|
+
"/api/svc/v1/provider-accounts/providers",
|
|
266
|
+
).catch(() => null),
|
|
267
|
+
]);
|
|
268
|
+
const models = normalizeEnabledModels(raw);
|
|
269
|
+
if (providers == null) return models;
|
|
270
|
+
return enrichModelsWithReasoningEfforts(models, providers);
|
|
230
271
|
}
|
|
231
272
|
|
|
232
273
|
// ---------------------------------------------------------------------------
|