qlogicagent 2.18.3 → 2.18.5

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.
Files changed (47) hide show
  1. package/dist/agent.js +3 -3
  2. package/dist/cli.js +1 -1
  3. package/dist/index.js +559 -519
  4. package/dist/orchestration.js +1 -1
  5. package/dist/protocol.js +1 -1
  6. package/dist/skills/mcp/astraclaw-native-mcp-server.js +6 -6
  7. package/dist/types/cli/handlers/agents-handler.d.ts +33 -0
  8. package/dist/types/cli/handlers/community-handler.d.ts +1 -2
  9. package/dist/types/cli/handlers/memory-handler.d.ts +7 -1
  10. package/dist/types/cli/handlers/turn-handler.d.ts +10 -0
  11. package/dist/types/cli/orchestration-memory-context.d.ts +22 -0
  12. package/dist/types/orchestration/agent-instance.d.ts +5 -0
  13. package/dist/types/orchestration/goal-mode-adapters.d.ts +4 -0
  14. package/dist/types/orchestration/planner-memory-brief.d.ts +39 -0
  15. package/dist/types/orchestration/solo-spec-builder.d.ts +3 -0
  16. package/dist/types/protocol/methods.d.ts +0 -26
  17. package/dist/types/protocol/wire/agent-methods.d.ts +0 -12
  18. package/dist/types/protocol/wire/gateway-rpc.d.ts +11 -14
  19. package/dist/types/protocol/wire/index.d.ts +1 -1
  20. package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +0 -16
  21. package/dist/types/runtime/community/community-consent-client.d.ts +0 -21
  22. package/dist/types/runtime/execution/memory-decay.d.ts +1 -1
  23. package/dist/types/runtime/hooks/memory-hooks.d.ts +6 -0
  24. package/dist/types/runtime/infra/agent-paths.d.ts +9 -7
  25. package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +0 -6
  26. package/dist/types/runtime/infra/checkpoint-backend.d.ts +1 -1
  27. package/dist/types/runtime/infra/migrate-device-scope.d.ts +49 -0
  28. package/dist/types/runtime/infra/project-data-paths.d.ts +4 -3
  29. package/dist/types/runtime/infra/project-skill-manifest.d.ts +3 -2
  30. package/dist/types/runtime/ports/index.d.ts +1 -1
  31. package/dist/types/runtime/ports/memory-provider.d.ts +22 -7
  32. package/dist/types/skills/memory/fts-segment.d.ts +20 -0
  33. package/dist/types/skills/memory/local-memory-provider.d.ts +55 -10
  34. package/dist/types/skills/memory/local-store-records.d.ts +6 -1
  35. package/dist/types/skills/memory/local-store.d.ts +96 -17
  36. package/dist/types/skills/memory/memdir.d.ts +16 -6
  37. package/dist/types/skills/memory/memory-consolidation.d.ts +7 -0
  38. package/dist/types/skills/memory/proposal-consumer.d.ts +51 -0
  39. package/dist/types/skills/memory/sqlite-memory-mappers.d.ts +2 -1
  40. package/dist/types/skills/memory/sqlite-memory-schema.d.ts +9 -1
  41. package/dist/types/skills/tools/image-generate-tool.d.ts +1 -1
  42. package/package.json +3 -2
  43. package/dist/types/cli/tool-bootstrap-community-registration.d.ts +0 -9
  44. package/dist/types/runtime/community/community-discovery-cache.d.ts +0 -24
  45. package/dist/types/runtime/community/community-discovery-coordinator.d.ts +0 -33
  46. package/dist/types/runtime/hooks/community-discovery-hook.d.ts +0 -18
  47. package/dist/types/skills/tools/community-seek-tool.d.ts +0 -49
@@ -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,19 +55,50 @@ 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
- * Hybrid search: FTS5 + vector similarity, de-duplicated and merged.
61
- */
62
- searchHybrid(query: string, queryEmbedding: Float32Array | null, userId: string, limit?: number): MemorySearchHit[];
72
+ * Hybrid search: FTS5 + vector similarity, fused by rank-tempered RRF.
73
+ *
74
+ * Two currencies, each carrying signal the other cannot:
75
+ * - channel scores (0-1, isomorphic across FTS/vector) carry MAGNITUDE —
76
+ * an exact lexical hit must beat weak-consensus noise, which pure rank
77
+ * fusion cannot guarantee (rank ignores how strong a match is);
78
+ * - reciprocal ranks carry CONSENSUS and are scale-invariant — as the
79
+ * store grows, BM25 inflates until squashed top scores compress to
80
+ * near-ties and the two channels' score distributions drift apart;
81
+ * ranks keep differentiating where magnitudes saturate.
82
+ * fused = (1-w)*magnitude + w*rrfNorm keeps both properties. Magnitude of a
83
+ * dual hit is the stronger channel plus a fraction of the weaker (consensus
84
+ * also rewarded in score space); rrfNorm is the reciprocal-rank sum
85
+ * normalized so a dual #1 hit = 1.0. FTS ranks follow BM25 order, vector
86
+ * ranks follow the blended channel order — each channel's own relevance
87
+ * ordering. Rows found by FTS only (e.g. no embedding) compete in the same
88
+ * fused domain and remain reachable, not buried.
89
+ */
90
+ searchHybrid(query: string, queryEmbedding: Float32Array | null, userId: string, limit?: number, expectedModel?: string): MemorySearchHit[];
63
91
  /**
64
92
  * Get all memories for a user (paginated).
65
93
  */
