keywordgraph-mcp-server 1.7.3 → 1.8.4
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 +81 -3
- package/dist/api/client.d.ts +3 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -1
- package/dist/api/client.js.map +1 -1
- package/dist/api/config-store.d.ts +11 -0
- package/dist/api/config-store.d.ts.map +1 -1
- package/dist/api/config-store.js +7 -0
- package/dist/api/config-store.js.map +1 -1
- package/dist/config/brand.d.ts.map +1 -1
- package/dist/config/brand.js +11 -0
- package/dist/config/brand.js.map +1 -1
- package/dist/http-server.js +3 -1
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -11
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +9 -2
- package/dist/instructions.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +32 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/resources/about.d.ts.map +1 -1
- package/dist/resources/about.js +9 -1
- package/dist/resources/about.js.map +1 -1
- package/dist/schemas/index.d.ts +353 -63
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +407 -31
- package/dist/schemas/index.js.map +1 -1
- package/dist/tools/addProjectLearnings.d.ts +30 -0
- package/dist/tools/addProjectLearnings.d.ts.map +1 -0
- package/dist/tools/addProjectLearnings.js +197 -0
- package/dist/tools/addProjectLearnings.js.map +1 -0
- package/dist/tools/analyzeLlmResults.d.ts +1 -1
- package/dist/tools/analyzeLlmResults.d.ts.map +1 -1
- package/dist/tools/analyzeLlmResults.js +5 -2
- package/dist/tools/analyzeLlmResults.js.map +1 -1
- package/dist/tools/deleteGraph.d.ts +43 -0
- package/dist/tools/deleteGraph.d.ts.map +1 -0
- package/dist/tools/deleteGraph.js +145 -0
- package/dist/tools/deleteGraph.js.map +1 -0
- package/dist/tools/deleteStatements.d.ts +106 -0
- package/dist/tools/deleteStatements.d.ts.map +1 -0
- package/dist/tools/deleteStatements.js +288 -0
- package/dist/tools/deleteStatements.js.map +1 -0
- package/dist/tools/developConceptualBridges.d.ts +1 -1
- package/dist/tools/developLatentTopics.d.ts +1 -1
- package/dist/tools/developTextTool.d.ts +1 -1
- package/dist/tools/enableProjectLearnings.d.ts +27 -0
- package/dist/tools/enableProjectLearnings.d.ts.map +1 -0
- package/dist/tools/enableProjectLearnings.js +68 -0
- package/dist/tools/enableProjectLearnings.js.map +1 -0
- package/dist/tools/generateOntologyGraph.d.ts +10 -3
- package/dist/tools/generateOntologyGraph.d.ts.map +1 -1
- package/dist/tools/generateOntologyGraph.js +142 -34
- package/dist/tools/generateOntologyGraph.js.map +1 -1
- package/dist/tools/generateResearchIdeas.d.ts +1 -1
- package/dist/tools/generateResearchQuestions.d.ts +1 -1
- package/dist/tools/generateResponses.d.ts +1 -1
- package/dist/tools/getProjectLearnings.d.ts +30 -0
- package/dist/tools/getProjectLearnings.d.ts.map +1 -0
- package/dist/tools/getProjectLearnings.js +151 -0
- package/dist/tools/getProjectLearnings.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/optimizeKnowledgeBase.d.ts +40 -0
- package/dist/tools/optimizeKnowledgeBase.d.ts.map +1 -0
- package/dist/tools/optimizeKnowledgeBase.js +230 -0
- package/dist/tools/optimizeKnowledgeBase.js.map +1 -0
- package/dist/tools/optimizeReasoning.d.ts +1 -1
- package/dist/tools/optimizeTextStructure.d.ts +1 -1
- package/dist/tools/submitWorkflowFeedback.d.ts +35 -0
- package/dist/tools/submitWorkflowFeedback.d.ts.map +1 -0
- package/dist/tools/submitWorkflowFeedback.js +62 -0
- package/dist/tools/submitWorkflowFeedback.js.map +1 -0
- package/dist/tools/updateStatements.d.ts +134 -0
- package/dist/tools/updateStatements.d.ts.map +1 -0
- package/dist/tools/updateStatements.js +378 -0
- package/dist/tools/updateStatements.js.map +1 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/callTracking.d.ts +29 -0
- package/dist/utils/callTracking.d.ts.map +1 -0
- package/dist/utils/callTracking.js +88 -0
- package/dist/utils/callTracking.js.map +1 -0
- package/dist/utils/feedback.d.ts +63 -0
- package/dist/utils/feedback.d.ts.map +1 -0
- package/dist/utils/feedback.js +115 -0
- package/dist/utils/feedback.js.map +1 -0
- package/dist/utils/graphInput.d.ts +1 -0
- package/dist/utils/graphInput.d.ts.map +1 -1
- package/dist/utils/graphInput.js +1 -1
- package/dist/utils/graphInput.js.map +1 -1
- package/dist/utils/graphLookup.d.ts +29 -0
- package/dist/utils/graphLookup.d.ts.map +1 -0
- package/dist/utils/graphLookup.js +57 -0
- package/dist/utils/graphLookup.js.map +1 -0
- package/dist/utils/knowledgeBase.d.ts +21 -0
- package/dist/utils/knowledgeBase.d.ts.map +1 -0
- package/dist/utils/knowledgeBase.js +110 -0
- package/dist/utils/knowledgeBase.js.map +1 -0
- package/dist/utils/learnings.d.ts +119 -0
- package/dist/utils/learnings.d.ts.map +1 -0
- package/dist/utils/learnings.js +337 -0
- package/dist/utils/learnings.js.map +1 -0
- package/llms-full.infranodus.txt +39 -1
- package/llms-full.txt +39 -1
- package/llms.infranodus.txt +2 -0
- package/llms.txt +2 -0
- package/package.json +3 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { brand } from "../config/brand.js";
|
|
2
|
+
import { DeleteGraphSchema } from "../schemas/index.js";
|
|
3
|
+
import { makeInfraNodusRequest } from "../api/client.js";
|
|
4
|
+
import { errorText, findGraphByName } from "../utils/graphLookup.js";
|
|
5
|
+
import { describeRequestError } from "./deleteStatements.js";
|
|
6
|
+
function textResult(payload, isError = false) {
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{ type: "text", text: JSON.stringify(payload, null, 2) },
|
|
10
|
+
],
|
|
11
|
+
...(isError ? { isError: true } : {}),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async function requestGraphDeletion(graphName, dryRun) {
|
|
15
|
+
try {
|
|
16
|
+
const data = (await makeInfraNodusRequest("/deleteGraph", {
|
|
17
|
+
name: graphName,
|
|
18
|
+
dryRun,
|
|
19
|
+
}));
|
|
20
|
+
if (!data || typeof data !== "object") {
|
|
21
|
+
return { ok: false, error: "Unexpected response from /deleteGraph." };
|
|
22
|
+
}
|
|
23
|
+
if (data.error)
|
|
24
|
+
return { ok: false, error: errorText(data.error) };
|
|
25
|
+
return { ok: true, data };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return { ok: false, error: describeRequestError(error) };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ask the user directly through MCP elicitation: a plain Accept / Decline
|
|
33
|
+
* (the spec defines "accept" as explicit approval; no extra form field, see
|
|
34
|
+
* delete_statements). A dismissed dialog or a client without the capability
|
|
35
|
+
* is "unavailable": the caller then returns the dry run so the question can
|
|
36
|
+
* be asked in chat.
|
|
37
|
+
*/
|
|
38
|
+
async function elicitApproval(extra, graphName, plan) {
|
|
39
|
+
if (!extra?.elicit || !extra.clientCapabilities?.elicitation) {
|
|
40
|
+
return { kind: "unavailable", detail: "client does not support elicitation" };
|
|
41
|
+
}
|
|
42
|
+
const lines = [
|
|
43
|
+
`Permanently delete the graph "${graphName}" from ${brand.name}, with all of its statements? This cannot be undone.`,
|
|
44
|
+
...(plan.isLive ? ["It is a live graph: its scheduled imports will stop."] : []),
|
|
45
|
+
...(plan.graphUrl ? ["", plan.graphUrl] : []),
|
|
46
|
+
];
|
|
47
|
+
try {
|
|
48
|
+
const result = await extra.elicit({
|
|
49
|
+
message: lines.join("\n"),
|
|
50
|
+
requestedSchema: { type: "object", properties: {} },
|
|
51
|
+
});
|
|
52
|
+
if (result.action === "accept")
|
|
53
|
+
return { kind: "accepted" };
|
|
54
|
+
if (result.action === "decline")
|
|
55
|
+
return { kind: "declined" };
|
|
56
|
+
return { kind: "unavailable", detail: "the user dismissed the dialog without answering" };
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return {
|
|
60
|
+
kind: "unavailable",
|
|
61
|
+
detail: `elicitation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export const deleteGraphTool = {
|
|
66
|
+
name: "delete_graph",
|
|
67
|
+
definition: {
|
|
68
|
+
title: `Delete a ${brand.name} Graph`,
|
|
69
|
+
description: `Delete one graph from the user's own ${brand.name} account entirely — all of its statements, revisions, settings, and its URL; the name becomes free again. IRREVERSIBLE once confirmed. ` +
|
|
70
|
+
`To empty a graph but keep it (for a rebuild in place), use delete_statements with deleteAll instead. ` +
|
|
71
|
+
`By default this is a DRY RUN: the response confirms the graph exists and reports its URL and whether it is a live graph, and nothing is deleted. Show that to the user; only if they agree, call again with the SAME graphName and confirm: true. If the client supports elicitation the user is asked directly and the deletion happens in the same call. ` +
|
|
72
|
+
`Never call this on your own initiative — only when the user asked to delete a graph. Only graphs in the user's own account can be targeted (there is no userName parameter); a name that is not in the account is an error and nothing is deleted.`,
|
|
73
|
+
inputSchema: DeleteGraphSchema.shape,
|
|
74
|
+
annotations: {
|
|
75
|
+
readOnlyHint: false,
|
|
76
|
+
destructiveHint: true,
|
|
77
|
+
idempotentHint: false,
|
|
78
|
+
openWorldHint: false,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
handler: async (params, extra) => {
|
|
82
|
+
try {
|
|
83
|
+
const graphName = params.graphName.trim();
|
|
84
|
+
// 1. The graph must exist in this account.
|
|
85
|
+
const graph = await findGraphByName(graphName);
|
|
86
|
+
if (!graph) {
|
|
87
|
+
return textResult({
|
|
88
|
+
error: `No graph named "${graphName}" in this ${brand.name} account. Nothing was deleted. Use list_graphs to check the exact name.`,
|
|
89
|
+
}, true);
|
|
90
|
+
}
|
|
91
|
+
// 2. Preview: the app resolves the same graph it will delete.
|
|
92
|
+
const preview = await requestGraphDeletion(graphName, true);
|
|
93
|
+
if (!preview.ok) {
|
|
94
|
+
return textResult({ error: `Dry run failed — nothing was deleted. ${preview.error}` }, true);
|
|
95
|
+
}
|
|
96
|
+
const plan = preview.data;
|
|
97
|
+
const graphUrl = plan.graphUrl ?? graph.defaultRevisionUrl ?? undefined;
|
|
98
|
+
// 3. Consent: confirm: true from the caller, or an accepted form.
|
|
99
|
+
let approved = params.confirm === true;
|
|
100
|
+
let elicitationDetail;
|
|
101
|
+
if (!approved) {
|
|
102
|
+
const answer = await elicitApproval(extra, graphName, plan);
|
|
103
|
+
if (answer.kind === "accepted") {
|
|
104
|
+
approved = true;
|
|
105
|
+
}
|
|
106
|
+
else if (answer.kind === "declined") {
|
|
107
|
+
return textResult({
|
|
108
|
+
deleted: false,
|
|
109
|
+
declined: true,
|
|
110
|
+
graphName,
|
|
111
|
+
message: "The user declined the deletion. Nothing was deleted. Do not retry.",
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
elicitationDetail = answer.detail;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!approved) {
|
|
119
|
+
return textResult({
|
|
120
|
+
deleted: false,
|
|
121
|
+
dryRun: true,
|
|
122
|
+
graphName,
|
|
123
|
+
...(graphUrl ? { graphUrl } : {}),
|
|
124
|
+
isLive: plan.isLive === true,
|
|
125
|
+
...(elicitationDetail ? { elicitation: elicitationDetail } : {}),
|
|
126
|
+
nextStep: "Nothing was deleted. Ask the user to confirm; if they agree, call delete_graph again with the SAME graphName and confirm: true.",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// 4. Delete.
|
|
130
|
+
const write = await requestGraphDeletion(graphName, false);
|
|
131
|
+
if (!write.ok) {
|
|
132
|
+
return textResult({ error: `Deletion failed. ${write.error}` }, true);
|
|
133
|
+
}
|
|
134
|
+
return textResult({
|
|
135
|
+
deleted: write.data.deleted === true,
|
|
136
|
+
graphName: write.data.graphName ?? graphName,
|
|
137
|
+
message: `The graph "${graphName}" and all of its statements were deleted.`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return textResult({ error: error instanceof Error ? error.message : String(error) }, true);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=deleteGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteGraph.js","sourceRoot":"","sources":["../../src/tools/deleteGraph.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAK7D,SAAS,UAAU,CAAC,OAAgB,EAAE,OAAO,GAAG,KAAK;IACpD,OAAO;QACN,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;SACjE;QACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrC,CAAC;AACH,CAAC;AAWD,KAAK,UAAU,oBAAoB,CAClC,SAAiB,EACjB,MAAe;IAEf,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,CAAC,MAAM,qBAAqB,CAAC,cAAc,EAAE;YACzD,IAAI,EAAE,SAAS;YACf,MAAM;SACN,CAAC,CAAmC,CAAC;QACtC,IAAI,CAAC,IAAI,IAAI,O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AAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjC,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,IAAI;oBAC5B,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChE,QAAQ,EACP,iIAAiI;iBAClI,CAAC,CAAC;YACJ,CAAC;YAED,aAAa;YACb,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC3D,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACf,OAAO,UAAU,CAAC,EAAE,KAAK,EAAE,oBAAoB,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,UAAU,CAAC;gBACjB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI;gBACpC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS;gBAC5C,OAAO,EAAE,cAAc,SAAS,2CAA2C;aAC3E,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,UAAU,CAChB,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACjE,IAAI,CACJ,CAAC;QACH,CAAC;IACF,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delete_statements — remove statements from a graph in the caller's own
|
|
3
|
+
* account by a filter the app resolves (see docs/drafts/delete-statements-tool.md).
|
|
4
|
+
*
|
|
5
|
+
* The first destructive tool in this server. Its safety comes from the
|
|
6
|
+
* shape of the call, not from trust in the model: exactly one selector, the
|
|
7
|
+
* graph must already exist, a dry run is the default, and the write only
|
|
8
|
+
* happens with `confirm: true` or an elicitation form the user accepts.
|
|
9
|
+
* The same filter is sent for the preview and for the write, so what the
|
|
10
|
+
* user approved is what gets removed.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { DeleteStatementsSchema } from "../schemas/index.js";
|
|
14
|
+
import type { ToolExtra } from "../types/index.js";
|
|
15
|
+
type Params = z.infer<typeof DeleteStatementsSchema>;
|
|
16
|
+
/** How many matched statements the dry run echoes back to the model. */
|
|
17
|
+
export declare const MATCHED_SHOWN = 50;
|
|
18
|
+
/** The filter part of the /deleteStatements body (everything but name/dryRun). */
|
|
19
|
+
export type Selector = {
|
|
20
|
+
categories: string[];
|
|
21
|
+
} | {
|
|
22
|
+
statements: string[];
|
|
23
|
+
} | {
|
|
24
|
+
query: string;
|
|
25
|
+
} | {
|
|
26
|
+
before?: string;
|
|
27
|
+
after?: string;
|
|
28
|
+
} | {
|
|
29
|
+
all: true;
|
|
30
|
+
} | {
|
|
31
|
+
statementIds: number[];
|
|
32
|
+
};
|
|
33
|
+
export type SelectorResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
selector: Selector;
|
|
36
|
+
kind: string;
|
|
37
|
+
} | {
|
|
38
|
+
ok: false;
|
|
39
|
+
error: string;
|
|
40
|
+
};
|
|
41
|
+
/** The selector fields shared by delete_statements and update_statements. */
|
|
42
|
+
export interface SelectorParams {
|
|
43
|
+
categories?: string[];
|
|
44
|
+
statements?: string[];
|
|
45
|
+
query?: string;
|
|
46
|
+
before?: string;
|
|
47
|
+
after?: string;
|
|
48
|
+
deleteAll?: boolean;
|
|
49
|
+
all?: boolean;
|
|
50
|
+
statementIds?: number[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolve exactly one selector from the parameters. Empty arrays, blank
|
|
54
|
+
* strings and `deleteAll: false` count as "not given". `before` and `after`
|
|
55
|
+
* are one selector together (a time window). Pure; no network.
|
|
56
|
+
*
|
|
57
|
+
* `allField` names the whole-graph flag: `deleteAll` for delete_statements,
|
|
58
|
+
* `all` for update_statements (both are sent to the app as `all: true`).
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildSelector(params: SelectorParams, allField?: "deleteAll" | "all"): SelectorResult;
|
|
61
|
+
export interface MatchedStatement {
|
|
62
|
+
id: number;
|
|
63
|
+
content: string;
|
|
64
|
+
categories?: string[];
|
|
65
|
+
timestamp?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* makeInfraNodusRequest throws `API request failed (status): body` on a
|
|
69
|
+
* non-2xx; the body is `{ error }`. Turn that into one readable line, with
|
|
70
|
+
* the status-specific meaning the model needs to act on it. Shared with
|
|
71
|
+
* update_statements, whose endpoint answers the same status codes.
|
|
72
|
+
*/
|
|
73
|
+
export declare function describeRequestError(error: unknown): string;
|
|
74
|
+
export declare const deleteStatementsTool: {
|
|
75
|
+
name: string;
|
|
76
|
+
definition: {
|
|
77
|
+
title: string;
|
|
78
|
+
description: string;
|
|
79
|
+
inputSchema: {
|
|
80
|
+
graphName: z.ZodString;
|
|
81
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
82
|
+
statements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
83
|
+
query: z.ZodOptional<z.ZodString>;
|
|
84
|
+
before: z.ZodOptional<z.ZodString>;
|
|
85
|
+
after: z.ZodOptional<z.ZodString>;
|
|
86
|
+
deleteAll: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
statementIds: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
88
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
89
|
+
};
|
|
90
|
+
annotations: {
|
|
91
|
+
readOnlyHint: boolean;
|
|
92
|
+
idempotentHint: boolean;
|
|
93
|
+
destructiveHint: boolean;
|
|
94
|
+
openWorldHint: boolean;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
handler: (params: Params, extra?: ToolExtra) => Promise<{
|
|
98
|
+
isError?: boolean | undefined;
|
|
99
|
+
content: {
|
|
100
|
+
type: "text";
|
|
101
|
+
text: string;
|
|
102
|
+
}[];
|
|
103
|
+
}>;
|
|
104
|
+
};
|
|
105
|
+
export {};
|
|
106
|
+
//# sourceMappingURL=deleteStatements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteStatements.d.ts","sourceRoot":"","sources":["../../src/tools/deleteStatements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAWrD,wEAAwE;AACxE,eAAO,MAAM,aAAa,KAAK,CAAC;AAShC,kFAAkF;AAClF,MAAM,MAAM,QAAQ,GACjB;IAAE,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GACxB;IAAE,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GACxB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,GACb;IAAE,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE9B,MAAM,MAAM,cAAc,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhC,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,cAAc,EACtB,QAAQ,GAAE,WAAW,GAAG,KAAmB,GACzC,cAAc,CAkDhB;AAMD,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAgBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqB3D;AAwFD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;sBAkBR,MAAM,UAAU,SAAS;;;;;;;CAyGjD,CAAC"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { brand } from "../config/brand.js";
|
|
2
|
+
import { DeleteStatementsSchema } from "../schemas/index.js";
|
|
3
|
+
import { makeInfraNodusRequest } from "../api/client.js";
|
|
4
|
+
import { errorText, findGraphByName } from "../utils/graphLookup.js";
|
|
5
|
+
import { timestampIsParsable } from "../utils/graphInput.js";
|
|
6
|
+
function textResult(payload, isError = false) {
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{ type: "text", text: JSON.stringify(payload, null, 2) },
|
|
10
|
+
],
|
|
11
|
+
...(isError ? { isError: true } : {}),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** How many matched statements the dry run echoes back to the model. */
|
|
15
|
+
export const MATCHED_SHOWN = 50;
|
|
16
|
+
/** How many matched statements the elicitation prompt quotes. */
|
|
17
|
+
const SAMPLE_IN_PROMPT = 5;
|
|
18
|
+
const SAMPLE_LENGTH = 160;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve exactly one selector from the parameters. Empty arrays, blank
|
|
21
|
+
* strings and `deleteAll: false` count as "not given". `before` and `after`
|
|
22
|
+
* are one selector together (a time window). Pure; no network.
|
|
23
|
+
*
|
|
24
|
+
* `allField` names the whole-graph flag: `deleteAll` for delete_statements,
|
|
25
|
+
* `all` for update_statements (both are sent to the app as `all: true`).
|
|
26
|
+
*/
|
|
27
|
+
export function buildSelector(params, allField = "deleteAll") {
|
|
28
|
+
const given = [];
|
|
29
|
+
if (Array.isArray(params.categories) && params.categories.length > 0) {
|
|
30
|
+
given.push({ kind: "categories", selector: { categories: params.categories } });
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(params.statements) && params.statements.length > 0) {
|
|
33
|
+
given.push({ kind: "statements", selector: { statements: params.statements } });
|
|
34
|
+
}
|
|
35
|
+
const query = params.query?.trim();
|
|
36
|
+
if (query)
|
|
37
|
+
given.push({ kind: "query", selector: { query } });
|
|
38
|
+
const before = params.before?.trim();
|
|
39
|
+
const after = params.after?.trim();
|
|
40
|
+
if (before || after) {
|
|
41
|
+
for (const [label, value] of [
|
|
42
|
+
["before", before],
|
|
43
|
+
["after", after],
|
|
44
|
+
]) {
|
|
45
|
+
if (value && !timestampIsParsable(value)) {
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
error: `${label} must be an ISO 8601 date or datetime (e.g. 2026-08-01 or 2026-08-01T12:00:00Z); got "${value}". Ambiguous formats such as 03.05.2026 are refused because the server could misread the month and day.`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
given.push({
|
|
53
|
+
kind: before && after ? "before/after" : before ? "before" : "after",
|
|
54
|
+
selector: { ...(before ? { before } : {}), ...(after ? { after } : {}) },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (params[allField] === true)
|
|
58
|
+
given.push({ kind: allField, selector: { all: true } });
|
|
59
|
+
if (Array.isArray(params.statementIds) && params.statementIds.length > 0) {
|
|
60
|
+
given.push({ kind: "statementIds", selector: { statementIds: params.statementIds } });
|
|
61
|
+
}
|
|
62
|
+
if (given.length === 0) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
error: `No selector given. Provide exactly one of: categories, statements, query, before/after, ${allField}: true, or statementIds.`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (given.length > 1) {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
error: `Exactly one selector per call; got ${given.map((g) => g.kind).join(" and ")}. Split the ${allField === "all" ? "update" : "deletion"} into separate calls.`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return { ok: true, selector: given[0].selector, kind: given[0].kind };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* makeInfraNodusRequest throws `API request failed (status): body` on a
|
|
78
|
+
* non-2xx; the body is `{ error }`. Turn that into one readable line, with
|
|
79
|
+
* the status-specific meaning the model needs to act on it. Shared with
|
|
80
|
+
* update_statements, whose endpoint answers the same status codes.
|
|
81
|
+
*/
|
|
82
|
+
export function describeRequestError(error) {
|
|
83
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
84
|
+
const match = /^API request failed \((\d+)\): ([\s\S]*)$/.exec(message);
|
|
85
|
+
if (!match)
|
|
86
|
+
return message;
|
|
87
|
+
const status = Number(match[1]);
|
|
88
|
+
let detail = match[2].trim();
|
|
89
|
+
try {
|
|
90
|
+
const parsed = JSON.parse(detail);
|
|
91
|
+
detail = errorText(parsed.error ?? parsed.message ?? parsed);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// plain-text body; keep as is
|
|
95
|
+
}
|
|
96
|
+
const hint = status === 400
|
|
97
|
+
? "The request was rejected."
|
|
98
|
+
: status === 403
|
|
99
|
+
? "The graph is not in this account (or the request was anonymous); only your own graphs can be edited."
|
|
100
|
+
: status === 404
|
|
101
|
+
? "The graph was not found in this account."
|
|
102
|
+
: "";
|
|
103
|
+
return [`${status}: ${detail}`, hint].filter(Boolean).join(" ");
|
|
104
|
+
}
|
|
105
|
+
async function requestDeletion(graphName, selector, dryRun) {
|
|
106
|
+
try {
|
|
107
|
+
const data = (await makeInfraNodusRequest("/deleteStatements", {
|
|
108
|
+
name: graphName,
|
|
109
|
+
...selector,
|
|
110
|
+
dryRun,
|
|
111
|
+
}));
|
|
112
|
+
if (!data || typeof data !== "object") {
|
|
113
|
+
return { ok: false, error: "Unexpected response from /deleteStatements." };
|
|
114
|
+
}
|
|
115
|
+
if (data.error)
|
|
116
|
+
return { ok: false, error: errorText(data.error) };
|
|
117
|
+
return { ok: true, data };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return { ok: false, error: describeRequestError(error) };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function sampleLine(statement, index) {
|
|
124
|
+
const content = (statement.content ?? "").replace(/\s+/g, " ").trim();
|
|
125
|
+
const shown = content.length > SAMPLE_LENGTH ? `${content.slice(0, SAMPLE_LENGTH - 1)}…` : content;
|
|
126
|
+
const labels = statement.categories?.length
|
|
127
|
+
? ` [${statement.categories.join(", ")}]`
|
|
128
|
+
: "";
|
|
129
|
+
return `${index + 1}. ${shown}${labels}`;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Ask the user directly through MCP elicitation. The dialog is a plain
|
|
133
|
+
* Accept / Decline: the spec defines "accept" as the user's explicit
|
|
134
|
+
* approval, so no extra checkbox is asked for (a checkbox defaulting to
|
|
135
|
+
* false made a plain Accept read as a decline in Claude Code). "decline"
|
|
136
|
+
* is a real no. A dismissed dialog, a client without the capability, or a
|
|
137
|
+
* transport error is "unavailable": the caller then returns the dry run so
|
|
138
|
+
* the question can be asked in chat.
|
|
139
|
+
*/
|
|
140
|
+
async function elicitApproval(extra, graphName, plan) {
|
|
141
|
+
if (!extra?.elicit || !extra.clientCapabilities?.elicitation) {
|
|
142
|
+
return { kind: "unavailable", detail: "client does not support elicitation" };
|
|
143
|
+
}
|
|
144
|
+
const matchedCount = plan.matchedCount ?? 0;
|
|
145
|
+
const sample = (plan.matched ?? []).slice(0, SAMPLE_IN_PROMPT).map(sampleLine);
|
|
146
|
+
const more = matchedCount - sample.length;
|
|
147
|
+
const lines = [
|
|
148
|
+
`Permanently delete ${matchedCount} statement(s) from "${graphName}" in ${brand.name}? This cannot be undone.`,
|
|
149
|
+
"",
|
|
150
|
+
...sample,
|
|
151
|
+
...(more > 0 ? [`… and ${more} more`] : []),
|
|
152
|
+
];
|
|
153
|
+
try {
|
|
154
|
+
const result = await extra.elicit({
|
|
155
|
+
message: lines.join("\n"),
|
|
156
|
+
requestedSchema: { type: "object", properties: {} },
|
|
157
|
+
});
|
|
158
|
+
if (result.action === "accept")
|
|
159
|
+
return { kind: "accepted" };
|
|
160
|
+
if (result.action === "decline")
|
|
161
|
+
return { kind: "declined" };
|
|
162
|
+
return { kind: "unavailable", detail: "the user dismissed the dialog without answering" };
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return {
|
|
166
|
+
kind: "unavailable",
|
|
167
|
+
detail: `elicitation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Tool
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
export const deleteStatementsTool = {
|
|
175
|
+
name: "delete_statements",
|
|
176
|
+
definition: {
|
|
177
|
+
title: `Delete Statements from a ${brand.name} Graph`,
|
|
178
|
+
description: `Delete statements from a graph in the user's own ${brand.name} account, selected by a filter the server resolves. IRREVERSIBLE once confirmed: deleted statements cannot be recovered. ` +
|
|
179
|
+
`Select with exactly one of: categories (every statement carrying one of these labels — the way to drop everything that came from one source, because the file path, page name, or [[label]] parent it was uploaded under is its category), statements (exact text), query (case-insensitive substring or /regex/), before/after (an ISO 8601 window; the two count as one selector), deleteAll (empties the graph but keeps it — same name, URL, and settings such as wikilinksMode — for a rebuild in place), or statementIds (advanced). ` +
|
|
180
|
+
`By default this is a DRY RUN: the response says how many statements matched and shows them, and nothing is deleted. Show that to the user; only if they agree, call again with the SAME filter and confirm: true. If the client supports elicitation the user is asked directly and the deletion happens in the same call. A filter that matches nothing returns deleted: 0 without asking. ` +
|
|
181
|
+
`To replace one source's statements after it changed: delete_statements with categories: ["<source>"], then create_knowledge_graph to the same graphName. To rebuild a whole graph in place: deleteAll, then create_knowledge_graph to the same graphName. ` +
|
|
182
|
+
`Never call this on your own initiative — only when the user asked to delete, replace, or rebuild something. The graph must already exist in the user's account (there is no userName parameter; other users' graphs cannot be targeted) and this tool never creates one.`,
|
|
183
|
+
inputSchema: DeleteStatementsSchema.shape,
|
|
184
|
+
annotations: {
|
|
185
|
+
readOnlyHint: false,
|
|
186
|
+
idempotentHint: false,
|
|
187
|
+
destructiveHint: true,
|
|
188
|
+
openWorldHint: false,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
handler: async (params, extra) => {
|
|
192
|
+
try {
|
|
193
|
+
// 1. Exactly one selector — no network until this holds.
|
|
194
|
+
const resolved = buildSelector(params);
|
|
195
|
+
if (!resolved.ok)
|
|
196
|
+
return textResult({ error: resolved.error }, true);
|
|
197
|
+
const { selector, kind } = resolved;
|
|
198
|
+
const graphName = params.graphName.trim();
|
|
199
|
+
// 2. The graph must exist in this account. Never create.
|
|
200
|
+
const graph = await findGraphByName(graphName);
|
|
201
|
+
if (!graph) {
|
|
202
|
+
return textResult({
|
|
203
|
+
error: `No graph named "${graphName}" in this ${brand.name} account. Nothing was deleted. Use list_graphs to check the exact name; this tool never creates graphs.`,
|
|
204
|
+
}, true);
|
|
205
|
+
}
|
|
206
|
+
// 3. Preview with the same filter that the write will use.
|
|
207
|
+
const preview = await requestDeletion(graphName, selector, true);
|
|
208
|
+
if (!preview.ok) {
|
|
209
|
+
return textResult({ error: `Dry run failed — nothing was deleted. ${preview.error}` }, true);
|
|
210
|
+
}
|
|
211
|
+
const plan = preview.data;
|
|
212
|
+
const matchedCount = plan.matchedCount ?? plan.matched?.length ?? 0;
|
|
213
|
+
const graphUrl = plan.graphUrl ?? graph.defaultRevisionUrl ?? undefined;
|
|
214
|
+
if (matchedCount === 0) {
|
|
215
|
+
return textResult({
|
|
216
|
+
deleted: 0,
|
|
217
|
+
matchedCount: 0,
|
|
218
|
+
graphName,
|
|
219
|
+
...(graphUrl ? { graphUrl } : {}),
|
|
220
|
+
filter: selector,
|
|
221
|
+
message: "Nothing matched — no deletion performed.",
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// 4. Consent: confirm: true from the caller, or an accepted form.
|
|
225
|
+
let approved = params.confirm === true;
|
|
226
|
+
let elicitationDetail;
|
|
227
|
+
if (!approved) {
|
|
228
|
+
const answer = await elicitApproval(extra, graphName, plan);
|
|
229
|
+
if (answer.kind === "accepted") {
|
|
230
|
+
approved = true;
|
|
231
|
+
}
|
|
232
|
+
else if (answer.kind === "declined") {
|
|
233
|
+
return textResult({
|
|
234
|
+
deleted: 0,
|
|
235
|
+
declined: true,
|
|
236
|
+
matchedCount,
|
|
237
|
+
graphName,
|
|
238
|
+
message: "The user declined the deletion. Nothing was deleted. Do not retry.",
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
elicitationDetail = answer.detail;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (!approved) {
|
|
246
|
+
const matched = plan.matched ?? [];
|
|
247
|
+
return textResult({
|
|
248
|
+
deleted: 0,
|
|
249
|
+
dryRun: true,
|
|
250
|
+
matchedCount,
|
|
251
|
+
matchedShown: Math.min(matched.length, MATCHED_SHOWN),
|
|
252
|
+
matched: matched.slice(0, MATCHED_SHOWN),
|
|
253
|
+
...(plan.matchedByCategory ? { matchedByCategory: plan.matchedByCategory } : {}),
|
|
254
|
+
graphName,
|
|
255
|
+
...(graphUrl ? { graphUrl } : {}),
|
|
256
|
+
selector: kind,
|
|
257
|
+
filter: selector,
|
|
258
|
+
...(elicitationDetail ? { elicitation: elicitationDetail } : {}),
|
|
259
|
+
nextStep: "Nothing was deleted. Show these to the user; if they agree, call delete_statements again with the SAME filter and confirm: true.",
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// 5. Write with the identical filter.
|
|
263
|
+
const write = await requestDeletion(graphName, selector, false);
|
|
264
|
+
if (!write.ok) {
|
|
265
|
+
return textResult({ error: `Deletion failed. ${write.error}` }, true);
|
|
266
|
+
}
|
|
267
|
+
const result = write.data;
|
|
268
|
+
const deleted = result.removedCount ?? result.removedIds?.length ?? 0;
|
|
269
|
+
return textResult({
|
|
270
|
+
deleted,
|
|
271
|
+
removedIds: result.removedIds ?? [],
|
|
272
|
+
...(result.ignoredIds?.length ? { ignoredIds: result.ignoredIds } : {}),
|
|
273
|
+
...(typeof result.remaining === "number" ? { remaining: result.remaining } : {}),
|
|
274
|
+
graphName: result.graphName ?? graphName,
|
|
275
|
+
...(result.graphUrl ?? graphUrl ? { graphUrl: result.graphUrl ?? graphUrl } : {}),
|
|
276
|
+
...(deleted !== matchedCount
|
|
277
|
+
? {
|
|
278
|
+
note: `The dry run matched ${matchedCount} statement(s) but ${deleted} were removed — the graph changed between preview and deletion.`,
|
|
279
|
+
}
|
|
280
|
+
: {}),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
return textResult({ error: error instanceof Error ? error.message : String(error) }, true);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
//# sourceMappingURL=deleteStatements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteStatements.js","sourceRoot":"","sources":["../../src/tools/deleteSt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String, "many">>;
|
|
14
14
|
graphName: z.ZodOptional<z.ZodString>;
|
|
15
15
|
requestMode: z.ZodDefault<z.ZodEnum<["question", "transcend"]>>;
|
|
16
|
-
modelToUse: z.ZodDefault<z.ZodEnum<["claude-opus-
|
|
16
|
+
modelToUse: z.ZodDefault<z.ZodEnum<["claude-opus-5", "claude-sonnet-5", "claude-fable-5", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "grok-4.1-fast-non-reasoning", "grok-4.1-fast-reasoning", "gpt-4o", "gpt-4o-mini", "gpt-5.4", "gpt-5.4-mini", "gpt-5.6-terra", "gpt-5.6-sol"]>>;
|
|
17
17
|
};
|
|
18
18
|
annotations: {
|
|
19
19
|
readOnlyHint: boolean;
|
|
@@ -13,7 +13,7 @@ export declare const developLatentTopicsTool: {
|
|
|
13
13
|
timestamps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
14
|
graphName: z.ZodOptional<z.ZodString>;
|
|
15
15
|
requestMode: z.ZodDefault<z.ZodEnum<["question", "transcend"]>>;
|
|
16
|
-
modelToUse: z.ZodDefault<z.ZodEnum<["claude-opus-
|
|
16
|
+
modelToUse: z.ZodDefault<z.ZodEnum<["claude-opus-5", "claude-sonnet-5", "claude-fable-5", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "grok-4.1-fast-non-reasoning", "grok-4.1-fast-reasoning", "gpt-4o", "gpt-4o-mini", "gpt-5.4", "gpt-5.4-mini", "gpt-5.6-terra", "gpt-5.6-sol"]>>;
|
|
17
17
|
};
|
|
18
18
|
annotations: {
|
|
19
19
|
readOnlyHint: boolean;
|
|
@@ -15,7 +15,7 @@ export declare const developTextTool: {
|
|
|
15
15
|
useSeveralGaps: z.ZodDefault<z.ZodBoolean>;
|
|
16
16
|
gapDepth: z.ZodDefault<z.ZodNumber>;
|
|
17
17
|
transcendDiscourse: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
-
modelToUse: z.ZodDefault<z.ZodEnum<["claude-opus-
|
|
18
|
+
modelToUse: z.ZodDefault<z.ZodEnum<["claude-opus-5", "claude-sonnet-5", "claude-fable-5", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "grok-4.1-fast-non-reasoning", "grok-4.1-fast-reasoning", "gpt-4o", "gpt-4o-mini", "gpt-5.4", "gpt-5.4-mini", "gpt-5.6-terra", "gpt-5.6-sol"]>>;
|
|
19
19
|
};
|
|
20
20
|
annotations: {
|
|
21
21
|
readOnlyHint: boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { EnableProjectLearningsSchema } from "../schemas/index.js";
|
|
3
|
+
import type { ToolExtra } from "../types/index.js";
|
|
4
|
+
export declare const enableProjectLearningsTool: {
|
|
5
|
+
name: string;
|
|
6
|
+
definition: {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
project: z.ZodString;
|
|
11
|
+
};
|
|
12
|
+
annotations: {
|
|
13
|
+
readOnlyHint: boolean;
|
|
14
|
+
idempotentHint: boolean;
|
|
15
|
+
destructiveHint: boolean;
|
|
16
|
+
openWorldHint: boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
handler: (params: z.infer<typeof EnableProjectLearningsSchema>, extra?: ToolExtra) => Promise<{
|
|
20
|
+
isError?: boolean | undefined;
|
|
21
|
+
content: {
|
|
22
|
+
type: "text";
|
|
23
|
+
text: string;
|
|
24
|
+
}[];
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=enableProjectLearnings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableProjectLearnings.d.ts","sourceRoot":"","sources":["../../src/tools/enableProjectLearnings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAOnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAWnD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;sBAkB7B,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,UAC5C,SAAS;;;;;;;CAiDlB,CAAC"}
|