pulse-coder-engine 0.0.1-alpha.3 → 0.0.1-alpha.6
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/LICENSE +21 -0
- package/dist/built-in/index.cjs +522 -63
- package/dist/built-in/index.cjs.map +1 -1
- package/dist/built-in/index.d.cts +1 -1
- package/dist/built-in/index.d.ts +1 -1
- package/dist/built-in/index.js +504 -47
- package/dist/built-in/index.js.map +1 -1
- package/dist/index-BkkQyz2L.d.cts +291 -0
- package/dist/index-BkkQyz2L.d.ts +291 -0
- package/dist/index.cjs +599 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -46
- package/dist/index.d.ts +106 -46
- package/dist/index.js +575 -65
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/index-DDqISE31.d.cts +0 -120
- package/dist/index-DDqISE31.d.ts +0 -120
package/dist/index.d.cts
CHANGED
|
@@ -1,51 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { C as ClarificationRequest, T as Tool, L as LLMProviderFactory, S as SystemPromptOption, a as ToolHooks, b as Context, c as ToolExecutionContext, E as EnginePluginLoadOptions, I as ILogger, d as EngineRunHook } from './index-BkkQyz2L.cjs';
|
|
2
|
+
export { B as BuiltInPlanModeService, e as BuiltInSkillRegistry, f as EnginePlugin, g as EnginePluginContext, h as Extension, i as IExtensionContext, j as IPlugin, M as ModePolicy, P as PlanIntentLabel, k as PlanMode, l as PlanModeEvent, m as PlanModeEventName, n as PlanModeService, o as PlanModeTransitionResult, p as ToolCategory, q as ToolMeta, r as ToolRisk, s as builtInMCPPlugin, t as builtInPlanModePlugin, u as builtInPlugins, v as builtInSkillsPlugin } from './index-BkkQyz2L.cjs';
|
|
3
|
+
import { StepResult, ModelMessage, ToolSet, streamText, Tool as Tool$1 } from 'ai';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import 'events';
|
|
6
6
|
|
|
7
|
-
interface ClarificationRequest {
|
|
8
|
-
id: string;
|
|
9
|
-
question: string;
|
|
10
|
-
context?: string;
|
|
11
|
-
defaultAnswer?: string;
|
|
12
|
-
timeout: number;
|
|
13
|
-
}
|
|
14
|
-
interface ToolExecutionContext {
|
|
15
|
-
onClarificationRequest?: (request: ClarificationRequest) => Promise<string>;
|
|
16
|
-
abortSignal?: AbortSignal;
|
|
17
|
-
}
|
|
18
|
-
interface Tool<Input = any, Output = any> {
|
|
19
|
-
name: string;
|
|
20
|
-
description: string;
|
|
21
|
-
inputSchema: FlexibleSchema<Input>;
|
|
22
|
-
execute: (input: Input, context?: ToolExecutionContext) => Promise<Output>;
|
|
23
|
-
}
|
|
24
|
-
interface Context {
|
|
25
|
-
messages: ModelMessage[];
|
|
26
|
-
}
|
|
27
|
-
interface IPlugin {
|
|
28
|
-
name: string;
|
|
29
|
-
version: string;
|
|
30
|
-
extensions: Extension[];
|
|
31
|
-
activate(context: IExtensionContext): Promise<void>;
|
|
32
|
-
deactivate?(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
interface Extension {
|
|
35
|
-
type: 'skill' | 'mcp' | 'tool' | 'context';
|
|
36
|
-
provider: any;
|
|
37
|
-
}
|
|
38
|
-
interface IExtensionContext {
|
|
39
|
-
registerTools(toolName: string, tool: Tool<any, any>): void;
|
|
40
|
-
logger: ILogger;
|
|
41
|
-
}
|
|
42
|
-
interface ILogger {
|
|
43
|
-
debug(message: string, meta?: Record<string, unknown>): void;
|
|
44
|
-
info(message: string, meta?: Record<string, unknown>): void;
|
|
45
|
-
warn(message: string, meta?: Record<string, unknown>): void;
|
|
46
|
-
error(message: string, error?: Error, meta?: Record<string, unknown>): void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
7
|
interface LoopOptions {
|
|
50
8
|
onText?: (delta: string) => void;
|
|
51
9
|
onToolCall?: (toolCall: any) => void;
|
|
@@ -56,6 +14,14 @@ interface LoopOptions {
|
|
|
56
14
|
onResponse?: (messages: StepResult<ToolSet>['response']['messages']) => void;
|
|
57
15
|
abortSignal?: AbortSignal;
|
|
58
16
|
tools?: Record<string, Tool>;
|
|
17
|
+
/** Custom LLM provider factory. Overrides the default provider when set. */
|
|
18
|
+
provider?: LLMProviderFactory;
|
|
19
|
+
/** Model name passed to the provider. Overrides DEFAULT_MODEL when set. */
|
|
20
|
+
model?: string;
|
|
21
|
+
/** Custom system prompt. See SystemPromptOption for the three supported forms. */
|
|
22
|
+
systemPrompt?: SystemPromptOption;
|
|
23
|
+
/** Hooks fired around every tool execution (before/after). */
|
|
24
|
+
hooks?: ToolHooks;
|
|
59
25
|
}
|
|
60
26
|
declare function loop(context: Context, options?: LoopOptions): Promise<string>;
|
|
61
27
|
|
|
@@ -169,6 +135,12 @@ interface StreamOptions {
|
|
|
169
135
|
chunk: any;
|
|
170
136
|
}) => void;
|
|
171
137
|
toolExecutionContext?: ToolExecutionContext;
|
|
138
|
+
/** Custom LLM provider. Falls back to the default CoderAI provider when not set. */
|
|
139
|
+
provider?: LLMProviderFactory;
|
|
140
|
+
/** Model name to pass to the provider. Falls back to DEFAULT_MODEL when not set. */
|
|
141
|
+
model?: string;
|
|
142
|
+
/** Custom system prompt. See SystemPromptOption for the three supported forms. */
|
|
143
|
+
systemPrompt?: SystemPromptOption;
|
|
172
144
|
}
|
|
173
145
|
declare const streamTextAI: (messages: ModelMessage[], tools: Record<string, Tool>, options?: StreamOptions) => ReturnType<typeof streamText> & {
|
|
174
146
|
steps: StepResult<any>[];
|
|
@@ -182,6 +154,8 @@ type CompactResult = {
|
|
|
182
154
|
};
|
|
183
155
|
declare const maybeCompactContext: (context: Context, options?: {
|
|
184
156
|
force?: boolean;
|
|
157
|
+
provider?: LLMProviderFactory;
|
|
158
|
+
model?: string;
|
|
185
159
|
}) => Promise<CompactResult>;
|
|
186
160
|
|
|
187
161
|
interface ClarifyInput {
|
|
@@ -342,6 +316,83 @@ interface EngineOptions {
|
|
|
342
316
|
userConfigPlugins?: UserConfigPluginLoadOptions;
|
|
343
317
|
disableBuiltInPlugins?: boolean;
|
|
344
318
|
config?: Record<string, any>;
|
|
319
|
+
/**
|
|
320
|
+
* 自定义 LLM Provider。
|
|
321
|
+
* 接收模型名称,返回 Vercel AI SDK LanguageModel 实例。
|
|
322
|
+
* 未设置时使用环境变量配置的默认 Provider(OpenAI / Anthropic)。
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* import { createOpenAI } from '@ai-sdk/openai';
|
|
326
|
+
* const engine = new Engine({
|
|
327
|
+
* llmProvider: createOpenAI({ apiKey: 'sk-...', baseURL: 'https://my-proxy/v1' }).chat,
|
|
328
|
+
* model: 'gpt-4o',
|
|
329
|
+
* });
|
|
330
|
+
*/
|
|
331
|
+
llmProvider?: LLMProviderFactory;
|
|
332
|
+
/**
|
|
333
|
+
* 模型名称,传递给 llmProvider。未设置时使用 DEFAULT_MODEL。
|
|
334
|
+
*/
|
|
335
|
+
model?: string;
|
|
336
|
+
/**
|
|
337
|
+
* 直接注册自定义工具,无需创建 EnginePlugin。
|
|
338
|
+
* 这些工具会与内置工具以及插件注册的工具合并。
|
|
339
|
+
* 若与内置工具同名,自定义工具优先级更高。
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* import { z } from 'zod';
|
|
343
|
+
* const engine = new Engine({
|
|
344
|
+
* tools: {
|
|
345
|
+
* myTool: {
|
|
346
|
+
* name: 'myTool',
|
|
347
|
+
* description: '查询内部数据库',
|
|
348
|
+
* inputSchema: z.object({ query: z.string() }),
|
|
349
|
+
* execute: async ({ query }) => fetchFromDB(query),
|
|
350
|
+
* },
|
|
351
|
+
* },
|
|
352
|
+
* });
|
|
353
|
+
*/
|
|
354
|
+
tools?: Record<string, Tool>;
|
|
355
|
+
/**
|
|
356
|
+
* 自定义 System Prompt,三种形式:
|
|
357
|
+
* - `string` — 完全替换内置 prompt
|
|
358
|
+
* - `() => string` — 工厂函数,每次请求调用(支持动态 prompt)
|
|
359
|
+
* - `{ append: string }` — 在内置 prompt 末尾追加业务上下文
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* const engine = new Engine({
|
|
363
|
+
* systemPrompt: { append: '公司规范:所有变量使用 camelCase。禁止使用 any 类型。' },
|
|
364
|
+
* });
|
|
365
|
+
*/
|
|
366
|
+
systemPrompt?: SystemPromptOption;
|
|
367
|
+
/**
|
|
368
|
+
* Tool 执行钩子,在每次工具调用前/后触发。
|
|
369
|
+
* - `onBeforeToolCall` 可以修改入参,或抛错来拦截调用。
|
|
370
|
+
* - `onAfterToolCall` 可以修改返回值(如脱敏、截断)。
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* const engine = new Engine({
|
|
374
|
+
* hooks: {
|
|
375
|
+
* onBeforeToolCall: (name, input) => {
|
|
376
|
+
* if (name === 'bash') throw new Error('bash 工具已被禁用');
|
|
377
|
+
* },
|
|
378
|
+
* onAfterToolCall: (name, input, output) => {
|
|
379
|
+
* auditLogger.log({ name, input, output });
|
|
380
|
+
* return output;
|
|
381
|
+
* },
|
|
382
|
+
* },
|
|
383
|
+
* });
|
|
384
|
+
*/
|
|
385
|
+
hooks?: ToolHooks;
|
|
386
|
+
/**
|
|
387
|
+
* 自定义日志实现。未设置时使用 console.*。
|
|
388
|
+
* 兼容 winston / pino 等主流日志库。
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* import pino from 'pino';
|
|
392
|
+
* const logger = pino();
|
|
393
|
+
* const engine = new Engine({ logger });
|
|
394
|
+
*/
|
|
395
|
+
logger?: ILogger;
|
|
345
396
|
}
|
|
346
397
|
/**
|
|
347
398
|
* 重构后的引擎类
|
|
@@ -362,6 +413,7 @@ declare class Engine {
|
|
|
362
413
|
* 准备引擎插件列表(包含内置插件)
|
|
363
414
|
*/
|
|
364
415
|
private prepareEnginePlugins;
|
|
416
|
+
private applyRunHooks;
|
|
365
417
|
/**
|
|
366
418
|
* 运行AI循环
|
|
367
419
|
*/
|
|
@@ -373,6 +425,7 @@ declare class Engine {
|
|
|
373
425
|
enginePlugins: string[];
|
|
374
426
|
userConfigPlugins: string[];
|
|
375
427
|
tools: string[];
|
|
428
|
+
runHooks: string[];
|
|
376
429
|
services: string[];
|
|
377
430
|
protocols: string[];
|
|
378
431
|
};
|
|
@@ -401,11 +454,13 @@ declare class PluginManager {
|
|
|
401
454
|
private enginePlugins;
|
|
402
455
|
private userConfigPlugins;
|
|
403
456
|
private tools;
|
|
457
|
+
private runHooks;
|
|
404
458
|
private services;
|
|
405
459
|
private protocols;
|
|
406
460
|
private config;
|
|
407
461
|
private events;
|
|
408
462
|
private logger;
|
|
463
|
+
constructor(logger?: ILogger);
|
|
409
464
|
/**
|
|
410
465
|
* 初始化插件系统
|
|
411
466
|
*/
|
|
@@ -457,6 +512,10 @@ declare class PluginManager {
|
|
|
457
512
|
* 工具获取
|
|
458
513
|
*/
|
|
459
514
|
getTools(): Record<string, any>;
|
|
515
|
+
/**
|
|
516
|
+
* 运行时钩子获取
|
|
517
|
+
*/
|
|
518
|
+
getRunHooks(): EngineRunHook[];
|
|
460
519
|
/**
|
|
461
520
|
* 服务获取
|
|
462
521
|
*/
|
|
@@ -472,6 +531,7 @@ declare class PluginManager {
|
|
|
472
531
|
enginePlugins: string[];
|
|
473
532
|
userConfigPlugins: string[];
|
|
474
533
|
tools: string[];
|
|
534
|
+
runHooks: string[];
|
|
475
535
|
services: string[];
|
|
476
536
|
protocols: string[];
|
|
477
537
|
};
|
|
@@ -481,4 +541,4 @@ declare class PluginManager {
|
|
|
481
541
|
private resolvePath;
|
|
482
542
|
}
|
|
483
543
|
|
|
484
|
-
export { BashTool, BuiltinTools, BuiltinToolsMap,
|
|
544
|
+
export { BashTool, BuiltinTools, BuiltinToolsMap, ClarificationRequest, ClarifyTool, Context, EditTool, Engine, GrepTool, ILogger, LLMProviderFactory, LsTool, PluginManager, Engine as PulseAgent, ReadTool, SystemPromptOption, TavilyTool, Tool, ToolExecutionContext, ToolHooks, type UserConfigPlugin, type UserConfigPluginLoadOptions, WriteTool, getFinalToolsMap, loop, maybeCompactContext, streamTextAI };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { C as ClarificationRequest, T as Tool, L as LLMProviderFactory, S as SystemPromptOption, a as ToolHooks, b as Context, c as ToolExecutionContext, E as EnginePluginLoadOptions, I as ILogger, d as EngineRunHook } from './index-BkkQyz2L.js';
|
|
2
|
+
export { B as BuiltInPlanModeService, e as BuiltInSkillRegistry, f as EnginePlugin, g as EnginePluginContext, h as Extension, i as IExtensionContext, j as IPlugin, M as ModePolicy, P as PlanIntentLabel, k as PlanMode, l as PlanModeEvent, m as PlanModeEventName, n as PlanModeService, o as PlanModeTransitionResult, p as ToolCategory, q as ToolMeta, r as ToolRisk, s as builtInMCPPlugin, t as builtInPlanModePlugin, u as builtInPlugins, v as builtInSkillsPlugin } from './index-BkkQyz2L.js';
|
|
3
|
+
import { StepResult, ModelMessage, ToolSet, streamText, Tool as Tool$1 } from 'ai';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import 'events';
|
|
6
6
|
|
|
7
|
-
interface ClarificationRequest {
|
|
8
|
-
id: string;
|
|
9
|
-
question: string;
|
|
10
|
-
context?: string;
|
|
11
|
-
defaultAnswer?: string;
|
|
12
|
-
timeout: number;
|
|
13
|
-
}
|
|
14
|
-
interface ToolExecutionContext {
|
|
15
|
-
onClarificationRequest?: (request: ClarificationRequest) => Promise<string>;
|
|
16
|
-
abortSignal?: AbortSignal;
|
|
17
|
-
}
|
|
18
|
-
interface Tool<Input = any, Output = any> {
|
|
19
|
-
name: string;
|
|
20
|
-
description: string;
|
|
21
|
-
inputSchema: FlexibleSchema<Input>;
|
|
22
|
-
execute: (input: Input, context?: ToolExecutionContext) => Promise<Output>;
|
|
23
|
-
}
|
|
24
|
-
interface Context {
|
|
25
|
-
messages: ModelMessage[];
|
|
26
|
-
}
|
|
27
|
-
interface IPlugin {
|
|
28
|
-
name: string;
|
|
29
|
-
version: string;
|
|
30
|
-
extensions: Extension[];
|
|
31
|
-
activate(context: IExtensionContext): Promise<void>;
|
|
32
|
-
deactivate?(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
interface Extension {
|
|
35
|
-
type: 'skill' | 'mcp' | 'tool' | 'context';
|
|
36
|
-
provider: any;
|
|
37
|
-
}
|
|
38
|
-
interface IExtensionContext {
|
|
39
|
-
registerTools(toolName: string, tool: Tool<any, any>): void;
|
|
40
|
-
logger: ILogger;
|
|
41
|
-
}
|
|
42
|
-
interface ILogger {
|
|
43
|
-
debug(message: string, meta?: Record<string, unknown>): void;
|
|
44
|
-
info(message: string, meta?: Record<string, unknown>): void;
|
|
45
|
-
warn(message: string, meta?: Record<string, unknown>): void;
|
|
46
|
-
error(message: string, error?: Error, meta?: Record<string, unknown>): void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
7
|
interface LoopOptions {
|
|
50
8
|
onText?: (delta: string) => void;
|
|
51
9
|
onToolCall?: (toolCall: any) => void;
|
|
@@ -56,6 +14,14 @@ interface LoopOptions {
|
|
|
56
14
|
onResponse?: (messages: StepResult<ToolSet>['response']['messages']) => void;
|
|
57
15
|
abortSignal?: AbortSignal;
|
|
58
16
|
tools?: Record<string, Tool>;
|
|
17
|
+
/** Custom LLM provider factory. Overrides the default provider when set. */
|
|
18
|
+
provider?: LLMProviderFactory;
|
|
19
|
+
/** Model name passed to the provider. Overrides DEFAULT_MODEL when set. */
|
|
20
|
+
model?: string;
|
|
21
|
+
/** Custom system prompt. See SystemPromptOption for the three supported forms. */
|
|
22
|
+
systemPrompt?: SystemPromptOption;
|
|
23
|
+
/** Hooks fired around every tool execution (before/after). */
|
|
24
|
+
hooks?: ToolHooks;
|
|
59
25
|
}
|
|
60
26
|
declare function loop(context: Context, options?: LoopOptions): Promise<string>;
|
|
61
27
|
|
|
@@ -169,6 +135,12 @@ interface StreamOptions {
|
|
|
169
135
|
chunk: any;
|
|
170
136
|
}) => void;
|
|
171
137
|
toolExecutionContext?: ToolExecutionContext;
|
|
138
|
+
/** Custom LLM provider. Falls back to the default CoderAI provider when not set. */
|
|
139
|
+
provider?: LLMProviderFactory;
|
|
140
|
+
/** Model name to pass to the provider. Falls back to DEFAULT_MODEL when not set. */
|
|
141
|
+
model?: string;
|
|
142
|
+
/** Custom system prompt. See SystemPromptOption for the three supported forms. */
|
|
143
|
+
systemPrompt?: SystemPromptOption;
|
|
172
144
|
}
|
|
173
145
|
declare const streamTextAI: (messages: ModelMessage[], tools: Record<string, Tool>, options?: StreamOptions) => ReturnType<typeof streamText> & {
|
|
174
146
|
steps: StepResult<any>[];
|
|
@@ -182,6 +154,8 @@ type CompactResult = {
|
|
|
182
154
|
};
|
|
183
155
|
declare const maybeCompactContext: (context: Context, options?: {
|
|
184
156
|
force?: boolean;
|
|
157
|
+
provider?: LLMProviderFactory;
|
|
158
|
+
model?: string;
|
|
185
159
|
}) => Promise<CompactResult>;
|
|
186
160
|
|
|
187
161
|
interface ClarifyInput {
|
|
@@ -342,6 +316,83 @@ interface EngineOptions {
|
|
|
342
316
|
userConfigPlugins?: UserConfigPluginLoadOptions;
|
|
343
317
|
disableBuiltInPlugins?: boolean;
|
|
344
318
|
config?: Record<string, any>;
|
|
319
|
+
/**
|
|
320
|
+
* 自定义 LLM Provider。
|
|
321
|
+
* 接收模型名称,返回 Vercel AI SDK LanguageModel 实例。
|
|
322
|
+
* 未设置时使用环境变量配置的默认 Provider(OpenAI / Anthropic)。
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* import { createOpenAI } from '@ai-sdk/openai';
|
|
326
|
+
* const engine = new Engine({
|
|
327
|
+
* llmProvider: createOpenAI({ apiKey: 'sk-...', baseURL: 'https://my-proxy/v1' }).chat,
|
|
328
|
+
* model: 'gpt-4o',
|
|
329
|
+
* });
|
|
330
|
+
*/
|
|
331
|
+
llmProvider?: LLMProviderFactory;
|
|
332
|
+
/**
|
|
333
|
+
* 模型名称,传递给 llmProvider。未设置时使用 DEFAULT_MODEL。
|
|
334
|
+
*/
|
|
335
|
+
model?: string;
|
|
336
|
+
/**
|
|
337
|
+
* 直接注册自定义工具,无需创建 EnginePlugin。
|
|
338
|
+
* 这些工具会与内置工具以及插件注册的工具合并。
|
|
339
|
+
* 若与内置工具同名,自定义工具优先级更高。
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* import { z } from 'zod';
|
|
343
|
+
* const engine = new Engine({
|
|
344
|
+
* tools: {
|
|
345
|
+
* myTool: {
|
|
346
|
+
* name: 'myTool',
|
|
347
|
+
* description: '查询内部数据库',
|
|
348
|
+
* inputSchema: z.object({ query: z.string() }),
|
|
349
|
+
* execute: async ({ query }) => fetchFromDB(query),
|
|
350
|
+
* },
|
|
351
|
+
* },
|
|
352
|
+
* });
|
|
353
|
+
*/
|
|
354
|
+
tools?: Record<string, Tool>;
|
|
355
|
+
/**
|
|
356
|
+
* 自定义 System Prompt,三种形式:
|
|
357
|
+
* - `string` — 完全替换内置 prompt
|
|
358
|
+
* - `() => string` — 工厂函数,每次请求调用(支持动态 prompt)
|
|
359
|
+
* - `{ append: string }` — 在内置 prompt 末尾追加业务上下文
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* const engine = new Engine({
|
|
363
|
+
* systemPrompt: { append: '公司规范:所有变量使用 camelCase。禁止使用 any 类型。' },
|
|
364
|
+
* });
|
|
365
|
+
*/
|
|
366
|
+
systemPrompt?: SystemPromptOption;
|
|
367
|
+
/**
|
|
368
|
+
* Tool 执行钩子,在每次工具调用前/后触发。
|
|
369
|
+
* - `onBeforeToolCall` 可以修改入参,或抛错来拦截调用。
|
|
370
|
+
* - `onAfterToolCall` 可以修改返回值(如脱敏、截断)。
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* const engine = new Engine({
|
|
374
|
+
* hooks: {
|
|
375
|
+
* onBeforeToolCall: (name, input) => {
|
|
376
|
+
* if (name === 'bash') throw new Error('bash 工具已被禁用');
|
|
377
|
+
* },
|
|
378
|
+
* onAfterToolCall: (name, input, output) => {
|
|
379
|
+
* auditLogger.log({ name, input, output });
|
|
380
|
+
* return output;
|
|
381
|
+
* },
|
|
382
|
+
* },
|
|
383
|
+
* });
|
|
384
|
+
*/
|
|
385
|
+
hooks?: ToolHooks;
|
|
386
|
+
/**
|
|
387
|
+
* 自定义日志实现。未设置时使用 console.*。
|
|
388
|
+
* 兼容 winston / pino 等主流日志库。
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* import pino from 'pino';
|
|
392
|
+
* const logger = pino();
|
|
393
|
+
* const engine = new Engine({ logger });
|
|
394
|
+
*/
|
|
395
|
+
logger?: ILogger;
|
|
345
396
|
}
|
|
346
397
|
/**
|
|
347
398
|
* 重构后的引擎类
|
|
@@ -362,6 +413,7 @@ declare class Engine {
|
|
|
362
413
|
* 准备引擎插件列表(包含内置插件)
|
|
363
414
|
*/
|
|
364
415
|
private prepareEnginePlugins;
|
|
416
|
+
private applyRunHooks;
|
|
365
417
|
/**
|
|
366
418
|
* 运行AI循环
|
|
367
419
|
*/
|
|
@@ -373,6 +425,7 @@ declare class Engine {
|
|
|
373
425
|
enginePlugins: string[];
|
|
374
426
|
userConfigPlugins: string[];
|
|
375
427
|
tools: string[];
|
|
428
|
+
runHooks: string[];
|
|
376
429
|
services: string[];
|
|
377
430
|
protocols: string[];
|
|
378
431
|
};
|
|
@@ -401,11 +454,13 @@ declare class PluginManager {
|
|
|
401
454
|
private enginePlugins;
|
|
402
455
|
private userConfigPlugins;
|
|
403
456
|
private tools;
|
|
457
|
+
private runHooks;
|
|
404
458
|
private services;
|
|
405
459
|
private protocols;
|
|
406
460
|
private config;
|
|
407
461
|
private events;
|
|
408
462
|
private logger;
|
|
463
|
+
constructor(logger?: ILogger);
|
|
409
464
|
/**
|
|
410
465
|
* 初始化插件系统
|
|
411
466
|
*/
|
|
@@ -457,6 +512,10 @@ declare class PluginManager {
|
|
|
457
512
|
* 工具获取
|
|
458
513
|
*/
|
|
459
514
|
getTools(): Record<string, any>;
|
|
515
|
+
/**
|
|
516
|
+
* 运行时钩子获取
|
|
517
|
+
*/
|
|
518
|
+
getRunHooks(): EngineRunHook[];
|
|
460
519
|
/**
|
|
461
520
|
* 服务获取
|
|
462
521
|
*/
|
|
@@ -472,6 +531,7 @@ declare class PluginManager {
|
|
|
472
531
|
enginePlugins: string[];
|
|
473
532
|
userConfigPlugins: string[];
|
|
474
533
|
tools: string[];
|
|
534
|
+
runHooks: string[];
|
|
475
535
|
services: string[];
|
|
476
536
|
protocols: string[];
|
|
477
537
|
};
|
|
@@ -481,4 +541,4 @@ declare class PluginManager {
|
|
|
481
541
|
private resolvePath;
|
|
482
542
|
}
|
|
483
543
|
|
|
484
|
-
export { BashTool, BuiltinTools, BuiltinToolsMap,
|
|
544
|
+
export { BashTool, BuiltinTools, BuiltinToolsMap, ClarificationRequest, ClarifyTool, Context, EditTool, Engine, GrepTool, ILogger, LLMProviderFactory, LsTool, PluginManager, Engine as PulseAgent, ReadTool, SystemPromptOption, TavilyTool, Tool, ToolExecutionContext, ToolHooks, type UserConfigPlugin, type UserConfigPluginLoadOptions, WriteTool, getFinalToolsMap, loop, maybeCompactContext, streamTextAI };
|