@rnsk/toolkits 0.0.3 → 0.0.5
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 +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -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 +3 -3
- package/dist/toolkits/github/tools/Actions/list-workflow-run-artifacts.d.ts +1 -1
- package/dist/toolkits/github/tools/Activity/list-notifications.d.ts +1 -1
- 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/list-authenticated-user-issues.d.ts +3 -3
- package/dist/toolkits/github/tools/Issues/list-issue-comments.d.ts +1 -1
- package/dist/toolkits/github/tools/Issues/list-org-issues.d.ts +3 -3
- 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 +3 -3
- 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/manifest.js +1 -1
- package/dist/toolkits/gmail/tools/create-draft.d.ts +1 -1
- package/dist/toolkits/gmail/tools/reply-to-thread.d.ts +1 -1
- package/dist/toolkits/gmail/tools/send-message.d.ts +1 -1
- package/dist/toolkits/google-calendar/manifest.js +1 -6
- package/dist/toolkits/google-docs/icon.d.ts +5 -0
- package/dist/toolkits/google-docs/icon.js +6 -0
- package/dist/toolkits/google-docs/manifest.d.ts +3 -0
- package/dist/toolkits/google-docs/manifest.js +40 -0
- package/dist/toolkits/google-docs/tools/append-text.d.ts +30 -0
- package/dist/toolkits/google-docs/tools/append-text.js +48 -0
- package/dist/toolkits/google-docs/tools/copy-document.d.ts +27 -0
- package/dist/toolkits/google-docs/tools/copy-document.js +43 -0
- package/dist/toolkits/google-docs/tools/create-document.d.ts +26 -0
- package/dist/toolkits/google-docs/tools/create-document.js +39 -0
- package/dist/toolkits/google-docs/tools/delete-content.d.ts +28 -0
- package/dist/toolkits/google-docs/tools/delete-content.js +45 -0
- package/dist/toolkits/google-docs/tools/delete-document.d.ts +23 -0
- package/dist/toolkits/google-docs/tools/delete-document.js +30 -0
- package/dist/toolkits/google-docs/tools/get-document-text.d.ts +26 -0
- package/dist/toolkits/google-docs/tools/get-document-text.js +35 -0
- package/dist/toolkits/google-docs/tools/get-document.d.ts +5 -0
- package/dist/toolkits/google-docs/tools/get-document.js +29 -0
- package/dist/toolkits/google-docs/tools/index.d.ts +299 -0
- package/dist/toolkits/google-docs/tools/index.js +85 -0
- package/dist/toolkits/google-docs/tools/insert-text.d.ts +28 -0
- package/dist/toolkits/google-docs/tools/insert-text.js +39 -0
- package/dist/toolkits/google-docs/tools/list-documents.d.ts +21 -0
- package/dist/toolkits/google-docs/tools/list-documents.js +39 -0
- package/dist/toolkits/google-docs/tools/replace-text.d.ts +32 -0
- package/dist/toolkits/google-docs/tools/replace-text.js +48 -0
- package/dist/toolkits/google-docs/tools/utils.d.ts +12 -0
- package/dist/toolkits/google-docs/tools/utils.js +48 -0
- package/dist/toolkits/google-drive/icon.d.ts +5 -0
- package/dist/toolkits/google-drive/icon.js +6 -0
- package/dist/toolkits/google-drive/manifest.d.ts +3 -0
- package/dist/toolkits/google-drive/manifest.js +37 -0
- package/dist/toolkits/google-drive/tools/copy-file.d.ts +7 -0
- package/dist/toolkits/google-drive/tools/copy-file.js +41 -0
- package/dist/toolkits/google-drive/tools/create-folder.d.ts +6 -0
- package/dist/toolkits/google-drive/tools/create-folder.js +42 -0
- package/dist/toolkits/google-drive/tools/delete-file.d.ts +23 -0
- package/dist/toolkits/google-drive/tools/delete-file.js +30 -0
- package/dist/toolkits/google-drive/tools/download-file.d.ts +30 -0
- package/dist/toolkits/google-drive/tools/download-file.js +61 -0
- package/dist/toolkits/google-drive/tools/get-file.d.ts +5 -0
- package/dist/toolkits/google-drive/tools/get-file.js +31 -0
- package/dist/toolkits/google-drive/tools/index.d.ts +188 -0
- package/dist/toolkits/google-drive/tools/index.js +85 -0
- package/dist/toolkits/google-drive/tools/list-files.d.ts +21 -0
- package/dist/toolkits/google-drive/tools/list-files.js +42 -0
- package/dist/toolkits/google-drive/tools/move-file.d.ts +7 -0
- package/dist/toolkits/google-drive/tools/move-file.js +51 -0
- package/dist/toolkits/google-drive/tools/search-files.d.ts +21 -0
- package/dist/toolkits/google-drive/tools/search-files.js +36 -0
- package/dist/toolkits/google-drive/tools/update-file.d.ts +7 -0
- package/dist/toolkits/google-drive/tools/update-file.js +44 -0
- package/dist/toolkits/google-drive/tools/upload-file.d.ts +8 -0
- package/dist/toolkits/google-drive/tools/upload-file.js +58 -0
- package/dist/toolkits/google-sheets/manifest.js +1 -6
- 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 +20 -4
- 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/schema-helpers.d.ts +0 -20
- package/dist/runtime/schema-helpers.js +0 -157
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const moveFile = tool({
|
|
5
|
+
description: 'Move a file or folder to a different parent folder in Google Drive.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
fileId: z.string().describe('The ID of the file or folder to move'),
|
|
9
|
+
newParentId: z.string().describe('The ID of the destination folder'),
|
|
10
|
+
removeParentId: z.string().optional().describe('Parent folder ID to remove (auto-detected if omitted)'),
|
|
11
|
+
}),
|
|
12
|
+
execute: async ({ googleDriveToken, fileId, newParentId, removeParentId }) => {
|
|
13
|
+
try {
|
|
14
|
+
let removeParents = removeParentId;
|
|
15
|
+
if (!removeParents) {
|
|
16
|
+
const metaUrl = `https://www.googleapis.com/drive/v3/files/${fileId}?fields=parents`;
|
|
17
|
+
const metaResponse = await fetch(metaUrl, {
|
|
18
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
19
|
+
});
|
|
20
|
+
if (!metaResponse.ok) {
|
|
21
|
+
const error = await metaResponse.json();
|
|
22
|
+
return { error: 'Failed to get file parents', details: error };
|
|
23
|
+
}
|
|
24
|
+
const meta = await metaResponse.json();
|
|
25
|
+
removeParents = meta.parents?.[0];
|
|
26
|
+
}
|
|
27
|
+
const url = new URL(`https://www.googleapis.com/drive/v3/files/${fileId}`);
|
|
28
|
+
url.searchParams.set('addParents', newParentId);
|
|
29
|
+
if (removeParents) {
|
|
30
|
+
url.searchParams.set('removeParents', removeParents);
|
|
31
|
+
}
|
|
32
|
+
url.searchParams.set('fields', 'id,name,parents');
|
|
33
|
+
const response = await fetch(url.toString(), {
|
|
34
|
+
method: 'PATCH',
|
|
35
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
const error = await response.json();
|
|
39
|
+
return { error: 'Failed to move file', details: error };
|
|
40
|
+
}
|
|
41
|
+
return await response.json();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
error: 'Error moving file',
|
|
46
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=move-file.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const searchFiles: import("ai").Tool<{
|
|
2
|
+
q: string;
|
|
3
|
+
pageSize: number;
|
|
4
|
+
googleDriveToken: string;
|
|
5
|
+
}, {
|
|
6
|
+
error: string;
|
|
7
|
+
details: any;
|
|
8
|
+
files?: undefined;
|
|
9
|
+
message?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
files: any;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
details?: undefined;
|
|
14
|
+
message?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
error: string;
|
|
17
|
+
message: string;
|
|
18
|
+
details?: undefined;
|
|
19
|
+
files?: undefined;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=search-files.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const searchFiles = tool({
|
|
5
|
+
description: 'Search for files and folders in Google Drive using a Drive query.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
q: z.string().describe('Drive search query (e.g. "name contains \'report\'" or "mimeType=\'application/pdf\'")'),
|
|
9
|
+
pageSize: z.number().optional().default(20).describe('Maximum number of results to return'),
|
|
10
|
+
}),
|
|
11
|
+
execute: async ({ googleDriveToken, q, pageSize = 20 }) => {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL('https://www.googleapis.com/drive/v3/files');
|
|
14
|
+
const query = `trashed = false and (${q})`;
|
|
15
|
+
url.searchParams.set('q', query);
|
|
16
|
+
url.searchParams.set('pageSize', String(pageSize));
|
|
17
|
+
url.searchParams.set('fields', 'files(id,name,mimeType,modifiedTime,parents,webViewLink)');
|
|
18
|
+
const response = await fetch(url.toString(), {
|
|
19
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
const error = await response.json();
|
|
23
|
+
return { error: 'Failed to search files', details: error };
|
|
24
|
+
}
|
|
25
|
+
const data = await response.json();
|
|
26
|
+
return { files: data.files ?? [] };
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return {
|
|
30
|
+
error: 'Error searching files',
|
|
31
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=search-files.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const updateFile = tool({
|
|
5
|
+
description: 'Update file metadata in Google Drive (rename, description).',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
fileId: z.string().describe('The ID of the file to update'),
|
|
9
|
+
name: z.string().optional().describe('New file name'),
|
|
10
|
+
description: z.string().optional().describe('New file description'),
|
|
11
|
+
}),
|
|
12
|
+
execute: async ({ googleDriveToken, fileId, name, description }) => {
|
|
13
|
+
try {
|
|
14
|
+
const metadata = {};
|
|
15
|
+
if (name !== undefined)
|
|
16
|
+
metadata.name = name;
|
|
17
|
+
if (description !== undefined)
|
|
18
|
+
metadata.description = description;
|
|
19
|
+
if (Object.keys(metadata).length === 0) {
|
|
20
|
+
return { error: 'At least one of name or description must be provided' };
|
|
21
|
+
}
|
|
22
|
+
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${fileId}`, {
|
|
23
|
+
method: 'PATCH',
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${googleDriveToken}`,
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify(metadata),
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
const error = await response.json();
|
|
32
|
+
return { error: 'Failed to update file', details: error };
|
|
33
|
+
}
|
|
34
|
+
return await response.json();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
error: 'Error updating file',
|
|
39
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=update-file.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const uploadFile = tool({
|
|
5
|
+
description: 'Upload a file to Google Drive using multipart upload.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
name: z.string().describe('File name'),
|
|
9
|
+
mimeType: z.string().describe('MIME type of the file (e.g. text/plain, application/pdf)'),
|
|
10
|
+
content: z.string().describe('Base64-encoded file content'),
|
|
11
|
+
parentId: z.string().optional().describe('Parent folder ID (defaults to root)'),
|
|
12
|
+
}),
|
|
13
|
+
execute: async ({ googleDriveToken, name, mimeType, content, parentId }) => {
|
|
14
|
+
try {
|
|
15
|
+
const metadata = { name };
|
|
16
|
+
if (parentId) {
|
|
17
|
+
metadata.parents = [parentId];
|
|
18
|
+
}
|
|
19
|
+
const boundary = '-------rnsk_drive_upload';
|
|
20
|
+
const metadataPart = JSON.stringify(metadata);
|
|
21
|
+
const contentBuffer = Buffer.from(content, 'base64');
|
|
22
|
+
const body = [
|
|
23
|
+
`--${boundary}`,
|
|
24
|
+
'Content-Type: application/json; charset=UTF-8',
|
|
25
|
+
'',
|
|
26
|
+
metadataPart,
|
|
27
|
+
`--${boundary}`,
|
|
28
|
+
`Content-Type: ${mimeType}`,
|
|
29
|
+
'',
|
|
30
|
+
].join('\r\n');
|
|
31
|
+
const bodyBuffer = Buffer.concat([
|
|
32
|
+
Buffer.from(body, 'utf-8'),
|
|
33
|
+
contentBuffer,
|
|
34
|
+
Buffer.from(`\r\n--${boundary}--`, 'utf-8'),
|
|
35
|
+
]);
|
|
36
|
+
const response = await fetch('https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=id,name,mimeType,webViewLink', {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${googleDriveToken}`,
|
|
40
|
+
'Content-Type': `multipart/related; boundary=${boundary}`,
|
|
41
|
+
},
|
|
42
|
+
body: bodyBuffer,
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const error = await response.json();
|
|
46
|
+
return { error: 'Failed to upload file', details: error };
|
|
47
|
+
}
|
|
48
|
+
return await response.json();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
error: 'Error uploading file',
|
|
53
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=upload-file.js.map
|
|
@@ -13,12 +13,7 @@ export default defineToolkit({
|
|
|
13
13
|
tokenField: 'googleSheetsToken',
|
|
14
14
|
provider: {
|
|
15
15
|
slug: 'google-sheets',
|
|
16
|
-
env: {
|
|
17
|
-
clientId: 'GOOGLE_CLIENT_ID',
|
|
18
|
-
clientSecret: 'GOOGLE_CLIENT_SECRET',
|
|
19
|
-
clientIdFallback: 'GMAIL_CLIENT_ID',
|
|
20
|
-
clientSecretFallback: 'GMAIL_CLIENT_SECRET',
|
|
21
|
-
},
|
|
16
|
+
env: { clientId: 'GOOGLE_SHEET_CLIENT_ID', clientSecret: 'GOOGLE_SHEET_CLIENT_SECRET' },
|
|
22
17
|
authorizeUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
23
18
|
tokenUrl: 'https://oauth2.googleapis.com/token',
|
|
24
19
|
scopes: [
|
|
@@ -3,6 +3,11 @@ import { LINEAR_ICON } from './icon.js';
|
|
|
3
3
|
import { linearSearchIssues } from './tools/search-issues.js';
|
|
4
4
|
import { linearCreateIssue } from './tools/create-issue.js';
|
|
5
5
|
import { linearListTeams } from './tools/list-teams.js';
|
|
6
|
+
import { linearGetIssue } from './tools/get-issue.js';
|
|
7
|
+
import { linearUpdateIssue } from './tools/update-issue.js';
|
|
8
|
+
import { linearListProjects } from './tools/list-projects.js';
|
|
9
|
+
import { linearListWorkflowStates } from './tools/list-workflow-states.js';
|
|
10
|
+
import { linearAddComment } from './tools/add-comment.js';
|
|
6
11
|
export default defineToolkit({
|
|
7
12
|
id: 'linear',
|
|
8
13
|
displayName: 'Linear',
|
|
@@ -45,6 +50,36 @@ export default defineToolkit({
|
|
|
45
50
|
requiredAuth: 'linearToken',
|
|
46
51
|
scope: 'read',
|
|
47
52
|
}),
|
|
53
|
+
defineTool({
|
|
54
|
+
name: 'linearGetIssue',
|
|
55
|
+
tool: linearGetIssue,
|
|
56
|
+
requiredAuth: 'linearToken',
|
|
57
|
+
scope: 'read',
|
|
58
|
+
}),
|
|
59
|
+
defineTool({
|
|
60
|
+
name: 'linearUpdateIssue',
|
|
61
|
+
tool: linearUpdateIssue,
|
|
62
|
+
requiredAuth: 'linearToken',
|
|
63
|
+
scope: 'write',
|
|
64
|
+
}),
|
|
65
|
+
defineTool({
|
|
66
|
+
name: 'linearListProjects',
|
|
67
|
+
tool: linearListProjects,
|
|
68
|
+
requiredAuth: 'linearToken',
|
|
69
|
+
scope: 'read',
|
|
70
|
+
}),
|
|
71
|
+
defineTool({
|
|
72
|
+
name: 'linearListWorkflowStates',
|
|
73
|
+
tool: linearListWorkflowStates,
|
|
74
|
+
requiredAuth: 'linearToken',
|
|
75
|
+
scope: 'read',
|
|
76
|
+
}),
|
|
77
|
+
defineTool({
|
|
78
|
+
name: 'linearAddComment',
|
|
79
|
+
tool: linearAddComment,
|
|
80
|
+
requiredAuth: 'linearToken',
|
|
81
|
+
scope: 'write',
|
|
82
|
+
}),
|
|
48
83
|
],
|
|
49
84
|
meta: { since: '0.0.1' },
|
|
50
85
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const linearAddComment = tool({
|
|
4
|
+
description: 'Add a comment to a Linear issue.',
|
|
5
|
+
inputSchema: z.object({
|
|
6
|
+
issueId: z.string().describe('Linear issue UUID'),
|
|
7
|
+
body: z.string().describe('Comment body (markdown supported)'),
|
|
8
|
+
linearToken: z.string().optional().describe('Linear API token (injected by system)'),
|
|
9
|
+
}),
|
|
10
|
+
execute: async ({ issueId, body, linearToken }) => {
|
|
11
|
+
const graphqlQuery = {
|
|
12
|
+
query: `
|
|
13
|
+
mutation CreateComment($input: CommentCreateInput!) {
|
|
14
|
+
commentCreate(input: $input) {
|
|
15
|
+
success
|
|
16
|
+
comment {
|
|
17
|
+
id
|
|
18
|
+
body
|
|
19
|
+
url
|
|
20
|
+
createdAt
|
|
21
|
+
user { id name }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
variables: {
|
|
27
|
+
input: {
|
|
28
|
+
issueId,
|
|
29
|
+
body,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const response = await fetch('https://api.linear.app/graphql', {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
Authorization: `Bearer ${linearToken}`,
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(graphqlQuery),
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
const error = await response.json();
|
|
43
|
+
return { error: 'Failed to add Linear comment', details: error };
|
|
44
|
+
}
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
if (data.errors?.length) {
|
|
47
|
+
return { error: 'Linear GraphQL error', details: data.errors };
|
|
48
|
+
}
|
|
49
|
+
return data.data.commentCreate;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=add-comment.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const linearGetIssue = tool({
|
|
4
|
+
description: 'Get a single Linear issue by UUID or identifier (e.g. ENG-123). Returns title, description, status, assignee, priority, and URL.',
|
|
5
|
+
inputSchema: z.object({
|
|
6
|
+
issueId: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe('Linear issue UUID. Use linearSearchIssues if you only have a title or keyword.'),
|
|
10
|
+
identifier: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Human-readable issue identifier, e.g. ENG-123 (team key + number).'),
|
|
14
|
+
linearToken: z.string().optional().describe('Linear API token (injected by system)'),
|
|
15
|
+
}),
|
|
16
|
+
execute: async ({ issueId, identifier, linearToken }) => {
|
|
17
|
+
if (!issueId && !identifier) {
|
|
18
|
+
return { error: 'Provide either issueId (UUID) or identifier (e.g. ENG-123).' };
|
|
19
|
+
}
|
|
20
|
+
if (issueId) {
|
|
21
|
+
const graphqlQuery = {
|
|
22
|
+
query: `
|
|
23
|
+
query GetIssue($id: String!) {
|
|
24
|
+
issue(id: $id) {
|
|
25
|
+
id
|
|
26
|
+
identifier
|
|
27
|
+
title
|
|
28
|
+
description
|
|
29
|
+
priority
|
|
30
|
+
url
|
|
31
|
+
createdAt
|
|
32
|
+
updatedAt
|
|
33
|
+
state { id name type }
|
|
34
|
+
assignee { id name email }
|
|
35
|
+
team { id name key }
|
|
36
|
+
project { id name }
|
|
37
|
+
labels { nodes { id name color } }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`,
|
|
41
|
+
variables: { id: issueId },
|
|
42
|
+
};
|
|
43
|
+
const response = await fetch('https://api.linear.app/graphql', {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
Authorization: `Bearer ${linearToken}`,
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(graphqlQuery),
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
const error = await response.json();
|
|
53
|
+
return { error: 'Failed to get Linear issue', details: error };
|
|
54
|
+
}
|
|
55
|
+
const data = await response.json();
|
|
56
|
+
if (data.errors?.length) {
|
|
57
|
+
return { error: 'Linear GraphQL error', details: data.errors };
|
|
58
|
+
}
|
|
59
|
+
return data.data.issue;
|
|
60
|
+
}
|
|
61
|
+
const match = identifier.match(/^([A-Za-z]+)-(\d+)$/);
|
|
62
|
+
if (!match) {
|
|
63
|
+
return { error: 'identifier must look like TEAM-123 (team key and issue number).' };
|
|
64
|
+
}
|
|
65
|
+
const [, teamKey, numberStr] = match;
|
|
66
|
+
const number = Number(numberStr);
|
|
67
|
+
const graphqlQuery = {
|
|
68
|
+
query: `
|
|
69
|
+
query IssueByIdentifier($teamKey: String!, $number: Float!) {
|
|
70
|
+
issues(filter: {
|
|
71
|
+
team: { key: { eq: $teamKey } }
|
|
72
|
+
number: { eq: $number }
|
|
73
|
+
}, first: 1) {
|
|
74
|
+
nodes {
|
|
75
|
+
id
|
|
76
|
+
identifier
|
|
77
|
+
title
|
|
78
|
+
description
|
|
79
|
+
priority
|
|
80
|
+
url
|
|
81
|
+
createdAt
|
|
82
|
+
updatedAt
|
|
83
|
+
state { id name type }
|
|
84
|
+
assignee { id name email }
|
|
85
|
+
team { id name key }
|
|
86
|
+
project { id name }
|
|
87
|
+
labels { nodes { id name color } }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`,
|
|
92
|
+
variables: { teamKey, number },
|
|
93
|
+
};
|
|
94
|
+
const response = await fetch('https://api.linear.app/graphql', {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
headers: {
|
|
97
|
+
'Content-Type': 'application/json',
|
|
98
|
+
Authorization: `Bearer ${linearToken}`,
|
|
99
|
+
},
|
|
100
|
+
body: JSON.stringify(graphqlQuery),
|
|
101
|
+
});
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
const error = await response.json();
|
|
104
|
+
return { error: 'Failed to get Linear issue', details: error };
|
|
105
|
+
}
|
|
106
|
+
const data = await response.json();
|
|
107
|
+
if (data.errors?.length) {
|
|
108
|
+
return { error: 'Linear GraphQL error', details: data.errors };
|
|
109
|
+
}
|
|
110
|
+
const issue = data.data.issues.nodes[0];
|
|
111
|
+
if (!issue) {
|
|
112
|
+
return { error: `No issue found for identifier ${identifier}` };
|
|
113
|
+
}
|
|
114
|
+
return issue;
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=get-issue.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const linearListProjects = tool({
|
|
4
|
+
description: 'List Linear projects. Returns project IDs, names, status, and associated teams.',
|
|
5
|
+
inputSchema: z.object({
|
|
6
|
+
linearToken: z.string().optional().describe('Linear API token (injected by system)'),
|
|
7
|
+
}),
|
|
8
|
+
execute: async ({ linearToken }) => {
|
|
9
|
+
const graphqlQuery = {
|
|
10
|
+
query: `
|
|
11
|
+
query {
|
|
12
|
+
projects(first: 50) {
|
|
13
|
+
nodes {
|
|
14
|
+
id
|
|
15
|
+
name
|
|
16
|
+
description
|
|
17
|
+
state
|
|
18
|
+
url
|
|
19
|
+
startDate
|
|
20
|
+
targetDate
|
|
21
|
+
teams { nodes { id name key } }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
};
|
|
27
|
+
const response = await fetch('https://api.linear.app/graphql', {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
Authorization: `Bearer ${linearToken}`,
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify(graphqlQuery),
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const error = await response.json();
|
|
37
|
+
return { error: 'Failed to list Linear projects', details: error };
|
|
38
|
+
}
|
|
39
|
+
const data = await response.json();
|
|
40
|
+
if (data.errors?.length) {
|
|
41
|
+
return { error: 'Linear GraphQL error', details: data.errors };
|
|
42
|
+
}
|
|
43
|
+
return data.data.projects.nodes;
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=list-projects.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const linearListWorkflowStates: import("ai").Tool<{
|
|
2
|
+
teamId: string;
|
|
3
|
+
linearToken?: string | undefined;
|
|
4
|
+
}, {
|
|
5
|
+
error: string;
|
|
6
|
+
details: any;
|
|
7
|
+
teamId?: undefined;
|
|
8
|
+
teamName?: undefined;
|
|
9
|
+
teamKey?: undefined;
|
|
10
|
+
states?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
error: string;
|
|
13
|
+
details?: undefined;
|
|
14
|
+
teamId?: undefined;
|
|
15
|
+
teamName?: undefined;
|
|
16
|
+
teamKey?: undefined;
|
|
17
|
+
states?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
teamId: any;
|
|
20
|
+
teamName: any;
|
|
21
|
+
teamKey: any;
|
|
22
|
+
states: any;
|
|
23
|
+
error?: undefined;
|
|
24
|
+
details?: undefined;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=list-workflow-states.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const linearListWorkflowStates = tool({
|
|
4
|
+
description: 'List workflow states (statuses) for a Linear team. Use state IDs with linearUpdateIssue to move issues (e.g. Todo → In Progress → Done).',
|
|
5
|
+
inputSchema: z.object({
|
|
6
|
+
teamId: z.string().describe('Team UUID. Use linearListTeams to find team IDs.'),
|
|
7
|
+
linearToken: z.string().optional().describe('Linear API token (injected by system)'),
|
|
8
|
+
}),
|
|
9
|
+
execute: async ({ teamId, linearToken }) => {
|
|
10
|
+
const graphqlQuery = {
|
|
11
|
+
query: `
|
|
12
|
+
query TeamWorkflowStates($teamId: String!) {
|
|
13
|
+
team(id: $teamId) {
|
|
14
|
+
id
|
|
15
|
+
name
|
|
16
|
+
key
|
|
17
|
+
states {
|
|
18
|
+
nodes {
|
|
19
|
+
id
|
|
20
|
+
name
|
|
21
|
+
type
|
|
22
|
+
color
|
|
23
|
+
position
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`,
|
|
29
|
+
variables: { teamId },
|
|
30
|
+
};
|
|
31
|
+
const response = await fetch('https://api.linear.app/graphql', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: {
|
|
34
|
+
'Content-Type': 'application/json',
|
|
35
|
+
Authorization: `Bearer ${linearToken}`,
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify(graphqlQuery),
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
const error = await response.json();
|
|
41
|
+
return { error: 'Failed to list Linear workflow states', details: error };
|
|
42
|
+
}
|
|
43
|
+
const data = await response.json();
|
|
44
|
+
if (data.errors?.length) {
|
|
45
|
+
return { error: 'Linear GraphQL error', details: data.errors };
|
|
46
|
+
}
|
|
47
|
+
const team = data.data.team;
|
|
48
|
+
if (!team) {
|
|
49
|
+
return { error: `Team not found: ${teamId}` };
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
teamId: team.id,
|
|
53
|
+
teamName: team.name,
|
|
54
|
+
teamKey: team.key,
|
|
55
|
+
states: team.states.nodes,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=list-workflow-states.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const linearUpdateIssue: import("ai").Tool<{
|
|
2
|
+
issueId: string;
|
|
3
|
+
description?: string | undefined;
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
linearToken?: string | undefined;
|
|
6
|
+
stateId?: string | undefined;
|
|
7
|
+
assigneeId?: string | null | undefined;
|
|
8
|
+
priority?: number | undefined;
|
|
9
|
+
projectId?: string | undefined;
|
|
10
|
+
}, any>;
|
|
11
|
+
//# sourceMappingURL=update-issue.d.ts.map
|