@keepur/hive 0.8.0 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keepur/hive",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "hiveApi": "1.0.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -70,8 +70,10 @@
70
70
  "dependencies": {
71
71
  "@anthropic-ai/claude-agent-sdk": "^0.2.63",
72
72
  "@anthropic-ai/sdk": "^0.82.0",
73
+ "@google/adk": "^1.1.0",
73
74
  "@linear/sdk": "^76.0.0",
74
75
  "@modelcontextprotocol/sdk": "^1.27.1",
76
+ "@openai/agents": "^0.11.4",
75
77
  "@qdrant/js-client-rest": "^1.17.0",
76
78
  "@slack/socket-mode": "^2.0.5",
77
79
  "@slack/web-api": "^7.14.1",
package/pkg/cli.min.js CHANGED
@@ -223,7 +223,7 @@ Hive Setup Wizard
223
223
  `);let r=ut(s,"hive.yaml");Pe(r)&&(((0,an.parse)(Yc(r,"utf-8"))??{}).instance?.id||(console.error(`Error: ${r} is missing instance.id. Delete it and run 'hive init' again.`),process.exit(1))),process.env.HIVE_HOME=s;let{runWizard:o}=await Promise.resolve().then(()=>(Hc(),jc));await o(s,i,t)}var an,iy,Vc=T(()=>{"use strict";an=ie(ce(),1);W();fc();iy=10});var Qc={};Y(Qc,{showStatus:()=>hy});import{execFileSync as Wc}from"node:child_process";import{existsSync as fy,readFileSync as dy}from"node:fs";import{resolve as py}from"node:path";async function hy(){console.log(`Hive home: ${$}`);let t=py($,process.env.HIVE_CONFIG??"hive.yaml");if(!fy(t)){console.log("Status: not initialized (run 'hive init')");return}let n=((0,Jc.parse)(dy(t,"utf-8"))??{}).instance?.id??"hive",s=`com.hive.${n}.agent`;console.log(`Instance: ${n}`);try{let r=Wc("launchctl",["list"],{encoding:"utf-8"}).split(`
224
224
  `).find(o=>o.includes(s));if(r){let o=r.trim().split(/\s+/),a=o[0],l=o[1];console.log(`Service: running (PID ${a}, last exit ${l})`)}else console.log("Service: not running")}catch{console.log("Service: unknown (could not query launchctl)")}try{Wc("mongosh",["--eval","db.runCommand({ping:1})","--quiet"],{encoding:"utf-8",timeout:5e3}),console.log("MongoDB: connected")}catch{console.log("MongoDB: not reachable")}}var Jc,zc=T(()=>{"use strict";Jc=ie(ce(),1);W()});import{existsSync as Xc,mkdirSync as my,readdirSync as gy,renameSync as yy}from"node:fs";import{resolve as bs}from"node:path";function Zc(t=$,e=Ke){let n=bs(e,"plugins","node_modules"),s=bs(t,"plugins","node_modules");if(!Xc(n))return{moved:[],skipped:!0};let i=gy(n);if(i.length===0)return{moved:[],skipped:!0};my(s,{recursive:!0});let r=[];for(let o of i){let a=bs(n,o),l=bs(s,o);Xc(l)||(yy(a,l),r.push(o))}return{moved:r,skipped:!1}}var eu=T(()=>{"use strict";W()});import{readFileSync as Sy,existsSync as vy}from"node:fs";function ks(t,e){let n=Sn(t),s=process.env.HIVE_CONFIG||"hive.yaml",i={};vy(n)&&(i=(0,tu.parse)(Sy(n,"utf-8"))??{});let r=i.instance?.id??"hive",o=i.instance?.portBase??3100,a=Object.values(i.instance?.ports??{}),l=Array.from({length:7},(f,d)=>o+d),c=Array.from(new Set([...l,...a])).sort((f,d)=>f-d),u={HIVE_SINGLE_INSTANCE:"1",HIVE_SINGLE_ID:r,HIVE_SINGLE_CONFIG:s,HIVE_SINGLE_LOGS:"logs",HIVE_SINGLE_PORTS:c.join(" "),HIVE_SINGLE_ROOT:t};return e&&(u.HIVE_SINGLE_TAG=e),u}var tu,Mr=T(()=>{"use strict";tu=ie(ce(),1);W()});var au=v((Sb,Se)=>{var Dr=ke("fs"),Es=ke("path"),wy=ke("os"),by=ke("crypto"),nu=["\u25C8 encrypted .env [www.dotenvx.com]","\u25C8 secrets for agents [www.dotenvx.com]","\u2301 auth for agents [www.vestauth.com]","\u2318 custom filepath { path: '/custom/path/.env' }","\u2318 enable debugging { debug: true }","\u2318 override existing { override: true }","\u2318 suppress logs { quiet: true }","\u2318 multiple files { path: ['.env.local', '.env'] }"];function ky(){return nu[Math.floor(Math.random()*nu.length)]}function ft(t){return typeof t=="string"?!["false","0","no","off",""].includes(t.toLowerCase()):!!t}function Ey(){return process.stdout.isTTY}function Ay(t){return Ey()?`\x1B[2m${t}\x1B[0m`:t}var Iy=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function _y(t){let e={},n=t.toString();n=n.replace(/\r\n?/mg,`
225
225
  `);let s;for(;(s=Iy.exec(n))!=null;){let i=s[1],r=s[2]||"";r=r.trim();let o=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),o==='"'&&(r=r.replace(/\\n/g,`
226
- `),r=r.replace(/\\r/g,"\r")),e[i]=r}return e}function Ty(t){t=t||{};let e=ou(t);t.path=e;let n=B.configDotenv(t);if(!n.parsed){let o=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw o.code="MISSING_DATA",o}let s=ru(t).split(","),i=s.length,r;for(let o=0;o<i;o++)try{let a=s[o].trim(),l=Ny(n,a);r=B.decrypt(l.ciphertext,l.key);break}catch(a){if(o+1>=i)throw a}return B.parse(r)}function Oy(t){console.error(`\u26A0 ${t}`)}function ln(t){console.log(`\u2506 ${t}`)}function iu(t){console.log(`\u25C7 ${t}`)}function ru(t){return t&&t.DOTENV_KEY&&t.DOTENV_KEY.length>0?t.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Ny(t,e){let n;try{n=new URL(e)}catch(a){if(a.code==="ERR_INVALID_URL"){let l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw a}let s=n.password;if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let i=n.searchParams.get("environment");if(!i){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let r=`DOTENV_VAULT_${i.toUpperCase()}`,o=t.parsed[r];if(!o){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${r} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:o,key:s}}function ou(t){let e=null;if(t&&t.path&&t.path.length>0)if(Array.isArray(t.path))for(let n of t.path)Dr.existsSync(n)&&(e=n.endsWith(".vault")?n:`${n}.vault`);else e=t.path.endsWith(".vault")?t.path:`${t.path}.vault`;else e=Es.resolve(process.cwd(),".env.vault");return Dr.existsSync(e)?e:null}function su(t){return t[0]==="~"?Es.join(wy.homedir(),t.slice(1)):t}function Cy(t){let e=ft(process.env.DOTENV_CONFIG_DEBUG||t&&t.debug),n=ft(process.env.DOTENV_CONFIG_QUIET||t&&t.quiet);(e||!n)&&iu("loading env from encrypted .env.vault");let s=B._parseVault(t),i=process.env;return t&&t.processEnv!=null&&(i=t.processEnv),B.populate(i,s,t),{parsed:s}}function Ly(t){let e=Es.resolve(process.cwd(),".env"),n="utf8",s=process.env;t&&t.processEnv!=null&&(s=t.processEnv);let i=ft(s.DOTENV_CONFIG_DEBUG||t&&t.debug),r=ft(s.DOTENV_CONFIG_QUIET||t&&t.quiet);t&&t.encoding?n=t.encoding:i&&ln("no encoding is specified (UTF-8 is used by default)");let o=[e];if(t&&t.path)if(!Array.isArray(t.path))o=[su(t.path)];else{o=[];for(let u of t.path)o.push(su(u))}let a,l={};for(let u of o)try{let f=B.parse(Dr.readFileSync(u,{encoding:n}));B.populate(l,f,t)}catch(f){i&&ln(`failed to load ${u} ${f.message}`),a=f}let c=B.populate(s,l,t);if(i=ft(s.DOTENV_CONFIG_DEBUG||i),r=ft(s.DOTENV_CONFIG_QUIET||r),i||!r){let u=Object.keys(c).length,f=[];for(let d of o)try{let p=Es.relative(process.cwd(),d);f.push(p)}catch(p){i&&ln(`failed to load ${d} ${p.message}`),a=p}iu(`injected env (${u}) from ${f.join(",")} ${Ay(`// tip: ${ky()}`)}`)}return a?{parsed:l,error:a}:{parsed:l}}function $y(t){if(ru(t).length===0)return B.configDotenv(t);let e=ou(t);return e?B._configVault(t):(Oy(`you set DOTENV_KEY but you are missing a .env.vault file at ${e}`),B.configDotenv(t))}function Py(t,e){let n=Buffer.from(e.slice(-64),"hex"),s=Buffer.from(t,"base64"),i=s.subarray(0,12),r=s.subarray(-16);s=s.subarray(12,-16);try{let o=by.createDecipheriv("aes-256-gcm",n,i);return o.setAuthTag(r),`${o.update(s)}${o.final()}`}catch(o){let a=o instanceof RangeError,l=o.message==="Invalid key length",c=o.message==="Unsupported state or unable to authenticate data";if(a||l){let u=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw u.code="INVALID_DOTENV_KEY",u}else if(c){let u=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw u.code="DECRYPTION_FAILED",u}else throw o}}function My(t,e,n={}){let s=!!(n&&n.debug),i=!!(n&&n.override),r={};if(typeof e!="object"){let o=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw o.code="OBJECT_REQUIRED",o}for(let o of Object.keys(e))Object.prototype.hasOwnProperty.call(t,o)?(i===!0&&(t[o]=e[o],r[o]=e[o]),s&&ln(i===!0?`"${o}" is already defined and WAS overwritten`:`"${o}" is already defined and was NOT overwritten`)):(t[o]=e[o],r[o]=e[o]);return r}var B={configDotenv:Ly,_configVault:Cy,_parseVault:Ty,config:$y,decrypt:Py,parse:_y,populate:My};Se.exports.configDotenv=B.configDotenv;Se.exports._configVault=B._configVault;Se.exports._parseVault=B._parseVault;Se.exports.config=B.config;Se.exports.decrypt=B.decrypt;Se.exports.parse=B.parse;Se.exports.populate=B.populate;Se.exports=B});var As,lu=T(()=>{"use strict";As={externalComms:!0,codeTask:!1,codeAccess:!1}});import{execFileSync as Dy}from"node:child_process";function cu(t,e){if(process.platform!=="darwin")return"";try{return Dy("security",["find-generic-password","-s",`hive/${t}/${e}`,"-w"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}catch{return""}}var uu=T(()=>{"use strict"});var dt={};Y(dt,{config:()=>Fy});import{readFileSync as qy,existsSync as hu,readdirSync as Ry,statSync as xy}from"node:fs";import{resolve as qr}from"node:path";import{randomUUID as Rr}from"node:crypto";function fu(t){let e=process.env[t]||gu(t);if(!e)throw new Error(`Missing required env var: ${t}`);return e}function g(t,e){return process.env[t]||gu(t)||e}function By(t){if(t?.length)return t.map(n=>qr(n.replace(/^~/,process.env.HOME??"/tmp")));let e=qr(Ke,"plugins/claude-code");return hu(e)?Ry(e).map(n=>qr(e,n)).filter(n=>xy(n).isDirectory()):[]}var pu,mu,Ky,du,S,Ob,cn,gu,De,Ge,Fy,pt=T(()=>{"use strict";pu=ie(au(),1),mu=ie(ce(),1);lu();uu();W();Ky=vo($);pu.default.config({path:Ky});du=Sn($),S={};hu(du)&&(S=(0,mu.parse)(qy(du,"utf-8"))??{});Ob=process.env.HOME??"/tmp",cn=S.instance?.id??"hive",gu=t=>cu(cn,t),De=S.instance?.portBase??3100,Ge=S.instance?.ports??{},Fy={instance:{id:cn,portBase:De},business:{name:S.business?.name??g("BUSINESS_NAME",""),description:S.business?.description??"",location:S.business?.location??"",ownerName:S.business?.owner?.name??"",ownerRole:S.business?.owner?.role??""},slack:{appToken:fu("SLACK_APP_TOKEN"),botToken:fu("SLACK_BOT_TOKEN"),mcpToken:g("SLACK_MCP_TOKEN",""),auditChannel:g("SLACK_AUDIT_CHANNEL",S.slack?.auditChannel??""),localMcpServer:!!(S.slack?.localMcpServer??!1)},anthropic:{apiKey:g("ANTHROPIC_API_KEY","")},linear:{apiKey:g("LINEAR_API_KEY",""),teamId:g("LINEAR_TEAM_ID","")},clickup:{apiToken:g("CLICKUP_API_TOKEN","")},github:{repo:g("GITHUB_REPO",""),token:g("GH_TOKEN","")},brave:{apiKey:g("BRAVE_API_KEY","")},taskLedger:{apiUrl:g("TASK_LEDGER_API_URL","http://localhost:3002"),agentKeys:Object.fromEntries(Object.entries(process.env).filter(([t])=>t.startsWith("TASK_LEDGER_KEY_")).map(([t,e])=>[t.replace("TASK_LEDGER_KEY_","").toLowerCase().replace(/_/g,"-"),e])),apiKey:g("TASK_LEDGER_API_KEY","")},mongo:{uri:g("MONGODB_URI","mongodb://localhost:27017"),dbName:g("MONGODB_DB",`hive_${cn}`)},defaultAgent:g("DEFAULT_AGENT","chief-of-staff"),google:{account:g("GOOGLE_ACCOUNT",S.google?.account??""),client:g("GOG_CLIENT",S.google?.client??""),accounts:S.google?.accounts??{},sharedFolder:g("DRIVE_SHARED_FOLDER",S.google?.sharedFolder??S.googleWorkspace?.sharedFolder??"")},googleWorkspace:{account:g("GWS_ACCOUNT",S.googleWorkspace?.account??""),gwsPath:g("GWS_PATH",""),sharedFolder:g("GWS_SHARED_FOLDER",S.googleWorkspace?.sharedFolder??"")},quo:{apiKey:g("QUO_API_KEY",""),phoneNumberId:g("QUO_PHONE_NUMBER_ID",""),lines:S.quo?.lines??{}},sms:{lines:S.sms?.lines??[]},imessage:{enabled:S.imessage?.enabled??!1,slackChannel:S.imessage?.slackChannel??"imessage",hotWindowMs:S.imessage?.hotWindowMs??3e5,coldIntervalMs:S.imessage?.coldIntervalMs??3e5,hotIntervalMs:S.imessage?.hotIntervalMs??1e4},resend:{apiKey:g("RESEND_API_KEY",""),fromAddress:g("RESEND_FROM_ADDRESS",""),defaultCc:g("RESEND_DEFAULT_CC",""),defaultBcc:g("RESEND_DEFAULT_BCC",""),emailDomain:g("RESEND_EMAIL_DOMAIN",S.resend?.emailDomain??""),businessName:g("RESEND_BUSINESS_NAME",S.resend?.businessName??"")},plugins:S.plugins??[],skillRegistries:S.skillRegistries??[{name:"keepur-default",url:"https://github.com/keepur/hive-skills",default:!0}],operatorSkillsRepo:S.operatorSkillsRepo?{url:String(S.operatorSkillsRepo.url),branch:S.operatorSkillsRepo.branch?String(S.operatorSkillsRepo.branch):"main"}:null,gemini:{apiKey:g("GEMINI_API_KEY",""),visionModel:g("GEMINI_VISION_MODEL","gemini-2.5-flash")},permits:{mongoUri:g("PERMITS_MONGO_URI","mongodb://localhost:27017/permits")},recall:{apiKey:g("RECALL_API_KEY",""),region:g("RECALL_API_REGION","us-west-2"),monitorPort:parseInt(g("MEETING_MONITOR_PORT",String(Ge.recall??De+1)),10),monitorPublicUrl:g("MEETING_MONITOR_PUBLIC_URL",""),webhookSecret:g("RECALL_WEBHOOK_SECRET","")},scheduler:{heartbeatIntervalMs:parseInt(g("HEARTBEAT_INTERVAL_MS","120000"),10)},background:{port:parseInt(g("BG_TASK_PORT",String(Ge.background??De)),10),authToken:g("BG_TASK_AUTH_TOKEN","")||Rr()},slackInternal:{port:parseInt(g("SLACK_INTERNAL_PORT",String(Ge.slackInternal??De+6)),10),authToken:g("SLACK_INTERNAL_TOKEN","")||Rr()},codeTask:{port:parseInt(g("CODE_TASK_PORT",String(Ge.codeTask??De+2)),10),authToken:g("CODE_TASK_AUTH_TOKEN","")||Rr(),pluginDirs:By(S.codeTask?.pluginDirs),defaultModel:g("CODE_TASK_MODEL","claude-sonnet-4-6"),defaultMaxTurns:parseInt(g("CODE_TASK_MAX_TURNS","100"),10),defaultMaxBudget:parseFloat(g("CODE_TASK_MAX_BUDGET","5.00")),maxConcurrent:parseInt(g("CODE_TASK_MAX_CONCURRENT","2"),10),maxLifetimeMs:parseInt(g("CODE_TASK_MAX_LIFETIME_MS",String(480*60*1e3)),10),staleGraceMs:parseInt(g("CODE_TASK_STALE_GRACE_MS",String(1800*1e3)),10)},ws:{enabled:g("WS_ENABLED","false")==="true",port:parseInt(g("WS_PORT",String(Ge.ws??De+3)),10)},beekeeper:{port:parseInt(g("BEEKEEPER_PORT",String(S.beekeeper?.port??8420)),10)},workflow:{enabled:g("WORKFLOW_ENABLED","false")==="true"},adminApi:{port:parseInt(g("ADMIN_API_PORT",String(Ge.adminApi??De+4)),10),token:g("ADMIN_API_TOKEN","")},voice:{enabled:!!S.voice?.provider,provider:S.voice?.provider??"",publicUrl:S.voice?.publicUrl??"",phoneNumberId:S.voice?.phoneNumberId??"",assistants:S.voice?.assistants??{},apiKey:g("VAPI_API_KEY",""),serverSecret:g("VAPI_SERVER_SECRET",""),port:parseInt(g("VOICE_PORT",String(Ge.voice??De+5)),10)},autonomy:{externalComms:S.autonomy?.externalComms??As.externalComms,codeTask:S.autonomy?.codeTask??As.codeTask,codeAccess:S.autonomy?.codeAccess??As.codeAccess},modelRouter:{enabled:g("MODEL_ROUTER_ENABLED","true")==="true",model:g("MODEL_ROUTER_MODEL","claude-haiku-4-5-20251001"),timeoutMs:parseInt(g("MODEL_ROUTER_TIMEOUT_MS","8000"),10)},sweeper:{intervalMs:parseInt(g("SWEEPER_INTERVAL_MS","300000"),10),threadTtlMs:parseInt(g("SWEEPER_THREAD_TTL_MS","86400000"),10),taskFileTtlMs:parseInt(g("SWEEPER_TASK_FILE_TTL_MS","604800000"),10),meetingSessionTtlMs:parseInt(g("SWEEPER_MEETING_TTL_MS","3600000"),10),cacheTtlMs:parseInt(g("SWEEPER_CACHE_TTL_MS","3600000"),10),retryMaxAttempts:parseInt(g("SWEEPER_RETRY_MAX_ATTEMPTS","3"),10),retryBaseDelayMs:parseInt(g("SWEEPER_RETRY_BASE_DELAY_MS","30000"),10)},retention:(()=>{let t=S.retention?.paths??{data:7,"agents/*/scratch":7,"agents/*/feeds":7,"agents/*/playwright":3,"agents/*/reports":0,logs:30},e={};for(let[i,r]of Object.entries(t)){if(typeof r!="number"||!Number.isFinite(r)||r<0)throw new Error(`Invalid retention.paths.${i}: must be a non-negative integer (got ${r})`);e[i]={days:r}}let n=Number(S.retention?.defaults?.days??7);if(!Number.isFinite(n)||n<0)throw new Error(`Invalid retention.defaults.days: ${n}`);let s=parseInt(g("RETENTION_INTERVAL_MS",String(S.retention?.intervalMs??168*36e5)),10);if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid retention.intervalMs: must be a positive integer (got ${s})`);return{enabled:!!(S.retention?.enabled??!1),intervalMs:s,defaultDays:n,paths:e}})(),memory:{hotBudgetTokens:parseInt(g("MEMORY_HOT_BUDGET_TOKENS",String(S.memory?.hotBudgetTokens??3e3)),10),sweepIntervalHours:parseFloat(g("MEMORY_SWEEP_INTERVAL_HOURS",String(S.memory?.sweepIntervalHours??6))),hotThreshold:parseFloat(g("MEMORY_HOT_THRESHOLD",String(S.memory?.hotThreshold??.6))),warmThreshold:parseFloat(g("MEMORY_WARM_THRESHOLD",String(S.memory?.warmThreshold??.3))),recencyHalfLifeDays:parseFloat(g("MEMORY_RECENCY_HALF_LIFE_DAYS",String(S.memory?.recencyHalfLifeDays??7))),coldSummaryMinRecords:parseInt(g("MEMORY_COLD_SUMMARY_MIN",String(S.memory?.coldSummaryMinRecords??5)),10),coldRetentionDays:parseInt(g("MEMORY_COLD_RETENTION_DAYS",String(S.memory?.coldRetentionDays??90)),10),purgeRetentionDays:parseInt(g("MEMORY_PURGE_RETENTION_DAYS",String(S.memory?.purgeRetentionDays??7)),10),reflectionMinTurns:parseInt(g("MEMORY_REFLECTION_MIN_TURNS",String(S.memory?.reflectionMinTurns??3)),10)},codeIndex:{enabled:S.codeIndex?.enabled===!0||process.env.CODE_INDEX_ENABLED==="true",scoreThreshold:parseFloat(g("CODE_INDEX_SCORE_THRESHOLD",String(S.codeIndex?.scoreThreshold??.65))),prefetchLimit:parseInt(g("CODE_INDEX_PREFETCH_LIMIT",String(S.codeIndex?.prefetchLimit??8)),10),sessionKnowledge:{enabled:(S.codeIndex?.sessionKnowledge?.enabled??!0)&&process.env.CODE_INDEX_SESSION_KNOWLEDGE!=="false"},repos:S.codeIndex?.repos??{}},events:{retentionDays:parseInt(g("EVENT_RETENTION_DAYS",String(S.events?.retentionDays??30)),10)},activity:{enabled:(S.activity?.enabled??!0)&&process.env.ACTIVITY_LOG_ENABLED!=="false",bufferSize:parseInt(g("ACTIVITY_BUFFER_SIZE",String(S.activity?.bufferSize??200)),10),flushIntervalMs:parseInt(g("ACTIVITY_FLUSH_INTERVAL_MS",String(S.activity?.flushIntervalMs??3e4)),10),retentionDays:parseInt(g("ACTIVITY_RETENTION_DAYS",String(S.activity?.retentionDays??90)),10)},autoDream:{enabled:S.autoDream?.enabled??!0,idleThresholdMinutes:parseInt(g("AUTODREAM_IDLE_THRESHOLD_MINUTES",String(S.autoDream?.idleThresholdMinutes??30)),10),cooldownMinutes:parseInt(g("AUTODREAM_COOLDOWN_MINUTES",String(S.autoDream?.cooldownMinutes??60)),10),similarityThreshold:parseFloat(g("AUTODREAM_SIMILARITY_THRESHOLD",String(S.autoDream?.similarityThreshold??.85))),patternMinCount:parseInt(g("AUTODREAM_PATTERN_MIN_COUNT",String(S.autoDream?.patternMinCount??3)),10),maxClustersPerRun:parseInt(g("AUTODREAM_MAX_CLUSTERS",String(S.autoDream?.maxClustersPerRun??20)),10),maxContradictionPairsPerRun:parseInt(g("AUTODREAM_MAX_CONTRADICTIONS",String(S.autoDream?.maxContradictionPairsPerRun??30)),10),maxPromotionsPerRun:parseInt(g("AUTODREAM_MAX_PROMOTIONS",String(S.autoDream?.maxPromotionsPerRun??10)),10),maxBudgetUsd:parseFloat(g("AUTODREAM_MAX_BUDGET_USD",String(S.autoDream?.maxBudgetUsd??.1)))},browser:{cdpEndpoint:g("BROWSER_CDP_ENDPOINT","")},tasksDir:{code:g("CODE_TASKS_DIR",`/tmp/${cn}-code-tasks`),background:g("BG_TASKS_DIR",`/tmp/${cn}-bg-tasks`)}}});function Is(t,e,n,s){if(yu[t]<yu[Uy])return;let i={ts:new Date().toISOString(),level:t,component:e,msg:n,...s};(t==="error"?process.stderr:process.stdout).write(JSON.stringify(i)+`
226
+ `),r=r.replace(/\\r/g,"\r")),e[i]=r}return e}function Ty(t){t=t||{};let e=ou(t);t.path=e;let n=B.configDotenv(t);if(!n.parsed){let o=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw o.code="MISSING_DATA",o}let s=ru(t).split(","),i=s.length,r;for(let o=0;o<i;o++)try{let a=s[o].trim(),l=Ny(n,a);r=B.decrypt(l.ciphertext,l.key);break}catch(a){if(o+1>=i)throw a}return B.parse(r)}function Oy(t){console.error(`\u26A0 ${t}`)}function ln(t){console.log(`\u2506 ${t}`)}function iu(t){console.log(`\u25C7 ${t}`)}function ru(t){return t&&t.DOTENV_KEY&&t.DOTENV_KEY.length>0?t.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Ny(t,e){let n;try{n=new URL(e)}catch(a){if(a.code==="ERR_INVALID_URL"){let l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw a}let s=n.password;if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let i=n.searchParams.get("environment");if(!i){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let r=`DOTENV_VAULT_${i.toUpperCase()}`,o=t.parsed[r];if(!o){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${r} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:o,key:s}}function ou(t){let e=null;if(t&&t.path&&t.path.length>0)if(Array.isArray(t.path))for(let n of t.path)Dr.existsSync(n)&&(e=n.endsWith(".vault")?n:`${n}.vault`);else e=t.path.endsWith(".vault")?t.path:`${t.path}.vault`;else e=Es.resolve(process.cwd(),".env.vault");return Dr.existsSync(e)?e:null}function su(t){return t[0]==="~"?Es.join(wy.homedir(),t.slice(1)):t}function Cy(t){let e=ft(process.env.DOTENV_CONFIG_DEBUG||t&&t.debug),n=ft(process.env.DOTENV_CONFIG_QUIET||t&&t.quiet);(e||!n)&&iu("loading env from encrypted .env.vault");let s=B._parseVault(t),i=process.env;return t&&t.processEnv!=null&&(i=t.processEnv),B.populate(i,s,t),{parsed:s}}function Ly(t){let e=Es.resolve(process.cwd(),".env"),n="utf8",s=process.env;t&&t.processEnv!=null&&(s=t.processEnv);let i=ft(s.DOTENV_CONFIG_DEBUG||t&&t.debug),r=ft(s.DOTENV_CONFIG_QUIET||t&&t.quiet);t&&t.encoding?n=t.encoding:i&&ln("no encoding is specified (UTF-8 is used by default)");let o=[e];if(t&&t.path)if(!Array.isArray(t.path))o=[su(t.path)];else{o=[];for(let u of t.path)o.push(su(u))}let a,l={};for(let u of o)try{let f=B.parse(Dr.readFileSync(u,{encoding:n}));B.populate(l,f,t)}catch(f){i&&ln(`failed to load ${u} ${f.message}`),a=f}let c=B.populate(s,l,t);if(i=ft(s.DOTENV_CONFIG_DEBUG||i),r=ft(s.DOTENV_CONFIG_QUIET||r),i||!r){let u=Object.keys(c).length,f=[];for(let d of o)try{let p=Es.relative(process.cwd(),d);f.push(p)}catch(p){i&&ln(`failed to load ${d} ${p.message}`),a=p}iu(`injected env (${u}) from ${f.join(",")} ${Ay(`// tip: ${ky()}`)}`)}return a?{parsed:l,error:a}:{parsed:l}}function $y(t){if(ru(t).length===0)return B.configDotenv(t);let e=ou(t);return e?B._configVault(t):(Oy(`you set DOTENV_KEY but you are missing a .env.vault file at ${e}`),B.configDotenv(t))}function Py(t,e){let n=Buffer.from(e.slice(-64),"hex"),s=Buffer.from(t,"base64"),i=s.subarray(0,12),r=s.subarray(-16);s=s.subarray(12,-16);try{let o=by.createDecipheriv("aes-256-gcm",n,i);return o.setAuthTag(r),`${o.update(s)}${o.final()}`}catch(o){let a=o instanceof RangeError,l=o.message==="Invalid key length",c=o.message==="Unsupported state or unable to authenticate data";if(a||l){let u=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw u.code="INVALID_DOTENV_KEY",u}else if(c){let u=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw u.code="DECRYPTION_FAILED",u}else throw o}}function My(t,e,n={}){let s=!!(n&&n.debug),i=!!(n&&n.override),r={};if(typeof e!="object"){let o=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw o.code="OBJECT_REQUIRED",o}for(let o of Object.keys(e))Object.prototype.hasOwnProperty.call(t,o)?(i===!0&&(t[o]=e[o],r[o]=e[o]),s&&ln(i===!0?`"${o}" is already defined and WAS overwritten`:`"${o}" is already defined and was NOT overwritten`)):(t[o]=e[o],r[o]=e[o]);return r}var B={configDotenv:Ly,_configVault:Cy,_parseVault:Ty,config:$y,decrypt:Py,parse:_y,populate:My};Se.exports.configDotenv=B.configDotenv;Se.exports._configVault=B._configVault;Se.exports._parseVault=B._parseVault;Se.exports.config=B.config;Se.exports.decrypt=B.decrypt;Se.exports.parse=B.parse;Se.exports.populate=B.populate;Se.exports=B});var As,lu=T(()=>{"use strict";As={externalComms:!0,codeTask:!1,codeAccess:!1}});import{execFileSync as Dy}from"node:child_process";function cu(t,e){if(process.platform!=="darwin")return"";try{return Dy("security",["find-generic-password","-s",`hive/${t}/${e}`,"-w"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}catch{return""}}var uu=T(()=>{"use strict"});var dt={};Y(dt,{config:()=>Fy});import{readFileSync as qy,existsSync as hu,readdirSync as Ry,statSync as xy}from"node:fs";import{resolve as qr}from"node:path";import{randomUUID as Rr}from"node:crypto";function fu(t){let e=process.env[t]||gu(t);if(!e)throw new Error(`Missing required env var: ${t}`);return e}function g(t,e){return process.env[t]||gu(t)||e}function By(t){if(t?.length)return t.map(n=>qr(n.replace(/^~/,process.env.HOME??"/tmp")));let e=qr(Ke,"plugins/claude-code");return hu(e)?Ry(e).map(n=>qr(e,n)).filter(n=>xy(n).isDirectory()):[]}var pu,mu,Ky,du,S,Ob,cn,gu,De,Ge,Fy,pt=T(()=>{"use strict";pu=ie(au(),1),mu=ie(ce(),1);lu();uu();W();Ky=vo($);pu.default.config({path:Ky});du=Sn($),S={};hu(du)&&(S=(0,mu.parse)(qy(du,"utf-8"))??{});Ob=process.env.HOME??"/tmp",cn=S.instance?.id??"hive",gu=t=>cu(cn,t),De=S.instance?.portBase??3100,Ge=S.instance?.ports??{},Fy={instance:{id:cn,portBase:De},business:{name:S.business?.name??g("BUSINESS_NAME",""),description:S.business?.description??"",location:S.business?.location??"",ownerName:S.business?.owner?.name??"",ownerRole:S.business?.owner?.role??""},slack:{appToken:fu("SLACK_APP_TOKEN"),botToken:fu("SLACK_BOT_TOKEN"),mcpToken:g("SLACK_MCP_TOKEN",""),auditChannel:g("SLACK_AUDIT_CHANNEL",S.slack?.auditChannel??""),localMcpServer:!!(S.slack?.localMcpServer??!1)},anthropic:{apiKey:g("ANTHROPIC_API_KEY","")},openai:{agentModel:g("OPENAI_AGENT_MODEL","")},codex:{agentModel:g("CODEX_AGENT_MODEL","gpt-5.4-mini")},linear:{apiKey:g("LINEAR_API_KEY",""),teamId:g("LINEAR_TEAM_ID","")},clickup:{apiToken:g("CLICKUP_API_TOKEN","")},github:{repo:g("GITHUB_REPO",""),token:g("GH_TOKEN","")},brave:{apiKey:g("BRAVE_API_KEY","")},taskLedger:{apiUrl:g("TASK_LEDGER_API_URL","http://localhost:3002"),agentKeys:Object.fromEntries(Object.entries(process.env).filter(([t])=>t.startsWith("TASK_LEDGER_KEY_")).map(([t,e])=>[t.replace("TASK_LEDGER_KEY_","").toLowerCase().replace(/_/g,"-"),e])),apiKey:g("TASK_LEDGER_API_KEY","")},mongo:{uri:g("MONGODB_URI","mongodb://localhost:27017"),dbName:g("MONGODB_DB",`hive_${cn}`)},defaultAgent:g("DEFAULT_AGENT","chief-of-staff"),google:{account:g("GOOGLE_ACCOUNT",S.google?.account??""),client:g("GOG_CLIENT",S.google?.client??""),accounts:S.google?.accounts??{},sharedFolder:g("DRIVE_SHARED_FOLDER",S.google?.sharedFolder??S.googleWorkspace?.sharedFolder??"")},googleWorkspace:{account:g("GWS_ACCOUNT",S.googleWorkspace?.account??""),gwsPath:g("GWS_PATH",""),sharedFolder:g("GWS_SHARED_FOLDER",S.googleWorkspace?.sharedFolder??"")},quo:{apiKey:g("QUO_API_KEY",""),phoneNumberId:g("QUO_PHONE_NUMBER_ID",""),lines:S.quo?.lines??{}},sms:{lines:S.sms?.lines??[]},imessage:{enabled:S.imessage?.enabled??!1,slackChannel:S.imessage?.slackChannel??"imessage",hotWindowMs:S.imessage?.hotWindowMs??3e5,coldIntervalMs:S.imessage?.coldIntervalMs??3e5,hotIntervalMs:S.imessage?.hotIntervalMs??1e4},resend:{apiKey:g("RESEND_API_KEY",""),fromAddress:g("RESEND_FROM_ADDRESS",""),defaultCc:g("RESEND_DEFAULT_CC",""),defaultBcc:g("RESEND_DEFAULT_BCC",""),emailDomain:g("RESEND_EMAIL_DOMAIN",S.resend?.emailDomain??""),businessName:g("RESEND_BUSINESS_NAME",S.resend?.businessName??"")},plugins:S.plugins??[],skillRegistries:S.skillRegistries??[{name:"keepur-default",url:"https://github.com/keepur/hive-skills",default:!0}],operatorSkillsRepo:S.operatorSkillsRepo?{url:String(S.operatorSkillsRepo.url),branch:S.operatorSkillsRepo.branch?String(S.operatorSkillsRepo.branch):"main"}:null,gemini:{apiKey:g("GEMINI_API_KEY",""),visionModel:g("GEMINI_VISION_MODEL","gemini-2.5-flash"),agentModel:g("GEMINI_AGENT_MODEL","")},permits:{mongoUri:g("PERMITS_MONGO_URI","mongodb://localhost:27017/permits")},recall:{apiKey:g("RECALL_API_KEY",""),region:g("RECALL_API_REGION","us-west-2"),monitorPort:parseInt(g("MEETING_MONITOR_PORT",String(Ge.recall??De+1)),10),monitorPublicUrl:g("MEETING_MONITOR_PUBLIC_URL",""),webhookSecret:g("RECALL_WEBHOOK_SECRET","")},scheduler:{heartbeatIntervalMs:parseInt(g("HEARTBEAT_INTERVAL_MS","120000"),10)},background:{port:parseInt(g("BG_TASK_PORT",String(Ge.background??De)),10),authToken:g("BG_TASK_AUTH_TOKEN","")||Rr()},slackInternal:{port:parseInt(g("SLACK_INTERNAL_PORT",String(Ge.slackInternal??De+6)),10),authToken:g("SLACK_INTERNAL_TOKEN","")||Rr()},codeTask:{port:parseInt(g("CODE_TASK_PORT",String(Ge.codeTask??De+2)),10),authToken:g("CODE_TASK_AUTH_TOKEN","")||Rr(),pluginDirs:By(S.codeTask?.pluginDirs),defaultModel:g("CODE_TASK_MODEL","claude-sonnet-4-6"),defaultMaxTurns:parseInt(g("CODE_TASK_MAX_TURNS","100"),10),defaultMaxBudget:parseFloat(g("CODE_TASK_MAX_BUDGET","5.00")),maxConcurrent:parseInt(g("CODE_TASK_MAX_CONCURRENT","2"),10),maxLifetimeMs:parseInt(g("CODE_TASK_MAX_LIFETIME_MS",String(480*60*1e3)),10),staleGraceMs:parseInt(g("CODE_TASK_STALE_GRACE_MS",String(1800*1e3)),10)},ws:{enabled:g("WS_ENABLED","false")==="true",port:parseInt(g("WS_PORT",String(Ge.ws??De+3)),10)},beekeeper:{port:parseInt(g("BEEKEEPER_PORT",String(S.beekeeper?.port??8420)),10)},workflow:{enabled:g("WORKFLOW_ENABLED","false")==="true"},adminApi:{port:parseInt(g("ADMIN_API_PORT",String(Ge.adminApi??De+4)),10),token:g("ADMIN_API_TOKEN","")},voice:{enabled:!!S.voice?.provider,provider:S.voice?.provider??"",publicUrl:S.voice?.publicUrl??"",phoneNumberId:S.voice?.phoneNumberId??"",assistants:S.voice?.assistants??{},apiKey:g("VAPI_API_KEY",""),serverSecret:g("VAPI_SERVER_SECRET",""),port:parseInt(g("VOICE_PORT",String(Ge.voice??De+5)),10)},autonomy:{externalComms:S.autonomy?.externalComms??As.externalComms,codeTask:S.autonomy?.codeTask??As.codeTask,codeAccess:S.autonomy?.codeAccess??As.codeAccess},modelRouter:{enabled:g("MODEL_ROUTER_ENABLED","true")==="true",model:g("MODEL_ROUTER_MODEL","claude-haiku-4-5-20251001"),timeoutMs:parseInt(g("MODEL_ROUTER_TIMEOUT_MS","8000"),10)},sweeper:{intervalMs:parseInt(g("SWEEPER_INTERVAL_MS","300000"),10),threadTtlMs:parseInt(g("SWEEPER_THREAD_TTL_MS","86400000"),10),taskFileTtlMs:parseInt(g("SWEEPER_TASK_FILE_TTL_MS","604800000"),10),meetingSessionTtlMs:parseInt(g("SWEEPER_MEETING_TTL_MS","3600000"),10),cacheTtlMs:parseInt(g("SWEEPER_CACHE_TTL_MS","3600000"),10),retryMaxAttempts:parseInt(g("SWEEPER_RETRY_MAX_ATTEMPTS","3"),10),retryBaseDelayMs:parseInt(g("SWEEPER_RETRY_BASE_DELAY_MS","30000"),10)},retention:(()=>{let t=S.retention?.paths??{data:7,"agents/*/scratch":7,"agents/*/feeds":7,"agents/*/playwright":3,"agents/*/reports":0,logs:30},e={};for(let[i,r]of Object.entries(t)){if(typeof r!="number"||!Number.isFinite(r)||r<0)throw new Error(`Invalid retention.paths.${i}: must be a non-negative integer (got ${r})`);e[i]={days:r}}let n=Number(S.retention?.defaults?.days??7);if(!Number.isFinite(n)||n<0)throw new Error(`Invalid retention.defaults.days: ${n}`);let s=parseInt(g("RETENTION_INTERVAL_MS",String(S.retention?.intervalMs??168*36e5)),10);if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid retention.intervalMs: must be a positive integer (got ${s})`);return{enabled:!!(S.retention?.enabled??!1),intervalMs:s,defaultDays:n,paths:e}})(),memory:{hotBudgetTokens:parseInt(g("MEMORY_HOT_BUDGET_TOKENS",String(S.memory?.hotBudgetTokens??3e3)),10),sweepIntervalHours:parseFloat(g("MEMORY_SWEEP_INTERVAL_HOURS",String(S.memory?.sweepIntervalHours??6))),hotThreshold:parseFloat(g("MEMORY_HOT_THRESHOLD",String(S.memory?.hotThreshold??.6))),warmThreshold:parseFloat(g("MEMORY_WARM_THRESHOLD",String(S.memory?.warmThreshold??.3))),recencyHalfLifeDays:parseFloat(g("MEMORY_RECENCY_HALF_LIFE_DAYS",String(S.memory?.recencyHalfLifeDays??7))),coldSummaryMinRecords:parseInt(g("MEMORY_COLD_SUMMARY_MIN",String(S.memory?.coldSummaryMinRecords??5)),10),coldRetentionDays:parseInt(g("MEMORY_COLD_RETENTION_DAYS",String(S.memory?.coldRetentionDays??90)),10),purgeRetentionDays:parseInt(g("MEMORY_PURGE_RETENTION_DAYS",String(S.memory?.purgeRetentionDays??7)),10),reflectionMinTurns:parseInt(g("MEMORY_REFLECTION_MIN_TURNS",String(S.memory?.reflectionMinTurns??3)),10)},codeIndex:{enabled:S.codeIndex?.enabled===!0||process.env.CODE_INDEX_ENABLED==="true",scoreThreshold:parseFloat(g("CODE_INDEX_SCORE_THRESHOLD",String(S.codeIndex?.scoreThreshold??.65))),prefetchLimit:parseInt(g("CODE_INDEX_PREFETCH_LIMIT",String(S.codeIndex?.prefetchLimit??8)),10),sessionKnowledge:{enabled:(S.codeIndex?.sessionKnowledge?.enabled??!0)&&process.env.CODE_INDEX_SESSION_KNOWLEDGE!=="false"},repos:S.codeIndex?.repos??{}},events:{retentionDays:parseInt(g("EVENT_RETENTION_DAYS",String(S.events?.retentionDays??30)),10)},activity:{enabled:(S.activity?.enabled??!0)&&process.env.ACTIVITY_LOG_ENABLED!=="false",bufferSize:parseInt(g("ACTIVITY_BUFFER_SIZE",String(S.activity?.bufferSize??200)),10),flushIntervalMs:parseInt(g("ACTIVITY_FLUSH_INTERVAL_MS",String(S.activity?.flushIntervalMs??3e4)),10),retentionDays:parseInt(g("ACTIVITY_RETENTION_DAYS",String(S.activity?.retentionDays??90)),10)},autoDream:{enabled:S.autoDream?.enabled??!1,quietPeriodMinutes:parseInt(g("AUTODREAM_QUIET_PERIOD_MINUTES",String(S.autoDream?.quietPeriodMinutes??S.autoDream?.idleThresholdMinutes??120)),10),cooldownMinutes:parseInt(g("AUTODREAM_COOLDOWN_MINUTES",String(S.autoDream?.cooldownMinutes??1440)),10),minNewMemories:parseInt(g("AUTODREAM_MIN_NEW_MEMORIES",String(S.autoDream?.minNewMemories??10)),10),similarityThreshold:parseFloat(g("AUTODREAM_SIMILARITY_THRESHOLD",String(S.autoDream?.similarityThreshold??.85))),patternMinCount:parseInt(g("AUTODREAM_PATTERN_MIN_COUNT",String(S.autoDream?.patternMinCount??3)),10),maxClustersPerRun:parseInt(g("AUTODREAM_MAX_CLUSTERS",String(S.autoDream?.maxClustersPerRun??20)),10),maxContradictionPairsPerRun:parseInt(g("AUTODREAM_MAX_CONTRADICTIONS",String(S.autoDream?.maxContradictionPairsPerRun??30)),10),maxPromotionsPerRun:parseInt(g("AUTODREAM_MAX_PROMOTIONS",String(S.autoDream?.maxPromotionsPerRun??2)),10),maxRunBudgetUsd:parseFloat(g("AUTODREAM_MAX_RUN_BUDGET_USD",String(S.autoDream?.maxRunBudgetUsd??S.autoDream?.maxBudgetUsd??.05))),maxCallBudgetUsd:parseFloat(g("AUTODREAM_MAX_CALL_BUDGET_USD",String(S.autoDream?.maxCallBudgetUsd??S.autoDream?.maxBudgetUsd??.01)))},browser:{cdpEndpoint:g("BROWSER_CDP_ENDPOINT","")},tasksDir:{code:g("CODE_TASKS_DIR",`/tmp/${cn}-code-tasks`),background:g("BG_TASKS_DIR",`/tmp/${cn}-bg-tasks`)}}});function Is(t,e,n,s){if(yu[t]<yu[Uy])return;let i={ts:new Date().toISOString(),level:t,component:e,msg:n,...s};(t==="error"?process.stderr:process.stdout).write(JSON.stringify(i)+`
227
227
  `)}function D(t){return{debug:(e,n)=>Is("debug",t,e,n),info:(e,n)=>Is("info",t,e,n),warn:(e,n)=>Is("warn",t,e,n),error:(e,n)=>Is("error",t,e,n)}}var yu,Uy,se=T(()=>{"use strict";yu={debug:0,info:1,warn:2,error:3},Uy=process.env.LOG_LEVEL||"info"});var bu={};Y(bu,{checkoutSha:()=>Ur,findTagForSha:()=>mt,listSkillsInClone:()=>fn,lsRemoteHead:()=>Fr,partialClone:()=>Br,shallowClone:()=>un,verifyGitAvailable:()=>ht});import{execFileSync as fe}from"node:child_process";import{existsSync as Su,readdirSync as jy,statSync as Hy,rmSync as xr,mkdtempSync as vu}from"node:fs";import{join as Ve}from"node:path";import{tmpdir as wu}from"node:os";function ht(){try{fe("git",["--version"],{stdio:"pipe"})}catch{throw new Error("git is required for skill installation but was not found. Install git and retry.")}}function un(t){let e=vu(Ve(wu(),"hive-skill-install-")),n=Ve(e,"repo"),s=()=>{try{xr(e,{recursive:!0,force:!0})}catch{}};try{fe("git",["clone","--depth","1",t,n],{stdio:"pipe",timeout:6e4});let i=fe("git",["rev-parse","HEAD"],{cwd:n,stdio:"pipe",encoding:"utf-8"}).trim();return Kr.debug("Shallow clone complete",{url:t,headSha:i}),{dir:n,headSha:i,cleanup:s}}catch(i){throw s(),new Error(`registry fetch failed: ${String(i)}`)}}function Br(t){let e=vu(Ve(wu(),"hive-skill-upgrade-")),n=Ve(e,"repo"),s=()=>{try{xr(e,{recursive:!0,force:!0})}catch{}};try{try{fe("git",["clone","--filter=blob:none","--no-checkout",t,n],{stdio:"pipe",timeout:12e4}),fe("git",["checkout","HEAD"],{cwd:n,stdio:"pipe"})}catch(r){Kr.debug("Blobless clone failed, falling back to full clone",{error:String(r)}),xr(n,{recursive:!0,force:!0}),fe("git",["clone",t,n],{stdio:"pipe",timeout:12e4})}let i=fe("git",["rev-parse","HEAD"],{cwd:n,stdio:"pipe",encoding:"utf-8"}).trim();return Kr.debug("Partial clone complete",{url:t,headSha:i}),{dir:n,headSha:i,cleanup:s}}catch(i){throw s(),new Error(`registry fetch failed: ${String(i)}`)}}function Fr(t){let n=fe("git",["ls-remote",t,"HEAD"],{stdio:"pipe",encoding:"utf-8",timeout:3e4}).trim().split(" ")[0];if(!n)throw new Error(`Could not determine HEAD for ${t}`);return n}function fn(t){let e=Ve(t,"skills");return Su(e)?jy(e).filter(n=>{try{let s=Ve(e,n);return Hy(s).isDirectory()&&Su(Ve(s,"SKILL.md"))}catch{return!1}}):[]}function Ur(t,e){fe("git",["checkout",e],{cwd:t,stdio:"pipe"})}function mt(t,e){try{return fe("git",["describe","--tags","--exact-match",e],{cwd:t,stdio:"pipe",encoding:"utf-8"}).trim()||void 0}catch{return}}var Kr,gt=T(()=>{"use strict";se();Kr=D("registry-fetch")});import{join as Yy}from"node:path";import{readFileSync as Gy}from"node:fs";function ku(t,e){let s=Gy(t,"utf-8").match(/^---\n([\s\S]*?)\n---/);if(!s)return e;let i=s[1].match(/^workflow:\s*(.+)$/m);return i?i[1].trim():e}function Eu(t,e,n){return Yy(t,e,"skills",n)}var Au=T(()=>{"use strict"});import{readFileSync as Vy,writeFileSync as Wy}from"node:fs";function jr(t){let e=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!e)throw new Error("No YAML frontmatter found");let n=e[1],s=e[2],i={name:"",description:"",agents:[]},r=n.split(`
228
228
  `),o=0;for(;o<r.length;){let a=r[o];if(a.trim()===""){o++;continue}let l=a.match(/^(\w[\w-]*):\s*(.*)/);if(!l){o++;continue}let c=l[1],u=l[2].trim();if(c==="name")i.name=We(u);else if(c==="description")i.description=We(u);else if(c==="workflow")i.workflow=We(u);else if(c==="agents"){let f=u.match(/^\[([^\]]*)\]$/);if(f)i.agents=f[1].split(",").map(d=>We(d.trim())).filter(d=>d.length>0);else if(u==="")for(i.agents=[];o+1<r.length&&r[o+1].match(/^\s+-\s+/);){o++;let d=r[o].replace(/^\s+-\s+/,"").trim();i.agents.push(We(d))}else i.agents=[We(u)]}else if(c==="origin")for(i.origin=Iu(r,o);o+1<r.length&&r[o+1].match(/^\s+\S/);)o++;else if(c==="author")for(i.author=Iu(r,o);o+1<r.length&&r[o+1].match(/^\s+\S/);)o++;o++}return{frontmatter:i,body:s}}function Iu(t,e){let n={},s=e+1;for(;s<t.length&&t[s].match(/^\s+\S/);){let i=t[s].match(/^\s+([\w][\w-]*):\s*(.*)/);if(i){let r=i[2].trim();r==="true"?n[i[1]]=!0:r==="false"?n[i[1]]=!1:n[i[1]]=We(r)}s++}return n}function We(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"):t}function Hr(t,e){let n=[];n.push(`name: ${_s(t.name)}`),n.push(`description: ${_s(t.description)}`);let s=t.agents.join(", ");return n.push(`agents: [${s}]`),t.workflow&&n.push(`workflow: ${_s(t.workflow)}`),t.origin&&(n.push("origin:"),_u(n,t.origin)),t.author&&(n.push("author:"),_u(n,t.author)),`---
229
229
  ${n.join(`