adam-agent-server 1.9.0 → 1.11.0
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/adam-tools-ET23EDSQ.js +1 -0
- package/dist/approval-handler-J6RUTICJ.js +1 -0
- package/dist/audit-manager-7KPLFG2B.js +1 -0
- package/dist/bree-engine-52CYOPIN.js +1 -0
- package/dist/channels-OOIM62BX.js +1 -0
- package/dist/{channels-ZNMTMMCY.js → channels-WFC26TED.js} +1 -1
- package/dist/{chunk-XIQVXRZH.js → chunk-23Y7QFK3.js} +4 -4
- package/dist/chunk-25ZHHZQV.js +80 -0
- package/dist/chunk-2WMUME2D.js +146 -0
- package/dist/chunk-6JBSBSCL.js +1 -0
- package/dist/chunk-76IJC5WL.js +1 -0
- package/dist/{chunk-6M2QCKAS.js → chunk-7T4B2MZ7.js} +1 -1
- package/dist/{chunk-7F4SZXI2.js → chunk-AQO6IIHV.js} +13 -13
- package/dist/chunk-AVM3O74V.js +5 -0
- package/dist/{chunk-XTOOD44S.js → chunk-B44X7JAJ.js} +1 -1
- package/dist/{chunk-KUJFQDT5.js → chunk-B544JOZM.js} +2 -2
- package/dist/{chunk-YKMWAVUH.js → chunk-CYQUP2RP.js} +8 -8
- package/dist/{chunk-VPZSOYE5.js → chunk-D5LZGIJU.js} +1 -1
- package/dist/{chunk-MYVYH4PQ.js → chunk-ETOTUZPB.js} +1 -1
- package/dist/{chunk-TTP7QRAQ.js → chunk-FUWPDXXG.js} +1 -1
- package/dist/{chunk-HSEP6LNQ.js → chunk-IYJVHEQ4.js} +1 -1
- package/dist/chunk-JYHOGBCP.js +12 -0
- package/dist/{chunk-J4Y54LIC.js → chunk-LPNJ4EW5.js} +3 -3
- package/dist/{chunk-3N7MGASP.js → chunk-MQWYGDNT.js} +1 -1
- package/dist/chunk-N5FW6FUS.js +1 -0
- package/dist/{chunk-W7U3ASGR.js → chunk-NPIXYK5G.js} +1 -1
- package/dist/chunk-O7XQSONJ.js +5 -0
- package/dist/{chunk-C2SD2NMZ.js → chunk-Q2ISNOBQ.js} +1 -1
- package/dist/{chunk-7WJF65TQ.js → chunk-QYRI4HYA.js} +1 -1
- package/dist/chunk-R2WB5BKF.js +7 -0
- package/dist/{chunk-6XVWIRR2.js → chunk-RMGBR3XZ.js} +1 -1
- package/dist/{chunk-3HZE5DQZ.js → chunk-SC2DDRYB.js} +1 -1
- package/dist/{chunk-5AUQIK3Q.js → chunk-SDT3PBHF.js} +1 -1
- package/dist/{chunk-YWUX3ZTO.js → chunk-U2LBBBWO.js} +1 -1
- package/dist/chunk-UXDTFTG5.js +10 -0
- package/dist/chunk-WQFNB2MQ.js +32 -0
- package/dist/chunk-X5V4VMET.js +26 -0
- package/dist/{chunk-IZ3WZHCM.js → chunk-Y5FFL6UO.js} +1 -1
- package/dist/{chunk-UYOLAFUR.js → chunk-YFCFPB2Q.js} +1 -1
- package/dist/{chunk-EJBGJLA2.js → chunk-ZFDULJGB.js} +1 -1
- package/dist/chunk-ZQ4PNKMQ.js +10 -0
- package/dist/cli.js +1 -1
- package/dist/config-GH6LQRYM.js +1 -0
- package/dist/{config-CILWJYZB.js → config-GKVOAMY2.js} +1 -1
- package/dist/{db-JO24ZLIN.js → db-FACSMWEY.js} +1 -1
- package/dist/delivery-log-JIQMHBJ5.js +1 -0
- package/dist/engine-OHYWUUMJ.js +1 -0
- package/dist/evolution-audit-M7FSYRQR.js +1 -0
- package/dist/{external-api-QKRNGSYS.js → external-api-MP4PAU7J.js} +1 -1
- package/dist/index.js +21 -13
- package/dist/learner-OUNQSWN7.js +1 -0
- package/dist/{memories-LXH4VHCH.js → memories-ABE7PMQL.js} +1 -1
- package/dist/memory-extractor-ZX2NJIBV.js +6 -0
- package/dist/memory-service-UWER3T2S.js +1 -0
- package/dist/outbound-gateway-XDCGAXXW.js +1 -0
- package/dist/{presets-XR2OBXUP.js → presets-R3D4E6SK.js} +1 -1
- package/dist/{role-presets-DYWDEQYU.js → role-presets-7JIX34HF.js} +1 -1
- package/dist/role-workspace-ISGPO25D.js +1 -0
- package/dist/{roles-DRPLO4LY.js → roles-WNKRM6FD.js} +1 -1
- package/dist/{runtime-YPBWWMXW.js → runtime-G6DVR5OY.js} +1 -1
- package/dist/session-manager-QC734QQA.js +1 -0
- package/dist/{task-templates-4DWXHLFZ.js → task-templates-SNKZJ3DI.js} +1 -1
- package/dist/workflow-executor-M6QOEUKC.js +1 -0
- package/package.json +1 -1
- package/dist/adam-tools-FSI5XKDL.js +0 -1
- package/dist/approval-handler-JYCGXQUE.js +0 -1
- package/dist/audit-manager-CLKTJPLM.js +0 -1
- package/dist/bree-engine-XJR5TKVC.js +0 -1
- package/dist/channels-DY2OW7YQ.js +0 -1
- package/dist/chunk-3IQADR6L.js +0 -144
- package/dist/chunk-56QP5ZHF.js +0 -79
- package/dist/chunk-ARQF52V6.js +0 -5
- package/dist/chunk-DKMF4B33.js +0 -5
- package/dist/chunk-KO7XBNPV.js +0 -12
- package/dist/chunk-LV4XLPCD.js +0 -26
- package/dist/chunk-OFTIPZTH.js +0 -1
- package/dist/chunk-OY2KVSIX.js +0 -7
- package/dist/chunk-PFYYS7CI.js +0 -10
- package/dist/chunk-QPIWPQWM.js +0 -29
- package/dist/chunk-UQDC3X6O.js +0 -10
- package/dist/chunk-YVVKUPGL.js +0 -1
- package/dist/config-W2OD7PXZ.js +0 -1
- package/dist/delivery-log-QPQM5YU7.js +0 -1
- package/dist/engine-ZAPYG7G4.js +0 -1
- package/dist/evolution-audit-ZLYQ3ZYV.js +0 -1
- package/dist/learner-ACHENH6R.js +0 -1
- package/dist/memory-extractor-URH4YHK3.js +0 -6
- package/dist/memory-service-23P6VNKZ.js +0 -1
- package/dist/outbound-gateway-Y3P3T3VH.js +0 -1
- package/dist/role-workspace-LHW7AWPF.js +0 -1
- package/dist/session-manager-Z6K4U5X7.js +0 -1
- package/dist/workflow-executor-6ZMNL34C.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as a}from"./chunk-6JBSBSCL.js";import{b as o,d as p}from"./chunk-AQO6IIHV.js";p();function u(e){return{id:e.id,parentId:e.parent_id??void 0,status:e.status,prompt:e.prompt,originalPrompt:e.original_prompt??void 0,config:JSON.parse(e.config),result:e.result??void 0,error:e.error??void 0,sdkSessionId:e.sdk_session_id??void 0,templateId:e.template_id??void 0,roleId:e.role_id??void 0,stepId:e.step_id??void 0,sourceSessionId:e.source_session_id??void 0,deliverTo:e.deliver_to?JSON.parse(e.deliver_to):void 0,reportTo:e.report_to?JSON.parse(e.report_to):void 0,createdAt:e.created_at,startedAt:e.started_at??void 0,completedAt:e.completed_at??void 0,costUsd:e.cost_usd??void 0,tokenUsage:e.token_usage?JSON.parse(e.token_usage):void 0,numTurns:e.num_turns??void 0,totalDurationMs:e.total_duration_ms??void 0,blockReason:e.block_reason_json?JSON.parse(e.block_reason_json):void 0,traceId:e.trace_id??void 0}}function f(e){o().prepare(`
|
|
2
|
+
INSERT INTO tasks (id, parent_id, status, prompt, original_prompt, config, result, error,
|
|
3
|
+
sdk_session_id, template_id, role_id, step_id, source_session_id, notify_targets, deliver_to, report_to,
|
|
4
|
+
created_at, started_at, completed_at,
|
|
5
|
+
cost_usd, token_usage, num_turns, total_duration_ms, trace_id)
|
|
6
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
7
|
+
`).run(e.id,e.parentId??null,e.status,e.prompt,e.originalPrompt??null,JSON.stringify(e.config),e.result??null,e.error??null,e.sdkSessionId??null,e.templateId??null,e.roleId??null,e.stepId??null,e.sourceSessionId??null,null,e.deliverTo?JSON.stringify(e.deliverTo):null,e.reportTo?JSON.stringify(e.reportTo):null,e.createdAt,e.startedAt??null,e.completedAt??null,e.costUsd??null,e.tokenUsage?JSON.stringify(e.tokenUsage):null,e.numTurns??null,e.totalDurationMs??null,e.traceId??a()??null)}function m(e){let r=o().prepare("SELECT * FROM tasks WHERE id = ?").get(e);return r?u(r):void 0}function T(e,n){let r=o(),t=[],s=[],l={parentId:"parent_id",status:"status",prompt:"prompt",result:"result",error:"error",sdkSessionId:"sdk_session_id",templateId:"template_id",roleId:"role_id",stepId:"step_id",sourceSessionId:"source_session_id",originalPrompt:"original_prompt",startedAt:"started_at",completedAt:"completed_at",costUsd:"cost_usd",numTurns:"num_turns",totalDurationMs:"total_duration_ms"};for(let[i,d]of Object.entries(l))i in n&&(t.push(`${d} = ?`),s.push(n[i]??null));"config"in n&&(t.push("config = ?"),s.push(JSON.stringify(n.config))),"tokenUsage"in n&&(t.push("token_usage = ?"),s.push(n.tokenUsage?JSON.stringify(n.tokenUsage):null)),"deliverTo"in n&&(t.push("deliver_to = ?"),s.push(n.deliverTo?JSON.stringify(n.deliverTo):null)),"reportTo"in n&&(t.push("report_to = ?"),s.push(n.reportTo?JSON.stringify(n.reportTo):null)),"blockReason"in n&&(t.push("block_reason_json = ?"),s.push(n.blockReason?JSON.stringify(n.blockReason):null)),t.length!==0&&(s.push(e),r.prepare(`UPDATE tasks SET ${t.join(", ")} WHERE id = ?`).run(...s))}function E(e,n=100,r=0,t){let s=o(),l="SELECT * FROM tasks",i=[],d=[];return e&&(i.push("status = ?"),d.push(e)),t&&(i.push("role_id = ?"),d.push(t)),i.length>0&&(l+=" WHERE "+i.join(" AND ")),l+=" ORDER BY created_at DESC LIMIT ? OFFSET ?",d.push(n,r),s.prepare(l).all(...d).map(u)}function k(e){return o().prepare("SELECT * FROM tasks WHERE parent_id = ? ORDER BY created_at ASC").all(e).map(u)}function S(e){return o().prepare("SELECT COALESCE(SUM(cost_usd), 0) as total FROM tasks WHERE completed_at >= ? AND cost_usd IS NOT NULL").get(e).total}function b(e){return o().prepare("SELECT trace_id FROM tasks WHERE id = ?").get(e)?.trace_id??void 0}export{f as a,m as b,T as c,E as d,k as e,S as f,b as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as y,r as T}from"./chunk-
|
|
1
|
+
import{n as y,r as T}from"./chunk-U2LBBBWO.js";import{d as h,h as F}from"./chunk-WBAPIPST.js";import{c as R,h as P}from"./chunk-MRTJFYPR.js";import{c as v,e as A}from"./chunk-FCV2DPZQ.js";import{readFileSync as b,writeFileSync as C,existsSync as k}from"fs";import{join as W}from"path";function w(e){let n=W(d(e),".env");if(!k(n))return null;let i=b(n,"utf-8"),t={};for(let o of i.split(`
|
|
2
2
|
`)){let s=o.trim();if(!s||s.startsWith("#"))continue;let c=s.startsWith("export ")?s.slice(7).trim():s,u=c.indexOf("=");if(u===-1)continue;let f=c.slice(0,u).trim(),r=c.slice(u+1).trim();(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),!(r.includes("$")&&(r=r.replace(/\$\{(\w+)\}|\$(\w+)/g,(p,l,a)=>{let g=l??a;return t[g]??process.env[g]??""}),!r))&&(t[f]=r)}return t}function V(e,n){let i=w(e);if(!i)return n;let t={...n},o=0;for(let[s,c]of Object.entries(i)){if(s.startsWith("ANTHROPIC_")){x.warn({roleName:e,key:s},"Role .env contains ANTHROPIC_* key; ignored (managed globally)");continue}s in t||(t[s]=c,o++)}return o>0&&x.info({roleName:e,seeded:o},"Seeded role envVars from .env file"),Object.keys(t).length>0?t:void 0}function M(e,n){let i=w(e);if(!i)return[];let t=n??{},o=[];for(let[s,c]of Object.entries(i)){if(s.startsWith("ANTHROPIC_"))continue;let u=t[s]??"";u!==c&&o.push({envKey:s,dbValue:u,envValue:c})}for(let[s,c]of Object.entries(t))s in i||o.push({envKey:s,dbValue:c,envValue:""});return o}function N(e,n){let i=W(d(e),".env"),t=n??{},o=[],s=new Set;if(k(i)){let u=b(i,"utf-8");for(let f of u.split(`
|
|
3
3
|
`)){let r=f.trim();if(!r||r.startsWith("#")){o.push(f);continue}let p=r.startsWith("export ")?r.slice(7).trim():r,l=p.indexOf("=");if(l===-1){o.push(f);continue}let a=p.slice(0,l).trim(),g=r.startsWith("export ")?"export ":"";a in t&&(o.push(`${g}${a}=${t[a]}`),s.add(a))}}let c=0;for(let[u,f]of Object.entries(t)){if(s.has(u)){c++;continue}f&&f.length>0&&(o.push(`${u}=${f}`),c++)}return C(i,o.join(`
|
|
4
4
|
`)+`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as f}from"./chunk-
|
|
1
|
+
import{b as f}from"./chunk-B544JOZM.js";import{b as m}from"./chunk-Y5FFL6UO.js";import{c as h,h as v}from"./chunk-MRTJFYPR.js";v();var p=h("channels"),u=new Map,I=3e5,A=new Set(["telegram"]);function w(i){let e=i.trim().toLowerCase().match(/^(yes|y|是|允许|no|n|否|拒绝)\s+(\S+)$/);if(!e)return null;let[,c,l]=e,o=["yes","y","\u662F","\u5141\u8BB8"].includes(c);return{requestId:l,decision:o?"allow":"deny"}}function $(i){let n=m(i);return n?A.has(n.platform):!1}var T={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}"},P={low:"\u4F4E",medium:"\u4E2D",high:"\u9AD8"};function k(i){let n=["\u{1F512} \u9700\u8981\u5BA1\u6279",""];for(let e of i.steps){if(e.description.startsWith("Execute task without OS sandbox"))n.push("\u26A0\uFE0F \u65E0\u6C99\u7BB1\u6267\u884C \u2014 \u6587\u4EF6\u7CFB\u7EDF\u9694\u79BB\u672A\u542F\u7528");else{let o=e.description.indexOf(": "),r=o>0?e.description.slice(0,o):"Operation";if(n.push(`\u64CD\u4F5C: ${r}`),r==="Bash"&&o>0)try{let t=JSON.parse(e.description.slice(o+2));if(t.command){let s=String(t.command).trim();n.push(`\u547D\u4EE4: ${s.length>120?s.slice(0,117)+"...":s}`)}}catch{let t=e.description.slice(o+2,o+122);n.push(`\u8BE6\u60C5: ${t}${e.description.length>o+122?"...":""}`)}else if(o>0){let t=e.description.slice(o+2,o+122);n.push(`\u8BE6\u60C5: ${t}${e.description.length>o+122?"...":""}`)}}let c=T[e.riskLevel]??"\u{1F7E1}",l=P[e.riskLevel]??e.riskLevel;n.push(`\u98CE\u9669: ${c} ${l}`),n.push("")}return n.join(`
|
|
2
2
|
`).trimEnd()}async function C(i,n,e,c,l,o=I){let r=e,t=r.slice(0,8);u.set(t,{planId:e,taskId:c,channelId:i,chatId:n,requestId:r,timestamp:Date.now(),timeoutMs:o});let s=f(),d=$(i);if(d){let a=`${l}
|
|
3
3
|
|
|
4
4
|
`;await s.send({channelId:i,chatId:n,content:a,messageType:"approval",replyMarkup:{inlineKeyboard:[[{text:"\u2705 Allow",callbackData:`yes ${t}`},{text:"\u274C Deny",callbackData:`no ${t}`}]]}})}else{let a=[l,"",`Reply 'yes ${t}' or 'no ${t}'`].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-76IJC5WL.js";import{c as p}from"./chunk-7IFLU3CY.js";import{d as c}from"./chunk-N5FW6FUS.js";import{f as d,h as R}from"./chunk-WBAPIPST.js";import{c as g,h as y}from"./chunk-MRTJFYPR.js";R();import{readFileSync as P,existsSync as _}from"fs";import{resolve as O}from"path";import{homedir as E}from"os";import{parse as w}from"yaml";y();var T=g("config");function S(e){return e.replace(/\$\{(\w+)}/g,(t,r)=>process.env[r]??"")}function h(e){return e.startsWith("~/")?O(E(),e.slice(2)):e}function u(e){if(typeof e=="string")return S(e);if(Array.isArray(e))return e.map(u);if(e!==null&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=u(n);return t}return e}function m(e,t){let r={...e};for(let n of Object.keys(t)){let s=t[n],o=e[n];s!==null&&typeof s=="object"&&!Array.isArray(s)&&o!==null&&typeof o=="object"&&!Array.isArray(o)?r[n]=m(o,s):r[n]=s}return r}function v(e){return e.defaults.deniedReadPaths&&(e.defaults.deniedReadPaths=e.defaults.deniedReadPaths.map(h)),e.defaults.sensitivePaths&&!e.defaults.deniedReadPaths&&(T.warn("config.defaults.sensitivePaths is deprecated \u2014 use config.defaults.deniedReadPaths instead. Values have been migrated automatically."),e.defaults.deniedReadPaths=e.defaults.sensitivePaths.map(h)),e}function k(){let e={};for(let t of process.argv.slice(2)){let r=t.match(/^--([a-z-]+)=(.+)$/);r&&(e[r[1]]=r[2])}return e}function A(e){let t=process.env.ADAM_PORT;t&&(e.server.port=parseInt(t,10));let r=process.env.ANTHROPIC_MODEL;r&&(e.defaults.model=r);let n=process.env.ADAM_API_KEY;return n&&(e.server.apiKey=n),e}function C(e){let t=k();return t.port&&(e.server.port=parseInt(t.port,10)),t.host&&(e.server.host=t.host),t.timeout&&(e.defaults.timeout=parseInt(t.timeout,10)),t["api-key"]&&(e.server.apiKey=t["api-key"]),e}function D(e){let t=e??d,r={};if(_(t)){let f=P(t,"utf-8"),l=w(f);l&&(r=u(l))}let n=m(i,r),s=A(n),o=C(s);return v(o)}function I(){let e=JSON.parse(JSON.stringify(i)),t=A(e),r=C(t);return v(r)}function V(){let e={},t={ANTHROPIC_API_KEY:"anthropic.apiKey",ANTHROPIC_BASE_URL:"anthropic.baseUrl",ANTHROPIC_MODEL:"anthropic.model",ANTHROPIC_DEFAULT_OPUS_MODEL:"anthropic.defaultOpusModel",ANTHROPIC_DEFAULT_SONNET_MODEL:"anthropic.defaultSonnetModel",ANTHROPIC_DEFAULT_HAIKU_MODEL:"anthropic.defaultHaikuModel",ANTHROPIC_SMALL_FAST_MODEL:"anthropic.smallFastModel",ADAM_PORT:"server.port",ADAM_API_KEY:"server.apiKey"},r={};for(let[s,o]of Object.entries(t)){let a=process.env[s];if(a&&a.length>0)if(o==="server.port"){let f=parseInt(a,10);isNaN(f)||(e[o]=f)}else e[o]=a}let n=p();if(n)for(let[s,o]of Object.entries(n))s in t||s.startsWith("ANTHROPIC_")||s.startsWith("ADAM_")||(r[s]=o);return Object.keys(r).length>0&&(e["defaults.env"]=r),e}function j(){try{return c().defaults}catch{return i.defaults}}function W(){try{return c().chat??i.chat}catch{return i.chat}}export{D as a,I as b,V as c,j as d,W as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as p,g as N}from"./chunk-XTOOD44S.js";import{b as o,d as C}from"./chunk-7F4SZXI2.js";import{b as l,h as g}from"./chunk-WBAPIPST.js";import{c,e as A}from"./chunk-FCV2DPZQ.js";import*as h from"os";import*as y from"path";function u(e){return e.startsWith("~/")||e==="~"?y.join(h.homedir(),e.slice(1)):e}var _=c(()=>{"use strict";g()});function R(e){return w.includes(e)}function S(e){return v[e]}function E(){return w.map(e=>v[e])}function V(e,i=e!=="none"){return E().map(s=>T(s,e,i))}function T(e,i,s=i!=="none"){return process.platform==="darwin"?e.status==="runtime-enforced"&&(i!=="sandbox-exec"||!s)?{...e,availability:"runtime-unavailable",editable:!1,effectiveDisabledReason:"Current runtime has no macOS sandbox backend; Adam cannot enforce this capability on Roles."}:e.status==="runtime-enforced"?{...e,availability:"editable",editable:!0}:{...e,availability:e.status,editable:!1,effectiveDisabledReason:e.disabledReason}:{...e,availability:"platform-unsupported",editable:!1,effectiveDisabledReason:"macOS only"}}function z(e){if(!e?.length)return;for(let s of e)if(!R(s.id))throw new Error(`Unknown OS capability: ${s.id}`);let i=d(e);if(i?.length){for(let s of i){let t=S(s.id);if(t.status!=="runtime-enforced")throw new Error(`OS capability '${t.label}' is not editable in Role settings`);if(t.supportsTargets){if(!s.targets?.length)throw new Error(`OS capability '${t.label}' requires at least one target bundle id`);for(let n of s.targets)if(!D(n))throw new Error(`Invalid automation target bundle id: ${n}`)}else if(s.targets?.length)throw new Error(`OS capability '${t.label}' does not accept targets`)}return i}}function d(e){if(!e||e.length===0)return;let i=new Set,s=[];for(let t of e){if(!R(t.id))throw new Error(`Unknown OS capability: ${t.id}`);if(i.has(t.id))continue;i.add(t.id);let n=S(t.id),r={id:t.id};n.supportsTargets&&t.targets?.length&&(r.targets=[...new Set(t.targets.map(a=>a.trim()).filter(Boolean))]),s.push(r)}return s.length>0?s.sort((t,n)=>t.id.localeCompare(n.id)):void 0}function D(e){return x.test(e)}var w,v,x,O=c(()=>{"use strict";w=["location-services","calendars","contacts","files-and-folders","full-disk-access","homekit","media-and-apple-music","passkeys-access-for-web-browsers","photos","reminders","accessibility","app-management","automation","bluetooth","camera","developer-tools","focus","input-monitoring","local-network","microphone","motion-and-fitness","remote-desktop","screen-and-system-audio-recording","speech-recognition"],v={"location-services":{id:"location-services",label:"Location Services",description:"Access device location and region context.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},calendars:{id:"calendars",label:"Calendars",description:"Access Calendar data via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},contacts:{id:"contacts",label:"Contacts",description:"Access Contacts data via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"files-and-folders":{id:"files-and-folders",label:"Files & Folders",description:"Host-level file access categories managed outside Role sandboxing.",platform:"darwin",status:"host-only",disabledReason:"Role file boundaries are already controlled by visiblePaths and deniedReadPaths."},"full-disk-access":{id:"full-disk-access",label:"Full Disk Access",description:"Host-level macOS grant for protected storage locations.",platform:"darwin",status:"host-only",disabledReason:"This is a host app permission, not a Role-level control."},homekit:{id:"homekit",label:"HomeKit",description:"Access HomeKit devices and home automation data.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"media-and-apple-music":{id:"media-and-apple-music",label:"Media & Apple Music",description:"Access Apple Music and media library data.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"passkeys-access-for-web-browsers":{id:"passkeys-access-for-web-browsers",label:"Passkeys Access for Web Browsers",description:"Access passkeys for browser-integrated authentication.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},photos:{id:"photos",label:"Photos",description:"Access the Photos library via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},reminders:{id:"reminders",label:"Reminders",description:"Access Reminder data via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},accessibility:{id:"accessibility",label:"Accessibility",description:"Control desktop UI and accessibility automation surfaces.",platform:"darwin",status:"runtime-enforced"},"app-management":{id:"app-management",label:"App Management",description:"Manage or inspect other installed applications.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},automation:{id:"automation",label:"Automation",description:"Launch and control other apps via Apple Events.",platform:"darwin",status:"runtime-enforced",supportsTargets:!0},bluetooth:{id:"bluetooth",label:"Bluetooth",description:"Access nearby Bluetooth devices.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},camera:{id:"camera",label:"Camera",description:"Capture camera input.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"developer-tools":{id:"developer-tools",label:"Developer Tools",description:"Use system developer tooling privileges.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},focus:{id:"focus",label:"Focus",description:"Access Focus state and related automation.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"input-monitoring":{id:"input-monitoring",label:"Input Monitoring",description:"Observe keyboard and input device activity.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"local-network":{id:"local-network",label:"Local Network",description:"Discover and communicate with devices on the local network.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},microphone:{id:"microphone",label:"Microphone",description:"Capture microphone input.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"motion-and-fitness":{id:"motion-and-fitness",label:"Motion & Fitness",description:"Access motion and fitness sensor data.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"remote-desktop":{id:"remote-desktop",label:"Remote Desktop",description:"Control or observe remote desktop sessions.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"screen-and-system-audio-recording":{id:"screen-and-system-audio-recording",label:"Screen & System Audio Recording",description:"Capture the screen and system audio.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"speech-recognition":{id:"speech-recognition",label:"Speech Recognition",description:"Use system speech recognition services.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."}},x=/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/});var L={};A(L,{createRole:()=>I,deleteRole:()=>U,getRole:()=>J,getRoleByName:()=>P,listRoles:()=>B,updateRole:()=>k,validateAdditionalDirectories:()=>f});import{existsSync as M}from"fs";import{resolve as m}from"path";function f(e,i){for(let s of e){let t=typeof s=="string"?s:s.path;if(!t.startsWith("/")&&!t.startsWith("~/")&&t!=="~")throw new Error(`additionalDirectories must be absolute paths: '${t}' is not absolute`);let n=m(u(t));if(!n.startsWith("/"))throw new Error(`additionalDirectories must be absolute paths: '${t}' is not absolute`);for(let r of l){let a=m(u(r));if(n.startsWith(a))throw new Error(`additionalDirectories cannot include hardcoded denied path: '${t}' matches '${r}'`)}if(i?.length)for(let r of i){let a=m(u(r));if(n.startsWith(a)||a.startsWith(n))throw new Error(`additionalDirectories cannot overlap with deniedReadPaths: '${t}' conflicts with '${r}'`)}if(!M(n))throw new Error(`additionalDirectories path does not exist: '${t}'`)}}function b(e){return{id:e.id,name:e.name,cagPrompt:e.cag_prompt,learnedRules:e.learned_rules?JSON.parse(e.learned_rules):[],memoryStreamId:e.memory_stream_id,status:e.status,performanceScore:e.performance_score??void 0,preferences:e.preferences?JSON.parse(e.preferences):{},createdAt:e.created_at,updatedAt:e.updated_at??void 0,allowedTools:e.allowed_tools?JSON.parse(e.allowed_tools):void 0,disallowedTools:e.disallowed_tools?JSON.parse(e.disallowed_tools):void 0,evaluationCriteria:e.evaluation_criteria?JSON.parse(e.evaluation_criteria):void 0,executionMode:e.execution_mode??void 0,model:e.model??void 0,maxBudgetUsd:e.max_budget_usd??void 0,approvalRequired:e.approval_required?JSON.parse(e.approval_required):void 0,source:e.source??void 0,additionalDirectories:(()=>{if(e.additional_directories!==null)try{let i=JSON.parse(e.additional_directories);return Array.isArray(i)?i.map(s=>typeof s=="string"?{path:s}:s):void 0}catch{return}})(),allowedChannels:e.allowed_channels?JSON.parse(e.allowed_channels):void 0,mcpServers:e.mcp_servers?JSON.parse(e.mcp_servers):void 0,inheritUserSettings:e.inherit_user_settings===1?!0:void 0,permissionMode:e.permission_mode??void 0,allowedBashPatterns:e.allowed_bash_patterns?JSON.parse(e.allowed_bash_patterns):void 0,deniedBashPatterns:e.denied_bash_patterns?JSON.parse(e.denied_bash_patterns):void 0,envVars:e.env_vars?JSON.parse(e.env_vars):void 0,osCapabilities:e.os_capabilities?d(JSON.parse(e.os_capabilities)):void 0,presetId:e.preset_id??void 0}}function I(e){let i=p("defaults.deniedReadPaths")??[...l];e.additionalDirectories&&f(e.additionalDirectories,i),o().prepare(`
|
|
1
|
+
import{a as p,g as N}from"./chunk-B44X7JAJ.js";import{b as o,d as C}from"./chunk-AQO6IIHV.js";import{b as l,h as g}from"./chunk-WBAPIPST.js";import{c,e as A}from"./chunk-FCV2DPZQ.js";import*as h from"os";import*as y from"path";function u(e){return e.startsWith("~/")||e==="~"?y.join(h.homedir(),e.slice(1)):e}var _=c(()=>{"use strict";g()});function R(e){return w.includes(e)}function S(e){return v[e]}function E(){return w.map(e=>v[e])}function V(e,i=e!=="none"){return E().map(s=>T(s,e,i))}function T(e,i,s=i!=="none"){return process.platform==="darwin"?e.status==="runtime-enforced"&&(i!=="sandbox-exec"||!s)?{...e,availability:"runtime-unavailable",editable:!1,effectiveDisabledReason:"Current runtime has no macOS sandbox backend; Adam cannot enforce this capability on Roles."}:e.status==="runtime-enforced"?{...e,availability:"editable",editable:!0}:{...e,availability:e.status,editable:!1,effectiveDisabledReason:e.disabledReason}:{...e,availability:"platform-unsupported",editable:!1,effectiveDisabledReason:"macOS only"}}function z(e){if(!e?.length)return;for(let s of e)if(!R(s.id))throw new Error(`Unknown OS capability: ${s.id}`);let i=d(e);if(i?.length){for(let s of i){let t=S(s.id);if(t.status!=="runtime-enforced")throw new Error(`OS capability '${t.label}' is not editable in Role settings`);if(t.supportsTargets){if(!s.targets?.length)throw new Error(`OS capability '${t.label}' requires at least one target bundle id`);for(let n of s.targets)if(!D(n))throw new Error(`Invalid automation target bundle id: ${n}`)}else if(s.targets?.length)throw new Error(`OS capability '${t.label}' does not accept targets`)}return i}}function d(e){if(!e||e.length===0)return;let i=new Set,s=[];for(let t of e){if(!R(t.id))throw new Error(`Unknown OS capability: ${t.id}`);if(i.has(t.id))continue;i.add(t.id);let n=S(t.id),r={id:t.id};n.supportsTargets&&t.targets?.length&&(r.targets=[...new Set(t.targets.map(a=>a.trim()).filter(Boolean))]),s.push(r)}return s.length>0?s.sort((t,n)=>t.id.localeCompare(n.id)):void 0}function D(e){return x.test(e)}var w,v,x,O=c(()=>{"use strict";w=["location-services","calendars","contacts","files-and-folders","full-disk-access","homekit","media-and-apple-music","passkeys-access-for-web-browsers","photos","reminders","accessibility","app-management","automation","bluetooth","camera","developer-tools","focus","input-monitoring","local-network","microphone","motion-and-fitness","remote-desktop","screen-and-system-audio-recording","speech-recognition"],v={"location-services":{id:"location-services",label:"Location Services",description:"Access device location and region context.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},calendars:{id:"calendars",label:"Calendars",description:"Access Calendar data via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},contacts:{id:"contacts",label:"Contacts",description:"Access Contacts data via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"files-and-folders":{id:"files-and-folders",label:"Files & Folders",description:"Host-level file access categories managed outside Role sandboxing.",platform:"darwin",status:"host-only",disabledReason:"Role file boundaries are already controlled by visiblePaths and deniedReadPaths."},"full-disk-access":{id:"full-disk-access",label:"Full Disk Access",description:"Host-level macOS grant for protected storage locations.",platform:"darwin",status:"host-only",disabledReason:"This is a host app permission, not a Role-level control."},homekit:{id:"homekit",label:"HomeKit",description:"Access HomeKit devices and home automation data.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"media-and-apple-music":{id:"media-and-apple-music",label:"Media & Apple Music",description:"Access Apple Music and media library data.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"passkeys-access-for-web-browsers":{id:"passkeys-access-for-web-browsers",label:"Passkeys Access for Web Browsers",description:"Access passkeys for browser-integrated authentication.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},photos:{id:"photos",label:"Photos",description:"Access the Photos library via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},reminders:{id:"reminders",label:"Reminders",description:"Access Reminder data via macOS privacy controls.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},accessibility:{id:"accessibility",label:"Accessibility",description:"Control desktop UI and accessibility automation surfaces.",platform:"darwin",status:"runtime-enforced"},"app-management":{id:"app-management",label:"App Management",description:"Manage or inspect other installed applications.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},automation:{id:"automation",label:"Automation",description:"Launch and control other apps via Apple Events.",platform:"darwin",status:"runtime-enforced",supportsTargets:!0},bluetooth:{id:"bluetooth",label:"Bluetooth",description:"Access nearby Bluetooth devices.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},camera:{id:"camera",label:"Camera",description:"Capture camera input.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"developer-tools":{id:"developer-tools",label:"Developer Tools",description:"Use system developer tooling privileges.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},focus:{id:"focus",label:"Focus",description:"Access Focus state and related automation.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"input-monitoring":{id:"input-monitoring",label:"Input Monitoring",description:"Observe keyboard and input device activity.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"local-network":{id:"local-network",label:"Local Network",description:"Discover and communicate with devices on the local network.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},microphone:{id:"microphone",label:"Microphone",description:"Capture microphone input.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"motion-and-fitness":{id:"motion-and-fitness",label:"Motion & Fitness",description:"Access motion and fitness sensor data.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"remote-desktop":{id:"remote-desktop",label:"Remote Desktop",description:"Control or observe remote desktop sessions.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"screen-and-system-audio-recording":{id:"screen-and-system-audio-recording",label:"Screen & System Audio Recording",description:"Capture the screen and system audio.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."},"speech-recognition":{id:"speech-recognition",label:"Speech Recognition",description:"Use system speech recognition services.",platform:"darwin",status:"registered-unwired",disabledReason:"Not wired into Adam runtime yet."}},x=/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/});var L={};A(L,{createRole:()=>I,deleteRole:()=>U,getRole:()=>J,getRoleByName:()=>P,listRoles:()=>B,updateRole:()=>k,validateAdditionalDirectories:()=>f});import{existsSync as M}from"fs";import{resolve as m}from"path";function f(e,i){for(let s of e){let t=typeof s=="string"?s:s.path;if(!t.startsWith("/")&&!t.startsWith("~/")&&t!=="~")throw new Error(`additionalDirectories must be absolute paths: '${t}' is not absolute`);let n=m(u(t));if(!n.startsWith("/"))throw new Error(`additionalDirectories must be absolute paths: '${t}' is not absolute`);for(let r of l){let a=m(u(r));if(n.startsWith(a))throw new Error(`additionalDirectories cannot include hardcoded denied path: '${t}' matches '${r}'`)}if(i?.length)for(let r of i){let a=m(u(r));if(n.startsWith(a)||a.startsWith(n))throw new Error(`additionalDirectories cannot overlap with deniedReadPaths: '${t}' conflicts with '${r}'`)}if(!M(n))throw new Error(`additionalDirectories path does not exist: '${t}'`)}}function b(e){return{id:e.id,name:e.name,cagPrompt:e.cag_prompt,learnedRules:e.learned_rules?JSON.parse(e.learned_rules):[],memoryStreamId:e.memory_stream_id,status:e.status,performanceScore:e.performance_score??void 0,preferences:e.preferences?JSON.parse(e.preferences):{},createdAt:e.created_at,updatedAt:e.updated_at??void 0,allowedTools:e.allowed_tools?JSON.parse(e.allowed_tools):void 0,disallowedTools:e.disallowed_tools?JSON.parse(e.disallowed_tools):void 0,evaluationCriteria:e.evaluation_criteria?JSON.parse(e.evaluation_criteria):void 0,executionMode:e.execution_mode??void 0,model:e.model??void 0,maxBudgetUsd:e.max_budget_usd??void 0,approvalRequired:e.approval_required?JSON.parse(e.approval_required):void 0,source:e.source??void 0,additionalDirectories:(()=>{if(e.additional_directories!==null)try{let i=JSON.parse(e.additional_directories);return Array.isArray(i)?i.map(s=>typeof s=="string"?{path:s}:s):void 0}catch{return}})(),allowedChannels:e.allowed_channels?JSON.parse(e.allowed_channels):void 0,mcpServers:e.mcp_servers?JSON.parse(e.mcp_servers):void 0,inheritUserSettings:e.inherit_user_settings===1?!0:void 0,permissionMode:e.permission_mode??void 0,allowedBashPatterns:e.allowed_bash_patterns?JSON.parse(e.allowed_bash_patterns):void 0,deniedBashPatterns:e.denied_bash_patterns?JSON.parse(e.denied_bash_patterns):void 0,envVars:e.env_vars?JSON.parse(e.env_vars):void 0,osCapabilities:e.os_capabilities?d(JSON.parse(e.os_capabilities)):void 0,presetId:e.preset_id??void 0}}function I(e){let i=p("defaults.deniedReadPaths")??[...l];e.additionalDirectories&&f(e.additionalDirectories,i),o().prepare(`
|
|
2
2
|
INSERT INTO roles (id, name, cag_prompt, learned_rules, memory_stream_id, status,
|
|
3
3
|
performance_score, preferences, created_at, updated_at,
|
|
4
4
|
allowed_tools, disallowed_tools, evaluation_criteria, execution_mode, model,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as l}from"./chunk-SWP2JC54.js";import{d as f,k as p,m as g,n as M,o as h,q as b}from"./chunk-X5V4VMET.js";async function S(t,o,i={}){let s=i.topK??10,c=i.hybridConfig??h,n;try{n=await l(o)}catch{}let a=n??new Float32Array(384),m=b(t,a,o,s*2,c,{excludeSuperseded:!0}),d=t?M(t):p,y=m.map(({node:e,combinedRelevance:u})=>{let C=Math.min(.3,(e.retrievedCount??0)*.05),x=g(e.createdAt,u,e.importance,d)+C;return{...e,score:x}});y.sort((e,u)=>u.score-e.score);let r=y.slice(0,s);for(let e of r)f(e.id);return r}async function R(t,o,i=5,s=2e3){try{let{estimateTokens:c}=await import("./token-estimator-HMPVGDCN.js"),n=await S(o,t,{topK:i});if(n.length===0)return"";let a=[],m=0,d=c(`[Memory Context \u2014 retrieved from prior interactions]
|
|
2
|
+
|
|
3
|
+
[User Request]
|
|
4
|
+
`);for(let r of n){let e=c(`- [${r.tier??"episodic"}] ${r.content}
|
|
5
|
+
`);if(m+e+d>s)break;a.push(r),m+=e}return a.length===0?"":`[Memory Context \u2014 retrieved from prior interactions]
|
|
6
|
+
${a.map(r=>`- [${r.tier??"episodic"}] ${r.content}`).join(`
|
|
7
|
+
`)}
|
|
8
|
+
|
|
9
|
+
[User Request]
|
|
10
|
+
`}catch{return""}}async function k(t,o,i,s={}){return(await S(t,o,s)).filter(n=>i.includes(n.tier??"episodic"))}export{S as a,R as b,k as c};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import{c as u}from"./chunk-6JBSBSCL.js";import{b as o,d as a}from"./chunk-AQO6IIHV.js";a();import{v4 as c}from"uuid";function g(t){o().prepare(`
|
|
2
|
+
INSERT INTO evolution_audit (id, timestamp, old_rules, new_rules, diff, trigger_task_id, role_id, source, trace_id)
|
|
3
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
4
|
+
`).run(c(),t.timestamp,t.oldRules,t.newRules,t.diff,t.triggerTaskId??null,t.roleId??null,t.source??"reflection",t.traceId??u()??null)}function R(t=100,e=0){return o().prepare(`
|
|
5
|
+
SELECT id, timestamp, old_rules as oldRules, new_rules as newRules, diff,
|
|
6
|
+
trigger_task_id as triggerTaskId, role_id as roleId, source,
|
|
7
|
+
trace_id as traceId
|
|
8
|
+
FROM evolution_audit
|
|
9
|
+
ORDER BY timestamp DESC
|
|
10
|
+
LIMIT ? OFFSET ?
|
|
11
|
+
`).all(t,e)}function _(t,e=100,i=0){return o().prepare(`
|
|
12
|
+
SELECT id, timestamp, old_rules as oldRules, new_rules as newRules, diff,
|
|
13
|
+
trigger_task_id as triggerTaskId, role_id as roleId, source,
|
|
14
|
+
trace_id as traceId
|
|
15
|
+
FROM evolution_audit
|
|
16
|
+
WHERE role_id = ?
|
|
17
|
+
ORDER BY timestamp DESC
|
|
18
|
+
LIMIT ? OFFSET ?
|
|
19
|
+
`).all(t,e,i)}function m(t){return o().prepare(`
|
|
20
|
+
SELECT id, timestamp, old_rules as oldRules, new_rules as newRules, diff,
|
|
21
|
+
trigger_task_id as triggerTaskId, role_id as roleId, source,
|
|
22
|
+
trace_id as traceId
|
|
23
|
+
FROM evolution_audit
|
|
24
|
+
WHERE role_id = ?
|
|
25
|
+
ORDER BY timestamp DESC
|
|
26
|
+
LIMIT 1
|
|
27
|
+
`).get(t)}function v(t,e){let i=t.split(`
|
|
28
|
+
`).filter(Boolean),r=e.split(`
|
|
29
|
+
`).filter(Boolean),s=r.filter(d=>!i.includes(d)),l=i.filter(d=>!r.includes(d)),n=[];return s.length>0&&n.push(`+ ${s.join(`
|
|
30
|
+
+ `)}`),l.length>0&&n.push(`- ${l.join(`
|
|
31
|
+
- `)}`),n.join(`
|
|
32
|
+
`)||"(no changes)"}export{g as a,R as b,_ as c,m as d,v as e};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{l as M,r as D}from"./chunk-U2LBBBWO.js";import{b as u,d as O}from"./chunk-AQO6IIHV.js";O();D();function E(e){return{id:e.id,roleId:e.role_id,type:e.type,content:e.content,embedding:e.embedding?new Float32Array(e.embedding.buffer,e.embedding.byteOffset,e.embedding.byteLength/4):void 0,keywords:e.keywords?JSON.parse(e.keywords):[],importance:e.importance,sourceType:e.source_type,sourceTaskId:e.source_task_id??void 0,evidence:e.evidence?JSON.parse(e.evidence):void 0,createdAt:e.created_at,lastAccessed:e.last_accessed,retrievedCount:e.retrieved_count,tier:e.tier,supersededBy:e.superseded_by??void 0}}function _(e){return Buffer.from(e.buffer,e.byteOffset,e.byteLength)}function I(e){u().prepare(`
|
|
2
|
+
INSERT INTO memories (id, role_id, type, content, embedding, keywords,
|
|
3
|
+
importance, source_type, source_task_id, evidence,
|
|
4
|
+
created_at, last_accessed, retrieved_count, tier, superseded_by)
|
|
5
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
6
|
+
`).run(e.id,e.roleId,e.type,e.content,e.embedding?_(e.embedding):null,JSON.stringify(e.keywords),e.importance,e.sourceType,e.sourceTaskId??null,e.evidence?JSON.stringify(e.evidence):null,e.createdAt,e.lastAccessed,e.retrievedCount,e.tier,e.supersededBy??null)}function U(e){let o=u().prepare("SELECT * FROM memories WHERE id = ?").get(e);return o?E(o):void 0}function Y(e,r){let o=u(),n=[],t=[];return r.content!==void 0&&(n.push("content = ?"),t.push(r.content)),r.embedding!==void 0&&(n.push("embedding = ?"),t.push(_(r.embedding))),r.keywords!==void 0&&(n.push("keywords = ?"),t.push(JSON.stringify(r.keywords))),r.importance!==void 0&&(n.push("importance = ?"),t.push(r.importance)),r.type!==void 0&&(n.push("type = ?"),t.push(r.type)),n.length===0?!0:(n.push("last_accessed = ?"),t.push(Date.now()),t.push(e),o.prepare(`UPDATE memories SET ${n.join(", ")} WHERE id = ?`).run(...t).changes>0)}function J(e){u().prepare("UPDATE memories SET retrieved_count = retrieved_count + 1, last_accessed = ? WHERE id = ?").run(Date.now(),e)}function j(e,r){let n=u().prepare("UPDATE memories SET superseded_by = ? WHERE id = ?"),t=0;for(let c of e){let s=n.run(r,c);t+=s.changes}return t}function q(e){return u().prepare("SELECT COUNT(*) as count FROM memories WHERE role_id = ?").get(e).count}function V(e,r=100,o=0){return u().prepare("SELECT * FROM memories WHERE role_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?").all(e,r,o).map(E)}function v(e,r){let o=0,n=0,t=0;for(let s=0;s<e.length;s++)o+=e[s]*r[s],n+=e[s]*e[s],t+=r[s]*r[s];let c=Math.sqrt(n)*Math.sqrt(t);return c===0?0:o/c}function C(e,r,o,n){let t=u(),c=["embedding IS NOT NULL"],s=[];e&&(c.push("role_id = ?"),s.push(e)),n?.excludeSuperseded&&c.push("superseded_by IS NULL"),n?.tiers&&n.tiers.length>0&&(c.push(`tier IN (${n.tiers.map(()=>"?").join(",")})`),s.push(...n.tiers));let b=`SELECT * FROM memories WHERE ${c.join(" AND ")}
|
|
7
|
+
ORDER BY importance DESC, created_at DESC
|
|
8
|
+
LIMIT ?`;return s.push(Math.min(o*10,1e3)),t.prepare(b).all(...s).map(d=>{let a=new Float32Array(d.embedding.buffer,d.embedding.byteOffset,d.embedding.byteLength/4),m=v(r,a),g=Math.min(1,Math.max(0,m));return{row:d,cosine:g}}).sort((d,a)=>a.cosine-d.cosine).slice(0,o).map(d=>({node:E(d.row),cosine:d.cosine}))}function x(e){let r=e.split(/\s+/).filter(Boolean);return r.length===0?'""':r.map(n=>`"${n.replace(/"/g,'""')}"`).join(" OR ")}function W(e,r,o){let n=u(),t=x(r);return(e?n.prepare(`
|
|
9
|
+
SELECT m.*, rank AS bm25_score FROM memories m
|
|
10
|
+
JOIN memories_fts fts ON m.rowid = fts.rowid
|
|
11
|
+
WHERE memories_fts MATCH ? AND m.role_id = ?
|
|
12
|
+
ORDER BY rank
|
|
13
|
+
LIMIT ?
|
|
14
|
+
`).all(t,e,o):n.prepare(`
|
|
15
|
+
SELECT m.*, rank AS bm25_score FROM memories m
|
|
16
|
+
JOIN memories_fts fts ON m.rowid = fts.rowid
|
|
17
|
+
WHERE memories_fts MATCH ?
|
|
18
|
+
ORDER BY rank
|
|
19
|
+
LIMIT ?
|
|
20
|
+
`).all(t,o)).map(s=>({node:E(s),bm25:-s.bm25_score}))}function $(e){u().prepare("DELETE FROM memories WHERE id = ?").run(e)}var S={recency:.5,relevance:3,importance:2},L=.9;function F(e){let o=(Date.now()-e)/(1e3*60*60*24);return Math.min(1,Math.max(0,Math.pow(L,o)))}function z(e,r,o,n=S){let t=F(e),c=Math.min(1,Math.max(0,r)),s=o/5;return n.recency*t+n.relevance*c+n.importance*s}function G(e){return M(e)?.preferences?.scoringWeights??S}var H={vectorWeight:.6,bm25Weight:.4};function P(e,r=1e4,o=90){let n=u(),t=0,c=Date.now()-10080*60*1e3,s=n.prepare("DELETE FROM memories WHERE role_id = ? AND superseded_by IS NOT NULL AND created_at < ?").run(e,c);t+=s.changes;let b=Date.now()-720*60*60*1e3,l=n.prepare("DELETE FROM memories WHERE role_id = ? AND retrieved_count = 0 AND importance <= 2 AND created_at < ?").run(e,b);t+=l.changes;let f=Date.now()-o*24*60*60*1e3,d=n.prepare("DELETE FROM memories WHERE role_id = ? AND importance < 4 AND created_at < ?").run(e,f);t+=d.changes;let a=n.prepare("SELECT COUNT(*) as cnt FROM memories WHERE role_id = ?").get(e);if(a.cnt>r){let m=a.cnt-r;n.prepare(`
|
|
21
|
+
DELETE FROM memories WHERE id IN (
|
|
22
|
+
SELECT id FROM memories WHERE role_id = ? AND tier != 'semantic'
|
|
23
|
+
ORDER BY importance ASC, retrieved_count ASC, created_at ASC
|
|
24
|
+
LIMIT ?
|
|
25
|
+
)
|
|
26
|
+
`).run(e,m),t+=m}return t}function Q(e,r,o,n,t=H,c){let s=C(e,r,n*2,c),b=W(e,o,n*2),l=new Map;for(let{node:i,cosine:p}of s)l.set(i.id,{node:i,cosine:p,bm25:0});for(let{node:i,bm25:p}of b){let y=l.get(i.id);y?y.bm25=p:l.set(i.id,{node:i,cosine:0,bm25:p})}let f=c?.tiers&&c.tiers.length>0?new Set(c.tiers):null,d=c?.excludeSuperseded===!0,a=[];for(let i of l.values())f&&!f.has(i.node.tier??"episodic")||d&&i.node.supersededBy||a.push(i);let m=1/0,g=-1/0,R=0;for(let{bm25:i}of a)i!==0&&(R++,i<m&&(m=i),i>g&&(g=i));let h=g-m,N=i=>i===0||R===0?0:h<=0?1:(i-m)/h;return a.map(({node:i,cosine:p,bm25:y})=>{let T=N(y),A=t.vectorWeight*p+t.bm25Weight*T;return{node:i,cosine:p,bm25:y,combinedRelevance:A}}).sort((i,p)=>p.combinedRelevance-i.combinedRelevance).slice(0,n)}export{I as a,U as b,Y as c,J as d,j as e,q as f,V as g,C as h,W as i,$ as j,S as k,F as l,z as m,G as n,H as o,P as p,Q as q};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as s,d as i}from"./chunk-
|
|
1
|
+
import{b as s,d as i}from"./chunk-AQO6IIHV.js";i();function l(e){return{id:e.id,name:e.name,platform:e.platform,enabled:e.enabled===1,status:e.status,config:JSON.parse(e.config),linkedRoleId:e.linked_role_id??void 0,allowedChatIds:e.allowed_chat_ids?JSON.parse(e.allowed_chat_ids):void 0,createdAt:e.created_at,updatedAt:e.updated_at??void 0,lastMessageAt:e.last_message_at??void 0,messageCount:e.message_count}}function o(e){s().prepare(`
|
|
2
2
|
INSERT INTO channels (id, name, platform, enabled, status, config, linked_role_id,
|
|
3
3
|
allowed_chat_ids, created_at, updated_at, last_message_at, message_count)
|
|
4
4
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l}from"./chunk-SWP2JC54.js";import{a as h,b as u,c,d as m,e as v,f as x}from"./chunk-
|
|
1
|
+
import{a as l}from"./chunk-SWP2JC54.js";import{a as h,b as u,c,d as m,e as v,f as x}from"./chunk-FUWPDXXG.js";import{a as C}from"./chunk-X5V4VMET.js";import{b as S,d as y}from"./chunk-ZQ4PNKMQ.js";import{a as i}from"./chunk-L7JP7DUO.js";import{e as p}from"./chunk-SDT3PBHF.js";import{v4 as D}from"uuid";import{v4 as I}from"uuid";function _(e){if(e.length<20)return null;let t=e.trim();return t.length>300?{content:`User request: ${t.slice(0,280)}...`,importance:3,type:"thought"}:{content:`User request: ${t}`,importance:3,type:"thought"}}function b(e){if(e.length<20)return null;let t=e.trim();return t.length>400?{content:`Assistant response: ${t.slice(0,370)}...`,importance:2,type:"event"}:{content:`Assistant response: ${t}`,importance:2,type:"event"}}function N(e){let t=S(e,200,0),s=[];for(let o of t){let r=o.role==="user"?_(o.content):b(o.content);r&&s.push(r)}return{facts:s}}function $(e){let t=e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(s=>s.length>2);return[...new Set(t)].slice(0,20)}async function A(e,t){let{facts:s}=N(e),o=0;for(let r of s){let f=r.content.slice(0,500),g;try{g=await l(f)}catch{}let M=$(f),T={id:I(),roleId:t,type:r.type,content:f,embedding:g,keywords:M,importance:r.importance,sourceType:"session_archive",createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};C(T),o++}return o}var n=new Map,a;function w(e){return`${e.type}:${e.channelId??""}:${e.chatId??""}`}function F(){n.clear();let e=m("active",1e3);for(let t of e)n.set(t.id,t)}function Q(e,t){let s=Date.now(),o={id:D(),status:"active",source:e,createdAt:s,lastActiveAt:s,messageCount:0};return h(o),n.set(o.id,o),i.emit({type:"session_created",session:o}),o}function V(e){for(let s of n.values())if(w(s.source)===w(e))return s;let t=v(e);return t&&n.set(t.id,t),t}function B(e){let t=n.get(e);return t||u(e)}function E(e){let t=Date.now();c(e,{status:"archived",archivedAt:t}),p().archiveExtractMemory&&u(e)&&A(e,"role-chat-manager").catch(()=>{}),n.delete(e),i.emit({type:"session_archived",sessionId:e})}function W(e){c(e,{status:"active",archivedAt:void 0});let t=u(e);return t&&(n.set(t.id,t),i.emit({type:"session_restored",session:t})),t}function X(e){y(e),x(e),n.delete(e),i.emit({type:"session_deleted",sessionId:e})}function Y(e){let t=Date.now();c(e,{lastActiveAt:t});let s=n.get(e);s&&(s.lastActiveAt=t)}function Z(e){let t=B(e);if(t){let s=t.messageCount+1;c(e,{messageCount:s});let o=n.get(e);o&&(o.messageCount=s)}}function ee(e){return m(e)}function P(){let t=p().sessionTimeoutMinutes*60*1e3,s=Date.now();for(let o of n.values())if(s-o.lastActiveAt>t)try{E(o.id)}catch{}}function R(e=6e4){d(),a=setInterval(P,e)}function d(){a&&(clearInterval(a),a=void 0)}function te(){return a}function se(){F(),R()}function oe(){d(),n.clear()}function ne(){d(),n.clear()}export{F as a,Q as b,V as c,B as d,E as e,W as f,X as g,Y as h,Z as i,ee as j,R as k,d as l,te as m,se as n,oe as o,ne as p};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{f as S}from"./chunk-
|
|
1
|
+
import{f as S}from"./chunk-NPIXYK5G.js";import{b as y}from"./chunk-SC2DDRYB.js";import{b as v}from"./chunk-FUWPDXXG.js";import{e as m}from"./chunk-ZQ4PNKMQ.js";import{b as g}from"./chunk-R2WB5BKF.js";import{b as C}from"./chunk-B544JOZM.js";import{b as R}from"./chunk-Y5FFL6UO.js";import{a as h}from"./chunk-L7JP7DUO.js";import{a as k,b as P,c as o,d as f,e as T,f as x,g as E}from"./chunk-O7XQSONJ.js";import{c as w,h as _}from"./chunk-MRTJFYPR.js";_();import{v4 as M}from"uuid";var l=w("admin"),I=new Map,u=null,p=null,c=null,D=class{constructor(){h.on("task_status_change",e=>{(e.newStatus==="completed"||e.newStatus==="failed")&&this.handleTaskStatusChange(e.taskId,e.newStatus).catch(n=>{l.error({taskId:e.taskId,error:n},"Delivery processing failed")})}),h.on("plan_approval_request",e=>{this.handlePlanApprovalRequest(e.taskId,e.planId,e.plan).catch(n=>{l.error({taskId:e.taskId,error:n},"Delivery processing failed (plan_approval)")})}),l.info("DeliveryEngine initialized")}async handlePlanApprovalRequest(e,n,r){let t=g(e),i=this.getSourceChannelForTask(e);if(i){let d=y(r),{sendApprovalToChannel:b}=await import("./approval-handler-J6RUTICJ.js");await b(i.channelId,i.chatId,n,e,d)}let a=y(r)+`
|
|
2
2
|
|
|
3
3
|
Task: ${e}`;await this.matchAndDeliver("plan_approval_request",{templateId:t?.templateId,roleId:t?.roleId,prompt:t?.prompt,taskStatus:"pending"},a,e)}getSourceChannelForTask(e){try{let n=m(e);if(!n)return null;let r=v(n.sessionId);return!r||r.source.type!=="channel"||!r.source.channelId||!r.source.chatId?null:{channelId:r.source.channelId,chatId:r.source.chatId}}catch{return null}}async handleTaskStatusChange(e,n){let r=g(e);if(!r)return;let t={templateId:r.templateId,roleId:r.roleId,prompt:r.prompt,taskStatus:n},i=n==="completed"?"task_complete":"task_error",a=r.result??r.error??"";await this.matchAndDeliver(i,t,a,e)}async matchAndDeliver(e,n,r,t){let i=S(e,n);if(i.length!==0){l.debug({eventType:e,ruleCount:i.length,taskId:t},"Matched delivery rules");for(let a of i){if(!this.checkRateLimit(a)){l.warn({ruleId:a.id,maxPerMinute:a.maxPerMinute},"Delivery rate limit exceeded, skipping");continue}if(a.skipOriginChannel&&a.target.type==="channel"&&t&&this.isOriginChannel(t,a.target))continue;let d={id:M(),ruleId:a.id,taskId:t,status:"pending",target:a.target,content:r,attempts:0,createdAt:Date.now(),expiresAt:Date.now()+k,source:"rule"};P(d),await this.attemptDelivery(d,a)}}}async attemptDeliveryPublic(e,n){return this.attemptDelivery(e,n)}async attemptDelivery(e,n){let r=C();try{if(e.target.type==="channel"){let t=e.target.chatId;!t&&e.target.channelId&&(t=R(e.target.channelId)?.config?.userId);let i=await r.send({taskId:e.taskId,channelId:e.target.channelId,chatId:t,content:e.content,messageType:"deliver"});i.success?(f(e.id),l.info({entryId:e.id,ruleId:n.id,targetType:"channel"},"Delivery successful")):o(e.id,"failed",i.error??"Gateway returned failure")}else if(e.target.type==="webhook"){let t=await r.send({taskId:e.taskId,webhookUrl:e.target.webhookUrl,content:e.content,messageType:"deliver"});t.success?(f(e.id),l.info({entryId:e.id,ruleId:n.id,targetType:"webhook"},"Webhook delivery successful")):o(e.id,"failed",t.error??"Gateway returned failure")}}catch(t){let i=t instanceof Error?t.message:String(t);o(e.id,"failed",i),l.warn({entryId:e.id,error:i},"Delivery attempt failed")}}checkRateLimit(e){let n=Date.now(),r=6e4,t=I.get(e.id);t||(t=[],I.set(e.id,t));let i=n-r;for(;t.length>0&&t[0]<i;)t.shift();return t.length>=e.maxPerMinute?!1:(t.push(n),!0)}isOriginChannel(e,n){try{if(n.type!=="channel"||!n.channelId)return!1;let r=m(e);if(!r)return!1;let t=v(r.sessionId);return t?t.source.type==="channel"&&t.source.channelId===n.channelId&&(!n.chatId||t.source.chatId===n.chatId):!1}catch{return!1}}async retryPending(){let e=T("rule",50),n=x("rule",50),r=[...e,...n];if(r.length!==0){l.debug({count:r.length},"Retrying pending/failed deliveries");for(let t of r){if(t.attempts>=3){o(t.id,"failed","Max retries (3) exceeded");continue}let i={id:t.ruleId??"retry-synthetic",eventType:"*",matchCriteria:{},target:t.target,maxPerMinute:5,skipOriginChannel:!0,enabled:!0,createdAt:0};await this.attemptDelivery(t,i)}}}};function $(){return c}function H(){c||(c=new D,u=setInterval(()=>{c?.retryPending().catch(s=>{l.error({error:s},"Delivery retry scan failed")})},6e4),p=setInterval(()=>{try{let s=E();s>0&&l.info({cleaned:s},"Expired delivery log entries cleaned up")}catch(s){l.error({error:s},"Delivery cleanup failed")}},36e5),l.info("DeliveryEngine started with retry (60s) and cleanup (1h) timers"))}function J(){u&&(clearInterval(u),u=null),p&&(clearInterval(p),p=null),c=null,I.clear(),l.info("DeliveryEngine stopped")}export{D as a,$ as b,H as c,J as d};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{c as d}from"./chunk-6JBSBSCL.js";import{b as n,d as o}from"./chunk-AQO6IIHV.js";o();function a(e){return{id:e.id,sessionId:e.session_id,role:e.role,content:e.content,source:{type:e.source_type},taskId:e.task_id??void 0,channelMessageId:e.channel_message_id??void 0,metadata:e.metadata?JSON.parse(e.metadata):void 0,createdAt:e.created_at,traceId:e.trace_id??void 0}}function g(e){n().prepare(`
|
|
2
|
+
INSERT INTO chat_messages (id, session_id, role, content, source_type, task_id,
|
|
3
|
+
channel_message_id, metadata, created_at, trace_id)
|
|
4
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
5
|
+
`).run(e.id,e.sessionId,e.role,e.content,e.source.type,e.taskId??null,e.channelMessageId??null,e.metadata?JSON.stringify(e.metadata):null,e.createdAt,e.traceId??d()??null)}function p(e,s=100,t=0){return n().prepare("SELECT * FROM chat_messages WHERE session_id = ? ORDER BY created_at ASC LIMIT ? OFFSET ?").all(e,s,t).map(a)}function E(e,s){return n().prepare("SELECT * FROM chat_messages WHERE session_id = ? ORDER BY created_at DESC LIMIT ?").all(e,s).reverse().map(a)}function _(e){n().prepare("DELETE FROM chat_messages WHERE session_id = ?").run(e)}function M(e){let t=n().prepare("SELECT * FROM chat_messages WHERE task_id = ? LIMIT 1").get(e);return t?a(t):void 0}function l(e,s=50,t=0){return n().prepare(`
|
|
6
|
+
SELECT m.* FROM chat_messages m
|
|
7
|
+
JOIN chat_sessions s ON m.session_id = s.id
|
|
8
|
+
WHERE s.source_type = 'channel' AND s.source_channel_id = ?
|
|
9
|
+
ORDER BY m.created_at DESC LIMIT ? OFFSET ?
|
|
10
|
+
`).all(e,s,t).map(a)}export{g as a,p as b,E as c,_ as d,M as e,l as f};
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as W,b as h,c as z,e as V}from"./chunk-PHT24MOV.js";import{a as B,b as J,d as G}from"./chunk-
|
|
2
|
+
import{a as W,b as h,c as z,e as V}from"./chunk-PHT24MOV.js";import{a as B,b as J,d as G}from"./chunk-MQWYGDNT.js";import{a as q}from"./chunk-IYJVHEQ4.js";import"./chunk-D5LZGIJU.js";import{b as _}from"./chunk-7IFLU3CY.js";import"./chunk-N5FW6FUS.js";import{c as M,e as K,g as de}from"./chunk-B44X7JAJ.js";import{b as H,c as j,d as ce}from"./chunk-AQO6IIHV.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";import{Command as we}from"commander";import{fork as ue}from"child_process";import{readFileSync as L,writeFileSync as me,existsSync as v,unlinkSync as $,mkdirSync as pe,openSync as ge}from"fs";import{join as D}from"path";import{homedir as fe}from"os";var P=D(fe(),".adam"),S=D(P,"adam.pid"),k=D(P,"adam.port"),b=D(P,"server.log");function he(){v(P)||pe(P,{recursive:!0})}function C(){if(!v(S))return null;let e=parseInt(L(S,"utf-8").trim(),10);return isNaN(e)?null:e}function ve(){if(!v(k))return null;let e=parseInt(L(k,"utf-8").trim(),10);return isNaN(e)?null:e}function A(e){try{return process.kill(e,0),!0}catch{return!1}}async function N(){he();let e=C();if(e&&A(e))throw new Error(`Server already running (PID ${e})`);v(S)&&$(S),v(k)&&$(k);let o=ge(b,"a"),t=D(B,"dist/index.js"),n=ue(t,[],{detached:!0,stdio:["ignore",o,o,"ipc"]}),l=await new Promise((i,c)=>{let g=setTimeout(()=>{n.kill(),c(new Error(`Server start timeout. Check logs: ${b}`))},1e4);n.on("message",a=>{if(a&&typeof a=="object"&&a.type==="ready"){clearTimeout(g);let s=a.port;s?i(s):c(new Error("Ready signal received but missing port"))}}),n.on("exit",a=>{clearTimeout(g);let s=v(b)?L(b,"utf-8").split(`
|
|
3
3
|
`).slice(-10).join(`
|
|
4
4
|
`):"";c(new Error(`Server exited with code ${a}.
|
|
5
5
|
${s?`Last log lines:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b,b as c,d,e}from"./chunk-SDT3PBHF.js";import{a}from"./chunk-76IJC5WL.js";import"./chunk-7IFLU3CY.js";import"./chunk-N5FW6FUS.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as DEFAULT_CONFIG,e as getChatConfig,d as getDefaults,b as loadConfig,c as loadDefaultConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-B44X7JAJ.js";import"./chunk-AQO6IIHV.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";g();export{f as deleteConfigValue,c as getAllConfig,a as getConfigValue,e as isConfigEmpty,d as seedConfig,b as setConfigValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-
|
|
1
|
+
import{a,b,c,d}from"./chunk-AQO6IIHV.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";d();export{c as closeDb,b as getDb,a as runMigrations};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-O7XQSONJ.js";import"./chunk-6JBSBSCL.js";import"./chunk-AQO6IIHV.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as TTL_MS,g as cleanupExpired,b as createDeliveryLog,i as getDeliveryLogByRule,h as getDeliveryLogByTask,f as getFailedDeliveries,e as getPendingDeliveries,d as markDelivered,c as updateDeliveryLogStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-ZFDULJGB.js";import"./chunk-NPIXYK5G.js";import"./chunk-SC2DDRYB.js";import"./chunk-FUWPDXXG.js";import"./chunk-ZQ4PNKMQ.js";import"./chunk-R2WB5BKF.js";import"./chunk-B544JOZM.js";import"./chunk-Y5FFL6UO.js";import"./chunk-L7JP7DUO.js";import"./chunk-O7XQSONJ.js";import"./chunk-6JBSBSCL.js";import"./chunk-AQO6IIHV.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as DeliveryEngine,b as getDeliveryEngine,c as initDeliveryEngine,d as stopDeliveryEngine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-WQFNB2MQ.js";import"./chunk-6JBSBSCL.js";import"./chunk-AQO6IIHV.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as createEvolutionAudit,e as generateDiff,d as getLatestRoleEvolution,b as listEvolutionAudit,c as listEvolutionAuditByRole};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-76IJC5WL.js";import"./chunk-WBAPIPST.js";import{c as a,h as c}from"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";c();var u=a("agent");async function m(n){let e=f();if(e.length===0)return{scores:[],errors:[]};let s=[],r=[];for(let t of e)try{let o=await l(t);o!==null&&s.push({nodeId:n,score:o,source:t.name,fetchedAt:Date.now()})}catch(o){r.push(`External API "${t.name}" (${t.url}): ${o instanceof Error?o.message:String(o)}`),u.warn({endpoint:t.name,error:o},"External API fetch failed")}return{scores:s,errors:r}}async function l(n){let e=await fetch(n.url,{signal:AbortSignal.timeout(5e3),headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`HTTP ${e.status} ${e.statusText}`);let s=await e.json(),r=p(s,n.scorePath);if(typeof r!="number"||isNaN(r))throw new Error(`Score at "${n.scorePath}" is not a number: ${JSON.stringify(r)}`);return Math.max(0,Math.min(1,r))}function p(n,e){let s=e.replace(/^\$\.?/,""),r=n;for(let t of s.split(".")){if(r==null||typeof r!="object")return;r=r[t]}return r}function f(){return i.externalApis??[]}export{m as collectExternalApiScores};
|