qlogicagent 2.18.2 → 2.18.4
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/agent.js +38 -24
- package/dist/cli.js +1 -1
- package/dist/index.js +553 -485
- package/dist/orchestration.js +11 -11
- package/dist/protocol.js +1 -1
- package/dist/skills/mcp/astraclaw-native-mcp-server.js +8 -6
- package/dist/types/agent/memory-recall-injection.d.ts +2 -1
- package/dist/types/agent/tool-loop/budget-continuation-policy.d.ts +4 -0
- package/dist/types/agent/tool-loop/completion-action-policy.d.ts +9 -1
- package/dist/types/cli/credential-vault.d.ts +6 -0
- package/dist/types/cli/handlers/community-handler.d.ts +1 -2
- package/dist/types/cli/handlers/memory-handler.d.ts +7 -0
- package/dist/types/cli/handlers/turn-handler.d.ts +50 -1
- package/dist/types/cli/memory-coordinator.d.ts +4 -0
- package/dist/types/cli/pet-runtime.d.ts +2 -0
- package/dist/types/cli/rpc-registry.d.ts +11 -0
- package/dist/types/cli/runtime-hook-bootstrap.d.ts +2 -0
- package/dist/types/cli/skill-tools-bootstrap.d.ts +5 -0
- package/dist/types/cli/stdio-acp-request-host.d.ts +2 -1
- package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +1 -0
- package/dist/types/cli/stdio-server.d.ts +4 -0
- package/dist/types/cli/task-distillation-coordinator.d.ts +79 -0
- package/dist/types/cli/tool-bootstrap-core-registration.d.ts +24 -0
- package/dist/types/cli/turn-core.d.ts +0 -6
- package/dist/types/cli/turn-project-router.d.ts +9 -0
- package/dist/types/contracts/hooks.d.ts +3 -0
- package/dist/types/contracts/turn-event.d.ts +8 -4
- package/dist/types/orchestration/agent-instance.d.ts +4 -0
- package/dist/types/orchestration/context/reactive-compact.d.ts +4 -6
- package/dist/types/orchestration/error-handling/retry-loop.d.ts +0 -22
- package/dist/types/orchestration/goal-loop-coordinator.d.ts +6 -0
- package/dist/types/orchestration/goal-mode-adapters.d.ts +20 -1
- package/dist/types/orchestration/goal-run-types.d.ts +10 -0
- package/dist/types/orchestration/skill-improvement.d.ts +7 -2
- package/dist/types/orchestration/workflow/run-history-store.d.ts +2 -0
- package/dist/types/orchestration/workflow/workflow-runtime.d.ts +8 -0
- package/dist/types/protocol/methods.d.ts +0 -26
- package/dist/types/protocol/wire/acp-agent-management.d.ts +3 -0
- package/dist/types/protocol/wire/agent-events.d.ts +2 -2
- package/dist/types/protocol/wire/agent-methods.d.ts +0 -11
- package/dist/types/protocol/wire/gateway-rpc.d.ts +1 -0
- package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +3 -0
- package/dist/types/protocol/wire/notification-payloads.d.ts +27 -0
- package/dist/types/runtime/community/community-consent-client.d.ts +0 -21
- package/dist/types/runtime/config/tunable-defaults.d.ts +6 -0
- package/dist/types/runtime/execution/memory-decay.d.ts +5 -1
- package/dist/types/runtime/hooks/context-compression.d.ts +5 -0
- package/dist/types/runtime/hooks/memory-hooks.d.ts +16 -0
- package/dist/types/runtime/infra/acp-detector.d.ts +8 -0
- package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +10 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +9 -7
- package/dist/types/runtime/infra/agent-process.d.ts +6 -0
- package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +9 -6
- package/dist/types/runtime/infra/checkpoint-backend.d.ts +1 -1
- package/dist/types/runtime/infra/migrate-device-scope.d.ts +49 -0
- package/dist/types/runtime/infra/project-data-paths.d.ts +4 -3
- package/dist/types/runtime/infra/project-skill-manifest.d.ts +3 -2
- package/dist/types/runtime/infra/working-materials-store.d.ts +8 -14
- package/dist/types/runtime/pet/pet-profile-service.d.ts +7 -0
- package/dist/types/runtime/pet/petdex-forge-service.d.ts +3 -1
- package/dist/types/runtime/ports/memory-provider.d.ts +23 -0
- package/dist/types/runtime/ports/project-memory-store.d.ts +2 -0
- package/dist/types/runtime/prompt/environment-context.d.ts +15 -3
- package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +7 -0
- package/dist/types/runtime/prompt/instruction-loader.d.ts +0 -1
- package/dist/types/runtime/session/inbound-upload-persistence.d.ts +4 -0
- package/dist/types/runtime/session/session-catalog.d.ts +8 -0
- package/dist/types/runtime/session/session-resume.d.ts +5 -0
- package/dist/types/runtime/session/session-transcript-store.d.ts +8 -1
- package/dist/types/skills/mcp/mcp-manager.d.ts +25 -1
- package/dist/types/skills/memory/fts-segment.d.ts +20 -0
- package/dist/types/skills/memory/local-memory-provider.d.ts +66 -4
- package/dist/types/skills/memory/local-store-records.d.ts +6 -1
- package/dist/types/skills/memory/local-store.d.ts +63 -10
- package/dist/types/skills/memory/memdir.d.ts +17 -4
- package/dist/types/skills/memory/memory-consolidation.d.ts +7 -0
- package/dist/types/skills/memory/proposal-consumer.d.ts +51 -0
- package/dist/types/skills/memory/sqlite-memory-mappers.d.ts +2 -1
- package/dist/types/skills/memory/sqlite-memory-schema.d.ts +9 -1
- package/dist/types/skills/memory/task-distillation.d.ts +148 -0
- package/dist/types/skills/tools/search-tool.d.ts +6 -0
- package/dist/types/skills/tools/shell/task-output.d.ts +2 -0
- package/package.json +3 -2
- package/dist/types/agent/tool-loop/skill-instruction-policy.d.ts +0 -7
- package/dist/types/agent/tool-loop/tool-guardrails.d.ts +0 -24
- package/dist/types/cli/tool-bootstrap-community-registration.d.ts +0 -9
- package/dist/types/cli/turn-skill-autopersist.d.ts +0 -22
- package/dist/types/runtime/community/community-discovery-cache.d.ts +0 -24
- package/dist/types/runtime/community/community-discovery-coordinator.d.ts +0 -33
- package/dist/types/runtime/hooks/community-discovery-hook.d.ts +0 -18
- package/dist/types/skills/tools/community-seek-tool.d.ts +0 -49
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { SqliteDatabase } from "./local-store-records.js";
|
|
2
|
-
export declare const MEMORY_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS memories (\n id TEXT PRIMARY KEY,\n text TEXT NOT NULL,\n user_id TEXT NOT NULL,\n category TEXT NOT NULL DEFAULT 'general',\n importance REAL NOT NULL DEFAULT 0.5,\n confidence REAL NOT NULL DEFAULT 1.0,\n source TEXT NOT NULL DEFAULT 'agent',\n session_id TEXT NOT NULL DEFAULT '',\n event_date TEXT NOT NULL DEFAULT '',\n tags TEXT NOT NULL DEFAULT '[]',\n embedding BLOB,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n access_count INTEGER NOT NULL DEFAULT 0,\n last_accessed_at INTEGER NOT NULL DEFAULT 0,\n is_archived INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE INDEX IF NOT EXISTS idx_memories_user ON memories(user_id);\nCREATE INDEX IF NOT EXISTS idx_memories_user_category ON memories(user_id, category);\nCREATE INDEX IF NOT EXISTS idx_memories_user_importance ON memories(user_id, importance DESC);\nCREATE INDEX IF NOT EXISTS idx_memories_created ON memories(created_at DESC);\n\nCREATE TABLE IF NOT EXISTS memory_observations (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n text TEXT NOT NULL,\n source TEXT NOT NULL,\n source_priority INTEGER NOT NULL DEFAULT 0,\n session_id TEXT NOT NULL DEFAULT '',\n evidence_type TEXT NOT NULL DEFAULT 'text',\n payload TEXT NOT NULL DEFAULT '{}',\n created_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_observations_user_created ON memory_observations(user_id, created_at DESC);\nCREATE INDEX IF NOT EXISTS idx_memory_observations_source ON memory_observations(user_id, source);\n\nCREATE TABLE IF NOT EXISTS memory_proposals (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n observation_ids TEXT NOT NULL DEFAULT '[]',\n text TEXT NOT NULL,\n category TEXT NOT NULL DEFAULT 'general',\n importance REAL NOT NULL DEFAULT 0.5,\n confidence REAL NOT NULL DEFAULT 0.5,\n source TEXT NOT NULL DEFAULT 'agent',\n source_priority INTEGER NOT NULL DEFAULT 0,\n entity TEXT NOT NULL DEFAULT '',\n predicate TEXT NOT NULL DEFAULT '',\n value_json TEXT NOT NULL DEFAULT '{}',\n valid_time TEXT NOT NULL DEFAULT '',\n tags TEXT NOT NULL DEFAULT '[]',\n status TEXT NOT NULL DEFAULT 'pending',\n related_claim_ids TEXT NOT NULL DEFAULT '[]',\n idempotency_key TEXT,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_proposals_user_status ON memory_proposals(user_id, status);\nCREATE INDEX IF NOT EXISTS idx_memory_proposals_fact ON memory_proposals(user_id, entity, predicate, valid_time);\n\nCREATE TABLE IF NOT EXISTS memory_claims (\n id TEXT PRIMARY KEY,\n memory_id TEXT NOT NULL DEFAULT '',\n user_id TEXT NOT NULL,\n entity TEXT NOT NULL DEFAULT '',\n predicate TEXT NOT NULL DEFAULT '',\n value_json TEXT NOT NULL DEFAULT '{}',\n text TEXT NOT NULL,\n category TEXT NOT NULL DEFAULT 'general',\n importance REAL NOT NULL DEFAULT 0.5,\n confidence REAL NOT NULL DEFAULT 0.5,\n source TEXT NOT NULL DEFAULT 'agent',\n source_priority INTEGER NOT NULL DEFAULT 0,\n status TEXT NOT NULL DEFAULT 'active',\n valid_time TEXT NOT NULL DEFAULT '',\n evidence_ids TEXT NOT NULL DEFAULT '[]',\n supersedes_claim_id TEXT NOT NULL DEFAULT '',\n conflict_group_id TEXT NOT NULL DEFAULT '',\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_claims_user_status ON memory_claims(user_id, status);\nCREATE INDEX IF NOT EXISTS idx_memory_claims_memory ON memory_claims(memory_id);\nCREATE INDEX IF NOT EXISTS idx_memory_claims_fact ON memory_claims(user_id, entity, predicate, valid_time);\n\nCREATE TABLE IF NOT EXISTS memory_conflicts (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n claim_a_id TEXT NOT NULL,\n claim_b_id TEXT NOT NULL,\n reason TEXT NOT NULL,\n status TEXT NOT NULL DEFAULT 'open',\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_conflicts_user_status ON memory_conflicts(user_id, status);\n\nCREATE TABLE IF NOT EXISTS memory_attachments (\n id TEXT PRIMARY KEY,\n memory_id TEXT NOT NULL DEFAULT '',\n user_id TEXT NOT NULL,\n kind TEXT NOT NULL DEFAULT 'file',\n filename TEXT NOT NULL DEFAULT '',\n mime_type TEXT NOT NULL DEFAULT '',\n size INTEGER NOT NULL DEFAULT 0,\n rel_path TEXT NOT NULL,\n extracted_text TEXT NOT NULL DEFAULT '',\n created_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_attachments_memory ON memory_attachments(memory_id);\nCREATE INDEX IF NOT EXISTS idx_memory_attachments_orphan ON memory_attachments(user_id, memory_id, created_at);\n\
|
|
2
|
+
export declare const MEMORY_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS memories (\n id TEXT PRIMARY KEY,\n text TEXT NOT NULL,\n user_id TEXT NOT NULL,\n category TEXT NOT NULL DEFAULT 'general',\n importance REAL NOT NULL DEFAULT 0.5,\n confidence REAL NOT NULL DEFAULT 1.0,\n source TEXT NOT NULL DEFAULT 'agent',\n session_id TEXT NOT NULL DEFAULT '',\n event_date TEXT NOT NULL DEFAULT '',\n tags TEXT NOT NULL DEFAULT '[]',\n embedding BLOB,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n access_count INTEGER NOT NULL DEFAULT 0,\n last_accessed_at INTEGER NOT NULL DEFAULT 0,\n is_archived INTEGER NOT NULL DEFAULT 0,\n text_seg TEXT NOT NULL DEFAULT '',\n embedding_model TEXT NOT NULL DEFAULT '',\n embedding_dims INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE INDEX IF NOT EXISTS idx_memories_user ON memories(user_id);\nCREATE INDEX IF NOT EXISTS idx_memories_user_category ON memories(user_id, category);\nCREATE INDEX IF NOT EXISTS idx_memories_user_importance ON memories(user_id, importance DESC);\nCREATE INDEX IF NOT EXISTS idx_memories_created ON memories(created_at DESC);\n\nCREATE TABLE IF NOT EXISTS memory_observations (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n text TEXT NOT NULL,\n source TEXT NOT NULL,\n source_priority INTEGER NOT NULL DEFAULT 0,\n session_id TEXT NOT NULL DEFAULT '',\n evidence_type TEXT NOT NULL DEFAULT 'text',\n payload TEXT NOT NULL DEFAULT '{}',\n created_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_observations_user_created ON memory_observations(user_id, created_at DESC);\nCREATE INDEX IF NOT EXISTS idx_memory_observations_source ON memory_observations(user_id, source);\n\nCREATE TABLE IF NOT EXISTS memory_proposals (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n observation_ids TEXT NOT NULL DEFAULT '[]',\n text TEXT NOT NULL,\n category TEXT NOT NULL DEFAULT 'general',\n importance REAL NOT NULL DEFAULT 0.5,\n confidence REAL NOT NULL DEFAULT 0.5,\n source TEXT NOT NULL DEFAULT 'agent',\n source_priority INTEGER NOT NULL DEFAULT 0,\n entity TEXT NOT NULL DEFAULT '',\n predicate TEXT NOT NULL DEFAULT '',\n value_json TEXT NOT NULL DEFAULT '{}',\n valid_time TEXT NOT NULL DEFAULT '',\n tags TEXT NOT NULL DEFAULT '[]',\n status TEXT NOT NULL DEFAULT 'pending',\n related_claim_ids TEXT NOT NULL DEFAULT '[]',\n idempotency_key TEXT,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_proposals_user_status ON memory_proposals(user_id, status);\nCREATE INDEX IF NOT EXISTS idx_memory_proposals_fact ON memory_proposals(user_id, entity, predicate, valid_time);\n\nCREATE TABLE IF NOT EXISTS memory_claims (\n id TEXT PRIMARY KEY,\n memory_id TEXT NOT NULL DEFAULT '',\n user_id TEXT NOT NULL,\n entity TEXT NOT NULL DEFAULT '',\n predicate TEXT NOT NULL DEFAULT '',\n value_json TEXT NOT NULL DEFAULT '{}',\n text TEXT NOT NULL,\n category TEXT NOT NULL DEFAULT 'general',\n importance REAL NOT NULL DEFAULT 0.5,\n confidence REAL NOT NULL DEFAULT 0.5,\n source TEXT NOT NULL DEFAULT 'agent',\n source_priority INTEGER NOT NULL DEFAULT 0,\n status TEXT NOT NULL DEFAULT 'active',\n valid_time TEXT NOT NULL DEFAULT '',\n evidence_ids TEXT NOT NULL DEFAULT '[]',\n supersedes_claim_id TEXT NOT NULL DEFAULT '',\n conflict_group_id TEXT NOT NULL DEFAULT '',\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_claims_user_status ON memory_claims(user_id, status);\nCREATE INDEX IF NOT EXISTS idx_memory_claims_memory ON memory_claims(memory_id);\nCREATE INDEX IF NOT EXISTS idx_memory_claims_fact ON memory_claims(user_id, entity, predicate, valid_time);\n\nCREATE TABLE IF NOT EXISTS memory_conflicts (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n claim_a_id TEXT NOT NULL,\n claim_b_id TEXT NOT NULL,\n reason TEXT NOT NULL,\n status TEXT NOT NULL DEFAULT 'open',\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_conflicts_user_status ON memory_conflicts(user_id, status);\n\nCREATE TABLE IF NOT EXISTS memory_attachments (\n id TEXT PRIMARY KEY,\n memory_id TEXT NOT NULL DEFAULT '',\n user_id TEXT NOT NULL,\n kind TEXT NOT NULL DEFAULT 'file',\n filename TEXT NOT NULL DEFAULT '',\n mime_type TEXT NOT NULL DEFAULT '',\n size INTEGER NOT NULL DEFAULT 0,\n rel_path TEXT NOT NULL,\n extracted_text TEXT NOT NULL DEFAULT '',\n created_at INTEGER NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_memory_attachments_memory ON memory_attachments(memory_id);\nCREATE INDEX IF NOT EXISTS idx_memory_attachments_orphan ON memory_attachments(user_id, memory_id, created_at);\n\n";
|
|
3
|
+
/**
|
|
4
|
+
* FTS index + sync triggers, kept as a separate DDL block because the CJK
|
|
5
|
+
* migration below must DROP and re-create exactly this set — a second copy
|
|
6
|
+
* would drift. The index covers the pre-segmented shadow column `text_seg`
|
|
7
|
+
* (see fts-segment.ts), NOT raw `text`: unicode61 cannot segment CJK, so raw
|
|
8
|
+
* Chinese text is unsearchable by keyword.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MEMORY_FTS_SCHEMA_SQL = "\nCREATE VIRTUAL TABLE IF NOT EXISTS memories_fts USING fts5(\n id UNINDEXED,\n user_id UNINDEXED,\n text_seg,\n category,\n tags,\n content=memories,\n content_rowid=rowid,\n tokenize='unicode61 remove_diacritics 2'\n);\n\nCREATE TRIGGER IF NOT EXISTS memories_ai AFTER INSERT ON memories BEGIN\n INSERT INTO memories_fts(rowid, id, user_id, text_seg, category, tags)\n VALUES (new.rowid, new.id, new.user_id, new.text_seg, new.category, new.tags);\nEND;\n\nCREATE TRIGGER IF NOT EXISTS memories_ad AFTER DELETE ON memories BEGIN\n INSERT INTO memories_fts(memories_fts, rowid, id, user_id, text_seg, category, tags)\n VALUES ('delete', old.rowid, old.id, old.user_id, old.text_seg, old.category, old.tags);\nEND;\n\nCREATE TRIGGER IF NOT EXISTS memories_au AFTER UPDATE ON memories BEGIN\n INSERT INTO memories_fts(memories_fts, rowid, id, user_id, text_seg, category, tags)\n VALUES ('delete', old.rowid, old.id, old.user_id, old.text_seg, old.category, old.tags);\n INSERT INTO memories_fts(rowid, id, user_id, text_seg, category, tags)\n VALUES (new.rowid, new.id, new.user_id, new.text_seg, new.category, new.tags);\nEND;\n";
|
|
3
11
|
export declare function initializeMemorySchema(db: SqliteDatabase): void;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task distillation (R3, 记忆体系 v2) — 任务后蒸馏的纯逻辑层。
|
|
3
|
+
* spec: xiaozhiclaw-runtime/docs/memory-layering-and-distillation-spec.md
|
|
4
|
+
*
|
|
5
|
+
* 蒸馏对象 = "费了劲才做成的任务的做法"(程序性配方),绝不是每轮都跑:
|
|
6
|
+
* 候选采集(回合完成,轻量) → 空闲窗聚类(签名 embedding,宁严勿松) →
|
|
7
|
+
* 簇 ≥ 重复阈值才产 1 条 procedure 记忆 → 高复用晋升技能(见 coordinator)。
|
|
8
|
+
* 成功闸不用 LLM 自评:正常终态 + 同 session 近窗内未被"重做"(在线否决)。
|
|
9
|
+
* 与 feedback-distillation(反馈域)无关 —— 这里蒸馏的是任务执行模式。
|
|
10
|
+
*/
|
|
11
|
+
/** 同模式判定的余弦下限。错聚有害(把不同任务蒸成一份配方),漏聚无害(下次再攒)。 */
|
|
12
|
+
export declare const TASK_DISTILL_CLUSTER_SIM = 0.86;
|
|
13
|
+
/** 在线否决窗口:同 session 内距离 ≤N 回合出现高相似任务 = 前一次疑似被重做(纠正信号)。 */
|
|
14
|
+
export declare const TASK_DISTILL_REDO_WINDOW_TURNS = 3;
|
|
15
|
+
/** 候选滚动上限(jsonl 只保留最近 N 条,防无界增长)。 */
|
|
16
|
+
export declare const TASK_DISTILL_MAX_CANDIDATES = 200;
|
|
17
|
+
/** 晋升推荐阈值:procedure 被召回复用 ≥N 次且未被负反馈沉底。 */
|
|
18
|
+
export declare const TASK_DISTILL_PROMOTE_ACCESS = 3;
|
|
19
|
+
export declare const PROCEDURE_TAG = "distilled@v1";
|
|
20
|
+
export declare const PROCEDURE_CATEGORY = "procedure";
|
|
21
|
+
export interface TaskCandidate {
|
|
22
|
+
id: string;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
/** session 内回合序号(在线否决的距离度量) */
|
|
25
|
+
turnIndex: number;
|
|
26
|
+
/** 任务首句(user prompt 头部,签名文本) */
|
|
27
|
+
promptHead: string;
|
|
28
|
+
toolCallCount: number;
|
|
29
|
+
distinctToolCount: number;
|
|
30
|
+
/** 工具调用序列(name 有序去连续重复),配方步骤的原料 */
|
|
31
|
+
toolSequence: string[];
|
|
32
|
+
durationMs: number;
|
|
33
|
+
at: number;
|
|
34
|
+
/** 签名 embedding(bge-m3);无 embedding 的候选不参与聚类(宁严勿松) */
|
|
35
|
+
embedding?: number[];
|
|
36
|
+
status: "pending" | "rejected" | "distilled";
|
|
37
|
+
}
|
|
38
|
+
export interface CandidateStoreFile {
|
|
39
|
+
candidates: TaskCandidate[];
|
|
40
|
+
}
|
|
41
|
+
export declare function candidateStorePath(profileMemoryDir: string): string;
|
|
42
|
+
export declare function readCandidateStore(path: string): CandidateStoreFile;
|
|
43
|
+
export declare function writeCandidateStore(path: string, store: CandidateStoreFile): void;
|
|
44
|
+
export declare function cosine(a: readonly number[], b: readonly number[]): number;
|
|
45
|
+
export interface CollectInput {
|
|
46
|
+
id: string;
|
|
47
|
+
sessionId: string;
|
|
48
|
+
turnIndex: number;
|
|
49
|
+
promptHead: string;
|
|
50
|
+
toolCallCount: number;
|
|
51
|
+
distinctToolCount: number;
|
|
52
|
+
toolSequence: string[];
|
|
53
|
+
durationMs: number;
|
|
54
|
+
at: number;
|
|
55
|
+
embedding?: number[];
|
|
56
|
+
/** 回合终态:非正常终态的任务不候选(成功闸①) */
|
|
57
|
+
ok: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface CollectResult {
|
|
60
|
+
accepted: boolean;
|
|
61
|
+
/** 被本次采集在线否决(疑似被重做)的旧候选 id */
|
|
62
|
+
rejectedIds: string[];
|
|
63
|
+
reason?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 采集一个回合为蒸馏候选。
|
|
67
|
+
* 在线否决(成功闸②):同 session、距离 ≤REDO_WINDOW 回合内出现高相似新任务,
|
|
68
|
+
* 视为前一次被重做/纠正 —— 否决旧候选(新候选照常入列,它可能是成功版)。
|
|
69
|
+
* 跨 session 或距离更远的相似 = 模式重复,恰是蒸馏想要的信号,全部保留。
|
|
70
|
+
*/
|
|
71
|
+
export declare function collectCandidate(store: CandidateStoreFile, input: CollectInput): CollectResult;
|
|
72
|
+
export declare function clusterCandidates(store: CandidateStoreFile): TaskCandidate[][];
|
|
73
|
+
/** 压缩工具序列:去连续重复,保顺序。 */
|
|
74
|
+
export declare function compressToolSequence(seq: readonly string[]): string[];
|
|
75
|
+
export declare function clusterSignature(cluster: readonly TaskCandidate[]): string;
|
|
76
|
+
export declare function renderProcedureFallback(cluster: readonly TaskCandidate[]): string;
|
|
77
|
+
/** reverted = 升格后被撤销(降格) —— 与"暂不"(dismissed)分开计,是降格率仪表的分子。 */
|
|
78
|
+
export type PromotionStatus = "proposed" | "accepted" | "dismissed" | "reverted";
|
|
79
|
+
export interface PromotionProposal {
|
|
80
|
+
procedureId: string;
|
|
81
|
+
/** 配方首行(展示用) */
|
|
82
|
+
title: string;
|
|
83
|
+
accessCount: number;
|
|
84
|
+
proposedAt: number;
|
|
85
|
+
status: PromotionStatus;
|
|
86
|
+
/** 状态变迁时间(度量面:接受率/响应时长的数据源) */
|
|
87
|
+
resolvedAt?: number;
|
|
88
|
+
/** accepted 时记录升格产出的技能名(demote 反查) */
|
|
89
|
+
skillName?: string;
|
|
90
|
+
/** V3.3 自动档升格(非用户点击) */
|
|
91
|
+
auto?: boolean;
|
|
92
|
+
/** 自动升格的开场确认卡已读(「知道了」) */
|
|
93
|
+
acknowledgedAt?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface PromotionStoreFile {
|
|
96
|
+
proposals: PromotionProposal[];
|
|
97
|
+
}
|
|
98
|
+
export declare function promotionStorePath(profileMemoryDir: string): string;
|
|
99
|
+
export declare function readPromotionStore(path: string): PromotionStoreFile;
|
|
100
|
+
export declare function writePromotionStore(path: string, store: PromotionStoreFile): void;
|
|
101
|
+
/** 达标条目 upsert 为提议。dismissed/accepted 是终态,永不复活(拍板②:暂不=不再打扰)。
|
|
102
|
+
* 已 proposed 的只刷新 accessCount。返回是否新增。 */
|
|
103
|
+
export declare function upsertProposal(store: PromotionStoreFile, input: {
|
|
104
|
+
procedureId: string;
|
|
105
|
+
title: string;
|
|
106
|
+
accessCount: number;
|
|
107
|
+
now: number;
|
|
108
|
+
}): boolean;
|
|
109
|
+
export declare function resolveProposal(store: PromotionStoreFile, procedureId: string, status: "accepted" | "dismissed", now: number): boolean;
|
|
110
|
+
/** 降格:accepted → reverted(区分"暂不";降格率=reverted/accepted 家族)。 */
|
|
111
|
+
export declare function revertProposal(store: PromotionStoreFile, procedureId: string, now: number): PromotionProposal | null;
|
|
112
|
+
/** 配方文本 → SKILL.md 的确定性降级模板(LLM 格式转换失败时兜底)。 */
|
|
113
|
+
export declare function renderSkillMarkdownFallback(name: string, procedureText: string): string;
|
|
114
|
+
/** 自动档解锁条件(拍板③):样本、接受率、降格率。 */
|
|
115
|
+
export declare const V3_AUTO_MIN_SAMPLES = 10;
|
|
116
|
+
export declare const V3_AUTO_MIN_ACCEPT_RATE = 0.7;
|
|
117
|
+
export declare const V3_AUTO_MAX_REVERT_RATE = 0.1;
|
|
118
|
+
/** 自动档触发严阈值(拍板④,比手动档 3 更严)。 */
|
|
119
|
+
export declare const V3_AUTO_MIN_ACCESS = 5;
|
|
120
|
+
export declare const V3_AUTO_MIN_SESSIONS = 3;
|
|
121
|
+
export interface ProcedureUsage {
|
|
122
|
+
/** 召回复用过它的 session 集合 */
|
|
123
|
+
sessions: string[];
|
|
124
|
+
/** 复用后回合失败次数(零容忍:自动档要求 0) */
|
|
125
|
+
negativeCount: number;
|
|
126
|
+
}
|
|
127
|
+
export interface ProcedureUsageStoreFile {
|
|
128
|
+
usage: Record<string, ProcedureUsage>;
|
|
129
|
+
}
|
|
130
|
+
export declare function procedureUsagePath(profileMemoryDir: string): string;
|
|
131
|
+
export declare function readProcedureUsage(path: string): ProcedureUsageStoreFile;
|
|
132
|
+
export declare function writeProcedureUsage(path: string, store: ProcedureUsageStoreFile): void;
|
|
133
|
+
export declare function recordProcedureRecall(store: ProcedureUsageStoreFile, procedureId: string, sessionId: string): void;
|
|
134
|
+
export declare function recordProcedureNegative(store: ProcedureUsageStoreFile, procedureId: string): void;
|
|
135
|
+
export interface PromotionMetrics {
|
|
136
|
+
samples: number;
|
|
137
|
+
accepted: number;
|
|
138
|
+
dismissed: number;
|
|
139
|
+
reverted: number;
|
|
140
|
+
acceptRate: number;
|
|
141
|
+
revertRate: number;
|
|
142
|
+
autoEnabled: boolean;
|
|
143
|
+
}
|
|
144
|
+
/** 手动阶段仪表(拍板③):接受率=accepted 家族/已决样本;降格率=reverted/accepted 家族。
|
|
145
|
+
* 任何时刻降格率回升超限即自动退回手动档(autoEnabled 现算,无粘滞)。 */
|
|
146
|
+
export declare function computePromotionMetrics(proposals: readonly PromotionProposal[]): PromotionMetrics;
|
|
147
|
+
/** 自动档严阈值(拍板④):复用 ≥5 + 跨 ≥3 session + 零负反馈。 */
|
|
148
|
+
export declare function qualifiesForAutoPromotion(accessCount: number, usage: ProcedureUsage | undefined): boolean;
|
|
@@ -105,6 +105,12 @@ export interface SearchToolDeps {
|
|
|
105
105
|
contextAfter?: string[];
|
|
106
106
|
}>;
|
|
107
107
|
truncated: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Optional incompleteness note from the backend (e.g. the search process was
|
|
110
|
+
* killed by timeout/output cap). Appended verbatim to the model-visible
|
|
111
|
+
* content — details alone would be silent to the model.
|
|
112
|
+
*/
|
|
113
|
+
note?: string;
|
|
108
114
|
}>;
|
|
109
115
|
/** Resolve relative path to absolute. If omitted, cwd is used. */
|
|
110
116
|
resolvePath?(input: string): string;
|
|
@@ -30,6 +30,8 @@ export declare class TaskOutput {
|
|
|
30
30
|
/** Get captured stderr. In file mode stderr is interleaved with stdout. */
|
|
31
31
|
getStderr(): string;
|
|
32
32
|
get outputFileSize(): number;
|
|
33
|
+
/** Non-null when the last spill-to-disk attempt failed (output only in memory). */
|
|
34
|
+
get spillError(): string | null;
|
|
33
35
|
/**
|
|
34
36
|
* Whether the output file content is fully contained in getStdout().
|
|
35
37
|
* If true, the file can be deleted.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.4",
|
|
4
4
|
"description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,12 +70,13 @@
|
|
|
70
70
|
"start": "node dist/cli.js",
|
|
71
71
|
"test": "vitest run",
|
|
72
72
|
"test:replay": "vitest run benchmarks/transcript-replay",
|
|
73
|
-
"check": "pnpm run check:encoding-corruption && pnpm run check:mechanical-rules && tsc --noEmit && pnpm test && pnpm run check:architecture-boundaries && pnpm run check:provider-core-boundary && pnpm run check:provider-core-release-sync && pnpm run check:pet-core-boundary && pnpm run check:workspace-hygiene && pnpm run check:package-artifact",
|
|
73
|
+
"check": "pnpm run check:encoding-corruption && pnpm run check:mechanical-rules && pnpm run check:windows-hide && tsc --noEmit && pnpm test && pnpm run check:architecture-boundaries && pnpm run check:provider-core-boundary && pnpm run check:provider-core-release-sync && pnpm run check:pet-core-boundary && pnpm run check:workspace-hygiene && pnpm run check:package-artifact",
|
|
74
74
|
"test:watch": "vitest",
|
|
75
75
|
"benchmark:hermes-superiority": "tsx benchmarks/hermes-superiority/runner.ts",
|
|
76
76
|
"lint": "oxlint .",
|
|
77
77
|
"check:encoding-corruption": "node scripts/check-encoding-corruption.mjs",
|
|
78
78
|
"check:mechanical-rules": "node scripts/check-mechanical-rules.mjs",
|
|
79
|
+
"check:windows-hide": "node scripts/check-windows-hide.mjs src",
|
|
79
80
|
"check:architecture-boundaries": "node scripts/check-architecture-boundaries.mjs",
|
|
80
81
|
"check:provider-core-boundary": "node scripts/check-provider-core-boundary.mjs",
|
|
81
82
|
"check:provider-core-release-sync": "node scripts/check-provider-core-release-sync.mjs",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { buildSkillInstruction } from "../../orchestration/index.js";
|
|
2
|
-
export interface SkillInstructionPolicyInput {
|
|
3
|
-
totalToolCallCount: number;
|
|
4
|
-
distinctToolNames: ReadonlySet<string>;
|
|
5
|
-
projectRoot?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function resolveToolUsageSkillInstruction(input: SkillInstructionPolicyInput): ReturnType<typeof buildSkillInstruction>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type ToolGuardrailLevel = "allow" | "warn" | "block" | "halt";
|
|
2
|
-
export type ToolGuardrailReason = "exact_failure_repeat" | "same_tool_failure_repeat" | "idempotent_no_progress";
|
|
3
|
-
export interface ToolGuardrailDecision {
|
|
4
|
-
level: ToolGuardrailLevel;
|
|
5
|
-
reason?: ToolGuardrailReason;
|
|
6
|
-
message?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ToolGuardrailConfig {
|
|
9
|
-
warnAfter?: number;
|
|
10
|
-
blockAfter?: number;
|
|
11
|
-
haltAfter?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class ToolCallGuardrailController {
|
|
14
|
-
private exact;
|
|
15
|
-
private sameToolFailures;
|
|
16
|
-
private readonly config;
|
|
17
|
-
constructor(config?: ToolGuardrailConfig);
|
|
18
|
-
record(input: {
|
|
19
|
-
toolName: string;
|
|
20
|
-
argumentsJson: string;
|
|
21
|
-
ok: boolean;
|
|
22
|
-
message: unknown;
|
|
23
|
-
}): ToolGuardrailDecision;
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PortableTool } from "../skills/portable-tool.js";
|
|
2
|
-
import { type CommunityDiscoveryResult } from "../runtime/community/community-discovery-coordinator.js";
|
|
3
|
-
export interface LocalCommunityToolRegistrationContext {
|
|
4
|
-
tools: PortableTool<any>[];
|
|
5
|
-
/** 测试可注入的发现实现;默认从 env consent client 构造协调器。 */
|
|
6
|
-
discover?: (intent: string) => Promise<CommunityDiscoveryResult>;
|
|
7
|
-
}
|
|
8
|
-
export declare const localCommunityToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalCommunityToolRegistrationContext>;
|
|
9
|
-
export declare function registerLocalCommunityTools(context: LocalCommunityToolRegistrationContext): void;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface TurnSkillAutoPersistHost {
|
|
2
|
-
log(message: string): void;
|
|
3
|
-
}
|
|
4
|
-
export type AutoPersistResult = {
|
|
5
|
-
status: "ignored";
|
|
6
|
-
} | {
|
|
7
|
-
status: "exists";
|
|
8
|
-
skillPath: string;
|
|
9
|
-
} | {
|
|
10
|
-
status: "created";
|
|
11
|
-
skillPath: string;
|
|
12
|
-
} | {
|
|
13
|
-
status: "skipped";
|
|
14
|
-
skillPath: string;
|
|
15
|
-
reason: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function maybeAutoPersistSkillInstruction(params: {
|
|
18
|
-
instruction: unknown;
|
|
19
|
-
eventTurnId: string;
|
|
20
|
-
projectRoot: string;
|
|
21
|
-
host: TurnSkillAutoPersistHost;
|
|
22
|
-
}): Promise<AutoPersistResult>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CommunityRegistryMatchResult } from "./community-consent-client.js";
|
|
2
|
-
export interface CommunityDiscoveryCacheEntry {
|
|
3
|
-
intentKey: string;
|
|
4
|
-
resourceId: string;
|
|
5
|
-
type: string;
|
|
6
|
-
title: string;
|
|
7
|
-
summary: string;
|
|
8
|
-
sourceTier: string;
|
|
9
|
-
trustStage: string;
|
|
10
|
-
effectiveRiskTier: string;
|
|
11
|
-
latestVersion: string | null;
|
|
12
|
-
cachedAt: string;
|
|
13
|
-
}
|
|
14
|
-
export interface CommunityDiscoveryCacheOptions {
|
|
15
|
-
ownerUserId?: string;
|
|
16
|
-
filePath?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare class CommunityDiscoveryCache {
|
|
19
|
-
private readonly filePath;
|
|
20
|
-
constructor(options?: CommunityDiscoveryCacheOptions);
|
|
21
|
-
readAll(): CommunityDiscoveryCacheEntry[];
|
|
22
|
-
find(intentKey: string): CommunityDiscoveryCacheEntry | undefined;
|
|
23
|
-
writeMatch(intentKey: string, match: CommunityRegistryMatchResult, now?: Date): CommunityDiscoveryCacheEntry;
|
|
24
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { CommunityConsentClient, CommunityRegistryMatchResult } from "./community-consent-client.js";
|
|
2
|
-
import { CommunityDiscoveryCache, type CommunityDiscoveryCacheEntry } from "./community-discovery-cache.js";
|
|
3
|
-
export interface LocalCommunityResourceIndex {
|
|
4
|
-
findInstalled(intentKey: string): CommunityRegistryMatchResult | undefined;
|
|
5
|
-
}
|
|
6
|
-
export type CommunityDiscoveryStatus = "matched" | "local" | "cached" | "miss" | "disabled" | "unavailable";
|
|
7
|
-
export interface CommunityDiscoveryResult {
|
|
8
|
-
status: CommunityDiscoveryStatus;
|
|
9
|
-
intentKey: string;
|
|
10
|
-
match?: CommunityRegistryMatchResult;
|
|
11
|
-
cacheEntry?: CommunityDiscoveryCacheEntry;
|
|
12
|
-
error?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface CommunityDiscoveryCoordinatorOptions {
|
|
15
|
-
client: Pick<CommunityConsentClient, "matchRegistry"> | null;
|
|
16
|
-
cache?: CommunityDiscoveryCache;
|
|
17
|
-
localIndex?: LocalCommunityResourceIndex;
|
|
18
|
-
topK?: number;
|
|
19
|
-
now?: () => Date;
|
|
20
|
-
}
|
|
21
|
-
export declare class CommunityDiscoveryCoordinator {
|
|
22
|
-
private readonly client;
|
|
23
|
-
private readonly cache;
|
|
24
|
-
private readonly localIndex?;
|
|
25
|
-
private readonly topK;
|
|
26
|
-
private readonly now;
|
|
27
|
-
private readonly inMemory;
|
|
28
|
-
constructor(options: CommunityDiscoveryCoordinatorOptions);
|
|
29
|
-
matchForTurn(intent: string): Promise<CommunityDiscoveryResult>;
|
|
30
|
-
prefetchIdle(intents: string[]): Promise<CommunityDiscoveryResult[]>;
|
|
31
|
-
private memo;
|
|
32
|
-
}
|
|
33
|
-
export declare function normalizeDiscoveryIntent(intent: string): string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { HookRegistry } from "../../contracts/hooks.js";
|
|
2
|
-
import type { CommunityDiscoveryCoordinator } from "../community/community-discovery-coordinator.js";
|
|
3
|
-
export interface CommunityDiscoveryHookDeps {
|
|
4
|
-
/** Online community discovery coordinator (null disables discovery). */
|
|
5
|
-
communityDiscovery?: CommunityDiscoveryCoordinator | null;
|
|
6
|
-
/** Logger. */
|
|
7
|
-
log: {
|
|
8
|
-
debug(msg: string): void;
|
|
9
|
-
warn(msg: string): void;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Register the community-discovery hook on `memory.before_recall`.
|
|
14
|
-
* Runs at lower priority (60) than QMemory prefetch (50) so it supplements,
|
|
15
|
-
* not replaces, the standard memory recall. When a Hub resource matches the
|
|
16
|
-
* turn, its metadata is injected into recalledMemories as a suggestion.
|
|
17
|
-
*/
|
|
18
|
-
export declare function registerCommunityDiscoveryHook(hooks: HookRegistry, deps: CommunityDiscoveryHookDeps): () => void;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
-
import type { CommunityDiscoveryResult, CommunityDiscoveryStatus } from "../../runtime/community/community-discovery-coordinator.js";
|
|
3
|
-
import type { CommunityInstallRiskTier, CommunityInstallSourceTier, CommunityInstallTrustStage, CommunityRegistryMatchResult } from "../../runtime/community/community-consent-client.js";
|
|
4
|
-
export declare const COMMUNITY_SEEK_TOOL_NAME: "community_seek";
|
|
5
|
-
export interface CommunitySeekParams {
|
|
6
|
-
intent: string;
|
|
7
|
-
}
|
|
8
|
-
export interface CommunitySeekPackageCandidate {
|
|
9
|
-
kind: "package";
|
|
10
|
-
id: string;
|
|
11
|
-
title: string;
|
|
12
|
-
summary: string;
|
|
13
|
-
capabilityTags: string[];
|
|
14
|
-
sourceTier: CommunityInstallSourceTier;
|
|
15
|
-
trustStage: CommunityInstallTrustStage;
|
|
16
|
-
effectiveRiskTier: CommunityInstallRiskTier;
|
|
17
|
-
latestVersion: string | null;
|
|
18
|
-
}
|
|
19
|
-
/** 轻回执:落进对话的可折叠"去社区找了个 X"(展示侧由 UI 渲染)。 */
|
|
20
|
-
export interface CommunitySeekReceipt {
|
|
21
|
-
intent: string;
|
|
22
|
-
status: CommunityDiscoveryStatus;
|
|
23
|
-
packageCount: number;
|
|
24
|
-
topTitle?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface CommunitySeekResult {
|
|
27
|
-
status: CommunityDiscoveryStatus;
|
|
28
|
-
intent: string;
|
|
29
|
-
packages: CommunitySeekPackageCandidate[];
|
|
30
|
-
}
|
|
31
|
-
export interface CommunitySeekDeps {
|
|
32
|
-
/** 发现协调器:本地前置 + consent + 缓存 + ≤1 次 O(1) registry_match。 */
|
|
33
|
-
discover(intent: string): Promise<CommunityDiscoveryResult>;
|
|
34
|
-
/** 轻回执 sink(对话侧渲染);best-effort,抛错不影响工具结果。 */
|
|
35
|
-
onReceipt?(receipt: CommunitySeekReceipt): void;
|
|
36
|
-
}
|
|
37
|
-
export declare function toPackageCandidate(match: CommunityRegistryMatchResult): CommunitySeekPackageCandidate;
|
|
38
|
-
export declare function runCommunitySeek(deps: CommunitySeekDeps, params: CommunitySeekParams): Promise<CommunitySeekResult>;
|
|
39
|
-
export declare const COMMUNITY_SEEK_TOOL_SCHEMA: {
|
|
40
|
-
readonly type: "object";
|
|
41
|
-
readonly properties: {
|
|
42
|
-
readonly intent: {
|
|
43
|
-
readonly type: "string";
|
|
44
|
-
readonly description: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
readonly required: readonly ["intent"];
|
|
48
|
-
};
|
|
49
|
-
export declare function createCommunitySeekTool(deps: CommunitySeekDeps): PortableTool<CommunitySeekParams>;
|