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