toolcraft 0.0.150 → 0.0.151

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/composition.json CHANGED
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.150",
116
+ "version": "0.0.151",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.150",
126
+ "version": "0.0.151",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.150",
116
+ "version": "0.0.151",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.150",
126
+ "version": "0.0.151",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -38,6 +38,29 @@ const ignoredFileChangeCommand = defineCommand({
38
38
  changes: [{ kind: "added", path: "flows/morning.json", newContent: "{}\n" }]
39
39
  })
40
40
  });
41
+ defineCommand({
42
+ name: "mapped-result",
43
+ params: S.Object({}),
44
+ result: S.Object({ data: S.Array(S.String()) }),
45
+ mcpResult: (result) => ({ data: result }),
46
+ handler: async () => [],
47
+ });
48
+ defineCommand({
49
+ name: "invalid-async-mapped-result",
50
+ params: S.Object({}),
51
+ result: S.Object({ data: S.Array(S.String()) }),
52
+ // @ts-expect-error MCP result mappers are synchronous
53
+ mcpResult: async (result) => ({ data: result }),
54
+ handler: async () => [],
55
+ });
56
+ defineCommand({
57
+ name: "invalid-scalar-mapped-result",
58
+ params: S.Object({}),
59
+ result: S.Object({ data: S.Array(S.String()) }),
60
+ // @ts-expect-error MCP structured results must have an object root
61
+ mcpResult: () => "invalid",
62
+ handler: async () => [],
63
+ });
41
64
  const ignoredGroup = defineGroup({
42
65
  name: "root",
43
66
  scope: ignoredScope,
package/dist/mcp.js CHANGED
@@ -892,7 +892,15 @@ function createResolvedMCPServer(root, options, runtime = {}) {
892
892
  return renderPendingApproval(result);
893
893
  }
894
894
  if (tool.resultSchema !== undefined) {
895
- const mcpResult = tool.command.mcpResult === undefined ? result : tool.command.mcpResult(result);
895
+ let mcpResult = result;
896
+ if (tool.command.mcpResult !== undefined) {
897
+ try {
898
+ mcpResult = tool.command.mcpResult(result);
899
+ }
900
+ catch (error) {
901
+ throw new ToolError(JSON_RPC_ERROR_CODES.INTERNAL_ERROR, error instanceof Error ? error.message : String(error));
902
+ }
903
+ }
896
904
  const structuredContent = validateCommandResult(tool.resultSchema, mcpResult, casing);
897
905
  return {
898
906
  content: [{ type: "text", text: JSON.stringify(structuredContent) }],
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.150",
11
+ "version": "0.0.151",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.150",
3
+ "version": "0.0.151",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.150",
3
+ "version": "0.0.151",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "yaml"
159
159
  ],
160
160
  "optionalDependencies": {
161
- "toolcraft-schema": "0.0.150",
161
+ "toolcraft-schema": "0.0.151",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",