mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-10 04:40:47 +08:00
Fix KB local tool schemas so Netx Ops preset can mount.
DSH defineTool expects a flat parameter map; full JSON Schema objects broke hosts with KB configured (0.1.35). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
da08c38949
commit
62d3f565ce
8 changed files with 272 additions and 425 deletions
|
|
@ -672,6 +672,11 @@ function watchKbContext(listener) {
|
|||
var str = (description) => ({ type: "string", ...description ? { description } : {} });
|
||||
var bool = (description) => ({ type: "boolean", ...description ? { description } : {} });
|
||||
var num = (description) => ({ type: "number", ...description ? { description } : {} });
|
||||
var reqStr = (description) => ({
|
||||
type: "string",
|
||||
required: true,
|
||||
...description ? { description } : {}
|
||||
});
|
||||
function renderJson(_args, value) {
|
||||
return [{ type: "text", text: JSON.stringify(value, null, 0) }];
|
||||
}
|
||||
|
|
@ -708,20 +713,16 @@ function registerKbLocalTools(ctx, snapshot = getKbContext()) {
|
|||
return () => {};
|
||||
const entries = [
|
||||
tool("netx__kbWriteMemory", `Create (or overwrite) one diary-style memory markdown under ${localRoot}/memories/. ` + "bucket: note→日常笔记, rca_review→排障复盘, ai_trace→AI思维链. " + "Default create-only; set overwrite=true to replace same filename. " + "Do not use workspace Write — KB is outside the sandbox.", {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
required: ["bucket", "slug", "body"],
|
||||
properties: {
|
||||
bucket: {
|
||||
type: "string",
|
||||
enum: ["note", "rca_review", "ai_trace"],
|
||||
description: "Memory subdirectory"
|
||||
},
|
||||
slug: str("Short filename stem (no path separators)"),
|
||||
body: str("Full markdown body"),
|
||||
date: str("Optional YYYY-MM-DD (default today)"),
|
||||
overwrite: bool("Replace if the target file already exists")
|
||||
}
|
||||
bucket: {
|
||||
type: "string",
|
||||
required: true,
|
||||
enum: ["note", "rca_review", "ai_trace"],
|
||||
description: "Memory subdirectory"
|
||||
},
|
||||
slug: reqStr("Short filename stem (no path separators)"),
|
||||
body: reqStr("Full markdown body"),
|
||||
date: str("Optional YYYY-MM-DD (default today)"),
|
||||
overwrite: bool("Replace if the target file already exists")
|
||||
}, (args) => createMemory(liveSnapshot(), {
|
||||
bucket: args.bucket,
|
||||
slug: String(args.slug ?? ""),
|
||||
|
|
@ -730,16 +731,11 @@ function registerKbLocalTools(ctx, snapshot = getKbContext()) {
|
|||
overwrite: args.overwrite === true
|
||||
})),
|
||||
tool("netx__kbWriteDraft", `Create (or overwrite) a DRAFT case under ${localRoot}/drafts/. ` + "Filename is forced to DRAFT-YYYYMMDD-…; body gets status: draft frontmatter if missing. " + "Set overwrite=true to replace. Not for identity/ or formal RCA.", {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
required: ["slug", "body"],
|
||||
properties: {
|
||||
slug: str("Case stem (DRAFT- prefix added if missing)"),
|
||||
body: str("Markdown body (RCA-ish draft)"),
|
||||
domain: str("Optional fault-domain subfolder under drafts/"),
|
||||
date: str("Optional event date YYYY-MM-DD or YYYYMMDD"),
|
||||
overwrite: bool("Replace if the target file already exists")
|
||||
}
|
||||
slug: reqStr("Case stem (DRAFT- prefix added if missing)"),
|
||||
body: reqStr("Markdown body (RCA-ish draft)"),
|
||||
domain: str("Optional fault-domain subfolder under drafts/"),
|
||||
date: str("Optional event date YYYY-MM-DD or YYYYMMDD"),
|
||||
overwrite: bool("Replace if the target file already exists")
|
||||
}, (args) => createDraft(liveSnapshot(), {
|
||||
slug: String(args.slug ?? ""),
|
||||
body: String(args.body ?? ""),
|
||||
|
|
@ -748,20 +744,16 @@ function registerKbLocalTools(ctx, snapshot = getKbContext()) {
|
|||
overwrite: args.overwrite === true
|
||||
})),
|
||||
tool("netx__kbWriteSuggestion", `Create (or overwrite) a suggestion under ${localRoot}/suggestions/{theory|improvement}/. ` + "Use for theory corrections or tool/process improvements — never rewrite identity/.", {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
required: ["kind", "slug", "body"],
|
||||
properties: {
|
||||
kind: {
|
||||
type: "string",
|
||||
enum: ["theory", "improvement"],
|
||||
description: "theory = knowledge fix; improvement = tools/skills/process"
|
||||
},
|
||||
slug: str("Short filename stem"),
|
||||
body: str("Full markdown body"),
|
||||
date: str("Optional YYYY-MM-DD (default today)"),
|
||||
overwrite: bool("Replace if the target file already exists")
|
||||
}
|
||||
kind: {
|
||||
type: "string",
|
||||
required: true,
|
||||
enum: ["theory", "improvement"],
|
||||
description: "theory = knowledge fix; improvement = tools/skills/process"
|
||||
},
|
||||
slug: reqStr("Short filename stem"),
|
||||
body: reqStr("Full markdown body"),
|
||||
date: str("Optional YYYY-MM-DD (default today)"),
|
||||
overwrite: bool("Replace if the target file already exists")
|
||||
}, (args) => createSuggestion(liveSnapshot(), {
|
||||
kind: args.kind,
|
||||
slug: String(args.slug ?? ""),
|
||||
|
|
@ -770,38 +762,24 @@ function registerKbLocalTools(ctx, snapshot = getKbContext()) {
|
|||
overwrite: args.overwrite === true
|
||||
})),
|
||||
tool("netx__kbUpdateLocal", `Replace the body of an existing file under memories|drafts|suggestions ` + `(absolute path or path relative to ${localRoot}). ` + "Cannot touch identity/ or outside paths.local. Drafts keep status: draft.", {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
required: ["path", "body"],
|
||||
properties: {
|
||||
path: str("Absolute path or path relative to KB local root"),
|
||||
body: str("New full markdown body")
|
||||
}
|
||||
path: reqStr("Absolute path or path relative to KB local root"),
|
||||
body: reqStr("New full markdown body")
|
||||
}, (args) => updateLocalFile(liveSnapshot(), {
|
||||
path: String(args.path ?? ""),
|
||||
body: String(args.body ?? "")
|
||||
})),
|
||||
tool("netx__kbDeleteLocal", `Delete one existing markdown under memories|drafts|suggestions ` + `(absolute or relative to ${localRoot}). Refuses identity/ and escapes.`, {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
required: ["path"],
|
||||
properties: {
|
||||
path: str("Absolute path or path relative to KB local root")
|
||||
}
|
||||
path: reqStr("Absolute path or path relative to KB local root")
|
||||
}, (args) => deleteLocalFile(liveSnapshot(), {
|
||||
path: String(args.path ?? "")
|
||||
})),
|
||||
tool("netx__kbListLocal", `List recent .md files under ${localRoot} memories|drafts|suggestions (newest first). ` + "Does not include identity/. Read contents via absolute paths from the listing.", {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
root: {
|
||||
type: "string",
|
||||
enum: ["memories", "drafts", "suggestions", "all"],
|
||||
description: "Subtree to list (default all writable)"
|
||||
},
|
||||
limit: num("Max entries 1–200 (default 50)")
|
||||
}
|
||||
root: {
|
||||
type: "string",
|
||||
enum: ["memories", "drafts", "suggestions", "all"],
|
||||
description: "Subtree to list (default all writable)"
|
||||
},
|
||||
limit: num("Max entries 1–200 (default 50)")
|
||||
}, (args) => listLocalFiles(liveSnapshot(), {
|
||||
root: args.root ?? "all",
|
||||
limit: typeof args.limit === "number" ? args.limit : undefined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue