@rnsk/toolkits 0.0.2 → 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.
- package/README.md +104 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/toolkits/github/tools/Actions/get-workflow-job.d.ts +3 -3
- package/dist/toolkits/github/tools/Actions/list-artifacts.d.ts +1 -1
- package/dist/toolkits/github/tools/Actions/list-workflow-jobs.d.ts +4 -4
- package/dist/toolkits/github/tools/Actions/list-workflow-run-artifacts.d.ts +1 -1
- package/dist/toolkits/github/tools/Activity/list-notifications.d.ts +2 -2
- package/dist/toolkits/github/tools/Activity/list-public-events.d.ts +1 -1
- package/dist/toolkits/github/tools/Activity/list-repo-events.d.ts +1 -1
- package/dist/toolkits/github/tools/Activity/list-user-events.d.ts +1 -1
- package/dist/toolkits/github/tools/Apps/list-installations.d.ts +1 -1
- package/dist/toolkits/github/tools/Checks/create-check-run.d.ts +5 -5
- package/dist/toolkits/github/tools/Checks/create-check-suite.d.ts +2 -2
- package/dist/toolkits/github/tools/Checks/get-check-run.d.ts +2 -2
- package/dist/toolkits/github/tools/Checks/get-check-suite.d.ts +2 -2
- package/dist/toolkits/github/tools/Checks/list-check-runs.d.ts +4 -4
- package/dist/toolkits/github/tools/Checks/update-check-run.d.ts +4 -4
- package/dist/toolkits/github/tools/CodeScanning/list-alerts.d.ts +2 -2
- package/dist/toolkits/github/tools/CodeScanning/update-alert.d.ts +1 -1
- package/dist/toolkits/github/tools/Collaborators/add-collaborator.d.ts +1 -1
- package/dist/toolkits/github/tools/Collaborators/check-collaborator.d.ts +1 -1
- package/dist/toolkits/github/tools/Collaborators/list-collaborators.d.ts +1 -1
- package/dist/toolkits/github/tools/Collaborators/remove-collaborator.d.ts +1 -1
- package/dist/toolkits/github/tools/Commits/compare-commits.d.ts +2 -2
- package/dist/toolkits/github/tools/Commits/get-commit.d.ts +2 -2
- package/dist/toolkits/github/tools/Commits/list-commits.d.ts +1 -1
- package/dist/toolkits/github/tools/Commits/list-pull-requests-associated-with-commit.d.ts +2 -2
- package/dist/toolkits/github/tools/Dependabot/list-alerts.d.ts +1 -1
- package/dist/toolkits/github/tools/Dependabot/update-alert.d.ts +1 -1
- package/dist/toolkits/github/tools/DeployKeys/list-deploy-keys.d.ts +1 -1
- package/dist/toolkits/github/tools/Deployments/create-deployment.d.ts +1 -1
- package/dist/toolkits/github/tools/Deployments/list-deployments.d.ts +1 -1
- package/dist/toolkits/github/tools/Environments/list-environments.d.ts +1 -1
- package/dist/toolkits/github/tools/Files/create-or-update-file.d.ts +1 -1
- package/dist/toolkits/github/tools/Gists/create-gist.d.ts +1 -1
- package/dist/toolkits/github/tools/Git/create-blob.d.ts +1 -1
- package/dist/toolkits/github/tools/Git/create-tree.d.ts +1 -1
- package/dist/toolkits/github/tools/Issues/add-issue-assignees.d.ts +1 -1
- package/dist/toolkits/github/tools/Issues/add-issue-labels.d.ts +1 -1
- package/dist/toolkits/github/tools/Issues/list-authenticated-user-issues.d.ts +4 -4
- package/dist/toolkits/github/tools/Issues/list-issue-comments.d.ts +1 -1
- package/dist/toolkits/github/tools/Issues/list-org-issues.d.ts +4 -4
- package/dist/toolkits/github/tools/Issues/list-repo-issues.d.ts +2 -2
- package/dist/toolkits/github/tools/Issues/list-user-account-issues.d.ts +4 -4
- package/dist/toolkits/github/tools/Organizations/get-org-membership.d.ts +1 -1
- package/dist/toolkits/github/tools/Organizations/list-org-members.d.ts +1 -1
- package/dist/toolkits/github/tools/Organizations/list-org-repositories.d.ts +2 -2
- package/dist/toolkits/github/tools/Organizations/list-user-organizations.d.ts +1 -1
- package/dist/toolkits/github/tools/Organizations/update-organization.d.ts +1 -1
- package/dist/toolkits/github/tools/PRs/create-pull-request-review.d.ts +1 -1
- package/dist/toolkits/github/tools/PRs/list-pull-request-files.d.ts +1 -1
- package/dist/toolkits/github/tools/PRs/list-pull-requests.d.ts +1 -1
- package/dist/toolkits/github/tools/Projects/list-org-projects.d.ts +1 -1
- package/dist/toolkits/github/tools/Projects/list-project-columns.d.ts +1 -1
- package/dist/toolkits/github/tools/Projects/list-repo-projects.d.ts +1 -1
- package/dist/toolkits/github/tools/Projects/update-project.d.ts +1 -1
- package/dist/toolkits/github/tools/Reactions/create-commit-comment-reaction.d.ts +1 -1
- package/dist/toolkits/github/tools/Reactions/create-issue-reaction.d.ts +1 -1
- package/dist/toolkits/github/tools/Reactions/list-commit-comment-reactions.d.ts +1 -1
- package/dist/toolkits/github/tools/Reactions/list-issue-reactions.d.ts +1 -1
- package/dist/toolkits/github/tools/Reactions/list-pr-comment-reactions.d.ts +1 -1
- package/dist/toolkits/github/tools/Releases/list-releases.d.ts +1 -1
- package/dist/toolkits/github/tools/Repos/get-repo-contributors.d.ts +1 -1
- package/dist/toolkits/github/tools/Repos/list-branches.d.ts +1 -1
- package/dist/toolkits/github/tools/Repos/list-repos.d.ts +2 -2
- package/dist/toolkits/github/tools/Repos/watch-repo.d.ts +1 -1
- package/dist/toolkits/github/tools/Search/search-repos.d.ts +1 -1
- package/dist/toolkits/github/tools/SecretScanning/list-alerts.d.ts +1 -1
- package/dist/toolkits/github/tools/SecretScanning/update-alert.d.ts +1 -1
- package/dist/toolkits/github/tools/SecurityAdvisories/create-repository-advisory.d.ts +1 -1
- package/dist/toolkits/github/tools/SecurityAdvisories/get-repository-advisory.d.ts +1 -1
- package/dist/toolkits/github/tools/SecurityAdvisories/list-global-advisories.d.ts +1 -1
- package/dist/toolkits/github/tools/SecurityAdvisories/list-repository-advisories.d.ts +2 -2
- package/dist/toolkits/github/tools/Stars/list-stargazers.d.ts +1 -1
- package/dist/toolkits/github/tools/Stars/list-starred-repos.d.ts +1 -1
- package/dist/toolkits/github/tools/Statuses/create-commit-status.d.ts +1 -1
- package/dist/toolkits/github/tools/Statuses/list-commit-statuses.d.ts +1 -1
- package/dist/toolkits/github/tools/Teams/list-team-members.d.ts +1 -1
- package/dist/toolkits/github/tools/Teams/list-team-repos.d.ts +1 -1
- package/dist/toolkits/github/tools/Teams/list-teams.d.ts +1 -1
- package/dist/toolkits/github/tools/Users/get-user-context.d.ts +1 -1
- package/dist/toolkits/github/tools/Users/update-authenticated-user.d.ts +1 -1
- package/dist/toolkits/github/tools/Webhooks/create-repo-webhook.d.ts +1 -1
- package/dist/toolkits/github/tools/Webhooks/list-repo-webhooks.d.ts +1 -1
- package/dist/toolkits/github/tools/Webhooks/update-repo-webhook.d.ts +1 -1
- package/dist/toolkits/github/tools/Workflows/list-workflow-runs.d.ts +2 -2
- package/dist/toolkits/github/tools/Workflows/list-workflows.d.ts +1 -1
- package/dist/toolkits/github/tools/index.d.ts +4859 -175
- package/dist/toolkits/github/tools/index.js +342 -342
- package/dist/toolkits/gmail/icon.js +14 -14
- package/dist/toolkits/gmail/manifest.js +78 -5
- package/dist/toolkits/gmail/tools/create-draft.d.ts +34 -0
- package/dist/toolkits/gmail/tools/create-draft.js +60 -0
- package/dist/toolkits/gmail/tools/delete-draft.d.ts +23 -0
- package/dist/toolkits/gmail/tools/delete-draft.js +34 -0
- package/dist/toolkits/gmail/tools/get-draft.d.ts +32 -0
- package/dist/toolkits/gmail/tools/get-draft.js +36 -0
- package/dist/toolkits/gmail/tools/get-message.d.ts +12 -12
- package/dist/toolkits/gmail/tools/get-message.js +3 -24
- package/dist/toolkits/gmail/tools/get-thread.d.ts +29 -0
- package/dist/toolkits/gmail/tools/get-thread.js +39 -0
- package/dist/toolkits/gmail/tools/index.d.ts +17 -0
- package/dist/toolkits/gmail/tools/index.js +17 -0
- package/dist/toolkits/gmail/tools/list-drafts.d.ts +28 -0
- package/dist/toolkits/gmail/tools/list-drafts.js +43 -0
- package/dist/toolkits/gmail/tools/list-labels.d.ts +20 -0
- package/dist/toolkits/gmail/tools/list-labels.js +46 -0
- package/dist/toolkits/gmail/tools/list-threads.d.ts +28 -0
- package/dist/toolkits/gmail/tools/list-threads.js +43 -0
- package/dist/toolkits/gmail/tools/modify-message-labels.d.ts +31 -0
- package/dist/toolkits/gmail/tools/modify-message-labels.js +44 -0
- package/dist/toolkits/gmail/tools/reply-to-thread.d.ts +33 -0
- package/dist/toolkits/gmail/tools/reply-to-thread.js +58 -0
- package/dist/toolkits/gmail/tools/send-draft.d.ts +29 -0
- package/dist/toolkits/gmail/tools/send-draft.js +41 -0
- package/dist/toolkits/gmail/tools/send-message.d.ts +4 -1
- package/dist/toolkits/gmail/tools/send-message.js +18 -16
- package/dist/toolkits/gmail/tools/trash-message.d.ts +29 -0
- package/dist/toolkits/gmail/tools/trash-message.js +37 -0
- package/dist/toolkits/gmail/tools/untrash-message.d.ts +29 -0
- package/dist/toolkits/gmail/tools/untrash-message.js +37 -0
- package/dist/toolkits/gmail/tools/utils.d.ts +41 -0
- package/dist/toolkits/gmail/tools/utils.js +97 -0
- package/dist/toolkits/google-calendar/manifest.js +1 -1
- package/dist/toolkits/google-calendar/tools/delete-event.d.ts +27 -0
- package/dist/toolkits/google-calendar/tools/delete-event.js +38 -0
- package/dist/toolkits/google-calendar/tools/get-event.d.ts +24 -0
- package/dist/toolkits/google-calendar/tools/get-event.js +37 -0
- package/dist/toolkits/google-calendar/tools/index.d.ts +181 -3
- package/dist/toolkits/google-calendar/tools/index.js +31 -2
- package/dist/toolkits/google-calendar/tools/search-events.d.ts +27 -0
- package/dist/toolkits/google-calendar/tools/search-events.js +49 -0
- package/dist/toolkits/google-calendar/tools/update-event.d.ts +29 -0
- package/dist/toolkits/google-calendar/tools/update-event.js +56 -0
- package/dist/toolkits/google-sheets/manifest.js +2 -2
- package/dist/toolkits/google-sheets/tools/append-values.d.ts +41 -0
- package/dist/toolkits/google-sheets/tools/append-values.js +51 -0
- package/dist/toolkits/google-sheets/tools/clear-values.d.ts +27 -0
- package/dist/toolkits/google-sheets/tools/clear-values.js +41 -0
- package/dist/toolkits/google-sheets/tools/create-spreadsheet.d.ts +33 -0
- package/dist/toolkits/google-sheets/tools/create-spreadsheet.js +59 -0
- package/dist/toolkits/google-sheets/tools/index.d.ts +205 -7
- package/dist/toolkits/google-sheets/tools/index.js +39 -4
- package/dist/toolkits/google-sheets/tools/update-values.d.ts +38 -0
- package/dist/toolkits/google-sheets/tools/update-values.js +50 -0
- package/dist/toolkits/linear/manifest.js +35 -0
- package/dist/toolkits/linear/tools/add-comment.d.ts +6 -0
- package/dist/toolkits/linear/tools/add-comment.js +52 -0
- package/dist/toolkits/linear/tools/get-issue.d.ts +6 -0
- package/dist/toolkits/linear/tools/get-issue.js +117 -0
- package/dist/toolkits/linear/tools/list-projects.d.ts +4 -0
- package/dist/toolkits/linear/tools/list-projects.js +46 -0
- package/dist/toolkits/linear/tools/list-workflow-states.d.ts +26 -0
- package/dist/toolkits/linear/tools/list-workflow-states.js +59 -0
- package/dist/toolkits/linear/tools/update-issue.d.ts +11 -0
- package/dist/toolkits/linear/tools/update-issue.js +78 -0
- package/dist/toolkits/notion/tools/append-block-children.d.ts +1 -1
- package/dist/toolkits/notion/tools/index.d.ts +105 -12
- package/dist/toolkits/notion/tools/index.js +8 -8
- package/dist/toolkits/notion/tools/query-database.d.ts +1 -1
- package/package.json +5 -7
- package/dist/runtime/credentials.d.ts +0 -28
- package/dist/runtime/credentials.js +0 -15
- package/dist/runtime/index.d.ts +0 -5
- package/dist/runtime/index.js +0 -5
- package/dist/runtime/meta-tools.d.ts +0 -101
- package/dist/runtime/meta-tools.js +0 -250
- package/dist/runtime/registry.d.ts +0 -20
- package/dist/runtime/registry.js +0 -35
- /package/dist/{runtime → core}/schema-helpers.d.ts +0 -0
- /package/dist/{runtime → core}/schema-helpers.js +0 -0
|
@@ -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
|
package/dist/runtime/registry.js
DELETED
|
@@ -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
|
|
File without changes
|
|
File without changes
|