hackwriter 0.0.2
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 +9 -0
- package/README.md +55 -0
- package/dist/agent/Agent.d.ts +9 -0
- package/dist/agent/Agent.d.ts.map +1 -0
- package/dist/agent/Agent.js +2 -0
- package/dist/agent/Agent.js.map +1 -0
- package/dist/agent/AgentExecutor.d.ts +36 -0
- package/dist/agent/AgentExecutor.d.ts.map +1 -0
- package/dist/agent/AgentExecutor.js +306 -0
- package/dist/agent/AgentExecutor.js.map +1 -0
- package/dist/agent/ApprovalManager.d.ts +8 -0
- package/dist/agent/ApprovalManager.d.ts.map +1 -0
- package/dist/agent/ApprovalManager.js +45 -0
- package/dist/agent/ApprovalManager.js.map +1 -0
- package/dist/agent/ContextCompressor.d.ts +9 -0
- package/dist/agent/ContextCompressor.d.ts.map +1 -0
- package/dist/agent/ContextCompressor.js +58 -0
- package/dist/agent/ContextCompressor.js.map +1 -0
- package/dist/agent/ConversationContext.d.ts +19 -0
- package/dist/agent/ConversationContext.d.ts.map +1 -0
- package/dist/agent/ConversationContext.js +236 -0
- package/dist/agent/ConversationContext.js.map +1 -0
- package/dist/agent/ModelFactory.d.ts +4 -0
- package/dist/agent/ModelFactory.d.ts.map +1 -0
- package/dist/agent/ModelFactory.js +32 -0
- package/dist/agent/ModelFactory.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +146 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/setup.d.ts +2 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +110 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/config/ConfigSchema.d.ts +75 -0
- package/dist/config/ConfigSchema.d.ts.map +1 -0
- package/dist/config/ConfigSchema.js +54 -0
- package/dist/config/ConfigSchema.js.map +1 -0
- package/dist/config/Configuration.d.ts +30 -0
- package/dist/config/Configuration.d.ts.map +1 -0
- package/dist/config/Configuration.js +2 -0
- package/dist/config/Configuration.js.map +1 -0
- package/dist/config/ConfigurationLoader.d.ts +8 -0
- package/dist/config/ConfigurationLoader.d.ts.map +1 -0
- package/dist/config/ConfigurationLoader.js +75 -0
- package/dist/config/ConfigurationLoader.js.map +1 -0
- package/dist/messaging/MessageBus.d.ts +11 -0
- package/dist/messaging/MessageBus.d.ts.map +1 -0
- package/dist/messaging/MessageBus.js +23 -0
- package/dist/messaging/MessageBus.js.map +1 -0
- package/dist/messaging/MessageTypes.d.ts +39 -0
- package/dist/messaging/MessageTypes.d.ts.map +1 -0
- package/dist/messaging/MessageTypes.js +2 -0
- package/dist/messaging/MessageTypes.js.map +1 -0
- package/dist/session/SessionManager.d.ts +11 -0
- package/dist/session/SessionManager.d.ts.map +1 -0
- package/dist/session/SessionManager.js +56 -0
- package/dist/session/SessionManager.js.map +1 -0
- package/dist/tools/base/Tool.d.ts +19 -0
- package/dist/tools/base/Tool.d.ts.map +1 -0
- package/dist/tools/base/Tool.js +15 -0
- package/dist/tools/base/Tool.js.map +1 -0
- package/dist/tools/base/ToolRegistry.d.ts +16 -0
- package/dist/tools/base/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/base/ToolRegistry.js +29 -0
- package/dist/tools/base/ToolRegistry.js.map +1 -0
- package/dist/tools/file/ListFilesTool.d.ts +17 -0
- package/dist/tools/file/ListFilesTool.d.ts.map +1 -0
- package/dist/tools/file/ListFilesTool.js +80 -0
- package/dist/tools/file/ListFilesTool.js.map +1 -0
- package/dist/tools/file/ReadFileTool.d.ts +13 -0
- package/dist/tools/file/ReadFileTool.d.ts.map +1 -0
- package/dist/tools/file/ReadFileTool.js +32 -0
- package/dist/tools/file/ReadFileTool.js.map +1 -0
- package/dist/tools/file/WriteFileTool.d.ts +18 -0
- package/dist/tools/file/WriteFileTool.d.ts.map +1 -0
- package/dist/tools/file/WriteFileTool.js +54 -0
- package/dist/tools/file/WriteFileTool.js.map +1 -0
- package/dist/tools/file/index.d.ts +4 -0
- package/dist/tools/file/index.d.ts.map +1 -0
- package/dist/tools/file/index.js +4 -0
- package/dist/tools/file/index.js.map +1 -0
- package/dist/tools/hackmd/CreateNoteTool.d.ts +27 -0
- package/dist/tools/hackmd/CreateNoteTool.d.ts.map +1 -0
- package/dist/tools/hackmd/CreateNoteTool.js +85 -0
- package/dist/tools/hackmd/CreateNoteTool.js.map +1 -0
- package/dist/tools/hackmd/DeleteNoteTool.d.ts +19 -0
- package/dist/tools/hackmd/DeleteNoteTool.d.ts.map +1 -0
- package/dist/tools/hackmd/DeleteNoteTool.js +54 -0
- package/dist/tools/hackmd/DeleteNoteTool.js.map +1 -0
- package/dist/tools/hackmd/ExportNoteTool.d.ts +18 -0
- package/dist/tools/hackmd/ExportNoteTool.d.ts.map +1 -0
- package/dist/tools/hackmd/ExportNoteTool.js +75 -0
- package/dist/tools/hackmd/ExportNoteTool.js.map +1 -0
- package/dist/tools/hackmd/GetHistoryTool.d.ts +16 -0
- package/dist/tools/hackmd/GetHistoryTool.d.ts.map +1 -0
- package/dist/tools/hackmd/GetHistoryTool.js +51 -0
- package/dist/tools/hackmd/GetHistoryTool.js.map +1 -0
- package/dist/tools/hackmd/GetUserInfoTool.d.ts +13 -0
- package/dist/tools/hackmd/GetUserInfoTool.d.ts.map +1 -0
- package/dist/tools/hackmd/GetUserInfoTool.js +30 -0
- package/dist/tools/hackmd/GetUserInfoTool.js.map +1 -0
- package/dist/tools/hackmd/ListNotesTool.d.ts +17 -0
- package/dist/tools/hackmd/ListNotesTool.d.ts.map +1 -0
- package/dist/tools/hackmd/ListNotesTool.js +48 -0
- package/dist/tools/hackmd/ListNotesTool.js.map +1 -0
- package/dist/tools/hackmd/ListTeamsTool.d.ts +13 -0
- package/dist/tools/hackmd/ListTeamsTool.d.ts.map +1 -0
- package/dist/tools/hackmd/ListTeamsTool.js +34 -0
- package/dist/tools/hackmd/ListTeamsTool.js.map +1 -0
- package/dist/tools/hackmd/ReadNoteTool.d.ts +16 -0
- package/dist/tools/hackmd/ReadNoteTool.d.ts.map +1 -0
- package/dist/tools/hackmd/ReadNoteTool.js +36 -0
- package/dist/tools/hackmd/ReadNoteTool.js.map +1 -0
- package/dist/tools/hackmd/SearchNotesTool.d.ts +17 -0
- package/dist/tools/hackmd/SearchNotesTool.d.ts.map +1 -0
- package/dist/tools/hackmd/SearchNotesTool.js +49 -0
- package/dist/tools/hackmd/SearchNotesTool.js.map +1 -0
- package/dist/tools/hackmd/UpdateNoteTool.d.ts +20 -0
- package/dist/tools/hackmd/UpdateNoteTool.d.ts.map +1 -0
- package/dist/tools/hackmd/UpdateNoteTool.js +62 -0
- package/dist/tools/hackmd/UpdateNoteTool.js.map +1 -0
- package/dist/tools/hackmd/errorHandler.d.ts +6 -0
- package/dist/tools/hackmd/errorHandler.d.ts.map +1 -0
- package/dist/tools/hackmd/errorHandler.js +59 -0
- package/dist/tools/hackmd/errorHandler.js.map +1 -0
- package/dist/tools/hackmd/index.d.ts +11 -0
- package/dist/tools/hackmd/index.d.ts.map +1 -0
- package/dist/tools/hackmd/index.js +24 -0
- package/dist/tools/hackmd/index.js.map +1 -0
- package/dist/ui/shell/CommandRegistry.d.ts +20 -0
- package/dist/ui/shell/CommandRegistry.d.ts.map +1 -0
- package/dist/ui/shell/CommandRegistry.js +77 -0
- package/dist/ui/shell/CommandRegistry.js.map +1 -0
- package/dist/ui/shell/InteractiveShell.d.ts +15 -0
- package/dist/ui/shell/InteractiveShell.d.ts.map +1 -0
- package/dist/ui/shell/InteractiveShell.js +94 -0
- package/dist/ui/shell/InteractiveShell.js.map +1 -0
- package/dist/ui/shell/OutputRenderer.d.ts +8 -0
- package/dist/ui/shell/OutputRenderer.d.ts.map +1 -0
- package/dist/ui/shell/OutputRenderer.js +85 -0
- package/dist/ui/shell/OutputRenderer.js.map +1 -0
- package/dist/utils/ErrorTypes.d.ts +58 -0
- package/dist/utils/ErrorTypes.d.ts.map +1 -0
- package/dist/utils/ErrorTypes.js +156 -0
- package/dist/utils/ErrorTypes.js.map +1 -0
- package/dist/utils/Logger.d.ts +13 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +72 -0
- package/dist/utils/Logger.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Tool } from '../base/Tool';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
export class ReadFileTool extends Tool {
|
|
4
|
+
name = 'read_file';
|
|
5
|
+
description = 'Read the content of a local file';
|
|
6
|
+
inputSchema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
filePath: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
description: 'Path to the file to read',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
required: ['filePath'],
|
|
15
|
+
};
|
|
16
|
+
async call(params) {
|
|
17
|
+
try {
|
|
18
|
+
const content = await fs.readFile(params.filePath, 'utf-8');
|
|
19
|
+
const stats = await fs.stat(params.filePath);
|
|
20
|
+
const output = `**File:** ${params.filePath}\n` +
|
|
21
|
+
`**Size:** ${stats.size} bytes\n` +
|
|
22
|
+
`**Modified:** ${stats.mtime.toLocaleString()}\n\n` +
|
|
23
|
+
`**Content:**\n\`\`\`\n${content}\n\`\`\``;
|
|
24
|
+
return this.ok(output, `Successfully read file: ${params.filePath}`, 'Read');
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const errorMsg = `Failed to read file: ${this.formatError(error)}`;
|
|
28
|
+
return this.error(errorMsg, errorMsg, 'Read failed');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ReadFileTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadFileTool.js","sourceRoot":"","sources":["../../../src/tools/file/ReadFileTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AACtE,OAAO,EAA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WriteFileParams {
|
|
4
|
+
filePath: string;
|
|
5
|
+
content: string;
|
|
6
|
+
createDirectories?: boolean;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare class WriteFileTool extends Tool<WriteFileParams> {
|
|
10
|
+
private approvalManager;
|
|
11
|
+
readonly name = "write_file";
|
|
12
|
+
readonly description = "Write content to a local file";
|
|
13
|
+
readonly inputSchema: ToolSchema;
|
|
14
|
+
constructor(approvalManager: ApprovalManager);
|
|
15
|
+
call(params: WriteFileParams): Promise<ToolResult>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=WriteFileTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WriteFileTool.d.ts","sourceRoot":"","sources":["../../../src/tools/file/WriteFileTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAInE,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,aAAc,SAAQ,IAAI,CAAC,eAAe,CAAC;IAsB1C,OAAO,CAAC,eAAe;IArBnC,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,mCAAmC;IACvD,QAAQ,CAAC,WAAW,EAAE,UAAU,CAiB9B;gBAEkB,eAAe,EAAE,eAAe;IAI9C,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;CA6CzD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Tool } from '../base/Tool';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
export class WriteFileTool extends Tool {
|
|
5
|
+
approvalManager;
|
|
6
|
+
name = 'write_file';
|
|
7
|
+
description = 'Write content to a local file';
|
|
8
|
+
inputSchema = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
filePath: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'Path to the file to write',
|
|
14
|
+
},
|
|
15
|
+
content: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Content to write to the file',
|
|
18
|
+
},
|
|
19
|
+
createDirectories: {
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
description: 'Create parent directories if they don\'t exist (default: true)',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ['filePath', 'content'],
|
|
25
|
+
};
|
|
26
|
+
constructor(approvalManager) {
|
|
27
|
+
super();
|
|
28
|
+
this.approvalManager = approvalManager;
|
|
29
|
+
}
|
|
30
|
+
async call(params) {
|
|
31
|
+
const approved = await this.approvalManager.request(this.name, 'write_file', `Write to file "${params.filePath}"`);
|
|
32
|
+
if (!approved) {
|
|
33
|
+
return this.error('Operation rejected by user', 'Operation rejected by user', 'Rejected');
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const createDirs = params.createDirectories !== false;
|
|
37
|
+
if (createDirs) {
|
|
38
|
+
const dir = dirname(params.filePath);
|
|
39
|
+
await fs.mkdir(dir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
await fs.writeFile(params.filePath, params.content, 'utf-8');
|
|
42
|
+
const stats = await fs.stat(params.filePath);
|
|
43
|
+
const output = `✅ File written successfully!\n\n` +
|
|
44
|
+
`**Path:** ${params.filePath}\n` +
|
|
45
|
+
`**Size:** ${stats.size} bytes\n`;
|
|
46
|
+
return this.ok(output, `File written to ${params.filePath}`, 'Written');
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const errorMsg = `Failed to write file: ${this.formatError(error)}`;
|
|
50
|
+
return this.error(errorMsg, errorMsg, 'Write failed');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=WriteFileTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WriteFileTool.js","sourceRoot":"","sources":["../../../src/tools/file/WriteFileTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,MAAM,OAAO,aAAc,SAAQ,IAAqB;IAsBlC;IArBX,IAAI,GAAG,YAAY,CAAC;IACpB,WAAW,GAAG,+BAA+B,CAAC;IAC9C,WAAW,GAAe;QACjC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2BAA2B;aACzC;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;YACD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,gEAAgE;aAC9E;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC;KAClC,CAAC;IAEF,YAAoB,eAAgC;QAClD,KAAK,EAAE,CAAC;QADU,oBAAe,GAAf,eAAe,CAAiB;IAEpD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAuB;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CACjD,IAAI,CAAC,IAAI,EACT,YAAY,EACZ,kBAAkB,MAAM,CAAC,QAAQ,GAAG,CACrC,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAC,KAAK,CACf,4BAA4B,EA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@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { API } from "@hackmd/api";
|
|
2
|
+
import { Tool, type ToolResult, type ToolSchema } from "../base/Tool";
|
|
3
|
+
import type { ApprovalManager } from "../../agent/ApprovalManager";
|
|
4
|
+
declare enum NotePermissionRole {
|
|
5
|
+
OWNER = "owner",
|
|
6
|
+
SIGNED_IN = "signed_in",
|
|
7
|
+
GUEST = "guest"
|
|
8
|
+
}
|
|
9
|
+
interface CreateNoteParams {
|
|
10
|
+
title: string;
|
|
11
|
+
content: string;
|
|
12
|
+
teamPath?: string;
|
|
13
|
+
readPermission?: NotePermissionRole;
|
|
14
|
+
writePermission?: NotePermissionRole;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare class CreateNoteTool extends Tool<CreateNoteParams> {
|
|
18
|
+
private hackmdClient;
|
|
19
|
+
private approvalManager;
|
|
20
|
+
readonly name = "create_note";
|
|
21
|
+
readonly description = "Create a new note in HackMD. Use teamPath to create a team note.";
|
|
22
|
+
readonly inputSchema: ToolSchema;
|
|
23
|
+
constructor(hackmdClient: API, approvalManager: ApprovalManager);
|
|
24
|
+
call(params: CreateNoteParams): Promise<ToolResult>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=CreateNoteTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateNoteTool.d.ts","sourceRoot":"","sources":["../../../src/tools/hackmd/CreateNoteTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAInE,aAAK,kBAAkB;IACrB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,KAAK,UAAU;CAChB;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,cAAe,SAAQ,IAAI,CAAC,gBAAgB,CAAC;IAkCtD,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;IAlCzB,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,sEACiD;IACrE,QAAQ,CAAC,WAAW,EAAE,UAAU,CA2B9B;gBAGQ,YAAY,EAAE,GAAG,EACjB,eAAe,EAAE,eAAe;IAKpC,IAAI,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CA4D1D"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Tool } from "../base/Tool";
|
|
2
|
+
import { handleHackMDError } from "./errorHandler";
|
|
3
|
+
// Re-define enum as the package doesn't export it properly
|
|
4
|
+
var NotePermissionRole;
|
|
5
|
+
(function (NotePermissionRole) {
|
|
6
|
+
NotePermissionRole["OWNER"] = "owner";
|
|
7
|
+
NotePermissionRole["SIGNED_IN"] = "signed_in";
|
|
8
|
+
NotePermissionRole["GUEST"] = "guest";
|
|
9
|
+
})(NotePermissionRole || (NotePermissionRole = {}));
|
|
10
|
+
export class CreateNoteTool extends Tool {
|
|
11
|
+
hackmdClient;
|
|
12
|
+
approvalManager;
|
|
13
|
+
name = "create_note";
|
|
14
|
+
description = "Create a new note in HackMD. Use teamPath to create a team note.";
|
|
15
|
+
inputSchema = {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
title: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "The title of the new note",
|
|
21
|
+
},
|
|
22
|
+
content: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "The markdown content of the note",
|
|
25
|
+
},
|
|
26
|
+
teamPath: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Optional: team path or ID to create a team note",
|
|
29
|
+
},
|
|
30
|
+
readPermission: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: ["owner", "signed_in", "guest"],
|
|
33
|
+
description: "Who can read the note (default: owner)",
|
|
34
|
+
},
|
|
35
|
+
writePermission: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: ["owner", "signed_in", "guest"],
|
|
38
|
+
description: "Who can write to the note (default: owner)",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ["title", "content"],
|
|
42
|
+
};
|
|
43
|
+
constructor(hackmdClient, approvalManager) {
|
|
44
|
+
super();
|
|
45
|
+
this.hackmdClient = hackmdClient;
|
|
46
|
+
this.approvalManager = approvalManager;
|
|
47
|
+
}
|
|
48
|
+
async call(params) {
|
|
49
|
+
const isTeamNote = Boolean(params.teamPath);
|
|
50
|
+
const actionDesc = isTeamNote
|
|
51
|
+
? `Create team note "${params.title}" in team "${params.teamPath}"`
|
|
52
|
+
: `Create note "${params.title}"`;
|
|
53
|
+
const approved = await this.approvalManager.request(this.name, isTeamNote ? "create_team_note" : "create_note", actionDesc);
|
|
54
|
+
if (!approved) {
|
|
55
|
+
return this.error("Operation rejected by user", "Operation rejected by user", "Rejected");
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const noteData = {
|
|
59
|
+
title: params.title,
|
|
60
|
+
content: params.content,
|
|
61
|
+
readPermission: params.readPermission ?? NotePermissionRole.OWNER,
|
|
62
|
+
writePermission: params.writePermission ?? NotePermissionRole.OWNER,
|
|
63
|
+
};
|
|
64
|
+
const note = isTeamNote
|
|
65
|
+
? await this.hackmdClient.createTeamNote(params.teamPath, noteData)
|
|
66
|
+
: await this.hackmdClient.createNote(noteData);
|
|
67
|
+
const output = isTeamNote
|
|
68
|
+
? `✅ Team note created successfully!\n\n` +
|
|
69
|
+
`**Title:** ${note.title}\n` +
|
|
70
|
+
`**ID:** \`${note.id}\`\n` +
|
|
71
|
+
`**Team:** ${params.teamPath}\n` +
|
|
72
|
+
`**Link:** ${note.publishLink}\n`
|
|
73
|
+
: `✅ Note created successfully!\n\n` +
|
|
74
|
+
`**Title:** ${note.title}\n` +
|
|
75
|
+
`**ID:** \`${note.id}\`\n` +
|
|
76
|
+
`**Link:** ${note.publishLink}\n`;
|
|
77
|
+
return this.ok(output, `${isTeamNote ? "Team note" : "Note"} "${params.title}" created successfully`, `Created: ${params.title}`);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const appError = handleHackMDError(error, `Failed to create ${isTeamNote ? "team " : ""}note`);
|
|
81
|
+
return this.error(appError.toUserString(), appError.message, "Creation failed");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=CreateNoteTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateNoteTool.js","sourceRoot":"","sources":["../../../src/tools/hackmd/CreateNoteTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,2DAA2D;AAC3D,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACrB,qCAAe,CAAA;IACf,6CAAuB,CAAA;IACvB,qCAAe,CAAA;AACjB,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AA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,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,iBAAiB,CAChC,KAAK,EACL,oBAAoB,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CACpD,CAAC;YACF,OAAO,IAAI,CAAC,KAAK,CACf,QAAQ,CAAC,YAAY,EAAE,EACvB,QAAQ,CAAC,OAAO,EAChB,iBAAiB,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { API } from "@hackmd/api";
|
|
2
|
+
import { Tool, type ToolResult, type ToolSchema } from "../base/Tool";
|
|
3
|
+
import type { ApprovalManager } from "../../agent/ApprovalManager";
|
|
4
|
+
interface DeleteNoteParams {
|
|
5
|
+
noteId: string;
|
|
6
|
+
teamPath?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare class DeleteNoteTool extends Tool<DeleteNoteParams> {
|
|
10
|
+
private hackmdClient;
|
|
11
|
+
private approvalManager;
|
|
12
|
+
readonly name = "delete_note";
|
|
13
|
+
readonly description = "Delete a HackMD note (requires confirmation). Use teamPath for team notes.";
|
|
14
|
+
readonly inputSchema: ToolSchema;
|
|
15
|
+
constructor(hackmdClient: API, approvalManager: ApprovalManager);
|
|
16
|
+
call(params: DeleteNoteParams): Promise<ToolResult>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=DeleteNoteTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteNoteTool.d.ts","sourceRoot":"","sources":["../../../src/tools/hackmd/DeleteNoteTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,cAAe,SAAQ,IAAI,CAAC,gBAAgB,CAAC;IAoBtD,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;IApBzB,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,gFAC2D;IAC/E,QAAQ,CAAC,WAAW,EAAE,UAAU,CAa9B;gBAGQ,YAAY,EAAE,GAAG,EACjB,eAAe,EAAE,eAAe;IAKpC,IAAI,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CAgD1D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Tool } from "../base/Tool";
|
|
2
|
+
import { handleHackMDError } from "./errorHandler";
|
|
3
|
+
export class DeleteNoteTool extends Tool {
|
|
4
|
+
hackmdClient;
|
|
5
|
+
approvalManager;
|
|
6
|
+
name = "delete_note";
|
|
7
|
+
description = "Delete a HackMD note (requires confirmation). Use teamPath for team notes.";
|
|
8
|
+
inputSchema = {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
noteId: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "The ID of the note to delete",
|
|
14
|
+
},
|
|
15
|
+
teamPath: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Optional: team path or ID for team notes",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ["noteId"],
|
|
21
|
+
};
|
|
22
|
+
constructor(hackmdClient, approvalManager) {
|
|
23
|
+
super();
|
|
24
|
+
this.hackmdClient = hackmdClient;
|
|
25
|
+
this.approvalManager = approvalManager;
|
|
26
|
+
}
|
|
27
|
+
async call(params) {
|
|
28
|
+
const isTeamNote = Boolean(params.teamPath);
|
|
29
|
+
const actionDesc = isTeamNote
|
|
30
|
+
? `Delete team note ${params.noteId} from team "${params.teamPath}"? This action cannot be undone.`
|
|
31
|
+
: `Delete note ${params.noteId}? This action cannot be undone.`;
|
|
32
|
+
const approved = await this.approvalManager.request(this.name, isTeamNote ? "delete_team_note" : "delete_note", actionDesc);
|
|
33
|
+
if (!approved) {
|
|
34
|
+
return this.error("Deletion cancelled by user", "Deletion cancelled by user", "Cancelled");
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
if (isTeamNote) {
|
|
38
|
+
await this.hackmdClient.deleteTeamNote(params.teamPath, params.noteId);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
await this.hackmdClient.deleteNote(params.noteId);
|
|
42
|
+
}
|
|
43
|
+
const output = isTeamNote
|
|
44
|
+
? `✅ Team note deleted successfully\n**ID:** \`${params.noteId}\`\n**Team:** ${params.teamPath}`
|
|
45
|
+
: `✅ Note deleted successfully\n**ID:** \`${params.noteId}\``;
|
|
46
|
+
return this.ok(output, `${isTeamNote ? "Team note" : "Note"} deleted`, "Deleted");
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const appError = handleHackMDError(error, `Failed to delete ${isTeamNote ? "team " : ""}note`);
|
|
50
|
+
return this.error(appError.toUserString(), appError.message, "Deletion failed");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=DeleteNoteTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteNoteTool.js","sourceRoot":"","sources":["../../../src/tools/hackmd/DeleteNoteTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAQnD,MAAM,OAAO,cAAe,SAAQ,IAAsB;IAoB9C;IACA;IApBD,IAAI,GAAG,aAAa,CAAC;IACrB,WA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MAAM,CAAC,CAAC;YACpD,CAAC;YAED,MAAM,MAAM,GAAG,UAAU;gBACvB,CAAC,CAAC,+CAA+C,MAAM,CAAC,MAAM,iBAAiB,MAAM,CAAC,QAAQ,EAAE;gBAChG,CAAC,CAAC,0CAA0C,MAAM,CAAC,MAAM,IAAI,CAAC;YAEhE,OAAO,IAAI,CAAC,EAAE,CACZ,MAAM,EACN,GAAG,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,UAAU,EAC9C,SAAS,CACV,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,iBAAiB,CAChC,KAAK,EACL,oBAAoB,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CACpD,CAAC;YACF,OAAO,IAAI,CAAC,KAAK,CACf,QAAQ,CAAC,YAAY,EAAE,EACvB,QAAQ,CAAC,OAAO,EAChB,iBAAiB,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { API } from '@hackmd/api';
|
|
2
|
+
import { Tool, type ToolResult, type ToolSchema } from '../base/Tool';
|
|
3
|
+
interface ExportNoteParams {
|
|
4
|
+
noteId: string;
|
|
5
|
+
outputPath: string;
|
|
6
|
+
format?: 'md' | 'html' | 'pdf';
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare class ExportNoteTool extends Tool<ExportNoteParams> {
|
|
10
|
+
private hackmdClient;
|
|
11
|
+
readonly name = "export_note";
|
|
12
|
+
readonly description = "Export a HackMD note to a local file";
|
|
13
|
+
readonly inputSchema: ToolSchema;
|
|
14
|
+
constructor(hackmdClient: API);
|
|
15
|
+
call(params: ExportNoteParams): Promise<ToolResult>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=ExportNoteTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportNoteTool.d.ts","sourceRoot":"","sources":["../../../src/tools/hackmd/ExportNoteTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGtE,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,cAAe,SAAQ,IAAI,CAAC,gBAAgB,CAAC;IAuB5C,OAAO,CAAC,YAAY;IAtBhC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,0CAA0C;IAC9D,QAAQ,CAAC,WAAW,EAAE,UAAU,CAkB9B;gBAEkB,YAAY,EAAE,GAAG;IAI/B,IAAI,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CA2D1D"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Tool } from '../base/Tool';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
export class ExportNoteTool extends Tool {
|
|
4
|
+
hackmdClient;
|
|
5
|
+
name = 'export_note';
|
|
6
|
+
description = 'Export a HackMD note to a local file';
|
|
7
|
+
inputSchema = {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
noteId: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The ID of the note to export',
|
|
13
|
+
},
|
|
14
|
+
outputPath: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The local file path to export to',
|
|
17
|
+
},
|
|
18
|
+
format: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
enum: ['md', 'html', 'pdf'],
|
|
21
|
+
description: 'Export format (default: md)',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ['noteId', 'outputPath'],
|
|
25
|
+
};
|
|
26
|
+
constructor(hackmdClient) {
|
|
27
|
+
super();
|
|
28
|
+
this.hackmdClient = hackmdClient;
|
|
29
|
+
}
|
|
30
|
+
async call(params) {
|
|
31
|
+
try {
|
|
32
|
+
const note = await this.hackmdClient.getNote(params.noteId);
|
|
33
|
+
const format = params.format ?? 'md';
|
|
34
|
+
let content;
|
|
35
|
+
let filePath = params.outputPath;
|
|
36
|
+
if (format === 'md') {
|
|
37
|
+
content = note.content;
|
|
38
|
+
if (!filePath.endsWith('.md')) {
|
|
39
|
+
filePath = `${filePath}.md`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (format === 'html') {
|
|
43
|
+
// Basic markdown to HTML conversion (simplified)
|
|
44
|
+
content = `<!DOCTYPE html>
|
|
45
|
+
<html>
|
|
46
|
+
<head>
|
|
47
|
+
<title>${note.title}</title>
|
|
48
|
+
<meta charset="utf-8">
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
<h1>${note.title}</h1>
|
|
52
|
+
<pre>${note.content}</pre>
|
|
53
|
+
</body>
|
|
54
|
+
</html>`;
|
|
55
|
+
if (!filePath.endsWith('.html')) {
|
|
56
|
+
filePath = `${filePath}.html`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return this.error('PDF export is not yet implemented', 'PDF export is not yet implemented', 'Not implemented');
|
|
61
|
+
}
|
|
62
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
63
|
+
const output = `✅ Note exported successfully!\n\n` +
|
|
64
|
+
`**Title:** ${note.title}\n` +
|
|
65
|
+
`**Format:** ${format}\n` +
|
|
66
|
+
`**Output:** ${filePath}\n`;
|
|
67
|
+
return this.ok(output, `Note exported to ${filePath}`, 'Exported');
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
const errorMsg = `Failed to export note: ${this.formatError(error)}`;
|
|
71
|
+
return this.error(errorMsg, errorMsg, 'Export failed');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=ExportNoteTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportNoteTool.js","sourceRoot":"","sources":["../../../src/tools/hackmd/ExportNoteTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AASzC,MAAM,OAAO,cAAe,SAAQ,IAAsB;IAuBpC;IAtBX,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG,sCAAsC,CAAC;IACrD,WAAW,GAAe;QACjC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kCAAkC;aAChD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC;gBAC3B,WAAW,EAAE,6BAA6B;aAC3C;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;KACnC,CAAC;IAEF,YAAoB,YAAiB;QACnC,KAAK,EAAE,CAAC;QADU,iBAAY,GAAZ,YAAY,CAAK;IAErC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAwB;QACjC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC;YA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H,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { API } from '@hackmd/api';
|
|
2
|
+
import { Tool, type ToolResult, type ToolSchema } from '../base/Tool';
|
|
3
|
+
interface GetHistoryParams {
|
|
4
|
+
limit?: number;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare class GetHistoryTool extends Tool<GetHistoryParams> {
|
|
8
|
+
private hackmdClient;
|
|
9
|
+
readonly name = "get_history";
|
|
10
|
+
readonly description = "Get the history of recently viewed notes";
|
|
11
|
+
readonly inputSchema: ToolSchema;
|
|
12
|
+
constructor(hackmdClient: API);
|
|
13
|
+
call(params: GetHistoryParams): Promise<ToolResult>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=GetHistoryTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetHistoryTool.d.ts","sourceRoot":"","sources":["../../../src/tools/hackmd/GetHistoryTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtE,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAUD,qBAAa,cAAe,SAAQ,IAAI,CAAC,gBAAgB,CAAC;IAa5C,OAAO,CAAC,YAAY;IAZhC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,8CAA8C;IAClE,QAAQ,CAAC,WAAW,EAAE,UAAU,CAQ9B;gBAEkB,YAAY,EAAE,GAAG;IAI/B,IAAI,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CAgD1D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Tool } from '../base/Tool';
|
|
2
|
+
export class GetHistoryTool extends Tool {
|
|
3
|
+
hackmdClient;
|
|
4
|
+
name = 'get_history';
|
|
5
|
+
description = 'Get the history of recently viewed notes';
|
|
6
|
+
inputSchema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
limit: {
|
|
10
|
+
type: 'number',
|
|
11
|
+
description: 'Maximum number of history items to return (default: 20)',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
constructor(hackmdClient) {
|
|
16
|
+
super();
|
|
17
|
+
this.hackmdClient = hackmdClient;
|
|
18
|
+
}
|
|
19
|
+
async call(params) {
|
|
20
|
+
try {
|
|
21
|
+
const history = await this.hackmdClient.getHistory();
|
|
22
|
+
const limit = params.limit ?? 20;
|
|
23
|
+
const limitedHistory = history.slice(0, limit);
|
|
24
|
+
if (!limitedHistory || limitedHistory.length === 0) {
|
|
25
|
+
return this.ok('No history found', 'No history found', 'No history');
|
|
26
|
+
}
|
|
27
|
+
const output = limitedHistory
|
|
28
|
+
.map((item, index) => {
|
|
29
|
+
const title = item.text ?? 'Untitled';
|
|
30
|
+
const id = item.id ?? 'Unknown ID';
|
|
31
|
+
const tags = Array.isArray(item.tags) && item.tags.length > 0
|
|
32
|
+
? item.tags.join(', ')
|
|
33
|
+
: 'None';
|
|
34
|
+
const lastVisited = item.time
|
|
35
|
+
? new Date(item.time).toLocaleString()
|
|
36
|
+
: 'Unknown';
|
|
37
|
+
return (`${index + 1}. **${title}**\n` +
|
|
38
|
+
` ID: \`${id}\`\n` +
|
|
39
|
+
` Last visited: ${lastVisited}\n` +
|
|
40
|
+
` Tags: ${tags}\n`);
|
|
41
|
+
})
|
|
42
|
+
.join('\n');
|
|
43
|
+
return this.ok(output, `Found ${history.length} history items (showing ${limitedHistory.length})`, `${history.length} items`);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const errorMsg = `Failed to get history: ${this.formatError(error)}`;
|
|
47
|
+
return this.error(errorMsg, errorMsg, 'Failed');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=GetHistoryTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetHistoryTool.js","sourceRoot":"","sources":["../../../src/tools/hackmd/GetHistoryTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AAetE,MAAM,OAAO,cAAe,SAAQ,IAAsB;IAapC;IAZX,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG,0CAA0C,CAAC;IACzD,WAAW,GAAe;QACjC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yDAAyD;aACvE;SACF;KACF,CAAC;IAEF,YAAoB,YAAiB;QACnC,KAAK,EAAE,CAAC;QADU,iBAAY,GAAZ,YAAY,CAAK;IAErC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAwB;QACjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,EAAoB,CAAC;YACvE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;YACjC,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAE/C,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnD,OAAO,IAAI,CAAC,EAAE,CACZ,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,CACb,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG,cAAc;iBAC1B,GAAG,CAAC,CAAC,IAAkB,EAAE,KAAa,EAAE,EAAE;gBACzC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC;gBACtC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,YAAY,CAAC;gBACnC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;oBAC3D,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;oBACtB,CAAC,CAAC,MAAM,CAAC;gBACX,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI;oBAC3B,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE;oBACtC,CAAC,CAAC,SAAS,CAAC;gBAEd,OAAO,CACL,GAAG,KAAK,GAAG,CAAC,OAAO,KAAK,MAAM;oBAC9B,YAAY,EAAE,MAAM;oBACpB,oBAAoB,WAAW,IAAI;oBACnC,YAAY,IAAI,IAAI,CACrB,CAAC;YACJ,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO,IAAI,CAAC,EAAE,CACZ,MAAM,EACN,SAAS,OAAO,CAAC,MAAM,2BAA2B,cAAc,CAAC,MAAM,GAAG,EAC1E,GAAG,OAAO,CAAC,MAAM,QAAQ,CAC1B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,0BAA0B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACrE,OAAO,IAAI,CAAC,KAAK,CACf,QAAQ,EACR,QAAQ,EACR,QAAQ,CACT,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { API } from '@hackmd/api';
|
|
2
|
+
import { Tool, type ToolResult, type ToolSchema } from '../base/Tool';
|
|
3
|
+
type GetUserInfoParams = Record<string, unknown>;
|
|
4
|
+
export declare class GetUserInfoTool extends Tool<GetUserInfoParams> {
|
|
5
|
+
private hackmdClient;
|
|
6
|
+
readonly name = "get_user_info";
|
|
7
|
+
readonly description = "Get information about the current HackMD user";
|
|
8
|
+
readonly inputSchema: ToolSchema;
|
|
9
|
+
constructor(hackmdClient: API);
|
|
10
|
+
call(_params: GetUserInfoParams): Promise<ToolResult>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=GetUserInfoTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetUserInfoTool.d.ts","sourceRoot":"","sources":["../../../src/tools/hackmd/GetUserInfoTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtE,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,qBAAa,eAAgB,SAAQ,IAAI,CAAC,iBAAiB,CAAC;IAQ9C,OAAO,CAAC,YAAY;IAPhC,QAAQ,CAAC,IAAI,mBAAmB;IAChC,QAAQ,CAAC,WAAW,mDAAmD;IACvE,QAAQ,CAAC,WAAW,EAAE,UAAU,CAG9B;gBAEkB,YAAY,EAAE,GAAG;IAI/B,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;CAyB5D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Tool } from '../base/Tool';
|
|
2
|
+
export class GetUserInfoTool extends Tool {
|
|
3
|
+
hackmdClient;
|
|
4
|
+
name = 'get_user_info';
|
|
5
|
+
description = 'Get information about the current HackMD user';
|
|
6
|
+
inputSchema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {},
|
|
9
|
+
};
|
|
10
|
+
constructor(hackmdClient) {
|
|
11
|
+
super();
|
|
12
|
+
this.hackmdClient = hackmdClient;
|
|
13
|
+
}
|
|
14
|
+
async call(_params) {
|
|
15
|
+
try {
|
|
16
|
+
const user = await this.hackmdClient.getMe();
|
|
17
|
+
const output = `**User Information**\n\n` +
|
|
18
|
+
`**Name:** ${user.name ?? 'N/A'}\n` +
|
|
19
|
+
`**Email:** ${user.email ?? 'N/A'}\n` +
|
|
20
|
+
`**User Path:** ${user.userPath ?? 'N/A'}\n` +
|
|
21
|
+
`**Photo:** ${user.photo ?? 'N/A'}\n`;
|
|
22
|
+
return this.ok(output, 'Successfully retrieved user information', user.name || 'User info');
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const errorMsg = `Failed to get user info: ${this.formatError(error)}`;
|
|
26
|
+
return this.error(errorMsg, errorMsg, 'Failed');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=GetUserInfoTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetUserInfoTool.js","sourceRoot":"","sources":["../../../src/tools/hackmd/GetUserInfoTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoC,MAAM,cAAc,CAAC;AAItE,MAAM,OAAO,eAAgB,SAAQ,IAAuB;IAQtC;IAPX,IAAI,GAAG,eAAe,CAAC;IACvB,WAAW,GAAG,+CAA+C,CAAC;IAC9D,WAAW,GAAe;QACjC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;KACf,CAAC;IAEF,YAAoB,YAAiB;QACnC,KAAK,EAAE,CAAC;QADU,iBAAY,GAAZ,YAAY,CAAK;IAErC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAE7C,MAAM,MAAM,GACV,0BAA0B;gBAC1B,aAAa,IAAI,CAAC,IAAI,IAAI,KAAK,IAAI;gBACnC,cAAc,IAAI,CAAC,KAAK,IAAI,KAAK,IAAI;gBACrC,kBAAkB,IAAI,CAAC,QAAQ,IAAI,KAAK,IAAI;gBAC5C,cAAc,IAAI,CAAC,KAAK,IAAI,KAAK,IAAI,CAAC;YAExC,OAAO,IAAI,CAAC,EAAE,CACZ,MAAM,EACN,yCAAyC,EACzC,IAAI,CAAC,IAAI,IAAI,WAAW,CACzB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,4BAA4B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACvE,OAAO,IAAI,CAAC,KAAK,CACf,QAAQ,EACR,QAAQ,EACR,QAAQ,CACT,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { API } from "@hackmd/api";
|
|
2
|
+
import { Tool, type ToolResult, type ToolSchema } from "../base/Tool";
|
|
3
|
+
interface ListNotesParams {
|
|
4
|
+
teamPath?: string;
|
|
5
|
+
limit?: number;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare class ListNotesTool extends Tool<ListNotesParams> {
|
|
9
|
+
private hackmdClient;
|
|
10
|
+
readonly name = "list_notes";
|
|
11
|
+
readonly description = "List notes from HackMD. Use teamPath to list team notes.";
|
|
12
|
+
readonly inputSchema: ToolSchema;
|
|
13
|
+
constructor(hackmdClient: API);
|
|
14
|
+
call(params: ListNotesParams): Promise<ToolResult>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=ListNotesTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListNotesTool.d.ts","sourceRoot":"","sources":["../../../src/tools/hackmd/ListNotesTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGtE,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,aAAc,SAAQ,IAAI,CAAC,eAAe,CAAC;IAkB1C,OAAO,CAAC,YAAY;IAjBhC,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,8DACyC;IAC7D,QAAQ,CAAC,WAAW,EAAE,UAAU,CAY9B;gBAEkB,YAAY,EAAE,GAAG;IAI/B,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;CAqCzD"}
|