@olane/o-tool 0.4.4 → 0.6.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/dist/src/o-tool.d.ts.map +1 -1
- package/dist/src/o-tool.js +17 -15
- package/package.json +8 -4
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":"AAAA,OAAO,EAIL,SAAS,EAMV,MAAM,eAAe,CAAC;AASvB;;;;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":"AAAA,OAAO,EAIL,SAAS,EAMV,MAAM,eAAe,CAAC;AASvB;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAqV7E"}
|
package/dist/src/o-tool.js
CHANGED
|
@@ -14,7 +14,6 @@ export function oTool(Base) {
|
|
|
14
14
|
const config = args[0];
|
|
15
15
|
}
|
|
16
16
|
validateToolCall(oRequest) {
|
|
17
|
-
this.logger.debug('Validating tool call: ' + oRequest.method);
|
|
18
17
|
const method = oRequest.method;
|
|
19
18
|
if (!method) {
|
|
20
19
|
throw new Error('method parameter is required');
|
|
@@ -54,10 +53,13 @@ export function oTool(Base) {
|
|
|
54
53
|
});
|
|
55
54
|
let success = true;
|
|
56
55
|
const result = await this.execute(request).catch((error) => {
|
|
57
|
-
this.logger.error('Error executing tool: '
|
|
56
|
+
this.logger.error('Error executing tool: ', error);
|
|
58
57
|
success = false;
|
|
58
|
+
const responseError = error instanceof oToolError
|
|
59
|
+
? error
|
|
60
|
+
: new oToolError(oToolErrorCodes.TOOL_ERROR, error.message);
|
|
59
61
|
return {
|
|
60
|
-
error:
|
|
62
|
+
error: responseError.toJSON(),
|
|
61
63
|
};
|
|
62
64
|
});
|
|
63
65
|
if (success) {
|
|
@@ -76,13 +78,13 @@ export function oTool(Base) {
|
|
|
76
78
|
const request = new oRequest(requestConfig);
|
|
77
79
|
let success = true;
|
|
78
80
|
const result = await this.execute(request, stream).catch((error) => {
|
|
79
|
-
this.logger.error('Error executing tool: '
|
|
81
|
+
this.logger.error('Error executing tool: ', error, typeof error);
|
|
80
82
|
success = false;
|
|
81
83
|
const responseError = error instanceof oToolError
|
|
82
84
|
? error
|
|
83
85
|
: new oToolError(oToolErrorCodes.TOOL_ERROR, error.message);
|
|
84
86
|
return {
|
|
85
|
-
error: responseError,
|
|
87
|
+
error: responseError.toJSON(),
|
|
86
88
|
};
|
|
87
89
|
});
|
|
88
90
|
if (success) {
|
|
@@ -97,7 +99,6 @@ export function oTool(Base) {
|
|
|
97
99
|
return CoreUtils.sendResponse(response, streamData.stream);
|
|
98
100
|
}
|
|
99
101
|
async execute(req, stream) {
|
|
100
|
-
this.logger.debug('Tool handling incoming stream: ' + this.address.protocol);
|
|
101
102
|
// const protocolUsageCounter = this.p2pNode.metrics?.registerCounter(
|
|
102
103
|
// 'libp2p_protocol_custom_track',
|
|
103
104
|
// {
|
|
@@ -114,7 +115,6 @@ export function oTool(Base) {
|
|
|
114
115
|
if (request.method === oProtocolMethods.ROUTE &&
|
|
115
116
|
request.params.address === this.address.value) {
|
|
116
117
|
const { payload } = request.params;
|
|
117
|
-
this.logger.debug('Reached destination, processing payload', payload);
|
|
118
118
|
request = new oRequest({
|
|
119
119
|
id: requestConfig.id,
|
|
120
120
|
method: payload.method,
|
|
@@ -124,7 +124,6 @@ export function oTool(Base) {
|
|
|
124
124
|
...(payload.params || {}), // TODO: is this correct? this line used to be ...payload
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
|
-
this.logger.debug('Processed request: ', request);
|
|
128
127
|
}
|
|
129
128
|
const result = await this.run(request, stream);
|
|
130
129
|
return result;
|
|
@@ -141,13 +140,15 @@ export function oTool(Base) {
|
|
|
141
140
|
data: request.params,
|
|
142
141
|
});
|
|
143
142
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
// resolve o:// addresses
|
|
144
|
+
// THIS HAS A RECURSIVE CALL issue
|
|
145
|
+
this.logger.debug('Calling function at address: ', this.address.toString(), 'with request: ', request.method);
|
|
146
|
+
// const isPlaceholder = this.address.toString().includes('placeholder');
|
|
147
|
+
// request = await oRequest.translateToRawRequest(request, this);
|
|
148
|
+
let result = await this.callMyTool(request, stream);
|
|
149
|
+
// result = await oRequest.translateResultForAgent(result, this);
|
|
150
|
+
return result;
|
|
151
|
+
// translate to o:// addresses
|
|
151
152
|
}
|
|
152
153
|
myToolParams(tool) {
|
|
153
154
|
const func = Object.keys(this).find((key) => key.startsWith('_params_' + tool));
|
|
@@ -249,6 +250,7 @@ export function oTool(Base) {
|
|
|
249
250
|
async whoami() {
|
|
250
251
|
const metadata = await super.whoami();
|
|
251
252
|
return {
|
|
253
|
+
// @ts-ignore
|
|
252
254
|
tools: this.myTools(),
|
|
253
255
|
description: this.description,
|
|
254
256
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-tool",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"test": "aegir test",
|
|
20
20
|
"test:node": "aegir test -t node",
|
|
21
|
+
"deep:clean": "rm -rf node_modules && rm package-lock.json",
|
|
21
22
|
"test:browser": "aegir test -t browser",
|
|
22
23
|
"build": "tsc",
|
|
23
24
|
"start:prod": "node dist/index.js",
|
|
@@ -34,6 +35,9 @@
|
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@eslint/eslintrc": "^3.3.1",
|
|
36
37
|
"@eslint/js": "^9.29.0",
|
|
38
|
+
"@olane/o-config": "0.6.1",
|
|
39
|
+
"@olane/o-core": "0.6.1",
|
|
40
|
+
"@olane/o-protocol": "0.6.1",
|
|
37
41
|
"@tsconfig/node20": "^20.1.6",
|
|
38
42
|
"@types/jest": "^30.0.0",
|
|
39
43
|
"@types/uuid": "^10.0.0",
|
|
@@ -53,9 +57,9 @@
|
|
|
53
57
|
"typescript": "^5.8.3"
|
|
54
58
|
},
|
|
55
59
|
"peerDependencies": {
|
|
56
|
-
"@olane/o-config": "^0.
|
|
57
|
-
"@olane/o-core": "^0.
|
|
58
|
-
"@olane/o-protocol": "^0.
|
|
60
|
+
"@olane/o-config": "^0.6.1",
|
|
61
|
+
"@olane/o-core": "^0.6.1",
|
|
62
|
+
"@olane/o-protocol": "^0.6.1"
|
|
59
63
|
},
|
|
60
64
|
"dependencies": {
|
|
61
65
|
"debug": "^4.4.1",
|