@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.
- package/CHANGELOG.md +40 -0
- package/dist/{chunk-6ZOGBD7E.js → chunk-2NLIAJJX.js} +8 -1
- package/dist/{chunk-6ZOGBD7E.js.map → chunk-2NLIAJJX.js.map} +1 -1
- 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 -3
- 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-CSRQSnHu.d.ts} +141 -78
- 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 +27 -0
- 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 +15 -0
- package/src/server/types.ts +447 -385
- package/src/sessionThreadMetadata.ts +5 -2
- package/src/truefoundryOwnedSessionsThreadListAdapter.test.ts +2 -1
- package/src/truefoundryThreadListAdapter.test.ts +1 -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, 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
|
|
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.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
-
|
|
489
|
-
|
|
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
|
-
|
|
497
|
-
|
|
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
|
-
|
|
509
|
-
|
|
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
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
|
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
|
-
|
|
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<
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
758
|
+
/** Omit to keep the existing key; send a value to rotate. */
|
|
759
|
+
apiKey?: string;
|
|
711
760
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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<
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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 {
|
|
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
|
@@ -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
|
-
...(
|
|
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: {
|
|
1743
|
+
custom: {
|
|
1744
|
+
...(existing?.role === "assistant" ? existing.metadata.custom : {}),
|
|
1745
|
+
...update.metadata?.custom,
|
|
1746
|
+
turnId,
|
|
1747
|
+
},
|
|
1742
1748
|
},
|
|
1743
1749
|
};
|
|
1744
1750
|
}
|