From 3fdd12fa819c52c4428c4687756edeee47c10733 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Wed, 15 Jul 2026 15:17:33 -0400 Subject: [PATCH] feat(ai): publish package --- bun.lock | 1 + packages/ai/package.json | 44 ++++--------------- packages/ai/script/publish.ts | 38 ++++++++++++++++ packages/ai/src/index.ts | 2 +- packages/ai/src/protocols.ts | 1 + .../ai/src/protocols/bedrock-event-stream.ts | 4 +- packages/ai/src/protocols/openai-chat.ts | 2 +- packages/ai/src/providers.ts | 1 + .../ai/src/providers/google-vertex-shared.ts | 2 +- .../providers/openai-compatible/responses.ts | 1 + packages/ai/src/route.ts | 1 + packages/ai/src/route/auth-options.ts | 7 ++- packages/ai/src/route/auth.ts | 30 ++++++------- packages/ai/src/route/client.ts | 22 +++++----- packages/ai/src/route/endpoint.ts | 13 +++--- packages/ai/src/route/framing.ts | 4 +- packages/ai/src/route/index.ts | 6 +-- packages/ai/src/route/transport/http.ts | 6 +-- packages/ai/src/route/transport/index.ts | 8 ++-- packages/ai/src/tool.ts | 8 ++-- packages/ai/tsconfig.build.json | 8 ++++ packages/ai/tsconfig.json | 17 +++---- script/publish.ts | 3 ++ 23 files changed, 129 insertions(+), 100 deletions(-) create mode 100644 packages/ai/script/publish.ts create mode 100644 packages/ai/src/protocols.ts create mode 100644 packages/ai/src/providers.ts create mode 100644 packages/ai/src/providers/openai-compatible/responses.ts create mode 100644 packages/ai/src/route.ts create mode 100644 packages/ai/tsconfig.build.json diff --git a/bun.lock b/bun.lock index 1351ffe83d..260f3a16ee 100644 --- a/bun.lock +++ b/bun.lock @@ -168,6 +168,7 @@ "@tsconfig/bun": "catalog:", "@types/bun": "catalog:", "@typescript/native-preview": "catalog:", + "typescript": "catalog:", }, }, "packages/console/app": { diff --git a/packages/ai/package.json b/packages/ai/package.json index 51a46be066..36c3e22673 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -4,47 +4,18 @@ "name": "@opencode-ai/ai", "type": "module", "license": "MIT", - "private": true, "scripts": { "setup:recording-env": "bun run script/setup-recording-env.ts", "test": "bun test --timeout 30000 --only-failures", - "typecheck": "tsgo --noEmit" + "typecheck": "tsgo --noEmit", + "build": "tsc -p tsconfig.build.json" }, + "files": [ + "dist" + ], "exports": { ".": "./src/index.ts", - "./route": "./src/route/index.ts", - "./provider": "./src/provider.ts", - "./providers": "./src/providers/index.ts", - "./provider-package": "./src/provider-package.ts", - "./providers/amazon-bedrock": "./src/providers/amazon-bedrock.ts", - "./providers/anthropic": "./src/providers/anthropic.ts", - "./providers/anthropic-compatible": "./src/providers/anthropic-compatible.ts", - "./providers/azure": "./src/providers/azure.ts", - "./providers/azure/responses": "./src/providers/azure/responses.ts", - "./providers/azure/chat": "./src/providers/azure/chat.ts", - "./providers/cloudflare": "./src/providers/cloudflare.ts", - "./providers/github-copilot": "./src/providers/github-copilot.ts", - "./providers/google": "./src/providers/google.ts", - "./providers/google-vertex": "./src/providers/google-vertex.ts", - "./providers/google-vertex/anthropic": "./src/providers/google-vertex/anthropic.ts", - "./providers/openai": "./src/providers/openai.ts", - "./providers/openai/responses": "./src/providers/openai/responses.ts", - "./providers/openai/chat": "./src/providers/openai/chat.ts", - "./providers/openai-compatible": "./src/providers/openai-compatible.ts", - "./providers/openai-compatible/responses": "./src/providers/openai-compatible-responses.ts", - "./providers/openai-compatible-profile": "./src/providers/openai-compatible-profile.ts", - "./providers/openrouter": "./src/providers/openrouter.ts", - "./providers/xai": "./src/providers/xai.ts", - "./protocols": "./src/protocols/index.ts", - "./protocols/anthropic-messages": "./src/protocols/anthropic-messages.ts", - "./protocols/bedrock-converse": "./src/protocols/bedrock-converse.ts", - "./protocols/gemini": "./src/protocols/gemini.ts", - "./protocols/google-vertex-anthropic": "./src/protocols/google-vertex-anthropic.ts", - "./protocols/google-vertex-gemini": "./src/protocols/google-vertex-gemini.ts", - "./protocols/openai-chat": "./src/protocols/openai-chat.ts", - "./protocols/openai-compatible-chat": "./src/protocols/openai-compatible-chat.ts", - "./protocols/openai-compatible-responses": "./src/protocols/openai-compatible-responses.ts", - "./protocols/openai-responses": "./src/protocols/openai-responses.ts" + "./*": "./src/*.ts" }, "devDependencies": { "@clack/prompts": "1.0.0-alpha.1", @@ -52,7 +23,8 @@ "@opencode-ai/http-recorder": "workspace:*", "@tsconfig/bun": "catalog:", "@types/bun": "catalog:", - "@typescript/native-preview": "catalog:" + "@typescript/native-preview": "catalog:", + "typescript": "catalog:" }, "dependencies": { "@smithy/eventstream-codec": "4.2.14", diff --git a/packages/ai/script/publish.ts b/packages/ai/script/publish.ts new file mode 100644 index 0000000000..f03dd084b0 --- /dev/null +++ b/packages/ai/script/publish.ts @@ -0,0 +1,38 @@ +#!/usr/bin/env bun +import { Script } from "@opencode-ai/script" +import { $ } from "bun" +import { fileURLToPath } from "url" + +const dir = fileURLToPath(new URL("..", import.meta.url)) +process.chdir(dir) + +async function published(name: string, version: string) { + return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0 +} + +await $`bun run build` +const originalText = await Bun.file("package.json").text() +const pkg = JSON.parse(originalText) as { + name: string + version: string + exports: Record +} +if (await published(pkg.name, pkg.version)) { + console.log(`already published ${pkg.name}@${pkg.version}`) +} else { + for (const [key, value] of Object.entries(pkg.exports)) { + const file = value.replace("./src/", "./dist/").replace(".ts", "") + // @ts-ignore + pkg.exports[key] = { + import: file + ".js", + types: file + ".d.ts", + } + } + await Bun.write("package.json", JSON.stringify(pkg, null, 2)) + try { + await $`bun pm pack` + await $`npm publish *.tgz --tag ${Script.channel} --access public` + } finally { + await Bun.write("package.json", originalText) + } +} diff --git a/packages/ai/src/index.ts b/packages/ai/src/index.ts index 83edee7155..273861b26f 100644 --- a/packages/ai/src/index.ts +++ b/packages/ai/src/index.ts @@ -18,7 +18,7 @@ export type { AnyTool, ExecutableTool, ExecutableTools, - Tool as ToolShape, + Definition as ToolShape, ToolExecute, ToolExecuteContext, ToolModelOutputInput, diff --git a/packages/ai/src/protocols.ts b/packages/ai/src/protocols.ts new file mode 100644 index 0000000000..96aa6ee43d --- /dev/null +++ b/packages/ai/src/protocols.ts @@ -0,0 +1 @@ +export * from "./protocols/index" diff --git a/packages/ai/src/protocols/bedrock-event-stream.ts b/packages/ai/src/protocols/bedrock-event-stream.ts index d07d7de475..0312ea7d57 100644 --- a/packages/ai/src/protocols/bedrock-event-stream.ts +++ b/packages/ai/src/protocols/bedrock-event-stream.ts @@ -1,7 +1,7 @@ import { EventStreamCodec } from "@smithy/eventstream-codec" import { fromUtf8, toUtf8 } from "@smithy/util-utf8" import { Effect, Stream } from "effect" -import type { Framing } from "../route/framing" +import { Framing } from "../route/framing" import { ProviderShared } from "./shared" // Bedrock streams responses using the AWS event stream binary protocol — each @@ -79,7 +79,7 @@ const consumeFrames = (route: string) => (state: FrameBufferState, chunk: Uint8A * under its `:event-type` header so the chunk schema can match the JSON * payload directly. */ -export const framing = (route: string): Framing => ({ +export const framing = (route: string): Framing.Definition => ({ id: "aws-event-stream", frame: (bytes) => bytes.pipe(Stream.mapAccumEffect(() => initialFrameBuffer, consumeFrames(route))), }) diff --git a/packages/ai/src/protocols/openai-chat.ts b/packages/ai/src/protocols/openai-chat.ts index cba67ce0a9..c74ab7fd64 100644 --- a/packages/ai/src/protocols/openai-chat.ts +++ b/packages/ai/src/protocols/openai-chat.ts @@ -160,7 +160,7 @@ export const OpenAIChatEvent = Schema.Struct({ export type OpenAIChatEvent = Schema.Schema.Type type OpenAIChatRequestMessage = LLMRequest["messages"][number] -interface ParserState { +export interface ParserState { readonly tools: ToolStream.State readonly toolCallEvents: ReadonlyArray readonly usage?: Usage diff --git a/packages/ai/src/providers.ts b/packages/ai/src/providers.ts new file mode 100644 index 0000000000..e43654f054 --- /dev/null +++ b/packages/ai/src/providers.ts @@ -0,0 +1 @@ +export * from "./providers/index" diff --git a/packages/ai/src/providers/google-vertex-shared.ts b/packages/ai/src/providers/google-vertex-shared.ts index 48c96fd5d1..cd8a4168e6 100644 --- a/packages/ai/src/providers/google-vertex-shared.ts +++ b/packages/ai/src/providers/google-vertex-shared.ts @@ -6,7 +6,7 @@ const SCOPE = "https://www.googleapis.com/auth/cloud-platform" export type OAuthOptions = | { readonly accessToken?: string; readonly auth?: never } - | { readonly accessToken?: never; readonly auth?: Auth } + | { readonly accessToken?: never; readonly auth?: Auth.Definition } export type ApiKeyOptions = | (OAuthOptions & { readonly apiKey?: never }) diff --git a/packages/ai/src/providers/openai-compatible/responses.ts b/packages/ai/src/providers/openai-compatible/responses.ts new file mode 100644 index 0000000000..03404ca68b --- /dev/null +++ b/packages/ai/src/providers/openai-compatible/responses.ts @@ -0,0 +1 @@ +export * from "../openai-compatible-responses" diff --git a/packages/ai/src/route.ts b/packages/ai/src/route.ts new file mode 100644 index 0000000000..e76b133a7a --- /dev/null +++ b/packages/ai/src/route.ts @@ -0,0 +1 @@ +export * from "./route/index" diff --git a/packages/ai/src/route/auth-options.ts b/packages/ai/src/route/auth-options.ts index 7e40aa12a2..957ae9b311 100644 --- a/packages/ai/src/route/auth-options.ts +++ b/packages/ai/src/route/auth-options.ts @@ -4,7 +4,7 @@ import { Auth } from "./auth" export type ApiKeyMode = "optional" | "required" export type AuthOverride = { - readonly auth: Auth + readonly auth: Auth.Definition readonly apiKey?: never } @@ -44,7 +44,10 @@ export type AtLeastOne = { * override, otherwise resolve `apiKey` (option > config var) and apply it as * a bearer token. */ -export const bearer = (options: ProviderAuthOption<"optional">, envVar: string | ReadonlyArray): Auth => { +export const bearer = ( + options: ProviderAuthOption<"optional">, + envVar: string | ReadonlyArray, +): Auth.Definition => { if ("auth" in options && options.auth) return options.auth return (Array.isArray(envVar) ? envVar : [envVar]) .reduce( diff --git a/packages/ai/src/route/auth.ts b/packages/ai/src/route/auth.ts index 32871c0454..9bbbb2b84c 100644 --- a/packages/ai/src/route/auth.ts +++ b/packages/ai/src/route/auth.ts @@ -25,19 +25,19 @@ export interface AuthInput { export interface Credential { readonly load: Effect.Effect readonly orElse: (that: Credential) => Credential - readonly bearer: () => Auth - readonly header: (name: string) => Auth + readonly bearer: () => Definition + readonly header: (name: string) => Definition readonly pipe: (f: (self: Credential) => A) => A } -export interface Auth { +export interface Definition { readonly apply: (input: AuthInput) => Effect.Effect - readonly andThen: (that: Auth) => Auth - readonly orElse: (that: Auth) => Auth - readonly pipe: (f: (self: Auth) => A) => A + readonly andThen: (that: Definition) => Definition + readonly orElse: (that: Definition) => Definition + readonly pipe: (f: (self: Definition) => A) => A } -export const isAuth = (input: unknown): input is Auth => +export const isAuth = (input: unknown): input is Definition => typeof input === "object" && input !== null && "apply" in input && typeof input.apply === "function" const credential = (load: Effect.Effect): Credential => { @@ -51,8 +51,8 @@ const credential = (load: Effect.Effect): Cr return self } -const auth = (apply: Auth["apply"]): Auth => { - const self: Auth = { +const auth = (apply: Definition["apply"]): Definition => { + const self: Definition = { apply, andThen: (that) => auth((input) => apply(input).pipe(Effect.flatMap((headers) => that.apply({ ...input, headers })))), @@ -109,15 +109,15 @@ const credentialInput = (source: Secret | Credential) => ? credentialFromSecret(source, "value") : source -export function bearer(source: Secret | Credential): Auth +export function bearer(source: Secret | Credential): Definition export function bearer(source: Secret | Credential) { return credentialInput(source).bearer() } export const apiKey = bearer -export function header(name: string): (source: Secret | Credential) => Auth -export function header(name: string, source: Secret | Credential): Auth +export function header(name: string): (source: Secret | Credential) => Definition +export function header(name: string, source: Secret | Credential): Definition export function header(name: string, source?: Secret | Credential) { if (source === undefined) { return (next: Secret | Credential) => credentialInput(next).header(name) @@ -125,8 +125,8 @@ export function header(name: string, source?: Secret | Credential) { return credentialInput(source).header(name) } -export function bearerHeader(name: string): (source: Secret | Credential) => Auth -export function bearerHeader(name: string, source: Secret | Credential): Auth +export function bearerHeader(name: string): (source: Secret | Credential) => Definition +export function bearerHeader(name: string, source: Secret | Credential): Definition export function bearerHeader(name: string, source?: Secret | Credential) { const render = (input: Secret | Credential) => fromCredential(credentialInput(input), (secret) => ({ [name]: `Bearer ${secret}` })) @@ -149,7 +149,7 @@ const toLLMError = (error: AuthError): LLMError => { } export const toEffect = - (input: Auth) => + (input: Definition) => (authInput: AuthInput): Effect.Effect => input.apply(authInput).pipe(Effect.mapError(toLLMError)) diff --git a/packages/ai/src/route/client.ts b/packages/ai/src/route/client.ts index 2ef0db0222..067292329b 100644 --- a/packages/ai/src/route/client.ts +++ b/packages/ai/src/route/client.ts @@ -1,9 +1,9 @@ import { Cause, Context, Effect, Layer, Schema, Stream } from "effect" import * as Option from "effect/Option" -import { Auth, type Auth as AuthDef } from "./auth" +import { Auth } from "./auth" import { Endpoint, type EndpointPatch } from "./endpoint" import { RequestExecutor } from "./executor" -import type { Framing } from "./framing" +import { Framing } from "./framing" import { HttpTransport } from "./transport" import type { Transport, TransportRuntime } from "./transport" import { WebSocketExecutor } from "./transport" @@ -40,8 +40,8 @@ export interface Route { /** ProviderMetadata namespace emitted and consumed by this route. */ readonly providerMetadataKey?: string readonly protocol: ProtocolID - readonly endpoint: Endpoint - readonly auth: AuthDef + readonly endpoint: Endpoint.Definition + readonly auth: Auth.Definition readonly transport: Transport readonly defaults: RouteDefaults readonly body: RouteBody @@ -86,7 +86,7 @@ export interface RouteDefaultsInput { export interface RoutePatch extends RouteDefaultsInput { readonly id?: string readonly provider?: string | ProviderID - readonly auth?: AuthDef + readonly auth?: Auth.Definition readonly transport?: Transport readonly endpoint?: EndpointPatch } @@ -122,7 +122,7 @@ const mergeRouteDefaults = (base: RouteDefaults | undefined, patch: RouteDefault } } -const endpointBaseURL = (endpoint: Endpoint) => +const endpointBaseURL = (endpoint: Endpoint.Definition) => typeof endpoint.baseURL === "string" ? endpoint.baseURL : undefined const mergeHeaders = (...items: ReadonlyArray | undefined>) => { @@ -192,11 +192,11 @@ export interface MakeInput { /** Semantic API contract — owns body construction, body schema, and parsing. */ readonly protocol: Protocol /** Where the request is sent. */ - readonly endpoint: Endpoint + readonly endpoint: Endpoint.Definition /** Per-request transport auth. Provider facades override this via `route.with(...)`. */ - readonly auth?: AuthDef + readonly auth?: Auth.Definition /** Stream framing — bytes -> frames before `protocol.stream.event` decoding. */ - readonly framing: Framing + readonly framing: Framing.Definition /** Static / per-request headers added before `auth` runs. */ readonly headers?: (input: { readonly request: LLMRequest }) => Record /** Route/request defaults used when compiling requests for this route. */ @@ -213,9 +213,9 @@ export interface MakeTransportInput { /** Semantic API contract — owns body construction, body schema, and parsing. */ readonly protocol: Protocol /** Where the request is sent. */ - readonly endpoint: Endpoint + readonly endpoint: Endpoint.Definition /** Per-request transport auth. Provider facades override this via `route.with(...)`. */ - readonly auth?: AuthDef + readonly auth?: Auth.Definition /** Static / per-request headers added before `auth` runs. */ readonly headers?: (input: { readonly request: LLMRequest }) => Record /** Runnable transport route. */ diff --git a/packages/ai/src/route/endpoint.ts b/packages/ai/src/route/endpoint.ts index accbe53243..2b2077907d 100644 --- a/packages/ai/src/route/endpoint.ts +++ b/packages/ai/src/route/endpoint.ts @@ -19,21 +19,24 @@ export type EndpointPart = string | ((input: EndpointInput) => strin * URL embeds the model id, region, or another body field (e.g. Bedrock, * Gemini). */ -export interface Endpoint { +export interface Definition { readonly baseURL?: string readonly path: EndpointPart readonly query?: Record } -export type EndpointPatch = Partial> +export type EndpointPatch = Partial> /** Construct an `Endpoint` from a path string or path function. */ -export const path = (value: EndpointPart, options: Omit, "path"> = {}): Endpoint => ({ +export const path = ( + value: EndpointPart, + options: Omit, "path"> = {}, +): Definition => ({ ...options, path: value, }) -export const merge = (base: Endpoint, patch: EndpointPatch): Endpoint => ({ +export const merge = (base: Definition, patch: EndpointPatch): Definition => ({ ...base, ...patch, baseURL: patch.baseURL ?? base.baseURL, @@ -44,7 +47,7 @@ export const merge = (base: Endpoint, patch: EndpointPatch): E const renderPart = (part: EndpointPart, input: EndpointInput) => typeof part === "function" ? part(input) : part -export const render = (endpoint: Endpoint, input: EndpointInput) => { +export const render = (endpoint: Definition, input: EndpointInput) => { const url = new URL(`${ProviderShared.trimBaseUrl(endpoint.baseURL ?? "")}${renderPart(endpoint.path, input)}`) for (const [key, value] of Object.entries(endpoint.query ?? {})) url.searchParams.set(key, value) return url diff --git a/packages/ai/src/route/framing.ts b/packages/ai/src/route/framing.ts index ef4855817d..f4ec86cbf9 100644 --- a/packages/ai/src/route/framing.ts +++ b/packages/ai/src/route/framing.ts @@ -16,12 +16,12 @@ import type { LLMError } from "../schema" * The frame type is opaque to this layer; the protocol's `decode` step turns * a frame into a typed chunk. */ -export interface Framing { +export interface Definition { readonly id: string readonly frame: (bytes: Stream.Stream) => Stream.Stream } /** Server-Sent Events framing. Used by every JSON-streaming HTTP provider. */ -export const sse: Framing = { id: "sse", frame: ProviderShared.sseFraming } +export const sse: Definition = { id: "sse", frame: ProviderShared.sseFraming } export * as Framing from "./framing" diff --git a/packages/ai/src/route/index.ts b/packages/ai/src/route/index.ts index 48f4b7bc33..70db881ea4 100644 --- a/packages/ai/src/route/index.ts +++ b/packages/ai/src/route/index.ts @@ -17,9 +17,9 @@ export { Framing } from "./framing" export { Protocol } from "./protocol" export { HttpTransport, WebSocketExecutor, WebSocketTransport } from "./transport" export * as Transport from "./transport" -export type { Auth as AuthShape, AuthInput, Credential, CredentialError } from "./auth" +export type { Definition as AuthShape, AuthInput, Credential, CredentialError } from "./auth" export type { ApiKeyMode, AuthOverride, ProviderAuthOption } from "./auth-options" -export type { Endpoint as EndpointFn, EndpointInput } from "./endpoint" -export type { Framing as FramingDef } from "./framing" +export type { Definition as EndpointFn, EndpointInput } from "./endpoint" +export type { Definition as FramingDef } from "./framing" export type { Protocol as ProtocolDef } from "./protocol" export type { Transport as TransportDef, TransportRuntime } from "./transport" diff --git a/packages/ai/src/route/transport/http.ts b/packages/ai/src/route/transport/http.ts index 29da888929..785e450a5e 100644 --- a/packages/ai/src/route/transport/http.ts +++ b/packages/ai/src/route/transport/http.ts @@ -2,7 +2,7 @@ import { Effect, Stream } from "effect" import { Headers, HttpClientRequest } from "effect/unstable/http" import { Auth } from "../auth" import { render as renderEndpoint } from "../endpoint" -import { Framing, type Framing as FramingDef } from "../framing" +import { Framing } from "../framing" import type { Transport, TransportPrepareInput } from "./index" import * as ProviderShared from "../../protocols/shared" import { mergeJsonRecords, type LLMRequest } from "../../schema" @@ -18,7 +18,7 @@ export interface JsonRequestParts { export interface HttpPrepared { readonly request: HttpClientRequest.HttpClientRequest - readonly framing: FramingDef + readonly framing: Framing.Definition } const applyQuery = (url: string, query: Record | undefined) => { @@ -107,7 +107,7 @@ export const jsonRequestParts = (input: JsonRequestInput) => }) export interface HttpJsonInput<_Body, Frame> { - readonly framing: FramingDef + readonly framing: Framing.Definition } export type HttpJsonPatch = Partial> diff --git a/packages/ai/src/route/transport/index.ts b/packages/ai/src/route/transport/index.ts index fde9d6c415..cf8fef1d08 100644 --- a/packages/ai/src/route/transport/index.ts +++ b/packages/ai/src/route/transport/index.ts @@ -1,6 +1,6 @@ import type { Effect, Stream } from "effect" -import type { Endpoint } from "../endpoint" -import type { Auth } from "../auth" +import { Endpoint } from "../endpoint" +import { Auth } from "../auth" import type { Interface as RequestExecutorInterface } from "../executor" import type { Interface as WebSocketExecutorInterface } from "./websocket" import type { LLMError, LLMRequest } from "../../schema" @@ -23,8 +23,8 @@ export interface Transport { export interface TransportPrepareInput { readonly body: Body readonly request: LLMRequest - readonly endpoint: Endpoint - readonly auth: Auth + readonly endpoint: Endpoint.Definition + readonly auth: Auth.Definition readonly encodeBody: (body: Body) => string readonly headers?: (input: { readonly request: LLMRequest }) => Record } diff --git a/packages/ai/src/tool.ts b/packages/ai/src/tool.ts index 11ed9854ca..62bd0df82f 100644 --- a/packages/ai/src/tool.ts +++ b/packages/ai/src/tool.ts @@ -45,7 +45,7 @@ export type ToolToModelOutput, Success extend * Internally each tool also carries memoized codecs and a precomputed * `ToolDefinition` so callers do not rebuild them per invocation. */ -export interface Tool, Success extends ToolSchema> { +export interface Definition, Success extends ToolSchema> { readonly description: string readonly parameters: Parameters readonly success: Success @@ -68,9 +68,9 @@ export interface Tool, Success extends ToolSc readonly _definition: ToolDefinitionClass } -export type AnyTool = Tool +export type AnyTool = Definition -export type ExecutableTool, Success extends ToolSchema> = Tool< +export type ExecutableTool, Success extends ToolSchema> = Definition< Parameters, Success > & { @@ -145,7 +145,7 @@ export function make, Success extends ToolSch readonly execute?: undefined readonly toModelOutput?: ToolToModelOutput readonly toStructuredOutput?: (output: Success["Encoded"]) => unknown -}): Tool +}): Definition export function make(config: { readonly description: string readonly jsonSchema: JsonSchema.JsonSchema diff --git a/packages/ai/tsconfig.build.json b/packages/ai/tsconfig.build.json new file mode 100644 index 0000000000..2e9770e8d3 --- /dev/null +++ b/packages/ai/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./tsconfig.json", + "compilerOptions": { + "allowImportingTsExtensions": false, + "noEmit": false + } +} diff --git a/packages/ai/tsconfig.json b/packages/ai/tsconfig.json index 2bc480ffbb..dfd9a832c7 100644 --- a/packages/ai/tsconfig.json +++ b/packages/ai/tsconfig.json @@ -1,15 +1,12 @@ { - "$schema": "https://json.schemastore.org/tsconfig", + "$schema": "https://json.schemastore.org/tsconfig.json", "extends": "@tsconfig/bun/tsconfig.json", "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "declaration": true, "lib": ["ESNext", "DOM", "DOM.Iterable"], - "noUncheckedIndexedAccess": false, - "plugins": [ - { - "name": "@effect/language-service", - "transform": "@effect/language-service/transform", - "namespaceImportPackages": ["effect", "@effect/*"] - } - ] - } + "noUncheckedIndexedAccess": false + }, + "include": ["src"] } diff --git a/script/publish.ts b/script/publish.ts index 33ffef6532..7b5ca8a39d 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -38,6 +38,9 @@ await prepareReleaseFiles() console.log("\n=== schema ===\n") await $`bun ./packages/schema/script/publish.ts` +console.log("\n=== ai ===\n") +await $`bun ./packages/ai/script/publish.ts` + console.log("\n=== protocol ===\n") await $`bun ./packages/protocol/script/publish.ts`