(args: z.infer<typeof CreateArgs>, ctx: ToolContext)
| 49 | description = 'Create a new versioned artifact (a self-contained web page, React component, SVG, or doc the user will keep and iterate on). Returns the artifact id. Prefer this over dumping a large standalone file into chat.'; |
| 50 | argsSchema = CreateArgs; |
| 51 | isReadOnly = false; |
| 52 | isDestructive = false; |
| 53 | |
| 54 | async execute(args: z.infer<typeof CreateArgs>, ctx: ToolContext): Promise<ToolResult> { |
| 55 | if (!isArtifactType(args.type)) { |
| 56 | return { content: `Invalid artifact type "${args.type}". Use one of: ${TYPE_VALUES.join(', ')}.`, isError: true }; |
| 57 | } |
| 58 | const { manifest, absFile } = await createArtifact( |
| 59 | ctx.cwd, |
| 60 | { title: args.title, type: args.type as ArtifactType, content: args.content, note: args.note }, |
| 61 | (p, c) => ctx.transaction.write(p, c), |
| 62 | ); |
| 63 | ctx.emit({ type: 'progress', message: `Created artifact "${manifest.id}" (v1)` }); |
| 64 | return { |
| 65 | content: `Created artifact "${manifest.id}" (${manifest.type}, v1) at ${absFile}. Use artifact_update with id="${manifest.id}" to revise it.`, |
| 66 | metadata: { artifactId: manifest.id, version: 1, type: manifest.type, path: absFile }, |
| 67 | }; |
| 68 | } |
nothing calls this directly
no test coverage detected