(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;
})
| 1597 | : Effect.void; |
| 1598 | |
| 1599 | const saveAndDeliverArtifact = (input: { |
| 1600 | readonly code: string; |
| 1601 | readonly title: string; |
| 1602 | readonly description?: string; |
| 1603 | readonly existingId?: string; |
| 1604 | readonly bindings?: Readonly<Record<string, ArtifactBinding>>; |
| 1605 | /** Sanitized layout markup from the smoke render, when it produced any. */ |
| 1606 | readonly preview?: string | null; |
| 1607 | }): Effect.Effect<McpToolResult, unknown> => |
| 1608 | Effect.gen(function* () { |
| 1609 | if (!artifacts) return artifactsUnavailableResult(); |
| 1610 | const saved = yield* artifacts.save({ |
| 1611 | ...(input.existingId === undefined ? {} : { id: input.existingId }), |
| 1612 | title: input.title, |
| 1613 | description: input.description ?? null, |
| 1614 | code: input.code, |
| 1615 | ...(input.bindings === undefined ? {} : { bindings: input.bindings }), |
| 1616 | preview: input.preview ?? null, |
| 1617 | }); |
| 1618 | yield* notifyArtifactUsage(input.existingId === undefined ? "created" : "updated"); |
| 1619 | // Resolve once and report the value actually used, so the span can |
| 1620 | // never disagree with what the client received. |
| 1621 | const delivered = deliverArtifact({ |
| 1622 | code: saved.code, |
| 1623 | artifactId: saved.id, |
| 1624 | title: saved.title, |
| 1625 | }); |
| 1626 | yield* Effect.annotateCurrentSpan({ |
| 1627 | "mcp.artifact.id": saved.id, |
| 1628 | "mcp.artifact.apps_enabled": appsEnabled, |
| 1629 | }); |
| 1630 | return delivered; |
| 1631 | }); |
| 1632 | |
| 1633 | /** |
| 1634 | * Whether the client can render an app, resolved at render time. |
no test coverage detected