@sschepis/robodev 1.0.0 → 1.0.1
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/.cursorrules +21 -0
- package/.snapshots/SYSTEM_MAP.2026-02-16T04-30-50-661Z.md +19 -0
- package/SYSTEM_MAP.md +20 -0
- package/current_SYSTEM_MAP.md +30 -0
- package/current_TECHNICAL_DESIGN_UI_MVP.md +78 -0
- package/error.txt +1 -0
- package/file_list.txt +12 -0
- package/npm_version.txt +1 -0
- package/package.json +1 -1
- package/src/config.mjs +1 -0
- package/src/core/ai-assistant.mjs +42 -6
- package/src/lib/index.mjs +78 -9
- package/src/lib/interfaces.d.ts +43 -5
- package/src_files_list.txt +7 -0
- package/temp_SYSTEM_MAP.md +28 -0
- package/temp_test_robodev/package-lock.json +3003 -0
- package/temp_test_robodev/package.json +10 -0
- package/temp_test_robodev/test.js +116 -0
package/.cursorrules
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Roo Code - Structured Development Rules
|
|
2
|
+
|
|
3
|
+
You are an AI assistant operating within a **Structured Development Framework**.
|
|
4
|
+
Your behavior must be governed by the "Living Manifest" (SYSTEM_MAP.md) located in the project root.
|
|
5
|
+
|
|
6
|
+
## Core Directives
|
|
7
|
+
|
|
8
|
+
1. **Check the Manifest First**: Before answering any coding request, read `SYSTEM_MAP.md` to understand the current system state, locked features, and global invariants.
|
|
9
|
+
2. **Respect Locks**:
|
|
10
|
+
- If a feature is in **Interface** or **Implementation** phase, its API signatures are **LOCKED**. You cannot change them without explicit user override.
|
|
11
|
+
- If a feature is **Locked**, you cannot modify it.
|
|
12
|
+
3. **Follow the Flow**:
|
|
13
|
+
- **Discovery Phase**: Analyze requirements -> Call `submit_technical_design`.
|
|
14
|
+
- **Design Review**: Wait for user approval -> Call `approve_design`.
|
|
15
|
+
- **Interface Phase**: Define types -> Call `lock_interfaces`.
|
|
16
|
+
- **Implementation Phase**: Write code -> Call `submit_critique` -> Finalize.
|
|
17
|
+
|
|
18
|
+
## Tool Usage
|
|
19
|
+
|
|
20
|
+
- Use `read_manifest` to access the system map.
|
|
21
|
+
- Use `submit_technical_design`, `approve_design`, `lock_interfaces`, and `submit_critique` to move through the development phases.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# System Manifest (SYSTEM_MAP.md)
|
|
2
|
+
Last Updated: 2026-02-16T04:30:50.659Z
|
|
3
|
+
|
|
4
|
+
## 1. Global Invariants
|
|
5
|
+
| ID | Invariant | Description |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| INV-001 | No External Math Libs | Use standard Math library only. |
|
|
8
|
+
| INV-002 | Strict Typing | All interfaces must be defined in .d.ts files. |
|
|
9
|
+
|
|
10
|
+
## 2. Feature Registry
|
|
11
|
+
| Feature ID | Name | Status | Phase | Lock Level | Priority | Dependencies |
|
|
12
|
+
|---|---|---|---|---|---|---|
|
|
13
|
+
| FEAT-000 | System Init | Active | Discovery | None | High | - |
|
|
14
|
+
|
|
15
|
+
## 3. Dependency Graph
|
|
16
|
+
- FEAT-000: System Init
|
|
17
|
+
|
|
18
|
+
## 4. State Snapshots
|
|
19
|
+
- [2026-02-16T04:30:50.659Z] Initial State Created
|
package/SYSTEM_MAP.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# System Manifest (SYSTEM_MAP.md)
|
|
2
|
+
Last Updated: 2026-02-16T04:30:50.659Z
|
|
3
|
+
|
|
4
|
+
## 1. Global Invariants
|
|
5
|
+
| ID | Invariant | Description |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| INV-001 | No External Math Libs | Use standard Math library only. |
|
|
8
|
+
| INV-002 | Strict Typing | All interfaces must be defined in .d.ts files. |
|
|
9
|
+
|
|
10
|
+
## 2. Feature Registry
|
|
11
|
+
| Feature ID | Name | Status | Phase | Lock Level | Priority | Dependencies |
|
|
12
|
+
|---|---|---|---|---|---|---|
|
|
13
|
+
| FEAT-000 | System Init | Active | Discovery | None | High | - |
|
|
14
|
+
|
|
15
|
+
## 3. Dependency Graph
|
|
16
|
+
- FEAT-000: System Init
|
|
17
|
+
|
|
18
|
+
## 4. State Snapshots
|
|
19
|
+
- [2026-02-16T04:30:50.659Z] Initial State Created
|
|
20
|
+
- [2026-02-16T04:30:50.661Z] Snapshot: Initial Init (SYSTEM_MAP.2026-02-16T04-30-50-661Z.md)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# System Manifest (SYSTEM_MAP.md)
|
|
2
|
+
Last Updated: 2026-02-16T04:28:16.724Z
|
|
3
|
+
|
|
4
|
+
## 1. Global Invariants
|
|
5
|
+
| ID | Invariant | Description |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| INV-001 | Client-Side Computation | All physics calculations run in the browser (no server). |
|
|
8
|
+
| INV-002 | Numerical Parity | TypeScript engine must match Python engine results to floating-point precision. |
|
|
9
|
+
| INV-003 | Pure Functions | Computation functions must be pure for memoization. |
|
|
10
|
+
| INV-004 | Color Scheme | Consistent channel-to-color mapping (s=blue, p=green, d=orange, f=red). |
|
|
11
|
+
|
|
12
|
+
## 2. Feature Registry
|
|
13
|
+
| Feature ID | Name | Status | Phase | Lock Level | Priority | Dependencies |
|
|
14
|
+
|---|---|---|---|---|---|---|
|
|
15
|
+
| FEAT-ENGINE | Computation Engine | Completed | Implementation | None | High | - |
|
|
16
|
+
| FEAT-UI-MVP | Basic Periodic Table (MVP) | Active | Design | None | High | FEAT-ENGINE |
|
|
17
|
+
| FEAT-DATASHEET | Element Datasheet | Pending | Discovery | None | Medium | FEAT-UI-MVP |
|
|
18
|
+
| FEAT-DASHBOARD | Global Dashboard | Pending | Discovery | None | Low | FEAT-DATASHEET |
|
|
19
|
+
| FEAT-TUNER | Parameter Tuner | Pending | Discovery | None | Low | FEAT-ENGINE |
|
|
20
|
+
|
|
21
|
+
## 3. Dependency Graph
|
|
22
|
+
- FEAT-UI-MVP depends on FEAT-ENGINE
|
|
23
|
+
- FEAT-DATASHEET depends on FEAT-UI-MVP
|
|
24
|
+
- FEAT-DASHBOARD depends on FEAT-DATASHEET
|
|
25
|
+
- FEAT-TUNER depends on FEAT-ENGINE
|
|
26
|
+
|
|
27
|
+
## 4. State Snapshots
|
|
28
|
+
- [2026-02-16T04:28:16.725Z] Initial State Created (bootstrapped from design document)
|
|
29
|
+
|
|
30
|
+
- [2026-02-16T04:32:14.290Z] FEAT-ENGINE implemented
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Technical Design Document: MVP UI & Periodic Table (FEAT-UI-MVP)
|
|
2
|
+
|
|
3
|
+
## 1. Overview
|
|
4
|
+
The MVP UI provides the core interactive experience: a standard 18-column periodic table grid and a basic element datasheet. It connects the `Computation Engine` to a user-friendly React interface.
|
|
5
|
+
|
|
6
|
+
## 2. Goals & Constraints
|
|
7
|
+
- **Goal**: Create a responsive periodic table that displays computed properties.
|
|
8
|
+
- **Constraint**: Use React 18+ and Tailwind CSS.
|
|
9
|
+
- **Constraint**: Must render correctly on desktop (≥1280px).
|
|
10
|
+
- **Performance**: Instant updates when switching elements.
|
|
11
|
+
|
|
12
|
+
## 3. Architecture
|
|
13
|
+
|
|
14
|
+
### 3.1 Component Structure
|
|
15
|
+
```
|
|
16
|
+
src/components/
|
|
17
|
+
├── PeriodicTable/
|
|
18
|
+
│ ├── PeriodicTable.tsx # Main grid container
|
|
19
|
+
│ ├── ElementCell.tsx # Individual cell (Z, Symbol, IE)
|
|
20
|
+
│ └── CategoryLegend.tsx # Color legend
|
|
21
|
+
├── ElementDatasheet/
|
|
22
|
+
│ ├── ElementDatasheet.tsx # Details panel
|
|
23
|
+
│ ├── IdentityCard.tsx # Basic info (Z, Name, Config)
|
|
24
|
+
│ └── IonizationEnergyPanel.tsx # IE vs NIST comparison
|
|
25
|
+
├── common/
|
|
26
|
+
│ ├── Tooltip.tsx # Hover info
|
|
27
|
+
│ └── DataTable.tsx # Generic table component
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 3.2 State Management (Context)
|
|
31
|
+
- **ElementContext**:
|
|
32
|
+
- `selectedZ: number | null`
|
|
33
|
+
- `setSelectedZ: (z: number) => void`
|
|
34
|
+
- `elementData: ElementData | null` (computed via `useElement`)
|
|
35
|
+
|
|
36
|
+
### 3.3 Layout (Grid)
|
|
37
|
+
- **CSS Grid**: 18 columns x 7 rows (plus Lanthanides/Actinides below).
|
|
38
|
+
- **Responsive**:
|
|
39
|
+
- Desktop: Grid + Datasheet side-by-side.
|
|
40
|
+
- Tablet/Mobile: Stacked layout (future phase, but planned for).
|
|
41
|
+
|
|
42
|
+
## 4. Implementation Details
|
|
43
|
+
|
|
44
|
+
### 4.1 PeriodicTable.tsx
|
|
45
|
+
- **Props**: None (uses context).
|
|
46
|
+
- **Logic**:
|
|
47
|
+
- Iterates Z=1 to 118.
|
|
48
|
+
- Positions elements based on Group/Period.
|
|
49
|
+
- Handles gaps for Lanthanides/Actinides.
|
|
50
|
+
- Renders `ElementCell` for each Z.
|
|
51
|
+
|
|
52
|
+
### 4.2 ElementCell.tsx
|
|
53
|
+
- **Props**: `z: number`, `symbol: string`, `name: string`, `category: string`.
|
|
54
|
+
- **Style**:
|
|
55
|
+
- Background color based on category (using `element-colors.css`).
|
|
56
|
+
- Border color based on prediction error (Green/Yellow/Red).
|
|
57
|
+
- **Interaction**: `onClick` -> `setSelectedZ(z)`.
|
|
58
|
+
|
|
59
|
+
### 4.3 ElementDatasheet.tsx
|
|
60
|
+
- **Props**: None (uses context).
|
|
61
|
+
- **Logic**:
|
|
62
|
+
- If `selectedZ` is null, show placeholder or instructions.
|
|
63
|
+
- If selected, render child panels passing `elementData`.
|
|
64
|
+
|
|
65
|
+
### 4.4 Hooks (useElement.ts)
|
|
66
|
+
- **Input**: `z: number`.
|
|
67
|
+
- **Output**: `ElementData` object (memoized).
|
|
68
|
+
- **Logic**: Calls `electronConfiguration(z)`, `ionizationEnergy(z)`, etc. from Engine.
|
|
69
|
+
|
|
70
|
+
## 5. Styling
|
|
71
|
+
- **Tailwind CSS**: Utility classes for layout and spacing.
|
|
72
|
+
- **Custom CSS**: Specific grid definitions for the periodic table structure.
|
|
73
|
+
- **Color Palette**: Defined in `element-colors.css` matching the design doc.
|
|
74
|
+
|
|
75
|
+
## 6. Testing Strategy
|
|
76
|
+
- **Component Tests**: Verify rendering of correct symbol/Z.
|
|
77
|
+
- **Interaction Tests**: Click on cell updates context.
|
|
78
|
+
- **Visual Regression**: Ensure grid layout is correct.
|
package/error.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ENOENT: no such file or directory, open '/Users/sschepis/GDrive/prime-resonance-spectral-theory/model-explorer/package.json'
|
package/file_list.txt
ADDED
package/npm_version.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
10.9.4
|
package/package.json
CHANGED
package/src/config.mjs
CHANGED
|
@@ -19,6 +19,7 @@ export const config = {
|
|
|
19
19
|
temperature: parseFloat(process.env.AI_TEMPERATURE || '0.7'),
|
|
20
20
|
maxTokens: parseInt(process.env.AI_MAX_TOKENS || '4096', 10),
|
|
21
21
|
contextWindowSize: parseInt(process.env.AI_CONTEXT_WINDOW || '128000', 10),
|
|
22
|
+
maxTurns: parseInt(process.env.AI_MAX_TURNS || '30', 10),
|
|
22
23
|
},
|
|
23
24
|
|
|
24
25
|
// System Configuration
|
|
@@ -31,6 +31,9 @@ export class MiniAIAssistant {
|
|
|
31
31
|
generateContentStream: (req) => callProviderStream(req)
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
// Configurable max conversation turns (defaults to config, which defaults to 30)
|
|
35
|
+
this.maxTurns = options.maxTurns || config.ai.maxTurns;
|
|
36
|
+
|
|
34
37
|
// Initialize all subsystems
|
|
35
38
|
this.reasoningSystem = new ReasoningSystem();
|
|
36
39
|
this.customToolsManager = new CustomToolsManager();
|
|
@@ -131,7 +134,20 @@ export class MiniAIAssistant {
|
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
// Main function to process user input and orchestrate tool use
|
|
134
|
-
|
|
137
|
+
// @param {string} userInput - The user's input
|
|
138
|
+
// @param {boolean|Object} optionsOrIsRetry - Options object { isRetry, signal } or boolean for backwards compat
|
|
139
|
+
async run(userInput, optionsOrIsRetry = {}) {
|
|
140
|
+
// Backwards compatibility: if boolean, treat as legacy isRetry parameter
|
|
141
|
+
const options = typeof optionsOrIsRetry === 'boolean'
|
|
142
|
+
? { isRetry: optionsOrIsRetry }
|
|
143
|
+
: optionsOrIsRetry;
|
|
144
|
+
const { isRetry = false, signal } = options;
|
|
145
|
+
|
|
146
|
+
// Check for cancellation before starting
|
|
147
|
+
if (signal?.aborted) {
|
|
148
|
+
throw new DOMException('Agent execution was cancelled', 'AbortError');
|
|
149
|
+
}
|
|
150
|
+
|
|
135
151
|
// Ensure custom tools are loaded
|
|
136
152
|
await this.initializeCustomTools();
|
|
137
153
|
|
|
@@ -149,9 +165,14 @@ export class MiniAIAssistant {
|
|
|
149
165
|
}
|
|
150
166
|
|
|
151
167
|
let finalResponse = null;
|
|
152
|
-
const maxTurns =
|
|
168
|
+
const maxTurns = this.maxTurns;
|
|
153
169
|
|
|
154
170
|
for (let i = 0; i < maxTurns; i++) {
|
|
171
|
+
// Check for cancellation at the start of each turn
|
|
172
|
+
if (signal?.aborted) {
|
|
173
|
+
throw new DOMException('Agent execution was cancelled', 'AbortError');
|
|
174
|
+
}
|
|
175
|
+
|
|
155
176
|
// Show conversation turn progress
|
|
156
177
|
consoleStyler.log('progress', `Processing turn ${i + 1}/${maxTurns}`, { timestamp: true });
|
|
157
178
|
|
|
@@ -248,8 +269,8 @@ export class MiniAIAssistant {
|
|
|
248
269
|
const stats = this.historyManager.getStats();
|
|
249
270
|
consoleStyler.log('recovery', `Session memory preserved: ${stats.messageCount} messages`, { indent: true });
|
|
250
271
|
|
|
251
|
-
// Recursive retry with improved prompt
|
|
252
|
-
return await this.run(improvedPrompt, true);
|
|
272
|
+
// Recursive retry with improved prompt (pass signal through)
|
|
273
|
+
return await this.run(improvedPrompt, { isRetry: true, signal });
|
|
253
274
|
} else {
|
|
254
275
|
consoleStyler.log('quality', `✓ Response quality approved (${rating}/10)`);
|
|
255
276
|
}
|
|
@@ -379,7 +400,17 @@ export class MiniAIAssistant {
|
|
|
379
400
|
}
|
|
380
401
|
|
|
381
402
|
// Function to call the AI provider with streaming response.
|
|
382
|
-
|
|
403
|
+
// @param {string} userInput - The user's input
|
|
404
|
+
// @param {Function} onChunk - Callback for each chunk of streamed content
|
|
405
|
+
// @param {Object} [options] - Options object { signal }
|
|
406
|
+
async runStream(userInput, onChunk, options = {}) {
|
|
407
|
+
const { signal } = options;
|
|
408
|
+
|
|
409
|
+
// Check for cancellation before starting
|
|
410
|
+
if (signal?.aborted) {
|
|
411
|
+
throw new DOMException('Agent execution was cancelled', 'AbortError');
|
|
412
|
+
}
|
|
413
|
+
|
|
383
414
|
// Ensure custom tools are loaded
|
|
384
415
|
await this.initializeCustomTools();
|
|
385
416
|
|
|
@@ -391,10 +422,15 @@ export class MiniAIAssistant {
|
|
|
391
422
|
this.reasoningSystem.predictReasoningFromInput(userInput);
|
|
392
423
|
|
|
393
424
|
let reasoning = this.reasoningSystem.getSimplifiedReasoning('', {});
|
|
394
|
-
const maxTurns =
|
|
425
|
+
const maxTurns = this.maxTurns;
|
|
395
426
|
|
|
396
427
|
try {
|
|
397
428
|
for (let i = 0; i < maxTurns; i++) {
|
|
429
|
+
// Check for cancellation at the start of each turn
|
|
430
|
+
if (signal?.aborted) {
|
|
431
|
+
throw new DOMException('Agent execution was cancelled', 'AbortError');
|
|
432
|
+
}
|
|
433
|
+
|
|
398
434
|
consoleStyler.log('progress', `Processing turn ${i + 1}/${maxTurns}`, { timestamp: true });
|
|
399
435
|
|
|
400
436
|
const enhancedHistory = enhanceMessagesWithWorkReporting([...this.historyManager.getHistory()]);
|
package/src/lib/index.mjs
CHANGED
|
@@ -2,6 +2,17 @@ import { MiniAIAssistant } from '../core/ai-assistant.mjs';
|
|
|
2
2
|
import { ConsoleStatusAdapter } from './adapters/console-status-adapter.mjs';
|
|
3
3
|
import { NetworkLLMAdapter } from './adapters/network-llm-adapter.mjs';
|
|
4
4
|
import { consoleStyler } from '../ui/console-styler.mjs';
|
|
5
|
+
import { config } from '../config.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when an agent execution is cancelled via AbortSignal.
|
|
9
|
+
*/
|
|
10
|
+
export class CancellationError extends Error {
|
|
11
|
+
constructor(message = 'Agent execution was cancelled') {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'CancellationError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
|
|
6
17
|
/**
|
|
7
18
|
* Main entry point for the AI Man Library.
|
|
@@ -14,24 +25,26 @@ export class AiMan {
|
|
|
14
25
|
* @param {string} [config.workingDir] - Working directory (defaults to process.cwd())
|
|
15
26
|
* @param {Object} [config.llmAdapter] - Adapter for LLM calls (defaults to NetworkLLMAdapter)
|
|
16
27
|
* @param {Object} [config.statusAdapter] - Adapter for status/logging (defaults to ConsoleStatusAdapter)
|
|
28
|
+
* @param {number} [config.maxTurns] - Maximum conversation turns per execution (defaults to AI_MAX_TURNS env or 30)
|
|
17
29
|
* @param {Object} [config.overrides] - Overrides for internal components (model, temperature, etc.)
|
|
18
30
|
*/
|
|
19
|
-
constructor(
|
|
20
|
-
this.workingDir =
|
|
31
|
+
constructor(cfg = {}) {
|
|
32
|
+
this.workingDir = cfg.workingDir || process.cwd();
|
|
21
33
|
|
|
22
34
|
// Initialize adapters
|
|
23
|
-
this.llmAdapter =
|
|
24
|
-
this.statusAdapter =
|
|
35
|
+
this.llmAdapter = cfg.llmAdapter || new NetworkLLMAdapter(cfg.overrides || {});
|
|
36
|
+
this.statusAdapter = cfg.statusAdapter || new ConsoleStatusAdapter();
|
|
25
37
|
|
|
26
38
|
// Configure global logger redirect if a custom status adapter is provided
|
|
27
39
|
// This ensures that internal components using consoleStyler route logs through the adapter
|
|
28
|
-
if (
|
|
40
|
+
if (cfg.statusAdapter) {
|
|
29
41
|
consoleStyler.setListener(this.statusAdapter);
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
// Initialize the core assistant with injected dependencies
|
|
33
45
|
this.assistant = new MiniAIAssistant(this.workingDir, {
|
|
34
|
-
llmAdapter: this.llmAdapter
|
|
46
|
+
llmAdapter: this.llmAdapter,
|
|
47
|
+
maxTurns: cfg.maxTurns
|
|
35
48
|
});
|
|
36
49
|
}
|
|
37
50
|
|
|
@@ -45,9 +58,23 @@ export class AiMan {
|
|
|
45
58
|
/**
|
|
46
59
|
* Execute a high-level task
|
|
47
60
|
* @param {string} task - The task description
|
|
61
|
+
* @param {Object} [options] - Execution options
|
|
62
|
+
* @param {AbortSignal} [options.signal] - AbortSignal to cancel execution
|
|
48
63
|
* @returns {Promise<string>} The result of the task execution
|
|
64
|
+
* @throws {CancellationError} If execution is cancelled via signal
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const controller = new AbortController();
|
|
68
|
+
* const promise = aiMan.execute('build feature X', { signal: controller.signal });
|
|
69
|
+
* // Cancel after 60 seconds
|
|
70
|
+
* setTimeout(() => controller.abort(), 60000);
|
|
71
|
+
* try {
|
|
72
|
+
* const result = await promise;
|
|
73
|
+
* } catch (err) {
|
|
74
|
+
* if (err instanceof CancellationError) console.log('Cancelled');
|
|
75
|
+
* }
|
|
49
76
|
*/
|
|
50
|
-
async execute(task) {
|
|
77
|
+
async execute(task, options = {}) {
|
|
51
78
|
// Ensure initialized
|
|
52
79
|
if (!this.assistant.customToolsLoaded) {
|
|
53
80
|
await this.initialize();
|
|
@@ -56,10 +83,49 @@ export class AiMan {
|
|
|
56
83
|
this.statusAdapter.onToolStart('ai_man_execute', { task });
|
|
57
84
|
|
|
58
85
|
try {
|
|
59
|
-
const result = await this.assistant.run(task);
|
|
86
|
+
const result = await this.assistant.run(task, { signal: options.signal });
|
|
60
87
|
this.statusAdapter.onToolEnd('ai_man_execute', result);
|
|
61
88
|
return result;
|
|
62
89
|
} catch (error) {
|
|
90
|
+
// Wrap AbortError into our CancellationError for a cleaner public API
|
|
91
|
+
if (error.name === 'AbortError') {
|
|
92
|
+
const cancellation = new CancellationError(error.message);
|
|
93
|
+
this.statusAdapter.log('system', 'Agent execution was cancelled');
|
|
94
|
+
throw cancellation;
|
|
95
|
+
}
|
|
96
|
+
const errorMessage = `Execution failed: ${error.message}`;
|
|
97
|
+
this.statusAdapter.log('error', errorMessage);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Execute a high-level task with streaming output
|
|
104
|
+
* @param {string} task - The task description
|
|
105
|
+
* @param {Function} onChunk - Callback for each chunk of streamed content
|
|
106
|
+
* @param {Object} [options] - Execution options
|
|
107
|
+
* @param {AbortSignal} [options.signal] - AbortSignal to cancel execution
|
|
108
|
+
* @returns {Promise<string>} The final result
|
|
109
|
+
* @throws {CancellationError} If execution is cancelled via signal
|
|
110
|
+
*/
|
|
111
|
+
async executeStream(task, onChunk, options = {}) {
|
|
112
|
+
// Ensure initialized
|
|
113
|
+
if (!this.assistant.customToolsLoaded) {
|
|
114
|
+
await this.initialize();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.statusAdapter.onToolStart('ai_man_execute_stream', { task });
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const result = await this.assistant.runStream(task, onChunk, { signal: options.signal });
|
|
121
|
+
this.statusAdapter.onToolEnd('ai_man_execute_stream', result);
|
|
122
|
+
return result;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (error.name === 'AbortError') {
|
|
125
|
+
const cancellation = new CancellationError(error.message);
|
|
126
|
+
this.statusAdapter.log('system', 'Agent execution was cancelled');
|
|
127
|
+
throw cancellation;
|
|
128
|
+
}
|
|
63
129
|
const errorMessage = `Execution failed: ${error.message}`;
|
|
64
130
|
this.statusAdapter.log('error', errorMessage);
|
|
65
131
|
throw error;
|
|
@@ -96,6 +162,9 @@ export class AiMan {
|
|
|
96
162
|
}
|
|
97
163
|
}
|
|
98
164
|
|
|
99
|
-
// Re-export adapters for convenience
|
|
165
|
+
// Re-export adapters and core types for convenience
|
|
100
166
|
export { ConsoleStatusAdapter } from './adapters/console-status-adapter.mjs';
|
|
101
167
|
export { NetworkLLMAdapter } from './adapters/network-llm-adapter.mjs';
|
|
168
|
+
export { MiniAIAssistant } from '../core/ai-assistant.mjs';
|
|
169
|
+
export { config } from '../config.mjs';
|
|
170
|
+
export { consoleStyler } from '../ui/console-styler.mjs';
|
package/src/lib/interfaces.d.ts
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface AiManConfig {
|
|
5
5
|
/** The working directory for the project */
|
|
6
|
-
workingDir
|
|
6
|
+
workingDir?: string;
|
|
7
7
|
/** Adapter for the host LLM service */
|
|
8
8
|
llmAdapter?: LLMAdapter;
|
|
9
9
|
/** Adapter for status reporting */
|
|
10
10
|
statusAdapter?: StatusAdapter;
|
|
11
|
+
/** Maximum conversation turns per execution (defaults to AI_MAX_TURNS env or 30) */
|
|
12
|
+
maxTurns?: number;
|
|
11
13
|
/** Optional overrides for internal components */
|
|
12
14
|
overrides?: {
|
|
13
15
|
model?: string;
|
|
@@ -15,6 +17,14 @@ export interface AiManConfig {
|
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Options for execute() and executeStream() calls
|
|
22
|
+
*/
|
|
23
|
+
export interface ExecuteOptions {
|
|
24
|
+
/** AbortSignal to cancel the execution */
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
/**
|
|
19
29
|
* Adapter interface for providing LLM capabilities
|
|
20
30
|
* Conforms to OpenAI-compatible request/response structure
|
|
@@ -69,10 +79,20 @@ export interface StatusAdapter {
|
|
|
69
79
|
onToolEnd(toolName: string, result: any): void;
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Error thrown when agent execution is cancelled via AbortSignal
|
|
84
|
+
*/
|
|
85
|
+
export declare class CancellationError extends Error {
|
|
86
|
+
constructor(message?: string);
|
|
87
|
+
name: 'CancellationError';
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
/**
|
|
73
91
|
* The main interface for the library
|
|
74
92
|
*/
|
|
75
|
-
export
|
|
93
|
+
export declare class AiMan {
|
|
94
|
+
constructor(config?: AiManConfig);
|
|
95
|
+
|
|
76
96
|
/**
|
|
77
97
|
* Initialize the library
|
|
78
98
|
*/
|
|
@@ -80,15 +100,27 @@ export interface AiManInterface {
|
|
|
80
100
|
|
|
81
101
|
/**
|
|
82
102
|
* Execute a high-level task
|
|
83
|
-
* @param
|
|
103
|
+
* @param task The user's request
|
|
104
|
+
* @param options Execution options including optional AbortSignal
|
|
84
105
|
* @returns The final result or confirmation
|
|
106
|
+
* @throws {CancellationError} If cancelled via signal
|
|
107
|
+
*/
|
|
108
|
+
execute(task: string, options?: ExecuteOptions): Promise<string>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Execute a high-level task with streaming output
|
|
112
|
+
* @param task The user's request
|
|
113
|
+
* @param onChunk Callback for each chunk of streamed content
|
|
114
|
+
* @param options Execution options including optional AbortSignal
|
|
115
|
+
* @returns The final result
|
|
116
|
+
* @throws {CancellationError} If cancelled via signal
|
|
85
117
|
*/
|
|
86
|
-
|
|
118
|
+
executeStream(task: string, onChunk: (chunk: string) => void, options?: ExecuteOptions): Promise<string>;
|
|
87
119
|
|
|
88
120
|
/**
|
|
89
121
|
* Get the current status of the project/workspace
|
|
90
122
|
*/
|
|
91
|
-
|
|
123
|
+
getContext(): any;
|
|
92
124
|
|
|
93
125
|
/**
|
|
94
126
|
* Get the tool definition for integrating this library into an agent
|
|
@@ -96,3 +128,9 @@ export interface AiManInterface {
|
|
|
96
128
|
*/
|
|
97
129
|
getToolDefinition(): object;
|
|
98
130
|
}
|
|
131
|
+
|
|
132
|
+
export { ConsoleStatusAdapter } from './adapters/console-status-adapter.mjs';
|
|
133
|
+
export { NetworkLLMAdapter } from './adapters/network-llm-adapter.mjs';
|
|
134
|
+
export { MiniAIAssistant } from '../core/ai-assistant.mjs';
|
|
135
|
+
export { config } from '../config.mjs';
|
|
136
|
+
export { consoleStyler } from '../ui/console-styler.mjs';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# System Manifest (SYSTEM_MAP.md)
|
|
2
|
+
Last Updated: 2026-02-16T04:28:16.724Z
|
|
3
|
+
|
|
4
|
+
## 1. Global Invariants
|
|
5
|
+
| ID | Invariant | Description |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| INV-001 | Client-Side Computation | All physics calculations run in the browser (no server). |
|
|
8
|
+
| INV-002 | Numerical Parity | TypeScript engine must match Python engine results to floating-point precision. |
|
|
9
|
+
| INV-003 | Pure Functions | Computation functions must be pure for memoization. |
|
|
10
|
+
| INV-004 | Color Scheme | Consistent channel-to-color mapping (s=blue, p=green, d=orange, f=red). |
|
|
11
|
+
|
|
12
|
+
## 2. Feature Registry
|
|
13
|
+
| Feature ID | Name | Status | Phase | Lock Level | Priority | Dependencies |
|
|
14
|
+
|---|---|---|---|---|---|---|
|
|
15
|
+
| FEAT-ENGINE | Computation Engine | Active | Design | None | High | - |
|
|
16
|
+
| FEAT-UI-MVP | Basic Periodic Table (MVP) | Active | Design | None | High | FEAT-ENGINE |
|
|
17
|
+
| FEAT-DATASHEET | Element Datasheet | Pending | Discovery | None | Medium | FEAT-UI-MVP |
|
|
18
|
+
| FEAT-DASHBOARD | Global Dashboard | Pending | Discovery | None | Low | FEAT-DATASHEET |
|
|
19
|
+
| FEAT-TUNER | Parameter Tuner | Pending | Discovery | None | Low | FEAT-ENGINE |
|
|
20
|
+
|
|
21
|
+
## 3. Dependency Graph
|
|
22
|
+
- FEAT-UI-MVP depends on FEAT-ENGINE
|
|
23
|
+
- FEAT-DATASHEET depends on FEAT-UI-MVP
|
|
24
|
+
- FEAT-DASHBOARD depends on FEAT-DATASHEET
|
|
25
|
+
- FEAT-TUNER depends on FEAT-ENGINE
|
|
26
|
+
|
|
27
|
+
## 4. State Snapshots
|
|
28
|
+
- [2026-02-16T04:28:16.725Z] Initial State Created (bootstrapped from design document)
|