@datalayer/agent-runtimes 1.3.25 → 1.3.28
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/lib/chat/messages/ChatMessages.d.ts +4 -4
- package/lib/chat/messages/ChatMessages.js +17 -17
- package/lib/config/AgentConfiguration.js +1 -1
- package/lib/examples/example-selector.js +1 -1
- package/lib/loop/apps/AppRenderer.d.ts +8 -1
- package/lib/loop/apps/AppRenderer.js +10 -2
- package/lib/loop/apps/checks.d.ts +6 -1
- package/lib/loop/apps/checks.js +17 -0
- package/lib/loop/embed/LoopEmbed.js +14 -1
- package/lib/loop/plugins/chat/ChatView.js +40 -6
- package/lib/loop/plugins/chat/Presence.d.ts +9 -0
- package/lib/loop/plugins/chat/Presence.js +57 -0
- package/lib/loop/plugins/chat/index.d.ts +27 -0
- package/lib/loop/plugins/chat/presenceStatus.d.ts +26 -0
- package/lib/loop/plugins/chat/presenceStatus.js +28 -0
- package/lib/loop/presets.d.ts +5 -1
- package/lib/loop/presets.js +4 -2
- package/lib/protocols/A2AAdapter.d.ts +1 -1
- package/lib/specs/uiPlugins.d.ts +6 -1
- package/lib/specs/uiPlugins.js +471 -0
- package/lib/stores/chatStore.d.ts +11 -11
- package/lib/stores/chatStore.js +34 -34
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/types/agentspecs.d.ts +33 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +1 -1
- package/lib/types/{extensions.d.ts → uiPlugins.d.ts} +49 -49
- package/lib/types/{extensions.js → uiPlugins.js} +8 -8
- package/lib/{extensions/A2UIExtension.d.ts → ui-plugins/A2UIPlugin.d.ts} +7 -7
- package/lib/{extensions/A2UIExtension.js → ui-plugins/A2UIPlugin.js} +4 -4
- package/lib/{extensions/MCPUIExtension.d.ts → ui-plugins/MCPUIPlugin.d.ts} +9 -9
- package/lib/{extensions/MCPUIExtension.js → ui-plugins/MCPUIPlugin.js} +6 -6
- package/lib/ui-plugins/UIPluginRegistry.d.ts +65 -0
- package/lib/{extensions/ExtensionRegistry.js → ui-plugins/UIPluginRegistry.js} +32 -32
- package/lib/ui-plugins/index.d.ts +9 -0
- package/lib/ui-plugins/index.js +12 -0
- package/package.json +1 -1
- package/scripts/codegen/generate_agents.py +6 -6
- package/scripts/codegen/generate_ui_plugins.py +64 -4
- package/lib/extensions/ExtensionRegistry.d.ts +0 -65
- package/lib/extensions/index.d.ts +0 -9
- package/lib/extensions/index.js +0 -12
package/lib/stores/index.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* @module store
|
|
9
9
|
*/
|
|
10
10
|
export { agentRuntimeStore, useAgentRuntimeStore, useAgentRuntimeConnection, useAgentRuntimeStatus, useAgentRuntimeError, useAgentRuntimeIsLaunching, useAgentRuntimeApprovals, useAgentRuntimePendingCount, useAgentRuntimeMcpStatus, useAgentRuntimeFullContext, useAgentRuntimeContextSnapshot, useAgentRuntimeCostUsage, useAgentRuntimeCodemodeStatus, useAgentRuntimeWsState, useAgentRuntimeLoadedSkills, useAgentRuntimeActiveSubagentToolCallId, useAgentRuntimeRunningSubagentNames, runningSubagentNames, isSubagentRunOver, useAgentRuntimeSubagentActivity, useAgentRuntimeSubagentActivityByToolCall, useAgentRuntimeCompaction, useAgentRuntimeHistoryVersion, getAgentRuntimeState, subscribeToAgentRuntime, } from './agentRuntimeStore';
|
|
11
|
-
export { useChatStore, useChatMessages, useChatLoading, useChatStreaming, useChatError, useChatTools, useChatOpen, useChatConfig, useChatReady, useChatInferenceProvider,
|
|
11
|
+
export { useChatStore, useChatMessages, useChatLoading, useChatStreaming, useChatError, useChatTools, useChatOpen, useChatConfig, useChatReady, useChatInferenceProvider, useChatUIPluginRegistry, defaultChatConfig, } from './chatStore';
|
|
12
12
|
export { useConversationStore, useConversationMessages, useNeedsFetch, useIsFetching, } from './conversationStore';
|
|
@@ -74,6 +74,35 @@ export interface AgentCapability {
|
|
|
74
74
|
/** Free text, for humans reading a catalogue; never matched on. */
|
|
75
75
|
tags?: string[];
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* A visual component a UI plugin renders (LOOP C-13), named as a surface names
|
|
79
|
+
* it. A standard one's properties are its protocol's own; Datalayer's own
|
|
80
|
+
* carry theirs as a JSON Schema, from which its properties form is drawn (C-14).
|
|
81
|
+
*/
|
|
82
|
+
export interface ComponentSpec {
|
|
83
|
+
/** The name a surface gives it (e.g. 'Table'). */
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
/** What it is for, in a sentence. */
|
|
87
|
+
description: string;
|
|
88
|
+
/** text, input, action, data, conversation, media, layout. */
|
|
89
|
+
category: string;
|
|
90
|
+
/** Its face on the palette. */
|
|
91
|
+
emoji: string;
|
|
92
|
+
/** Its properties are its protocol's own. */
|
|
93
|
+
standard: boolean;
|
|
94
|
+
/** Its properties as a JSON Schema, when it is Datalayer's own. */
|
|
95
|
+
properties?: Record<string, unknown>;
|
|
96
|
+
/** What it can be bound to: what it shows, what it sends. */
|
|
97
|
+
bindings?: {
|
|
98
|
+
shows: string[];
|
|
99
|
+
sends: string[];
|
|
100
|
+
};
|
|
101
|
+
/** What it reports. */
|
|
102
|
+
events: string[];
|
|
103
|
+
/** A valid configuration of it. */
|
|
104
|
+
example?: Record<string, unknown>;
|
|
105
|
+
}
|
|
77
106
|
/**
|
|
78
107
|
* How an agent's answer becomes an interface: a protocol the host renders
|
|
79
108
|
* (`agentspecs/ui-plugins`). An agent spec's `uiPlugin` names one.
|
|
@@ -89,6 +118,10 @@ export interface UIPluginSpec {
|
|
|
89
118
|
docsUrl: string;
|
|
90
119
|
/** Whether an agent spec may name it today. */
|
|
91
120
|
enabled: boolean;
|
|
121
|
+
/** The catalog its components are written in. */
|
|
122
|
+
catalog: string;
|
|
123
|
+
/** The visual components it renders (LOOP C-13). */
|
|
124
|
+
components: ComponentSpec[];
|
|
92
125
|
}
|
|
93
126
|
/** A check a Frame requires of the output of work done under it. */
|
|
94
127
|
export interface FrameGuardSpec {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export * from './eventspecs';
|
|
|
17
17
|
export * from './evals';
|
|
18
18
|
export * from './examples';
|
|
19
19
|
export * from './execution';
|
|
20
|
-
export * from './
|
|
20
|
+
export * from './uiPlugins';
|
|
21
21
|
export * from './guardrails';
|
|
22
22
|
export * from './inference';
|
|
23
23
|
export * from './loops';
|
package/lib/types/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export * from './eventspecs';
|
|
|
21
21
|
export * from './evals';
|
|
22
22
|
export * from './examples';
|
|
23
23
|
export * from './execution';
|
|
24
|
-
export * from './
|
|
24
|
+
export * from './uiPlugins';
|
|
25
25
|
export * from './guardrails';
|
|
26
26
|
export * from './inference';
|
|
27
27
|
export * from './loops';
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* UI plugin types for the chat.
|
|
3
|
+
* UI plugins add pluggable UI and protocol capabilities.
|
|
4
4
|
*
|
|
5
|
-
* @module types/
|
|
5
|
+
* @module types/plugin
|
|
6
6
|
*/
|
|
7
7
|
import type { ReactNode } from 'react';
|
|
8
8
|
import type { ChatMessage } from './messages';
|
|
9
9
|
import type { ToolRenderProps } from './tools';
|
|
10
10
|
import type { ProtocolEvent } from './protocol';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* UI plugin type identifiers
|
|
13
13
|
*/
|
|
14
|
-
export type
|
|
14
|
+
export type UIPluginType = 'a2ui' | 'mcp-ui' | 'tool-approval' | 'dev-console' | 'activity' | 'custom';
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* UI plugin lifecycle hooks
|
|
17
17
|
*/
|
|
18
|
-
export interface
|
|
19
|
-
/** Called when
|
|
18
|
+
export interface UIPluginLifecycle {
|
|
19
|
+
/** Called when plugin is registered */
|
|
20
20
|
onRegister?: () => void;
|
|
21
|
-
/** Called when
|
|
21
|
+
/** Called when plugin is unregistered */
|
|
22
22
|
onUnregister?: () => void;
|
|
23
23
|
/** Called when chat context changes */
|
|
24
24
|
onContextChange?: (context: unknown) => void;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Message renderer
|
|
27
|
+
* Message renderer plugin
|
|
28
28
|
* Used to render custom message types (A2UI, activity messages, etc.)
|
|
29
29
|
*/
|
|
30
|
-
export interface
|
|
30
|
+
export interface MessageRendererUIPlugin {
|
|
31
31
|
type: 'message-renderer';
|
|
32
|
-
/** Unique
|
|
32
|
+
/** Unique plugin name */
|
|
33
33
|
name: string;
|
|
34
|
-
/** Check if this
|
|
34
|
+
/** Check if this plugin can render the message */
|
|
35
35
|
canRender: (message: ChatMessage) => boolean;
|
|
36
36
|
/** Render the message */
|
|
37
37
|
render: (props: {
|
|
@@ -42,14 +42,14 @@ export interface MessageRendererExtension {
|
|
|
42
42
|
priority?: number;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Activity renderer
|
|
45
|
+
* Activity renderer plugin
|
|
46
46
|
* Used to render protocol-specific activity messages
|
|
47
47
|
*/
|
|
48
|
-
export interface
|
|
48
|
+
export interface ActivityRendererUIPlugin {
|
|
49
49
|
type: 'activity-renderer';
|
|
50
|
-
/** Unique
|
|
50
|
+
/** Unique plugin name */
|
|
51
51
|
name: string;
|
|
52
|
-
/** Activity types this
|
|
52
|
+
/** Activity types this plugin handles */
|
|
53
53
|
activityTypes: string[];
|
|
54
54
|
/** Render the activity */
|
|
55
55
|
render: (props: {
|
|
@@ -61,14 +61,14 @@ export interface ActivityRendererExtension {
|
|
|
61
61
|
priority?: number;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Tool UI
|
|
64
|
+
* Tool UI plugin
|
|
65
65
|
* Used to provide custom UI for tool calls (beyond tool's own render)
|
|
66
66
|
*/
|
|
67
|
-
export interface
|
|
67
|
+
export interface ToolUIPlugin {
|
|
68
68
|
type: 'tool-ui';
|
|
69
|
-
/** Unique
|
|
69
|
+
/** Unique plugin name */
|
|
70
70
|
name: string;
|
|
71
|
-
/** Tool names this
|
|
71
|
+
/** Tool names this plugin handles (or '*' for all) */
|
|
72
72
|
toolNames: string[] | '*';
|
|
73
73
|
/** Render custom UI for tool */
|
|
74
74
|
render: (props: ToolRenderProps & {
|
|
@@ -79,14 +79,14 @@ export interface ToolUIExtension {
|
|
|
79
79
|
priority?: number;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Protocol event
|
|
82
|
+
* Protocol event plugin
|
|
83
83
|
* Used to handle custom protocol events
|
|
84
84
|
*/
|
|
85
|
-
export interface
|
|
85
|
+
export interface ProtocolEventUIPlugin {
|
|
86
86
|
type: 'protocol-event';
|
|
87
|
-
/** Unique
|
|
87
|
+
/** Unique plugin name */
|
|
88
88
|
name: string;
|
|
89
|
-
/** Event types this
|
|
89
|
+
/** Event types this plugin handles */
|
|
90
90
|
eventTypes: string[];
|
|
91
91
|
/** Handle the protocol event */
|
|
92
92
|
handle: (event: ProtocolEvent) => void;
|
|
@@ -94,12 +94,12 @@ export interface ProtocolEventExtension {
|
|
|
94
94
|
render?: (event: ProtocolEvent) => ReactNode;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
* Panel
|
|
97
|
+
* Panel plugin
|
|
98
98
|
* Used to add custom panels (dev console, settings, etc.)
|
|
99
99
|
*/
|
|
100
|
-
export interface
|
|
100
|
+
export interface PanelUIPlugin {
|
|
101
101
|
type: 'panel';
|
|
102
|
-
/** Unique
|
|
102
|
+
/** Unique plugin name */
|
|
103
103
|
name: string;
|
|
104
104
|
/** Panel title */
|
|
105
105
|
title: string;
|
|
@@ -113,30 +113,30 @@ export interface PanelExtension {
|
|
|
113
113
|
defaultVisible?: boolean;
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
-
* Union type for all
|
|
116
|
+
* Union type for all uiPlugins
|
|
117
117
|
*/
|
|
118
|
-
export type
|
|
118
|
+
export type ChatUIPlugin = MessageRendererUIPlugin | ActivityRendererUIPlugin | ToolUIPlugin | ProtocolEventUIPlugin | PanelUIPlugin;
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
120
|
+
* UI plugin registration options
|
|
121
121
|
*/
|
|
122
|
-
export interface
|
|
123
|
-
/** Replace existing
|
|
122
|
+
export interface UIPluginRegistrationOptions {
|
|
123
|
+
/** Replace existing plugin with same name */
|
|
124
124
|
replace?: boolean;
|
|
125
|
-
/** Enable/disable
|
|
125
|
+
/** Enable/disable plugin */
|
|
126
126
|
enabled?: boolean;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* UI plugin registry entry
|
|
130
130
|
*/
|
|
131
|
-
export interface
|
|
132
|
-
|
|
131
|
+
export interface UIPluginRegistryEntry {
|
|
132
|
+
plugin: ChatUIPlugin;
|
|
133
133
|
enabled: boolean;
|
|
134
134
|
registeredAt: Date;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* A2UI specific
|
|
137
|
+
* A2UI specific plugin types
|
|
138
138
|
*/
|
|
139
|
-
export declare namespace
|
|
139
|
+
export declare namespace A2UIPlugin {
|
|
140
140
|
/** A2UI surface state */
|
|
141
141
|
interface Surface {
|
|
142
142
|
id: string;
|
|
@@ -164,18 +164,18 @@ export declare namespace A2UIExtension {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
|
-
* Type guard to check
|
|
167
|
+
* Type guard to check plugin type
|
|
168
168
|
*/
|
|
169
|
-
export declare function
|
|
170
|
-
export declare function
|
|
171
|
-
export declare function
|
|
172
|
-
export declare function
|
|
173
|
-
export declare function
|
|
169
|
+
export declare function isMessageRendererUIPlugin(ext: ChatUIPlugin): ext is MessageRendererUIPlugin;
|
|
170
|
+
export declare function isActivityRendererUIPlugin(ext: ChatUIPlugin): ext is ActivityRendererUIPlugin;
|
|
171
|
+
export declare function isToolUIPlugin(ext: ChatUIPlugin): ext is ToolUIPlugin;
|
|
172
|
+
export declare function isProtocolEventUIPlugin(ext: ChatUIPlugin): ext is ProtocolEventUIPlugin;
|
|
173
|
+
export declare function isPanelUIPlugin(ext: ChatUIPlugin): ext is PanelUIPlugin;
|
|
174
174
|
/**
|
|
175
|
-
* Helper to create a message renderer
|
|
175
|
+
* Helper to create a message renderer plugin
|
|
176
176
|
*/
|
|
177
|
-
export declare function createMessageRenderer(name: string, canRender:
|
|
177
|
+
export declare function createMessageRenderer(name: string, canRender: MessageRendererUIPlugin['canRender'], render: MessageRendererUIPlugin['render'], priority?: number): MessageRendererUIPlugin;
|
|
178
178
|
/**
|
|
179
|
-
* Helper to create an activity renderer
|
|
179
|
+
* Helper to create an activity renderer plugin
|
|
180
180
|
*/
|
|
181
|
-
export declare function createActivityRenderer(name: string, activityTypes: string[], render:
|
|
181
|
+
export declare function createActivityRenderer(name: string, activityTypes: string[], render: ActivityRendererUIPlugin['render'], priority?: number): ActivityRendererUIPlugin;
|
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Type guard to check
|
|
6
|
+
* Type guard to check plugin type
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
8
|
+
export function isMessageRendererUIPlugin(ext) {
|
|
9
9
|
return ext.type === 'message-renderer';
|
|
10
10
|
}
|
|
11
|
-
export function
|
|
11
|
+
export function isActivityRendererUIPlugin(ext) {
|
|
12
12
|
return ext.type === 'activity-renderer';
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function isToolUIPlugin(ext) {
|
|
15
15
|
return ext.type === 'tool-ui';
|
|
16
16
|
}
|
|
17
|
-
export function
|
|
17
|
+
export function isProtocolEventUIPlugin(ext) {
|
|
18
18
|
return ext.type === 'protocol-event';
|
|
19
19
|
}
|
|
20
|
-
export function
|
|
20
|
+
export function isPanelUIPlugin(ext) {
|
|
21
21
|
return ext.type === 'panel';
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Helper to create a message renderer
|
|
24
|
+
* Helper to create a message renderer plugin
|
|
25
25
|
*/
|
|
26
26
|
export function createMessageRenderer(name, canRender, render, priority = 0) {
|
|
27
27
|
return {
|
|
@@ -33,7 +33,7 @@ export function createMessageRenderer(name, canRender, render, priority = 0) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Helper to create an activity renderer
|
|
36
|
+
* Helper to create an activity renderer plugin
|
|
37
37
|
*/
|
|
38
38
|
export function createActivityRenderer(name, activityTypes, render, priority = 0) {
|
|
39
39
|
return {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A2UI
|
|
2
|
+
* A2UI plugin for chat component.
|
|
3
3
|
* Renders A2UI protocol messages from A2A agents using @a2ui/react v0.8.
|
|
4
4
|
*
|
|
5
|
-
* @module components/
|
|
5
|
+
* @module components/uiPlugins/A2UIPlugin
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import type { ComponentInstance } from '@a2ui/react';
|
|
9
9
|
import type { ChatMessage } from '../types/messages';
|
|
10
|
-
import type {
|
|
10
|
+
import type { ActivityRendererUIPlugin, A2UIPlugin as A2UIPluginNamespace } from '../types/uiPlugins';
|
|
11
11
|
interface ValueMap {
|
|
12
12
|
key: string;
|
|
13
13
|
valueString?: string;
|
|
@@ -42,11 +42,11 @@ export interface A2UIMessage {
|
|
|
42
42
|
*/
|
|
43
43
|
export declare function createA2UIRenderer(_customRenderers?: Record<string, React.ComponentType<{
|
|
44
44
|
content: unknown;
|
|
45
|
-
}>>):
|
|
45
|
+
}>>): ActivityRendererUIPlugin;
|
|
46
46
|
/**
|
|
47
|
-
* A2UI
|
|
47
|
+
* A2UI UI plugin implementation class.
|
|
48
48
|
*/
|
|
49
|
-
export declare class
|
|
49
|
+
export declare class A2UIPluginImpl implements ActivityRendererUIPlugin {
|
|
50
50
|
readonly name = "a2ui";
|
|
51
51
|
readonly type: "activity-renderer";
|
|
52
52
|
readonly activityTypes: string[];
|
|
@@ -62,4 +62,4 @@ export declare class A2UIExtensionImpl implements ActivityRendererExtension {
|
|
|
62
62
|
message: ChatMessage;
|
|
63
63
|
}) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
64
64
|
}
|
|
65
|
-
export type {
|
|
65
|
+
export type { A2UIPluginNamespace };
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* A2UI
|
|
6
|
+
* A2UI plugin for chat component.
|
|
7
7
|
* Renders A2UI protocol messages from A2A agents using @a2ui/react v0.8.
|
|
8
8
|
*
|
|
9
|
-
* @module components/
|
|
9
|
+
* @module components/uiPlugins/A2UIPlugin
|
|
10
10
|
*/
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import { A2UIViewer, initializeDefaultCatalog } from '@a2ui/react';
|
|
@@ -157,9 +157,9 @@ export function createA2UIRenderer(_customRenderers) {
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
|
-
* A2UI
|
|
160
|
+
* A2UI UI plugin implementation class.
|
|
161
161
|
*/
|
|
162
|
-
export class
|
|
162
|
+
export class A2UIPluginImpl {
|
|
163
163
|
name = 'a2ui';
|
|
164
164
|
type = 'activity-renderer';
|
|
165
165
|
activityTypes = ['a2ui'];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP-UI
|
|
2
|
+
* MCP-UI plugin for chat component.
|
|
3
3
|
* Renders MCP UI protocol messages and resources.
|
|
4
4
|
*
|
|
5
|
-
* @module components/
|
|
5
|
+
* @module components/uiPlugins/MCPUIPlugin
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ActivityRendererUIPlugin } from '../types/uiPlugins';
|
|
9
9
|
/**
|
|
10
10
|
* MCP-UI resource types
|
|
11
11
|
*/
|
|
@@ -50,20 +50,20 @@ export interface MCPUIMessage {
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function createMCPUIRenderer(customRenderers?: Record<string, React.ComponentType<{
|
|
52
52
|
resource: MCPUIResource;
|
|
53
|
-
}>>):
|
|
53
|
+
}>>): ActivityRendererUIPlugin;
|
|
54
54
|
/**
|
|
55
|
-
* MCP-UI
|
|
55
|
+
* MCP-UI UI plugin implementation class
|
|
56
56
|
*/
|
|
57
|
-
export declare class
|
|
57
|
+
export declare class MCPUIPluginImpl {
|
|
58
58
|
private renderer;
|
|
59
59
|
private customRenderers;
|
|
60
60
|
constructor(customRenderers?: Record<string, React.ComponentType<{
|
|
61
61
|
resource: MCPUIResource;
|
|
62
62
|
}>>);
|
|
63
63
|
/**
|
|
64
|
-
* Get the activity renderer
|
|
64
|
+
* Get the activity renderer plugin
|
|
65
65
|
*/
|
|
66
|
-
getRenderer():
|
|
66
|
+
getRenderer(): ActivityRendererUIPlugin;
|
|
67
67
|
/**
|
|
68
68
|
* Register a custom renderer for a MIME type
|
|
69
69
|
*/
|
|
@@ -71,7 +71,7 @@ export declare class MCPUIExtensionImpl {
|
|
|
71
71
|
resource: MCPUIResource;
|
|
72
72
|
}>): void;
|
|
73
73
|
/**
|
|
74
|
-
* Cleanup
|
|
74
|
+
* Cleanup plugin state
|
|
75
75
|
*/
|
|
76
76
|
cleanup(): void;
|
|
77
77
|
}
|
|
@@ -4,10 +4,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* MCP-UI
|
|
7
|
+
* MCP-UI plugin for chat component.
|
|
8
8
|
* Renders MCP UI protocol messages and resources.
|
|
9
9
|
*
|
|
10
|
-
* @module components/
|
|
10
|
+
* @module components/uiPlugins/MCPUIPlugin
|
|
11
11
|
*/
|
|
12
12
|
import React from 'react';
|
|
13
13
|
/**
|
|
@@ -180,9 +180,9 @@ const UIElement = ({ element, }) => {
|
|
|
180
180
|
}, children?.map((child, index) => (_jsx(UIElement, { element: child.uiElement }, index))));
|
|
181
181
|
};
|
|
182
182
|
/**
|
|
183
|
-
* MCP-UI
|
|
183
|
+
* MCP-UI UI plugin implementation class
|
|
184
184
|
*/
|
|
185
|
-
export class
|
|
185
|
+
export class MCPUIPluginImpl {
|
|
186
186
|
renderer;
|
|
187
187
|
customRenderers;
|
|
188
188
|
constructor(customRenderers) {
|
|
@@ -190,7 +190,7 @@ export class MCPUIExtensionImpl {
|
|
|
190
190
|
this.renderer = createMCPUIRenderer(this.customRenderers);
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
|
-
* Get the activity renderer
|
|
193
|
+
* Get the activity renderer plugin
|
|
194
194
|
*/
|
|
195
195
|
getRenderer() {
|
|
196
196
|
return this.renderer;
|
|
@@ -204,7 +204,7 @@ export class MCPUIExtensionImpl {
|
|
|
204
204
|
this.renderer = createMCPUIRenderer(this.customRenderers);
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
|
-
* Cleanup
|
|
207
|
+
* Cleanup plugin state
|
|
208
208
|
*/
|
|
209
209
|
cleanup() {
|
|
210
210
|
// Context cleanup handled by renderer garbage collection
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI plugin registry for the chat.
|
|
3
|
+
* Manages custom renderers and plugin points.
|
|
4
|
+
*
|
|
5
|
+
* @module components/uiPlugins/UIPluginRegistry
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatUIPlugin, MessageRendererUIPlugin, ActivityRendererUIPlugin, ToolUIPlugin, ProtocolEventUIPlugin, PanelUIPlugin } from '../types/uiPlugins';
|
|
8
|
+
/** Internal plugin type for registry organization */
|
|
9
|
+
export type InternalUIPluginType = 'message-renderer' | 'activity-renderer' | 'tool-ui' | 'protocol-event' | 'panel';
|
|
10
|
+
/**
|
|
11
|
+
* UI plugin registry class
|
|
12
|
+
*/
|
|
13
|
+
export declare class UIPluginRegistry {
|
|
14
|
+
private uiPlugins;
|
|
15
|
+
private byType;
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Register an plugin
|
|
19
|
+
*/
|
|
20
|
+
register(plugin: ChatUIPlugin): void;
|
|
21
|
+
/**
|
|
22
|
+
* Unregister an plugin
|
|
23
|
+
*/
|
|
24
|
+
unregister(pluginName: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get an plugin by name
|
|
27
|
+
*/
|
|
28
|
+
get<T extends ChatUIPlugin>(pluginName: string): T | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get all uiPlugins of a specific type
|
|
31
|
+
*/
|
|
32
|
+
getByType<T extends ChatUIPlugin>(type: InternalUIPluginType): T[];
|
|
33
|
+
/**
|
|
34
|
+
* Get all registered uiPlugins
|
|
35
|
+
*/
|
|
36
|
+
getAll(): ChatUIPlugin[];
|
|
37
|
+
/**
|
|
38
|
+
* Check if an plugin is registered
|
|
39
|
+
*/
|
|
40
|
+
has(pluginName: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get message renderers
|
|
43
|
+
*/
|
|
44
|
+
getMessageRenderers(): MessageRendererUIPlugin[];
|
|
45
|
+
/**
|
|
46
|
+
* Get activity renderer for a specific activity type
|
|
47
|
+
*/
|
|
48
|
+
getActivityRenderer(activityType: string): ActivityRendererUIPlugin | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Get tool UI for a specific tool
|
|
51
|
+
*/
|
|
52
|
+
getToolUI(toolName: string): ToolUIPlugin | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Get all panels
|
|
55
|
+
*/
|
|
56
|
+
getPanels(): PanelUIPlugin[];
|
|
57
|
+
/**
|
|
58
|
+
* Get protocol event handlers for an event type
|
|
59
|
+
*/
|
|
60
|
+
getProtocolEventHandlers(eventType: string): ProtocolEventUIPlugin[];
|
|
61
|
+
/**
|
|
62
|
+
* Clear all uiPlugins
|
|
63
|
+
*/
|
|
64
|
+
clear(): void;
|
|
65
|
+
}
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Get the internal type string from an
|
|
6
|
+
* Get the internal type string from an plugin
|
|
7
7
|
*/
|
|
8
|
-
function
|
|
8
|
+
function getUIPluginType(ext) {
|
|
9
9
|
return ext.type;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Get the name from an
|
|
12
|
+
* Get the name from an plugin
|
|
13
13
|
*/
|
|
14
|
-
function
|
|
14
|
+
function getUIPluginName(ext) {
|
|
15
15
|
return ext.name;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* UI plugin registry class
|
|
19
19
|
*/
|
|
20
|
-
export class
|
|
21
|
-
|
|
20
|
+
export class UIPluginRegistry {
|
|
21
|
+
uiPlugins = new Map();
|
|
22
22
|
byType = new Map();
|
|
23
23
|
constructor() {
|
|
24
24
|
// Initialize type maps
|
|
@@ -34,52 +34,52 @@ export class ExtensionRegistry {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Register an
|
|
37
|
+
* Register an plugin
|
|
38
38
|
*/
|
|
39
|
-
register(
|
|
40
|
-
const name =
|
|
41
|
-
if (this.
|
|
42
|
-
console.warn(`[
|
|
39
|
+
register(plugin) {
|
|
40
|
+
const name = getUIPluginName(plugin);
|
|
41
|
+
if (this.uiPlugins.has(name)) {
|
|
42
|
+
console.warn(`[UIPluginRegistry] UI plugin ${name} already registered, replacing`);
|
|
43
43
|
}
|
|
44
|
-
this.
|
|
45
|
-
this.byType.get(
|
|
44
|
+
this.uiPlugins.set(name, plugin);
|
|
45
|
+
this.byType.get(getUIPluginType(plugin))?.add(name);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Unregister an
|
|
48
|
+
* Unregister an plugin
|
|
49
49
|
*/
|
|
50
|
-
unregister(
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
this.byType.get(
|
|
54
|
-
this.
|
|
50
|
+
unregister(pluginName) {
|
|
51
|
+
const plugin = this.uiPlugins.get(pluginName);
|
|
52
|
+
if (plugin) {
|
|
53
|
+
this.byType.get(getUIPluginType(plugin))?.delete(pluginName);
|
|
54
|
+
this.uiPlugins.delete(pluginName);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Get an
|
|
58
|
+
* Get an plugin by name
|
|
59
59
|
*/
|
|
60
|
-
get(
|
|
61
|
-
return this.
|
|
60
|
+
get(pluginName) {
|
|
61
|
+
return this.uiPlugins.get(pluginName);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Get all
|
|
64
|
+
* Get all uiPlugins of a specific type
|
|
65
65
|
*/
|
|
66
66
|
getByType(type) {
|
|
67
67
|
const names = this.byType.get(type) || new Set();
|
|
68
68
|
return Array.from(names)
|
|
69
|
-
.map(name => this.
|
|
69
|
+
.map(name => this.uiPlugins.get(name))
|
|
70
70
|
.filter(ext => ext !== undefined);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Get all registered
|
|
73
|
+
* Get all registered uiPlugins
|
|
74
74
|
*/
|
|
75
75
|
getAll() {
|
|
76
|
-
return Array.from(this.
|
|
76
|
+
return Array.from(this.uiPlugins.values());
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* Check if an
|
|
79
|
+
* Check if an plugin is registered
|
|
80
80
|
*/
|
|
81
|
-
has(
|
|
82
|
-
return this.
|
|
81
|
+
has(pluginName) {
|
|
82
|
+
return this.uiPlugins.has(pluginName);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Get message renderers
|
|
@@ -115,10 +115,10 @@ export class ExtensionRegistry {
|
|
|
115
115
|
return handlers.filter(h => h.eventTypes.includes(eventType) || h.eventTypes.includes('*'));
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* Clear all
|
|
118
|
+
* Clear all uiPlugins
|
|
119
119
|
*/
|
|
120
120
|
clear() {
|
|
121
|
-
this.
|
|
121
|
+
this.uiPlugins.clear();
|
|
122
122
|
for (const set of this.byType.values()) {
|
|
123
123
|
set.clear();
|
|
124
124
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI plugin exports for the chat: how an agent's answer becomes an interface (A2UI, MCP UI).
|
|
3
|
+
*
|
|
4
|
+
* @module components/uiPlugins
|
|
5
|
+
*/
|
|
6
|
+
export { UIPluginRegistry } from './UIPluginRegistry';
|
|
7
|
+
export type { InternalUIPluginType } from './UIPluginRegistry';
|
|
8
|
+
export { createA2UIRenderer, A2UIPluginImpl, type A2UIMessage, } from './A2UIPlugin';
|
|
9
|
+
export { createMCPUIRenderer, MCPUIPluginImpl, type MCPUIMessage, type MCPUIResource, } from './MCPUIPlugin';
|