@fastino-ai/pioneer-cli 0.2.2 → 0.2.3

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.
Files changed (40) hide show
  1. package/.claude/settings.local.json +7 -1
  2. package/.cursor/rules/api-documentation.mdc +14 -0
  3. package/.cursor/rules/backend-location-rule.mdc +5 -0
  4. package/Medical_NER_Dataset_1.jsonl +50 -0
  5. package/README.md +4 -1
  6. package/bun.lock +52 -0
  7. package/package.json +5 -2
  8. package/src/api.ts +551 -22
  9. package/src/chat/ChatApp.tsx +548 -263
  10. package/src/client/ToolExecutor.ts +175 -0
  11. package/src/client/WebSocketClient.ts +333 -0
  12. package/src/client/index.ts +2 -0
  13. package/src/config.ts +49 -139
  14. package/src/index.tsx +796 -106
  15. package/src/telemetry.ts +173 -0
  16. package/src/tests/config.test.ts +19 -0
  17. package/src/tools/bash.ts +1 -1
  18. package/src/tools/filesystem.ts +1 -1
  19. package/src/tools/index.ts +2 -9
  20. package/src/tools/sandbox.ts +1 -1
  21. package/src/tools/types.ts +25 -0
  22. package/src/utils/index.ts +6 -0
  23. package/fastino-ai-pioneer-cli-0.2.0.tgz +0 -0
  24. package/ner_dataset.json +0 -111
  25. package/src/agent/Agent.ts +0 -342
  26. package/src/agent/BudgetManager.ts +0 -167
  27. package/src/agent/LLMClient.ts +0 -435
  28. package/src/agent/ToolRegistry.ts +0 -97
  29. package/src/agent/index.ts +0 -15
  30. package/src/agent/types.ts +0 -84
  31. package/src/evolution/EvalRunner.ts +0 -301
  32. package/src/evolution/EvolutionEngine.ts +0 -319
  33. package/src/evolution/FeedbackCollector.ts +0 -197
  34. package/src/evolution/ModelTrainer.ts +0 -371
  35. package/src/evolution/index.ts +0 -18
  36. package/src/evolution/types.ts +0 -110
  37. package/src/tools/modal.ts +0 -269
  38. package/src/tools/training.ts +0 -443
  39. package/src/tools/wandb.ts +0 -348
  40. /package/src/{agent → utils}/FileResolver.ts +0 -0
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Telemetry module for Pioneer CLI.
3
+ * Opt-in anonymous analytics sent via Pioneer API → Datadog.
4
+ *
5
+ * Privacy-first:
6
+ * - Disabled by default, requires explicit opt-in
7
+ * - Anonymous UUID per installation (no PII)
8
+ * - Only tracks feature usage, never user content
9
+ */
10
+
11
+ import crypto from "crypto";
12
+ import os from "os";
13
+ import { loadConfig, saveConfig, getBaseUrl, getApiKey } from "./config.js";
14
+ import packageJson from "../package.json";
15
+
16
+ // Telemetry endpoint on Pioneer API (forwards to Datadog)
17
+ const TELEMETRY_PATH = "/cli/telemetry";
18
+
19
+ /**
20
+ * Get or create an anonymous installation ID.
21
+ */
22
+ function getAnonymousId(): string {
23
+ const config = loadConfig();
24
+
25
+ if (config.telemetry?.anonymousId) {
26
+ return config.telemetry.anonymousId;
27
+ }
28
+
29
+ const anonymousId = crypto.randomUUID();
30
+ saveConfig({
31
+ telemetry: {
32
+ ...config.telemetry,
33
+ anonymousId,
34
+ },
35
+ });
36
+
37
+ return anonymousId;
38
+ }
39
+
40
+ /**
41
+ * Check if telemetry is enabled.
42
+ */
43
+ export function isEnabled(): boolean {
44
+ if (process.env.PIONEER_TELEMETRY === "false") return false;
45
+ if (process.env.PIONEER_TELEMETRY === "true") return true;
46
+
47
+ const config = loadConfig();
48
+ return config.telemetry?.enabled === true;
49
+ }
50
+
51
+ /**
52
+ * Check if user has made a telemetry choice.
53
+ */
54
+ export function hasChosenTelemetry(): boolean {
55
+ const config = loadConfig();
56
+ return config.telemetry?.enabled !== undefined;
57
+ }
58
+
59
+ /**
60
+ * Enable or disable telemetry.
61
+ */
62
+ export function setEnabled(enabled: boolean): void {
63
+ const config = loadConfig();
64
+ saveConfig({
65
+ telemetry: {
66
+ ...config.telemetry,
67
+ enabled,
68
+ anonymousId: enabled
69
+ ? (config.telemetry?.anonymousId || crypto.randomUUID())
70
+ : config.telemetry?.anonymousId,
71
+ },
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Send event to Pioneer API telemetry endpoint.
77
+ * Fire-and-forget, never blocks or throws.
78
+ */
79
+ function sendEvent(event: string, properties?: Record<string, unknown>): void {
80
+ if (!isEnabled()) {
81
+ return;
82
+ }
83
+
84
+ const baseUrl = getBaseUrl().replace(/\/$/, "");
85
+ const url = `${baseUrl}${TELEMETRY_PATH}`;
86
+ const apiKey = getApiKey();
87
+
88
+ const payload = {
89
+ event,
90
+ installation_id: getAnonymousId(),
91
+ cli_version: packageJson.version,
92
+ os_type: os.type(),
93
+ os_platform: os.platform(),
94
+ os_arch: os.arch(),
95
+ ...properties,
96
+ };
97
+
98
+ const headers: Record<string, string> = { "Content-Type": "application/json" };
99
+ if (apiKey) {
100
+ headers["X-API-Key"] = apiKey;
101
+ }
102
+
103
+ try {
104
+ fetch(url, {
105
+ method: "POST",
106
+ headers,
107
+ body: JSON.stringify(payload),
108
+ }).catch(() => {});
109
+ } catch {
110
+ // Silently fail
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Track an event.
116
+ */
117
+ export function track(event: string, properties?: Record<string, unknown>): void {
118
+ sendEvent(event, properties);
119
+ }
120
+
121
+ /**
122
+ * Track CLI command invocation.
123
+ */
124
+ export function trackCommand(command: string, subcommand?: string): void {
125
+ track("cli_command", { command, subcommand });
126
+ }
127
+
128
+ /**
129
+ * Track dataset generation.
130
+ */
131
+ export function trackDatasetGenerate(
132
+ type: "ner" | "classification" | "custom",
133
+ numExamples: number,
134
+ saveToRemote: boolean
135
+ ): void {
136
+ track("dataset_generate", { type, num_examples: numExamples, save_to_remote: saveToRemote });
137
+ }
138
+
139
+ /**
140
+ * Track chat session start.
141
+ */
142
+ export function trackChatSessionStart(provider: string, model: string): void {
143
+ track("chat_session_start", { provider, model });
144
+ }
145
+
146
+ /**
147
+ * Track chat session end.
148
+ */
149
+ export function trackChatSessionEnd(
150
+ durationMs: number,
151
+ messageCount: number,
152
+ toolCallCount: number
153
+ ): void {
154
+ track("chat_session_end", {
155
+ duration_seconds: Math.round(durationMs / 1000),
156
+ message_count: messageCount,
157
+ tool_call_count: toolCallCount,
158
+ });
159
+ }
160
+
161
+ /**
162
+ * Track job creation.
163
+ */
164
+ export function trackJobCreate(baseModel: string): void {
165
+ track("job_create", { base_model: baseModel });
166
+ }
167
+
168
+ /**
169
+ * Track model download.
170
+ */
171
+ export function trackModelDownload(): void {
172
+ track("model_download");
173
+ }
@@ -0,0 +1,19 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { DEFAULT_BASE_URL, DEFAULT_MLE_MODEL, AVAILABLE_MLE_MODELS } from "../config";
3
+
4
+ describe("Config defaults", () => {
5
+ test("DEFAULT_BASE_URL should be defined", () => {
6
+ expect(DEFAULT_BASE_URL).toBeDefined();
7
+ expect(typeof DEFAULT_BASE_URL).toBe("string");
8
+ });
9
+
10
+ test("DEFAULT_MLE_MODEL should be defined", () => {
11
+ expect(DEFAULT_MLE_MODEL).toBeDefined();
12
+ expect(typeof DEFAULT_MLE_MODEL).toBe("string");
13
+ });
14
+
15
+ test("AVAILABLE_MLE_MODELS should contain default model", () => {
16
+ const modelIds = AVAILABLE_MLE_MODELS.map(m => m.id);
17
+ expect(modelIds).toContain(DEFAULT_MLE_MODEL);
18
+ });
19
+ });
package/src/tools/bash.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { spawn } from "child_process";
6
- import type { Tool, ToolResult, ToolParameter } from "../agent/types.js";
6
+ import type { Tool, ToolResult, ToolParameter } from "./types.js";
7
7
 
8
8
  export interface BashOptions {
9
9
  cwd?: string;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as fs from "fs";
6
6
  import * as path from "path";
7
- import type { Tool, ToolResult, ToolParameter } from "../agent/types.js";
7
+ import type { Tool, ToolResult, ToolParameter } from "./types.js";
8
8
 
9
9
  export interface FilesystemOptions {
10
10
  basePath?: string;
@@ -2,6 +2,8 @@
2
2
  * Tools module exports
3
3
  */
4
4
 
5
+ export type { Tool, ToolResult, ToolParameter } from "./types.js";
6
+
5
7
  export { createBashTool, executeBashStream } from "./bash.js";
6
8
  export type { BashOptions } from "./bash.js";
7
9
 
@@ -18,12 +20,3 @@ export type { FilesystemOptions } from "./filesystem.js";
18
20
  export { Sandbox, createSandboxTool, isDockerAvailable } from "./sandbox.js";
19
21
  export type { SandboxOptions, SandboxResult } from "./sandbox.js";
20
22
 
21
- export { createModalRunTool, createModalDeployTool, createModalTools, isModalAvailable } from "./modal.js";
22
- export type { ModalConfig } from "./modal.js";
23
-
24
- export { createWandbLogTool, createWandbQueryTool, createWandbTools, isWandbAvailable } from "./wandb.js";
25
- export type { WandbConfig } from "./wandb.js";
26
-
27
- export { createTrainingTool, createFineTuningTool, createTrainingTools } from "./training.js";
28
- export type { TrainingConfig } from "./training.js";
29
-
@@ -7,7 +7,7 @@ import { spawn, execSync } from "child_process";
7
7
  import * as fs from "fs";
8
8
  import * as path from "path";
9
9
  import * as os from "os";
10
- import type { Tool, ToolResult } from "../agent/types.js";
10
+ import type { Tool, ToolResult } from "./types.js";
11
11
 
12
12
  export interface SandboxOptions {
13
13
  timeout?: number; // ms
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Tool system types
3
+ */
4
+
5
+ export interface ToolParameter {
6
+ name: string;
7
+ type: "string" | "number" | "boolean" | "array" | "object";
8
+ description: string;
9
+ required: boolean;
10
+ default?: unknown;
11
+ }
12
+
13
+ export interface ToolResult {
14
+ toolCallId: string;
15
+ output: string;
16
+ success: boolean;
17
+ error?: string;
18
+ }
19
+
20
+ export interface Tool {
21
+ name: string;
22
+ description: string;
23
+ parameters: ToolParameter[];
24
+ execute: (args: Record<string, unknown>) => Promise<ToolResult>;
25
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility exports
3
+ */
4
+
5
+ export { FileResolver, getFileResolver } from "./FileResolver.js";
6
+ export type { FileReference, ResolvedMessage } from "./FileResolver.js";
Binary file
package/ner_dataset.json DELETED
@@ -1,111 +0,0 @@
1
- [
2
- {
3
- "id": 1,
4
- "text": "Apple Inc. announced that Tim Cook will visit their new facility in Cupertino, California on March 15, 2024.",
5
- "entities": [
6
- {"text": "Apple Inc.", "start": 0, "end": 10, "label": "ORGANIZATION"},
7
- {"text": "Tim Cook", "start": 27, "end": 35, "label": "PERSON"},
8
- {"text": "Cupertino", "start": 70, "end": 79, "label": "LOCATION"},
9
- {"text": "California", "start": 81, "end": 91, "label": "LOCATION"},
10
- {"text": "March 15, 2024", "start": 95, "end": 109, "label": "DATE"}
11
- ]
12
- },
13
- {
14
- "id": 2,
15
- "text": "Dr. Sarah Johnson from Harvard University published groundbreaking research on quantum computing last Wednesday.",
16
- "entities": [
17
- {"text": "Sarah Johnson", "start": 4, "end": 17, "label": "PERSON"},
18
- {"text": "Harvard University", "start": 23, "end": 41, "label": "ORGANIZATION"},
19
- {"text": "last Wednesday", "start": 98, "end": 112, "label": "DATE"}
20
- ]
21
- },
22
- {
23
- "id": 3,
24
- "text": "The European Union imposed new sanctions on Russia following the meeting in Brussels between President Biden and Emmanuel Macron.",
25
- "entities": [
26
- {"text": "European Union", "start": 4, "end": 18, "label": "ORGANIZATION"},
27
- {"text": "Russia", "start": 44, "end": 50, "label": "LOCATION"},
28
- {"text": "Brussels", "start": 76, "end": 84, "label": "LOCATION"},
29
- {"text": "Biden", "start": 103, "end": 108, "label": "PERSON"},
30
- {"text": "Emmanuel Macron", "start": 113, "end": 128, "label": "PERSON"}
31
- ]
32
- },
33
- {
34
- "id": 4,
35
- "text": "Amazon Web Services reported $25 billion in revenue for Q4 2023, with significant growth in the Asia-Pacific region.",
36
- "entities": [
37
- {"text": "Amazon Web Services", "start": 0, "end": 19, "label": "ORGANIZATION"},
38
- {"text": "$25 billion", "start": 29, "end": 40, "label": "MONEY"},
39
- {"text": "Q4 2023", "start": 56, "end": 63, "label": "DATE"},
40
- {"text": "Asia-Pacific", "start": 96, "end": 108, "label": "LOCATION"}
41
- ]
42
- },
43
- {
44
- "id": 5,
45
- "text": "Professor Michael Chen will deliver a keynote speech at the International Conference on AI in Tokyo, Japan next month.",
46
- "entities": [
47
- {"text": "Michael Chen", "start": 10, "end": 22, "label": "PERSON"},
48
- {"text": "International Conference on AI", "start": 60, "end": 90, "label": "EVENT"},
49
- {"text": "Tokyo", "start": 94, "end": 99, "label": "LOCATION"},
50
- {"text": "Japan", "start": 101, "end": 106, "label": "LOCATION"},
51
- {"text": "next month", "start": 107, "end": 117, "label": "DATE"}
52
- ]
53
- },
54
- {
55
- "id": 6,
56
- "text": "The World Health Organization confirmed 500 new cases in Mumbai, India, prompting WHO Director-General Tedros Adhanom to issue a statement.",
57
- "entities": [
58
- {"text": "World Health Organization", "start": 4, "end": 29, "label": "ORGANIZATION"},
59
- {"text": "500", "start": 40, "end": 43, "label": "QUANTITY"},
60
- {"text": "Mumbai", "start": 57, "end": 63, "label": "LOCATION"},
61
- {"text": "India", "start": 65, "end": 70, "label": "LOCATION"},
62
- {"text": "WHO", "start": 82, "end": 85, "label": "ORGANIZATION"},
63
- {"text": "Tedros Adhanom", "start": 103, "end": 117, "label": "PERSON"}
64
- ]
65
- },
66
- {
67
- "id": 7,
68
- "text": "Tesla's stock rose 15% after Elon Musk announced a new manufacturing plant in Berlin, Germany, scheduled to open in January 2025.",
69
- "entities": [
70
- {"text": "Tesla", "start": 0, "end": 5, "label": "ORGANIZATION"},
71
- {"text": "15%", "start": 18, "end": 21, "label": "PERCENT"},
72
- {"text": "Elon Musk", "start": 28, "end": 37, "label": "PERSON"},
73
- {"text": "Berlin", "start": 78, "end": 84, "label": "LOCATION"},
74
- {"text": "Germany", "start": 86, "end": 93, "label": "LOCATION"},
75
- {"text": "January 2025", "start": 116, "end": 128, "label": "DATE"}
76
- ]
77
- },
78
- {
79
- "id": 8,
80
- "text": "The Nobel Prize in Literature was awarded to British author Margaret Atwood at the ceremony in Stockholm on December 10th.",
81
- "entities": [
82
- {"text": "Nobel Prize in Literature", "start": 4, "end": 29, "label": "EVENT"},
83
- {"text": "British", "start": 45, "end": 52, "label": "NATIONALITY"},
84
- {"text": "Margaret Atwood", "start": 60, "end": 75, "label": "PERSON"},
85
- {"text": "Stockholm", "start": 95, "end": 104, "label": "LOCATION"},
86
- {"text": "December 10th", "start": 108, "end": 121, "label": "DATE"}
87
- ]
88
- },
89
- {
90
- "id": 9,
91
- "text": "Microsoft Corporation acquired OpenAI for approximately $10 billion, as confirmed by CEO Satya Nadella in Redmond yesterday.",
92
- "entities": [
93
- {"text": "Microsoft Corporation", "start": 0, "end": 21, "label": "ORGANIZATION"},
94
- {"text": "OpenAI", "start": 31, "end": 37, "label": "ORGANIZATION"},
95
- {"text": "$10 billion", "start": 56, "end": 67, "label": "MONEY"},
96
- {"text": "Satya Nadella", "start": 89, "end": 102, "label": "PERSON"},
97
- {"text": "Redmond", "start": 106, "end": 113, "label": "LOCATION"},
98
- {"text": "yesterday", "start": 114, "end": 123, "label": "DATE"}
99
- ]
100
- },
101
- {
102
- "id": 10,
103
- "text": "Dr. Li Wei from the Beijing Institute of Technology developed a new algorithm that processes 10 terabytes of data in under 2 hours.",
104
- "entities": [
105
- {"text": "Li Wei", "start": 4, "end": 10, "label": "PERSON"},
106
- {"text": "Beijing Institute of Technology", "start": 20, "end": 51, "label": "ORGANIZATION"},
107
- {"text": "10 terabytes", "start": 93, "end": 105, "label": "QUANTITY"},
108
- {"text": "2 hours", "start": 124, "end": 131, "label": "TIME"}
109
- ]
110
- }
111
- ]