import{createRequire as D}from"node:module";var x=Object.defineProperty;var y=(j)=>j;function B(j,q){this[j]=y.bind(null,q)}var J=(j,q)=>{for(var v in q)x(j,v,{get:q[v],enumerable:!0,configurable:!0,set:B.bind(q,v)})};var K=(j,q)=>()=>(j&&(q=j(j=0)),q);var N=D(import.meta.url);function P(j){let q=[];for(let v of j.messages)if(v.role==="user"||v.role==="assistant"){let w=typeof v.content==="string"?v.content:JSON.stringify(v.content);q.push({role:v.role,content:w})}return{sessionId:j.sessionId,messages:q,metadata:{agentId:j.agentId,tenantId:j.tenantId,actorId:j.actorId}}}function G(j){return{sessionId:j?.sessionId,messages:[],metadata:{tenantId:j?.tenantId,actorId:j?.actorId,...j?.metadata}}}function Q(){return G()}function R(j){return{tenantId:j?.tenantId,actorId:j?.actorId,sessionId:j?.sessionId,...j?.metadata}}function V(j,q){return{...j,messages:[...j.messages,{role:"user",content:q}]}}function W(j,q){return{...j,messages:[...j.messages,{role:"assistant",content:q}]}}function X(j){return{...j,messages:[]}}function Y(j,q){return j.messages.slice(-q)}function Z(j){if(typeof j==="string")return[];return j.filter((q)=>q.type==="tool_use")}function _(j,q,v=!1){return{type:"tool_result",tool_use_id:j,content:typeof q==="string"?q:JSON.stringify(q),is_error:v}}function $(j,q){return{...j,metadata:{...j.metadata,...q}}}function f(j){return j.messages.length}function H(j){let q=0;for(let v of j.messages)if(typeof v.content==="string")q+=v.content.length;else q+=JSON.stringify(v.content).length;return Math.ceil(q/4)}function z(j){let q=0,v=0;for(let w of j.messages)if(w.role==="user")q++;else v++;return{messageCount:j.messages.length,userMessages:q,assistantMessages:v,estimatedTokens:H(j)}}export{$ as updateSessionMetadata,P as toClaudeAgentSession,z as summarizeSession,Y as getRecentMessages,f as getMessageCount,Z as extractToolUseBlocks,H as estimateTokens,_ as createToolResultBlock,Q as createEmptyClaudeSession,G as createClaudeAgentSession,X as clearSession,R as buildClaudeAgentContext,V as appendUserMessage,W as appendAssistantMessage};
