thinkpool-pair 0.7.419 → 0.7.420
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/hermes-event-mapper.mjs +1 -1
- package/package.json +1 -1
- package/publish-manifest.json +5 -5
package/hermes-event-mapper.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{evidenceForToolResult as t}from"./evidence-citations.mjs";const e=t=>"string"==typeof t?t:"text"===t?.type?String(t.text||""):"content"===t?.type?e(t.content):"",s=t=>{if("string"==typeof t?.rawOutput)return t.rawOutput;const s=(t?.content||[]).map(e).filter(Boolean).join("\n");if(s)return s;if(null!=t?.rawOutput)try{return JSON.stringify(t.rawOutput)}catch{return String(t.rawOutput)}return""};export function hermesToolFor(t={}){const s=String(t.kind||"").toLowerCase(),n=String(t.title||""),
|
|
1
|
+
import{evidenceForToolResult as t}from"./evidence-citations.mjs";const e=t=>"string"==typeof t?t:"text"===t?.type?String(t.text||""):"content"===t?.type?e(t.content):"",s=t=>{if("string"==typeof t?.rawOutput)return t.rawOutput;const s=(t?.content||[]).map(e).filter(Boolean).join("\n");if(s)return s;if(null!=t?.rawOutput)try{return JSON.stringify(t.rawOutput)}catch{return String(t.rawOutput)}return""};export function hermesToolFor(t={}){const s=String(t.kind||"").toLowerCase(),n=String(t.title||""),i=t.rawInput&&"object"==typeof t.rawInput?t.rawInput:{},o=String(t.server||i.server||""),r=String(t.tool||i.tool||i.name||"");if("project-context"===o&&"search_context_evidence"===r)return{name:"mcp__project-context__search_context_evidence",input:i};const a=(t.content||[]).find(t=>"terminal"===t?.type),d=(t.content||[]).map(e).find(t=>t.trim().startsWith("$ ")),l=t.locations?.[0]?.path;if("execute"===s||a||d)return{name:"Bash",input:{...i,command:i.command||d?.trim().slice(2)||n}};if("edit"===s){const e=(t=>{const e=(Array.isArray(t)?t:[]).filter(t=>"diff"===t?.type);return e.length?1===e.length?{file_path:e[0].path||"",path:e[0].path||"",old_string:e[0].oldText||"",new_string:e[0].newText||""}:{file_path:e[0].path||"",path:e[0].path||"",edits:e.map(t=>({file_path:t.path||"",old_string:t.oldText||"",new_string:t.newText||""}))}:null})(t.content);return{name:e?.edits?"MultiEdit":n.toLowerCase().includes("write")?"Write":"Edit",input:{...i,...e||{},file_path:e?.file_path||i.path||l||"",path:e?.path||i.path||l||""}}}return"read"===s?{name:"Read",input:{...i,file_path:i.path||l||"",path:i.path||l||""}}:"search"===s?{name:"Grep",input:i}:"fetch"===s?{name:"WebFetch",input:i}:{name:n||"HermesTool",input:i}}export class HermesEventMapper{constructor({onEvent:t,sessionId:e=null,model:s=null}={}){this.onEvent=t,this.sessionId=e,this.model=s,this.tools=new Map,this.text="",this.thought="",this.textCid=null,this.turnText="",this._streamSeq=0}_emit(t){try{this.onEvent?.(t)}catch{}}_flushAssistantSegment(){const t=[];return this.thought&&t.push({type:"thinking",text:this.thought,reasoningKind:"thought"}),this.text&&t.push({type:"text",text:this.text}),!!t.length&&(this._emit({kind:"assistant",blocks:t,parentToolUseId:null,...this.textCid?{replacesCid:this.textCid}:{}}),this.text&&(this.turnText=this.turnText?`${this.turnText}\n${this.text}`:this.text),this.text="",this.thought="",this.textCid=null,!0)}startSession({sessionId:t,models:e,modes:s,commands:n=[]}={}){this.sessionId=t||this.sessionId,this.model=e?.currentModelId||this.model;const i=(e?.availableModels||[]).map(t=>({value:t.modelId,displayName:t.name||t.modelId,description:t.description||""}));this._emit({kind:"system",sessionId:this.sessionId,model:this.model,commands:n,models:i,modes:s}),i.length&&this._emit({kind:"models",models:i,model:this.model})}push(n={}){if(n.sessionId&&this.sessionId&&n.sessionId!==this.sessionId)return;const i=n.update||n;switch(i.sessionUpdate){case"agent_message_chunk":{const t=e(i.content);if(!t)return;return this.text+=t,this.textCid||=`hermes-stream:${this.sessionId||"session"}:${Date.now()}:${++this._streamSeq}`,void this._emit({kind:"assistant_stream",cid:this.textCid,text:this.text,streaming:!0})}case"agent_thought_chunk":{const t=e(i.content);if(!t)return;const s=!this.thought;return this.thought+=t,void(s&&this._emit({kind:"active-status",message:"model call active"}))}case"tool_call":{this._flushAssistantSegment();const t=hermesToolFor(i);return this.tools.set(i.toolCallId,{...i,...t,startedAt:Date.now()}),void this._emit({kind:"assistant",blocks:[{type:"tool_use",id:i.toolCallId,name:t.name,input:t.input}],parentToolUseId:null})}case"tool_call_update":{const e=this.tools.get(i.toolCallId)||{},n={...e,...i};if(this.tools.set(i.toolCallId,n),!["completed","failed"].includes(i.status))return;const o=hermesToolFor(n),r=[{type:"text",text:s(n)}],a=t(o.name,r);return this._emit({kind:"tool_result",toolUseId:i.toolCallId,content:r,...a?{evidence:a}:{},toolInput:{...e.input||{},...o.input||{}},isError:"failed"===i.status,durationMs:e.startedAt?Date.now()-e.startedAt:void 0,parentToolUseId:null}),void this.tools.delete(i.toolCallId)}case"usage_update":{const t=Number(i.used)||0,e=Number(i.size)||0;return void this._emit({kind:"usage",ctx:{used:t,max:e,pct:e?Math.min(100,Math.round(t/e*100)):0,over:e>0&&t>e,model:this.model}})}case"available_commands_update":return void this._emit({kind:"system",sessionId:this.sessionId,model:this.model,commands:(i.availableCommands||[]).map(t=>{if("string"==typeof t)return t.startsWith("/")?t:`/${t}`;const e=String(t?.name||"").replace(/^\/+/,""),s=t?.input?.hint||t?.inputHint||t?.input_hint||"";return{name:`/${e}`,description:String(t?.description||""),...s?{inputHint:String(s)}:{}}}).filter(t=>"string"==typeof t?"/"!==t:"/"!==t.name)});case"current_mode_update":return void this._emit({kind:"mode",mode:i.currentModeId});case"plan":{this._flushAssistantSegment();const t=(i.entries||[]).map(t=>({content:t.content||"",activeForm:t.content||"",status:"in_progress"===t.status?"in_progress":"completed"===t.status?"completed":"pending"}));return void this._emit({kind:"assistant",blocks:[{type:"tool_use",id:`hermes-plan:${this.sessionId}`,name:"TodoWrite",input:{todos:t}}],parentToolUseId:null})}default:return}}finishTurn({stopReason:t="end_turn",usage:e=null}={}){for(const[e,s]of this.tools){const n="cancelled"===t;this._emit({kind:"tool_result",toolUseId:e,content:[{type:"text",text:n?"[cancelled]":"Hermes ended the turn without reporting this tool result."}],toolInput:s.input||void 0,isError:!n&&"end_turn"!==t,missing:!n,durationMs:s.startedAt?Date.now()-s.startedAt:void 0,parentToolUseId:null})}this.tools.clear(),this._flushAssistantSegment(),this._emit({kind:"result",subtype:"cancelled"===t?"aborted":"end_turn"===t?"success":"error_during_execution",sessionId:this.sessionId,model:this.model,costUsd:null,usage:e?{input_tokens:Number(e.inputTokens)||0,cache_read_input_tokens:Number(e.cachedReadTokens)||0,cache_creation_input_tokens:0,output_tokens:(Number(e.outputTokens)||0)+(Number(e.thoughtTokens)||0)}:null,numTurns:1,durationMs:void 0,denials:0,resultText:this.turnText||this.text||null}),this.turnText=""}compactOutcome(){const t=String(this.turnText||this.text||"").match(/Context compressed:\s*(\d+)\s*->\s*(\d+)\s*messages[\s\S]*?~?([\d,]+)\s*->\s*~?([\d,]+)\s*tokens/i);return t?{preMessages:Number(t[1]),postMessages:Number(t[2]),preTokens:Number(t[3].replace(/,/g,"")),postTokens:Number(t[4].replace(/,/g,""))}:null}}
|
package/package.json
CHANGED
package/publish-manifest.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
3
|
"package": "thinkpool-pair",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.420",
|
|
5
5
|
"kind": "minified",
|
|
6
6
|
"minifiedModules": 141,
|
|
7
|
-
"sourceModuleBytes":
|
|
8
|
-
"artifactModuleBytes":
|
|
7
|
+
"sourceModuleBytes": 1861854,
|
|
8
|
+
"artifactModuleBytes": 849570,
|
|
9
9
|
"files": {
|
|
10
|
-
"package.json": "
|
|
10
|
+
"package.json": "e7d31b086d9da77a674d9be393de4fc8328e7d895173ecf0ad417851510ef389",
|
|
11
11
|
"LICENSE": "8a030197ca1cad9669909ca14c9ad15cf48d9fe551da526ccaf1fca993eddb23",
|
|
12
12
|
"bridge.mjs": "e5a1ccea71b516549814936808830ec70a5efefd9bbf0190ba8db23504428ebe",
|
|
13
13
|
"bridge-service.sh": "b64f27c473ca8f3a49190fd08c23947ab14ca9958d70b6fa53c7bddc2be91403",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"hermes-model-cache.mjs": "aee23efdebe1aa5e10053f291a9153981fe9b45065c293c9519ca73477251e72",
|
|
62
62
|
"hermes-policy.mjs": "f4dbb4cc2d7bc612fccb08b32054a3eb2c8319d5824cc399a630d3dca4556113",
|
|
63
63
|
"hermes-acp-bootstrap.py": "e2abdad97bdf06fcf5b73d3b78ba8dd2f518e307001056b029e2bf5ee1887406",
|
|
64
|
-
"hermes-event-mapper.mjs": "
|
|
64
|
+
"hermes-event-mapper.mjs": "e7bc344d2a43100b8aef39ac969a27369cde81c9d9b64931029051d89c400b44",
|
|
65
65
|
"hermes-probe.mjs": "3fc419707f0df9342bc3a5fbfbba2ec2ba1511309dfb1ad8cc79f6f8da4e6b3d",
|
|
66
66
|
"hermes-setup.mjs": "50840b3e0101dc94aa2cd6dd2456efd8377e30bd5d797a00d360fae28e13dddb",
|
|
67
67
|
"hermes-isolation.mjs": "50e960ce815c520805245cc75719c9c53e2c5af51b7304c8ecef8a4946e23c6d",
|