clawdi 0.14.95 → 0.14.96
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/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,14 +34,14 @@ ${c}`}],source:a(),...o?{timestamp:o}:{}});for(let m=0;m<l.length;m++){let g=Tr(
|
|
|
34
34
|
FROM messages
|
|
35
35
|
WHERE session_id = ?
|
|
36
36
|
)
|
|
37
|
-
`}function X3(e,t){return ZPe("sha256").update(JSON.stringify([r0e,e.id,e.source,e.model,e.title,e.started_at,e.ended_at,e.message_count,e.input_tokens,e.output_tokens,e.cache_read_tokens,t.presentation_state])).digest("hex")}function s0e(e){let t=new Set(e.prepare("PRAGMA table_info(sessions)").all().map((
|
|
37
|
+
`}function X3(e,t){return ZPe("sha256").update(JSON.stringify([r0e,e.id,e.source,e.model,e.title,e.started_at,e.ended_at,e.message_count,e.input_tokens,e.output_tokens,e.cache_read_tokens,t.presentation_state])).digest("hex")}function s0e(e){let t=new Set(e.prepare("PRAGMA table_info(sessions)").all().map((i)=>i.name)),n=new Set(oD(e).map((i)=>i.name));if(!["id","source"].every((i)=>t.has(i))||!["session_id","role","timestamp"].every((i)=>n.has(i)))return{lastUserInputAt:null,complete:!1};let r=t.has("model_config")?"AND NOT (json_valid(s.model_config) AND json_extract(s.model_config, '$._delegate_from') IS NOT NULL)":"";try{let o=e.prepare(`
|
|
38
38
|
SELECT MAX(m.timestamp) AS last_user_input_at
|
|
39
39
|
FROM messages AS m
|
|
40
40
|
JOIN sessions AS s ON s.id = m.session_id
|
|
41
41
|
WHERE lower(m.role) = 'user'
|
|
42
|
-
AND lower(coalesce(s.source, '')) NOT IN ('cron', 'subagent', 'curator')
|
|
43
|
-
|
|
44
|
-
`).get()?.last_user_input_at??null;if(
|
|
42
|
+
AND lower(coalesce(s.source, '')) NOT IN ('cron', 'subagent', 'curator', 'kanban')
|
|
43
|
+
${r}
|
|
44
|
+
`).get()?.last_user_input_at??null;if(o===null)return{lastUserInputAt:null,complete:!0};let s=Ny(Number(o));return s?{lastUserInputAt:s,complete:!0}:{lastUserInputAt:null,complete:!1}}catch{return{lastUserInputAt:null,complete:!1}}}function oK(e){if(!e?.startsWith(J3))return e;try{return JSON.parse(e.slice(J3.length))}catch{return e}}function Q3(e){let t=e.replace(sK,"");for(let n of t.matchAll(aK)){let r=n.index,i=t.lastIndexOf(`
|
|
45
45
|
`,r-1)+1;if(t.slice(i,r).trim().length===0){t=t.slice(0,r);break}}return t.replace(a0e,"")}function eK(e){let t=[];for(let n of e.matchAll(sK)){let r=n[0].replace(/^<[^>]+>/,"").replace(/<\/[^>]+>$/,"");if(r)t.push(r)}for(let n of e.matchAll(aK)){let r=n.index,i=e.lastIndexOf(`
|
|
46
46
|
`,r-1)+1;if(e.slice(i,r).trim().length>0)continue;let o=e.slice(r+n[0].length);if(!o.includes("</")&&o)t.push(o);break}return t}function tK(e){if(e===null)return;try{return JSON.parse(e)}catch{return e}}function lK(e,t){let n=oK(e);if(!t)return n;if(typeof n==="string")return Q3(n);let r=(i)=>{let o=ve(i);if(!o||typeof o.text!=="string")return i;return{...o,text:Q3(o.text)}};return Array.isArray(n)?n.map(r):r(n)}function l0e(e,t){return tr(lK(e,t)).filter((n)=>n.type!=="text"||n.text.length>0)}function c0e(e){if(e.role!=="assistant")return null;let t=oK(e.content),n=[];if(e.reasoning)n.push(e.reasoning);if(e.reasoning_content)n.push(e.reasoning_content);let r=(o)=>{if(typeof o==="string")n.push(...eK(o));else{let s=ve(o);if(typeof s?.text==="string")n.push(...eK(s.text))}};if(Array.isArray(t))t.forEach(r);else r(t);let i=[...new Set(n.filter(Boolean))];return Tr({type:"reasoning",summary:i.map((o)=>({type:"summary_text",text:o})),reasoning_details:tK(e.reasoning_details),codex_reasoning_items:tK(e.codex_reasoning_items)})}function Ny(e){if(!Number.isFinite(e))return;let t=new Date(e*1000);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function nK(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0?e:void 0}function u0e(e){if(!e)return;let t;try{t=JSON.parse(e)}catch{return}let n=ve(t);if(!n)return;let r={},i=nK(n.task_count),o=nK(n.attempt);if(i!==void 0)r.task_count=i;if(o!==void 0)r.attempt=o;if(Array.isArray(n.reactions)){let s=n.reactions.flatMap((a)=>{let l=ve(a),c=N(l?.emoji),u=N(l?.author);if(!c||c.length>64||!u||u.length>100)return[];let d=typeof l?.at==="number"?Ny(l.at):void 0;return[{emoji:c,author:u,...d?{at:d}:{},...typeof l?.seen==="boolean"?{seen:l.seen}:{}}]});if(s.length>0)r.reactions=s}return Object.keys(r).length>0?r:void 0}function d0e(e){let t=e.display_kind?.trim()||void 0,n=u0e(e.display_metadata);return{lifecycle:e.active?"active":e.compacted?"compacted":"inactive",display:t==="hidden"?"hidden":t?"event":"message",compressed_summary:Boolean(e._compressed_summary),...t?{display_kind:t}:{},...n?{display_metadata:n}:{}}}function p0e(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter((n)=>ve(n)!==null):[]}catch{return[]}}function m0e(e,t,n){let r=d0e(e),i=Ny(e.timestamp),o=(c)=>({adapter:"hermes",session_key:t,record_id:String(e.id),record_seq:e.id,part_index:c}),s=[],a=p0e(e.tool_calls),l=c0e(e);if(l)s.push({type:"reasoning",...l,source:o(0),semantics:r,...i?{timestamp:i}:{},...n?{model:n}:{}});if(e.role==="user"||e.role==="assistant"||e.role==="system"||e.role==="developer"){let c=l0e(e.content,e.role==="assistant");if(c.length>0||a.length===0)s.push({type:"message",role:e.role,parts:c,source:o(0),semantics:r,...i?{timestamp:i}:{},...e.role==="assistant"&&n?{model:n}:{}})}if(e.role==="assistant")for(let c=0;c<a.length;c++){let u=a[c];if(!u)continue;let d=ve(u.function),p=N(d?.name)??N(u.name);if(!p)continue;let m=N(u.id)??`hermes:${t}:${e.id}:tool-call:${c}`,g=d?.arguments??u.arguments;s.push({type:"tool_call",call_id:m,name:p,arguments_json:Or(g),source:o(c+1),semantics:r,...i?{timestamp:i}:{},...n?{model:n}:{}})}if(e.role==="tool")s.push({type:"tool_result",call_id:e.tool_call_id??`hermes:${t}:${e.id}:tool-result`,...e.tool_name?{name:e.tool_name}:{},status:"completed",...Dr(lK(e.content,!1)),source:o(0),semantics:r,...i?{timestamp:i}:{}});return s}function cK(){return Wl()}function Ma(){return Jo(cK(),"state.db")}function ti(){return Jo(cK(),"skills")}function rK(e){return e.startsWith(".")||ro.has(e)}function iK(e){let t=QPe(ti(),e).replaceAll("\\","/");return en(t)?t:null}function f0e(e){if(!e)return null;if(e.startsWith("{"))try{let t=JSON.parse(e);return t.default||t.model||null}catch{return/['"](?:default|model)['"]\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1]??null}return e}class sD{agentType="hermes";sessions={contentProtocol:(e)=>this.getContentProtocol(e),collect:(e,t)=>this.collectSessions(e,t),scan:(e,t,n)=>this.scanSessions(e,t,n),resolve:(e,t)=>this.resolveSession(e,t),watchPaths:()=>this.getSessionsWatchPaths()};skills={collect:(e)=>this.collectSkills(e),listKeys:(e)=>this.listSkillKeys(e),path:(e)=>this.getSkillPath(e),rootDir:()=>this.getSkillsRootDir(),sharedPath:(e,t)=>this.getSharedSkillPath(e,t),writeArchive:(e,t)=>this.writeSkillArchive(e,t),writeSharedArchive:(e,t,n)=>this.writeSharedSkillArchive(e,t,n),remove:(e)=>this.removeLocalSkill(e)};async detect(){return Na(Ma())}async getVersion(){return Oi("hermes",["--version"])}async getContentProtocol(e){if(e?.signal.throwIfAborted(),!Na(Ma()))return"snapshot-v1";let t=await _m(Ma());try{return e?.signal.throwIfAborted(),Y3(oD(t))?"events-v1":"snapshot-v1"}finally{t.close()}}async collectSessions(e,t){t?.signal.throwIfAborted();let n=await this.scanSessions(e,new Map,t),r=[],i=0;for await(let o of n.batches)r.push(...o.sessions),i+=o.dedupedCount;return{sessions:r,dedupedCount:i,coverage:n.coverage}}async scanSessions(e,t,n){if(!Na(Ma()))return{coverage:"complete",userActivity:{lastUserInputAt:null,complete:!1},batches:async function*(){}()};let r=await _m(Ma());try{return n?.signal.throwIfAborted(),{coverage:"complete",userActivity:s0e(r),batches:this.readSessionBatches(r,t,n)}}catch(i){throw r.close(),i}}async*readSessionBatches(e,t,n){try{let r=this.sessionReaders(e),i=null;while(!0){if(n)await e0e(void 0,{signal:n.signal});n?.signal.throwIfAborted();let o=e.prepare(`
|
|
47
47
|
SELECT id, source, model, title, started_at, ended_at,
|
package/package.json
CHANGED