66
94
  listByUser(userId: string, page?: number, pageSize?: number, activeOnly?: boolean): MemoryRecord[];
95
+ /**
96
+ * All active memories carrying a tag (LIKE match on the quoted JSON-array
97
+ * element). Tag consumers (resident refresh / onboarding replace-purge) need
98
+ * the COMPLETE tag set regardless of age — the windowed atlas read silently
99
+ * truncated them once history outgrew one page/time window.
100
+ */
101
+ listByTag(userId: string, tag: string, limit?: number): MemoryRecord[];
67
102
  /**
68
103
  * Return a windowed atlas payload for large-history visualization.
69
104
  *
@@ -89,7 +124,7 @@ export declare class LocalMemoryStore {
89
124
  /**
90
125
  * Update memory text and bump updatedAt.
91
126
  */
92
- updateText(id: string, text: string, embedding?: Float32Array): boolean;
127
+ updateText(id: string, text: string, embedding?: Float32Array, embeddingModel?: string): boolean;
93
128
  /**
94
129
  * Update editable memory fields and bump updatedAt.
95
130
  */
@@ -120,6 +155,25 @@ export declare class LocalMemoryStore {
120
155
  * Memories written by the agent but never recalled are likely noise.
121
156
  */
122
157
  decayNoiseArchival(userId: string, minAgeDays?: number, maxImportance?: number): number;
158
+ /**
159
+ * Observation retention: memory_observations is an append-only audit trail
160
+ * (every propose/commit writes one) with NO reader of its own — without a
161
+ * retention window it grows forever, the same disease the proposals table
162
+ * had before the consumer existed. Delete rows older than the window that
163
+ * are NOT referenced by any claim's evidence_ids or proposal's
164
+ * observation_ids (referenced rows are live audit evidence and stay).
165
+ */
166
+ decayObservations(userId: string, retentionDays?: number): number;
167
+ /**
168
+ * Resolved-proposal retention: terminal rows (accepted/merged/rejected/
169
+ * expired) are processing history, not memory — past the window they only
170
+ * grow the table. Rows carrying an idempotency_key are KEPT FOREVER: they
171
+ * are the crash-safe ledger that stops feedback distillation from
172
+ * re-proposing the same evidence cluster (deleting them would re-open the
173
+ * exact duplicate-write hole the key exists to close). Pending rows are
174
+ * never touched here — the consumer owns their TTL (status=expired).
175
+ */
176
+ decayResolvedProposals(userId: string, retentionDays?: number): number;
123
177
  /**
124
178
  * Run all decay strategies. Returns total affected count.
125
179
  */
@@ -196,23 +250,34 @@ export declare class LocalMemoryStore {
196
250
  date: string;
197
251
  }>;
198
252
  };
199
- /**
200
- * Find memories related to a specific event date (±tolerance).
201
- * Used for temporal context retrieval, such as finding memories around a requested date.
202
- */
203
- findByEventDate(userId: string, targetDate: string, toleranceDays?: number): MemorySearchHit[];
204
253
  /**
205
254
  * Record an access (for importance/relevance boosting).
206
255
  */
207
256
  recordAccess(id: string): void;
257
+ /** Total active memory rows across ALL users (health reporting). */
258
+ countAll(): number;
208
259
  /**
209
260
  * Get total memory count for a user.
210
261
  */
211
262
  count(userId: string, activeOnly?: boolean): number;
212
263
  /**
213
- * Delete all memories for a user.
214
- */
215
- resetUser(userId: string): number;
264
+ * Delete ALL long-term memory state for a user — every table, not just
265
+ * `memories`. Claims carry entity/predicate/value facts in clear text and
266
+ * observations carry raw conversation excerpts; leaving them behind after a
267
+ * "clear my memory" is a broken privacy promise, not a smaller reset.
268
+ *
269
+ * Returns the attachment rel_paths so the caller can delete the on-disk
270
+ * files (the store only owns the index rows).
271
+ */
272
+ resetUser(userId: string): {
273
+ memories: number;
274
+ observations: number;
275
+ proposals: number;
276
+ claims: number;
277
+ conflicts: number;
278
+ profiles: number;
279
+ attachmentRelPaths: string[];
280
+ };
216
281
  /**
217
282
  * Run SQLite VACUUM to reclaim space after deletions/archival.
218
283
  * Should be called periodically (e.g. after decay cycles).
@@ -228,10 +293,13 @@ export declare class LocalMemoryStore {
228
293
  freePages: number;
229
294
  };
230
295
  /**
231
- * Export archived memories as JSONL (for cold storage / backup).
232
- * Deletes exported records from the database to reclaim space.
296
+ * List the oldest archived memories for cold-storage export. Read-only:
297
+ * purging is a SEPARATE step (purgeMemoriesByIds) the caller performs only
298
+ * after the export has durably landed on disk. The old fused
299
+ * export-then-delete shape destroyed data whenever the caller dropped the
300
+ * return value.
233
301
  */
