qlogicagent 2.16.6 → 2.16.8

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 (97) hide show
  1. package/dist/agent.js +16 -16
  2. package/dist/cli.js +412 -413
  3. package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -0
  4. package/dist/default-project-knowledge/rules/project-workflow.md +6 -0
  5. package/dist/index.js +411 -412
  6. package/dist/protocol.js +1 -1
  7. package/dist/types/cli/agent-runtime-bootstrap.d.ts +1 -0
  8. package/dist/types/cli/base-tool-bootstrap.d.ts +3 -0
  9. package/dist/types/cli/handlers/community-handler.d.ts +2 -28
  10. package/dist/types/cli/handlers/files-handler.d.ts +6 -0
  11. package/dist/types/cli/handlers/message-feedback-handler.d.ts +31 -0
  12. package/dist/types/cli/handlers/pet-handler.d.ts +1 -0
  13. package/dist/types/cli/handlers/project-handler.d.ts +1 -0
  14. package/dist/types/cli/handlers/turn-baseline-handler.d.ts +8 -0
  15. package/dist/types/cli/handlers/turn-handler.d.ts +5 -0
  16. package/dist/types/cli/handlers/workflow-handler.d.ts +0 -11
  17. package/dist/types/cli/handlers/working-materials-handler.d.ts +9 -0
  18. package/dist/types/cli/idle-dream-coordinator.d.ts +6 -0
  19. package/dist/types/cli/mcp-bootstrap.d.ts +1 -0
  20. package/dist/types/cli/memory-coordinator.d.ts +1 -0
  21. package/dist/types/cli/project-template-seeder.d.ts +2 -2
  22. package/dist/types/cli/rpc-registry.d.ts +6 -0
  23. package/dist/types/cli/runtime-hook-bootstrap.d.ts +1 -0
  24. package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +1 -0
  25. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +1 -0
  26. package/dist/types/cli/stdio-runtime-bootstrap.d.ts +1 -0
  27. package/dist/types/cli/tool-bootstrap-community-registration.d.ts +0 -6
  28. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +2 -0
  29. package/dist/types/cli/tool-bootstrap.d.ts +2 -0
  30. package/dist/types/cli/turn-skill-autopersist.d.ts +0 -25
  31. package/dist/types/protocol/methods.d.ts +24 -201
  32. package/dist/types/protocol/wire/agent-events.d.ts +2 -2
  33. package/dist/types/protocol/wire/agent-methods.d.ts +10 -205
  34. package/dist/types/protocol/wire/gateway-rpc.d.ts +160 -0
  35. package/dist/types/protocol/wire/notification-payloads.d.ts +34 -0
  36. package/dist/types/runtime/community/community-consent-client.d.ts +9 -186
  37. package/dist/types/runtime/community/community-discovery-coordinator.d.ts +1 -1
  38. package/dist/types/runtime/infra/default-path-service.d.ts +1 -1
  39. package/dist/types/runtime/infra/feedback-distillation-worker.d.ts +20 -0
  40. package/dist/types/runtime/infra/feedback-distillation.d.ts +30 -0
  41. package/dist/types/runtime/infra/feedback-event-store.d.ts +179 -0
  42. package/dist/types/runtime/infra/feedback-outbox.d.ts +26 -0
  43. package/dist/types/runtime/infra/feedback-redaction.d.ts +71 -0
  44. package/dist/types/runtime/infra/feedback-upload-client.d.ts +40 -0
  45. package/dist/types/runtime/infra/feedback-upload-worker.d.ts +11 -0
  46. package/dist/types/runtime/infra/project-data-paths.d.ts +5 -5
  47. package/dist/types/runtime/infra/turn-baseline-store.d.ts +102 -0
  48. package/dist/types/runtime/infra/turn-telemetry-store.d.ts +59 -0
  49. package/dist/types/runtime/infra/working-materials-store.d.ts +35 -0
  50. package/dist/types/runtime/pet/daily-journey-summarizer.d.ts +25 -0
  51. package/dist/types/runtime/pet/index.d.ts +2 -1
  52. package/dist/types/runtime/pet/journey-catchup.d.ts +14 -0
  53. package/dist/types/runtime/pet/journey-day-aggregator.d.ts +27 -0
  54. package/dist/types/runtime/pet/journey-narrative-prompt.d.ts +8 -0
  55. package/dist/types/runtime/pet/pet-profile-service.d.ts +14 -1
  56. package/dist/types/runtime/ports/memory-provider.d.ts +6 -0
  57. package/dist/types/runtime/ports/path-service.d.ts +1 -1
  58. package/dist/types/runtime/ports/tool-contracts.d.ts +2 -0
  59. package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +14 -0
  60. package/dist/types/runtime/prompt/instruction-loader.d.ts +7 -7
  61. package/dist/types/skills/mcp/mcp-manager.d.ts +11 -0
  62. package/dist/types/skills/memory/local-memory-provider.d.ts +3 -3
  63. package/dist/types/skills/memory/local-store-records.d.ts +18 -1
  64. package/dist/types/skills/memory/local-store.d.ts +8 -195
  65. package/dist/types/skills/memory/memory-consolidation.d.ts +14 -0
  66. package/dist/types/skills/memory/sqlite-memory-schema.d.ts +1 -1
  67. package/dist/types/skills/plugins/plugin-marketplace.d.ts +1 -1
  68. package/dist/types/skills/tools/community-seek-tool.d.ts +0 -33
  69. package/dist/types/skills/tools/instructions-tool.d.ts +2 -2
  70. package/dist/types/skills/tools/skill-tool.d.ts +1 -1
  71. package/dist/vendor/hatch-pet/LICENSE.txt +201 -201
  72. package/dist/vendor/hatch-pet/NOTICE.md +25 -25
  73. package/dist/vendor/hatch-pet/references/animation-rows.md +29 -29
  74. package/dist/vendor/hatch-pet/references/codex-pet-contract.md +35 -35
  75. package/dist/vendor/hatch-pet/references/qa-rubric.md +66 -66
  76. package/dist/vendor/hatch-pet/scripts/compose_atlas.py +169 -169
  77. package/dist/vendor/hatch-pet/scripts/derive_running_left_from_running_right.py +150 -150
  78. package/dist/vendor/hatch-pet/scripts/extract_strip_frames.py +408 -408
  79. package/dist/vendor/hatch-pet/scripts/inspect_frames.py +256 -256
  80. package/dist/vendor/hatch-pet/scripts/make_contact_sheet.py +96 -96
  81. package/dist/vendor/hatch-pet/scripts/prepare_pet_run.py +834 -834
  82. package/dist/vendor/hatch-pet/scripts/render_animation_previews.py +78 -78
  83. package/dist/vendor/hatch-pet/scripts/validate_atlas.py +157 -157
  84. package/package.json +1 -1
  85. package/dist/types/runtime/community/activity-event-emitter.d.ts +0 -31
  86. package/dist/types/runtime/community/activity-event.d.ts +0 -62
  87. package/dist/types/runtime/community/community-desensitization-red-team-cli.d.ts +0 -7
  88. package/dist/types/runtime/community/community-desensitization.d.ts +0 -29
  89. package/dist/types/runtime/community/community-pet-publisher.d.ts +0 -27
  90. package/dist/types/runtime/community/community-signal-reporter.d.ts +0 -19
  91. package/dist/types/runtime/community/community-telemetry-metadata.d.ts +0 -4
  92. package/dist/types/runtime/community/community-telemetry-recorder.d.ts +0 -6
  93. package/dist/types/runtime/community/community-telemetry-types.d.ts +0 -1
  94. package/dist/types/runtime/community/pet-activity-sink.d.ts +0 -36
  95. package/dist/types/runtime/community/pet-key.d.ts +0 -7
  96. package/dist/types/runtime/community/roaming-gate.d.ts +0 -19
  97. package/dist/types/runtime/community/social-emission.d.ts +0 -16
