@rizom/brain 0.2.0-alpha.685 → 0.2.0-alpha.686
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 +27 -27
- package/dist/chunks/{app-jyfk7s9m.js → app-4c53djz8.js} +2 -2
- package/dist/chunks/{index-v7fe5rpz.js → index-6na1nq7g.js} +2 -2
- package/dist/chunks/{index-nj68nsdp.js → index-955w889r.js} +3 -3
- package/dist/chunks/{index-nj68nsdp.js.map → index-955w889r.js.map} +3 -3
- package/dist/chunks/{index-cn7cb3ve.js → index-ez8a274a.js} +3 -3
- package/dist/chunks/{index-cn7cb3ve.js.map → index-ez8a274a.js.map} +1 -1
- package/dist/chunks/{index-kyhqwbat.js → index-f33mthze.js} +2 -2
- package/dist/chunks/{index-27ea29ae.js → index-qte031xt.js} +2 -2
- package/dist/chunks/{index-7dx1zqyb.js → index-yhwj6qak.js} +2 -2
- package/dist/chunks/{linkedin-template-q4aankvw.js → linkedin-template-4we655mx.js} +2 -2
- package/dist/chunks/{package-gy1ank6b.js → package-pzecgmq7.js} +3 -3
- package/dist/chunks/{package-gy1ank6b.js.map → package-pzecgmq7.js.map} +1 -1
- package/dist/entities.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces.js +1 -1
- package/dist/model.js +25 -25
- package/dist/model.js.map +1 -1
- package/dist/services.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/ui/studio-chunks/main-7zrz7m38.js.map +1 -1
- package/package.json +1 -1
- /package/dist/chunks/{app-jyfk7s9m.js.map → app-4c53djz8.js.map} +0 -0
- /package/dist/chunks/{index-v7fe5rpz.js.map → index-6na1nq7g.js.map} +0 -0
- /package/dist/chunks/{index-kyhqwbat.js.map → index-f33mthze.js.map} +0 -0
- /package/dist/chunks/{index-27ea29ae.js.map → index-qte031xt.js.map} +0 -0
- /package/dist/chunks/{index-7dx1zqyb.js.map → index-yhwj6qak.js.map} +0 -0
- /package/dist/chunks/{linkedin-template-q4aankvw.js.map → linkedin-template-4we655mx.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fx as t}from"./index-yxb1d9bc.js";var g={name:"@rizom/brain",version:"0.2.0-alpha.
|
|
2
|
+
import{fx as t}from"./index-yxb1d9bc.js";var g={name:"@rizom/brain",version:"0.2.0-alpha.686",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=5C1CB0F9E62770D364756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-ez8a274a.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,UAAS,aAGlB,IAAM,EAAwB,EAAE,YAAY,CAC1C,KAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EACtB,QAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EACzB,aAAc,EAAE,OAAO,EAAE,OAAO,EAAG,EAAE,OAAO,CAAC,EAAE,SAAS,EACxD,iBAAkB,EAAE,OAAO,EAAE,OAAO,EAAG,EAAE,OAAO,CAAC,EAAE,SAAS,CAC9D,CAAC,EAUM,MAAM,UAAsC,KAAM,CACvD,WAAW,CACT,EACA,EACA,EACA,CACA,MACE,EACI,YAAY,EAAgB,QAAQ,EAAgB,mCAAmC,YAAoB,+GAC3G,YAAY,EAAgB,QAAQ,EAAgB,uHAC1D,EACA,KAAK,KAAO,gCAEhB,CAMA,SAAS,CAAmB,CAAC,EAA6B,CACxD,IAAM,EAAS,EAAQ,CAAS,EAChC,OAAO,IAAW,EACd,CAAC,CAAS,EACV,CAAC,EAAW,GAAG,EAAoB,CAAM,CAAC,EAGhD,SAAS,CAAiB,CACxB,EACA,EAC0B,CAC1B,OAAO,OAAO,OAAO,CACnB,KAAM,EAAS,KACf,QAAS,EAAS,QAClB,aAAc,OAAO,OAAO,IAAM,EAAS,cAAgB,CAAC,CAAG,CAAC,EAChE,iBAAkB,OAAO,OAAO,IAAM,EAAS,kBAAoB,CAAC,CAAG,CAAC,EACxE,WACF,CAAC,EAOI,SAAS,CAAmB,CACjC,EAC0B,CAC1B,IAAM,EAAY,EAAoB,CAAa,EAAE,KAAK,CAAC,IACzD,EAAW,EAAK,EAAW,cAAc,CAAC,CAC5C,EACA,GAAI,IAAc,OAChB,MAAU,MACR,gCAAgC,0CAClC,EAEF,IAAM,EAAe,EAAK,EAAW,cAAc,EAC7C,EAAuB,KAAK,MAAM,EAAa,EAAc,MAAM,CAAC,EACpE,EAAS,EAAsB,UAAU,CAAW,EAC1D,GAAI,CAAC,EAAO,QACV,MAAU,MACR,IAAI,mDACN,EAEF,OAAO,EAAkB,EAAO,KAAM,CAAS,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": "5C1CB0F9E62770D364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$f as Bc,Ab as gd,Af as Dd,Ag as zo,Bb as fd,Bc as Vn,Be as bd,Cb as hd,Ce as Sd,Db as yd,De as No,Dg as Tr,Eb as Xn,Ee as Ho,Eg as fs,Ei as tc,Ej as js,Fb as eo,Fe as Wo,Fg as ke,Fi as rc,Fj as ad,Gb as to,Gi as pt,He as qo,Hg as od,Hj as xs,Ib as Mt,Ig as hs,Ih as mn,Ii as sd,Jb as rs,Je as Ql,Jh as ye,Ji as Ps,Jj as Ka,Kb as St,Kc as is,Ke as Kl,Kh as gn,Kj as Xt,Lb as We,Le as Vl,Mb as Ae,Me as Yl,Nb as lc,Ne as rd,Nf as vn,Ob as hl,Oe as kl,Of as gt,Pa as dt,Pd as U,Pf as Ha,Qa as Se,Qb as A,Qf as id,Ra as uo,Rb as gr,Rd as nc,Rh as vs,Sa as z,Sb as ti,Sd as Oa,Sh as fn,Tb as Yc,Td as xi,Th as zr,Ua as de,Ub as Ao,Uf as Zs,Uh as bs,Vb as jo,Vh as hn,Wa as po,Wb as Do,Wh as Ss,Xh as Sc,Yb as vt,Yh as Rs,Zb as $r,Zh as Oo,_h as ws,ag as _c,ai as xo,bg as Zc,bi as Mo,cb as mo,cc as fr,cg as ds,ci as Lo,dc as Uc,dg as us,di as Uo,eg as ps,ei as $o,hb as qr,hd as Rr,ib as xt,jb as no,kb as oo,ld as ul,mb as so,nb as cd,nd as Ts,ne as $a,oe as yt,pd as Es,qb as ao,qd as qc,qf as wd,qj as ks,rb as fo,rf as Pd,rg as ms,rj as Bo,sd as yl,se as Jn,sf as Cd,tb as ge,td as ns,te as cs,tg as gs,ub as fe,uc as td,ue as yn,ug as qe,uj as As,vb as ld,vc as _s,vd as ie,ve as ls,vg as Wa,vj as _o,wb as dd,wc as ro,wd as Fi,wg as qa,wj as Cs,xb as ud,xe as Bs,xf as nr,xj as Zo,yb as pd,ye as ei,yf as Ec,yg as Ja,zb as md,zc as $c,zf as Qn,zg as nd}from"./index-nj68nsdp.js";import{El as ce,En as ys,Fn as Aa,Gm as ed,Hl as Ce,In as me,Jl as x,Kl as He,Km as Ko,Mn as re,Qk as Ma,Rk as V,Rl as qn,Sj as al,Tj as cl,Uj as Ie,Wj as Pr,Xj as mr,Yj as tt,an as Da,bm as ve,cn as za,dm as At,im as $s,in as se,jm as Vt,jn as te,nl as Eo,nm as Fa,ol as ko,pn as os,qm as Qt,rl as Wn,vn as Ic,wn as ss,xn as as,zn as Jl}from"./index-nv18ttqn.js";import{Nn as Ge,On as Te}from"./index-dgjygks7.js";import{Av as vo,Cs as X,Hv as Fe,Jv as ae,Kv as bo,Lv as Yt,Mv as Na,Pp as I,Pv as Ga,Tr as le,Vr as ts,fs as k,tv as b,us as E}from"./index-qzjfm25x.js";import{fx as l}from"./index-yxb1d9bc.js";function Dr(e,t){let r=new Set(t.map((i)=>i.type));return e.byType.filter((i)=>(i.status==="pending"||i.status==="processing")&&!r.has(i.type))}function $e(e,t){let r=e.workerSessions,i=r.active===0?"missing":r.stale>0?"stale":"active",n=e.duePending>0&&(e.oldestDuePendingAgeMs??0)>=120000&&e.totals.processing===0&&(e.latestClaimAgeMs===null||e.latestClaimAgeMs>=120000),o=[];if(i==="missing")o.push("No live worker session");else if(i==="stale")o.push(`${r.stale} stale worker session(s)`);if(n)o.push(`${e.duePending} due job(s) have remained unclaimed for at least 120000ms`);if(t){let s=Dr(e,t).reduce((a,c)=>a+c.count,0);if(s>0)o.push(`${s} active job(s) have no declared executor`)}return{status:o.length===0?"operational":"degraded",reasons:o,worker:{state:i,activeSessions:r.active,staleSessions:r.stale,latestHeartbeatAgeMs:r.latestHeartbeatAgeMs},queue:{duePending:e.duePending,processing:e.totals.processing,oldestDuePendingAgeMs:e.oldestDuePendingAgeMs,latestClaimAgeMs:e.latestClaimAgeMs,stalled:n}}}async function cn(e){let{config:t,services:r,bootTime:i,endpoints:n,interactions:o}=e,[s,a,c,d]=await Promise.all([r.entityService.getEntityCounts(dt("runtime app info reports operator-facing aggregate status")),r.entityService.countEmbeddings(),r.daemonRegistry.getStatuses(),r.jobQueueService.getDiagnostics()]),u=s.reduce((p,g)=>p+g.count,0);return{model:t.name||"brain-app",version:t.version||"1.0.0",uptime:Math.floor((Date.now()-i)/1000),entities:u,entityCounts:s,embeddings:a,backgroundWork:$e(d,r.jobQueueService.getExecutionRegistrations()),ai:{model:t.ai.model,embeddingModel:r.embeddingService.identity.model},daemons:c,endpoints:n(),interactions:o()}}import{readdir as ln,readFile as qd}from"fs/promises";var Jd=10;async function Gd(e="/proc"){let t=null;try{t=(await ln(`${e}/self/fd`)).length}catch{}try{let i=(await ln(e,{withFileTypes:!0})).filter((s)=>s.isDirectory()&&/^\d+$/.test(s.name)).map((s)=>s.name),n=0,o=0;return await Promise.all(i.map(async(s)=>{try{let a=await qd(`${e}/${s}/status`,"utf8");if(o++,/^State:\s+Z\b/m.test(a))n++}catch{}})),{fileDescriptors:t,processCount:o,zombieCount:n}}catch{return{fileDescriptors:t,processCount:null,zombieCount:null}}}function dn(e,t,r){return t.status==="fulfilled"?{name:e,status:"healthy",message:r}:{name:e,status:"unhealthy",message:x(t.reason)}}function Qd(e){if(!e)return{name:"job-worker",status:"degraded",message:"Worker session state is unavailable"};let t=e.workerSessions,r=$e(e).worker;if(r.state==="missing")return{name:"job-worker",status:"degraded",message:"No live worker session",details:{sessions:t}};if(r.state==="stale")return{name:"job-worker",status:"degraded",message:`${t.stale} stale worker session(s)`,details:{sessions:t}};return{name:"job-worker",status:"healthy",message:`${t.active} live worker session(s)`,details:{sessions:t}}}function Kd(e){if(!e)return{name:"job-queue-progress",status:"degraded",message:"Queue progress state is unavailable"};let t=$e(e).queue;return t.stalled?{name:"job-queue-progress",status:"degraded",message:`${t.duePending} due job(s) are not being claimed`,details:{queue:t}}:{name:"job-queue-progress",status:"healthy",message:"Due jobs are being claimed",details:{queue:t}}}function Vd(e,t){if(!e||!t)return{name:"job-execution-inventory",status:"degraded",message:"Job execution inventory is unavailable"};let r=Dr(e,t),i=r.reduce((n,o)=>n+o.count,0);return i===0?{name:"job-execution-inventory",status:"healthy",message:"Every active job type has a declared executor"}:{name:"job-execution-inventory",status:"degraded",message:`${i} active job(s) have no declared executor`,details:{jobs:r}}}function Yd(e){if(!e)return{name:"attempt-leases",status:"degraded",message:"Lease state is unavailable"};return e.staleLeaseCount===0?{name:"attempt-leases",status:"healthy",message:"No stale processing leases"}:{name:"attempt-leases",status:"degraded",message:`${e.staleLeaseCount} processing lease(s) are stale`,details:{staleLeaseCount:e.staleLeaseCount}}}function Xd(e){if(!e.initialized)return{name:"projection-circuits",status:"degraded",message:"Projection runtime supervisor is not initialized"};if(e.openCircuits.length===0)return{name:"projection-circuits",status:"healthy",message:"No projection circuits are open"};return{name:"projection-circuits",status:"degraded",message:`${e.openCircuits.length} projection circuit(s) open`,details:{circuits:e.openCircuits}}}async function eu(e){let t=e.entityService.getProjectionStore(),[r,i,n]=await Promise.all([t.getActiveWave(),t.getUnresolvedProjectionIncidentDiagnostics(Jd),t.getProjectionBatchDiagnostics?.()??Promise.resolve({preparing:0,open:0,abandoned:0,expiredCallbackLeases:0,oldestActiveAgeMs:null,oldestProgressAgeMs:null})]);if(!r)return{waveId:null,batches:n,strandedRules:[],incidentCount:i.total,incidents:i.incidents};let s=(await t.listWaveRules(r.id)).filter((c)=>c.status==="queued"||c.status==="failed"),a=(await Promise.all(s.map(async(c)=>{let d=c.jobId?await e.jobQueueService.getStatus(c.jobId):null;if(c.status!=="failed"&&d&&(d.status==="pending"||d.status==="processing"))return null;return{ruleId:c.ruleId,jobId:c.jobId,jobStatus:d?.status??"missing"}}))).filter((c)=>c!==null);return{waveId:r.id,batches:n,strandedRules:a,incidentCount:i.total,incidents:i.incidents}}function tu(e){if(e.batches.abandoned>0)return{name:"projection-waves",status:"degraded",message:`${e.batches.abandoned} projection batch(es) await recovery`,details:{batches:e.batches}};if(e.batches.expiredCallbackLeases>0)return{name:"projection-waves",status:"degraded",message:"A callback projection batch lease has expired",details:{batches:e.batches}};if(e.incidentCount>0)return{name:"projection-waves",status:"degraded",message:`${e.incidentCount} unresolved terminal projection incident(s)`,details:{incidentCount:e.incidentCount,incidentsTruncated:e.incidentCount>e.incidents.length,incidents:e.incidents.map((t)=>({waveId:t.waveId,ruleId:t.ruleId,jobId:t.jobId,failureReason:t.failureReason,createdAt:t.createdAt}))}};if(!e.waveId)return{name:"projection-waves",status:"healthy",message:e.batches.open+e.batches.preparing>0?`${e.batches.open+e.batches.preparing} projection batch(es) active`:"No active projection wave",...e.batches.open+e.batches.preparing>0&&{details:{batches:e.batches}}};if(e.strandedRules.length===0)return{name:"projection-waves",status:"healthy",message:`Projection wave ${e.waveId} is progressing`};return{name:"projection-waves",status:"degraded",message:`Projection wave ${e.waveId} has ${e.strandedRules.length} stranded rule job(s)`,details:{waveId:e.waveId,strandedRules:e.strandedRules}}}function ru(e){let t=e.filter((r)=>r.status!=="running"||r.health?.status==="error");return t.length===0?{name:"daemons",status:"healthy",message:`${e.length} daemon(s) healthy`}:{name:"daemons",status:"degraded",message:`${t.length} daemon(s) unhealthy`,details:{daemons:t.map((r)=>({name:r.name,status:r.status,health:r.health?.status,message:r.health?.message}))}}}async function un(e){let t=e.now?.()??Date.now(),r=(e.memoryUsage??process.memoryUsage)(),[i,n,o,s,a,c,d,u]=await Promise.allSettled([e.entityService.getEntityCounts(dt("runtime readiness database probe")),e.jobQueueService.getDiagnostics(t),Promise.resolve(e.jobQueueService.getExecutionRegistrations()),e.daemonRegistry.getStatuses(),(e.readProcessSignals??Gd)(),e.projectionRuntimeSupervisor.getDiagnostics(),eu(e),e.operationalHealthRegistry.getChecks()]),p=n.status==="fulfilled"?n.value:null,g=o.status==="fulfilled"?o.value??null:null,m=s.status==="fulfilled"?s.value:[],f=a.status==="fulfilled"?a.value:{fileDescriptors:null,processCount:null,zombieCount:null},h=c.status==="fulfilled"?c.value:{status:"unhealthy",initialized:!1,trackedRoots:0,openCircuits:[]},v=[dn("entity-database",i,"Entity database is accessible"),dn("job-queue-database",n,"Job queue database is accessible"),Qd(p),Kd(p),Vd(p,g),Yd(p),c.status==="fulfilled"?Xd(h):{name:"projection-circuits",status:"degraded",message:x(c.reason)},d.status==="fulfilled"?tu(d.value):{name:"projection-waves",status:"degraded",message:x(d.reason)},s.status==="fulfilled"?ru(m):{name:"daemons",status:"degraded",message:x(s.reason)}],y=u.status==="fulfilled"?u.value:[{name:"plugin-operational-health",status:"degraded",message:"Plugin operational health is unavailable"}],S=[...v,...y];return{status:v.some((R)=>R.status==="unhealthy")?"not_ready":"ready",operationalStatus:S.some((R)=>R.status!=="healthy")?"degraded":"operational",checkedAt:new Date(t).toISOString(),checks:S,resources:{memory:{rssBytes:r.rss,heapUsedBytes:r.heapUsed,heapTotalBytes:r.heapTotal},fileDescriptors:f.fileDescriptors,processes:{total:f.processCount,zombies:f.zombieCount},queue:p,projection:{initialized:h.initialized,trackedRoots:h.trackedRoots,openCircuits:h.openCircuits},worker:p?.workerSessions??{total:0,active:0,stale:0,latestHeartbeatAgeMs:null}}}}function pn(){return{dataDir:"./data",cacheDir:"./cache",distDir:"./dist"}}function he(e){return{database:{url:`file:${e.dataDir}/brain.db`},jobQueueDatabase:{url:`file:${e.dataDir}/brain-jobs.db`},conversationDatabase:{url:`file:${e.dataDir}/conversations.db`},runtimeStateDatabase:{url:`file:${e.dataDir}/runtime-state.db`},embeddingDatabase:{url:`file:${e.dataDir}/embeddings.db`},embedding:{enabled:!0}}}var Be=l.strictObject({enabled:l.boolean().optional().describe("Serve HTTP; defaults to whether the selected bundles host the web surface"),preview:l.boolean().optional().describe("Serve the preview site; defaults to whether a site builder runs"),hostname:l.string().trim().min(1).optional().describe("Bind address; use 127.0.0.1 for isolated local tests"),productionDistDir:l.string().min(1).optional().describe("Directory of the production site, when no site builder writes it"),previewDistDir:l.string().min(1).optional().describe("Directory of the preview site, when no site builder writes it"),sharedImagesDir:l.string().min(1).optional().describe("Directory of shared optimized images")}),ut=Be.extend({enabled:l.boolean().default(!1),preview:l.boolean().default(!0),port:l.number().default(8080).describe("Port of the production listener")});var Or=pn(),iu=l.looseObject({label:l.string().min(1),pluralName:l.string().optional(),layout:l.string().optional(),paginate:l.boolean().optional(),pageSize:l.number().optional(),navigation:l.object({show:l.boolean().optional(),slot:l.enum(["primary","secondary"]).optional(),priority:l.number().optional()}).optional()});function Mr(){return he(Or)}var xe=l.enum(["debug","info","warn","error"]);var Lr=l.object({name:l.string().default("brain-app"),version:l.string().default("1.0.0"),database:Ce,jobQueueDatabase:Ce,jobQueue:l.object({workerConcurrency:l.number().int().min(1).max(32).default(4)}).prefault({}),conversationDatabase:Ce,runtimeStateDatabase:Ce,embeddingDatabase:Ce,ai:l.object({apiKey:l.string().default(""),imageApiKey:l.string().optional(),model:l.string().refine(mn,{error:(e)=>`Unsupported model "${String(e.input)}"`}),embeddingModel:l.string().refine((e)=>zr(e)!==void 0,{error:(e)=>hn(String(e.input))}).default(fn),modelRuntimeUrl:l.string().url().optional(),answerModel:l.string().optional(),visionModel:l.string().optional(),imageModel:l.string().optional(),temperature:l.number().min(0).max(2).default(0.7),webSearch:l.boolean().default(!0),reasoningEffort:se.optional()}).superRefine((e,t)=>{if(e.answerModel&&ye(e.answerModel)!=="local")t.addIssue({code:"custom",path:["answerModel"],message:`answerModel must be a local: model, not ${e.answerModel}`});if(e.visionModel&&ye(e.visionModel)!=="local")t.addIssue({code:"custom",path:["visionModel"],message:`visionModel must be a local: model, not ${e.visionModel}`});if(e.modelRuntimeUrl)return;let r=[...ye(e.model)==="local"?[e.model]:[],...[e.answerModel,e.visionModel].filter((i)=>i!==void 0&&ye(i)==="local"),...e.imageModel&&gn(e.imageModel).provider==="local"?[e.imageModel]:[],...zr(e.embeddingModel)?.provider==="local"?[e.embeddingModel]:[]];for(let i of r)t.addIssue({code:"custom",path:["modelRuntimeUrl"],message:`${i} needs modelRuntime.url`})}),embedding:l.object({enabled:l.boolean().default(!0)}),logging:l.object({level:xe.default("info"),format:l.enum(["text","json"]).default("text"),file:l.string().optional(),context:l.string().default("shell")}).prefault({level:"info",context:"shell"}),features:l.object({}).default({}),plugins:l.array(pt).default([]),dataDir:l.string().default("./brain-data"),gitBrokerSocket:l.string().min(1).optional(),gitBrokerCheckout:l.string().min(1).optional(),spaces:l.array(l.string()).default([]),siteBaseUrl:l.string().optional(),localSiteUrl:l.string().optional(),preferLocalUrls:l.boolean().default(!1),production:l.boolean().default(!1),themeCSS:l.string().default(""),entityDisplay:l.record(l.string(),iu).optional(),profileKind:l.string().trim().min(1).optional(),http:ut.prefault({})});function mt(e={}){let{plugins:t=[],permissions:r={},identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s,ai:a,logging:c,embedding:d,jobQueue:u,...p}=e,{entityDisplay:g,...m}=Lr.parse({...Mr(),...V(p),ai:V({...a}),logging:V({...c}),embedding:V({...d}),jobQueue:V({...u}),plugins:[]});return{...m,plugins:t,permissions:r,...V({entityDisplay:g,identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s})}}var M={NOTE:"note",BRAIN_CHARACTER:"brain-character",ANCHOR_PROFILE:"anchor-profile"},_e={KNOWLEDGE_QUERY:"shell:knowledge-query",BASE_ENTITY_DISPLAY:"shell:base-entity-display",CONTENT_GENERATION:"shell:content-generation"},Ur={ENTITIES:"shell:entities"};var nu=yn.extend({templateName:l.string()}),ou=l.object({slug:l.string()}),su="The style guide governs voice, tone, wording and form: paragraphing, sentence rhythm, hooks, rhetorical questions and calls to action. The instructions below and any additional instructions in the request govern the task, required content, length limits, platform constraints and output format. When either conflicts with the style guide on voice or form, follow the style guide.",au="Generate the content described in your instructions.";function cu(e){return e instanceof l.ZodType}function lu(e){if(!e)return;return e.replace(/^https?:\/\//,"").replace(/\/$/,"")}class ft{aiService;entityService;templateRegistry;getIdentityContent;getProfileContent;entityUrls;id="ai-content";name="AI Content Generator";description="Generates content using AI based on templates and prompts";constructor(e,t,r,i,n,o,s){this.aiService=e,this.entityService=t,this.templateRegistry=r,this.getIdentityContent=i,this.getProfileContent=n,this.entityUrls=o,this.siteBaseUrl=lu(s)}siteBaseUrl;async generate(e,t,r){return this.generateWithContext(e,t,r)}async generateScoped(e,t,r){return this.generateWithContext(e,t,r.signal,r)}async generateWithContext(e,t,r,i){r?.throwIfAborted();let n=nu.parse(e),o=this.templateRegistry.get(n.templateName);if(!o)throw Error(`Template not found: ${n.templateName}`);if(!o.basePrompt)throw Error(`Template ${n.templateName} must have basePrompt for content generation`);let s=i?await vn((v,y)=>i.getEntity(v,y),n.templateName,o.basePrompt):await gt(this.entityService,n.templateName,o.basePrompt);r?.throwIfAborted();let a=[s,n.prompt].filter(Boolean).join(" "),c=a.length>0&&o.useKnowledgeContext===!0,d=this.entityService.getWeightMap(),u=Object.keys(d).length>0,p=c?i?await i.search(a,{limit:5,...u&&{weight:d}}):await this.entityService.search({query:a,options:{limit:5,...u&&{weight:d},...r&&{signal:r}}}):[];r?.throwIfAborted();let g=this.buildPrompt(n,p),m=i?await this.readIdentities(i,n.representedIdentity):void 0,f=this.buildSystemPrompt(s,n,m);if(!cu(o.schema))throw Error(`Template ${o.name} cannot be used for AI generation: schema is not an AI generation schema`);r?.throwIfAborted();let h=await this.aiService.generateObject(f,g,o.schema,r);return r?.throwIfAborted(),t.parse(h.object)}async readIdentities(e,t){let r=async(o)=>(await e.getEntity(o,o))?.content??"",[i,n]=await Promise.all([t!=="none"?r(M.BRAIN_CHARACTER):"",t===void 0||t==="anchor"?r(M.ANCHOR_PROFILE):""]);return{brain:i,anchor:n}}buildSystemPrompt(e,t,r){let i=[];if(t.representedIdentity===void 0||t.representedIdentity==="brain"||t.representedIdentity==="anchor")i.push("# Brain Identity",r?.brain??this.getIdentityContent(),"");if(t.representedIdentity===void 0||t.representedIdentity==="anchor")i.push("# Represented Anchor",r?.anchor??this.getProfileContent(),"");let n=this.selectStyleGuidance(t);if(n)i.push("# Style Guide",n,"","# Precedence",su,"");return i.push("# Instructions",e),i.join(`
|
|
2
|
+
import{$f as Bc,Ab as gd,Af as Dd,Ag as zo,Bb as fd,Bc as Vn,Be as bd,Cb as hd,Ce as Sd,Db as yd,De as No,Dg as Tr,Eb as Xn,Ee as Ho,Eg as fs,Ei as tc,Ej as js,Fb as eo,Fe as Wo,Fg as ke,Fi as rc,Fj as ad,Gb as to,Gi as pt,He as qo,Hg as od,Hj as xs,Ib as Mt,Ig as hs,Ih as mn,Ii as sd,Jb as rs,Je as Ql,Jh as ye,Ji as Ps,Jj as Ka,Kb as St,Kc as is,Ke as Kl,Kh as gn,Kj as Xt,Lb as We,Le as Vl,Mb as Ae,Me as Yl,Nb as lc,Ne as rd,Nf as vn,Ob as hl,Oe as kl,Of as gt,Pa as dt,Pd as U,Pf as Ha,Qa as Se,Qb as A,Qf as id,Ra as uo,Rb as gr,Rd as nc,Rh as vs,Sa as z,Sb as ti,Sd as Oa,Sh as fn,Tb as Yc,Td as xi,Th as zr,Ua as de,Ub as Ao,Uf as Zs,Uh as bs,Vb as jo,Vh as hn,Wa as po,Wb as Do,Wh as Ss,Xh as Sc,Yb as vt,Yh as Rs,Zb as $r,Zh as Oo,_h as ws,ag as _c,ai as xo,bg as Zc,bi as Mo,cb as mo,cc as fr,cg as ds,ci as Lo,dc as Uc,dg as us,di as Uo,eg as ps,ei as $o,hb as qr,hd as Rr,ib as xt,jb as no,kb as oo,ld as ul,mb as so,nb as cd,nd as Ts,ne as $a,oe as yt,pd as Es,qb as ao,qd as qc,qf as wd,qj as ks,rb as fo,rf as Pd,rg as ms,rj as Bo,sd as yl,se as Jn,sf as Cd,tb as ge,td as ns,te as cs,tg as gs,ub as fe,uc as td,ue as yn,ug as qe,uj as As,vb as ld,vc as _s,vd as ie,ve as ls,vg as Wa,vj as _o,wb as dd,wc as ro,wd as Fi,wg as qa,wj as Cs,xb as ud,xe as Bs,xf as nr,xj as Zo,yb as pd,ye as ei,yf as Ec,yg as Ja,zb as md,zc as $c,zf as Qn,zg as nd}from"./index-955w889r.js";import{El as ce,En as ys,Fn as Aa,Gm as ed,Hl as Ce,In as me,Jl as x,Kl as He,Km as Ko,Mn as re,Qk as Ma,Rk as V,Rl as qn,Sj as al,Tj as cl,Uj as Ie,Wj as Pr,Xj as mr,Yj as tt,an as Da,bm as ve,cn as za,dm as At,im as $s,in as se,jm as Vt,jn as te,nl as Eo,nm as Fa,ol as ko,pn as os,qm as Qt,rl as Wn,vn as Ic,wn as ss,xn as as,zn as Jl}from"./index-nv18ttqn.js";import{Nn as Ge,On as Te}from"./index-dgjygks7.js";import{Av as vo,Cs as X,Hv as Fe,Jv as ae,Kv as bo,Lv as Yt,Mv as Na,Pp as I,Pv as Ga,Tr as le,Vr as ts,fs as k,tv as b,us as E}from"./index-qzjfm25x.js";import{fx as l}from"./index-yxb1d9bc.js";function Dr(e,t){let r=new Set(t.map((i)=>i.type));return e.byType.filter((i)=>(i.status==="pending"||i.status==="processing")&&!r.has(i.type))}function $e(e,t){let r=e.workerSessions,i=r.active===0?"missing":r.stale>0?"stale":"active",n=e.duePending>0&&(e.oldestDuePendingAgeMs??0)>=120000&&e.totals.processing===0&&(e.latestClaimAgeMs===null||e.latestClaimAgeMs>=120000),o=[];if(i==="missing")o.push("No live worker session");else if(i==="stale")o.push(`${r.stale} stale worker session(s)`);if(n)o.push(`${e.duePending} due job(s) have remained unclaimed for at least 120000ms`);if(t){let s=Dr(e,t).reduce((a,c)=>a+c.count,0);if(s>0)o.push(`${s} active job(s) have no declared executor`)}return{status:o.length===0?"operational":"degraded",reasons:o,worker:{state:i,activeSessions:r.active,staleSessions:r.stale,latestHeartbeatAgeMs:r.latestHeartbeatAgeMs},queue:{duePending:e.duePending,processing:e.totals.processing,oldestDuePendingAgeMs:e.oldestDuePendingAgeMs,latestClaimAgeMs:e.latestClaimAgeMs,stalled:n}}}async function cn(e){let{config:t,services:r,bootTime:i,endpoints:n,interactions:o}=e,[s,a,c,d]=await Promise.all([r.entityService.getEntityCounts(dt("runtime app info reports operator-facing aggregate status")),r.entityService.countEmbeddings(),r.daemonRegistry.getStatuses(),r.jobQueueService.getDiagnostics()]),u=s.reduce((p,g)=>p+g.count,0);return{model:t.name||"brain-app",version:t.version||"1.0.0",uptime:Math.floor((Date.now()-i)/1000),entities:u,entityCounts:s,embeddings:a,backgroundWork:$e(d,r.jobQueueService.getExecutionRegistrations()),ai:{model:t.ai.model,embeddingModel:r.embeddingService.identity.model},daemons:c,endpoints:n(),interactions:o()}}import{readdir as ln,readFile as qd}from"fs/promises";var Jd=10;async function Gd(e="/proc"){let t=null;try{t=(await ln(`${e}/self/fd`)).length}catch{}try{let i=(await ln(e,{withFileTypes:!0})).filter((s)=>s.isDirectory()&&/^\d+$/.test(s.name)).map((s)=>s.name),n=0,o=0;return await Promise.all(i.map(async(s)=>{try{let a=await qd(`${e}/${s}/status`,"utf8");if(o++,/^State:\s+Z\b/m.test(a))n++}catch{}})),{fileDescriptors:t,processCount:o,zombieCount:n}}catch{return{fileDescriptors:t,processCount:null,zombieCount:null}}}function dn(e,t,r){return t.status==="fulfilled"?{name:e,status:"healthy",message:r}:{name:e,status:"unhealthy",message:x(t.reason)}}function Qd(e){if(!e)return{name:"job-worker",status:"degraded",message:"Worker session state is unavailable"};let t=e.workerSessions,r=$e(e).worker;if(r.state==="missing")return{name:"job-worker",status:"degraded",message:"No live worker session",details:{sessions:t}};if(r.state==="stale")return{name:"job-worker",status:"degraded",message:`${t.stale} stale worker session(s)`,details:{sessions:t}};return{name:"job-worker",status:"healthy",message:`${t.active} live worker session(s)`,details:{sessions:t}}}function Kd(e){if(!e)return{name:"job-queue-progress",status:"degraded",message:"Queue progress state is unavailable"};let t=$e(e).queue;return t.stalled?{name:"job-queue-progress",status:"degraded",message:`${t.duePending} due job(s) are not being claimed`,details:{queue:t}}:{name:"job-queue-progress",status:"healthy",message:"Due jobs are being claimed",details:{queue:t}}}function Vd(e,t){if(!e||!t)return{name:"job-execution-inventory",status:"degraded",message:"Job execution inventory is unavailable"};let r=Dr(e,t),i=r.reduce((n,o)=>n+o.count,0);return i===0?{name:"job-execution-inventory",status:"healthy",message:"Every active job type has a declared executor"}:{name:"job-execution-inventory",status:"degraded",message:`${i} active job(s) have no declared executor`,details:{jobs:r}}}function Yd(e){if(!e)return{name:"attempt-leases",status:"degraded",message:"Lease state is unavailable"};return e.staleLeaseCount===0?{name:"attempt-leases",status:"healthy",message:"No stale processing leases"}:{name:"attempt-leases",status:"degraded",message:`${e.staleLeaseCount} processing lease(s) are stale`,details:{staleLeaseCount:e.staleLeaseCount}}}function Xd(e){if(!e.initialized)return{name:"projection-circuits",status:"degraded",message:"Projection runtime supervisor is not initialized"};if(e.openCircuits.length===0)return{name:"projection-circuits",status:"healthy",message:"No projection circuits are open"};return{name:"projection-circuits",status:"degraded",message:`${e.openCircuits.length} projection circuit(s) open`,details:{circuits:e.openCircuits}}}async function eu(e){let t=e.entityService.getProjectionStore(),[r,i,n]=await Promise.all([t.getActiveWave(),t.getUnresolvedProjectionIncidentDiagnostics(Jd),t.getProjectionBatchDiagnostics?.()??Promise.resolve({preparing:0,open:0,abandoned:0,expiredCallbackLeases:0,oldestActiveAgeMs:null,oldestProgressAgeMs:null})]);if(!r)return{waveId:null,batches:n,strandedRules:[],incidentCount:i.total,incidents:i.incidents};let s=(await t.listWaveRules(r.id)).filter((c)=>c.status==="queued"||c.status==="failed"),a=(await Promise.all(s.map(async(c)=>{let d=c.jobId?await e.jobQueueService.getStatus(c.jobId):null;if(c.status!=="failed"&&d&&(d.status==="pending"||d.status==="processing"))return null;return{ruleId:c.ruleId,jobId:c.jobId,jobStatus:d?.status??"missing"}}))).filter((c)=>c!==null);return{waveId:r.id,batches:n,strandedRules:a,incidentCount:i.total,incidents:i.incidents}}function tu(e){if(e.batches.abandoned>0)return{name:"projection-waves",status:"degraded",message:`${e.batches.abandoned} projection batch(es) await recovery`,details:{batches:e.batches}};if(e.batches.expiredCallbackLeases>0)return{name:"projection-waves",status:"degraded",message:"A callback projection batch lease has expired",details:{batches:e.batches}};if(e.incidentCount>0)return{name:"projection-waves",status:"degraded",message:`${e.incidentCount} unresolved terminal projection incident(s)`,details:{incidentCount:e.incidentCount,incidentsTruncated:e.incidentCount>e.incidents.length,incidents:e.incidents.map((t)=>({waveId:t.waveId,ruleId:t.ruleId,jobId:t.jobId,failureReason:t.failureReason,createdAt:t.createdAt}))}};if(!e.waveId)return{name:"projection-waves",status:"healthy",message:e.batches.open+e.batches.preparing>0?`${e.batches.open+e.batches.preparing} projection batch(es) active`:"No active projection wave",...e.batches.open+e.batches.preparing>0&&{details:{batches:e.batches}}};if(e.strandedRules.length===0)return{name:"projection-waves",status:"healthy",message:`Projection wave ${e.waveId} is progressing`};return{name:"projection-waves",status:"degraded",message:`Projection wave ${e.waveId} has ${e.strandedRules.length} stranded rule job(s)`,details:{waveId:e.waveId,strandedRules:e.strandedRules}}}function ru(e){let t=e.filter((r)=>r.status!=="running"||r.health?.status==="error");return t.length===0?{name:"daemons",status:"healthy",message:`${e.length} daemon(s) healthy`}:{name:"daemons",status:"degraded",message:`${t.length} daemon(s) unhealthy`,details:{daemons:t.map((r)=>({name:r.name,status:r.status,health:r.health?.status,message:r.health?.message}))}}}async function un(e){let t=e.now?.()??Date.now(),r=(e.memoryUsage??process.memoryUsage)(),[i,n,o,s,a,c,d,u]=await Promise.allSettled([e.entityService.getEntityCounts(dt("runtime readiness database probe")),e.jobQueueService.getDiagnostics(t),Promise.resolve(e.jobQueueService.getExecutionRegistrations()),e.daemonRegistry.getStatuses(),(e.readProcessSignals??Gd)(),e.projectionRuntimeSupervisor.getDiagnostics(),eu(e),e.operationalHealthRegistry.getChecks()]),p=n.status==="fulfilled"?n.value:null,g=o.status==="fulfilled"?o.value??null:null,m=s.status==="fulfilled"?s.value:[],f=a.status==="fulfilled"?a.value:{fileDescriptors:null,processCount:null,zombieCount:null},h=c.status==="fulfilled"?c.value:{status:"unhealthy",initialized:!1,trackedRoots:0,openCircuits:[]},v=[dn("entity-database",i,"Entity database is accessible"),dn("job-queue-database",n,"Job queue database is accessible"),Qd(p),Kd(p),Vd(p,g),Yd(p),c.status==="fulfilled"?Xd(h):{name:"projection-circuits",status:"degraded",message:x(c.reason)},d.status==="fulfilled"?tu(d.value):{name:"projection-waves",status:"degraded",message:x(d.reason)},s.status==="fulfilled"?ru(m):{name:"daemons",status:"degraded",message:x(s.reason)}],y=u.status==="fulfilled"?u.value:[{name:"plugin-operational-health",status:"degraded",message:"Plugin operational health is unavailable"}],S=[...v,...y];return{status:v.some((R)=>R.status==="unhealthy")?"not_ready":"ready",operationalStatus:S.some((R)=>R.status!=="healthy")?"degraded":"operational",checkedAt:new Date(t).toISOString(),checks:S,resources:{memory:{rssBytes:r.rss,heapUsedBytes:r.heapUsed,heapTotalBytes:r.heapTotal},fileDescriptors:f.fileDescriptors,processes:{total:f.processCount,zombies:f.zombieCount},queue:p,projection:{initialized:h.initialized,trackedRoots:h.trackedRoots,openCircuits:h.openCircuits},worker:p?.workerSessions??{total:0,active:0,stale:0,latestHeartbeatAgeMs:null}}}}function pn(){return{dataDir:"./data",cacheDir:"./cache",distDir:"./dist"}}function he(e){return{database:{url:`file:${e.dataDir}/brain.db`},jobQueueDatabase:{url:`file:${e.dataDir}/brain-jobs.db`},conversationDatabase:{url:`file:${e.dataDir}/conversations.db`},runtimeStateDatabase:{url:`file:${e.dataDir}/runtime-state.db`},embeddingDatabase:{url:`file:${e.dataDir}/embeddings.db`},embedding:{enabled:!0}}}var Be=l.strictObject({enabled:l.boolean().optional().describe("Serve HTTP; defaults to whether the selected bundles host the web surface"),preview:l.boolean().optional().describe("Serve the preview site; defaults to whether a site builder runs"),hostname:l.string().trim().min(1).optional().describe("Bind address; use 127.0.0.1 for isolated local tests"),productionDistDir:l.string().min(1).optional().describe("Directory of the production site, when no site builder writes it"),previewDistDir:l.string().min(1).optional().describe("Directory of the preview site, when no site builder writes it"),sharedImagesDir:l.string().min(1).optional().describe("Directory of shared optimized images")}),ut=Be.extend({enabled:l.boolean().default(!1),preview:l.boolean().default(!0),port:l.number().default(8080).describe("Port of the production listener")});var Or=pn(),iu=l.looseObject({label:l.string().min(1),pluralName:l.string().optional(),layout:l.string().optional(),paginate:l.boolean().optional(),pageSize:l.number().optional(),navigation:l.object({show:l.boolean().optional(),slot:l.enum(["primary","secondary"]).optional(),priority:l.number().optional()}).optional()});function Mr(){return he(Or)}var xe=l.enum(["debug","info","warn","error"]);var Lr=l.object({name:l.string().default("brain-app"),version:l.string().default("1.0.0"),database:Ce,jobQueueDatabase:Ce,jobQueue:l.object({workerConcurrency:l.number().int().min(1).max(32).default(4)}).prefault({}),conversationDatabase:Ce,runtimeStateDatabase:Ce,embeddingDatabase:Ce,ai:l.object({apiKey:l.string().default(""),imageApiKey:l.string().optional(),model:l.string().refine(mn,{error:(e)=>`Unsupported model "${String(e.input)}"`}),embeddingModel:l.string().refine((e)=>zr(e)!==void 0,{error:(e)=>hn(String(e.input))}).default(fn),modelRuntimeUrl:l.string().url().optional(),answerModel:l.string().optional(),visionModel:l.string().optional(),imageModel:l.string().optional(),temperature:l.number().min(0).max(2).default(0.7),webSearch:l.boolean().default(!0),reasoningEffort:se.optional()}).superRefine((e,t)=>{if(e.answerModel&&ye(e.answerModel)!=="local")t.addIssue({code:"custom",path:["answerModel"],message:`answerModel must be a local: model, not ${e.answerModel}`});if(e.visionModel&&ye(e.visionModel)!=="local")t.addIssue({code:"custom",path:["visionModel"],message:`visionModel must be a local: model, not ${e.visionModel}`});if(e.modelRuntimeUrl)return;let r=[...ye(e.model)==="local"?[e.model]:[],...[e.answerModel,e.visionModel].filter((i)=>i!==void 0&&ye(i)==="local"),...e.imageModel&&gn(e.imageModel).provider==="local"?[e.imageModel]:[],...zr(e.embeddingModel)?.provider==="local"?[e.embeddingModel]:[]];for(let i of r)t.addIssue({code:"custom",path:["modelRuntimeUrl"],message:`${i} needs modelRuntime.url`})}),embedding:l.object({enabled:l.boolean().default(!0)}),logging:l.object({level:xe.default("info"),format:l.enum(["text","json"]).default("text"),file:l.string().optional(),context:l.string().default("shell")}).prefault({level:"info",context:"shell"}),features:l.object({}).default({}),plugins:l.array(pt).default([]),dataDir:l.string().default("./brain-data"),gitBrokerSocket:l.string().min(1).optional(),gitBrokerCheckout:l.string().min(1).optional(),spaces:l.array(l.string()).default([]),siteBaseUrl:l.string().optional(),localSiteUrl:l.string().optional(),preferLocalUrls:l.boolean().default(!1),production:l.boolean().default(!1),themeCSS:l.string().default(""),entityDisplay:l.record(l.string(),iu).optional(),profileKind:l.string().trim().min(1).optional(),http:ut.prefault({})});function mt(e={}){let{plugins:t=[],permissions:r={},identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s,ai:a,logging:c,embedding:d,jobQueue:u,...p}=e,{entityDisplay:g,...m}=Lr.parse({...Mr(),...V(p),ai:V({...a}),logging:V({...c}),embedding:V({...d}),jobQueue:V({...u}),plugins:[]});return{...m,plugins:t,permissions:r,...V({entityDisplay:g,identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s})}}var M={NOTE:"note",BRAIN_CHARACTER:"brain-character",ANCHOR_PROFILE:"anchor-profile"},_e={KNOWLEDGE_QUERY:"shell:knowledge-query",BASE_ENTITY_DISPLAY:"shell:base-entity-display",CONTENT_GENERATION:"shell:content-generation"},Ur={ENTITIES:"shell:entities"};var nu=yn.extend({templateName:l.string()}),ou=l.object({slug:l.string()}),su="The style guide governs voice, tone, wording and form: paragraphing, sentence rhythm, hooks, rhetorical questions and calls to action. The instructions below and any additional instructions in the request govern the task, required content, length limits, platform constraints and output format. When either conflicts with the style guide on voice or form, follow the style guide.",au="Generate the content described in your instructions.";function cu(e){return e instanceof l.ZodType}function lu(e){if(!e)return;return e.replace(/^https?:\/\//,"").replace(/\/$/,"")}class ft{aiService;entityService;templateRegistry;getIdentityContent;getProfileContent;entityUrls;id="ai-content";name="AI Content Generator";description="Generates content using AI based on templates and prompts";constructor(e,t,r,i,n,o,s){this.aiService=e,this.entityService=t,this.templateRegistry=r,this.getIdentityContent=i,this.getProfileContent=n,this.entityUrls=o,this.siteBaseUrl=lu(s)}siteBaseUrl;async generate(e,t,r){return this.generateWithContext(e,t,r)}async generateScoped(e,t,r){return this.generateWithContext(e,t,r.signal,r)}async generateWithContext(e,t,r,i){r?.throwIfAborted();let n=nu.parse(e),o=this.templateRegistry.get(n.templateName);if(!o)throw Error(`Template not found: ${n.templateName}`);if(!o.basePrompt)throw Error(`Template ${n.templateName} must have basePrompt for content generation`);let s=i?await vn((v,y)=>i.getEntity(v,y),n.templateName,o.basePrompt):await gt(this.entityService,n.templateName,o.basePrompt);r?.throwIfAborted();let a=[s,n.prompt].filter(Boolean).join(" "),c=a.length>0&&o.useKnowledgeContext===!0,d=this.entityService.getWeightMap(),u=Object.keys(d).length>0,p=c?i?await i.search(a,{limit:5,...u&&{weight:d}}):await this.entityService.search({query:a,options:{limit:5,...u&&{weight:d},...r&&{signal:r}}}):[];r?.throwIfAborted();let g=this.buildPrompt(n,p),m=i?await this.readIdentities(i,n.representedIdentity):void 0,f=this.buildSystemPrompt(s,n,m);if(!cu(o.schema))throw Error(`Template ${o.name} cannot be used for AI generation: schema is not an AI generation schema`);r?.throwIfAborted();let h=await this.aiService.generateObject(f,g,o.schema,r);return r?.throwIfAborted(),t.parse(h.object)}async readIdentities(e,t){let r=async(o)=>(await e.getEntity(o,o))?.content??"",[i,n]=await Promise.all([t!=="none"?r(M.BRAIN_CHARACTER):"",t===void 0||t==="anchor"?r(M.ANCHOR_PROFILE):""]);return{brain:i,anchor:n}}buildSystemPrompt(e,t,r){let i=[];if(t.representedIdentity===void 0||t.representedIdentity==="brain"||t.representedIdentity==="anchor")i.push("# Brain Identity",r?.brain??this.getIdentityContent(),"");if(t.representedIdentity===void 0||t.representedIdentity==="anchor")i.push("# Represented Anchor",r?.anchor??this.getProfileContent(),"");let n=this.selectStyleGuidance(t);if(n)i.push("# Style Guide",n,"","# Precedence",su,"");return i.push("# Instructions",e),i.join(`
|
|
3
3
|
`)}selectStyleGuidance(e){if(!e.styleGuide)return"";let t=[];if(e.styleGuide.voice)t.push("## Voice",e.styleGuide.voice);if(e.styleGuide.visual)t.push("## Visual",e.styleGuide.visual);return t.join(`
|
|
4
4
|
`)}buildPrompt(e,t=[]){let r=[];if(e.conversationHistory)r.push(`Recent conversation context:
|
|
5
5
|
${e.conversationHistory}`);if(t.length>0){let i=t.map((n)=>this.formatRelevantEntity(n,this.entityUrls)).join(`
|
|
@@ -103,4 +103,4 @@ ${ur(d)}`}:p,m=t.buildArgs((f)=>({operation:s,confirmed:!0,confirmationToken:f})
|
|
|
103
103
|
export{he as R,Be as S,xe as T,mt as U,D as V,Pu as W,Cu as X,xu as Y,ju as Z,Zn as _,zu as $,Ou as aa,Mu as ba,Lu as ca,Uu as da,$u as ea,Bu as fa,_u as ga,Ne as ha,So as ia,Xr as ja,Ws as ka,Ri as la,el as ma,rl as na,nl as oa,br as pa,Hg as qa,Ni as ra,qg as sa,Sr as ta,Jg as ua,Gg as va,AI as wa,Vg as xa,Yg as ya,Xg as za,ef as Aa,Yi as Ba,vd as Ca,Rd as Da,xd as Ea,Id as Fa,Tf as Ga,Ik as Ha,Ak as Ia,qk as Ja,Jk as Ka};
|
|
104
104
|
|
|
105
105
|
//# debugId=FB86C313AAAF2EE164756E2164756E21
|
|
106
|
-
//# sourceMappingURL=index-
|
|
106
|
+
//# sourceMappingURL=index-f33mthze.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as j,b as T}from"./index-bt14gyeg.js";import{d as g,e as m}from"./index-0c46r76d.js";import"./index-1vth7kw8.js";import{N as Z}from"./index-66v76w4h.js";import"./index-x8e40qwv.js";import{Bi as H,Eh as I,Li as P,Mi as R,Ni as L,Oi as B,Pi as w,Qi as M,Ti as D,_i as O,ej as E,yh as N,zh as F}from"./index-
|
|
2
|
+
import{a as j,b as T}from"./index-bt14gyeg.js";import{d as g,e as m}from"./index-0c46r76d.js";import"./index-1vth7kw8.js";import{N as Z}from"./index-66v76w4h.js";import"./index-x8e40qwv.js";import{Bi as H,Eh as I,Li as P,Mi as R,Ni as L,Oi as B,Pi as w,Qi as M,Ti as D,_i as O,ej as E,yh as N,zh as F}from"./index-955w889r.js";import{Jl as A,Qk as S}from"./index-nv18ttqn.js";import"./index-dgjygks7.js";import"./index-qzjfm25x.js";import{fx as v}from"./index-yxb1d9bc.js";import"./index-sjwcrhk7.js";import{ox as b}from"./index-43nane5a.js";var x=v.object({theme:v.object({primaryColor:v.string().describe("Primary color for the CLI theme").default("#0066cc"),accentColor:v.string().describe("Accent color for the CLI theme").default("#ff6600")}).describe("Theme configuration for the CLI interface").default({primaryColor:"#0066cc",accentColor:"#ff6600"})});var V={completed:"\u2713",declined:"\u25CB",failed:"\u2717"},q={deniedCardIds:void 0,resolveUrl:(r)=>r,isHiddenUrl:()=>!1,eventActionUnavailableLabel:void 0},y="cli",k={identity:{kind:"external",externalActorId:S("cli","operator")},interfaceType:"cli",role:"user"};function _(){return{inkApp:null,removeSignalHandlers:void 0,responseCallback:void 0,systemMessageCallback:void 0}}function z(r,e){let{logger:t}=r,o=new D({loadMessages:async(i)=>r.conversations.getMessages(i,{limit:50}),onRestoreError:(i,s)=>{t.debug("Failed to restore pending CLI approvals",{error:i,conversationId:s})}}),n=(i)=>{e.responseCallback?.(i)},a=()=>r.permissions.isAnchor("cli","local"),u=async(i,s)=>{let l=new Set(s);if(!M(i,l))return!1;let c=w({message:Y(i,s),approvalIds:l});if(c.kind==="not-confirmation")return!1;if(c.kind==="notice")return n(`_${c.message}_`),!0;o.removeApproval(y,c.approvalId);let C=await r.agent.confirmPendingAction(y,c.confirmed,c.approvalId,{userPermissionLevel:"admin",isAnchor:a(),interfaceType:"cli",actor:k});return o.syncFromResponse(y,C,c.approvalId),n(K(C.text,C.cards)),!0};return{async processInput(i){r.messages.startProcessingInput();try{let s=[...await o.getApprovalIds(y)];if(s.length>0){if(await u(i,s))return}let l=await r.agent.chat(i,y,{userPermissionLevel:"admin",isAnchor:a(),interfaceType:"cli",channelId:"cli",channelName:"CLI Terminal",actor:k}),c=P(l.cards),C=c.length>0?c.map((p)=>p.id):l.pendingConfirmations?.map((p)=>p.id)??[];o.replaceApprovals(y,C);let h=G(l);t.debug("Agent response received",{textLength:l.text.length,toolResultsCount:l.toolResults?.length??0,toolResults:l.toolResults?.map((p)=>({toolName:p.toolName,hasData:p.data!==void 0}))}),n(h)}catch(s){t.error("Error processing input",{error:s,input:i});let l=A(s,"An unknown error occurred");n(`**Error:** ${l}`)}finally{r.messages.endProcessingInput()}}}}function G(r){let e=O(r,{deniedCardIds:void 0}),t=[],o=[],n="";for(let a of e.directives)switch(a.kind){case"text":n=a.text;break;case"approvals":t.push(...a.cards);break;default:if(a.card.kind==="tool-approval"&&a.card.state==="approval-requested"){t.push(a.card);break}o.push(E(a.card,q))}return[J(n,t),...o].filter((a)=>a.trim().length>0).join(`
|
|
3
3
|
|
|
4
4
|
`)}function J(r,e){if(e.length===0)return r;let t=L(r,e);if(e.length===1){let n=e[0];if(!n)return r;let a=n.preview?`
|
|
5
5
|
|
|
@@ -16,4 +16,4 @@ _Please reply with **yes 1** / **no 1** for the matching action._`}function K(r,
|
|
|
16
16
|
${o.error}`:`${n} ${o.summary}`}function Y(r,e){let t=/^(.*?)\s+#?(\d+)$/.exec(r.trim());if(!t?.[1]||!t[2])return r;let o=e[Number(t[2])-1];return o?`${t[1]} ${o}`:r}var Q=H({id:"cli",config:x,setup:(r)=>(I(r).logger.debug("CLI interface registered with AgentService"),_())}),W=N(Q,(r)=>{let{state:e}=r,t=I(r),{logger:o,messages:n}=t,a=z(t,e),u=()=>{e.responseCallback=void 0,e.systemMessageCallback=void 0},i=()=>{if(n.unregisterProgressCallback(),u(),e.removeSignalHandlers?.(),e.removeSignalHandlers=void 0,e.inkApp)e.inkApp.unmount(),e.inkApp=null};return{id:"cli",start:async()=>{o.debug("Starting CLI interface");try{let[s,l,c]=await Promise.all([import("./index-7d33dmv5.js"),import("react"),import("./EnhancedApp-cbdz09fw.js")]),h=l.default.createElement(c.default,{interface:a,registerProgressCallback:(p)=>{n.registerProgressCallback(p)},unregisterProgressCallback:()=>{n.unregisterProgressCallback()},registerResponseCallback:(p)=>{e.responseCallback=p},registerSystemMessageCallback:(p)=>{e.systemMessageCallback=p},unregisterMessageCallbacks:u});e.inkApp=s.render(h),e.removeSignalHandlers=Z(["SIGINT","SIGTERM"],()=>{o.debug("Received termination signal, stopping CLI"),i()})}catch(s){throw o.error("Failed to start CLI interface",{error:s}),s}},stop:async()=>{o.debug("Stopping CLI interface"),i()},healthCheck:async()=>{let s=e.inkApp!==null;return{status:s?"healthy":"error",message:s?"CLI interface is running":"CLI interface not running",lastCheck:new Date,details:{hasInkApp:e.inkApp!==null,hasCallbacks:n.hasProgressCallback()}}}}}),X=F(W,({state:r})=>({send:({message:e})=>{let t=typeof e==="string"?e:e.fallbackText??"";if(!t)return;(r.systemMessageCallback??r.responseCallback)?.(t)}})),ee=X;import{jsx as d,jsxs as f}from"react/jsx-runtime";function re({batchStatus:r,showDetails:e=!0}){let{batchId:t,totalOperations:o,completedOperations:n,failedOperations:a,currentOperation:u,errors:i,status:s}=r,l=s==="processing",c=s==="completed",C=s==="failed",h=n-a;return f(g,{flexDirection:"column",marginY:1,children:[d(g,{marginBottom:1,children:f(m,{bold:!0,color:"cyan",children:["Batch Operation: ",t.slice(0,8),"..."]})}),d(g,{marginBottom:1,children:d(T,{current:n,total:o,message:"Overall Progress:",color:C?"red":c?"green":"yellow"})}),l&&u&&f(g,{marginBottom:1,children:[d(m,{color:"green",children:d(j,{type:"dots"})}),f(m,{color:"gray",children:[" ",u]})]}),e&&f(g,{flexDirection:"column",marginLeft:2,children:[h>0&&f(g,{children:[d(m,{color:"green",children:"\u2713 "}),f(m,{color:"gray",children:[h," successful"]})]}),a>0&&f(g,{children:[d(m,{color:"red",children:"\u2717 "}),f(m,{color:"gray",children:[a," failed"]})]}),i.length>0&&f(g,{flexDirection:"column",marginTop:1,children:[d(m,{color:"red",bold:!0,children:"Errors:"}),i.slice(0,3).map((p,U)=>f(g,{marginLeft:2,children:[d(m,{color:"red",children:"\u2022 "}),d(m,{color:"gray",children:p})]},U)),i.length>3&&d(g,{marginLeft:2,children:f(m,{color:"gray",children:["... and ",i.length-3," more"]})})]})]}),c&&d(g,{marginTop:1,children:d(m,{color:"green",bold:!0,children:"\u2713 Batch completed successfully"})}),C&&d(g,{marginTop:1,children:d(m,{color:"red",bold:!0,children:"\u2717 Batch failed"})})]})}export{re as BatchProgress,T as ProgressBar,x as cliConfigSchema,ee as default};
|
|
17
17
|
|
|
18
18
|
//# debugId=A7E9B4C2F466C14A64756E2164756E21
|
|
19
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-qte031xt.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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-
|
|
2
|
+
import{N as p}from"./index-66v76w4h.js";import{Ba as m,Ga as d,Ja as v,Ka as S}from"./index-f33mthze.js";import{Lg as h}from"./index-955w889r.js";import{Nn as t,On as r}from"./index-dgjygks7.js";import{fs as f,tv as s,us as a}from"./index-qzjfm25x.js";import{ox as g}from"./index-43nane5a.js";async function u(e){let[{default:i},{default:n}]=await Promise.all([import("./index-qte031xt.js"),import("./package-pzecgmq7.js")]);return h(i,e??{},{name:n.name,version:n.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}})}async registerCLIInterface(){if(!this.hasCLI)return;let e=this.getShell().getPluginManager();for(let i of await u(this.config.cliConfig))e.registerPlugin(i)}async initialize(e,i){if(!this.shell){if(!i?.migrationsCompleted)await this.migrate();this.createShell(e,i)}await this.registerCLIInterface(),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 n={debug:t.DEBUG,info:t.INFO,warn:t.WARN,error:t.ERROR}[this.config.logLevel??"info"]??t.INFO,o=r.createFresh({level:n,context:this.config.name,useStderr:this.hasCLI});if(this.hasCLI)r.getInstance().setUseStderr(!0);try{await this.initialize(void 0,e),await this.start(),e?.onRuntimeReady?.(),o.info(`\u2705 ${this.config.name} v${this.config.version} ready`),process.stdin.resume()}catch(l){o.error(`\u274C Failed to start ${this.config.name}:`,l),process.exit(1)}}static async run(e,i,n){await c.create(e,i).run(n)}setupSignalHandlers(){if(this.signalScope)return;let e=s.runSync(a.make()),i=()=>{this.requestGracefulShutdown("SIGINT")},n=()=>{this.requestGracefulShutdown("SIGTERM")},o=p(["SIGINT"],i),l=p(["SIGTERM"],n);s.runSync(a.addFinalizer(e,s.sync(()=>{l(),o()}))),this.signalScope=e}requestGracefulShutdown(e){if(this.signalShutdownFiber)return;let i=r.getInstance();i.info(`
|
|
3
3
|
Received ${e}, shutting down gracefully...`);let n=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(n)}async closeSignalScope(){let e=this.signalScope;if(this.signalScope=null,e)await s.runPromise(a.close(e,f.void))}getShell(){if(!this.shell)throw Error("Shell not initialized. Call initialize() first.");return this.shell}}
|
|
4
4
|
export{c as B};
|
|
5
5
|
|
|
6
6
|
//# debugId=DFC8DBE25A2FFC8764756E2164756E21
|
|
7
|
-
//# sourceMappingURL=index-
|
|
7
|
+
//# sourceMappingURL=index-yhwj6qak.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{J as a,K as b}from"./index-d6yevd78.js";import"./index-
|
|
2
|
+
import{J as a,K as b}from"./index-d6yevd78.js";import"./index-955w889r.js";import"./index-nv18ttqn.js";import"./index-dgjygks7.js";import"./index-qzjfm25x.js";import"./index-yxb1d9bc.js";import"./index-sjwcrhk7.js";import"./index-43nane5a.js";export{a as linkedinPostSchema,b as linkedinTemplate};
|
|
3
3
|
|
|
4
4
|
//# debugId=8C511D780B2BDF1E64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=linkedin-template-
|
|
5
|
+
//# sourceMappingURL=linkedin-template-4we655mx.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./index-43nane5a.js";var n="@brains/chat-repl",i="AGPL-3.0-only",t="0.2.0-alpha.
|
|
2
|
+
import"./index-43nane5a.js";var n="@brains/chat-repl",i="AGPL-3.0-only",t="0.2.0-alpha.686",r={"@brains/contracts":"workspace:*","@brains/plugins":"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/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=AE8B19F6F8C430B964756E2164756E21
|
|
5
|
+
//# sourceMappingURL=package-pzecgmq7.js.map
|
package/dist/entities.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunks/index-624fhq2j.js";import{Yf as p,_g as t,eh as x,fh as a,gh as b,hh as c,ih as d,jh as g,uc as m}from"./chunks/index-
|
|
2
|
+
import"./chunks/index-624fhq2j.js";import{Yf as p,_g as t,eh as x,fh as a,gh as b,hh as c,ih as d,jh as g,uc as m}from"./chunks/index-955w889r.js";import{bm as f}from"./chunks/index-nv18ttqn.js";import"./chunks/index-dgjygks7.js";import"./chunks/index-qzjfm25x.js";import{fx as e}from"./chunks/index-yxb1d9bc.js";import"./chunks/index-sjwcrhk7.js";import"./chunks/index-43nane5a.js";export{m as ProjectionJsonObjectSchema,f as defineChannel,t as defineDashboardWidget,x as defineDataSource,a as defineEntity,b as defineEntityAnalyticsReport,c as defineEntityJob,g as defineEntityPackage,d as defineProjection,p as defineProjectionRule,e as z};
|
|
3
3
|
|
|
4
4
|
//# debugId=39A2AE8E5708AB7664756E2164756E21
|
|
5
5
|
//# sourceMappingURL=entities.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{La as d,Ma as t}from"./chunks/index-
|
|
2
|
+
import{La as d,Ma as t}from"./chunks/index-6na1nq7g.js";import{Jg as a}from"./chunks/index-955w889r.js";import"./chunks/index-nv18ttqn.js";import"./chunks/index-dgjygks7.js";import"./chunks/index-qzjfm25x.js";import"./chunks/index-yxb1d9bc.js";import"./chunks/index-sjwcrhk7.js";import"./chunks/index-43nane5a.js";function s(e,i){let o=new Set,n=new Set;for(let r of e){if(!t(r))throw Error(`${i} contains a value that was not returned by use()`);if(o.has(r.definition))throw Error(`${i} contains duplicate plugin definition "${r.definition.id}"; include each configured definition only once`);if(n.has(r.definition.id))throw Error(`${i} contains duplicate local plugin id "${r.definition.id}"; give each package definition a unique local id before composing it`);o.add(r.definition),n.add(r.definition.id)}}function l(e){a(e.id,"Bundle id"),s(e.members,`Bundle "${e.id}"`);for(let i of e.config??[])if(!t(i.member))throw Error(`Bundle "${e.id}" config contains a value that was not returned by use()`);for(let i of e.permissions??[])if(!t(i.member))throw Error(`Bundle "${e.id}" permissions contains a value that was not returned by use()`);for(let i of e.evalDisable??[])if(!t(i))throw Error(`Bundle "${e.id}" evalDisable contains a value that was not returned by use()`);return Object.freeze({...e,members:Object.freeze([...e.members]),...e.config?{config:Object.freeze([...e.config])}:{},...e.permissions?{permissions:Object.freeze([...e.permissions])}:{},...e.agentInstructions?{agentInstructions:Object.freeze([...e.agentInstructions])}:{},...e.evalDisable?{evalDisable:Object.freeze([...e.evalDisable])}:{}})}function u(e){if(!e.name.trim())throw Error("Brain name must not be empty");if(e.bundleContract?.trim().length===0)throw Error("Brain bundleContract must not be empty");s(e.plugins,`Brain "${e.name}"`);let i=new Set(e.plugins),o=new Set;for(let n of e.bundles??[]){if(o.has(n.id))throw Error(`Brain "${e.name}" has duplicate bundle "${n.id}"`);o.add(n.id);for(let r of n.members)if(!i.has(r))throw Error(`Brain "${e.name}" bundle "${n.id}" references a plugin outside its catalog`);for(let r of n.config??[])if(!i.has(r.member))throw Error(`Brain "${e.name}" bundle "${n.id}" config references a plugin outside its catalog`);for(let r of n.permissions??[])if(!i.has(r.member))throw Error(`Brain "${e.name}" bundle "${n.id}" permissions reference a plugin outside its catalog`);for(let r of n.evalDisable??[])if(!i.has(r))throw Error(`Brain "${e.name}" bundle "${n.id}" evalDisable references a plugin outside its catalog`)}for(let n of e.evalDisable??[])if(!i.has(n))throw Error(`Brain "${e.name}" evalDisable references a plugin outside its catalog`);return Object.freeze({...e,plugins:Object.freeze([...e.plugins]),...e.bundles?{bundles:Object.freeze([...e.bundles])}:{},...e.agentInstructions?{agentInstructions:Object.freeze([...e.agentInstructions])}:{},...e.evalDisable?{evalDisable:Object.freeze([...e.evalDisable])}:{}})}export{u as defineBrain,l as defineBundle,d as use};
|
|
3
3
|
|
|
4
4
|
//# debugId=1E4C68D6D339798664756E2164756E21
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/interfaces.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunks/index-x8e40qwv.js";import{Ai as a,Bi as b,Ci as c,Di as d,mh as p,yi as t,zi as x}from"./chunks/index-
|
|
2
|
+
import"./chunks/index-x8e40qwv.js";import{Ai as a,Bi as b,Ci as c,Di as d,mh as p,yi as t,zi as x}from"./chunks/index-955w889r.js";import{Pl as f,rn as m}from"./chunks/index-nv18ttqn.js";import"./chunks/index-dgjygks7.js";import"./chunks/index-qzjfm25x.js";import{fx as e}from"./chunks/index-yxb1d9bc.js";import"./chunks/index-sjwcrhk7.js";import"./chunks/index-43nane5a.js";export{f as SdkError,m as UserPermissionLevelSchema,p as defineAccountSettings,a as defineDaemon,b as defineInterface,c as defineMessageInterface,d as defineMessageInterfacePackage,x as defineRoute,t as protocol,e as z};
|
|
3
3
|
|
|
4
4
|
//# debugId=74241F5CB13CD20E64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=interfaces.js.map
|