adam-agent-server 1.19.0 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/approval-handler-GXIVBJ4Z.js +1 -0
  2. package/dist/artifacts-DDHH47IE.js +1 -0
  3. package/dist/audit-diagnostics-HLHS3MHM.js +1 -0
  4. package/dist/audit-manager-PDMOR2MX.js +1 -0
  5. package/dist/bree-engine-6UKRI4UN.js +1 -0
  6. package/dist/{channels-ZHCTFSDA.js → channels-3J6U6GYH.js} +1 -1
  7. package/dist/channels-YOBMSBWV.js +1 -0
  8. package/dist/{chat-tool-calls-4BQWZCJH.js → chat-tool-calls-5Z53IXRF.js} +1 -1
  9. package/dist/{chunk-4ZESWP3J.js → chunk-2BLSA25Q.js} +1 -1
  10. package/dist/{chunk-WG3C43QS.js → chunk-3JTHJ3FZ.js} +1 -1
  11. package/dist/{chunk-PO66F7UQ.js → chunk-4NRIKWSD.js} +1 -1
  12. package/dist/{chunk-VZL2DGC4.js → chunk-5ZL6RHPE.js} +1 -1
  13. package/dist/{chunk-6GYNUTPP.js → chunk-6GVYOHD5.js} +5 -5
  14. package/dist/{chunk-GQS3ED3B.js → chunk-6NIWU43Z.js} +1 -1
  15. package/dist/{chunk-4ZG4UMAK.js → chunk-6SBLFYCU.js} +1 -1
  16. package/dist/{chunk-FN64ZULV.js → chunk-AKQ3AFVI.js} +1 -1
  17. package/dist/{chunk-JXZCQ5XW.js → chunk-CQDOIHPV.js} +1 -1
  18. package/dist/{chunk-QJXV4SQE.js → chunk-EXB2JIBR.js} +1 -1
  19. package/dist/{chunk-ORFLN4BF.js → chunk-G5I76LX2.js} +1 -1
  20. package/dist/{chunk-HEHST2E2.js → chunk-GYOZGA7G.js} +1 -1
  21. package/dist/{chunk-CN5NEJXG.js → chunk-ISTUK7Q6.js} +1 -1
  22. package/dist/chunk-J4JO7O3T.js +182 -0
  23. package/dist/{chunk-2JM3URDG.js → chunk-KO6UB6VW.js} +1 -1
  24. package/dist/chunk-LE5YRP37.js +14 -0
  25. package/dist/{chunk-FQHGIY3E.js → chunk-N4BV2WAU.js} +1 -1
  26. package/dist/{chunk-VOH52UDS.js → chunk-NUTGYMDP.js} +1 -1
  27. package/dist/{chunk-4G4CKAXY.js → chunk-NX3CIEZA.js} +1 -1
  28. package/dist/{chunk-ZGA52HRD.js → chunk-P2EDMFVO.js} +1 -1
  29. package/dist/{chunk-DRS5NOAA.js → chunk-PU2T7HBY.js} +1 -1
  30. package/dist/{chunk-R7Q6FSV4.js → chunk-PZH5NKUL.js} +11 -11
  31. package/dist/{chunk-EPLSB63A.js → chunk-QF3B4OWI.js} +1 -1
  32. package/dist/{chunk-JVYSSJKT.js → chunk-QQWUWGSK.js} +2 -2
  33. package/dist/{chunk-DFTRUOT6.js → chunk-QX65LEYA.js} +1 -1
  34. package/dist/{chunk-IAGTZGGV.js → chunk-R3MSLP6P.js} +2 -2
  35. package/dist/{chunk-KM4EFB4N.js → chunk-SDHMBWVC.js} +1 -1
  36. package/dist/{chunk-A3YUIWLK.js → chunk-SONOE4ZJ.js} +1 -1
  37. package/dist/{chunk-WDMSZS4W.js → chunk-VVPB3TD4.js} +1 -1
  38. package/dist/{chunk-L4APYD5A.js → chunk-X3PJNX2R.js} +1 -1
  39. package/dist/{chunk-EBZCHLYS.js → chunk-XEXSXMWK.js} +1 -1
  40. package/dist/{chunk-7QT2ZX3K.js → chunk-YGR5ZTGT.js} +1 -1
  41. package/dist/{chunk-76MMY2XC.js → chunk-YGZQMZTA.js} +1 -1
  42. package/dist/{chunk-YEGUFMLJ.js → chunk-YI2QQTZE.js} +1 -1
  43. package/dist/{chunk-KQMKRRYW.js → chunk-ZARKPBI2.js} +45 -45
  44. package/dist/{chunk-LMQPGVM7.js → chunk-ZEGZ2I35.js} +4 -4
  45. package/dist/cli.js +1 -1
  46. package/dist/{config-GOJLI3X2.js → config-7Y7I7KX4.js} +1 -1
  47. package/dist/{db-ROXIYW5B.js → db-P7ELD5DS.js} +1 -1
  48. package/dist/{delivery-log-TGJZ5HU7.js → delivery-log-EVRKJ5GD.js} +1 -1
  49. package/dist/engine-FE7NCHOG.js +1 -0
  50. package/dist/{evolution-audit-TFJF666X.js → evolution-audit-XIWF3JIF.js} +1 -1
  51. package/dist/execution-tools-PGURN3N6.js +1 -0
  52. package/dist/index.js +68 -67
  53. package/dist/{learner-ACBX3GI7.js → learner-PWDQUZ5O.js} +1 -1
  54. package/dist/{memories-RAIR5O2F.js → memories-2OJFLLBT.js} +1 -1
  55. package/dist/{memory-extractor-A6CAOFOX.js → memory-extractor-N7M4YSPL.js} +1 -1
  56. package/dist/{memory-gc-W63MGSDH.js → memory-gc-R42SPM52.js} +1 -1
  57. package/dist/memory-service-V7B5MY37.js +1 -0
  58. package/dist/outbound-gateway-NHNHVHF2.js +1 -0
  59. package/dist/presets-H2UV3HIF.js +1 -0
  60. package/dist/{reflection-job-XC2F7GTT.js → reflection-job-ECJX5ERQ.js} +1 -1
  61. package/dist/role-presets-7SWGUPV2.js +1 -0
  62. package/dist/role-workspace-AOYIGLG4.js +1 -0
  63. package/dist/{roles-LZCJ7QFS.js → roles-5TWJBGAQ.js} +1 -1
  64. package/dist/{session-manager-PU4GH3E4.js → session-manager-5P2FAEV3.js} +1 -1
  65. package/dist/skill-registry-XOX4OSHY.js +1 -0
  66. package/dist/{task-templates-52LAC6OA.js → task-templates-CTQHB6TA.js} +1 -1
  67. package/dist/template-dispatch-Z2TKWOMY.js +1 -0
  68. package/package.json +1 -1
  69. package/dist/approval-handler-S3NV7OPO.js +0 -1
  70. package/dist/artifacts-NFMM3ORE.js +0 -1
  71. package/dist/audit-diagnostics-IHU3CJYZ.js +0 -1
  72. package/dist/audit-manager-MUMEEP3C.js +0 -1
  73. package/dist/bree-engine-EEKUQA3U.js +0 -1
  74. package/dist/channels-IDBWHLLE.js +0 -1
  75. package/dist/chunk-MMVDXKYS.js +0 -14
  76. package/dist/chunk-NKS7LEA7.js +0 -182
  77. package/dist/engine-GN7PJPGQ.js +0 -1
  78. package/dist/execution-tools-BQD2O25X.js +0 -1
  79. package/dist/memory-service-H4OFUNCF.js +0 -1
  80. package/dist/outbound-gateway-LKRQYPA2.js +0 -1
  81. package/dist/presets-FO6RSGDN.js +0 -1
  82. package/dist/role-presets-SDA664QG.js +0 -1
  83. package/dist/role-workspace-NGJEJG3H.js +0 -1
  84. package/dist/skill-registry-XKLE2LXU.js +0 -1
  85. package/dist/template-dispatch-PJFSWEO2.js +0 -1
