@truefoundry/assistant-ui-runtime 0.1.10-rc.1 → 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 +66 -0
- package/dist/{chunk-BRPTG6VA.js → chunk-2NLIAJJX.js} +100 -12
- package/dist/chunk-2NLIAJJX.js.map +1 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.js +70 -66
- 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-CgZUnILu.d.ts → types-CSRQSnHu.d.ts} +148 -80
- package/package.json +3 -3
- package/src/convertTurnMessages.test.ts +123 -0
- package/src/convertTurnMessages.ts +8 -2
- package/src/draft/truefoundryDraftThreadListAdapter.test.ts +58 -4
- package/src/draft/truefoundryDraftThreadListAdapter.ts +18 -22
- package/src/index.ts +27 -0
- package/src/plugins/truefoundry-agent-server-adapter/chatServer.ts +1 -1
- package/src/plugins/truefoundry-agent-server-adapter/cp.test.ts +169 -6
- package/src/plugins/truefoundry-agent-server-adapter/cp.ts +126 -1
- package/src/plugins/truefoundry-agent-server-adapter/createTrueFoundryAgentUIServer.ts +7 -0
- package/src/plugins/truefoundry-agent-server-adapter/normalizeAgentSpec.test.ts +34 -0
- package/src/plugins/truefoundry-agent-server-adapter/normalizeAgentSpec.ts +12 -5
- package/src/plugins/truefoundry-agent-server-adapter/types.ts +2 -2
- package/src/server/index.ts +15 -0
- package/src/server/types.ts +448 -381
- package/src/sessionThreadMetadata.ts +42 -0
- package/src/truefoundryOwnedSessionsThreadListAdapter.test.ts +17 -0
- package/src/truefoundryOwnedSessionsThreadListAdapter.ts +13 -25
- package/src/truefoundryThreadListAdapter.test.ts +17 -9
- package/src/truefoundryThreadListAdapter.ts +9 -14
- package/src/types.ts +5 -0
- package/src/useTrueFoundryAgentRuntime.ts +4 -1
- package/dist/chunk-BRPTG6VA.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AgentSessionClient } from 'truefoundry-gateway-sdk/agents';
|
|
2
2
|
import { PrivateAgentSessionClient } from 'truefoundry-gateway-sdk/agents/private';
|
|
3
|
-
import { A as AgentSpec,
|
|
3
|
+
import { A as AgentSpec, K as CreateSessionRequest, W as ListSessionsParams, S as Session, d as Turn, 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,10 +246,18 @@ 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
|
-
/** Agent selector row
|
|
254
|
+
/** Agent selector row. Host extends for metadata; `agentSpec` enables Edit. */
|
|
249
255
|
interface AgentSelectorEntry {
|
|
250
256
|
name: string;
|
|
257
|
+
/** Stable id when distinct from display `name`. Falls back to `name` when omitted. */
|
|
258
|
+
agentId?: string;
|
|
259
|
+
/** Published agent spec — required for Edit; optional for Try-only hosts. */
|
|
260
|
+
agentSpec?: AgentSpec;
|
|
251
261
|
}
|
|
252
262
|
type SearchAgentSelectorParams = {
|
|
253
263
|
query?: string;
|
|
@@ -255,19 +265,19 @@ type SearchAgentSelectorParams = {
|
|
|
255
265
|
offset?: number;
|
|
256
266
|
};
|
|
257
267
|
/**
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
*/
|
|
271
281
|
type SkillMount = object;
|
|
272
282
|
type McpServerMount = object;
|
|
273
283
|
interface ModelParams {
|
|
@@ -279,10 +289,10 @@ interface Model {
|
|
|
279
289
|
params?: ModelParams;
|
|
280
290
|
}
|
|
281
291
|
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
+
*/
|
|
286
296
|
interface AgentSpec<TModel extends Model = Model, TSkill extends SkillMount = SkillMount, TMcp extends McpServerMount = McpServerMount> {
|
|
287
297
|
model: TModel;
|
|
288
298
|
skills?: TSkill[];
|
|
@@ -321,11 +331,12 @@ type PageParams = {
|
|
|
321
331
|
pageToken?: string;
|
|
322
332
|
};
|
|
323
333
|
interface ListSessionsParams extends PageParams {
|
|
324
|
-
|
|
334
|
+
/** Host-owned agent identity filter. Hosts that key agents by name pass that name here. */
|
|
335
|
+
agentId?: string;
|
|
325
336
|
/** Host-specific filter (e.g. TFY startTimestamp). */
|
|
326
337
|
startTimestamp?: string;
|
|
327
338
|
}
|
|
328
|
-
type PreviousTurnIdInput = "auto" | string;
|
|
339
|
+
type PreviousTurnIdInput = "auto" | "none" | string;
|
|
329
340
|
type UserMessageContent = string | Array<{
|
|
330
341
|
type: "text";
|
|
331
342
|
text: string;
|
|
@@ -387,11 +398,11 @@ interface Turn {
|
|
|
387
398
|
createdAt: string;
|
|
388
399
|
}
|
|
389
400
|
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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
|
+
*/
|
|
395
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> {
|
|
396
407
|
createSession(req: TCreate): Promise<TSession>;
|
|
397
408
|
listSessions(req?: TList): Promise<ListResult<TSession>>;
|
|
@@ -454,43 +465,63 @@ interface AgentChatServer<TSpec extends AgentSpec = AgentSpec, TSession extends
|
|
|
454
465
|
path: string;
|
|
455
466
|
}): Promise<Blob>;
|
|
456
467
|
}
|
|
468
|
+
/** Request body for `AgentBuilderServer.saveAgent`. */
|
|
469
|
+
interface SaveAgentRequest<TSpec extends AgentSpec = AgentSpec> {
|
|
470
|
+
agentName: string;
|
|
471
|
+
agentSpec: TSpec;
|
|
472
|
+
}
|
|
457
473
|
/**
|
|
458
|
-
* Builder
|
|
459
|
-
* Passed separately from the runtime's chat server.
|
|
474
|
+
* Builder feature flags — atoms gate sandbox / skill / settings surfaces on these.
|
|
460
475
|
*/
|
|
461
|
-
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>;
|
|
462
496
|
getModels(): Promise<TModel[]>;
|
|
463
497
|
getSkills(): Promise<TSkill[]>;
|
|
464
498
|
getMcp(): Promise<TMcp[]>;
|
|
465
499
|
searchAgents(req?: SearchAgentSelectorParams): Promise<TAgent[]>;
|
|
466
|
-
saveAgent(req:
|
|
467
|
-
agentName: string;
|
|
468
|
-
agentSpec: TSpec;
|
|
469
|
-
}): Promise<TSave>;
|
|
500
|
+
saveAgent(req: SaveAgentRequest<TSpec>): Promise<TSave>;
|
|
470
501
|
deleteAgent?(req: {
|
|
471
502
|
agentName: string;
|
|
472
503
|
}): Promise<void>;
|
|
473
504
|
}
|
|
474
505
|
/**
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
+
*/
|
|
481
512
|
type ProviderType = string;
|
|
482
513
|
/**
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
514
|
+
* Model row — form "Model ID" + "Display name".
|
|
515
|
+
* Host extends for properties, etc.
|
|
516
|
+
*/
|
|
486
517
|
interface ModelEntry {
|
|
487
518
|
id: string;
|
|
488
519
|
name: string;
|
|
489
520
|
}
|
|
490
521
|
/**
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
522
|
+
* Write config for create/update (custom form + catalog "Save key").
|
|
523
|
+
* Host extends. `baseUrl` present iff `type === "custom"`.
|
|
524
|
+
*/
|
|
494
525
|
interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
|
|
495
526
|
type: ProviderType;
|
|
496
527
|
name: string;
|
|
@@ -500,9 +531,9 @@ interface ModelProviderConfigBase<TModel extends ModelEntry = ModelEntry> {
|
|
|
500
531
|
models: TModel[];
|
|
501
532
|
}
|
|
502
533
|
/**
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
534
|
+
* Configured provider card (list/read). No raw `apiKey`.
|
|
535
|
+
* Host extends for apiKeySet, timestamps, etc.
|
|
536
|
+
*/
|
|
506
537
|
interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
|
|
507
538
|
id: string;
|
|
508
539
|
type: ProviderType;
|
|
@@ -512,14 +543,16 @@ interface ModelProviderBase<TModel extends ModelEntry = ModelEntry> {
|
|
|
512
543
|
models: TModel[];
|
|
513
544
|
}
|
|
514
545
|
/**
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
+
*/
|
|
519
550
|
interface ModelProviderCatalogEntry<TModel extends ModelEntry = ModelEntry> {
|
|
520
551
|
type: ProviderType;
|
|
521
552
|
name: string;
|
|
522
553
|
models: TModel[];
|
|
554
|
+
supportedReasoningEfforts?: string[];
|
|
555
|
+
logo?: string;
|
|
523
556
|
}
|
|
524
557
|
/** Create — no `id`; server assigns it. Catalog path = entry + apiKey. */
|
|
525
558
|
type CreateModelProviderRequest<TModel extends ModelEntry = ModelEntry> = ModelProviderConfigBase<TModel>;
|
|
@@ -560,7 +593,7 @@ type ConnectorAuthNone = {
|
|
|
560
593
|
type ConnectorAuth = ConnectorAuthOAuth | ConnectorAuthApiKey | ConnectorAuthNone;
|
|
561
594
|
type ConnectorAuthPublicOAuth = {
|
|
562
595
|
type: "dcr";
|
|
563
|
-
authUrl
|
|
596
|
+
authUrl?: string;
|
|
564
597
|
};
|
|
565
598
|
type ConnectorAuthPublicApiKey = {
|
|
566
599
|
type: "header";
|
|
@@ -571,18 +604,19 @@ type ConnectorAuthPublicNone = {
|
|
|
571
604
|
};
|
|
572
605
|
type ConnectorAuthPublic = ConnectorAuthPublicOAuth | ConnectorAuthPublicApiKey | ConnectorAuthPublicNone;
|
|
573
606
|
/**
|
|
574
|
-
|
|
575
|
-
|
|
607
|
+
* MCP / connector create-edit config. Host extends for extra fields, etc.
|
|
608
|
+
*/
|
|
576
609
|
interface ConnectorConfigBase<TAuth extends ConnectorAuth = ConnectorAuth> {
|
|
577
610
|
name: string;
|
|
578
611
|
url: string;
|
|
579
612
|
auth: TAuth;
|
|
580
613
|
}
|
|
581
614
|
/**
|
|
582
|
-
* 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`.
|
|
583
617
|
* Host extends.
|
|
584
618
|
*/
|
|
585
|
-
interface ConnectorBase<
|
|
619
|
+
interface ConnectorBase<TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
|
|
586
620
|
id: string;
|
|
587
621
|
name: string;
|
|
588
622
|
description: string;
|
|
@@ -591,7 +625,6 @@ interface ConnectorBase<TTool extends ToolBase = ToolBase, TAuth extends Connect
|
|
|
591
625
|
/** When true, UI should not show Disconnect. */
|
|
592
626
|
requiresAuth: boolean;
|
|
593
627
|
authenticated: boolean;
|
|
594
|
-
tools: TTool[];
|
|
595
628
|
}
|
|
596
629
|
/** Discovery catalog entry for "+ Add MCP server". Host extends. */
|
|
597
630
|
interface ConnectorCatalogEntry<TAuth extends ConnectorAuthPublic = ConnectorAuthPublic> {
|
|
@@ -600,6 +633,7 @@ interface ConnectorCatalogEntry<TAuth extends ConnectorAuthPublic = ConnectorAut
|
|
|
600
633
|
description?: string;
|
|
601
634
|
url: string;
|
|
602
635
|
auth: TAuth;
|
|
636
|
+
logo?: string;
|
|
603
637
|
}
|
|
604
638
|
/** Create connector — no `id`; server assigns it. Host extends. */
|
|
605
639
|
type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = ConnectorConfigBase<TAuth>;
|
|
@@ -607,21 +641,36 @@ type CreateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = Conne
|
|
|
607
641
|
type UpdateConnectorRequest<TAuth extends ConnectorAuth = ConnectorAuth> = ConnectorConfigBase<TAuth> & {
|
|
608
642
|
id: string;
|
|
609
643
|
};
|
|
610
|
-
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>> {
|
|
611
655
|
getConnectorCatalog(): Promise<TCatalogEntry[]>;
|
|
656
|
+
getConnector(req: {
|
|
657
|
+
id: string;
|
|
658
|
+
}): Promise<TConnector>;
|
|
612
659
|
listConnectors(req?: {
|
|
613
660
|
query?: string;
|
|
614
661
|
}): Promise<TConnector[]>;
|
|
662
|
+
getToolsByConnectorId(req: {
|
|
663
|
+
id: string;
|
|
664
|
+
}): Promise<TTool[]>;
|
|
615
665
|
createConnector(req: TCreate): Promise<TConnector>;
|
|
616
666
|
/** Full replace update keyed by connector `id`. */
|
|
617
667
|
updateConnector(req: TUpdate): Promise<TConnector>;
|
|
618
668
|
/**
|
|
619
669
|
* Start connector auth (e.g. OAuth).
|
|
620
|
-
*
|
|
670
|
+
* May return a connector (already authenticated / with `auth.authUrl`) or a
|
|
671
|
+
* result carrying `authorization_endpoint` for the popup flow.
|
|
621
672
|
*/
|
|
622
|
-
authenticateConnector(req:
|
|
623
|
-
id: string;
|
|
624
|
-
}): Promise<TConnector>;
|
|
673
|
+
authenticateConnector(req: AuthenticateConnectorRequest): Promise<TConnector | ConnectorAuthenticationResult<TConnector>>;
|
|
625
674
|
/** Clear connector auth. */
|
|
626
675
|
disconnectConnector(req: {
|
|
627
676
|
id: string;
|
|
@@ -674,7 +723,7 @@ interface SkillCatalogServer<TSkill extends SkillBase = SkillBase, TCatalogEntry
|
|
|
674
723
|
id: string;
|
|
675
724
|
}): Promise<void>;
|
|
676
725
|
}
|
|
677
|
-
/** Mutable sandbox settings shared by catalog rows, create, and update. */
|
|
726
|
+
/** Mutable sandbox provider settings shared by catalog rows, create, and update. */
|
|
678
727
|
interface SandboxConfig {
|
|
679
728
|
snapshotName: string;
|
|
680
729
|
execTimeoutMs: number;
|
|
@@ -687,14 +736,18 @@ interface SandboxCatalogEntry extends SandboxConfig {
|
|
|
687
736
|
name: string;
|
|
688
737
|
type: string;
|
|
689
738
|
}
|
|
690
|
-
|
|
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 {
|
|
691
744
|
id: string;
|
|
692
745
|
name: string;
|
|
693
746
|
catalogId: string;
|
|
694
747
|
isConnected: boolean;
|
|
695
748
|
}
|
|
696
749
|
interface CreateSandboxRequest extends SandboxConfig {
|
|
697
|
-
/** `SandboxCatalogEntry.id` used to create this sandbox. */
|
|
750
|
+
/** `SandboxCatalogEntry.id` used to create this sandbox provider. */
|
|
698
751
|
catalogId: string;
|
|
699
752
|
name: string;
|
|
700
753
|
type: string;
|
|
@@ -702,24 +755,37 @@ interface CreateSandboxRequest extends SandboxConfig {
|
|
|
702
755
|
}
|
|
703
756
|
interface UpdateSandboxRequest extends SandboxConfig {
|
|
704
757
|
id: string;
|
|
705
|
-
|
|
758
|
+
/** Omit to keep the existing key; send a value to rotate. */
|
|
759
|
+
apiKey?: string;
|
|
706
760
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
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?: {
|
|
710
770
|
query?: string;
|
|
711
|
-
}): Promise<
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
771
|
+
}): Promise<TProvider[]>;
|
|
772
|
+
createSandboxProvider(req: TCreate): Promise<TProvider>;
|
|
773
|
+
updateSandboxProvider(req: TUpdate): Promise<TProvider>;
|
|
774
|
+
deleteSandboxProvider?(req: {
|
|
715
775
|
id: string;
|
|
716
776
|
}): Promise<void>;
|
|
717
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;
|
|
718
784
|
/**
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
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
|
+
*/
|
|
723
789
|
interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogServer, TConnectorCatalog extends ConnectorCatalogServer = ConnectorCatalogServer, TSkillCatalog extends SkillCatalogServer = SkillCatalogServer, TSandboxCatalog extends SandboxCatalogServer = SandboxCatalogServer> {
|
|
724
790
|
modelCatalog: TModelCatalog;
|
|
725
791
|
connectorCatalog: TConnectorCatalog;
|
|
@@ -730,15 +796,17 @@ interface CatalogServer<TModelCatalog extends ModelCatalogServer = ModelCatalogS
|
|
|
730
796
|
}
|
|
731
797
|
/**
|
|
732
798
|
* Composed host port: chat + builder + optional settings catalog.
|
|
733
|
-
* Agent-ui's `AgentUIServer` mirrors this shape; named differently here to
|
|
734
|
-
* avoid colliding with that package's local type name.
|
|
735
799
|
*
|
|
736
800
|
* `catalog` is optional — if the host passes it, settings UI can call
|
|
737
801
|
* `useCatalogServer()` / show modelCatalog, connectorCatalog, and skillCatalog;
|
|
738
802
|
* if omitted, those surfaces stay hidden.
|
|
803
|
+
*
|
|
804
|
+
* trueforge-ui re-exports this as `AgentUIServer`.
|
|
739
805
|
*/
|
|
740
806
|
type AgentUIServerPort<TChat extends AgentChatServer = AgentChatServer, TBuilder extends AgentBuilderServer = AgentBuilderServer, TCatalog extends CatalogServer = CatalogServer> = TChat & TBuilder & {
|
|
741
807
|
catalog?: TCatalog;
|
|
742
808
|
};
|
|
809
|
+
/** Host-facing alias used by trueforge-ui. */
|
|
810
|
+
type AgentUIServer = AgentUIServerPort;
|
|
743
811
|
|
|
744
|
-
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truefoundry/assistant-ui-runtime",
|
|
3
|
-
"version": "0.1.
|
|
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": {
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"typecheck": "tsc --noEmit"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@assistant-ui/core": "^0.2.
|
|
58
|
-
"@assistant-ui/store": "^0.2.
|
|
57
|
+
"@assistant-ui/core": "^0.2.22",
|
|
58
|
+
"@assistant-ui/store": "^0.2.21"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@types/react": "*",
|
|
@@ -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",
|