@linzumi/cli 1.0.131 → 1.0.132
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/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
const require = createRequire(import.meta.url);
|
|
3
|
-
import{randomUUID as
|
|
4
|
-
`)}function
|
|
5
|
-
`);case"mcpToolCall":return g(v(
|
|
3
|
+
import{randomUUID as ce}from"node:crypto";import{mkdir as me,realpath as pe,writeFile as _e}from"node:fs/promises";import{homedir as J}from"node:os";import{join as L}from"node:path";function $(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function _(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function h(e,t){let r=e.length,i=new Array(r),n=0;for(let s=0;s<r;++s){let o=e[s],m=t(o);m!==void 0&&(i[n]=_(m),n=n+1|0)}return i.length=n,i}function g(e,t,r){return e!==void 0?r(_(e)):t}function k(e,t){if(e!==void 0)return $(t(_(e)))}function v(e,t){if(e!==void 0)return t(_(e))}function E(e,t){return e!==void 0?_(e):t}var R=["codex","claude-code","pi","opencode"];function M(e){return e}function D(e,t){let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function d(e,t){let r=e[t];if(typeof r=="string")return r}function T(e,t){let r=e[t];if(Array.isArray(r))return r}function I(e){return h(e,t=>{if(typeof t!="object"||t===null||Array.isArray(t))return;if(d(t,"type")==="text")return d(t,"text")}).join(`
|
|
4
|
+
`)}function j(e,t,r,i){return e+":"+t+":"+r+":"+i}function N(e,t){let r=t.split(":"),i=r[0],n=r[1],s=r[2];if(i===void 0||n===void 0||s===void 0||!(i===e&&n!==""&&s!==""&&r.length>=4))return;let o=r.slice(3,r.length).join(":");if(o!=="")return{keySessionId:n,keyTurnId:s,keyItemId:o}}function W(e,t){return{threadId:e,threadTitle:void 0,nodes:t,hasMore:!1,cursor:void 0,budget:void 0,session:void 0}}var V="codex";function ne(e,t,r){return j(V,e,t,r)}function ie(e){if(e===void 0)return"system_notice";switch(e){case"agentMessage":return"assistant_message";case"commandExecution":return"command_execution";case"fileChange":return"file_change";case"collabAgentToolCall":case"dynamicToolCall":case"mcpToolCall":return"tool_call";case"reasoning":return"reasoning";case"plan":case"subAgentActivity":return"agent_status";case"terminalInput":return"terminal_input";case"userMessage":return"user_message";default:return"system_notice"}}function B(e){return h(e,t=>{if(typeof t=="string")return t})}function se(e){let t=d(e,"type");if(t===void 0)return"";switch(t){case"collabAgentToolCall":return E(d(e,"prompt"),"");case"commandExecution":return E(d(e,"aggregatedOutput"),"");case"dynamicToolCall":return g(T(e,"contentItems"),"",I);case"fileChange":return g(T(e,"changes"),[],n=>h(n,s=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s))return d(s,"path")})).join(`
|
|
5
|
+
`);case"mcpToolCall":return g(v(D(e,"result"),n=>T(n,"content")),"",I);case"reasoning":let r=g(T(e,"summary"),[],B),i=g(T(e,"content"),[],B);return r.concat(i).filter(n=>n!=="").join(`
|
|
6
6
|
|
|
7
|
-
`);case"subAgentActivity":return E(
|
|
7
|
+
`);case"subAgentActivity":return E(d(e,"agentPath"),"");case"agentMessage":case"plan":case"terminalInput":return E(d(e,"text"),"");case"userMessage":return g(T(e,"content"),"",I);default:return""}}function oe(e){return new Date(e).toISOString()}function K(e,t){let r=[];return t.turns.forEach(i=>{i.items.forEach(n=>{let s=n.item,o;o=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{};let m=E(d(o,"id"),"");r.push({kind:ie(d(o,"type")),seq:r.length+1|0,at:k(n.completedAtMs,oe),harness:V,body:se(o),structured:n.item,actor:void 0,attachments:[],sourceSeq:void 0,streamKey:ne(t.harnessSessionId,i.turnId,m)})})}),W(e,r)}var ue="claude-code";function le(e){return"rehydrated-"+e.toString()}var ae="rehydrated-marker";function de(e,t){switch(e){case"agent_status":return"[status] "+t;case"approval_request":return"[approval] "+t;case"command_execution":return`[command]
|
|
8
8
|
`+t;case"error":return"[error] "+t;case"file_change":return`[file change]
|
|
9
9
|
`+t;case"system_notice":return"[notice] "+t;case"terminal_input":return`[terminal input]
|
|
10
10
|
`+t;case"tool_call":return`[tool call]
|
|
11
11
|
`+t;case"tool_result":return`[tool result]
|
|
12
|
-
`+t;default:return"["+e+"] "+t}}function
|
|
12
|
+
`+t;default:return"["+e+"] "+t}}function U(e,t,r,i){let n={};n.type="text",n.text=i;let s={};s.role=e,s.content=[n];let o={};return o.type=e,o.session_id=t,o.uuid=r,o.message=s,o}function fe(e,t,r,i,n){return"[linzumi cross-harness resume] This session continues linzumi thread "+r+", "+("imported from the "+e+" session "+t+". ")+(i.toString()+" activity records follow verbatim; ")+(n.toString()+" reasoning records were redacted ")+"(provider-private reasoning is never forged across harnesses)."}function z(e,t){let r={contents:void 0},i=a=>{if(r.contents===void 0){r.contents=a;return}};e===""?i("the caller-bound target session identity must be non-empty"):e.includes(":")&&i("the caller-bound target session identity must be colon-free"),r.contents===void 0&&t.nodes.length===0&&i("an empty page rehydrates nothing - the source session must carry content");let n={contents:void 0},s={contents:void 0};t.nodes.forEach(a=>{if(r.contents===void 0){let l=s.contents;l!==void 0&&a.seq<=l?i("page nodes must ascend by seq"):s.contents=a.seq}if(r.contents===void 0){let l=h(R.map(M),f=>k(v(a.streamKey,c=>N(f,c)),c=>[f,c.keySessionId]))[0];if(l!==void 0){let f=l[1],c=l[0];if(c===ue)i("the page was minted by the claude harness - same-harness resume rides the native session store, never rehydration");else{let b=n.contents;b!==void 0&&(b[0]!==c||b[1]!==f)?i("page mixes two harness session identities"):n.contents=[c,f]}}else i("node carries no parseable minted stream_key identity of a catalog harness")}if(r.contents!==void 0)return;let u=a.structured;if(!(typeof u=="object"&&u!==null&&!Array.isArray(u)))return i("node carries no verbatim native passthrough")});let o=r.contents,m=n.contents;if(o!==void 0)return{TAG:"Error",_0:o};if(m===void 0)return{TAG:"Error",_0:"page carries no source harness identity"};let A=m[1];if(A===e)return{TAG:"Error",_0:"the caller-bound target session identity must be distinct from the source session identity"};let O=m[0],y=[],S=[],p={contents:0};t.nodes.forEach(a=>{let u=a.kind;if(u==="reasoning"){p.contents=p.contents+1|0;return}let l;switch(u){case"assistant_message":l=["assistant",a.body];break;case"user_message":l=["user",a.body];break;default:l=["assistant",de(u,a.body)]}let f=l[0],c=le(a.seq);y.push({sourceSeq:a.seq,sourceKind:u,uuid:c,role:f}),S.push(U(f,e,c,l[1]))});let w=[U("user",e,ae,fe(O,A,t.threadId,S.length,p.contents))].concat(S);return{TAG:"Ok",_0:{session:{harnessSessionId:e,messages:w},report:{sourceHarness:O,sourceSessionId:A,sessionMessageCount:w.length,redactedReasoningCount:p.contents,emissions:y}}}}function he(e,t){if(e.TAG!=="Ok")throw new Error(`${t}: ${JSON.stringify(e._0)}`);return e._0}function ge(e,t=J()){let r=e.replace(/[^a-zA-Z0-9]/g,"-");return L(t,".claude","projects",r)}async function $e({activity:e,codexThreadId:t,kandanThreadId:r,targetSessionId:i=ce(),cwd:n,home:s=J()}){try{let o=(e?.turns??[]).filter(u=>u.items.length>0);if(o.reduce((u,l)=>u+l.items.length,0)===0)return{ok:!1,failure:"no recorded harness activity to carry over (the failover journal is empty)"};let A=K(r,{harnessSessionId:t,turns:o}),O=he(z(i,A),"claude rehydration refused the exported page"),y=n;try{y=await pe(n)}catch{return{ok:!1,failure:`the thread's working directory is not resolvable: ${n}`}}let S=ge(y,s);await me(S,{recursive:!0});let p=L(S,`${i}.jsonl`),G=null,w=Date.now(),a=O.session.messages.map((u,l)=>{let f={parentUuid:G,isSidechain:!1,userType:"external",cwd:y,sessionId:i,version:"0.0.0-linzumi-cross-harness-failover",type:u.type,message:u.message,uuid:u.uuid,timestamp:new Date(w+l).toISOString()};return G=u.uuid,f});return await _e(p,a.map(u=>JSON.stringify(u)).join(`
|
|
13
13
|
`)+`
|
|
14
|
-
`),{ok:!0,targetSessionId:i,sessionFile:p,transpiledItemCount:O.report.emissions.length,redactedReasoningCount:O.report.redactedReasoningCount}}catch(o){return{ok:!1,failure:o instanceof Error?o.message:String(o)}}}export{
|
|
14
|
+
`),{ok:!0,targetSessionId:i,sessionFile:p,transpiledItemCount:O.report.emissions.length,redactedReasoningCount:O.report.redactedReasoningCount}}catch(o){return{ok:!1,failure:o instanceof Error?o.message:String(o)}}}export{ge as claudeSessionStoreDir,$e as transpileAndSeedClaudeSession};
|