@basicmemory/openclaw-basic-memory 0.24.1 → 1.1.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.
- package/README.md +28 -16
- package/bm-client.ts +461 -140
- package/commands/cli.ts +5 -6
- package/commands/slash.ts +4 -4
- package/config.ts +5 -0
- package/context-engine/basic-memory-context-engine.ts +74 -9
- package/context-engine/types.ts +21 -0
- package/dist/bm-client.d.ts +101 -32
- package/dist/bm-client.js +346 -108
- package/dist/commands/cli.d.ts +1 -1
- package/dist/commands/cli.js +5 -5
- package/dist/commands/slash.d.ts +1 -1
- package/dist/commands/slash.js +4 -3
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/context-engine/basic-memory-context-engine.d.ts +20 -1
- package/dist/context-engine/basic-memory-context-engine.js +50 -2
- package/dist/context-engine/types.d.ts +9 -0
- package/dist/context-engine/types.js +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +78 -69
- package/dist/memory/basic-memory-capability.d.ts +19 -0
- package/dist/memory/basic-memory-capability.js +196 -0
- package/dist/tools/build-context.d.ts +1 -1
- package/dist/tools/build-context.js +12 -4
- package/dist/tools/delete-note.d.ts +1 -1
- package/dist/tools/delete-note.js +2 -1
- package/dist/tools/edit-note.d.ts +1 -1
- package/dist/tools/edit-note.js +22 -12
- package/dist/tools/list-memory-projects.d.ts +1 -1
- package/dist/tools/list-memory-projects.js +2 -1
- package/dist/tools/list-workspaces.d.ts +1 -1
- package/dist/tools/list-workspaces.js +4 -4
- package/dist/tools/move-note.d.ts +1 -1
- package/dist/tools/move-note.js +2 -1
- package/dist/tools/read-note.d.ts +1 -1
- package/dist/tools/read-note.js +2 -1
- package/dist/tools/schema-diff.d.ts +1 -1
- package/dist/tools/schema-diff.js +7 -4
- package/dist/tools/schema-infer.d.ts +1 -1
- package/dist/tools/schema-infer.js +3 -2
- package/dist/tools/schema-validate.d.ts +1 -1
- package/dist/tools/schema-validate.js +7 -5
- package/dist/tools/search-notes.d.ts +1 -1
- package/dist/tools/search-notes.js +13 -6
- package/dist/tools/write-note.d.ts +1 -1
- package/dist/tools/write-note.js +11 -12
- package/index.ts +92 -84
- package/memory/basic-memory-capability.ts +259 -0
- package/openclaw.plugin.json +1 -3
- package/package.json +6 -5
- package/scripts/setup-bm.sh +1 -4
- package/skills/manifest.json +10 -5
- package/skills/memory-agents/SKILL.md +23 -10
- package/skills/memory-capture/SKILL.md +29 -18
- package/skills/memory-comark/SKILL.md +17 -6
- package/skills/memory-continue/SKILL.md +47 -27
- package/skills/memory-curate/SKILL.md +40 -24
- package/skills/memory-defrag/SKILL.md +18 -7
- package/skills/memory-doctor/SKILL.md +93 -0
- package/skills/memory-ingest/SKILL.md +35 -18
- package/skills/memory-lifecycle/SKILL.md +35 -22
- package/skills/memory-literary-analysis/SKILL.md +112 -75
- package/skills/memory-metadata-search/SKILL.md +39 -28
- package/skills/memory-notes/SKILL.md +75 -50
- package/skills/memory-okf/SKILL.md +27 -15
- package/skills/memory-quest/SKILL.md +24 -8
- package/skills/memory-reflect/SKILL.md +25 -13
- package/skills/memory-research/SKILL.md +28 -13
- package/skills/memory-schema/SKILL.md +36 -24
- package/skills/memory-start/SKILL.md +116 -0
- package/skills/memory-tasks/SKILL.md +34 -22
- package/tools/build-context.ts +14 -5
- package/tools/delete-note.ts +2 -2
- package/tools/edit-note.ts +27 -14
- package/tools/list-memory-projects.ts +6 -2
- package/tools/list-workspaces.ts +8 -5
- package/tools/move-note.ts +2 -2
- package/tools/read-note.ts +2 -2
- package/tools/schema-diff.ts +9 -5
- package/tools/schema-infer.ts +3 -3
- package/tools/schema-validate.ts +7 -6
- package/tools/search-notes.ts +18 -7
- package/tools/write-note.ts +12 -12
- package/dist/tools/memory-provider.d.ts +0 -15
- package/dist/tools/memory-provider.js +0 -275
- package/skills/memory-onboarding/SKILL.md +0 -142
- package/skills/memory-onboarding/evals/evals.json +0 -29
- package/skills/memory-onboarding/references/assistant-setup.md +0 -72
- package/skills/memory-onboarding/references/conventions.md +0 -118
- package/skills/memory-onboarding/references/domain-playbooks.md +0 -159
- package/skills/memory-onboarding/references/schema-guide.md +0 -136
- package/tools/memory-provider.ts +0 -336
package/commands/cli.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry"
|
|
2
|
-
import type
|
|
2
|
+
import { type BmClient, searchResultText } from "../bm-client.ts"
|
|
3
3
|
import type { BasicMemoryConfig } from "../config.ts"
|
|
4
4
|
import { log } from "../logger.ts"
|
|
5
5
|
|
|
@@ -31,13 +31,12 @@ export function registerCli(
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
for (const r of results) {
|
|
34
|
-
const score = r.score ? ` (${
|
|
34
|
+
const score = r.score ? ` (score ${r.score.toFixed(2)})` : ""
|
|
35
35
|
console.log(`- ${r.title}${score}`)
|
|
36
|
-
|
|
36
|
+
const text = searchResultText(r)
|
|
37
|
+
if (text) {
|
|
37
38
|
const preview =
|
|
38
|
-
|
|
39
|
-
? `${r.content.slice(0, 100)}...`
|
|
40
|
-
: r.content
|
|
39
|
+
text.length > 100 ? `${text.slice(0, 100)}...` : text
|
|
41
40
|
console.log(` ${preview}`)
|
|
42
41
|
}
|
|
43
42
|
}
|
package/commands/slash.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { execSync } from "node:child_process"
|
|
|
2
2
|
import { dirname, resolve } from "node:path"
|
|
3
3
|
import { fileURLToPath } from "node:url"
|
|
4
4
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry"
|
|
5
|
-
import type
|
|
5
|
+
import { type BmClient, describeToolError } from "../bm-client.ts"
|
|
6
6
|
import { log } from "../logger.ts"
|
|
7
7
|
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
@@ -62,7 +62,7 @@ export function registerCommands(
|
|
|
62
62
|
} catch (err) {
|
|
63
63
|
log.error("/remember failed", err)
|
|
64
64
|
return {
|
|
65
|
-
text:
|
|
65
|
+
text: `Failed to save memory: ${describeToolError(err)}`,
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
},
|
|
@@ -89,7 +89,7 @@ export function registerCommands(
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const lines = results.map((r, i) => {
|
|
92
|
-
const score = r.score ? ` (${
|
|
92
|
+
const score = r.score ? ` (score ${r.score.toFixed(2)})` : ""
|
|
93
93
|
return `${i + 1}. ${r.title}${score}`
|
|
94
94
|
})
|
|
95
95
|
|
|
@@ -99,7 +99,7 @@ export function registerCommands(
|
|
|
99
99
|
} catch (err) {
|
|
100
100
|
log.error("/recall failed", err)
|
|
101
101
|
return {
|
|
102
|
-
text:
|
|
102
|
+
text: `Failed to search: ${describeToolError(err)}`,
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
},
|
package/config.ts
CHANGED
|
@@ -7,6 +7,9 @@ export type BasicMemoryConfig = {
|
|
|
7
7
|
memoryDir: string
|
|
8
8
|
memoryFile: string
|
|
9
9
|
projectPath: string
|
|
10
|
+
// False when projectPath fell back to the workspace-root default, so
|
|
11
|
+
// startup may adopt an existing project of the same name where it lives.
|
|
12
|
+
projectPathConfigured: boolean
|
|
10
13
|
autoCapture: boolean
|
|
11
14
|
captureMinChars: number
|
|
12
15
|
autoRecall: boolean
|
|
@@ -100,6 +103,8 @@ export function parseConfig(raw: unknown): BasicMemoryConfig {
|
|
|
100
103
|
typeof cfg.projectPath === "string" && cfg.projectPath.length > 0
|
|
101
104
|
? cfg.projectPath
|
|
102
105
|
: ".",
|
|
106
|
+
projectPathConfigured:
|
|
107
|
+
typeof cfg.projectPath === "string" && cfg.projectPath.length > 0,
|
|
103
108
|
bmPath:
|
|
104
109
|
typeof cfg.bmPath === "string" && cfg.bmPath.length > 0
|
|
105
110
|
? cfg.bmPath
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AssembleResult,
|
|
3
|
-
BootstrapResult,
|
|
4
|
-
CompactResult,
|
|
5
|
-
ContextEngine,
|
|
6
|
-
SubagentSpawnPreparation,
|
|
7
|
-
} from "openclaw/plugin-sdk"
|
|
8
1
|
import { delegateCompactionToRuntime } from "openclaw/plugin-sdk/core"
|
|
9
2
|
import type { BmClient } from "../bm-client.ts"
|
|
10
3
|
import type { BasicMemoryConfig } from "../config.ts"
|
|
11
4
|
import { selectCaptureTurn } from "../hooks/capture.ts"
|
|
12
5
|
import { loadRecallState } from "../hooks/recall.ts"
|
|
13
6
|
import { log } from "../logger.ts"
|
|
7
|
+
import type {
|
|
8
|
+
AssembleResult,
|
|
9
|
+
BootstrapResult,
|
|
10
|
+
CommitTurnResult,
|
|
11
|
+
CompactResult,
|
|
12
|
+
ContextEngine,
|
|
13
|
+
SubagentSpawnPreparation,
|
|
14
|
+
} from "./types.ts"
|
|
14
15
|
|
|
15
16
|
export const MAX_ASSEMBLE_RECALL_CHARS = 1200
|
|
16
17
|
const TRUNCATED_RECALL_SUFFIX = "\n\n[Basic Memory recall truncated]"
|
|
17
18
|
const SUBAGENT_HANDOFF_FOLDER = "agent/subagents"
|
|
18
19
|
const MAX_SUBAGENT_RECALL_CHARS = 800
|
|
20
|
+
// OpenClaw's reply for "nothing to say", used by heartbeat polls and silent
|
|
21
|
+
// maintenance turns.
|
|
22
|
+
const SILENT_REPLY_TOKEN = "NO_REPLY"
|
|
19
23
|
|
|
20
24
|
type BootstrapParams = Parameters<NonNullable<ContextEngine["bootstrap"]>>[0]
|
|
21
25
|
type AssembleParams = Parameters<ContextEngine["assemble"]>[0]
|
|
22
26
|
type AfterTurnParams = Parameters<NonNullable<ContextEngine["afterTurn"]>>[0]
|
|
27
|
+
type CommitTurnParams = Parameters<NonNullable<ContextEngine["commitTurn"]>>[0]
|
|
23
28
|
type CompactParams = Parameters<ContextEngine["compact"]>[0]
|
|
24
29
|
type PrepareSubagentSpawnParams = Parameters<
|
|
25
30
|
NonNullable<ContextEngine["prepareSubagentSpawn"]>
|
|
@@ -53,6 +58,19 @@ function boundRecallContext(context: string): string {
|
|
|
53
58
|
return `${trimmed}${TRUNCATED_RECALL_SUFFIX}`
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Heartbeat polls and silent replies are host housekeeping, not
|
|
63
|
+
* conversation, so they are acknowledged without being recorded.
|
|
64
|
+
*/
|
|
65
|
+
function isHousekeepingTurn(
|
|
66
|
+
isHeartbeat: boolean | undefined,
|
|
67
|
+
turn: { assistantText: string },
|
|
68
|
+
): boolean {
|
|
69
|
+
return (
|
|
70
|
+
isHeartbeat === true || turn.assistantText.trim() === SILENT_REPLY_TOKEN
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
56
74
|
function slugifySessionKey(sessionKey: string): string {
|
|
57
75
|
return sessionKey
|
|
58
76
|
.toLowerCase()
|
|
@@ -98,7 +116,7 @@ function buildSubagentCompletionUpdate(params: {
|
|
|
98
116
|
}): string {
|
|
99
117
|
const statusLine =
|
|
100
118
|
params.reason === "completed"
|
|
101
|
-
? "Child run completed. Durable conversation capture continues through the normal
|
|
119
|
+
? "Child run completed. Durable conversation capture continues through the normal turn commit path."
|
|
102
120
|
: `Child run ended with reason: ${params.reason}.`
|
|
103
121
|
|
|
104
122
|
return [
|
|
@@ -118,6 +136,18 @@ export class BasicMemoryContextEngine implements ContextEngine {
|
|
|
118
136
|
name: "Basic Memory Context Engine",
|
|
119
137
|
version: "0.1.5",
|
|
120
138
|
ownsCompaction: false,
|
|
139
|
+
// OpenClaw 2026.10+ runs an engine for durable turns only when it
|
|
140
|
+
// declares both semantics; otherwise the turn degrades to "legacy" and
|
|
141
|
+
// nothing is captured (#1880).
|
|
142
|
+
// - The fence holds because assemble() passes the host's messages through
|
|
143
|
+
// unchanged and the engine keeps no transcript of its own, so it never
|
|
144
|
+
// reads past the admitted user entry.
|
|
145
|
+
// - Advancement is idempotent because commitTurn() records the
|
|
146
|
+
// advancement key in the conversation note and skips keys it has seen.
|
|
147
|
+
transcriptSemantics: {
|
|
148
|
+
currentTurnFence: "before-current-turn-entry-v1",
|
|
149
|
+
turnAdvancementIdempotency: "atomic-idempotent-v1",
|
|
150
|
+
},
|
|
121
151
|
} as const
|
|
122
152
|
|
|
123
153
|
private readonly sessionState = new Map<string, SessionMemoryState>()
|
|
@@ -171,6 +201,41 @@ export class BasicMemoryContextEngine implements ContextEngine {
|
|
|
171
201
|
}
|
|
172
202
|
}
|
|
173
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Capture one accepted turn on hosts with durable turn advancement.
|
|
206
|
+
*
|
|
207
|
+
* The host calls this instead of afterTurn() for admitted turns, and may
|
|
208
|
+
* call it again with the same advancement key after a crash. Errors
|
|
209
|
+
* propagate so the host keeps the turn queued and retries it.
|
|
210
|
+
*/
|
|
211
|
+
async commitTurn(params: CommitTurnParams): Promise<CommitTurnResult> {
|
|
212
|
+
if (!this.cfg.autoCapture) return { status: "committed" }
|
|
213
|
+
|
|
214
|
+
// messages spans exactly the admitted user entry through the terminal
|
|
215
|
+
// entry, so the whole payload is the current turn.
|
|
216
|
+
const turn = selectCaptureTurn(params.messages, this.cfg.captureMinChars)
|
|
217
|
+
if (!turn || isHousekeepingTurn(params.isHeartbeat, turn)) {
|
|
218
|
+
return { status: "committed" }
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
log.debug(
|
|
222
|
+
`context-engine commitTurn: session=${params.sessionId} user=${turn.userText.length} assistant=${turn.assistantText.length}`,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
const status = await this.client.indexConversation(
|
|
226
|
+
turn.userText,
|
|
227
|
+
turn.assistantText,
|
|
228
|
+
{ turnKey: params.advancementKey },
|
|
229
|
+
)
|
|
230
|
+
return { status }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Capture fallback for hosts that predate commitTurn().
|
|
235
|
+
*
|
|
236
|
+
* Hosts that route a turn through commitTurn() skip afterTurn() for that
|
|
237
|
+
* turn, so the two paths never record the same exchange.
|
|
238
|
+
*/
|
|
174
239
|
async afterTurn(params: AfterTurnParams): Promise<void> {
|
|
175
240
|
if (!this.cfg.autoCapture) return
|
|
176
241
|
|
|
@@ -179,7 +244,7 @@ export class BasicMemoryContextEngine implements ContextEngine {
|
|
|
179
244
|
selectCaptureTurn(newMessages, this.cfg.captureMinChars) ??
|
|
180
245
|
selectCaptureTurn(params.messages, this.cfg.captureMinChars)
|
|
181
246
|
|
|
182
|
-
if (!turn) return
|
|
247
|
+
if (!turn || isHousekeepingTurn(params.isHeartbeat, turn)) return
|
|
183
248
|
|
|
184
249
|
log.debug(
|
|
185
250
|
`context-engine afterTurn: session=${params.sessionId} user=${turn.userText.length} assistant=${turn.assistantText.length}`,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core"
|
|
2
|
+
|
|
3
|
+
// OpenClaw 2026.10 dropped the bare "openclaw/plugin-sdk" entry point that used
|
|
4
|
+
// to export ContextEngine and its result types. Derive them from the public
|
|
5
|
+
// registerContextEngine signature so we depend only on plugin-sdk/core.
|
|
6
|
+
type ContextEngineFactory = Parameters<
|
|
7
|
+
OpenClawPluginApi["registerContextEngine"]
|
|
8
|
+
>[1]
|
|
9
|
+
|
|
10
|
+
export type ContextEngine = Awaited<ReturnType<ContextEngineFactory>>
|
|
11
|
+
export type AssembleResult = Awaited<ReturnType<ContextEngine["assemble"]>>
|
|
12
|
+
export type BootstrapResult = Awaited<
|
|
13
|
+
ReturnType<NonNullable<ContextEngine["bootstrap"]>>
|
|
14
|
+
>
|
|
15
|
+
export type CompactResult = Awaited<ReturnType<ContextEngine["compact"]>>
|
|
16
|
+
export type SubagentSpawnPreparation = NonNullable<
|
|
17
|
+
Awaited<ReturnType<NonNullable<ContextEngine["prepareSubagentSpawn"]>>>
|
|
18
|
+
>
|
|
19
|
+
export type CommitTurnResult = Awaited<
|
|
20
|
+
ReturnType<NonNullable<ContextEngine["commitTurn"]>>
|
|
21
|
+
>
|
package/dist/bm-client.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
export declare class ProjectUnavailableError extends Error {
|
|
2
|
+
readonly project: string;
|
|
3
|
+
readonly reason: string;
|
|
4
|
+
constructor(project: string, reason: string);
|
|
5
|
+
}
|
|
1
6
|
export declare class NoteAlreadyExistsError extends Error {
|
|
2
7
|
readonly permalink: string;
|
|
3
|
-
constructor(title: string, permalink: string);
|
|
8
|
+
constructor(title: string, permalink: string, message?: string);
|
|
4
9
|
}
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* bm_write refused a conditional overwrite: the note is no longer the
|
|
7
12
|
* revision named by expected_checksum. Nothing was written; currentChecksum is
|
|
8
|
-
*
|
|
13
|
+
* available revision when supplied by a server. A null value means unknown;
|
|
14
|
+
* 1.0 puts revision details in the refusal message, not a checksum field.
|
|
9
15
|
*/
|
|
10
16
|
export declare class NoteRevisionConflictError extends Error {
|
|
11
17
|
readonly permalink: string | null;
|
|
12
18
|
readonly currentChecksum: string | null;
|
|
13
|
-
constructor(title: string, permalink: string | null, currentChecksum: string | null);
|
|
19
|
+
constructor(title: string, permalink: string | null, currentChecksum: string | null, message?: string);
|
|
14
20
|
}
|
|
15
21
|
/** A BM MCP tool returned isError; toolMessage is the tool's own error text. */
|
|
16
22
|
export declare class BmToolError extends Error {
|
|
@@ -24,7 +30,14 @@ export interface SearchResult {
|
|
|
24
30
|
content: string;
|
|
25
31
|
score?: number;
|
|
26
32
|
file_path: string;
|
|
33
|
+
matched_chunk?: string | null;
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The text to preview for a search hit. `content` is the start of the note,
|
|
37
|
+
* so for a long note (a day of captured conversation) the matching part can
|
|
38
|
+
* sit far below any preview cut-off; the matched chunk is the part that hit.
|
|
39
|
+
*/
|
|
40
|
+
export declare function searchResultText(result: SearchResult): string;
|
|
28
41
|
export interface NoteResult {
|
|
29
42
|
title: string;
|
|
30
43
|
permalink: string;
|
|
@@ -38,7 +51,7 @@ export interface EditNoteResult {
|
|
|
38
51
|
title: string;
|
|
39
52
|
permalink: string;
|
|
40
53
|
file_path: string;
|
|
41
|
-
operation:
|
|
54
|
+
operation: EditOperation;
|
|
42
55
|
checksum?: string | null;
|
|
43
56
|
}
|
|
44
57
|
interface ReadNoteOptions {
|
|
@@ -55,6 +68,7 @@ interface WriteNoteOptions {
|
|
|
55
68
|
/** Checksum of the revision read; overwrite only while it is still current. */
|
|
56
69
|
expectedChecksum?: string;
|
|
57
70
|
}
|
|
71
|
+
export type EditOperation = "append" | "prepend" | "find_replace" | "replace_section" | "insert_before_section" | "insert_after_section";
|
|
58
72
|
interface EditNoteOptions {
|
|
59
73
|
find_text?: string;
|
|
60
74
|
section?: string;
|
|
@@ -74,7 +88,8 @@ export interface ContextResult {
|
|
|
74
88
|
permalink: string;
|
|
75
89
|
relation_type?: string;
|
|
76
90
|
from_entity?: string;
|
|
77
|
-
to_entity?: string;
|
|
91
|
+
to_entity?: string | null;
|
|
92
|
+
to_name?: string | null;
|
|
78
93
|
}>;
|
|
79
94
|
}>;
|
|
80
95
|
}
|
|
@@ -87,6 +102,7 @@ export interface RecentResult {
|
|
|
87
102
|
export interface ProjectListResult {
|
|
88
103
|
name: string;
|
|
89
104
|
path: string;
|
|
105
|
+
local_path?: string | null;
|
|
90
106
|
external_id?: string | null;
|
|
91
107
|
source?: string | null;
|
|
92
108
|
qualified_name?: string | null;
|
|
@@ -102,27 +118,34 @@ export interface ProjectListResult {
|
|
|
102
118
|
export interface WorkspaceResult {
|
|
103
119
|
tenant_id: string;
|
|
104
120
|
name: string;
|
|
105
|
-
workspace_type: string;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
workspace_type: string | null;
|
|
122
|
+
}
|
|
123
|
+
export interface SchemaNoteValidation {
|
|
124
|
+
note_identifier: string;
|
|
125
|
+
schema_entity: string;
|
|
126
|
+
passed: boolean;
|
|
127
|
+
warnings: string[];
|
|
128
|
+
errors: string[];
|
|
109
129
|
}
|
|
110
130
|
export interface SchemaValidationResult {
|
|
111
|
-
|
|
131
|
+
note_type?: string | null;
|
|
112
132
|
total_notes: number;
|
|
113
133
|
total_entities: number;
|
|
114
134
|
valid_count: number;
|
|
115
135
|
warning_count: number;
|
|
116
136
|
error_count: number;
|
|
117
|
-
results:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
results: SchemaNoteValidation[];
|
|
138
|
+
type_summaries?: Array<{
|
|
139
|
+
note_type: string;
|
|
140
|
+
total_notes: number;
|
|
141
|
+
total_entities: number;
|
|
142
|
+
valid_count: number;
|
|
143
|
+
warning_count: number;
|
|
144
|
+
error_count: number;
|
|
122
145
|
}>;
|
|
123
146
|
}
|
|
124
147
|
export interface SchemaInferResult {
|
|
125
|
-
|
|
148
|
+
note_type: string;
|
|
126
149
|
notes_analyzed: number;
|
|
127
150
|
field_frequencies: Array<{
|
|
128
151
|
name: string;
|
|
@@ -139,38 +162,69 @@ export interface SchemaInferResult {
|
|
|
139
162
|
suggested_optional: string[];
|
|
140
163
|
excluded: string[];
|
|
141
164
|
}
|
|
165
|
+
export interface SchemaDriftField {
|
|
166
|
+
name: string;
|
|
167
|
+
source: string;
|
|
168
|
+
count: number;
|
|
169
|
+
total: number;
|
|
170
|
+
percentage: number;
|
|
171
|
+
}
|
|
142
172
|
export interface SchemaDiffResult {
|
|
143
|
-
|
|
173
|
+
note_type: string;
|
|
144
174
|
schema_found: boolean;
|
|
145
|
-
new_fields:
|
|
146
|
-
|
|
147
|
-
source: string;
|
|
148
|
-
count: number;
|
|
149
|
-
total: number;
|
|
150
|
-
percentage: number;
|
|
151
|
-
}>;
|
|
152
|
-
dropped_fields: Array<{
|
|
153
|
-
name: string;
|
|
154
|
-
source: string;
|
|
155
|
-
declared_in?: string;
|
|
156
|
-
}>;
|
|
175
|
+
new_fields: SchemaDriftField[];
|
|
176
|
+
dropped_fields: SchemaDriftField[];
|
|
157
177
|
cardinality_changes: string[];
|
|
178
|
+
notes_compared?: number | null;
|
|
158
179
|
}
|
|
180
|
+
export declare function isNoteNotFoundError(err: unknown): boolean;
|
|
181
|
+
export type ConversationCaptureStatus = "committed" | "duplicate";
|
|
182
|
+
/**
|
|
183
|
+
* The server's own explanation of a failed tool call, for showing to an agent.
|
|
184
|
+
* A refusal payload becomes "CODE: message"; other tool text passes through.
|
|
185
|
+
*/
|
|
186
|
+
export declare function describeToolError(err: unknown): string;
|
|
187
|
+
/** describeToolError, but saying plainly when the note does not exist. */
|
|
188
|
+
export declare function describeNoteError(err: unknown): string;
|
|
159
189
|
export declare class BmClient {
|
|
160
190
|
private bmPath;
|
|
161
191
|
private project;
|
|
162
192
|
private cwd?;
|
|
163
193
|
private env?;
|
|
164
194
|
private shouldRun;
|
|
195
|
+
private serviceRunning;
|
|
196
|
+
private startup;
|
|
197
|
+
private startupRetry;
|
|
198
|
+
private projectPath?;
|
|
199
|
+
private adoptExistingProject;
|
|
200
|
+
private projectSetupError;
|
|
201
|
+
private prepare?;
|
|
165
202
|
private client;
|
|
166
203
|
private transport;
|
|
167
204
|
private connectPromise;
|
|
168
205
|
private retryDelaysMs;
|
|
206
|
+
private conversationWrites;
|
|
169
207
|
constructor(bmPath: string, project: string);
|
|
208
|
+
/**
|
|
209
|
+
* Connect to BM and create the plugin's project.
|
|
210
|
+
*
|
|
211
|
+
* Returns the startup promise; callers that must not block (the plugin
|
|
212
|
+
* service, which OpenClaw gives only a few seconds) can leave it running.
|
|
213
|
+
* Tool calls made meanwhile wait for it. If it fails, the next tool call
|
|
214
|
+
* runs it again, so a transient failure does not leave the plugin dead.
|
|
215
|
+
*/
|
|
170
216
|
start(options?: {
|
|
171
217
|
cwd?: string;
|
|
172
218
|
env?: Record<string, string>;
|
|
219
|
+
projectPath?: string;
|
|
220
|
+
adoptExistingProject?: boolean;
|
|
221
|
+
prepare?: () => Promise<void>;
|
|
173
222
|
}): Promise<void>;
|
|
223
|
+
private runStartup;
|
|
224
|
+
private startupProjectPath;
|
|
225
|
+
projectUnavailableReason(): string | null;
|
|
226
|
+
private waitForStartup;
|
|
227
|
+
isServiceRunning(): boolean;
|
|
174
228
|
stop(): Promise<void>;
|
|
175
229
|
private connectWithRetries;
|
|
176
230
|
private ensureConnected;
|
|
@@ -179,9 +233,12 @@ export declare class BmClient {
|
|
|
179
233
|
private disconnectCurrent;
|
|
180
234
|
private callToolRaw;
|
|
181
235
|
private callTool;
|
|
236
|
+
private callStructured;
|
|
237
|
+
private targetsPluginProject;
|
|
182
238
|
private routedProject;
|
|
183
239
|
private routing;
|
|
184
240
|
ensureProject(projectPath: string): Promise<void>;
|
|
241
|
+
private createProject;
|
|
185
242
|
listWorkspaces(): Promise<WorkspaceResult[]>;
|
|
186
243
|
listProjects(workspace?: string): Promise<ProjectListResult[]>;
|
|
187
244
|
search(query?: string, limit?: number, project?: string, metadata?: {
|
|
@@ -195,7 +252,7 @@ export declare class BmClient {
|
|
|
195
252
|
writeNote(title: string, content: string, folder: string, project?: string, overwrite?: boolean, options?: WriteNoteOptions): Promise<NoteResult>;
|
|
196
253
|
buildContext(url: string, depth?: number, project?: string): Promise<ContextResult>;
|
|
197
254
|
recentActivity(timeframe?: string, project?: string): Promise<RecentResult[]>;
|
|
198
|
-
editNote(identifier: string, operation:
|
|
255
|
+
editNote(identifier: string, operation: EditOperation, content: string, options?: EditNoteOptions, project?: string): Promise<EditNoteResult>;
|
|
199
256
|
deleteNote(identifier: string, project?: string): Promise<{
|
|
200
257
|
title: string;
|
|
201
258
|
permalink: string;
|
|
@@ -205,7 +262,19 @@ export declare class BmClient {
|
|
|
205
262
|
schemaValidate(noteType?: string, identifier?: string, project?: string): Promise<SchemaValidationResult>;
|
|
206
263
|
schemaInfer(noteType: string, threshold?: number, project?: string): Promise<SchemaInferResult>;
|
|
207
264
|
schemaDiff(noteType: string, project?: string): Promise<SchemaDiffResult>;
|
|
208
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Append one user/assistant exchange to today's conversation note.
|
|
267
|
+
*
|
|
268
|
+
* With a turnKey the capture is idempotent: the entry carries a marker
|
|
269
|
+
* derived from the key, and a key already present in today's or
|
|
270
|
+
* yesterday's note is reported as a duplicate instead of written again.
|
|
271
|
+
* Yesterday is checked because a host retry can cross midnight.
|
|
272
|
+
*/
|
|
273
|
+
indexConversation(userMessage: string, assistantResponse: string, options?: {
|
|
274
|
+
turnKey?: string;
|
|
275
|
+
}): Promise<ConversationCaptureStatus>;
|
|
276
|
+
private writeConversationEntry;
|
|
277
|
+
private noteContains;
|
|
209
278
|
getProject(): string;
|
|
210
279
|
}
|
|
211
280
|
export {};
|