@octopi-agent/engine 0.58.0 → 0.70.7
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/config-schema/context.d.ts +1 -1
- package/dist/config-schema/context.js +1 -1
- package/dist/config-schema/engine.d.ts +122 -1
- package/dist/config-schema/engine.js +4 -1
- package/dist/config-schema/substrate.d.ts +123 -0
- package/dist/config-schema/substrate.js +161 -0
- package/dist/config.d.ts +101 -1
- package/dist/harness/agent/builder.d.ts +15 -1
- package/dist/harness/agent/builder.js +41 -4
- package/dist/harness/agent/config-bridge.js +17 -4
- package/dist/harness/{context/capabilities → capabilities}/document/backends/docx.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/docx.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/office-parser.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/office-parser.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/pdf.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/pdf.js +13 -3
- package/dist/harness/{context/capabilities → capabilities}/document/backends/plain.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/plain.js +13 -4
- package/dist/harness/{context/capabilities → capabilities}/document/backends/sheet.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/sheet.js +25 -5
- package/dist/harness/{context/capabilities → capabilities}/document/backends/xmind.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/xmind.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/errors.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/errors.js +1 -1
- package/dist/harness/capabilities/document/factory.d.ts +33 -0
- package/dist/harness/capabilities/document/factory.js +37 -0
- package/dist/harness/{context/capabilities → capabilities}/document/format.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/format.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/html-to-md.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/html-to-md.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/index.d.ts +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/index.js +2 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/factory.d.ts +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/factory.js +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/soffice.d.ts +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/soffice.js +44 -1
- package/dist/harness/{context/capabilities → capabilities}/document/port.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/port.js +4 -4
- package/dist/harness/{context/capabilities → capabilities}/document/types.d.ts +11 -1
- package/dist/harness/{context/capabilities → capabilities}/document/types.js +1 -1
- package/dist/harness/capabilities/document/worker-port.d.ts +13 -0
- package/dist/harness/capabilities/document/worker-port.js +78 -0
- package/dist/harness/context/capabilities/index.d.ts +2 -2
- package/dist/harness/context/capabilities/index.js +2 -2
- package/dist/harness/context/capabilities/summary/gate.js +2 -2
- package/dist/harness/context/capabilities/summary/policies.js +5 -5
- package/dist/harness/context/capabilities/summary/registry.js +29 -24
- package/dist/harness/context/layer-health.js +3 -2
- package/dist/harness/context/layers.d.ts +27 -13
- package/dist/harness/context/layers.js +76 -66
- package/dist/harness/context/system-prompt-assembler.d.ts +3 -0
- package/dist/harness/context/system-prompt-assembler.js +11 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.js +3 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.d.ts +56 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.js +281 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +98 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +250 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.d.ts +124 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.js +372 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +109 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.js +8 -0
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.d.ts +10 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +102 -5
- package/dist/harness/extension/plugin-ecosystem/tools/memory.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +14 -0
- package/dist/harness/index.d.ts +8 -5
- package/dist/harness/index.js +4 -2
- package/dist/harness/knowledge/adapters.d.ts +8 -5
- package/dist/harness/knowledge/adapters.js +53 -13
- package/dist/harness/knowledge/client.d.ts +197 -0
- package/dist/harness/knowledge/client.js +237 -0
- package/dist/harness/knowledge/connector-fetcher.d.ts +2 -2
- package/dist/harness/knowledge/connectors.d.ts +3 -3
- package/dist/harness/knowledge/connectors.js +14 -8
- package/dist/harness/knowledge/db.d.ts +40 -5
- package/dist/harness/knowledge/db.js +441 -113
- package/dist/harness/knowledge/document-extract-worker.js +55 -12
- package/dist/harness/knowledge/embed-runner.d.ts +53 -0
- package/dist/harness/knowledge/embed-runner.js +171 -0
- package/dist/harness/knowledge/engine-thread.d.ts +1 -0
- package/dist/harness/knowledge/engine-thread.js +302 -0
- package/dist/harness/knowledge/extract-document.d.ts +21 -5
- package/dist/harness/knowledge/extract-document.js +32 -8
- package/dist/harness/knowledge/fetchers.d.ts +14 -3
- package/dist/harness/knowledge/fetchers.js +52 -16
- package/dist/harness/knowledge/file-identity.d.ts +53 -0
- package/dist/harness/knowledge/file-identity.js +172 -0
- package/dist/harness/knowledge/file-index-store.d.ts +50 -0
- package/dist/harness/knowledge/file-index-store.js +132 -0
- package/dist/harness/knowledge/file-limits.d.ts +86 -0
- package/dist/harness/knowledge/file-limits.js +175 -0
- package/dist/harness/knowledge/fts.d.ts +60 -0
- package/dist/harness/knowledge/fts.js +218 -0
- package/dist/harness/knowledge/grounding.d.ts +3 -2
- package/dist/harness/knowledge/http-app.d.ts +50 -0
- package/dist/harness/knowledge/http-app.js +652 -0
- package/dist/harness/knowledge/http-bridge.d.ts +49 -0
- package/dist/harness/knowledge/http-bridge.js +17 -0
- package/dist/harness/knowledge/index-store.d.ts +158 -93
- package/dist/harness/knowledge/index-store.js +982 -441
- package/dist/harness/knowledge/index.d.ts +45 -5
- package/dist/harness/knowledge/index.js +23 -2
- package/dist/harness/knowledge/ingest.d.ts +262 -87
- package/dist/harness/knowledge/ingest.js +1072 -480
- package/dist/harness/knowledge/job-control-state.d.ts +29 -0
- package/dist/harness/knowledge/job-control-state.js +44 -0
- package/dist/harness/knowledge/job-control.d.ts +35 -0
- package/dist/harness/knowledge/job-control.js +86 -0
- package/dist/harness/knowledge/job-queue.d.ts +62 -0
- package/dist/harness/knowledge/job-queue.js +173 -0
- package/dist/harness/knowledge/knowledge-serve-child.d.ts +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +100 -0
- package/dist/harness/knowledge/local-stack.d.ts +27 -0
- package/dist/harness/knowledge/local-stack.js +63 -0
- package/dist/harness/knowledge/membership-store.d.ts +65 -0
- package/dist/harness/knowledge/membership-store.js +198 -0
- package/dist/harness/knowledge/network-guard.d.ts +11 -2
- package/dist/harness/knowledge/network-guard.js +130 -85
- package/dist/harness/knowledge/parse-text-in-worker.d.ts +32 -0
- package/dist/harness/knowledge/parse-text-in-worker.js +158 -0
- package/dist/harness/knowledge/query-service.d.ts +272 -0
- package/dist/harness/knowledge/query-service.js +326 -0
- package/dist/harness/knowledge/query-worker-client.d.ts +96 -0
- package/dist/harness/knowledge/query-worker-client.js +207 -0
- package/dist/harness/knowledge/query-worker.d.ts +1 -0
- package/dist/harness/knowledge/query-worker.js +186 -0
- package/dist/harness/knowledge/read-http.d.ts +35 -0
- package/dist/harness/knowledge/read-http.js +373 -0
- package/dist/harness/knowledge/retriever.d.ts +22 -5
- package/dist/harness/knowledge/retriever.js +66 -35
- package/dist/harness/knowledge/secret-scan.d.ts +13 -2
- package/dist/harness/knowledge/secret-scan.js +25 -2
- package/dist/harness/knowledge/serve.d.ts +48 -0
- package/dist/harness/knowledge/serve.js +336 -0
- package/dist/harness/knowledge/source-store.d.ts +97 -19
- package/dist/harness/knowledge/source-store.js +166 -94
- package/dist/harness/knowledge/start-service-process.d.ts +49 -0
- package/dist/harness/knowledge/start-service-process.js +158 -0
- package/dist/harness/knowledge/text-parse-worker.d.ts +1 -0
- package/dist/harness/knowledge/text-parse-worker.js +54 -0
- package/dist/harness/knowledge/types.d.ts +1 -1
- package/dist/harness/knowledge/types.js +1 -1
- package/dist/harness/knowledge/vector-ann.d.ts +42 -0
- package/dist/harness/knowledge/vector-ann.js +68 -0
- package/dist/harness/knowledge/writer-lock.d.ts +13 -0
- package/dist/harness/knowledge/writer-lock.js +71 -0
- package/dist/harness/knowledge/writer-service.d.ts +194 -0
- package/dist/harness/knowledge/writer-service.js +355 -0
- package/dist/harness/knowledge/writer-worker-client.d.ts +102 -0
- package/dist/harness/knowledge/writer-worker-client.js +381 -0
- package/dist/harness/knowledge/writer-worker.d.ts +1 -0
- package/dist/harness/knowledge/writer-worker.js +189 -0
- package/dist/harness/memory/cognition-decay.d.ts +36 -0
- package/dist/harness/memory/cognition-decay.js +55 -0
- package/dist/harness/memory/cognition-gates.d.ts +60 -0
- package/dist/harness/memory/cognition-gates.js +191 -0
- package/dist/harness/memory/cognition-trigger.d.ts +30 -0
- package/dist/harness/memory/cognition-trigger.js +41 -0
- package/dist/harness/memory/cognition-types.d.ts +1 -1
- package/dist/harness/memory/cognition.d.ts +40 -8
- package/dist/harness/memory/cognition.js +432 -79
- package/dist/harness/memory/conceptualizer.d.ts +66 -0
- package/dist/harness/memory/conceptualizer.js +246 -0
- package/dist/harness/memory/index.d.ts +16 -2
- package/dist/harness/memory/index.js +11 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +9 -0
- package/dist/harness/memory/sqlite/agent-db.js +118 -15
- package/dist/harness/memory/sqlite/cognition-store.d.ts +55 -16
- package/dist/harness/memory/sqlite/cognition-store.js +591 -144
- package/dist/harness/memory/sqlite/embedding.d.ts +5 -2
- package/dist/harness/memory/sqlite/embedding.js +109 -16
- package/dist/harness/memory/sqlite/keyword-search.d.ts +21 -0
- package/dist/harness/memory/sqlite/keyword-search.js +64 -0
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +33 -14
- package/dist/harness/memory/sqlite/wisdom-store.js +257 -44
- package/dist/harness/memory/types.d.ts +331 -16
- package/dist/harness/memory/types.js +49 -0
- package/dist/harness/memory/wisdom-formation.d.ts +101 -0
- package/dist/harness/memory/wisdom-formation.js +304 -0
- package/dist/harness/memory/wisdom-gates.d.ts +50 -0
- package/dist/harness/memory/wisdom-gates.js +204 -0
- package/dist/harness/memory/wisdom-policy.d.ts +107 -0
- package/dist/harness/memory/wisdom-policy.js +220 -0
- package/dist/harness/memory/wisdom-types.d.ts +3 -2
- package/dist/harness/memory/wisdom-types.js +2 -2
- package/dist/harness/memory/wisdom.d.ts +27 -0
- package/dist/harness/memory/wisdom.js +181 -0
- package/dist/harness/run/agent/agent.d.ts +9 -0
- package/dist/harness/run/agent/agent.js +19 -0
- package/dist/harness/run/reliability/run-agent.js +6 -2
- package/dist/harness/run/runner.js +2 -1
- package/dist/harness/session/attachments/service.d.ts +1 -1
- package/dist/harness/session/attachments/service.js +1 -1
- package/dist/harness/session/index.d.ts +1 -0
- package/dist/harness/session/index.js +1 -0
- package/dist/harness/session/title.d.ts +86 -0
- package/dist/harness/session/title.js +268 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +8 -0
- package/dist/harness/shared/events/agent-event-map.js +1 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.d.ts +9 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +125 -0
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -0
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +12 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.js +93 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +91 -0
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -0
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -0
- package/dist/subsystems/wisdom-steward/formation/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +212 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -0
- package/dist/subsystems/wisdom-steward/govern/handler.d.ts +17 -0
- package/dist/subsystems/wisdom-steward/govern/handler.js +68 -0
- package/dist/worker-path.d.ts +8 -0
- package/dist/worker-path.js +15 -0
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 写入经 confidence + gates;检索含 shadow、排除 deleted。
|
|
5
5
|
*/
|
|
6
6
|
import type { RegisteredTool } from '@octopi-agent/core/types.js';
|
|
7
|
-
import type { MemoryStore } from '../../../memory/types.js';
|
|
7
|
+
import type { MemoryChannel, MemoryStore, MemoryType } from '../../../memory/types.js';
|
|
8
8
|
import { type ConfidenceProfileConfig } from '../../../memory/confidence.js';
|
|
9
9
|
import { type GateConfig } from '../../../memory/gates.js';
|
|
10
10
|
export interface MemoryToolOptions {
|
|
@@ -12,6 +12,16 @@ export interface MemoryToolOptions {
|
|
|
12
12
|
gates?: GateConfig;
|
|
13
13
|
/** 每次触发默认最大写入条数提示(工具描述用) */
|
|
14
14
|
maxWritesPerTrigger?: number;
|
|
15
|
+
/** 成功落库后回调(概念化触发等);不得抛错打断写路径 */
|
|
16
|
+
onStored?: (info: {
|
|
17
|
+
id: string;
|
|
18
|
+
proposition: string;
|
|
19
|
+
evidence: string;
|
|
20
|
+
type: MemoryType;
|
|
21
|
+
status: string;
|
|
22
|
+
channel: MemoryChannel;
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
}) => void;
|
|
15
25
|
}
|
|
16
26
|
/** 创建记忆工具集 */
|
|
17
27
|
export declare function createMemoryTools(store: MemoryStore, options?: MemoryToolOptions): RegisteredTool[];
|
|
@@ -136,6 +136,20 @@ export function createMemoryStoreTool(store, options) {
|
|
|
136
136
|
winnerId: id,
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
+
try {
|
|
140
|
+
options?.onStored?.({
|
|
141
|
+
id,
|
|
142
|
+
proposition,
|
|
143
|
+
evidence,
|
|
144
|
+
type,
|
|
145
|
+
status,
|
|
146
|
+
channel,
|
|
147
|
+
sessionId: context.sessionId,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// 触发回调失败不影响 Memory 已落库事实
|
|
152
|
+
}
|
|
139
153
|
return {
|
|
140
154
|
id,
|
|
141
155
|
stored: true,
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -12,8 +12,10 @@ export type { WebSearchToolOptions } from './extension/plugin-ecosystem/tools/we
|
|
|
12
12
|
export { createSessionHistoryPort, resolveHistoryAccess, } from './session/history/index.js';
|
|
13
13
|
export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTool, } from './extension/plugin-ecosystem/tools/session-history.js';
|
|
14
14
|
export type { SessionHistoryPort, SessionHistoryQuery, SessionHistorySearchResult, SessionHistoryOptions, } from './session/history/index.js';
|
|
15
|
-
export { createSummaryPort, applyToolOutputGate, createDefaultSummaryPolicies, resolveSummaryModel, getToolSummaryBinding, createCompactEngine, createMemorySummaryCache,
|
|
16
|
-
export
|
|
15
|
+
export { createSummaryPort, applyToolOutputGate, createDefaultSummaryPolicies, resolveSummaryModel, getToolSummaryBinding, createCompactEngine, createMemorySummaryCache, } from './context/capabilities/index.js';
|
|
16
|
+
export { createDefaultDocumentPort, createDefaultBackends, createDocumentPortFromConfig, DocumentExtractError, isDocumentExtractError, } from './capabilities/document/index.js';
|
|
17
|
+
export type { ContentUnit, ContentKind, ContentChannel, SummaryPort, SummaryPolicy, SummaryResult, ToolSummaryBinding, ToolSummarySupport, CreateSummaryPortOptions, CompactEngine, CompactOptions, CompactOutcome, } from './context/capabilities/index.js';
|
|
18
|
+
export type { DocumentPort, DocumentCapabilities, DocumentMeta, ExtractResult, ExtractSource, ExtractOptions, ExtractWarning, DocumentExtractBackend, LegacyConverter, CreateDocumentPortOptions, DocumentCapabilityConfig, } from './capabilities/document/index.js';
|
|
17
19
|
export { AgentBuilder, createAgent, isSubsystemAllowed, discoverSubsystemSpecs } from './agent/builder.js';
|
|
18
20
|
export type { AgentBuildOptions, AgentBuildResult, AgentBuildCoreResult, AgentTraceOptions } from './agent/builder.js';
|
|
19
21
|
export type { ChannelAdapter, ChannelMessage, ChannelReply } from './extension/plugin-ecosystem/channel-types.js';
|
|
@@ -93,12 +95,13 @@ export type { AgentRuntimeConfig, Trigger, TriggerType, TriggerPayload, TriggerS
|
|
|
93
95
|
export type { KnowledgeCatalogItem, KnowledgeCatalogProvider } from './knowledge/catalog-index.js';
|
|
94
96
|
export { KnowledgeDatabase, KnowledgeSourceStore, KnowledgeIndexStore, KnowledgeIngest, KnowledgeRetriever, GroundingAssembler, formatKnowledgeGroundingMessage, resolveGroundingQuery, wrapUntrustedKnowledgeBlock, isKnowledgeGroundingMessage, stripKnowledgeGrounding, KnowledgeHitLog, KnowledgePurger, FormatAdapterRegistry, resolveKnowledgePaths, generateKnowledgeDescription, heuristicDescription, scanSecretShapes, hashContent, textAdapter, markdownAdapter, codeAdapter, } from './knowledge/index.js';
|
|
95
97
|
export type { KnowledgeDatabaseOptions, KnowledgePaths, KnowledgeDescribePort, KnowledgeDescribeOptions, KnowledgeDescribeResult, KnowledgeSource, KnowledgeSourceInput, KnowledgeSourcePatch, KnowledgeSourceKind, KnowledgeSourceStatus, KnowledgeSourceSync, KnowledgeSourceError, KnowledgeScopeRef, KnowledgeScopeLevel, KnowledgeIngestOptions, IngestProgressEvent, IngestJobKind, HybridSearchOptions, HybridSearchResult, AutoGroundDecision, GroundingMode, KnowledgeRetrieverOptions, KnowledgeHitRecord, KnowledgeHitStats, PromotionCandidate, PurgeResult, FormatAdapter, KnowledgeChunkDraft, IndexedFileRecord, ChunkHit, } from './knowledge/index.js';
|
|
96
|
-
export { InMemoryMemoryStore, InMemoryConceptGraph, AgentDatabase, SqliteMemoryStore, SqliteWisdomStore, SqliteConceptGraph, createEmbeddingProvider } from './memory/index.js';
|
|
98
|
+
export { InMemoryMemoryStore, InMemoryWisdomStore, InMemoryConceptGraph, AgentDatabase, SqliteMemoryStore, SqliteWisdomStore, SqliteConceptGraph, createEmbeddingProvider } from './memory/index.js';
|
|
97
99
|
export type { AgentDatabaseOptions, SqliteMemoryStoreOptions, SqliteConceptGraphOptions, EmbeddingProvider, EmbeddingConfig } from './memory/index.js';
|
|
98
100
|
export { createEmbeddingProviderFromModels, resolveEmbeddingRuntime, isEmbeddingEnabled, tokenizeKeywordQuery, scoreKeywordFields, } from './memory/index.js';
|
|
99
101
|
export type { MemoryType, MemoryEntry, MemoryQuery, MemoryStats, MemoryStore } from './memory/types.js';
|
|
100
|
-
export type { WisdomEntry, WisdomStore } from './memory/types.js';
|
|
101
|
-
export type { ConceptNode, ConceptEdge, ConceptGraph, ConceptGraphStore } from './memory/types.js';
|
|
102
|
+
export type { WisdomEntry, WisdomStore, WisdomStatus, WisdomOrigin, WisdomKind, WisdomScenario, WisdomEffect, WisdomDerivation, WisdomOutcomes, AdmitWisdomInput, AdmitWisdomResult, WisdomInjectQuery, WisdomInjectPick, WisdomStats, } from './memory/types.js';
|
|
103
|
+
export type { ConceptKind, ConceptRelationType, ConceptStatus, EvidenceClass, EdgeBasis, ConceptNode, ConceptEdge, ConceptGraph, MergeCandidate, AdmitConceptInput, AdmitConceptResult, AdmitEdgeInput, AdmitEdgeResult, ConceptGateReason, SpreadingActivateOptions, ActivatedGraph, ConceptGraphStats, DecayResult, ConceptGraphStore, } from './memory/types.js';
|
|
104
|
+
export { evaluateConceptGate, licenseEdge, conceptualizeAndAdmit, parseConceptualizerJson, DEFAULT_EDGE_DECAY_PER_DAY, hebbianStrengthen, nextEdgeStrength, } from './memory/index.js';
|
|
102
105
|
export type { Planner, Reflector, AgentState, AgentStats, Plan, PlanStep, StepResult, ExecutionRecord, Assessment, Pattern, } from './collaboration/orchestration/cognitive-loop.js';
|
|
103
106
|
export type { SessionData, SessionLifecycleMeta, SessionLifecycleStatus, MemoryExtractionStatus } from './session/types.js';
|
|
104
107
|
export { SessionAwareRunner } from './run/runner.js';
|
package/dist/harness/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export { createWebSearchTool } from './extension/plugin-ecosystem/tools/web-sear
|
|
|
11
11
|
export { createSessionHistoryPort, resolveHistoryAccess, } from './session/history/index.js';
|
|
12
12
|
export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTool, } from './extension/plugin-ecosystem/tools/session-history.js';
|
|
13
13
|
// ── Capabilities(公用能力;横切,不计入业务领域口径) ──
|
|
14
|
-
export { createSummaryPort, applyToolOutputGate, createDefaultSummaryPolicies, resolveSummaryModel, getToolSummaryBinding, createCompactEngine, createMemorySummaryCache,
|
|
14
|
+
export { createSummaryPort, applyToolOutputGate, createDefaultSummaryPolicies, resolveSummaryModel, getToolSummaryBinding, createCompactEngine, createMemorySummaryCache, } from './context/capabilities/index.js';
|
|
15
|
+
export { createDefaultDocumentPort, createDefaultBackends, createDocumentPortFromConfig, DocumentExtractError, isDocumentExtractError, } from './capabilities/document/index.js';
|
|
15
16
|
// ── Agent Building ──
|
|
16
17
|
export { AgentBuilder, createAgent, isSubsystemAllowed, discoverSubsystemSpecs } from './agent/builder.js';
|
|
17
18
|
export { setRunTelemetryFactory, getRunTelemetryFactory } from './observability/run-telemetry.js';
|
|
@@ -74,8 +75,9 @@ export { KnowledgeDatabase, KnowledgeSourceStore, KnowledgeIndexStore, Knowledge
|
|
|
74
75
|
// ── Concurrency ──
|
|
75
76
|
// (exported from concurrency/index.ts)
|
|
76
77
|
// ── Memory ──
|
|
77
|
-
export { InMemoryMemoryStore, InMemoryConceptGraph, AgentDatabase, SqliteMemoryStore, SqliteWisdomStore, SqliteConceptGraph, createEmbeddingProvider } from './memory/index.js';
|
|
78
|
+
export { InMemoryMemoryStore, InMemoryWisdomStore, InMemoryConceptGraph, AgentDatabase, SqliteMemoryStore, SqliteWisdomStore, SqliteConceptGraph, createEmbeddingProvider } from './memory/index.js';
|
|
78
79
|
export { createEmbeddingProviderFromModels, resolveEmbeddingRuntime, isEmbeddingEnabled, tokenizeKeywordQuery, scoreKeywordFields, } from './memory/index.js';
|
|
80
|
+
export { evaluateConceptGate, licenseEdge, conceptualizeAndAdmit, parseConceptualizerJson, DEFAULT_EDGE_DECAY_PER_DAY, hebbianStrengthen, nextEdgeStrength, } from './memory/index.js';
|
|
79
81
|
// ── Runner ──
|
|
80
82
|
export { SessionAwareRunner } from './run/runner.js';
|
|
81
83
|
// ── Tool effect isolation (I5) ──
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* 无 adapter 的类型跳过并记 skipped,不挡整库。
|
|
2
|
+
* Axure 导出侧车(data.js / document.js):压缩伪代码,无检索价值。
|
|
3
|
+
* **只认内容标记**,不按文件名一刀切——业务项目的 data.js 仍须正常索引。
|
|
5
4
|
*/
|
|
5
|
+
export declare function looksLikeAxureExportJs(head: string): boolean;
|
|
6
6
|
export interface KnowledgeChunkDraft {
|
|
7
7
|
ordinal: number;
|
|
8
8
|
text: string;
|
|
@@ -10,6 +10,8 @@ export interface KnowledgeChunkDraft {
|
|
|
10
10
|
endLine: number;
|
|
11
11
|
/** 符号名(代码启发式;Markdown 为标题;可选) */
|
|
12
12
|
symbol?: string;
|
|
13
|
+
/** 预计算 FTS token 流(worker 产出;写库直用,避免主线程 CJK 分词) */
|
|
14
|
+
ftsToks?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface FormatAdapter {
|
|
15
17
|
id: string;
|
|
@@ -45,8 +47,9 @@ export declare function chunkCodeBySymbols(content: string, opts?: {
|
|
|
45
47
|
/** 代码:符号启发式(函数/类/接口);失败/无符号则行窗 */
|
|
46
48
|
export declare const codeAdapter: FormatAdapter;
|
|
47
49
|
/**
|
|
48
|
-
* HTML
|
|
49
|
-
*
|
|
50
|
+
* HTML:先抽正文再切块。
|
|
51
|
+
* 本地/外源统一走 htmlToStructuredText——Axure 等导出页含大段 script/style,
|
|
52
|
+
* 若 raw HTML 直接进 markdown 切块 + FTS,会产生海量 token 并写爆索引。
|
|
50
53
|
*/
|
|
51
54
|
export declare const htmlAdapter: FormatAdapter;
|
|
52
55
|
export declare class FormatAdapterRegistry {
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 无 adapter 的类型跳过并记 skipped,不挡整库。
|
|
5
5
|
*/
|
|
6
|
+
import { htmlToStructuredText } from './html.js';
|
|
7
|
+
/**
|
|
8
|
+
* Axure 导出侧车(data.js / document.js):压缩伪代码,无检索价值。
|
|
9
|
+
* **只认内容标记**,不按文件名一刀切——业务项目的 data.js 仍须正常索引。
|
|
10
|
+
*/
|
|
11
|
+
export function looksLikeAxureExportJs(head) {
|
|
12
|
+
return head.includes('$axure.loadCurrentPage') || head.includes('$axure.utils.Browser');
|
|
13
|
+
}
|
|
6
14
|
/** 默认噪音目录(对齐 file-search) */
|
|
7
15
|
export const IGNORED_DIRS = new Set([
|
|
8
16
|
'node_modules',
|
|
@@ -36,6 +44,8 @@ function pushParagraphs(content, startLineBase, maxChars) {
|
|
|
36
44
|
const chunks = [];
|
|
37
45
|
const lines = content.split('\n');
|
|
38
46
|
let buf = [];
|
|
47
|
+
/** 当前 buf 的近似长度(避免每行 join 整段) */
|
|
48
|
+
let bufLen = 0;
|
|
39
49
|
let bufStart = startLineBase;
|
|
40
50
|
let ordinal = 0;
|
|
41
51
|
const flush = (endLine) => {
|
|
@@ -43,24 +53,40 @@ function pushParagraphs(content, startLineBase, maxChars) {
|
|
|
43
53
|
if (text) {
|
|
44
54
|
chunks.push({
|
|
45
55
|
ordinal: ordinal++,
|
|
46
|
-
text
|
|
56
|
+
text,
|
|
47
57
|
startLine: bufStart,
|
|
48
58
|
endLine,
|
|
49
59
|
});
|
|
50
60
|
}
|
|
51
61
|
buf = [];
|
|
62
|
+
bufLen = 0;
|
|
52
63
|
};
|
|
53
64
|
for (let i = 0; i < lines.length; i++) {
|
|
54
|
-
|
|
65
|
+
let line = lines[i];
|
|
55
66
|
const absLine = startLineBase + i;
|
|
67
|
+
// 超长单行(压缩 HTML / 导出页)按 maxChars 切开,禁止 slice 丢弃尾部
|
|
68
|
+
while (line.length > maxChars) {
|
|
69
|
+
if (bufLen > 0)
|
|
70
|
+
flush(absLine - 1);
|
|
71
|
+
const head = line.slice(0, maxChars);
|
|
72
|
+
chunks.push({
|
|
73
|
+
ordinal: ordinal++,
|
|
74
|
+
text: head,
|
|
75
|
+
startLine: absLine,
|
|
76
|
+
endLine: absLine,
|
|
77
|
+
});
|
|
78
|
+
line = line.slice(maxChars);
|
|
79
|
+
}
|
|
80
|
+
// 先断再装:禁止「加完一行才 flush」导致 chunk 超 maxChars 一整行
|
|
81
|
+
if (buf.length > 0 && bufLen + line.length + 1 > maxChars) {
|
|
82
|
+
flush(absLine - 1);
|
|
83
|
+
}
|
|
56
84
|
if (buf.length === 0)
|
|
57
85
|
bufStart = absLine;
|
|
58
86
|
buf.push(line);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
else if (joined.length >= maxChars) {
|
|
87
|
+
bufLen += line.length + 1;
|
|
88
|
+
const isBlank = line.trim() === '';
|
|
89
|
+
if (isBlank && bufLen >= MIN_CHUNK_CHARS) {
|
|
64
90
|
flush(absLine);
|
|
65
91
|
}
|
|
66
92
|
}
|
|
@@ -321,7 +347,8 @@ export const codeAdapter = {
|
|
|
321
347
|
'.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs',
|
|
322
348
|
'.py', '.go', '.rs', '.java', '.kt', '.c', '.cc', '.cpp', '.h', '.hpp',
|
|
323
349
|
'.rb', '.php', '.cs', '.swift', '.scala', '.sh', '.bash', '.ps1',
|
|
324
|
-
|
|
350
|
+
// .html/.htm/.xhtml 归 htmlAdapter(文档进向量);勿再声明在此
|
|
351
|
+
'.sql', '.css', '.scss', '.vue', '.svelte',
|
|
325
352
|
],
|
|
326
353
|
chunk(content) {
|
|
327
354
|
const bySymbol = chunkCodeBySymbols(content);
|
|
@@ -351,15 +378,18 @@ export const codeAdapter = {
|
|
|
351
378
|
},
|
|
352
379
|
};
|
|
353
380
|
/**
|
|
354
|
-
* HTML
|
|
355
|
-
*
|
|
381
|
+
* HTML:先抽正文再切块。
|
|
382
|
+
* 本地/外源统一走 htmlToStructuredText——Axure 等导出页含大段 script/style,
|
|
383
|
+
* 若 raw HTML 直接进 markdown 切块 + FTS,会产生海量 token 并写爆索引。
|
|
356
384
|
*/
|
|
357
385
|
export const htmlAdapter = {
|
|
358
386
|
id: 'html',
|
|
359
387
|
extensions: ['.html', '.htm', '.xhtml'],
|
|
360
388
|
mimes: ['text/html', 'application/xhtml+xml'],
|
|
361
389
|
chunk(content, path) {
|
|
362
|
-
|
|
390
|
+
const looksRaw = /<\s*[a-z!/?]/i.test(content);
|
|
391
|
+
const text = looksRaw ? htmlToStructuredText(content) : content;
|
|
392
|
+
return markdownAdapter.chunk(text, path);
|
|
363
393
|
},
|
|
364
394
|
};
|
|
365
395
|
export class FormatAdapterRegistry {
|
|
@@ -371,10 +401,20 @@ export class FormatAdapterRegistry {
|
|
|
371
401
|
}
|
|
372
402
|
register(adapter) {
|
|
373
403
|
for (const ext of adapter.extensions) {
|
|
374
|
-
|
|
404
|
+
const key = ext.toLowerCase();
|
|
405
|
+
const prev = this.byExt.get(key);
|
|
406
|
+
if (prev && prev.id !== adapter.id) {
|
|
407
|
+
throw new Error(`format adapter extension conflict: ${key} owned by ${prev.id}, cannot register ${adapter.id}`);
|
|
408
|
+
}
|
|
409
|
+
this.byExt.set(key, adapter);
|
|
375
410
|
}
|
|
376
411
|
for (const mime of adapter.mimes ?? []) {
|
|
377
|
-
|
|
412
|
+
const key = mime.toLowerCase();
|
|
413
|
+
const prev = this.byMime.get(key);
|
|
414
|
+
if (prev && prev.id !== adapter.id) {
|
|
415
|
+
throw new Error(`format adapter mime conflict: ${key} owned by ${prev.id}, cannot register ${adapter.id}`);
|
|
416
|
+
}
|
|
417
|
+
this.byMime.set(key, adapter);
|
|
378
418
|
}
|
|
379
419
|
}
|
|
380
420
|
/**
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KnowledgeClient — Gateway 侧 RPC(不打开 knowledge.db)
|
|
3
|
+
*/
|
|
4
|
+
export interface KnowledgeClientOptions {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
token: string;
|
|
7
|
+
/**
|
|
8
|
+
* HTTP 超时。默认 30s:索引期 FTS/写库会让 Service 短暂繁忙,
|
|
9
|
+
* 5s 会把正常的「忙」误报成 timeout/503。仍应通过分批让出保证 /health 可达。
|
|
10
|
+
*/
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
/**
|
|
13
|
+
* 只读 API 超时(search/list/stats)。默认 12s:
|
|
14
|
+
* 查询走 Query Worker,应快速失败并由 UI 重试,而不是拖到 30s。
|
|
15
|
+
*/
|
|
16
|
+
readTimeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare class KnowledgeClient {
|
|
19
|
+
private readonly opts;
|
|
20
|
+
constructor(opts: KnowledgeClientOptions);
|
|
21
|
+
get baseUrl(): string;
|
|
22
|
+
get token(): string;
|
|
23
|
+
private request;
|
|
24
|
+
health(): Promise<{
|
|
25
|
+
ok: boolean;
|
|
26
|
+
service: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}>;
|
|
29
|
+
ready(): Promise<{
|
|
30
|
+
ready: boolean;
|
|
31
|
+
sqliteVec: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
ensurePrincipal(localAgentId: string, displayName?: string): Promise<unknown>;
|
|
34
|
+
listSources(opts?: {
|
|
35
|
+
scopeLevel?: 'global' | 'project' | 'session';
|
|
36
|
+
projectKey?: string;
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
39
|
+
createSource(input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
40
|
+
patchSource(sourceId: string, patch: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
41
|
+
deleteSource(sourceId: string): Promise<unknown>;
|
|
42
|
+
reindex(sourceId: string): Promise<unknown>;
|
|
43
|
+
/** 按路径 / 筛选强制重解析(中止态自动 resume) */
|
|
44
|
+
reprocess(sourceId: string, opts: {
|
|
45
|
+
paths?: string[];
|
|
46
|
+
filter?: {
|
|
47
|
+
status?: string;
|
|
48
|
+
ext?: string;
|
|
49
|
+
q?: string;
|
|
50
|
+
};
|
|
51
|
+
}): Promise<{
|
|
52
|
+
queued: number;
|
|
53
|
+
alreadyActive: number;
|
|
54
|
+
cleanedNonFiles: number;
|
|
55
|
+
resumed: boolean;
|
|
56
|
+
rejected: number;
|
|
57
|
+
}>;
|
|
58
|
+
search(agentId: string, q: string, opts?: {
|
|
59
|
+
sessionId?: string;
|
|
60
|
+
limit?: number;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
hits: unknown[];
|
|
63
|
+
keywordHits: number;
|
|
64
|
+
vectorHits: number;
|
|
65
|
+
}>;
|
|
66
|
+
/** turn 级自动召回分档(与 Search Worker `autoGround` 同源) */
|
|
67
|
+
autoGround(agentId: string, q: string, opts?: {
|
|
68
|
+
sessionId?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
recall?: 'off' | 'hint' | 'hybrid' | 'inject';
|
|
71
|
+
}): Promise<{
|
|
72
|
+
mode: 'inject' | 'hint' | 'none';
|
|
73
|
+
hits: unknown[];
|
|
74
|
+
hint?: string;
|
|
75
|
+
reason: string;
|
|
76
|
+
coverage: number;
|
|
77
|
+
scoreFloor: number;
|
|
78
|
+
}>;
|
|
79
|
+
stats(agentId: string): Promise<Record<string, number>>;
|
|
80
|
+
visibility(agentId: string, op: 'assignProject' | 'unassignProject' | 'hide' | 'unhide', body: {
|
|
81
|
+
projectKey?: string;
|
|
82
|
+
sourceId?: string;
|
|
83
|
+
}): Promise<unknown>;
|
|
84
|
+
listProjects(): Promise<Array<Record<string, unknown>>>;
|
|
85
|
+
createProject(input: {
|
|
86
|
+
projectKey: string;
|
|
87
|
+
displayName?: string;
|
|
88
|
+
visibility?: string;
|
|
89
|
+
}): Promise<Record<string, unknown>>;
|
|
90
|
+
deleteProject(projectKey: string): Promise<unknown>;
|
|
91
|
+
getSource(sourceId: string): Promise<Record<string, unknown>>;
|
|
92
|
+
/** 中止源任务;省略 sourceId = 中止本 Gateway 全部源 */
|
|
93
|
+
abort(sourceId?: string): Promise<unknown>;
|
|
94
|
+
/** 继续源任务;省略 sourceId = 继续本 Gateway 全部源 */
|
|
95
|
+
resume(sourceId?: string): Promise<unknown>;
|
|
96
|
+
listFiles(sourceId: string): Promise<Array<Record<string, unknown>>>;
|
|
97
|
+
listFilesPaged(sourceId: string, opts?: {
|
|
98
|
+
status?: 'indexed' | 'skipped' | 'error' | 'all';
|
|
99
|
+
ext?: string;
|
|
100
|
+
q?: string;
|
|
101
|
+
page?: number;
|
|
102
|
+
pageSize?: number;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
items: Array<Record<string, unknown>>;
|
|
105
|
+
total: number;
|
|
106
|
+
page: number;
|
|
107
|
+
pageSize: number;
|
|
108
|
+
statusCounts: {
|
|
109
|
+
indexed: number;
|
|
110
|
+
skipped: number;
|
|
111
|
+
error: number;
|
|
112
|
+
};
|
|
113
|
+
extCounts: Array<{
|
|
114
|
+
ext: string;
|
|
115
|
+
n: number;
|
|
116
|
+
}>;
|
|
117
|
+
}>;
|
|
118
|
+
catalog(agentId: string): Promise<unknown[]>;
|
|
119
|
+
promotionCandidates(): Promise<unknown[]>;
|
|
120
|
+
describeSource(sourceId: string): Promise<{
|
|
121
|
+
generatedDescription: string;
|
|
122
|
+
source: string;
|
|
123
|
+
}>;
|
|
124
|
+
listChunks(agentId: string, sourceId: string, path: string): Promise<Array<{
|
|
125
|
+
id: string;
|
|
126
|
+
text: string;
|
|
127
|
+
startLine: number;
|
|
128
|
+
endLine: number;
|
|
129
|
+
ordinal: number;
|
|
130
|
+
path: string;
|
|
131
|
+
}>>;
|
|
132
|
+
read(agentId: string, body: {
|
|
133
|
+
chunkId?: string;
|
|
134
|
+
sourceId?: string;
|
|
135
|
+
path?: string;
|
|
136
|
+
}): Promise<{
|
|
137
|
+
found: boolean;
|
|
138
|
+
path?: string;
|
|
139
|
+
startLine?: number;
|
|
140
|
+
endLine?: number;
|
|
141
|
+
text?: string;
|
|
142
|
+
chunkCount?: number;
|
|
143
|
+
}>;
|
|
144
|
+
getVisibility(agentId: string): Promise<{
|
|
145
|
+
assignedProjects: string[];
|
|
146
|
+
hiddenSourceIds: string[];
|
|
147
|
+
}>;
|
|
148
|
+
sessionVisibility(agentId: string, sessionId: string): Promise<Array<Record<string, unknown>>>;
|
|
149
|
+
setSessionVisibility(agentId: string, item: {
|
|
150
|
+
sessionId: string;
|
|
151
|
+
targetType: 'project' | 'source';
|
|
152
|
+
targetId: string;
|
|
153
|
+
op: 'include' | 'exclude';
|
|
154
|
+
}): Promise<unknown>;
|
|
155
|
+
replaceSessionVisibility(agentId: string, sessionId: string, items: Array<{
|
|
156
|
+
targetType: 'project' | 'source';
|
|
157
|
+
targetId: string;
|
|
158
|
+
op: 'include' | 'exclude';
|
|
159
|
+
}>): Promise<unknown>;
|
|
160
|
+
clearSessionVisibility(agentId: string, sessionId: string, target?: {
|
|
161
|
+
targetType: 'project' | 'source';
|
|
162
|
+
targetId: string;
|
|
163
|
+
}): Promise<unknown>;
|
|
164
|
+
jobControl(sourceId: string): Promise<{
|
|
165
|
+
aborted: boolean;
|
|
166
|
+
jobsQueued: number;
|
|
167
|
+
jobsRunning: number;
|
|
168
|
+
jobsCancelled: number;
|
|
169
|
+
embedMissing: boolean;
|
|
170
|
+
canAbort: boolean;
|
|
171
|
+
canResume: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
jobs(query?: {
|
|
174
|
+
sourceId?: string;
|
|
175
|
+
status?: string;
|
|
176
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* AutoGroundPort 适配器 — Gateway 侧 turn 级 grounding 走 Knowledge Service。
|
|
180
|
+
* 不打开 knowledge.db;分档逻辑在 Search Worker 的 KnowledgeRetriever.autoGround。
|
|
181
|
+
*/
|
|
182
|
+
export declare class ClientKnowledgeGrounding {
|
|
183
|
+
private readonly client;
|
|
184
|
+
/** 缺省 recall(agents[].knowledge.recall / 全局);请求可覆盖 */
|
|
185
|
+
private readonly defaultRecall?;
|
|
186
|
+
constructor(client: KnowledgeClient,
|
|
187
|
+
/** 缺省 recall(agents[].knowledge.recall / 全局);请求可覆盖 */
|
|
188
|
+
defaultRecall?: "off" | "hint" | "hybrid" | "inject" | undefined);
|
|
189
|
+
autoGround(query: string, opts: {
|
|
190
|
+
agentId: string;
|
|
191
|
+
sessionId?: string;
|
|
192
|
+
limit?: number;
|
|
193
|
+
tenantId?: string;
|
|
194
|
+
gatewayId?: string;
|
|
195
|
+
recall?: 'off' | 'hint' | 'hybrid' | 'inject';
|
|
196
|
+
}): Promise<import('./retriever.js').AutoGroundDecision>;
|
|
197
|
+
}
|