shennian 0.2.125 → 0.2.126

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.
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "jsMinified": true,
4
4
  "minifier": "esbuild",
5
- "fileCount": 135,
5
+ "fileCount": 136,
6
6
  "files": [
7
7
  {
8
8
  "file": "bin/shennian.js",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  {
18
18
  "file": "src/agent-env.js",
19
- "beforeBytes": 3799,
20
- "afterBytes": 2099
19
+ "beforeBytes": 4611,
20
+ "afterBytes": 2531
21
21
  },
22
22
  {
23
23
  "file": "src/agents/adapter.js",
@@ -126,13 +126,13 @@
126
126
  },
127
127
  {
128
128
  "file": "src/agents/pi-context.js",
129
- "beforeBytes": 8077,
130
- "afterBytes": 4817
129
+ "beforeBytes": 8159,
130
+ "afterBytes": 4871
131
131
  },
132
132
  {
133
133
  "file": "src/agents/pi.js",
134
- "beforeBytes": 30742,
135
- "afterBytes": 14501
134
+ "beforeBytes": 30797,
135
+ "afterBytes": 14542
136
136
  },
137
137
  {
138
138
  "file": "src/agents/platform-instructions.js",
@@ -481,8 +481,8 @@
481
481
  },
482
482
  {
483
483
  "file": "src/env-path.js",
484
- "beforeBytes": 2795,
485
- "afterBytes": 1377
484
+ "beforeBytes": 3337,
485
+ "afterBytes": 1634
486
486
  },
487
487
  {
488
488
  "file": "src/fs/boundary.js",
@@ -621,8 +621,8 @@
621
621
  },
622
622
  {
623
623
  "file": "src/session/handlers/tool-detail.js",
624
- "beforeBytes": 8800,
625
- "afterBytes": 4161
624
+ "beforeBytes": 10763,
625
+ "afterBytes": 4812
626
626
  },
627
627
  {
628
628
  "file": "src/session/handlers/wechat-helper-runtime.js",
@@ -678,6 +678,11 @@
678
678
  "file": "src/upgrade/engine.js",
679
679
  "beforeBytes": 13403,
680
680
  "afterBytes": 5673
681
+ },
682
+ {
683
+ "file": "src/windows-shell.js",
684
+ "beforeBytes": 1415,
685
+ "afterBytes": 743
681
686
  }
682
687
  ]
683
688
  }
