govon 1.2.2 → 1.4.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.
- package/bin/govon.js +2 -41
- package/dist/App.d.ts +22 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +307 -0
- package/dist/App.js.map +1 -0
- package/dist/client.d.ts +102 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +332 -0
- package/dist/client.js.map +1 -0
- package/dist/components/ApprovalPrompt.d.ts +15 -0
- package/dist/components/ApprovalPrompt.d.ts.map +1 -0
- package/dist/components/ApprovalPrompt.js +35 -0
- package/dist/components/ApprovalPrompt.js.map +1 -0
- package/dist/components/Banner.d.ts +6 -0
- package/dist/components/Banner.d.ts.map +1 -0
- package/dist/components/Banner.js +27 -0
- package/dist/components/Banner.js.map +1 -0
- package/dist/components/InputBar.d.ts +8 -0
- package/dist/components/InputBar.d.ts.map +1 -0
- package/dist/components/InputBar.js +26 -0
- package/dist/components/InputBar.js.map +1 -0
- package/dist/components/MarkdownView.d.ts +9 -0
- package/dist/components/MarkdownView.d.ts.map +1 -0
- package/dist/components/MarkdownView.js +38 -0
- package/dist/components/MarkdownView.js.map +1 -0
- package/dist/components/MessageBubble.d.ts +14 -0
- package/dist/components/MessageBubble.d.ts.map +1 -0
- package/dist/components/MessageBubble.js +15 -0
- package/dist/components/MessageBubble.js.map +1 -0
- package/dist/components/MetadataBar.d.ts +7 -0
- package/dist/components/MetadataBar.d.ts.map +1 -0
- package/dist/components/MetadataBar.js +19 -0
- package/dist/components/MetadataBar.js.map +1 -0
- package/dist/components/Spinner.d.ts +7 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +51 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/ThinkingBlock.d.ts +9 -0
- package/dist/components/ThinkingBlock.d.ts.map +1 -0
- package/dist/components/ThinkingBlock.js +9 -0
- package/dist/components/ThinkingBlock.js.map +1 -0
- package/dist/components/ToolPanel.d.ts +7 -0
- package/dist/components/ToolPanel.d.ts.map +1 -0
- package/dist/components/ToolPanel.js +19 -0
- package/dist/components/ToolPanel.js.map +1 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +64 -0
- package/dist/config.js.map +1 -0
- package/dist/data/spinnerVerbs.d.ts +7 -0
- package/dist/data/spinnerVerbs.d.ts.map +1 -0
- package/dist/data/spinnerVerbs.js +58 -0
- package/dist/data/spinnerVerbs.js.map +1 -0
- package/dist/hooks/useDaemon.d.ts +16 -0
- package/dist/hooks/useDaemon.d.ts.map +1 -0
- package/dist/hooks/useDaemon.js +55 -0
- package/dist/hooks/useDaemon.js.map +1 -0
- package/dist/hooks/useHistory.d.ts +13 -0
- package/dist/hooks/useHistory.d.ts.map +1 -0
- package/dist/hooks/useHistory.js +170 -0
- package/dist/hooks/useHistory.js.map +1 -0
- package/dist/hooks/useSSE.d.ts +29 -0
- package/dist/hooks/useSSE.d.ts.map +1 -0
- package/dist/hooks/useSSE.js +341 -0
- package/dist/hooks/useSSE.js.map +1 -0
- package/dist/hooks/useTheme.d.ts +39 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +36 -0
- package/dist/hooks/useTheme.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1496 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +67 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -19
- package/README.md +0 -45
- package/lib/python-check.js +0 -223
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSSE.d.ts","sourceRoot":"","sources":["../../src/hooks/useSSE.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAA0B,MAAM,EAAE,MAAM,aAAa,CAAC;AAOlE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,+CAA+C;IAC/C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAMD,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,aAAa,GAAG,YAAY,CAiJnF"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSSE — React hook managing the SSE streaming lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the fallback chain in src/cli/shell.py _try_process_query (lines 164-202):
|
|
5
|
+
* 1. Try v3 fine-grained streaming (client.streamV3)
|
|
6
|
+
* 2. On failure → try v2 node-level streaming (client.stream)
|
|
7
|
+
* 3. On failure → try blocking run (client.run)
|
|
8
|
+
*
|
|
9
|
+
* Cancellation is handled via an AbortController stored in a ref.
|
|
10
|
+
* The controller.signal is forwarded to every client call so that aborting the
|
|
11
|
+
* controller immediately cancels the underlying fetch (no zombie requests).
|
|
12
|
+
*
|
|
13
|
+
* An unmount guard (mountedRef) prevents dispatching into unmounted components.
|
|
14
|
+
*/
|
|
15
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
16
|
+
import { NODE_STATUS_MESSAGES } from '../types.js';
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Hook implementation
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
export function useSSE({ client, dispatch, sessionId }) {
|
|
21
|
+
/** Holds the AbortController for the current in-flight request. */
|
|
22
|
+
const abortRef = useRef(null);
|
|
23
|
+
/**
|
|
24
|
+
* Unmount guard — set to false when the component unmounts.
|
|
25
|
+
* All async callbacks check this before dispatching to avoid state updates
|
|
26
|
+
* on unmounted components (which would leak memory and produce React warnings).
|
|
27
|
+
*/
|
|
28
|
+
const mountedRef = useRef(true);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
mountedRef.current = true;
|
|
31
|
+
return () => {
|
|
32
|
+
mountedRef.current = false;
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
/**
|
|
36
|
+
* Safe dispatch — drops the action if the component has already unmounted.
|
|
37
|
+
* All internal helpers receive this wrapper instead of the raw dispatch.
|
|
38
|
+
*/
|
|
39
|
+
const safeDispatch = useCallback((action) => {
|
|
40
|
+
if (mountedRef.current)
|
|
41
|
+
dispatch(action);
|
|
42
|
+
}, [dispatch]);
|
|
43
|
+
// -------------------------------------------------------------------------
|
|
44
|
+
// cancel — abort the current streaming request
|
|
45
|
+
// -------------------------------------------------------------------------
|
|
46
|
+
const cancel = useCallback(() => {
|
|
47
|
+
if (abortRef.current) {
|
|
48
|
+
abortRef.current.abort();
|
|
49
|
+
abortRef.current = null;
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
// -------------------------------------------------------------------------
|
|
53
|
+
// submit — attempt v3 → v2 → blocking, dispatch actions along the way
|
|
54
|
+
// -------------------------------------------------------------------------
|
|
55
|
+
const submit = useCallback(async (query) => {
|
|
56
|
+
// Cancel any previous in-flight request before starting a new one.
|
|
57
|
+
cancel();
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
abortRef.current = controller;
|
|
60
|
+
// Guard against stale cleanup: if a newer submit() starts while this
|
|
61
|
+
// one is still unwinding, we must not null out the newer controller.
|
|
62
|
+
const isCurrentRun = () => abortRef.current === controller;
|
|
63
|
+
// Stable message ID for the assistant slot opened before streaming begins.
|
|
64
|
+
const assistantMsgId = crypto.randomUUID();
|
|
65
|
+
const timestamp = new Date().toISOString();
|
|
66
|
+
const sid = sessionId ?? undefined;
|
|
67
|
+
safeDispatch({ type: 'SET_LOADING', payload: true });
|
|
68
|
+
safeDispatch({ type: 'SET_ERROR', payload: null });
|
|
69
|
+
safeDispatch({
|
|
70
|
+
type: 'START_ASSISTANT_MESSAGE',
|
|
71
|
+
payload: { id: assistantMsgId, timestamp },
|
|
72
|
+
});
|
|
73
|
+
// ------------------------------------------------------------------
|
|
74
|
+
// Path 1: v3 fine-grained streaming
|
|
75
|
+
// ------------------------------------------------------------------
|
|
76
|
+
const { success: v3Success, contentDispatched: v3ContentDispatched } = await _tryV3(client, query, sid, assistantMsgId, controller, safeDispatch);
|
|
77
|
+
if (v3Success) {
|
|
78
|
+
safeDispatch({ type: 'SET_API_VERSION', payload: 'v3' });
|
|
79
|
+
safeDispatch({ type: 'SET_LOADING', payload: false });
|
|
80
|
+
if (isCurrentRun())
|
|
81
|
+
abortRef.current = null;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Bail out immediately if the user cancelled.
|
|
85
|
+
if (controller.signal.aborted) {
|
|
86
|
+
safeDispatch({ type: 'SET_LOADING', payload: false });
|
|
87
|
+
if (isCurrentRun())
|
|
88
|
+
abortRef.current = null;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// If v3 emitted content tokens before failing, the message buffer is
|
|
92
|
+
// already partially written. Falling through to v2 would corrupt it by
|
|
93
|
+
// appending v2 content on top of the partial v3 content. Treat this as
|
|
94
|
+
// a terminal error instead.
|
|
95
|
+
if (v3ContentDispatched) {
|
|
96
|
+
safeDispatch({
|
|
97
|
+
type: 'SET_ERROR',
|
|
98
|
+
payload: 'Streaming interrupted after partial response — please retry.',
|
|
99
|
+
});
|
|
100
|
+
safeDispatch({ type: 'SET_LOADING', payload: false });
|
|
101
|
+
if (isCurrentRun())
|
|
102
|
+
abortRef.current = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// ------------------------------------------------------------------
|
|
106
|
+
// Path 2: v2 node-level streaming
|
|
107
|
+
// ------------------------------------------------------------------
|
|
108
|
+
const v2Success = await _tryV2(client, query, sid, assistantMsgId, controller, safeDispatch);
|
|
109
|
+
if (v2Success) {
|
|
110
|
+
safeDispatch({ type: 'SET_API_VERSION', payload: 'v2' });
|
|
111
|
+
safeDispatch({ type: 'SET_LOADING', payload: false });
|
|
112
|
+
if (isCurrentRun())
|
|
113
|
+
abortRef.current = null;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (controller.signal.aborted) {
|
|
117
|
+
safeDispatch({ type: 'SET_LOADING', payload: false });
|
|
118
|
+
if (isCurrentRun())
|
|
119
|
+
abortRef.current = null;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// ------------------------------------------------------------------
|
|
123
|
+
// Path 3: blocking run
|
|
124
|
+
// ------------------------------------------------------------------
|
|
125
|
+
await _tryBlocking(client, query, sid, assistantMsgId, controller, safeDispatch);
|
|
126
|
+
safeDispatch({ type: 'SET_LOADING', payload: false });
|
|
127
|
+
if (isCurrentRun())
|
|
128
|
+
abortRef.current = null;
|
|
129
|
+
}, [client, safeDispatch, sessionId, cancel]);
|
|
130
|
+
return { submit, cancel };
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Attempt v3 SSE streaming. Returns a V3Result describing the outcome.
|
|
134
|
+
*
|
|
135
|
+
* Returns success=true only on a clean run_complete event.
|
|
136
|
+
* Returns success=false, contentDispatched=false on network/HTTP exceptions
|
|
137
|
+
* (safe to fall through to v2).
|
|
138
|
+
* Returns success=false, contentDispatched=false when an explicit `error`
|
|
139
|
+
* event is received — the error is already dispatched and the caller
|
|
140
|
+
* should NOT fall through (the event is a terminal server-side error).
|
|
141
|
+
* We signal this by returning success=false but we still set contentDispatched
|
|
142
|
+
* to true so the caller surfaces the error rather than trying v2.
|
|
143
|
+
*/
|
|
144
|
+
async function _tryV3(client, query, sessionId, assistantMsgId, controller, dispatch) {
|
|
145
|
+
let contentDispatched = false;
|
|
146
|
+
try {
|
|
147
|
+
for await (const raw of client.streamV3(query, sessionId, undefined, controller.signal)) {
|
|
148
|
+
// Respect cancellation mid-stream.
|
|
149
|
+
if (controller.signal.aborted)
|
|
150
|
+
return { success: false, contentDispatched };
|
|
151
|
+
const event = raw;
|
|
152
|
+
switch (event.type) {
|
|
153
|
+
case 'thinking_start':
|
|
154
|
+
dispatch({
|
|
155
|
+
type: 'START_THINKING_STEP',
|
|
156
|
+
payload: { iteration: event.iteration },
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
159
|
+
case 'thinking_delta':
|
|
160
|
+
contentDispatched = true;
|
|
161
|
+
dispatch({
|
|
162
|
+
type: 'APPEND_STREAMING_THINKING',
|
|
163
|
+
payload: event.content,
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
case 'thinking_end':
|
|
167
|
+
dispatch({
|
|
168
|
+
type: 'END_THINKING_STEP',
|
|
169
|
+
payload: { iteration: event.iteration, tool_calls: event.tool_calls },
|
|
170
|
+
});
|
|
171
|
+
break;
|
|
172
|
+
case 'tool_start':
|
|
173
|
+
dispatch({
|
|
174
|
+
type: 'MARK_TOOL_START',
|
|
175
|
+
payload: { tool: event.tool },
|
|
176
|
+
});
|
|
177
|
+
break;
|
|
178
|
+
case 'tool_end':
|
|
179
|
+
dispatch({
|
|
180
|
+
type: 'MARK_TOOL_END',
|
|
181
|
+
payload: { tool: event.tool, success: event.success },
|
|
182
|
+
});
|
|
183
|
+
break;
|
|
184
|
+
case 'response_delta':
|
|
185
|
+
contentDispatched = true;
|
|
186
|
+
dispatch({
|
|
187
|
+
type: 'APPEND_STREAMING_CONTENT',
|
|
188
|
+
payload: event.content,
|
|
189
|
+
});
|
|
190
|
+
break;
|
|
191
|
+
case 'run_complete':
|
|
192
|
+
dispatch({
|
|
193
|
+
type: 'FINALIZE_ASSISTANT_MESSAGE',
|
|
194
|
+
payload: {
|
|
195
|
+
messageId: assistantMsgId,
|
|
196
|
+
content: event.text,
|
|
197
|
+
evidence: event.evidence_items,
|
|
198
|
+
metadata: event.metadata,
|
|
199
|
+
sessionId: event.session_id,
|
|
200
|
+
threadId: event.thread_id,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
// run_complete signals a clean finish — return success immediately.
|
|
204
|
+
return { success: true, contentDispatched };
|
|
205
|
+
case 'error':
|
|
206
|
+
// An explicit server-side error event is a terminal state.
|
|
207
|
+
// Dispatch the error and signal the caller NOT to fall through by
|
|
208
|
+
// returning contentDispatched=true (treated as "buffer tainted").
|
|
209
|
+
dispatch({ type: 'SET_ERROR', payload: event.error });
|
|
210
|
+
return { success: false, contentDispatched: true };
|
|
211
|
+
default:
|
|
212
|
+
// Unknown event type — ignore and continue streaming.
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Generator exhausted without a run_complete event — treat as failure.
|
|
217
|
+
// contentDispatched reflects whether any tokens were written.
|
|
218
|
+
return { success: false, contentDispatched };
|
|
219
|
+
}
|
|
220
|
+
catch (_err) {
|
|
221
|
+
// Network error, HTTP non-2xx, abort, or JSON parse failure from the client.
|
|
222
|
+
return { success: false, contentDispatched };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Attempt v2 node-level SSE streaming. Returns true on clean completion,
|
|
227
|
+
* false on error so the caller can fall through to the blocking path.
|
|
228
|
+
*/
|
|
229
|
+
async function _tryV2(client, query, sessionId, assistantMsgId, controller, dispatch) {
|
|
230
|
+
try {
|
|
231
|
+
for await (const raw of client.stream(query, sessionId, controller.signal)) {
|
|
232
|
+
if (controller.signal.aborted)
|
|
233
|
+
return false;
|
|
234
|
+
const event = raw;
|
|
235
|
+
const { node, status } = event;
|
|
236
|
+
// Update the status bar label for recognised node transitions.
|
|
237
|
+
const statusMsg = NODE_STATUS_MESSAGES[node];
|
|
238
|
+
if (statusMsg !== undefined) {
|
|
239
|
+
dispatch({ type: 'SET_STATUS_LABEL', payload: statusMsg });
|
|
240
|
+
}
|
|
241
|
+
if (node === 'agent' && status === 'completed') {
|
|
242
|
+
if (event.planned_tools && event.planned_tools.length > 0) {
|
|
243
|
+
// Agent has decided which tools to call next.
|
|
244
|
+
dispatch({
|
|
245
|
+
type: 'SET_STATUS_LABEL',
|
|
246
|
+
payload: `도구 실행 예정: ${event.planned_tools.join(', ')}`,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
// When final_text is present, the agent run finished on this node.
|
|
250
|
+
if (event.final_text !== undefined) {
|
|
251
|
+
dispatch({
|
|
252
|
+
type: 'FINALIZE_ASSISTANT_MESSAGE',
|
|
253
|
+
payload: {
|
|
254
|
+
messageId: assistantMsgId,
|
|
255
|
+
content: event.final_text,
|
|
256
|
+
evidence: event.evidence_items ?? [],
|
|
257
|
+
metadata: {},
|
|
258
|
+
sessionId: event.session_id ?? '',
|
|
259
|
+
threadId: event.thread_id ?? '',
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (node === 'tools' && status === 'completed') {
|
|
266
|
+
// Tool node finished — update status label; individual tool tracking
|
|
267
|
+
// is not available at v2 granularity so we only set the label.
|
|
268
|
+
dispatch({ type: 'SET_STATUS_LABEL', payload: '도구 실행 완료' });
|
|
269
|
+
}
|
|
270
|
+
if (node === 'approval_wait' && status === 'awaiting_approval') {
|
|
271
|
+
if (event.approval_request !== undefined) {
|
|
272
|
+
dispatch({
|
|
273
|
+
type: 'SET_PENDING_APPROVAL',
|
|
274
|
+
payload: event.approval_request,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (node === 'persist' && status === 'completed') {
|
|
279
|
+
if (event.final_text !== undefined) {
|
|
280
|
+
dispatch({
|
|
281
|
+
type: 'FINALIZE_ASSISTANT_MESSAGE',
|
|
282
|
+
payload: {
|
|
283
|
+
messageId: assistantMsgId,
|
|
284
|
+
content: event.final_text,
|
|
285
|
+
evidence: event.evidence_items ?? [],
|
|
286
|
+
metadata: {},
|
|
287
|
+
sessionId: event.session_id ?? '',
|
|
288
|
+
threadId: event.thread_id ?? '',
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (node === 'error') {
|
|
295
|
+
dispatch({
|
|
296
|
+
type: 'SET_ERROR',
|
|
297
|
+
payload: event.error ?? 'Unknown error from v2 stream',
|
|
298
|
+
});
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// Generator exhausted without a persist/agent run_complete event.
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
catch (_err) {
|
|
306
|
+
// Network/HTTP error or abort — try next path.
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Attempt the blocking /v2/agent/run endpoint as a last resort.
|
|
312
|
+
* Dispatches FINALIZE on success, SET_ERROR on failure.
|
|
313
|
+
*/
|
|
314
|
+
async function _tryBlocking(client, query, sessionId, assistantMsgId, controller, dispatch) {
|
|
315
|
+
if (controller.signal.aborted)
|
|
316
|
+
return;
|
|
317
|
+
try {
|
|
318
|
+
const result = await client.run(query, sessionId, controller.signal);
|
|
319
|
+
if (controller.signal.aborted)
|
|
320
|
+
return;
|
|
321
|
+
dispatch({
|
|
322
|
+
type: 'FINALIZE_ASSISTANT_MESSAGE',
|
|
323
|
+
payload: {
|
|
324
|
+
messageId: assistantMsgId,
|
|
325
|
+
content: result.text,
|
|
326
|
+
evidence: result.evidence_items ?? [],
|
|
327
|
+
metadata: result.metadata ?? {},
|
|
328
|
+
sessionId: result.session_id,
|
|
329
|
+
threadId: result.thread_id ?? '',
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
dispatch({ type: 'SET_API_VERSION', payload: 'v2' });
|
|
333
|
+
}
|
|
334
|
+
catch (err) {
|
|
335
|
+
if (controller.signal.aborted)
|
|
336
|
+
return;
|
|
337
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
338
|
+
dispatch({ type: 'SET_ERROR', payload: msg });
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=useSSE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSSE.js","sourceRoot":"","sources":["../../src/hooks/useSSE.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAmBnD,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAiB;IACnE,mEAAmE;IACnE,MAAM,QAAQ,GAAG,MAAM,CAAyB,IAAI,CAAC,CAAC;IAEtD;;;;OAIG;IACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAEhC,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1B,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;;OAGG;IACH,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,MAAc,EAAE,EAAE;QACjB,IAAI,UAAU,CAAC,OAAO;YAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,4EAA4E;IAC5E,+CAA+C;IAC/C,4EAA4E;IAE5E,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACrB,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACzB,QAAQ,CA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AAS,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAErE,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO;QAEtC,QAAQ,CAAC;YACP,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE;gBACP,SAAS,EAAE,cAAc;gBACzB,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,MAAM,CAAC,cAAc,IAAI,EAAE;gBACrC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;gBAC/B,SAAS,EAAE,MAAM,CAAC,UAAU;gBAC5B,QAAQ,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;aACjC;SACF,CAAC,CAAC;QACH,QAAQ,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO;QAEtC,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useTheme — resolves brand color tokens from the runtime environment.
|
|
3
|
+
*
|
|
4
|
+
* Respects the NO_COLOR convention (https://no-color.org/):
|
|
5
|
+
* when NO_COLOR is set to any value (including empty string), all color
|
|
6
|
+
* tokens are returned as empty strings so callers can safely pass them
|
|
7
|
+
* to Ink's <Text color="..."> prop without emitting ANSI sequences.
|
|
8
|
+
*
|
|
9
|
+
* RESOLVED_THEME is computed once at module load time because
|
|
10
|
+
* process.env values never change at runtime.
|
|
11
|
+
*/
|
|
12
|
+
/** Brand color tokens used throughout the TUI. */
|
|
13
|
+
export interface ThemeTokens {
|
|
14
|
+
/** Primary brand green — main interactive elements. */
|
|
15
|
+
primary: string;
|
|
16
|
+
/** Accent warm sand — highlights and callouts. */
|
|
17
|
+
accent: string;
|
|
18
|
+
/** Muted sage — secondary text and borders. */
|
|
19
|
+
muted: string;
|
|
20
|
+
/** Error red — destructive actions and error messages. */
|
|
21
|
+
error: string;
|
|
22
|
+
/** Warning amber — non-critical warnings. */
|
|
23
|
+
warning: string;
|
|
24
|
+
/** Success green — confirmation and done states. */
|
|
25
|
+
success: string;
|
|
26
|
+
/** Info blue — informational badges and labels. */
|
|
27
|
+
info: string;
|
|
28
|
+
/** Dimmed grey — disabled states and placeholders. */
|
|
29
|
+
dimmed: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns resolved theme color tokens for the current runtime environment.
|
|
33
|
+
*
|
|
34
|
+
* Usage:
|
|
35
|
+
* const theme = useTheme();
|
|
36
|
+
* <Text color={theme.primary}>Hello</Text>
|
|
37
|
+
*/
|
|
38
|
+
export declare function useTheme(): ThemeTokens;
|
|
39
|
+
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB;AAmBD;;;;;;GAMG;AACH,wBAAgB,QAAQ,IAAI,WAAW,CAEtC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useTheme — resolves brand color tokens from the runtime environment.
|
|
3
|
+
*
|
|
4
|
+
* Respects the NO_COLOR convention (https://no-color.org/):
|
|
5
|
+
* when NO_COLOR is set to any value (including empty string), all color
|
|
6
|
+
* tokens are returned as empty strings so callers can safely pass them
|
|
7
|
+
* to Ink's <Text color="..."> prop without emitting ANSI sequences.
|
|
8
|
+
*
|
|
9
|
+
* RESOLVED_THEME is computed once at module load time because
|
|
10
|
+
* process.env values never change at runtime.
|
|
11
|
+
*/
|
|
12
|
+
import { THEME_COLORS } from '../config.js';
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Module-level constants (computed once, never re-evaluated)
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
const EMPTY_TOKENS = {
|
|
17
|
+
primary: '', accent: '', muted: '', error: '',
|
|
18
|
+
warning: '', success: '', info: '', dimmed: '',
|
|
19
|
+
};
|
|
20
|
+
const RESOLVED_THEME = process.env.NO_COLOR !== undefined
|
|
21
|
+
? EMPTY_TOKENS
|
|
22
|
+
: { ...THEME_COLORS };
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Hook
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* Returns resolved theme color tokens for the current runtime environment.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* const theme = useTheme();
|
|
31
|
+
* <Text color={theme.primary}>Hello</Text>
|
|
32
|
+
*/
|
|
33
|
+
export function useTheme() {
|
|
34
|
+
return RESOLVED_THEME;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA0B5C,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAE9E,MAAM,YAAY,GAAgB;IAChC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAC7C,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;CAC/C,CAAC;AAEF,MAAM,cAAc,GAAgB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS;IACpE,CAAC,CAAC,YAAY;IACd,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC;AAExB,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG"}
|