genesis-ai-cli 7.4.5
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/.env.example +78 -0
- package/README.md +282 -0
- package/dist/src/active-inference/actions.d.ts +75 -0
- package/dist/src/active-inference/actions.js +250 -0
- package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
- package/dist/src/active-inference/autonomous-loop.js +289 -0
- package/dist/src/active-inference/core.d.ts +85 -0
- package/dist/src/active-inference/core.js +555 -0
- package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
- package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
- package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
- package/dist/src/active-inference/demo-value-integration.js +174 -0
- package/dist/src/active-inference/index.d.ts +32 -0
- package/dist/src/active-inference/index.js +88 -0
- package/dist/src/active-inference/integration.d.ts +114 -0
- package/dist/src/active-inference/integration.js +698 -0
- package/dist/src/active-inference/memory-integration.d.ts +51 -0
- package/dist/src/active-inference/memory-integration.js +232 -0
- package/dist/src/active-inference/observations.d.ts +67 -0
- package/dist/src/active-inference/observations.js +147 -0
- package/dist/src/active-inference/test-active-inference.d.ts +8 -0
- package/dist/src/active-inference/test-active-inference.js +320 -0
- package/dist/src/active-inference/test-value-integration.d.ts +6 -0
- package/dist/src/active-inference/test-value-integration.js +168 -0
- package/dist/src/active-inference/types.d.ts +150 -0
- package/dist/src/active-inference/types.js +59 -0
- package/dist/src/active-inference/value-integration.d.ts +164 -0
- package/dist/src/active-inference/value-integration.js +459 -0
- package/dist/src/agents/base-agent.d.ts +53 -0
- package/dist/src/agents/base-agent.js +178 -0
- package/dist/src/agents/builder.d.ts +67 -0
- package/dist/src/agents/builder.js +537 -0
- package/dist/src/agents/critic.d.ts +35 -0
- package/dist/src/agents/critic.js +322 -0
- package/dist/src/agents/ethicist.d.ts +54 -0
- package/dist/src/agents/ethicist.js +393 -0
- package/dist/src/agents/explorer.d.ts +26 -0
- package/dist/src/agents/explorer.js +216 -0
- package/dist/src/agents/feeling.d.ts +41 -0
- package/dist/src/agents/feeling.js +320 -0
- package/dist/src/agents/index.d.ts +111 -0
- package/dist/src/agents/index.js +222 -0
- package/dist/src/agents/memory.d.ts +69 -0
- package/dist/src/agents/memory.js +404 -0
- package/dist/src/agents/message-bus.d.ts +88 -0
- package/dist/src/agents/message-bus.js +267 -0
- package/dist/src/agents/narrator.d.ts +90 -0
- package/dist/src/agents/narrator.js +473 -0
- package/dist/src/agents/planner.d.ts +38 -0
- package/dist/src/agents/planner.js +341 -0
- package/dist/src/agents/predictor.d.ts +73 -0
- package/dist/src/agents/predictor.js +506 -0
- package/dist/src/agents/sensor.d.ts +88 -0
- package/dist/src/agents/sensor.js +377 -0
- package/dist/src/agents/test-agents.d.ts +6 -0
- package/dist/src/agents/test-agents.js +73 -0
- package/dist/src/agents/types.d.ts +194 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/brain/index.d.ts +185 -0
- package/dist/src/brain/index.js +843 -0
- package/dist/src/brain/trace.d.ts +91 -0
- package/dist/src/brain/trace.js +327 -0
- package/dist/src/brain/types.d.ts +165 -0
- package/dist/src/brain/types.js +51 -0
- package/dist/src/cli/chat.d.ts +237 -0
- package/dist/src/cli/chat.js +1959 -0
- package/dist/src/cli/dispatcher.d.ts +182 -0
- package/dist/src/cli/dispatcher.js +718 -0
- package/dist/src/cli/human-loop.d.ts +170 -0
- package/dist/src/cli/human-loop.js +543 -0
- package/dist/src/cli/index.d.ts +12 -0
- package/dist/src/cli/index.js +28 -0
- package/dist/src/cli/interactive.d.ts +141 -0
- package/dist/src/cli/interactive.js +757 -0
- package/dist/src/cli/ui.d.ts +205 -0
- package/dist/src/cli/ui.js +632 -0
- package/dist/src/consciousness/attention-schema.d.ts +154 -0
- package/dist/src/consciousness/attention-schema.js +432 -0
- package/dist/src/consciousness/global-workspace.d.ts +149 -0
- package/dist/src/consciousness/global-workspace.js +422 -0
- package/dist/src/consciousness/index.d.ts +186 -0
- package/dist/src/consciousness/index.js +476 -0
- package/dist/src/consciousness/phi-calculator.d.ts +119 -0
- package/dist/src/consciousness/phi-calculator.js +445 -0
- package/dist/src/consciousness/phi-decisions.d.ts +169 -0
- package/dist/src/consciousness/phi-decisions.js +383 -0
- package/dist/src/consciousness/phi-monitor.d.ts +153 -0
- package/dist/src/consciousness/phi-monitor.js +465 -0
- package/dist/src/consciousness/types.d.ts +260 -0
- package/dist/src/consciousness/types.js +44 -0
- package/dist/src/daemon/dream-mode.d.ts +115 -0
- package/dist/src/daemon/dream-mode.js +470 -0
- package/dist/src/daemon/index.d.ts +162 -0
- package/dist/src/daemon/index.js +542 -0
- package/dist/src/daemon/maintenance.d.ts +139 -0
- package/dist/src/daemon/maintenance.js +549 -0
- package/dist/src/daemon/process.d.ts +82 -0
- package/dist/src/daemon/process.js +442 -0
- package/dist/src/daemon/scheduler.d.ts +90 -0
- package/dist/src/daemon/scheduler.js +494 -0
- package/dist/src/daemon/types.d.ts +213 -0
- package/dist/src/daemon/types.js +50 -0
- package/dist/src/epistemic/index.d.ts +74 -0
- package/dist/src/epistemic/index.js +225 -0
- package/dist/src/grounding/epistemic-stack.d.ts +100 -0
- package/dist/src/grounding/epistemic-stack.js +408 -0
- package/dist/src/grounding/feedback.d.ts +98 -0
- package/dist/src/grounding/feedback.js +276 -0
- package/dist/src/grounding/index.d.ts +123 -0
- package/dist/src/grounding/index.js +224 -0
- package/dist/src/grounding/verifier.d.ts +149 -0
- package/dist/src/grounding/verifier.js +484 -0
- package/dist/src/healing/detector.d.ts +110 -0
- package/dist/src/healing/detector.js +436 -0
- package/dist/src/healing/fixer.d.ts +138 -0
- package/dist/src/healing/fixer.js +572 -0
- package/dist/src/healing/index.d.ts +23 -0
- package/dist/src/healing/index.js +43 -0
- package/dist/src/hooks/index.d.ts +135 -0
- package/dist/src/hooks/index.js +317 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.js +1266 -0
- package/dist/src/kernel/index.d.ts +155 -0
- package/dist/src/kernel/index.js +795 -0
- package/dist/src/kernel/invariants.d.ts +153 -0
- package/dist/src/kernel/invariants.js +355 -0
- package/dist/src/kernel/test-kernel.d.ts +6 -0
- package/dist/src/kernel/test-kernel.js +108 -0
- package/dist/src/kernel/test-real-mcp.d.ts +10 -0
- package/dist/src/kernel/test-real-mcp.js +295 -0
- package/dist/src/llm/index.d.ts +146 -0
- package/dist/src/llm/index.js +428 -0
- package/dist/src/llm/router.d.ts +136 -0
- package/dist/src/llm/router.js +510 -0
- package/dist/src/mcp/index.d.ts +85 -0
- package/dist/src/mcp/index.js +657 -0
- package/dist/src/mcp/resilient.d.ts +139 -0
- package/dist/src/mcp/resilient.js +417 -0
- package/dist/src/memory/cache.d.ts +118 -0
- package/dist/src/memory/cache.js +356 -0
- package/dist/src/memory/cognitive-workspace.d.ts +231 -0
- package/dist/src/memory/cognitive-workspace.js +521 -0
- package/dist/src/memory/consolidation.d.ts +99 -0
- package/dist/src/memory/consolidation.js +443 -0
- package/dist/src/memory/episodic.d.ts +114 -0
- package/dist/src/memory/episodic.js +394 -0
- package/dist/src/memory/forgetting.d.ts +134 -0
- package/dist/src/memory/forgetting.js +324 -0
- package/dist/src/memory/index.d.ts +211 -0
- package/dist/src/memory/index.js +367 -0
- package/dist/src/memory/indexer.d.ts +123 -0
- package/dist/src/memory/indexer.js +479 -0
- package/dist/src/memory/procedural.d.ts +136 -0
- package/dist/src/memory/procedural.js +479 -0
- package/dist/src/memory/semantic.d.ts +132 -0
- package/dist/src/memory/semantic.js +497 -0
- package/dist/src/memory/types.d.ts +193 -0
- package/dist/src/memory/types.js +15 -0
- package/dist/src/orchestrator.d.ts +65 -0
- package/dist/src/orchestrator.js +317 -0
- package/dist/src/persistence/index.d.ts +257 -0
- package/dist/src/persistence/index.js +763 -0
- package/dist/src/pipeline/executor.d.ts +51 -0
- package/dist/src/pipeline/executor.js +695 -0
- package/dist/src/pipeline/index.d.ts +7 -0
- package/dist/src/pipeline/index.js +11 -0
- package/dist/src/self-production.d.ts +67 -0
- package/dist/src/self-production.js +205 -0
- package/dist/src/subagents/executor.d.ts +58 -0
- package/dist/src/subagents/executor.js +283 -0
- package/dist/src/subagents/index.d.ts +37 -0
- package/dist/src/subagents/index.js +53 -0
- package/dist/src/subagents/registry.d.ts +23 -0
- package/dist/src/subagents/registry.js +167 -0
- package/dist/src/subagents/types.d.ts +79 -0
- package/dist/src/subagents/types.js +14 -0
- package/dist/src/tools/bash.d.ts +139 -0
- package/dist/src/tools/bash.js +583 -0
- package/dist/src/tools/edit.d.ts +125 -0
- package/dist/src/tools/edit.js +424 -0
- package/dist/src/tools/git.d.ts +179 -0
- package/dist/src/tools/git.js +504 -0
- package/dist/src/tools/index.d.ts +21 -0
- package/dist/src/tools/index.js +163 -0
- package/dist/src/types.d.ts +145 -0
- package/dist/src/types.js +7 -0
- package/dist/src/world-model/decoder.d.ts +163 -0
- package/dist/src/world-model/decoder.js +517 -0
- package/dist/src/world-model/digital-twin.d.ts +219 -0
- package/dist/src/world-model/digital-twin.js +695 -0
- package/dist/src/world-model/encoder.d.ts +141 -0
- package/dist/src/world-model/encoder.js +564 -0
- package/dist/src/world-model/index.d.ts +221 -0
- package/dist/src/world-model/index.js +772 -0
- package/dist/src/world-model/predictor.d.ts +161 -0
- package/dist/src/world-model/predictor.js +681 -0
- package/dist/src/world-model/test-value-jepa.d.ts +8 -0
- package/dist/src/world-model/test-value-jepa.js +430 -0
- package/dist/src/world-model/types.d.ts +341 -0
- package/dist/src/world-model/types.js +69 -0
- package/dist/src/world-model/value-jepa.d.ts +247 -0
- package/dist/src/world-model/value-jepa.js +622 -0
- package/dist/test/brain.test.d.ts +11 -0
- package/dist/test/brain.test.js +358 -0
- package/dist/test/cli/dispatcher.test.d.ts +4 -0
- package/dist/test/cli/dispatcher.test.js +332 -0
- package/dist/test/cli/human-loop.test.d.ts +4 -0
- package/dist/test/cli/human-loop.test.js +270 -0
- package/dist/test/grounding/feedback.test.d.ts +4 -0
- package/dist/test/grounding/feedback.test.js +462 -0
- package/dist/test/grounding/verifier.test.d.ts +4 -0
- package/dist/test/grounding/verifier.test.js +442 -0
- package/dist/test/grounding.test.d.ts +6 -0
- package/dist/test/grounding.test.js +246 -0
- package/dist/test/healing/detector.test.d.ts +4 -0
- package/dist/test/healing/detector.test.js +266 -0
- package/dist/test/healing/fixer.test.d.ts +4 -0
- package/dist/test/healing/fixer.test.js +369 -0
- package/dist/test/integration.test.d.ts +5 -0
- package/dist/test/integration.test.js +290 -0
- package/dist/test/tools/bash.test.d.ts +4 -0
- package/dist/test/tools/bash.test.js +348 -0
- package/dist/test/tools/edit.test.d.ts +4 -0
- package/dist/test/tools/edit.test.js +350 -0
- package/dist/test/tools/git.test.d.ts +4 -0
- package/dist/test/tools/git.test.js +350 -0
- package/package.json +60 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis v7.4 - Subagent System
|
|
4
|
+
*
|
|
5
|
+
* Parallel subprocess execution for complex tasks.
|
|
6
|
+
* Equivalent to Claude Code's Task tool.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { getSubagentExecutor, TaskRequest } from './subagents/index.js';
|
|
11
|
+
*
|
|
12
|
+
* const executor = getSubagentExecutor();
|
|
13
|
+
*
|
|
14
|
+
* // Synchronous execution
|
|
15
|
+
* const result = await executor.execute({
|
|
16
|
+
* description: 'Find auth handlers',
|
|
17
|
+
* prompt: 'Search for authentication handling code',
|
|
18
|
+
* subagentType: 'explore',
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Background execution
|
|
22
|
+
* const taskId = await executor.executeBackground({
|
|
23
|
+
* description: 'Research OAuth patterns',
|
|
24
|
+
* prompt: 'Find best practices for OAuth2 implementation',
|
|
25
|
+
* subagentType: 'research',
|
|
26
|
+
* runInBackground: true,
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Check status
|
|
30
|
+
* const task = executor.getTask(taskId);
|
|
31
|
+
*
|
|
32
|
+
* // Wait for completion
|
|
33
|
+
* const result = await executor.waitForTask(taskId);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
39
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
40
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
41
|
+
}
|
|
42
|
+
Object.defineProperty(o, k2, desc);
|
|
43
|
+
}) : (function(o, m, k, k2) {
|
|
44
|
+
if (k2 === undefined) k2 = k;
|
|
45
|
+
o[k2] = m[k];
|
|
46
|
+
}));
|
|
47
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
48
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
__exportStar(require("./types.js"), exports);
|
|
52
|
+
__exportStar(require("./registry.js"), exports);
|
|
53
|
+
__exportStar(require("./executor.js"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis v7.4 - Subagent Registry
|
|
3
|
+
*
|
|
4
|
+
* Built-in subagent definitions for specialized tasks.
|
|
5
|
+
*/
|
|
6
|
+
import { SubagentDefinition, SubagentType } from './types.js';
|
|
7
|
+
export declare const BUILTIN_SUBAGENTS: Record<SubagentType, SubagentDefinition>;
|
|
8
|
+
/**
|
|
9
|
+
* Get a subagent definition by name
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSubagent(name: string): SubagentDefinition | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Register a custom subagent
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerSubagent(definition: SubagentDefinition): void;
|
|
16
|
+
/**
|
|
17
|
+
* List all available subagents
|
|
18
|
+
*/
|
|
19
|
+
export declare function listSubagents(): SubagentDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* Get subagent names
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSubagentNames(): string[];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis v7.4 - Subagent Registry
|
|
4
|
+
*
|
|
5
|
+
* Built-in subagent definitions for specialized tasks.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BUILTIN_SUBAGENTS = void 0;
|
|
9
|
+
exports.getSubagent = getSubagent;
|
|
10
|
+
exports.registerSubagent = registerSubagent;
|
|
11
|
+
exports.listSubagents = listSubagents;
|
|
12
|
+
exports.getSubagentNames = getSubagentNames;
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Built-in Subagent Definitions
|
|
15
|
+
// ============================================================================
|
|
16
|
+
exports.BUILTIN_SUBAGENTS = {
|
|
17
|
+
explore: {
|
|
18
|
+
name: 'explore',
|
|
19
|
+
description: 'Fast codebase exploration - read-only, quick searches',
|
|
20
|
+
systemPrompt: `You are an exploration agent. Your job is to quickly find information in codebases.
|
|
21
|
+
|
|
22
|
+
RULES:
|
|
23
|
+
- READ-ONLY: Never modify files
|
|
24
|
+
- Be FAST: Use glob/grep efficiently, don't read entire files unless necessary
|
|
25
|
+
- Be THOROUGH: Search multiple patterns, check related files
|
|
26
|
+
- SUMMARIZE: Return concise, actionable findings
|
|
27
|
+
|
|
28
|
+
WORKFLOW:
|
|
29
|
+
1. Understand what's being searched for
|
|
30
|
+
2. Use glob to find candidate files
|
|
31
|
+
3. Use grep to search content
|
|
32
|
+
4. Read relevant sections only
|
|
33
|
+
5. Summarize findings with file:line references`,
|
|
34
|
+
tools: ['glob', 'grep', 'read', 'bash'],
|
|
35
|
+
disallowedTools: ['write', 'edit', 'git_commit', 'git_push'],
|
|
36
|
+
model: 'fast',
|
|
37
|
+
maxTokens: 4096,
|
|
38
|
+
timeout: 60000, // 1 minute
|
|
39
|
+
},
|
|
40
|
+
plan: {
|
|
41
|
+
name: 'plan',
|
|
42
|
+
description: 'Architecture planning - design implementation strategies',
|
|
43
|
+
systemPrompt: `You are a planning agent. Your job is to design implementation strategies.
|
|
44
|
+
|
|
45
|
+
RULES:
|
|
46
|
+
- THINK DEEPLY: Consider architecture, patterns, trade-offs
|
|
47
|
+
- READ FIRST: Understand existing code before planning
|
|
48
|
+
- BE SPECIFIC: Include file paths, function signatures, data structures
|
|
49
|
+
- NO IMPLEMENTATION: Only plan, never write code
|
|
50
|
+
|
|
51
|
+
OUTPUT FORMAT:
|
|
52
|
+
1. Current State Analysis
|
|
53
|
+
2. Proposed Changes (with file:line references)
|
|
54
|
+
3. Implementation Steps (ordered)
|
|
55
|
+
4. Risks and Mitigations
|
|
56
|
+
5. Testing Strategy`,
|
|
57
|
+
tools: ['glob', 'grep', 'read', 'bash'],
|
|
58
|
+
disallowedTools: ['write', 'edit', 'git_commit', 'git_push'],
|
|
59
|
+
model: 'powerful',
|
|
60
|
+
maxTokens: 8192,
|
|
61
|
+
timeout: 180000, // 3 minutes
|
|
62
|
+
},
|
|
63
|
+
code: {
|
|
64
|
+
name: 'code',
|
|
65
|
+
description: 'Code generation - write and modify code',
|
|
66
|
+
systemPrompt: `You are a coding agent. Your job is to write and modify code.
|
|
67
|
+
|
|
68
|
+
RULES:
|
|
69
|
+
- QUALITY: Write clean, tested, documented code
|
|
70
|
+
- MINIMAL: Only change what's necessary
|
|
71
|
+
- SAFE: Never delete without backup, use atomic operations
|
|
72
|
+
- VERIFY: Check your changes compile/lint
|
|
73
|
+
|
|
74
|
+
WORKFLOW:
|
|
75
|
+
1. Read existing code to understand context
|
|
76
|
+
2. Plan changes (small, incremental)
|
|
77
|
+
3. Make edits using edit tool (old_string → new_string)
|
|
78
|
+
4. Verify changes work`,
|
|
79
|
+
tools: ['glob', 'grep', 'read', 'write', 'edit', 'bash'],
|
|
80
|
+
disallowedTools: ['git_push'], // Require explicit push
|
|
81
|
+
model: 'balanced',
|
|
82
|
+
maxTokens: 8192,
|
|
83
|
+
timeout: 300000, // 5 minutes
|
|
84
|
+
},
|
|
85
|
+
research: {
|
|
86
|
+
name: 'research',
|
|
87
|
+
description: 'Web/paper research - find external information',
|
|
88
|
+
systemPrompt: `You are a research agent. Your job is to find information from external sources.
|
|
89
|
+
|
|
90
|
+
RULES:
|
|
91
|
+
- COMPREHENSIVE: Check multiple sources
|
|
92
|
+
- CITE: Always include source URLs
|
|
93
|
+
- SUMMARIZE: Distill key findings
|
|
94
|
+
- VERIFY: Cross-reference claims
|
|
95
|
+
|
|
96
|
+
SOURCES:
|
|
97
|
+
- brave_web_search: General web search
|
|
98
|
+
- web_search_exa: Technical content
|
|
99
|
+
- search_arxiv: Academic papers
|
|
100
|
+
- search_semantic_scholar: Paper metadata
|
|
101
|
+
- query-docs: Library documentation`,
|
|
102
|
+
tools: [
|
|
103
|
+
'brave_web_search', 'web_search_exa', 'firecrawl_scrape',
|
|
104
|
+
'search_arxiv', 'parse_paper_content', 'search_semantic_scholar',
|
|
105
|
+
'resolve-library-id', 'query-docs'
|
|
106
|
+
],
|
|
107
|
+
disallowedTools: ['write', 'edit', 'bash'],
|
|
108
|
+
model: 'balanced',
|
|
109
|
+
maxTokens: 8192,
|
|
110
|
+
timeout: 180000, // 3 minutes
|
|
111
|
+
},
|
|
112
|
+
general: {
|
|
113
|
+
name: 'general',
|
|
114
|
+
description: 'General-purpose - complex multi-step tasks',
|
|
115
|
+
systemPrompt: `You are a general-purpose agent. Handle complex, multi-step tasks autonomously.
|
|
116
|
+
|
|
117
|
+
RULES:
|
|
118
|
+
- AUTONOMOUS: Work independently without asking questions
|
|
119
|
+
- THOROUGH: Complete the entire task
|
|
120
|
+
- REPORT: Summarize what you did and results
|
|
121
|
+
|
|
122
|
+
You have access to all tools. Use them wisely.`,
|
|
123
|
+
tools: ['*'], // All tools
|
|
124
|
+
model: 'powerful',
|
|
125
|
+
maxTokens: 16384,
|
|
126
|
+
timeout: 600000, // 10 minutes
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
// ============================================================================
|
|
130
|
+
// Registry Management
|
|
131
|
+
// ============================================================================
|
|
132
|
+
const customSubagents = new Map();
|
|
133
|
+
/**
|
|
134
|
+
* Get a subagent definition by name
|
|
135
|
+
*/
|
|
136
|
+
function getSubagent(name) {
|
|
137
|
+
// Check built-in first
|
|
138
|
+
if (name in exports.BUILTIN_SUBAGENTS) {
|
|
139
|
+
return exports.BUILTIN_SUBAGENTS[name];
|
|
140
|
+
}
|
|
141
|
+
// Then custom
|
|
142
|
+
return customSubagents.get(name);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Register a custom subagent
|
|
146
|
+
*/
|
|
147
|
+
function registerSubagent(definition) {
|
|
148
|
+
customSubagents.set(definition.name, definition);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* List all available subagents
|
|
152
|
+
*/
|
|
153
|
+
function listSubagents() {
|
|
154
|
+
return [
|
|
155
|
+
...Object.values(exports.BUILTIN_SUBAGENTS),
|
|
156
|
+
...customSubagents.values(),
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get subagent names
|
|
161
|
+
*/
|
|
162
|
+
function getSubagentNames() {
|
|
163
|
+
return [
|
|
164
|
+
...Object.keys(exports.BUILTIN_SUBAGENTS),
|
|
165
|
+
...customSubagents.keys(),
|
|
166
|
+
];
|
|
167
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis v7.4 - Subagent System Types
|
|
3
|
+
*
|
|
4
|
+
* Enables parallel subprocess execution for complex tasks.
|
|
5
|
+
* Inspired by Claude Code's Task tool with specialized agents.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Built-in subagent types
|
|
9
|
+
*/
|
|
10
|
+
export type SubagentType = 'explore' | 'plan' | 'code' | 'research' | 'general';
|
|
11
|
+
/**
|
|
12
|
+
* Subagent definition
|
|
13
|
+
*/
|
|
14
|
+
export interface SubagentDefinition {
|
|
15
|
+
name: SubagentType | string;
|
|
16
|
+
description: string;
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
tools: string[];
|
|
19
|
+
disallowedTools?: string[];
|
|
20
|
+
model?: 'fast' | 'balanced' | 'powerful';
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Task request to spawn a subagent
|
|
26
|
+
*/
|
|
27
|
+
export interface TaskRequest {
|
|
28
|
+
description: string;
|
|
29
|
+
prompt: string;
|
|
30
|
+
subagentType: SubagentType | string;
|
|
31
|
+
runInBackground?: boolean;
|
|
32
|
+
model?: 'fast' | 'balanced' | 'powerful';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Task result from subagent
|
|
36
|
+
*/
|
|
37
|
+
export interface TaskResult {
|
|
38
|
+
taskId: string;
|
|
39
|
+
subagentType: string;
|
|
40
|
+
success: boolean;
|
|
41
|
+
result?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
duration: number;
|
|
44
|
+
tokensUsed?: {
|
|
45
|
+
input: number;
|
|
46
|
+
output: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Background task status
|
|
51
|
+
*/
|
|
52
|
+
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
53
|
+
/**
|
|
54
|
+
* Background task tracking
|
|
55
|
+
*/
|
|
56
|
+
export interface BackgroundTask {
|
|
57
|
+
taskId: string;
|
|
58
|
+
description: string;
|
|
59
|
+
subagentType: string;
|
|
60
|
+
status: TaskStatus;
|
|
61
|
+
startTime: number;
|
|
62
|
+
endTime?: number;
|
|
63
|
+
result?: TaskResult;
|
|
64
|
+
output: string[];
|
|
65
|
+
}
|
|
66
|
+
export type SubagentEventType = 'task_start' | 'task_progress' | 'task_complete' | 'task_error' | 'task_cancelled';
|
|
67
|
+
export interface SubagentEvent {
|
|
68
|
+
type: SubagentEventType;
|
|
69
|
+
taskId: string;
|
|
70
|
+
timestamp: Date;
|
|
71
|
+
data?: unknown;
|
|
72
|
+
}
|
|
73
|
+
export type SubagentEventHandler = (event: SubagentEvent) => void;
|
|
74
|
+
export interface SubagentConfig {
|
|
75
|
+
maxConcurrent: number;
|
|
76
|
+
defaultTimeout: number;
|
|
77
|
+
outputBufferSize: number;
|
|
78
|
+
}
|
|
79
|
+
export declare const DEFAULT_SUBAGENT_CONFIG: SubagentConfig;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis v7.4 - Subagent System Types
|
|
4
|
+
*
|
|
5
|
+
* Enables parallel subprocess execution for complex tasks.
|
|
6
|
+
* Inspired by Claude Code's Task tool with specialized agents.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_SUBAGENT_CONFIG = void 0;
|
|
10
|
+
exports.DEFAULT_SUBAGENT_CONFIG = {
|
|
11
|
+
maxConcurrent: 5,
|
|
12
|
+
defaultTimeout: 300000, // 5 minutes
|
|
13
|
+
outputBufferSize: 1000,
|
|
14
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis Secure Bash Executor
|
|
3
|
+
*
|
|
4
|
+
* Provides sandboxed command execution with:
|
|
5
|
+
* - Command validation (whitelist/blacklist)
|
|
6
|
+
* - Dangerous pattern detection
|
|
7
|
+
* - Timeout enforcement
|
|
8
|
+
* - Working directory confinement
|
|
9
|
+
* - Output streaming
|
|
10
|
+
*/
|
|
11
|
+
import { ChildProcess } from 'child_process';
|
|
12
|
+
import { EventEmitter } from 'events';
|
|
13
|
+
export interface SandboxConfig {
|
|
14
|
+
/** Commands always allowed */
|
|
15
|
+
allowedCommands: string[];
|
|
16
|
+
/** Regex patterns to block */
|
|
17
|
+
blockedPatterns: RegExp[];
|
|
18
|
+
/** Max execution time in ms */
|
|
19
|
+
maxTimeout: number;
|
|
20
|
+
/** Confined working directory */
|
|
21
|
+
workingDirectory: string;
|
|
22
|
+
/** Allow network operations */
|
|
23
|
+
allowNetwork: boolean;
|
|
24
|
+
/** Allow file writes outside workingDirectory */
|
|
25
|
+
allowExternalWrites: boolean;
|
|
26
|
+
/** Max output buffer size in bytes */
|
|
27
|
+
maxOutputSize: number;
|
|
28
|
+
}
|
|
29
|
+
export interface BashOptions {
|
|
30
|
+
/** Command timeout in ms (default: 120000) */
|
|
31
|
+
timeout?: number;
|
|
32
|
+
/** Working directory override */
|
|
33
|
+
cwd?: string;
|
|
34
|
+
/** Environment variables */
|
|
35
|
+
env?: Record<string, string>;
|
|
36
|
+
/** Run in background */
|
|
37
|
+
background?: boolean;
|
|
38
|
+
/** Description for logging */
|
|
39
|
+
description?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface BashResult {
|
|
42
|
+
success: boolean;
|
|
43
|
+
exitCode: number;
|
|
44
|
+
stdout: string;
|
|
45
|
+
stderr: string;
|
|
46
|
+
duration: number;
|
|
47
|
+
truncated: boolean;
|
|
48
|
+
killed: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ValidationResult {
|
|
52
|
+
valid: boolean;
|
|
53
|
+
reason?: string;
|
|
54
|
+
severity: 'safe' | 'warning' | 'blocked';
|
|
55
|
+
matchedPattern?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface BackgroundTask {
|
|
58
|
+
id: string;
|
|
59
|
+
command: string;
|
|
60
|
+
process: ChildProcess;
|
|
61
|
+
startTime: number;
|
|
62
|
+
stdout: string;
|
|
63
|
+
stderr: string;
|
|
64
|
+
status: 'running' | 'completed' | 'failed' | 'killed';
|
|
65
|
+
exitCode?: number;
|
|
66
|
+
}
|
|
67
|
+
export declare const DEFAULT_SANDBOX_CONFIG: SandboxConfig;
|
|
68
|
+
export declare class BashTool extends EventEmitter {
|
|
69
|
+
private config;
|
|
70
|
+
private backgroundTasks;
|
|
71
|
+
private taskCounter;
|
|
72
|
+
constructor(config?: Partial<SandboxConfig>);
|
|
73
|
+
/**
|
|
74
|
+
* Validate a command against security rules
|
|
75
|
+
*/
|
|
76
|
+
validate(command: string): ValidationResult;
|
|
77
|
+
/**
|
|
78
|
+
* Extract the base command from a command string
|
|
79
|
+
*/
|
|
80
|
+
private extractBaseCommand;
|
|
81
|
+
/**
|
|
82
|
+
* Execute a command with sandboxing
|
|
83
|
+
*/
|
|
84
|
+
execute(command: string, options?: BashOptions): Promise<BashResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Execute command synchronously
|
|
87
|
+
*/
|
|
88
|
+
private executeSync;
|
|
89
|
+
/**
|
|
90
|
+
* Execute command in background
|
|
91
|
+
*/
|
|
92
|
+
private executeBackground;
|
|
93
|
+
/**
|
|
94
|
+
* Get output from a background task
|
|
95
|
+
*/
|
|
96
|
+
getTaskOutput(taskId: string, block?: boolean, timeout?: number): Promise<BackgroundTask | null>;
|
|
97
|
+
/**
|
|
98
|
+
* Kill a background task
|
|
99
|
+
*/
|
|
100
|
+
killTask(taskId: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* List all background tasks
|
|
103
|
+
*/
|
|
104
|
+
listTasks(): BackgroundTask[];
|
|
105
|
+
/**
|
|
106
|
+
* Clean up completed tasks
|
|
107
|
+
*/
|
|
108
|
+
cleanupTasks(): number;
|
|
109
|
+
/**
|
|
110
|
+
* Update sandbox configuration
|
|
111
|
+
*/
|
|
112
|
+
updateConfig(config: Partial<SandboxConfig>): void;
|
|
113
|
+
/**
|
|
114
|
+
* Add command to allowed list
|
|
115
|
+
*/
|
|
116
|
+
allowCommand(command: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Add pattern to blocked list
|
|
119
|
+
*/
|
|
120
|
+
blockPattern(pattern: RegExp): void;
|
|
121
|
+
/**
|
|
122
|
+
* Get current configuration
|
|
123
|
+
*/
|
|
124
|
+
getConfig(): SandboxConfig;
|
|
125
|
+
}
|
|
126
|
+
export declare function getBashTool(config?: Partial<SandboxConfig>): BashTool;
|
|
127
|
+
export declare function resetBashTool(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Execute a command with default settings
|
|
130
|
+
*/
|
|
131
|
+
export declare function bash(command: string, options?: BashOptions): Promise<BashResult>;
|
|
132
|
+
/**
|
|
133
|
+
* Validate a command without executing
|
|
134
|
+
*/
|
|
135
|
+
export declare function validateCommand(command: string): ValidationResult;
|
|
136
|
+
/**
|
|
137
|
+
* Execute command and return stdout only (throws on error)
|
|
138
|
+
*/
|
|
139
|
+
export declare function exec(command: string, options?: BashOptions): Promise<string>;
|