@ankimcp/anki-mcp-server 0.8.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/LICENSE +7 -0
- package/README.md +756 -0
- package/bin/ankimcp.js +12 -0
- package/dist/anki-config.service.d.ts +10 -0
- package/dist/anki-config.service.js +42 -0
- package/dist/anki-config.service.js.map +1 -0
- package/dist/app.module.d.ts +5 -0
- package/dist/app.module.js +84 -0
- package/dist/app.module.js.map +1 -0
- package/dist/bootstrap.d.ts +3 -0
- package/dist/bootstrap.js +39 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.js +114 -0
- package/dist/cli.js.map +1 -0
- package/dist/http/guards/origin-validation.guard.d.ts +7 -0
- package/dist/http/guards/origin-validation.guard.js +52 -0
- package/dist/http/guards/origin-validation.guard.js.map +1 -0
- package/dist/main-http.d.ts +1 -0
- package/dist/main-http.js +42 -0
- package/dist/main-http.js.map +1 -0
- package/dist/main-stdio.d.ts +1 -0
- package/dist/main-stdio.js +20 -0
- package/dist/main-stdio.js.map +1 -0
- package/dist/mcp/clients/__mocks__/anki-connect.client.d.ts +6 -0
- package/dist/mcp/clients/__mocks__/anki-connect.client.js +18 -0
- package/dist/mcp/clients/__mocks__/anki-connect.client.js.map +1 -0
- package/dist/mcp/clients/anki-connect.client.d.ts +15 -0
- package/dist/mcp/clients/anki-connect.client.js +145 -0
- package/dist/mcp/clients/anki-connect.client.js.map +1 -0
- package/dist/mcp/config/anki-config.interface.d.ts +7 -0
- package/dist/mcp/config/anki-config.interface.js +5 -0
- package/dist/mcp/config/anki-config.interface.js.map +1 -0
- package/dist/mcp/primitives/essential/index.d.ts +32 -0
- package/dist/mcp/primitives/essential/index.js +130 -0
- package/dist/mcp/primitives/essential/index.js.map +1 -0
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.d.ts +12 -0
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.js +113 -0
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.js.map +1 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/content.md +195 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/index.d.ts +12 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/index.js +89 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/index.js.map +1 -0
- package/dist/mcp/primitives/essential/resources/system-info.resource.d.ts +21 -0
- package/dist/mcp/primitives/essential/resources/system-info.resource.js +115 -0
- package/dist/mcp/primitives/essential/resources/system-info.resource.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/add-note.tool.d.ts +93 -0
- package/dist/mcp/primitives/essential/tools/add-note.tool.js +185 -0
- package/dist/mcp/primitives/essential/tools/add-note.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/create-deck.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/create-deck.tool.js +121 -0
- package/dist/mcp/primitives/essential/tools/create-deck.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/create-model.tool.d.ts +88 -0
- package/dist/mcp/primitives/essential/tools/create-model.tool.js +144 -0
- package/dist/mcp/primitives/essential/tools/create-model.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/delete-notes.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/delete-notes.tool.js +120 -0
- package/dist/mcp/primitives/essential/tools/delete-notes.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/find-notes.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/find-notes.tool.js +106 -0
- package/dist/mcp/primitives/essential/tools/find-notes.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/get-due-cards.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/get-due-cards.tool.js +108 -0
- package/dist/mcp/primitives/essential/tools/get-due-cards.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/list-decks.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/list-decks.tool.js +117 -0
- package/dist/mcp/primitives/essential/tools/list-decks.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.d.ts +10 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.js +18 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.d.ts +12 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.js +22 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.d.ts +12 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.js +29 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.d.ts +15 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.js +41 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/index.d.ts +5 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/index.js +6 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/index.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.d.ts +89 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.js +141 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/model-field-names.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/model-field-names.tool.js +119 -0
- package/dist/mcp/primitives/essential/tools/model-field-names.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/model-names.tool.d.ts +81 -0
- package/dist/mcp/primitives/essential/tools/model-names.tool.js +80 -0
- package/dist/mcp/primitives/essential/tools/model-names.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/model-styling.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/model-styling.tool.js +93 -0
- package/dist/mcp/primitives/essential/tools/model-styling.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/notes-info.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/notes-info.tool.js +111 -0
- package/dist/mcp/primitives/essential/tools/notes-info.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/present-card.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/present-card.tool.js +100 -0
- package/dist/mcp/primitives/essential/tools/present-card.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/rate-card.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/rate-card.tool.js +101 -0
- package/dist/mcp/primitives/essential/tools/rate-card.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/sync.tool.d.ts +81 -0
- package/dist/mcp/primitives/essential/tools/sync.tool.js +61 -0
- package/dist/mcp/primitives/essential/tools/sync.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/update-model-styling.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/update-model-styling.tool.js +119 -0
- package/dist/mcp/primitives/essential/tools/update-model-styling.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/update-note-fields.tool.d.ts +96 -0
- package/dist/mcp/primitives/essential/tools/update-note-fields.tool.js +154 -0
- package/dist/mcp/primitives/essential/tools/update-note-fields.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/index.d.ts +23 -0
- package/dist/mcp/primitives/gui/index.js +94 -0
- package/dist/mcp/primitives/gui/index.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-add-cards.tool.d.ts +88 -0
- package/dist/mcp/primitives/gui/tools/gui-add-cards.tool.js +111 -0
- package/dist/mcp/primitives/gui/tools/gui-add-cards.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-browse.tool.d.ts +87 -0
- package/dist/mcp/primitives/gui/tools/gui-browse.tool.js +99 -0
- package/dist/mcp/primitives/gui/tools/gui-browse.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-current-card.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-current-card.tool.js +76 -0
- package/dist/mcp/primitives/gui/tools/gui-current-card.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-browser.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-browser.tool.js +64 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-browser.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-overview.tool.d.ts +83 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-overview.tool.js +88 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-overview.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-edit-note.tool.d.ts +83 -0
- package/dist/mcp/primitives/gui/tools/gui-edit-note.tool.js +80 -0
- package/dist/mcp/primitives/gui/tools/gui-edit-note.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-select-card.tool.d.ts +83 -0
- package/dist/mcp/primitives/gui/tools/gui-select-card.tool.js +90 -0
- package/dist/mcp/primitives/gui/tools/gui-select-card.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-selected-notes.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-selected-notes.tool.js +83 -0
- package/dist/mcp/primitives/gui/tools/gui-selected-notes.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-show-answer.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-show-answer.tool.js +74 -0
- package/dist/mcp/primitives/gui/tools/gui-show-answer.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-show-question.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-show-question.tool.js +74 -0
- package/dist/mcp/primitives/gui/tools/gui-show-question.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-undo.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-undo.tool.js +74 -0
- package/dist/mcp/primitives/gui/tools/gui-undo.tool.js.map +1 -0
- package/dist/mcp/types/anki.types.d.ts +180 -0
- package/dist/mcp/types/anki.types.js +18 -0
- package/dist/mcp/types/anki.types.js.map +1 -0
- package/dist/mcp/utils/anki.utils.d.ts +19 -0
- package/dist/mcp/utils/anki.utils.js +157 -0
- package/dist/mcp/utils/anki.utils.js.map +1 -0
- package/dist/mcp/utils/markdown.utils.d.ts +4 -0
- package/dist/mcp/utils/markdown.utils.js +60 -0
- package/dist/mcp/utils/markdown.utils.js.map +1 -0
- package/dist/mcp/utils/mcpb-workarounds.d.ts +1 -0
- package/dist/mcp/utils/mcpb-workarounds.js +13 -0
- package/dist/mcp/utils/mcpb-workarounds.js.map +1 -0
- package/dist/services/ngrok.service.d.ts +15 -0
- package/dist/services/ngrok.service.js +120 -0
- package/dist/services/ngrok.service.js.map +1 -0
- package/dist/test-fixtures/mock-data.d.ts +126 -0
- package/dist/test-fixtures/mock-data.js +112 -0
- package/dist/test-fixtures/mock-data.js.map +1 -0
- package/dist/test-fixtures/test-helpers.d.ts +12 -0
- package/dist/test-fixtures/test-helpers.js +24 -0
- package/dist/test-fixtures/test-helpers.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +168 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class UpdateModelStylingTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
updateModelStyling({ modelName, css }: {
|
|
8
|
+
modelName: string;
|
|
9
|
+
css: string;
|
|
10
|
+
}, context: Context): Promise<{
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
content: ({
|
|
13
|
+
[x: string]: unknown;
|
|
14
|
+
type: "text";
|
|
15
|
+
text: string;
|
|
16
|
+
_meta?: {
|
|
17
|
+
[x: string]: unknown;
|
|
18
|
+
} | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
type: "image";
|
|
22
|
+
data: string;
|
|
23
|
+
mimeType: string;
|
|
24
|
+
_meta?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
} | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
type: "audio";
|
|
30
|
+
data: string;
|
|
31
|
+
mimeType: string;
|
|
32
|
+
_meta?: {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
} | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
type: "resource_link";
|
|
38
|
+
name: string;
|
|
39
|
+
uri: string;
|
|
40
|
+
_meta?: {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
} | undefined;
|
|
43
|
+
mimeType?: string | undefined;
|
|
44
|
+
title?: string | undefined;
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
icons?: {
|
|
47
|
+
[x: string]: unknown;
|
|
48
|
+
src: string;
|
|
49
|
+
mimeType?: string | undefined;
|
|
50
|
+
sizes?: string[] | undefined;
|
|
51
|
+
}[] | undefined;
|
|
52
|
+
} | {
|
|
53
|
+
[x: string]: unknown;
|
|
54
|
+
type: "resource";
|
|
55
|
+
resource: {
|
|
56
|
+
[x: string]: unknown;
|
|
57
|
+
text: string;
|
|
58
|
+
uri: string;
|
|
59
|
+
_meta?: {
|
|
60
|
+
[x: string]: unknown;
|
|
61
|
+
} | undefined;
|
|
62
|
+
mimeType?: string | undefined;
|
|
63
|
+
} | {
|
|
64
|
+
[x: string]: unknown;
|
|
65
|
+
uri: string;
|
|
66
|
+
blob: string;
|
|
67
|
+
_meta?: {
|
|
68
|
+
[x: string]: unknown;
|
|
69
|
+
} | undefined;
|
|
70
|
+
mimeType?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
_meta?: {
|
|
73
|
+
[x: string]: unknown;
|
|
74
|
+
} | undefined;
|
|
75
|
+
})[];
|
|
76
|
+
_meta?: {
|
|
77
|
+
[x: string]: unknown;
|
|
78
|
+
} | undefined;
|
|
79
|
+
structuredContent?: {
|
|
80
|
+
[x: string]: unknown;
|
|
81
|
+
} | undefined;
|
|
82
|
+
isError?: boolean | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var UpdateModelStylingTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.UpdateModelStylingTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const mcp_nest_1 = require("@rekog/mcp-nest");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const anki_connect_client_1 = require("../../../clients/anki-connect.client");
|
|
18
|
+
const anki_utils_1 = require("../../../utils/anki.utils");
|
|
19
|
+
let UpdateModelStylingTool = UpdateModelStylingTool_1 = class UpdateModelStylingTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(UpdateModelStylingTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async updateModelStyling({ modelName, css }, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log(`Updating styling for model: ${modelName}`);
|
|
28
|
+
await context.reportProgress({ progress: 10, total: 100 });
|
|
29
|
+
let oldStyling = null;
|
|
30
|
+
try {
|
|
31
|
+
oldStyling = await this.ankiClient.invoke("modelStyling", {
|
|
32
|
+
modelName,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (_error) {
|
|
36
|
+
this.logger.warn(`Could not fetch old styling for ${modelName}`);
|
|
37
|
+
}
|
|
38
|
+
await context.reportProgress({ progress: 40, total: 100 });
|
|
39
|
+
await this.ankiClient.invoke("updateModelStyling", {
|
|
40
|
+
model: {
|
|
41
|
+
name: modelName,
|
|
42
|
+
css,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
await context.reportProgress({ progress: 80, total: 100 });
|
|
46
|
+
this.logger.log(`Successfully updated styling for model: ${modelName}`);
|
|
47
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
48
|
+
const cssLength = css.length;
|
|
49
|
+
const hasRtl = css.includes("direction: rtl") || css.includes("direction:rtl");
|
|
50
|
+
const hasCardClass = css.includes(".card");
|
|
51
|
+
const hasFrontClass = css.includes(".front");
|
|
52
|
+
const hasBackClass = css.includes(".back");
|
|
53
|
+
const hasClozeClass = css.includes(".cloze");
|
|
54
|
+
const response = {
|
|
55
|
+
success: true,
|
|
56
|
+
modelName,
|
|
57
|
+
cssLength,
|
|
58
|
+
cssInfo: {
|
|
59
|
+
hasRtlSupport: hasRtl,
|
|
60
|
+
hasCardStyling: hasCardClass,
|
|
61
|
+
hasFrontStyling: hasFrontClass,
|
|
62
|
+
hasBackStyling: hasBackClass,
|
|
63
|
+
hasClozeStyling: hasClozeClass,
|
|
64
|
+
},
|
|
65
|
+
message: `Successfully updated CSS styling for model "${modelName}"`,
|
|
66
|
+
};
|
|
67
|
+
if (oldStyling) {
|
|
68
|
+
response.oldCssLength = oldStyling.css.length;
|
|
69
|
+
response.cssLengthChange = cssLength - oldStyling.css.length;
|
|
70
|
+
}
|
|
71
|
+
return (0, anki_utils_1.createSuccessResponse)(response);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
this.logger.error(`Failed to update styling for model ${modelName}`, error);
|
|
75
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
76
|
+
if (errorMessage.includes("not found") ||
|
|
77
|
+
errorMessage.includes("does not exist") ||
|
|
78
|
+
errorMessage.includes("model not found")) {
|
|
79
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
80
|
+
modelName,
|
|
81
|
+
hint: "Model not found. Use modelNames tool to see available models.",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
85
|
+
modelName,
|
|
86
|
+
hint: "Make sure Anki is running and the model name is correct.",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.UpdateModelStylingTool = UpdateModelStylingTool;
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, mcp_nest_1.Tool)({
|
|
94
|
+
name: "updateModelStyling",
|
|
95
|
+
description: "Update the CSS styling for an existing note type (model). " +
|
|
96
|
+
"This changes how cards of this type are rendered in Anki. " +
|
|
97
|
+
"Useful for adding RTL (Right-to-Left) support, changing fonts, colors, or layout. " +
|
|
98
|
+
"Changes apply to all cards using this model.",
|
|
99
|
+
parameters: zod_1.z.object({
|
|
100
|
+
modelName: zod_1.z
|
|
101
|
+
.string()
|
|
102
|
+
.min(1)
|
|
103
|
+
.describe('Name of the model to update (e.g., "Basic", "Basic RTL")'),
|
|
104
|
+
css: zod_1.z
|
|
105
|
+
.string()
|
|
106
|
+
.min(1)
|
|
107
|
+
.describe('New CSS styling content. For RTL languages, include "direction: rtl;" in .card class. ' +
|
|
108
|
+
"This will completely replace the existing CSS."),
|
|
109
|
+
}),
|
|
110
|
+
}),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
113
|
+
__metadata("design:returntype", Promise)
|
|
114
|
+
], UpdateModelStylingTool.prototype, "updateModelStyling", null);
|
|
115
|
+
exports.UpdateModelStylingTool = UpdateModelStylingTool = UpdateModelStylingTool_1 = __decorate([
|
|
116
|
+
(0, common_1.Injectable)(),
|
|
117
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
118
|
+
], UpdateModelStylingTool);
|
|
119
|
+
//# sourceMappingURL=update-model-styling.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-model-styling.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/essential/tools/update-model-styling.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAGJ;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAElE,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAuBxD,AAAN,KAAK,CAAC,kBAAkB,CACtB,EAAE,SAAS,EAAE,GAAG,EAAsC,EACtD,OAAgB;QAEhB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;YAC5D,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAA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AC;CACF,CAAA;AAvHY,wDAAsB;AA0B3B;IArBL,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EACT,4DAA4D;YAC5D,4DAA4D;YAC5D,oFAAoF;YACpF,8CAA8C;QAChD,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,SAAS,EAAE,OAAC;iBACT,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,0DAA0D,CAAC;YACvE,GAAG,EAAE,OAAC;iBACH,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CACP,wFAAwF;gBACtF,gDAAgD,CACnD;SACJ,CAAC;KACH,CAAC;;;;gEA6FD;iCAtHU,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,sBAAsB,CAuHlC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class UpdateNoteFieldsTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
updateNoteFields({ note, }: {
|
|
8
|
+
note: {
|
|
9
|
+
id: number;
|
|
10
|
+
fields: Record<string, string>;
|
|
11
|
+
audio?: Array<{
|
|
12
|
+
url: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
fields: string[];
|
|
15
|
+
}>;
|
|
16
|
+
picture?: Array<{
|
|
17
|
+
url: string;
|
|
18
|
+
filename: string;
|
|
19
|
+
fields: string[];
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}, context: Context): Promise<{
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
content: ({
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
_meta?: {
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
} | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
type: "image";
|
|
34
|
+
data: string;
|
|
35
|
+
mimeType: string;
|
|
36
|
+
_meta?: {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
} | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
type: "audio";
|
|
42
|
+
data: string;
|
|
43
|
+
mimeType: string;
|
|
44
|
+
_meta?: {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
} | undefined;
|
|
47
|
+
} | {
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
type: "resource_link";
|
|
50
|
+
name: string;
|
|
51
|
+
uri: string;
|
|
52
|
+
_meta?: {
|
|
53
|
+
[x: string]: unknown;
|
|
54
|
+
} | undefined;
|
|
55
|
+
mimeType?: string | undefined;
|
|
56
|
+
title?: string | undefined;
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
icons?: {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
src: string;
|
|
61
|
+
mimeType?: string | undefined;
|
|
62
|
+
sizes?: string[] | undefined;
|
|
63
|
+
}[] | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
[x: string]: unknown;
|
|
66
|
+
type: "resource";
|
|
67
|
+
resource: {
|
|
68
|
+
[x: string]: unknown;
|
|
69
|
+
text: string;
|
|
70
|
+
uri: string;
|
|
71
|
+
_meta?: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
} | undefined;
|
|
74
|
+
mimeType?: string | undefined;
|
|
75
|
+
} | {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
uri: string;
|
|
78
|
+
blob: string;
|
|
79
|
+
_meta?: {
|
|
80
|
+
[x: string]: unknown;
|
|
81
|
+
} | undefined;
|
|
82
|
+
mimeType?: string | undefined;
|
|
83
|
+
};
|
|
84
|
+
_meta?: {
|
|
85
|
+
[x: string]: unknown;
|
|
86
|
+
} | undefined;
|
|
87
|
+
})[];
|
|
88
|
+
_meta?: {
|
|
89
|
+
[x: string]: unknown;
|
|
90
|
+
} | undefined;
|
|
91
|
+
structuredContent?: {
|
|
92
|
+
[x: string]: unknown;
|
|
93
|
+
} | undefined;
|
|
94
|
+
isError?: boolean | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var UpdateNoteFieldsTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.UpdateNoteFieldsTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const mcp_nest_1 = require("@rekog/mcp-nest");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const anki_connect_client_1 = require("../../../clients/anki-connect.client");
|
|
18
|
+
const anki_utils_1 = require("../../../utils/anki.utils");
|
|
19
|
+
let UpdateNoteFieldsTool = UpdateNoteFieldsTool_1 = class UpdateNoteFieldsTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(UpdateNoteFieldsTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async updateNoteFields({ note, }, context) {
|
|
26
|
+
try {
|
|
27
|
+
const fieldCount = Object.keys(note.fields).length;
|
|
28
|
+
this.logger.log(`Updating ${fieldCount} field(s) for note ID: ${note.id}`);
|
|
29
|
+
if (fieldCount === 0) {
|
|
30
|
+
return (0, anki_utils_1.createErrorResponse)(new Error("No fields provided for update"), {
|
|
31
|
+
noteId: note.id,
|
|
32
|
+
hint: "Provide at least one field to update",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
await context.reportProgress({ progress: 25, total: 100 });
|
|
36
|
+
const notesInfo = await this.ankiClient.invoke("notesInfo", {
|
|
37
|
+
notes: [note.id],
|
|
38
|
+
});
|
|
39
|
+
if (!notesInfo || notesInfo.length === 0 || !notesInfo[0]) {
|
|
40
|
+
return (0, anki_utils_1.createErrorResponse)(new Error("Note not found"), {
|
|
41
|
+
noteId: note.id,
|
|
42
|
+
hint: "The note ID is invalid or the note has been deleted. Use findNotes to get valid note IDs.",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const currentNote = notesInfo[0];
|
|
46
|
+
const modelName = currentNote.modelName;
|
|
47
|
+
const existingFields = Object.keys(currentNote.fields);
|
|
48
|
+
const invalidFields = Object.keys(note.fields).filter((field) => !existingFields.includes(field));
|
|
49
|
+
if (invalidFields.length > 0) {
|
|
50
|
+
return (0, anki_utils_1.createErrorResponse)(new Error(`Invalid fields for model "${modelName}"`), {
|
|
51
|
+
noteId: note.id,
|
|
52
|
+
modelName,
|
|
53
|
+
invalidFields,
|
|
54
|
+
validFields: existingFields,
|
|
55
|
+
hint: `These fields don't exist in the "${modelName}" model. Use modelFieldNames to see valid fields.`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
59
|
+
const updateParams = {
|
|
60
|
+
note: {
|
|
61
|
+
id: note.id,
|
|
62
|
+
fields: note.fields,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
if (note.audio) {
|
|
66
|
+
updateParams.note.audio = note.audio;
|
|
67
|
+
}
|
|
68
|
+
if (note.picture) {
|
|
69
|
+
updateParams.note.picture = note.picture;
|
|
70
|
+
}
|
|
71
|
+
await this.ankiClient.invoke("updateNoteFields", updateParams);
|
|
72
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
73
|
+
this.logger.log(`Successfully updated note ID: ${note.id}`);
|
|
74
|
+
const updatedFields = Object.keys(note.fields);
|
|
75
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
76
|
+
success: true,
|
|
77
|
+
noteId: note.id,
|
|
78
|
+
updatedFields,
|
|
79
|
+
fieldCount,
|
|
80
|
+
modelName,
|
|
81
|
+
message: `Successfully updated ${fieldCount} field${fieldCount === 1 ? "" : "s"} in note`,
|
|
82
|
+
cssNote: "HTML content is preserved. Model CSS styling remains unchanged.",
|
|
83
|
+
warning: "If changes don't appear, ensure the note wasn't open in Anki browser during update.",
|
|
84
|
+
hint: "Use notesInfo to verify the changes or findNotes to locate other notes to update.",
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
this.logger.error("Failed to update note fields", error);
|
|
89
|
+
if (error instanceof Error) {
|
|
90
|
+
if (error.message.includes("not found")) {
|
|
91
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
92
|
+
noteId: note.id,
|
|
93
|
+
hint: "Note not found. It may have been deleted.",
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (error.message.includes("field")) {
|
|
97
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
98
|
+
noteId: note.id,
|
|
99
|
+
providedFields: Object.keys(note.fields),
|
|
100
|
+
hint: "Check field names match exactly (case-sensitive). Use notesInfo to see current fields.",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
105
|
+
noteId: note.id,
|
|
106
|
+
hint: "Make sure Anki is running and the note is not open in the browser",
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
exports.UpdateNoteFieldsTool = UpdateNoteFieldsTool;
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, mcp_nest_1.Tool)({
|
|
114
|
+
name: "updateNoteFields",
|
|
115
|
+
description: "Update the fields of an existing note. Supports HTML content in fields and preserves CSS styling. " +
|
|
116
|
+
"WARNING: Do not view the note in Anki browser while updating, or the fields will not update properly. " +
|
|
117
|
+
"Close the browser or switch to a different note before updating. IMPORTANT: Only update notes that the user explicitly asked to modify.",
|
|
118
|
+
parameters: zod_1.z.object({
|
|
119
|
+
note: zod_1.z.object({
|
|
120
|
+
id: zod_1.z
|
|
121
|
+
.number()
|
|
122
|
+
.describe("The ID of the note to update. Get this from findNotes or notesInfo."),
|
|
123
|
+
fields: zod_1.z
|
|
124
|
+
.record(zod_1.z.string())
|
|
125
|
+
.describe("Fields to update with new content. Only include fields you want to change. " +
|
|
126
|
+
'HTML content is supported. Example: {"Front": "<b>New question</b>", "Back": "New answer"}'),
|
|
127
|
+
audio: zod_1.z
|
|
128
|
+
.array(zod_1.z.object({
|
|
129
|
+
url: zod_1.z.string().describe("URL of the audio file"),
|
|
130
|
+
filename: zod_1.z.string().describe("Filename to save as"),
|
|
131
|
+
fields: zod_1.z.array(zod_1.z.string()).describe("Fields to add audio to"),
|
|
132
|
+
}))
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("Optional audio files to add to the note"),
|
|
135
|
+
picture: zod_1.z
|
|
136
|
+
.array(zod_1.z.object({
|
|
137
|
+
url: zod_1.z.string().describe("URL of the image"),
|
|
138
|
+
filename: zod_1.z.string().describe("Filename to save as"),
|
|
139
|
+
fields: zod_1.z.array(zod_1.z.string()).describe("Fields to add image to"),
|
|
140
|
+
}))
|
|
141
|
+
.optional()
|
|
142
|
+
.describe("Optional images to add to the note"),
|
|
143
|
+
}),
|
|
144
|
+
}),
|
|
145
|
+
}),
|
|
146
|
+
__metadata("design:type", Function),
|
|
147
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
148
|
+
__metadata("design:returntype", Promise)
|
|
149
|
+
], UpdateNoteFieldsTool.prototype, "updateNoteFields", null);
|
|
150
|
+
exports.UpdateNoteFieldsTool = UpdateNoteFieldsTool = UpdateNoteFieldsTool_1 = __decorate([
|
|
151
|
+
(0, common_1.Injectable)(),
|
|
152
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
153
|
+
], UpdateNoteFieldsTool);
|
|
154
|
+
//# sourceMappingURL=update-note-fields.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-note-fields.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/essential/tools/update-note-fields.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAGF;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAEhE,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IA4CxD,AAAN,KAAK,CAAC,gBAAgB,CACpB,EACE,IAAI,GAgBL,EACD,OAAgB;QAEhB,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;YACnD,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,YAAY,UAAU,0BAA0B,IAAI,CAAC,EAAE,EAAE,CAC1D,CAAC;YAGF,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;gBACrB,OAAO,IAAA,gCAAmB,EAAC,IAAI,KAAK,CAAC,+BAA+B,CA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C/F;gBACH,KAAK,EAAE,OAAC;qBACL,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;oBACP,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;oBACjD,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;oBACpD,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;iBAC/D,CAAC,CACH;qBACA,QAAQ,EAAE;qBACV,QAAQ,CAAC,yCAAyC,CAAC;gBACtD,OAAO,EAAE,OAAC;qBACP,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;oBACP,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;oBAC5C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;oBACpD,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;iBAC/D,CAAC,CACH;qBACA,QAAQ,EAAE;qBACV,QAAQ,CAAC,oCAAoC,CAAC;aAClD,CAAC;SACH,CAAC;KACH,CAAC;;;;4DAwID;+BAtLU,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,oBAAoB,CAuLhC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { ANKI_CONFIG } from "../../config/anki-config.interface";
|
|
2
|
+
export type { IAnkiConfig } from "../../config/anki-config.interface";
|
|
3
|
+
export * from "../../types/anki.types";
|
|
4
|
+
export * from "../../utils/anki.utils";
|
|
5
|
+
export { AnkiConnectClient, AnkiConnectError, } from "../../clients/anki-connect.client";
|
|
6
|
+
export { GuiBrowseTool } from "./tools/gui-browse.tool";
|
|
7
|
+
export { GuiSelectCardTool } from "./tools/gui-select-card.tool";
|
|
8
|
+
export { GuiSelectedNotesTool } from "./tools/gui-selected-notes.tool";
|
|
9
|
+
export { GuiAddCardsTool } from "./tools/gui-add-cards.tool";
|
|
10
|
+
export { GuiEditNoteTool } from "./tools/gui-edit-note.tool";
|
|
11
|
+
export { GuiDeckOverviewTool } from "./tools/gui-deck-overview.tool";
|
|
12
|
+
export { GuiDeckBrowserTool } from "./tools/gui-deck-browser.tool";
|
|
13
|
+
export { GuiCurrentCardTool } from "./tools/gui-current-card.tool";
|
|
14
|
+
export { GuiShowQuestionTool } from "./tools/gui-show-question.tool";
|
|
15
|
+
export { GuiShowAnswerTool } from "./tools/gui-show-answer.tool";
|
|
16
|
+
export { GuiUndoTool } from "./tools/gui-undo.tool";
|
|
17
|
+
import { DynamicModule, Provider } from "@nestjs/common";
|
|
18
|
+
export interface McpPrimitivesAnkiGuiModuleOptions {
|
|
19
|
+
ankiConfigProvider: Provider;
|
|
20
|
+
}
|
|
21
|
+
export declare class McpPrimitivesAnkiGuiModule {
|
|
22
|
+
static forRoot(options: McpPrimitivesAnkiGuiModuleOptions): DynamicModule;
|
|
23
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
var McpPrimitivesAnkiGuiModule_1;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.McpPrimitivesAnkiGuiModule = exports.GuiUndoTool = exports.GuiShowAnswerTool = exports.GuiShowQuestionTool = exports.GuiCurrentCardTool = exports.GuiDeckBrowserTool = exports.GuiDeckOverviewTool = exports.GuiEditNoteTool = exports.GuiAddCardsTool = exports.GuiSelectedNotesTool = exports.GuiSelectCardTool = exports.GuiBrowseTool = exports.AnkiConnectError = exports.AnkiConnectClient = exports.ANKI_CONFIG = void 0;
|
|
25
|
+
var anki_config_interface_1 = require("../../config/anki-config.interface");
|
|
26
|
+
Object.defineProperty(exports, "ANKI_CONFIG", { enumerable: true, get: function () { return anki_config_interface_1.ANKI_CONFIG; } });
|
|
27
|
+
__exportStar(require("../../types/anki.types"), exports);
|
|
28
|
+
__exportStar(require("../../utils/anki.utils"), exports);
|
|
29
|
+
var anki_connect_client_1 = require("../../clients/anki-connect.client");
|
|
30
|
+
Object.defineProperty(exports, "AnkiConnectClient", { enumerable: true, get: function () { return anki_connect_client_1.AnkiConnectClient; } });
|
|
31
|
+
Object.defineProperty(exports, "AnkiConnectError", { enumerable: true, get: function () { return anki_connect_client_1.AnkiConnectError; } });
|
|
32
|
+
var gui_browse_tool_1 = require("./tools/gui-browse.tool");
|
|
33
|
+
Object.defineProperty(exports, "GuiBrowseTool", { enumerable: true, get: function () { return gui_browse_tool_1.GuiBrowseTool; } });
|
|
34
|
+
var gui_select_card_tool_1 = require("./tools/gui-select-card.tool");
|
|
35
|
+
Object.defineProperty(exports, "GuiSelectCardTool", { enumerable: true, get: function () { return gui_select_card_tool_1.GuiSelectCardTool; } });
|
|
36
|
+
var gui_selected_notes_tool_1 = require("./tools/gui-selected-notes.tool");
|
|
37
|
+
Object.defineProperty(exports, "GuiSelectedNotesTool", { enumerable: true, get: function () { return gui_selected_notes_tool_1.GuiSelectedNotesTool; } });
|
|
38
|
+
var gui_add_cards_tool_1 = require("./tools/gui-add-cards.tool");
|
|
39
|
+
Object.defineProperty(exports, "GuiAddCardsTool", { enumerable: true, get: function () { return gui_add_cards_tool_1.GuiAddCardsTool; } });
|
|
40
|
+
var gui_edit_note_tool_1 = require("./tools/gui-edit-note.tool");
|
|
41
|
+
Object.defineProperty(exports, "GuiEditNoteTool", { enumerable: true, get: function () { return gui_edit_note_tool_1.GuiEditNoteTool; } });
|
|
42
|
+
var gui_deck_overview_tool_1 = require("./tools/gui-deck-overview.tool");
|
|
43
|
+
Object.defineProperty(exports, "GuiDeckOverviewTool", { enumerable: true, get: function () { return gui_deck_overview_tool_1.GuiDeckOverviewTool; } });
|
|
44
|
+
var gui_deck_browser_tool_1 = require("./tools/gui-deck-browser.tool");
|
|
45
|
+
Object.defineProperty(exports, "GuiDeckBrowserTool", { enumerable: true, get: function () { return gui_deck_browser_tool_1.GuiDeckBrowserTool; } });
|
|
46
|
+
var gui_current_card_tool_1 = require("./tools/gui-current-card.tool");
|
|
47
|
+
Object.defineProperty(exports, "GuiCurrentCardTool", { enumerable: true, get: function () { return gui_current_card_tool_1.GuiCurrentCardTool; } });
|
|
48
|
+
var gui_show_question_tool_1 = require("./tools/gui-show-question.tool");
|
|
49
|
+
Object.defineProperty(exports, "GuiShowQuestionTool", { enumerable: true, get: function () { return gui_show_question_tool_1.GuiShowQuestionTool; } });
|
|
50
|
+
var gui_show_answer_tool_1 = require("./tools/gui-show-answer.tool");
|
|
51
|
+
Object.defineProperty(exports, "GuiShowAnswerTool", { enumerable: true, get: function () { return gui_show_answer_tool_1.GuiShowAnswerTool; } });
|
|
52
|
+
var gui_undo_tool_1 = require("./tools/gui-undo.tool");
|
|
53
|
+
Object.defineProperty(exports, "GuiUndoTool", { enumerable: true, get: function () { return gui_undo_tool_1.GuiUndoTool; } });
|
|
54
|
+
const common_1 = require("@nestjs/common");
|
|
55
|
+
const anki_connect_client_2 = require("../../clients/anki-connect.client");
|
|
56
|
+
const gui_browse_tool_2 = require("./tools/gui-browse.tool");
|
|
57
|
+
const gui_select_card_tool_2 = require("./tools/gui-select-card.tool");
|
|
58
|
+
const gui_selected_notes_tool_2 = require("./tools/gui-selected-notes.tool");
|
|
59
|
+
const gui_add_cards_tool_2 = require("./tools/gui-add-cards.tool");
|
|
60
|
+
const gui_edit_note_tool_2 = require("./tools/gui-edit-note.tool");
|
|
61
|
+
const gui_deck_overview_tool_2 = require("./tools/gui-deck-overview.tool");
|
|
62
|
+
const gui_deck_browser_tool_2 = require("./tools/gui-deck-browser.tool");
|
|
63
|
+
const gui_current_card_tool_2 = require("./tools/gui-current-card.tool");
|
|
64
|
+
const gui_show_question_tool_2 = require("./tools/gui-show-question.tool");
|
|
65
|
+
const gui_show_answer_tool_2 = require("./tools/gui-show-answer.tool");
|
|
66
|
+
const gui_undo_tool_2 = require("./tools/gui-undo.tool");
|
|
67
|
+
const MCP_PRIMITIVES = [
|
|
68
|
+
anki_connect_client_2.AnkiConnectClient,
|
|
69
|
+
gui_browse_tool_2.GuiBrowseTool,
|
|
70
|
+
gui_select_card_tool_2.GuiSelectCardTool,
|
|
71
|
+
gui_selected_notes_tool_2.GuiSelectedNotesTool,
|
|
72
|
+
gui_add_cards_tool_2.GuiAddCardsTool,
|
|
73
|
+
gui_edit_note_tool_2.GuiEditNoteTool,
|
|
74
|
+
gui_deck_overview_tool_2.GuiDeckOverviewTool,
|
|
75
|
+
gui_deck_browser_tool_2.GuiDeckBrowserTool,
|
|
76
|
+
gui_current_card_tool_2.GuiCurrentCardTool,
|
|
77
|
+
gui_show_question_tool_2.GuiShowQuestionTool,
|
|
78
|
+
gui_show_answer_tool_2.GuiShowAnswerTool,
|
|
79
|
+
gui_undo_tool_2.GuiUndoTool,
|
|
80
|
+
];
|
|
81
|
+
let McpPrimitivesAnkiGuiModule = McpPrimitivesAnkiGuiModule_1 = class McpPrimitivesAnkiGuiModule {
|
|
82
|
+
static forRoot(options) {
|
|
83
|
+
return {
|
|
84
|
+
module: McpPrimitivesAnkiGuiModule_1,
|
|
85
|
+
providers: [options.ankiConfigProvider, ...MCP_PRIMITIVES],
|
|
86
|
+
exports: MCP_PRIMITIVES,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
exports.McpPrimitivesAnkiGuiModule = McpPrimitivesAnkiGuiModule;
|
|
91
|
+
exports.McpPrimitivesAnkiGuiModule = McpPrimitivesAnkiGuiModule = McpPrimitivesAnkiGuiModule_1 = __decorate([
|
|
92
|
+
(0, common_1.Module)({})
|
|
93
|
+
], McpPrimitivesAnkiGuiModule);
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/mcp/primitives/gui/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AAAxD,oHAAA,WAAW,OAAA;AAIpB,yDAAuC;AAGvC,yDAAuC;AAGvC,yEAG2C;AAFzC,wHAAA,iBAAiB,OAAA;AACjB,uHAAA,gBAAgB,OAAA;AAIlB,2DAAwD;AAA/C,gHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,yHAAA,iBAAiB,OAAA;AAC1B,2EAAuE;AAA9D,+HAAA,oBAAoB,OAAA;AAG7B,iEA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