-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.ts
More file actions
114 lines (109 loc) · 3.03 KB
/
Copy pathmod.ts
File metadata and controls
114 lines (109 loc) · 3.03 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// 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 sci_runTool: Tool = {
definition: {
name: 'sci_run',
description: 'Run Python/R scientific computation',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[scientific-computing] sci_run executed');
return ok('sci_run', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'sci_run',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
const sci_simulateTool: Tool = {
definition: {
name: 'sci_simulate',
description: 'Run Monte Carlo or Bayesian simulation',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[scientific-computing] sci_simulate executed');
return ok('sci_simulate', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'sci_simulate',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
const sci_solveTool: Tool = {
definition: {
name: 'sci_solve',
description: 'Solve differential equations',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[scientific-computing] sci_solve executed');
return ok('sci_solve', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'sci_solve',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
const sci_export_figureTool: Tool = {
definition: {
name: 'sci_export_figure',
description: 'Export publication-quality LaTeX figure',
params: [],
capabilities: ['network:fetch'],
},
execute: async (args, ctx) => {
const s = Date.now();
try {
ctx.logger.info('[scientific-computing] sci_export_figure executed');
return ok('sci_export_figure', { status: 'completed', result: 'stub' }, s);
} catch (e) {
return {
toolName: 'sci_export_figure',
success: false,
output: '',
error: String(e),
durationMs: Date.now() - s,
};
}
},
};
export async function onLoad(ctx: PluginContext): Promise<void> {
ctx.logger.info('[cortex-plugin-scientific-computing] Loaded');
}
export async function onUnload(ctx: PluginContext): Promise<void> {
ctx.logger.info('[cortex-plugin-scientific-computing] Unloading...');
}
export const tools: Tool[] = [sci_runTool, sci_simulateTool, sci_solveTool, sci_export_figureTool];