@@ -1,8 +1,8 @@
1
- import v from"node:os";import l from"node:path";import{spawnSync as d}from"node:child_process";import{buildAugmentedPath as m}from"./env-path.js";const c="__SHENNIAN_AGENT_ENV_START__",f="__SHENNIAN_AGENT_ENV_END__";function u(e){return`'${e.replace(/'/g,"'\\''")}'`}function E(e){const n=e.indexOf(c),r=e.indexOf(f,n+c.length);if(n===-1||r===-1)return null;const o=e.slice(n+c.length,r);try{const t=JSON.parse(o),s={};for(const[a,i]of Object.entries(t))typeof i=="string"&&(s[a]=i);return s}catch{return null}}function h(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${u(c)}`,`${u(process.execPath)} -e ${u("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${u(f)}`].join("; ");for(const r of[["-ilc",n],["-lc",n]]){const o=d(e,r,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),t=typeof o.stdout=="string"?E(o.stdout):null;if(t)return t}return null}function _(){const e=`
1
+ import E from"node:os";import u from"node:path";import{spawnSync as d}from"node:child_process";import{buildAugmentedPath as h}from"./env-path.js";import{buildWindowsSystemEnv as m,resolveWindowsPowerShellPath as _}from"./windows-shell.js";const a="__SHENNIAN_AGENT_ENV_START__",p="__SHENNIAN_AGENT_ENV_END__";function l(e){return`'${e.replace(/'/g,"'\\''")}'`}function v(e){const n=e.indexOf(a),i=e.indexOf(p,n+a.length);if(n===-1||i===-1)return null;const r=e.slice(n+a.length,i);try{const t=JSON.parse(r),c={};for(const[s,o]of Object.entries(t))typeof o=="string"&&(c[s]=o);return c}catch{return null}}function g(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${l(a)}`,`${l(process.execPath)} -e ${l("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${l(p)}`].join("; ");for(const i of[["-ilc",n],["-lc",n]]){const r=d(e,i,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),t=typeof r.stdout=="string"?v(r.stdout):null;if(t)return t}return null}function w(){const e=`
2
2
  $envs = @{}
3
3
  [Environment]::GetEnvironmentVariables('Machine').GetEnumerator() | ForEach-Object { $envs[$_.Key] = [string]$_.Value }
4
4
  [Environment]::GetEnvironmentVariables('User').GetEnumerator() | ForEach-Object { $envs[$_.Key] = [string]$_.Value }
5
- Write-Output '${c}'
5
+ Write-Output '${a}'
6
6
  $envs | ConvertTo-Json -Compress
7
- Write-Output '${f}'
8
- `,n=d("powershell.exe",["-NoProfile","-Command",e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0});return typeof n.stdout=="string"?E(n.stdout):null}function g(){return(v.platform()==="win32"?_():h())??{}}function N(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return n.PATH=$(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function V(e={}){return N({daemonEnv:process.env,userEnv:g(),extra:e})}function p(e){return e?.PATH??e?.Path??e?.path}function $(e,n,r,o){const t=[];for(const a of[p(e),p(n),p(r)])for(const i of(a??"").split(l.delimiter))i&&!t.includes(i)&&t.push(i);const s=l.dirname(process.execPath);return s&&!t.includes(s)&&t.unshift(s),m({pathValue:t.join(l.delimiter),env:o})}export{V as buildAgentProcessEnv,N as mergeAgentProcessEnv,g as readLatestUserEnv};
7
+ Write-Output '${p}'
8
+ `,n=d(_(),["-NoProfile","-Command",e],{env:{...process.env,...m(process.env)},encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0});return typeof n.stdout=="string"?v(n.stdout):null}function N(){return(E.platform()==="win32"?w():g())??{}}function S(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return process.platform==="win32"&&Object.assign(n,m(n)),n.PATH=P(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function j(e={}){return S({daemonEnv:process.env,userEnv:N(),extra:e})}function f(e){return e?.PATH??e?.Path??e?.path}function P(e,n,i,r){const t=[];for(const s of[f(e),f(n),f(i)])for(const o of(s??"").split(u.delimiter))o&&!t.includes(o)&&t.push(o);if(process.platform==="win32"){const s=r.SystemRoot||r.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const o of[u.win32.join(s,"System32"),u.win32.join(s,"System32","WindowsPowerShell","v1.0"),u.win32.join(s)])o&&!t.includes(o)&&t.push(o)}const c=u.dirname(process.execPath);return c&&!t.includes(c)&&t.unshift(c),h({pathValue:t.join(u.delimiter),env:r})}export{j as buildAgentProcessEnv,S as mergeAgentProcessEnv,N as readLatestUserEnv};
@@ -1,12 +1,12 @@
1
- import u from"node:fs";import l from"node:path";import{resolveShennianPath as x}from"../config/index.js";const S="qwen3.6-plus";function w(e,t=process.platform){return t==="win32"?{file:"powershell.exe",args:["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",e],shell:"powershell"}:{file:"bash",args:["-c",e],shell:"bash"}}function d(e=S,t={}){return{id:e,name:e,api:"openai-completions",provider:t.provider??"shennian-proxy",baseUrl:t.baseUrl??"",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,...t.compat?{compat:t.compat}:{}}}const O=`\u4F60\u662F\u795E\u5FF5\u5185\u7F6E\u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u672C\u5730\u673A\u5668\u4E0A\u3002
1
+ import u from"node:fs";import l from"node:path";import{resolveShennianPath as S}from"../config/index.js";import{resolveWindowsPowerShellPath as x}from"../windows-shell.js";const d="qwen3.6-plus";function P(e,t=process.platform){return t==="win32"?{file:x(),args:["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",e],shell:"powershell"}:{file:"bash",args:["-c",e],shell:"bash"}}function E(e=d,t={}){return{id:e,name:e,api:"openai-completions",provider:t.provider??"shennian-proxy",baseUrl:t.baseUrl??"",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,...t.compat?{compat:t.compat}:{}}}const $=`\u4F60\u662F\u795E\u5FF5\u5185\u7F6E\u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u672C\u5730\u673A\u5668\u4E0A\u3002
2
2
  \u4F60\u53EF\u4EE5\u8BFB\u5199\u6587\u4EF6\u3001\u6267\u884C shell \u547D\u4EE4\u3001\u5E2E\u52A9\u7528\u6237\u5B8C\u6210\u7F16\u7A0B\u548C\u7CFB\u7EDF\u7BA1\u7406\u4EFB\u52A1\u3002
3
3
  \u5DE5\u4F5C\u76EE\u5F55\u5DF2\u8BBE\u7F6E\uFF0C\u64CD\u4F5C\u6587\u4EF6\u65F6\u4F7F\u7528\u76F8\u5BF9\u8DEF\u5F84\u6216\u7EDD\u5BF9\u8DEF\u5F84\u5747\u53EF\u3002
4
4
  \u5F53\u524D shell \u4F1A\u968F\u64CD\u4F5C\u7CFB\u7EDF\u9009\u62E9\uFF1AWindows \u4F7F\u7528 PowerShell\uFF0CmacOS/Linux \u4F7F\u7528 bash\u3002Windows \u4E0B\u9700\u8981\u771F\u5B9E curl \u65F6\u4F7F\u7528 curl.exe\uFF0C\u907F\u514D PowerShell \u7684 curl \u522B\u540D\u3002
5
- \u4FDD\u6301\u56DE\u590D\u7B80\u6D01\u3001\u51C6\u786E\uFF0C\u4E2D\u6587\u56DE\u590D\u3002`,h=24e3;function E(e){let t=l.resolve(e||process.cwd());try{const n=u.existsSync(t)?u.statSync(t):null;n&&!n.isDirectory()&&(t=l.dirname(t))}catch{}for(;;){const n=l.join(t,"AGENTS.md");if(u.existsSync(n))return n;const o=l.dirname(t);if(o===t)return null;t=o}}function $(e){const t=E(e);if(!t)return null;try{const n=u.readFileSync(t,"utf-8").trim();if(!n)return null;const o=n.length>h?`${n.slice(0,h)}
5
+ \u4FDD\u6301\u56DE\u590D\u7B80\u6D01\u3001\u51C6\u786E\uFF0C\u4E2D\u6587\u56DE\u590D\u3002`,h=24e3;function N(e){let t=l.resolve(e||process.cwd());try{const n=u.existsSync(t)?u.statSync(t):null;n&&!n.isDirectory()&&(t=l.dirname(t))}catch{}for(;;){const n=l.join(t,"AGENTS.md");if(u.existsSync(n))return n;const o=l.dirname(t);if(o===t)return null;t=o}}function b(e){const t=N(e);if(!t)return null;try{const n=u.readFileSync(t,"utf-8").trim();if(!n)return null;const o=n.length>h?`${n.slice(0,h)}
6
6
 
7
7
  ...\uFF08AGENTS.md \u5DF2\u622A\u65AD\uFF09`:n;return`# AGENTS.md instructions for ${l.dirname(t)}
8
8
 
9
- ${o}`}catch{return null}}const P=9e4,b=6,N=x("sessions"),k="summary.json",C="snapshot.json",L="messages.jsonl",j="pi-context.json";function R(e){let t=0;for(const n of e)t+=JSON.stringify(n).length;return Math.ceil(t/3)}function D(e){const t=[];for(const n of e){const o=n,s=String(o.role??"unknown");if(Array.isArray(o.content)){for(const r of o.content)if(r.type==="text"&&typeof r.text=="string")t.push(`[${s}] ${r.text.slice(0,500)}`);else if(r.type==="toolCall"){const c=typeof r.name=="string"?r.name:typeof r.toolName=="string"?r.toolName:"tool",i=r.arguments??r.args??{};t.push(`[${s}] tool:${c}(${JSON.stringify(i).slice(0,200)})`)}}}return t.join(`
10
- `)}function I(e){return JSON.parse(JSON.stringify(e))}function J(e){return l.join(N,e)}function A(e){if(!e||typeof e!="object")return null;const t=e;if(t.type==="text"&&typeof t.text=="string")return t.text;if(t.type==="thinking"&&typeof t.thinking=="string")return`[thinking] ${t.thinking}`;if(t.type==="toolCall"){const n=typeof t.name=="string"?t.name:typeof t.toolName=="string"?t.toolName:"tool",o=t.arguments??t.args??{};return`[toolCall] ${n}(${JSON.stringify(o).slice(0,300)})`}return t.type==="image"&&typeof t.mimeType=="string"?`[image] ${t.mimeType}`:null}function G(e,t){const n=[];for(const r of t){const c=String(r.role??"unknown"),i=Array.isArray(r.content)?r.content:[];for(const p of i){const a=A(p);a&&n.push(`[${c}] ${a}`)}}const s=n.slice(-8).join(`
11
- `).trim()||e?.trim()||null;return s?s.length>2e3?s.slice(s.length-2e3):s:null}function F(e,t){const n=Math.min(e.length,t.length);for(let o=0;o<n;o++)if(JSON.stringify(e[o])!==JSON.stringify(t[o]))return o;return n}async function U(e,t,n){const o=await fetch(`${e}/api/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({model:d("qwen-plus"),context:{messages:[{role:"user",content:[{type:"text",text:n}]}]},options:{temperature:.3,maxTokens:500}})});if(!o.ok||!o.body)return null;const s=o.body.getReader(),r=new TextDecoder,c=[];let i="";for(;;){const{done:p,value:a}=await s.read();if(p)break;i+=r.decode(a,{stream:!0});const m=i.split(`
12
- `);i=m.pop()??"";for(const g of m){if(!g.startsWith("data: "))continue;const y=g.slice(6).trim();if(!y)continue;const f=JSON.parse(y);f.type==="text_delta"&&typeof f.delta=="string"&&c.push(f.delta)}}return c.join("").trim()||null}export{P as CONTEXT_TOKEN_THRESHOLD,b as KEEP_RECENT_MESSAGES,j as LEGACY_SUMMARY_FILENAME,L as MESSAGES_FILENAME,S as PI_DEFAULT_MODEL_ID,C as SNAPSHOT_FILENAME,k as SUMMARY_FILENAME,O as SYSTEM_PROMPT,G as buildRollingSummary,w as buildShellCommandSpec,I as cloneMessages,d as createPiModel,R as estimateTokens,E as findAgentsMd,J as getSessionDir,$ as loadAgentsMdInstructions,F as longestCommonPrefixLength,D as messagesToText,U as requestProxySummary};
9
+ ${o}`}catch{return null}}const k=9e4,C=6,A=S("sessions"),L="summary.json",j="snapshot.json",R="messages.jsonl",D="pi-context.json";function I(e){let t=0;for(const n of e)t+=JSON.stringify(n).length;return Math.ceil(t/3)}function J(e){const t=[];for(const n of e){const o=n,s=String(o.role??"unknown");if(Array.isArray(o.content)){for(const r of o.content)if(r.type==="text"&&typeof r.text=="string")t.push(`[${s}] ${r.text.slice(0,500)}`);else if(r.type==="toolCall"){const c=typeof r.name=="string"?r.name:typeof r.toolName=="string"?r.toolName:"tool",i=r.arguments??r.args??{};t.push(`[${s}] tool:${c}(${JSON.stringify(i).slice(0,200)})`)}}}return t.join(`
10
+ `)}function G(e){return JSON.parse(JSON.stringify(e))}function F(e){return l.join(A,e)}function T(e){if(!e||typeof e!="object")return null;const t=e;if(t.type==="text"&&typeof t.text=="string")return t.text;if(t.type==="thinking"&&typeof t.thinking=="string")return`[thinking] ${t.thinking}`;if(t.type==="toolCall"){const n=typeof t.name=="string"?t.name:typeof t.toolName=="string"?t.toolName:"tool",o=t.arguments??t.args??{};return`[toolCall] ${n}(${JSON.stringify(o).slice(0,300)})`}return t.type==="image"&&typeof t.mimeType=="string"?`[image] ${t.mimeType}`:null}function W(e,t){const n=[];for(const r of t){const c=String(r.role??"unknown"),i=Array.isArray(r.content)?r.content:[];for(const p of i){const a=T(p);a&&n.push(`[${c}] ${a}`)}}const s=n.slice(-8).join(`
11
+ `).trim()||e?.trim()||null;return s?s.length>2e3?s.slice(s.length-2e3):s:null}function v(e,t){const n=Math.min(e.length,t.length);for(let o=0;o<n;o++)if(JSON.stringify(e[o])!==JSON.stringify(t[o]))return o;return n}async function U(e,t,n){const o=await fetch(`${e}/api/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({model:E("qwen-plus"),context:{messages:[{role:"user",content:[{type:"text",text:n}]}]},options:{temperature:.3,maxTokens:500}})});if(!o.ok||!o.body)return null;const s=o.body.getReader(),r=new TextDecoder,c=[];let i="";for(;;){const{done:p,value:a}=await s.read();if(p)break;i+=r.decode(a,{stream:!0});const m=i.split(`
12
+ `);i=m.pop()??"";for(const g of m){if(!g.startsWith("data: "))continue;const y=g.slice(6).trim();if(!y)continue;const f=JSON.parse(y);f.type==="text_delta"&&typeof f.delta=="string"&&c.push(f.delta)}}return c.join("").trim()||null}export{k as CONTEXT_TOKEN_THRESHOLD,C as KEEP_RECENT_MESSAGES,D as LEGACY_SUMMARY_FILENAME,R as MESSAGES_FILENAME,d as PI_DEFAULT_MODEL_ID,j as SNAPSHOT_FILENAME,L as SUMMARY_FILENAME,$ as SYSTEM_PROMPT,W as buildRollingSummary,P as buildShellCommandSpec,G as cloneMessages,E as createPiModel,I as estimateTokens,N as findAgentsMd,F as getSessionDir,b as loadAgentsMdInstructions,v as longestCommonPrefixLength,J as messagesToText,U as requestProxySummary};
@@ -1,14 +1,14 @@
1
- import{randomUUID as C}from"node:crypto";import c from"node:fs";import g from"node:path";import{execFile as _}from"node:child_process";import{promisify as b}from"node:util";import{Agent as A,streamProxy as T}from"@mariozechner/pi-agent-core";import{streamOpenAICompletions as I}from"@mariozechner/pi-ai/openai-completions";import{Type as d}from"@sinclair/typebox";import{AgentAdapter as D,registerAgent as j}from"./adapter.js";import{buildExternalChannelInstructions as F}from"./external-channel-instructions.js";import{loadConfig as L}from"../config/index.js";import{getManagedAgentProviderConfig as O}from"./config-status.js";import{SERVERS as $}from"../region.js";import{buildRollingSummary as E,buildShellCommandSpec as P,cloneMessages as y,CONTEXT_TOKEN_THRESHOLD as v,createPiModel as M,estimateTokens as w,getSessionDir as N,KEEP_RECENT_MESSAGES as k,LEGACY_SUMMARY_FILENAME as q,loadAgentsMdInstructions as z,longestCommonPrefixLength as R,MESSAGES_FILENAME as U,messagesToText as B,PI_DEFAULT_MODEL_ID as K,requestProxySummary as G,SNAPSHOT_FILENAME as J,SYSTEM_PROMPT as H,SUMMARY_FILENAME as Y}from"./pi-context.js";import{buildShellCommandSpec as yt}from"./pi-context.js";const W=b(_),V="https://dashscope.aliyuncs.com/compatible-mode/v1";function f(p,t){return g.resolve(p,t)}async function X(p,t,e,n){const i=P(t),{stdout:s,stderr:a}=await W(i.file,i.args,{cwd:p,env:{...process.env,...e},timeout:3e4,signal:n,maxBuffer:1024*1024,windowsHide:!0});return{stdout:s,stderr:a,shell:i.shell}}function Q(p,t={}){return[{name:"read_file",label:"\u8BFB\u53D6\u6587\u4EF6",description:"Read the full content of a file at the given path.",parameters:d.Object({path:d.String({description:"Absolute or relative file path"})}),async execute(e,{path:n}){let i="";try{return i=f(p,n),{content:[{type:"text",text:c.readFileSync(i,"utf-8")}],details:{path:i}}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:String(s)}`}],details:{path:i}}}}},{name:"write_file",label:"\u5199\u5165\u6587\u4EF6",description:"Write content to a file, creating it or overwriting if it exists.",parameters:d.Object({path:d.String({description:"Absolute or relative file path"}),content:d.String({description:"File content to write"})}),async execute(e,{path:n,content:i}){let s="";try{return s=f(p,n),c.mkdirSync(g.dirname(s),{recursive:!0}),c.writeFileSync(s,i,"utf-8"),{content:[{type:"text",text:`Written ${i.length} bytes to ${s}`}],details:{path:s}}}catch(a){return{content:[{type:"text",text:`Error: ${a instanceof Error?a.message:String(a)}`}],details:{path:s}}}}},{name:"list_directory",label:"\u5217\u51FA\u76EE\u5F55",description:"List files and directories at the given path.",parameters:d.Object({path:d.String({description:"Directory path to list",default:"."})}),async execute(e,{path:n}){let i="";try{return i=f(p,n),{content:[{type:"text",text:c.readdirSync(i,{withFileTypes:!0}).map(o=>`${o.isDirectory()?"d":"f"} ${o.name}`).join(`
2
- `)||"(empty)"}],details:{path:i}}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:String(s)}`}],details:{path:i}}}}},{name:"bash",label:"\u6267\u884C\u547D\u4EE4",description:"Execute a shell command in the working directory. Uses PowerShell on Windows and bash on macOS/Linux. Timeout: 30s.",parameters:d.Object({command:d.String({description:"Shell command to execute"})}),async execute(e,{command:n},i){try{const{stdout:s,stderr:a,shell:o}=await X(p,n,t,i);return{content:[{type:"text",text:[s,a].filter(Boolean).join(`
1
+ import{randomUUID as C}from"node:crypto";import c from"node:fs";import g from"node:path";import{execFile as b}from"node:child_process";import{promisify as _}from"node:util";import{Agent as A,streamProxy as T}from"@mariozechner/pi-agent-core";import{streamOpenAICompletions as I}from"@mariozechner/pi-ai/openai-completions";import{Type as d}from"@sinclair/typebox";import{AgentAdapter as D,registerAgent as j}from"./adapter.js";import{buildExternalChannelInstructions as F}from"./external-channel-instructions.js";import{loadConfig as L}from"../config/index.js";import{getManagedAgentProviderConfig as O}from"./config-status.js";import{SERVERS as $}from"../region.js";import{buildAgentProcessEnv as N}from"../agent-env.js";import{buildRollingSummary as E,buildShellCommandSpec as P,cloneMessages as y,CONTEXT_TOKEN_THRESHOLD as v,createPiModel as M,estimateTokens as w,getSessionDir as q,KEEP_RECENT_MESSAGES as k,LEGACY_SUMMARY_FILENAME as z,loadAgentsMdInstructions as R,longestCommonPrefixLength as U,MESSAGES_FILENAME as B,messagesToText as K,PI_DEFAULT_MODEL_ID as G,requestProxySummary as J,SNAPSHOT_FILENAME as H,SYSTEM_PROMPT as Y,SUMMARY_FILENAME as W}from"./pi-context.js";import{buildShellCommandSpec as ft}from"./pi-context.js";const V=_(b),X="https://dashscope.aliyuncs.com/compatible-mode/v1";function f(p,t){return g.resolve(p,t)}async function Q(p,t,e,n){const i=P(t),{stdout:s,stderr:a}=await V(i.file,i.args,{cwd:p,env:N(e),timeout:3e4,signal:n,maxBuffer:1024*1024,windowsHide:!0});return{stdout:s,stderr:a,shell:i.shell}}function Z(p,t={}){return[{name:"read_file",label:"\u8BFB\u53D6\u6587\u4EF6",description:"Read the full content of a file at the given path.",parameters:d.Object({path:d.String({description:"Absolute or relative file path"})}),async execute(e,{path:n}){let i="";try{return i=f(p,n),{content:[{type:"text",text:c.readFileSync(i,"utf-8")}],details:{path:i}}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:String(s)}`}],details:{path:i}}}}},{name:"write_file",label:"\u5199\u5165\u6587\u4EF6",description:"Write content to a file, creating it or overwriting if it exists.",parameters:d.Object({path:d.String({description:"Absolute or relative file path"}),content:d.String({description:"File content to write"})}),async execute(e,{path:n,content:i}){let s="";try{return s=f(p,n),c.mkdirSync(g.dirname(s),{recursive:!0}),c.writeFileSync(s,i,"utf-8"),{content:[{type:"text",text:`Written ${i.length} bytes to ${s}`}],details:{path:s}}}catch(a){return{content:[{type:"text",text:`Error: ${a instanceof Error?a.message:String(a)}`}],details:{path:s}}}}},{name:"list_directory",label:"\u5217\u51FA\u76EE\u5F55",description:"List files and directories at the given path.",parameters:d.Object({path:d.String({description:"Directory path to list",default:"."})}),async execute(e,{path:n}){let i="";try{return i=f(p,n),{content:[{type:"text",text:c.readdirSync(i,{withFileTypes:!0}).map(o=>`${o.isDirectory()?"d":"f"} ${o.name}`).join(`
2
+ `)||"(empty)"}],details:{path:i}}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:String(s)}`}],details:{path:i}}}}},{name:"bash",label:"\u6267\u884C\u547D\u4EE4",description:"Execute a shell command in the working directory. Uses PowerShell on Windows and bash on macOS/Linux. Timeout: 30s.",parameters:d.Object({command:d.String({description:"Shell command to execute"})}),async execute(e,{command:n},i){try{const{stdout:s,stderr:a,shell:o}=await Q(p,n,t,i);return{content:[{type:"text",text:[s,a].filter(Boolean).join(`
3
3
  ---stderr---
4
- `)||"(no output)"}],details:{command:n,shell:o}}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:String(s)}`}],details:{command:n,shell:P(n).shell}}}}},{name:"read_image",label:"\u8BFB\u53D6\u56FE\u7247",description:"Read an image file and return its content for visual analysis. Supports png, jpg, jpeg, gif, webp. Max 10 MB.",parameters:d.Object({path:d.String({description:"Absolute or relative path to the image file"})}),async execute(e,{path:n}){let i;try{i=f(p,n)}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:String(r)}`}],details:{path:n}}}const s=g.extname(i).toLowerCase().slice(1),o={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"}[s];if(!o)return{content:[{type:"text",text:`Error: unsupported image type ".${s}". Supported: png, jpg, jpeg, gif, webp`}],details:{path:i}};try{const r=c.statSync(i);return r.size>10*1024*1024?{content:[{type:"text",text:`Error: image too large (${(r.size/1024/1024).toFixed(1)} MB, max 10 MB)`}],details:{path:i}}:{content:[{type:"image",data:c.readFileSync(i).toString("base64"),mimeType:o}],details:{path:i,mimeType:o,size:r.size}}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:String(r)}`}],details:{path:i}}}}}]}class Z extends D{type="pi";agent=null;sessionId=null;workDir=null;seq=0;runId="";emittedLengths=new Map;terminalState="open";authToken=null;proxyUrl=null;providerConfig;sessionDir=null;messagesPath=null;snapshotPath=null;summaryPath=null;cachedSummary=null;restoredMessages=[];compressing=!1;lastSummaryMsgCount=0;pendingBaseMessages=[];finalizePromise=Promise.resolve();sendGeneration=0;externalChannel=null;shennianSessionId=null;extraEnv={};pendingSendStart=null;configure(t){this.shennianSessionId=t.sessionId??null,this.externalChannel=t.externalChannel??null,this.extraEnv=t.env??{}}async start(t,e,n){this.sessionId=t,this.workDir=e,this.seq=0,this.sessionDir=N(t),this.messagesPath=g.join(this.sessionDir,U),this.snapshotPath=g.join(this.sessionDir,J),this.summaryPath=g.join(this.sessionDir,Y),this.loadSnapshot(),this.loadSummary()}async send(t,e){const n=++this.sendGeneration,i=this.agent&&this.terminalState==="open"?y(this.pendingBaseMessages):null;i&&(this.agent?.abort(),this.agent=null,this.restoredMessages=i,this.finalizePromise=Promise.resolve());const s=L(),a=s.machineToken??s.accessToken;if(!a){this.emit("agentEvent",{state:"error",runId:this.runId,seq:++this.seq,message:"\u672A\u914D\u5BF9\uFF0C\u8BF7\u5148\u8FD0\u884C shennian \u5B8C\u6210\u673A\u5668\u914D\u5BF9"});return}this.authToken=a,this.proxyUrl=(s.serverUrl??$.cn.url).replace(/\/$/,"");const o=O("pi"),r=s.apiKeys?.dashscope?.trim();this.providerConfig=o??(r?{agent:"pi",token:r,updatedAt:""}:void 0),this.runId=C(),this.seq=0,this.emittedLengths.clear(),this.terminalState="open",this.agent||this.initAgent(),await this.finalizePromise.catch(()=>{}),this.agent?.setModel(M(e??K)),this.pendingBaseMessages=y(this.agent?.state.messages??[]);const u=this.runId,l=new Promise((h,m)=>{this.pendingSendStart={runId:u,resolve:h,reject:m}});this.emit("agentEvent",{state:"init",runId:u,seq:++this.seq}),this.agent.prompt(t).then(async()=>{n===this.sendGeneration&&(this.resolvePendingSendStart(u),await this.finalizePromise.catch(()=>{}))}).catch(h=>{if(n!==this.sendGeneration||(this.rejectPendingSendStart(u,h),this.terminalState!=="open"))return;this.terminalState="error";const m=h instanceof Error?h.message:String(h);m.includes("429")||m.includes("daily_quota_exceeded")||m.includes("nian_quota_exceeded")?this.emit("agentEvent",{state:"error",runId:u,seq:++this.seq,message:"Nian \u4ECA\u65E5\u989D\u5EA6\u5DF2\u7528\u5B8C\uFF0C\u6B21\u65E5\u81EA\u52A8\u6062\u590D\u3002"}):this.emit("agentEvent",{state:"error",runId:u,seq:++this.seq,message:m})}),await l}initAgent(){const t=this.workDir??process.cwd(),e=Q(t,this.extraEnv),n=z(t),i=new A({initialState:{systemPrompt:[H,n,`\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${t}`,F(this.externalChannel,t,this.shennianSessionId??void 0)].filter(Boolean).join(`
4
+ `)||"(no output)"}],details:{command:n,shell:o}}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:String(s)}`}],details:{command:n,shell:P(n).shell}}}}},{name:"read_image",label:"\u8BFB\u53D6\u56FE\u7247",description:"Read an image file and return its content for visual analysis. Supports png, jpg, jpeg, gif, webp. Max 10 MB.",parameters:d.Object({path:d.String({description:"Absolute or relative path to the image file"})}),async execute(e,{path:n}){let i;try{i=f(p,n)}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:String(r)}`}],details:{path:n}}}const s=g.extname(i).toLowerCase().slice(1),o={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"}[s];if(!o)return{content:[{type:"text",text:`Error: unsupported image type ".${s}". Supported: png, jpg, jpeg, gif, webp`}],details:{path:i}};try{const r=c.statSync(i);return r.size>10*1024*1024?{content:[{type:"text",text:`Error: image too large (${(r.size/1024/1024).toFixed(1)} MB, max 10 MB)`}],details:{path:i}}:{content:[{type:"image",data:c.readFileSync(i).toString("base64"),mimeType:o}],details:{path:i,mimeType:o,size:r.size}}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:String(r)}`}],details:{path:i}}}}}]}class tt extends D{type="pi";agent=null;sessionId=null;workDir=null;seq=0;runId="";emittedLengths=new Map;terminalState="open";authToken=null;proxyUrl=null;providerConfig;sessionDir=null;messagesPath=null;snapshotPath=null;summaryPath=null;cachedSummary=null;restoredMessages=[];compressing=!1;lastSummaryMsgCount=0;pendingBaseMessages=[];finalizePromise=Promise.resolve();sendGeneration=0;externalChannel=null;shennianSessionId=null;extraEnv={};pendingSendStart=null;configure(t){this.shennianSessionId=t.sessionId??null,this.externalChannel=t.externalChannel??null,this.extraEnv=t.env??{}}async start(t,e,n){this.sessionId=t,this.workDir=e,this.seq=0,this.sessionDir=q(t),this.messagesPath=g.join(this.sessionDir,B),this.snapshotPath=g.join(this.sessionDir,H),this.summaryPath=g.join(this.sessionDir,W),this.loadSnapshot(),this.loadSummary()}async send(t,e){const n=++this.sendGeneration,i=this.agent&&this.terminalState==="open"?y(this.pendingBaseMessages):null;i&&(this.agent?.abort(),this.agent=null,this.restoredMessages=i,this.finalizePromise=Promise.resolve());const s=L(),a=s.machineToken??s.accessToken;if(!a){this.emit("agentEvent",{state:"error",runId:this.runId,seq:++this.seq,message:"\u672A\u914D\u5BF9\uFF0C\u8BF7\u5148\u8FD0\u884C shennian \u5B8C\u6210\u673A\u5668\u914D\u5BF9"});return}this.authToken=a,this.proxyUrl=(s.serverUrl??$.cn.url).replace(/\/$/,"");const o=O("pi"),r=s.apiKeys?.dashscope?.trim();this.providerConfig=o??(r?{agent:"pi",token:r,updatedAt:""}:void 0),this.runId=C(),this.seq=0,this.emittedLengths.clear(),this.terminalState="open",this.agent||this.initAgent(),await this.finalizePromise.catch(()=>{}),this.agent?.setModel(M(e??G)),this.pendingBaseMessages=y(this.agent?.state.messages??[]);const u=this.runId,l=new Promise((h,m)=>{this.pendingSendStart={runId:u,resolve:h,reject:m}});this.emit("agentEvent",{state:"init",runId:u,seq:++this.seq}),this.agent.prompt(t).then(async()=>{n===this.sendGeneration&&(this.resolvePendingSendStart(u),await this.finalizePromise.catch(()=>{}))}).catch(h=>{if(n!==this.sendGeneration||(this.rejectPendingSendStart(u,h),this.terminalState!=="open"))return;this.terminalState="error";const m=h instanceof Error?h.message:String(h);m.includes("429")||m.includes("daily_quota_exceeded")||m.includes("nian_quota_exceeded")?this.emit("agentEvent",{state:"error",runId:u,seq:++this.seq,message:"Nian \u4ECA\u65E5\u989D\u5EA6\u5DF2\u7528\u5B8C\uFF0C\u6B21\u65E5\u81EA\u52A8\u6062\u590D\u3002"}):this.emit("agentEvent",{state:"error",runId:u,seq:++this.seq,message:m})}),await l}initAgent(){const t=this.workDir??process.cwd(),e=Z(t,this.extraEnv),n=R(t),i=new A({initialState:{systemPrompt:[Y,n,`\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${t}`,F(this.externalChannel,t,this.shennianSessionId??void 0)].filter(Boolean).join(`
5
5
 
6
- `),model:M(),tools:e},streamFn:(s,a,o)=>{const r=this.providerConfig;return r?.token?I(M(s.id,{provider:"dashscope",baseUrl:r.baseUrl||V,compat:{supportsDeveloperRole:!1,supportsStore:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"qwen"}}),a,{...o,apiKey:r.token}):T(s,a,{...o,authToken:this.authToken,proxyUrl:this.proxyUrl})},transformContext:s=>this.compressContext(s)});this.agent=i,this.restoredMessages.length>0?i.replaceMessages(y(this.restoredMessages)):this.cachedSummary&&(i.appendMessage({role:"user",content:[{type:"text",text:`[\u4E4B\u524D\u7684\u5BF9\u8BDD\u6458\u8981]
6
+ `),model:M(),tools:e},streamFn:(s,a,o)=>{const r=this.providerConfig;return r?.token?I(M(s.id,{provider:"dashscope",baseUrl:r.baseUrl||X,compat:{supportsDeveloperRole:!1,supportsStore:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"qwen"}}),a,{...o,apiKey:r.token}):T(s,a,{...o,authToken:this.authToken,proxyUrl:this.proxyUrl})},transformContext:s=>this.compressContext(s)});this.agent=i,this.restoredMessages.length>0?i.replaceMessages(y(this.restoredMessages)):this.cachedSummary&&(i.appendMessage({role:"user",content:[{type:"text",text:`[\u4E4B\u524D\u7684\u5BF9\u8BDD\u6458\u8981]
7
7
  ${this.cachedSummary}`}],timestamp:Date.now()}),i.appendMessage({role:"assistant",content:[{type:"text",text:"\u597D\u7684\uFF0C\u6211\u5DF2\u4E86\u89E3\u4E4B\u524D\u7684\u5BF9\u8BDD\u4E0A\u4E0B\u6587\uFF0C\u8BF7\u7EE7\u7EED\u3002"}],timestamp:Date.now()})),i.subscribe(s=>{if(this.agent!==i||this.terminalState!=="open")return;const a=++this.seq,o=this.runId;switch(s.type){case"agent_start":this.resolvePendingSendStart(o),this.emit("agentEvent",{state:"start",runId:o,seq:a});break;case"message_update":{const r=s.message;if(r.role!=="assistant")break;const u=r.content??[];for(let l=0;l<u.length;l++){const h=u[l];if(h.type==="text"&&h.text){const m=`text:${l}`,S=this.emittedLengths.get(m)??0;if(h.text.length>S){const x=h.text.slice(S);this.emittedLengths.set(m,h.text.length),this.emit("agentEvent",{state:"delta",runId:o,seq:a,text:x})}}else if(h.type==="thinking"&&h.thinking){const m=`thinking:${l}`,S=this.emittedLengths.get(m)??0;if(h.thinking.length>S){const x=h.thinking.slice(S);this.emittedLengths.set(m,h.thinking.length),this.emit("agentEvent",{state:"delta",runId:o,seq:a,text:x,thinking:!0})}}}break}case"tool_execution_start":this.emit("agentEvent",{state:"tool-call",runId:o,seq:a,name:s.toolName,args:s.args});break;case"tool_execution_end":this.emit("agentEvent",{state:"tool-result",runId:o,seq:a,name:s.toolName,result:typeof s.result=="string"?s.result:JSON.stringify(s.result)});break;case"agent_end":{this.terminalState="final";const r=s.messages,l=[...r].reverse().find(h=>h.role==="assistant")?.usage;this.emit("agentEvent",{state:"final",runId:o,seq:a,usage:l?{inputTokens:l.input??0,outputTokens:l.output??0}:void 0}),this.finalizePromise=this.finalizeTurn(r);break}}})}async compressAndReplace(){if(!this.agent||this.compressing)return;const t=this.agent.state.messages;if(w(t)<v)return;const n=this.splitMessages(t);if(!n)return;const i=await this.generateSummary(n.toCompress);if(!i)return;this.cachedSummary=i,this.lastSummaryMsgCount+=n.toCompress.length;const s=[{role:"user",content:[{type:"text",text:`[\u5386\u53F2\u5BF9\u8BDD\u6458\u8981]
8
8
  ${i}`}],timestamp:Date.now()},{role:"assistant",content:[{type:"text",text:"\u597D\u7684\uFF0C\u6211\u5DF2\u4E86\u89E3\u4E0A\u4E0B\u6587\u3002"}],timestamp:Date.now()},...n.toKeep];this.agent.replaceMessages(s)}async compressContext(t){if(w(t)<v||!this.cachedSummary)return t;const n=this.splitMessages(t);return n?[{role:"user",content:[{type:"text",text:`[\u5386\u53F2\u5BF9\u8BDD\u6458\u8981]
9
- ${this.cachedSummary}`}],timestamp:Date.now()},...n.toKeep]:t}splitMessages(t){const e=t.filter(i=>i.role!=="system");if(e.length<=k)return null;let n=e.length-k;for(;n>0&&e[n].role==="toolResult";)n--;return n<=0?null:{toCompress:e.slice(0,n),toKeep:e.slice(n)}}async generateSummary(t){if(!this.authToken||!this.proxyUrl||this.compressing)return this.cachedSummary;this.compressing=!0;try{const e=B(t);if(e.length<100)return null;const n=e.length>1e4?e.slice(0,1e4)+`
10
- ...(\u5DF2\u622A\u65AD)`:e;return await G(this.proxyUrl,this.authToken,`\u8BF7\u5C06\u4EE5\u4E0B\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u4E3A\u7B80\u6D01\u6458\u8981\uFF0C\u4FDD\u7559\u5173\u952E\u4FE1\u606F\uFF1A\u8BA8\u8BBA\u7684\u6587\u4EF6\u548C\u76EE\u5F55\u3001\u505A\u51FA\u7684\u6280\u672F\u51B3\u5B9A\u3001\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3001\u672A\u5B8C\u6210\u7684\u5DE5\u4F5C\u3002\u6458\u8981\u63A7\u5236\u5728 300 \u5B57\u4EE5\u5185\u3002
9
+ ${this.cachedSummary}`}],timestamp:Date.now()},...n.toKeep]:t}splitMessages(t){const e=t.filter(i=>i.role!=="system");if(e.length<=k)return null;let n=e.length-k;for(;n>0&&e[n].role==="toolResult";)n--;return n<=0?null:{toCompress:e.slice(0,n),toKeep:e.slice(n)}}async generateSummary(t){if(!this.authToken||!this.proxyUrl||this.compressing)return this.cachedSummary;this.compressing=!0;try{const e=K(t);if(e.length<100)return null;const n=e.length>1e4?e.slice(0,1e4)+`
10
+ ...(\u5DF2\u622A\u65AD)`:e;return await J(this.proxyUrl,this.authToken,`\u8BF7\u5C06\u4EE5\u4E0B\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u4E3A\u7B80\u6D01\u6458\u8981\uFF0C\u4FDD\u7559\u5173\u952E\u4FE1\u606F\uFF1A\u8BA8\u8BBA\u7684\u6587\u4EF6\u548C\u76EE\u5F55\u3001\u505A\u51FA\u7684\u6280\u672F\u51B3\u5B9A\u3001\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3001\u672A\u5B8C\u6210\u7684\u5DE5\u4F5C\u3002\u6458\u8981\u63A7\u5236\u5728 300 \u5B57\u4EE5\u5185\u3002
11
11
 
12
- ${n}`)}catch{return this.cachedSummary}finally{this.compressing=!1}}loadSnapshot(){if(this.snapshotPath)try{const t=c.readFileSync(this.snapshotPath,"utf-8"),e=JSON.parse(t);this.restoredMessages=Array.isArray(e.messages)?e.messages:[],this.cachedSummary=e.summary??this.cachedSummary,this.lastSummaryMsgCount=e.summarizedCount??this.lastSummaryMsgCount}catch{this.restoredMessages=[]}}loadSummary(){if(this.summaryPath)try{const t=c.readFileSync(this.summaryPath,"utf-8"),e=JSON.parse(t);this.cachedSummary=e.summary??null,this.lastSummaryMsgCount=e.summarizedCount??0}catch{if(!this.sessionDir)return;try{const t=g.join(this.sessionDir,q),e=c.readFileSync(t,"utf-8"),n=JSON.parse(e);this.cachedSummary=n.summary??null,this.lastSummaryMsgCount=n.summarizedCount??0}catch{}}}saveSummary(t){if(this.summaryPath)try{c.mkdirSync(g.dirname(this.summaryPath),{recursive:!0});const e=E(this.cachedSummary,t);this.cachedSummary=e,c.writeFileSync(this.summaryPath,JSON.stringify({version:1,summary:e,summarizedCount:this.lastSummaryMsgCount,updatedAt:Date.now()},null,2))}catch{}}saveSnapshot(t){if(!(!this.snapshotPath||!this.sessionId||!this.workDir))try{c.mkdirSync(g.dirname(this.snapshotPath),{recursive:!0}),c.writeFileSync(this.snapshotPath,JSON.stringify({version:1,sessionId:this.sessionId,workDir:this.workDir,summary:this.cachedSummary,summarizedCount:this.lastSummaryMsgCount,messages:t,updatedAt:Date.now()},null,2)),this.restoredMessages=y(t)}catch{}}appendMessagesLog(t){if(!(!this.messagesPath||t.length===0))try{c.mkdirSync(g.dirname(this.messagesPath),{recursive:!0});const e=t.map(n=>JSON.stringify(n)).join(`
12
+ ${n}`)}catch{return this.cachedSummary}finally{this.compressing=!1}}loadSnapshot(){if(this.snapshotPath)try{const t=c.readFileSync(this.snapshotPath,"utf-8"),e=JSON.parse(t);this.restoredMessages=Array.isArray(e.messages)?e.messages:[],this.cachedSummary=e.summary??this.cachedSummary,this.lastSummaryMsgCount=e.summarizedCount??this.lastSummaryMsgCount}catch{this.restoredMessages=[]}}loadSummary(){if(this.summaryPath)try{const t=c.readFileSync(this.summaryPath,"utf-8"),e=JSON.parse(t);this.cachedSummary=e.summary??null,this.lastSummaryMsgCount=e.summarizedCount??0}catch{if(!this.sessionDir)return;try{const t=g.join(this.sessionDir,z),e=c.readFileSync(t,"utf-8"),n=JSON.parse(e);this.cachedSummary=n.summary??null,this.lastSummaryMsgCount=n.summarizedCount??0}catch{}}}saveSummary(t){if(this.summaryPath)try{c.mkdirSync(g.dirname(this.summaryPath),{recursive:!0});const e=E(this.cachedSummary,t);this.cachedSummary=e,c.writeFileSync(this.summaryPath,JSON.stringify({version:1,summary:e,summarizedCount:this.lastSummaryMsgCount,updatedAt:Date.now()},null,2))}catch{}}saveSnapshot(t){if(!(!this.snapshotPath||!this.sessionId||!this.workDir))try{c.mkdirSync(g.dirname(this.snapshotPath),{recursive:!0}),c.writeFileSync(this.snapshotPath,JSON.stringify({version:1,sessionId:this.sessionId,workDir:this.workDir,summary:this.cachedSummary,summarizedCount:this.lastSummaryMsgCount,messages:t,updatedAt:Date.now()},null,2)),this.restoredMessages=y(t)}catch{}}appendMessagesLog(t){if(!(!this.messagesPath||t.length===0))try{c.mkdirSync(g.dirname(this.messagesPath),{recursive:!0});const e=t.map(n=>JSON.stringify(n)).join(`
13
13
  `)+`
14
- `;c.appendFileSync(this.messagesPath,e,"utf-8")}catch{}}getTurnMessages(t){const e=R(this.pendingBaseMessages,t);return y(t.slice(e))}async finalizeTurn(t){const e=y(t),n=this.getTurnMessages(e);this.appendMessagesLog(n),await this.compressAndReplace();const i=this.agent?y(this.agent.state.messages):e;this.cachedSummary||(this.cachedSummary=E(null,e)),this.saveSummary(i),this.saveSnapshot(i)}async resume(t){this.loadSnapshot(),this.loadSummary(),this.agent&&this.restoredMessages.length>0&&this.agent.replaceMessages(y(this.restoredMessages))}async stop(){if(this.rejectPendingSendStart(this.runId,new Error("Pi run stopped before dispatch completed")),await this.finalizePromise.catch(()=>{}),this.agent){const t=y(this.agent.state.messages??[]);this.saveSummary(t),this.saveSnapshot(t)}this.agent?.abort(),this.agent=null}resolvePendingSendStart(t){if(!this.pendingSendStart||this.pendingSendStart.runId!==t)return;const{resolve:e}=this.pendingSendStart;this.pendingSendStart=null,e()}rejectPendingSendStart(t,e){if(!this.pendingSendStart||this.pendingSendStart.runId!==t)return;const{reject:n}=this.pendingSendStart;this.pendingSendStart=null,n(e)}}j("pi",()=>new Z);export{Z as PiAdapter,yt as buildShellCommandSpec};
14
+ `;c.appendFileSync(this.messagesPath,e,"utf-8")}catch{}}getTurnMessages(t){const e=U(this.pendingBaseMessages,t);return y(t.slice(e))}async finalizeTurn(t){const e=y(t),n=this.getTurnMessages(e);this.appendMessagesLog(n),await this.compressAndReplace();const i=this.agent?y(this.agent.state.messages):e;this.cachedSummary||(this.cachedSummary=E(null,e)),this.saveSummary(i),this.saveSnapshot(i)}async resume(t){this.loadSnapshot(),this.loadSummary(),this.agent&&this.restoredMessages.length>0&&this.agent.replaceMessages(y(this.restoredMessages))}async stop(){if(this.rejectPendingSendStart(this.runId,new Error("Pi run stopped before dispatch completed")),await this.finalizePromise.catch(()=>{}),this.agent){const t=y(this.agent.state.messages??[]);this.saveSummary(t),this.saveSnapshot(t)}this.agent?.abort(),this.agent=null}resolvePendingSendStart(t){if(!this.pendingSendStart||this.pendingSendStart.runId!==t)return;const{resolve:e}=this.pendingSendStart;this.pendingSendStart=null,e()}rejectPendingSendStart(t,e){if(!this.pendingSendStart||this.pendingSendStart.runId!==t)return;const{reject:n}=this.pendingSendStart;this.pendingSendStart=null,n(e)}}j("pi",()=>new tt);export{tt as PiAdapter,ft as buildShellCommandSpec};
@@ -3,6 +3,7 @@ export declare function getUserBinPathCandidates(input?: {
3
3
  homedir?: string;
4
4
  exists?: (filePath: string) => boolean;
5
5
  readdir?: (filePath: string) => string[];
6
+ platform?: NodeJS.Platform;
6
7
  }): string[];
