@olane/o-tool 0.7.2 → 0.7.3
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/README.md +31 -8
- package/dist/src/o-tool.base.d.ts +0 -1
- package/dist/src/o-tool.base.d.ts.map +1 -1
- package/dist/src/o-tool.base.js +0 -8
- package/dist/src/o-tool.d.ts.map +1 -1
- package/dist/src/o-tool.js +5 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -95,22 +95,45 @@ class MyNetworkTool extends oTool(oNode) {
|
|
|
95
95
|
Tools are automatically discovered using naming conventions:
|
|
96
96
|
|
|
97
97
|
- **`_tool_methodName`** - Defines an executable tool method
|
|
98
|
-
|
|
98
|
+
|
|
99
|
+
Method metadata is defined using `oMethod` definition files that provide structured schemas for AI agents to understand how to use your tool methods.
|
|
99
100
|
|
|
100
101
|
```typescript
|
|
102
|
+
// weather.methods.ts - Define method schemas for AI discovery
|
|
103
|
+
import { oMethod } from '@olane/o-protocol';
|
|
104
|
+
|
|
105
|
+
export const WEATHER_METHODS: { [key: string]: oMethod } = {
|
|
106
|
+
get_forecast: {
|
|
107
|
+
name: 'get_forecast',
|
|
108
|
+
description: 'Get weather forecast for a city',
|
|
109
|
+
dependencies: [],
|
|
110
|
+
parameters: [
|
|
111
|
+
{
|
|
112
|
+
name: 'city',
|
|
113
|
+
type: 'string',
|
|
114
|
+
value: 'string',
|
|
115
|
+
description: 'City name to get forecast for',
|
|
116
|
+
required: true,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// weather.tool.ts - Implement the tool
|
|
101
123
|
class WeatherTool extends oToolBase {
|
|
124
|
+
constructor() {
|
|
125
|
+
super({
|
|
126
|
+
address: new oAddress('o://weather'),
|
|
127
|
+
description: 'Weather forecast service',
|
|
128
|
+
methods: WEATHER_METHODS,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
102
132
|
// Executable tool method
|
|
103
133
|
async _tool_get_forecast(request: oRequest): Promise<ToolResult> {
|
|
104
134
|
const { city } = request.params;
|
|
105
135
|
return { forecast: '☀️ Sunny, 72°F' };
|
|
106
136
|
}
|
|
107
|
-
|
|
108
|
-
// Parameter schema (optional)
|
|
109
|
-
_params_get_forecast() {
|
|
110
|
-
return {
|
|
111
|
-
city: { type: 'string', required: true, description: 'City name' }
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
137
|
}
|
|
115
138
|
```
|
|
116
139
|
|
|
@@ -19,7 +19,6 @@ export declare class oToolBase extends oCore {
|
|
|
19
19
|
run(request: oRequest, stream?: Stream): Promise<RunResult>;
|
|
20
20
|
myTools(obj?: any): Promise<string[]>;
|
|
21
21
|
findMethod(method: string): Promise<string | undefined>;
|
|
22
|
-
myToolParams(tool: string): Record<string, any>;
|
|
23
22
|
callMyTool(request: oRequest, stream?: Stream): Promise<ToolResult>;
|
|
24
23
|
index(): Promise<{
|
|
25
24
|
provider: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-tool.base.d.ts","sourceRoot":"","sources":["../../src/o-tool.base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,KAAK,EAGL,QAAQ,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAInE;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,OAAO,CAAC,OAAO,CAAkB;IAEjC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAY7C,mBAAmB,IAAI,GAAG,EAAE;IAI5B,OAAO,CACL,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,QAAQ,GACtB,OAAO,CAAC,WAAW,CAAC;IAGvB,gB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EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA8B3D,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA2BjE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAS/B,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIvD,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAqBnE,KAAK;;;;;;;IA4FL,MAAM;;;;CAQb"}
|
package/dist/src/o-tool.base.js
CHANGED
|
@@ -82,14 +82,6 @@ export class oToolBase extends oCore {
|
|
|
82
82
|
async findMethod(method) {
|
|
83
83
|
return (await this.myTools()).find((key) => key.startsWith(method));
|
|
84
84
|
}
|
|
85
|
-
myToolParams(tool) {
|
|
86
|
-
const func = Object.keys(this).find((key) => key.startsWith('_params_' + tool));
|
|
87
|
-
if (!func) {
|
|
88
|
-
throw new Error(`Tool ${tool} not found`);
|
|
89
|
-
}
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
return this[func]();
|
|
92
|
-
}
|
|
93
85
|
async callMyTool(request, stream) {
|
|
94
86
|
const method = request.method;
|
|
95
87
|
this.logger.debug('Calling tool: ' + method, 'Origin caller address: ', request?.params?._callerAddress);
|
package/dist/src/o-tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-tool.d.ts","sourceRoot":"","sources":["../../src/o-tool.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"o-tool.d.ts","sourceRoot":"","sources":["../../src/o-tool.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAgH7E"}
|
package/dist/src/o-tool.js
CHANGED
|
@@ -55,6 +55,11 @@ export function oTool(Base) {
|
|
|
55
55
|
}
|
|
56
56
|
return result;
|
|
57
57
|
}
|
|
58
|
+
async _tool_ping(request) {
|
|
59
|
+
return {
|
|
60
|
+
message: 'Pong!',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
58
63
|
async _tool_route(request) {
|
|
59
64
|
if (request.params.address === this.address.toString() ||
|
|
60
65
|
request.params.address === this.staticAddress.toString()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-tool",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "git+https://github.com/olane-labs/olane.git"
|
|
32
32
|
},
|
|
33
33
|
"author": "oLane Inc.",
|
|
34
|
-
"license": "
|
|
34
|
+
"license": "(MIT OR Apache-2.0)",
|
|
35
35
|
"description": "oLane base tool class",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@eslint/eslintrc": "^3.3.1",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"typescript": "^5.8.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@olane/o-config": "^0.7.
|
|
59
|
-
"@olane/o-core": "^0.7.
|
|
60
|
-
"@olane/o-protocol": "^0.7.
|
|
58
|
+
"@olane/o-config": "^0.7.2",
|
|
59
|
+
"@olane/o-core": "^0.7.2",
|
|
60
|
+
"@olane/o-protocol": "^0.7.2"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"debug": "^4.4.1",
|