@open1s/ezbos 1.0.5 → 1.1.0

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/tool.js CHANGED
@@ -30,9 +30,6 @@ export class ToolBuilder {
30
30
  handle(callback) {
31
31
  const isAsync = callback.constructor.name === 'AsyncFunction' ||
32
32
  callback.toString().startsWith('async ');
33
- if (isAsync) {
34
- throw new Error(`Tool "${this._name}" uses an async callback, but jsbos does not support async tool callbacks. Please use a synchronous callback instead.`);
35
- }
36
33
  const properties = {};
37
34
  for (const [key, spec] of Object.entries(this._params)) {
38
35
  properties[key] = { type: spec.type };
@@ -46,13 +43,10 @@ export class ToolBuilder {
46
43
  properties,
47
44
  required: this._required.length > 0 ? this._required : Object.keys(this._params)
48
45
  };
49
- const wrappedCallback = (rawArgs) => {
46
+ const wrappedCallback = async (rawArgs) => {
50
47
  try {
51
48
  const args = typeof rawArgs === 'string' ? JSON.parse(rawArgs) : rawArgs;
52
- const result = callback(args);
53
- if (result instanceof Promise) {
54
- throw new Error('Async tool callbacks are not supported. Use a sync callback instead.');
55
- }
49
+ const result = await callback(args);
56
50
  if (isErrorResult(result))
57
51
  return 'Error: ' + (result.error || 'Unknown error');
58
52
  if (result === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open1s/ezbos",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "Simple BrainOS - Easy wrapper for @open1s/jsbos",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "license": "MIT",
40
40
  "dependencies": {
41
- "@open1s/jsbos": "^2.2.4"
41
+ "@open1s/jsbos": "^2.2.6"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@modelcontextprotocol/sdk": "^1.29.0",
package/src/tool.ts CHANGED
@@ -57,9 +57,6 @@ export class ToolBuilder {
57
57
  handle(callback: (args: Record<string, any>) => any): InternalToolDef {
58
58
  const isAsync = callback.constructor.name === 'AsyncFunction' ||
59
59
  callback.toString().startsWith('async ');
60
- if (isAsync) {
61
- throw new Error(`Tool "${this._name}" uses an async callback, but jsbos does not support async tool callbacks. Please use a synchronous callback instead.`);
62
- }
63
60
 
64
61
  const properties: Record<string, any> = {};
65
62
  for (const [key, spec] of Object.entries(this._params)) {
@@ -74,14 +71,10 @@ export class ToolBuilder {
74
71
  required: this._required.length > 0 ? this._required : Object.keys(this._params)
75
72
  };
76
73
 
77
- const wrappedCallback = (rawArgs: any): string => {
74
+ const wrappedCallback = async (rawArgs: any): Promise<string> => {
78
75
  try {
79
76
  const args = typeof rawArgs === 'string' ? JSON.parse(rawArgs) : rawArgs;
80
- const result = callback(args);
81
-
82
- if (result instanceof Promise) {
83
- throw new Error('Async tool callbacks are not supported. Use a sync callback instead.');
84
- }
77
+ const result = await callback(args);
85
78
 
86
79
  if (isErrorResult(result)) return 'Error: ' + (result.error || 'Unknown error');
87
80
  if (result === undefined) return '';