7
8
  export declare function buildAugmentedPath(input?: {
8
9
  pathValue?: string;
@@ -1 +1 @@
1
- import p from"node:fs";import f from"node:os";import i from"node:path";const u="/usr/local/bin:/usr/bin:/bin";function o(e,t,s=!1){!t||e.includes(t)||(s?e.unshift(t):e.push(t))}function j(e={}){const t=e.env??process.env,s=e.homedir??f.homedir(),c=e.exists??p.existsSync,d=e.readdir??(a=>p.readdirSync(a)),n=[];if(process.platform==="win32"){const a=t.APPDATA?.trim()||i.join(s,"AppData","Roaming"),r=t.LOCALAPPDATA?.trim()||i.join(s,"AppData","Local");return o(n,i.join(a,"npm")),o(n,i.join(r,"pnpm")),o(n,i.join(s,"scoop","shims")),o(n,i.join("C:\\","Program Files","nodejs")),n}o(n,i.join(s,".local","bin")),o(n,i.join(s,".bun","bin")),o(n,i.join(s,".npm-global","bin")),o(n,i.join(s,".npm","bin")),o(n,i.join(s,".cargo","bin")),o(n,i.join(s,".maestro","bin"));const l=t.NVM_DIR?.trim()||i.join(s,".nvm"),m=i.join(l,"versions","node");try{const a=d(m).sort((r,b)=>b.localeCompare(r,void 0,{numeric:!0})).map(r=>i.join(m,r,"bin")).filter(r=>c(r));for(const r of a)o(n,r)}catch{}return o(n,"/opt/homebrew/bin"),o(n,"/usr/local/bin"),o(n,"/usr/bin"),o(n,"/bin"),o(n,"/usr/sbin"),o(n,"/sbin"),n}function P(e={}){const s=(e.pathValue??e.env?.PATH??process.env.PATH??u).split(i.delimiter).filter(Boolean);for(const c of j(e))o(s,c);return s.join(i.delimiter)}function v(){process.env.PATH=P()}export{v as augmentProcessPath,P as buildAugmentedPath,j as getUserBinPathCandidates};
1
+ import p from"node:fs";import h from"node:os";import s from"node:path";const P="/usr/local/bin:/usr/bin:/bin";function o(t,e,i=!1){!e||t.includes(e)||(i?t.unshift(e):t.push(e))}function u(t={}){const e=t.env??process.env,i=t.homedir??h.homedir(),c=t.exists??p.existsSync,f=t.readdir??(r=>p.readdirSync(r)),b=t.platform??process.platform,n=[];if(b==="win32"){const r=s.win32,a=e.APPDATA?.trim()||r.join(i,"AppData","Roaming"),m=e.LOCALAPPDATA?.trim()||r.join(i,"AppData","Local"),d=e.SystemRoot?.trim()||e.WINDIR?.trim()||e.windir?.trim()||r.join("C:\\","Windows");return o(n,r.join(i,".shennian","node")),o(n,s.win32.join(d,"System32")),o(n,s.win32.join(d,"System32","WindowsPowerShell","v1.0")),o(n,s.win32.join(d)),o(n,r.join(a,"npm")),o(n,r.join(m,"pnpm")),o(n,r.join(i,"scoop","shims")),o(n,r.join("C:\\","Program Files","nodejs")),n}o(n,s.join(i,".local","bin")),o(n,s.join(i,".bun","bin")),o(n,s.join(i,".npm-global","bin")),o(n,s.join(i,".npm","bin")),o(n,s.join(i,".cargo","bin")),o(n,s.join(i,".maestro","bin"));const j=e.NVM_DIR?.trim()||s.join(i,".nvm"),l=s.join(j,"versions","node");try{const r=f(l).sort((a,m)=>m.localeCompare(a,void 0,{numeric:!0})).map(a=>s.join(l,a,"bin")).filter(a=>c(a));for(const a of r)o(n,a)}catch{}return o(n,"/opt/homebrew/bin"),o(n,"/usr/local/bin"),o(n,"/usr/bin"),o(n,"/bin"),o(n,"/usr/sbin"),o(n,"/sbin"),n}function A(t={}){const i=(t.pathValue??t.env?.PATH??process.env.PATH??P).split(s.delimiter).filter(Boolean);for(const c of u(t))o(i,c);return i.join(s.delimiter)}function g(){process.env.PATH=A()}export{g as augmentProcessPath,A as buildAugmentedPath,u as getUserBinPathCandidates};
@@ -1 +1 @@
1
- import{isSystemControlPayload as R}from"@shennian/wire";import{readMessages as E}from"../store.js";const A=2e3,_=8e3,b=/(?:token|api[-_]?key|password|passwd|pwd|secret|authorization|cookie|credential|private[-_]?key)/i,T=/\b([A-Z0-9_]*(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|PWD|AUTH)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi,x=/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,D=/\bsk-[A-Za-z0-9_-]{12,}\b/g;function m(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function d(e){if(!e)return null;if(typeof e=="string")try{return d(JSON.parse(e))}catch{return null}const t=m(e);if(!t)return null;const s=typeof t.runId=="string"?t.runId:void 0,o=typeof t.sourceSeq=="number"?t.sourceSeq:typeof t.seq=="number"?t.seq:void 0,n=typeof t.toolIndex=="number"?t.toolIndex:void 0;return{...s?{runId:s}:{},...o!=null?{sourceSeq:o}:{},...n!=null?{toolIndex:n}:{}}}function p(e){return/^agent-(.+)-\d+$/.exec(e)?.[1]??null}function I(e){const t=/^agent-.+-(\d+)$/.exec(e);return t?Number(t[1]):null}function y(e){const t=typeof e=="number"?e:Number(e);return!Number.isFinite(t)||t<=0?A:Math.min(Math.max(200,Math.floor(t)),_)}function c(e,t){if(R(e))return"[SYSTEM CONTEXT REDACTED]";const s=e.replace(T,"$1=[REDACTED]").replace(x,"Bearer [REDACTED]").replace(D,"sk-[REDACTED]");return s.length>t?`${s.slice(0,t)}\u2026`:s}function u(e,t,s=0){if(e==null)return e;if(typeof e=="string")return c(e,t);if(typeof e=="number"||typeof e=="boolean")return e;if(s>=4)return"[Truncated]";if(Array.isArray(e))return e.slice(0,20).map(o=>u(o,t,s+1));if(typeof e=="object"){const o={};for(const[n,r]of Object.entries(e).slice(0,50)){if(b.test(n)){o[n]="[REDACTED]";continue}o[n]=u(r,t,s+1)}return o}return String(e)}function h(e,t){const o=m(e)?.command;if(typeof o=="string")return c(o,t);if(Array.isArray(o)){const n=o.map(r=>String(r)).join(" ");return c(n,t)}}function C(e){const t=E(e),s=[];for(const o of t)if(!(o.role!=="agent"||!o.payload.trim().startsWith("{")))try{const n=JSON.parse(o.payload),r=n.type;if(r!=="tool"&&r!=="tool_use"&&r!=="tool_result")continue;const a=typeof n.name=="string"&&n.name.trim()?n.name.trim():"tool";s.push({id:o.id,ts:o.ts,name:a,args:n.args,result:n.result,status:r==="tool_result"||Object.prototype.hasOwnProperty.call(n,"result")?"completed":n.status==="completed"||n.status==="failed"||n.status==="running"?n.status:"running",detailRef:d(n.detailRef)})}catch{}return s}function k(e,t,s){let o=0;e.id===t.messageId&&(o+=100),t.name&&e.name===t.name&&(o+=20);const n=s?.runId??t.runId??p(t.messageId),r=s?.sourceSeq??t.sourceSeq??I(t.messageId)??void 0;return n&&(e.detailRef?.runId??p(e.id))===n&&(o+=20),r!=null&&(e.detailRef?.sourceSeq??I(e.id))===r&&(o+=80),e.args!=null&&(o+=5),o}function q(e){const t=d(e.detailRef)??d({runId:e.runId,sourceSeq:e.sourceSeq,toolIndex:e.toolIndex}),s=C(e.sessionId);return s.length===0?null:s.map(n=>({candidate:n,score:k(n,e,t)})).filter(n=>n.score>0).sort((n,r)=>r.score-n.score||r.candidate.ts-n.candidate.ts)[0]?.candidate??null}async function O(e,t){const s=t.params,o=typeof s.sessionId=="string"?s.sessionId:"",n=typeof s.messageId=="string"?s.messageId:"";if(!o||!n){e.client.sendRes({type:"res",id:t.id,ok:!1,error:"sessionId and messageId are required"});return}const r={sessionId:o,messageId:n,...typeof s.name=="string"?{name:s.name}:{},...typeof s.toolIndex=="number"?{toolIndex:s.toolIndex}:{},...typeof s.runId=="string"?{runId:s.runId}:{},...typeof s.sourceSeq=="number"?{sourceSeq:s.sourceSeq}:{},...s.detailRef!==void 0?{detailRef:s.detailRef}:{},maxChars:y(s.maxChars)},a=y(r.maxChars),i=q(r);if(!i||i.args==null){const S={detailStatus:"not_found",messageId:n,toolIndex:r.toolIndex??0,name:r.name,resultOmitted:!0,source:"unavailable",reason:"tool detail is not available on this machine"};e.client.sendRes({type:"res",id:t.id,ok:!0,payload:S});return}const l=i.args==null?void 0:u(i.args,a),f=h(i.args,a),g={detailStatus:"available",messageId:n,toolIndex:r.toolIndex??0,name:i.name,status:i.status,...l!==void 0?{argsSummary:l}:{},...f?{command:f}:{},resultOmitted:!0,source:"local-session-store"};e.client.sendRes({type:"res",id:t.id,ok:!0,payload:g})}export{O as handleSessionToolDetail};
1
+ import{isSystemControlPayload as h}from"@shennian/wire";import{readMessages as x}from"../store.js";const q=2e3,D=8e3,C=/(?:token|api[-_]?key|password|passwd|pwd|secret|authorization|cookie|credential|private[-_]?key)/i,M=/\b([A-Z0-9_]*(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|PWD|AUTH)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi,N=/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,k=/\bsk-[A-Za-z0-9_-]{12,}\b/g;function R(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function l(e){if(!e)return null;if(typeof e=="string")try{return l(JSON.parse(e))}catch{return null}const t=R(e);if(!t)return null;const n=typeof t.runId=="string"?t.runId:void 0,r=typeof t.sourceSeq=="number"?t.sourceSeq:typeof t.seq=="number"?t.seq:void 0,s=typeof t.toolIndex=="number"?t.toolIndex:void 0;return{...n?{runId:n}:{},...r!=null?{sourceSeq:r}:{},...s!=null?{toolIndex:s}:{}}}function f(e){return/^agent-(.+)-\d+$/.exec(e)?.[1]??null}function m(e){const t=/^agent-.+-(\d+)$/.exec(e);return t?Number(t[1]):null}function E(e){const t=typeof e=="number"?e:Number(e);return!Number.isFinite(t)||t<=0?q:Math.min(Math.max(200,Math.floor(t)),D)}function d(e,t){if(h(e))return"[SYSTEM CONTEXT REDACTED]";const n=e.replace(M,"$1=[REDACTED]").replace(N,"Bearer [REDACTED]").replace(k,"sk-[REDACTED]");return n.length>t?`${n.slice(0,t)}\u2026`:n}function p(e,t,n=0){if(e==null)return e;if(typeof e=="string")return d(e,t);if(typeof e=="number"||typeof e=="boolean")return e;if(n>=4)return"[Truncated]";if(Array.isArray(e))return e.slice(0,20).map(r=>p(r,t,n+1));if(typeof e=="object"){const r={};for(const[s,o]of Object.entries(e).slice(0,50)){if(C.test(s)){r[s]="[REDACTED]";continue}r[s]=p(o,t,n+1)}return r}return String(e)}function O(e,t){const r=R(e)?.command;if(typeof r=="string")return d(r,t);if(Array.isArray(r)){const s=r.map(o=>String(o)).join(" ");return d(s,t)}}function A(e){const t=x(e),n=[];for(const r of t)if(!(r.role!=="agent"||!r.payload.trim().startsWith("{")))try{const s=JSON.parse(r.payload),o=s.type;if(o!=="tool"&&o!=="tool_use"&&o!=="tool_result")continue;const i=typeof s.name=="string"&&s.name.trim()?s.name.trim():"tool";n.push({id:r.id,ts:r.ts,name:i,args:s.args,result:s.result,status:o==="tool_result"||Object.prototype.hasOwnProperty.call(s,"result")?"completed":s.status==="completed"||s.status==="failed"||s.status==="running"?s.status:"running",detailRef:l(s.detailRef)})}catch{}return n}function w(e,t,n){let r=0;e.id===t.messageId&&(r+=100),t.name&&e.name===t.name&&(r+=20);const s=n?.runId??t.runId??f(t.messageId),o=n?.sourceSeq??t.sourceSeq??m(t.messageId)??void 0;return s&&(e.detailRef?.runId??f(e.id))===s&&(r+=20),o!=null&&(e.detailRef?.sourceSeq??m(e.id))===o&&(r+=80),e.args!=null&&(r+=5),r}function P(e){const t=l(e.detailRef)??l({runId:e.runId,sourceSeq:e.sourceSeq,toolIndex:e.toolIndex}),n=A(e.sessionId);return n.length===0?null:n.map(s=>({candidate:s,score:w(s,e,t)})).filter(s=>s.score>0).sort((s,o)=>o.score-s.score||o.candidate.ts-s.candidate.ts)[0]?.candidate??null}function b(e){return e.detailRef?.runId??f(e.id)}function I(e){return e.detailRef?.sourceSeq??m(e.id)}function F(e,t,n){if(n.result!=null)return n;const r=b(n)??t.runId??f(t.messageId),s=I(n)??t.sourceSeq??m(t.messageId);return A(e).filter(o=>{if(o.id===n.id||o.name!==n.name||o.result==null||r&&b(o)!==r)return!1;const i=I(o);return s!=null&&i!=null?i>=s:o.ts>=n.ts}).sort((o,i)=>{const u=I(o),a=I(i);return s!=null&&u!=null&&a!=null?Math.abs(u-s)-Math.abs(a-s):o.ts-i.ts})[0]??null}async function K(e,t){const n=t.params,r=typeof n.sessionId=="string"?n.sessionId:"",s=typeof n.messageId=="string"?n.messageId:"";if(!r||!s){e.client.sendRes({type:"res",id:t.id,ok:!1,error:"sessionId and messageId are required"});return}const o={sessionId:r,messageId:s,...typeof n.name=="string"?{name:n.name}:{},...typeof n.toolIndex=="number"?{toolIndex:n.toolIndex}:{},...typeof n.runId=="string"?{runId:n.runId}:{},...typeof n.sourceSeq=="number"?{sourceSeq:n.sourceSeq}:{},...n.detailRef!==void 0?{detailRef:n.detailRef}:{},maxChars:E(n.maxChars)},i=E(o.maxChars),u=P(o);if(!u||u.args==null&&u.result==null){const T={detailStatus:"not_found",messageId:s,toolIndex:o.toolIndex??0,name:o.name,resultOmitted:!0,source:"unavailable",reason:"tool detail is not available on this machine"};e.client.sendRes({type:"res",id:t.id,ok:!0,payload:T});return}const a=u.args==null?void 0:p(u.args,i),S=O(u.args,i),g=F(r,o,u),c=g?.result??u.result,y=typeof c=="string"?d(c,i):c==null?void 0:d(JSON.stringify(p(c,i)),i),_={detailStatus:"available",messageId:s,toolIndex:o.toolIndex??0,name:u.name,status:g?.status??u.status,...a!==void 0?{argsSummary:a}:{},...S?{command:S}:{},...y!==void 0?{result:y}:{},resultOmitted:y===void 0,source:"local-session-store"};e.client.sendRes({type:"res",id:t.id,ok:!0,payload:_})}export{K as handleSessionToolDetail};
@@ -0,0 +1,6 @@
1
+ export declare function resolveWindowsSystemRoot(env?: NodeJS.ProcessEnv): string;
2
+ export declare function resolveWindowsPowerShellPath(input?: {
3
+ env?: NodeJS.ProcessEnv;
4
+ exists?: (filePath: string) => boolean;
5
+ }): string;
6
+ export declare function buildWindowsSystemEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -0,0 +1 @@
1
+ import d from"node:fs";import r from"node:path";function s(o){const e=o?.trim();return e||null}function l(o=process.env){return s(o.SystemRoot)??s(o.WINDIR)??s(o.windir)??"C:\\Windows"}function f(o={}){const e=o.env??process.env,i=o.exists??d.existsSync,n=[s(e.SystemRoot),s(e.WINDIR),s(e.windir),"C:\\Windows"].filter((t,c,m)=>!!t&&m.indexOf(t)===c).map(t=>r.win32.join(t,"System32","WindowsPowerShell","v1.0","powershell.exe"));for(const t of n)if(i(t))return t;return n[0]??"powershell.exe"}function u(o=process.env){const e=l(o);return{SystemRoot:o.SystemRoot||e,WINDIR:o.WINDIR||e,ComSpec:o.ComSpec||r.win32.join(e,"System32","cmd.exe")}}export{u as buildWindowsSystemEnv,f as resolveWindowsPowerShellPath,l as resolveWindowsSystemRoot};
@@ -23,7 +23,8 @@ export type SessionToolDetailResponse = {
23
23
  status?: 'running' | 'completed' | 'failed';
24
24
  command?: string;
25
25
  argsSummary?: unknown;
26
- resultOmitted: true;
26
+ result?: string;
27
+ resultOmitted: boolean;
27
28
  source: ToolDetailSource;
28
29
  reason?: string;
29
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tool-detail.d.ts","sourceRoot":"","sources":["../src/tool-detail.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,aAAa,CAAA;AAExF,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,CAAA;AAEjB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,EAAE,gBAAgB,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,aAAa,EAAE,IAAI,CAAA;IACnB,MAAM,EAAE,gBAAgB,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA"}
1
+ {"version":3,"file":"tool-detail.d.ts","sourceRoot":"","sources":["../src/tool-detail.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,aAAa,CAAA;AAExF,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,CAAA;AAEjB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,EAAE,gBAAgB,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,gBAAgB,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shennian",
3
- "version": "0.2.125",
3
+ "version": "0.2.126",
4
4
  "description": "Shennian — AI Agent Control Plane CLI",
5
5
  "type": "module",
6
6
  "bin": {