(input: {
readonly code: string;
readonly title: string;
readonly description?: string;
readonly existingId?: string;
readonly bindings?: Readonly<Record<string, ArtifactBinding>>;
/** Sanitized layout markup from the smoke render, when it produced any. */
readonly preview?: string | null;
})
| 1713 | : Effect.void; |
| 1714 | |
| 1715 | const saveAndDeliverArtifact = (input: { |
| 1716 | readonly code: string; |
| 1717 | readonly title: string; |
| 1718 | readonly description?: string; |
| 1719 | readonly existingId?: string; |
| 1720 | readonly bindings?: Readonly<Record<string, ArtifactBinding>>; |
| 1721 | /** Sanitized layout markup from the smoke render, when it produced any. */ |
| 1722 | readonly preview?: string | null; |
| 1723 | }): Effect.Effect<McpToolResult, unknown> => |
| 1724 | Effect.gen(function* () { |
| 1725 | if (!artifacts) return artifactsUnavailableResult(); |
| 1726 | const saved = yield* artifacts.save({ |
| 1727 | ...(input.existingId === undefined ? {} : { id: input.existingId }), |
| 1728 | title: input.title, |
| 1729 | description: input.description ?? null, |
| 1730 | code: input.code, |
| 1731 | ...(input.bindings === undefined ? {} : { bindings: input.bindings }), |
| 1732 | preview: input.preview ?? null, |
| 1733 | }); |
| 1734 | yield* notifyArtifactUsage(input.existingId === undefined ? "created" : "updated"); |
| 1735 | // Resolve once and report the value actually used, so the span can |
| 1736 | // never disagree with what the client received. |
| 1737 | const delivered = deliverArtifact({ |
| 1738 | code: saved.code, |
| 1739 | artifactId: saved.id, |
| 1740 | title: saved.title, |
| 1741 | }); |
| 1742 | yield* Effect.annotateCurrentSpan({ |
| 1743 | "mcp.artifact.id": saved.id, |
| 1744 | "mcp.artifact.apps_enabled": appsEnabled, |
| 1745 | }); |
| 1746 | return delivered; |
| 1747 | }); |
| 1748 | |
| 1749 | /** |
| 1750 | * Whether the client can render an app, resolved at render time. |
no test coverage detected