@@ -35,6 +35,12 @@ export interface MemoryExtractionItem {
35
35
  tags?: string[];
36
36
  /** Ids of already-uploaded attachments to link to this memory on commit. */
37
37
  attachmentIds?: string[];
38
+ /** Evidence trail for distillation-style sources (feedback — §10): audit refs + crash-safe dedup key. */
39
+ evidence?: {
40
+ kind: string;
41
+ refs: string[];
42
+ idempotencyKey: string;
43
+ };
38
44
  }
39
45
  export interface MemoryConsolidationWriteResult {
40
46
  memoriesAdded?: number;
@@ -27,5 +27,5 @@ export interface PathService {
27
27
  getProjectInstructionsPath(projectRoot?: string): string;
28
28
  getProjectPluginsDir(projectRoot?: string): string;
29
29
  getProjectRulesDir(projectRoot?: string): string;
30
- getProjectSessionsRoot(projectRoot?: string): string;
30
+ getProjectSessionDataRoot(projectIdOrWorkspaceDir?: string): string;
31
31
  }
@@ -64,6 +64,8 @@ export interface ToolBootstrapConfig {
64
64
  debug(message: string): void;
65
65
  };
66
66
  getTaskScopeKey?(): string | undefined;
67
+ getCurrentTurnId?(): string | undefined;
68
+ sendNotification?(method: string, params: Record<string, unknown>): void;
67
69
  onExecProgress?(progress: ToolBootstrapProgress): void;
68
70
  }
