UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

48 lines • 2.12 kB
/** * The sandbox kit in an Adonis app: found through `@adonisjs/vite` — the dev server running in this * process (its `genuiSandboxKit()` plugin), else the descriptor it (or the assembler hook) wrote, * and in production the Vite manifest under the configured build directory. */ import { fileURLToPath } from 'node:url'; import { ADONIS_SANDBOX_KIT_DESCRIPTOR } from '../../vite/index.js'; import { sandboxKitDiscovery } from './discover.js'; import { sandboxKitDescriptorPath } from './plugin.js'; /** * Find the kit through the app's Vite setup. `app` is the Adonis application; `name`, a named kit's * (`genuiSandboxKit({ name })`). */ export async function adonisSandboxKitDiscovery(app, options = {}) { const adonis = app; const root = adonis === undefined ? process.cwd() : typeof adonis.appRoot === 'string' ? adonis.appRoot : fileURLToPath(adonis.appRoot); let vite; try { vite = (await adonis?.container.make('vite')); } catch { vite = undefined; } const config = adonis?.config.get('vite', {}) ?? {}; const buildDirectory = config.buildDirectory ?? 'public/assets'; return sandboxKitDiscovery({ root, ...(options.name !== undefined ? { name: options.name } : {}), descriptor: sandboxKitDescriptorPath(ADONIS_SANDBOX_KIT_DESCRIPTOR, options.name), manifest: { file: config.manifestFile ?? `${buildDirectory}/.vite/manifest.json`, outDir: buildDirectory, }, plugin: () => vite ?.getDevServer?.() ?.config.plugins.find((plugin) => plugin.name === 'genui-sandbox-kit' && plugin.api?.kitName === options.name)?.api, ...(adonis?.inProduction !== undefined ? { production: adonis.inProduction } : {}), ...(options.kitUrl !== undefined ? { kitUrl: options.kitUrl } : {}), ...(options.cssUrl !== undefined ? { cssUrl: options.cssUrl } : {}), ...(options.tailwindUrl !== undefined ? { tailwindUrl: options.tailwindUrl } : {}), }); } //# sourceMappingURL=adonis.js.map