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

Function runBoundAction

packages/hosts/mcp/src/artifacts-tools.test.ts:2183–2223  ·  view source on GitHub ↗
(input: {
    readonly code: string;
    readonly available: readonly BindableConnection[];
    readonly connections?: Record<string, string>;
    readonly action: Record<string, unknown>;
    readonly artifactIdOverride?: string;
  })

Source from the content-addressed store, hash-verified

2181 /** Saves a bound artifact, then runs one call from it and reports both the
2182 * tool result and whatever code actually reached the engine. */
2183 const runBoundAction = async (input: {
2184 readonly code: string;
2185 readonly available: readonly BindableConnection[];
2186 readonly connections?: Record<string, string>;
2187 readonly action: Record<string, unknown>;
2188 readonly artifactIdOverride?: string;
2189 }) => {
2190 const store = makeArtifactStore();
2191 const executed: string[] = [];
2192 const engine = makeStubEngine({
2193 executeWithPause: (code: string) =>
2194 Effect.sync(() => {
2195 executed.push(code);
2196 return { status: "completed", result: { result: "ok" } };
2197 }),
2198 });
2199
2200 let result: Awaited<ReturnType<Client["callTool"]>> | undefined;
2201 await withClient(
2202 engine,
2203 APPS_CAPS,
2204 async (client) => {
2205 const created = await client.callTool({
2206 name: "create-artifact",
2207 arguments: {
2208 code: input.code,
2209 title: "Bound",
2210 ...(input.connections === undefined ? {} : { connections: input.connections }),
2211 },
2212 });
2213 expect(created.isError, textOf(created)).toBeFalsy();
2214 const artifactId = input.artifactIdOverride ?? String(structuredOf(created).artifactId);
2215 result = await client.callTool({
2216 name: "execute-action",
2217 arguments: { ...input.action, artifactId },
2218 });
2219 },
2220 { artifacts: store.port, connections: connectionsPort(input.available) },
2221 );
2222 return { result: result!, executed };
2223 };
2224
2225 it("expands a short path through the artifact's binding", async () => {
2226 const { result, executed } = await runBoundAction({

Callers 1

Calls 8

makeArtifactStoreFunction · 0.85
connectionsPortFunction · 0.85
pushMethod · 0.80
makeStubEngineFunction · 0.70
withClientFunction · 0.70
textOfFunction · 0.70
structuredOfFunction · 0.70
syncMethod · 0.65

Tested by

no test coverage detected