diff --git a/packages/ai-sdk-mobx/ReadMe.md b/packages/ai-sdk-mobx/ReadMe.md index cb003a4..4632a0b 100644 --- a/packages/ai-sdk-mobx/ReadMe.md +++ b/packages/ai-sdk-mobx/ReadMe.md @@ -1,8 +1,28 @@ # AI SDK for MobX -MobX models for AI SDK interactions, built on [mobx-restful][1]. +MobX models for [AI SDK][2] interactions, built on [mobx-restful][1]. -This package is being prepared; its public model API is not available yet. +Each stateful React hook in `@ai-sdk/react` has a corresponding MobX model: + +| AI SDK hook | MobX model | +| -------------------------- | ----------------- | +| `useChat` | `ChatModel` | +| `useCompletion` | `CompletionModel` | +| `useObject` | `ObjectModel` | +| `experimental_useRealtime` | `RealtimeModel` | + +```ts +import { ChatModel, CompletionModel } from 'ai-sdk-mobx'; + +const chat = new ChatModel(); +await chat.sendMessage({ text: 'Hello!' }); + +const completion = new CompletionModel(); +await completion.complete('Write a greeting'); +``` + +The models expose their state as MobX observables. `ChatModel.chat` provides the +underlying AI SDK chat instance for the full chat API. ## Install @@ -11,3 +31,4 @@ npm install ai-sdk-mobx ``` [1]: https://github.com/idea2app/MobX-RESTful +[2]: https://github.com/vercel/ai/tree/main/packages/react diff --git a/packages/ai-sdk-mobx/package.json b/packages/ai-sdk-mobx/package.json index 66d2e10..de29e1d 100644 --- a/packages/ai-sdk-mobx/package.json +++ b/packages/ai-sdk-mobx/package.json @@ -1,6 +1,15 @@ { "name": "ai-sdk-mobx", "version": "0.1.0", + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, "license": "AGPL-3.0-only", "author": "shiy2008@gmail.com", "description": "MobX models for AI SDK interactions.", @@ -15,8 +24,10 @@ "dist/" ], "dependencies": { + "ai": "^7.0.173", "mobx": "^7.1.7", - "mobx-restful": "^2.1.5" + "mobx-restful": "^2.1.5", + "zod": "^4.6.7" }, "devDependencies": { "@swc-node/register": "^1.12.1", @@ -27,6 +38,6 @@ "scripts": { "check": "cross-env SWCRC=true SWC_CONFIG_FILE=../../.swcrc node --import @swc-node/register/esm-register --test test/*.test.ts", "test": "tsc --noEmit && npm run check", - "build": "echo Building ai-sdk-mobx" + "build": "tsc --project tsconfig.build.json" } } diff --git a/packages/ai-sdk-mobx/source/chat.ts b/packages/ai-sdk-mobx/source/chat.ts new file mode 100644 index 0000000..92294f8 --- /dev/null +++ b/packages/ai-sdk-mobx/source/chat.ts @@ -0,0 +1,124 @@ +import { action, observable, runInAction } from 'mobx'; +import { BaseModel } from 'mobx-restful'; +import { AbstractChat, type ChatInit, type ChatState, type ChatStatus, type UIMessage } from 'ai'; + +class MobXChat extends AbstractChat {} + +export class ChatModel extends BaseModel { + @observable accessor status: ChatStatus = 'ready'; + @observable accessor error: Error | undefined = undefined; + @observable accessor messages: UI_MESSAGE[] = []; + @observable accessor experimental_queuedMessages: UI_MESSAGE[] = []; + + readonly chat: MobXChat; + + constructor({ messages = [], ...options }: ChatInit = {}) { + super(); + runInAction(() => { + this.messages = messages; + }); + const model = this; + const state: ChatState = { + get status() { + return model.status; + }, + set status(value) { + runInAction(() => { + model.status = value; + }); + }, + get error() { + return model.error; + }, + set error(value) { + runInAction(() => { + model.error = value; + }); + }, + get messages() { + return model.messages; + }, + set messages(value) { + runInAction(() => { + model.messages = value; + }); + }, + get experimental_queuedMessages() { + return model.experimental_queuedMessages; + }, + set experimental_queuedMessages(value) { + runInAction(() => { + model.experimental_queuedMessages = value; + }); + }, + pushMessage: this.pushMessage, + popMessage: this.popMessage, + replaceMessage: this.replaceMessage, + snapshot: this.snapshot, + }; + this.chat = new MobXChat({ ...options, state }); + } + + @action + pushMessage = (message: UI_MESSAGE) => { + this.messages = [...this.messages, message]; + }; + + @action + popMessage = () => { + this.messages = this.messages.slice(0, -1); + }; + + @action + replaceMessage = (index: number, message: UI_MESSAGE) => { + this.messages = this.messages.map((current, position) => + position === index ? this.snapshot(message) : current, + ); + }; + + snapshot = (value: T): T => { + if ( + value == null || + typeof value !== 'object' || + !('parts' in value) || + !Array.isArray(value.parts) + ) + return value; + + return { + ...value, + parts: value.parts.map(part => + part != null && typeof part === 'object' ? { ...part } : part, + ), + ...('metadata' in value && value.metadata != null && typeof value.metadata === 'object' + ? { metadata: Array.isArray(value.metadata) ? [...value.metadata] : { ...value.metadata } } + : {}), + } as T; + }; + + get id() { + return this.chat.id; + } + + sendMessage: MobXChat['sendMessage'] = (...args) => this.chat.sendMessage(...args); + regenerate: MobXChat['regenerate'] = (...args) => this.chat.regenerate(...args); + stop = () => this.chat.stop(); + resumeStream = (...args: Parameters['resumeStream']>) => + this.chat.resumeStream(...args); + addToolOutput: MobXChat['addToolOutput'] = (...args) => + this.chat.addToolOutput(...args); + addToolApprovalResponse: MobXChat['addToolApprovalResponse'] = (...args) => + this.chat.addToolApprovalResponse(...args); + clearError = () => this.chat.clearError(); + dispose = () => this.chat.dispose(); + + @action + override clear() { + void this.chat.stop(); + this.messages = []; + this.experimental_queuedMessages = []; + this.status = 'ready'; + this.error = undefined; + super.clear(); + } +} diff --git a/packages/ai-sdk-mobx/source/completion.ts b/packages/ai-sdk-mobx/source/completion.ts new file mode 100644 index 0000000..bd208c9 --- /dev/null +++ b/packages/ai-sdk-mobx/source/completion.ts @@ -0,0 +1,113 @@ +import { action, observable, runInAction } from 'mobx'; +import { BaseModel } from 'mobx-restful'; +import { callCompletionApi, type CompletionRequestOptions, type UseCompletionOptions } from 'ai'; + +export class CompletionModel extends BaseModel { + @observable accessor completion = ''; + @observable accessor error: Error | undefined = undefined; + @observable accessor input = ''; + + private abortController: AbortController | null = null; + private requestId = 0; + private readonly options: UseCompletionOptions; + + constructor(options: UseCompletionOptions = {}) { + super(); + this.options = options; + runInAction(() => { + this.completion = options.initialCompletion ?? ''; + this.input = options.initialInput ?? ''; + }); + } + + async complete(prompt: string, requestOptions?: CompletionRequestOptions) { + const requestId = ++this.requestId; + const { api = '/api/completion', ...options } = this.options; + + return callCompletionApi({ + api, + prompt, + credentials: options.credentials, + headers: this.mergeHeaders(options.headers, requestOptions?.headers), + body: { ...options.body, ...requestOptions?.body }, + streamProtocol: options.streamProtocol, + fetch: options.fetch, + setCompletion: completion => { + if (requestId === this.requestId) this.setCompletion(completion); + }, + setLoading: loading => { + if (requestId === this.requestId) + runInAction(() => { + this.downloading = Number(loading); + }); + }, + setError: error => { + if (requestId === this.requestId) + runInAction(() => { + this.error = error; + }); + }, + setAbortController: controller => { + if (requestId === this.requestId) this.abortController = controller; + }, + getAbortController: () => this.abortController, + onFinish: options.onFinish, + onError: options.onError, + }); + } + + @action + setCompletion = (completion: string) => { + this.completion = completion; + }; + + @action + setInput = (input: string) => { + this.input = input; + }; + + handleInputChange = (event: { target: { value: string } }) => { + this.setInput(event.target.value); + }; + + async handleSubmit(event?: { preventDefault?: () => void }) { + event?.preventDefault?.(); + if (!this.input) return; + + const input = this.input; + this.setInput(''); + return this.complete(input); + } + + stop = () => { + this.abortController?.abort(); + }; + + @action + override clear() { + this.stop(); + this.requestId++; + this.abortController = null; + this.completion = ''; + this.error = undefined; + super.clear(); + } + + get isLoading() { + return this.downloading > 0; + } + + private mergeHeaders(...sources: Array | Headers | undefined>) { + const headers = new Headers(); + + for (const source of sources) { + if (source instanceof Headers) { + source.forEach((value, key) => headers.set(key, value)); + } else { + for (const [key, value] of Object.entries(source ?? {})) headers.set(key, value); + } + } + + return headers; + } +} diff --git a/packages/ai-sdk-mobx/source/index.ts b/packages/ai-sdk-mobx/source/index.ts new file mode 100644 index 0000000..3722b2b --- /dev/null +++ b/packages/ai-sdk-mobx/source/index.ts @@ -0,0 +1,4 @@ +export * from './chat.js'; +export * from './completion.js'; +export * from './object.js'; +export * from './realtime.js'; diff --git a/packages/ai-sdk-mobx/source/object.ts b/packages/ai-sdk-mobx/source/object.ts new file mode 100644 index 0000000..0476c1f --- /dev/null +++ b/packages/ai-sdk-mobx/source/object.ts @@ -0,0 +1,154 @@ +import { action, observable, runInAction } from 'mobx'; +import { BaseModel } from 'mobx-restful'; +import { + asSchema, + parsePartialJson, + type DeepPartial, + type FlexibleSchema, + type InferSchema, +} from 'ai'; + +export type ObjectModelOptions = { + api: string; + schema: SCHEMA; + initialValue?: DeepPartial; + fetch?: typeof globalThis.fetch; + credentials?: RequestCredentials; + headers?: + | Record + | Headers + | (() => Record | Headers | Promise | Headers>); + onFinish?: (result: { + object: RESULT | undefined; + error: Error | undefined; + }) => void | Promise; + onError?: (error: Error) => void; +}; + +export class ObjectModel< + SCHEMA extends FlexibleSchema, + RESULT = InferSchema, + INPUT = unknown, +> extends BaseModel { + @observable accessor object: DeepPartial | undefined; + @observable accessor error: Error | undefined = undefined; + + private abortController: AbortController | null = null; + + constructor(private readonly options: ObjectModelOptions) { + super(); + runInAction(() => { + this.object = options.initialValue; + }); + } + + async submit(input: INPUT) { + const controller = new AbortController(); + this.stop(); + this.abortController = controller; + runInAction(() => { + this.error = undefined; + this.object = undefined; + this.downloading = 1; + }); + + try { + const { headers, ...options } = this.options; + const resolvedHeaders = typeof headers === 'function' ? await headers() : headers; + const response = await (options.fetch ?? globalThis.fetch)(options.api, { + method: 'POST', + headers: this.mergeHeaders(resolvedHeaders), + credentials: options.credentials, + signal: controller.signal, + body: JSON.stringify(input), + }); + + if (!response.ok) throw new Error((await response.text()) || 'Failed to fetch the response.'); + if (response.body == null) throw new Error('The response body is empty.'); + + let accumulatedText = ''; + let latestObject: DeepPartial | undefined; + await response.body.pipeThrough(new TextDecoderStream()).pipeTo( + new WritableStream({ + write: async chunk => { + accumulatedText += chunk; + const { value } = await parsePartialJson(accumulatedText); + if (controller === this.abortController) { + latestObject = value as DeepPartial; + runInAction(() => { + this.object = latestObject; + }); + } + }, + close: async () => { + const validation = await asSchema(this.options.schema).validate?.(latestObject); + if (validation?.success) { + runInAction(() => { + this.object = validation.value as DeepPartial; + }); + } else if (validation != null) { + runInAction(() => { + this.error = validation.error; + }); + } + await this.options.onFinish?.( + validation == null + ? { + object: latestObject as RESULT | undefined, + error: undefined, + } + : validation.success + ? { + object: validation.value as RESULT, + error: undefined, + } + : { object: undefined, error: validation.error }, + ); + }, + }), + { signal: controller.signal }, + ); + } catch (error) { + if (!(error instanceof Error && error.name === 'AbortError')) { + const requestError = error instanceof Error ? error : new Error(String(error)); + runInAction(() => { + this.error = requestError; + }); + this.options.onError?.(requestError); + } + } finally { + if (controller === this.abortController) { + this.abortController = null; + runInAction(() => { + this.downloading = Math.max(0, this.downloading - 1); + }); + } + } + } + + @action + clear = () => { + this.stop(); + this.object = undefined; + this.error = undefined; + super.clear(); + }; + + @action + stop = () => { + this.abortController?.abort(); + this.abortController = null; + this.downloading = 0; + }; + + get isLoading() { + return this.downloading > 0; + } + + private mergeHeaders(source?: Record | Headers) { + const headers = new Headers({ 'Content-Type': 'application/json' }); + if (source instanceof Headers) source.forEach((value, key) => headers.set(key, value)); + else for (const [key, value] of Object.entries(source ?? {})) headers.set(key, value); + return headers; + } +} diff --git a/packages/ai-sdk-mobx/source/realtime.ts b/packages/ai-sdk-mobx/source/realtime.ts new file mode 100644 index 0000000..2f3992a --- /dev/null +++ b/packages/ai-sdk-mobx/source/realtime.ts @@ -0,0 +1,83 @@ +import { action, observable, runInAction } from 'mobx'; +import { BaseModel } from 'mobx-restful'; +import { + Experimental_AbstractRealtimeSession as AbstractRealtimeSession, + type Experimental_RealtimeServerEvent as RealtimeServerEvent, + type Experimental_RealtimeSessionOptions as RealtimeSessionOptions, + type Experimental_RealtimeState as RealtimeState, + type Experimental_RealtimeStatus as RealtimeStatus, + type UIMessage, +} from 'ai'; + +class RealtimeSession extends AbstractRealtimeSession { + protected state: RealtimeState = { + status: 'disconnected', + messages: [], + events: [], + isCapturing: false, + isPlaying: false, + }; + + constructor( + options: RealtimeSessionOptions, + private readonly publish: ( + key: KEY, + value: RealtimeState[KEY], + ) => void, + ) { + super(options); + } + + protected setState(key: KEY, value: RealtimeState[KEY]) { + this.state = { ...this.state, [key]: value }; + this.publish(key, value); + } +} + +export class RealtimeModel extends BaseModel { + @observable accessor status: RealtimeStatus = 'disconnected'; + @observable accessor messages: UIMessage[] = []; + @observable accessor events: RealtimeServerEvent[] = []; + @observable accessor isCapturing = false; + @observable accessor isPlaying = false; + @observable accessor session: RealtimeState['session']; + + private readonly realtime: RealtimeSession; + + constructor(options: RealtimeSessionOptions) { + super(); + this.realtime = new RealtimeSession(options, (key, value) => { + runInAction(() => { + this[key] = value as never; + }); + }); + } + + connect = (...args: Parameters) => this.realtime.connect(...args); + close = (...args: Parameters) => this.realtime.close(...args); + resumePlayback = () => this.realtime.resumePlayback(); + resumeAudioCapture = () => this.realtime.resumeAudioCapture(); + disconnect = () => this.realtime.disconnect(); + addToolOutput = (...args: Parameters) => + this.realtime.addToolOutput(...args); + sendEvent = (...args: Parameters) => + this.realtime.sendEvent(...args); + sendTextMessage = (...args: Parameters) => + this.realtime.sendTextMessage(...args); + sendAudio = (...args: Parameters) => + this.realtime.sendAudio(...args); + commitAudio = () => this.realtime.commitAudio(); + clearAudioBuffer = () => this.realtime.clearAudioBuffer(); + requestResponse = (...args: Parameters) => + this.realtime.requestResponse(...args); + cancelResponse = () => this.realtime.cancelResponse(); + startAudioCapture = (...args: Parameters) => + this.realtime.startAudioCapture(...args); + stopAudioCapture = () => this.realtime.stopAudioCapture(); + stopPlayback = () => this.realtime.stopPlayback(); + + @action + dispose = () => { + this.realtime.dispose(); + }; +} diff --git a/packages/ai-sdk-mobx/test/model.test.ts b/packages/ai-sdk-mobx/test/model.test.ts index 4a54fea..d29c3c2 100644 --- a/packages/ai-sdk-mobx/test/model.test.ts +++ b/packages/ai-sdk-mobx/test/model.test.ts @@ -1,6 +1,9 @@ import assert from 'node:assert/strict'; import test from 'node:test'; +import { isObservableProp } from 'mobx'; +import { jsonSchema } from 'ai'; import { BaseModel } from 'mobx-restful'; +import { ChatModel, CompletionModel, ObjectModel, RealtimeModel } from '../source/index.js'; test('Node.js test runner executes TypeScript with Stage 3 decorators via SWC', () => { const decorate = (value: (this: Example) => string) => @@ -29,3 +32,97 @@ test('mobx-restful BaseModel resets request state', () => { assert.equal(model.downloading, 0); assert.equal(model.uploading, 0); }); + +test('ChatModel keeps AI chat state observable and clears it', () => { + const model = new ChatModel(); + const message = { + id: 'message-1', + role: 'user', + parts: [{ type: 'text', text: 'Hello' }], + }; + + model.pushMessage(message as Parameters[0]); + + assert.equal(isObservableProp(model, 'messages'), true); + assert.equal(model.messages[0].id, 'message-1'); + assert.equal(model.id, model.chat.id); + + model.clear(); + + assert.deepEqual(model.messages, []); + assert.equal(model.status, 'ready'); +}); + +test('CompletionModel streams a completion and tracks request state', async () => { + let requestBody: unknown; + const model = new CompletionModel({ + api: '/completion', + streamProtocol: 'text', + fetch: async (_input, init) => { + requestBody = JSON.parse(String(init?.body)); + return new Response('generated text'); + }, + }); + + const result = await model.complete('prompt'); + + assert.deepEqual(requestBody, { prompt: 'prompt' }); + assert.equal(result, 'generated text'); + assert.equal(model.completion, 'generated text'); + assert.equal(model.isLoading, false); +}); + +test('ObjectModel parses and validates streamed JSON', async () => { + const schema = jsonSchema<{ name: string }>( + { type: 'object', properties: { name: { type: 'string' } } }, + { + validate: value => + value != null && typeof value === 'object' && 'name' in value + ? { + success: true, + value: { name: String(value.name).toUpperCase() }, + } + : { success: false, error: new Error('Invalid object') }, + }, + ); + const model = new ObjectModel({ + api: '/object', + schema, + fetch: async () => new Response('{"name":"Ada"}'), + }); + + await model.submit({ prompt: 'name' }); + + assert.deepEqual(model.object, { name: 'ADA' }); + assert.equal(model.isLoading, false); + assert.equal(model.error, undefined); +}); + +test('ObjectModel exposes schema validation errors', async () => { + const model = new ObjectModel({ + api: '/object', + schema: jsonSchema<{ name: string }>( + { type: 'object' }, + { + validate: () => ({ success: false, error: new Error('Invalid object') }), + }, + ), + fetch: async () => new Response('{"name":"Ada"}'), + }); + + await model.submit({ prompt: 'name' }); + + assert.deepEqual(model.object, { name: 'Ada' }); + assert.equal(model.error?.message, 'Invalid object'); +}); + +test('RealtimeModel exposes observable realtime hook state', () => { + const model = new RealtimeModel({ + model: {} as never, + api: { websocket: 'ws://localhost' }, + }); + + assert.equal(model.status, 'disconnected'); + assert.equal(isObservableProp(model, 'status'), true); + model.dispose(); +}); diff --git a/packages/ai-sdk-mobx/tsconfig.build.json b/packages/ai-sdk-mobx/tsconfig.build.json new file mode 100644 index 0000000..c655023 --- /dev/null +++ b/packages/ai-sdk-mobx/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "dist", + "rootDir": "source" + }, + "include": ["source/**/*.ts"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7cd77ae..286b54d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,16 +20,22 @@ importers: packages/ai-sdk-mobx: dependencies: + ai: + specifier: ^7.0.173 + version: 7.0.173(zod@4.6.7) mobx: specifier: ^7.1.7 version: 7.1.7 mobx-restful: specifier: ^2.1.5 - version: 2.1.5(core-js@3.51.0)(element-internals-polyfill@3.0.2)(jsdom@31.0.1)(mobx@7.1.7)(typescript@6.0.3) + version: 2.1.5(mobx@7.1.7)(typescript@6.0.3) + zod: + specifier: ^4.6.7 + version: 4.6.7 devDependencies: '@swc-node/register': specifier: ^1.12.1 - version: 1.12.1(@swc/core@1.16.22(@swc/helpers@0.5.24))(@swc/types@0.1.28)(typescript@6.0.3) + version: 1.12.1(typescript@6.0.3) '@types/node': specifier: ^26.6.6 version: 26.6.6 @@ -97,6 +103,22 @@ importers: packages: + '@ai-sdk/gateway@4.0.146': + resolution: {integrity: sha512-rJ5NQSyjnpo6HSBEYc9Ff6k1EROUuB7KeAfHYVbVDsk68ynY0Eb8JeWflZKXlT6NhYgqyCiBDxE5blXWACXMKQ==} + engines: {node: '>=22'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/provider-utils@5.0.81': + resolution: {integrity: sha512-pfvvdQ3d1WxdBuug/mnGEP6E48cPokwD8dMBnsFeeAUp0/rb/H2aj0f3mwOiY62gu/Cu5GO44e+SE5nDHyBWMA==} + engines: {node: '>=22'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/provider@4.0.38': + resolution: {integrity: sha512-GElz70UUCuDFFyD6m6aQJFgRY0HEABQzB5otzgkrisYaF5mnss7o0upAmbBTSD6KWiM9h7lZm1ls2c7xzHR8CA==} + engines: {node: '>=22'} + '@babel/code-frame@7.29.7': resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==} engines: {node: '>=6.9.0'} @@ -454,6 +476,9 @@ packages: '@shikijs/vscode-textmate@10.1.0': resolution: {integrity: sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ==} + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + '@swc-node/core@1.15.0': resolution: {integrity: sha512-WAerrrl087WgenB92XG4Th2t0NQFfMNLYSe0sW2cEMMqM/LQmP4rozsDJl0vuzTrbewjpKQryxFXI+aYig/dBg==} engines: {node: '>= 10'} @@ -634,6 +659,19 @@ packages: '@ungap/structured-clone@1.4.0': resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==} + '@vercel/oidc@3.2.0': + resolution: {integrity: sha512-UycprH3T6n3jH0k44NHMa7pnFHGu/N05MjojYr+Mc6I7obkoLIJujSWwin1pCvdy/eOxrI/l3uDLQsmcrOb4ug==} + engines: {node: '>= 20'} + + '@workflow/serde@4.1.0': + resolution: {integrity: sha512-pav4F2BoirECWR7Nf1TKt+2eETcBj7jj4cBefQ8VXQCA6NPkaKeLfj/zMgi+3zYV5ZIBT4GuUiphsj0/b9hPQQ==} + + ai@7.0.173: + resolution: {integrity: sha512-dLea37zT1h7cjkUsBprU4Rq35HJqhtHHaq1jTAXjHQoyfpeswpgCrhjZJWdWc10gjEAxmz114py7iLGQ3xIMxw==} + engines: {node: '>=22'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -762,6 +800,10 @@ packages: resolution: {integrity: sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==} engines: {node: '>=20.19.0'} + eventsource-parser@3.1.1: + resolution: {integrity: sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==} + engines: {node: '>=18.0.0'} + fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} @@ -851,6 +893,9 @@ packages: '@napi-rs/canvas': optional: true + json-schema@0.4.0: + resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==} + koajax@3.3.1: resolution: {integrity: sha512-rVkV3KmFJXDZ1O0OK//bRjhMVNxfwbZMI+0LZBGpj1jY0fsLOsUATtuBedDbaeU7GDMB5V2dNYqDaIhBKeeHpA==} deprecated: Don't use versions with old API & bugs @@ -1301,11 +1346,33 @@ packages: engines: {node: '>= 14.6'} hasBin: true + zod@4.6.7: + resolution: {integrity: sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==} + zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} snapshots: + '@ai-sdk/gateway@4.0.146(zod@4.6.7)': + dependencies: + '@ai-sdk/provider': 4.0.38 + '@ai-sdk/provider-utils': 5.0.81(zod@4.6.7) + '@vercel/oidc': 3.2.0 + zod: 4.6.7 + + '@ai-sdk/provider-utils@5.0.81(zod@4.6.7)': + dependencies: + '@ai-sdk/provider': 4.0.38 + '@standard-schema/spec': 1.1.0 + '@workflow/serde': 4.1.0 + eventsource-parser: 3.1.1 + zod: 4.6.7 + + '@ai-sdk/provider@4.0.38': + dependencies: + json-schema: 0.4.0 + '@babel/code-frame@7.29.7': dependencies: '@babel/helper-validator-identifier': 7.29.7 @@ -1609,6 +1676,10 @@ snapshots: '@shikijs/vscode-textmate@10.1.0': {} + '@standard-schema/spec@1.1.0': {} + + '@swc-node/core@1.15.0': {} + '@swc-node/core@1.15.0(@swc/core@1.16.22(@swc/helpers@0.5.24))(@swc/types@0.1.28)': dependencies: '@swc/core': 1.16.22(@swc/helpers@0.5.24) @@ -1631,6 +1702,22 @@ snapshots: - '@swc/types' - supports-color + '@swc-node/register@1.12.1(typescript@6.0.3)': + dependencies: + '@node-rs/xxhash': 1.7.8 + '@swc-node/core': 1.15.0 + '@swc-node/sourcemap-support': 0.6.1 + colorette: 2.0.20 + debug: 4.4.3 + fast-json-stable-stringify: 2.1.0 + oxc-resolver: 11.24.2 + pirates: 4.0.7 + tslib: 2.9.1 + typescript: 6.0.3 + transitivePeerDependencies: + - '@swc/types' + - supports-color + '@swc-node/sourcemap-support@0.6.1': dependencies: source-map-support: 0.5.21 @@ -1767,6 +1854,17 @@ snapshots: '@ungap/structured-clone@1.4.0': {} + '@vercel/oidc@3.2.0': {} + + '@workflow/serde@4.1.0': {} + + ai@7.0.173(zod@4.6.7): + dependencies: + '@ai-sdk/gateway': 4.0.146(zod@4.6.7) + '@ai-sdk/provider': 4.0.38 + '@ai-sdk/provider-utils': 5.0.81(zod@4.6.7) + zod: 4.6.7 + ansi-regex@5.0.1: {} ansi-styles@5.2.0: {} @@ -1880,6 +1978,8 @@ snapshots: entities@9.0.0: {} + eventsource-parser@3.1.1: {} + fast-json-stable-stringify@2.1.0: {} fdir@6.5.0(picomatch@4.0.7): @@ -2002,6 +2102,8 @@ snapshots: transitivePeerDependencies: - '@noble/hashes' + json-schema@0.4.0: {} + koajax@3.3.1(core-js@3.51.0)(element-internals-polyfill@3.0.2)(jsdom@31.0.1)(typescript@6.0.3): dependencies: '@swc/helpers': 0.5.24 @@ -2014,6 +2116,16 @@ snapshots: - element-internals-polyfill - typescript + koajax@3.3.1(typescript@6.0.3): + dependencies: + '@swc/helpers': 0.5.24 + regenerator-runtime: 0.14.1 + web-streams-polyfill: 4.5.1 + web-utility: 4.8.1(typescript@6.0.3) + transitivePeerDependencies: + - element-internals-polyfill + - typescript + lines-and-columns@1.2.4: {} lint-staged@17.6.0: @@ -2140,6 +2252,20 @@ snapshots: - jsdom - typescript + mobx-restful@2.1.5(mobx@7.1.7)(typescript@6.0.3): + dependencies: + '@swc/helpers': 0.5.24 + idb-keyval: 6.3.0 + koajax: 3.3.1(typescript@6.0.3) + mobx: 7.1.7 + regenerator-runtime: 0.14.1 + web-utility: 4.8.1(typescript@6.0.3) + transitivePeerDependencies: + - core-js + - element-internals-polyfill + - jsdom + - typescript + mobx@7.1.7: {} ms@2.1.3: {} @@ -2526,6 +2652,13 @@ snapshots: regenerator-runtime: 0.14.1 typescript: 6.0.3 + web-utility@4.8.1(typescript@6.0.3): + dependencies: + '@swc/helpers': 0.5.24 + mime: 4.1.2 + regenerator-runtime: 0.14.1 + typescript: 6.0.3 + webidl-conversions@8.0.1: {} whatwg-mimetype@5.0.0: {} @@ -2549,4 +2682,6 @@ snapshots: yaml@2.9.1: optional: true + zod@4.6.7: {} + zwitch@2.0.4: {}