@rizom/brain 0.2.0-alpha.691 → 0.2.0-alpha.692
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brain.js +16 -16
- package/dist/chunks/{app-zb4wkm3j.js → app-223hjhs8.js} +2 -2
- package/dist/chunks/{index-41mdbfrk.js → index-6q9qf483.js} +3 -3
- package/dist/chunks/{index-41mdbfrk.js.map → index-6q9qf483.js.map} +1 -1
- package/dist/chunks/index-zxffbhsj.js +7 -0
- package/dist/chunks/index-zxffbhsj.js.map +11 -0
- package/dist/chunks/{package-tvdk2gte.js → package-tn24s06v.js} +3 -3
- package/dist/chunks/{package-tvdk2gte.js.map → package-tn24s06v.js.map} +1 -1
- package/dist/model.js +14 -14
- package/dist/model.js.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-h2tqd54z.js +0 -7
- package/dist/chunks/index-h2tqd54z.js.map +0 -11
- /package/dist/chunks/{app-zb4wkm3j.js.map → app-223hjhs8.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B as a}from"./index-
|
|
2
|
+
import{B as a}from"./index-zxffbhsj.js";import"./index-66v76w4h.js";import"./index-tc1g7d2h.js";import"./index-dre4wmv8.js";import"./index-qnt46f4v.js";import"./index-yhsfzqsw.js";import"./index-g95msk2x.js";import"./index-q6a6w2ga.js";import"./index-x4qnbqvy.js";import"./index-edt6y87t.js";export{a as App};
|
|
3
3
|
|
|
4
4
|
//# debugId=85103B03B1AFE91364756E2164756E21
|
|
5
|
-
//# sourceMappingURL=app-
|
|
5
|
+
//# sourceMappingURL=app-223hjhs8.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{px as t}from"./index-q6a6w2ga.js";var g={name:"@rizom/brain",version:"0.2.0-alpha.
|
|
2
|
+
import{px as t}from"./index-q6a6w2ga.js";var g={name:"@rizom/brain",version:"0.2.0-alpha.692",description:"Brain runtime + CLI \u2014 scaffold, run, and manage AI brain instances",keywords:["brain","ai","cli","mcp","agent","personal-ai","knowledge-management"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{brain:"./dist/brain.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@clack/prompts":"^1.5.1","@modelcontextprotocol/client":"^2.3.1","@modelcontextprotocol/server":"^2.3.1","@tailwindcss/postcss":"^4.3.1","@tailwindcss/typography":"^0.5.20","@types/react":"^19.2.17",postcss:"^8.5.29",react:"^19.2.7","react-dom":"^19.2.7",tailwindcss:"^4.3.1",yaml:"^2.9.0",zod:"^4.2.0"},devDependencies:{"@brains/a2a":"workspace:*","@brains/action-board":"workspace:*","@brains/admin":"workspace:*","@brains/agent-discovery":"workspace:*","@brains/ai-evaluation":"workspace:*","@brains/ai-service":"workspace:*","@brains/analytics":"workspace:*","@brains/app":"workspace:*","@brains/ask-content":"workspace:*","@brains/assessment":"workspace:*","@brains/atproto":"workspace:*","@brains/atproto-registry":"workspace:*","@brains/auth-service":"workspace:*","@brains/blog":"workspace:*","@brains/book":"workspace:*","@brains/build-tools":"workspace:*","@brains/chat":"workspace:*","@brains/contact":"workspace:*","@brains/content-formatters":"workspace:*","@brains/content-pipeline":"workspace:*","@brains/contracts":"workspace:*","@brains/conversation-memory":"workspace:*","@brains/core":"workspace:*","@brains/dashboard":"workspace:*","@brains/decks":"workspace:*","@brains/deploy-support":"workspace:*","@brains/directory-sync":"workspace:*","@brains/doc":"workspace:*","@brains/document-plugin":"workspace:*","@brains/email":"workspace:*","@brains/email-workflows":"workspace:*","@brains/entity-service":"workspace:*","@brains/eslint-config":"workspace:*","@brains/faq":"workspace:*","@brains/form":"workspace:*","@brains/guide":"workspace:*","@brains/http-host":"workspace:*","@brains/image":"workspace:*","@brains/image-plugin":"workspace:*","@brains/knowledge-map":"workspace:*","@brains/link":"workspace:*","@brains/linkedin-import":"workspace:*","@brains/mcp":"workspace:*","@brains/mcp-service":"workspace:*","@brains/newsletter":"workspace:*","@brains/note":"workspace:*","@brains/notifications":"workspace:*","@brains/oauth-broker":"workspace:*","@brains/obsidian-vault":"workspace:*","@brains/onboarding":"workspace:*","@brains/operation-context":"workspace:*","@brains/playbooks":"workspace:*","@brains/plugins":"workspace:*","@brains/portfolio":"workspace:*","@brains/profile":"workspace:*","@brains/prompt":"workspace:*","@brains/quiz":"workspace:*","@brains/sdk":"workspace:*","@brains/series":"workspace:*","@brains/site-builder-plugin":"workspace:*","@brains/site-composition":"workspace:*","@brains/site-content":"workspace:*","@brains/site-default":"workspace:*","@brains/site-info":"workspace:*","@brains/site-organization":"workspace:*","@brains/site-personal":"workspace:*","@brains/site-professional":"workspace:*","@brains/social-media":"workspace:*","@brains/stock-photo":"workspace:*","@brains/studio":"workspace:*","@brains/style-guide":"workspace:*","@brains/templates":"workspace:*","@brains/test-utils":"workspace:*","@brains/theme-rizom":"workspace:*","@brains/topics":"workspace:*","@brains/typescript-config":"workspace:*","@brains/unified-inbox":"workspace:*","@brains/utils":"workspace:*","@brains/web-chat":"workspace:*","@brains/wishlist":"workspace:*","@libsql/client":"^0.17.4","@manypkg/get-packages":"^3.1.0","@rizom/theme-default":"workspace:*","@types/bun":"^1.4.0","@types/react-dom":"^19.0.3",rolldown:"^1.0.0","rolldown-plugin-dts":"^0.27.4",typescript:"^7.0.2"},engines:{bun:">=1.4.0"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./chat":{types:"./dist/chat.d.ts",import:"./dist/chat.js"},"./cli":"./dist/brain.js","./model":{types:"./dist/model.d.ts",import:"./dist/model.js"},"./entities":{types:"./dist/entities.d.ts",import:"./dist/entities.js"},"./services":{types:"./dist/services.d.ts",import:"./dist/services.js"},"./interfaces":{types:"./dist/interfaces.d.ts",import:"./dist/interfaces.js"},"./testing":{types:"./dist/testing.d.ts",import:"./dist/testing.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js"},"./tsconfig.instance.json":"./tsconfig.instance.json"},files:["dist","templates","tsconfig.instance.json"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brain-cli#readme",optionalDependencies:{"@bitwarden/sdk-napi":"^1.0.0","@libsql/client":"^0.17.4","@tailwindcss/oxide":"^4.1.4",lightningcss:"^1.29.2","react-devtools-core":"^7.0.1"},publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brain-cli"},scripts:{build:"bun scripts/build.ts","build:ui":"turbo run build --filter=@brains/web-chat --filter=@brains/studio",eval:"bun run build && brain-eval","eval:headless":"bun run eval --suite headless","eval:personal":"bun run eval --suite personal","eval:professional":"bun run eval --suite professional","eval:team":"bun run eval --suite team","eval:git":"bun run eval --suite professional --tags requires-supervised-git --mcp-basic --url http://localhost:8080 --token $MCP_AUTH_TOKEN",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts","start:minimal":"sh scripts/start-test-app.sh minimal","start:unified-inbox":"sh scripts/start-test-app.sh unified-inbox","start:personal":"sh scripts/start-test-app.sh personal","start:publishing":"sh scripts/start-test-app.sh publishing","start:team":"sh scripts/start-test-app.sh team",test:"bun test --parallel=4 --path-ignore-patterns='**/{boot-smoke,served-surface,canonical-eval-suites,public-plugin-api,public-authoring-golden,public-authoring-docs,public-chat-contract,package-metadata}.test.ts'","test:boot-smoke":"bun run build && bun run test:boot-smoke:prebuilt","test:boot-smoke:prebuilt":"bun test test/boot-smoke.test.ts test/served-surface.test.ts","test:evals":"bun test test/canonical-eval-suites.test.ts","test:surface":"bun test test/public-plugin-api.test.ts test/public-authoring-golden.test.ts test/public-authoring-docs.test.ts test/public-chat-contract.test.ts test/package-metadata.test.ts && bun run test:boot-smoke:prebuilt","test:packed:compat":"bun scripts/run-packed-compatibility.ts",typecheck:"tsc --noEmit && tsc --noEmit -p tsconfig.model.json"},type:"module"};import{existsSync as d,readFileSync as b}from"fs";import{dirname as u,join as a}from"path";var k=t.looseObject({name:t.string().min(1),version:t.string().min(1),dependencies:t.record(t.string(),t.string()).optional(),peerDependencies:t.record(t.string(),t.string()).optional()});class r extends Error{constructor(e,s,i){super(i?`Package "${e.name}@${e.version}" requires @rizom/brain "${i}", but "${s}" is installed; install a compatible Brain version or update the peer range only after testing that release`:`Package "${e.name}@${e.version}" must declare a @rizom/brain peer dependency; add the tested range under peerDependencies in its package.json`);this.name="PackagePeerCompatibilityError"}}function o(e){let s=u(e);return s===e?[e]:[e,...o(s)]}function m(e,s){return Object.freeze({name:e.name,version:e.version,dependencies:Object.freeze({...e.dependencies??{}}),peerDependencies:Object.freeze({...e.peerDependencies??{}}),directory:s})}function v(e){let s=o(e).find((p)=>d(a(p,"package.json")));if(s===void 0)throw Error(`No package.json at or above "${e}"; run from the package's own directory`);let i=a(s,"package.json"),c=JSON.parse(b(i,"utf8")),n=k.safeParse(c);if(!n.success)throw Error(`"${i}" must declare non-empty name and version fields`);return m(n.data,s)}function j(e,s){let i=e.peerDependencies["@rizom/brain"];if(!i||!Bun.semver.satisfies(s,i))throw new r(e,s,i)}
|
|
3
3
|
export{v as O,j as P,g as Q};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
6
|
-
//# sourceMappingURL=index-
|
|
5
|
+
//# debugId=2D0D25D099EC112264756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-6q9qf483.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { z } from \"@brains/utils/zod\";\n\nconst packageManifestSchema = z.looseObject({\n name: z.string().min(1),\n version: z.string().min(1),\n dependencies: z.record(z.string(), z.string()).optional(),\n peerDependencies: z.record(z.string(), z.string()).optional(),\n});\n\nexport interface InstalledPackageManifest {\n readonly name: string;\n readonly version: string;\n readonly dependencies: Readonly<Record<string, string>>;\n readonly peerDependencies: Readonly<Record<string, string>>;\n readonly directory: string;\n}\n\nexport class PackagePeerCompatibilityError extends Error {\n constructor(\n packageMetadata: InstalledPackageManifest,\n brainVersion: string,\n peerRange: string | undefined,\n ) {\n super(\n peerRange\n ? `Package \"${packageMetadata.name}@${packageMetadata.version}\" requires @rizom/brain \"${peerRange}\", but \"${brainVersion}\" is installed; install a compatible Brain version or update the peer range only after testing that release`\n : `Package \"${packageMetadata.name}@${packageMetadata.version}\" must declare a @rizom/brain peer dependency; add the tested range under peerDependencies in its package.json`,\n );\n this.name = \"PackagePeerCompatibilityError\";\n }\n}\n\nfunction matchesPackageRef(packageRef: string, packageName: string): boolean {\n return packageRef === packageName || packageRef.startsWith(`${packageName}/`);\n}\n\nfunction ancestorDirectories(directory: string): string[] {\n const parent = dirname(directory);\n return parent === directory\n ? [directory]\n : [directory, ...ancestorDirectories(parent)];\n}\n\nfunction installedManifest(\n manifest: z.output<typeof packageManifestSchema>,\n directory: string,\n): InstalledPackageManifest {\n return Object.freeze({\n name: manifest.name,\n version: manifest.version,\n dependencies: Object.freeze({ ...(manifest.dependencies ?? {}) }),\n peerDependencies: Object.freeze({ ...(manifest.peerDependencies ?? {}) }),\n directory,\n });\n}\n\n/**\n * The package a directory belongs to: the nearest `package.json` at or above\n * it, the way an installed module's package is found.\n */\nexport function findPackageManifest(\n fromDirectory: string,\n): InstalledPackageManifest {\n const directory = ancestorDirectories(fromDirectory).find((candidate) =>\n existsSync(join(candidate, \"package.json\")),\n );\n if (directory === undefined) {\n throw new Error(\n `No package.json at or above \"${fromDirectory}\"; run from the package's own directory`,\n );\n }\n const manifestPath = join(directory, \"package.json\");\n const rawManifest: unknown = JSON.parse(readFileSync(manifestPath, \"utf8\"));\n const parsed = packageManifestSchema.safeParse(rawManifest);\n if (!parsed.success) {\n throw new Error(\n `\"${manifestPath}\" must declare non-empty name and version fields`,\n );\n }\n return installedManifest(parsed.data, directory);\n}\n\nexport function resolveInstalledPackageManifest(\n packageRef: string,\n fromDirectory: string,\n): InstalledPackageManifest {\n let resolved: string;\n try {\n resolved = Bun.resolveSync(packageRef, fromDirectory);\n } catch (error) {\n throw new Error(\n `Could not resolve installed package \"${packageRef}\" from \"${fromDirectory}\"; install it in the Brain application or correct the package reference`,\n { cause: error },\n );\n }\n\n for (const directory of ancestorDirectories(dirname(resolved))) {\n const manifestPath = join(directory, \"package.json\");\n if (!existsSync(manifestPath)) continue;\n\n const rawManifest: unknown = JSON.parse(readFileSync(manifestPath, \"utf8\"));\n const parsed = packageManifestSchema.safeParse(rawManifest);\n if (parsed.success && matchesPackageRef(packageRef, parsed.data.name)) {\n return installedManifest(parsed.data, directory);\n }\n }\n\n throw new Error(\n `Resolved package \"${packageRef}\" from \"${fromDirectory}\" but could not find valid package metadata; ensure its package.json declares matching non-empty name and version fields`,\n );\n}\n\n/** A package runs only on a Brain its `@rizom/brain` peer range admits. */\nexport function assertBrainPeerCompatibility(\n packageMetadata: InstalledPackageManifest,\n brainVersion: string,\n): void {\n const peerRange = packageMetadata.peerDependencies[\"@rizom/brain\"];\n if (!peerRange || !Bun.semver.satisfies(brainVersion, peerRange)) {\n throw new PackagePeerCompatibilityError(\n packageMetadata,\n brainVersion,\n peerRange,\n );\n }\n}\n\nexport function resolveBrainDefinitionDependencies(\n brainPackageRef: string,\n fromDirectory: string,\n): InstalledPackageManifest[] {\n const brain = resolveInstalledPackageManifest(brainPackageRef, fromDirectory);\n if (brain.name === \"@rizom/brain\") return [];\n\n const runtime = resolveInstalledPackageManifest(\n \"@rizom/brain\",\n fromDirectory,\n );\n assertBrainPeerCompatibility(brain, runtime.version);\n\n const definitionDependencies = Object.keys(brain.dependencies)\n .map((dependency) =>\n resolveInstalledPackageManifest(dependency, brain.directory),\n )\n .filter(\n (dependency) => dependency.peerDependencies[\"@rizom/brain\"] !== undefined,\n );\n for (const dependency of definitionDependencies) {\n assertBrainPeerCompatibility(dependency, runtime.version);\n }\n return definitionDependencies;\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";24MAAA,qBAAS,kBAAY,WACrB,kBAAS,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S,EAkC1C,SAAS,CAA4B,CAC1C,EACA,EACM,CACN,IAAM,EAAY,EAAgB,iBAAiB,gBACnD,GAAI,CAAC,GAAa,CAAC,IAAI,OAAO,UAAU,EAAc,CAAS,EAC7D,MAAM,IAAI,EACR,EACA,EACA,CACF",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "2D0D25D099EC112264756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{N as p}from"./index-66v76w4h.js";import{Ba as m,Ga as d,Ja as v,Ka as S}from"./index-tc1g7d2h.js";import{Lg as u}from"./index-dre4wmv8.js";import{Xn as n,Yn as r}from"./index-yhsfzqsw.js";import{Dv as s,Es as l,ps as f}from"./index-g95msk2x.js";import{yx as g}from"./index-edt6y87t.js";async function h(e){let[{default:i},{default:t}]=await Promise.all([import("./index-sdvcnhe0.js"),import("./package-tn24s06v.js")]);return u(i,e??{},{name:t.name,version:t.version},{pluginId:"cli"})}class c{shell=null;config;signalScope=null;signalShutdownFiber=null;stopPromise=null;hasCLI=!1;static create(e,i){return new c(v(e),i)}constructor(e,i){if(this.config=e,this.hasCLI=process.argv.slice(2).includes("--cli"),i)this.shell=i}async migrate(){let e=r.getInstance();await new d(e).runAllMigrations({database:this.config.shellConfig?.database?.url??this.config.database,jobQueueDatabase:this.config.shellConfig?.jobQueueDatabase?.url,conversationDatabase:this.config.shellConfig?.conversationDatabase?.url,runtimeStateDatabase:this.config.shellConfig?.runtimeStateDatabase?.url})}createShell(e,i){this.shell=m.createFresh(S(this.config,e),void 0,{...i?.processRole&&{processRole:i.processRole},...i?.peerChannel&&{peerChannel:i.peerChannel}})}wantsCLI(e){return this.hasCLI||e?.cli===!0}async registerCLIInterface(e){if(!this.wantsCLI(e))return;let i=this.getShell().getPluginManager();for(let t of await h(this.config.cliConfig))i.registerPlugin(t)}async initialize(e,i){if(!this.shell){if(!i?.migrationsCompleted)await this.migrate();this.createShell(e,i)}await this.registerCLIInterface(i),await this.getShell().initialize(e)}async start(){if(this.stopPromise)return;this.setupSignalHandlers()}stop(){return this.stopPromise??=this.stopApp(),this.stopPromise}async stopApp(){await this.closeSignalScope(),await this.shell?.shutdown()}async run(e){let t={debug:n.DEBUG,info:n.INFO,warn:n.WARN,error:n.ERROR}[this.config.logLevel??"info"]??n.INFO,o=this.wantsCLI(e),a=r.createFresh({level:t,context:this.config.name,useStderr:o});if(o)r.getInstance().setUseStderr(!0);try{await this.initialize(void 0,e),await this.start(),e?.onRuntimeReady?.(),a.info(`\u2705 ${this.config.name} v${this.config.version} ready`),process.stdin.resume()}catch(C){a.error(`\u274C Failed to start ${this.config.name}:`,C),process.exit(1)}}static async run(e,i,t){await c.create(e,i).run(t)}setupSignalHandlers(){if(this.signalScope)return;let e=s.runSync(l.make()),i=()=>{this.requestGracefulShutdown("SIGINT")},t=()=>{this.requestGracefulShutdown("SIGTERM")},o=p(["SIGINT"],i),a=p(["SIGTERM"],t);s.runSync(l.addFinalizer(e,s.sync(()=>{a(),o()}))),this.signalScope=e}requestGracefulShutdown(e){if(this.signalShutdownFiber)return;let i=r.getInstance();i.info(`
|
|
3
|
+
Received ${e}, shutting down gracefully...`);let t=s.tryPromise({try:()=>this.stop(),catch:(o)=>o}).pipe(s.match({onFailure:(o)=>{i.error("Error during shutdown:",o),process.exit(1)},onSuccess:()=>{process.exit(0)}}));this.signalShutdownFiber=s.runFork(t)}async closeSignalScope(){let e=this.signalScope;if(this.signalScope=null,e)await s.runPromise(l.close(e,f.void))}getShell(){if(!this.shell)throw Error("Shell not initialized. Call initialize() first.");return this.shell}}
|
|
4
|
+
export{c as B};
|
|
5
|
+
|
|
6
|
+
//# debugId=CA66FC041D98DA0864756E2164756E21
|
|
7
|
+
//# sourceMappingURL=index-zxffbhsj.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../shell/app/src/cli-interface.ts", "../../../shell/app/src/app.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { Plugin } from \"@brains/plugins\";\nimport { instantiatePluginPackageDefinition } from \"@brains/plugins\";\nimport type { CLIConfig } from \"@brains/chat-repl\";\n\n/**\n * The terminal interface `--cli` adds: the chat-repl package's definition,\n * under the plugin id its class had, so its daemon stays `cli:cli`. Loaded\n * only when asked for, which keeps React and Ink out of every other start.\n */\nexport async function createCliInterface(\n config: CLIConfig | undefined,\n): Promise<Plugin[]> {\n const [{ default: cliInterface }, { default: manifest }] = await Promise.all([\n import(\"@brains/chat-repl\"),\n import(\"@brains/chat-repl/package.json\"),\n ]);\n return instantiatePluginPackageDefinition(\n cliInterface,\n config ?? {},\n { name: manifest.name, version: manifest.version },\n { pluginId: \"cli\" },\n );\n}\n",
|
|
6
|
+
"import { Shell } from \"@brains/core\";\nimport type { AppConfig, AppConfigInput } from \"./types\";\nimport { ConsoleLogger, LogLevel } from \"@brains/utils/logger\";\nimport { MigrationManager } from \"./migration-manager\";\nimport { createCliInterface } from \"./cli-interface\";\nimport {\n buildShellConfig,\n toAppConfig,\n type InitializeOptions,\n} from \"./shell-config\";\nimport { Effect, Exit, Scope } from \"@brains/utils/effect\";\nimport type { Fiber } from \"@brains/utils/effect\";\nimport type { PeerChannel, RuntimeProcessRole } from \"@brains/core\";\nimport { addProcessSignalListeners } from \"@brains/utils/process-signals\";\n\nexport interface AppRuntimeOptions {\n migrationsCompleted?: boolean;\n processRole?: RuntimeProcessRole;\n /** The line to the runtime's other processes, when supervised. */\n peerChannel?: PeerChannel;\n onRuntimeReady?: () => void;\n /**\n * Run the terminal chat interface, as `--cli` on the command line does. A\n * caller whose command line carries no `--cli`, such as a bundled\n * `brain chat`, asks for it here.\n */\n cli?: boolean;\n}\n\nexport class App {\n private shell: Shell | null = null;\n private config: AppConfig;\n private signalScope: Scope.Closeable | null = null;\n private signalShutdownFiber: Fiber.Fiber<void, never> | null = null;\n private stopPromise: Promise<void> | null = null;\n private hasCLI = false;\n\n public static create(config?: AppConfigInput, shell?: Shell): App {\n return new App(toAppConfig(config), shell);\n }\n\n private constructor(config: AppConfig, shell?: Shell) {\n this.config = config;\n // Check if --cli flag is present\n this.hasCLI = process.argv.slice(2).includes(\"--cli\");\n\n // Store the shell if provided, otherwise we'll create it in initialize()\n if (shell) {\n this.shell = shell;\n }\n }\n\n public async migrate(): Promise<void> {\n const logger = ConsoleLogger.getInstance();\n const migrationManager = new MigrationManager(logger);\n // Pass database URL overrides from shellConfig or simple config\n await migrationManager.runAllMigrations({\n database: this.config.shellConfig?.database?.url ?? this.config.database,\n jobQueueDatabase: this.config.shellConfig?.jobQueueDatabase?.url,\n conversationDatabase: this.config.shellConfig?.conversationDatabase?.url,\n runtimeStateDatabase: this.config.shellConfig?.runtimeStateDatabase?.url,\n });\n }\n\n private createShell(\n options?: InitializeOptions,\n runtimeOptions?: AppRuntimeOptions,\n ): void {\n // Let shellInitializer build the logger from shellConfig.logging so\n // logFile, format, and level take effect. ConsoleLogger.getInstance() ignores\n // options on a pre-existing singleton.\n this.shell = Shell.createFresh(\n buildShellConfig(this.config, options),\n undefined,\n {\n ...(runtimeOptions?.processRole && {\n processRole: runtimeOptions.processRole,\n }),\n ...(runtimeOptions?.peerChannel && {\n peerChannel: runtimeOptions.peerChannel,\n }),\n },\n );\n }\n\n private wantsCLI(runtimeOptions?: AppRuntimeOptions): boolean {\n return this.hasCLI || runtimeOptions?.cli === true;\n }\n\n private async registerCLIInterface(\n runtimeOptions?: AppRuntimeOptions,\n ): Promise<void> {\n if (!this.wantsCLI(runtimeOptions)) return;\n\n const pluginManager = this.getShell().getPluginManager();\n for (const plugin of await createCliInterface(this.config.cliConfig)) {\n pluginManager.registerPlugin(plugin);\n }\n }\n\n public async initialize(\n options?: InitializeOptions,\n runtimeOptions?: AppRuntimeOptions,\n ): Promise<void> {\n // A supervised child starts only after the parent has completed migrations.\n // Injected shells remain migration-free for tests and embedding applications.\n if (!this.shell) {\n if (!runtimeOptions?.migrationsCompleted) await this.migrate();\n this.createShell(options, runtimeOptions);\n }\n\n await this.registerCLIInterface(runtimeOptions);\n\n // Initialize shell (which will initialize all plugins including interfaces)\n await this.getShell().initialize(options);\n }\n\n public async start(): Promise<void> {\n if (this.stopPromise) return;\n this.setupSignalHandlers();\n }\n\n public stop(): Promise<void> {\n this.stopPromise ??= this.stopApp();\n return this.stopPromise;\n }\n\n private async stopApp(): Promise<void> {\n await this.closeSignalScope();\n await this.shell?.shutdown();\n }\n\n /**\n * Run the app - handles initialization, startup, and keeps process alive\n * This is the simplest way to start an app\n */\n public async run(runtimeOptions?: AppRuntimeOptions): Promise<void> {\n // Create logger for run output\n const logLevelMap: Record<string, LogLevel> = {\n debug: LogLevel.DEBUG,\n info: LogLevel.INFO,\n warn: LogLevel.WARN,\n error: LogLevel.ERROR,\n };\n const logLevel =\n logLevelMap[this.config.logLevel ?? \"info\"] ?? LogLevel.INFO;\n\n const hasCLI = this.wantsCLI(runtimeOptions);\n const logger = ConsoleLogger.createFresh({\n level: logLevel,\n context: this.config.name,\n useStderr: hasCLI, // Use stderr when CLI is active to avoid interfering with Ink UI\n });\n\n // Configure global logger instance to also use stderr if CLI is active\n if (hasCLI) {\n ConsoleLogger.getInstance().setUseStderr(true);\n }\n\n try {\n await this.initialize(undefined, runtimeOptions);\n await this.start();\n runtimeOptions?.onRuntimeReady?.();\n\n logger.info(`✅ ${this.config.name} v${this.config.version} ready`);\n\n // Keep process alive\n process.stdin.resume();\n } catch (error) {\n logger.error(`❌ Failed to start ${this.config.name}:`, error);\n process.exit(1);\n }\n }\n\n /**\n * Static convenience method to create and run an app in one call\n */\n public static async run(\n config?: AppConfigInput,\n shell?: Shell,\n runtimeOptions?: AppRuntimeOptions,\n ): Promise<void> {\n const app = App.create(config, shell);\n await app.run(runtimeOptions);\n }\n\n private setupSignalHandlers(): void {\n if (this.signalScope) return;\n\n const scope = Effect.runSync(Scope.make());\n const sigintHandler = (): void => {\n this.requestGracefulShutdown(\"SIGINT\");\n };\n const sigtermHandler = (): void => {\n this.requestGracefulShutdown(\"SIGTERM\");\n };\n\n const removeSigint = addProcessSignalListeners([\"SIGINT\"], sigintHandler);\n const removeSigterm = addProcessSignalListeners(\n [\"SIGTERM\"],\n sigtermHandler,\n );\n Effect.runSync(\n Scope.addFinalizer(\n scope,\n Effect.sync(() => {\n removeSigterm();\n removeSigint();\n }),\n ),\n );\n this.signalScope = scope;\n }\n\n private requestGracefulShutdown(signal: \"SIGINT\" | \"SIGTERM\"): void {\n if (this.signalShutdownFiber) return;\n\n const logger = ConsoleLogger.getInstance();\n logger.info(`\\nReceived ${signal}, shutting down gracefully...`);\n const shutdown = Effect.tryPromise({\n try: () => this.stop(),\n catch: (error) => error,\n }).pipe(\n Effect.match({\n onFailure: (error) => {\n logger.error(\"Error during shutdown:\", error);\n process.exit(1);\n },\n onSuccess: () => {\n process.exit(0);\n },\n }),\n );\n this.signalShutdownFiber = Effect.runFork(shutdown);\n }\n\n private async closeSignalScope(): Promise<void> {\n const scope = this.signalScope;\n this.signalScope = null;\n if (scope) await Effect.runPromise(Scope.close(scope, Exit.void));\n }\n\n public getShell(): Shell {\n if (!this.shell) {\n throw new Error(\"Shell not initialized. Call initialize() first.\");\n }\n return this.shell;\n }\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";qSASA,eAAsB,CAAkB,CACtC,EACmB,CACnB,KAAS,QAAS,IAAkB,QAAS,IAAc,MAAM,QAAQ,IAAI,CACpE,8BACA,+BACT,CAAC,EACD,OAAO,EACL,EACA,GAAU,CAAC,EACX,CAAE,KAAM,EAAS,KAAM,QAAS,EAAS,OAAQ,EACjD,CAAE,SAAU,KAAM,CACpB,ECQK,MAAM,CAAI,CACP,MAAsB,KACtB,OACA,YAAsC,KACtC,oBAAuD,KACvD,YAAoC,KACpC,OAAS,SAEH,OAAM,CAAC,EAAyB,EAAoB,CAChE,OAAO,IAAI,EAAI,EAAY,CAAM,EAAG,CAAK,EAGnC,WAAW,C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AAK;AAAA,WAAc,gCAAqC,EAC/D,IAAM,EAAW,EAAO,WAAW,CACjC,IAAK,IAAM,KAAK,KAAK,EACrB,MAAO,CAAC,IAAU,CACpB,CAAC,EAAE,KACD,EAAO,MAAM,CACX,UAAW,CAAC,IAAU,CACpB,EAAO,MAAM,yBAA0B,CAAK,EAC5C,QAAQ,KAAK,CAAC,GAEhB,UAAW,IAAM,CACf,QAAQ,KAAK,CAAC,EAElB,CAAC,CACH,EACA,KAAK,oBAAsB,EAAO,QAAQ,CAAQ,OAGtC,iBAAgB,EAAkB,CAC9C,IAAM,EAAQ,KAAK,YAEnB,GADA,KAAK,YAAc,KACf,EAAO,MAAM,EAAO,WAAW,EAAM,MAAM,EAAO,EAAK,IAAI,CAAC,EAG3D,QAAQ,EAAU,CACvB,GAAI,CAAC,KAAK,MACR,MAAU,MAAM,iDAAiD,EAEnE,OAAO,KAAK,MAEhB",
|
|
9
|
+
"debugId": "CA66FC041D98DA0864756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./index-edt6y87t.js";var n="@brains/chat-repl",i="AGPL-3.0-only",t="0.2.0-alpha.
|
|
2
|
+
import"./index-edt6y87t.js";var n="@brains/chat-repl",i="AGPL-3.0-only",t="0.2.0-alpha.692",r={"@brains/contracts":"workspace:*","@brains/sdk":"workspace:*","@brains/utils":"workspace:*",chalk:"^5.4.1",ink:"^7.0.6","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0",marked:"^18.0.5",react:"^19.2.7"},a={"@brains/eslint-config":"workspace:*","@brains/plugins":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.4.0","@types/react":"^19.2.17",typescript:"^7.0.2"},c=["src"],p="./src/index.ts",l="./src/index.ts",o=!0,k={dev:"tsc --watch",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},d="module",b="./src/index.ts",w={name:n,license:i,version:t,dependencies:r,devDependencies:a,files:c,main:p,module:l,private:o,scripts:k,type:d,types:b};export{w as default,r as dependencies,a as devDependencies,c as files,i as license,p as main,l as module,n as name,o as private,k as scripts,d as type,b as types,t as version};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=package-
|
|
4
|
+
//# debugId=E19D172DBB37B57864756E2164756E21
|
|
5
|
+
//# sourceMappingURL=package-tn24s06v.js.map
|