qlogicagent 2.18.3 → 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 +3 -3
- package/dist/cli.js +1 -1
- package/dist/index.js +458 -440
- package/dist/orchestration.js +1 -1
- package/dist/skills/mcp/astraclaw-native-mcp-server.js +6 -6
- 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/protocol/methods.d.ts +0 -26
- 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/runtime/community/community-consent-client.d.ts +0 -21
- package/dist/types/runtime/hooks/memory-hooks.d.ts +6 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +9 -7
- package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +0 -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/ports/memory-provider.d.ts +21 -0
- package/dist/types/skills/memory/fts-segment.d.ts +20 -0
- package/dist/types/skills/memory/local-memory-provider.d.ts +52 -4
- package/dist/types/skills/memory/local-store-records.d.ts +6 -1
- package/dist/types/skills/memory/local-store.d.ts +61 -10
- package/dist/types/skills/memory/memdir.d.ts +10 -5
- 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/package.json +3 -2
- package/dist/types/cli/tool-bootstrap-community-registration.d.ts +0 -9
- 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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - Without embedding: FTS-only search (still useful for exact/keyword matches)
|
|
10
10
|
*/
|
|
11
11
|
import type { MemoryProvider, MemorySearchResult, MemorySearchOptions, MemoryIngestMessage, MemoryIngestOptions } from "../../protocol/wire/index.js";
|
|
12
|
-
import type { MemoryClaimRecord, MemoryConflictRecord, MemoryUpdateInput, SqliteDatabase } from "./local-store.js";
|
|
12
|
+
import type { MemoryClaimRecord, MemoryConflictRecord, MemoryProposalRecord, MemoryUpdateInput, SqliteDatabase } from "./local-store.js";
|
|
13
13
|
import { type AdoptedAttachment } from "./memory-attachment-store.js";
|
|
14
14
|
import { type LocalEmbeddingConfig } from "./local-embedding.js";
|
|
15
15
|
import { type ExtractedMemoryItem, type MemoryConsolidationResult } from "./memory-consolidation.js";
|
|
@@ -32,6 +32,10 @@ export declare class LocalMemoryProvider implements MemoryProvider {
|
|
|
32
32
|
private attachmentStore;
|
|
33
33
|
private userIdPrefix;
|
|
34
34
|
private dbPath;
|
|
35
|
+
private attachmentsDir;
|
|
36
|
+
/** Active embedding model id — stamped onto stored vectors and used to skip
|
|
37
|
+
* incomparable vectors at search time (model switch = silent noise otherwise). */
|
|
38
|
+
private embeddingModelId;
|
|
35
39
|
/** One-shot flag: the embedding-degradation trace is logged once per provider instance. */
|
|
36
40
|
private embeddingFailureLogged;
|
|
37
41
|
constructor(config: LocalMemoryProviderConfig);
|
|
@@ -79,12 +83,47 @@ export declare class LocalMemoryProvider implements MemoryProvider {
|
|
|
79
83
|
}>;
|
|
80
84
|
remove(memoryId: string): Promise<boolean>;
|
|
81
85
|
update(memoryId: string, input: MemoryUpdateInput): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Prompt-injection screen for L2 writes. The memory-tool path already checks
|
|
88
|
+
* this, but implicit extraction / distillation / RPC ingestion used to write
|
|
89
|
+
* UNSCREENED — recalled memories land in a system message, so this is the
|
|
90
|
+
* last write-side gate. Rejections are traced, never silent.
|
|
91
|
+
*/
|
|
92
|
+
private screenUnsafeItems;
|
|
82
93
|
/**
|
|
83
94
|
* Commit extracted memory items through the single consolidation pipeline.
|
|
84
95
|
*/
|
|
85
96
|
ingestExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationResult>;
|
|
86
97
|
observeExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationResult>;
|
|
87
98
|
proposeExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Consume the pending-proposal backlog (the "proposals black hole" fix).
|
|
101
|
+
*
|
|
102
|
+
* Trust ladder, mirroring V3's graduated autonomy:
|
|
103
|
+
* - CORROBORATED facts — the same fact proposed again from an independent
|
|
104
|
+
* context (different session or different source) — commit automatically,
|
|
105
|
+
* with a trace. Evidence, not a confidence score, is the auto gate.
|
|
106
|
+
* - Feedback-distillation proposals commit alone: their >=2-evidence bar
|
|
107
|
+
* was already enforced upstream (idempotency-keyed sweep, §10).
|
|
108
|
+
* - dream-source proposals never commit alone; they only corroborate.
|
|
109
|
+
* - Everything else waits for corroboration and EXPIRES after the TTL —
|
|
110
|
+
* visibly (status=expired), not by silent deletion.
|
|
111
|
+
*/
|
|
112
|
+
consumePendingProposals(userId: string, opts?: {
|
|
113
|
+
now?: number;
|
|
114
|
+
ttlMs?: number;
|
|
115
|
+
maxCommitsPerPass?: number;
|
|
116
|
+
}): Promise<{
|
|
117
|
+
committed: number;
|
|
118
|
+
merged: number;
|
|
119
|
+
expiredIds: string[];
|
|
120
|
+
pendingLeft: number;
|
|
121
|
+
}>;
|
|
122
|
+
/** Proposals for the memory candidate surface: pending (default) or the
|
|
123
|
+
* read-only expired history. Other statuses stay internal. */
|
|
124
|
+
listPendingProposals(userId: string, limit?: number, status?: "pending" | "expired"): MemoryProposalRecord[];
|
|
125
|
+
/** Resolve one pending proposal from the UI: confirm -> commit now; dismiss -> rejected. */
|
|
126
|
+
resolveProposal(userId: string, proposalId: string, action: "confirm" | "dismiss"): Promise<boolean>;
|
|
88
127
|
listClaims(userId: string): MemoryClaimRecord[];
|
|
89
128
|
listConflicts(userId: string): MemoryConflictRecord[];
|
|
90
129
|
/**
|
|
@@ -106,7 +145,7 @@ export declare class LocalMemoryProvider implements MemoryProvider {
|
|
|
106
145
|
* Trigger memory decay - multi-strategy (temporal + staleness + noise).
|
|
107
146
|
* Also enforces capacity limit and runs vacuum for space reclamation.
|
|
108
147
|
*/
|
|
109
|
-
triggerDecay(userId: string
|
|
148
|
+
triggerDecay(userId: string): Promise<{
|
|
110
149
|
decayed: number;
|
|
111
150
|
}>;
|
|
112
151
|
/**
|
|
@@ -244,7 +283,8 @@ export declare class LocalMemoryProvider implements MemoryProvider {
|
|
|
244
283
|
metadata?: Record<string, unknown>;
|
|
245
284
|
}>;
|
|
246
285
|
/**
|
|
247
|
-
* Health check
|
|
286
|
+
* Health check — a real probe, not a constant: reports the actual active row
|
|
287
|
+
* count and turns DB access errors into status "error" instead of "healthy".
|
|
248
288
|
*/
|
|
249
289
|
health(): Promise<{
|
|
250
290
|
status: string;
|
|
@@ -256,7 +296,15 @@ export declare class LocalMemoryProvider implements MemoryProvider {
|
|
|
256
296
|
*/
|
|
257
297
|
count(userId: string): number;
|
|
258
298
|
/**
|
|
259
|
-
* Reset
|
|
299
|
+
* Reset ALL long-term memory state for a user: every SQLite table (memories,
|
|
300
|
+
* observations, proposals, claims, conflicts, attachments index, profile KV),
|
|
301
|
+
* the attachment files on disk, and the task-distillation working stores
|
|
302
|
+
* (candidate prompts are stored in clear text — they are memory-domain data
|
|
303
|
+
* and must not survive a "clear my memory"). promotion-proposals.json is
|
|
304
|
+
* deliberately KEPT: it is the audit trail of the user's own promote/demote
|
|
305
|
+
* decisions and the demote map for already-created skills.
|
|
306
|
+
*
|
|
307
|
+
* Returns the number of memory rows removed (wire-compat with the old shape).
|
|
260
308
|
*/
|
|
261
309
|
resetUser(userId: string): Promise<number>;
|
|
262
310
|
/**
|
|
@@ -38,6 +38,9 @@ export interface MemoryInsertInput {
|
|
|
38
38
|
eventDate?: string;
|
|
39
39
|
tags?: string[];
|
|
40
40
|
embedding?: Float32Array;
|
|
41
|
+
/** Provenance of `embedding` (model id). Vectors from different models are not
|
|
42
|
+
* comparable; search skips rows whose model/dims mismatch the query's. */
|
|
43
|
+
embeddingModel?: string;
|
|
41
44
|
}
|
|
42
45
|
export interface MemoryUpdateInput {
|
|
43
46
|
text?: string;
|
|
@@ -47,6 +50,8 @@ export interface MemoryUpdateInput {
|
|
|
47
50
|
eventDate?: string;
|
|
48
51
|
tags?: string[];
|
|
49
52
|
embedding?: Float32Array | null;
|
|
53
|
+
/** Provenance of the replacement embedding (see MemoryInsertInput). */
|
|
54
|
+
embeddingModel?: string;
|
|
50
55
|
}
|
|
51
56
|
export interface MemorySearchHit {
|
|
52
57
|
id: string;
|
|
@@ -97,7 +102,7 @@ export interface MemoryAtlasResult {
|
|
|
97
102
|
}
|
|
98
103
|
export type MemorySourceKind = "manual" | "explicit" | "document" | "image" | "video" | "auto" | "turn" | "dream" | "agent" | "feedback";
|
|
99
104
|
export type MemoryClaimStatus = "active" | "superseded" | "conflicted" | "archived" | "pending_confirmation";
|
|
100
|
-
export type MemoryProposalStatus = "pending" | "accepted" | "merged" | "conflicted" | "rejected";
|
|
105
|
+
export type MemoryProposalStatus = "pending" | "accepted" | "merged" | "conflicted" | "rejected" | "expired";
|
|
101
106
|
export interface MemoryObservationInput {
|
|
102
107
|
userId: string;
|
|
103
108
|
text: string;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - memories_fts: FTS5 full-text index for keyword search
|
|
13
13
|
* - profiles: user profile KV (future)
|
|
14
14
|
*/
|
|
15
|
-
import type { MemoryAtlasResult, MemoryClaimInput, MemoryClaimRecord, MemoryClaimStatus, MemoryConflictRecord, MemoryInsertInput, MemoryObservationInput, MemoryProposalInput, MemoryProposalStatus, MemoryRecord, MemorySearchHit, MemoryUpdateInput, SqliteDatabase } from "./local-store-records.js";
|
|
15
|
+
import type { MemoryAtlasResult, MemoryClaimInput, MemoryClaimRecord, MemoryClaimStatus, MemoryConflictRecord, MemoryInsertInput, MemoryObservationInput, MemoryProposalInput, MemoryProposalRecord, MemoryProposalStatus, MemoryRecord, MemorySearchHit, MemoryUpdateInput, SqliteDatabase } from "./local-store-records.js";
|
|
16
16
|
export { resolveMemoryDbPath } from "./memory-db-path.js";
|
|
17
17
|
export type { MemoryAtlasBucket, MemoryAtlasCluster, MemoryAtlasResult, MemoryAtlasWindowCursor, MemoryAttachmentRef, MemoryClaimInput, MemoryClaimRecord, MemoryClaimStatus, MemoryConflictRecord, MemoryInsertInput, MemoryObservationInput, MemoryObservationRecord, MemoryProposalInput, MemoryProposalRecord, MemoryProposalStatus, MemoryRecord, MemorySearchHit, MemorySourceKind, MemoryUpdateInput, SqliteDatabase, SqliteStatement, } from "./local-store-records.js";
|
|
18
18
|
/** Full attachment index row (DB-backed; file bytes live on disk under the attachments dir). */
|
|
@@ -41,7 +41,11 @@ export interface MemoryAttachmentInsert {
|
|
|
41
41
|
}
|
|
42
42
|
export declare class LocalMemoryStore {
|
|
43
43
|
private db;
|
|
44
|
+
/** Stamped onto rows whose embedding arrives without explicit provenance
|
|
45
|
+
* (the consolidation pipeline passes bare vectors). Set by the provider. */
|
|
46
|
+
private defaultEmbeddingModel;
|
|
44
47
|
constructor(db: SqliteDatabase);
|
|
48
|
+
setDefaultEmbeddingModel(model: string): void;
|
|
45
49
|
private initSchema;
|
|
46
50
|
/**
|
|
47
51
|
* Insert a new memory record. Returns the generated ID.
|
|
@@ -51,15 +55,23 @@ export declare class LocalMemoryStore {
|
|
|
51
55
|
* Full-text search using FTS5. Returns ranked results.
|
|
52
56
|
*/
|
|
53
57
|
searchFts(query: string, userId: string, limit?: number): MemorySearchHit[];
|
|
58
|
+
/** One-shot flag: embedding provenance mismatches are traced once per store instance. */
|
|
59
|
+
private embeddingMismatchLogged;
|
|
54
60
|
/**
|
|
55
61
|
* Vector similarity search using pre-computed embeddings.
|
|
56
62
|
* Performs brute-force cosine similarity (efficient for <100k records per user).
|
|
63
|
+
*
|
|
64
|
+
* Rows whose embedding provenance (dims, and model when both sides are known)
|
|
65
|
+
* differs from the query's are SKIPPED, not scored: cosine between vectors of
|
|
66
|
+
* different models/dims is numeric noise, and truncated dot products silently
|
|
67
|
+
* corrupt ranking. Legacy rows (no provenance columns) are accepted when their
|
|
68
|
+
* dimension happens to match — dropping them all would blank historical recall.
|
|
57
69
|
*/
|
|
58
|
-
searchVector(queryEmbedding: Float32Array, userId: string, limit?: number, minScore?: number): MemorySearchHit[];
|
|
70
|
+
searchVector(queryEmbedding: Float32Array, userId: string, limit?: number, minScore?: number, expectedModel?: string): MemorySearchHit[];
|
|
59
71
|
/**
|
|
60
72
|
* Hybrid search: FTS5 + vector similarity, de-duplicated and merged.
|
|
61
73
|
*/
|
|
62
|
-
searchHybrid(query: string, queryEmbedding: Float32Array | null, userId: string, limit?: number): MemorySearchHit[];
|
|
74
|
+
searchHybrid(query: string, queryEmbedding: Float32Array | null, userId: string, limit?: number, expectedModel?: string): MemorySearchHit[];
|
|
63
75
|
/**
|
|
64
76
|
* Get all memories for a user (paginated).
|
|
65
77
|
*/
|
|
@@ -89,7 +101,7 @@ export declare class LocalMemoryStore {
|
|
|
89
101
|
/**
|
|
90
102
|
* Update memory text and bump updatedAt.
|
|
91
103
|
*/
|
|
92
|
-
updateText(id: string, text: string, embedding?: Float32Array): boolean;
|
|
104
|
+
updateText(id: string, text: string, embedding?: Float32Array, embeddingModel?: string): boolean;
|
|
93
105
|
/**
|
|
94
106
|
* Update editable memory fields and bump updatedAt.
|
|
95
107
|
*/
|
|
@@ -120,6 +132,15 @@ export declare class LocalMemoryStore {
|
|
|
120
132
|
* Memories written by the agent but never recalled are likely noise.
|
|
121
133
|
*/
|
|
122
134
|
decayNoiseArchival(userId: string, minAgeDays?: number, maxImportance?: number): number;
|
|
135
|
+
/**
|
|
136
|
+
* Observation retention: memory_observations is an append-only audit trail
|
|
137
|
+
* (every propose/commit writes one) with NO reader of its own — without a
|
|
138
|
+
* retention window it grows forever, the same disease the proposals table
|
|
139
|
+
* had before the consumer existed. Delete rows older than the window that
|
|
140
|
+
* are NOT referenced by any claim's evidence_ids or proposal's
|
|
141
|
+
* observation_ids (referenced rows are live audit evidence and stay).
|
|
142
|
+
*/
|
|
143
|
+
decayObservations(userId: string, retentionDays?: number): number;
|
|
123
144
|
/**
|
|
124
145
|
* Run all decay strategies. Returns total affected count.
|
|
125
146
|
*/
|
|
@@ -205,14 +226,30 @@ export declare class LocalMemoryStore {
|
|
|
205
226
|
* Record an access (for importance/relevance boosting).
|
|
206
227
|
*/
|
|
207
228
|
recordAccess(id: string): void;
|
|
229
|
+
/** Total active memory rows across ALL users (health reporting). */
|
|
230
|
+
countAll(): number;
|
|
208
231
|
/**
|
|
209
232
|
* Get total memory count for a user.
|
|
210
233
|
*/
|
|
211
234
|
count(userId: string, activeOnly?: boolean): number;
|
|
212
235
|
/**
|
|
213
|
-
* Delete
|
|
214
|
-
|
|
215
|
-
|
|
236
|
+
* Delete ALL long-term memory state for a user — every table, not just
|
|
237
|
+
* `memories`. Claims carry entity/predicate/value facts in clear text and
|
|
238
|
+
* observations carry raw conversation excerpts; leaving them behind after a
|
|
239
|
+
* "clear my memory" is a broken privacy promise, not a smaller reset.
|
|
240
|
+
*
|
|
241
|
+
* Returns the attachment rel_paths so the caller can delete the on-disk
|
|
242
|
+
* files (the store only owns the index rows).
|
|
243
|
+
*/
|
|
244
|
+
resetUser(userId: string): {
|
|
245
|
+
memories: number;
|
|
246
|
+
observations: number;
|
|
247
|
+
proposals: number;
|
|
248
|
+
claims: number;
|
|
249
|
+
conflicts: number;
|
|
250
|
+
profiles: number;
|
|
251
|
+
attachmentRelPaths: string[];
|
|
252
|
+
};
|
|
216
253
|
/**
|
|
217
254
|
* Run SQLite VACUUM to reclaim space after deletions/archival.
|
|
218
255
|
* Should be called periodically (e.g. after decay cycles).
|
|
@@ -228,10 +265,13 @@ export declare class LocalMemoryStore {
|
|
|
228
265
|
freePages: number;
|
|
229
266
|
};
|
|
230
267
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
268
|
+
* List the oldest archived memories for cold-storage export. Read-only:
|
|
269
|
+
* purging is a SEPARATE step (purgeMemoriesByIds) the caller performs only
|
|
270
|
+
* after the export has durably landed on disk. The old fused
|
|
271
|
+
* export-then-delete shape destroyed data whenever the caller dropped the
|
|
272
|
+
* return value.
|
|
233
273
|
*/
|
|
234
|
-
|
|
274
|
+
listArchivedForExport(userId: string, maxExport?: number): Array<{
|
|
235
275
|
id: string;
|
|
236
276
|
text: string;
|
|
237
277
|
category: string;
|
|
@@ -240,6 +280,8 @@ export declare class LocalMemoryStore {
|
|
|
240
280
|
archivedAt: number;
|
|
241
281
|
tags: string[];
|
|
242
282
|
}>;
|
|
283
|
+
/** Physically delete memory rows by id (post-export purge step). */
|
|
284
|
+
purgeMemoriesByIds(ids: string[]): number;
|
|
243
285
|
/**
|
|
244
286
|
* Enforce capacity limit: if active memories exceed maxCount,
|
|
245
287
|
* archive the oldest lowest-importance ones.
|
|
@@ -253,6 +295,15 @@ export declare class LocalMemoryStore {
|
|
|
253
295
|
* a duplicate crash-safely (the key survives a worker restart mid-sweep).
|
|
254
296
|
*/
|
|
255
297
|
findProposalByIdempotencyKey(userId: string, idempotencyKey: string): string | null;
|
|
298
|
+
/**
|
|
299
|
+
* List proposals by status (oldest first) — the read side of the proposal
|
|
300
|
+
* consumer. Pending proposals from implicit-extract / feedback / dream used
|
|
301
|
+
* to have NO reader at all: they accumulated forever and never became
|
|
302
|
+
* searchable memories.
|
|
303
|
+
*/
|
|
304
|
+
listProposalsByStatus(userId: string, status: MemoryProposalStatus, limit?: number): MemoryProposalRecord[];
|
|
305
|
+
/** Bulk status transition for the proposal consumer (corroborated / expired). */
|
|
306
|
+
markProposalsStatus(ids: string[], status: MemoryProposalStatus): number;
|
|
256
307
|
updateProposalStatus(id: string, status: MemoryProposalStatus, relatedClaimIds?: string[]): boolean;
|
|
257
308
|
insertClaim(input: MemoryClaimInput): string;
|
|
258
309
|
listClaims(userId: string, statuses?: MemoryClaimStatus[]): MemoryClaimRecord[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Max bytes (UTF-8) for INDEX.md to inject into system prompt
|
|
1
|
+
/** Max bytes (UTF-8) for INDEX.md to inject into system prompt. */
|
|
2
2
|
export declare const INDEX_MAX_CHARS = 12288;
|
|
3
3
|
/** Max lines for INDEX.md injection. */
|
|
4
4
|
export declare const INDEX_MAX_LINES = 200;
|
|
@@ -11,7 +11,7 @@ export declare function getIndexPath(projectRoot: string): string;
|
|
|
11
11
|
/** Global-layer size budget: a cheat-sheet, not a memory store. */
|
|
12
12
|
export declare const USER_INDEX_MAX_CHARS = 2048;
|
|
13
13
|
export declare const USER_INDEX_MAX_LINES = 40;
|
|
14
|
-
/** Full path to the user-level global INDEX.md (
|
|
14
|
+
/** Full path to the user-level global INDEX.md (owner profile scoped). */
|
|
15
15
|
export declare function getUserIndexPath(): string;
|
|
16
16
|
/** Read the global layer for prompt injection, capped by the cheat-sheet budget.
|
|
17
17
|
* Returns null when absent/empty — the section simply doesn't render. */
|
|
@@ -33,10 +33,9 @@ export interface MemdirResult {
|
|
|
33
33
|
/** Current INDEX.md char usage */
|
|
34
34
|
indexUsage?: string;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export { isMemoryContentSafe } from "./memory-tool.js";
|
|
37
37
|
export declare class Memdir {
|
|
38
38
|
private readonly root;
|
|
39
|
-
private indexCache;
|
|
40
39
|
constructor(projectRoot: string);
|
|
41
40
|
/** Get the root directory path of this MEMDIR. */
|
|
42
41
|
getRootPath(): string;
|
|
@@ -97,6 +96,12 @@ export declare class Memdir {
|
|
|
97
96
|
private writeIndex;
|
|
98
97
|
private writeIndexUnlocked;
|
|
99
98
|
private ensureDir;
|
|
100
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Append an entry to the file listing section of INDEX.md (idempotent).
|
|
101
|
+
* Returns whether the entry is present afterwards. On overflow it first
|
|
102
|
+
* tries the same auto-compaction as addToIndex; a false return means the
|
|
103
|
+
* file exists but is INVISIBLE to recall — callers must surface that
|
|
104
|
+
* (the old behavior skipped silently and quietly orphaned topic files).
|
|
105
|
+
*/
|
|
101
106
|
private appendIndexEntry;
|
|
102
107
|
}
|
|
@@ -54,4 +54,11 @@ export declare class MemoryConsolidator {
|
|
|
54
54
|
*/
|
|
55
55
|
private findNearDuplicateMemory;
|
|
56
56
|
}
|
|
57
|
+
/** Containment threshold above which two texts count as the same memory.
|
|
58
|
+
* Exported: the proposal consumer uses the SAME bar to group same-fact proposals. */
|
|
59
|
+
export declare const NEAR_DUPLICATE_CONTAINMENT = 0.82;
|
|
60
|
+
/** Latin/digit words plus CJK character bigrams from normalized text. */
|
|
61
|
+
export declare function dedupTokens(text: string): Set<string>;
|
|
62
|
+
/** True when either side has a digit-bearing token the other side lacks. */
|
|
63
|
+
export declare function digitTokensDiffer(a: Set<string>, b: Set<string>): boolean;
|
|
57
64
|
export declare function sourcePriorityOf(source: string): number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proposal consumer (P0 — the factual-memory half of the promotion ladder).
|
|
3
|
+
*
|
|
4
|
+
* implicit-extract / feedback-distillation / dream all write PROPOSALS
|
|
5
|
+
* (status=pending). Before this module existed nothing ever read them back:
|
|
6
|
+
* the three automatic learning paths burned model calls writing dead rows.
|
|
7
|
+
*
|
|
8
|
+
* Trust ladder — evidence gates autonomy, mirroring the V3 skill-promotion
|
|
9
|
+
* doctrine (automatic only when the data says so; visible; revertible):
|
|
10
|
+
* - CORROBORATED: the same fact proposed >=2 times from independent
|
|
11
|
+
* contexts (different session, or different source) -> auto-commit as
|
|
12
|
+
* source "corroborated" (priority 70, so it actually becomes an active
|
|
13
|
+
* searchable memory — committing with the original implicit-extract
|
|
14
|
+
* priority 40 would just create another pending claim, i.e. the black
|
|
15
|
+
* hole one level deeper).
|
|
16
|
+
* - feedback-distillation proposals commit ALONE: their >=2-evidence bar
|
|
17
|
+
* was already enforced upstream (MIN_EVIDENCE + idempotency key, §10).
|
|
18
|
+
* - dream-tier sources (priority <= 20) never commit alone; they only
|
|
19
|
+
* corroborate facts seen elsewhere.
|
|
20
|
+
* - Everything else waits, and past the TTL flips to status "expired" —
|
|
21
|
+
* a visible terminal state, not a silent delete; the memory surface can
|
|
22
|
+
* still show expired proposals for manual rescue.
|
|
23
|
+
*
|
|
24
|
+
* Pure planning logic — no I/O; the provider executes the plan.
|
|
25
|
+
*/
|
|
26
|
+
import type { MemoryProposalRecord } from "./local-store-records.js";
|
|
27
|
+
import type { ExtractedMemoryItem } from "./memory-consolidation.js";
|
|
28
|
+
/** Uncorroborated proposals older than this flip to "expired". */
|
|
29
|
+
export declare const PROPOSAL_TTL_MS: number;
|
|
30
|
+
/** Independent contexts required for auto-commit. */
|
|
31
|
+
export declare const PROPOSAL_MIN_CORROBORATION = 2;
|
|
32
|
+
/** Idle-pass work cap; the rest stays pending for the next pass. */
|
|
33
|
+
export declare const PROPOSAL_MAX_COMMITS_PER_PASS = 20;
|
|
34
|
+
/** Source stamped on corroborated commits — registered in sourcePriorityOf. */
|
|
35
|
+
export declare const CORROBORATED_SOURCE = "corroborated";
|
|
36
|
+
export interface ProposalCommitGroup {
|
|
37
|
+
proposalIds: string[];
|
|
38
|
+
item: ExtractedMemoryItem;
|
|
39
|
+
/** Source used for the commit (drives claim authority). */
|
|
40
|
+
source: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ProposalConsumptionSummary {
|
|
43
|
+
commitGroups: ProposalCommitGroup[];
|
|
44
|
+
expiredIds: string[];
|
|
45
|
+
}
|
|
46
|
+
export interface ProposalConsumptionOptions {
|
|
47
|
+
now?: number;
|
|
48
|
+
ttlMs?: number;
|
|
49
|
+
maxCommitsPerPass?: number;
|
|
50
|
+
}
|
|
51
|
+
export declare function planProposalConsumption(pending: readonly MemoryProposalRecord[], opts?: ProposalConsumptionOptions): ProposalConsumptionSummary;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { MemoryClaimRecord, MemoryConflictRecord, MemoryRecord } from "./local-store-records.js";
|
|
1
|
+
import type { MemoryClaimRecord, MemoryConflictRecord, MemoryProposalRecord, MemoryRecord } from "./local-store-records.js";
|
|
2
2
|
export declare function rowToRecord(row: unknown): MemoryRecord;
|
|
3
3
|
export declare function rowToClaimRecord(row: unknown): MemoryClaimRecord;
|
|
4
|
+
export declare function rowToProposalRecord(row: unknown): MemoryProposalRecord;
|
|
4
5
|
export declare function rowToConflictRecord(row: unknown): MemoryConflictRecord;
|
|
5
6
|
export declare function parseJsonObject(raw: unknown): Record<string, unknown>;
|
|
6
7
|
export declare function parseJsonArray(raw: unknown): string[];
|
|
@@ -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;
|
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,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,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>;
|