diff --git a/.changeset/gorgeous-bats-explain.md b/.changeset/gorgeous-bats-explain.md new file mode 100644 index 0000000..e8cab43 --- /dev/null +++ b/.changeset/gorgeous-bats-explain.md @@ -0,0 +1,5 @@ +--- +"@statelyai/agent": patch +--- + +Simplify API (WIP) diff --git a/.changeset/pretty-fishes-shake.md b/.changeset/pretty-fishes-shake.md new file mode 100644 index 0000000..8444e54 --- /dev/null +++ b/.changeset/pretty-fishes-shake.md @@ -0,0 +1,5 @@ +--- +'@statelyai/agent': patch +--- + +Add `createSchemas`, `createOpenAIAdapter`, and change `createAgent` diff --git a/.gitignore b/.gitignore index c6bba59..381cdbc 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,5 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +.vscode/settings.json diff --git a/examples/helpers/helpers.ts b/examples/helpers/helpers.ts index 218d4c1..6fbab5c 100644 --- a/examples/helpers/helpers.ts +++ b/examples/helpers/helpers.ts @@ -3,7 +3,7 @@ import { fromPromise } from 'xstate'; export const getFromTerminal = fromPromise( async ({ input }) => { const topic = await new Promise((res) => { - console.log(input); + console.log(input + '\n'); const listener = (data: Buffer) => { const result = data.toString().trim(); process.stdin.off('data', listener); diff --git a/examples/joke.ts b/examples/joke.ts index 1f64520..464776a 100644 --- a/examples/joke.ts +++ b/examples/joke.ts @@ -1,21 +1,13 @@ import OpenAI from 'openai'; -import { - assign, - createActor, - fromCallback, - fromPromise, - log, - setup, -} from 'xstate'; -import { createAgent } from '../src'; +import { assign, fromCallback, fromPromise, log, setup } from 'xstate'; +import { createAgent, createOpenAIAdapter, createSchemas } from '../src'; import { loadingAnimation } from './helpers/loader'; const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); -const agent = createAgent(openai, { - model: 'gpt-3.5-turbo-1106', +const schemas = createSchemas({ context: { topic: { type: 'string' }, jokes: { @@ -23,18 +15,35 @@ const agent = createAgent(openai, { items: { type: 'string', }, - desire: { type: ['string', 'null'] }, - lastRating: { type: ['string', 'null'] }, + }, + desire: { type: ['string', 'null'] as const }, + lastRating: { type: ['string', 'null'] as const }, + }, + events: { + askForTopic: { + type: 'object', + properties: { + topic: { + type: 'string', + }, + }, + }, + endJokes: { + type: 'object', + properties: {}, }, }, - events: {}, }); -const getJokeCompletion = agent.fromChatCompletion( +const adapter = createOpenAIAdapter(openai, { + model: 'gpt-3.5-turbo-1106', +}); + +const getJokeCompletion = adapter.fromChat( (topic: string) => `Tell me a joke about ${topic}.` ); -const rateJoke = agent.fromChatCompletion( +const rateJoke = adapter.fromChat( (joke: string) => `Rate this joke on a scale of 1 to 10: ${joke}` ); @@ -52,7 +61,7 @@ const getTopic = fromPromise(async () => { return topic; }); -const decide = agent.fromEvent( +const decide = adapter.fromEventChoice( (lastRating: string) => `Choose what to do next, given the previous rating of the joke: ${lastRating}` ); @@ -96,15 +105,8 @@ const loader = fromCallback(({ input }: { input: string }) => { }); const jokeMachine = setup({ - types: { - context: {} as { - topic: string; - jokes: string[]; - desire: string | null; - lastRating: string | null; - }, - input: {} as { topic: string }, - }, + schemas, + types: schemas.types, actors: { getJokeCompletion, getTopic, @@ -146,7 +148,7 @@ const jokeMachine = setup({ event.output.choices[0]!.message.content! ), }), - log((x) => x.context.jokes.at(-1)), + log((x) => `\n` + x.context.jokes.at(-1)), ], target: 'rateJoke', }, @@ -168,7 +170,7 @@ const jokeMachine = setup({ lastRating: ({ event }) => event.output.choices[0]!.message.content!, }), - log(({ context }) => context.lastRating), + log(({ context }) => '\n' + context.lastRating), ], target: 'decide', }, @@ -210,5 +212,5 @@ const jokeMachine = setup({ }, }); -const actor = createActor(jokeMachine); -actor.start(); +const agent = createAgent(jokeMachine); +agent.start(); diff --git a/examples/multiAgentCollaboration.ts b/examples/multiAgentCollaboration.ts new file mode 100644 index 0000000..e69de29 diff --git a/examples/ticTacToe.ts b/examples/ticTacToe.ts index 68450df..b0133f2 100644 --- a/examples/ticTacToe.ts +++ b/examples/ticTacToe.ts @@ -1,6 +1,6 @@ -import { assign, setup, assertEvent, createActor } from 'xstate'; +import { assign, setup, assertEvent } from 'xstate'; import OpenAI from 'openai'; -import { createAgent } from '../src/openai'; +import { createOpenAIAdapter, createSchemas, createAgent } from '../src'; const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, @@ -8,8 +8,7 @@ const openai = new OpenAI({ type Player = 'x' | 'o'; -const agent = createAgent(openai, { - model: 'gpt-4-1106-preview', +const schemas = createSchemas({ context: { board: { type: 'array', @@ -69,16 +68,20 @@ const agent = createAgent(openai, { }, }); +const adapter = createOpenAIAdapter(openai, { + model: 'gpt-4-1106-preview', +}); + const initialContext = { board: Array(9).fill(null) as Array, moves: 0, player: 'x' as Player, gameReport: '', events: [], -} satisfies typeof agent.types.context; +} satisfies typeof schemas.types.context; -const bot = agent.fromEvent( - ({ context }: { context: typeof agent.types.context }) => ` +const bot = adapter.fromEventChoice( + ({ context }: { context: typeof schemas.types.context }) => ` You are playing a game of tic tac toe. This is the current game state. The 3x3 board is represented by a 9-element array. The first element is the top-left cell, the second element is the top-middle cell, the third element is the top-right cell, the fourth element is the middle-left cell, and so on. The value of each cell is either null, x, or o. The value of null means that the cell is empty. The value of x means that the cell is occupied by an x. The value of o means that the cell is occupied by an o. ${JSON.stringify(context, null, 2)} @@ -86,11 +89,11 @@ ${JSON.stringify(context, null, 2)} Execute the single best next move to try to win the game. Do not play on an existing cell.` ); -const gameReporter = agent.fromChatCompletionStream( +const gameReporter = adapter.fromChatStream( ({ context, }: { - context: typeof agent.types.context; + context: typeof schemas.types.context; }) => `Here is the game board: ${JSON.stringify(context.board, null, 2)} @@ -124,7 +127,8 @@ function getWinner(board: typeof initialContext.board): Player | null { } export const ticTacToeMachine = setup({ - types: agent.types, + schemas, + types: schemas.types, actors: { bot, gameReporter, @@ -248,14 +252,8 @@ export const ticTacToeMachine = setup({ }, }); -const actor = createActor(ticTacToeMachine, { - inspect: (e) => { - if (e.type === '@xstate.event') { - console.log(e.event); - } - }, -}); -actor.subscribe((s) => { +const agent = createAgent(ticTacToeMachine); +agent.subscribe((s) => { console.log(s.value, s.context); }); -actor.start(); +agent.start(); diff --git a/examples/weather.ts b/examples/weather.ts index 37dd792..5f204d3 100644 --- a/examples/weather.ts +++ b/examples/weather.ts @@ -1,6 +1,6 @@ import OpenAI from 'openai'; -import { createAgent, fromEventChoice } from '../src'; -import { assign, createActor, fromPromise, log, setup } from 'xstate'; +import { createAgent, createOpenAIAdapter, createSchemas } from '../src'; +import { assign, fromPromise, log, setup } from 'xstate'; import { getFromTerminal } from './helpers/helpers'; async function searchTavily( @@ -23,6 +23,7 @@ async function searchTavily( }, body: JSON.stringify(body), }); + const json = await response.json(); if (!response.ok) { throw new Error( @@ -39,8 +40,7 @@ const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); -const agent = createAgent(openai, { - model: 'gpt-4-1106-preview', +const schemas = createSchemas({ context: { location: { type: 'string' }, history: { type: 'array', items: { type: 'string' } }, @@ -64,17 +64,27 @@ const agent = createAgent(openai, { }, }); +const adapter = createOpenAIAdapter(openai, { + model: 'gpt-4-1106-preview', +}); + +const getWeather = fromPromise(async ({ input }: { input: string }) => { + const results = await searchTavily( + `Get the weather for this location: ${input}`, + { + maxResults: 5, + apiKey: process.env.TAVILY_API_KEY!, + } + ); + return results; +}); + const machine = setup({ - types: agent.types, + schemas, + types: schemas.types, actors: { - searchTavily: fromPromise(async ({ input }: { input: string }) => { - const results = await searchTavily(input, { - maxResults: 5, - apiKey: process.env.TAVILY_API_KEY!, - }); - return results; - }), - decide: agent.fromEvent( + getWeather, + decide: adapter.fromEventChoice( (input: string) => `Decide what to do based on the given input, which may or may not be a location: ${input}` ), @@ -121,9 +131,8 @@ const machine = setup({ gettingWeather: { entry: log('Getting weather...'), invoke: { - src: 'searchTavily', - input: ({ context }) => - `Get the weather for this location: ${context.location}`, + src: 'getWeather', + input: ({ context }) => context.location, onDone: { actions: [ log(({ event }) => event.output), @@ -144,4 +153,8 @@ const machine = setup({ }, }); -createActor(machine).start(); +createAgent(machine, { + input: { + location: 'New York', + }, +}).start(); diff --git a/package.json b/package.json index 5e600a1..5a4d87e 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "access": "public" }, "dependencies": { - "xstate": "^5.5.1" + "xstate": "^5.6.0" }, "packageManager": "pnpm@8.11.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9c3533..382007b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,13 +1,9 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - dependencies: xstate: - specifier: ^5.5.1 - version: 5.5.1 + specifier: ^5.6.0 + version: registry.npmjs.org/xstate@5.6.0 devDependencies: '@changesets/changelog-github': @@ -278,213 +274,6 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: true - /@esbuild/aix-ppc64@0.19.10: - resolution: {integrity: sha512-Q+mk96KJ+FZ30h9fsJl+67IjNJm3x2eX+GBWGmocAKgzp27cowCOOqSdscX80s0SpdFXZnIv/+1xD1EctFx96Q==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [aix] - requiresBuild: true - dev: true - optional: true - - /@esbuild/android-arm64@0.19.10: - resolution: {integrity: sha512-1X4CClKhDgC3by7k8aOWZeBXQX8dHT5QAMCAQDArCLaYfkppoARvh0fit3X2Qs+MXDngKcHv6XXyQCpY0hkK1Q==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@esbuild/android-arm@0.19.10: - resolution: {integrity: sha512-7W0bK7qfkw1fc2viBfrtAEkDKHatYfHzr/jKAHNr9BvkYDXPcC6bodtm8AyLJNNuqClLNaeTLuwURt4PRT9d7w==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@esbuild/android-x64@0.19.10: - resolution: {integrity: sha512-O/nO/g+/7NlitUxETkUv/IvADKuZXyH4BHf/g/7laqKC4i/7whLpB0gvpPc2zpF0q9Q6FXS3TS75QHac9MvVWw==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@esbuild/darwin-arm64@0.19.10: - resolution: {integrity: sha512-YSRRs2zOpwypck+6GL3wGXx2gNP7DXzetmo5pHXLrY/VIMsS59yKfjPizQ4lLt5vEI80M41gjm2BxrGZ5U+VMA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@esbuild/darwin-x64@0.19.10: - resolution: {integrity: sha512-alfGtT+IEICKtNE54hbvPg13xGBe4GkVxyGWtzr+yHO7HIiRJppPDhOKq3zstTcVf8msXb/t4eavW3jCDpMSmA==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@esbuild/freebsd-arm64@0.19.10: - resolution: {integrity: sha512-dMtk1wc7FSH8CCkE854GyGuNKCewlh+7heYP/sclpOG6Cectzk14qdUIY5CrKDbkA/OczXq9WesqnPl09mj5dg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/freebsd-x64@0.19.10: - resolution: {integrity: sha512-G5UPPspryHu1T3uX8WiOEUa6q6OlQh6gNl4CO4Iw5PS+Kg5bVggVFehzXBJY6X6RSOMS8iXDv2330VzaObm4Ag==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-arm64@0.19.10: - resolution: {integrity: sha512-QxaouHWZ+2KWEj7cGJmvTIHVALfhpGxo3WLmlYfJ+dA5fJB6lDEIg+oe/0//FuyVHuS3l79/wyBxbHr0NgtxJQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-arm@0.19.10: - resolution: {integrity: sha512-j6gUW5aAaPgD416Hk9FHxn27On28H4eVI9rJ4az7oCGTFW48+LcgNDBN+9f8rKZz7EEowo889CPKyeaD0iw9Kg==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-ia32@0.19.10: - resolution: {integrity: sha512-4ub1YwXxYjj9h1UIZs2hYbnTZBtenPw5NfXCRgEkGb0b6OJ2gpkMvDqRDYIDRjRdWSe/TBiZltm3Y3Q8SN1xNg==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-loong64@0.19.10: - resolution: {integrity: sha512-lo3I9k+mbEKoxtoIbM0yC/MZ1i2wM0cIeOejlVdZ3D86LAcFXFRdeuZmh91QJvUTW51bOK5W2BznGNIl4+mDaA==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-mips64el@0.19.10: - resolution: {integrity: sha512-J4gH3zhHNbdZN0Bcr1QUGVNkHTdpijgx5VMxeetSk6ntdt+vR1DqGmHxQYHRmNb77tP6GVvD+K0NyO4xjd7y4A==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-ppc64@0.19.10: - resolution: {integrity: sha512-tgT/7u+QhV6ge8wFMzaklOY7KqiyitgT1AUHMApau32ZlvTB/+efeCtMk4eXS+uEymYK249JsoiklZN64xt6oQ==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-riscv64@0.19.10: - resolution: {integrity: sha512-0f/spw0PfBMZBNqtKe5FLzBDGo0SKZKvMl5PHYQr3+eiSscfJ96XEknCe+JoOayybWUFQbcJTrk946i3j9uYZA==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-s390x@0.19.10: - resolution: {integrity: sha512-pZFe0OeskMHzHa9U38g+z8Yx5FNCLFtUnJtQMpwhS+r4S566aK2ci3t4NCP4tjt6d5j5uo4h7tExZMjeKoehAA==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-x64@0.19.10: - resolution: {integrity: sha512-SpYNEqg/6pZYoc+1zLCjVOYvxfZVZj6w0KROZ3Fje/QrM3nfvT2llI+wmKSrWuX6wmZeTapbarvuNNK/qepSgA==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/netbsd-x64@0.19.10: - resolution: {integrity: sha512-ACbZ0vXy9zksNArWlk2c38NdKg25+L9pr/mVaj9SUq6lHZu/35nx2xnQVRGLrC1KKQqJKRIB0q8GspiHI3J80Q==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/openbsd-x64@0.19.10: - resolution: {integrity: sha512-PxcgvjdSjtgPMiPQrM3pwSaG4kGphP+bLSb+cihuP0LYdZv1epbAIecHVl5sD3npkfYBZ0ZnOjR878I7MdJDFg==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/sunos-x64@0.19.10: - resolution: {integrity: sha512-ZkIOtrRL8SEJjr+VHjmW0znkPs+oJXhlJbNwfI37rvgeMtk3sxOQevXPXjmAPZPigVTncvFqLMd+uV0IBSEzqA==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - - /@esbuild/win32-arm64@0.19.10: - resolution: {integrity: sha512-+Sa4oTDbpBfGpl3Hn3XiUe4f8TU2JF7aX8cOfqFYMMjXp6ma6NJDztl5FDG8Ezx0OjwGikIHw+iA54YLDNNVfw==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@esbuild/win32-ia32@0.19.10: - resolution: {integrity: sha512-EOGVLK1oWMBXgfttJdPHDTiivYSjX6jDNaATeNOaCOFEVcfMjtbx7WVQwPSE1eIfCp/CaSF2nSrDtzc4I9f8TQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@esbuild/win32-x64@0.19.10: - resolution: {integrity: sha512-whqLG6Sc70AbU73fFYvuYzaE4MNMBIlR1Y/IrUeOXFrWHxBEjjbZaQ3IXIQS8wJdAzue2GwYZCjOrgrU1oUHoA==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@jridgewell/gen-mapping@0.3.3: resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} engines: {node: '>=6.0.0'} @@ -563,110 +352,6 @@ packages: fastq: 1.16.0 dev: true - /@rollup/rollup-android-arm-eabi@4.9.1: - resolution: {integrity: sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig==} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-android-arm64@4.9.1: - resolution: {integrity: sha512-Jto9Fl3YQ9OLsTDWtLFPtaIMSL2kwGyGoVCmPC8Gxvym9TCZm4Sie+cVeblPO66YZsYH8MhBKDMGZ2NDxuk/XQ==} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-darwin-arm64@4.9.1: - resolution: {integrity: sha512-LtYcLNM+bhsaKAIGwVkh5IOWhaZhjTfNOkGzGqdHvhiCUVuJDalvDxEdSnhFzAn+g23wgsycmZk1vbnaibZwwA==} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-darwin-x64@4.9.1: - resolution: {integrity: sha512-KyP/byeXu9V+etKO6Lw3E4tW4QdcnzDG/ake031mg42lob5tN+5qfr+lkcT/SGZaH2PdW4Z1NX9GHEkZ8xV7og==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-arm-gnueabihf@4.9.1: - resolution: {integrity: sha512-Yqz/Doumf3QTKplwGNrCHe/B2p9xqDghBZSlAY0/hU6ikuDVQuOUIpDP/YcmoT+447tsZTmirmjgG3znvSCR0Q==} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-arm64-gnu@4.9.1: - resolution: {integrity: sha512-u3XkZVvxcvlAOlQJ3UsD1rFvLWqu4Ef/Ggl40WAVCuogf4S1nJPHh5RTgqYFpCOvuGJ7H5yGHabjFKEZGExk5Q==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-arm64-musl@4.9.1: - resolution: {integrity: sha512-0XSYN/rfWShW+i+qjZ0phc6vZ7UWI8XWNz4E/l+6edFt+FxoEghrJHjX1EY/kcUGCnZzYYRCl31SNdfOi450Aw==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-riscv64-gnu@4.9.1: - resolution: {integrity: sha512-LmYIO65oZVfFt9t6cpYkbC4d5lKHLYv5B4CSHRpnANq0VZUQXGcCPXHzbCXCz4RQnx7jvlYB1ISVNCE/omz5cw==} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-x64-gnu@4.9.1: - resolution: {integrity: sha512-kr8rEPQ6ns/Lmr/hiw8sEVj9aa07gh1/tQF2Y5HrNCCEPiCBGnBUt9tVusrcBBiJfIt1yNaXN6r1CCmpbFEDpg==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-x64-musl@4.9.1: - resolution: {integrity: sha512-t4QSR7gN+OEZLG0MiCgPqMWZGwmeHhsM4AkegJ0Kiy6TnJ9vZ8dEIwHw1LcZKhbHxTY32hp9eVCMdR3/I8MGRw==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-win32-arm64-msvc@4.9.1: - resolution: {integrity: sha512-7XI4ZCBN34cb+BH557FJPmh0kmNz2c25SCQeT9OiFWEgf8+dL6ZwJ8f9RnUIit+j01u07Yvrsuu1rZGxJCc51g==} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-win32-ia32-msvc@4.9.1: - resolution: {integrity: sha512-yE5c2j1lSWOH5jp+Q0qNL3Mdhr8WuqCNVjc6BxbVfS5cAS6zRmdiw7ktb8GNpDCEUJphILY6KACoFoRtKoqNQg==} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-win32-x64-msvc@4.9.1: - resolution: {integrity: sha512-PyJsSsafjmIhVgaI1Zdj7m8BB8mMckFah/xbpplObyHfiXzKcI5UOUXRyOdHW7nz4DpMCuzLnF7v5IWHenCwYA==} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@tsconfig/node10@1.0.9: resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} dev: true @@ -956,7 +641,7 @@ packages: normalize-path: 3.0.0 readdirp: 3.6.0 optionalDependencies: - fsevents: 2.3.3 + fsevents: registry.npmjs.org/fsevents@2.3.3 dev: true /ci-info@3.9.0: @@ -1255,29 +940,29 @@ packages: hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/aix-ppc64': 0.19.10 - '@esbuild/android-arm': 0.19.10 - '@esbuild/android-arm64': 0.19.10 - '@esbuild/android-x64': 0.19.10 - '@esbuild/darwin-arm64': 0.19.10 - '@esbuild/darwin-x64': 0.19.10 - '@esbuild/freebsd-arm64': 0.19.10 - '@esbuild/freebsd-x64': 0.19.10 - '@esbuild/linux-arm': 0.19.10 - '@esbuild/linux-arm64': 0.19.10 - '@esbuild/linux-ia32': 0.19.10 - '@esbuild/linux-loong64': 0.19.10 - '@esbuild/linux-mips64el': 0.19.10 - '@esbuild/linux-ppc64': 0.19.10 - '@esbuild/linux-riscv64': 0.19.10 - '@esbuild/linux-s390x': 0.19.10 - '@esbuild/linux-x64': 0.19.10 - '@esbuild/netbsd-x64': 0.19.10 - '@esbuild/openbsd-x64': 0.19.10 - '@esbuild/sunos-x64': 0.19.10 - '@esbuild/win32-arm64': 0.19.10 - '@esbuild/win32-ia32': 0.19.10 - '@esbuild/win32-x64': 0.19.10 + '@esbuild/aix-ppc64': registry.npmjs.org/@esbuild/aix-ppc64@0.19.10 + '@esbuild/android-arm': registry.npmjs.org/@esbuild/android-arm@0.19.10 + '@esbuild/android-arm64': registry.npmjs.org/@esbuild/android-arm64@0.19.10 + '@esbuild/android-x64': registry.npmjs.org/@esbuild/android-x64@0.19.10 + '@esbuild/darwin-arm64': registry.npmjs.org/@esbuild/darwin-arm64@0.19.10 + '@esbuild/darwin-x64': registry.npmjs.org/@esbuild/darwin-x64@0.19.10 + '@esbuild/freebsd-arm64': registry.npmjs.org/@esbuild/freebsd-arm64@0.19.10 + '@esbuild/freebsd-x64': registry.npmjs.org/@esbuild/freebsd-x64@0.19.10 + '@esbuild/linux-arm': registry.npmjs.org/@esbuild/linux-arm@0.19.10 + '@esbuild/linux-arm64': registry.npmjs.org/@esbuild/linux-arm64@0.19.10 + '@esbuild/linux-ia32': registry.npmjs.org/@esbuild/linux-ia32@0.19.10 + '@esbuild/linux-loong64': registry.npmjs.org/@esbuild/linux-loong64@0.19.10 + '@esbuild/linux-mips64el': registry.npmjs.org/@esbuild/linux-mips64el@0.19.10 + '@esbuild/linux-ppc64': registry.npmjs.org/@esbuild/linux-ppc64@0.19.10 + '@esbuild/linux-riscv64': registry.npmjs.org/@esbuild/linux-riscv64@0.19.10 + '@esbuild/linux-s390x': registry.npmjs.org/@esbuild/linux-s390x@0.19.10 + '@esbuild/linux-x64': registry.npmjs.org/@esbuild/linux-x64@0.19.10 + '@esbuild/netbsd-x64': registry.npmjs.org/@esbuild/netbsd-x64@0.19.10 + '@esbuild/openbsd-x64': registry.npmjs.org/@esbuild/openbsd-x64@0.19.10 + '@esbuild/sunos-x64': registry.npmjs.org/@esbuild/sunos-x64@0.19.10 + '@esbuild/win32-arm64': registry.npmjs.org/@esbuild/win32-arm64@0.19.10 + '@esbuild/win32-ia32': registry.npmjs.org/@esbuild/win32-ia32@0.19.10 + '@esbuild/win32-x64': registry.npmjs.org/@esbuild/win32-x64@0.19.10 dev: true /escalade@3.1.1: @@ -1425,14 +1110,6 @@ packages: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true - /fsevents@2.3.3: - resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - dev: true - optional: true - /function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} dev: true @@ -1827,7 +1504,7 @@ packages: /jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} optionalDependencies: - graceful-fs: 4.2.11 + graceful-fs: registry.npmjs.org/graceful-fs@4.2.11 dev: true /kind-of@6.0.3: @@ -2353,20 +2030,20 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.9.1 - '@rollup/rollup-android-arm64': 4.9.1 - '@rollup/rollup-darwin-arm64': 4.9.1 - '@rollup/rollup-darwin-x64': 4.9.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.9.1 - '@rollup/rollup-linux-arm64-gnu': 4.9.1 - '@rollup/rollup-linux-arm64-musl': 4.9.1 - '@rollup/rollup-linux-riscv64-gnu': 4.9.1 - '@rollup/rollup-linux-x64-gnu': 4.9.1 - '@rollup/rollup-linux-x64-musl': 4.9.1 - '@rollup/rollup-win32-arm64-msvc': 4.9.1 - '@rollup/rollup-win32-ia32-msvc': 4.9.1 - '@rollup/rollup-win32-x64-msvc': 4.9.1 - fsevents: 2.3.3 + '@rollup/rollup-android-arm-eabi': registry.npmjs.org/@rollup/rollup-android-arm-eabi@4.9.1 + '@rollup/rollup-android-arm64': registry.npmjs.org/@rollup/rollup-android-arm64@4.9.1 + '@rollup/rollup-darwin-arm64': registry.npmjs.org/@rollup/rollup-darwin-arm64@4.9.1 + '@rollup/rollup-darwin-x64': registry.npmjs.org/@rollup/rollup-darwin-x64@4.9.1 + '@rollup/rollup-linux-arm-gnueabihf': registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf@4.9.1 + '@rollup/rollup-linux-arm64-gnu': registry.npmjs.org/@rollup/rollup-linux-arm64-gnu@4.9.1 + '@rollup/rollup-linux-arm64-musl': registry.npmjs.org/@rollup/rollup-linux-arm64-musl@4.9.1 + '@rollup/rollup-linux-riscv64-gnu': registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu@4.9.1 + '@rollup/rollup-linux-x64-gnu': registry.npmjs.org/@rollup/rollup-linux-x64-gnu@4.9.1 + '@rollup/rollup-linux-x64-musl': registry.npmjs.org/@rollup/rollup-linux-x64-musl@4.9.1 + '@rollup/rollup-win32-arm64-msvc': registry.npmjs.org/@rollup/rollup-win32-arm64-msvc@4.9.1 + '@rollup/rollup-win32-ia32-msvc': registry.npmjs.org/@rollup/rollup-win32-ia32-msvc@4.9.1 + '@rollup/rollup-win32-x64-msvc': registry.npmjs.org/@rollup/rollup-win32-x64-msvc@4.9.1 + fsevents: registry.npmjs.org/fsevents@2.3.3 dev: true /run-parallel@1.2.0: @@ -2967,10 +2644,6 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true - /xstate@5.5.1: - resolution: {integrity: sha512-12Was43pPJKg3JWoelOREtTNYgFz6tRlNrMaRuqOibEe3pn8/uOWiP8ySMfOynyIjHUxd4BU7wV9O54Ma3FM6g==} - dev: false - /y18n@4.0.3: resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} dev: true @@ -3045,3 +2718,414 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} dev: true + + registry.npmjs.org/@esbuild/aix-ppc64@0.19.10: + resolution: {integrity: sha512-Q+mk96KJ+FZ30h9fsJl+67IjNJm3x2eX+GBWGmocAKgzp27cowCOOqSdscX80s0SpdFXZnIv/+1xD1EctFx96Q==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.10.tgz} + name: '@esbuild/aix-ppc64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/android-arm64@0.19.10: + resolution: {integrity: sha512-1X4CClKhDgC3by7k8aOWZeBXQX8dHT5QAMCAQDArCLaYfkppoARvh0fit3X2Qs+MXDngKcHv6XXyQCpY0hkK1Q==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.10.tgz} + name: '@esbuild/android-arm64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/android-arm@0.19.10: + resolution: {integrity: sha512-7W0bK7qfkw1fc2viBfrtAEkDKHatYfHzr/jKAHNr9BvkYDXPcC6bodtm8AyLJNNuqClLNaeTLuwURt4PRT9d7w==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.10.tgz} + name: '@esbuild/android-arm' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/android-x64@0.19.10: + resolution: {integrity: sha512-O/nO/g+/7NlitUxETkUv/IvADKuZXyH4BHf/g/7laqKC4i/7whLpB0gvpPc2zpF0q9Q6FXS3TS75QHac9MvVWw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.10.tgz} + name: '@esbuild/android-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/darwin-arm64@0.19.10: + resolution: {integrity: sha512-YSRRs2zOpwypck+6GL3wGXx2gNP7DXzetmo5pHXLrY/VIMsS59yKfjPizQ4lLt5vEI80M41gjm2BxrGZ5U+VMA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.10.tgz} + name: '@esbuild/darwin-arm64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/darwin-x64@0.19.10: + resolution: {integrity: sha512-alfGtT+IEICKtNE54hbvPg13xGBe4GkVxyGWtzr+yHO7HIiRJppPDhOKq3zstTcVf8msXb/t4eavW3jCDpMSmA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.10.tgz} + name: '@esbuild/darwin-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/freebsd-arm64@0.19.10: + resolution: {integrity: sha512-dMtk1wc7FSH8CCkE854GyGuNKCewlh+7heYP/sclpOG6Cectzk14qdUIY5CrKDbkA/OczXq9WesqnPl09mj5dg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.10.tgz} + name: '@esbuild/freebsd-arm64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/freebsd-x64@0.19.10: + resolution: {integrity: sha512-G5UPPspryHu1T3uX8WiOEUa6q6OlQh6gNl4CO4Iw5PS+Kg5bVggVFehzXBJY6X6RSOMS8iXDv2330VzaObm4Ag==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.10.tgz} + name: '@esbuild/freebsd-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-arm64@0.19.10: + resolution: {integrity: sha512-QxaouHWZ+2KWEj7cGJmvTIHVALfhpGxo3WLmlYfJ+dA5fJB6lDEIg+oe/0//FuyVHuS3l79/wyBxbHr0NgtxJQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.10.tgz} + name: '@esbuild/linux-arm64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-arm@0.19.10: + resolution: {integrity: sha512-j6gUW5aAaPgD416Hk9FHxn27On28H4eVI9rJ4az7oCGTFW48+LcgNDBN+9f8rKZz7EEowo889CPKyeaD0iw9Kg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.10.tgz} + name: '@esbuild/linux-arm' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-ia32@0.19.10: + resolution: {integrity: sha512-4ub1YwXxYjj9h1UIZs2hYbnTZBtenPw5NfXCRgEkGb0b6OJ2gpkMvDqRDYIDRjRdWSe/TBiZltm3Y3Q8SN1xNg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.10.tgz} + name: '@esbuild/linux-ia32' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-loong64@0.19.10: + resolution: {integrity: sha512-lo3I9k+mbEKoxtoIbM0yC/MZ1i2wM0cIeOejlVdZ3D86LAcFXFRdeuZmh91QJvUTW51bOK5W2BznGNIl4+mDaA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.10.tgz} + name: '@esbuild/linux-loong64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-mips64el@0.19.10: + resolution: {integrity: sha512-J4gH3zhHNbdZN0Bcr1QUGVNkHTdpijgx5VMxeetSk6ntdt+vR1DqGmHxQYHRmNb77tP6GVvD+K0NyO4xjd7y4A==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.10.tgz} + name: '@esbuild/linux-mips64el' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-ppc64@0.19.10: + resolution: {integrity: sha512-tgT/7u+QhV6ge8wFMzaklOY7KqiyitgT1AUHMApau32ZlvTB/+efeCtMk4eXS+uEymYK249JsoiklZN64xt6oQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.10.tgz} + name: '@esbuild/linux-ppc64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-riscv64@0.19.10: + resolution: {integrity: sha512-0f/spw0PfBMZBNqtKe5FLzBDGo0SKZKvMl5PHYQr3+eiSscfJ96XEknCe+JoOayybWUFQbcJTrk946i3j9uYZA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.10.tgz} + name: '@esbuild/linux-riscv64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-s390x@0.19.10: + resolution: {integrity: sha512-pZFe0OeskMHzHa9U38g+z8Yx5FNCLFtUnJtQMpwhS+r4S566aK2ci3t4NCP4tjt6d5j5uo4h7tExZMjeKoehAA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.10.tgz} + name: '@esbuild/linux-s390x' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/linux-x64@0.19.10: + resolution: {integrity: sha512-SpYNEqg/6pZYoc+1zLCjVOYvxfZVZj6w0KROZ3Fje/QrM3nfvT2llI+wmKSrWuX6wmZeTapbarvuNNK/qepSgA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.10.tgz} + name: '@esbuild/linux-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/netbsd-x64@0.19.10: + resolution: {integrity: sha512-ACbZ0vXy9zksNArWlk2c38NdKg25+L9pr/mVaj9SUq6lHZu/35nx2xnQVRGLrC1KKQqJKRIB0q8GspiHI3J80Q==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.10.tgz} + name: '@esbuild/netbsd-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/openbsd-x64@0.19.10: + resolution: {integrity: sha512-PxcgvjdSjtgPMiPQrM3pwSaG4kGphP+bLSb+cihuP0LYdZv1epbAIecHVl5sD3npkfYBZ0ZnOjR878I7MdJDFg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.10.tgz} + name: '@esbuild/openbsd-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/sunos-x64@0.19.10: + resolution: {integrity: sha512-ZkIOtrRL8SEJjr+VHjmW0znkPs+oJXhlJbNwfI37rvgeMtk3sxOQevXPXjmAPZPigVTncvFqLMd+uV0IBSEzqA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.10.tgz} + name: '@esbuild/sunos-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/win32-arm64@0.19.10: + resolution: {integrity: sha512-+Sa4oTDbpBfGpl3Hn3XiUe4f8TU2JF7aX8cOfqFYMMjXp6ma6NJDztl5FDG8Ezx0OjwGikIHw+iA54YLDNNVfw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.10.tgz} + name: '@esbuild/win32-arm64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/win32-ia32@0.19.10: + resolution: {integrity: sha512-EOGVLK1oWMBXgfttJdPHDTiivYSjX6jDNaATeNOaCOFEVcfMjtbx7WVQwPSE1eIfCp/CaSF2nSrDtzc4I9f8TQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.10.tgz} + name: '@esbuild/win32-ia32' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@esbuild/win32-x64@0.19.10: + resolution: {integrity: sha512-whqLG6Sc70AbU73fFYvuYzaE4MNMBIlR1Y/IrUeOXFrWHxBEjjbZaQ3IXIQS8wJdAzue2GwYZCjOrgrU1oUHoA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.10.tgz} + name: '@esbuild/win32-x64' + version: 0.19.10 + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-android-arm-eabi@4.9.1: + resolution: {integrity: sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.1.tgz} + name: '@rollup/rollup-android-arm-eabi' + version: 4.9.1 + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-android-arm64@4.9.1: + resolution: {integrity: sha512-Jto9Fl3YQ9OLsTDWtLFPtaIMSL2kwGyGoVCmPC8Gxvym9TCZm4Sie+cVeblPO66YZsYH8MhBKDMGZ2NDxuk/XQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.1.tgz} + name: '@rollup/rollup-android-arm64' + version: 4.9.1 + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-darwin-arm64@4.9.1: + resolution: {integrity: sha512-LtYcLNM+bhsaKAIGwVkh5IOWhaZhjTfNOkGzGqdHvhiCUVuJDalvDxEdSnhFzAn+g23wgsycmZk1vbnaibZwwA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.1.tgz} + name: '@rollup/rollup-darwin-arm64' + version: 4.9.1 + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-darwin-x64@4.9.1: + resolution: {integrity: sha512-KyP/byeXu9V+etKO6Lw3E4tW4QdcnzDG/ake031mg42lob5tN+5qfr+lkcT/SGZaH2PdW4Z1NX9GHEkZ8xV7og==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.1.tgz} + name: '@rollup/rollup-darwin-x64' + version: 4.9.1 + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf@4.9.1: + resolution: {integrity: sha512-Yqz/Doumf3QTKplwGNrCHe/B2p9xqDghBZSlAY0/hU6ikuDVQuOUIpDP/YcmoT+447tsZTmirmjgG3znvSCR0Q==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.1.tgz} + name: '@rollup/rollup-linux-arm-gnueabihf' + version: 4.9.1 + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-linux-arm64-gnu@4.9.1: + resolution: {integrity: sha512-u3XkZVvxcvlAOlQJ3UsD1rFvLWqu4Ef/Ggl40WAVCuogf4S1nJPHh5RTgqYFpCOvuGJ7H5yGHabjFKEZGExk5Q==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.1.tgz} + name: '@rollup/rollup-linux-arm64-gnu' + version: 4.9.1 + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-linux-arm64-musl@4.9.1: + resolution: {integrity: sha512-0XSYN/rfWShW+i+qjZ0phc6vZ7UWI8XWNz4E/l+6edFt+FxoEghrJHjX1EY/kcUGCnZzYYRCl31SNdfOi450Aw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.1.tgz} + name: '@rollup/rollup-linux-arm64-musl' + version: 4.9.1 + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu@4.9.1: + resolution: {integrity: sha512-LmYIO65oZVfFt9t6cpYkbC4d5lKHLYv5B4CSHRpnANq0VZUQXGcCPXHzbCXCz4RQnx7jvlYB1ISVNCE/omz5cw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.1.tgz} + name: '@rollup/rollup-linux-riscv64-gnu' + version: 4.9.1 + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-linux-x64-gnu@4.9.1: + resolution: {integrity: sha512-kr8rEPQ6ns/Lmr/hiw8sEVj9aa07gh1/tQF2Y5HrNCCEPiCBGnBUt9tVusrcBBiJfIt1yNaXN6r1CCmpbFEDpg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.1.tgz} + name: '@rollup/rollup-linux-x64-gnu' + version: 4.9.1 + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-linux-x64-musl@4.9.1: + resolution: {integrity: sha512-t4QSR7gN+OEZLG0MiCgPqMWZGwmeHhsM4AkegJ0Kiy6TnJ9vZ8dEIwHw1LcZKhbHxTY32hp9eVCMdR3/I8MGRw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.1.tgz} + name: '@rollup/rollup-linux-x64-musl' + version: 4.9.1 + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-win32-arm64-msvc@4.9.1: + resolution: {integrity: sha512-7XI4ZCBN34cb+BH557FJPmh0kmNz2c25SCQeT9OiFWEgf8+dL6ZwJ8f9RnUIit+j01u07Yvrsuu1rZGxJCc51g==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.1.tgz} + name: '@rollup/rollup-win32-arm64-msvc' + version: 4.9.1 + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-win32-ia32-msvc@4.9.1: + resolution: {integrity: sha512-yE5c2j1lSWOH5jp+Q0qNL3Mdhr8WuqCNVjc6BxbVfS5cAS6zRmdiw7ktb8GNpDCEUJphILY6KACoFoRtKoqNQg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.1.tgz} + name: '@rollup/rollup-win32-ia32-msvc' + version: 4.9.1 + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/@rollup/rollup-win32-x64-msvc@4.9.1: + resolution: {integrity: sha512-PyJsSsafjmIhVgaI1Zdj7m8BB8mMckFah/xbpplObyHfiXzKcI5UOUXRyOdHW7nz4DpMCuzLnF7v5IWHenCwYA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.1.tgz} + name: '@rollup/rollup-win32-x64-msvc' + version: 4.9.1 + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz} + name: fsevents + version: 2.3.3 + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz} + name: graceful-fs + version: 4.2.11 + requiresBuild: true + dev: true + optional: true + + registry.npmjs.org/xstate@5.6.0: + resolution: {integrity: sha512-l62p4ZHM/fkGl68574s1dFzFmY8B3BeOff9EqBZbuonTSOXGx1fWTnh4SHSrS8Vhr5wyRT9afqWliMoO6Q+hUQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/xstate/-/xstate-5.6.0.tgz} + name: xstate + version: 5.6.0 + dev: false + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/src/openai.ts b/src/adapters/openai.ts similarity index 74% rename from src/openai.ts rename to src/adapters/openai.ts index 546b490..3f6bcba 100644 --- a/src/openai.ts +++ b/src/adapters/openai.ts @@ -4,21 +4,12 @@ import { ObservableActorLogic, Observer, PromiseActorLogic, - Values, fromObservable, fromPromise, - setup, + isMachineSnapshot, toObserver, } from 'xstate'; -import { getAllTransitions } from './utils'; -import { - ContextSchema, - EventSchemas, - ConvertContextToJSONSchema, - ConvertToJSONSchemas, - createEventSchemas, -} from './utils'; -import { FromSchema } from 'json-schema-to-ts'; +import { getAllTransitions } from '../utils'; import { ChatCompletionCreateParamsNonStreaming } from 'openai/resources'; import { ChatCompletionCreateParamsBase, @@ -34,7 +25,7 @@ import { */ export function fromChatCompletion( openai: OpenAI, - agentSettings: CreateAgentOutput, + agentSettings: OpenAIAdapterOutput, inputFn: ( input: TInput ) => string | OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming @@ -67,9 +58,9 @@ export function fromChatCompletion( * @param openai The OpenAI instance to use. * @param inputFn A function that maps arbitrary input to OpenAI chat completion input. */ -export function fromChatCompletionStream( +export function fromChatStream( openai: OpenAI, - agentSettings: CreateAgentOutput, + agentSettings: OpenAIAdapterOutput, inputFn: ( input: TInput ) => string | OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming @@ -128,7 +119,7 @@ export function fromChatCompletionStream( */ export function fromEventChoice( openai: OpenAI, - agentSettings: CreateAgentOutput, + agentSettings: OpenAIAdapterOutput, inputFn: ( input: TInput ) => string | OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming, @@ -142,6 +133,15 @@ export function fromEventChoice( ) { return fromPromise( async ({ input, self, system }) => { + const parentSnapshot = self._parent?.getSnapshot(); + + if (!parentSnapshot || !isMachineSnapshot(parentSnapshot)) { + return undefined; + } + + const schemas = parentSnapshot.machine.schemas as any; + const eventSchemaMap = schemas.events ?? {}; + const transitions = getAllTransitions(self._parent!.getSnapshot()); const functionNameMapping: Record = {}; const tools = transitions @@ -156,12 +156,10 @@ export function fromEventChoice( function: { name, description: - t.description ?? - agentSettings.schemas.events[t.eventType]?.description, + t.description ?? eventSchemaMap[t.eventType]?.description, parameters: { type: 'object', - properties: - agentSettings.schemas.events[t.eventType]?.properties ?? {}, + properties: eventSchemaMap[t.eventType]?.properties ?? {}, }, }, } as const; @@ -208,35 +206,35 @@ export function fromEventChoice( ); } -interface CreateAgentOutput< +interface OpenAIAdapterOutput< T extends { model: ChatCompletionCreateParamsBase['model']; - context: ContextSchema; - events: EventSchemas; } > { model: T['model']; - schemas: T; - types: { - context: FromSchema>; - events: FromSchema>>; - }; - fromEvent: ( - inputFn: (input: TInput) => string | ChatCompletionCreateParamsNonStreaming - ) => PromiseActorLogic< - FromSchema>>[] | undefined, - TInput - >; + /** + * Determines which event to send to the parent state machine actor based on the prompt. + */ fromEventChoice: ( - inputFn: (input: TInput) => string | ChatCompletionCreateParamsNonStreaming - ) => PromiseActorLogic< - FromSchema>>[] | undefined, - TInput - >; - fromChatCompletion: ( + inputFn: (input: TInput) => string | ChatCompletionCreateParamsNonStreaming, + options?: { + /** + * Immediately execute sending the event to the parent actor. + * @default true + */ + execute?: boolean; + } + ) => PromiseActorLogic; + /** + * Creates promise actor logic that resolves with a chat completion. + */ + fromChat: ( inputFn: (input: TInput) => string | ChatCompletionCreateParamsNonStreaming ) => PromiseActorLogic; - fromChatCompletionStream: ( + /** + * Creates observable actor logic that emits a chat completion stream. + */ + fromChatStream: ( inputFn: (input: TInput) => string | ChatCompletionCreateParamsStreaming ) => ObservableActorLogic< OpenAI.Chat.Completions.ChatCompletionChunk, @@ -244,34 +242,19 @@ interface CreateAgentOutput< >; } -export function createAgent< +export function createOpenAIAdapter< T extends { model: ChatCompletionCreateParamsBase['model']; - context: ContextSchema; - events: EventSchemas; } ->(openai: OpenAI, settings: T): CreateAgentOutput { - const agentSettings: CreateAgentOutput = { +>(openai: OpenAI, settings: T): OpenAIAdapterOutput { + const agentSettings: OpenAIAdapterOutput = { model: settings.model, - schemas: { - context: { - type: 'object', - properties: settings.context, - additionalProperties: false, - }, - events: createEventSchemas(settings.events), - } as any, - types: {} as any, - fromEvent: (input) => - // @ts-ignore - fromEventChoice(openai, agentSettings, input, { execute: true }), - // @ts-ignore infinitely deep - fromEventChoice: (input) => fromEventChoice(openai, agentSettings, input), - fromChatCompletion: (input) => - fromChatCompletion(openai, agentSettings, input), - fromChatCompletionStream: (input) => - fromChatCompletionStream(openai, agentSettings, input), + fromEventChoice: (input) => + // @ts-ignore infinitely deep + fromEventChoice(openai, agentSettings, input, { execute: true }) as any, + fromChat: (input) => fromChatCompletion(openai, agentSettings, input), + fromChatStream: (input) => fromChatStream(openai, agentSettings, input), }; - return agentSettings as any; + return agentSettings; } diff --git a/src/agent.ts b/src/agent.ts new file mode 100644 index 0000000..a5ebdaa --- /dev/null +++ b/src/agent.ts @@ -0,0 +1,8 @@ +import { ActorOptions, AnyStateMachine, createActor } from 'xstate'; + +export function createAgent( + ...args: Parameters> +) { + const [machine, options] = args; + return createActor(machine, options); +} diff --git a/src/index.ts b/src/index.ts index 901b76c..bdfd3ae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,3 @@ -export { - fromChatCompletion, - fromChatCompletionStream, - fromEventChoice, - createAgent, -} from './openai'; +export { createSchemas } from './schemas'; +export { createAgent } from './agent'; +export { createOpenAIAdapter } from './adapters/openai'; diff --git a/src/schemas.ts b/src/schemas.ts new file mode 100644 index 0000000..c8d8b0e --- /dev/null +++ b/src/schemas.ts @@ -0,0 +1,38 @@ +import { Values } from 'xstate'; +import { + ContextSchema, + EventSchemas, + ConvertContextToJSONSchema, + ConvertToJSONSchemas, + createEventSchemas, +} from './utils'; +import { FromSchema } from 'json-schema-to-ts'; + +export function createSchemas< + TContextSchema extends ContextSchema, + TEventSchemas extends EventSchemas +>({ + context, + events, +}: { + context: TContextSchema; + events: TEventSchemas; +}): { + context: ConvertContextToJSONSchema; + events: ConvertToJSONSchemas; + types: { + context: FromSchema>; + events: FromSchema>>; + }; +} { + return { + context: { + type: 'object', + properties: context, + additionalProperties: false, + required: Object.keys(context), + }, + events: createEventSchemas(events), + types: {} as any, + }; +}