@@ -1,8 +1,8 @@
1
- import{d as B,e as W,i as Y}from"./chunk-ITVCPC7G.js";import{c as g,h as K}from"./chunk-EZLBMUQD.js";import{b as H}from"./chunk-5PELJRUQ.js";import{constants as se,cpSync as ie,copyFileSync as y,existsSync as I,lstatSync as Ee,mkdirSync as k,readdirSync as ne,realpathSync as S,rmSync as $,statSync as C,unlinkSync as j,writeFileSync as oe}from"fs";import{dirname as q,extname as Te,isAbsolute as V,join as L,sep as R}from"path";import{v4 as _e}from"uuid";function U(){return process.env.ADAM_TEST_DIR||B}function ae(){return L(U(),["work","flows"].join(""))}function F(){return L(U(),"template-executions")}function z(e){return L(F(),e,"artifacts")}function J(e){let _=z(e);return k(_,{recursive:!0}),_}function Ce(e,_,l){if(!V(e))throw new Error(`path must be absolute: ${e}`);let a=S(_),d=a.endsWith(R)?a:a+R;if(l){let N=S(e),u=N.endsWith(R)?N:N+R;if(u===d||u.startsWith(d))return;throw new Error(`path escapes workspace: ${e} (resolved=${N}, root=${a})`)}if(I(e))throw Ee(e).isSymbolicLink()?new Error(`destination already exists and is a symlink: ${e}`):new Error(`destination already exists: ${e}`);let m=S(q(e)),O=m.endsWith(R)?m:m+R;if(!(O===d||O.startsWith(d)))throw new Error(`destination escapes workspace: ${e} (parent resolved=${m}, root=${a})`)}function Ue(e){let _=J(e.executionId),l=L(_,`${e.artifactId}.bin`);return y(e.sourcePath,l),{blobPath:l,sizeBytes:C(l).size}}async function De(e){let{createArtifact:_}=await import("./artifacts-NFMM3ORE.js"),l=_e(),a=L(J(e.executionId),`${l}.bin`);oe(a,e.text,"utf8");let d=Buffer.byteLength(e.text,"utf8");return _({id:l,sourceKind:"template_step",executionId:e.executionId,stepId:e.stepId,key:e.key,kind:"file",blobPath:a,mime:"text/markdown",originalFilename:`${e.key}.md`,sizeBytes:d,createdAt:Date.now(),roleId:e.roleId}),{artifactId:l,sizeBytes:d}}function he(e){j(e)}function xe(e){if(!I(e.blobPath))throw new Error(`blob file missing on disk: ${e.blobPath}`);return y(e.blobPath,e.destPath,se.COPYFILE_EXCL),{sizeBytes:C(e.destPath).size}}function Q(e){try{j(e)}catch(_){X.warn({err:_,blobPath:e},"Failed to remove TemplateExecution artifact blob")}}function ye(e){try{$(L(F(),e),{recursive:!0,force:!0})}catch(_){X.warn({err:_,executionId:e},"Failed to remove TemplateExecution artifacts directory")}}function ke(e,_,l){let a=z(e);if(!I(a))return 0;let d=0;for(let m of ne(a)){if(Te(m)!==".bin")continue;let O=m.slice(0,-4);if(_.has(O))continue;let N=L(a,m),u=C(N);Date.now()-u.mtimeMs<l||(Q(N),d++)}return d}async function Fe(e,_){let{deleteArtifactsByExecutionAndStep:l}=await import("./artifacts-NFMM3ORE.js"),a=l(e,_),d=0;for(let m of a)m.blobPath&&I(m.blobPath)&&(Q(m.blobPath),d++);return X.debug({executionId:e,stepId:_,deletedRows:a.length,deletedFiles:d},"cleanSlatePriorAttempt: done"),{deletedRows:a.length,deletedFiles:d}}function ce(e,_){let l=U();if(e==="template"){if(!_)throw new Error("template kind requires executionId");return L(l,"template-executions",_,"artifacts")}return L(l,"artifacts",e)}function we(e){let _=ce(e.kind,e.executionId);k(_,{recursive:!0});let l=L(_,`${e.artifactId}.bin`);return y(e.sourcePath,l),{blobPath:l,sizeBytes:C(l).size}}function Me(e){try{if(!V(e))return!1;let _=S(e),l=S(U()),a=l.endsWith(R)?l:l+R,d=_.endsWith(R)?_:_+R;return d===a||d.startsWith(a)}catch{return!1}}function Z(e){let _=ae();if(!I(_)||!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='template_execution_artifacts'").get())return;let a=e.prepare(`
1
+ import{d as B,e as W,i as Y}from"./chunk-ITVCPC7G.js";import{c as g,h as K}from"./chunk-EZLBMUQD.js";import{b as H}from"./chunk-5PELJRUQ.js";import{cpSync as se,copyFileSync as y,existsSync as I,lstatSync as ie,mkdirSync as k,readdirSync as Ee,realpathSync as S,rmSync as $,statSync as C,unlinkSync as j,writeFileSync as ne}from"fs";import{dirname as q,extname as oe,isAbsolute as V,join as L,sep as R}from"path";import{v4 as Te}from"uuid";function U(){return process.env.ADAM_TEST_DIR||B}function _e(){return L(U(),["work","flows"].join(""))}function F(){return L(U(),"template-executions")}function z(e){return L(F(),e,"artifacts")}function J(e){let _=z(e);return k(_,{recursive:!0}),_}function ge(e,_,l){if(!V(e))throw new Error(`path must be absolute: ${e}`);let a=S(_),d=a.endsWith(R)?a:a+R;if(l){let N=S(e),u=N.endsWith(R)?N:N+R;if(u===d||u.startsWith(d))return;throw new Error(`path escapes workspace: ${e} (resolved=${N}, root=${a})`)}if(I(e)&&ie(e).isSymbolicLink())throw new Error(`destination exists and is a symlink (refused): ${e}`);let m=S(q(e)),O=m.endsWith(R)?m:m+R;if(!(O===d||O.startsWith(d)))throw new Error(`destination escapes workspace: ${e} (parent resolved=${m}, root=${a})`)}function Ce(e){let _=J(e.executionId),l=L(_,`${e.artifactId}.bin`);return y(e.sourcePath,l),{blobPath:l,sizeBytes:C(l).size}}async function Ue(e){let{createArtifact:_}=await import("./artifacts-DDHH47IE.js"),l=Te(),a=L(J(e.executionId),`${l}.bin`);ne(a,e.text,"utf8");let d=Buffer.byteLength(e.text,"utf8");return _({id:l,sourceKind:"template_step",executionId:e.executionId,stepId:e.stepId,key:e.key,kind:"file",blobPath:a,mime:"text/markdown",originalFilename:`${e.key}.md`,sizeBytes:d,createdAt:Date.now(),roleId:e.roleId}),{artifactId:l,sizeBytes:d}}function De(e){j(e)}function he(e){if(!I(e.blobPath))throw new Error(`blob file missing on disk: ${e.blobPath}`);return y(e.blobPath,e.destPath),{sizeBytes:C(e.destPath).size}}function Q(e){try{j(e)}catch(_){X.warn({err:_,blobPath:e},"Failed to remove TemplateExecution artifact blob")}}function xe(e){try{$(L(F(),e),{recursive:!0,force:!0})}catch(_){X.warn({err:_,executionId:e},"Failed to remove TemplateExecution artifacts directory")}}function ye(e,_,l){let a=z(e);if(!I(a))return 0;let d=0;for(let m of Ee(a)){if(oe(m)!==".bin")continue;let O=m.slice(0,-4);if(_.has(O))continue;let N=L(a,m),u=C(N);Date.now()-u.mtimeMs<l||(Q(N),d++)}return d}async function ke(e,_){let{deleteArtifactsByExecutionAndStep:l}=await import("./artifacts-DDHH47IE.js"),a=l(e,_),d=0;for(let m of a)m.blobPath&&I(m.blobPath)&&(Q(m.blobPath),d++);return X.debug({executionId:e,stepId:_,deletedRows:a.length,deletedFiles:d},"cleanSlatePriorAttempt: done"),{deletedRows:a.length,deletedFiles:d}}function ae(e,_){let l=U();if(e==="template"){if(!_)throw new Error("template kind requires executionId");return L(l,"template-executions",_,"artifacts")}return L(l,"artifacts",e)}function Fe(e){let _=ae(e.kind,e.executionId);k(_,{recursive:!0});let l=L(_,`${e.artifactId}.bin`);return y(e.sourcePath,l),{blobPath:l,sizeBytes:C(l).size}}function we(e){try{if(!V(e))return!1;let _=S(e),l=S(U()),a=l.endsWith(R)?l:l+R,d=_.endsWith(R)?_:_+R;return d===a||d.startsWith(a)}catch{return!1}}function Z(e){let _=_e();if(!I(_)||!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='template_execution_artifacts'").get())return;let a=e.prepare(`
2
2
  SELECT id, execution_id, blob_path
3
3
  FROM template_execution_artifacts
4
4
  WHERE blob_path IS NOT NULL
5
- `).all(),d=_.endsWith(R)?_:_+R,m=F(),O=new Set;for(let N of a){if(!N.blob_path.startsWith(d))continue;let u=L(_,N.execution_id),v=L(m,N.execution_id),x=L(m,N.blob_path.slice(d.length));try{if(I(u)&&!I(v)&&(k(q(v),{recursive:!0}),ie(u,v,{recursive:!0,dereference:!1,force:!1})),!I(x)){X.warn({artifactId:N.id,blobPath:N.blob_path},"TemplateExecution artifact migration skipped missing copied blob");continue}e.prepare("UPDATE template_execution_artifacts SET blob_path = ? WHERE id = ?").run(x,N.id),O.add(N.execution_id)}catch(M){X.warn({err:M,artifactId:N.id,executionId:N.execution_id},"TemplateExecution artifact migration failed")}}for(let N of O){let u=L(m,N);if(I(u))try{$(L(_,N),{recursive:!0,force:!0})}catch(v){X.warn({err:v,executionId:N},"Failed to remove migrated legacy artifact directory")}}}var X,b=H(()=>{"use strict";Y();K();X=g("watchdog")});import le from"better-sqlite3";import{existsSync as Ne,mkdirSync as de}from"fs";import{dirname as pe}from"path";function Re(e){e.exec(`
5
+ `).all(),d=_.endsWith(R)?_:_+R,m=F(),O=new Set;for(let N of a){if(!N.blob_path.startsWith(d))continue;let u=L(_,N.execution_id),v=L(m,N.execution_id),x=L(m,N.blob_path.slice(d.length));try{if(I(u)&&!I(v)&&(k(q(v),{recursive:!0}),se(u,v,{recursive:!0,dereference:!1,force:!1})),!I(x)){X.warn({artifactId:N.id,blobPath:N.blob_path},"TemplateExecution artifact migration skipped missing copied blob");continue}e.prepare("UPDATE template_execution_artifacts SET blob_path = ? WHERE id = ?").run(x,N.id),O.add(N.execution_id)}catch(M){X.warn({err:M,artifactId:N.id,executionId:N.execution_id},"TemplateExecution artifact migration failed")}}for(let N of O){let u=L(m,N);if(I(u))try{$(L(_,N),{recursive:!0,force:!0})}catch(v){X.warn({err:v,executionId:N},"Failed to remove migrated legacy artifact directory")}}}var X,b=H(()=>{"use strict";Y();K();X=g("watchdog")});import ce from"better-sqlite3";import{existsSync as le,mkdirSync as Ne}from"fs";import{dirname as de}from"path";function Le(e){e.exec(`
6
6
  CREATE TABLE IF NOT EXISTS server_state (
7
7
  id INTEGER PRIMARY KEY CHECK(id = 1),
8
8
  sdk_session_id TEXT,
@@ -760,7 +760,7 @@ import{d as B,e as W,i as Y}from"./chunk-ITVCPC7G.js";import{c as g,h as K}from"
760
760
  UNIQUE(execution_id, step_id, key),
761
761
  FOREIGN KEY (execution_id) REFERENCES template_executions(id) ON DELETE CASCADE
762
762
  )
763
- `),e.prepare(`DROP INDEX IF EXISTS ${me}`).run(),e.prepare(`DROP INDEX IF EXISTS ${Le}`).run(),e.prepare("CREATE INDEX IF NOT EXISTS idx_template_execution_artifacts_execution ON template_execution_artifacts(execution_id)").run(),e.prepare("CREATE INDEX IF NOT EXISTS idx_template_execution_artifacts_step ON template_execution_artifacts(execution_id, step_id)").run(),Z(e),e.prepare("UPDATE server_state SET schema_version = 43 WHERE id = 1").run()}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<44&&(e.prepare("PRAGMA table_info(tasks)").all().some(t=>t.name==="error_category")||e.prepare("ALTER TABLE tasks ADD COLUMN error_category TEXT").run(),e.prepare("UPDATE server_state SET schema_version = 44 WHERE id = 1").run()),(e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<45&&(e.prepare("PRAGMA table_info(tasks)").all().some(t=>t.name==="retry_count")||e.prepare("ALTER TABLE tasks ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0").run(),e.exec(`
763
+ `),e.prepare(`DROP INDEX IF EXISTS ${pe}`).run(),e.prepare(`DROP INDEX IF EXISTS ${me}`).run(),e.prepare("CREATE INDEX IF NOT EXISTS idx_template_execution_artifacts_execution ON template_execution_artifacts(execution_id)").run(),e.prepare("CREATE INDEX IF NOT EXISTS idx_template_execution_artifacts_step ON template_execution_artifacts(execution_id, step_id)").run(),Z(e),e.prepare("UPDATE server_state SET schema_version = 43 WHERE id = 1").run()}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<44&&(e.prepare("PRAGMA table_info(tasks)").all().some(t=>t.name==="error_category")||e.prepare("ALTER TABLE tasks ADD COLUMN error_category TEXT").run(),e.prepare("UPDATE server_state SET schema_version = 44 WHERE id = 1").run()),(e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<45&&(e.prepare("PRAGMA table_info(tasks)").all().some(t=>t.name==="retry_count")||e.prepare("ALTER TABLE tasks ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0").run(),e.exec(`
764
764
  CREATE TABLE IF NOT EXISTS delayed_retries (
765
765
  id TEXT PRIMARY KEY,
766
766
  task_id TEXT NOT NULL,
@@ -1217,4 +1217,4 @@ import{d as B,e as W,i as Y}from"./chunk-ITVCPC7G.js";import{c as g,h as K}from"
1217
1217
  cost_usd, priced, estimated, sdk_total_cost_usd, num_turns, created_at)
1218
1218
  VALUES
1219
1219
  (?, ?, 'task', ?, NULL, ?, NULL, NULL, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?)
1220
- `),i=0;for(let E of r){let n=`backfill-${E.id}`,T={};if(E.token_usage)try{T=JSON.parse(E.token_usage)}catch{}let c=null;if(E.cost_breakdown)try{c=JSON.parse(E.cost_breakdown)}catch{}if(c&&Array.isArray(c.perModel)&&c.perModel.length>0)for(let p=0;p<c.perModel.length;p++){let o=c.perModel[p],f=`${n}-${p}`;t.run(f,n,o.model,E.id,o.inputTokens??0,o.outputTokens??0,o.cacheReadTokens??0,o.cacheCreationTokens??0,o.costUsd??0,o.priced?1:0,o.estimated?1:0,E.created_at??Date.now()),i++}else{let p=`${n}-0`,o=E.cost_usd>0?1:0;t.run(p,n,"unknown",E.id,T.input??0,T.output??0,0,0,E.cost_usd,o,0,E.created_at??Date.now()),i++}}e.prepare("UPDATE server_state SET schema_version = 84 WHERE id = 1").run(),console.info(`[db migration v84] llm_costs table created + ${i} rows backfilled from tasks`)}catch(r){throw new Error(`Schema v84 migration failed: ${r instanceof Error?r.message:String(r)}`)}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<85)try{let r=e.prepare("PRAGMA table_info(chat_messages)").all(),t=i=>r.some(E=>E.name===i);t("cost_usd")||e.exec("ALTER TABLE chat_messages ADD COLUMN cost_usd REAL"),t("token_usage")||e.exec("ALTER TABLE chat_messages ADD COLUMN token_usage TEXT"),t("model")||e.exec("ALTER TABLE chat_messages ADD COLUMN model TEXT"),e.prepare("UPDATE server_state SET schema_version = 85 WHERE id = 1").run(),console.info("[db migration v85] chat_messages cost columns added (cost_usd, token_usage, model)")}catch(r){throw new Error(`Schema v85 migration failed: ${r instanceof Error?r.message:String(r)}`)}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<87)try{e.prepare("PRAGMA table_info(tasks)").all().some(E=>E.name==="cost_breakdown")||(e.exec("ALTER TABLE tasks ADD COLUMN cost_breakdown TEXT"),console.info("[db migration v87] tasks.cost_breakdown re-added (drift repair)"));let t=e.prepare("PRAGMA table_info(chat_messages)").all(),i=E=>t.some(n=>n.name===E);i("cost_usd")||(e.exec("ALTER TABLE chat_messages ADD COLUMN cost_usd REAL"),console.info("[db migration v87] chat_messages.cost_usd re-added (drift repair)")),i("token_usage")||(e.exec("ALTER TABLE chat_messages ADD COLUMN token_usage TEXT"),console.info("[db migration v87] chat_messages.token_usage re-added (drift repair)")),i("model")||(e.exec("ALTER TABLE chat_messages ADD COLUMN model TEXT"),console.info("[db migration v87] chat_messages.model re-added (drift repair)")),e.prepare("UPDATE server_state SET schema_version = 87 WHERE id = 1").run()}catch(r){throw new Error(`Schema v87 migration failed: ${r instanceof Error?r.message:String(r)}`)}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<88)try{e.prepare("PRAGMA table_info(chat_sessions)").all().some(t=>t.name==="sdk_session_id")||(e.exec("ALTER TABLE chat_sessions ADD COLUMN sdk_session_id TEXT"),console.info("[db migration v88] chat_sessions.sdk_session_id added")),e.prepare("UPDATE server_state SET schema_version = 88 WHERE id = 1").run()}catch(r){throw new Error(`Schema v88 migration failed: ${r instanceof Error?r.message:String(r)}`)}try{let s=e.prepare("SELECT id, name, steps, role_preference FROM task_templates WHERE enabled = 1").all(),r=0;for(let t of s){if(t.role_preference)continue;let i;try{i=JSON.parse(t.steps)}catch{continue}if(!Array.isArray(i))continue;let E=!1;for(let n of i){let T=typeof n.roleId=="string"&&n.roleId.length>0,c=n.autoSelectRole===!0;!T&&!c&&(n.autoSelectRole=!0,n.requirements===void 0&&(n.requirements={}),E=!0)}E&&(e.prepare("UPDATE task_templates SET steps = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(i),Date.now(),t.id),r+=1,console.info(`[db migration] template auto-repaired: id=${t.id} name=${t.name}`))}r>0&&console.info(`[db migration] auto-repaired ${r} enabled template(s) with missing role config`)}catch(s){console.error("[db migration] template auto-repair failed:",s)}}function $e(){if(A)return A;let e=process.env.ADAM_DB_PATH||W,_=pe(e);return Ne(_)||de(_,{recursive:!0}),A=new le(e),A.pragma("journal_mode = WAL"),A.pragma("foreign_keys = ON"),A.pragma("trusted_schema = ON"),Re(A),A}function je(){A&&(A.close(),A=null)}var D,te,h,w,ee,re,me,Le,A,Ae=H(()=>{Y();K();b();D=g("store"),te=["work","flow_complete"].join(""),h=`${te}:`,w=["work","flow_executions"].join(""),ee=["work","flow_artifacts"].join(""),re=["idx","work","flow_executions_event_id"].join("_"),me=["idx","work","flow_artifacts_execution"].join("_"),Le=["idx","work","flow_artifacts_step"].join("_"),A=null});export{J as a,Ce as b,Ue as c,De as d,he as e,xe as f,Q as g,ye as h,ke as i,Fe as j,we as k,Me as l,b as m,Re as n,$e as o,je as p,Ae as q};
1220
+ `),i=0;for(let E of r){let n=`backfill-${E.id}`,T={};if(E.token_usage)try{T=JSON.parse(E.token_usage)}catch{}let c=null;if(E.cost_breakdown)try{c=JSON.parse(E.cost_breakdown)}catch{}if(c&&Array.isArray(c.perModel)&&c.perModel.length>0)for(let p=0;p<c.perModel.length;p++){let o=c.perModel[p],f=`${n}-${p}`;t.run(f,n,o.model,E.id,o.inputTokens??0,o.outputTokens??0,o.cacheReadTokens??0,o.cacheCreationTokens??0,o.costUsd??0,o.priced?1:0,o.estimated?1:0,E.created_at??Date.now()),i++}else{let p=`${n}-0`,o=E.cost_usd>0?1:0;t.run(p,n,"unknown",E.id,T.input??0,T.output??0,0,0,E.cost_usd,o,0,E.created_at??Date.now()),i++}}e.prepare("UPDATE server_state SET schema_version = 84 WHERE id = 1").run(),console.info(`[db migration v84] llm_costs table created + ${i} rows backfilled from tasks`)}catch(r){throw new Error(`Schema v84 migration failed: ${r instanceof Error?r.message:String(r)}`)}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<85)try{let r=e.prepare("PRAGMA table_info(chat_messages)").all(),t=i=>r.some(E=>E.name===i);t("cost_usd")||e.exec("ALTER TABLE chat_messages ADD COLUMN cost_usd REAL"),t("token_usage")||e.exec("ALTER TABLE chat_messages ADD COLUMN token_usage TEXT"),t("model")||e.exec("ALTER TABLE chat_messages ADD COLUMN model TEXT"),e.prepare("UPDATE server_state SET schema_version = 85 WHERE id = 1").run(),console.info("[db migration v85] chat_messages cost columns added (cost_usd, token_usage, model)")}catch(r){throw new Error(`Schema v85 migration failed: ${r instanceof Error?r.message:String(r)}`)}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<87)try{e.prepare("PRAGMA table_info(tasks)").all().some(E=>E.name==="cost_breakdown")||(e.exec("ALTER TABLE tasks ADD COLUMN cost_breakdown TEXT"),console.info("[db migration v87] tasks.cost_breakdown re-added (drift repair)"));let t=e.prepare("PRAGMA table_info(chat_messages)").all(),i=E=>t.some(n=>n.name===E);i("cost_usd")||(e.exec("ALTER TABLE chat_messages ADD COLUMN cost_usd REAL"),console.info("[db migration v87] chat_messages.cost_usd re-added (drift repair)")),i("token_usage")||(e.exec("ALTER TABLE chat_messages ADD COLUMN token_usage TEXT"),console.info("[db migration v87] chat_messages.token_usage re-added (drift repair)")),i("model")||(e.exec("ALTER TABLE chat_messages ADD COLUMN model TEXT"),console.info("[db migration v87] chat_messages.model re-added (drift repair)")),e.prepare("UPDATE server_state SET schema_version = 87 WHERE id = 1").run()}catch(r){throw new Error(`Schema v87 migration failed: ${r instanceof Error?r.message:String(r)}`)}if((e.prepare("SELECT schema_version FROM server_state WHERE id = 1").get()?.schema_version??0)<88)try{e.prepare("PRAGMA table_info(chat_sessions)").all().some(t=>t.name==="sdk_session_id")||(e.exec("ALTER TABLE chat_sessions ADD COLUMN sdk_session_id TEXT"),console.info("[db migration v88] chat_sessions.sdk_session_id added")),e.prepare("UPDATE server_state SET schema_version = 88 WHERE id = 1").run()}catch(r){throw new Error(`Schema v88 migration failed: ${r instanceof Error?r.message:String(r)}`)}try{let s=e.prepare("SELECT id, name, steps, role_preference FROM task_templates WHERE enabled = 1").all(),r=0;for(let t of s){if(t.role_preference)continue;let i;try{i=JSON.parse(t.steps)}catch{continue}if(!Array.isArray(i))continue;let E=!1;for(let n of i){let T=typeof n.roleId=="string"&&n.roleId.length>0,c=n.autoSelectRole===!0;!T&&!c&&(n.autoSelectRole=!0,n.requirements===void 0&&(n.requirements={}),E=!0)}E&&(e.prepare("UPDATE task_templates SET steps = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(i),Date.now(),t.id),r+=1,console.info(`[db migration] template auto-repaired: id=${t.id} name=${t.name}`))}r>0&&console.info(`[db migration] auto-repaired ${r} enabled template(s) with missing role config`)}catch(s){console.error("[db migration] template auto-repair failed:",s)}}function Ke(){if(A)return A;let e=process.env.ADAM_DB_PATH||W,_=de(e);return le(_)||Ne(_,{recursive:!0}),A=new ce(e),A.pragma("journal_mode = WAL"),A.pragma("foreign_keys = ON"),A.pragma("trusted_schema = ON"),Le(A),A}function $e(){A&&(A.close(),A=null)}var D,te,h,w,ee,re,pe,me,A,Re=H(()=>{Y();K();b();D=g("store"),te=["work","flow_complete"].join(""),h=`${te}:`,w=["work","flow_executions"].join(""),ee=["work","flow_artifacts"].join(""),re=["idx","work","flow_executions_event_id"].join("_"),pe=["idx","work","flow_artifacts_execution"].join("_"),me=["idx","work","flow_artifacts_step"].join("_"),A=null});export{J as a,ge as b,Ce as c,Ue as d,De as e,he as f,Q as g,xe as h,ye as i,ke as j,Fe as k,we as l,b as m,Le as n,Ke as o,$e as p,Re as q};
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as G,b as h,c as W,e as z}from"./chunk-AMJJ2WGU.js";import{a as B,b as J}from"./chunk-NTVLV7NI.js";import{a as q}from"./chunk-AUSR5JYV.js";import{c as R,e as K,g as ce}from"./chunk-CN5NEJXG.js";import{d as F}from"./chunk-JRRNGKDK.js";import"./chunk-3MROEPGR.js";import{o as H,p as j,q as le}from"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";import{Command as Se}from"commander";import{fork as de}from"child_process";import{readFileSync as L,writeFileSync as ue,existsSync as v,unlinkSync as $,mkdirSync as me,openSync as pe}from"fs";import{join as E}from"path";import{homedir as ge}from"os";var P=E(ge(),".adam"),y=E(P,"adam.pid"),k=E(P,"adam.port"),b=E(P,"server.log");function fe(){v(P)||me(P,{recursive:!0})}function C(){if(!v(y))return null;let e=parseInt(L(y,"utf-8").trim(),10);return isNaN(e)?null:e}function he(){if(!v(k))return null;let e=parseInt(L(k,"utf-8").trim(),10);return isNaN(e)?null:e}function O(e){try{return process.kill(e,0),!0}catch{return!1}}async function N(){fe();let e=C();if(e&&O(e))throw new Error(`Server already running (PID ${e})`);v(y)&&$(y),v(k)&&$(k);let o=pe(b,"a"),t=E(B,"dist/index.js"),n=de(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(`
2
+ import{a as G,b as h,c as W,e as z}from"./chunk-AMJJ2WGU.js";import{a as B,b as J}from"./chunk-NTVLV7NI.js";import{a as q}from"./chunk-AUSR5JYV.js";import{c as R,e as K,g as ce}from"./chunk-ISTUK7Q6.js";import{d as F}from"./chunk-JRRNGKDK.js";import"./chunk-3MROEPGR.js";import{o as H,p as j,q as le}from"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";import{Command as Se}from"commander";import{fork as de}from"child_process";import{readFileSync as L,writeFileSync as ue,existsSync as v,unlinkSync as $,mkdirSync as me,openSync as pe}from"fs";import{join as E}from"path";import{homedir as ge}from"os";var P=E(ge(),".adam"),y=E(P,"adam.pid"),k=E(P,"adam.port"),b=E(P,"server.log");function fe(){v(P)||me(P,{recursive:!0})}function C(){if(!v(y))return null;let e=parseInt(L(y,"utf-8").trim(),10);return isNaN(e)?null:e}function he(){if(!v(k))return null;let e=parseInt(L(k,"utf-8").trim(),10);return isNaN(e)?null:e}function O(e){try{return process.kill(e,0),!0}catch{return!1}}async function N(){fe();let e=C();if(e&&O(e))throw new Error(`Server already running (PID ${e})`);v(y)&&$(y),v(k)&&$(k);let o=pe(b,"a"),t=E(B,"dist/index.js"),n=de(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:
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";g();export{f as deleteConfigValue,c as getAllConfig,a as getConfigValue,e as isConfigEmpty,d as seedConfig,b as setConfigValue};
1
+ import{a,b,c,d,e,f,g}from"./chunk-ISTUK7Q6.js";import"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.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{n as a,o as b,p as c,q as d}from"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";d();export{c as closeDb,b as getDb,a as runMigrations};
1
+ import{n as a,o as b,p as c,q as d}from"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";d();export{c as closeDb,b as getDb,a as runMigrations};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-DRS5NOAA.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as TTL_MS,g as cleanupExpired,b as createDeliveryLog,j as getDeliveryLogByExecution,i as getDeliveryLogByRule,h as getDeliveryLogByTask,f as getFailedDeliveries,k as getLatestDeliveryForContext,e as getPendingDeliveries,d as markDelivered,c as updateDeliveryLogStatus};
1
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-PU2T7HBY.js";import"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as TTL_MS,g as cleanupExpired,b as createDeliveryLog,j as getDeliveryLogByExecution,i as getDeliveryLogByRule,h as getDeliveryLogByTask,f as getFailedDeliveries,k as getLatestDeliveryForContext,e as getPendingDeliveries,d as markDelivered,c as updateDeliveryLogStatus};
@@ -0,0 +1 @@
1
+ import{g as a,h as b,i as c,j as d}from"./chunk-QQWUWGSK.js";import"./chunk-YGZQMZTA.js";import"./chunk-4N5G7ND2.js";import"./chunk-VVPB3TD4.js";import"./chunk-NNMQGISW.js";import"./chunk-R3MSLP6P.js";import"./chunk-PU2T7HBY.js";import"./chunk-5ZL6RHPE.js";import"./chunk-YI2QQTZE.js";import"./chunk-NX3CIEZA.js";import"./chunk-X3PJNX2R.js";import"./chunk-G5I76LX2.js";import"./chunk-L7JP7DUO.js";import"./chunk-3JTHJ3FZ.js";import"./chunk-XEXSXMWK.js";import"./chunk-ISTUK7Q6.js";import"./chunk-J2VSAXVU.js";import"./chunk-3MROEPGR.js";import"./chunk-6GVYOHD5.js";import"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as DeliveryEngine,b as getDeliveryEngine,c as initDeliveryEngine,d as stopDeliveryEngine};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"./chunk-A3YUIWLK.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as createEvolutionAudit,e as generateDiff,d as getLatestRoleEvolution,b as listEvolutionAudit,c as listEvolutionAuditByRole};
1
+ import{a,b,c,d,e}from"./chunk-SONOE4ZJ.js";import"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as createEvolutionAudit,e as generateDiff,d as getLatestRoleEvolution,b as listEvolutionAudit,c as listEvolutionAuditByRole};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h}from"./chunk-LE5YRP37.js";import"./chunk-N4BV2WAU.js";import"./chunk-KO6UB6VW.js";import"./chunk-X3PJNX2R.js";import"./chunk-6NIWU43Z.js";import"./chunk-G5I76LX2.js";import"./chunk-L7JP7DUO.js";import"./chunk-GYOZGA7G.js";import"./chunk-4NRIKWSD.js";import"./chunk-6SBLFYCU.js";import"./chunk-T2Z2JDPY.js";import"./chunk-AKQ3AFVI.js";import"./chunk-3JTHJ3FZ.js";import"./chunk-ISTUK7Q6.js";import"./chunk-3MROEPGR.js";import"./chunk-6GVYOHD5.js";import"./chunk-ZEGZ2I35.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{e as EXECUTION_TOOLS_ALL_TOOL_NAMES,a as EXECUTION_TOOLS_MCP_NAME,c as EXECUTION_TOOLS_MUTATION_TOOLS,d as EXECUTION_TOOLS_READONLY_TOOLS,b as EXECUTION_TOOLS_TOOL_PREFIX,f as KEY_REGEX,h as createExecutionTools,g as inferMimeFromPath};