234
- exportAndPurgeArchived(userId: string, maxExport?: number): Array<{
302
+ listArchivedForExport(userId: string, maxExport?: number): Array<{
235
303
  id: string;
236
304
  text: string;
237
305
  category: string;
@@ -240,6 +308,8 @@ export declare class LocalMemoryStore {
240
308
  archivedAt: number;
241
309
  tags: string[];
242
310
  }>;
311
+ /** Physically delete memory rows by id (post-export purge step). */
312
+ purgeMemoriesByIds(ids: string[]): number;
243
313
  /**
244
314
  * Enforce capacity limit: if active memories exceed maxCount,
245
315
  * archive the oldest lowest-importance ones.
@@ -253,6 +323,15 @@ export declare class LocalMemoryStore {
253
323
  * a duplicate crash-safely (the key survives a worker restart mid-sweep).
254
324
  */
255
325
  findProposalByIdempotencyKey(userId: string, idempotencyKey: string): string | null;
326
+ /**
327
+ * List proposals by status (oldest first) — the read side of the proposal
328
+ * consumer. Pending proposals from implicit-extract / feedback / dream used
329
+ * to have NO reader at all: they accumulated forever and never became
330
+ * searchable memories.
331
+ */
332
+ listProposalsByStatus(userId: string, status: MemoryProposalStatus, limit?: number): MemoryProposalRecord[];
333
+ /** Bulk status transition for the proposal consumer (corroborated / expired). */
334
+ markProposalsStatus(ids: string[], status: MemoryProposalStatus): number;
256
335
  updateProposalStatus(id: string, status: MemoryProposalStatus, relatedClaimIds?: string[]): boolean;
257
336
  insertClaim(input: MemoryClaimInput): string;
258
337
  listClaims(userId: string, statuses?: MemoryClaimStatus[]): MemoryClaimRecord[];
@@ -1,4 +1,4 @@
1
- /** Max bytes (UTF-8) for INDEX.md to inject into system prompt (CC uses 25KB, we use 12KB). */
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 (QLOGICAGENT_HOME aware). */
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 declare function isMemoryContentSafe(text: string): boolean;
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;
@@ -88,7 +87,12 @@ export declare class Memdir {
88
87
  }>;
89
88
  /** Delete a topic file. INDEX.md cannot be deleted. */
90
89
  deleteFile(name: string): Promise<MemdirResult>;
91
- /** Search all memory files for keyword matches. Returns matching snippets. */
90
+ /**
91
+ * Search all memory files for keyword matches. Returns matching snippets.
92
+ * Tokenization shares fts-segment (latin words + CJK bigrams) with the L2
93
+ * keyword index — the old whitespace split treated a whole Chinese sentence
94
+ * as one "word", so multi-term Chinese queries scored all-or-nothing.
95
+ */
92
96
  searchLocal(query: string): Promise<Array<{
93
97
  file: string;
94
98
  snippet: string;
@@ -97,6 +101,12 @@ export declare class Memdir {
97
101
  private writeIndex;
98
102
  private writeIndexUnlocked;
99
103
  private ensureDir;
100
- /** Append an entry to the file listing section of INDEX.md (idempotent). */
104
+ /**
105
+ * Append an entry to the file listing section of INDEX.md (idempotent).
106
+ * Returns whether the entry is present afterwards. On overflow it first
107
+ * tries the same auto-compaction as addToIndex; a false return means the
108
+ * file exists but is INVISIBLE to recall — callers must surface that
109
+ * (the old behavior skipped silently and quietly orphaned topic files).
110
+ */
101
111
  private appendIndexEntry;
102
112
  }
@@ -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\nCREATE VIRTUAL TABLE IF NOT EXISTS memories_fts USING fts5(\n id UNINDEXED,\n user_id UNINDEXED,\n text,\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, category, tags)\n VALUES (new.rowid, new.id, new.user_id, new.text, 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, category, tags)\n VALUES ('delete', old.rowid, old.id, old.user_id, old.text, 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, category, tags)\n VALUES ('delete', old.rowid, old.id, old.user_id, old.text, old.category, old.tags);\n INSERT INTO memories_fts(rowid, id, user_id, text, category, tags)\n VALUES (new.rowid, new.id, new.user_id, new.text, new.category, new.tags);\nEND;\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;
@@ -29,7 +29,7 @@ export declare const IMAGE_GENERATE_TOOL_SCHEMA: {
29
29
  };
30
30
  readonly size: {
31
31
  readonly type: "string";
32
- readonly description: "Dimensions: e.g. '1024x1792' (portrait), '1792x1024' (landscape), '1024x1024' (square). Default: '1024x1024'.";
32
+ readonly description: string;
33
33
  };
34
34
  readonly image_url: {
35
35
  readonly type: "string";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlogicagent",
3
- "version": "2.18.3",
3
+ "version": "2.18.5",
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>;