MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / editArtifact

Function editArtifact

packages/hosts/mcp/src/tool-server.ts:1841–1873  ·  view source on GitHub ↗
(input: {
      readonly artifactId: string;
      readonly edits: readonly ArtifactEdit[];
      readonly title?: string;
      readonly description?: string;
      readonly connections?: Readonly<Record<string, string>>;
    })

Source from the content-addressed store, hash-verified

1839 * back here makes the retry immediate.
1840 */
1841 const editArtifact = (input: {
1842 readonly artifactId: string;
1843 readonly edits: readonly ArtifactEdit[];
1844 readonly title?: string;
1845 readonly description?: string;
1846 readonly connections?: Readonly<Record<string, string>>;
1847 }): Effect.Effect<McpToolResult, unknown> =>
1848 Effect.gen(function* () {
1849 // Same probe-proof refusal as create-artifact's update arm.
1850 const existing = yield* loadArtifact(input.artifactId);
1851 if (!existing) return actionArtifactUnavailableResult();
1852
1853 const applied = applyArtifactEdits(existing.code, input.edits);
1854 if (!applied.ok) return editRejectedResult(applied.message, existing.code);
1855
1856 yield* Effect.annotateCurrentSpan({
1857 "mcp.artifact.edit_count": input.edits.length,
1858 });
1859 return yield* validateRenderAndSave({
1860 code: applied.code,
1861 title: input.title ?? existing.title,
1862 description: input.description ?? existing.description ?? undefined,
1863 connections: input.connections,
1864 existing,
1865 });
1866 }).pipe(
1867 Effect.withSpan("mcp.host.tool.edit_artifact", {
1868 attributes: {
1869 "mcp.tool.name": "edit-artifact",
1870 "mcp.artifact.id": input.artifactId,
1871 },
1872 }),
1873 );
1874
1875 const listArtifacts = (): Effect.Effect<McpToolResult, unknown> =>
1876 Effect.gen(function* () {

Callers 1

createExecutorMcpServerFunction · 0.85

Calls 5

applyArtifactEditsFunction · 0.90
loadArtifactFunction · 0.85
editRejectedResultFunction · 0.85
validateRenderAndSaveFunction · 0.85

Tested by

no test coverage detected