qlogicagent 2.11.11 → 2.11.13
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/cli.js +566 -541
- package/dist/index.js +566 -541
- package/dist/types/cli/base-tool-bootstrap.d.ts +7 -0
- package/dist/types/cli/handlers/files-handler.d.ts +1 -0
- package/dist/types/cli/tool-bootstrap.d.ts +8 -0
- package/dist/types/protocol/methods.d.ts +3 -0
- package/dist/types/runtime/ports/source-provider.d.ts +39 -0
- package/dist/types/skills/tools/web-answer-tool.d.ts +27 -0
- package/dist/types/skills/tools/web-research-tool.d.ts +19 -0
- package/dist/types/skills/web-search/brave-source.d.ts +2 -0
- package/dist/types/skills/web-search/crawl4ai-extractor.d.ts +15 -0
- package/dist/types/skills/web-search/embedding-rerank.d.ts +13 -0
- package/dist/types/skills/web-search/exa-source.d.ts +2 -0
- package/dist/types/skills/web-search/multi-source-backend.d.ts +23 -0
- package/dist/types/skills/web-search/searxng-source.d.ts +2 -0
- package/dist/types/skills/web-search/serper-source.d.ts +2 -0
- package/dist/types/skills/web-search/source-factory.d.ts +7 -0
- package/dist/types/skills/web-search/stability.d.ts +26 -0
- package/dist/types/transport/acp-server.d.ts +2 -0
- package/package.json +22 -22
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { NotificationMethod, NotificationMethodMap } from "../protocol/notifications.js";
|
|
2
2
|
import type { ToolBootstrap } from "../runtime/ports/index.js";
|
|
3
|
+
import type { ModelPurpose } from "../runtime/infra/model-registry.js";
|
|
4
|
+
import type { LLMTransport } from "./provider-core-facade.js";
|
|
3
5
|
export interface BaseToolBootstrapDeps {
|
|
4
6
|
verbose: boolean;
|
|
5
7
|
toolBootstrap: ToolBootstrap;
|
|
6
8
|
log(message: string): void;
|
|
7
9
|
sendNotification<M extends NotificationMethod>(method: M, params: NotificationMethodMap[M]): void;
|
|
10
|
+
resolveClientForPurpose?(purpose: ModelPurpose): {
|
|
11
|
+
transport: LLMTransport;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
model: string;
|
|
14
|
+
} | null;
|
|
8
15
|
}
|
|
9
16
|
export declare function configureBaseToolBootstrap(deps: BaseToolBootstrapDeps): void;
|
|
@@ -11,6 +11,7 @@ export interface FilesHandlerHost {
|
|
|
11
11
|
export declare function resolveProjectDir(projectId: string): string | null;
|
|
12
12
|
export declare function handleFilesList(this: FilesHandlerHost, msg: AgentRpcRequest): Promise<void>;
|
|
13
13
|
export declare function handleFilesCreate(this: FilesHandlerHost, msg: AgentRpcRequest): Promise<void>;
|
|
14
|
+
export declare function handleFilesRead(this: FilesHandlerHost, msg: AgentRpcRequest): Promise<void>;
|
|
14
15
|
export declare function handleFilesRename(this: FilesHandlerHost, msg: AgentRpcRequest): Promise<void>;
|
|
15
16
|
export declare function handleFilesDelete(this: FilesHandlerHost, msg: AgentRpcRequest): Promise<void>;
|
|
16
17
|
export declare function handleFilesGitStatus(this: FilesHandlerHost, msg: AgentRpcRequest): Promise<void>;
|
|
@@ -2,6 +2,8 @@ import type { PortableTool } from "../skills/portable-tool.js";
|
|
|
2
2
|
import type { PermissionMode } from "../runtime/ports/permission-contracts.js";
|
|
3
3
|
import { type TaskToolHooks } from "../skills/tools/task-tool.js";
|
|
4
4
|
import { type ExecProgress } from "../skills/tools/exec-tool.js";
|
|
5
|
+
import type { ModelPurpose } from "../runtime/infra/model-registry.js";
|
|
6
|
+
import type { LLMTransport } from "./provider-core-facade.js";
|
|
5
7
|
import type { AgentLogger } from "../agent/types.js";
|
|
6
8
|
import { type AskUserQuestion } from "../skills/tools/ask-user-tool.js";
|
|
7
9
|
import type { PathService, ToolCatalog } from "../runtime/ports/index.js";
|
|
@@ -65,6 +67,12 @@ export interface BootstrapConfig {
|
|
|
65
67
|
log?: AgentLogger;
|
|
66
68
|
/** Called during foreground shell execution with incremental progress. */
|
|
67
69
|
onExecProgress?(progress: ExecProgress): void;
|
|
70
|
+
/** host 多档 LLM 解析(web_answer/web_research 用);未提供则不注册这些工具(零孤立)。 */
|
|
71
|
+
resolveClientForPurpose?(purpose: ModelPurpose): {
|
|
72
|
+
transport: LLMTransport;
|
|
73
|
+
apiKey: string;
|
|
74
|
+
model: string;
|
|
75
|
+
} | null;
|
|
68
76
|
}
|
|
69
77
|
/**
|
|
70
78
|
* Create all locally-executable tools and install into centralized tool pool.
|
|
@@ -172,6 +172,8 @@ export interface ToolsListParams {
|
|
|
172
172
|
category?: ToolCapabilityCategory;
|
|
173
173
|
/** Include tools that are normally deferred until activated. */
|
|
174
174
|
includeDeferred?: boolean;
|
|
175
|
+
/** Include tools that are installed but currently disabled by provider/config availability. */
|
|
176
|
+
includeUnavailable?: boolean;
|
|
175
177
|
}
|
|
176
178
|
export interface ToolsListResult {
|
|
177
179
|
tools: Array<{
|
|
@@ -185,6 +187,7 @@ export interface ToolsListResult {
|
|
|
185
187
|
description: string;
|
|
186
188
|
source: "builtin";
|
|
187
189
|
deferred: boolean;
|
|
190
|
+
enabled?: boolean;
|
|
188
191
|
parameters?: Record<string, unknown>;
|
|
189
192
|
}>;
|
|
190
193
|
total: number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface RawHit {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
snippet: string;
|
|
5
|
+
/** 由 L2 抓取回填(V0 不填) */
|
|
6
|
+
content?: string;
|
|
7
|
+
publishedAt?: string;
|
|
8
|
+
/** source 自带排序分(neural source 用),L3 重排前的参考 */
|
|
9
|
+
rawScore?: number;
|
|
10
|
+
/** 命中的 SourceProvider.id */
|
|
11
|
+
source: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SourceCapabilities {
|
|
14
|
+
/** 神经/语义召回(Exa=true,SearXNG=false) */
|
|
15
|
+
semantic: boolean;
|
|
16
|
+
/** 支持时效过滤 */
|
|
17
|
+
freshness: boolean;
|
|
18
|
+
/** 原生支持域名过滤(否则在聚合层兜底) */
|
|
19
|
+
domainFilter: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SourceQueryOptions {
|
|
22
|
+
maxResults?: number;
|
|
23
|
+
allowedDomains?: string[];
|
|
24
|
+
blockedDomains?: string[];
|
|
25
|
+
freshness?: "day" | "week" | "month" | "year" | "any";
|
|
26
|
+
lang?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SourceProvider {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly kind: "serp" | "neural" | "provider-native" | "mcp";
|
|
31
|
+
readonly capabilities: SourceCapabilities;
|
|
32
|
+
/**
|
|
33
|
+
* 只负责"召回原始链接+snippet"。
|
|
34
|
+
* 必须接收并尊重 signal —— 取消/硬超时由聚合层经 AbortSignal 强制透传。
|
|
35
|
+
*/
|
|
36
|
+
search(query: string, opts: SourceQueryOptions, signal: AbortSignal): Promise<RawHit[]>;
|
|
37
|
+
/** 可选主动健康检查(熔断器冷却后探活) */
|
|
38
|
+
health?(signal: AbortSignal): Promise<boolean>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
import type { WebSearchBackend } from "../../runtime/ports/web-search-contracts.js";
|
|
3
|
+
import type { WebFetchToolDeps } from "./web-fetch-tool.js";
|
|
4
|
+
export declare const WEB_ANSWER_TOOL_NAME: "web_answer";
|
|
5
|
+
export interface WebAnswerToolParams {
|
|
6
|
+
query: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const WEB_ANSWER_TOOL_SCHEMA: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly query: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "The question to answer using live web search. Be specific and concise.";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly required: readonly ["query"];
|
|
17
|
+
};
|
|
18
|
+
export interface WebAnswerToolDeps {
|
|
19
|
+
search: WebSearchBackend["search"];
|
|
20
|
+
fetchUrl: WebFetchToolDeps["fetchUrl"];
|
|
21
|
+
/**
|
|
22
|
+
* host 用指定档位 LLM 生成文本(内部 resolveClientForPurpose + transport.stream 累加)。
|
|
23
|
+
* 无可用模型时返回 null —— 工具据此 fail-loud 降级,不静默编造。
|
|
24
|
+
*/
|
|
25
|
+
generate(purpose: "smallModel" | "textGeneration", prompt: string, signal: AbortSignal): Promise<string | null>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createWebAnswerTool(deps: WebAnswerToolDeps): PortableTool<WebAnswerToolParams>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
import type { WebAnswerToolDeps } from "./web-answer-tool.js";
|
|
3
|
+
export declare const WEB_RESEARCH_TOOL_NAME: "web_research";
|
|
4
|
+
export interface WebResearchToolParams {
|
|
5
|
+
task: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const WEB_RESEARCH_TOOL_SCHEMA: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly task: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
readonly required: readonly ["task"];
|
|
16
|
+
};
|
|
17
|
+
/** 与 web_answer 同 deps:search / fetchUrl / generate(host LLM 累加)。 */
|
|
18
|
+
export type WebResearchToolDeps = WebAnswerToolDeps;
|
|
19
|
+
export declare function createWebResearchTool(deps: WebResearchToolDeps): PortableTool<WebResearchToolParams>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ExtractedContent {
|
|
2
|
+
content: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Crawl4aiExtractor {
|
|
6
|
+
/** 提取 URL 正文为 markdown;失败/未配置/超时返回 null(让上层回退本地提取)。 */
|
|
7
|
+
extract(url: string, opts?: {
|
|
8
|
+
maxChars?: number;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}): Promise<ExtractedContent | null>;
|
|
12
|
+
/** 是否已配置 base url(诊断用)。 */
|
|
13
|
+
isConfigured(): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function createCrawl4aiExtractor(): Crawl4aiExtractor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RawHit } from "../../runtime/ports/source-provider.js";
|
|
2
|
+
import { type EmbeddingProvider } from "../memory/local-embedding.js";
|
|
3
|
+
export interface Reranker {
|
|
4
|
+
/** 按 query 语义相关性重排 hits;失败/无模型时返回原序(fail-loud,不破坏召回)。 */
|
|
5
|
+
rerank(query: string, hits: RawHit[]): Promise<RawHit[]>;
|
|
6
|
+
}
|
|
7
|
+
export interface EmbeddingRerankerDeps {
|
|
8
|
+
/** 注入 embedding provider 工厂(默认复用 memory 的 embedding 解析)。测试/ECS 可替换。 */
|
|
9
|
+
getProvider?: () => EmbeddingProvider;
|
|
10
|
+
/** 每条 hit 文本(title+snippet)最大字符,控 token。默认 512。 */
|
|
11
|
+
maxTextChars?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function createEmbeddingReranker(deps?: EmbeddingRerankerDeps): Reranker;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WebSearchBackend } from "../../runtime/ports/web-search-contracts.js";
|
|
2
|
+
import type { SourceProvider, SourceQueryOptions } from "../../runtime/ports/source-provider.js";
|
|
3
|
+
import type { SourceCache, CircuitBreaker } from "./stability.js";
|
|
4
|
+
import type { Reranker } from "./embedding-rerank.js";
|
|
5
|
+
export interface SourceRouter {
|
|
6
|
+
pick(query: string, sources: SourceProvider[], opts: SourceQueryOptions): SourceProvider[];
|
|
7
|
+
}
|
|
8
|
+
/** V0 默认路由:全部 source 都打(已被熔断器在调用前过滤)。L1 分类器路由留 V1。 */
|
|
9
|
+
export declare const allSourcesRouter: SourceRouter;
|
|
10
|
+
export interface MultiSourceConfig {
|
|
11
|
+
sources: SourceProvider[];
|
|
12
|
+
router?: SourceRouter;
|
|
13
|
+
cache?: SourceCache;
|
|
14
|
+
breaker?: CircuitBreaker;
|
|
15
|
+
/** 每个 source 的硬超时(ms);实测起点 4–5s */
|
|
16
|
+
perSourceTimeoutMs?: number;
|
|
17
|
+
cacheTtlMs?: number;
|
|
18
|
+
dedupe?: boolean;
|
|
19
|
+
maxResults?: number;
|
|
20
|
+
/** L3 语义重排器(可选);dedupe 后、截断前对 hits 按 query 相关性重排。 */
|
|
21
|
+
rerank?: Reranker;
|
|
22
|
+
}
|
|
23
|
+
export declare function createMultiSourceBackend(cfg: MultiSourceConfig): WebSearchBackend;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SourceProvider } from "../../runtime/ports/source-provider.js";
|
|
2
|
+
/**
|
|
3
|
+
* 组装 web_search 的 L0 数据源集合。
|
|
4
|
+
* SearXNG 为默认主源;Exa/Brave/Serper 为 BYOK(凭证读 settings tunables / env),
|
|
5
|
+
* 未配置 key 时其 search 返回空数组,不影响整体召回。
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildWebSearchSources(): SourceProvider[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RawHit } from "../../runtime/ports/source-provider.js";
|
|
2
|
+
export interface SourceCache {
|
|
3
|
+
get(key: string): Promise<RawHit[] | null>;
|
|
4
|
+
set(key: string, hits: RawHit[], ttlMs: number): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class InMemorySourceCache implements SourceCache {
|
|
7
|
+
private readonly maxEntries;
|
|
8
|
+
private store;
|
|
9
|
+
constructor(maxEntries?: number);
|
|
10
|
+
get(key: string): Promise<RawHit[] | null>;
|
|
11
|
+
set(key: string, hits: RawHit[], ttlMs: number): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface CircuitBreaker {
|
|
14
|
+
canRequest(sourceId: string): boolean;
|
|
15
|
+
recordSuccess(sourceId: string): void;
|
|
16
|
+
recordFailure(sourceId: string): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class InMemoryCircuitBreaker implements CircuitBreaker {
|
|
19
|
+
private readonly threshold;
|
|
20
|
+
private readonly cooldownMs;
|
|
21
|
+
private state;
|
|
22
|
+
constructor(threshold?: number, cooldownMs?: number);
|
|
23
|
+
canRequest(sourceId: string): boolean;
|
|
24
|
+
recordSuccess(sourceId: string): void;
|
|
25
|
+
recordFailure(sourceId: string): void;
|
|
26
|
+
}
|
|
@@ -156,8 +156,10 @@ export declare class AcpServer {
|
|
|
156
156
|
private onSessionPrompt;
|
|
157
157
|
private onSessionClose;
|
|
158
158
|
private onSessionSetConfig;
|
|
159
|
+
private onSessionSetModel;
|
|
159
160
|
private onSessionSetMode;
|
|
160
161
|
private onAbort;
|
|
162
|
+
private onSessionCancel;
|
|
161
163
|
private onCancel;
|
|
162
164
|
private onDream;
|
|
163
165
|
private sendResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.13",
|
|
4
4
|
"description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -62,6 +62,26 @@
|
|
|
62
62
|
]
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"dev": "tsx watch src/index.ts",
|
|
67
|
+
"build": "node scripts/build.mjs",
|
|
68
|
+
"build:tsc": "tsc --noCheck",
|
|
69
|
+
"start": "node dist/cli.js",
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"check": "tsc --noEmit && pnpm test && pnpm run check:architecture-boundaries && pnpm run check:provider-core-boundary && pnpm run check:pet-core-boundary && pnpm run check:workspace-hygiene && pnpm run check:package-artifact",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"lint": "oxlint .",
|
|
74
|
+
"check:architecture-boundaries": "node scripts/check-architecture-boundaries.mjs",
|
|
75
|
+
"check:provider-core-boundary": "node scripts/check-provider-core-boundary.mjs",
|
|
76
|
+
"check:pet-core-boundary": "node scripts/check-pet-core-boundary.mjs",
|
|
77
|
+
"check:workspace-hygiene": "node scripts/check-workspace-hygiene.mjs",
|
|
78
|
+
"check:workspace-hygiene:strict": "node scripts/check-workspace-hygiene.mjs --strict",
|
|
79
|
+
"check:package-artifact": "npm run build && node scripts/check-package-artifact.mjs",
|
|
80
|
+
"redteam:community-desensitization": "tsx src/runtime/community/community-desensitization-red-team-cli.ts",
|
|
81
|
+
"redteam:community-sandbox": "tsx src/skills/permissions/community-sandbox-red-team-cli.ts",
|
|
82
|
+
"clean:workspace-hygiene": "node scripts/clean-workspace-hygiene.mjs",
|
|
83
|
+
"release": "node scripts/release.mjs"
|
|
84
|
+
},
|
|
65
85
|
"engines": {
|
|
66
86
|
"node": ">=22.0.0"
|
|
67
87
|
},
|
|
@@ -84,25 +104,5 @@
|
|
|
84
104
|
"tsx": "^4.19.0",
|
|
85
105
|
"typescript": "^5.9.0",
|
|
86
106
|
"vitest": "^3.1.0"
|
|
87
|
-
},
|
|
88
|
-
"scripts": {
|
|
89
|
-
"dev": "tsx watch src/index.ts",
|
|
90
|
-
"build": "node scripts/build.mjs",
|
|
91
|
-
"build:tsc": "tsc --noCheck",
|
|
92
|
-
"start": "node dist/cli.js",
|
|
93
|
-
"test": "vitest run",
|
|
94
|
-
"check": "tsc --noEmit && pnpm test && pnpm run check:architecture-boundaries && pnpm run check:provider-core-boundary && pnpm run check:pet-core-boundary && pnpm run check:workspace-hygiene && pnpm run check:package-artifact",
|
|
95
|
-
"test:watch": "vitest",
|
|
96
|
-
"lint": "oxlint .",
|
|
97
|
-
"check:architecture-boundaries": "node scripts/check-architecture-boundaries.mjs",
|
|
98
|
-
"check:provider-core-boundary": "node scripts/check-provider-core-boundary.mjs",
|
|
99
|
-
"check:pet-core-boundary": "node scripts/check-pet-core-boundary.mjs",
|
|
100
|
-
"check:workspace-hygiene": "node scripts/check-workspace-hygiene.mjs",
|
|
101
|
-
"check:workspace-hygiene:strict": "node scripts/check-workspace-hygiene.mjs --strict",
|
|
102
|
-
"check:package-artifact": "npm run build && node scripts/check-package-artifact.mjs",
|
|
103
|
-
"redteam:community-desensitization": "tsx src/runtime/community/community-desensitization-red-team-cli.ts",
|
|
104
|
-
"redteam:community-sandbox": "tsx src/skills/permissions/community-sandbox-red-team-cli.ts",
|
|
105
|
-
"clean:workspace-hygiene": "node scripts/clean-workspace-hygiene.mjs",
|
|
106
|
-
"release": "node scripts/release.mjs"
|
|
107
107
|
}
|
|
108
|
-
}
|
|
108
|
+
}
|