@rnsk/toolkits 0.0.3 → 0.0.4

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.
Files changed (116) hide show
  1. package/README.md +4 -4
  2. package/dist/toolkits/github/tools/Actions/get-workflow-job.d.ts +3 -3
  3. package/dist/toolkits/github/tools/Actions/list-artifacts.d.ts +1 -1
  4. package/dist/toolkits/github/tools/Actions/list-workflow-jobs.d.ts +3 -3
  5. package/dist/toolkits/github/tools/Actions/list-workflow-run-artifacts.d.ts +1 -1
  6. package/dist/toolkits/github/tools/Activity/list-notifications.d.ts +1 -1
  7. package/dist/toolkits/github/tools/Activity/list-public-events.d.ts +1 -1
  8. package/dist/toolkits/github/tools/Activity/list-repo-events.d.ts +1 -1
  9. package/dist/toolkits/github/tools/Activity/list-user-events.d.ts +1 -1
  10. package/dist/toolkits/github/tools/Apps/list-installations.d.ts +1 -1
  11. package/dist/toolkits/github/tools/Checks/create-check-run.d.ts +5 -5
  12. package/dist/toolkits/github/tools/Checks/create-check-suite.d.ts +2 -2
  13. package/dist/toolkits/github/tools/Checks/get-check-run.d.ts +2 -2
  14. package/dist/toolkits/github/tools/Checks/get-check-suite.d.ts +2 -2
  15. package/dist/toolkits/github/tools/Checks/list-check-runs.d.ts +4 -4
  16. package/dist/toolkits/github/tools/Checks/update-check-run.d.ts +4 -4
  17. package/dist/toolkits/github/tools/CodeScanning/list-alerts.d.ts +2 -2
  18. package/dist/toolkits/github/tools/CodeScanning/update-alert.d.ts +1 -1
  19. package/dist/toolkits/github/tools/Collaborators/add-collaborator.d.ts +1 -1
  20. package/dist/toolkits/github/tools/Collaborators/check-collaborator.d.ts +1 -1
  21. package/dist/toolkits/github/tools/Collaborators/list-collaborators.d.ts +1 -1
  22. package/dist/toolkits/github/tools/Collaborators/remove-collaborator.d.ts +1 -1
  23. package/dist/toolkits/github/tools/Commits/compare-commits.d.ts +2 -2
  24. package/dist/toolkits/github/tools/Commits/get-commit.d.ts +2 -2
  25. package/dist/toolkits/github/tools/Commits/list-commits.d.ts +1 -1
  26. package/dist/toolkits/github/tools/Commits/list-pull-requests-associated-with-commit.d.ts +2 -2
  27. package/dist/toolkits/github/tools/Dependabot/list-alerts.d.ts +1 -1
  28. package/dist/toolkits/github/tools/Dependabot/update-alert.d.ts +1 -1
  29. package/dist/toolkits/github/tools/DeployKeys/list-deploy-keys.d.ts +1 -1
  30. package/dist/toolkits/github/tools/Deployments/create-deployment.d.ts +1 -1
  31. package/dist/toolkits/github/tools/Deployments/list-deployments.d.ts +1 -1
  32. package/dist/toolkits/github/tools/Environments/list-environments.d.ts +1 -1
  33. package/dist/toolkits/github/tools/Files/create-or-update-file.d.ts +1 -1
  34. package/dist/toolkits/github/tools/Gists/create-gist.d.ts +1 -1
  35. package/dist/toolkits/github/tools/Git/create-blob.d.ts +1 -1
  36. package/dist/toolkits/github/tools/Git/create-tree.d.ts +1 -1
  37. package/dist/toolkits/github/tools/Issues/add-issue-assignees.d.ts +1 -1
  38. package/dist/toolkits/github/tools/Issues/list-authenticated-user-issues.d.ts +3 -3
  39. package/dist/toolkits/github/tools/Issues/list-issue-comments.d.ts +1 -1
  40. package/dist/toolkits/github/tools/Issues/list-org-issues.d.ts +3 -3
  41. package/dist/toolkits/github/tools/Issues/list-repo-issues.d.ts +2 -2
  42. package/dist/toolkits/github/tools/Issues/list-user-account-issues.d.ts +3 -3
  43. package/dist/toolkits/github/tools/Organizations/get-org-membership.d.ts +1 -1
  44. package/dist/toolkits/github/tools/Organizations/list-org-members.d.ts +1 -1
  45. package/dist/toolkits/github/tools/Organizations/list-org-repositories.d.ts +2 -2
  46. package/dist/toolkits/github/tools/Organizations/list-user-organizations.d.ts +1 -1
  47. package/dist/toolkits/github/tools/Organizations/update-organization.d.ts +1 -1
  48. package/dist/toolkits/github/tools/PRs/create-pull-request-review.d.ts +1 -1
  49. package/dist/toolkits/github/tools/PRs/list-pull-request-files.d.ts +1 -1
  50. package/dist/toolkits/github/tools/PRs/list-pull-requests.d.ts +1 -1
  51. package/dist/toolkits/github/tools/Projects/list-org-projects.d.ts +1 -1
  52. package/dist/toolkits/github/tools/Projects/list-project-columns.d.ts +1 -1
  53. package/dist/toolkits/github/tools/Projects/list-repo-projects.d.ts +1 -1
  54. package/dist/toolkits/github/tools/Projects/update-project.d.ts +1 -1
  55. package/dist/toolkits/github/tools/Reactions/create-commit-comment-reaction.d.ts +1 -1
  56. package/dist/toolkits/github/tools/Reactions/create-issue-reaction.d.ts +1 -1
  57. package/dist/toolkits/github/tools/Reactions/list-commit-comment-reactions.d.ts +1 -1
  58. package/dist/toolkits/github/tools/Reactions/list-issue-reactions.d.ts +1 -1
  59. package/dist/toolkits/github/tools/Reactions/list-pr-comment-reactions.d.ts +1 -1
  60. package/dist/toolkits/github/tools/Releases/list-releases.d.ts +1 -1
  61. package/dist/toolkits/github/tools/Repos/get-repo-contributors.d.ts +1 -1
  62. package/dist/toolkits/github/tools/Repos/list-branches.d.ts +1 -1
  63. package/dist/toolkits/github/tools/Repos/list-repos.d.ts +2 -2
  64. package/dist/toolkits/github/tools/Repos/watch-repo.d.ts +1 -1
  65. package/dist/toolkits/github/tools/Search/search-repos.d.ts +1 -1
  66. package/dist/toolkits/github/tools/SecretScanning/list-alerts.d.ts +1 -1
  67. package/dist/toolkits/github/tools/SecretScanning/update-alert.d.ts +1 -1
  68. package/dist/toolkits/github/tools/SecurityAdvisories/create-repository-advisory.d.ts +1 -1
  69. package/dist/toolkits/github/tools/SecurityAdvisories/get-repository-advisory.d.ts +1 -1
  70. package/dist/toolkits/github/tools/SecurityAdvisories/list-global-advisories.d.ts +1 -1
  71. package/dist/toolkits/github/tools/SecurityAdvisories/list-repository-advisories.d.ts +2 -2
  72. package/dist/toolkits/github/tools/Stars/list-stargazers.d.ts +1 -1
  73. package/dist/toolkits/github/tools/Stars/list-starred-repos.d.ts +1 -1
  74. package/dist/toolkits/github/tools/Statuses/create-commit-status.d.ts +1 -1
  75. package/dist/toolkits/github/tools/Statuses/list-commit-statuses.d.ts +1 -1
  76. package/dist/toolkits/github/tools/Teams/list-team-members.d.ts +1 -1
  77. package/dist/toolkits/github/tools/Teams/list-team-repos.d.ts +1 -1
  78. package/dist/toolkits/github/tools/Teams/list-teams.d.ts +1 -1
  79. package/dist/toolkits/github/tools/Users/get-user-context.d.ts +1 -1
  80. package/dist/toolkits/github/tools/Users/update-authenticated-user.d.ts +1 -1
  81. package/dist/toolkits/github/tools/Webhooks/create-repo-webhook.d.ts +1 -1
  82. package/dist/toolkits/github/tools/Webhooks/list-repo-webhooks.d.ts +1 -1
  83. package/dist/toolkits/github/tools/Webhooks/update-repo-webhook.d.ts +1 -1
  84. package/dist/toolkits/github/tools/Workflows/list-workflow-runs.d.ts +2 -2
  85. package/dist/toolkits/github/tools/Workflows/list-workflows.d.ts +1 -1
  86. package/dist/toolkits/github/tools/index.d.ts +4859 -175
  87. package/dist/toolkits/github/tools/index.js +342 -342
  88. package/dist/toolkits/gmail/tools/create-draft.d.ts +1 -1
  89. package/dist/toolkits/gmail/tools/reply-to-thread.d.ts +1 -1
  90. package/dist/toolkits/gmail/tools/send-message.d.ts +1 -1
  91. package/dist/toolkits/linear/manifest.js +35 -0
  92. package/dist/toolkits/linear/tools/add-comment.d.ts +6 -0
  93. package/dist/toolkits/linear/tools/add-comment.js +52 -0
  94. package/dist/toolkits/linear/tools/get-issue.d.ts +6 -0
  95. package/dist/toolkits/linear/tools/get-issue.js +117 -0
  96. package/dist/toolkits/linear/tools/list-projects.d.ts +4 -0
  97. package/dist/toolkits/linear/tools/list-projects.js +46 -0
  98. package/dist/toolkits/linear/tools/list-workflow-states.d.ts +26 -0
  99. package/dist/toolkits/linear/tools/list-workflow-states.js +59 -0
  100. package/dist/toolkits/linear/tools/update-issue.d.ts +11 -0
  101. package/dist/toolkits/linear/tools/update-issue.js +78 -0
  102. package/dist/toolkits/notion/tools/append-block-children.d.ts +1 -1
  103. package/dist/toolkits/notion/tools/index.d.ts +105 -12
  104. package/dist/toolkits/notion/tools/index.js +8 -8
  105. package/dist/toolkits/notion/tools/query-database.d.ts +1 -1
  106. package/package.json +4 -3
  107. package/dist/runtime/credentials.d.ts +0 -28
  108. package/dist/runtime/credentials.js +0 -15
  109. package/dist/runtime/index.d.ts +0 -5
  110. package/dist/runtime/index.js +0 -5
  111. package/dist/runtime/meta-tools.d.ts +0 -101
  112. package/dist/runtime/meta-tools.js +0 -250
  113. package/dist/runtime/registry.d.ts +0 -20
  114. package/dist/runtime/registry.js +0 -35
  115. package/dist/runtime/schema-helpers.d.ts +0 -20
  116. package/dist/runtime/schema-helpers.js +0 -157
