adam-agent-server 1.15.0 → 1.16.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/App-Z2GJAMX3.js +14 -0
- package/dist/approval-handler-6NPN24UN.js +1 -0
- package/dist/artifacts-S2KD6W76.js +1 -0
- package/dist/audit-diagnostics-2MDM3IQT.js +1 -0
- package/dist/audit-manager-QG7CMBV2.js +1 -0
- package/dist/bree-engine-3QSLZF3W.js +1 -0
- package/dist/channels-S4AAOOTN.js +1 -0
- package/dist/channels-TYXSSI7D.js +1 -0
- package/dist/{chat-tool-calls-KARPW7PE.js → chat-tool-calls-2C7O4B2X.js} +1 -1
- package/dist/chunk-32LOJEHE.js +32 -0
- package/dist/{chunk-VNXTBIPI.js → chunk-3UR2PN5N.js} +1 -1
- package/dist/{chunk-D3SPXZZY.js → chunk-3UZIEE2D.js} +1 -1
- package/dist/chunk-4234WJJD.js +178 -0
- package/dist/{chunk-2N4EOZZ4.js → chunk-52FETPCI.js} +1 -1
- package/dist/{chunk-3KNR2F6H.js → chunk-6Y2DN2UH.js} +1 -1
- package/dist/{chunk-NWGRLNUM.js → chunk-AG5SADAI.js} +1 -1
- package/dist/chunk-AQAHVNNG.js +34 -0
- package/dist/{chunk-FD4IKMXV.js → chunk-C2XFPUFV.js} +1 -1
- package/dist/chunk-EWYXVBOG.js +61 -0
- package/dist/{chunk-ISKCTUI7.js → chunk-FHESRUJY.js} +1 -1
- package/dist/{chunk-BKNXRSJU.js → chunk-FYULPPFR.js} +1 -1
- package/dist/{chunk-GXWB47NF.js → chunk-H4MMEULK.js} +4 -4
- package/dist/chunk-HC34HJFF.js +1 -0
- package/dist/{chunk-XF7YHFVR.js → chunk-HJICGOD4.js} +1 -1
- package/dist/{chunk-F6U5TMM3.js → chunk-HXDS4NWI.js} +1 -1
- package/dist/{chunk-3BRHWRZ5.js → chunk-I44JKROJ.js} +1 -1
- package/dist/chunk-K2TZW4DU.js +132 -0
- package/dist/{chunk-RBJPQYV3.js → chunk-K4IE6DPX.js} +1 -1
- package/dist/{chunk-NPGZRSGL.js → chunk-LQVBWVLE.js} +1 -1
- package/dist/chunk-LVHLUAZW.js +22 -0
- package/dist/{chunk-ICAM2GUU.js → chunk-MNSZE3NV.js} +1 -1
- package/dist/{chunk-KJNAORKM.js → chunk-MTQI6B7T.js} +1 -1
- package/dist/chunk-NS6WVZMS.js +1 -0
- package/dist/{chunk-IRUR4DVD.js → chunk-OGY42NUN.js} +1 -1
- package/dist/{chunk-OQ3JOTPK.js → chunk-OXGWWSKT.js} +1 -1
- package/dist/{chunk-I7LJ4432.js → chunk-P5Q2UINT.js} +1 -1
- package/dist/{chunk-BPXS4QEO.js → chunk-QL2ZOLMC.js} +88 -21
- package/dist/{chunk-TZCMK3UG.js → chunk-R24YRJRG.js} +1 -1
- package/dist/{chunk-42V6ZPCS.js → chunk-SCUPWMI5.js} +1 -1
- package/dist/{chunk-J3VYLSJI.js → chunk-TCBGUVVU.js} +1 -1
- package/dist/{chunk-XIVFVKMB.js → chunk-TJTH7LHX.js} +1 -1
- package/dist/chunk-VVQ532U2.js +6 -0
- package/dist/chunk-WVHN54MA.js +14 -0
- package/dist/{chunk-XZEBYOFR.js → chunk-YNS5LQX5.js} +10 -10
- package/dist/cli.js +2 -2
- package/dist/{config-XO7TGH27.js → config-HDAAV5FV.js} +1 -1
- package/dist/{db-WCTOLFAZ.js → db-HFBXO2O5.js} +1 -1
- package/dist/{delivery-log-ML4RJOBM.js → delivery-log-3O3OHKY4.js} +1 -1
- package/dist/engine-J43ECCH7.js +1 -0
- package/dist/{evolution-audit-HLU7LQL6.js → evolution-audit-BSGPFGFK.js} +1 -1
- package/dist/execution-tools-HHUPWLCF.js +1 -0
- package/dist/index.js +41 -41
- package/dist/{learner-NJXX2RUL.js → learner-TQQZKRSB.js} +1 -1
- package/dist/{memories-JDTQM3UN.js → memories-2DY5G6ZN.js} +1 -1
- package/dist/{memory-extractor-5PTMCSOX.js → memory-extractor-TUOOFST2.js} +1 -1
- package/dist/memory-gc-MRO53MEY.js +1 -0
- package/dist/memory-service-23WVAW7T.js +1 -0
- package/dist/outbound-gateway-VXODXSQR.js +1 -0
- package/dist/presets-KJV6SNNB.js +1 -0
- package/dist/{reflection-job-ST4ANCGB.js → reflection-job-EFFW3WOR.js} +3 -3
- package/dist/role-presets-PHHL3OEN.js +1 -0
- package/dist/role-workspace-USY47ZPQ.js +1 -0
- package/dist/{roles-F6AEM6B5.js → roles-3JXNHL7K.js} +1 -1
- package/dist/{session-manager-JTQRJI7R.js → session-manager-PI3JEINK.js} +1 -1
- package/dist/skill-registry-ROGU2WED.js +1 -0
- package/dist/{task-templates-6G46OVYT.js → task-templates-4YPKFFKG.js} +1 -1
- package/dist/template-dispatch-46TN534D.js +1 -0
- package/package.json +1 -1
- package/web/dist/assets/ArtifactDetail-9DJdEqCz.js +66 -0
- package/web/dist/assets/Artifacts-CQ6SAemH.js +1 -0
- package/web/dist/assets/{Button-fLMsJd5o.js → Button-xVc-P0vm.js} +1 -1
- package/web/dist/assets/{Card-cy-gHU0O.js → Card-WUD1cwG6.js} +1 -1
- package/web/dist/assets/ChannelDetail-B21nBQwi.js +1 -0
- package/web/dist/assets/{Channels-DMutLV9r.js → Channels-CAeGE1r7.js} +2 -2
- package/web/dist/assets/Chat-KpFWchPp.js +2 -0
- package/web/dist/assets/{Dashboard-CoatfhW8.js → Dashboard-DkRwHNmr.js} +1 -1
- package/web/dist/assets/{EmptyState-C5kVDHc7.js → EmptyState-BLB33cKG.js} +1 -1
- package/web/dist/assets/{EnvVarEditor-BvRsHayG.js → EnvVarEditor-BchUNrmz.js} +1 -1
- package/web/dist/assets/{EventDefDetail-zuJydp12.js → EventDefDetail-DnBwWWfT.js} +1 -1
- package/web/dist/assets/Events-ByIzPIs2.js +1 -0
- package/web/dist/assets/{Evolution-Br41g99g.js → Evolution-Vh9RKdma.js} +1 -1
- package/web/dist/assets/{ExtensionDetail-BXlphIkn.js → ExtensionDetail-0CtJh5rF.js} +1 -1
- package/web/dist/assets/Extensions--O1ulwlC.js +1 -0
- package/web/dist/assets/{FeatureRequests-oaXQNu43.js → FeatureRequests-XhQbGg_q.js} +1 -1
- package/web/dist/assets/GoalDetail-DIOxf7ES.js +1 -0
- package/web/dist/assets/Goals-CZnHu9qC.js +1 -0
- package/web/dist/assets/{Logs-BZKxhdnb.js → Logs-DdeG3GiY.js} +1 -1
- package/web/dist/assets/{Memories-DhJJk-KB.js → Memories-D-EAODUg.js} +1 -1
- package/web/dist/assets/{Mistakes-DxThj9as.js → Mistakes-wW78K3cP.js} +1 -1
- package/web/dist/assets/{NotFound-buXr2gl7.js → NotFound-BsxIP-Xm.js} +1 -1
- package/web/dist/assets/{PageHeader-BgNbz3JV.js → PageHeader-D8pqg_wk.js} +1 -1
- package/web/dist/assets/Plugins-DDUdX51_.js +1 -0
- package/web/dist/assets/{RoleDetail-rClUsHwS.js → RoleDetail-CU3G9j_q.js} +4 -4
- package/web/dist/assets/Roles-BCoSzDBg.js +1 -0
- package/web/dist/assets/{SectionHeader-CwX6m1f6.js → SectionHeader-DZo4QVWr.js} +1 -1
- package/web/dist/assets/{Settings-My2lOEWv.js → Settings-K3usfV-2.js} +1 -1
- package/web/dist/assets/{Strategies-YLMryJlG.js → Strategies-Bg4qlLei.js} +1 -1
- package/web/dist/assets/{Switch-PNpjNoGn.js → Switch-WWPXnSOG.js} +1 -1
- package/web/dist/assets/{Table-BrERwl-F.js → Table-XjSmrOyn.js} +1 -1
- package/web/dist/assets/{Tabs-CGHmpUAD.js → Tabs-CSbcG_5T.js} +1 -1
- package/web/dist/assets/TaskDetail-C5roukcV.js +2 -0
- package/web/dist/assets/Work-DGTWSgtc.js +1 -0
- package/web/dist/assets/{es2015-JqLIWAgH.js → es2015-BgPT8VkR.js} +1 -1
- package/web/dist/assets/index-KNUbHDLy.css +2 -0
- package/web/dist/assets/index-iD-HOtIu.js +12 -0
- package/web/dist/assets/{useIsMobileLayout-Blj4Mk4K.js → useIsMobileLayout-DF2fEEM9.js} +1 -1
- package/web/dist/assets/{usePluginsWithUsage-Ch9WCFTb.js → usePluginsWithUsage-CjU8Lkdn.js} +1 -1
- package/web/dist/assets/vendor-icons-H7p0EuQJ.js +1 -0
- package/web/dist/assets/{vendor-react-Bp_V-Hsf.js → vendor-react-C1yKjxEP.js} +1 -1
- package/web/dist/assets/{vendor-state-Zjl_6-V3.js → vendor-state-D0TNAbOY.js} +1 -1
- package/web/dist/index.html +7 -7
- package/dist/App-6TRGTNZ7.js +0 -13
- package/dist/approval-handler-YLO3V75T.js +0 -1
- package/dist/audit-diagnostics-MASYIEGZ.js +0 -1
- package/dist/audit-manager-LYBXP7U4.js +0 -1
- package/dist/bree-engine-AA7EVKTG.js +0 -1
- package/dist/channels-2IL6USWL.js +0 -1
- package/dist/channels-6BEGHNOK.js +0 -1
- package/dist/chunk-6NWIZ3BH.js +0 -220
- package/dist/chunk-APAOIZN4.js +0 -114
- package/dist/chunk-CLNYHWZ6.js +0 -5
- package/dist/chunk-EVUZ5LH2.js +0 -1
- package/dist/chunk-L47LZYVG.js +0 -21
- package/dist/chunk-LU3D53ZV.js +0 -34
- package/dist/chunk-SVUP3F4V.js +0 -14
- package/dist/chunk-TLP4ZMJB.js +0 -19
- package/dist/chunk-UFWMUBFH.js +0 -25
- package/dist/engine-XLH4VL6Y.js +0 -1
- package/dist/execution-tools-SYP3GR6T.js +0 -1
- package/dist/memory-gc-BCHTOSXK.js +0 -1
- package/dist/memory-service-66EMRJXO.js +0 -1
- package/dist/outbound-gateway-3INYZDOR.js +0 -1
- package/dist/presets-DT3J2ON4.js +0 -1
- package/dist/role-presets-3IQKCSVQ.js +0 -1
- package/dist/role-workspace-SIHNI6HO.js +0 -1
- package/dist/skill-registry-4JT62GEF.js +0 -1
- package/dist/template-dispatch-2K7KV7YS.js +0 -1
- package/dist/template-execution-artifacts-NEPSVD2B.js +0 -1
- package/web/dist/assets/ChannelDetail-CsKBPHkT.js +0 -1
- package/web/dist/assets/Chat-DWTs-iOw.js +0 -2
- package/web/dist/assets/Events-nCImjXyr.js +0 -1
- package/web/dist/assets/Extensions-3lhbw0A2.js +0 -1
- package/web/dist/assets/GoalDetail-DRDg1JDv.js +0 -1
- package/web/dist/assets/Goals-DGmKvtGA.js +0 -1
- package/web/dist/assets/Plugins-BXrsGsXs.js +0 -1
- package/web/dist/assets/Roles-DH9cRv8h.js +0 -1
- package/web/dist/assets/TaskDetail-Bkaq0NwW.js +0 -2
- package/web/dist/assets/Work-4OcGMu_a.js +0 -1
- package/web/dist/assets/index-C-e-qpXc.js +0 -12
- package/web/dist/assets/index-DGTVc0qD.css +0 -2
- package/web/dist/assets/vendor-icons-U4igmrUq.js +0 -1
- /package/web/dist/assets/{format-BUYXZqDw.js → format-ZWN4JNj-.js} +0 -0
- /package/web/dist/assets/{ui-CerQw0jA.js → ui-D1crlGpt.js} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{n as o,p as k}from"./chunk-QL2ZOLMC.js";import{c as R}from"./chunk-FCV2DPZQ.js";import{basename as S}from"path";import{v4 as x}from"uuid";function u(t){return{id:t.id,sourceKind:t.source_kind,executionId:t.execution_id??void 0,taskId:t.task_id??void 0,chatSessionId:t.chat_session_id??void 0,stepId:t.step_id??void 0,roleId:t.role_id??void 0,key:t.key??void 0,kind:t.kind,value:t.value_json?JSON.parse(t.value_json):void 0,blobPath:t.blob_path??void 0,mime:t.mime??void 0,originalFilename:t.original_filename??void 0,sizeBytes:t.size_bytes,createdAt:t.created_at,locator:t.locator??void 0,contentHash:t.content_hash??void 0,retentionHint:t.retention_hint??void 0,encryptionClass:t.encryption_class??void 0,purpose:t.purpose??void 0,replaces:t.replaces??void 0,producedByRole:t.produced_by_role??void 0,access:t.access??void 0,priority:t.priority??void 0}}function O(t){if(!t.roleId||t.roleId.trim()==="")throw new Error("createArtifact: roleId required (application-layer enforcement)");p(o(),t)}function p(t,e){t.prepare(`
|
|
2
|
+
INSERT INTO artifacts (
|
|
3
|
+
id, source_kind, execution_id, task_id, chat_session_id, step_id, role_id,
|
|
4
|
+
key, kind, value_json, blob_path, mime, original_filename, size_bytes, created_at,
|
|
5
|
+
locator, content_hash, retention_hint, encryption_class, purpose, replaces, produced_by_role, access, priority
|
|
6
|
+
)
|
|
7
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
8
|
+
`).run(e.id,e.sourceKind,e.executionId??null,e.taskId??null,e.chatSessionId??null,e.stepId??null,e.roleId??null,e.key??null,e.kind,e.value!==void 0?JSON.stringify(e.value):null,e.blobPath??null,e.mime??null,e.originalFilename??null,e.sizeBytes,e.createdAt,e.locator??null,e.contentHash??null,e.retentionHint??null,e.encryptionClass??null,e.purpose??null,e.replaces??null,e.producedByRole??null,e.access??null,e.priority??null)}function y(t,e,n,i){let r=t.prepare(`
|
|
9
|
+
SELECT * FROM artifacts
|
|
10
|
+
WHERE source_kind = 'template_step' AND execution_id = ? AND step_id = ? AND key = ?
|
|
11
|
+
`).get(e,n,i);return r?u(r):void 0}function v(t,e,n){return y(o(),t,e,n)}function H(t){let e=o().prepare("SELECT * FROM artifacts WHERE id = ?").get(t);return e?u(e):void 0}function h(t,e){let n=o(),i="SELECT * FROM artifacts WHERE execution_id = ?",r=[t];return e&&(i+=" AND step_id = ?",r.push(e)),i+=" ORDER BY created_at ASC",n.prepare(i).all(...r).map(u)}function L(t){return o().prepare("SELECT * FROM artifacts WHERE task_id = ? ORDER BY created_at ASC").all(t).map(u)}function P(t){return o().prepare("SELECT * FROM artifacts WHERE chat_session_id = ? ORDER BY created_at ASC").all(t).map(u)}function K(t,e){let n=o(),i="SELECT * FROM artifacts WHERE role_id = ?",r=[t];e?.sourceKind&&(i+=" AND source_kind = ?",r.push(e.sourceKind)),i+=" ORDER BY created_at ASC";let s=n.prepare(i).all(...r).map(u);return e?.mimePrefix&&(s=s.filter(a=>a.mime?.startsWith(e.mimePrefix))),s}function W(t){let e=o(),n=h(t);return e.prepare("DELETE FROM artifacts WHERE execution_id = ?").run(t),n}function z(t,e){let n=o(),i=h(t).filter(r=>r.stepId===e);return n.prepare("DELETE FROM artifacts WHERE execution_id = ? AND step_id = ?").run(t,e),i}function N(t){o().prepare("DELETE FROM artifacts WHERE id = ?").run(t)}function $(t){return o().prepare("DELETE FROM artifacts WHERE id = ?").run(t).changes>0}function T(t){if(!t||typeof t!="object")return!1;let e=t;return e.type!=="artifact_collection"||typeof e.outputAs!="string"||e.outputAs.length===0||!Array.isArray(e.items)?!1:e.items.every(n=>n!=null&&typeof n=="object"&&typeof n.artifactId=="string"&&n.artifactId.length>0&&typeof n.key=="string"&&n.key.length>0&&typeof n.sizeBytes=="number"&&Number.isFinite(n.sizeBytes)&&(n.filename===void 0||typeof n.filename=="string")&&(n.mime===void 0||typeof n.mime=="string")&&(n.purpose===void 0||typeof n.purpose=="string"))}function j(t,e,n){return g(o(),t,e,n)}function q(t,e,n,i){let r=o();return r.transaction(()=>{let s=y(r,t,e,n);if(!s||s.kind!=="json"||!T(s.value))throw new Error(`Artifact collection manifest not found at ${e}/${n}`);let a=g(r,t,e,i.key??"",new Set([n])),l={...i,key:a};p(r,l);let d={...s.value,items:[...s.value.items,m(l)]};return{manifestArtifact:I(r,s,d),childArtifact:l}})()}function U(t,e,n,i,r){let c=o();return c.transaction(()=>{let a=y(c,t,e,n);if(!a||a.id!==i.id)throw new Error(`Primary artifact changed before collection conversion at ${e}/${n}`);if(a.kind!=="file"||!a.blobPath)throw new Error(`Primary artifact at ${e}/${n} is not a file`);let l=g(c,t,e,a.originalFilename??a.key??n,new Set([n]));c.prepare("UPDATE artifacts SET key = ? WHERE id = ?").run(l,a.id);let d={...a,key:l},A=g(c,t,e,r.key??"",new Set([n,l])),f={...r,key:A};p(c,f);let _={type:"artifact_collection",outputAs:n,items:[m(d),m(f)]},E={id:x(),sourceKind:i.sourceKind,executionId:t,stepId:e,key:n,kind:"json",value:_,sizeBytes:b(_),createdAt:Date.now(),purpose:"data",roleId:i.roleId};return p(c,E),{manifestArtifact:E,childArtifact:f,rekeyedPrimaryArtifact:d}})()}function Y(t){return o().prepare(`
|
|
12
|
+
SELECT id
|
|
13
|
+
FROM template_executions
|
|
14
|
+
WHERE status != 'running' AND COALESCE(completed_at, started_at) < ?
|
|
15
|
+
`).all(t).map(i=>i.id)}function g(t,e,n,i,r=new Set){let c=t.prepare(`
|
|
16
|
+
SELECT key FROM artifacts
|
|
17
|
+
WHERE execution_id = ? AND step_id = ?
|
|
18
|
+
`).all(e,n),s=new Set(c.map(l=>l.key));for(let l of r)s.add(l);let a=B(i);if(!s.has(a))return a;for(let l=2;l<1e4;l++){let d=`-${l}`,f=`${a.slice(0,Math.max(1,256-d.length))}${d}`;if(!s.has(f))return f}throw new Error(`Unable to allocate unique artifact key for ${n}/${i}`)}function B(t){let e=t.replace(/\\/g,"/"),i=S(e).replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,256);return!i||i==="."||i===".."?"artifact":C.test(i)?i:"artifact"}function m(t){return{artifactId:t.id,key:t.key??"",...t.originalFilename?{filename:t.originalFilename}:{},...t.mime?{mime:t.mime}:{},sizeBytes:t.sizeBytes,...t.purpose?{purpose:t.purpose}:{}}}function I(t,e,n){let i=b(n);return t.prepare(`
|
|
19
|
+
UPDATE artifacts
|
|
20
|
+
SET value_json = ?, size_bytes = ?
|
|
21
|
+
WHERE id = ?
|
|
22
|
+
`).run(JSON.stringify(n),i,e.id),{...e,value:n,sizeBytes:i}}function b(t){return Buffer.byteLength(JSON.stringify(t),"utf8")}function J(t,e){let n=[],i=[];t.sourceKind&&(n.push("source_kind = ?"),i.push(t.sourceKind)),t.mimePrefix&&(n.push("mime LIKE ? ESCAPE '\\'"),i.push(t.mimePrefix.replace(/[\\%_]/g,"\\$&")+"%")),t.roleId&&(n.push("role_id = ?"),i.push(t.roleId)),t.taskId&&(n.push("task_id = ?"),i.push(t.taskId)),t.executionId&&(n.push("execution_id = ?"),i.push(t.executionId)),t.chatSessionId&&(n.push("chat_session_id = ?"),i.push(t.chatSessionId)),t.from!==void 0&&(n.push("created_at >= ?"),i.push(t.from)),t.to!==void 0&&(n.push("created_at <= ?"),i.push(t.to)),t.deliveryStatus&&(n.push("(EXISTS (SELECT 1 FROM delivery_log dl WHERE dl.status = ? AND (dl.task_id = artifacts.task_id OR dl.task_id = artifacts.execution_id)))"),i.push(t.deliveryStatus));let r=n.length?"WHERE "+n.join(" AND "):"",c=o(),s=c.prepare(`SELECT COUNT(*) AS n FROM artifacts ${r}`).get(...i);return{artifacts:c.prepare(`SELECT * FROM artifacts ${r} ORDER BY created_at DESC LIMIT ? OFFSET ?`).all(...i,e.limit,e.offset).map(u),total:s.n}}var C,M=R(()=>{k();C=/^[\p{L}0-9._-]{1,256}$/u});export{O as a,v as b,H as c,h as d,L as e,P as f,K as g,W as h,z as i,N as j,$ as k,T as l,j as m,q as n,U as o,Y as p,J as q,M as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as A,i as J}from"./chunk-
|
|
1
|
+
import{e as A,i as J}from"./chunk-3UR2PN5N.js";import{v,z as D}from"./chunk-MTQI6B7T.js";import{existsSync as m,readFileSync as P,readdirSync as w}from"fs";import{join as d}from"path";import E from"os";var b=()=>d(E.homedir(),".claude","plugins"),S=()=>d(b(),"installed_plugins.json"),_=()=>d(b(),"known_marketplaces.json"),x=()=>d(E.homedir(),".claude","settings.json");function y(s){try{if(!m(s))return null;let i=P(s,"utf-8");return JSON.parse(i)}catch{return null}}function R(){return y(x())?.enabledPlugins??{}}function T(s){let i=s;function l(t,p){let a={};try{if(!m(t))return a;let u=P(t,"utf-8").replace(/^```yaml\r?\n/,"").replace(/^```\r?\n/,"");for(let f of p){let r=new RegExp(`^${f}:\\s*(.+)$`,"m"),e=u.match(r);e&&(a[f]=e[1].trim())}}catch{}return a}function o(t){try{if(!m(t))return{};let p=P(t,"utf-8"),a=p.match(/^```yaml\r?\n([\s\S]*?)\r?\n```\r?\n/);if(!a){let r={};for(let e of p.split(/\r?\n/)){let n=e.match(/^(\w+):\s*(.+)$/);n&&(r[n[1]]=n[2])}return{name:r.name,description:r.description}}let c=a[1],u={};for(let r of c.split(/\r?\n/)){let e=r.match(/^(\w+):\s*(.*)$/);if(e){let[,n,g]=e;g.trim()&&(u[n]=g.trim())}}let f=c.match(/error_patterns:\r?\n([\s\S]*?)(?=\n\w|\n$)/);if(f){let r=f[1],e=[],n={};for(let g of r.split(/\r?\n/)){let h=g.match(/^\s*-\s*pattern:\s*(.+)$/);if(h){n.pattern&&e.push(n),n={pattern:h[1].replace(/^["']|["']$/g,"")};continue}let k=g.match(/^\s*category:\s*(.+)$/);if(k){n.category=k[1].trim();continue}let j=g.match(/^\s*user_action:\s*(.+)$/);if(j){n.user_action=j[1].replace(/^["']|["']$/g,""),n.pattern&&n.category&&n.user_action&&(e.push(n),n={});continue}}n.pattern&&e.push(n),e.length>0&&(u.error_patterns=e)}return{name:u.name,description:u.description,error_patterns:u.error_patterns}}catch{}return{}}try{let t={name:"",skills:[],agents:[],mcpServers:[],hooks:[],lspServers:[]},p=d(i,".claude-plugin","plugin.json");if(m(p))try{let r=JSON.parse(P(p,"utf-8"));t.name=r.name??"",t.version=r.version,t.description=r.description,Array.isArray(r.lspServers)&&(t.lspServers=r.lspServers),Array.isArray(r.mcpServers)&&(t.mcpServers=r.mcpServers),Array.isArray(r.hooks)&&(t.hooks=r.hooks)}catch{}let a=d(i,"skills");if(m(a)){let r=w(a,{withFileTypes:!0});for(let e of r){if(!e.isDirectory()&&!e.isSymbolicLink())continue;let n=d(a,e.name,"SKILL.md"),g=o(n);g.name&&t.skills.push({name:g.name,description:g.description??"",error_patterns:g.error_patterns})}}let c=d(i,"agents");if(m(c)){let r=w(c,{withFileTypes:!0});for(let e of r){if(!e.isFile()||!e.name.endsWith(".md"))continue;let n=l(d(c,e.name),["name","description"]);n.name&&t.agents.push({name:n.name,description:n.description??""})}}let u=d(i,".mcp.json");if(m(u))try{let r=JSON.parse(P(u,"utf-8"));r.mcpServers&&typeof r.mcpServers=="object"&&(t.mcpServers=Object.keys(r.mcpServers))}catch{}let f=d(i,"hooks","hooks.json");if(m(f))try{let r=JSON.parse(P(f,"utf-8"));Array.isArray(r)&&(t.hooks=r.map(e=>typeof e=="object"&&e!==null&&"event"in e?String(e.event):String(e)))}catch{}return t}catch{return null}}function $(s){let i=y(S());if(!i?.plugins)return[];let l=R(),o=[];for(let[t,p]of Object.entries(i.plugins))if(!(!Array.isArray(p)||p.length===0))for(let a of p){let c=a.scope??"user";s?.scope&&c!==s.scope||s?.projectPath&&a.projectPath!==s.projectPath||o.push({id:t,name:t.split("@")[0],version:a.version??"",scope:c,projectPath:a.projectPath,installPath:a.installPath??d(b(),t),enabled:l[t]??a.enabled??!0,installedAt:a.installedAt??"",lastUpdated:a.lastUpdated??""})}return o}function G(s){let i=y(S());if(!i?.plugins?.[s])return null;let l=i.plugins[s];if(!Array.isArray(l)||l.length===0)return null;let o=l[0],t=R();return{id:s,name:s.split("@")[0],version:o.version??"",scope:o.scope??"user",projectPath:o.projectPath,installPath:o.installPath??d(b(),s),enabled:t[s]??o.enabled??!0,installedAt:o.installedAt??"",lastUpdated:o.lastUpdated??""}}function M(s){let i=y(S()),l=new Map;for(let o of s){let t=i?.plugins?.[o];Array.isArray(t)&&t.length>0&&l.set(o,t[0].installPath??d(b(),o))}return l}function U(){return y(_())?.marketplaces??[]}function I(s){let i=d(s,".claude","settings.json"),l=y(i);return{enabledPlugins:l?.enabledPlugins??{},mcpServers:l?.mcpServers??{},allowedTools:l?.allowedTools??[],disallowedTools:l?.disallowedTools??[]}}J();D();var C={Read:{category:"File",label:"read"},Write:{category:"File",label:"write"},Edit:{category:"File",label:"edit"},Glob:{category:"Search",label:"find files"},Grep:{category:"Search",label:"search content"},Bash:{category:"Execution",label:"shell commands"},WebSearch:{category:"Web",label:"web search"},WebFetch:{category:"Web",label:"fetch pages"},NotebookEdit:{category:"Execution",label:"Jupyter notebooks"}};function q(s,i){let l=s.allowedTools??[],o=s.osCapabilities??[];if(l.length===0&&o.length===0&&Object.keys(s.mcpServers??{}).length===0&&(s.additionalDirectories?.length??0)===0&&(!i||i.plugins.length===0))return"No tool permissions";let t=new Map,p=[];for(let e of l){let n=C[e];if(n){let g=t.get(n.category)??[];g.push(n.label),t.set(n.category,g)}else p.push(e)}let a=[];for(let[e,n]of t)a.push(`${e} (${n.join(", ")})`);p.length>0&&a.push(p.join(", "));let c=a.join(" \xB7 "),u=e=>{c=c?`${c} \xB7 ${e}`:e},f=Object.keys(s.mcpServers??{});f.length>0&&u(`MCP: ${f.join(", ")}`);let r=s.additionalDirectories??[];if(r.length>0&&u(`Dirs: ${r.map(e=>e.path).join(", ")}`),o.length>0){let e=o.map(n=>{let g=v(n.id);return n.id==="automation"&&n.targets?.length?`${g.label} (${n.targets.join(", ")})`:g.label});u(`OS: ${e.join(", ")}`)}if(i&&i.plugins.length>0){let e=i.plugins.map(n=>{let g=[];return n.skills.length>0&&g.push(`skills: ${n.skills.map(h=>h.name).join(", ")}`),n.agents.length>0&&g.push(`agents: ${n.agents.map(h=>h.name).join(", ")}`),g.length>0?`${n.name} (${g.join("; ")})`:n.name});u(`Plugins: ${e.join(", ")}`)}return c}function O(s){let i=[],l=s.additionalDirectories??[];for(let o of l){if(!o.inheritPlugins&&!o.inheritMcp)continue;let t=I(o.path),p=Object.entries(t.enabledPlugins).filter(([,c])=>c).map(([c])=>c),a=M(p);for(let[,c]of a)i.includes(c)||i.push(c)}try{let o=A(s.name),t=$({scope:"project",projectPath:o});for(let p of t)p.installPath&&!i.includes(p.installPath)&&i.push(p.installPath)}catch{}return i}function z(s){let i=O(s),l=[];for(let o of i){let t=T(o);t&&l.push({name:t.name||o.split("/").pop()||"unknown",description:t.description,skills:t.skills,agents:t.agents,mcpServers:t.mcpServers,hooks:t.hooks})}return{plugins:l}}export{R as a,T as b,$ as c,G as d,U as e,I as f,q as g,O as h,z as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as m,g as L}from"./chunk-
|
|
1
|
+
import{a as m,g as L}from"./chunk-OGY42NUN.js";import{n as a,p as x}from"./chunk-QL2ZOLMC.js";import{b as u,h as _}from"./chunk-WBAPIPST.js";import{c as v,e as N}from"./chunk-245WE5AF.js";import{c as l}from"./chunk-FCV2DPZQ.js";var f,p,T=l(()=>{"use strict";f={stylePreferences:[],avoidedActions:[],pinnedParameters:[]},p=class extends Error{constructor(i,r,n,s){super(`Role '${r}' has ${n} active task(s) (${s.join(", ")}) and cannot be deleted without the force flag.`);this.roleId=i;this.roleName=r;this.activeTaskCount=n;this.taskStatuses=s;this.name="RoleHasActiveTasksError"}roleId;roleName;activeTaskCount;taskStatuses;code="ROLE_HAS_ACTIVE_TASKS"}});import*as R from"os";import*as S from"path";function g(e){return e.startsWith("~/")||e==="~"?S.join(R.homedir(),e.slice(1)):e}var C=l(()=>{"use strict";_()});function E(e){return A.includes(e)}function I(e){return k[e]}function B(){return A.map(e=>k[e])}function ee(e,t=e!=="none"){return B().map(i=>J(i,e,t))}function J(e,t,i=t!=="none"){return process.platform==="darwin"?e.status==="runtime-enforced"&&(t!=="sandbox-exec"||!i)?{...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 te(e){if(!e?.length)return;for(let i of e)if(!E(i.id))throw new Error(`Unknown OS capability: ${i.id}`);let t=c(e);if(t?.length){for(let i of t){let r=I(i.id);if(r.status!=="runtime-enforced")throw new Error(`OS capability '${r.label}' is not editable in Role settings`);if(r.supportsTargets){if(!i.targets?.length)throw new Error(`OS capability '${r.label}' requires at least one target bundle id`);for(let n of i.targets)if(!F(n))throw new Error(`Invalid automation target bundle id: ${n}`)}else if(i.targets?.length)throw new Error(`OS capability '${r.label}' does not accept targets`)}return t}}function c(e){if(!e||e.length===0)return;let t=new Set,i=[];for(let r of e){if(!E(r.id))throw new Error(`Unknown OS capability: ${r.id}`);if(t.has(r.id))continue;t.add(r.id);let n=I(r.id),s={id:r.id};n.supportsTargets&&r.targets?.length&&(s.targets=[...new Set(r.targets.map(o=>o.trim()).filter(Boolean))]),i.push(s)}return i.length>0?i.sort((r,n)=>r.id.localeCompare(n.id)):void 0}function F(e){return U.test(e)}var A,k,U,w=l(()=>{"use strict";A=["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"],k={"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."}},U=/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/});function b(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,errorCategory:e.error_category??void 0,retryCount:e.retry_count}}function se(e){a().prepare(`
|
|
2
2
|
INSERT INTO tasks (id, parent_id, status, prompt, original_prompt, config, result, error,
|
|
3
3
|
sdk_session_id, template_id, role_id, step_id, source_session_id, notify_targets, deliver_to, report_to,
|
|
4
4
|
created_at, started_at, completed_at,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(n){return n?n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n==="application/pdf"?"pdf":null:null}export{t as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as r,p as s}from"./chunk-QL2ZOLMC.js";import{c as i}from"./chunk-FCV2DPZQ.js";function p(e){let n=r().prepare("SELECT value FROM config WHERE key = ?").get(e);if(n)try{return JSON.parse(n.value)}catch{return n.value}}function E(e,t){let n=r(),o=JSON.stringify(t),u=Date.now();n.prepare(`INSERT INTO config (key, value, updated_at) VALUES (?, ?, ?)
|
|
2
2
|
ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`).run(e,o,u)}function k(){let t=r().prepare("SELECT key, value FROM config").all(),n={};for(let o of t)try{n[o.key]=JSON.parse(o.value)}catch{n[o.key]=o.value}return n}function b(e){let t=r(),n=t.prepare("INSERT OR IGNORE INTO config (key, value, updated_at) VALUES (?, ?, ?)"),o=Date.now(),u=0;return t.transaction(()=>{for(let[c,a]of Object.entries(e)){if(a==null||a==="")continue;n.run(c,JSON.stringify(a),o).changes>0&&u++}})(),u}function w(){return r().prepare("SELECT COUNT(*) as count FROM config").get().count===0}function O(e){return r().prepare("DELETE FROM config WHERE key = ?").run(e).changes>0}var d=i(()=>{s()});export{p as a,E as b,k as c,b as d,w as e,O as f,d as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as b}from"./chunk-
|
|
1
|
+
import{s as b}from"./chunk-K2TZW4DU.js";import{s,u as m,w as x}from"./chunk-K4IE6DPX.js";import{a as p}from"./chunk-L7JP7DUO.js";import{q as T}from"./chunk-TJTH7LHX.js";import{F as f,I as J}from"./chunk-MTQI6B7T.js";import{c as h,h as C}from"./chunk-BLCNUT53.js";C();J();import{v4 as l}from"uuid";import{CronExpressionParser as E}from"cron-parser";var n=h("scheduler"),y=class{cronJobs=new Map;started=!1;templateExecutionCompletionHandler=null;async start(){if(this.started)return;this.started=!0;let e=m(!0),t=0;for(let r of e)r.trigger.type==="cron"&&r.trigger.cron&&(this.scheduleCronJob(r),t++);let o=0;for(let r of e)r.trigger.type==="once"&&r.trigger.runAt&&(this.scheduleOnceJob(r.id),o++);this.templateExecutionCompletionHandler=r=>{(r.status==="completed"||r.status==="partial")&&this.checkTemplateCompleteTriggers(r.templateId).catch(i=>{n.error({templateId:r.templateId,error:i},"Template-complete trigger check failed")})},p.on("template_execution_status_change",this.templateExecutionCompletionHandler),this.cronJobs.set("memory-cleanup",setInterval(()=>{this.runMemoryCleanup()},36e5)),n.info({cronCount:t,onceCount:o},"Bree engine started with cron jobs + memory cleanup")}runMemoryCleanup(){try{let e=f(void 0,1e3,0),t=0;for(let o of e)t+=T(o.id);t>0&&n.info({totalCleaned:t},"Memory cleanup completed")}catch(e){n.warn({error:e},"Memory cleanup failed")}}async stop(){for(let[,e]of this.cronJobs)clearTimeout(e),clearInterval(e);this.cronJobs.clear(),this.templateExecutionCompletionHandler&&(p.off("template_execution_status_change",this.templateExecutionCompletionHandler),this.templateExecutionCompletionHandler=null),this.started=!1,n.info("Bree engine stopped")}scheduleCronJob(e){let t=`template-${e.id}`;this.cronJobs.has(t)&&(clearTimeout(this.cronJobs.get(t)),this.cronJobs.delete(t));let o;try{o=E.parse(e.trigger.cron)}catch{n.warn({templateId:e.id,cron:e.trigger.cron},"Invalid cron expression");return}let r=()=>{let u=o.next().getTime()-Date.now();return Math.max(u,1e3)},i=()=>{this.executeCronTrigger(e.id).catch(u=>{n.error({templateId:e.id,error:u},"Cron trigger failed")});let d=setTimeout(i,r());this.cronJobs.set(t,d)},c=r(),a=setTimeout(i,c);this.cronJobs.set(t,a),n.debug({jobName:t,nextRun:new Date(Date.now()+c).toISOString()},"Scheduled cron job")}async executeCronTrigger(e){let t=s(e);!t||!t.enabled||(n.info({templateName:t.name},"Cron triggered"),await this.executeTemplateExecution(t,l()))}async scheduleJob(e){let t=s(e);t&&t.trigger.type==="cron"&&t.trigger.cron&&this.scheduleCronJob(t)}async unscheduleJob(e){let t=`template-${e}`,o=this.cronJobs.get(t);o&&(clearTimeout(o),this.cronJobs.delete(t))}async runNow(e,t){let o=s(e);if(!o)throw new Error(`Template ${e} not found`);let r=l();return this.executeTemplateExecution(o,r,t).catch(i=>{n.error({templateId:e,error:i},"TemplateExecution failed")}),r}async checkTemplateCompleteTriggers(e){let o=m(!0).filter(r=>r.trigger.type!=="template_complete"||!r.trigger.event?!1:r.trigger.event===`template_complete:${e}`);for(let r of o)n.info({templateName:r.name,sourceTemplateId:e},"Template-complete trigger matched"),await this.executeTemplateExecution(r,l())}async executeTemplateExecution(e,t,o={}){await b(e,{...o,executionId:t,triggerContext:o.triggerContext??{source:"bree"}})}scheduleOnceJob(e){let t=s(e);if(!t||!t.enabled||t.trigger.type!=="once")return;let r=(t.trigger.runAt?new Date(t.trigger.runAt).getTime():0)-Date.now();if(r<=0){n.info({templateId:e,runAt:t.trigger.runAt},"Once-shot template past due, executing immediately"),this.executeOnceTrigger(e).catch(a=>{n.error({templateId:e,error:a},"Once trigger execution failed")});return}let i=`template-${e}`;this.cronJobs.has(i)&&clearTimeout(this.cronJobs.get(i));let c=setTimeout(()=>{this.cronJobs.delete(i),this.executeOnceTrigger(e).catch(a=>{n.error({templateId:e,error:a},"Once trigger execution failed")})},r);this.cronJobs.set(i,c),n.info({templateId:e,runAt:t.trigger.runAt,delayMs:r},"Scheduled once-shot job")}async executeOnceTrigger(e){let t=s(e);!t||!t.enabled||(n.info({templateName:t.name},"Once-shot triggered"),await this.executeTemplateExecution(t,l()),x(e),n.info({templateId:e},"Once-shot template auto-disabled after execution"))}},v=null;function N(){return v}function j(g){v=g}export{y as a,N as b,j as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as x,e as C}from"./chunk-HJICGOD4.js";import{a as y,b as u,c,d as m,e as h,f as v}from"./chunk-AG5SADAI.js";import{a as i}from"./chunk-L7JP7DUO.js";import{a as S}from"./chunk-DRO3DG7X.js";import{a as l}from"./chunk-TJTH7LHX.js";import{e as p}from"./chunk-VKKDSXMR.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=x(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 S(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"};l(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 y(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=h(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){C(e),v(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};
|