abmind 0.2.5 → 0.2.7-alpha.0

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 (177) hide show
  1. package/SUPPORTED-SURFACE.md +20 -2
  2. package/dist/cli/abmind-hook-recall.js +17 -40
  3. package/dist/cli/abmind-hook-recall.js.map +1 -1
  4. package/dist/cli/abmind-hook-store.js +10 -31
  5. package/dist/cli/abmind-hook-store.js.map +1 -1
  6. package/dist/cli/abmind-hook-wakeup.js +17 -3
  7. package/dist/cli/abmind-hook-wakeup.js.map +1 -1
  8. package/dist/cli/abmind-install.js +19 -19
  9. package/dist/cli/abmind-install.js.map +1 -1
  10. package/dist/cli/abmind-restore.js +10 -0
  11. package/dist/cli/abmind-restore.js.map +1 -1
  12. package/dist/cli/abmind-sleep.d.ts +9 -5
  13. package/dist/cli/abmind-sleep.d.ts.map +1 -1
  14. package/dist/cli/abmind-sleep.js +61 -14
  15. package/dist/cli/abmind-sleep.js.map +1 -1
  16. package/dist/cli/hook-lifecycle-adapter.d.ts +11 -0
  17. package/dist/cli/hook-lifecycle-adapter.d.ts.map +1 -0
  18. package/dist/cli/hook-lifecycle-adapter.js +33 -0
  19. package/dist/cli/hook-lifecycle-adapter.js.map +1 -0
  20. package/dist/src/context-engine.d.ts +13 -3
  21. package/dist/src/context-engine.d.ts.map +1 -1
  22. package/dist/src/context-engine.js +22 -5
  23. package/dist/src/context-engine.js.map +1 -1
  24. package/dist/src/context-orchestrator.d.ts +20 -2
  25. package/dist/src/context-orchestrator.d.ts.map +1 -1
  26. package/dist/src/context-orchestrator.js +11 -3
  27. package/dist/src/context-orchestrator.js.map +1 -1
  28. package/dist/src/context-tier-renderer.d.ts +8 -1
  29. package/dist/src/context-tier-renderer.d.ts.map +1 -1
  30. package/dist/src/context-tier-renderer.js +7 -2
  31. package/dist/src/context-tier-renderer.js.map +1 -1
  32. package/dist/src/ensure-initialized.d.ts +5 -0
  33. package/dist/src/ensure-initialized.d.ts.map +1 -1
  34. package/dist/src/ensure-initialized.js +19 -28
  35. package/dist/src/ensure-initialized.js.map +1 -1
  36. package/dist/src/fts-utils.d.ts +47 -0
  37. package/dist/src/fts-utils.d.ts.map +1 -0
  38. package/dist/src/fts-utils.js +65 -0
  39. package/dist/src/fts-utils.js.map +1 -0
  40. package/dist/src/host-integration/identity.d.ts +10 -0
  41. package/dist/src/host-integration/identity.d.ts.map +1 -0
  42. package/dist/src/host-integration/identity.js +66 -0
  43. package/dist/src/host-integration/identity.js.map +1 -0
  44. package/dist/src/host-integration/index.d.ts +5 -0
  45. package/dist/src/host-integration/index.d.ts.map +1 -0
  46. package/dist/src/host-integration/index.js +4 -0
  47. package/dist/src/host-integration/index.js.map +1 -0
  48. package/dist/src/host-integration/lifecycle.d.ts +14 -0
  49. package/dist/src/host-integration/lifecycle.d.ts.map +1 -0
  50. package/dist/src/host-integration/lifecycle.js +192 -0
  51. package/dist/src/host-integration/lifecycle.js.map +1 -0
  52. package/dist/src/host-integration/render.d.ts +5 -0
  53. package/dist/src/host-integration/render.d.ts.map +1 -0
  54. package/dist/src/host-integration/render.js +20 -0
  55. package/dist/src/host-integration/render.js.map +1 -0
  56. package/dist/src/host-integration/types.d.ts +107 -0
  57. package/dist/src/host-integration/types.d.ts.map +1 -0
  58. package/dist/src/host-integration/types.js +2 -0
  59. package/dist/src/host-integration/types.js.map +1 -0
  60. package/dist/src/imemory-system.d.ts +1 -1
  61. package/dist/src/imemory-system.d.ts.map +1 -1
  62. package/dist/src/index.d.ts +6 -4
  63. package/dist/src/index.d.ts.map +1 -1
  64. package/dist/src/index.js +3 -1
  65. package/dist/src/index.js.map +1 -1
  66. package/dist/src/maintenance-service.d.ts +11 -0
  67. package/dist/src/maintenance-service.d.ts.map +1 -1
  68. package/dist/src/maintenance-service.js +43 -0
  69. package/dist/src/maintenance-service.js.map +1 -1
  70. package/dist/src/memory-index.d.ts +0 -16
  71. package/dist/src/memory-index.d.ts.map +1 -1
  72. package/dist/src/memory-index.js +1 -60
  73. package/dist/src/memory-index.js.map +1 -1
  74. package/dist/src/memory-manager.d.ts +6 -2
  75. package/dist/src/memory-manager.d.ts.map +1 -1
  76. package/dist/src/memory-manager.js +9 -5
  77. package/dist/src/memory-manager.js.map +1 -1
  78. package/dist/src/message-store.d.ts +15 -3
  79. package/dist/src/message-store.d.ts.map +1 -1
  80. package/dist/src/message-store.js +28 -9
  81. package/dist/src/message-store.js.map +1 -1
  82. package/dist/src/openclaw-plugin/index.d.ts.map +1 -1
  83. package/dist/src/openclaw-plugin/index.js +3 -2
  84. package/dist/src/openclaw-plugin/index.js.map +1 -1
  85. package/dist/src/pi-plugin/abtars-client.d.ts +22 -0
  86. package/dist/src/pi-plugin/abtars-client.d.ts.map +1 -0
  87. package/dist/src/pi-plugin/abtars-client.js +153 -0
  88. package/dist/src/pi-plugin/abtars-client.js.map +1 -0
  89. package/dist/src/pi-plugin/abtars-tools.d.ts +8 -0
  90. package/dist/src/pi-plugin/abtars-tools.d.ts.map +1 -0
  91. package/dist/src/pi-plugin/abtars-tools.js +317 -0
  92. package/dist/src/pi-plugin/abtars-tools.js.map +1 -0
  93. package/dist/src/pi-plugin/identity.d.ts +8 -0
  94. package/dist/src/pi-plugin/identity.d.ts.map +1 -0
  95. package/dist/src/pi-plugin/identity.js +37 -0
  96. package/dist/src/pi-plugin/identity.js.map +1 -0
  97. package/dist/src/pi-plugin/index.d.ts +3 -0
  98. package/dist/src/pi-plugin/index.d.ts.map +1 -0
  99. package/dist/src/pi-plugin/index.js +139 -0
  100. package/dist/src/pi-plugin/index.js.map +1 -0
  101. package/dist/src/pi-plugin/messages.d.ts +4 -0
  102. package/dist/src/pi-plugin/messages.d.ts.map +1 -0
  103. package/dist/src/pi-plugin/messages.js +36 -0
  104. package/dist/src/pi-plugin/messages.js.map +1 -0
  105. package/dist/src/pi-plugin/pi-types.d.ts +126 -0
  106. package/dist/src/pi-plugin/pi-types.d.ts.map +1 -0
  107. package/dist/src/pi-plugin/pi-types.js +15 -0
  108. package/dist/src/pi-plugin/pi-types.js.map +1 -0
  109. package/dist/src/pi-plugin/runtime.d.ts +21 -0
  110. package/dist/src/pi-plugin/runtime.d.ts.map +1 -0
  111. package/dist/src/pi-plugin/runtime.js +60 -0
  112. package/dist/src/pi-plugin/runtime.js.map +1 -0
  113. package/dist/src/pi-plugin/tools.d.ts +11 -0
  114. package/dist/src/pi-plugin/tools.d.ts.map +1 -0
  115. package/dist/src/pi-plugin/tools.js +136 -0
  116. package/dist/src/pi-plugin/tools.js.map +1 -0
  117. package/dist/src/recall-boosts.d.ts +15 -0
  118. package/dist/src/recall-boosts.d.ts.map +1 -0
  119. package/dist/src/recall-boosts.js +159 -0
  120. package/dist/src/recall-boosts.js.map +1 -0
  121. package/dist/src/recall-engine.d.ts +0 -2
  122. package/dist/src/recall-engine.d.ts.map +1 -1
  123. package/dist/src/recall-engine.js +1 -151
  124. package/dist/src/recall-engine.js.map +1 -1
  125. package/dist/src/reconcile.d.ts +2 -0
  126. package/dist/src/reconcile.d.ts.map +1 -1
  127. package/dist/src/reconcile.js +21 -4
  128. package/dist/src/reconcile.js.map +1 -1
  129. package/dist/src/session-context.d.ts +1 -0
  130. package/dist/src/session-context.d.ts.map +1 -1
  131. package/dist/src/session-context.js +42 -23
  132. package/dist/src/session-context.js.map +1 -1
  133. package/dist/src/sleep/audit.d.ts +6 -0
  134. package/dist/src/sleep/audit.d.ts.map +1 -1
  135. package/dist/src/sleep/audit.js +6 -8
  136. package/dist/src/sleep/audit.js.map +1 -1
  137. package/dist/src/sleep/basic.d.ts +1 -1
  138. package/dist/src/sleep/basic.d.ts.map +1 -1
  139. package/dist/src/sleep/basic.js +5 -2
  140. package/dist/src/sleep/basic.js.map +1 -1
  141. package/dist/src/sleep/catchup.d.ts +17 -0
  142. package/dist/src/sleep/catchup.d.ts.map +1 -0
  143. package/dist/src/sleep/catchup.js +141 -0
  144. package/dist/src/sleep/catchup.js.map +1 -0
  145. package/dist/src/sleep/contracts.d.ts +112 -0
  146. package/dist/src/sleep/contracts.d.ts.map +1 -0
  147. package/dist/src/sleep/contracts.js +25 -0
  148. package/dist/src/sleep/contracts.js.map +1 -0
  149. package/dist/src/sleep/llm-budget.d.ts +49 -0
  150. package/dist/src/sleep/llm-budget.d.ts.map +1 -0
  151. package/dist/src/sleep/llm-budget.js +106 -0
  152. package/dist/src/sleep/llm-budget.js.map +1 -0
  153. package/dist/src/sleep/locks.d.ts +9 -5
  154. package/dist/src/sleep/locks.d.ts.map +1 -1
  155. package/dist/src/sleep/locks.js +8 -11
  156. package/dist/src/sleep/locks.js.map +1 -1
  157. package/dist/src/sleep/orchestrator.d.ts +20 -86
  158. package/dist/src/sleep/orchestrator.d.ts.map +1 -1
  159. package/dist/src/sleep/orchestrator.js +291 -755
  160. package/dist/src/sleep/orchestrator.js.map +1 -1
  161. package/dist/src/sleep/state.d.ts +15 -18
  162. package/dist/src/sleep/state.d.ts.map +1 -1
  163. package/dist/src/sleep/state.js +24 -19
  164. package/dist/src/sleep/state.js.map +1 -1
  165. package/dist/src/sleep/test-harness.d.ts +3 -1
  166. package/dist/src/sleep/test-harness.d.ts.map +1 -1
  167. package/dist/src/sleep/test-harness.js +3 -2
  168. package/dist/src/sleep/test-harness.js.map +1 -1
  169. package/dist/src/soul-seeder.d.ts +36 -0
  170. package/dist/src/soul-seeder.d.ts.map +1 -0
  171. package/dist/src/soul-seeder.js +69 -0
  172. package/dist/src/soul-seeder.js.map +1 -0
  173. package/dist/src/wake-up-builder.d.ts +3 -1
  174. package/dist/src/wake-up-builder.d.ts.map +1 -1
  175. package/dist/src/wake-up-builder.js +29 -5
  176. package/dist/src/wake-up-builder.js.map +1 -1
  177. package/package.json +20 -2
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Ambient type declarations for Pi extension API types.
3
+ *
4
+ * These types are provided by the Pi host at runtime via
5
+ * `@earendil-works/pi-coding-agent`, `@earendil-works/pi-agent-core`,
6
+ * and `@earendil-works/pi-ai`. We declare them here so the pi-plugin
7
+ * module compiles without those packages installed.
8
+ *
9
+ * At runtime inside Pi, the actual packages supply the real types and
10
+ * values. Standalone abmind must not import this file at the root level.
11
+ */
12
+ import type { TSchema } from "@sinclair/typebox";
13
+ export interface ExtensionAPI {
14
+ on<E = unknown, R = void>(event: string, handler: (event: E, ctx: ExtensionContext) => R | Promise<R>): void;
15
+ registerTool<TParams extends TSchema = TSchema, TDetails = unknown>(tool: ToolDefinition<TParams, TDetails>): void;
16
+ sendMessage<T = unknown>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details">, options?: {
17
+ triggerTurn?: boolean;
18
+ deliverAs?: "steer" | "followUp" | "nextTurn";
19
+ }): void;
20
+ events: EventBus;
21
+ }
22
+ export interface ExtensionContext {
23
+ sessionManager: ReadonlySessionManager;
24
+ signal: AbortSignal | undefined;
25
+ cwd: string;
26
+ }
27
+ export interface ReadonlySessionManager {
28
+ getSessionId(): string;
29
+ }
30
+ export interface EventBus {
31
+ emit(event: string, data: unknown): void;
32
+ }
33
+ export interface SessionStartEvent {
34
+ type: "session_start";
35
+ reason: "startup" | "reload" | "new" | "resume" | "fork";
36
+ previousSessionFile?: string;
37
+ }
38
+ export interface BeforeAgentStartEvent {
39
+ type: "before_agent_start";
40
+ prompt: string;
41
+ systemPrompt: string;
42
+ }
43
+ export interface AgentEndEvent {
44
+ type: "agent_end";
45
+ messages: AgentMessage[];
46
+ }
47
+ export interface SessionShutdownEvent {
48
+ type: "session_shutdown";
49
+ reason: "quit" | "reload" | "new" | "resume" | "fork";
50
+ targetSessionFile?: string;
51
+ }
52
+ export interface SessionCompactEvent {
53
+ type: "session_compact";
54
+ reason: "manual" | "threshold" | "overflow";
55
+ fromExtension: boolean;
56
+ }
57
+ export interface TextContent {
58
+ type: "text";
59
+ text: string;
60
+ }
61
+ export interface ThinkingContent {
62
+ type: "thinking";
63
+ thinking: string;
64
+ }
65
+ export interface ToolCallContent {
66
+ type: "toolCall";
67
+ id: string;
68
+ name: string;
69
+ arguments: Record<string, unknown>;
70
+ }
71
+ export interface AssistantMessage {
72
+ role: "assistant";
73
+ content: (TextContent | ThinkingContent | ToolCallContent)[];
74
+ stopReason: StopReason;
75
+ usage: {
76
+ inputTokens: number;
77
+ outputTokens: number;
78
+ };
79
+ model: string;
80
+ timestamp?: number;
81
+ }
82
+ export type StopReason = "stop" | "length" | "toolUse" | "error" | "aborted";
83
+ export interface UserMessage {
84
+ role: "user";
85
+ content: string | (TextContent | ImageContent)[];
86
+ timestamp: number;
87
+ }
88
+ export interface ToolResultMessage {
89
+ role: "toolResult";
90
+ toolCallId: string;
91
+ toolName: string;
92
+ content: (TextContent | ImageContent)[];
93
+ isError: boolean;
94
+ timestamp: number;
95
+ }
96
+ export interface CustomMessage<T = unknown> {
97
+ role: "custom";
98
+ customType: string;
99
+ content: string | (TextContent | ImageContent | ThinkingContent)[];
100
+ display: boolean;
101
+ details?: T;
102
+ timestamp: number;
103
+ }
104
+ export type AgentMessage = AssistantMessage | UserMessage | ToolResultMessage | CustomMessage;
105
+ export type ImageContent = {
106
+ type: "image";
107
+ data: string;
108
+ mimeType: string;
109
+ };
110
+ export interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown> {
111
+ name: string;
112
+ label: string;
113
+ description: string;
114
+ parameters: TParams;
115
+ promptSnippet?: string;
116
+ promptGuidelines?: string[];
117
+ execute(toolCallId: string, params: Record<string, unknown>, signal: AbortSignal | undefined, onUpdate: AgentToolUpdateCallback<TDetails> | undefined, ctx: ExtensionContext): Promise<AgentToolResult<TDetails>>;
118
+ }
119
+ export type AgentToolUpdateCallback<T> = (partialResult: AgentToolResult<T>) => void;
120
+ export interface AgentToolResult<T> {
121
+ content: (TextContent | ImageContent)[];
122
+ details: T;
123
+ terminate?: boolean;
124
+ }
125
+ export declare function defineTool<TParams extends TSchema, TDetails = unknown>(tool: ToolDefinition<TParams, TDetails>): ToolDefinition<TParams, TDetails>;
126
+ //# sourceMappingURL=pi-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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E,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CACL,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GAAG,SAAS,EACvD,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;CACvC;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAErF,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACxC,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,EAAE,QAAQ,GAAG,OAAO,EACpE,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,GACtC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAEnC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Ambient type declarations for Pi extension API types.
3
+ *
4
+ * These types are provided by the Pi host at runtime via
5
+ * `@earendil-works/pi-coding-agent`, `@earendil-works/pi-agent-core`,
6
+ * and `@earendil-works/pi-ai`. We declare them here so the pi-plugin
7
+ * module compiles without those packages installed.
8
+ *
9
+ * At runtime inside Pi, the actual packages supply the real types and
10
+ * values. Standalone abmind must not import this file at the root level.
11
+ */
12
+ export function defineTool(tool) {
13
+ return tool;
14
+ }
15
+ //# sourceMappingURL=pi-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-types.js","sourceRoot":"","sources":["../../../src/pi-plugin/pi-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsJH,MAAM,UAAU,UAAU,CACxB,IAAuC;IAEvC,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { MemoryConfig } from "../memory-config.js";
2
+ import { MemoryManager } from "../memory-manager.js";
3
+ import { HostMemoryLifecycle } from "../host-integration/lifecycle.js";
4
+ import type { ExecutionIdentity } from "../host-integration/types.js";
5
+ export interface PiRuntimeState {
6
+ memory: MemoryManager | null;
7
+ lifecycle: HostMemoryLifecycle | null;
8
+ identity: ExecutionIdentity | null;
9
+ pendingWakeUp: string;
10
+ pendingUserPrompt: string | null;
11
+ runGeneration: number;
12
+ lastCapturedGeneration: number;
13
+ closed: boolean;
14
+ }
15
+ export interface PiRuntime {
16
+ state: PiRuntimeState;
17
+ close(): void;
18
+ }
19
+ export declare function createPiRuntime(memoryConfig?: Partial<MemoryConfig>): Promise<PiRuntime>;
20
+ export declare function hasDegraded(runtime: PiRuntime): boolean;
21
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/pi-plugin/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAItE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAsB,eAAe,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAqC9F;AAmBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAEvD"}
@@ -0,0 +1,60 @@
1
+ import { loadMemoryConfig } from "../memory-config.js";
2
+ import { MemoryManager } from "../memory-manager.js";
3
+ import { logError, logInfo } from "../mem-logger.js";
4
+ import { HostMemoryLifecycle } from "../host-integration/lifecycle.js";
5
+ const TAG = "pi-plugin";
6
+ export async function createPiRuntime(memoryConfig) {
7
+ const config = memoryConfig
8
+ ? { ...loadMemoryConfig(), ...memoryConfig }
9
+ : loadMemoryConfig();
10
+ let memory = null;
11
+ let lifecycle = null;
12
+ try {
13
+ memory = new MemoryManager(config);
14
+ await memory.initialize();
15
+ lifecycle = new HostMemoryLifecycle(memory, {
16
+ writerId: "abmind-pi-plugin",
17
+ failOpen: true,
18
+ });
19
+ logInfo(TAG, "Memory initialized for Pi plugin");
20
+ }
21
+ catch (err) {
22
+ logError(TAG, "Memory initialization failed (degraded mode)", err);
23
+ memory = null;
24
+ lifecycle = null;
25
+ }
26
+ const state = {
27
+ memory,
28
+ lifecycle: lifecycle ?? null,
29
+ identity: null,
30
+ pendingWakeUp: "",
31
+ pendingUserPrompt: null,
32
+ runGeneration: 0,
33
+ lastCapturedGeneration: -1,
34
+ closed: false,
35
+ };
36
+ return {
37
+ state,
38
+ close: () => closeRuntime(state),
39
+ };
40
+ }
41
+ function closeRuntime(state) {
42
+ if (state.closed)
43
+ return;
44
+ state.closed = true;
45
+ state.pendingWakeUp = "";
46
+ state.pendingUserPrompt = null;
47
+ state.identity = null;
48
+ state.runGeneration = 0;
49
+ state.lastCapturedGeneration = -1;
50
+ if (state.memory) {
51
+ state.memory.close();
52
+ state.memory = null;
53
+ }
54
+ state.lifecycle = null;
55
+ logInfo(TAG, "Pi plugin runtime closed");
56
+ }
57
+ export function hasDegraded(runtime) {
58
+ return runtime.state.lifecycle === null;
59
+ }
60
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/pi-plugin/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAW,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAGvE,MAAM,GAAG,GAAG,WAAW,CAAC;AAkBxB,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,YAAoC;IACxE,MAAM,MAAM,GAAG,YAAY;QACzB,CAAC,CAAC,EAAE,GAAG,gBAAgB,EAAE,EAAE,GAAG,YAAY,EAAE;QAC5C,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAEvB,IAAI,MAAM,GAAyB,IAAI,CAAC;IACxC,IAAI,SAAS,GAA+B,IAAI,CAAC;IAEjD,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1B,SAAS,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE;YAC1C,QAAQ,EAAE,kBAAkB;YAC5B,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,EAAE,kCAAkC,CAAC,CAAC;IACn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11 @@
1
+ import type { HostMemoryLifecycle } from "../host-integration/lifecycle.js";
2
+ import type { ExecutionIdentity } from "../host-integration/types.js";
3
+ import { type ToolDefinition } from "./pi-types.js";
4
+ interface ToolDeps {
5
+ lifecycle: HostMemoryLifecycle;
6
+ getIdentity(): ExecutionIdentity;
7
+ }
8
+ export declare function createRecallTool(deps: ToolDeps): ToolDefinition;
9
+ export declare function createStoreTool(deps: ToolDeps): ToolDefinition;
10
+ export {};
11
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/pi-plugin/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAc,KAAK,cAAc,EAA+C,MAAM,eAAe,CAAC;AAsC7G,UAAU,QAAQ;IAChB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,WAAW,IAAI,iBAAiB,CAAC;CAClC;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CA8D/D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAuE9D"}
@@ -0,0 +1,136 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { extractEnglishTokens } from "../query-tokenizer.js";
3
+ import { defineTool } from "./pi-types.js";
4
+ const MemoryTypeEnum = Type.Union([
5
+ Type.Literal("fact"),
6
+ Type.Literal("decision"),
7
+ Type.Literal("preference"),
8
+ Type.Literal("event"),
9
+ Type.Literal("lesson"),
10
+ Type.Literal("feedback"),
11
+ Type.Literal("story"),
12
+ Type.Literal("secret"),
13
+ ]);
14
+ const VALID_MEMORY_TYPES = ["fact", "decision", "preference", "event", "lesson", "feedback", "story", "secret"];
15
+ function toMemoryType(raw) {
16
+ if (raw && VALID_MEMORY_TYPES.includes(raw))
17
+ return raw;
18
+ return "fact";
19
+ }
20
+ export function createRecallTool(deps) {
21
+ return defineTool({
22
+ name: "abmind_recall",
23
+ label: "Abmind Recall",
24
+ description: "Search past memories, decisions, and facts stored by abmind. Returns relevant memory hits with scores.",
25
+ promptSnippet: "When the user asks about past decisions, preferences, or information that might have been stored in memory, use abmind_recall.",
26
+ promptGuidelines: [
27
+ "Use this tool when you need to remember information from past conversations",
28
+ "Formulate queries using key English terms the memory might be indexed under",
29
+ "Results include a relevance score — higher is better",
30
+ ],
31
+ parameters: Type.Object({
32
+ query: Type.String({ minLength: 1, description: "Search query — English terms likely to appear in stored memory" }),
33
+ limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 50, default: 10, description: "Maximum number of results" })),
34
+ minScore: Type.Optional(Type.Number({ minimum: 0, maximum: 1, description: "Minimum relevance score threshold" })),
35
+ maxClassification: Type.Optional(Type.Integer({ minimum: 0, maximum: 3, default: 2, description: "Maximum classification level (0=general, 3=personal)" })),
36
+ }),
37
+ async execute(_toolCallId, rawParams, signal, _onUpdate, _ctx) {
38
+ if (signal?.aborted) {
39
+ return { content: [{ type: "text", text: "Recall cancelled." }], details: { cancelled: true } };
40
+ }
41
+ const params = rawParams;
42
+ const identity = deps.getIdentity();
43
+ const tokens = extractEnglishTokens(params.query ?? "");
44
+ const limit = params.limit ?? 10;
45
+ const maxClassification = params.maxClassification ?? 2;
46
+ try {
47
+ const result = await deps.lifecycle.recall({
48
+ identity,
49
+ query: { translated: tokens.length > 0 ? tokens : [params.query], original: params.query },
50
+ limit,
51
+ minScore: params.minScore,
52
+ maxClassification,
53
+ });
54
+ const lines = result.hits.map(h => `- [${h.date}] (score: ${h.score.toFixed(3)}) ${h.content.slice(0, 200)}`);
55
+ const text = lines.length > 0
56
+ ? `Found ${result.hits.length} memory hit(s):\n${lines.join("\n")}`
57
+ : "No matching memories found.";
58
+ return {
59
+ content: [{ type: "text", text }],
60
+ details: { hits: result.hits, diagnostics: result.diagnostics },
61
+ };
62
+ }
63
+ catch (err) {
64
+ return {
65
+ content: [{ type: "text", text: `Recall failed: ${err instanceof Error ? err.message : String(err)}` }],
66
+ details: { error: String(err) },
67
+ };
68
+ }
69
+ },
70
+ });
71
+ }
72
+ export function createStoreTool(deps) {
73
+ return defineTool({
74
+ name: "abmind_store",
75
+ label: "Abmind Store",
76
+ description: "Store a fact, decision, preference, event, lesson, or feedback in abmind for long-term memory. Content should be in canonical English.",
77
+ promptSnippet: "When the user states a new preference, makes a decision, shares personal information, or expresses something worth remembering, use abmind_store.",
78
+ promptGuidelines: [
79
+ "Store factual information, user preferences, and decisions explicitly",
80
+ "Write content in clear, canonical English for best retrieval later",
81
+ "Use the memory type that best fits: fact, decision, preference, event, lesson, feedback, story, or secret",
82
+ ],
83
+ parameters: Type.Object({
84
+ content: Type.String({ minLength: 1, description: "Memory content in canonical English" }),
85
+ original: Type.Optional(Type.String({ description: "Original-language text (if translated)" })),
86
+ type: Type.Optional(MemoryTypeEnum),
87
+ topic: Type.Optional(Type.String({ description: "Topic label for categorization" })),
88
+ classification: Type.Optional(Type.Integer({ minimum: 0, maximum: 3, description: "Classification level (0=general, 3=highly personal)" })),
89
+ emotion: Type.Optional(Type.Integer({ minimum: -5, maximum: 5, description: "Emotional valence (-5=negative, 0=neutral, 5=positive)" })),
90
+ confidence: Type.Optional(Type.Number({ minimum: 0, maximum: 1, description: "Confidence in the memory accuracy" })),
91
+ }),
92
+ async execute(_toolCallId, rawParams, signal, _onUpdate, _ctx) {
93
+ if (signal?.aborted) {
94
+ return { content: [{ type: "text", text: "Store cancelled." }], details: { cancelled: true } };
95
+ }
96
+ const params = rawParams;
97
+ const identity = deps.getIdentity();
98
+ try {
99
+ const result = await deps.lifecycle.store({
100
+ identity,
101
+ contentEn: params.content ?? "",
102
+ contentOriginal: params.original ?? params.content ?? "",
103
+ memoryType: toMemoryType(params.type),
104
+ emotionScore: params.emotion ?? 0,
105
+ topic: params.topic ?? "general",
106
+ classification: params.classification ?? 1,
107
+ confidence: params.confidence,
108
+ emotionTags: undefined,
109
+ emotionContext: undefined,
110
+ keyword: undefined,
111
+ sourceMessageIds: undefined,
112
+ trust: undefined,
113
+ integrity: undefined,
114
+ credibility: undefined,
115
+ });
116
+ if (result.stored) {
117
+ return {
118
+ content: [{ type: "text", text: `Memory stored successfully (${result.memoriesCount} memory record(s)).` }],
119
+ details: result,
120
+ };
121
+ }
122
+ return {
123
+ content: [{ type: "text", text: `Store failed: ${result.error ?? "unknown error"}` }],
124
+ details: result,
125
+ };
126
+ }
127
+ catch (err) {
128
+ return {
129
+ content: [{ type: "text", text: `Store failed: ${err instanceof Error ? err.message : String(err)}` }],
130
+ details: { error: String(err) },
131
+ };
132
+ }
133
+ },
134
+ });
135
+ }
136
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/pi-plugin/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAoE,MAAM,eAAe,CAAC;AAE7G,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;IAC1B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;CACvB,CAAC,CAAC;AASH,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE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Context, spacing, emotion, and quality boost helpers for the recall pipeline.
3
+ * Extracted from recall-engine.ts (#1229).
4
+ * Uses `import type` for RecallHit/RecallContext to avoid a runtime circular dependency
5
+ * (recall-engine.ts imports these functions; this module imports the types from recall-engine.ts).
6
+ */
7
+ import type Database from "better-sqlite3";
8
+ import type { RecallHit, RecallContext } from "./recall-engine.js";
9
+ export declare function applyContextBoost(results: RecallHit[], ctx: RecallContext): RecallHit[];
10
+ export declare function applySpacingBoost(results: RecallHit[], db: Database.Database): RecallHit[];
11
+ /** Recall-engine emotion boost multiplier: |emotion_score| * this = additive boost. */
12
+ export declare const RECALL_EMOTION_MULT = 0.02;
13
+ export declare function applyEmotionBoost(results: RecallHit[], db: Database.Database): RecallHit[];
14
+ export declare function applyQualityBoost(results: RecallHit[], db: Database.Database): RecallHit[];
15
+ //# sourceMappingURL=recall-boosts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall-boosts.d.ts","sourceRoot":"","sources":["../../src/recall-boosts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAqBnE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,aAAa,GAAG,SAAS,EAAE,CA6BvF;AAcD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,SAAS,EAAE,CAc1F;AAgBD,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,SAAS,EAAE,CAgB1F;AAQD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,SAAS,EAAE,CAgC1F"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * recall-boosts.ts — Context, spacing, emotion, and quality boost helpers for the recall pipeline.
3
+ * Extracted from recall-engine.ts (#1229).
4
+ * Uses `import type` for RecallHit/RecallContext to avoid a runtime circular dependency
5
+ * (recall-engine.ts imports these functions; this module imports the types from recall-engine.ts).
6
+ */
7
+ import { logDebug } from "./mem-logger.js";
8
+ const TAG = "recall";
9
+ const DAY_MS = 86400000;
10
+ // ── Context boost weights (env-tunable) ─────────────────────────────────────
11
+ const CTX_HOUR_BOOST = parseFloat(process.env.RECALL_CONTEXT_HOUR_BOOST ?? "0.02");
12
+ const CTX_DOW_BOOST = parseFloat(process.env.RECALL_CONTEXT_DOW_BOOST ?? "0.015");
13
+ const CTX_TOPIC_BOOST = parseFloat(process.env.RECALL_CONTEXT_TOPIC_BOOST ?? "0.03");
14
+ function hourBucket(hour) {
15
+ if (hour >= 6 && hour < 12)
16
+ return 0; // morning
17
+ if (hour >= 12 && hour < 18)
18
+ return 1; // afternoon
19
+ if (hour >= 18 && hour < 23)
20
+ return 2; // evening
21
+ return 3; // night
22
+ }
23
+ function isWeekend(dow) { return dow === 0 || dow === 6; }
24
+ export function applyContextBoost(results, ctx) {
25
+ if (!ctx.hour && ctx.hour !== 0 && !ctx.dayOfWeek && ctx.dayOfWeek !== 0 && !ctx.topic)
26
+ return results;
27
+ let boostedCount = 0;
28
+ const boosted = results.map(hit => {
29
+ let boost = 0;
30
+ const ts = hit.createdAt;
31
+ if (ts && (ctx.hour != null || ctx.dayOfWeek != null)) {
32
+ const d = new Date(ts);
33
+ if (ctx.hour != null && hourBucket(d.getHours()) === hourBucket(ctx.hour)) {
34
+ boost += CTX_HOUR_BOOST;
35
+ }
36
+ if (ctx.dayOfWeek != null) {
37
+ const storedDow = d.getDay();
38
+ if (storedDow === ctx.dayOfWeek)
39
+ boost += CTX_DOW_BOOST;
40
+ else if (isWeekend(storedDow) === isWeekend(ctx.dayOfWeek))
41
+ boost += CTX_DOW_BOOST * 0.5;
42
+ }
43
+ }
44
+ if (ctx.topic && hit.topic && hit.topic !== "general" && hit.topic === ctx.topic) {
45
+ boost += CTX_TOPIC_BOOST;
46
+ }
47
+ if (boost > 0)
48
+ boostedCount++;
49
+ return boost > 0 ? { ...hit, score: hit.score + boost } : hit;
50
+ });
51
+ if (boostedCount > 0) {
52
+ logDebug(TAG, `context-boost applied to ${boostedCount}/${results.length} candidates`);
53
+ }
54
+ return boosted;
55
+ }
56
+ // ── Spacing boost (#244) ────────────────────────────────────────────────────
57
+ function spacingBoost(timestamps) {
58
+ if (timestamps.length < 2)
59
+ return 1.0;
60
+ const intervals = [];
61
+ for (let i = 1; i < timestamps.length; i++)
62
+ intervals.push(timestamps[i] - timestamps[i - 1]);
63
+ const avg = intervals.reduce((a, b) => a + b, 0) / intervals.length;
64
+ if (avg >= 7 * DAY_MS)
65
+ return 1.3;
66
+ if (avg >= 1 * DAY_MS)
67
+ return 1.15;
68
+ return 1.0;
69
+ }
70
+ export function applySpacingBoost(results, db) {
71
+ if (results.length === 0)
72
+ return results;
73
+ const ids = results.filter(r => r.id != null).map(r => r.id);
74
+ if (ids.length === 0)
75
+ return results;
76
+ const ph = ids.map(() => "?").join(",");
77
+ const rows = db.prepare(`SELECT id, recall_timestamps FROM extracted_memories WHERE id IN (${ph})`).all(...ids);
78
+ const tsMap = new Map(rows.map(r => [r.id, JSON.parse(r.recall_timestamps ?? "[]")]));
79
+ return results.map(hit => {
80
+ if (!hit.id)
81
+ return hit;
82
+ const ts = tsMap.get(hit.id);
83
+ if (!ts || ts.length < 2)
84
+ return hit;
85
+ const mult = spacingBoost(ts);
86
+ return mult > 1.0 ? { ...hit, score: hit.score * mult } : hit;
87
+ });
88
+ }
89
+ // ── Emotion boost (#404) ────────────────────────────────────────────────────
90
+ //
91
+ // Tie-breaker-only boost for emotionally charged memories. Linear: |e| * 0.02,
92
+ // max +0.10 at |e|=5. Intentionally small — recall-engine scores are in the
93
+ // 0.4-1.2 range (darwinism ~0.95-1.25, cosine ~0-1, hamming ~0-1, hardcoded
94
+ // 0.5/0.6), so +0.10 is ~10% — enough to break ties, not enough to override a
95
+ // relevance gap of 0.2+.
96
+ //
97
+ // NOT the same weight as memory-index.ts EMOTION_BOOST_WEIGHT (0.5 * log(1+|e|)).
98
+ // That path operates on BM25 scores (5-20+), where +0.9 is proportionate.
99
+ // Different score regime, different weight — same direction (boost), same
100
+ // concept (emotional salience as tie-breaker). Each path applies the boost
101
+ // exactly once. Do NOT sum results across the two paths.
102
+ /** Recall-engine emotion boost multiplier: |emotion_score| * this = additive boost. */
103
+ export const RECALL_EMOTION_MULT = 0.02;
104
+ export function applyEmotionBoost(results, db) {
105
+ if (results.length === 0)
106
+ return results;
107
+ const ids = results.filter(r => r.id != null).map(r => r.id);
108
+ if (ids.length === 0)
109
+ return results;
110
+ const ph = ids.map(() => "?").join(",");
111
+ const rows = db.prepare(`SELECT id, emotion_score FROM extracted_memories WHERE id IN (${ph})`).all(...ids);
112
+ const emMap = new Map(rows.map(r => [r.id, r.emotion_score]));
113
+ return results.map(hit => {
114
+ if (hit.id == null)
115
+ return hit;
116
+ const e = emMap.get(hit.id);
117
+ if (e == null || e === 0)
118
+ return hit;
119
+ const boost = Math.abs(e) * RECALL_EMOTION_MULT;
120
+ return { ...hit, score: hit.score + boost, emotionScore: e };
121
+ });
122
+ }
123
+ // ── Quality boost (#824) ────────────────────────────────────────────────────
124
+ //
125
+ // Citation/rejection signal: memories the agent actually used get boosted,
126
+ // memories the user rejected get penalized. Uses (cited - rejected) / surfaced.
127
+ // Also applies ×0.85 penalty for memories recalled 5+ times in last 30d with 0 citations.
128
+ export function applyQualityBoost(results, db) {
129
+ if (results.length === 0)
130
+ return results;
131
+ const ids = results.filter(r => r.id != null).map(r => r.id);
132
+ if (ids.length === 0)
133
+ return results;
134
+ const ph = ids.map(() => "?").join(",");
135
+ const rows = db.prepare(`SELECT id, recall_count, cited_count, rejected_count, recall_timestamps FROM extracted_memories WHERE id IN (${ph})`).all(...ids);
136
+ const qMap = new Map(rows.map(r => [r.id, r]));
137
+ const now = Date.now();
138
+ const thirtyDays = 30 * DAY_MS;
139
+ return results.map(hit => {
140
+ if (hit.id == null)
141
+ return hit;
142
+ const row = qMap.get(hit.id);
143
+ if (!row || row.recall_count === 0)
144
+ return hit;
145
+ // Quality score: (cited - rejected) / recall_count, clamped to [-0.10, +0.15]
146
+ const qualityScore = (row.cited_count - row.rejected_count) / Math.max(row.recall_count, 1);
147
+ const boost = Math.max(-0.10, Math.min(0.15, qualityScore * 0.15));
148
+ // Penalty: 5+ recent recalls with 0 citations → ×0.85
149
+ let penalty = 1.0;
150
+ if (row.cited_count === 0 && row.recall_count >= 5) {
151
+ const timestamps = JSON.parse(row.recall_timestamps ?? "[]");
152
+ const recentRecalls = timestamps.filter(t => (now - t) < thirtyDays).length;
153
+ if (recentRecalls >= 5)
154
+ penalty = 0.85;
155
+ }
156
+ return { ...hit, score: (hit.score + boost) * penalty };
157
+ });
158
+ }
159
+ //# sourceMappingURL=recall-boosts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall-boosts.js","sourceRoot":"","sources":["../../src/recall-boosts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,GAAG,GAAG,QAAQ,CAAC;AAErB,MAAM,MAAM,GAAG,QAAQ,CAAC;AAExB,+EAA+E;AAE/E,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,MAAM,CAAC,CAAC;AACnF,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,OAAO,CAAC,CAAC;AAClF,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,MAAM,CAAC,CAAC;AAErF,SAAS,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,KAAK,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAC;YACvE,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC;YAC5E,IAAI,aAAa,IAAI,CAAC;gBAAE,OAAO,GAAG,IAAI,CAAC;QACzC,CAAC;QAED,OAAO,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,OAAO,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -77,7 +77,5 @@ export type RecallDeps = {
77
77
  /** Optional — when provided, Se stage uses it instead of loading a fresh ollama client (#173). */
78
78
  embeddingProvider?: import("./embedding-provider.js").IEmbeddingProvider;
79
79
  };
80
- export declare function applyContextBoost(results: RecallHit[], ctx: RecallContext): RecallHit[];
81
- export declare function applyEmotionBoost(results: RecallHit[], db: Database.Database): RecallHit[];
82
80
  export declare function recallSearch(deps: RecallDeps, params: RecallParams): Promise<RecallResult>;
83
81
  //# sourceMappingURL=recall-engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"recall-engine.d.ts","sourceRoot":"","sources":["../../src/recall-engine.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYrD,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAA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