@theprototype/agent 1.54.0 → 1.56.0
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/catalog.json +5106 -650
- package/package.json +1 -1
- package/src/catalog.js +203 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theprototype/agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.56.0",
|
|
4
4
|
"description": "Let an AI agent (Claude Code, Claude Desktop, any MCP host) join a theprototype.app session from its link and build the 3D scene with you.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/catalog.js
CHANGED
|
@@ -43,6 +43,28 @@ export const TOOL_ANNOTATIONS = /** @type {Record<string, {title: string, read?:
|
|
|
43
43
|
control_simulation: { title: 'Run or stop the simulation', destructive: true },
|
|
44
44
|
delete_objects: { title: 'Delete objects', destructive: true },
|
|
45
45
|
clear_scene: { title: 'Clear the scene', destructive: true },
|
|
46
|
+
create_lathe: { title: 'Make a lathed shape', destructive: false },
|
|
47
|
+
create_tube: { title: 'Make a tube along a path', destructive: false },
|
|
48
|
+
extrude_shape: { title: 'Extrude an outline', destructive: false },
|
|
49
|
+
create_mesh: { title: 'Make a mesh from data', destructive: false },
|
|
50
|
+
set_geometry: { title: 'Reshape objects', destructive: true },
|
|
51
|
+
edit_mesh: { title: 'Edit a mesh', destructive: true },
|
|
52
|
+
set_material: { title: 'Change materials and textures', destructive: true, openWorld: true },
|
|
53
|
+
list_materials: { title: 'Read materials', read: true },
|
|
54
|
+
get_material: { title: 'Read one material', read: true },
|
|
55
|
+
create_shader: { title: 'Give objects a shader', destructive: true },
|
|
56
|
+
edit_shader: { title: 'Edit a shader', destructive: true },
|
|
57
|
+
assign_shader: { title: 'Copy or remove a shader', destructive: true },
|
|
58
|
+
describe_shader_nodes: { title: 'Look up shader node types', read: true },
|
|
59
|
+
set_post: { title: 'Change the post effects', destructive: true },
|
|
60
|
+
get_post: { title: 'Read the post effects', read: true },
|
|
61
|
+
create_post_graph: { title: 'Add a custom post effect', destructive: false },
|
|
62
|
+
uv_unwrap: { title: 'Unwrap UVs', destructive: true },
|
|
63
|
+
set_uv: { title: 'Set texture tiling or face mapping', destructive: true },
|
|
64
|
+
undo_last: { title: 'Undo your last change', destructive: true },
|
|
65
|
+
set_pivot: { title: 'Set the point an object turns about', destructive: true },
|
|
66
|
+
create_pivot: { title: 'Make a pivot group', destructive: false },
|
|
67
|
+
add_image: { title: 'Add an image to the library', destructive: false, openWorld: true },
|
|
46
68
|
install_modules: { title: 'Install modules', destructive: false, openWorld: true },
|
|
47
69
|
accept_offer: { title: 'Answer a question the app asks', destructive: true },
|
|
48
70
|
connect: { title: 'Join a session', destructive: false, openWorld: true },
|
|
@@ -93,6 +115,7 @@ export const GUIDANCE = [
|
|
|
93
115
|
on: ['status', 'list_scene']
|
|
94
116
|
},
|
|
95
117
|
{ line: 'Call status first: it says whether you may edit (a viewer can only look).', on: ['status'] },
|
|
118
|
+
{ line: 'When the person says "undo that" or "take that back", call undo_last; if it refuses, say who changed what.', on: ['undo_last'] },
|
|
96
119
|
{
|
|
97
120
|
line: 'You act as this person in their own tab: status "you" is them (their peer id, name and role); the other users are everyone else.',
|
|
98
121
|
on: ['status', 'where_are_users'],
|
|
@@ -167,7 +190,9 @@ export function buildCatalog(hostTools, opts = {}) {
|
|
|
167
190
|
if (!Array.isArray(hostTools) || !hostTools.length) throw new Error('the host tool list is empty');
|
|
168
191
|
const mapped = mapHostTools(hostTools);
|
|
169
192
|
// the bridge tools a page answers itself; `connect` is the agent CLI's (the Worker drops it, serve keeps it)
|
|
170
|
-
const
|
|
193
|
+
const plain = [...mapped.tools, ...bridgeTools('browser'), ...connectorOnlyTools()].map(annotate);
|
|
194
|
+
const tools = withGuidance(plain);
|
|
195
|
+
const connector = opts.connectorExcluded ? connectorView(plain, opts.connectorExcluded) : undefined;
|
|
171
196
|
return {
|
|
172
197
|
format: CATALOG_FORMAT,
|
|
173
198
|
generator: {
|
|
@@ -179,10 +204,186 @@ export function buildCatalog(hostTools, opts = {}) {
|
|
|
179
204
|
instructions: connectorInstructions(tools.map((t) => t.name)),
|
|
180
205
|
// mcp-fix: what the connector leaves out, on purpose (core's CONNECTOR_BLOCKED_TOOLS); the Worker checks against it
|
|
181
206
|
...(opts.connectorExcluded ? { connectorExcluded: [...opts.connectorExcluded].sort() } : {}),
|
|
182
|
-
tools
|
|
207
|
+
tools,
|
|
208
|
+
// 85a TB: what the claude.ai connector lists — the same tools, with the 85 ones grouped into families
|
|
209
|
+
...(connector ? { connector } : {})
|
|
183
210
|
};
|
|
184
211
|
}
|
|
185
212
|
|
|
213
|
+
/**
|
|
214
|
+
* 85a TB — THE CONNECTOR'S TOOL FAMILIES (owner tool budget 2026-11-01, roadmap 85's table). The claude.ai
|
|
215
|
+
* connector stays at about 40 tools and its 22 published tools never change, so new work joins as ONE tool per
|
|
216
|
+
* family with an `action` field. Grouping happens ONLY here (and in the Worker, which turns `{action, <action>:
|
|
217
|
+
* {...}}` back into the fine tool before relaying): the tab, local agents and `serve` keep the fine names.
|
|
218
|
+
* `actions` maps an action to the fine tool it runs. The action's fields go in an object named after the action,
|
|
219
|
+
* which carries the fine tool's own schema and description, so nothing about a tool is lost by grouping it.
|
|
220
|
+
* Reserved, not built yet: edit_shape `update` (G6b update_mesh), assets search / place / prefab (85-world, 85b),
|
|
221
|
+
* set_look environment / sky / light (85-scene, 85b), create_shape from_image (73's image-to-3D is generate_mesh,
|
|
222
|
+
* which the connector leaves out).
|
|
223
|
+
* @type {Readonly<Record<string, {title: string, summary: string, actions: Record<string, string>}>>}
|
|
224
|
+
*/
|
|
225
|
+
export const CONNECTOR_FAMILIES = Object.freeze({
|
|
226
|
+
create_shape: {
|
|
227
|
+
title: 'Make a shape',
|
|
228
|
+
summary:
|
|
229
|
+
'Make shapes the basic objects cannot: a lathe (a vase, a bowl, a lamp from a profile turned around an axis), a tube along a path (a rail, a pipe, a cable), an extruded outline (a sign, a star, a wall with a hole), or a mesh from your own vertices (anything else).',
|
|
230
|
+
actions: { lathe: 'create_lathe', tube: 'create_tube', extrude: 'extrude_shape', mesh: 'create_mesh' }
|
|
231
|
+
},
|
|
232
|
+
edit_shape: {
|
|
233
|
+
title: 'Reshape or model objects',
|
|
234
|
+
summary:
|
|
235
|
+
'Change the shape of objects that exist: params = new size / segments / type in place, mesh = model faces and vertices (extrude, inset, bevel, subdivide, weld, smooth, dissolve, make a face), pivot = the point an object turns about, pivot_group = a group at a joint so several parts swing together.',
|
|
236
|
+
actions: { params: 'set_geometry', mesh: 'edit_mesh', pivot: 'set_pivot', pivot_group: 'create_pivot' }
|
|
237
|
+
},
|
|
238
|
+
set_look: {
|
|
239
|
+
title: 'Materials, shaders, UVs and post effects',
|
|
240
|
+
summary:
|
|
241
|
+
'How things look: material = colour, roughness, metal, glow, see-through and textures (a library image, a CC0 material by name or an https image); list_materials / get_material read them; shader / edit_shader / assign_shader / shader_nodes = node shaders on objects; post / get_post / post_graph = the scene\'s post effects (bloom, colour grade, vignette; the host is asked first); unwrap / uv = texture mapping and tiling.',
|
|
242
|
+
actions: {
|
|
243
|
+
material: 'set_material',
|
|
244
|
+
list_materials: 'list_materials',
|
|
245
|
+
get_material: 'get_material',
|
|
246
|
+
shader: 'create_shader',
|
|
247
|
+
edit_shader: 'edit_shader',
|
|
248
|
+
assign_shader: 'assign_shader',
|
|
249
|
+
shader_nodes: 'describe_shader_nodes',
|
|
250
|
+
post: 'set_post',
|
|
251
|
+
get_post: 'get_post',
|
|
252
|
+
post_graph: 'create_post_graph',
|
|
253
|
+
unwrap: 'uv_unwrap',
|
|
254
|
+
uv: 'set_uv'
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
assets: {
|
|
258
|
+
title: 'Images and assets',
|
|
259
|
+
summary: 'The shared library: image = put an image into it (an https URL, base64 data, or a canvas you describe) and get its hash for textures.',
|
|
260
|
+
actions: { image: 'add_image' }
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
/** Connector tools that are not in a family: the 22 published ones + undo_last (1.56). A tool in none of these,
|
|
265
|
+
* no family and not left out on purpose fails the generator: a new connector name needs an owner row. */
|
|
266
|
+
export const CONNECTOR_STANDALONE = Object.freeze([
|
|
267
|
+
'list_scene',
|
|
268
|
+
'create_objects',
|
|
269
|
+
'update_objects',
|
|
270
|
+
'delete_objects',
|
|
271
|
+
'group_objects',
|
|
272
|
+
'clear_scene',
|
|
273
|
+
'animate_parts',
|
|
274
|
+
'create_flow_nodes',
|
|
275
|
+
'update_flow_nodes',
|
|
276
|
+
'describe_node_types',
|
|
277
|
+
'create_behaviour',
|
|
278
|
+
'edit_behaviour',
|
|
279
|
+
'set_physics',
|
|
280
|
+
'create_joints',
|
|
281
|
+
'control_simulation',
|
|
282
|
+
'what_can_you_do',
|
|
283
|
+
'save_scene',
|
|
284
|
+
'status',
|
|
285
|
+
'screenshot',
|
|
286
|
+
'wait_for_edit',
|
|
287
|
+
'join_session',
|
|
288
|
+
'where_are_users',
|
|
289
|
+
'undo_last',
|
|
290
|
+
// left out by the Worker's own policy (generate_mesh), kept listed so the Worker's EXCLUDED_TOOLS stays the scope call
|
|
291
|
+
'generate_mesh'
|
|
292
|
+
]);
|
|
293
|
+
|
|
294
|
+
/** fine tool → `family {action}` wording, for text the connector's model reads @returns {Map<string, string>} */
|
|
295
|
+
export function familyNames() {
|
|
296
|
+
const out = new Map();
|
|
297
|
+
for (const [family, f] of Object.entries(CONNECTOR_FAMILIES))
|
|
298
|
+
for (const [action, tool] of Object.entries(f.actions)) out.set(tool, family + " {action: '" + action + "'}");
|
|
299
|
+
return out;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** a text with every fine family-member name said the connector's way @param {string} text */
|
|
303
|
+
export function sayFamilyNames(text) {
|
|
304
|
+
const names = familyNames();
|
|
305
|
+
return names.size ? String(text).replace(new RegExp('\\b(' + [...names.keys()].join('|') + ')\\b', 'g'), (m) => names.get(m) ?? m) : String(text);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The connector's view of the catalog: standalone tools as they are, family members replaced by their family
|
|
310
|
+
* (at the first member's place). Throws when a tool is in no list — the budget rule.
|
|
311
|
+
* @param {{name: string, title: string, description: string, inputSchema: any, annotations: Record<string, any>}[]} plain annotated, before guidance
|
|
312
|
+
* @param {string[]} excluded core's CONNECTOR_BLOCKED_TOOLS
|
|
313
|
+
*/
|
|
314
|
+
export function connectorView(plain, excluded) {
|
|
315
|
+
const byName = new Map(plain.map((t) => [t.name, t]));
|
|
316
|
+
const familyOf = new Map();
|
|
317
|
+
for (const [family, f] of Object.entries(CONNECTOR_FAMILIES)) for (const tool of Object.values(f.actions)) familyOf.set(tool, family);
|
|
318
|
+
const stray = plain.map((t) => t.name).filter((n) => !CONNECTOR_STANDALONE.includes(n) && !familyOf.has(n) && !excluded.includes(n));
|
|
319
|
+
if (stray.length)
|
|
320
|
+
throw new Error('tools with no place in the connector (tools/agent/src/catalog.js CONNECTOR_FAMILIES / CONNECTOR_STANDALONE / CONNECTOR_BLOCKED_TOOLS): ' + stray.join(', '));
|
|
321
|
+
/** @type {any[]} */
|
|
322
|
+
const list = [];
|
|
323
|
+
/** @type {Record<string, Record<string, string>>} */
|
|
324
|
+
const families = {};
|
|
325
|
+
let placed = false;
|
|
326
|
+
for (const t of plain) {
|
|
327
|
+
if (!familyOf.has(t.name)) {
|
|
328
|
+
list.push(t);
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (placed) continue;
|
|
332
|
+
// every family at the place of the first member, in the table's order
|
|
333
|
+
placed = true;
|
|
334
|
+
for (const [family, f] of Object.entries(CONNECTOR_FAMILIES)) {
|
|
335
|
+
const actions = Object.entries(f.actions).filter(([, tool]) => byName.has(tool));
|
|
336
|
+
if (!actions.length) continue;
|
|
337
|
+
families[family] = Object.fromEntries(actions);
|
|
338
|
+
list.push(familyTool(family, f, actions.map(([action, tool]) => [action, /** @type {any} */ (byName.get(tool))])));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const tools = withGuidance(list);
|
|
342
|
+
return { instructions: connectorInstructions(tools.map((t) => t.name)), families, tools };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* One family as one MCP tool. `{action, <action>: {...}}`; the per-action object has the fine tool's own schema.
|
|
347
|
+
* @param {string} family @param {{title: string, summary: string}} f @param {[string, any][]} actions
|
|
348
|
+
*/
|
|
349
|
+
function familyTool(family, f, actions) {
|
|
350
|
+
/** @type {Record<string, any>} */
|
|
351
|
+
const properties = {
|
|
352
|
+
action: { type: 'string', enum: actions.map(([a]) => a), description: 'What to do. Put its fields in the object named after the action.' }
|
|
353
|
+
};
|
|
354
|
+
for (const [action, t] of actions) properties[action] = { ...t.inputSchema, description: sayFamilyNames(t.description) };
|
|
355
|
+
const example = actions[0][0];
|
|
356
|
+
const description =
|
|
357
|
+
f.summary + '\nCall it as {"action": "' + example + '", "' + example + '": {…its fields…}}; each action\'s fields and limits are in its object below.';
|
|
358
|
+
const edits = actions.filter(([, t]) => !t.annotations.readOnlyHint);
|
|
359
|
+
const annotations = {
|
|
360
|
+
title: f.title,
|
|
361
|
+
readOnlyHint: false,
|
|
362
|
+
destructiveHint: edits.some(([, t]) => t.annotations.destructiveHint !== false),
|
|
363
|
+
openWorldHint: actions.some(([, t]) => t.annotations.openWorldHint === true)
|
|
364
|
+
};
|
|
365
|
+
return { name: family, title: f.title, description, inputSchema: { type: 'object', properties, required: ['action'] }, annotations };
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* The Worker's half, kept here so core's unit tests cover it with the same tables: a family call → the fine tool
|
|
370
|
+
* and its arguments. A missing per-action object falls back to the call's other fields (a model that flattened them).
|
|
371
|
+
* @param {Record<string, Record<string, string>>} families @param {string} name @param {any} args
|
|
372
|
+
* @returns {{tool: string, args: any} | {error: string} | null} null = not a family
|
|
373
|
+
*/
|
|
374
|
+
export function resolveFamilyCall(families, name, args) {
|
|
375
|
+
const actions = families?.[name];
|
|
376
|
+
if (!actions) return null;
|
|
377
|
+
const action = typeof args?.action === 'string' ? args.action : '';
|
|
378
|
+
const tool = actions[action];
|
|
379
|
+
if (!tool) return { error: name + ' needs an action: one of ' + Object.keys(actions).join(', ') + '.' };
|
|
380
|
+
const inner = args[action];
|
|
381
|
+
if (inner && typeof inner === 'object' && !Array.isArray(inner)) return { tool, args: inner };
|
|
382
|
+
const { action: _a, ...rest } = args;
|
|
383
|
+
for (const a of Object.keys(actions)) delete rest[a];
|
|
384
|
+
return { tool, args: rest };
|
|
385
|
+
}
|
|
386
|
+
|
|
186
387
|
/**
|
|
187
388
|
* mcp-fix: the tab's list and the catalog must agree. Fails on a tool a connector tab answers that the catalog neither
|
|
188
389
|
* lists nor leaves out on purpose, and on a listed tool no connector tab can answer. `tabTools` comes from a real
|