@jclaw/core 0.4.2 → 0.6.0
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/dist/extensions/built-in/file-operations.d.ts +7 -0
- package/dist/extensions/built-in/file-operations.d.ts.map +1 -0
- package/dist/extensions/built-in/file-operations.js +222 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/runtime/agent.d.ts +3 -87
- package/dist/runtime/agent.d.ts.map +1 -1
- package/dist/runtime/agent.js +83 -222
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations.d.ts","sourceRoot":"","sources":["../../../src/extensions/built-in/file-operations.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,gBAAgB,CAAC;AAmM5D;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,SA2DrC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir, rmdir, readdir, unlink, } from 'fs/promises';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
/**
|
|
5
|
+
* Create a new file
|
|
6
|
+
*/
|
|
7
|
+
async function fileCreate(path, content = '') {
|
|
8
|
+
try {
|
|
9
|
+
const resolvedPath = resolve(path);
|
|
10
|
+
await writeFile(resolvedPath, content, 'utf-8');
|
|
11
|
+
return { success: true, data: { path: resolvedPath } };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return {
|
|
15
|
+
success: false,
|
|
16
|
+
error: error instanceof Error ? error.message : 'Unknown error creating file',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Read file contents
|
|
22
|
+
*/
|
|
23
|
+
async function fileRead(path) {
|
|
24
|
+
try {
|
|
25
|
+
const resolvedPath = resolve(path);
|
|
26
|
+
const content = await readFile(resolvedPath, 'utf-8');
|
|
27
|
+
return { success: true, data: { path: resolvedPath, content } };
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
error: error instanceof Error ? error.message : 'Unknown error reading file',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Write/overwrite file contents
|
|
38
|
+
*/
|
|
39
|
+
async function fileWrite(path, content) {
|
|
40
|
+
try {
|
|
41
|
+
const resolvedPath = resolve(path);
|
|
42
|
+
await writeFile(resolvedPath, content, 'utf-8');
|
|
43
|
+
return { success: true, data: { path: resolvedPath } };
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
error: error instanceof Error ? error.message : 'Unknown error writing file',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Delete a file
|
|
54
|
+
*/
|
|
55
|
+
async function fileDelete(path) {
|
|
56
|
+
try {
|
|
57
|
+
const resolvedPath = resolve(path);
|
|
58
|
+
await unlink(resolvedPath);
|
|
59
|
+
return { success: true, data: { path: resolvedPath } };
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: error instanceof Error ? error.message : 'Unknown error deleting file',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a directory (recursive)
|
|
70
|
+
*/
|
|
71
|
+
async function dirCreate(path) {
|
|
72
|
+
try {
|
|
73
|
+
const resolvedPath = resolve(path);
|
|
74
|
+
await mkdir(resolvedPath, { recursive: true });
|
|
75
|
+
return { success: true, data: { path: resolvedPath } };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: error instanceof Error
|
|
81
|
+
? error.message
|
|
82
|
+
: 'Unknown error creating directory',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Delete a directory
|
|
88
|
+
*/
|
|
89
|
+
async function dirDelete(path) {
|
|
90
|
+
try {
|
|
91
|
+
const resolvedPath = resolve(path);
|
|
92
|
+
await rmdir(resolvedPath);
|
|
93
|
+
return { success: true, data: { path: resolvedPath } };
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
error: error instanceof Error
|
|
99
|
+
? error.message
|
|
100
|
+
: 'Unknown error deleting directory',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* List directory contents
|
|
106
|
+
*/
|
|
107
|
+
async function dirList(path) {
|
|
108
|
+
try {
|
|
109
|
+
const resolvedPath = resolve(path);
|
|
110
|
+
const entries = await readdir(resolvedPath, { withFileTypes: true });
|
|
111
|
+
const items = entries.map((entry) => ({
|
|
112
|
+
name: entry.name,
|
|
113
|
+
type: entry.isDirectory() ? 'directory' : 'file',
|
|
114
|
+
isFile: entry.isFile(),
|
|
115
|
+
isDirectory: entry.isDirectory(),
|
|
116
|
+
}));
|
|
117
|
+
return { success: true, data: { path: resolvedPath, items } };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: error instanceof Error
|
|
123
|
+
? error.message
|
|
124
|
+
: 'Unknown error listing directory',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Search files using glob pattern
|
|
130
|
+
*/
|
|
131
|
+
async function fileGlob(pattern, cwd) {
|
|
132
|
+
try {
|
|
133
|
+
const searchPath = cwd ? resolve(cwd) : process.cwd();
|
|
134
|
+
const files = await glob(pattern, { cwd: searchPath, absolute: true });
|
|
135
|
+
return { success: true, data: { pattern, cwd: searchPath, files } };
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
error: error instanceof Error ? error.message : 'Unknown error in glob search',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Find files by name (recursive search)
|
|
146
|
+
*/
|
|
147
|
+
async function fileFind(name, cwd) {
|
|
148
|
+
try {
|
|
149
|
+
const searchPath = cwd ? resolve(cwd) : process.cwd();
|
|
150
|
+
const pattern = `**/${name}`;
|
|
151
|
+
const files = await glob(pattern, { cwd: searchPath, absolute: true });
|
|
152
|
+
return { success: true, data: { name, cwd: searchPath, files } };
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
success: false,
|
|
157
|
+
error: error instanceof Error ? error.message : 'Unknown error finding file',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* File Operations Extension Definition
|
|
163
|
+
*/
|
|
164
|
+
export const fileOperationsExtension = {
|
|
165
|
+
name: '@jclaw/builtin-file-operations',
|
|
166
|
+
version: '1.0.0',
|
|
167
|
+
description: 'Built-in file system operations for JClaw Agent',
|
|
168
|
+
capabilities: [
|
|
169
|
+
{
|
|
170
|
+
name: 'file_create',
|
|
171
|
+
description: 'Create a new file with optional initial content',
|
|
172
|
+
handler: fileCreate,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'file_read',
|
|
176
|
+
description: 'Read the contents of a file',
|
|
177
|
+
handler: fileRead,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'file_write',
|
|
181
|
+
description: 'Write or overwrite file contents',
|
|
182
|
+
handler: fileWrite,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'file_delete',
|
|
186
|
+
description: 'Delete a file',
|
|
187
|
+
handler: fileDelete,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'dir_create',
|
|
191
|
+
description: 'Create a directory (supports recursive creation)',
|
|
192
|
+
handler: dirCreate,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'dir_delete',
|
|
196
|
+
description: 'Delete an empty directory',
|
|
197
|
+
handler: dirDelete,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'dir_list',
|
|
201
|
+
description: 'List contents of a directory',
|
|
202
|
+
handler: dirList,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'file_glob',
|
|
206
|
+
description: 'Search files using glob patterns (e.g., "*.ts")',
|
|
207
|
+
handler: fileGlob,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'file_find',
|
|
211
|
+
description: 'Find files by name recursively',
|
|
212
|
+
handler: fileFind,
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
async install() {
|
|
216
|
+
console.log('📁 File operations extension installed');
|
|
217
|
+
},
|
|
218
|
+
async uninstall() {
|
|
219
|
+
console.log('📁 File operations extension uninstalled');
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
export default fileOperationsExtension;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export { LLMClient, createLLMClient, type LLMClientConfig, type ChatMessage, typ
|
|
|
11
11
|
export { MutationGenerator, createMutationGenerator, type MutationGeneratorConfig, SandboxValidator, createSandbox, type SandboxConfig, EvolutionEngine, createEvolutionEngine, type EvolutionStrategy, type Mutation, type ValidationResult, type EvolutionConfig, type Gene, type EvolutionResult, EvolverAdapter, createEvolverAdapter, type EvolverAdapterConfig, type EvolverResult, } from './evolution/index.js';
|
|
12
12
|
export { AutoSkillGenerator, createAutoSkillGenerator, AutoSkillInstaller, createAutoSkillInstaller, type AutoSkillConfig, type CapabilityGap, type DiscoveryResult, type GeneratedExtension, type GenerationResult, type GenerationStep, type InstallationResult, type SkillUsageStats, type AutoSkillMetadata, type SkillVersion, } from './auto-skill/index.js';
|
|
13
13
|
export { A2AProtocol, GEPProtocol, type A2AMessage, type A2AMessageType, type GEPPacket, type NodeInfo, type GeneSharePayload, type GeneRequestPayload, type TaskDelegatePayload, EvoMapClient, createEvoMapClient, type EvoMapConfig, type GeneResponse, } from './network/index.js';
|
|
14
|
+
export { fileOperationsExtension } from './extensions/built-in/file-operations.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,IAAI,EACJ,UAAU,EACV,cAAc,EACd,aAAa,EACb,QAAQ,EACR,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,YAAY,EACZ,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,UAAU,EACV,WAAW,EACX,KAAK,WAAW,GACjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,gBAAgB,EAChB,aAAa,EACb,KAAK,aAAa,EAClB,eAAe,EACf,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,IAAI,EACT,KAAK,eAAe,EACpB,cAAc,EACd,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,WAAW,EACX,WAAW,EACX,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,YAAY,EACZ,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,IAAI,EACJ,UAAU,EACV,cAAc,EACd,aAAa,EACb,QAAQ,EACR,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAA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ist/index.js
CHANGED
|
@@ -17,3 +17,4 @@ export { MutationGenerator, createMutationGenerator, SandboxValidator, createSan
|
|
|
17
17
|
export { AutoSkillGenerator, createAutoSkillGenerator, AutoSkillInstaller, createAutoSkillInstaller, } from './auto-skill/index.js';
|
|
18
18
|
// Network
|
|
19
19
|
export { A2AProtocol, GEPProtocol, EvoMapClient, createEvoMapClient, } from './network/index.js';
|
|
20
|
+
export { fileOperationsExtension } from './extensions/built-in/file-operations.js';
|
package/dist/runtime/agent.d.ts
CHANGED
|
@@ -1,74 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Runtime
|
|
3
|
-
*
|
|
4
|
-
* Core implementation of the JClaw agent runtime.
|
|
5
|
-
* Provides task execution, context management, and lifecycle control.
|
|
6
|
-
* Now with AutoSkill support for self-evolving capabilities!
|
|
7
|
-
*
|
|
8
|
-
* @module @jclaw/core/runtime/agent
|
|
9
|
-
*/
|
|
10
1
|
import type { AgentRuntime, Task, TaskResult, ContextManager } from '../types.js';
|
|
11
2
|
import { type LLMClientConfig } from './llm-client.js';
|
|
12
3
|
import { ExtensionRegistry } from '../extension-system/registry.js';
|
|
13
|
-
import type { AutoSkillConfig,
|
|
14
|
-
import type { SkillShAdapterConfig } from '../skill-sh/types.js';
|
|
15
|
-
/**
|
|
16
|
-
* Configuration for the agent runtime
|
|
17
|
-
*/
|
|
4
|
+
import type { AutoSkillConfig, SkillShAdapterConfig } from '../auto-skill/types.js';
|
|
18
5
|
export interface AgentConfig {
|
|
19
|
-
/** Agent name */
|
|
20
6
|
name?: string;
|
|
21
|
-
/** Agent version */
|
|
22
7
|
version?: string;
|
|
23
|
-
/** Execution mode (default: 'local') */
|
|
24
8
|
executionMode?: 'local' | 'docker' | 'hybrid';
|
|
25
|
-
/** LLM client configuration */
|
|
26
9
|
llm?: LLMClientConfig;
|
|
27
|
-
/** Context manager instance */
|
|
28
10
|
contextManager?: ContextManager;
|
|
29
|
-
/** System prompt for the agent */
|
|
30
11
|
systemPrompt?: string;
|
|
31
|
-
/** Enable verbose logging */
|
|
32
12
|
verbose?: boolean;
|
|
33
|
-
/** Enable automatic skill generation */
|
|
34
13
|
enableAutoSkill?: boolean;
|
|
35
|
-
/** AutoSkill configuration */
|
|
36
14
|
autoSkillConfig?: Partial<AutoSkillConfig>;
|
|
37
|
-
/** Skill.sh configuration */
|
|
38
15
|
skillShConfig?: Partial<SkillShAdapterConfig>;
|
|
39
|
-
/** Extension registry for managing capabilities */
|
|
40
16
|
extensionRegistry?: ExtensionRegistry;
|
|
41
17
|
}
|
|
42
|
-
/**
|
|
43
|
-
* JClaw Agent Runtime
|
|
44
|
-
*
|
|
45
|
-
* The main runtime for executing tasks with the JClaw agent.
|
|
46
|
-
* Implements the AgentRuntime interface and provides:
|
|
47
|
-
* - Task execution with LLM integration
|
|
48
|
-
* - Context management through SimpleMemory
|
|
49
|
-
* - Command execution through local/docker executors
|
|
50
|
-
* - **NEW: AutoSkill for self-generating capabilities!**
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const agent = new JClawAgent({
|
|
55
|
-
* name: 'my-agent',
|
|
56
|
-
* enableAutoSkill: true, // Enable self-evolution!
|
|
57
|
-
* llm: {
|
|
58
|
-
* apiBase: 'https://api.openai.com/v1',
|
|
59
|
-
* apiKey: process.env.OPENAI_API_KEY!,
|
|
60
|
-
* model: 'gpt-4'
|
|
61
|
-
* }
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* await agent.start();
|
|
65
|
-
* const result = await agent.execute({
|
|
66
|
-
* id: 'task-1',
|
|
67
|
-
* prompt: 'Analyze the project structure'
|
|
68
|
-
* });
|
|
69
|
-
* await agent.stop();
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
18
|
export declare class JClawAgent implements AgentRuntime {
|
|
73
19
|
readonly executionMode: 'local' | 'docker' | 'hybrid';
|
|
74
20
|
private readonly config;
|
|
@@ -77,48 +23,18 @@ export declare class JClawAgent implements AgentRuntime {
|
|
|
77
23
|
private running;
|
|
78
24
|
private autoSkillGenerator?;
|
|
79
25
|
private autoSkillInstaller?;
|
|
80
|
-
private
|
|
81
|
-
private _skillConverter?;
|
|
82
|
-
private _skillDiscovery?;
|
|
83
|
-
private _skillRegistry?;
|
|
26
|
+
private skillDiscovery?;
|
|
84
27
|
private evolutionEngine?;
|
|
85
|
-
|
|
86
|
-
* Create a new JClaw agent instance.
|
|
87
|
-
*
|
|
88
|
-
* @param config - Configuration options
|
|
89
|
-
*/
|
|
28
|
+
private extensionRegistry?;
|
|
90
29
|
constructor(config?: AgentConfig);
|
|
91
|
-
/**
|
|
92
|
-
* Get the context manager instance.
|
|
93
|
-
*/
|
|
94
30
|
get context(): ContextManager;
|
|
95
|
-
/**
|
|
96
|
-
* Start the agent runtime.
|
|
97
|
-
*/
|
|
98
31
|
start(): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* Stop the agent runtime.
|
|
101
|
-
*/
|
|
102
32
|
stop(): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Execute a task.
|
|
105
|
-
*
|
|
106
|
-
* @param task - The task to execute
|
|
107
|
-
* @returns Task execution result
|
|
108
|
-
*/
|
|
109
33
|
execute(task: Task): Promise<TaskResult>;
|
|
110
|
-
/**
|
|
111
|
-
* Execute a task with AutoSkill self-evolution support.
|
|
112
|
-
*
|
|
113
|
-
* This method attempts to execute the task, and if it fails due to missing
|
|
114
|
-
* capabilities, it will automatically discover, generate, and install new skills.
|
|
115
|
-
*/
|
|
116
34
|
private executeWithAutoSkill;
|
|
117
|
-
generateSkillsForTask(task: Task): Promise<GeneratedExtension[]>;
|
|
118
35
|
isRunning(): boolean;
|
|
119
36
|
get name(): string;
|
|
120
37
|
get version(): string;
|
|
121
|
-
private getDefaultSystemPrompt;
|
|
122
38
|
}
|
|
123
39
|
export declare function createAgent(config?: AgentConfig): JClawAgent;
|
|
124
40
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/runtime/agent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/runtime/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAOpE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGpF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC9C,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,qBAAa,UAAW,YAAW,YAAY;IAC7C,QAAQ,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;IAC7B,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAe;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAC,CAAqB;IAChD,OAAO,CAAC,kBAAkB,CAAC,CAAqB;IAChD,OAAO,CAAC,cAAc,CAAC,CAAuB;IAC9C,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,iBAAiB,CAAC,CAAoB;gBAElC,MAAM,GAAE,WAAgB;IAapC,IAAI,OAAO,IAAI,cAAc,CAG5B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsCtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;YAQhC,oBAAoB;IA6ClC,SAAS,IAAI,OAAO;IACpB,IAAI,IAAI,IAAI,MAAM,CAA6B;IAC/C,IAAI,OAAO,IAAI,MAAM,CAAgC;CACtD;AAED,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAE5D"}
|
package/dist/runtime/agent.js
CHANGED
|
@@ -1,284 +1,145 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Runtime
|
|
3
|
-
*
|
|
4
|
-
* Core implementation of the JClaw agent runtime.
|
|
5
|
-
* Provides task execution, context management, and lifecycle control.
|
|
6
|
-
* Now with AutoSkill support for self-evolving capabilities!
|
|
7
|
-
*
|
|
8
|
-
* @module @jclaw/core/runtime/agent
|
|
9
|
-
*/
|
|
10
1
|
import { TaskExecutor } from './task-executor.js';
|
|
11
2
|
import { LLMClient } from './llm-client.js';
|
|
12
|
-
import { LocalExecutor } from '../executor/local.js';
|
|
13
3
|
import { ExtensionRegistry } from '../extension-system/registry.js';
|
|
14
4
|
import { EvolutionEngine } from '../evolution/engine.js';
|
|
15
|
-
import { createAutoSkillGenerator
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* - Task execution with LLM integration
|
|
22
|
-
* - Context management through SimpleMemory
|
|
23
|
-
* - Command execution through local/docker executors
|
|
24
|
-
* - **NEW: AutoSkill for self-generating capabilities!**
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const agent = new JClawAgent({
|
|
29
|
-
* name: 'my-agent',
|
|
30
|
-
* enableAutoSkill: true, // Enable self-evolution!
|
|
31
|
-
* llm: {
|
|
32
|
-
* apiBase: 'https://api.openai.com/v1',
|
|
33
|
-
* apiKey: process.env.OPENAI_API_KEY!,
|
|
34
|
-
* model: 'gpt-4'
|
|
35
|
-
* }
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* await agent.start();
|
|
39
|
-
* const result = await agent.execute({
|
|
40
|
-
* id: 'task-1',
|
|
41
|
-
* prompt: 'Analyze the project structure'
|
|
42
|
-
* });
|
|
43
|
-
* await agent.stop();
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
5
|
+
import { createAutoSkillGenerator } from '../auto-skill/generator.js';
|
|
6
|
+
import { createAutoSkillInstaller } from '../auto-skill/installer.js';
|
|
7
|
+
import { createSkillDiscoveryEngine } from '../skill-sh/discovery.js';
|
|
8
|
+
import { createSkillShAdapter } from '../skill-sh/adapter.js';
|
|
9
|
+
import { createSkillConverter } from '../skill-sh/converter.js';
|
|
10
|
+
import { fileOperationsExtension } from '../extensions/built-in/file-operations.js';
|
|
46
11
|
export class JClawAgent {
|
|
47
12
|
executionMode;
|
|
48
13
|
config;
|
|
49
14
|
llmClient;
|
|
50
15
|
taskExecutor;
|
|
51
16
|
running = false;
|
|
52
|
-
// AutoSkill components
|
|
53
17
|
autoSkillGenerator;
|
|
54
18
|
autoSkillInstaller;
|
|
55
|
-
|
|
56
|
-
_skillShAdapter;
|
|
57
|
-
_skillConverter;
|
|
58
|
-
_skillDiscovery;
|
|
59
|
-
_skillRegistry;
|
|
19
|
+
skillDiscovery;
|
|
60
20
|
evolutionEngine;
|
|
61
|
-
|
|
62
|
-
* Create a new JClaw agent instance.
|
|
63
|
-
*
|
|
64
|
-
* @param config - Configuration options
|
|
65
|
-
*/
|
|
21
|
+
extensionRegistry;
|
|
66
22
|
constructor(config = {}) {
|
|
67
23
|
this.config = {
|
|
68
24
|
name: 'jclaw-agent',
|
|
69
25
|
version: '0.1.0',
|
|
70
26
|
executionMode: 'local',
|
|
71
|
-
systemPrompt:
|
|
27
|
+
systemPrompt: 'You are JClaw, a self-evolving AI agent.',
|
|
72
28
|
verbose: false,
|
|
73
29
|
enableAutoSkill: false,
|
|
74
|
-
autoSkillConfig: undefined,
|
|
75
30
|
...config,
|
|
76
31
|
};
|
|
77
32
|
this.executionMode = config.executionMode ?? 'local';
|
|
78
33
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the context manager instance.
|
|
81
|
-
*/
|
|
82
34
|
get context() {
|
|
83
|
-
if (!this.config.contextManager)
|
|
35
|
+
if (!this.config.contextManager)
|
|
84
36
|
throw new Error('Context manager not configured');
|
|
85
|
-
}
|
|
86
37
|
return this.config.contextManager;
|
|
87
38
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Start the agent runtime.
|
|
90
|
-
*/
|
|
91
39
|
async start() {
|
|
92
|
-
if (this.running)
|
|
40
|
+
if (this.running)
|
|
93
41
|
return;
|
|
94
|
-
}
|
|
95
|
-
console.log(`🚀 Starting ${this.config.name} v${this.config.version}...`);
|
|
96
|
-
// Initialize LLM client
|
|
42
|
+
console.log(`🚀 Starting ${this.config.name} v${this.config.version}...\n`);
|
|
97
43
|
if (this.config.llm) {
|
|
98
44
|
this.llmClient = new LLMClient(this.config.llm);
|
|
99
|
-
console.log('✅ LLM client initialized');
|
|
45
|
+
console.log('✅ LLM client initialized\n');
|
|
100
46
|
}
|
|
101
|
-
// Initialize task executor
|
|
102
47
|
this.taskExecutor = new TaskExecutor({
|
|
103
48
|
llmClient: this.llmClient,
|
|
104
|
-
|
|
49
|
+
context: this.config.contextManager,
|
|
105
50
|
verbose: this.config.verbose,
|
|
106
51
|
});
|
|
107
|
-
// Initialize AutoSkill if enabled
|
|
108
52
|
if (this.config.enableAutoSkill) {
|
|
109
|
-
console.log('🧬 AutoSkill enabled - initializing self-evolution
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.
|
|
122
|
-
|
|
53
|
+
console.log('🧬 AutoSkill enabled - initializing self-evolution...\n');
|
|
54
|
+
this.evolutionEngine = new EvolutionEngine({ populationSize: 10, mutationRate: 0.1, selectionPressure: 0.5 });
|
|
55
|
+
this.extensionRegistry = this.config.extensionRegistry ?? new ExtensionRegistry();
|
|
56
|
+
const skillShAdapter = createSkillShAdapter(this.llmClient, this.config.skillShConfig);
|
|
57
|
+
const skillConverter = createSkillConverter(this.llmClient);
|
|
58
|
+
this.autoSkillGenerator = createAutoSkillGenerator(this.llmClient, this.extensionRegistry, this.evolutionEngine, this.config.autoSkillConfig);
|
|
59
|
+
this.autoSkillInstaller = createAutoSkillInstaller(this.extensionRegistry, this.config.autoSkillConfig?.storageDir);
|
|
60
|
+
this.skillDiscovery = createSkillDiscoveryEngine(this.llmClient, this.extensionRegistry, skillShAdapter, skillConverter, this.autoSkillGenerator);
|
|
61
|
+
console.log('✅ AutoSkill components initialized\n');
|
|
62
|
+
}
|
|
63
|
+
// Register built-in file operations extension
|
|
64
|
+
if (!this.extensionRegistry) {
|
|
65
|
+
this.extensionRegistry = new ExtensionRegistry();
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
this.extensionRegistry.register(fileOperationsExtension);
|
|
69
|
+
console.log("📁 Built-in file operations registered\n");
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.warn("⚠️ Failed to register file operations:", error);
|
|
123
73
|
}
|
|
124
74
|
this.running = true;
|
|
125
|
-
console.log('✅ Agent started');
|
|
75
|
+
console.log('✅ Agent started\n');
|
|
126
76
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Stop the agent runtime.
|
|
129
|
-
*/
|
|
130
77
|
async stop() {
|
|
131
|
-
if (!this.running)
|
|
78
|
+
if (!this.running)
|
|
132
79
|
return;
|
|
133
|
-
}
|
|
134
80
|
console.log('🛑 Stopping agent...');
|
|
135
81
|
this.running = false;
|
|
136
82
|
console.log('✅ Agent stopped');
|
|
137
83
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Execute a task.
|
|
140
|
-
*
|
|
141
|
-
* @param task - The task to execute
|
|
142
|
-
* @returns Task execution result
|
|
143
|
-
*/
|
|
144
84
|
async execute(task) {
|
|
145
|
-
if (!this.running)
|
|
146
|
-
throw new Error('Agent not started
|
|
147
|
-
|
|
148
|
-
if (!this.taskExecutor) {
|
|
85
|
+
if (!this.running)
|
|
86
|
+
throw new Error('Agent not started');
|
|
87
|
+
if (!this.taskExecutor)
|
|
149
88
|
throw new Error('Task executor not initialized');
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// Execute with AutoSkill retry logic if enabled
|
|
156
|
-
if (this.config.enableAutoSkill) {
|
|
157
|
-
return await this.executeWithAutoSkill(task);
|
|
158
|
-
}
|
|
159
|
-
// Simple execution without AutoSkill
|
|
160
|
-
return await this.taskExecutor.execute(task);
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
164
|
-
return {
|
|
165
|
-
taskId: task.id,
|
|
166
|
-
success: false,
|
|
167
|
-
output: '',
|
|
168
|
-
error: errorMessage,
|
|
169
|
-
duration: 0,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
89
|
+
if (this.config.verbose)
|
|
90
|
+
console.log(`\n📝 Executing task: ${task.prompt}\n`);
|
|
91
|
+
if (this.config.enableAutoSkill)
|
|
92
|
+
return await this.executeWithAutoSkill(task);
|
|
93
|
+
return await this.taskExecutor.execute(task);
|
|
172
94
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Execute a task with AutoSkill self-evolution support.
|
|
175
|
-
*
|
|
176
|
-
* This method attempts to execute the task, and if it fails due to missing
|
|
177
|
-
* capabilities, it will automatically discover, generate, and install new skills.
|
|
178
|
-
*/
|
|
179
95
|
async executeWithAutoSkill(task) {
|
|
180
|
-
if (!this.taskExecutor)
|
|
96
|
+
if (!this.taskExecutor)
|
|
181
97
|
throw new Error('Task executor not initialized');
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// Check if error is due to missing capability
|
|
191
|
-
if (!this.autoSkillGenerator || !this.autoSkillInstaller) {
|
|
192
|
-
throw error; // AutoSkill not available
|
|
193
|
-
}
|
|
194
|
-
// Discover missing capabilities
|
|
195
|
-
console.log('🔍 Discovering missing capabilities...');
|
|
196
|
-
const discovery = await this.autoSkillGenerator.discoverCapabilities(task);
|
|
197
|
-
if (discovery.gaps.length === 0) {
|
|
198
|
-
console.log(' No missing capabilities identified');
|
|
199
|
-
throw error; // Not a capability issue
|
|
200
|
-
}
|
|
201
|
-
console.log(` Found ${discovery.gaps.length} missing capabilities:`);
|
|
202
|
-
for (const gap of discovery.gaps) {
|
|
203
|
-
console.log(` - ${gap.capability}: ${gap.description}`);
|
|
204
|
-
}
|
|
205
|
-
// Generate and install each missing capability
|
|
206
|
-
for (const gap of discovery.gaps) {
|
|
207
|
-
console.log(`\n🔧 Generating skill: ${gap.capability}...`);
|
|
208
|
-
const generation = await this.autoSkillGenerator.generateExtension(gap);
|
|
209
|
-
if (!generation.success || !generation.extension) {
|
|
210
|
-
console.error(` Failed to generate: ${generation.error}`);
|
|
211
|
-
continue;
|
|
98
|
+
const maxAttempts = this.config.autoSkillConfig?.maxGenerationAttempts || 3;
|
|
99
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
100
|
+
try {
|
|
101
|
+
console.log(`🔄 Attempt ${attempt}/${maxAttempts}...\n`);
|
|
102
|
+
const result = await this.taskExecutor.execute(task);
|
|
103
|
+
if (result.success) {
|
|
104
|
+
console.log('✅ Task completed successfully!\n');
|
|
105
|
+
return result;
|
|
212
106
|
}
|
|
213
|
-
console.log(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
107
|
+
console.log(`❌ Task failed: ${result.error}\n`);
|
|
108
|
+
if (!this.skillDiscovery || !this.autoSkillInstaller) {
|
|
109
|
+
console.log('⚠️ AutoSkill components not available\n');
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
console.log('🔍 Analyzing missing capabilities...\n');
|
|
113
|
+
const discovery = await this.skillDiscovery.discover(task.prompt);
|
|
114
|
+
if (discovery.recommended && discovery.confidence > 0.5) {
|
|
115
|
+
console.log(`✅ Found skill: ${discovery.recommended.name}`);
|
|
116
|
+
console.log(` Source: ${discovery.source}`);
|
|
117
|
+
console.log(` Confidence: ${(discovery.confidence * 100).toFixed(0)}%\n`);
|
|
118
|
+
console.log('📦 Installing skill...\n');
|
|
119
|
+
const installed = await this.skillDiscovery.installSkill(discovery.recommended);
|
|
120
|
+
if (installed) {
|
|
121
|
+
console.log('✅ Skill installed successfully!\n');
|
|
122
|
+
console.log('🔄 Retrying task with new capability...\n');
|
|
123
|
+
continue;
|
|
225
124
|
}
|
|
226
125
|
}
|
|
126
|
+
if (attempt >= maxAttempts) {
|
|
127
|
+
return { taskId: task.id, success: false, output: '', error: `Task failed after ${maxAttempts} attempts. Last error: ${result.error}` };
|
|
128
|
+
}
|
|
227
129
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (!this.autoSkillGenerator) {
|
|
235
|
-
throw new Error(`AutoSkill not enabled. Set enableAutoSkill: true in config.`);
|
|
236
|
-
}
|
|
237
|
-
console.log(`Analyzing task for skill generation...`);
|
|
238
|
-
const discovery = await this.autoSkillGenerator.discoverCapabilities(task);
|
|
239
|
-
const generated = [];
|
|
240
|
-
for (const gap of discovery.gaps) {
|
|
241
|
-
console.log(`Generating: ${gap.capability}`);
|
|
242
|
-
const result = await this.autoSkillGenerator.generateExtension(gap);
|
|
243
|
-
if (result.success && result.extension) {
|
|
244
|
-
generated.push(result.extension);
|
|
245
|
-
console.log(` Generated successfully`);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
console.error(` Failed: ${result.error}`);
|
|
130
|
+
catch (error) {
|
|
131
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
132
|
+
console.log(`❌ Attempt ${attempt} failed: ${errorMessage}\n`);
|
|
133
|
+
if (attempt >= maxAttempts) {
|
|
134
|
+
return { taskId: task.id, success: false, output: '', error: `Task failed after ${maxAttempts} attempts. Last error: ${errorMessage}` };
|
|
135
|
+
}
|
|
249
136
|
}
|
|
250
137
|
}
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
isRunning() {
|
|
254
|
-
return this.running;
|
|
255
|
-
}
|
|
256
|
-
get name() {
|
|
257
|
-
return this.config.name;
|
|
258
|
-
}
|
|
259
|
-
get version() {
|
|
260
|
-
return this.config.version;
|
|
261
|
-
}
|
|
262
|
-
getDefaultSystemPrompt() {
|
|
263
|
-
return `You are JClaw, a self-evolving AI agent with persistent memory.
|
|
264
|
-
|
|
265
|
-
Core capabilities:
|
|
266
|
-
1. Understand and plan complex tasks
|
|
267
|
-
2. Execute shell commands safely
|
|
268
|
-
3. Learn from context and previous interactions
|
|
269
|
-
4. Adapt and improve over time
|
|
270
|
-
5. **Generate new skills when needed!**
|
|
271
|
-
|
|
272
|
-
Guidelines:
|
|
273
|
-
- Always think step by step
|
|
274
|
-
- Explain your reasoning clearly
|
|
275
|
-
- Use shell commands when appropriate
|
|
276
|
-
- Report errors honestly and suggest solutions
|
|
277
|
-
- Learn from mistakes and adapt
|
|
278
|
-
- **When facing a new challenge, suggest generating a new skill**
|
|
279
|
-
|
|
280
|
-
Remember: You have access to persistent memory and can evolve your own capabilities!`;
|
|
138
|
+
return { taskId: task.id, success: false, output: '', error: `Task failed after ${maxAttempts} attempts` };
|
|
281
139
|
}
|
|
140
|
+
isRunning() { return this.running; }
|
|
141
|
+
get name() { return this.config.name; }
|
|
142
|
+
get version() { return this.config.version; }
|
|
282
143
|
}
|
|
283
144
|
export function createAgent(config) {
|
|
284
145
|
return new JClawAgent(config);
|
package/dist/types.d.ts
CHANGED
|
@@ -142,6 +142,8 @@ export interface Capability {
|
|
|
142
142
|
description: string;
|
|
143
143
|
/** JSON Schema for input validation (optional) */
|
|
144
144
|
inputSchema?: Record<string, unknown>;
|
|
145
|
+
/** Handler function for this capability */
|
|
146
|
+
handler?: (input: unknown) => Promise<unknown>;
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
149
|
* 扩展接口
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,uCAAuC;IACvC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,QAAQ,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,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACvD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jclaw/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Universal self-evolving Agent
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Universal self-evolving Agent with improved AutoSkill retry logic",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
10
10
|
"files": ["dist", "README.md"],
|
|
11
11
|
"scripts": {"build": "tsc"},
|
|
12
|
-
"keywords": ["ai", "agent", "cli"],
|
|
12
|
+
"keywords": ["ai", "agent", "cli", "self-evolving"],
|
|
13
13
|
"author": "JClaw Team",
|
|
14
|
-
"license": "MIT"
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"glob": "^10.3.10"
|
|
17
|
+
}
|
|
15
18
|
}
|