@jclaw/core 0.1.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.
Files changed (189) hide show
  1. package/dist/auto-skill/generator.d.ts +30 -0
  2. package/dist/auto-skill/generator.d.ts.map +1 -0
  3. package/dist/auto-skill/generator.js +262 -0
  4. package/dist/auto-skill/generator.js.map +1 -0
  5. package/dist/auto-skill/index.d.ts +11 -0
  6. package/dist/auto-skill/index.d.ts.map +1 -0
  7. package/dist/auto-skill/index.js +10 -0
  8. package/dist/auto-skill/index.js.map +1 -0
  9. package/dist/auto-skill/installer.d.ts +44 -0
  10. package/dist/auto-skill/installer.d.ts.map +1 -0
  11. package/dist/auto-skill/installer.js +201 -0
  12. package/dist/auto-skill/installer.js.map +1 -0
  13. package/dist/auto-skill/types.d.ts +179 -0
  14. package/dist/auto-skill/types.d.ts.map +1 -0
  15. package/dist/auto-skill/types.js +9 -0
  16. package/dist/auto-skill/types.js.map +1 -0
  17. package/dist/cli/commands/config.d.ts +16 -0
  18. package/dist/cli/commands/config.d.ts.map +1 -0
  19. package/dist/cli/commands/config.js +119 -0
  20. package/dist/cli/commands/config.js.map +1 -0
  21. package/dist/cli/commands/exec.d.ts +12 -0
  22. package/dist/cli/commands/exec.d.ts.map +1 -0
  23. package/dist/cli/commands/exec.js +41 -0
  24. package/dist/cli/commands/exec.js.map +1 -0
  25. package/dist/cli/index.d.ts +10 -0
  26. package/dist/cli/index.d.ts.map +1 -0
  27. package/dist/cli/index.js +91 -0
  28. package/dist/cli/index.js.map +1 -0
  29. package/dist/cli/run.d.ts +9 -0
  30. package/dist/cli/run.d.ts.map +1 -0
  31. package/dist/cli/run.js +13 -0
  32. package/dist/cli/run.js.map +1 -0
  33. package/dist/context/index.d.ts +6 -0
  34. package/dist/context/index.d.ts.map +1 -0
  35. package/dist/context/index.js +12 -0
  36. package/dist/context/index.js.map +1 -0
  37. package/dist/context/memsearch-client.d.ts +34 -0
  38. package/dist/context/memsearch-client.d.ts.map +1 -0
  39. package/dist/context/memsearch-client.js +182 -0
  40. package/dist/context/memsearch-client.js.map +1 -0
  41. package/dist/context/mock-client.d.ts +116 -0
  42. package/dist/context/mock-client.d.ts.map +1 -0
  43. package/dist/context/mock-client.js +150 -0
  44. package/dist/context/mock-client.js.map +1 -0
  45. package/dist/context/openviking-client.d.ts +87 -0
  46. package/dist/context/openviking-client.d.ts.map +1 -0
  47. package/dist/context/openviking-client.js +166 -0
  48. package/dist/context/openviking-client.js.map +1 -0
  49. package/dist/context/openviking-mcp-client.d.ts +29 -0
  50. package/dist/context/openviking-mcp-client.d.ts.map +1 -0
  51. package/dist/context/openviking-mcp-client.js +81 -0
  52. package/dist/context/openviking-mcp-client.js.map +1 -0
  53. package/dist/context/simple-memory-client.d.ts +43 -0
  54. package/dist/context/simple-memory-client.d.ts.map +1 -0
  55. package/dist/context/simple-memory-client.enhanced.d.ts +39 -0
  56. package/dist/context/simple-memory-client.enhanced.d.ts.map +1 -0
  57. package/dist/context/simple-memory-client.enhanced.js +207 -0
  58. package/dist/context/simple-memory-client.enhanced.js.map +1 -0
  59. package/dist/context/simple-memory-client.js +270 -0
  60. package/dist/context/simple-memory-client.js.map +1 -0
  61. package/dist/evolution/continuous.d.ts +127 -0
  62. package/dist/evolution/continuous.d.ts.map +1 -0
  63. package/dist/evolution/continuous.js +238 -0
  64. package/dist/evolution/continuous.js.map +1 -0
  65. package/dist/evolution/engine.d.ts +97 -0
  66. package/dist/evolution/engine.d.ts.map +1 -0
  67. package/dist/evolution/engine.js +187 -0
  68. package/dist/evolution/engine.js.map +1 -0
  69. package/dist/evolution/evolver-adapter.d.ts +104 -0
  70. package/dist/evolution/evolver-adapter.d.ts.map +1 -0
  71. package/dist/evolution/evolver-adapter.js +227 -0
  72. package/dist/evolution/evolver-adapter.js.map +1 -0
  73. package/dist/evolution/index.d.ts +9 -0
  74. package/dist/evolution/index.d.ts.map +1 -0
  75. package/dist/evolution/index.js +8 -0
  76. package/dist/evolution/index.js.map +1 -0
  77. package/dist/evolution/memory.d.ts +106 -0
  78. package/dist/evolution/memory.d.ts.map +1 -0
  79. package/dist/evolution/memory.js +232 -0
  80. package/dist/evolution/memory.js.map +1 -0
  81. package/dist/evolution/mutation.d.ts +66 -0
  82. package/dist/evolution/mutation.d.ts.map +1 -0
  83. package/dist/evolution/mutation.js +139 -0
  84. package/dist/evolution/mutation.js.map +1 -0
  85. package/dist/evolution/sandbox.d.ts +96 -0
  86. package/dist/evolution/sandbox.d.ts.map +1 -0
  87. package/dist/evolution/sandbox.js +194 -0
  88. package/dist/evolution/sandbox.js.map +1 -0
  89. package/dist/evolution/types.d.ts +93 -0
  90. package/dist/evolution/types.d.ts.map +1 -0
  91. package/dist/evolution/types.js +9 -0
  92. package/dist/evolution/types.js.map +1 -0
  93. package/dist/executor/index.d.ts +10 -0
  94. package/dist/executor/index.d.ts.map +1 -0
  95. package/dist/executor/index.js +10 -0
  96. package/dist/executor/index.js.map +1 -0
  97. package/dist/executor/interface.d.ts +9 -0
  98. package/dist/executor/interface.d.ts.map +1 -0
  99. package/dist/executor/interface.js +9 -0
  100. package/dist/executor/interface.js.map +1 -0
  101. package/dist/executor/local.d.ts +36 -0
  102. package/dist/executor/local.d.ts.map +1 -0
  103. package/dist/executor/local.js +95 -0
  104. package/dist/executor/local.js.map +1 -0
  105. package/dist/extension-system/capability-router.d.ts +106 -0
  106. package/dist/extension-system/capability-router.d.ts.map +1 -0
  107. package/dist/extension-system/capability-router.js +167 -0
  108. package/dist/extension-system/capability-router.js.map +1 -0
  109. package/dist/extension-system/index.d.ts +11 -0
  110. package/dist/extension-system/index.d.ts.map +1 -0
  111. package/dist/extension-system/index.js +11 -0
  112. package/dist/extension-system/index.js.map +1 -0
  113. package/dist/extension-system/loader.d.ts +93 -0
  114. package/dist/extension-system/loader.d.ts.map +1 -0
  115. package/dist/extension-system/loader.js +245 -0
  116. package/dist/extension-system/loader.js.map +1 -0
  117. package/dist/extension-system/registry.d.ts +112 -0
  118. package/dist/extension-system/registry.d.ts.map +1 -0
  119. package/dist/extension-system/registry.js +161 -0
  120. package/dist/extension-system/registry.js.map +1 -0
  121. package/dist/index.d.ts +14 -0
  122. package/dist/index.d.ts.map +1 -0
  123. package/dist/index.js +20 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/network/client.d.ts +130 -0
  126. package/dist/network/client.d.ts.map +1 -0
  127. package/dist/network/client.js +230 -0
  128. package/dist/network/client.js.map +1 -0
  129. package/dist/network/index.d.ts +10 -0
  130. package/dist/network/index.d.ts.map +1 -0
  131. package/dist/network/index.js +10 -0
  132. package/dist/network/index.js.map +1 -0
  133. package/dist/network/protocol.d.ts +159 -0
  134. package/dist/network/protocol.d.ts.map +1 -0
  135. package/dist/network/protocol.js +118 -0
  136. package/dist/network/protocol.js.map +1 -0
  137. package/dist/runtime/agent.d.ts +124 -0
  138. package/dist/runtime/agent.d.ts.map +1 -0
  139. package/dist/runtime/agent.js +286 -0
  140. package/dist/runtime/agent.js.map +1 -0
  141. package/dist/runtime/agent_fixed.d.ts +39 -0
  142. package/dist/runtime/agent_fixed.d.ts.map +1 -0
  143. package/dist/runtime/agent_fixed.js +193 -0
  144. package/dist/runtime/agent_fixed.js.map +1 -0
  145. package/dist/runtime/index.d.ts +11 -0
  146. package/dist/runtime/index.d.ts.map +1 -0
  147. package/dist/runtime/index.js +11 -0
  148. package/dist/runtime/index.js.map +1 -0
  149. package/dist/runtime/llm-client.d.ts +108 -0
  150. package/dist/runtime/llm-client.d.ts.map +1 -0
  151. package/dist/runtime/llm-client.js +125 -0
  152. package/dist/runtime/llm-client.js.map +1 -0
  153. package/dist/runtime/task-executor.d.ts +92 -0
  154. package/dist/runtime/task-executor.d.ts.map +1 -0
  155. package/dist/runtime/task-executor.js +203 -0
  156. package/dist/runtime/task-executor.js.map +1 -0
  157. package/dist/skill-sh/adapter.d.ts +40 -0
  158. package/dist/skill-sh/adapter.d.ts.map +1 -0
  159. package/dist/skill-sh/adapter.js +258 -0
  160. package/dist/skill-sh/adapter.js.map +1 -0
  161. package/dist/skill-sh/converter.d.ts +37 -0
  162. package/dist/skill-sh/converter.d.ts.map +1 -0
  163. package/dist/skill-sh/converter.js +175 -0
  164. package/dist/skill-sh/converter.js.map +1 -0
  165. package/dist/skill-sh/discovery.d.ts +29 -0
  166. package/dist/skill-sh/discovery.d.ts.map +1 -0
  167. package/dist/skill-sh/discovery.js +189 -0
  168. package/dist/skill-sh/discovery.js.map +1 -0
  169. package/dist/skill-sh/index.d.ts +19 -0
  170. package/dist/skill-sh/index.d.ts.map +1 -0
  171. package/dist/skill-sh/index.js +20 -0
  172. package/dist/skill-sh/index.js.map +1 -0
  173. package/dist/skill-sh/quality.d.ts +51 -0
  174. package/dist/skill-sh/quality.d.ts.map +1 -0
  175. package/dist/skill-sh/quality.js +146 -0
  176. package/dist/skill-sh/quality.js.map +1 -0
  177. package/dist/skill-sh/registry.d.ts +58 -0
  178. package/dist/skill-sh/registry.d.ts.map +1 -0
  179. package/dist/skill-sh/registry.js +118 -0
  180. package/dist/skill-sh/registry.js.map +1 -0
  181. package/dist/skill-sh/types.d.ts +228 -0
  182. package/dist/skill-sh/types.d.ts.map +1 -0
  183. package/dist/skill-sh/types.js +9 -0
  184. package/dist/skill-sh/types.js.map +1 -0
  185. package/dist/types.d.ts +199 -0
  186. package/dist/types.d.ts.map +1 -0
  187. package/dist/types.js +10 -0
  188. package/dist/types.js.map +1 -0
  189. package/package.json +41 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * LLM Client