@@ -1,28 +0,0 @@
1
- import type { ToolkitManifest } from '../core/types.js';
2
- import type { ToolRegistry } from './registry.js';
3
- export interface CredentialResolver {
4
- getToken: (tokenField: string) => Promise<string | null>;
5
- getServiceEnv: (envName: string) => string | undefined;
6
- }
7
- export interface MetaToolPolicyResult {
8
- allowed: boolean;
9
- error?: string;
10
- reason?: string;
11
- }
12
- export interface MetaToolHooks {
13
- checkToolPolicy?: (toolName: string) => MetaToolPolicyResult;
14
- sanitizeToolResult?: (result: unknown) => unknown;
15
- sanitizeToolPayload?: (payload: Record<string, unknown>) => Record<string, unknown>;
16
- isWebSearchEnabled?: () => boolean;
17
- getAppUrl?: () => string;
18
- getProviderSlugs?: () => string[];
19
- isToolkitAvailable?: (toolkitId: string) => {
20
- available: boolean;
21
- reason?: string;
22
- };
23
- }
24
- export declare function registerAllToolsFromManifests(registry: ToolRegistry, manifests: ToolkitManifest[], options?: {
25
- skipUnavailable?: boolean;
26
- isToolkitAvailable?: (id: string) => boolean;
27
- }): void;
28
- //# sourceMappingURL=credentials.d.ts.map
@@ -1,15 +0,0 @@
1
- export function registerAllToolsFromManifests(registry, manifests, options) {
2
- for (const manifest of manifests) {
3
- if (options?.skipUnavailable && options.isToolkitAvailable && !options.isToolkitAvailable(manifest.id)) {
4
- continue;
5
- }
6
- for (const toolDef of manifest.tools) {
7
- registry.register(toolDef.name, toolDef.description ?? toolDef.tool.description ?? '', toolDef.tool, {
8
- requiredAuth: toolDef.requiredAuth,
9
- scope: toolDef.scope,
10
- toolkitId: manifest.id,
11
- });
12
- }
13
- }
14
- }
15
- //# sourceMappingURL=credentials.js.map
@@ -1,5 +0,0 @@
1
- export { getToolInputZodSchema, resolveZodObjectShape, toolInputToJsonSchema, extractParameterInfo, coerceArguments, TOOL_OUTPUT_JSON_SCHEMA, type ParameterInfo, } from './schema-helpers.js';
2
- export { createToolRegistry, type ToolRegistry, type ToolRegistryEntry } from './registry.js';
3
- export { registerAllToolsFromManifests, type CredentialResolver, type MetaToolHooks, type MetaToolPolicyResult, } from './credentials.js';
4
- export { createMetaTools } from './meta-tools.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- export { getToolInputZodSchema, resolveZodObjectShape, toolInputToJsonSchema, extractParameterInfo, coerceArguments, TOOL_OUTPUT_JSON_SCHEMA, } from './schema-helpers.js';
2
- export { createToolRegistry } from './registry.js';
3
- export { registerAllToolsFromManifests, } from './credentials.js';
4
- export { createMetaTools } from './meta-tools.js';
5
- //# sourceMappingURL=index.js.map
@@ -1,101 +0,0 @@
1
- import type { CredentialResolver, MetaToolHooks } from './credentials.js';
2
- import type { ToolRegistry } from './registry.js';
3
- export interface MetaToolsConfig {
4
- registry: ToolRegistry;
5
- credentials: CredentialResolver;
6
- hooks?: MetaToolHooks;
7
- }
8
- export declare function createMetaTools({ registry, credentials, hooks }: MetaToolsConfig): {
9
- searchTool: import("ai").Tool<{
10
- pattern: string;
11
- searchIn: "names" | "descriptions" | "both";
12
- }, {
13
- pattern: string;
14
- searchIn: "names" | "descriptions" | "both";
15
- matches: number;
16
- tools: {
17
- name: string;
18
- description: string;
19
- parameters: Record<string, unknown> | undefined;
20
- requiredAuth: string | undefined;
21
- }[];
22
- error?: undefined;
23
- message?: undefined;
24
- } | {
25
- error: string;
26
- message: string;
27
- pattern: string;
28
- searchIn?: undefined;
29
- matches?: undefined;
30
- tools?: undefined;
31
- }>;
32
- checkAuthentication: import("ai").Tool<{
33
- toolName: string;
34
- }, {
35
- error: string;
36
- toolName: string;
37
- availableTools: string[];
38
- authenticated?: undefined;
39
- reason?: undefined;
40
- message?: undefined;
41
- requiredAuth?: undefined;
42
- } | {
43
- authenticated: boolean;
44
- toolName: string;
45
- reason: string;
46
- message: string | undefined;
47
- error?: undefined;
48
- availableTools?: undefined;
49
- requiredAuth?: undefined;
50
- } | {
51
- authenticated: boolean;
52
- toolName: string;
53
- reason: string;
54
- error?: undefined;
55
- availableTools?: undefined;
56
- message?: undefined;
57
- requiredAuth?: undefined;
58
- } | {
59
- authenticated: boolean;
60
- toolName: string;
61
- requiredAuth: string;
62
- reason: string;
63
- error?: undefined;
64
- availableTools?: undefined;
65
- message?: undefined;
66
- } | {
67
- authenticated: boolean;
68
- toolName: string;
69
- error?: undefined;
70
- availableTools?: undefined;
71
- reason?: undefined;
72
- message?: undefined;
73
- requiredAuth?: undefined;
74
- } | {
75
- error: string;
76
- toolName: string;
77
- message: string;
78
- availableTools?: undefined;
79
- authenticated?: undefined;
80
- reason?: undefined;
81
- requiredAuth?: undefined;
82
- }>;
83
- initiateConnection: import("ai").Tool<{
84
- provider: string;
85
- }, {
86
- link: string;
87
- provider: string;
88
- error?: undefined;
89
- supportedProviders?: undefined;
90
- } | {
91
- error: string;
92
- provider: string;
93
- supportedProviders: string[];
94
- link?: undefined;
95
- }>;
96
- executeTool: import("ai").Tool<{
97
- args: Record<string, unknown>;
98
- toolName: string;
99
- }, Record<string, unknown>>;
100
- };
101
- //# sourceMappingURL=meta-tools.d.ts.map
@@ -1,250 +0,0 @@
1
- import { tool } from 'ai';
2
- import { z } from 'zod';
3
- import { coerceArguments, extractParameterInfo, getToolInputZodSchema, resolveZodObjectShape, } from './schema-helpers.js';
4
- export function createMetaTools({ registry, credentials, hooks = {} }) {
5
- const { checkToolPolicy, sanitizeToolResult = (r) => r, sanitizeToolPayload = (p) => p, isWebSearchEnabled = () => true, getAppUrl = () => process.env.APP_URL ?? 'http://localhost:3000', getProviderSlugs = () => [], isToolkitAvailable, } = hooks;
6
- const searchTool = tool({
7
- description: 'Search for available tools in the registry based on a regex pattern. Use this to discover tools that can help with a specific task. Returns detailed parameter information including types and descriptions.',
8
- inputSchema: z.object({
9
- pattern: z.string().describe('Regex pattern to search for in tool names and descriptions'),
10
- searchIn: z
11
- .enum(['names', 'descriptions', 'both'])
12
- .optional()
13
- .default('both')
14
- .describe('Where to search: names, descriptions, or both'),
15
- }),
16
- execute: async ({ pattern, searchIn = 'both' }) => {
17
- try {
18
- const results = registry.search(pattern, searchIn);
19
- return {
20
- pattern,
21
- searchIn,
22
- matches: results.length,
23
- tools: results.map((toolMetadata) => {
24
- const toolSchema = getToolInputZodSchema(toolMetadata.tool);
25
- const shape = resolveZodObjectShape(toolSchema);
26
- const parameters = {};
27
- if (shape) {
28
- for (const [paramName, paramSchema] of Object.entries(shape)) {
29
- parameters[paramName] = extractParameterInfo(paramSchema);
30
- }
31
- }
32
- return {
33
- name: toolMetadata.name,
34
- description: toolMetadata.description,
35
- parameters: Object.keys(parameters).length > 0 ? parameters : undefined,
36
- requiredAuth: toolMetadata.requiredAuth,
37
- };
38
- }),
39
- };
40
- }
41
- catch (error) {
42
- return {
43
- error: 'Failed to search tools',
44
- message: error instanceof Error ? error.message : 'Unknown error',
45
- pattern,
46
- };
47
- }
48
- },
49
- });
50
- const checkAuthentication = tool({
51
- description: 'Check whether the user is authenticated for a specific tool. Use this after searchTool when a tool has requiredAuth.',
52
- inputSchema: z.object({
53
- toolName: z.string().describe('Name of the tool to check authentication for'),
54
- }),
55
- execute: async ({ toolName }) => {
56
- try {
57
- const toolMetadata = registry.get(toolName);
58
- if (!toolMetadata) {
59
- return {
60
- error: 'Tool not found',
61
- toolName,
62
- availableTools: registry.getToolNames(),
63
- };
64
- }
65
- if (isToolkitAvailable) {
66
- const availability = isToolkitAvailable(toolMetadata.toolkitId);
67
- if (!availability.available) {
68
- return {
69
- authenticated: false,
70
- toolName,
71
- reason: 'toolkit_unconfigured',
72
- message: availability.reason,
73
- };
74
- }
75
- }
76
- if (!toolMetadata.requiredAuth) {
77
- return {
78
- authenticated: true,
79
- toolName,
80
- reason: 'no_auth_required',
81
- };
82
- }
83
- const token = await credentials.getToken(toolMetadata.requiredAuth);
84
- if (!token) {
85
- return {
86
- authenticated: false,
87
- toolName,
88
- requiredAuth: toolMetadata.requiredAuth,
89
- reason: 'token_missing',
90
- };
91
- }
92
- return {
93
- authenticated: true,
94
- toolName,
95
- };
96
- }
97
- catch (error) {
98
- return {
99
- error: 'Failed to check authentication',
100
- toolName,
101
- message: error instanceof Error ? error.message : 'Unknown error',
102
- };
103
- }
104
- },
105
- });
106
- const initiateConnection = tool({
107
- description: 'Get a link for the user to connect an external provider. Use when checkAuthentication returns not authenticated.',
108
- inputSchema: z.object({
109
- provider: z.string().describe('Provider to connect: e.g. "github" for githubToken'),
110
- }),
111
- execute: async ({ provider }) => {
112
- const baseUrl = getAppUrl();
113
- const slug = provider.toLowerCase().replace(/\s+/g, '-');
114
- const supported = getProviderSlugs();
115
- if (supported.includes(slug)) {
116
- return {
117
- link: `${baseUrl}/auth/provider/${slug}`,
118
- provider: slug,
119
- };
120
- }
121
- return {
122
- error: 'Unknown provider',
123
- provider,
124
- supportedProviders: supported,
125
- };
126
- },
127
- });
128
- const executeTool = tool({
129
- description: 'Execute any tool from the registry by providing its name and arguments. Use this after finding a suitable tool with searchTool.',
130
- inputSchema: z.object({
131
- toolName: z.string().describe('Name of the tool to execute'),
132
- args: z.record(z.string(), z.unknown()).describe('Arguments to pass to the tool'),
133
- }),
134
- execute: async ({ toolName, args }) => {
135
- try {
136
- if ((toolName === 'webSearch' || toolName === 'webScrape') &&
137
- !isWebSearchEnabled()) {
138
- return {
139
- error: 'Web search is disabled',
140
- toolName,
141
- message: 'Firecrawl is turned off for this request.',
142
- };
143
- }
144
- if (checkToolPolicy) {
145
- const policy = checkToolPolicy(toolName);
146
- if (policy.allowed === false) {
147
- return {
148
- error: policy.error,
149
- toolName,
150
- reason: policy.reason,
151
- };
152
- }
153
- }
154
- const toolMetadata = registry.get(toolName);
155
- if (!toolMetadata) {
156
- return {
157
- error: 'Tool not found',
158
- toolName,
159
- availableTools: registry.getToolNames(),
160
- };
161
- }
162
- if (isToolkitAvailable) {
163
- const availability = isToolkitAvailable(toolMetadata.toolkitId);
164
- if (!availability.available) {
165
- return {
166
- error: 'toolkit_unconfigured',
167
- toolName,
168
- toolkitId: toolMetadata.toolkitId,
169
- message: availability.reason ?? 'This toolkit is not configured on the server.',
170
- };
171
- }
172
- }
173
- const toolInstance = toolMetadata.tool;
174
- const toolSchema = getToolInputZodSchema(toolMetadata.tool);
175
- let authToken;
176
- if (toolMetadata.requiredAuth) {
177
- const token = await credentials.getToken(toolMetadata.requiredAuth);
178
- if (!token) {
179
- return {
180
- error: 'Tool requires connection',
181
- toolName,
182
- requiredAuth: toolMetadata.requiredAuth,
183
- message: 'This tool requires a connected account. Use initiateConnection(provider) to get a link.',
184
- };
185
- }
186
- authToken = token;
187
- }
188
- const injectAuth = (payload) => {
189
- if (authToken != null && toolMetadata.requiredAuth) {
190
- return { ...payload, [toolMetadata.requiredAuth]: authToken };
191
- }
192
- return payload;
193
- };
194
- if (toolSchema) {
195
- try {
196
- const coercedArgs = coerceArguments(args, toolSchema);
197
- const parsedArgs = toolSchema.parse(coercedArgs);
198
- const argsWithToken = injectAuth(parsedArgs);
199
- const result = await toolInstance.execute(argsWithToken);
200
- return sanitizeToolPayload({
201
- toolName,
202
- toolkitId: toolMetadata.toolkitId,
203
- success: true,
204
- result: sanitizeToolResult(result),
205
- });
206
- }
207
- catch (validationError) {
208
- const shape = resolveZodObjectShape(toolSchema) ?? {};
209
- const paramDetails = {};
210
- for (const [paramName, paramSchema] of Object.entries(shape)) {
211
- paramDetails[paramName] = extractParameterInfo(paramSchema);
212
- }
213
- return {
214
- error: 'Invalid arguments for tool',
215
- toolName,
216
- message: validationError instanceof Error
217
- ? validationError.message
218
- : 'Schema validation failed',
219
- expectedParameters: paramDetails,
220
- providedParameters: Object.keys(args),
221
- providedValues: args,
222
- };
223
- }
224
- }
225
- const argsWithToken = injectAuth(args);
226
- const result = await toolInstance.execute(argsWithToken);
227
- return sanitizeToolPayload({
228
- toolName,
229
- toolkitId: toolMetadata.toolkitId,
230
- success: true,
231
- result: sanitizeToolResult(result),
232
- });
233
- }
234
- catch (error) {
235
- return {
236
- error: 'Failed to execute tool',
237
- toolName,
238
- message: error instanceof Error ? error.message : 'Unknown error',
239
- };
240
- }
241
- },
242
- });
243
- return {
244
- searchTool,
245
- checkAuthentication,
246
- initiateConnection,
247
- executeTool,
248
- };
249
- }
250
- //# sourceMappingURL=meta-tools.js.map
@@ -1,20 +0,0 @@
1
- export interface ToolRegistryEntry {
2
- name: string;
3
- description: string;
4
- tool: unknown;
5
- requiredAuth?: string;
6
- scope?: 'read' | 'write' | 'delete';
7
- toolkitId: string;
8
- }
9
- export interface ToolRegistry {
10
- register: (name: string, description: string, tool: unknown, options?: {
11
- requiredAuth?: string;
12
- scope?: 'read' | 'write' | 'delete';
13
- toolkitId?: string;
14
- }) => void;
15
- get: (name: string) => ToolRegistryEntry | undefined;
16
- getToolNames: () => string[];
17
- search: (pattern: string, searchIn?: 'names' | 'descriptions' | 'both') => ToolRegistryEntry[];
18
- }
19
- export declare function createToolRegistry(): ToolRegistry;
20
- //# sourceMappingURL=registry.d.ts.map
@@ -1,35 +0,0 @@
1
- export function createToolRegistry() {
2
- const tools = new Map();
3
- return {
4
- register(name, description, tool, options) {
5
- if (tools.has(name)) {
6
- throw new Error(`Duplicate tool registration: "${name}"`);
7
- }
8
- tools.set(name, {
9
- name,
10
- description,
11
- tool,
12
- requiredAuth: options?.requiredAuth,
13
- scope: options?.scope ?? 'read',
14
- toolkitId: options?.toolkitId ?? 'unknown',
15
- });
16
- },
17
- get(name) {
18
- return tools.get(name);
19
- },
20
- getToolNames() {
21
- return Array.from(tools.keys());
22
- },
23
- search(pattern, searchIn = 'both') {
24
- const regex = new RegExp(pattern, 'i');
25
- return Array.from(tools.values()).filter((entry) => {
26
- if (searchIn === 'names')
27
- return regex.test(entry.name);
28
- if (searchIn === 'descriptions')
29
- return regex.test(entry.description);
30
- return regex.test(entry.name) || regex.test(entry.description);
31
- });
32
- },
33
- };
34
- }
35
- //# sourceMappingURL=registry.js.map
@@ -1,20 +0,0 @@
1
- export declare const TOOL_OUTPUT_JSON_SCHEMA: Record<string, unknown>;
2
- export declare function getToolInputZodSchema(tool: any): any | null;
3
- export declare function resolveZodObjectShape(schema: {
4
- shape?: Record<string, unknown>;
5
- _def?: {
6
- shape?: Record<string, unknown> | (() => Record<string, unknown>);
7
- };
8
- } | null | undefined): Record<string, unknown> | null;
9
- export declare function toolInputToJsonSchema(tool: any, requiredAuth?: string): Record<string, unknown>;
10
- export interface ParameterInfo {
11
- type: string;
12
- required: boolean;
13
- description?: string;
14
- itemType?: string;
15
- options?: string[];
16
- values?: string[];
17
- }
18
- export declare function extractParameterInfo(zodType: any): ParameterInfo | Record<string, unknown>;
19
- export declare function coerceArguments(args: Record<string, unknown>, schema: any): Record<string, unknown>;
20
- //# sourceMappingURL=schema-helpers.d.ts.map
@@ -1,157 +0,0 @@
1
- import { zodToJsonSchema } from 'zod-to-json-schema';
2
- export const TOOL_OUTPUT_JSON_SCHEMA = {
3
- type: 'object',
4
- description: 'JSON object returned by the tool. May include result data or an error field.',
5
- additionalProperties: true,
6
- };
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- export function getToolInputZodSchema(tool) {
9
- if (!tool || typeof tool !== 'object')
10
- return null;
11
- return tool.inputSchema ?? tool._def?.parameters ?? null;
12
- }
13
- export function resolveZodObjectShape(schema) {
14
- if (!schema)
15
- return null;
16
- if (schema.shape)
17
- return schema.shape;
18
- const defShape = schema._def?.shape;
19
- if (typeof defShape === 'function')
20
- return defShape();
21
- if (defShape && typeof defShape === 'object')
22
- return defShape;
23
- return null;
24
- }
25
- function flattenJsonSchema(schema) {
26
- if (schema.$ref && typeof schema.$ref === 'string' && schema.definitions) {
27
- const refName = schema.$ref.replace('#/definitions/', '');
28
- const definitions = schema.definitions;
29
- const resolved = definitions[refName];
30
- if (resolved) {
31
- return {
32
- ...resolved,
33
- ...(schema.$schema ? { $schema: schema.$schema } : {}),
34
- };
35
- }
36
- }
37
- return schema;
38
- }
39
- function stripAuthFromJsonSchema(schema, requiredAuth) {
40
- const properties = schema.properties;
41
- if (!properties)
42
- return schema;
43
- const filtered = { ...properties };
44
- for (const key of Object.keys(filtered)) {
45
- if (key === requiredAuth || key.endsWith('Token')) {
46
- delete filtered[key];
47
- }
48
- }
49
- const required = Array.isArray(schema.required)
50
- ? schema.required.filter((key) => key !== requiredAuth && !key.endsWith('Token'))
51
- : undefined;
52
- return {
53
- ...schema,
54
- properties: filtered,
55
- ...(required && required.length > 0 ? { required } : {}),
56
- };
57
- }
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- export function toolInputToJsonSchema(tool, requiredAuth) {
60
- const zodSchema = getToolInputZodSchema(tool);
61
- if (!zodSchema) {
62
- return { type: 'object', properties: {} };
63
- }
64
- const jsonSchema = zodToJsonSchema(zodSchema, {
65
- $refStrategy: 'none',
66
- });
67
- return stripAuthFromJsonSchema(flattenJsonSchema(jsonSchema), requiredAuth);
68
- }
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- export function extractParameterInfo(zodType) {
71
- const typeName = zodType._def?.typeName;
72
- const info = {
73
- type: typeName?.replace('Zod', '').toLowerCase() || 'unknown',
74
- required: !(zodType?.isOptional?.() ?? false),
75
- description: zodType.description || undefined,
76
- };
77
- switch (typeName) {
78
- case 'ZodNumber':
79
- info.type = 'number';
80
- break;
81
- case 'ZodString':
82
- info.type = 'string';
83
- break;
84
- case 'ZodBoolean':
85
- info.type = 'boolean';
86
- break;
87
- case 'ZodArray':
88
- info.type = 'array';
89
- info.itemType = extractParameterInfo(zodType._def.type).type;
90
- break;
91
- case 'ZodObject':
92
- info.type = 'object';
93
- break;
94
- case 'ZodUnion':
95
- info.type = 'union';
96
- info.options =
97
- zodType._def.options?.map(
98
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
- (opt) => extractParameterInfo(opt).type) || [];
100
- break;
101
- case 'ZodEnum':
102
- info.type = 'enum';
103
- info.values = zodType._def.values || [];
104
- break;
105
- case 'ZodOptional': {
106
- const innerInfo = extractParameterInfo(zodType._def.innerType);
107
- return { ...innerInfo, required: false };
108
- }
109
- default:
110
- info.type = typeName?.replace('Zod', '').toLowerCase() || 'any';
111
- }
112
- return info;
113
- }
114
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
- export function coerceArguments(args, schema) {
116
- const shape = resolveZodObjectShape(schema);
117
- if (!shape)
118
- return args;
119
- const coercedArgs = {};
120
- for (const [key, value] of Object.entries(args)) {
121
- const fieldSchema = shape[key];
122
- if (!fieldSchema) {
123
- coercedArgs[key] = value;
124
- continue;
125
- }
126
- let typeName = fieldSchema._def?.typeName;
127
- let actualSchema = fieldSchema;
128
- if (typeName === 'ZodOptional') {
129
- actualSchema = fieldSchema._def?.innerType;
130
- typeName = actualSchema?._def?.typeName;
131
- }
132
- try {
133
- switch (typeName) {
134
- case 'ZodNumber':
135
- coercedArgs[key] = typeof value === 'string' ? parseFloat(value) : Number(value);
136
- break;
137
- case 'ZodString':
138
- coercedArgs[key] = String(value);
139
- break;
140
- case 'ZodBoolean':
141
- coercedArgs[key] =
142
- typeof value === 'string' ? value.toLowerCase() === 'true' : Boolean(value);
143
- break;
144
- case 'ZodArray':
145
- coercedArgs[key] = Array.isArray(value) ? value : [value];
146
- break;
147
- default:
148
- coercedArgs[key] = value;
149
- }
150
- }
151
- catch {
152
- coercedArgs[key] = value;
153
- }
154
- }
155
- return coercedArgs;
156
- }
157
- //# sourceMappingURL=schema-helpers.js.map