@fastino-ai/pioneer-cli 0.2.7 → 0.2.9
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/README.md +63 -72
- package/package.json +2 -1
- package/src/api.ts +670 -228
- package/src/chat/ChatApp.tsx +5 -2
- package/src/client/WebSocketClient.ts +25 -7
- package/src/config.ts +23 -1
- package/src/index.tsx +3004 -1124
package/src/chat/ChatApp.tsx
CHANGED
|
@@ -855,7 +855,8 @@ File references:
|
|
|
855
855
|
}, [client, state.isProcessing]);
|
|
856
856
|
|
|
857
857
|
// Handle keyboard shortcuts
|
|
858
|
-
useInput(
|
|
858
|
+
useInput(
|
|
859
|
+
(char, key) => {
|
|
859
860
|
if (key.ctrl && char === "c") {
|
|
860
861
|
exit();
|
|
861
862
|
return;
|
|
@@ -920,7 +921,9 @@ File references:
|
|
|
920
921
|
return;
|
|
921
922
|
}
|
|
922
923
|
}
|
|
923
|
-
|
|
924
|
+
},
|
|
925
|
+
{ isActive: isRawModeSupported }
|
|
926
|
+
);
|
|
924
927
|
|
|
925
928
|
if (!client) {
|
|
926
929
|
return (
|
|
@@ -42,7 +42,7 @@ export interface WebSocketClientCallbacks {
|
|
|
42
42
|
onToolCall?: (call: ToolCallRequest) => Promise<string>;
|
|
43
43
|
onAssistantMessage?: (content: string) => void;
|
|
44
44
|
onError?: (error: Error) => void;
|
|
45
|
-
onDone?: (messages?: HistoryMessage[]) => void;
|
|
45
|
+
onDone?: (messages?: HistoryMessage[], sessionId?: string) => void;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface ChatOptions {
|
|
@@ -98,9 +98,10 @@ export class WebSocketClient {
|
|
|
98
98
|
|
|
99
99
|
this.ws.on("open", () => {
|
|
100
100
|
this.state = "connected";
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
|
|
101
|
+
// Send auth explicitly as a defensive fallback when header auth is not
|
|
102
|
+
// propagated by proxy layers (some environments only support
|
|
103
|
+
// first-message auth for WS).
|
|
104
|
+
if (this.apiKey) {
|
|
104
105
|
this.ws?.send(JSON.stringify({ type: "auth", api_key: this.apiKey }));
|
|
105
106
|
}
|
|
106
107
|
resolve();
|
|
@@ -122,7 +123,7 @@ export class WebSocketClient {
|
|
|
122
123
|
// Only call onDone if not already called (prevents duplicate)
|
|
123
124
|
if (!this.doneCalled) {
|
|
124
125
|
this.doneCalled = true;
|
|
125
|
-
this.callbacks.onDone?.();
|
|
126
|
+
this.callbacks.onDone?.(undefined, undefined);
|
|
126
127
|
}
|
|
127
128
|
if (this.doneResolver) {
|
|
128
129
|
this.doneResolver();
|
|
@@ -143,6 +144,15 @@ export class WebSocketClient {
|
|
|
143
144
|
|
|
144
145
|
private async handleMessage(message: WebSocketMessage): Promise<void> {
|
|
145
146
|
switch (message.type) {
|
|
147
|
+
case "auth_required":
|
|
148
|
+
if (this.apiKey) {
|
|
149
|
+
this.send({ type: "auth", api_key: this.apiKey });
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case "auth_success":
|
|
154
|
+
break;
|
|
155
|
+
|
|
146
156
|
case "stream":
|
|
147
157
|
this.callbacks.onStream?.(message.content as string);
|
|
148
158
|
break;
|
|
@@ -211,8 +221,16 @@ export class WebSocketClient {
|
|
|
211
221
|
this.doneCalled = true;
|
|
212
222
|
// Pass the message history if provided by the backend
|
|
213
223
|
const messages = message.messages as HistoryMessage[] | undefined;
|
|
214
|
-
|
|
215
|
-
|
|
224
|
+
const sessionId = typeof message.session_id === "string" ? message.session_id : undefined;
|
|
225
|
+
console.log(
|
|
226
|
+
"[DEBUG] Done event received, messages:",
|
|
227
|
+
messages?.length,
|
|
228
|
+
"roles:",
|
|
229
|
+
messages?.map((m) => m.role),
|
|
230
|
+
"sessionId:",
|
|
231
|
+
sessionId
|
|
232
|
+
);
|
|
233
|
+
this.callbacks.onDone?.(messages, sessionId);
|
|
216
234
|
}
|
|
217
235
|
if (this.doneResolver) {
|
|
218
236
|
this.doneResolver();
|
package/src/config.ts
CHANGED
|
@@ -23,8 +23,12 @@ export interface Config {
|
|
|
23
23
|
// Hugging Face token for pushing datasets/models
|
|
24
24
|
hfToken?: string;
|
|
25
25
|
|
|
26
|
+
// Last agent conversation ID used for resuming chats
|
|
27
|
+
lastAgentConversationId?: string;
|
|
28
|
+
|
|
26
29
|
// Telemetry (opt-in analytics)
|
|
27
30
|
telemetry?: TelemetryConfig;
|
|
31
|
+
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
const CONFIG_DIR = path.join(os.homedir(), ".pioneer");
|
|
@@ -36,7 +40,8 @@ export const DEFAULT_BASE_URL = process.env.PIONEER_API_URL || "https://api.pion
|
|
|
36
40
|
// WebSocket URL environments
|
|
37
41
|
const WS_URLS: Record<string, string> = {
|
|
38
42
|
local: "ws://localhost:5001/mle-agent/ws",
|
|
39
|
-
dev: "wss://
|
|
43
|
+
dev: "wss://api-dev.pioneer.ai/mle-agent/ws",
|
|
44
|
+
stg: "wss://api-stg.pioneer.ai/mle-agent/ws",
|
|
40
45
|
prod: "wss://api.pioneer.ai/mle-agent/ws",
|
|
41
46
|
};
|
|
42
47
|
|
|
@@ -65,6 +70,12 @@ export function getWsUrl(): string {
|
|
|
65
70
|
// Dev API Gateway detected - use dev WebSocket URL
|
|
66
71
|
return WS_URLS.dev;
|
|
67
72
|
}
|
|
73
|
+
if (baseUrl.includes("api-dev.pioneer.ai")) {
|
|
74
|
+
return WS_URLS.dev;
|
|
75
|
+
}
|
|
76
|
+
if (baseUrl.includes("api-stg.pioneer.ai")) {
|
|
77
|
+
return WS_URLS.stg;
|
|
78
|
+
}
|
|
68
79
|
if (baseUrl === "https://api.pioneer.ai" || baseUrl === "https://api.pioneer.ai/") {
|
|
69
80
|
// Production detected
|
|
70
81
|
return WS_URLS.prod;
|
|
@@ -162,6 +173,17 @@ export function getBaseUrl(): string {
|
|
|
162
173
|
return DEFAULT_BASE_URL;
|
|
163
174
|
}
|
|
164
175
|
|
|
176
|
+
export function getLastAgentConversationId(): string | undefined {
|
|
177
|
+
return loadConfig().lastAgentConversationId;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function setLastAgentConversationId(conversationId?: string): void {
|
|
181
|
+
if (!conversationId) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
saveConfig({ lastAgentConversationId: conversationId });
|
|
185
|
+
}
|
|
186
|
+
|
|
165
187
|
export function getMleModel(): string | undefined {
|
|
166
188
|
return loadConfig().mleModel;
|
|
167
189
|
}
|