-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.ts
More file actions
94 lines (90 loc) · 2.56 KB
/
Copy pathmod.ts
File metadata and controls
94 lines (90 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// deno-lint-ignore-file require-await, no-unused-vars
import type { PluginContext, Tool, ToolCallResult } from 'cortex/plugins';
function ok(n: string, o: unknown, s: number): ToolCallResult {
return {
toolName: n,
success: true,
output: JSON.stringify(o, null, 2),
durationMs: Date.now() - s,
};
}
const tutorial_generateTool: Tool = {
definition: {
name: 'tutorial_generate',
description: 'Generate tutorial from codebase or API',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[interactive-tutorials] tutorial_generate executed');
return ok('tutorial_generate', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'tutorial_generate',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
const tutorial_add_exerciseTool: Tool = {
definition: {
name: 'tutorial_add_exercise',
description: 'Add interactive exercise with validation',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[interactive-tutorials] tutorial_add_exercise executed');
return ok('tutorial_add_exercise', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'tutorial_add_exercise',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
const tutorial_exportTool: Tool = {
definition: {
name: 'tutorial_export',
description: 'Export tutorial to Mintlify or GitBook',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[interactive-tutorials] tutorial_export executed');
return ok('tutorial_export', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'tutorial_export',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
export async function onLoad(ctx: PluginContext): Promise<void> {
ctx.logger.info('[cortex-plugin-interactive-tutorials] Loaded');
}
export async function onUnload(ctx: PluginContext): Promise<void> {
ctx.logger.info('[cortex-plugin-interactive-tutorials] Unloading...');
}
export const tools: Tool[] = [
tutorial_generateTool,
tutorial_add_exerciseTool,
tutorial_exportTool,
];