diff --git a/packages/cli-v3/package.json b/packages/cli-v3/package.json index 1b25dafd9..838d65cb5 100644 --- a/packages/cli-v3/package.json +++ b/packages/cli-v3/package.json @@ -50,6 +50,7 @@ "@types/node": "20.14.14", "@types/object-hash": "^3.0.6", "@types/react": "^18.2.48", + "@types/resolve": "^1.20.6", "@types/semver": "^7.3.13", "@types/ws": "^8.5.3", "cpy-cli": "^5.0.0", @@ -58,12 +59,12 @@ "open": "^10.0.3", "p-retry": "^6.1.0", "rimraf": "^5.0.7", + "ts-essentials": "10.0.1", + "tshy": "^3.0.2", "type-fest": "^3.6.0", "typescript": "^5.5.4", "vitest": "^1.6.0", - "xdg-app-paths": "^8.3.0", - "tshy": "^3.0.2", - "ts-essentials": "10.0.1" + "xdg-app-paths": "^8.3.0" }, "scripts": { "typecheck": "tsc", @@ -91,57 +92,58 @@ "@opentelemetry/semantic-conventions": "1.25.1", "@trigger.dev/core": "workspace:3.0.0-beta.52", "@types/degit": "^2.8.3", + "async-sema": "^3.1.1", + "c12": "^1.11.1", "chalk": "^5.2.0", "chokidar": "^3.5.3", "cli-table3": "^0.6.3", "commander": "^9.4.1", + "defu": "^6.1.4", "degit": "^2.8.4", + "dotenv": "^16.4.5", + "esbuild": "^0.23.0", "evt": "^2.4.13", "execa": "^9.1.0", + "find-up": "^7.0.0", + "glob": "^11.0.0", + "glob-to-regexp": "^0.4.1", "gradient-string": "^2.0.2", + "hono": "^4.4.13", + "import-in-the-middle": "1.9.1", + "import-meta-resolve": "^4.1.0", "ink": "^4.4.1", "jsonc-parser": "3.2.1", "liquidjs": "^10.9.2", + "magicast": "^0.3.4", + "minimatch": "^10.0.1", + "mlly": "^1.7.1", "mock-fs": "^5.2.0", "nanoid": "^4.0.2", "node-fetch": "^3.3.0", "object-hash": "^3.0.0", "p-debounce": "^4.0.0", "p-throttle": "^6.1.0", + "package-json-from-dist": "^1.0.0", "partysocket": "^0.0.17", + "pkg-types": "^1.1.3", "proxy-agent": "^6.3.0", "react": "^18.2.0", - "react-error-boundary": "^4.0.12", + "react-error-boundary": "^3.1.4", + "resolve": "^1.22.8", "semver": "^7.5.0", + "signal-exit": "^4.1.0", "simple-git": "^3.19.0", + "source-map-support": "0.5.21", "terminal-link": "^3.0.0", "tiny-invariant": "^1.2.0", "tsconfig-paths": "^4.2.0", "typescript": "^5.4.0", + "unplugin": "^1.12.0", "update-check": "^1.5.4", "url": "^0.11.1", "ws": "^8.12.0", - "zod-validation-error": "^1.5.0", - "async-sema": "^3.1.1", - "c12": "^1.11.1", - "defu": "^6.1.4", - "dotenv": "^16.4.5", - "esbuild": "^0.23.0", - "find-up": "^7.0.0", - "glob": "^11.0.0", - "glob-to-regexp": "^0.4.1", - "hono": "^4.4.13", - "import-in-the-middle": "1.9.1", - "import-meta-resolve": "^4.1.0", - "magicast": "^0.3.4", - "mlly": "^1.7.1", - "package-json-from-dist": "^1.0.0", - "pkg-types": "^1.1.3", - "resolve": "^1.22.8", - "signal-exit": "^4.1.0", - "source-map-support": "0.5.21", - "unplugin": "^1.12.0", - "zod": "3.23.8" + "zod": "3.23.8", + "zod-validation-error": "^1.5.0" }, "engines": { "node": ">=18.20.0" diff --git a/packages/cli-v3/src/apiClient.ts b/packages/cli-v3/src/apiClient.ts index 3b65f4582..a042a25d1 100644 --- a/packages/cli-v3/src/apiClient.ts +++ b/packages/cli-v3/src/apiClient.ts @@ -121,13 +121,7 @@ export class CliApiClient { }); } - async getProjectEnv({ - projectRef, - env, - }: { - projectRef: string; - env: "dev" | "prod" | "staging"; - }) { + async getProjectEnv({ projectRef, env }: { projectRef: string; env: string }) { if (!this.accessToken) { throw new Error("getProjectDevEnv: No access token"); } diff --git a/packages/cli-v3/src/build/bundle.ts b/packages/cli-v3/src/build/bundle.ts new file mode 100644 index 000000000..4aba4ee4a --- /dev/null +++ b/packages/cli-v3/src/build/bundle.ts @@ -0,0 +1,213 @@ +import { ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { BuildTarget, TaskFile } from "@trigger.dev/core/v3/schemas"; +import * as esbuild from "esbuild"; +import { join, resolve } from "node:path"; +import { logger } from "../utilities/logger.js"; +import { packageModules, shims } from "./packageModules.js"; +import { buildPlugins } from "./plugins.js"; + +export interface BundleOptions { + target: BuildTarget; + destination: string; + cwd: string; + resolvedConfig: ResolvedConfig; + jsxFactory?: string; + jsxFragment?: string; + jsxAutomatic?: boolean; + watch?: boolean; + plugins?: esbuild.Plugin[]; +} + +export type BundleResult = { + files: TaskFile[]; + configPath: string; + loaderPath: string | undefined; + workerProdPath: string | undefined; + workerDevPath: string | undefined; + stop: (() => Promise) | undefined; +}; + +export async function bundleWorker( + options: BundleOptions +): Promise { + const { resolvedConfig } = options; + + // We need to add the package entry points here somehow + // Then we need to get them out of the build result into the build manifest + // taskhero/dist/esm/workers/dev.js + // taskhero/dist/esm/telemetry/loader.js + const entryPoints = await getEntryPoints(resolvedConfig); + const $buildPlugins = await buildPlugins(options.target, resolvedConfig); + + let initialBuildResult: (result: esbuild.BuildResult) => void; + const initialBuildResultPromise = new Promise( + (resolve) => (initialBuildResult = resolve) + ); + const buildResultPlugin: esbuild.Plugin = { + name: "Initial build result plugin", + setup(build) { + build.onEnd(initialBuildResult); + }, + }; + + const buildOptions: esbuild.BuildOptions & { metafile: true } = { + entryPoints, + outdir: options.destination, + absWorkingDir: options.cwd, + bundle: true, + metafile: true, + write: true, + minify: false, + splitting: true, + charset: "utf8", + platform: "node", + sourcemap: true, + sourcesContent: options.target === "dev", + conditions: ["taskhero", "node"], + format: "esm", + target: ["node20", "es2022"], + loader: { + ".js": "jsx", + ".mjs": "jsx", + ".cjs": "jsx", + ".wasm": "copy", + }, + outExtension: { ".js": ".mjs" }, + inject: [...shims], // TODO: copy this into the working dir to work with Yarn PnP + jsx: options.jsxAutomatic ? "automatic" : undefined, + jsxDev: options.jsxAutomatic && options.target === "dev" ? true : undefined, + plugins: [...$buildPlugins, ...(options.plugins ?? []), buildResultPlugin], + ...(options.jsxFactory && { jsxFactory: options.jsxFactory }), + ...(options.jsxFragment && { jsxFragment: options.jsxFragment }), + logLevel: "silent", + logOverride: { + 'empty-glob': 'silent', + }, + }; + + let result: esbuild.BuildResult; + let stop: BundleResult["stop"]; + + logger.debug("Building worker with options", buildOptions); + + if (options.watch) { + const ctx = await esbuild.context(buildOptions); + await ctx.watch(); + result = await initialBuildResultPromise; + if (result.errors.length > 0) { + throw new Error("Failed to build"); + } + + stop = async function () { + await ctx.dispose(); + }; + } else { + result = await esbuild.build(buildOptions); + // Even when we're not watching, we still want some way of cleaning up the + // temporary directory when we don't need it anymore + stop = async function () {}; + } + + const bundleResult = getBundleResultFromBuild(options.cwd, result); + + if (!bundleResult) { + throw new Error("Failed to get bundle result"); + } + + return { ...bundleResult, stop }; +} + +export function getBundleResultFromBuild( + workingDir: string, + result: esbuild.BuildResult<{ metafile: true }> +): Omit | undefined { + const files: Array<{ entry: string; out: string }> = []; + const imports = new Set(); + let configPath: string | undefined; + let loaderPath: string | undefined; + let workerDevPath: string | undefined; + let workerProdPath: string | undefined; + + for (const [outputPath, outputMeta] of Object.entries( + result.metafile.outputs + )) { + if (outputPath.endsWith(".mjs")) { + const $outputPath = resolve(workingDir, outputPath); + + if (outputMeta.entryPoint) { + if (outputMeta.entryPoint.startsWith("trigger.config.ts")) { + configPath = $outputPath; + } else if ( + outputMeta.entryPoint.includes( + "dist/esm/telemetry/loader.js" + ) + ) { + loaderPath = $outputPath; + } else if ( + outputMeta.entryPoint.includes("dist/esm/workers/dev.js") + ) { + workerDevPath = $outputPath; + } else if ( + outputMeta.entryPoint.includes("dist/esm/workers/prod.js") + ) { + workerProdPath = $outputPath; + } else { + files.push({ + entry: outputMeta.entryPoint, + out: $outputPath, + }); + } + } + } + } + + if (!configPath) { + return undefined; + } + + return { + files, + configPath: configPath, + loaderPath, + workerDevPath, + workerProdPath, + }; +} + +async function getEntryPoints(config: ResolvedConfig) { + const projectEntryPoints = config.dirs.flatMap((dir) => dirToEntryPointGlob(dir)); + + if (config.configFile) { + projectEntryPoints.push(config.configFile); + } + + projectEntryPoints.push(...packageModules); + + return projectEntryPoints; +} + +// Converts a directory to a glob that matches all the entry points in that +function dirToEntryPointGlob(dir: string): string[] { + return [join(dir, "**", "*.ts"), join(dir, "**", "*.tsx"), join(dir, "**", "*.js"), join(dir, "**", "*.jsx")]; +} + + + +export function logBuildWarnings(warnings: esbuild.Message[]) { + const logs = esbuild.formatMessagesSync(warnings, { kind: "warning", color: true }); + for (const log of logs) { + console.warn(log); + } +} + +/** + * Logs all errors/warnings associated with an esbuild BuildFailure in the same + * style esbuild would. + */ +export function logBuildFailure(errors: esbuild.Message[], warnings: esbuild.Message[]) { + const logs = esbuild.formatMessagesSync(errors, { kind: "error", color: true }); + for (const log of logs) { + console.error(log); + } + logBuildWarnings(warnings); +} \ No newline at end of file diff --git a/packages/cli-v3/src/build/extensions.ts b/packages/cli-v3/src/build/extensions.ts new file mode 100644 index 000000000..eb89e4955 --- /dev/null +++ b/packages/cli-v3/src/build/extensions.ts @@ -0,0 +1,179 @@ +import * as esbuild from "esbuild"; +import { resolveModule } from "./resolveModule.js"; +import { BuildContext, BuildExtension, BuildLayer, RegisteredPlugin, RegisterPluginOptions, ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { BuildManifest, BuildTarget } from "@trigger.dev/core/v3/schemas"; +import { logger } from "../utilities/logger.js"; + +export function createExtensionForPlugin( + plugin: esbuild.Plugin, + options: RegisterPluginOptions = {} +): BuildExtension { + return { + name: plugin.name, + onBuildStart(context) { + context.registerPlugin(plugin, options); + }, + }; +} + +export interface InternalBuildContext extends BuildContext { + getLayers(): BuildLayer[]; + clearLayers(): void; + getPlugins(): RegisteredPlugin[]; + appendExtension(extension: BuildExtension): void; + prependExtension(extension: BuildExtension): void; + getExtensions(): BuildExtension[]; +} + +export async function notifyExtensionOnBuildStart( + context: InternalBuildContext +) { + for (const extension of context.getExtensions()) { + if (extension.onBuildStart) { + await extension.onBuildStart(context); + } + } +} + +export async function notifyExtensionOnBuildComplete( + context: InternalBuildContext, + manifest: BuildManifest +): Promise { + let $manifest = manifest; + + for (const extension of context.getExtensions()) { + if (extension.onBuildComplete) { + await extension.onBuildComplete(context, $manifest); + logger.debug(`Applying extension ${extension.name} to manifest`, { + context, + manifest, + }); + $manifest = applyContextLayersToManifest(context, $manifest); + } + } + + return $manifest; +} + +export function createBuildContext( + target: BuildTarget, + config: ResolvedConfig +): InternalBuildContext { + const layers: BuildLayer[] = []; + const registeredPlugins: RegisteredPlugin[] = []; + const extensions: BuildExtension[] = config.build.extensions ?? []; + + return { + target, + config: config, + workingDir: config.workingDir, + addLayer(layer) { + layers.push(layer); + }, + getLayers() { + return layers; + }, + clearLayers() { + layers.splice(0); + }, + registerPlugin(plugin, options) { + if (options?.target && options.target !== target) { + return; + } + + registeredPlugins.push({ plugin, ...options }); + }, + getPlugins() { + return registeredPlugins; + }, + resolvePath: async (path) => { + try { + return await resolveModule(path, config.workingDir); + } catch (error) { + return undefined; + } + }, + getExtensions() { + return extensions; + }, + appendExtension(extension) { + extensions.push(extension); + }, + prependExtension(extension) { + extensions.unshift(extension); + }, + }; +} + +function applyContextLayersToManifest( + context: InternalBuildContext, + manifest: BuildManifest +): BuildManifest { + for (const layer of context.getLayers()) { + manifest = applyLayerToManifest(layer, manifest); + } + + context.clearLayers(); + + return manifest; +} + +function applyLayerToManifest( + layer: BuildLayer, + manifest: BuildManifest +): BuildManifest { + let $manifest = { ...manifest }; + + if (layer.commands) { + manifest.build.commands ??= []; + manifest.build.commands = manifest.build.commands.concat(layer.commands); + } + + if (layer.build?.env) { + manifest.build.env ??= {}; + Object.assign(manifest.build.env, layer.build.env); + } + + if (layer.deploy?.env) { + manifest.deploy.env ??= {}; + Object.assign(manifest.deploy.env, layer.deploy.env); + } + + if (layer.dependencies) { + const externals = manifest.externals ?? []; + + for (const [name, version] of Object.entries(layer.dependencies)) { + externals.push({ name, version }); + } + + $manifest.externals = externals; + } + + return $manifest; +} + +export function resolvePluginsForContext( + context: InternalBuildContext +): esbuild.Plugin[] { + const registeredPlugins = context.getPlugins(); + + if (registeredPlugins.length === 0) { + return []; + } + + const sortedPlugins = [...registeredPlugins].sort((a, b) => { + const order = { first: 0, undefined: 1, last: 2, $head: -1 }; + const aOrder = order[a.placement as keyof typeof order] ?? 1; + const bOrder = order[b.placement as keyof typeof order] ?? 1; + + // If the placement order is different, sort based on that + if (aOrder !== bOrder) { + return aOrder - bOrder; + } + + // If the placement order is the same, maintain original order + return registeredPlugins.indexOf(a) - registeredPlugins.indexOf(b); + }); + + return sortedPlugins.map((plugin) => plugin.plugin); +} diff --git a/packages/cli-v3/src/build/externals.ts b/packages/cli-v3/src/build/externals.ts new file mode 100644 index 000000000..904b38497 --- /dev/null +++ b/packages/cli-v3/src/build/externals.ts @@ -0,0 +1,280 @@ + +import * as esbuild from "esbuild"; +import { makeRe } from "minimatch"; +import { mkdir, symlink } from "node:fs/promises"; +import { dirname, join } from "node:path"; +import { readPackageJSON, resolvePackageJSON } from "pkg-types"; +import nodeResolve from "resolve"; +import { getInstrumentedPackageNames } from "./instrumentation.js"; +import { BuildTarget } from "@trigger.dev/core/v3/schemas"; +import { BuildExtension, ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { logger } from "../utilities/logger.js"; + +const FORCED_EXTERNALS = ["import-in-the-middle"]; + +/** + * externals in dev might not be resolvable from the worker directory + * for example, if the external is not an immediate dependency of the project + * and the project is not hoisting the dependency (e.g. pnpm, npm with nested) + * + * This function will create a symbolic link from a place where the external is resolvable + * to the actual resolved external path + */ +async function linkUnresolvableExternals( + externals: Array, + resolveDir: string +) { + for (const external of externals) { + if (!(await isExternalResolvable(external, resolveDir))) { + logger.debug("External is not resolvable", { external }); + await linkExternal(external, resolveDir); + } + } +} + +async function linkExternal(external: CollectedExternal, resolveDir: string) { + const destinationPath = join(resolveDir, "node_modules"); + await mkdir(destinationPath, { recursive: true }); + + logger.debug("Make a symbolic link", { + fromPath: external.path, + destinationPath, + external, + }); + await symlink(external.path, join(destinationPath, external.name), "dir"); +} + +async function isExternalResolvable( + external: CollectedExternal, + resolveDir: string +) { + try { + const resolvedPath = nodeResolve.sync(external.name, { + basedir: resolveDir, + }); + + logger.debug("Resolved external", { + external, + resolvedPath, + }); + + return true; + } catch (e) { + console.error("Could not resolve external", { external, resolveDir, e }); + return false; + } +} + +export type CollectedExternal = { + name: string; + path: string; + version: string; +}; + +export type ExternalsCollector = { + externals: Array; + plugin: esbuild.Plugin; +}; + +function createExternalsCollector( + target: BuildTarget, + resolvedConfig: ResolvedConfig +): ExternalsCollector { + const externals: Array = []; + + const maybeExternals = discoverMaybeExternals(target, resolvedConfig); + + logger.debug("Maybe externals", { maybeExternals }); + + return { + externals, + plugin: { + name: "externals", + setup: (build) => { + build.onStart(async () => { + externals.splice(0); + }); + + build.onEnd(async () => { + logger.debug("Collected externals", { externals }); + }); + + maybeExternals.forEach((external) => { + build.onResolve( + { filter: external.filter, namespace: "file" }, + async (args) => { + const resolvedPath = nodeResolve.sync(args.path, { + basedir: args.resolveDir, + }); + + logger.debug("Resolved external", { + external, + resolvedPath, + args, + }); + + const packageJsonPath = await resolvePackageJSON( + dirname(resolvedPath) + ); + + if (!packageJsonPath) { + return undefined; + } + + logger.debug("Found package.json", { packageJsonPath }); + + const packageJson = await readPackageJSON(packageJsonPath); + + if (!packageJson || !packageJson.name) { + return undefined; + } + + if (!external.filter.test(packageJson.name)) { + logger.debug("Package name does not match", { + external, + packageJson, + }); + + return undefined; + } + + if (!packageJson.version) { + logger.debug("No version found in package.json", { + external, + packageJson, + }); + + return undefined; + } + + externals.push({ + name: packageJson.name, + path: dirname(packageJsonPath), + version: packageJson.version, + }); + + logger.debug("Resolved external", { + external, + resolvedPath, + args, + }); + + return { + external: true, + }; + } + ); + }); + }, + }, + }; +} + +type MaybeExternal = { raw: string; filter: RegExp }; + +function discoverMaybeExternals( + target: BuildTarget, + config: ResolvedConfig +): Array { + const external: Array = []; + + for (const externalName of FORCED_EXTERNALS) { + const externalRegex = makeRe(externalName); + + if (!externalRegex) { + continue; + } + + external.push({ + raw: externalName, + filter: new RegExp( + `^${externalName}$|${externalRegex.source}` + ), + }); + } + + if (config.build?.external) { + for (const externalName of config.build?.external) { + const externalRegex = makeRe(externalName); + + if (!externalRegex) { + continue; + } + + external.push({ + raw: externalName, + filter: externalRegex, + }); + } + } + + for (const externalName of getInstrumentedPackageNames(config)) { + const externalRegex = makeRe(externalName); + + if (!externalRegex) { + continue + } + + external.push({ + raw: externalName, + filter: new RegExp( + `^${externalName}$|${externalRegex.source}` + ), + }); + } + + for (const buildExtension of config.build?.extensions ?? []) { + const moduleExternals = buildExtension.externalsForTarget?.(target); + + for (const externalName of moduleExternals ?? []) { + const externalRegex = makeRe(externalName); + + if (!externalRegex) { + continue; + } + + external.push({ + raw: externalName, + filter: new RegExp( + `^${externalName}$|${externalRegex.source}` + ), + }); + } + } + + return external; +} + +export function createExternalsBuildExtension( + target: BuildTarget, + config: ResolvedConfig +): BuildExtension { + const { externals, plugin } = createExternalsCollector(target, config); + + return { + name: "externals", + onBuildStart(context) { + context.registerPlugin(plugin, { + target, + // @ts-expect-error + placement: "$head", // cheat to get to the front of the plugins + }); + }, + onBuildComplete: async (context, manifest) => { + if (context.target === "dev") { + await linkUnresolvableExternals(externals, manifest.outputPath); + } + + context.addLayer({ + id: "externals", + dependencies: externals.reduce( + (acc, external) => { + acc[external.name] = external.version; + return acc; + }, + {} as Record + ), + }); + }, + }; +} diff --git a/packages/cli-v3/src/build/instrumentation.ts b/packages/cli-v3/src/build/instrumentation.ts new file mode 100644 index 000000000..e60bd423f --- /dev/null +++ b/packages/cli-v3/src/build/instrumentation.ts @@ -0,0 +1,29 @@ +import { InstrumentationModuleDefinition } from "@opentelemetry/instrumentation"; +import { ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { builtinModules } from "node:module"; + +export function getInstrumentedPackageNames( + config: ResolvedConfig +): Array { + const packageNames = []; + + if (config.instrumentations) { + for (const instrumentation of config.instrumentations) { + const moduleDefinitions = ( + instrumentation as any + ).getModuleDefinitions?.() as Array; + + if (!Array.isArray(moduleDefinitions)) { + continue + } + + for (const moduleDefinition of moduleDefinitions) { + if (!builtinModules.includes(moduleDefinition.name)) { + packageNames.push(moduleDefinition.name); + } + } + } + } + + return packageNames; +} diff --git a/packages/cli-v3/src/build/manifests.ts b/packages/cli-v3/src/build/manifests.ts new file mode 100644 index 000000000..090d41ff0 --- /dev/null +++ b/packages/cli-v3/src/build/manifests.ts @@ -0,0 +1,29 @@ +import { BuildManifest } from "@trigger.dev/core/v3/schemas"; +import { cp } from "node:fs/promises"; +import { logger } from "../utilities/logger.js"; + +export async function copyManifestToDir(manifest: BuildManifest, source: string, destination: string): Promise { + // Copy the dir in destination to workerDir + await cp(source, destination, { recursive: true }); + + logger.debug("Copied manifest to dir", { source, destination }); + + // Then update the manifest to point to the new workerDir + const updatedManifest = { ...manifest }; + + updatedManifest.configPath = updatedManifest.configPath.replace(source, destination); + updatedManifest.loaderPath = updatedManifest.loaderPath?.replace(source, destination); + updatedManifest.workerEntryPath = updatedManifest.workerEntryPath?.replace(source, destination); + updatedManifest.workerForkPath = updatedManifest.workerForkPath?.replace(source, destination); + + updatedManifest.files = updatedManifest.files.map((file) => { + return { + ...file, + out: file.out.replace(source, destination), + }; + }); + + updatedManifest.outputPath = destination; + + return updatedManifest; +} \ No newline at end of file diff --git a/packages/cli-v3/src/build/packageModules.ts b/packages/cli-v3/src/build/packageModules.ts new file mode 100644 index 000000000..f5d99852a --- /dev/null +++ b/packages/cli-v3/src/build/packageModules.ts @@ -0,0 +1,18 @@ +import { join } from "node:path"; +import { sourceDir } from "../sourceDir.js"; + +export const devEntryPoint = join(sourceDir, "workers", "dev.js") +export const prodEntryPoint = join(sourceDir, "workers", "prod.js") +export const telemetryLoader = join(sourceDir, "telemetry", "loader.js") + +export const packageModules = [ + devEntryPoint, + prodEntryPoint, + telemetryLoader, +] + +export const esmShimPath = join(sourceDir, "shims", "esm.js") + +export const shims = [ + esmShimPath +] \ No newline at end of file diff --git a/packages/cli-v3/src/build/plugins.ts b/packages/cli-v3/src/build/plugins.ts new file mode 100644 index 000000000..12abb223c --- /dev/null +++ b/packages/cli-v3/src/build/plugins.ts @@ -0,0 +1,41 @@ +import * as esbuild from "esbuild"; +import { BuildTarget } from "@trigger.dev/core/v3/schemas"; +import { ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { configPlugin } from "../config.js"; +import { logger } from "../utilities/logger.js"; + +export async function buildPlugins( + target: BuildTarget, + resolvedConfig: ResolvedConfig +): Promise { + logger.debug("Building plugins for target", target); + + const plugins: esbuild.Plugin[] = []; + + const $configPlugin = configPlugin(resolvedConfig); + + if ($configPlugin) { + plugins.push($configPlugin); + } + + return plugins; +} + +export function analyzeMetadataPlugin(): esbuild.Plugin { + return { + name: "analyze-metafile", + setup(build) { + build.onEnd(async (result) => { + if (!result.metafile) { + return; + } + + console.log( + await esbuild.analyzeMetafile(result.metafile, { + verbose: true, + }) + ); + }); + }, + }; +} diff --git a/packages/cli-v3/src/build/resolveModule-cjs.cts b/packages/cli-v3/src/build/resolveModule-cjs.cts new file mode 100644 index 000000000..9f6ee481c --- /dev/null +++ b/packages/cli-v3/src/build/resolveModule-cjs.cts @@ -0,0 +1,4 @@ +export function resolveModule(moduleName: string) { + // @ts-ignore + return require.resolve(moduleName); +} diff --git a/packages/cli-v3/src/build/resolveModule.ts b/packages/cli-v3/src/build/resolveModule.ts new file mode 100644 index 000000000..183ef05d6 --- /dev/null +++ b/packages/cli-v3/src/build/resolveModule.ts @@ -0,0 +1,9 @@ +// @ts-ignore +import { resolvePath } from "mlly"; + +export function resolveModule(moduleName: string, url?: string) { + return resolvePath(moduleName, { + // @ts-ignore + url: url ?? import.meta.url, + }); +} diff --git a/packages/cli-v3/src/commands/dev.tsx b/packages/cli-v3/src/commands/dev.tsx index 190ae582a..2d5b7269b 100644 --- a/packages/cli-v3/src/commands/dev.tsx +++ b/packages/cli-v3/src/commands/dev.tsx @@ -5,7 +5,14 @@ import { CommonCommandOptions, commonOptions, wrapCommandAction } from "../cli/c import { chalkError } from "../utilities/cliOutput.js"; import { logger } from "../utilities/logger.js"; import { runtimeCheck } from "../utilities/runtimeCheck.js"; -import { isLoggedIn } from "../utilities/session.js"; +import { getProjectClient, isLoggedIn, LoginResultOk } from "../utilities/session.js"; +import { printDevBanner, printStandloneInitialBanner } from "../utilities/initialBanner.js"; +import { updateTriggerPackages } from "./update.js"; +import { watchConfig } from "../config.js"; +import { ResolvedConfig } from "@trigger.dev/core/v3/build"; +import Dev from "../dev/dev.js"; +import { render } from "ink"; +import React from "react"; let apiClient: CliApiClient | undefined; @@ -17,7 +24,7 @@ const DevCommandOptions = CommonCommandOptions.extend({ skipUpdateCheck: z.boolean().default(false), }); -type DevCommandOptions = z.infer; +export type DevCommandOptions = z.infer; export function configureDevCommand(program: Command) { return commonOptions( @@ -33,9 +40,9 @@ export function configureDevCommand(program: Command) { .option("--debugger", "Enable the debugger") .option("--debug-otel", "Enable OpenTelemetry debugging") .option("--skip-update-check", "Skip checking for @trigger.dev package updates") - ).action(async (path, options) => { + ).action(async (_, options) => { wrapCommandAction("dev", DevCommandOptions, options, async (opts) => { - await devCommand(path, opts); + await devCommand(opts); }); }); } @@ -43,7 +50,7 @@ export function configureDevCommand(program: Command) { const MINIMUM_NODE_MAJOR = 18; const MINIMUM_NODE_MINOR = 20; -export async function devCommand(dir: string, options: DevCommandOptions) { +export async function devCommand(options: DevCommandOptions) { try { runtimeCheck(MINIMUM_NODE_MAJOR, MINIMUM_NODE_MINOR); } catch (e) { @@ -71,4 +78,97 @@ export async function devCommand(dir: string, options: DevCommandOptions) { process.exitCode = 1; return; } + + let watcher; + try { + const devInstance = await startDev({ ...options, cwd: process.cwd(), login: authorization }); + watcher = devInstance.watcher; + const { waitUntilExit } = devInstance.devReactElement; + await waitUntilExit(); + } finally { + await watcher?.stop(); + } +} + +type StartDevOptions = DevCommandOptions & { + login: LoginResultOk; + cwd: string; +}; + +async function startDev(options: StartDevOptions) { + logger.debug("Starting dev CLI", { options }); + + let watcher: Awaited> | undefined; + let rerender: (node: React.ReactNode) => void | undefined; + + try { + if (options.logLevel) { + logger.loggerLevel = options.logLevel; + } + + await printStandloneInitialBanner(true); + + let displayedUpdateMessage = false; + + if (!options.skipUpdateCheck) { + displayedUpdateMessage = await updateTriggerPackages(options.cwd, { ...options }, true, true); + } + + printDevBanner(displayedUpdateMessage); + + watcher = await watchConfig({ + cwd: options.cwd, + async onUpdate(config) { + logger.debug("Updated config, rerendering", { config }); + rerender(await getDevReactElement(config)); + }, + overrides: { + project: options.projectRef, + }, + configFile: options.config, + }); + + logger.debug("Initial config", watcher.config); + + // eslint-disable-next-line no-inner-declarations + async function getDevReactElement(configParam: ResolvedConfig) { + const projectClient = await getProjectClient({ + accessToken: options.login.auth.accessToken, + apiUrl: options.login.auth.apiUrl, + projectRef: configParam.project, + env: "dev", + profile: options.profile, + }); + + if (!projectClient) { + process.exit(1); + } + + return ( + + ); + } + + const devReactElement = render(await getDevReactElement(watcher.config)); + rerender = devReactElement.rerender; + + return { + devReactElement, + watcher, + stop: async () => { + devReactElement.unmount(); + await watcher?.stop(); + }, + }; + } catch (error) { + await watcher?.stop(); + throw error; + } } diff --git a/packages/cli-v3/src/config.ts b/packages/cli-v3/src/config.ts index 1a9f3ea38..0eefec4d7 100644 --- a/packages/cli-v3/src/config.ts +++ b/packages/cli-v3/src/config.ts @@ -7,9 +7,12 @@ import { readdir } from "node:fs/promises"; import { basename, dirname, isAbsolute, join, relative } from "node:path"; import { findWorkspaceDir, resolveLockfile, resolvePackageJSON, resolveTSConfig } from "pkg-types"; import { generateCode, loadFile } from "./imports/magicast.js"; +import { logger } from "./utilities/logger.js"; export type ResolveConfigOptions = { cwd?: string; + overrides?: Partial; + configFile?: string; }; export async function loadConfig({ @@ -40,19 +43,22 @@ export async function watchConfig({ onUpdate, debounce = 100, ignoreInitial = true, + overrides, + configFile, }: ResolveWatchConfigOptions): Promise { const result = await c12.watchConfig({ name: "trigger", + configFile, cwd, debounce, chokidarOptions: { ignoreInitial }, acceptHMR: async ({ oldConfig, newConfig, getDiff }) => { const diff = getDiff(); - console.log("watchConfig.acceptHMR", { diff, oldConfig, newConfig }); + logger.debug("watchConfig.acceptHMR", { diff, oldConfig, newConfig }); if (diff.length === 0) { - console.log("No config changed detected!"); + logger.debug("No config changed detected!"); return true; // No changes! } @@ -62,17 +68,17 @@ export async function watchConfig({ const diff = getDiff(); if (diff.length === 0) { - console.log("No config changed detected!"); + logger.debug("No config changed detected!"); return; } - const resolvedConfig = await resolveConfig(cwd, newConfig); + const resolvedConfig = await resolveConfig(cwd, newConfig, overrides); onUpdate(resolvedConfig); }, }); - const config = await resolveConfig(cwd, result); + const config = await resolveConfig(cwd, result, overrides); return { config, @@ -96,10 +102,10 @@ export function configPlugin(resolvedConfig: ResolvedConfig): esbuild.Plugin | u // Convert the filename to a regex to filter against const filter = new RegExp(`${filename.replace(/\./g, "\\.")}$`); - console.log("trigger-config-strip.filter", filter); + logger.debug("trigger-config-strip.filter", filter); build.onLoad({ filter }, async (args) => { - console.log("trigger-config-strip.onLoad", args); + logger.debug("trigger-config-strip.onLoad", args); const $mod = await loadFile(args.path); @@ -113,7 +119,7 @@ export function configPlugin(resolvedConfig: ResolvedConfig): esbuild.Plugin | u const contents = generateCode($mod); - console.log("trigger-config-strip.onLoad.contents", contents); + logger.debug("trigger-config-strip.onLoad.contents", contents); return { contents: contents.code, @@ -127,7 +133,8 @@ export function configPlugin(resolvedConfig: ResolvedConfig): esbuild.Plugin | u async function resolveConfig( cwd: string, - result: c12.ResolvedConfig + result: c12.ResolvedConfig, + overrides?: Partial ): Promise { const packageJsonPath = await resolvePackageJSON(cwd); const tsconfigPath = await resolveTSConfig(cwd); @@ -149,6 +156,7 @@ async function resolveConfig( lockfilePath, workspaceDir, }, + overrides, result.config, { dirs, diff --git a/packages/cli-v3/src/dev/dev.tsx b/packages/cli-v3/src/dev/dev.tsx new file mode 100644 index 000000000..39bc0edcd --- /dev/null +++ b/packages/cli-v3/src/dev/dev.tsx @@ -0,0 +1,83 @@ +import { Text, useApp, useStdin } from "ink"; +import React, { useEffect } from "react"; +import { withErrorBoundary } from "react-error-boundary"; +import { DevSessionOptions, startDevSession } from "./devSession.js"; + +export type DevProps = DevSessionOptions; + +export function DevImplementation(props: DevProps): JSX.Element { + // only load the UI if we're running in a supported environment + const { isRawModeSupported } = useStdin(); + const { exit } = useApp(); + + const onErr = (error: Error) => { + exit(error); + }; + + return props.showInteractiveDevSession ?? isRawModeSupported ? ( + + ) : ( + + ); +} + +type DevSessionProps = DevProps & { + onErr: (error: Error) => void; +}; + +function InteractiveDevSession(props: DevSessionProps) { + return ( + <> + + + ); +} + +function DevSession(props: DevSessionProps) { + const dev = useDev(props); + + return <>; +} + +function useDev(props: DevSessionProps) { + useEffect(() => { + let watcher: Awaited> | undefined; + + async function run() { + watcher = await startDevSession(props); + } + + run().catch((error) => { + // If esbuild fails on first run, we want to quit the process + // since we can't recover from here + // related: https://github.com/evanw/esbuild/issues/1037 + props.onErr(error); + }); + + return () => { + watcher?.stop(); + }; + }, [ + props.client, + props.initialMode, + props.name, + props.rawArgs, + props.rawConfig, + props.showInteractiveDevSession, + ]); +} + +function ErrorFallback(props: { error: Error }) { + const { exit } = useApp(); + useEffect(() => exit(props.error)); + return ( + <> + Something went wrong: + {props.error.stack} + + ); +} + +export default withErrorBoundary(DevImplementation, { + FallbackComponent: ErrorFallback, +}) as React.ComponentType; diff --git a/packages/cli-v3/src/dev/devSession.ts b/packages/cli-v3/src/dev/devSession.ts new file mode 100644 index 000000000..873d5a42e --- /dev/null +++ b/packages/cli-v3/src/dev/devSession.ts @@ -0,0 +1,159 @@ +import { DEFAULT_RUNTIME, ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { BuildManifest } from "@trigger.dev/core/v3/schemas"; +import * as esbuild from "esbuild"; +import { CliApiClient } from "../apiClient.js"; +import { + BundleResult, + bundleWorker, + getBundleResultFromBuild, + logBuildFailure, + logBuildWarnings, +} from "../build/bundle.js"; +import { + createBuildContext, + notifyExtensionOnBuildComplete, + notifyExtensionOnBuildStart, + resolvePluginsForContext, +} from "../build/extensions.js"; +import { createExternalsBuildExtension } from "../build/externals.js"; +import { devEntryPoint, telemetryLoader } from "../build/packageModules.js"; +import { type DevCommandOptions } from "../commands/dev.js"; +import { logger } from "../utilities/logger.js"; +import { EphemeralDirectory, getTmpDir } from "../utilities/tempDirectories.js"; +import { copyManifestToDir } from "../build/manifests.js"; + +export type DevSessionOptions = { + name: string | undefined; + initialMode: "local"; + showInteractiveDevSession: boolean | undefined; + rawConfig: ResolvedConfig; + rawArgs: DevCommandOptions; + client: CliApiClient; +}; + +export async function startDevSession({ rawConfig }: DevSessionOptions) { + const destination = getTmpDir(rawConfig.workingDir, "build"); + + logger.debug("Starting dev session", { destination: destination.path, rawConfig }); + + const externalsExtension = createExternalsBuildExtension("dev", rawConfig); + const buildContext = createBuildContext("dev", rawConfig); + buildContext.prependExtension(externalsExtension); + await notifyExtensionOnBuildStart(buildContext); + const pluginsFromExtensions = resolvePluginsForContext(buildContext); + + async function updateBundle(bundle: BundleResult, workerDir?: EphemeralDirectory) { + try { + let buildManifest = await createBuildManifestFromBundle( + bundle, + destination.path, + rawConfig, + workerDir?.path + ); + + buildManifest = await notifyExtensionOnBuildComplete(buildContext, buildManifest); + + logger.debug("Updated bundle", { bundle, buildManifest }); + } catch (error) { + logger.error("Error updating bundle", { error }); + } + } + + async function updateBuild(build: esbuild.BuildResult, workerDir: EphemeralDirectory) { + const bundle = getBundleResultFromBuild(rawConfig.workingDir, build); + + if (bundle) { + await updateBundle({ ...bundle, stop: undefined }, workerDir); + } + } + + let bundled = false; + const onEnd = { + name: "on-end", + setup(b: esbuild.PluginBuild) { + b.onStart(() => { + logger.debug("on-end plugin started"); + }); + b.onEnd(async (result: esbuild.BuildResult) => { + const errors = result.errors; + const warnings = result.warnings; + if (errors.length > 0) { + logBuildFailure(errors, warnings); + return; + } + + if (warnings.length > 0) { + logBuildWarnings(warnings); + } + + if (!bundled) { + // First bundle, no need to update bundle + bundled = true; + } else { + const workerDir = getTmpDir(rawConfig.workingDir, "worker"); + + await updateBuild(result, workerDir); + } + }); + }, + }; + + async function runBundle() { + const bundleResult = await bundleWorker({ + target: "dev", + cwd: rawConfig.workingDir, + destination: destination.path, + watch: true, + resolvedConfig: rawConfig, + plugins: [...pluginsFromExtensions, onEnd], + jsxFactory: rawConfig.build.jsx.factory, + jsxFragment: rawConfig.build.jsx.fragment, + jsxAutomatic: rawConfig.build.jsx.automatic, + }); + + await updateBundle(bundleResult); + + return bundleResult.stop; + } + + const stopBundling = await runBundle(); + + return { + stop: () => { + logger.debug("Stopping dev session"); + + destination.remove(); + stopBundling?.().catch((error) => {}); + }, + }; +} + +async function createBuildManifestFromBundle( + bundle: BundleResult, + destination: string, + resolvedConfig: ResolvedConfig, + workerDir: string | undefined +): Promise { + const buildManifest: BuildManifest = { + runtime: resolvedConfig.runtime ?? DEFAULT_RUNTIME, + target: "dev", + files: bundle.files, + externals: [], + config: resolvedConfig, + outputPath: destination, + workerEntryPath: bundle.workerDevPath ?? devEntryPoint, + workerForkPath: bundle.workerDevPath ?? devEntryPoint, + loaderPath: bundle.loaderPath ?? telemetryLoader, + configPath: bundle.configPath, + deploy: { + env: {}, + }, + build: {}, + }; + + if (!workerDir) { + return buildManifest; + } + + return copyManifestToDir(buildManifest, destination, workerDir); +} diff --git a/packages/cli-v3/src/shims/esm.ts b/packages/cli-v3/src/shims/esm.ts new file mode 100644 index 000000000..89189d980 --- /dev/null +++ b/packages/cli-v3/src/shims/esm.ts @@ -0,0 +1,9 @@ +import { createRequire } from "node:module"; +import path from "node:path"; +import url from "node:url"; + +// @ts-ignore +globalThis.require = createRequire(import.meta.url); +// @ts-ignore +globalThis.__filename = url.fileURLToPath(import.meta.url); +globalThis.__dirname = path.dirname(__filename); diff --git a/packages/cli-v3/src/sourceDir-cjs.cts b/packages/cli-v3/src/sourceDir-cjs.cts new file mode 100644 index 000000000..efd581a39 --- /dev/null +++ b/packages/cli-v3/src/sourceDir-cjs.cts @@ -0,0 +1,3 @@ +import { pathToFileURL } from "node:url"; +//@ts-ignore - Have to ignore because TSC thinks this is ESM +export const sourceDir = pathToFileURL(__dirname).pathname; diff --git a/packages/cli-v3/src/sourceDir.ts b/packages/cli-v3/src/sourceDir.ts new file mode 100644 index 000000000..3035fb031 --- /dev/null +++ b/packages/cli-v3/src/sourceDir.ts @@ -0,0 +1,2 @@ +//@ts-ignore +export const sourceDir = new URL(".", import.meta.url).pathname; diff --git a/packages/cli-v3/src/telemetry/loader.ts b/packages/cli-v3/src/telemetry/loader.ts new file mode 100644 index 000000000..427d0cf29 --- /dev/null +++ b/packages/cli-v3/src/telemetry/loader.ts @@ -0,0 +1,23 @@ +import { register } from "node:module"; + +type ImportHookData = { + include?: string[]; + exclude?: string[]; +}; + +const data: ImportHookData = {}; + +if (typeof process.env.OTEL_IMPORT_HOOK_INCLUDES === "string") { + data.include = process.env.OTEL_IMPORT_HOOK_INCLUDES.split(","); +} + +if (typeof process.env.OTEL_IMPORT_HOOK_EXCLUDES === "string") { + data.exclude = process.env.OTEL_IMPORT_HOOK_EXCLUDES.split(","); +} + +// @ts-ignore +register("import-in-the-middle/hook.mjs", import.meta.url, { + // @ts-ignore + parentURL: import.meta.url, + data, +}); diff --git a/packages/cli-v3/src/utilities/session.ts b/packages/cli-v3/src/utilities/session.ts index 63ccaa32e..0b50be786 100644 --- a/packages/cli-v3/src/utilities/session.ts +++ b/packages/cli-v3/src/utilities/session.ts @@ -2,21 +2,24 @@ import { recordSpanException } from "@trigger.dev/core/v3/workers"; import { CliApiClient } from "../apiClient.js"; import { readAuthConfigProfile } from "./configFiles.js"; import { getTracer } from "../telemetry/tracing.js"; +import { logger } from "./logger.js"; const tracer = getTracer(); +export type LoginResultOk = { + ok: true; + profile: string; + userId: string; + email: string; + dashboardUrl: string; + auth: { + apiUrl: string; + accessToken: string; + }; +}; + export type LoginResult = - | { - ok: true; - profile: string; - userId: string; - email: string; - dashboardUrl: string; - auth: { - apiUrl: string; - accessToken: string; - }; - } + | LoginResultOk | { ok: false; error: string; @@ -85,3 +88,41 @@ export async function isLoggedIn(profile: string = "default"): Promise {} : () => fs.rmSync(tmpDir, { recursive: true, force: true }); + let removeExitListener = keep ? () => {} : onExit(removeDir); + + return { + path: tmpDir, + remove() { + removeExitListener(); + removeDir(); + }, + }; +} diff --git a/packages/cli-v3/src/workers/dev.ts b/packages/cli-v3/src/workers/dev.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/packages/cli-v3/src/workers/dev.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/cli-v3/src/workers/prod.ts b/packages/cli-v3/src/workers/prod.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/packages/cli-v3/src/workers/prod.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/cli-v3/tsconfig.json b/packages/cli-v3/tsconfig.json index ea0b74abd..861389fdc 100644 --- a/packages/cli-v3/tsconfig.json +++ b/packages/cli-v3/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "isolatedDeclarations": false, "composite": true, - "sourceMap": true + "sourceMap": true, + "jsx": "react-jsx" }, "include": ["./src/**/*.ts", "./src/**/*.tsx"] } diff --git a/packages/core/src/v3/build/resolvedConfig.ts b/packages/core/src/v3/build/resolvedConfig.ts index 9c9f1406d..54e05866c 100644 --- a/packages/core/src/v3/build/resolvedConfig.ts +++ b/packages/core/src/v3/build/resolvedConfig.ts @@ -1,7 +1,7 @@ import { type Defu } from "defu"; import type { Prettify } from "ts-essentials"; import { TriggerConfig } from "../config.js"; -import { BuildRuntime } from "../schemas/config.js"; +import { BuildRuntime } from "../schemas/build.js"; export type ResolvedConfig = Prettify< Defu< diff --git a/packages/core/src/v3/build/runtime.ts b/packages/core/src/v3/build/runtime.ts index 12f8c6bc9..3d77e4ac8 100644 --- a/packages/core/src/v3/build/runtime.ts +++ b/packages/core/src/v3/build/runtime.ts @@ -1,4 +1,4 @@ -import { BuildRuntime } from "../schemas/config.js"; +import { BuildRuntime } from "../schemas/build.js"; export const DEFAULT_RUNTIME: BuildRuntime = "node20"; diff --git a/packages/core/src/v3/config.ts b/packages/core/src/v3/config.ts index 54e33fe86..81ff906e1 100644 --- a/packages/core/src/v3/config.ts +++ b/packages/core/src/v3/config.ts @@ -1,10 +1,14 @@ -import { Instrumentation } from "@opentelemetry/instrumentation"; -import { BuildRuntime } from "./schemas/config.js"; -import { BuildExtension } from "./build/extensions.js"; -import { MachinePresetName } from "./schemas/common.js"; -import { LogLevel } from "./logger/taskLogger.js"; -import { FailureFnParams, InitFnParams, StartFnParams, SuccessFnParams } from "./types/index.js"; -import { RetryOptions } from "./index.js"; +import type { Instrumentation } from "@opentelemetry/instrumentation"; +import type { BuildExtension } from "./build/extensions.js"; +import type { MachinePresetName } from "./schemas/common.js"; +import type { LogLevel } from "./logger/taskLogger.js"; +import type { + FailureFnParams, + InitFnParams, + StartFnParams, + SuccessFnParams, +} from "./types/index.js"; +import type { BuildRuntime, RetryOptions } from "./index.js"; export type TriggerConfig = { /** diff --git a/packages/core/src/v3/schemas/build.ts b/packages/core/src/v3/schemas/build.ts index ae4e2caa6..72e65df1b 100644 --- a/packages/core/src/v3/schemas/build.ts +++ b/packages/core/src/v3/schemas/build.ts @@ -62,38 +62,6 @@ export const TaskManifest = z.object({ export type TaskManifest = z.infer; -export const ExecuteTaskMessage = z.object({ - type: z.literal("execute-task"), - data: z.object({ - task: TaskManifest, - payload: z.unknown(), - projectRef: z.string(), - configPath: z.string(), - }), -}); - -export type ExecuteTaskMessage = z.infer; - -export const RunExecution = z.object({ - task: TaskManifest, - payload: z.unknown(), - projectRef: z.string(), - configPath: z.string(), - entryPath: z.string(), - loaderPath: z.string().optional(), - env: z.record(z.string()), - cwd: z.string().optional(), -}); - -export type RunExecution = z.infer; - -export const ParentToChildMessages = z.discriminatedUnion("type", [ - IndexMessage, - ExecuteTaskMessage, -]); - -export type ParentToChildMessages = z.infer; - export const WorkerManifest = z.object({ tasks: TaskManifest.array(), }); @@ -108,63 +76,3 @@ export const WorkerManifestMessage = z.object({ }); export type WorkerManifestMessage = z.infer; - -export const FailedTaskCompletion = z.object({ - ok: z.literal(false), - error: z.object({ - message: z.string(), - stack: z.string().optional(), - name: z.string().optional(), - }), -}); - -export type FailedTaskCompletion = z.infer; - -export const SuccessfulTaskCompletion = z.object({ - ok: z.literal(true), - output: z.unknown(), -}); - -export type SuccessfulTaskCompletion = z.infer; - -export const TaskCompletion = z.discriminatedUnion("ok", [ - FailedTaskCompletion, - SuccessfulTaskCompletion, -]); - -export type TaskCompletion = z.infer; - -export const CompletedTask = z.object({ - id: z.string(), - completion: TaskCompletion, - spans: z.array(z.any()), -}); - -export type CompletedTask = z.infer; - -export const CompletedTaskMessage = z.object({ - type: z.literal("completed-task"), - data: CompletedTask, -}); - -export type CompletedTaskMessage = z.infer; - -export const ChildToParentMessages = z.discriminatedUnion("type", [ - WorkerManifestMessage, - CompletedTaskMessage, -]); - -export type ChildToParentMessages = z.infer; - -export const TriggerTaskResult = z.discriminatedUnion("ok", [ - z.object({ - ok: z.literal(true), - output: z.unknown(), - }), - z.object({ - ok: z.literal(false), - error: z.string(), - }), -]); - -export type TriggerTaskResult = z.infer; diff --git a/packages/core/src/v3/schemas/config.ts b/packages/core/src/v3/schemas/config.ts index 4be06e7b3..d8081f391 100644 --- a/packages/core/src/v3/schemas/config.ts +++ b/packages/core/src/v3/schemas/config.ts @@ -1,13 +1,9 @@ import { z } from "zod"; export const ConfigManifest = z.object({ - projectRef: z.string(), + project: z.string(), dirs: z.string().array(), external: z.string().array().optional(), }); export type ConfigManifest = z.infer; - -export const BuildRuntime = z.enum(["node20", "bun"]); - -export type BuildRuntime = z.infer; diff --git a/packages/core/src/v3/schemas/index.ts b/packages/core/src/v3/schemas/index.ts index 4d8b8eae0..6f8b74e64 100644 --- a/packages/core/src/v3/schemas/index.ts +++ b/packages/core/src/v3/schemas/index.ts @@ -9,3 +9,4 @@ export * from "./fetch.js"; export * from "./eventFilter.js"; export * from "./openTelemetry.js"; export * from "./config.js"; +export * from "./build.js"; diff --git a/packages/trigger-sdk/package.json b/packages/trigger-sdk/package.json index 8cc84ec67..a147b44cc 100644 --- a/packages/trigger-sdk/package.json +++ b/packages/trigger-sdk/package.json @@ -43,13 +43,14 @@ "get-caller-file": "^2.0.5", "git-remote-origin-url": "^4.0.0", "git-repo-info": "^2.1.1", + "msw": "^2.2.1", + "package-json-from-dist": "^1.0.0", "slug": "^6.0.0", "terminal-link": "^3.0.0", "ulid": "^2.3.0", "uuid": "^9.0.0", "ws": "^8.11.0", - "zod": "3.23.8", - "msw": "^2.2.1" + "zod": "3.23.8" }, "devDependencies": { "@types/debug": "^4.1.7", @@ -60,9 +61,9 @@ "encoding": "^0.1.13", "msw": "^2.2.1", "rimraf": "^3.0.2", + "tshy": "^3.0.2", "typed-emitter": "^2.1.0", - "typescript": "^5.5.4", - "tshy": "^3.0.2" + "typescript": "^5.5.4" }, "engines": { "node": ">=18.20.0" diff --git a/packages/trigger-sdk/src/pkg-cjs.cts b/packages/trigger-sdk/src/pkg-cjs.cts new file mode 100644 index 000000000..ec0aaf66b --- /dev/null +++ b/packages/trigger-sdk/src/pkg-cjs.cts @@ -0,0 +1,3 @@ +import { findPackageJson, loadPackageJson } from "package-json-from-dist"; +export const pkg = loadPackageJson(__filename); +export const pj = findPackageJson(__filename); diff --git a/packages/trigger-sdk/src/pkg.ts b/packages/trigger-sdk/src/pkg.ts new file mode 100644 index 000000000..53c3b414a --- /dev/null +++ b/packages/trigger-sdk/src/pkg.ts @@ -0,0 +1,5 @@ +import { findPackageJson, loadPackageJson } from "package-json-from-dist"; +//@ts-ignore +export const pkg = loadPackageJson(import.meta.url); +//@ts-ignore +export const pj = findPackageJson(import.meta.url); diff --git a/packages/trigger-sdk/src/v3/shared.ts b/packages/trigger-sdk/src/v3/shared.ts index 4ddc2235b..193d7e579 100644 --- a/packages/trigger-sdk/src/v3/shared.ts +++ b/packages/trigger-sdk/src/v3/shared.ts @@ -36,10 +36,10 @@ import { taskCatalog, taskContext, } from "@trigger.dev/core/v3"; -import { version } from "../../package.json"; import { tracer } from "./tracer.js"; import { PollOptions, RetrieveRunResult, runs } from "./runs.js"; import { IdempotencyKey, idempotencyKeys, isIdempotencyKey } from "./idempotencyKeys.js"; +import { pkg } from "../pkg.js"; export type Context = TaskRunContext; @@ -545,7 +545,7 @@ export function createTask< taskCatalog.registerTaskMetadata({ id: params.id, - packageVersion: version, + packageVersion: pkg.version, queue: params.queue, retry: params.retry ? { ...defaultRetryOptions, ...params.retry } : undefined, machine: params.machine, diff --git a/packages/trigger-sdk/src/v3/tracer.ts b/packages/trigger-sdk/src/v3/tracer.ts index d33502336..97cfb194b 100644 --- a/packages/trigger-sdk/src/v3/tracer.ts +++ b/packages/trigger-sdk/src/v3/tracer.ts @@ -1,4 +1,4 @@ import { TriggerTracer } from "@trigger.dev/core/v3"; -import { version } from "../../package.json"; +import { pkg } from "../pkg.js"; -export const tracer = new TriggerTracer({ name: "@trigger.dev/sdk", version: version }); +export const tracer = new TriggerTracer({ name: "@trigger.dev/sdk", version: pkg.version }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 529b66a54..350f851ef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -969,6 +969,9 @@ importers: magicast: specifier: ^0.3.4 version: 0.3.4 + minimatch: + specifier: ^10.0.1 + version: 10.0.1 mlly: specifier: ^1.7.1 version: 1.7.1 @@ -1006,8 +1009,8 @@ importers: specifier: ^18.2.0 version: 18.2.0 react-error-boundary: - specifier: ^4.0.12 - version: 4.0.12(react@18.2.0) + specifier: ^3.1.4 + version: 3.1.4(react@18.2.0) resolve: specifier: ^1.22.8 version: 1.22.8 @@ -1069,6 +1072,9 @@ importers: '@types/react': specifier: ^18.2.48 version: 18.2.48 + '@types/resolve': + specifier: ^1.20.6 + version: 1.20.6 '@types/semver': specifier: ^7.3.13 version: 7.5.1 @@ -1334,6 +1340,9 @@ importers: msw: specifier: ^2.2.1 version: 2.2.1(typescript@5.5.4) + package-json-from-dist: + specifier: ^1.0.0 + version: 1.0.0 slug: specifier: ^6.0.0 version: 6.1.0 @@ -1411,8 +1420,8 @@ importers: specifier: ^0.10.1 version: 0.10.1(typescript@5.5.4)(zod@3.23.8) '@traceloop/instrumentation-openai': - specifier: ^0.3.9 - version: 0.3.9(@opentelemetry/api@1.4.1) + specifier: ^0.10.0 + version: 0.10.0(@opentelemetry/api@1.4.1) '@trigger.dev/sdk': specifier: workspace:* version: link:../../packages/trigger-sdk @@ -3523,7 +3532,6 @@ packages: engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.14.1 - dev: false /@babel/template@7.22.15: resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==} @@ -3619,7 +3627,7 @@ packages: /@changesets/apply-release-plan@6.1.4: resolution: {integrity: sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/config': 2.3.1 '@changesets/get-version-range-type': 0.3.2 '@changesets/git': 2.0.0 @@ -3637,7 +3645,7 @@ packages: /@changesets/assemble-release-plan@5.2.4(patch_hash=3wuhjtl4hjck4itk3w32z4cd5u): resolution: {integrity: sha512-xJkWX+1/CUaOUWTguXEbCDTyWJFECEhmdtbkjhn5GVBGxdP/JwaHBIU9sW3FR6gD07UwZ7ovpiPclQZs+j+mvg==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/errors': 0.1.4 '@changesets/get-dependents-graph': 1.3.6 '@changesets/types': 5.2.1 @@ -3731,7 +3739,7 @@ packages: /@changesets/get-release-plan@3.0.17: resolution: {integrity: sha512-6IwKTubNEgoOZwDontYc2x2cWXfr6IKxP3IhKeK+WjyD6y3M4Gl/jdQvBw+m/5zWILSOCAaGLu2ZF6Q+WiPniw==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/assemble-release-plan': 5.2.4(patch_hash=3wuhjtl4hjck4itk3w32z4cd5u) '@changesets/config': 2.3.1 '@changesets/pre': 1.0.14 @@ -3747,7 +3755,7 @@ packages: /@changesets/git@2.0.0: resolution: {integrity: sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/errors': 0.1.4 '@changesets/types': 5.2.1 '@manypkg/get-packages': 1.1.3 @@ -3772,7 +3780,7 @@ packages: /@changesets/pre@1.0.14: resolution: {integrity: sha512-dTsHmxQWEQekHYHbg+M1mDVYFvegDh9j/kySNuDKdylwfMEevTeDouR7IfHNyVodxZXu17sXoJuf2D0vi55FHQ==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/errors': 0.1.4 '@changesets/types': 5.2.1 '@manypkg/get-packages': 1.1.3 @@ -3782,7 +3790,7 @@ packages: /@changesets/read@0.5.9: resolution: {integrity: sha512-T8BJ6JS6j1gfO1HFq50kU3qawYxa4NTbI/ASNVVCBTsKquy2HYwM9r7ZnzkiMe8IEObAJtUVGSrePCOxAK2haQ==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/git': 2.0.0 '@changesets/logger': 0.0.5 '@changesets/parse': 0.3.16 @@ -3802,7 +3810,7 @@ packages: /@changesets/write@0.2.3: resolution: {integrity: sha512-Dbamr7AIMvslKnNYsLFafaVORx4H0pvCA2MHqgtNCySMe1blImEyAEOzDmcgKAkgz4+uwoLz7demIrX+JBr/Xw==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/types': 5.2.1 fs-extra: 7.0.1 human-id: 1.0.2 @@ -6808,7 +6816,7 @@ packages: /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/node': 12.20.55 find-up: 4.1.0 fs-extra: 8.1.0 @@ -6816,7 +6824,7 @@ packages: /@manypkg/get-packages@1.1.3: resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 @@ -7381,22 +7389,6 @@ packages: - supports-color dev: true - /@opentelemetry/instrumentation@0.48.0(@opentelemetry/api@1.4.1): - resolution: {integrity: sha512-sjtZQB5PStIdCw5ovVTDGwnmQC+GGYArJNgIcydrDSqUTdYBnMrN9P4pwQZgS3vTGIp+TU1L8vMXGe51NVmIKQ==} - engines: {node: '>=14'} - peerDependencies: - '@opentelemetry/api': ^1.3.0 - dependencies: - '@opentelemetry/api': 1.4.1 - '@types/shimmer': 1.0.2 - import-in-the-middle: 1.7.1 - require-in-the-middle: 7.1.1 - semver: 7.5.4 - shimmer: 1.2.1 - transitivePeerDependencies: - - supports-color - dev: false - /@opentelemetry/instrumentation@0.49.1(@opentelemetry/api@1.4.1): resolution: {integrity: sha512-0DLtWtaIppuNNRRllSD4bjU8ZIiLp1cDXvJEbp752/Zf+y3gaLNaoGRGIlX4UHhcsrmtL+P2qxi3Hodi8VuKiQ==} engines: {node: '>=14'} @@ -7465,6 +7457,23 @@ packages: - supports-color dev: true + /@opentelemetry/instrumentation@0.52.1(@opentelemetry/api@1.4.1): + resolution: {integrity: sha512-uXJbYU/5/MBHjMp1FqrILLRuiJCs3Ofk0MeRDk8g1S1gD47U8X3JnSwcMO1rtRo1x1a7zKaQHaoYu49p/4eSKw==} + engines: {node: '>=14'} + peerDependencies: + '@opentelemetry/api': ^1.3.0 + dependencies: + '@opentelemetry/api': 1.4.1 + '@opentelemetry/api-logs': 0.52.1 + '@types/shimmer': 1.0.2 + import-in-the-middle: 1.11.0 + require-in-the-middle: 7.1.1 + semver: 7.5.4 + shimmer: 1.2.1 + transitivePeerDependencies: + - supports-color + dev: false + /@opentelemetry/instrumentation@0.52.1(@opentelemetry/api@1.9.0): resolution: {integrity: sha512-uXJbYU/5/MBHjMp1FqrILLRuiJCs3Ofk0MeRDk8g1S1gD47U8X3JnSwcMO1rtRo1x1a7zKaQHaoYu49p/4eSKw==} engines: {node: '>=14'} @@ -7958,25 +7967,25 @@ packages: /@radix-ui/number@1.0.0: resolution: {integrity: sha512-Ofwh/1HX69ZfJRiRBMTy7rgjAzHmwe4kW9C9Y99HTRUcYLUuVT0KESFj15rPjRgKJs20GPq8Bm5aEDJ8DuA3vA==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: false /@radix-ui/number@1.0.1: resolution: {integrity: sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: false /@radix-ui/primitive@1.0.0: resolution: {integrity: sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: false /@radix-ui/primitive@1.0.1: resolution: {integrity: sha512-yQ8oGX2GVsEYMWGxcovu1uGWPCxV5BFfeeYxqPmuAzUyLT9qmaMXSAhXpb0WrspIeqYzdJpkh2vHModJPgRIaw==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: false /@radix-ui/react-alert-dialog@1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0): @@ -8011,7 +8020,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -8072,7 +8081,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) '@radix-ui/react-context': 1.0.0(react@18.2.0) '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) @@ -8094,7 +8103,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@radix-ui/react-context': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0) @@ -8118,7 +8127,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@radix-ui/react-context': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.3.1)(react-dom@18.2.0)(react@18.2.0) @@ -8134,7 +8143,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -8147,7 +8156,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -8161,7 +8170,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.3.1 react: 18.2.0 dev: false @@ -8171,7 +8180,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -8184,7 +8193,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -8198,7 +8207,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.3.1 react: 18.2.0 dev: false @@ -8243,7 +8252,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@radix-ui/react-context': 1.0.1(@types/react@18.2.69)(react@18.2.0) @@ -8269,7 +8278,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -8282,7 +8291,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -8296,7 +8305,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.3.1 react: 18.2.0 dev: false @@ -8307,7 +8316,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.0 '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) @@ -8330,7 +8339,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0) @@ -8355,7 +8364,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.3.1)(react-dom@18.2.0)(react@18.2.0) @@ -8397,7 +8406,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -8410,7 +8419,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -8424,7 +8433,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.3.1 react: 18.2.0 dev: false @@ -8435,7 +8444,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-use-callback-ref': 1.0.0(react@18.2.0) @@ -8456,7 +8465,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.69)(react@18.2.0) @@ -8494,7 +8503,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-layout-effect': 1.0.0(react@18.2.0) react: 18.2.0 dev: false @@ -8508,7 +8517,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@types/react': 18.2.69 react: 18.2.0 @@ -8523,7 +8532,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@types/react': 18.3.1 react: 18.2.0 @@ -8610,7 +8619,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@floating-ui/react-dom': 0.7.2(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-arrow': 1.0.2(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) @@ -8693,7 +8702,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -8712,7 +8721,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0) '@types/react': 18.2.69 '@types/react-dom': 18.2.7 @@ -8733,7 +8742,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.3.1)(react-dom@18.2.0)(react@18.2.0) '@types/react': 18.3.1 '@types/react-dom': 18.2.7 @@ -8768,7 +8777,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) '@radix-ui/react-use-layout-effect': 1.0.0(react@18.2.0) react: 18.2.0 @@ -8788,7 +8797,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@types/react': 18.2.69 @@ -8810,7 +8819,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@types/react': 18.3.1 @@ -8825,7 +8834,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-slot': 1.0.1(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -8844,7 +8853,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-slot': 1.0.2(@types/react@18.2.69)(react@18.2.0) '@types/react': 18.2.69 '@types/react-dom': 18.2.7 @@ -8865,7 +8874,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-slot': 1.0.2(@types/react@18.3.1)(react@18.2.0) '@types/react': 18.3.1 '@types/react-dom': 18.2.7 @@ -8909,7 +8918,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.0 '@radix-ui/react-collection': 1.0.2(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) @@ -8936,7 +8945,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-collection': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.69)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.69)(react@18.2.0) @@ -8965,7 +8974,7 @@ packages: '@types/react-dom': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-collection': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.3.1)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.3.1)(react@18.2.0) @@ -9051,7 +9060,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) react: 18.2.0 dev: false @@ -9244,7 +9253,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -9257,7 +9266,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -9271,7 +9280,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.3.1 react: 18.2.0 dev: false @@ -9281,7 +9290,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-callback-ref': 1.0.0(react@18.2.0) react: 18.2.0 dev: false @@ -9295,7 +9304,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@types/react': 18.2.69 react: 18.2.0 @@ -9310,7 +9319,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@types/react': 18.3.1 react: 18.2.0 @@ -9321,7 +9330,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-callback-ref': 1.0.0(react@18.2.0) react: 18.2.0 dev: false @@ -9335,7 +9344,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@types/react': 18.2.69 react: 18.2.0 @@ -9350,7 +9359,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@types/react': 18.3.1 react: 18.2.0 @@ -9361,7 +9370,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -9374,7 +9383,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -9388,7 +9397,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.3.1 react: 18.2.0 dev: false @@ -9398,7 +9407,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -9411,7 +9420,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/react': 18.2.69 react: 18.2.0 dev: false @@ -9421,7 +9430,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/rect': 1.0.0 react: 18.2.0 dev: false @@ -9446,7 +9455,7 @@ packages: peerDependencies: react: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-layout-effect': 1.0.0(react@18.2.0) react: 18.2.0 dev: false @@ -9460,7 +9469,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.2.69)(react@18.2.0) '@types/react': 18.2.69 react: 18.2.0 @@ -9475,7 +9484,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.3.1)(react@18.2.0) '@types/react': 18.3.1 react: 18.2.0 @@ -9487,7 +9496,7 @@ packages: react: ^16.8 || ^17.0 || ^18.0 react-dom: ^16.8 || ^17.0 || ^18.0 dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -9517,7 +9526,7 @@ packages: /@radix-ui/rect@1.0.0: resolution: {integrity: sha512-d0O68AYy/9oeEy1DdC07bz1/ZXX+DqCskRd3i4JzLSTXwefzaepQrKjXC7aNM8lTHjFLDO0pDgaEiQ7jEk+HVg==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: false /@radix-ui/rect@1.0.1: @@ -12413,7 +12422,7 @@ packages: engines: {node: '>=12'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 '@types/aria-query': 5.0.1 aria-query: 5.1.3 chalk: 4.1.2 @@ -12430,19 +12439,23 @@ packages: resolution: {integrity: sha512-vqd7ZUDSrXFVT1n8b2kc3LnklncDQFPvR58yUS1kEP23/nHPAO9l1lMjUfnPrXYYk4Hj54rrLKMW5ipwk7k09A==} dev: true - /@traceloop/ai-semantic-conventions@0.3.8: - resolution: {integrity: sha512-RGLFpq3JrRKBhGItq4AbNIoe2h4K5VY4ay4J55B8X7d23VA3fs9QNtv2qlSVkRiEGHinXsCk3RUULUE2GFEu7w==} + /@traceloop/ai-semantic-conventions@0.10.0: + resolution: {integrity: sha512-B7XuwDpSNXtyz1SUi6Xqd/t6xg0dS9V80pLaIxbQC0n5vsHfao5MPqz7jY8WgZroCANFFiDVDE0JMJsX1vfk7Q==} engines: {node: '>=14'} + dependencies: + '@opentelemetry/api': 1.9.0 dev: false - /@traceloop/instrumentation-openai@0.3.9(@opentelemetry/api@1.4.1): - resolution: {integrity: sha512-Ru2QBK6crx0dtWXd4aMyFNRP9cA2WF+8Rjt2ctOgu/R7M7fmNvtcXveY0qXZ1doKYzzt0+icZqs0ahJEn8WYcQ==} + /@traceloop/instrumentation-openai@0.10.0(@opentelemetry/api@1.4.1): + resolution: {integrity: sha512-rp1J6FOJLNZ1M08xsz2B84STNV3AGKxCq+44w7mgadOCyI6GDw7a1lbLo+wTV0dxnt34HPBBdrvRXCFHd3JK9Q==} engines: {node: '>=14'} dependencies: '@opentelemetry/core': 1.25.1(@opentelemetry/api@1.4.1) - '@opentelemetry/instrumentation': 0.48.0(@opentelemetry/api@1.4.1) + '@opentelemetry/instrumentation': 0.52.1(@opentelemetry/api@1.4.1) '@opentelemetry/semantic-conventions': 1.25.1 - '@traceloop/ai-semantic-conventions': 0.3.8 + '@traceloop/ai-semantic-conventions': 0.10.0 + js-tiktoken: 1.0.12 + tslib: 2.6.2 transitivePeerDependencies: - '@opentelemetry/api' - supports-color @@ -12979,6 +12992,10 @@ packages: form-data: 2.5.1 dev: false + /@types/resolve@1.20.6: + resolution: {integrity: sha512-A4STmOXPhMUtHH+S6ymgE2GiBSMqf4oTvcQZMcHzokuTLVYzXTB8ttjcgxOVaAp2lGwEdzZ0J+cRbbeevQj1UQ==} + dev: true + /@types/responselike@1.0.0: resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} dependencies: @@ -13621,6 +13638,13 @@ packages: dependencies: acorn: 8.10.0 + /acorn-import-assertions@1.9.0(acorn@8.12.1): + resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==} + peerDependencies: + acorn: ^8 + dependencies: + acorn: 8.12.1 + /acorn-import-attributes@1.9.5(acorn@8.10.0): resolution: {integrity: sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==} peerDependencies: @@ -13635,6 +13659,14 @@ packages: dependencies: acorn: 8.10.0 + /acorn-jsx@5.3.2(acorn@8.12.1): + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + acorn: 8.12.1 + dev: true + /acorn-node@1.8.2: resolution: {integrity: sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==} dependencies: @@ -16070,7 +16102,7 @@ packages: /dom-helpers@5.2.1: resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 csstype: 3.1.1 dev: false @@ -20297,6 +20329,12 @@ packages: resolution: {integrity: sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==} dev: true + /js-tiktoken@1.0.12: + resolution: {integrity: sha512-L7wURW1fH9Qaext0VzaUDpFGVQgjkdE3Dgsy9/+yXyGEpBKnylTd0mU0bfbNkKDlXRb6TEsZkwuflu1B8uQbJQ==} + dependencies: + base64-js: 1.5.1 + dev: false + /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -20962,7 +21000,7 @@ packages: /media-query-parser@2.0.2: resolution: {integrity: sha512-1N4qp+jE0pL5Xv4uEcwVUhIkwdUO3S/9gML90nqKA7v7FcOS5vUtatfzok9S9U1EJU8dHWlcv95WLnKmmxZI9w==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: true /media-typer@0.3.0: @@ -21087,8 +21125,8 @@ packages: /micromark-extension-mdxjs@1.0.0: resolution: {integrity: sha512-TZZRZgeHvtgm+IhtgC2+uDMR7h8eTKF0QUX9YsgoL9+bADBpBY6SiLvWqnBlLbCEevITmTqmEuY3FoxMKVs1rQ==} dependencies: - acorn: 8.10.0 - acorn-jsx: 5.3.2(acorn@8.10.0) + acorn: 8.12.1 + acorn-jsx: 5.3.2(acorn@8.12.1) micromark-extension-mdx-expression: 1.0.3 micromark-extension-mdx-jsx: 1.0.3 micromark-extension-mdx-md: 1.0.0 @@ -23907,12 +23945,13 @@ packages: - webpack-cli dev: false - /react-error-boundary@4.0.12(react@18.2.0): - resolution: {integrity: sha512-kJdxdEYlb7CPC1A0SeUY38cHpjuu6UkvzKiAmqmOFL21VRfMhOcWxTCBgLVCO0VEMh9JhFNcVaXlV4/BTpiwOA==} + /react-error-boundary@3.1.4(react@18.2.0): + resolution: {integrity: sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA==} + engines: {node: '>=10', npm: '>=6'} peerDependencies: react: '>=16.13.1' dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 react: 18.2.0 dev: false @@ -24156,7 +24195,7 @@ packages: react: '>=16.6.0' react-dom: '>=16.6.0' dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -24354,12 +24393,11 @@ packages: /regenerator-runtime@0.14.1: resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} - dev: false /regenerator-transform@0.15.1: resolution: {integrity: sha512-knzmNAcuyxV+gQCufkYcvOqX/qIIfHLv0u5x79kRxuGojfYVky1f15TzZEu2Avte8QGepvUNTnLskf8E6X6Vyg==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: true /regex-not@1.0.2: @@ -24884,7 +24922,7 @@ packages: /rtl-css-js@1.16.1: resolution: {integrity: sha512-lRQgou1mu19e+Ya0LsTvKrVJ5TYUbqCVPAiImX3UfLTenarvPUl1QFdvu5Z3PYmHT9RCcwIfbjRQBntExyj3Zg==} dependencies: - '@babel/runtime': 7.22.5 + '@babel/runtime': 7.24.5 dev: false /run-applescript@7.0.0: @@ -26078,7 +26116,7 @@ packages: fast-glob: 3.3.1 glob-parent: 6.0.2 is-glob: 4.0.3 - jiti: 1.21.0 + jiti: 1.21.6 lilconfig: 2.1.0 micromatch: 4.0.5 normalize-path: 3.0.0 @@ -26250,7 +26288,7 @@ packages: hasBin: true dependencies: '@jridgewell/source-map': 0.3.3 - acorn: 8.10.0 + acorn: 8.12.1 commander: 2.20.3 source-map-support: 0.5.21 @@ -28166,8 +28204,8 @@ packages: '@webassemblyjs/ast': 1.11.5 '@webassemblyjs/wasm-edit': 1.11.5 '@webassemblyjs/wasm-parser': 1.11.5 - acorn: 8.10.0 - acorn-import-assertions: 1.9.0(acorn@8.10.0) + acorn: 8.12.1 + acorn-import-assertions: 1.9.0(acorn@8.12.1) browserslist: 4.23.0 chrome-trace-event: 1.0.3 enhanced-resolve: 5.15.0 @@ -28206,8 +28244,8 @@ packages: '@webassemblyjs/ast': 1.11.5 '@webassemblyjs/wasm-edit': 1.11.5 '@webassemblyjs/wasm-parser': 1.11.5 - acorn: 8.10.0 - acorn-import-assertions: 1.9.0(acorn@8.10.0) + acorn: 8.12.1 + acorn-import-assertions: 1.9.0(acorn@8.12.1) browserslist: 4.23.0 chrome-trace-event: 1.0.3 enhanced-resolve: 5.15.0 diff --git a/references/v3-catalog/package.json b/references/v3-catalog/package.json index 9ce49fd25..3794f28b0 100644 --- a/references/v3-catalog/package.json +++ b/references/v3-catalog/package.json @@ -23,7 +23,7 @@ "@react-email/render": "^0.0.7", "@sindresorhus/slugify": "^2.2.1", "@t3-oss/env-nextjs": "^0.10.1", - "@traceloop/instrumentation-openai": "^0.3.9", + "@traceloop/instrumentation-openai": "^0.10.0", "@trigger.dev/sdk": "workspace:*", "dotenv": "^16.4.5", "execa": "^8.0.1", diff --git a/references/v3-catalog/src/trigger/simple.ts b/references/v3-catalog/src/trigger/simple.ts index b8c3a1094..5e563acd8 100644 --- a/references/v3-catalog/src/trigger/simple.ts +++ b/references/v3-catalog/src/trigger/simple.ts @@ -21,7 +21,7 @@ export const anyPayloadTask = task({ }); if (result.ok) { - logger.info("Result from fetch-post-task", { output: result.output }); + logger.info("Result from fetch-post-task 211111s", { output: result.output }); } else { logger.error("Error from fetch-post-task", { error: result.error }); } diff --git a/references/v3-catalog/trigger.config.ts b/references/v3-catalog/trigger.config.ts index b5ac16875..8de304db9 100644 --- a/references/v3-catalog/trigger.config.ts +++ b/references/v3-catalog/trigger.config.ts @@ -1,39 +1,10 @@ -import { InfisicalClient } from "@infisical/sdk"; +import { defineConfig } from "@trigger.dev/sdk/v3"; import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai"; -import { defineConfig, type ResolveEnvironmentVariablesFunction } from "@trigger.dev/sdk/v3"; - -export { handleError } from "./src/handleError"; - -export const resolveEnvVars: ResolveEnvironmentVariablesFunction = async ({ - projectRef, - env, - environment, -}) => { - if (env.INFISICAL_CLIENT_ID === undefined || env.INFISICAL_CLIENT_SECRET === undefined) { - return; - } - - const client = new InfisicalClient({ - clientId: env.INFISICAL_CLIENT_ID, - clientSecret: env.INFISICAL_CLIENT_SECRET, - }); - - const secrets = await client.listSecrets({ - environment, - projectId: env.INFISICAL_PROJECT_ID!, - }); - - return { - variables: secrets.map((secret) => ({ - name: secret.secretKey, - value: secret.secretValue, - })), - }; -}; export default defineConfig({ project: "yubjwjsfkxnylobaqvqz", machine: "small-2x", + instrumentations: [new OpenAIInstrumentation()], retries: { enabledInDev: true, default: { @@ -45,12 +16,7 @@ export default defineConfig({ }, }, enableConsoleLogging: false, - additionalPackages: ["wrangler@3.35.0", "pg@8.11.5"], - additionalFiles: ["./wrangler/wrangler.toml"], - dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp", /@t3-oss/], - instrumentations: [new OpenAIInstrumentation()], logLevel: "info", - postInstall: "echo '========== config.postInstall'", onStart: async (payload, { ctx }) => { console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); }, diff --git a/references/v3-catalog/tsconfig.json b/references/v3-catalog/tsconfig.json index ee519e26d..d3dbd2f86 100644 --- a/references/v3-catalog/tsconfig.json +++ b/references/v3-catalog/tsconfig.json @@ -11,7 +11,10 @@ "jsx": "preserve", "emitDecoratorMetadata": true, "experimentalDecorators": true, - "lib": ["DOM", "DOM.Iterable"] + "lib": ["DOM", "DOM.Iterable"], + "paths": { + "@/*": ["./src/*"] + } }, "include": ["./src/**/*.ts", "trigger.config.ts", "src/trigger/email.tsx"] }