figmanage 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/analytics.js +3 -2
- package/dist/cli/branching.js +9 -3
- package/dist/cli/comments.js +10 -4
- package/dist/cli/components.js +21 -4
- package/dist/cli/compound-commands.js +13 -12
- package/dist/cli/export.js +3 -2
- package/dist/cli/files.js +14 -8
- package/dist/cli/helpers.d.ts +1 -0
- package/dist/cli/helpers.js +10 -0
- package/dist/cli/libraries.js +2 -1
- package/dist/cli/navigate.js +11 -10
- package/dist/cli/org.js +13 -12
- package/dist/cli/permissions.js +13 -7
- package/dist/cli/projects.js +12 -6
- package/dist/cli/reading.js +3 -2
- package/dist/cli/teams.js +9 -3
- package/dist/cli/variables.js +29 -7
- package/dist/cli/versions.js +3 -2
- package/dist/cli/webhooks.js +14 -4
- package/dist/helpers.d.ts +11 -0
- package/dist/helpers.js +41 -0
- package/dist/operations/analytics.js +1 -1
- package/dist/operations/components.d.ts +8 -2
- package/dist/operations/components.js +4 -2
- package/dist/operations/compound-manager.js +8 -9
- package/dist/operations/compound.d.ts +3 -0
- package/dist/operations/compound.js +14 -8
- package/dist/operations/files.js +1 -1
- package/dist/operations/libraries.js +1 -1
- package/dist/operations/org.js +1 -1
- package/dist/operations/reading.js +2 -0
- package/dist/operations/teams.js +1 -1
- package/dist/operations/variables.js +11 -0
- package/dist/operations/webhooks.d.ts +4 -1
- package/dist/operations/webhooks.js +2 -1
- package/dist/tools/analytics.js +6 -5
- package/dist/tools/branching.js +7 -6
- package/dist/tools/comments.js +14 -9
- package/dist/tools/components.js +24 -15
- package/dist/tools/compound-manager.js +10 -7
- package/dist/tools/compound.js +34 -22
- package/dist/tools/export.js +6 -5
- package/dist/tools/files.js +13 -12
- package/dist/tools/libraries.js +6 -3
- package/dist/tools/navigate.js +29 -18
- package/dist/tools/org.js +25 -24
- package/dist/tools/permissions.js +14 -11
- package/dist/tools/projects.js +10 -9
- package/dist/tools/reading.js +11 -7
- package/dist/tools/register.d.ts +8 -2
- package/dist/tools/register.js +9 -14
- package/dist/tools/teams.js +7 -6
- package/dist/tools/variables.js +12 -8
- package/dist/tools/versions.js +6 -5
- package/dist/tools/webhooks.js +15 -12
- package/package.json +1 -1
package/dist/tools/files.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
2
|
+
import { defineTool, toolResult, toolError, toolSummary, figmaId } from './register.js';
|
|
3
|
+
import { formatApiError } from '../helpers.js';
|
|
3
4
|
import { createFile, renameFile, moveFiles, duplicateFile, trashFiles, restoreFiles, favoriteFile, setLinkAccess, } from '../operations/files.js';
|
|
4
5
|
// -- create_file --
|
|
5
6
|
defineTool({
|
|
@@ -17,10 +18,10 @@ defineTool({
|
|
|
17
18
|
}, async ({ project_id, editor_type, org_id }) => {
|
|
18
19
|
try {
|
|
19
20
|
const result = await createFile(config, { project_id, editor_type, org_id });
|
|
20
|
-
return
|
|
21
|
+
return toolSummary(`Created ${result.editor_type || 'design'} file.`, result);
|
|
21
22
|
}
|
|
22
23
|
catch (e) {
|
|
23
|
-
return toolError(`Failed to create file: ${e
|
|
24
|
+
return toolError(`Failed to create file: ${formatApiError(e)}`);
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
},
|
|
@@ -43,7 +44,7 @@ defineTool({
|
|
|
43
44
|
return toolResult(`Renamed to "${name}"`);
|
|
44
45
|
}
|
|
45
46
|
catch (e) {
|
|
46
|
-
return toolError(`Failed to rename file: ${e
|
|
47
|
+
return toolError(`Failed to rename file: ${formatApiError(e)}`);
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
},
|
|
@@ -69,7 +70,7 @@ defineTool({
|
|
|
69
70
|
return toolResult(msg);
|
|
70
71
|
}
|
|
71
72
|
catch (e) {
|
|
72
|
-
return toolError(`Failed to move files: ${e
|
|
73
|
+
return toolError(`Failed to move files: ${formatApiError(e)}`);
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
},
|
|
@@ -89,10 +90,10 @@ defineTool({
|
|
|
89
90
|
}, async ({ file_key, project_id }) => {
|
|
90
91
|
try {
|
|
91
92
|
const result = await duplicateFile(config, { file_key, project_id });
|
|
92
|
-
return
|
|
93
|
+
return toolSummary(`Duplicated file.`, result);
|
|
93
94
|
}
|
|
94
95
|
catch (e) {
|
|
95
|
-
return toolError(`Failed to duplicate file: ${e
|
|
96
|
+
return toolError(`Failed to duplicate file: ${formatApiError(e)}`);
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
},
|
|
@@ -105,7 +106,7 @@ defineTool({
|
|
|
105
106
|
destructive: true,
|
|
106
107
|
register(server, config) {
|
|
107
108
|
server.registerTool('trash_files', {
|
|
108
|
-
description: 'Move files to trash. Supports batch operations.',
|
|
109
|
+
description: 'Move files to trash (recoverable via restore_files). Supports batch operations.',
|
|
109
110
|
inputSchema: {
|
|
110
111
|
file_keys: z.array(figmaId).min(1).describe('Array of file keys to trash'),
|
|
111
112
|
},
|
|
@@ -115,7 +116,7 @@ defineTool({
|
|
|
115
116
|
return toolResult(`Trashed ${result.succeeded} file(s)`);
|
|
116
117
|
}
|
|
117
118
|
catch (e) {
|
|
118
|
-
return toolError(`Failed to trash files: ${e
|
|
119
|
+
return toolError(`Failed to trash files: ${formatApiError(e)}`);
|
|
119
120
|
}
|
|
120
121
|
});
|
|
121
122
|
},
|
|
@@ -140,7 +141,7 @@ defineTool({
|
|
|
140
141
|
return toolResult(msg);
|
|
141
142
|
}
|
|
142
143
|
catch (e) {
|
|
143
|
-
return toolError(`Failed to restore files: ${e
|
|
144
|
+
return toolError(`Failed to restore files: ${formatApiError(e)}`);
|
|
144
145
|
}
|
|
145
146
|
});
|
|
146
147
|
},
|
|
@@ -163,7 +164,7 @@ defineTool({
|
|
|
163
164
|
return toolResult(`${result.favorited ? 'Favorited' : 'Unfavorited'} file ${file_key}`);
|
|
164
165
|
}
|
|
165
166
|
catch (e) {
|
|
166
|
-
return toolError(`Failed to toggle favorite: ${e
|
|
167
|
+
return toolError(`Failed to toggle favorite: ${formatApiError(e)}`);
|
|
167
168
|
}
|
|
168
169
|
});
|
|
169
170
|
},
|
|
@@ -186,7 +187,7 @@ defineTool({
|
|
|
186
187
|
return toolResult(`Set link access to "${result.link_access}" on file ${file_key}`);
|
|
187
188
|
}
|
|
188
189
|
catch (e) {
|
|
189
|
-
return toolError(`Failed to set link access: ${e
|
|
190
|
+
return toolError(`Failed to set link access: ${formatApiError(e)}`);
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
},
|
package/dist/tools/libraries.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
1
|
+
import { defineTool, toolResult, toolError, toolSummary, figmaId } from './register.js';
|
|
2
|
+
import { formatApiError } from '../helpers.js';
|
|
2
3
|
import { listOrgLibraries } from '../operations/libraries.js';
|
|
3
4
|
// -- list_org_libraries --
|
|
4
5
|
defineTool({
|
|
@@ -13,10 +14,12 @@ defineTool({
|
|
|
13
14
|
}, async ({ org_id }) => {
|
|
14
15
|
try {
|
|
15
16
|
const result = await listOrgLibraries(config, { org_id });
|
|
16
|
-
|
|
17
|
+
if (result.length === 0)
|
|
18
|
+
return toolResult('No libraries found.');
|
|
19
|
+
return toolSummary(`${result.length} library/libraries.`, result, 'Use library_usage to see adoption metrics.');
|
|
17
20
|
}
|
|
18
21
|
catch (e) {
|
|
19
|
-
return toolError(`Failed to list org libraries: ${e
|
|
22
|
+
return toolError(`Failed to list org libraries: ${formatApiError(e)}`);
|
|
20
23
|
}
|
|
21
24
|
});
|
|
22
25
|
},
|
package/dist/tools/navigate.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
2
|
+
import { defineTool, toolResult, toolError, toolSummary, figmaId } from './register.js';
|
|
3
|
+
import { formatApiError } from '../helpers.js';
|
|
3
4
|
import { checkAuthStatus, listOrgs, switchOrg, listTeams, listProjects, listFiles, listRecentFiles, search, getFileInfo, listFavorites, } from '../operations/navigate.js';
|
|
4
5
|
// -- check_auth --
|
|
5
6
|
defineTool({
|
|
@@ -34,10 +35,10 @@ defineTool({
|
|
|
34
35
|
if (orgs.length === 0) {
|
|
35
36
|
return toolResult('No workspaces found. You may be on a free/starter plan.');
|
|
36
37
|
}
|
|
37
|
-
return
|
|
38
|
+
return toolSummary(`Found ${orgs.length} workspace(s).`, orgs, 'Use switch_org to change workspace, or list_teams to browse.');
|
|
38
39
|
}
|
|
39
40
|
catch (e) {
|
|
40
|
-
return toolError(`Failed to list orgs: ${e
|
|
41
|
+
return toolError(`Failed to list orgs: ${formatApiError(e)}`);
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
},
|
|
@@ -60,7 +61,7 @@ defineTool({
|
|
|
60
61
|
return toolResult(`Switched workspace: ${result.previous} -> ${result.current.name} (${result.current.id})`);
|
|
61
62
|
}
|
|
62
63
|
catch (e) {
|
|
63
|
-
return toolError(`Failed to switch org: ${e
|
|
64
|
+
return toolError(`Failed to switch org: ${formatApiError(e)}`);
|
|
64
65
|
}
|
|
65
66
|
});
|
|
66
67
|
},
|
|
@@ -75,10 +76,12 @@ defineTool({
|
|
|
75
76
|
}, async () => {
|
|
76
77
|
try {
|
|
77
78
|
const teams = await listTeams(config);
|
|
78
|
-
|
|
79
|
+
if (teams.length === 0)
|
|
80
|
+
return toolResult('No teams found.');
|
|
81
|
+
return toolSummary(`Found ${teams.length} team(s).`, teams, 'Use list_projects with a team_id to browse projects.');
|
|
79
82
|
}
|
|
80
83
|
catch (e) {
|
|
81
|
-
return toolError(`Failed to list teams: ${e
|
|
84
|
+
return toolError(`Failed to list teams: ${formatApiError(e)}`);
|
|
82
85
|
}
|
|
83
86
|
});
|
|
84
87
|
},
|
|
@@ -96,10 +99,12 @@ defineTool({
|
|
|
96
99
|
}, async ({ team_id }) => {
|
|
97
100
|
try {
|
|
98
101
|
const projects = await listProjects(config, { team_id });
|
|
99
|
-
|
|
102
|
+
if (projects.length === 0)
|
|
103
|
+
return toolResult('No projects found.');
|
|
104
|
+
return toolSummary(`Found ${projects.length} project(s).`, projects, 'Use list_files with a project_id to see files.');
|
|
100
105
|
}
|
|
101
106
|
catch (e) {
|
|
102
|
-
return toolError(`Failed to list projects: ${e
|
|
107
|
+
return toolError(`Failed to list projects: ${formatApiError(e)}`);
|
|
103
108
|
}
|
|
104
109
|
});
|
|
105
110
|
},
|
|
@@ -119,10 +124,12 @@ defineTool({
|
|
|
119
124
|
}, async ({ project_id, page_size, page_token }) => {
|
|
120
125
|
try {
|
|
121
126
|
const result = await listFiles(config, { project_id, page_size, page_token });
|
|
122
|
-
|
|
127
|
+
const count = result.files.length;
|
|
128
|
+
const summary = `${count} file(s).` + (result.pagination?.has_more ? ' More pages available.' : '');
|
|
129
|
+
return toolSummary(summary, result, 'Use get_file_info or get_file for details.');
|
|
123
130
|
}
|
|
124
131
|
catch (e) {
|
|
125
|
-
return toolError(`Failed to list files: ${e
|
|
132
|
+
return toolError(`Failed to list files: ${formatApiError(e)}`);
|
|
126
133
|
}
|
|
127
134
|
});
|
|
128
135
|
},
|
|
@@ -137,10 +144,12 @@ defineTool({
|
|
|
137
144
|
}, async () => {
|
|
138
145
|
try {
|
|
139
146
|
const files = await listRecentFiles(config);
|
|
140
|
-
|
|
147
|
+
if (files.length === 0)
|
|
148
|
+
return toolResult('No recent files.');
|
|
149
|
+
return toolSummary(`${files.length} recently accessed file(s).`, files, 'Use get_file_info for details.');
|
|
141
150
|
}
|
|
142
151
|
catch (e) {
|
|
143
|
-
return toolError(`Failed to list recent files: ${e
|
|
152
|
+
return toolError(`Failed to list recent files: ${formatApiError(e)}`);
|
|
144
153
|
}
|
|
145
154
|
});
|
|
146
155
|
},
|
|
@@ -163,10 +172,10 @@ defineTool({
|
|
|
163
172
|
if (results.length === 0) {
|
|
164
173
|
return toolResult('No results. Try list_recent_files or browse via list_projects + list_files.');
|
|
165
174
|
}
|
|
166
|
-
return
|
|
175
|
+
return toolSummary(`Found ${results.length} result(s).`, results, 'Use get_file_info for file details.');
|
|
167
176
|
}
|
|
168
177
|
catch (e) {
|
|
169
|
-
return toolError(`Search failed: ${e
|
|
178
|
+
return toolError(`Search failed: ${formatApiError(e)}`);
|
|
170
179
|
}
|
|
171
180
|
});
|
|
172
181
|
},
|
|
@@ -184,10 +193,10 @@ defineTool({
|
|
|
184
193
|
}, async ({ file_key }) => {
|
|
185
194
|
try {
|
|
186
195
|
const info = await getFileInfo(config, { file_key });
|
|
187
|
-
return
|
|
196
|
+
return toolSummary(`${info.name} (${info.editor_type || 'design'})`, info);
|
|
188
197
|
}
|
|
189
198
|
catch (e) {
|
|
190
|
-
return toolError(`Failed to get file info: ${e
|
|
199
|
+
return toolError(`Failed to get file info: ${formatApiError(e)}`);
|
|
191
200
|
}
|
|
192
201
|
});
|
|
193
202
|
},
|
|
@@ -202,10 +211,12 @@ defineTool({
|
|
|
202
211
|
}, async () => {
|
|
203
212
|
try {
|
|
204
213
|
const favorites = await listFavorites(config);
|
|
205
|
-
|
|
214
|
+
if (favorites.length === 0)
|
|
215
|
+
return toolResult('No favorites found.');
|
|
216
|
+
return toolSummary(`${favorites.length} favorited file(s).`, favorites, 'Use get_file_info for details.');
|
|
206
217
|
}
|
|
207
218
|
catch (e) {
|
|
208
|
-
return toolError(`Failed to list favorites: ${e
|
|
219
|
+
return toolError(`Failed to list favorites: ${formatApiError(e)}`);
|
|
209
220
|
}
|
|
210
221
|
});
|
|
211
222
|
},
|
package/dist/tools/org.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
2
|
+
import { defineTool, toolResult, toolError, toolSummary, figmaId } from './register.js';
|
|
3
|
+
import { formatApiError } from '../helpers.js';
|
|
3
4
|
import { listAdmins, listOrgTeams, seatUsage, listTeamMembers, billingOverview, listInvoices, orgDomains, aiCreditUsage, exportMembers, listOrgMembers, contractRates, changeSeat, } from '../operations/org.js';
|
|
4
5
|
// -- list_admins --
|
|
5
6
|
defineTool({
|
|
@@ -15,10 +16,10 @@ defineTool({
|
|
|
15
16
|
}, async ({ org_id, include_license_admins }) => {
|
|
16
17
|
try {
|
|
17
18
|
const result = await listAdmins(config, { org_id, include_license_admins });
|
|
18
|
-
return
|
|
19
|
+
return toolSummary(`${result.length} admin(s).`, result);
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
return toolError(`Failed to list admins: ${e
|
|
22
|
+
return toolError(`Failed to list admins: ${formatApiError(e)}`);
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
},
|
|
@@ -37,10 +38,10 @@ defineTool({
|
|
|
37
38
|
}, async ({ org_id, include_secret_teams }) => {
|
|
38
39
|
try {
|
|
39
40
|
const result = await listOrgTeams(config, { org_id, include_secret_teams });
|
|
40
|
-
return
|
|
41
|
+
return toolSummary(`${result.length} team(s) in the org.`, result, 'Use list_team_members for member details.');
|
|
41
42
|
}
|
|
42
43
|
catch (e) {
|
|
43
|
-
return toolError(`Failed to list org teams: ${e
|
|
44
|
+
return toolError(`Failed to list org teams: ${formatApiError(e)}`);
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
},
|
|
@@ -59,10 +60,10 @@ defineTool({
|
|
|
59
60
|
}, async ({ org_id, search_query }) => {
|
|
60
61
|
try {
|
|
61
62
|
const result = await seatUsage(config, { org_id, search_query });
|
|
62
|
-
return
|
|
63
|
+
return toolSummary('Seat usage breakdown:', result);
|
|
63
64
|
}
|
|
64
65
|
catch (e) {
|
|
65
|
-
return toolError(`Failed to fetch seat usage: ${e
|
|
66
|
+
return toolError(`Failed to fetch seat usage: ${formatApiError(e)}`);
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
},
|
|
@@ -80,10 +81,10 @@ defineTool({
|
|
|
80
81
|
}, async ({ team_id }) => {
|
|
81
82
|
try {
|
|
82
83
|
const result = await listTeamMembers(config, { team_id });
|
|
83
|
-
return
|
|
84
|
+
return toolSummary(`${result.length} member(s).`, result);
|
|
84
85
|
}
|
|
85
86
|
catch (e) {
|
|
86
|
-
return toolError(`Failed to list team members: ${e
|
|
87
|
+
return toolError(`Failed to list team members: ${formatApiError(e)}`);
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
90
|
},
|
|
@@ -101,10 +102,10 @@ defineTool({
|
|
|
101
102
|
}, async ({ org_id }) => {
|
|
102
103
|
try {
|
|
103
104
|
const result = await billingOverview(config, { org_id });
|
|
104
|
-
return
|
|
105
|
+
return toolSummary('Billing overview:', result);
|
|
105
106
|
}
|
|
106
107
|
catch (e) {
|
|
107
|
-
return toolError(`Failed to fetch billing overview: ${e
|
|
108
|
+
return toolError(`Failed to fetch billing overview: ${formatApiError(e)}`);
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
111
|
},
|
|
@@ -122,10 +123,10 @@ defineTool({
|
|
|
122
123
|
}, async ({ org_id }) => {
|
|
123
124
|
try {
|
|
124
125
|
const result = await listInvoices(config, { org_id });
|
|
125
|
-
return
|
|
126
|
+
return toolSummary(`${result.length} invoice(s).`, result);
|
|
126
127
|
}
|
|
127
128
|
catch (e) {
|
|
128
|
-
return toolError(`Failed to list invoices: ${e
|
|
129
|
+
return toolError(`Failed to list invoices: ${formatApiError(e)}`);
|
|
129
130
|
}
|
|
130
131
|
});
|
|
131
132
|
},
|
|
@@ -143,10 +144,10 @@ defineTool({
|
|
|
143
144
|
}, async ({ org_id }) => {
|
|
144
145
|
try {
|
|
145
146
|
const result = await orgDomains(config, { org_id });
|
|
146
|
-
return
|
|
147
|
+
return toolSummary('Domain configuration:', result);
|
|
147
148
|
}
|
|
148
149
|
catch (e) {
|
|
149
|
-
return toolError(`Failed to fetch org domains: ${e
|
|
150
|
+
return toolError(`Failed to fetch org domains: ${formatApiError(e)}`);
|
|
150
151
|
}
|
|
151
152
|
});
|
|
152
153
|
},
|
|
@@ -164,10 +165,10 @@ defineTool({
|
|
|
164
165
|
}, async ({ plan_id }) => {
|
|
165
166
|
try {
|
|
166
167
|
const result = await aiCreditUsage(config, { plan_id });
|
|
167
|
-
return
|
|
168
|
+
return toolSummary('AI credit usage:', result);
|
|
168
169
|
}
|
|
169
170
|
catch (e) {
|
|
170
|
-
return toolError(`Failed to fetch AI credit usage: ${e
|
|
171
|
+
return toolError(`Failed to fetch AI credit usage: ${formatApiError(e)}`);
|
|
171
172
|
}
|
|
172
173
|
});
|
|
173
174
|
},
|
|
@@ -189,7 +190,7 @@ defineTool({
|
|
|
189
190
|
return toolResult(msg);
|
|
190
191
|
}
|
|
191
192
|
catch (e) {
|
|
192
|
-
return toolError(`Failed to export members: ${e
|
|
193
|
+
return toolError(`Failed to export members: ${formatApiError(e)}`);
|
|
193
194
|
}
|
|
194
195
|
});
|
|
195
196
|
},
|
|
@@ -208,10 +209,10 @@ defineTool({
|
|
|
208
209
|
}, async ({ org_id, search_query }) => {
|
|
209
210
|
try {
|
|
210
211
|
const result = await listOrgMembers(config, { org_id, search_query });
|
|
211
|
-
return
|
|
212
|
+
return toolSummary(`${result.length} member(s).`, result, 'Use change_seat to modify seat types.');
|
|
212
213
|
}
|
|
213
214
|
catch (e) {
|
|
214
|
-
return toolError(`Failed to list org members: ${e
|
|
215
|
+
return toolError(`Failed to list org members: ${formatApiError(e)}`);
|
|
215
216
|
}
|
|
216
217
|
});
|
|
217
218
|
},
|
|
@@ -229,10 +230,10 @@ defineTool({
|
|
|
229
230
|
}, async ({ org_id }) => {
|
|
230
231
|
try {
|
|
231
232
|
const result = await contractRates(config, { org_id });
|
|
232
|
-
return
|
|
233
|
+
return toolSummary('Seat pricing:', result);
|
|
233
234
|
}
|
|
234
235
|
catch (e) {
|
|
235
|
-
return toolError(`Failed to fetch contract rates: ${e
|
|
236
|
+
return toolError(`Failed to fetch contract rates: ${formatApiError(e)}`);
|
|
236
237
|
}
|
|
237
238
|
});
|
|
238
239
|
},
|
|
@@ -257,10 +258,10 @@ defineTool({
|
|
|
257
258
|
const result = await changeSeat(config, { user_id, seat_type, org_id, confirm });
|
|
258
259
|
if (typeof result === 'string')
|
|
259
260
|
return toolResult(result);
|
|
260
|
-
return
|
|
261
|
+
return toolSummary('Seat change requires confirmation.', result);
|
|
261
262
|
}
|
|
262
263
|
catch (e) {
|
|
263
|
-
return toolError(
|
|
264
|
+
return toolError(`Failed to change seat: ${formatApiError(e)}`);
|
|
264
265
|
}
|
|
265
266
|
});
|
|
266
267
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
2
|
+
import { defineTool, toolResult, toolError, toolSummary, figmaId } from './register.js';
|
|
3
|
+
import { formatApiError } from '../helpers.js';
|
|
3
4
|
import { getPermissions, setPermissions, share, revokeAccess, listRoleRequests, approveRoleRequest, denyRoleRequest, } from '../operations/permissions.js';
|
|
4
5
|
// -- get_permissions --
|
|
5
6
|
defineTool({
|
|
@@ -15,10 +16,10 @@ defineTool({
|
|
|
15
16
|
}, async ({ resource_type, resource_id }) => {
|
|
16
17
|
try {
|
|
17
18
|
const result = await getPermissions(config, { resource_type, resource_id });
|
|
18
|
-
return
|
|
19
|
+
return toolSummary(`${result.length} user(s) with access.`, result, 'Use set_permissions or revoke_access to modify.');
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
return toolError(`Failed to get permissions: ${e
|
|
22
|
+
return toolError(`Failed to get permissions: ${formatApiError(e)}`);
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
},
|
|
@@ -43,7 +44,7 @@ defineTool({
|
|
|
43
44
|
return toolResult(msg);
|
|
44
45
|
}
|
|
45
46
|
catch (e) {
|
|
46
|
-
return toolError(
|
|
47
|
+
return toolError(`Failed to set permissions: ${formatApiError(e)}`);
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
},
|
|
@@ -71,7 +72,7 @@ defineTool({
|
|
|
71
72
|
return toolResult(msg);
|
|
72
73
|
}
|
|
73
74
|
catch (e) {
|
|
74
|
-
return toolError(`Failed to share: ${e
|
|
75
|
+
return toolError(`Failed to share: ${formatApiError(e)}`);
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
},
|
|
@@ -84,7 +85,7 @@ defineTool({
|
|
|
84
85
|
destructive: true,
|
|
85
86
|
register(server, config) {
|
|
86
87
|
server.registerTool('revoke_access', {
|
|
87
|
-
description: "Remove
|
|
88
|
+
description: "Remove a user's access to a file, project, or team. The user loses access immediately.",
|
|
88
89
|
inputSchema: {
|
|
89
90
|
resource_type: z.enum(['file', 'folder', 'team']).describe('Type of resource'),
|
|
90
91
|
resource_id: figmaId.describe('Resource ID'),
|
|
@@ -96,7 +97,7 @@ defineTool({
|
|
|
96
97
|
return toolResult(msg);
|
|
97
98
|
}
|
|
98
99
|
catch (e) {
|
|
99
|
-
return toolError(
|
|
100
|
+
return toolError(`Failed to revoke access: ${formatApiError(e)}`);
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
103
|
},
|
|
@@ -112,10 +113,12 @@ defineTool({
|
|
|
112
113
|
}, async () => {
|
|
113
114
|
try {
|
|
114
115
|
const result = await listRoleRequests(config);
|
|
115
|
-
|
|
116
|
+
if (result.length === 0)
|
|
117
|
+
return toolResult('No pending access requests.');
|
|
118
|
+
return toolSummary(`${result.length} pending request(s).`, result, 'Use approve_role_request or deny_role_request.');
|
|
116
119
|
}
|
|
117
120
|
catch (e) {
|
|
118
|
-
return toolError(`Failed to list role requests: ${e
|
|
121
|
+
return toolError(`Failed to list role requests: ${formatApiError(e)}`);
|
|
119
122
|
}
|
|
120
123
|
});
|
|
121
124
|
},
|
|
@@ -137,7 +140,7 @@ defineTool({
|
|
|
137
140
|
return toolResult(msg);
|
|
138
141
|
}
|
|
139
142
|
catch (e) {
|
|
140
|
-
return toolError(`Failed to approve request: ${e
|
|
143
|
+
return toolError(`Failed to approve request: ${formatApiError(e)}`);
|
|
141
144
|
}
|
|
142
145
|
});
|
|
143
146
|
},
|
|
@@ -159,7 +162,7 @@ defineTool({
|
|
|
159
162
|
return toolResult(msg);
|
|
160
163
|
}
|
|
161
164
|
catch (e) {
|
|
162
|
-
return toolError(`Failed to deny request: ${e
|
|
165
|
+
return toolError(`Failed to deny request: ${formatApiError(e)}`);
|
|
163
166
|
}
|
|
164
167
|
});
|
|
165
168
|
},
|
package/dist/tools/projects.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { defineTool, toolResult, toolError, figmaId } from './register.js';
|
|
2
|
+
import { defineTool, toolResult, toolError, toolSummary, figmaId } from './register.js';
|
|
3
|
+
import { formatApiError } from '../helpers.js';
|
|
3
4
|
import { createProject, renameProject, moveProject, trashProject, restoreProject, setProjectDescription, } from '../operations/projects.js';
|
|
4
5
|
// -- create_project --
|
|
5
6
|
defineTool({
|
|
@@ -16,10 +17,10 @@ defineTool({
|
|
|
16
17
|
}, async ({ team_id, name }) => {
|
|
17
18
|
try {
|
|
18
19
|
const result = await createProject(config, { team_id, name });
|
|
19
|
-
return
|
|
20
|
+
return toolSummary(`Created project "${result.name}".`, result, 'Use list_files to see files, or create_file to add one.');
|
|
20
21
|
}
|
|
21
22
|
catch (e) {
|
|
22
|
-
return toolError(`Failed to create project: ${e
|
|
23
|
+
return toolError(`Failed to create project: ${formatApiError(e)}`);
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
},
|
|
@@ -42,7 +43,7 @@ defineTool({
|
|
|
42
43
|
return toolResult(`Renamed project ${project_id} to "${name}"`);
|
|
43
44
|
}
|
|
44
45
|
catch (e) {
|
|
45
|
-
return toolError(`Failed to rename project: ${e
|
|
46
|
+
return toolError(`Failed to rename project: ${formatApiError(e)}`);
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
},
|
|
@@ -65,7 +66,7 @@ defineTool({
|
|
|
65
66
|
return toolResult(`Moved project ${project_id} to team ${destination_team_id}`);
|
|
66
67
|
}
|
|
67
68
|
catch (e) {
|
|
68
|
-
return toolError(`Failed to move project: ${e
|
|
69
|
+
return toolError(`Failed to move project: ${formatApiError(e)}`);
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
},
|
|
@@ -78,7 +79,7 @@ defineTool({
|
|
|
78
79
|
destructive: true,
|
|
79
80
|
register(server, config) {
|
|
80
81
|
server.registerTool('trash_project', {
|
|
81
|
-
description: 'Move a project to trash.',
|
|
82
|
+
description: 'Move a project and all its files to trash. Recoverable via restore_project.',
|
|
82
83
|
inputSchema: {
|
|
83
84
|
project_id: figmaId.describe('Project ID to trash'),
|
|
84
85
|
},
|
|
@@ -88,7 +89,7 @@ defineTool({
|
|
|
88
89
|
return toolResult(`Trashed project ${project_id}`);
|
|
89
90
|
}
|
|
90
91
|
catch (e) {
|
|
91
|
-
return toolError(`Failed to trash project: ${e
|
|
92
|
+
return toolError(`Failed to trash project: ${formatApiError(e)}`);
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
},
|
|
@@ -110,7 +111,7 @@ defineTool({
|
|
|
110
111
|
return toolResult(`Restored project ${project_id}`);
|
|
111
112
|
}
|
|
112
113
|
catch (e) {
|
|
113
|
-
return toolError(`Failed to restore project: ${e
|
|
114
|
+
return toolError(`Failed to restore project: ${formatApiError(e)}`);
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
117
|
},
|
|
@@ -133,7 +134,7 @@ defineTool({
|
|
|
133
134
|
return toolResult(`Updated description for project ${project_id}`);
|
|
134
135
|
}
|
|
135
136
|
catch (e) {
|
|
136
|
-
return toolError(`Failed to set description: ${e
|
|
137
|
+
return toolError(`Failed to set description: ${formatApiError(e)}`);
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
},
|
package/dist/tools/reading.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { defineTool,
|
|
2
|
+
import { defineTool, toolError, toolSummary, figmaId } from './register.js';
|
|
3
|
+
import { formatApiError } from '../helpers.js';
|
|
3
4
|
import { getFile, getNodes } from '../operations/reading.js';
|
|
4
5
|
// -- get_file --
|
|
5
6
|
defineTool({
|
|
@@ -7,7 +8,7 @@ defineTool({
|
|
|
7
8
|
auth: 'pat',
|
|
8
9
|
register(server, config) {
|
|
9
10
|
server.registerTool('get_file', {
|
|
10
|
-
description: 'Read file contents as a node tree. To read a branch, use the branch file key from list_branches.',
|
|
11
|
+
description: 'Read file contents as a node tree. Use depth to limit response size (full trees can be very large). depth=1 returns pages only. To read a branch, use the branch file key from list_branches.',
|
|
11
12
|
inputSchema: {
|
|
12
13
|
file_key: figmaId.describe('File key (or branch file key from list_branches)'),
|
|
13
14
|
depth: z.number().int().optional().describe('Tree depth limit. 0=root, 1=pages, 2=top-level frames. Omit for full tree.'),
|
|
@@ -16,10 +17,12 @@ defineTool({
|
|
|
16
17
|
}, async ({ file_key, depth, node_id }) => {
|
|
17
18
|
try {
|
|
18
19
|
const result = await getFile(config, { file_key, depth, node_id });
|
|
19
|
-
|
|
20
|
+
const name = result.name || 'Untitled';
|
|
21
|
+
const pages = result.document?.children?.length || 0;
|
|
22
|
+
return toolSummary(`${name}: ${pages} page(s). Use depth parameter to limit response size.`, result);
|
|
20
23
|
}
|
|
21
24
|
catch (e) {
|
|
22
|
-
return toolError(`Failed to get file: ${e
|
|
25
|
+
return toolError(`Failed to get file: ${formatApiError(e)}`);
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
28
|
},
|
|
@@ -30,7 +33,7 @@ defineTool({
|
|
|
30
33
|
auth: 'pat',
|
|
31
34
|
register(server, config) {
|
|
32
35
|
server.registerTool('get_nodes', {
|
|
33
|
-
description: 'Read specific nodes from a file. Returns node
|
|
36
|
+
description: 'Read specific nodes from a file. Returns the full node tree for each ID including type, name, layout properties, fills, strokes, and children.',
|
|
34
37
|
inputSchema: {
|
|
35
38
|
file_key: figmaId.describe('File key'),
|
|
36
39
|
node_ids: z.array(figmaId).min(1).describe('Node IDs to fetch'),
|
|
@@ -39,10 +42,11 @@ defineTool({
|
|
|
39
42
|
}, async ({ file_key, node_ids, depth }) => {
|
|
40
43
|
try {
|
|
41
44
|
const result = await getNodes(config, { file_key, node_ids, depth });
|
|
42
|
-
|
|
45
|
+
const nodeCount = result.nodes ? Object.keys(result.nodes).length : 0;
|
|
46
|
+
return toolSummary(`${nodeCount} node(s) returned.`, result);
|
|
43
47
|
}
|
|
44
48
|
catch (e) {
|
|
45
|
-
return toolError(`Failed to get nodes: ${e
|
|
49
|
+
return toolError(`Failed to get nodes: ${formatApiError(e)}`);
|
|
46
50
|
}
|
|
47
51
|
});
|
|
48
52
|
},
|
package/dist/tools/register.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ export declare function toolResult(text: string): {
|
|
|
20
20
|
text: string;
|
|
21
21
|
}>;
|
|
22
22
|
};
|
|
23
|
+
/** Format a tool response with a summary line, JSON data, and optional next-step guidance. */
|
|
24
|
+
export declare function toolSummary(summary: string, data: unknown, nextStep?: string): {
|
|
25
|
+
content: Array<{
|
|
26
|
+
type: 'text';
|
|
27
|
+
text: string;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
23
30
|
export declare function toolError(message: string): {
|
|
24
31
|
isError: true;
|
|
25
32
|
content: Array<{
|
|
@@ -27,6 +34,5 @@ export declare function toolError(message: string): {
|
|
|
27
34
|
text: string;
|
|
28
35
|
}>;
|
|
29
36
|
};
|
|
30
|
-
export
|
|
31
|
-
export declare function requireOrgId(config: AuthConfig, explicit?: string): string;
|
|
37
|
+
export { resolveOrgId, requireOrgId } from '../helpers.js';
|
|
32
38
|
//# sourceMappingURL=register.d.ts.map
|