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

Function editArtifact

packages/hosts/mcp/src/tool-server.ts:1878–1910  ·  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

1876 * back here makes the retry immediate.
1877 */
1878 const editArtifact = (input: {
1879 readonly artifactId: string;
1880 readonly edits: readonly ArtifactEdit[];
1881 readonly title?: string;
1882 readonly description?: string;
1883 readonly connections?: Readonly<Record<string, string>>;
1884 }): Effect.Effect<McpToolResult, unknown> =>
1885 Effect.gen(function* () {
1886 // Same probe-proof refusal as create-artifact's update arm.
1887 const existing = yield* loadArtifact(input.artifactId);
1888 if (!existing) return actionArtifactUnavailableResult();
1889
1890 const applied = applyArtifactEdits(existing.code, input.edits);
1891 if (!applied.ok) return editRejectedResult(applied.message, existing.code);
1892
1893 yield* Effect.annotateCurrentSpan({
1894 "mcp.artifact.edit_count": input.edits.length,
1895 });
1896 return yield* validateRenderAndSave({
1897 code: applied.code,
1898 title: input.title ?? existing.title,
1899 description: input.description ?? existing.description ?? undefined,
1900 connections: input.connections,
1901 existing,
1902 });
1903 }).pipe(
1904 Effect.withSpan("mcp.host.tool.edit_artifact", {
1905 attributes: {
1906 "mcp.tool.name": "edit-artifact",
1907 "mcp.artifact.id": input.artifactId,
1908 },
1909 }),
1910 );
1911
1912 const listArtifacts = (): Effect.Effect<McpToolResult, unknown> =>
1913 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