@couplet/agent-ui 1.0.0

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.
@@ -0,0 +1,219 @@
1
+ type AgentMessageRole = 'user' | 'assistant' | 'system';
2
+ type AgentStatus = 'idle' | 'streaming' | 'retrying' | 'error';
3
+ type ChainNodeType = 'thinking' | 'tool_call' | 'tool_result' | 'user_reply' | 'final' | 'task_plan' | 'task_update' | 'goal';
4
+ interface AgentClarify {
5
+ readonly question: string;
6
+ readonly options?: readonly string[];
7
+ }
8
+ interface AgentPendingClarify {
9
+ readonly question: string;
10
+ readonly options: readonly string[];
11
+ readonly chainReplyTo: string;
12
+ }
13
+ interface AgentToolCallFunction {
14
+ readonly name: string;
15
+ readonly arguments: string;
16
+ }
17
+ interface AgentToolCall {
18
+ readonly index: number;
19
+ readonly id: string;
20
+ readonly type: string;
21
+ readonly function: AgentToolCallFunction;
22
+ }
23
+ interface ChainNode {
24
+ readonly id: string;
25
+ readonly type: ChainNodeType;
26
+ readonly title?: string;
27
+ readonly content?: string;
28
+ readonly tool_name?: string;
29
+ readonly tool_input?: Record<string, unknown>;
30
+ readonly tool_output?: Record<string, unknown>;
31
+ readonly parent_id?: string;
32
+ readonly created_at?: string;
33
+ }
34
+ interface AgentMessage {
35
+ readonly id: string;
36
+ readonly role: AgentMessageRole;
37
+ readonly content: string;
38
+ readonly reasoning?: string;
39
+ readonly toolCalls?: readonly AgentToolCall[];
40
+ readonly type?: 'message' | 'clarify' | 'plan' | 'access' | 'error' | 'chain';
41
+ readonly clarify?: AgentClarify;
42
+ readonly chain?: readonly ChainNode[];
43
+ readonly createdAt: number;
44
+ readonly error?: boolean;
45
+ readonly chainReplyTo?: string;
46
+ }
47
+ interface AgentSession {
48
+ readonly id: string;
49
+ readonly title: string;
50
+ readonly project: string;
51
+ readonly createdAt: number;
52
+ readonly updatedAt: number;
53
+ readonly messages: readonly AgentMessage[];
54
+ }
55
+ interface ContextUsageCategory {
56
+ readonly id: string;
57
+ readonly label: string;
58
+ readonly tokens: number;
59
+ }
60
+ interface ContextUsage {
61
+ readonly budget_tokens: number;
62
+ readonly used_tokens: number;
63
+ readonly used_percent: number;
64
+ readonly categories: readonly ContextUsageCategory[];
65
+ readonly source?: 'estimated' | 'provider';
66
+ readonly estimated_tokens?: number;
67
+ readonly prompt_tokens?: number;
68
+ }
69
+ interface AgentStreamRequest {
70
+ readonly session_id: string;
71
+ readonly message: {
72
+ readonly role: 'user';
73
+ readonly content: string;
74
+ };
75
+ readonly stream: true;
76
+ readonly chain_reply_to?: string;
77
+ }
78
+ interface StreamEventBase {
79
+ readonly kind: string;
80
+ }
81
+ interface MessageChunkEvent extends StreamEventBase {
82
+ readonly kind: 'MessageChunk';
83
+ readonly text: string;
84
+ }
85
+ interface MessageStopEvent extends StreamEventBase {
86
+ readonly kind: 'MessageStop';
87
+ readonly final: boolean;
88
+ }
89
+ interface ThinkingChunkEvent extends StreamEventBase {
90
+ readonly kind: 'ThinkingChunk';
91
+ readonly content: string;
92
+ readonly node_id?: string | null;
93
+ }
94
+ interface ToolCallFinishedEvent extends StreamEventBase {
95
+ readonly kind: 'ToolCallFinished';
96
+ readonly tool_name: string;
97
+ readonly duration: number;
98
+ readonly ok: boolean;
99
+ readonly index: number;
100
+ }
101
+ interface ToolCallEvent extends StreamEventBase {
102
+ readonly kind: 'ToolCallEvent';
103
+ readonly node_id: string;
104
+ readonly tool_name: string;
105
+ readonly tool_input?: Record<string, unknown> | null;
106
+ readonly title?: string | null;
107
+ }
108
+ interface ToolResultEvent extends StreamEventBase {
109
+ readonly kind: 'ToolResultEvent';
110
+ readonly node_id: string;
111
+ readonly tool_name: string;
112
+ readonly tool_output?: Record<string, unknown> | null;
113
+ readonly title?: string | null;
114
+ }
115
+ interface UserReplyEvent extends StreamEventBase {
116
+ readonly kind: 'UserReplyEvent';
117
+ readonly node_id: string;
118
+ readonly content: string;
119
+ readonly parent_id?: string | null;
120
+ }
121
+ interface ClarifyEvent extends StreamEventBase {
122
+ readonly kind: 'ClarifyEvent';
123
+ readonly node_id: string;
124
+ readonly question: string;
125
+ readonly options: readonly string[];
126
+ }
127
+ interface FinalEvent extends StreamEventBase {
128
+ readonly kind: 'FinalEvent';
129
+ readonly node_id: string;
130
+ readonly content: string;
131
+ }
132
+ interface RetryingEvent extends StreamEventBase {
133
+ readonly kind: 'Retrying';
134
+ readonly attempt: number;
135
+ readonly max_retries: number;
136
+ readonly delay: number;
137
+ readonly reason: string;
138
+ }
139
+ interface ContextCompressedEvent extends StreamEventBase {
140
+ readonly kind: 'ContextCompressed';
141
+ }
142
+ interface LongToolHintEvent extends StreamEventBase {
143
+ readonly kind: 'LongToolHint';
144
+ readonly tool_name: string;
145
+ readonly duration: number;
146
+ }
147
+ interface FatalErrorEvent extends StreamEventBase {
148
+ readonly kind: 'FatalError';
149
+ readonly message: string;
150
+ }
151
+ interface ContextUsageEvent extends StreamEventBase {
152
+ readonly kind: 'ContextUsageEvent';
153
+ readonly budget_tokens: number;
154
+ readonly used_tokens: number;
155
+ readonly used_percent: number;
156
+ readonly categories: readonly {
157
+ readonly id: string;
158
+ readonly label: string;
159
+ readonly tokens: number;
160
+ }[];
161
+ readonly source?: 'estimated' | 'provider';
162
+ readonly estimated_tokens?: number;
163
+ readonly prompt_tokens?: number;
164
+ }
165
+ interface OpenPageEvent extends StreamEventBase {
166
+ readonly kind: 'OpenPageEvent';
167
+ readonly url: string;
168
+ readonly title?: string | null;
169
+ }
170
+ interface OpenExternalLinkEvent extends StreamEventBase {
171
+ readonly kind: 'OpenExternalLinkEvent';
172
+ readonly url: string;
173
+ readonly title?: string | null;
174
+ }
175
+ type AgentNavigationEvent = OpenPageEvent | OpenExternalLinkEvent;
176
+ type StreamEvent = MessageChunkEvent | MessageStopEvent | ThinkingChunkEvent | ToolCallFinishedEvent | ToolCallEvent | ToolResultEvent | UserReplyEvent | ClarifyEvent | FinalEvent | RetryingEvent | ContextCompressedEvent | LongToolHintEvent | FatalErrorEvent | ContextUsageEvent | OpenPageEvent | OpenExternalLinkEvent;
177
+
178
+ interface AgentTransport {
179
+ request<T>(url: string, init?: RequestInit): Promise<T>;
180
+ requestStream(url: string, init?: RequestInit): Promise<Response>;
181
+ }
182
+ interface AgentEndpoints {
183
+ readonly createSession: string;
184
+ readonly sessions: string;
185
+ readonly completions: string;
186
+ }
187
+ interface ChatSessionListItem {
188
+ readonly id: string;
189
+ readonly title?: string | null;
190
+ readonly is_active?: boolean;
191
+ readonly created_at?: string | null;
192
+ readonly updated_at?: string | null;
193
+ readonly message_count?: number;
194
+ }
195
+ interface AgentClient {
196
+ readonly endpoints: AgentEndpoints;
197
+ createSession(): Promise<string>;
198
+ listSessions(): Promise<readonly ChatSessionListItem[]>;
199
+ loadLatestSession(): Promise<{
200
+ sessionId: string;
201
+ messages: AgentMessage[];
202
+ }>;
203
+ getSessionDetail(sessionId: string): Promise<AgentSession>;
204
+ fetchContextUsage(sessionId: string): Promise<ContextUsage>;
205
+ sendMessageStream(options: {
206
+ readonly request: AgentStreamRequest;
207
+ readonly signal?: AbortSignal;
208
+ readonly onEvent: (event: StreamEvent) => void;
209
+ }): Promise<void>;
210
+ }
211
+ interface ChatSessionListResponse {
212
+ readonly sessions: ChatSessionListItem[];
213
+ }
214
+ interface CreateAgentClientOptions {
215
+ readonly transport: AgentTransport;
216
+ readonly endpoints?: Partial<AgentEndpoints>;
217
+ }
218
+
219
+ export type { AgentSession as A, ToolCallFinishedEvent as B, ContextUsage as C, ToolResultEvent as D, FatalErrorEvent as F, LongToolHintEvent as L, MessageChunkEvent as M, OpenExternalLinkEvent as O, RetryingEvent as R, StreamEvent as S, ThinkingChunkEvent as T, UserReplyEvent as U, AgentStatus as a, AgentClient as b, AgentNavigationEvent as c, AgentPendingClarify as d, AgentClarify as e, AgentEndpoints as f, AgentMessage as g, AgentMessageRole as h, AgentStreamRequest as i, AgentToolCall as j, AgentToolCallFunction as k, AgentTransport as l, ChainNode as m, ChainNodeType as n, ChatSessionListItem as o, ChatSessionListResponse as p, ClarifyEvent as q, ContextCompressedEvent as r, ContextUsageCategory as s, ContextUsageEvent as t, CreateAgentClientOptions as u, FinalEvent as v, MessageStopEvent as w, OpenPageEvent as x, StreamEventBase as y, ToolCallEvent as z };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@couplet/agent-ui",
3
+ "version": "1.0.0",
4
+ "description": "TurboMesh Agent conversation UI and session runtime",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "files": ["dist"],
10
+ "scripts": {
11
+ "build": "tsup",
12
+ "typecheck": "tsc -p tsconfig.json --noEmit",
13
+ "lint": "tsc -p tsconfig.json --noEmit",
14
+ "test": "vitest run"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./core": {
22
+ "types": "./dist/core.d.ts",
23
+ "default": "./dist/core.js"
24
+ },
25
+ "./client": {
26
+ "types": "./dist/client.d.ts",
27
+ "default": "./dist/client.js"
28
+ }
29
+ },
30
+ "dependencies": {
31
+ "clsx": "catalog:",
32
+ "lucide-react": "catalog:",
33
+ "react-markdown": "catalog:",
34
+ "tailwind-merge": "catalog:"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "catalog:",
38
+ "@types/react": "catalog:",
39
+ "@types/react-dom": "catalog:",
40
+ "react": "catalog:",
41
+ "react-dom": "catalog:",
42
+ "swr": "catalog:",
43
+ "tsup": "^8.5.0",
44
+ "typescript": "catalog:",
45
+ "vitest": "^3.2.4"
46
+ },
47
+ "peerDependencies": {
48
+ "react": "^19.0.0",
49
+ "react-dom": "^19.0.0",
50
+ "swr": "^2.0.0"
51
+ }
52
+ }