@gotza02/seq-thinking 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp-server.js +1 -1
- package/package.json +9 -3
- package/agents_test.log +0 -15
- package/data/agents/1770106504306-dljh9ef.json +0 -68
- package/data/agents/1770106504310-4oarrst.json +0 -58
- package/data/agents/1770106540588-pvitt55.json +0 -68
- package/data/agents/1770106540595-z2ya871.json +0 -58
- package/data/agents/1770106710890-0e2naq1.json +0 -68
- package/data/agents/1770106710893-r076yxx.json +0 -58
- package/data/agents/1770109212161-4ybd0i7.json +0 -68
- package/data/agents/1770109212166-gkhya8h.json +0 -58
- package/data/agents/1770117726716-lrnm415.json +0 -68
- package/data/agents/1770117726719-w6hsf3v.json +0 -58
- package/data/sessions/1770100622009-5afiuyv.json +0 -499
- package/data/sessions/1770106504312-75zk750.json +0 -107
- package/data/sessions/1770106540597-z8e8soo.json +0 -150
- package/data/sessions/1770106710894-0kxgy5x.json +0 -150
- package/data/sessions/1770109212169-zpddeb9.json +0 -150
- package/data/sessions/1770117726720-frcwj99.json +0 -150
- package/real_world_test.log +0 -200
- package/real_world_test_dynamic.log +0 -184
- package/real_world_test_real.log +0 -184
- package/src/__tests__/agents.test.ts +0 -858
- package/src/__tests__/mcp-server.test.ts +0 -380
- package/src/__tests__/sequential-thinking.test.ts +0 -687
- package/src/__tests__/swarm-coordinator.test.ts +0 -903
- package/src/__tests__/types.test.ts +0 -839
- package/src/__tests__/utils.test.ts +0 -322
- package/src/agents/base-agent.ts +0 -288
- package/src/agents/critic-agent.ts +0 -582
- package/src/agents/index.ts +0 -11
- package/src/agents/meta-reasoning-agent.ts +0 -314
- package/src/agents/reasoner-agent.ts +0 -312
- package/src/agents/synthesizer-agent.ts +0 -641
- package/src/index.ts +0 -118
- package/src/mcp-server.ts +0 -391
- package/src/real_world_test.ts +0 -89
- package/src/sequential-thinking.ts +0 -614
- package/src/swarm-coordinator.ts +0 -772
- package/src/types/index.ts +0 -915
- package/src/utils/index.ts +0 -1004
- package/src/utils/llm-adapter.ts +0 -110
- package/src/utils/logger.ts +0 -56
- package/src/utils/persistence.ts +0 -109
- package/test_output.log +0 -0
- package/tsconfig.json +0 -21
package/src/utils/llm-adapter.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Adapter to call external CLI tools via child_process
|
|
3
|
-
* @module utils/llm-adapter
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { exec } from 'child_process';
|
|
7
|
-
import { promisify } from 'util';
|
|
8
|
-
import { Logger } from './logger.js';
|
|
9
|
-
|
|
10
|
-
const execAsync = promisify(exec);
|
|
11
|
-
|
|
12
|
-
export interface LLMResponse {
|
|
13
|
-
content: string;
|
|
14
|
-
error?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class LLMAdapter {
|
|
18
|
-
/**
|
|
19
|
-
* Main entry point to call an LLM based on provider pool
|
|
20
|
-
*/
|
|
21
|
-
static async call(prompt: string, systemPrompt?: string, providerOverride?: string): Promise<LLMResponse> {
|
|
22
|
-
const providerEnv = process.env.provider || 'gemini';
|
|
23
|
-
const providers = providerOverride ? [providerOverride] : providerEnv.split(',').map(p => p.trim());
|
|
24
|
-
|
|
25
|
-
let lastError = '';
|
|
26
|
-
|
|
27
|
-
for (const provider of providers) {
|
|
28
|
-
const combinedPrompt = systemPrompt ? `${systemPrompt}\n\nUser: ${prompt}` : prompt;
|
|
29
|
-
|
|
30
|
-
// For testing/development: If MOCK_LLM is set, return mock data
|
|
31
|
-
if (process.env.MOCK_LLM === 'true') {
|
|
32
|
-
Logger.debug('LLM Mock Call', { provider, promptLength: prompt.length });
|
|
33
|
-
return { content: `[MOCK RESPONSE from ${provider}] I have analyzed your request: ${prompt.substring(0, 50)}...` };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Logger.info('LLM Call initiated', { provider });
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
let response: LLMResponse;
|
|
40
|
-
switch (provider.toLowerCase()) {
|
|
41
|
-
case 'gemini':
|
|
42
|
-
response = await this.safeExec(`gemini ask ${this.escapeShell(combinedPrompt)}`);
|
|
43
|
-
break;
|
|
44
|
-
case 'claude':
|
|
45
|
-
response = await this.safeExec(`claude ${this.escapeShell(combinedPrompt)} --non-interactive`);
|
|
46
|
-
break;
|
|
47
|
-
case 'kimi':
|
|
48
|
-
response = await this.safeExec(`kimi chat ${this.escapeShell(combinedPrompt)}`);
|
|
49
|
-
break;
|
|
50
|
-
case 'opencode':
|
|
51
|
-
response = await this.safeExec(`opencode ask ${this.escapeShell(combinedPrompt)}`);
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
response = { content: '', error: `Unsupported provider: ${provider}` };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (response.content && !response.error) {
|
|
58
|
-
return response; // Success!
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
lastError = response.error || 'Unknown error';
|
|
62
|
-
Logger.warn(`Provider ${provider} failed, trying next...`, { error: lastError });
|
|
63
|
-
|
|
64
|
-
} catch (error: any) {
|
|
65
|
-
lastError = error.message;
|
|
66
|
-
Logger.error(`LLM Adapter Error with ${provider}`, { error: lastError });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return { content: '', error: `All providers failed. Last error: ${lastError}` };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Safely execute CLI command with timeout and existence check
|
|
75
|
-
*/
|
|
76
|
-
private static async safeExec(cmd: string): Promise<LLMResponse> {
|
|
77
|
-
try {
|
|
78
|
-
// Check if command base exists (first word)
|
|
79
|
-
const baseCmd = cmd.split(' ')[0];
|
|
80
|
-
try {
|
|
81
|
-
await execAsync(`command -v ${baseCmd}`);
|
|
82
|
-
} catch {
|
|
83
|
-
const error = `CLI tool '${baseCmd}' not found or not in PATH. Please install and login.`;
|
|
84
|
-
Logger.warn('CLI tool missing', { baseCmd });
|
|
85
|
-
return { content: '', error };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const { stdout, stderr } = await execAsync(cmd, {
|
|
89
|
-
timeout: 60000 // 60 second timeout
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
if (stderr && stderr.trim()) {
|
|
93
|
-
Logger.debug('CLI Stderr output', { baseCmd, stderr: stderr.substring(0, 100) });
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return { content: stdout.trim() };
|
|
97
|
-
} catch (error: any) {
|
|
98
|
-
Logger.error('Execution failed', { command: cmd.substring(0, 50), error: error.message });
|
|
99
|
-
return { content: '', error: error.message };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Securely escape string for shell execution
|
|
105
|
-
*/
|
|
106
|
-
private static escapeShell(cmd: string): string {
|
|
107
|
-
// For Unix-like systems, wrapping in single quotes and escaping existing single quotes
|
|
108
|
-
return "'" + cmd.replace(/'/g, "'\'" ) + "'";
|
|
109
|
-
}
|
|
110
|
-
}
|
package/src/utils/logger.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple Structured Logging Utility
|
|
3
|
-
* @module utils/logger
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export enum LogLevel {
|
|
7
|
-
DEBUG = 0,
|
|
8
|
-
INFO = 1,
|
|
9
|
-
WARN = 2,
|
|
10
|
-
ERROR = 3
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class Logger {
|
|
14
|
-
private static level: LogLevel = LogLevel.INFO;
|
|
15
|
-
|
|
16
|
-
static setLevel(level: LogLevel) {
|
|
17
|
-
this.level = level;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static debug(message: string, context: any = {}) {
|
|
21
|
-
if (this.level <= LogLevel.DEBUG) {
|
|
22
|
-
this.log('DEBUG', message, context);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static info(message: string, context: any = {}) {
|
|
27
|
-
if (this.level <= LogLevel.INFO) {
|
|
28
|
-
this.log('INFO', message, context);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static warn(message: string, context: any = {}) {
|
|
33
|
-
if (this.level <= LogLevel.WARN) {
|
|
34
|
-
this.log('WARN', message, context);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static error(message: string, context: any = {}) {
|
|
39
|
-
if (this.level <= LogLevel.ERROR) {
|
|
40
|
-
this.log('ERROR', message, context);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private static log(level: string, message: string, context: any) {
|
|
45
|
-
const timestamp = new Date().toISOString();
|
|
46
|
-
const logEntry = {
|
|
47
|
-
timestamp,
|
|
48
|
-
level,
|
|
49
|
-
message,
|
|
50
|
-
...context
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Write to stderr to avoid interfering with MCP stdio protocol
|
|
54
|
-
process.stderr.write(JSON.stringify(logEntry) + '\n');
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/utils/persistence.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistence Manager for JSON-based file storage
|
|
3
|
-
* @module utils/persistence
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from 'fs/promises';
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import { Logger } from './logger.js';
|
|
9
|
-
|
|
10
|
-
export class PersistenceManager {
|
|
11
|
-
private baseDir: string;
|
|
12
|
-
|
|
13
|
-
constructor(baseDir: string = './data') {
|
|
14
|
-
this.baseDir = baseDir;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Ensure storage directories exist
|
|
19
|
-
*/
|
|
20
|
-
async initialize(subDirs: string[] = ['sessions', 'agents', 'tasks']) {
|
|
21
|
-
try {
|
|
22
|
-
await fs.mkdir(this.baseDir, { recursive: true });
|
|
23
|
-
for (const dir of subDirs) {
|
|
24
|
-
await fs.mkdir(path.join(this.baseDir, dir), { recursive: true });
|
|
25
|
-
}
|
|
26
|
-
} catch (error) {
|
|
27
|
-
Logger.error('Failed to initialize persistence directory', { error });
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Save an object to a JSON file
|
|
34
|
-
*/
|
|
35
|
-
async save(collection: string, id: string, data: any) {
|
|
36
|
-
const filePath = path.join(this.baseDir, collection, `${id}.json`);
|
|
37
|
-
try {
|
|
38
|
-
// Handle Maps by converting them to objects/arrays for JSON serialization
|
|
39
|
-
const serializedData = this.serialize(data);
|
|
40
|
-
await fs.writeFile(filePath, JSON.stringify(serializedData, null, 2), 'utf8');
|
|
41
|
-
} catch (error) {
|
|
42
|
-
Logger.error(`Failed to save ${collection}/${id}`, { error });
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Load an object from a JSON file
|
|
49
|
-
*/
|
|
50
|
-
async load<T>(collection: string, id: string): Promise<T | null> {
|
|
51
|
-
const filePath = path.join(this.baseDir, collection, `${id}.json`);
|
|
52
|
-
try {
|
|
53
|
-
const content = await fs.readFile(filePath, 'utf8');
|
|
54
|
-
return JSON.parse(content) as T;
|
|
55
|
-
} catch (error: any) {
|
|
56
|
-
if (error.code === 'ENOENT') return null;
|
|
57
|
-
Logger.error(`Failed to load ${collection}/${id}`, { error });
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* List all IDs in a collection
|
|
64
|
-
*/
|
|
65
|
-
async list(collection: string): Promise<string[]> {
|
|
66
|
-
const dirPath = path.join(this.baseDir, collection);
|
|
67
|
-
try {
|
|
68
|
-
const files = await fs.readdir(dirPath);
|
|
69
|
-
return files
|
|
70
|
-
.filter(f => f.endsWith('.json'))
|
|
71
|
-
.map(f => f.replace('.json', ''));
|
|
72
|
-
} catch (error: any) {
|
|
73
|
-
if (error.code === 'ENOENT') return [];
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Delete an object
|
|
80
|
-
*/
|
|
81
|
-
async delete(collection: string, id: string) {
|
|
82
|
-
const filePath = path.join(this.baseDir, collection, `${id}.json`);
|
|
83
|
-
try {
|
|
84
|
-
await fs.unlink(filePath);
|
|
85
|
-
} catch (error: any) {
|
|
86
|
-
if (error.code !== 'ENOENT') throw error;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Helper to serialize complex objects (like Maps)
|
|
92
|
-
*/
|
|
93
|
-
private serialize(obj: any): any {
|
|
94
|
-
if (obj instanceof Map) {
|
|
95
|
-
return { _type: 'Map', data: Array.from(obj.entries()) };
|
|
96
|
-
}
|
|
97
|
-
if (Array.isArray(obj)) {
|
|
98
|
-
return obj.map(item => this.serialize(item));
|
|
99
|
-
}
|
|
100
|
-
if (obj !== null && typeof obj === 'object' && !(obj instanceof Date)) {
|
|
101
|
-
const result: any = {};
|
|
102
|
-
for (const key in obj) {
|
|
103
|
-
result[key] = this.serialize(obj[key]);
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
return obj;
|
|
108
|
-
}
|
|
109
|
-
}
|
package/test_output.log
DELETED
|
File without changes
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"allowSyntheticDefaultImports": true
|
|
18
|
-
},
|
|
19
|
-
"include": ["src/**/*"],
|
|
20
|
-
"exclude": ["node_modules", "dist"]
|
|
21
|
-
}
|