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,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis Tools Module
|
|
4
|
+
*
|
|
5
|
+
* Local tool capabilities:
|
|
6
|
+
* - Bash: Secure command execution
|
|
7
|
+
* - Edit: Diff-based file editing
|
|
8
|
+
* - Git: Native git operations
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.toolRegistry = void 0;
|
|
26
|
+
__exportStar(require("./bash.js"), exports);
|
|
27
|
+
__exportStar(require("./edit.js"), exports);
|
|
28
|
+
__exportStar(require("./git.js"), exports);
|
|
29
|
+
// Will be populated as tools are added
|
|
30
|
+
exports.toolRegistry = new Map();
|
|
31
|
+
// Register bash tool
|
|
32
|
+
const bash_js_1 = require("./bash.js");
|
|
33
|
+
exports.toolRegistry.set('bash', {
|
|
34
|
+
name: 'bash',
|
|
35
|
+
description: 'Execute shell commands in a secure sandbox',
|
|
36
|
+
execute: async (params) => {
|
|
37
|
+
const command = params.command;
|
|
38
|
+
const options = params.options;
|
|
39
|
+
return (0, bash_js_1.getBashTool)().execute(command, options);
|
|
40
|
+
},
|
|
41
|
+
validate: (params) => {
|
|
42
|
+
const command = params.command;
|
|
43
|
+
if (!command) {
|
|
44
|
+
return { valid: false, reason: 'Missing command parameter' };
|
|
45
|
+
}
|
|
46
|
+
const result = (0, bash_js_1.getBashTool)().validate(command);
|
|
47
|
+
return { valid: result.valid, reason: result.reason };
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
// Register edit tool
|
|
51
|
+
const edit_js_1 = require("./edit.js");
|
|
52
|
+
exports.toolRegistry.set('edit', {
|
|
53
|
+
name: 'edit',
|
|
54
|
+
description: 'Edit files using diff-based replacement',
|
|
55
|
+
execute: async (params) => {
|
|
56
|
+
return (0, edit_js_1.getEditTool)().edit({
|
|
57
|
+
file_path: params.file_path,
|
|
58
|
+
old_string: params.old_string,
|
|
59
|
+
new_string: params.new_string,
|
|
60
|
+
replace_all: params.replace_all,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
validate: (params) => {
|
|
64
|
+
const file_path = params.file_path;
|
|
65
|
+
const old_string = params.old_string;
|
|
66
|
+
const new_string = params.new_string;
|
|
67
|
+
if (!file_path)
|
|
68
|
+
return { valid: false, reason: 'Missing file_path parameter' };
|
|
69
|
+
if (!old_string)
|
|
70
|
+
return { valid: false, reason: 'Missing old_string parameter' };
|
|
71
|
+
if (new_string === undefined)
|
|
72
|
+
return { valid: false, reason: 'Missing new_string parameter' };
|
|
73
|
+
return (0, edit_js_1.getEditTool)().validatePath(file_path);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
exports.toolRegistry.set('write', {
|
|
77
|
+
name: 'write',
|
|
78
|
+
description: 'Write content to a file',
|
|
79
|
+
execute: async (params) => {
|
|
80
|
+
const { file_path, content, backup } = params;
|
|
81
|
+
return (0, edit_js_1.getEditTool)().write({
|
|
82
|
+
file_path: file_path,
|
|
83
|
+
content: content,
|
|
84
|
+
backup: backup,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
validate: (params) => {
|
|
88
|
+
const { file_path, content } = params;
|
|
89
|
+
if (!file_path)
|
|
90
|
+
return { valid: false, reason: 'Missing file_path parameter' };
|
|
91
|
+
if (content === undefined)
|
|
92
|
+
return { valid: false, reason: 'Missing content parameter' };
|
|
93
|
+
return (0, edit_js_1.getEditTool)().validatePath(file_path);
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
// Register git tools
|
|
97
|
+
const git_js_1 = require("./git.js");
|
|
98
|
+
exports.toolRegistry.set('git_status', {
|
|
99
|
+
name: 'git_status',
|
|
100
|
+
description: 'Get git repository status',
|
|
101
|
+
execute: async (params) => {
|
|
102
|
+
return (0, git_js_1.getGitTool)().status(params.cwd);
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
exports.toolRegistry.set('git_diff', {
|
|
106
|
+
name: 'git_diff',
|
|
107
|
+
description: 'Get diff of changes',
|
|
108
|
+
execute: async (params) => {
|
|
109
|
+
return (0, git_js_1.getGitTool)().diff({
|
|
110
|
+
staged: params.staged,
|
|
111
|
+
file: params.file,
|
|
112
|
+
}, params.cwd);
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
exports.toolRegistry.set('git_log', {
|
|
116
|
+
name: 'git_log',
|
|
117
|
+
description: 'Get commit history',
|
|
118
|
+
execute: async (params) => {
|
|
119
|
+
return (0, git_js_1.getGitTool)().log({
|
|
120
|
+
count: params.count,
|
|
121
|
+
oneline: params.oneline,
|
|
122
|
+
}, params.cwd);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
exports.toolRegistry.set('git_add', {
|
|
126
|
+
name: 'git_add',
|
|
127
|
+
description: 'Stage files for commit',
|
|
128
|
+
execute: async (params) => {
|
|
129
|
+
const files = params.files;
|
|
130
|
+
if (!files || files.length === 0) {
|
|
131
|
+
return { success: false, error: 'No files specified' };
|
|
132
|
+
}
|
|
133
|
+
return (0, git_js_1.getGitTool)().add(files, params.cwd);
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
exports.toolRegistry.set('git_commit', {
|
|
137
|
+
name: 'git_commit',
|
|
138
|
+
description: 'Create a commit',
|
|
139
|
+
execute: async (params) => {
|
|
140
|
+
const message = params.message;
|
|
141
|
+
if (!message) {
|
|
142
|
+
return { success: false, error: 'Missing commit message' };
|
|
143
|
+
}
|
|
144
|
+
return (0, git_js_1.getGitTool)().commit({
|
|
145
|
+
message,
|
|
146
|
+
addSignature: params.addSignature,
|
|
147
|
+
files: params.files,
|
|
148
|
+
}, params.cwd);
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
exports.toolRegistry.set('git_push', {
|
|
152
|
+
name: 'git_push',
|
|
153
|
+
description: 'Push to remote (requires confirmation)',
|
|
154
|
+
execute: async (params) => {
|
|
155
|
+
return (0, git_js_1.getGitTool)().push({
|
|
156
|
+
remote: params.remote,
|
|
157
|
+
branch: params.branch,
|
|
158
|
+
setUpstream: params.setUpstream,
|
|
159
|
+
force: params.force,
|
|
160
|
+
confirmed: params.confirmed,
|
|
161
|
+
}, params.cwd);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis - System Creator Types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for MCP orchestration
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Names of all 13 MCP servers available to Genesis.
|
|
8
|
+
* Renamed from MCPServer to avoid conflict with MCPServerState interface.
|
|
9
|
+
*/
|
|
10
|
+
export type MCPServerName = 'filesystem' | 'github' | 'openai' | 'memory' | 'gemini' | 'context7' | 'arxiv' | 'semantic-scholar' | 'wolfram' | 'firecrawl' | 'exa' | 'brave-search' | 'stability-ai';
|
|
11
|
+
/** @deprecated Use MCPServerName instead */
|
|
12
|
+
export type MCPServer = MCPServerName;
|
|
13
|
+
export interface MCPCapability {
|
|
14
|
+
server: MCPServerName;
|
|
15
|
+
category: 'knowledge' | 'creation' | 'research' | 'visual' | 'storage';
|
|
16
|
+
tools: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SystemSpec {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
type: 'autopoietic' | 'agent' | 'multi-agent' | 'service' | 'custom';
|
|
23
|
+
features: string[];
|
|
24
|
+
constraints?: string[];
|
|
25
|
+
inspirations?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface GeneratedSystem {
|
|
28
|
+
spec: SystemSpec;
|
|
29
|
+
research: ResearchResult;
|
|
30
|
+
architecture: Architecture;
|
|
31
|
+
code: GeneratedCode;
|
|
32
|
+
visuals: Visual[];
|
|
33
|
+
repo?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ResearchResult {
|
|
36
|
+
papers: Paper[];
|
|
37
|
+
documentation: Documentation[];
|
|
38
|
+
codeExamples: CodeExample[];
|
|
39
|
+
webResults: WebResult[];
|
|
40
|
+
insights: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface Paper {
|
|
43
|
+
title: string;
|
|
44
|
+
authors: string[];
|
|
45
|
+
year: number;
|
|
46
|
+
source: 'arxiv' | 'semantic-scholar';
|
|
47
|
+
url: string;
|
|
48
|
+
summary: string;
|
|
49
|
+
relevance: number;
|
|
50
|
+
}
|
|
51
|
+
export interface Documentation {
|
|
52
|
+
library: string;
|
|
53
|
+
source: 'context7';
|
|
54
|
+
content: string;
|
|
55
|
+
examples: string[];
|
|
56
|
+
}
|
|
57
|
+
export interface CodeExample {
|
|
58
|
+
source: 'exa' | 'github';
|
|
59
|
+
language: string;
|
|
60
|
+
code: string;
|
|
61
|
+
description: string;
|
|
62
|
+
}
|
|
63
|
+
export interface WebResult {
|
|
64
|
+
source: 'gemini' | 'brave-search' | 'firecrawl';
|
|
65
|
+
title: string;
|
|
66
|
+
url: string;
|
|
67
|
+
content: string;
|
|
68
|
+
}
|
|
69
|
+
export interface Architecture {
|
|
70
|
+
components: Component[];
|
|
71
|
+
relations: Relation[];
|
|
72
|
+
invariants: string[];
|
|
73
|
+
operations: Operation[];
|
|
74
|
+
events: EventType[];
|
|
75
|
+
}
|
|
76
|
+
export interface Component {
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
type: 'core' | 'service' | 'adapter' | 'util';
|
|
80
|
+
description: string;
|
|
81
|
+
dependencies: string[];
|
|
82
|
+
}
|
|
83
|
+
export interface Relation {
|
|
84
|
+
from: string;
|
|
85
|
+
to: string;
|
|
86
|
+
type: 'uses' | 'extends' | 'implements' | 'triggers';
|
|
87
|
+
}
|
|
88
|
+
export interface Operation {
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
inputs: Parameter[];
|
|
93
|
+
outputs: Parameter[];
|
|
94
|
+
complexity: number;
|
|
95
|
+
}
|
|
96
|
+
export interface Parameter {
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
required: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface EventType {
|
|
102
|
+
name: string;
|
|
103
|
+
payload: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
export interface GeneratedCode {
|
|
106
|
+
files: CodeFile[];
|
|
107
|
+
language: 'typescript' | 'python' | 'rust';
|
|
108
|
+
framework?: string;
|
|
109
|
+
tests: CodeFile[];
|
|
110
|
+
}
|
|
111
|
+
export interface CodeFile {
|
|
112
|
+
path: string;
|
|
113
|
+
content: string;
|
|
114
|
+
description: string;
|
|
115
|
+
}
|
|
116
|
+
export interface Visual {
|
|
117
|
+
type: 'architecture' | 'concept' | 'flow' | 'logo';
|
|
118
|
+
prompt: string;
|
|
119
|
+
path: string;
|
|
120
|
+
}
|
|
121
|
+
export interface KnowledgeEntity {
|
|
122
|
+
name: string;
|
|
123
|
+
type: string;
|
|
124
|
+
observations: string[];
|
|
125
|
+
}
|
|
126
|
+
export interface KnowledgeRelation {
|
|
127
|
+
from: string;
|
|
128
|
+
to: string;
|
|
129
|
+
relationType: string;
|
|
130
|
+
}
|
|
131
|
+
export type PipelineStage = 'research' | 'design' | 'generate' | 'visualize' | 'persist' | 'publish';
|
|
132
|
+
export interface PipelineResult<T> {
|
|
133
|
+
stage: PipelineStage;
|
|
134
|
+
success: boolean;
|
|
135
|
+
data?: T;
|
|
136
|
+
error?: string;
|
|
137
|
+
duration: number;
|
|
138
|
+
mcpsUsed: MCPServerName[];
|
|
139
|
+
}
|
|
140
|
+
export interface PipelineConfig {
|
|
141
|
+
stages: PipelineStage[];
|
|
142
|
+
parallel: boolean;
|
|
143
|
+
verbose: boolean;
|
|
144
|
+
dryRun: boolean;
|
|
145
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis 6.0 - Latent State Decoder
|
|
3
|
+
*
|
|
4
|
+
* Decodes latent states back to interpretable representations.
|
|
5
|
+
*
|
|
6
|
+
* Capabilities:
|
|
7
|
+
* - Decode to text descriptions
|
|
8
|
+
* - Decode to structured state
|
|
9
|
+
* - Decode to feature maps
|
|
10
|
+
* - Interpolate between states
|
|
11
|
+
*
|
|
12
|
+
* The decoder is the inverse of the encoder, allowing the system
|
|
13
|
+
* to generate human-readable outputs from internal representations.
|
|
14
|
+
*
|
|
15
|
+
* Architecture:
|
|
16
|
+
* - Modality-specific decoders
|
|
17
|
+
* - Feature extraction
|
|
18
|
+
* - Narrative generation
|
|
19
|
+
*
|
|
20
|
+
* References:
|
|
21
|
+
* - VAE Decoders (Kingma & Welling, 2014)
|
|
22
|
+
* - VQ-VAE (van den Oord et al., 2017)
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { createLatentDecoder } from './world-model/decoder.js';
|
|
27
|
+
*
|
|
28
|
+
* const decoder = createLatentDecoder();
|
|
29
|
+
*
|
|
30
|
+
* // Decode to text
|
|
31
|
+
* const description = decoder.decodeToText(latentState);
|
|
32
|
+
*
|
|
33
|
+
* // Decode to structured state
|
|
34
|
+
* const state = decoder.decodeToState(latentState);
|
|
35
|
+
*
|
|
36
|
+
* // Interpolate between states
|
|
37
|
+
* const interpolated = decoder.interpolate(stateA, stateB, 0.5);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
import { Modality, LatentState, LatentFeature } from './types.js';
|
|
41
|
+
export interface DecodedOutput {
|
|
42
|
+
id: string;
|
|
43
|
+
sourceState: string;
|
|
44
|
+
modality: Modality;
|
|
45
|
+
output: unknown;
|
|
46
|
+
confidence: number;
|
|
47
|
+
timestamp: Date;
|
|
48
|
+
}
|
|
49
|
+
export interface TextDecoding extends DecodedOutput {
|
|
50
|
+
modality: 'text';
|
|
51
|
+
output: string;
|
|
52
|
+
keywords: string[];
|
|
53
|
+
sentiment: number;
|
|
54
|
+
}
|
|
55
|
+
export interface StateDecoding extends DecodedOutput {
|
|
56
|
+
modality: 'state';
|
|
57
|
+
output: Record<string, unknown>;
|
|
58
|
+
numericFields: string[];
|
|
59
|
+
categoricalFields: string[];
|
|
60
|
+
}
|
|
61
|
+
export interface FeatureDecoding extends DecodedOutput {
|
|
62
|
+
modality: 'state';
|
|
63
|
+
output: LatentFeature[];
|
|
64
|
+
topActivations: number[];
|
|
65
|
+
}
|
|
66
|
+
export interface DecoderConfig {
|
|
67
|
+
outputDim: number;
|
|
68
|
+
vocabularySize: number;
|
|
69
|
+
maxTextLength: number;
|
|
70
|
+
featureThreshold: number;
|
|
71
|
+
interpolationSteps: number;
|
|
72
|
+
}
|
|
73
|
+
export declare const DEFAULT_DECODER_CONFIG: DecoderConfig;
|
|
74
|
+
export type DecoderEventType = 'decoded_text' | 'decoded_state' | 'decoded_features' | 'interpolated' | 'error';
|
|
75
|
+
export type DecoderEventHandler = (event: {
|
|
76
|
+
type: DecoderEventType;
|
|
77
|
+
data?: unknown;
|
|
78
|
+
}) => void;
|
|
79
|
+
export declare class LatentDecoder {
|
|
80
|
+
private config;
|
|
81
|
+
private eventHandlers;
|
|
82
|
+
private decodingCount;
|
|
83
|
+
private interpolationCount;
|
|
84
|
+
constructor(config?: Partial<DecoderConfig>);
|
|
85
|
+
/**
|
|
86
|
+
* Decode latent state to text description
|
|
87
|
+
*/
|
|
88
|
+
decodeToText(state: LatentState): TextDecoding;
|
|
89
|
+
/**
|
|
90
|
+
* Extract keywords from vector
|
|
91
|
+
*/
|
|
92
|
+
private vectorToKeywords;
|
|
93
|
+
/**
|
|
94
|
+
* Calculate sentiment from vector
|
|
95
|
+
*/
|
|
96
|
+
private calculateSentiment;
|
|
97
|
+
/**
|
|
98
|
+
* Generate natural language description
|
|
99
|
+
*/
|
|
100
|
+
private generateDescription;
|
|
101
|
+
/**
|
|
102
|
+
* Decode latent state to structured state
|
|
103
|
+
*/
|
|
104
|
+
decodeToState(state: LatentState): StateDecoding;
|
|
105
|
+
/**
|
|
106
|
+
* Convert sigmoid value to range
|
|
107
|
+
*/
|
|
108
|
+
private sigmoidToRange;
|
|
109
|
+
/**
|
|
110
|
+
* Decode to feature representation
|
|
111
|
+
*/
|
|
112
|
+
decodeToFeatures(state: LatentState): FeatureDecoding;
|
|
113
|
+
/**
|
|
114
|
+
* Group related features
|
|
115
|
+
*/
|
|
116
|
+
private groupFeatures;
|
|
117
|
+
/**
|
|
118
|
+
* Interpolate between two latent states
|
|
119
|
+
*/
|
|
120
|
+
interpolate(stateA: LatentState, stateB: LatentState, t: number): LatentState;
|
|
121
|
+
/**
|
|
122
|
+
* Generate interpolation sequence
|
|
123
|
+
*/
|
|
124
|
+
interpolateSequence(stateA: LatentState, stateB: LatentState, steps?: number): LatentState[];
|
|
125
|
+
/**
|
|
126
|
+
* Spherical interpolation (SLERP) for better interpolation on unit sphere
|
|
127
|
+
*/
|
|
128
|
+
slerp(stateA: LatentState, stateB: LatentState, t: number): LatentState;
|
|
129
|
+
/**
|
|
130
|
+
* Get indices of dominant (highest absolute) values
|
|
131
|
+
*/
|
|
132
|
+
private getDominantIndices;
|
|
133
|
+
/**
|
|
134
|
+
* Normalize vector
|
|
135
|
+
*/
|
|
136
|
+
private normalize;
|
|
137
|
+
/**
|
|
138
|
+
* Compare two latent states
|
|
139
|
+
*/
|
|
140
|
+
compare(stateA: LatentState, stateB: LatentState): {
|
|
141
|
+
similarity: number;
|
|
142
|
+
distance: number;
|
|
143
|
+
divergentDimensions: number[];
|
|
144
|
+
commonFeatures: string[];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Analyze latent state structure
|
|
148
|
+
*/
|
|
149
|
+
analyze(state: LatentState): {
|
|
150
|
+
sparsity: number;
|
|
151
|
+
dominantRegion: string;
|
|
152
|
+
clusterAssignment: number;
|
|
153
|
+
anomalyScore: number;
|
|
154
|
+
};
|
|
155
|
+
on(handler: DecoderEventHandler): () => void;
|
|
156
|
+
private emit;
|
|
157
|
+
stats(): {
|
|
158
|
+
decodingCount: number;
|
|
159
|
+
interpolationCount: number;
|
|
160
|
+
};
|
|
161
|
+
getConfig(): DecoderConfig;
|
|
162
|
+
}
|
|
163
|
+
export declare function createLatentDecoder(config?: Partial<DecoderConfig>): LatentDecoder;
|