3
+ *
4
+ * Provides a generic interface for LLM API calls.
5
+ * Supports OpenAI-compatible APIs and can be extended for other providers.
6
+ *
7
+ * @module @jclaw/core/runtime/llm-client
8
+ */
9
+ /**
10
+ * Configuration for LLM client
11
+ */
12
+ export interface LLMClientConfig {
13
+ /** API endpoint URL */
14
+ apiBase: string;
15
+ /** API key for authentication */
16
+ apiKey: string;
17
+ /** Model identifier */
18
+ model: string;
19
+ /** Request timeout in milliseconds (default: 60000) */
20
+ timeout?: number;
21
+ /** Maximum tokens in response (default: 4096) */
22
+ maxTokens?: number;
23
+ /** Temperature for sampling (default: 0.7) */
24
+ temperature?: number;
25
+ }
26
+ /**
27
+ * Message structure for chat completions
28
+ */
29
+ export interface ChatMessage {
30
+ /** Role of the message sender */
31
+ role: 'system' | 'user' | 'assistant';
32
+ /** Content of the message */
33
+ content: string;
34
+ }
35
+ /**
36
+ * Response from LLM completion
37
+ */
38
+ export interface LLMResponse {
39
+ /** Generated text content */
40
+ content: string;
41
+ /** Model used for generation */
42
+ model: string;
43
+ /** Token usage statistics */
44
+ usage?: {
45
+ promptTokens: number;
46
+ completionTokens: number;
47
+ totalTokens: number;
48
+ };
49
+ /** Duration of the request in milliseconds */
50
+ duration: number;
51
+ }
52
+ /**
53
+ * LLM Client for making API calls to language models.
54
+ *
55
+ * Supports OpenAI-compatible APIs and provides a unified interface
56
+ * for chat completions.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const client = new LLMClient({
61
+ * apiBase: 'https://api.openai.com/v1',
62
+ * apiKey: 'sk-...',
63
+ * model: 'gpt-4'
64
+ * });
65
+ *
66
+ * const response = await client.chat([
67
+ * { role: 'user', content: 'Hello!' }
68
+ * ]);
69
+ * ```
70
+ */
71
+ export declare class LLMClient {
72
+ private readonly config;
73
+ /**
74
+ * Create a new LLM client instance.
75
+ *
76
+ * @param config - Configuration options including API credentials
77
+ */
78
+ constructor(config: LLMClientConfig);
79
+ /**
80
+ * Send a chat completion request to the LLM.
81
+ *
82
+ * @param messages - Array of chat messages
83
+ * @param options - Optional overrides for this specific request
84
+ * @returns Promise resolving to LLM response
85
+ * @throws Error if the API request fails
86
+ */
87
+ chat(messages: ChatMessage[], options?: Partial<Pick<LLMClientConfig, 'maxTokens' | 'temperature'>>): Promise<LLMResponse>;
88
+ /**
89
+ * Send a simple text prompt and get a response.
90
+ *
91
+ * @param prompt - The prompt text
92
+ * @param systemPrompt - Optional system prompt
93
+ * @returns Promise resolving to response content
94
+ */
95
+ complete(prompt: string, systemPrompt?: string): Promise<string>;
96
+ /**
97
+ * Get the configured model name.
98
+ */
99
+ get model(): string;
100
+ }
101
+ /**
102
+ * Create a new LLM client instance.
103
+ *
104
+ * @param config - Configuration options
105
+ * @returns New LLMClient instance
106
+ */
107
+ export declare function createLLMClient(config: LLMClientConfig): LLMClient;
108
+ //# sourceMappingURL=llm-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-client.d.ts","sourceRoot":"","sources":["../../src/runtime/llm-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,CAAC,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiE;IAExF;;;;OAIG;gBACS,MAAM,EAAE,eAAe;IASnC;;;;;;;OAOG;IACG,IAAI,CACR,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,GACpE,OAAO,CAAC,WAAW,CAAC;IAuDvB;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAatE;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;CACF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAElE"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * LLM Client
3
+ *
4
+ * Provides a generic interface for LLM API calls.
5
+ * Supports OpenAI-compatible APIs and can be extended for other providers.
6
+ *
7
+ * @module @jclaw/core/runtime/llm-client
8
+ */
9
+ /**
10
+ * LLM Client for making API calls to language models.
11
+ *
12
+ * Supports OpenAI-compatible APIs and provides a unified interface
13
+ * for chat completions.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const client = new LLMClient({
18
+ * apiBase: 'https://api.openai.com/v1',
19
+ * apiKey: 'sk-...',
20
+ * model: 'gpt-4'
21
+ * });
22
+ *
23
+ * const response = await client.chat([
24
+ * { role: 'user', content: 'Hello!' }
25
+ * ]);
26
+ * ```
27
+ */
28
+ export class LLMClient {
29
+ config;
30
+ /**
31
+ * Create a new LLM client instance.
32
+ *
33
+ * @param config - Configuration options including API credentials
34
+ */
35
+ constructor(config) {
36
+ this.config = {
37
+ timeout: 60000,
38
+ maxTokens: 4096,
39
+ temperature: 0.7,
40
+ ...config,
41
+ };
42
+ }
43
+ /**
44
+ * Send a chat completion request to the LLM.
45
+ *
46
+ * @param messages - Array of chat messages
47
+ * @param options - Optional overrides for this specific request
48
+ * @returns Promise resolving to LLM response
49
+ * @throws Error if the API request fails
50
+ */
51
+ async chat(messages, options) {
52
+ const startTime = Date.now();
53
+ try {
54
+ const response = await fetch(`${this.config.apiBase}/chat/completions`, {
55
+ method: 'POST',
56
+ headers: {
57
+ 'Content-Type': 'application/json',
58
+ Authorization: `Bearer ${this.config.apiKey}`,
59
+ },
60
+ body: JSON.stringify({
61
+ model: this.config.model,
62
+ messages,
63
+ max_tokens: options?.maxTokens ?? this.config.maxTokens,
64
+ temperature: options?.temperature ?? this.config.temperature,
65
+ }),
66
+ signal: AbortSignal.timeout(this.config.timeout),
67
+ });
68
+ if (!response.ok) {
69
+ const errorText = await response.text();
70
+ throw new Error(`LLM API error: ${response.status} - ${errorText}`);
71
+ }
72
+ const data = (await response.json());
73
+ const content = data.choices[0]?.message?.content ?? '';
74
+ const duration = Date.now() - startTime;
75
+ return {
76
+ content,
77
+ model: data.model,
78
+ usage: data.usage
79
+ ? {
80
+ promptTokens: data.usage.prompt_tokens,
81
+ completionTokens: data.usage.completion_tokens,
82
+ totalTokens: data.usage.total_tokens,
83
+ }
84
+ : undefined,
85
+ duration,
86
+ };
87
+ }
88
+ catch (error) {
89
+ const message = error instanceof Error ? error.message : 'Unknown error';
90
+ throw new Error(`LLM request failed: ${message}`);
91
+ }
92
+ }
93
+ /**
94
+ * Send a simple text prompt and get a response.
95
+ *
96
+ * @param prompt - The prompt text
97
+ * @param systemPrompt - Optional system prompt
98
+ * @returns Promise resolving to response content
99
+ */
100
+ async complete(prompt, systemPrompt) {
101
+ const messages = [];
102
+ if (systemPrompt) {
103
+ messages.push({ role: 'system', content: systemPrompt });
104
+ }
105
+ messages.push({ role: 'user', content: prompt });
106
+ const response = await this.chat(messages);
107
+ return response.content;
108
+ }
109
+ /**
110
+ * Get the configured model name.
111
+ */
112
+ get model() {
113
+ return this.config.model;
114
+ }
115
+ }
116
+ /**
117
+ * Create a new LLM client instance.
118
+ *
119
+ * @param config - Configuration options
120
+ * @returns New LLMClient instance
121
+ */
122
+ export function createLLMClient(config) {
123
+ return new LLMClient(config);
124
+ }
125
+ //# sourceMappingURL=llm-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-client.js","sourceRoot":"","sources":["../../src/runtime/llm-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgDH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,SAAS;IACH,MAAM,CAAiE;IAExF;;;;OAIG;IACH,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,GAAG;YAChB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CACR,QAAuB,EACvB,OAAqE;QAErE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,mBAAmB,EAAE;gBACtE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;iBAC9C;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;oBACxB,QAAQ;oBACR,UAAU,EAAE,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS;oBACvD,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW;iBAC7D,CAAC;gBACF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;aACjD,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,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AC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Task Executor
3
+ *
4
+ * Manages task execution workflow including context retrieval,
5
+ * LLM interaction, and command execution.
6
+ *
7
+ * @module @jclaw/core/runtime/task-executor
8
+ */
9
+ import type { Task, TaskResult, ContextManager, Executor } from '../types.js';
10
+ import { LLMClient } from './llm-client.js';
11
+ /**
12
+ * Configuration for task executor
13
+ */
14
+ export interface TaskExecutorConfig {
15
+ /** LLM client for generating responses */
16
+ llmClient: LLMClient;
17
+ /** Context manager for knowledge retrieval */
18
+ contextManager?: ContextManager;
19
+ /** Command executor for running shell commands */
20
+ executor?: Executor;
21
+ /** System prompt for the agent */
22
+ systemPrompt?: string;
23
+ /** Maximum retries for failed tasks (default: 3) */
24
+ maxRetries?: number;
25
+ /** Enable verbose logging */
26
+ verbose?: boolean;
27
+ }
28
+ /**
29
+ * Task Executor
30
+ *
31
+ * Orchestrates task execution by:
32
+ * - Retrieving relevant context
33
+ * - Generating plans with LLM
34
+ * - Executing commands when needed
35
+ * - Handling errors and retries
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const executor = new TaskExecutor({
40
+ * llmClient: createLLMClient(config),
41
+ * contextManager: openVikingClient,
42
+ * executor: localExecutor
43
+ * });
44
+ *
45
+ * const result = await executor.execute({
46
+ * id: 'task-1',
47
+ * prompt: 'List all files in the current directory'
48
+ * });
49
+ * ```
50
+ */
51
+ export declare class TaskExecutor {
52
+ private readonly config;
53
+ /**
54
+ * Create a new task executor instance.
55
+ *
56
+ * @param config - Configuration options
57
+ */
58
+ constructor(config: TaskExecutorConfig);
59
+ /**
60
+ * Execute a task and return the result.
61
+ *
62
+ * @param task - The task to execute
63
+ * @returns Promise resolving to task result
64
+ */
65
+ execute(task: Task): Promise<TaskResult>;
66
+ /**
67
+ * Internal method to execute a single task attempt.
68
+ */
69
+ private executeTask;
70
+ /**
71
+ * Extract shell commands from LLM response.
72
+ *
73
+ * Looks for commands in code blocks marked as shell/bash.
74
+ */
75
+ private extractCommands;
76
+ /**
77
+ * Log message if verbose mode is enabled.
78
+ */
79
+ private log;
80
+ /**
81
+ * Sleep for specified milliseconds.
82
+ */
83
+ private sleep;
84
+ }
85
+ /**
86
+ * Create a new task executor instance.
87
+ *
88
+ * @param config - Configuration options
89
+ * @returns New TaskExecutor instance
90
+ */
91
+ export declare function createTaskExecutor(config: TaskExecutorConfig): TaskExecutor;
92
+ //# sourceMappingURL=task-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-executor.d.ts","sourceRoot":"","sources":["../../src/runtime/task-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAC;AAc9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,SAAS,EAAE,SAAS,CAAC;IACrB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAGrB;IAEF;;;;OAIG;gBACS,MAAM,EAAE,kBAAkB;IAStC;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAsC9C;;OAEG;YACW,WAAW;IAuEzB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB;;OAEG;IACH,OAAO,CAAC,GAAG;IAMX;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAE3E"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Task Executor
3
+ *
4
+ * Manages task execution workflow including context retrieval,
5
+ * LLM interaction, and command execution.
6
+ *
7
+ * @module @jclaw/core/runtime/task-executor
8
+ */
9
+ /**
10
+ * System prompt for the agent
11
+ */
12
+ const DEFAULT_SYSTEM_PROMPT = `You are JClaw, a self-evolving AI agent.
13
+ You help users complete tasks by:
14
+ 1. Understanding their request
15
+ 2. Planning the necessary steps
16
+ 3. Executing commands when needed
17
+ 4. Reporting results clearly
18
+
19
+ Always think step by step and explain your reasoning.`;
20
+ /**
21
+ * Task Executor
22
+ *
23
+ * Orchestrates task execution by:
24
+ * - Retrieving relevant context
25
+ * - Generating plans with LLM
26
+ * - Executing commands when needed
27
+ * - Handling errors and retries
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const executor = new TaskExecutor({
32
+ * llmClient: createLLMClient(config),
33
+ * contextManager: openVikingClient,
34
+ * executor: localExecutor
35
+ * });
36
+ *
37
+ * const result = await executor.execute({
38
+ * id: 'task-1',
39
+ * prompt: 'List all files in the current directory'
40
+ * });
41
+ * ```
42
+ */
43
+ export class TaskExecutor {
44
+ config;
45
+ /**
46
+ * Create a new task executor instance.
47
+ *
48
+ * @param config - Configuration options
49
+ */
50
+ constructor(config) {
51
+ this.config = {
52
+ systemPrompt: DEFAULT_SYSTEM_PROMPT,
53
+ maxRetries: 3,
54
+ verbose: false,
55
+ ...config,
56
+ };
57
+ }
58
+ /**
59
+ * Execute a task and return the result.
60
+ *
61
+ * @param task - The task to execute
62
+ * @returns Promise resolving to task result
63
+ */
64
+ async execute(task) {
65
+ const startTime = Date.now();
66
+ let attempts = 0;
67
+ let lastError;
68
+ while (attempts < this.config.maxRetries) {
69
+ attempts++;
70
+ try {
71
+ const output = await this.executeTask(task);
72
+ const duration = Date.now() - startTime;
73
+ return {
74
+ taskId: task.id,
75
+ success: true,
76
+ output,
77
+ duration,
78
+ };
79
+ }
80
+ catch (error) {
81
+ lastError = error instanceof Error ? error.message : 'Unknown error';
82
+ this.log(`Attempt ${attempts} failed: ${lastError}`);
83
+ // Wait before retry (exponential backoff)
84
+ if (attempts < this.config.maxRetries) {
85
+ await this.sleep(1000 * Math.pow(2, attempts - 1));
86
+ }
87
+ }
88
+ }
89
+ const duration = Date.now() - startTime;
90
+ return {
91
+ taskId: task.id,
92
+ success: false,
93
+ error: `Task failed after ${attempts} attempts. Last error: ${lastError}`,
94
+ duration,
95
+ };
96
+ }
97
+ /**
98
+ * Internal method to execute a single task attempt.
99
+ */
100
+ async executeTask(task) {
101
+ // Build messages array
102
+ const messages = [
103
+ { role: 'system', content: this.config.systemPrompt },
104
+ ];
105
+ // Add context if available
106
+ if (this.config.contextManager) {
107
+ try {
108
+ const context = await this.config.contextManager.query(task.prompt, { topK: 5 });
109
+ if (context) {
110
+ messages.push({
111
+ role: 'system',
112
+ content: `Relevant context:\n${context}`,
113
+ });
114
+ }
115
+ }
116
+ catch {
117
+ this.log('Warning: Failed to retrieve context');
118
+ }
119
+ }
120
+ // Add user prompt
121
+ messages.push({ role: 'user', content: task.prompt });
122
+ // Add task context if provided
123
+ if (task.context) {
124
+ messages.push({
125
+ role: 'user',
126
+ content: `Additional context: ${JSON.stringify(task.context, null, 2)}`,
127
+ });
128
+ }
129
+ // Get LLM response
130
+ const response = await this.config.llmClient.chat(messages);
131
+ // Check if we need to execute commands
132
+ const commands = this.extractCommands(response.content);
133
+ if (commands.length > 0 && this.config.executor) {
134
+ for (const cmd of commands) {
135
+ this.log(`Executing command: ${cmd}`);
136
+ const result = await this.config.executor.execute(cmd, {
137
+ mode: task.executionMode,
138
+ });
139
+ if (result.exitCode !== 0) {
140
+ // Feed error back to LLM
141
+ messages.push({ role: 'assistant', content: response.content });
142
+ messages.push({
143
+ role: 'user',
144
+ content: `Command failed with exit code ${result.exitCode}:\n${result.stderr}`,
145
+ });
146
+ const retryResponse = await this.config.llmClient.chat(messages);
147
+ return retryResponse.content;
148
+ }
149
+ // Feed output back to LLM
150
+ messages.push({ role: 'assistant', content: response.content });
151
+ messages.push({
152
+ role: 'user',
153
+ content: `Command output:\n${result.stdout}`,
154
+ });
155
+ }
156
+ const finalResponse = await this.config.llmClient.chat(messages);
157
+ return finalResponse.content;
158
+ }
159
+ return response.content;
160
+ }
161
+ /**
162
+ * Extract shell commands from LLM response.
163
+ *
164
+ * Looks for commands in code blocks marked as shell/bash.
165
+ */
166
+ extractCommands(content) {
167
+ const commands = [];
168
+ // Match ```shell or ```bash code blocks
169
+ const shellBlockRegex = /```(?:shell|bash|sh)\n([\s\S]*?)```/g;
170
+ let match;
171
+ while ((match = shellBlockRegex.exec(content)) !== null) {
172
+ const cmd = match[1]?.trim();
173
+ if (cmd && !cmd.startsWith('#')) {
174
+ commands.push(cmd);
175
+ }
176
+ }
177
+ return commands;
178
+ }
179
+ /**
180
+ * Log message if verbose mode is enabled.
181
+ */
182
+ log(message) {
183
+ if (this.config.verbose) {
184
+ console.log(`[TaskExecutor] ${message}`);
185
+ }
186
+ }
187
+ /**
188
+ * Sleep for specified milliseconds.
189
+ */
190
+ sleep(ms) {
191
+ return new Promise((resolve) => setTimeout(resolve, ms));
192
+ }
193
+ }
194
+ /**
195
+ * Create a new task executor instance.
196
+ *
197
+ * @param config - Configuration options
198
+ * @returns New TaskExecutor instance
199
+ */
200
+ export function createTaskExecutor(config) {
201
+ return new TaskExecutor(config);
202
+ }
203
+ //# sourceMappingURL=task-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-executor.js","sourceRoot":"","sources":["../../src/runtime/task-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,MAAM,qBAAqB,GAAG;;;;;;;sDAOwB,CAAC;AAoBvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,YAAY;IACN,MAAM,CAGrB;IAEF;;;;OAIG;IACH,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG;YACZ,YAAY,EAAE,qBAAqB;YACnC,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,KAAK;YACd,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,IAAU;QACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,SAA6B,CAAC;QAElC,OAAO,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACzC,QAAQ,EAAE,CAAC;YAEX,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;gBAExC,OAAO;oBACL,MAAM,EAAE,IAAI,CAAC,EAAE;oBACf,OAAO,EAAE,IAAI;oBACb,MAAM;oBACN,QAAQ;iBACT,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAA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QACzB,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Skill.sh Adapter
3
+ *
4
+ * @module @jclaw/core/skill-sh/adapter
5
+ */
6
+ import type { LLMClient } from '../runtime/llm-client.js';
7
+ import type { SkillShResult, SkillShDetail, SkillShAdapterConfig, SkillSearchOptions, SkillFrontmatter, SkillInstallationResult } from './types.js';
8
+ export declare class SkillShAdapter {
9
+ private llmClient;
10
+ private readonly config;
11
+ private cache;
12
+ constructor(llmClient: LLMClient, config?: SkillShAdapterConfig);
13
+ search(options: SkillSearchOptions): Promise<SkillShResult[]>;
14
+ getSkill(skillId: string): Promise<SkillShDetail | null>;
15
+ downloadSkillMd(owner: string, repo: string): Promise<string | null>;
16
+ installSkill(skillId: string): Promise<SkillInstallationResult>;
17
+ parseFrontmatter(content: string): SkillFrontmatter | null;
18
+ private getSkillInstallPath;
19
+ private getCache;
20
+ private setCache;
21
+ private ensureCacheDir;
22
+ private getHeaders;
23
+ }
24
+ export declare function createSkillShAdapter(llmClient: LLMClient, config?: SkillShAdapterConfig): SkillShAdapter;
25
+ export interface SkillShSearchResponse {
26
+ results: SkillShResult[];
27
+ total: number;
28
+ page: number;
29
+ hasMore: boolean;
30
+ }
31
+ export declare function searchSkillShAPI(query: string, options?: {
32
+ limit?: number;
33
+ sortBy?: string;
34
+ }): Promise<SkillShSearchResponse>;
35
+ export declare function clearSkillShCache(): void;
36
+ export declare function getCacheStats(): {
37
+ size: number;
38
+ keys: string[];
39
+ };
40
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/skill-sh/adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAapB,qBAAa,cAAc;IAKvB,OAAO,CAAC,SAAS;IAJnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,KAAK,CAAgE;gBAGnE,SAAS,EAAE,SAAS,EAC5B,MAAM,CAAC,EAAE,oBAAoB;IAMzB,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAgC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAyBxD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA0BpE,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA6BrE,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IA+B1D,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,QAAQ;IAWhB,OAAO,CAAC,QAAQ;YAKF,cAAc;IAO5B,OAAO,CAAC,UAAU;CAMnB;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,GAC5B,cAAc,CAEhB;AAGD,MAAM,W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