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

Function editArtifact

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

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