69
71
  export interface ToolBootstrap {
@@ -21,5 +21,19 @@ export declare function getFreshWorkspaceEvidencePolicy(messages: readonly Promp
21
21
  export declare function looksLikeBuildIntent(messages: readonly PromptMessageLike[] | string): boolean;
22
22
  export declare function isLightweightChatTurn(messages: readonly PromptMessageLike[] | string): boolean;
23
23
  export declare function isExplicitNoToolTurn(messages: readonly PromptMessageLike[] | string): boolean;
24
+ /**
25
+ * Orchestration / capability primitives that survive every evidence filter.
26
+ * The policy's job is to FORCE fresh-evidence tools into the turn, not to
27
+ * strip the coordination layer — removing task/agent here silently breaks
28
+ * sub-agent delegation and background-task tracking on any turn whose text
29
+ * happens to match an evidence pattern (e.g. "write reports/x.json").
30
+ * `skill_view` belongs here for the same reason: it is the capability-invocation
31
+ * primitive, and the `# Available Skills` section tells the model to call it.
32
+ * Stripping `skill_view` on a file/mutation/shell turn (i.e. almost every real task)
33
+ * makes that instruction impossible to follow — the model cannot call a tool it
34
+ * was never given — which was the entire "skills never self-activate" bug.
35
+ * (skills_list / skill_manage are not load-bearing for self-activation, so they
36
+ * stay subject to the normal evidence filter.)
37
+ */
24
38
  export declare function selectFreshWorkspaceEvidenceTools<TTool extends ToolNameLike>(tools: readonly TTool[], policy: FreshWorkspaceEvidencePolicy): TTool[];
25
39
  export declare function createFreshWorkspaceEvidenceSection(policy: FreshWorkspaceEvidencePolicy): SystemPromptSection | null;
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Instruction Loader — CC claudemd.ts parity (adapted for qlogicagent).
3
3
  *
4
- * Discovers and loads instruction files following CC's load order:
5
- * 1. User instructions (~/.qlogicagent/INSTRUCTIONS.md)
6
- * 2. Project instructions (INSTRUCTIONS.md, .qlogicagent/INSTRUCTIONS.md,
4
+ * Discovers and loads project instruction files following CC's walkup model:
5
+ * 1. Project instructions (INSTRUCTIONS.md, .qlogicagent/INSTRUCTIONS.md,
7
6
  * .qlogicagent/rules/*.md — walkup from cwd to git root)
8
- * 3. Local instructions (INSTRUCTIONS.local.md — private, not checked in)
7
+ * 2. Local instructions (INSTRUCTIONS.local.md — private, not checked in)
8
+ *
9
+ * Profile-scoped user templates are copied into project knowledge at project creation time.
9
10
  *
10
11
  * Features ported from CC:
11
12
  * - Walkup discovery (cwd → root)
@@ -37,12 +38,11 @@ export interface LiteralResponseRequirement {
37
38
  * Load all instruction files following CC's discovery order.
38
39
  *
39
40
  * Discovery order (priority: last loaded = highest):
40
- * 1. User: ~/.qlogicagent/INSTRUCTIONS.md, ~/.qlogicagent/rules/*.md
41
- * 2. Project: Walk from git root → cwd, each dir:
41
+ * 1. Project: Walk from git root → cwd, each dir:
42
42
  * - INSTRUCTIONS.md
43
43
  * - .qlogicagent/INSTRUCTIONS.md
44
44
  * - .qlogicagent/rules/*.md (unconditional)
45
- * 3. Local: INSTRUCTIONS.local.md (per dir, walkup)
45
+ * 2. Local: INSTRUCTIONS.local.md (per dir, walkup)
46
46
  *
47
47
  * @param cwd - Starting directory for walkup discovery
48
48
  * @param hooks - Optional hook registry for instructions.loaded event
@@ -46,6 +46,17 @@ export interface McpManagerConfig {
46
46
  /** Runtime-owned catalog used for dynamic MCP tool injection. */
47
47
  toolCatalog?: ToolRegistryLike;
48
48
  }
49
+ /**
50
+ * Run `attempt` up to `options.attempts` times, backing off `baseDelayMs * n`
51
+ * between tries. Returns the first success; rethrows the last error if every
52
+ * attempt fails. `sleep` is injectable so callers (and tests) control timing.
53
+ */
54
+ export declare function connectWithRetry<T>(attempt: () => Promise<T>, options: {
55
+ attempts: number;
56
+ baseDelayMs: number;
57
+ sleep?: (ms: number) => Promise<void>;
58
+ onRetry?: (attemptNumber: number, err: unknown) => void;
59
+ }): Promise<T>;
49
60
  export declare class McpManager {
50
61
  private runtime;
51
62
  private definitions;
@@ -162,7 +162,7 @@ export declare class LocalMemoryProvider implements MemoryProvider {
162
162
  page?: number;
163
163
  pageSize?: number;
164
164
  activeOnly?: boolean;
165
- }): import("./local-store.js").MemoryRecord[];
165
+ }): import("./local-store-records.js").MemoryRecord[];
166
166
  /**
167
167
  * Find memories by event date (+/- tolerance). For temporal context retrieval.
168
168
  */
@@ -178,8 +178,8 @@ export declare class LocalMemoryProvider implements MemoryProvider {
178
178
  bucketCount?: number;
179
179
  clusterLimit?: number;
180
180
  activeOnly?: boolean;
181
- }): import("./local-store.js").MemoryAtlasResult;
182
- findByEventDate(userId: string, targetDate: string, toleranceDays?: number): import("./local-store.js").MemorySearchHit[];
181
+ }): import("./local-store-records.js").MemoryAtlasResult;
182
+ findByEventDate(userId: string, targetDate: string, toleranceDays?: number): import("./local-store-records.js").MemorySearchHit[];
183
183
  /**
184
184
  * Find related memories (event continuity detection).
185
185
  * Given a new memory, finds existing memories that are semantically related
@@ -1,3 +1,12 @@
1
+ /** Lightweight attachment reference carried on records / atlas wire (no bytes, no extractedText). */
2
+ export interface MemoryAttachmentRef {
3
+ id: string;
4
+ kind: string;
5
+ filename: string;
6
+ mimeType: string;
7
+ size: number;
8
+ url: string;
9
+ }
1
10
  export interface MemoryRecord {
2
11
  id: string;
3
12
  text: string;
@@ -15,6 +24,8 @@ export interface MemoryRecord {
15
24
  accessCount: number;
16
25
  lastAccessedAt: number;
17
26
  isArchived: boolean;
27
+ /** Lightweight attachment refs (populated by the provider for atlas/detail). */
28
+ attachments?: MemoryAttachmentRef[];
18
29
  }
19
30
  export interface MemoryInsertInput {
20
31
  text: string;
@@ -84,7 +95,7 @@ export interface MemoryAtlasResult {
84
95
  endAt: number;
85
96
  } | null;
86
97
  }
87
- export type MemorySourceKind = "manual" | "explicit" | "document" | "image" | "video" | "auto" | "turn" | "dream" | "agent";
98
+ export type MemorySourceKind = "manual" | "explicit" | "document" | "image" | "video" | "auto" | "turn" | "dream" | "agent" | "feedback";
88
99
  export type MemoryClaimStatus = "active" | "superseded" | "conflicted" | "archived" | "pending_confirmation";
89
100
  export type MemoryProposalStatus = "pending" | "accepted" | "merged" | "conflicted" | "rejected";
90
101
  export interface MemoryObservationInput {
@@ -119,6 +130,12 @@ export interface MemoryProposalInput {
119
130
  tags?: string[];
120
131
  status?: MemoryProposalStatus;
121
132
  relatedClaimIds?: string[];
133
+ /**
134
+ * Crash-safe dedup key for evidence-bearing sources (feedback distillation — §10). When set,
135
+ * proposeExtracted skips inserting a duplicate proposal for the same key. Left undefined by all
136
+ * existing callers (LLM extraction / dream / manual), so their behaviour is unchanged.
137
+ */
138
+ idempotencyKey?: string;
122
139
  }
123
140
  export interface MemoryProposalRecord extends Omit<MemoryProposalInput, "value" | "validTime" | "tags" | "status" | "relatedClaimIds"> {
124
141
  id: string;
@@ -12,36 +12,9 @@
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
16
  export { resolveMemoryDbPath } from "./memory-db-path.js";
16
- export interface MemoryRecord {
17
- id: string;
18
- text: string;
19
- userId: string;
20
- category: string;
21
- importance: number;
22
- confidence: number;
23
- source: string;
24
- sessionId: string;
25
- eventDate: string;
26
- tags: string[];
27
- embedding: Float32Array | null;
28
- createdAt: number;
29
- updatedAt: number;
30
- accessCount: number;
31
- lastAccessedAt: number;
32
- isArchived: boolean;
33
- /** Lightweight attachment refs (populated by the provider for atlas/detail). */
34
- attachments?: MemoryAttachmentRef[];
35
- }
36
- /** Lightweight attachment reference carried on records / atlas wire (no bytes, no extractedText). */
37
- export interface MemoryAttachmentRef {
38
- id: string;
39
- kind: string;
40
- filename: string;
41
- mimeType: string;
42
- size: number;
43
- url: string;
44
- }
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";
45
18
  /** Full attachment index row (DB-backed; file bytes live on disk under the attachments dir). */
46
19
  export interface MemoryAttachmentRow {
47
20
  id: string;
@@ -66,172 +39,6 @@ export interface MemoryAttachmentInsert {
66
39
  extractedText?: string;
67
40
  memoryId?: string;
68
41
  }
69
- export interface MemoryInsertInput {
70
- text: string;
71
- userId: string;
72
- category?: string;
73
- importance?: number;
74
- confidence?: number;
75
- source?: string;
76
- sessionId?: string;
77
- eventDate?: string;
78
- tags?: string[];
79
- embedding?: Float32Array;
80
- }
81
- export interface MemoryUpdateInput {
82
- text?: string;
83
- category?: string;
84
- importance?: number;
85
- source?: string;
86
- eventDate?: string;
87
- tags?: string[];
88
- embedding?: Float32Array | null;
89
- }
90
- export interface MemorySearchHit {
91
- id: string;
92
- text: string;
93
- score: number;
94
- category: string;
95
- importance: number;
96
- metadata: Record<string, unknown>;
97
- }
98
- export interface MemoryAtlasBucket {
99
- id: string;
100
- startAt: number;
101
- endAt: number;
102
- count: number;
103
- avgImportance: number;
104
- avgConfidence: number;
105
- topCategory: string;
106
- }
107
- export interface MemoryAtlasCluster {
108
- id: string;
109
- label: string;
110
- kind: "source" | "category" | "tag";
111
- count: number;
112
- startAt: number;
113
- endAt: number;
114
- avgImportance: number;
115
- avgConfidence: number;
116
- topCategory: string;
117
- }
118
- export interface MemoryAtlasWindowCursor {
119
- startAt: number;
120
- endAt: number;
121
- centerAt: number;
122
- pageSize: number;
123
- hasBefore: boolean;
124
- hasAfter: boolean;
125
- }
126
- export interface MemoryAtlasResult {
127
- totalCount: number;
128
- records: MemoryRecord[];
129
- buckets: MemoryAtlasBucket[];
130
- clusters: MemoryAtlasCluster[];
131
- windowCursor: MemoryAtlasWindowCursor | null;
132
- timeRange: {
133
- startAt: number;
134
- endAt: number;
135
- } | null;
136
- }
137
- export type MemorySourceKind = "manual" | "explicit" | "document" | "image" | "video" | "auto" | "turn" | "dream" | "agent";
138
- export type MemoryClaimStatus = "active" | "superseded" | "conflicted" | "archived" | "pending_confirmation";
139
- export type MemoryProposalStatus = "pending" | "accepted" | "merged" | "conflicted" | "rejected";
140
- export interface MemoryObservationInput {
141
- userId: string;
142
- text: string;
143
- source: string;
144
- sourcePriority: number;
145
- sessionId?: string;
146
- evidenceType?: string;
147
- payload?: Record<string, unknown>;
148
- }
149
- export interface MemoryObservationRecord extends Required<Omit<MemoryObservationInput, "payload" | "sessionId" | "evidenceType">> {
150
- id: string;
151
- sessionId: string;
152
- evidenceType: string;
153
- payload: Record<string, unknown>;
154
- createdAt: number;
155
- }
156
- export interface MemoryProposalInput {
157
- userId: string;
158
- observationIds: string[];
159
- text: string;
160
- category: string;
161
- importance: number;
162
- confidence: number;
163
- source: string;
164
- sourcePriority: number;
165
- entity: string;
166
- predicate: string;
167
- value: Record<string, unknown>;
168
- validTime?: string;
169
- tags?: string[];
170
- status?: MemoryProposalStatus;
171
- relatedClaimIds?: string[];
172
- }
173
- export interface MemoryProposalRecord extends Omit<MemoryProposalInput, "value" | "validTime" | "tags" | "status" | "relatedClaimIds"> {
174
- id: string;
175
- value: Record<string, unknown>;
176
- validTime: string;
177
- tags: string[];
178
- status: MemoryProposalStatus;
179
- relatedClaimIds: string[];
180
- createdAt: number;
181
- updatedAt: number;
182
- }
183
- export interface MemoryClaimInput {
184
- userId: string;
185
- memoryId?: string;
186
- entity: string;
187
- predicate: string;
188
- value: Record<string, unknown>;
189
- text: string;
190
- category: string;
191
- importance: number;
192
- confidence: number;
193
- source: string;
194
- sourcePriority: number;
195
- status: MemoryClaimStatus;
196
- validTime?: string;
197
- evidenceIds: string[];
198
- supersedesClaimId?: string;
199
- conflictGroupId?: string;
200
- }
201
- export interface MemoryClaimRecord extends Omit<MemoryClaimInput, "memoryId" | "value" | "validTime" | "supersedesClaimId" | "conflictGroupId"> {
202
- id: string;
203
- memoryId: string;
204
- value: Record<string, unknown>;
205
- validTime: string;
206
- supersedesClaimId: string;
207
- conflictGroupId: string;
208
- createdAt: number;
209
- updatedAt: number;
210
- }
211
- export interface MemoryConflictRecord {
212
- id: string;
213
- userId: string;
214
- claimAId: string;
215
- claimBId: string;
216
- reason: string;
217
- status: "open" | "resolved" | "dismissed";
218
- createdAt: number;
219
- updatedAt: number;
220
- }
221
- export interface SqliteDatabase {
222
- exec(sql: string): void;
223
- prepare(sql: string): SqliteStatement;
224
- pragma(pragma: string): unknown;
225
- close(): void;
226
- }
227
- export interface SqliteStatement {
228
- run(...params: unknown[]): {
229
- changes: number;
230
- lastInsertRowid: number | bigint;
231
- };
232
- get(...params: unknown[]): unknown;
233
- all(...params: unknown[]): unknown[];
234
- }
235
42
  export declare class LocalMemoryStore {
236
43
  private db;
237
44
  constructor(db: SqliteDatabase);
@@ -438,6 +245,12 @@ export declare class LocalMemoryStore {
438
245
  enforceCapacityLimit(userId: string, maxCount?: number): number;
439
246
  insertObservation(input: MemoryObservationInput): string;
440
247
  insertProposal(input: MemoryProposalInput): string;
248
+ /**
249
+ * Look up an existing proposal by its idempotency key (feedback distillation — §10). Returns the
250
+ * proposal id if one already exists for this user + key, else null, letting proposeExtracted skip
251
+ * a duplicate crash-safely (the key survives a worker restart mid-sweep).
252
+ */
253
+ findProposalByIdempotencyKey(userId: string, idempotencyKey: string): string | null;
441
254
  updateProposalStatus(id: string, status: MemoryProposalStatus, relatedClaimIds?: string[]): boolean;
442
255
  insertClaim(input: MemoryClaimInput): string;
443
256
  listClaims(userId: string, statuses?: MemoryClaimStatus[]): MemoryClaimRecord[];
@@ -9,6 +9,20 @@ export interface ExtractedMemoryItem {
9
9
  tags?: string[];
10
10
  /** Ids of already-uploaded attachments to link to this memory on commit. */
11
11
  attachmentIds?: string[];
12
+ /**
13
+ * Explicit confidence for evidence-bearing sources (feedback distillation — §10). When set,
14
+ * proposeExtracted uses it verbatim instead of the source-derived default. Other callers omit it.
15
+ */
16
+ confidence?: number;
17
+ /**
18
+ * Evidence trail for distillation-style sources. `refs` (e.g. feedbackIds + turn:<id>) is stored
19
+ * on the observation for audit; `idempotencyKey` makes the proposal insert crash-safe + dedup'd.
20
+ */
21
+ evidence?: {
22
+ kind: string;
23
+ refs: string[];
24
+ idempotencyKey: string;
25
+ };
12
26
  }
13
27
  export interface MemoryConsolidationOptions {
14
28
  source?: string;
@@ -1,3 +1,3 @@
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 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);\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";
3
3
  export declare function initializeMemorySchema(db: SqliteDatabase): void;
@@ -51,7 +51,7 @@ export declare function loadCachedPlugins(): string[];
51
51
  export declare function installMarketplacePlugins(config: MarketplaceConfig, log: MarketplaceLogger): Promise<string[]>;
52
52
  /**
53
53
  * Get the marketplace config from user settings.
54
- * Reads ~/.qlogicagent/marketplace.json
54
+ * Reads ~/.qlogicagent/profiles/<owner>/marketplace.json
55
55
  */
56
56
  export declare function loadMarketplaceConfig(): MarketplaceConfig | null;
57
57
  /**
@@ -2,10 +2,8 @@ import type { PortableTool } from "../portable-tool.js";
2
2
  import type { CommunityDiscoveryResult, CommunityDiscoveryStatus } from "../../runtime/community/community-discovery-coordinator.js";
3
3
  import type { CommunityInstallRiskTier, CommunityInstallSourceTier, CommunityInstallTrustStage, CommunityRegistryMatchResult } from "../../runtime/community/community-consent-client.js";
4
4
  export declare const COMMUNITY_SEEK_TOOL_NAME: "community_seek";
5
- export type CommunitySeekKind = "package" | "answer";
6
5
  export interface CommunitySeekParams {
7
6
  intent: string;
8
- kinds?: CommunitySeekKind[];
9
7
  }
10
8
  export interface CommunitySeekPackageCandidate {
11
9
  kind: "package";
@@ -18,46 +16,23 @@ export interface CommunitySeekPackageCandidate {
18
16
  effectiveRiskTier: CommunityInstallRiskTier;
19
17
  latestVersion: string | null;
20
18
  }
21
- export interface CommunitySeekAnswerCandidate {
22
- kind: "answer";
23
- reviewId: string;
24
- resourceId: string;
25
- title: string;
26
- /** 对端 agent 的经验文本(发布侧已过脱敏硬闸 R24)。 */
27
- experience: string;
28
- outcome: "success" | "fail" | "neutral";
29
- }
30
- export type CommunitySeekCandidate = CommunitySeekPackageCandidate | CommunitySeekAnswerCandidate;
31
19
  /** 轻回执:落进对话的可折叠"去社区找了个 X"(展示侧由 UI 渲染)。 */
32
20
  export interface CommunitySeekReceipt {
33
21
  intent: string;
34
22
  status: CommunityDiscoveryStatus;
35
23
  packageCount: number;
36
- answerCount: number;
37
24
  topTitle?: string;
38
25
  }
39
26
  export interface CommunitySeekResult {
40
27
  status: CommunityDiscoveryStatus;
41
28
  intent: string;
42
29
  packages: CommunitySeekPackageCandidate[];
43
- answers: CommunitySeekAnswerCandidate[];
44
30
  }
45
31
  export interface CommunitySeekDeps {
46
32
  /** 发现协调器:本地前置 + consent + 缓存 + ≤1 次 O(1) registry_match。 */
47
33
  discover(intent: string): Promise<CommunityDiscoveryResult>;
48
- /** 经验答案源(Cut1 默认无:hub registry_match 扩返经验答案后接入)。 */
49
- findAnswers?(intent: string, topK: number): Promise<CommunitySeekAnswerCandidate[]>;
50
34
  /** 轻回执 sink(对话侧渲染);best-effort,抛错不影响工具结果。 */
51
35
  onReceipt?(receipt: CommunitySeekReceipt): void;
52
- /**
53
- * 「去社区张罗到了」→ 发一条 acquire ActivityEvent(父总纲 Cut1「落…一条 ActivityEvent」):
54
- * 自家宠物现身于命中资源的店铺/街区。anchor 只给 shopId(店铺=canonical resourceId);
55
- * 街区由集市端按 layout 反解。best-effort fire-and-forget,抛错/未配置都不影响工具结果。
56
- */
57
- onAcquire?(anchor: {
58
- shopId?: string;
59
- districtId?: string;
60
- }): void;
61
36
  }
62
37
  export declare function toPackageCandidate(match: CommunityRegistryMatchResult): CommunitySeekPackageCandidate;
63
38
  export declare function runCommunitySeek(deps: CommunitySeekDeps, params: CommunitySeekParams): Promise<CommunitySeekResult>;
@@ -68,14 +43,6 @@ export declare const COMMUNITY_SEEK_TOOL_SCHEMA: {
68
43
  readonly type: "string";
69
44
  readonly description: string;
70
45
  };
71
- readonly kinds: {
72
- readonly type: "array";
73
- readonly items: {
74
- readonly type: "string";
75
- readonly enum: readonly ["package", "answer"];
76
- };
77
- readonly description: "Restrict results to packages and/or answers. Omit for both.";
78
- };
79
46
  };
80
47
  readonly required: readonly ["intent"];
81
48
  };
@@ -17,9 +17,9 @@ export interface InstructionsToolDeps {
17
17
  /** Read a single instruction file. Returns null if not found. */
18
18
  read(projectId: string, filename: string): InstructionFileContent | null;
19
19
  /** Write (create or overwrite) an instruction file. */
20
- write(projectId: string, filename: string, content: string): InstructionFileContent;
20
+ write(projectId: string, filename: string, content: string): InstructionFileContent | Promise<InstructionFileContent>;
21
21
  /** Remove an instruction file. Returns true if deleted. */
22
- remove(projectId: string, filename: string): boolean;
22
+ remove(projectId: string, filename: string): boolean | Promise<boolean>;
23
23
  }
24
24
  export declare const INSTRUCTIONS_TOOL_NAME: "instructions";
25
25
  export type InstructionsAction = "list" | "read" | "write" | "edit" | "delete";
@@ -27,7 +27,7 @@ export declare const SKILL_VIEW_TOOL_SCHEMA: {
27
27
  readonly properties: {
28
28
  readonly name: {
29
29
  readonly type: "string";
30
- readonly description: "The skill to use. Calling skill_view(name='X') loads that skill and you follow its instructions in THIS turn that single call is all you need to USE a skill.";
30
+ readonly description: "The skill to use. For a matching workflow, call skill_view before read/search/exec/MCP. Calling skill_view(name='X') loads that skill and you follow its instructions in THIS turn - that single call is all you need to USE a skill.";
31
31
  };
32
32
  readonly args: {
33
33
  readonly type: "string";