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

Function runBoundAction

packages/hosts/mcp/src/artifacts-tools.test.ts:2231–2271  ·  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

2229 /** Saves a bound artifact, then runs one call from it and reports both the
2230 * tool result and whatever code actually reached the engine. */
2231 const runBoundAction = async (input: {
2232 readonly code: string;
2233 readonly available: readonly BindableConnection[];
2234 readonly connections?: Record<string, string>;
2235 readonly action: Record<string, unknown>;
2236 readonly artifactIdOverride?: string;
2237 }) => {
2238 const store = makeArtifactStore();
2239 const executed: string[] = [];
2240 const engine = makeStubEngine({
2241 executeWithPause: (code: string) =>
2242 Effect.sync(() => {
2243 executed.push(code);
2244 return { status: "completed", result: { result: "ok" } };
2245 }),
2246 });
2247
2248 let result: Awaited<ReturnType<Client["callTool"]>> | undefined;
2249 await withClient(
2250 engine,
2251 APPS_CAPS,
2252 async (client) => {
2253 const created = await client.callTool({
2254 name: "create-artifact",
2255 arguments: {
2256 code: input.code,
2257 title: "Bound",
2258 ...(input.connections === undefined ? {} : { connections: input.connections }),
2259 },
2260 });
2261 expect(created.isError, textOf(created)).toBeFalsy();
2262 const artifactId = input.artifactIdOverride ?? String(structuredOf(created).artifactId);
2263 result = await client.callTool({
2264 name: "execute-action",
2265 arguments: { ...input.action, artifactId },
2266 });
2267 },
2268 { artifacts: store.port, connections: connectionsPort(input.available) },
2269 );
2270 return { result: result!, executed };
2271 };
2272
2273 it("expands a short path through the artifact's binding", async () => {
2274 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