@oh-my-tool/sdk 0.2.0 → 0.3.1
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/package.json +15 -6
- package/src/index.ts +66 -66
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oh-my-tool/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
1
|
+
{
|
|
2
|
+
"name": "@oh-my-tool/sdk",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"description": "Oh My Tool extension SDK",
|
|
6
|
-
"keywords": [
|
|
6
|
+
"keywords": [
|
|
7
|
+
"ai",
|
|
8
|
+
"agent",
|
|
9
|
+
"tools",
|
|
10
|
+
"extensions",
|
|
11
|
+
"sdk",
|
|
12
|
+
"bun"
|
|
13
|
+
],
|
|
7
14
|
"homepage": "https://github.com/oh-my-tool/oh-my-tool#readme",
|
|
8
15
|
"repository": {
|
|
9
16
|
"type": "git",
|
|
@@ -14,7 +21,9 @@
|
|
|
14
21
|
"exports": {
|
|
15
22
|
".": "./src/index.ts"
|
|
16
23
|
},
|
|
17
|
-
"files": [
|
|
24
|
+
"files": [
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
18
27
|
"engines": {
|
|
19
28
|
"bun": ">=1.4.0"
|
|
20
29
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
export const OMT_API_VERSION = "0.1.0";
|
|
2
|
-
|
|
3
|
-
export interface ToolManifest {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
keywords?: string[];
|
|
7
|
-
risk?: "read" | "write" | "admin";
|
|
8
|
-
inputSchema?: Record<string, unknown>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ExtensionManifest {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
15
|
-
sdkVersion: string;
|
|
16
|
-
description: string;
|
|
17
|
-
keywords?: string[];
|
|
18
|
-
entry?: string;
|
|
19
|
-
tools: ToolManifest[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ToolContext {
|
|
23
|
-
toolName: string;
|
|
24
|
-
logger: Logger;
|
|
25
|
-
config: Record<string, unknown>;
|
|
26
|
-
secrets: SecretStore;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface Logger {
|
|
30
|
-
debug(msg: string): void;
|
|
31
|
-
info(msg: string): void;
|
|
32
|
-
warn(msg: string): void;
|
|
33
|
-
error(msg: string): void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface SecretStore {
|
|
37
|
-
get(name: string): Promise<string | undefined>;
|
|
38
|
-
set(name: string, value: string): Promise<void>;
|
|
39
|
-
delete(name: string): Promise<void>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface ToolResult {
|
|
43
|
-
data: unknown;
|
|
44
|
-
meta?: Record<string, unknown>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type ToolHandler = (
|
|
48
|
-
ctx: ToolContext,
|
|
49
|
-
input: unknown,
|
|
50
|
-
) => Promise<ToolResult>;
|
|
51
|
-
|
|
52
|
-
export interface ExtensionDefinition {
|
|
53
|
-
handlers: Record<string, ToolHandler>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function defineExtension(ext: ExtensionDefinition): ExtensionDefinition {
|
|
57
|
-
return ext;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class ToolError extends Error {
|
|
61
|
-
constructor(
|
|
62
|
-
public code: string,
|
|
63
|
-
message: string,
|
|
64
|
-
) {
|
|
65
|
-
super(message);
|
|
66
|
-
}
|
|
1
|
+
export const OMT_API_VERSION = "0.1.0";
|
|
2
|
+
|
|
3
|
+
export interface ToolManifest {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
keywords?: string[];
|
|
7
|
+
risk?: "read" | "write" | "admin";
|
|
8
|
+
inputSchema?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ExtensionManifest {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
version: string;
|
|
15
|
+
sdkVersion: string;
|
|
16
|
+
description: string;
|
|
17
|
+
keywords?: string[];
|
|
18
|
+
entry?: string;
|
|
19
|
+
tools: ToolManifest[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ToolContext {
|
|
23
|
+
toolName: string;
|
|
24
|
+
logger: Logger;
|
|
25
|
+
config: Record<string, unknown>;
|
|
26
|
+
secrets: SecretStore;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Logger {
|
|
30
|
+
debug(msg: string): void;
|
|
31
|
+
info(msg: string): void;
|
|
32
|
+
warn(msg: string): void;
|
|
33
|
+
error(msg: string): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SecretStore {
|
|
37
|
+
get(name: string): Promise<string | undefined>;
|
|
38
|
+
set(name: string, value: string): Promise<void>;
|
|
39
|
+
delete(name: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ToolResult {
|
|
43
|
+
data: unknown;
|
|
44
|
+
meta?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ToolHandler = (
|
|
48
|
+
ctx: ToolContext,
|
|
49
|
+
input: unknown,
|
|
50
|
+
) => Promise<ToolResult>;
|
|
51
|
+
|
|
52
|
+
export interface ExtensionDefinition {
|
|
53
|
+
handlers: Record<string, ToolHandler>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function defineExtension(ext: ExtensionDefinition): ExtensionDefinition {
|
|
57
|
+
return ext;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class ToolError extends Error {
|
|
61
|
+
constructor(
|
|
62
|
+
public code: string,
|
|
63
|
+
message: string,
|
|
64
|
+
) {
|
|
65
|
+
super(message);
|
|
66
|
+
}
|
|
67
67
|
}
|