(input: {
readonly code: string;
readonly available: readonly BindableConnection[];
readonly connections?: Record<string, string>;
readonly action: Record<string, unknown>;
readonly artifactIdOverride?: string;
})
| 1887 | /** Saves a bound artifact, then runs one call from it and reports both the |
| 1888 | * tool result and whatever code actually reached the engine. */ |
| 1889 | const runBoundAction = async (input: { |
| 1890 | readonly code: string; |
| 1891 | readonly available: readonly BindableConnection[]; |
| 1892 | readonly connections?: Record<string, string>; |
| 1893 | readonly action: Record<string, unknown>; |
| 1894 | readonly artifactIdOverride?: string; |
| 1895 | }) => { |
| 1896 | const store = makeArtifactStore(); |
| 1897 | const executed: string[] = []; |
| 1898 | const engine = makeStubEngine({ |
| 1899 | executeWithPause: (code: string) => |
| 1900 | Effect.sync(() => { |
| 1901 | executed.push(code); |
| 1902 | return { status: "completed", result: { result: "ok" } }; |
| 1903 | }), |
| 1904 | }); |
| 1905 | |
| 1906 | let result: Awaited<ReturnType<Client["callTool"]>> | undefined; |
| 1907 | await withClient( |
| 1908 | engine, |
| 1909 | APPS_CAPS, |
| 1910 | async (client) => { |
| 1911 | const created = await client.callTool({ |
| 1912 | name: "create-artifact", |
| 1913 | arguments: { |
| 1914 | code: input.code, |
| 1915 | title: "Bound", |
| 1916 | ...(input.connections === undefined ? {} : { connections: input.connections }), |
| 1917 | }, |
| 1918 | }); |
| 1919 | expect(created.isError, textOf(created)).toBeFalsy(); |
| 1920 | const artifactId = input.artifactIdOverride ?? String(structuredOf(created).artifactId); |
| 1921 | result = await client.callTool({ |
| 1922 | name: "execute-action", |
| 1923 | arguments: { ...input.action, artifactId }, |
| 1924 | }); |
| 1925 | }, |
| 1926 | { artifacts: store.port, connections: connectionsPort(input.available) }, |
| 1927 | ); |
| 1928 | return { result: result!, executed }; |
| 1929 | }; |
| 1930 | |
| 1931 | it("expands a short path through the artifact's binding", async () => { |
| 1932 | const { result, executed } = await runBoundAction({ |
no test coverage detected