aws-runtime-bridge 1.9.162 → 1.9.169

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/dist/adapter/AcodeSdkAdapter.d.ts +31 -3
  3. package/dist/adapter/AcodeSdkAdapter.js +4 -9
  4. package/dist/adapter/ClaudeSdkAdapter.d.ts +2 -0
  5. package/dist/adapter/ClaudeSdkAdapter.js +3 -3
  6. package/dist/adapter/CodexSdkAdapter.d.ts +2 -0
  7. package/dist/adapter/CodexSdkAdapter.js +3 -3
  8. package/dist/adapter/OpencodeSdkAdapter.d.ts +2 -0
  9. package/dist/adapter/OpencodeSdkAdapter.js +3 -3
  10. package/dist/adapter/prompts.d.ts +1 -1
  11. package/dist/adapter/prompts.js +1 -1
  12. package/dist/adapter/types.d.ts +41 -4
  13. package/dist/adapter/types.js +1 -1
  14. package/dist/browser/frame-encode.d.ts +25 -0
  15. package/dist/browser/frame-encode.js +2 -0
  16. package/dist/browser/screencast-differ.d.ts +2 -3
  17. package/dist/browser/screencast-differ.js +1 -1
  18. package/dist/browser/screencast-manager.js +1 -1
  19. package/dist/browser/types.d.ts +5 -1
  20. package/dist/browser/types.js +1 -1
  21. package/dist/desktop/desktop-mcp-client.js +2 -2
  22. package/dist/routes/background-tasks.js +3 -3
  23. package/dist/routes/capabilities.js +1 -1
  24. package/dist/routes/dashboard.d.ts +2 -0
  25. package/dist/routes/dashboard.js +4 -4
  26. package/dist/routes/git.js +22 -22
  27. package/dist/routes/instance.js +1 -1
  28. package/dist/routes/launch.js +10 -10
  29. package/dist/routes/mcp-extra.js +2 -2
  30. package/dist/routes/mcp.d.ts +4 -0
  31. package/dist/routes/mcp.js +1 -1
  32. package/dist/routes/plugins.js +1 -1
  33. package/dist/routes/pty.d.ts +11 -3
  34. package/dist/routes/pty.js +3 -3
  35. package/dist/routes/runtime-binding.js +1 -1
  36. package/dist/routes/sessions.js +1 -1
  37. package/dist/routes/skills.js +1 -1
  38. package/dist/routes/sub-agents.js +8 -8
  39. package/dist/routes/terminal.d.ts +16 -2
  40. package/dist/routes/terminal.js +34 -36
  41. package/dist/services/agent-process-manager.js +1 -1
  42. package/dist/services/agent-pty-manager.js +4 -4
  43. package/dist/services/aws-client-agent-mcp.js +2 -2
  44. package/dist/services/capability-config.d.ts +8 -0
  45. package/dist/services/capability-config.js +2 -2
  46. package/dist/services/desktop-mcp-manager.d.ts +3 -1
  47. package/dist/services/desktop-mcp-manager.js +1 -1
  48. package/dist/services/instance-ai-config-service.js +1 -1
  49. package/dist/services/instance-features.d.ts +10 -0
  50. package/dist/services/instance-features.js +1 -1
  51. package/dist/services/instance-init-service.js +1 -1
  52. package/dist/services/launch-manager.d.ts +9 -1
  53. package/dist/services/launch-manager.js +6 -6
  54. package/dist/services/launch-metrics.d.ts +1 -1
  55. package/dist/services/launch-metrics.js +4 -3
  56. package/dist/services/mcp-deploy.d.ts +4 -0
  57. package/dist/services/mcp-env-injector.d.ts +12 -0
  58. package/dist/services/mcp-env-injector.js +2 -0
  59. package/dist/services/mcp-launch-binding-queue.d.ts +8 -0
  60. package/dist/services/mcp-launch-binding-queue.js +1 -1
  61. package/dist/services/orphan-monitor.js +1 -1
  62. package/dist/services/panel-env.d.ts +6 -2
  63. package/dist/services/panel-env.js +1 -1
  64. package/dist/services/plugin-manager.js +9 -9
  65. package/dist/services/process-detector.d.ts +23 -3
  66. package/dist/services/process-detector.js +13 -13
  67. package/dist/services/runtime-resources-snapshot.d.ts +3 -0
  68. package/dist/services/runtime-resources-snapshot.js +3 -0
  69. package/dist/services/session-output.d.ts +13 -0
  70. package/dist/services/session-output.js +4 -4
  71. package/dist/services/tunnel-client.js +1 -1
  72. package/dist/services/workspace-files.js +1 -1
  73. package/dist/types.d.ts +4 -0
  74. package/dist/utils/env-safety.d.ts +15 -0
  75. package/dist/utils/env-safety.js +2 -0
  76. package/dist/utils/lifecycle-log.d.ts +2 -0
  77. package/dist/utils/lifecycle-log.js +3 -0
  78. package/dist/utils/mcp-utils.js +1 -1
  79. package/package/acode/dist/background-command-manager.js +4 -4
  80. package/package/acode/dist/built-in-file-tools.d.ts +13 -0
  81. package/package/acode/dist/built-in-file-tools.js +2 -2
  82. package/package/acode/dist/builtins/shellCommandPreparation.d.ts +2 -0
  83. package/package/acode/dist/builtins/shellCommandPreparation.js +2 -2
  84. package/package/acode/dist/compaction.d.ts +10 -0
  85. package/package/acode/dist/compaction.js +6 -6
  86. package/package/acode/dist/context-overflow.js +1 -1
  87. package/package/acode/dist/index.d.ts +1 -0
  88. package/package/acode/dist/index.js +1 -1
  89. package/package/acode/dist/mcpToolNames.d.ts +4 -0
  90. package/package/acode/dist/mcpToolNames.js +1 -1
  91. package/package/acode/dist/runtime-environment.d.ts +2 -0
  92. package/package/acode/dist/runtime-environment.js +3 -2
  93. package/package/acode/dist/runtime.d.ts +68 -8
  94. package/package/acode/dist/runtime.js +28 -27
  95. package/package/acode/dist/sub-agent-manager.js +1 -1
  96. package/package/acode/dist/tool-allocation.js +1 -1
  97. package/package/acode/dist/tool-group-manager.d.ts +12 -0
  98. package/package/acode/dist/tool-group-manager.js +8 -4
  99. package/package/acode/dist/types.d.ts +8 -0
  100. package/package/acode/package.json +1 -1
  101. package/package/aws-client-agent-mcp/README.md +1 -0
  102. package/package/aws-client-agent-mcp/dist/agent-client.d.ts +22 -8
  103. package/package/aws-client-agent-mcp/dist/agent-client.js +1 -1
  104. package/package/aws-client-agent-mcp/dist/http-client.d.ts +10 -0
  105. package/package/aws-client-agent-mcp/dist/http-client.js +1 -1
  106. package/package/aws-client-agent-mcp/dist/logger.d.ts +2 -1
  107. package/package/aws-client-agent-mcp/dist/logger.js +2 -2
  108. package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +19 -2
  109. package/package/aws-client-agent-mcp/dist/mcp-server.js +18 -18
  110. package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +15 -4
  111. package/package/aws-client-agent-mcp/dist/mcp-tools.js +79 -29
  112. package/package/aws-client-agent-mcp/dist/memory-store.d.ts +2 -0
  113. package/package/aws-client-agent-mcp/dist/memory-store.js +3 -3
  114. package/package/aws-client-agent-mcp/dist/message-buffer.js +1 -1
  115. package/package/aws-client-agent-mcp/dist/office/office-workspace.d.ts +15 -0
  116. package/package/aws-client-agent-mcp/dist/office/office-workspace.js +1 -1
  117. package/package/aws-client-agent-mcp/dist/status-reporter.js +1 -1
  118. package/package/aws-client-agent-mcp/dist/tool-groups.d.ts +4 -0
  119. package/package/aws-client-agent-mcp/dist/tool-groups.js +2 -2
  120. package/package/aws-client-agent-mcp/dist/types.d.ts +52 -1
  121. package/package/aws-client-agent-mcp/dist/websocket-client.js +1 -1
  122. package/package/aws-client-agent-mcp/package.json +1 -1
  123. package/package.json +1 -1
@@ -10,6 +10,8 @@ export declare const PRUNE_PROTECT = 40000;
10
10
 
11
11
  export declare const PRUNE_MINIMUM = 20000;
12
12
 
13
+ export declare const RUNTIME_RESOURCES_PREFIX = "ACode runtime resources:";
14
+
13
15
  export declare const COMPACTION_LLM_PROMPT_TEMPLATE: string;
14
16
  interface ChatMessageLike {
15
17
  role: "system" | "user" | "assistant" | "tool";
@@ -63,6 +65,8 @@ export type LLMSummarizer = (input: {
63
65
 
64
66
  export declare function calculateCompactionThreshold(contextLimit: number, maxOutput: number, inputLimit?: number): number;
65
67
 
68
+ export declare function resolveReplayWindow(contextLimit: number, inputLimit?: number): number;
69
+
66
70
  export declare function lookupModelLimits(modelName: string, configOverrides?: {
67
71
  contextLimit?: number;
68
72
  maxOutput?: number;
@@ -75,6 +79,8 @@ export declare function estimateTextTokens(text: string): number;
75
79
 
76
80
  export declare function estimateTokens(text: string): number;
77
81
 
82
+ export declare function conversationSizeBytes(messages: readonly ChatMessageLike[]): number;
83
+
78
84
  export declare function estimateConversationTokens(messages: readonly ChatMessageLike[]): number;
79
85
 
80
86
  export declare function conversationSizeKB(messages: readonly ChatMessageLike[]): number;
@@ -88,6 +94,10 @@ export declare function pruneToolOutputs(messages: ChatMessageLike[], contextLim
88
94
  freedTokens: number;
89
95
  };
90
96
 
97
+ export declare function isCompactionSummaryMessage(message: ChatMessageLike): boolean;
98
+
99
+ export declare function isRuntimeResourcesMessage(message: ChatMessageLike): boolean;
100
+
91
101
  export declare function summarizeConversation(messages: ChatMessageLike[], options?: {
92
102
  llmSummarizer?: LLMSummarizer;
93
103
  contextLimit?: number;
@@ -1,7 +1,7 @@
1
- const nt=2e4,rt=.55,z=[[32e3,.7],[128e3,.75],[512e3,.8],[Number.POSITIVE_INFINITY,.85]];function T(t){if(t<=0)return .55;for(const[e,o]of z)if(t<e)return o;return .85}const U=4e4,j=2e4,B=.5,F=.1,G=new Set(["skill","todo_write","todo_read"]),y={read_file:0,Read:0,grep:0,Grep:0,glob:0,Glob:0,"contextweaver_codebase-retrieval":0,Edit:1,edit:1,Write:1,write:1,write_file:1,webfetch:2,WebFetch:2,WebSearch:2,websearch_web_search_exa:2,bash:3,Bash:3,run_terminal_command:3,playwright_browser_:4},L=2;function K(t){if(!t)return L;if(y[t]!==void 0)return y[t];const e=Object.keys(y).filter(o=>t.startsWith(o)).sort((o,n)=>n.length-o.length);return e.length>0?y[e[0]]:L}const M=128e3,C=8192,D=8,W=6e3,R=500,k="ACode context compaction summary:",it=["Please summarize the conversation above using the following structured format.","Keep each section concise but preserve all actionable details.","Omit any section that has no relevant content.","","## Goal","The user's primary objective in this conversation (1-2 sentences).","","## Known Facts","Key facts already established: decisions, findings, errors, constraints, and user-stated preferences.","","## Done","Tasks that have been completed (do not redo these).","","## In Progress","What is currently being worked on but not yet finished: which step it stopped at and any partial results.","","## Next Steps","The immediate next actions to take to continue the work.","","## Files","Files read, modified, or created with brief context.","","Output only the summary, no preamble."].join(`
2
- `),$=1.5,E=4,J=1.15,X=2e3,H=8;function lt(t,e,o){const n=Math.floor(t*T(t)),l=o??t,s=Math.min(2e4,e),i=l-s;return Math.min(n,i)}const g={"claude-4":{contextLimit:2e5,maxOutput:8192},"claude-sonnet-4":{contextLimit:2e5,maxOutput:8192},"claude-3-5-sonnet":{contextLimit:2e5,maxOutput:8192},"claude-3-opus":{contextLimit:2e5,maxOutput:8192},"claude-3-haiku":{contextLimit:2e5,maxOutput:8192},"claude-2":{contextLimit:1e5,maxOutput:4096},"gpt-4o":{contextLimit:128e3,maxOutput:16384},"gpt-4-turbo":{contextLimit:128e3,maxOutput:4096},"gpt-4":{contextLimit:8192,maxOutput:4096},"gpt-3.5-turbo":{contextLimit:16384,maxOutput:4096},o1:{contextLimit:2e5,maxOutput:1e5},"o3-mini":{contextLimit:2e5,maxOutput:1e5},"gemini-2.0-flash":{contextLimit:1048576,maxOutput:8192},"gemini-2.5-pro":{contextLimit:1048576,maxOutput:8192},"gemini-1.5-pro":{contextLimit:2097152,maxOutput:8192},"gemini-1.5-flash":{contextLimit:1048576,maxOutput:8192},deepseek:{contextLimit:64e3,maxOutput:8192},"deepseek-chat":{contextLimit:64e3,maxOutput:8192},"deepseek-reasoner":{contextLimit:64e3,maxOutput:8192},"qwen-max":{contextLimit:32e3,maxOutput:8192},"qwen-plus":{contextLimit:128e3,maxOutput:8192},"qwen-turbo":{contextLimit:1e6,maxOutput:8192},"glm-4":{contextLimit:128e3,maxOutput:4096},"yi-":{contextLimit:2e5,maxOutput:4096},"llama-3":{contextLimit:8192,maxOutput:4096},"llama-2":{contextLimit:4096,maxOutput:4096},mistral:{contextLimit:32e3,maxOutput:4096},mixtral:{contextLimit:32e3,maxOutput:4096},codestral:{contextLimit:256e3,maxOutput:8192},grok:{contextLimit:131072,maxOutput:4096},"nova-":{contextLimit:2e5,maxOutput:8192}};function st(t,e){if(e?.contextLimit&&e.contextLimit>0)return{contextLimit:e.contextLimit,maxOutput:e.maxOutput??C};if(!t)return{contextLimit:M,maxOutput:C};const o=t.toLowerCase().trim();if(g[o])return g[o];const n=Object.keys(g).filter(l=>o.startsWith(l)).sort((l,s)=>s.length-l.length);return n.length>0?g[n[0]]:{contextLimit:M,maxOutput:C}}function q(t){if(!t)return 0;let e=0,o=0;for(const n of t)n>"\xFF"?e++:o++;return Math.ceil(e/$+o/E)}function A(t){return t?Math.ceil(q(t)*J):0}function V(t){if(typeof t=="object"&&t!==null){const e=t;return e.type==="text"&&typeof e.text=="string"?A(e.text):e.type==="image_url"||e.type==="document"?X:Math.ceil(JSON.stringify(t).length/E)}return typeof t=="string"?A(t):0}function Y(t){let e=16;if(typeof t.content=="string")e+=t.content.length*2;else if(Array.isArray(t.content))for(const o of t.content)typeof o=="object"&&o!==null&&(e+=JSON.stringify(o).length);return t.tool_calls&&(e+=JSON.stringify(t.tool_calls).length),t.tool_call_id&&(e+=t.tool_call_id.length),e}function x(t){let e=0;for(const o of t){if(typeof o.content=="string")e+=A(o.content);else if(Array.isArray(o.content))for(const n of o.content)e+=V(n);o.tool_calls&&(e+=H+Math.ceil(JSON.stringify(o.tool_calls).length/E))}return e}function b(t){let e=0;for(const o of t)e+=Y(o);return Math.round(e/1024*10)/10}function at(t,e,o){if(e<=0)return!1;const n=x(t),l=Math.floor(e*T(e));return n>=l}function ct(t,e,o){if(o<=0)return!1;const n=t+e,l=Math.floor(o*T(o));return n>=l}function Q(t){return t.role==="tool"}function Z(t,e,o){if(!(t.role!=="tool"||!t.tool_call_id))for(let n=o-1;n>=0;n--){const l=e[n];if(l&&l.role==="assistant"&&Array.isArray(l.tool_calls)){for(const s of l.tool_calls)if(typeof s=="object"&&s!==null&&"id"in s&&s.id===t.tool_call_id){const i=s.function;return i?String(i.name??""):void 0}}}}function tt(t,e=M){if(t.length===0)return{prunedCount:0,freedTokens:0};const o=Math.min(U,Math.floor(e*B)),n=Math.min(j,Math.floor(e*F));let l=0;const s=[],i=[];let c=0;for(let r=t.length-1;r>=0;r--){const a=t[r];if(a.role==="user"&&c++,c<2||!Q(a))continue;const f=Z(a,t,r);if(f&&G.has(f))continue;const u=typeof a.content=="string"?a.content:"",p=A(u);if(l+=p,l>o){const h=f?K(f):L,d={msg:a,tokens:p,name:f??""};h<=1?i.push(d):s.push(d)}}s.sort((r,a)=>a.tokens-r.tokens),i.sort((r,a)=>r.tokens-a.tokens);const m=[];let _=0;for(const r of s){if(_>=n)break;_+=r.tokens,m.push(r.msg)}if(_<n){for(const r of i)if(_+=r.tokens,m.push(r.msg),_>=n)break}if(_<n)return{prunedCount:0,freedTokens:0};for(const r of m)r.content="[Old tool result content cleared]";return{prunedCount:m.length,freedTokens:_}}function N(t){return t.role==="system"&&typeof t.content=="string"&&t.content.startsWith(k)}function v(t,e){const o=typeof t.content=="string"?t.content:Array.isArray(t.content)?t.content.map(s=>typeof s=="object"&&s!==null?JSON.stringify(s):String(s)).join(" "):"",n=o.length>R?`${o.slice(0,R)}\u2026`:o,l=[`${e+1}. ${t.role}`];if(t.tool_calls&&Array.isArray(t.tool_calls)&&t.tool_calls.length>0){const s=t.tool_calls.map(i=>{if(typeof i=="object"&&i!==null){const c=i.function;return c?String(c.name??""):""}return""}).filter(Boolean).join(", ");s&&l.push(`tool_calls=${s}`)}return t.tool_call_id&&l.push(`tool_call_id=${t.tool_call_id}`),n&&l.push(`content=${n}`),l.join(" | ")}async function et(t,e){const o=t.filter(r=>r.role==="system"&&!N(r)),n=t.filter(r=>r.role!=="system"||N(r)),l=Math.max(0,n.length-D);if(l===0)return 0;const s=n.slice(0,l);let i=n.slice(l);const c=new Set;for(const r of i)if(r.role==="assistant"&&r.tool_calls?.length)for(const a of r.tool_calls)typeof a=="object"&&a!==null&&typeof a.id=="string"&&c.add(a.id);i=i.filter(r=>r.role==="tool"&&r.tool_call_id?c.has(r.tool_call_id):!0);let m=!0;for(;m;){m=!1;const r=new Set;for(const u of i)if(u.role==="assistant"&&u.tool_calls?.length)for(const p of u.tool_calls)typeof p=="object"&&p!==null&&typeof p.id=="string"&&r.add(p.id);const a=new Set;for(const u of i)u.role==="tool"&&u.tool_call_id&&a.add(u.tool_call_id);const f=i.filter(u=>{if(u.role==="tool"&&u.tool_call_id)return r.has(u.tool_call_id);if(u.role==="assistant"&&u.tool_calls?.length){const p=new Set;for(const d of u.tool_calls)typeof d=="object"&&d!==null&&typeof d.id=="string"&&p.add(d.id);if(p.size===0)return!0;let h=!0;for(const d of p)if(!a.has(d)){h=!1;break}return h}return!0});f.length!==i.length&&(m=!0,i=f)}if(i.length===0)return 0;let _=null;if(e?.llmSummarizer)try{const r=s.map((a,f)=>v(a,f)).join(`
3
- `);_=await e.llmSummarizer({conversationText:r,messageCount:l,contextLimit:e.contextLimit??M})}catch{_=null}if(t.length=0,t.push(...o),_!==null)t.push({role:"system",content:[k,`${l} earlier conversation messages were summarized by LLM to free context space.`,"Preserve the user's goal, known facts, completed work, in-progress work, next steps, file paths, and errors from this summary.","Continue from where the work left off \u2014 do not redo completed tasks.","Recent messages below remain authoritative.","",_].join(`
4
- `)});else{const a=s.map((f,u)=>v(f,u)).join(`
5
- `).slice(0,W);t.push({role:"system",content:[k,`${l} earlier conversation messages were summarized to free context space.`,"Preserve the user's goal, known facts, completed work, in-progress work, next steps, file paths, and errors from this summary.","Continue from where the work left off \u2014 do not redo completed tasks.","Recent messages below remain authoritative.","",a].join(`
6
- `)})}return t.push(...i),l}function ot(t){if(t.length<=1)return 0;let e=0;for(;e<t.length&&t[e].role==="system";)e++;if(e>=t.length)return 0;let o=t.length;for(let i=e+1;i<t.length;i++)if(t[i].role==="user"){o=i;break}if(o>=t.length)return 0;const n=new Set;for(let i=e;i<o;i++){const c=t[i];if(c.role==="assistant"&&Array.isArray(c.tool_calls))for(const m of c.tool_calls)typeof m=="object"&&m!==null&&typeof m.id=="string"&&n.add(m.id)}const l=o-e;t.splice(e,l);let s=0;if(n.size>0)for(let i=t.length-1;i>=e;i--){const c=t[i];c.role==="tool"&&c.tool_call_id&&n.has(c.tool_call_id)&&(t.splice(i,1),s++)}return l+s}async function ut(t,e,o=C,n){const l=b(t),s=t.length,i=x(t);let c="none",m=0,_=0,r=0,a=!1;n?.onPhase&&n.onPhase({phase:"prune_start",messageCount:t.length});const f=tt(t,e);f.prunedCount>0&&(c="prune",m=f.prunedCount,r+=f.freedTokens),n?.onPhase&&n.onPhase({phase:"prune_end",prunedCount:f.prunedCount,freedTokens:f.freedTokens});const u=x(t);if((n?.actualUsedTokens?Math.max(u,Math.max(n.actualUsedTokens,i)-r):u)>=Math.floor(e*T(e))){n?.onPhase&&n.onPhase({phase:"summarize_start",messageCount:t.length});const S=await et(t,{llmSummarizer:n?.llmSummarizer,contextLimit:e});if(S>0){c=c==="prune"?"prune+summarize":"summarize",_=S;const O=x(t);r=Math.max(r,i-O),a=!!t.find(I=>I.role==="system"&&typeof I.content=="string"&&I.content.includes("summarized by LLM"))}else{const O=ot(t);if(O>0){c=c==="prune"?"prune+summarize":"summarize",_=O;const P=x(t);r=Math.max(r,i-P)}}n?.onPhase&&n.onPhase({phase:"summarize_end",summarizedCount:_,usedLLM:a})}const h=b(t),d=t.length,w=x(t);return c==="none"?{strategy:"none",freedTokens:0,sizeBeforeKB:l,sizeAfterKB:l,tokensBefore:i,tokensAfter:w,messageCountBefore:s,messageCountAfter:d,prunedToolMessages:0,summarizedMessages:0}:{strategy:c,freedTokens:r,sizeBeforeKB:l,sizeAfterKB:h,tokensBefore:i,tokensAfter:w,messageCountBefore:s,messageCountAfter:d,prunedToolMessages:m,summarizedMessages:_}}export{nt as COMPACTION_BUFFER,it as COMPACTION_LLM_PROMPT_TEMPLATE,rt as COMPACTION_TRIGGER_RATIO,j as PRUNE_MINIMUM,U as PRUNE_PROTECT,lt as calculateCompactionThreshold,b as conversationSizeKB,x as estimateConversationTokens,q as estimateTextTokens,A as estimateTokens,T as getCompactionTriggerRatio,at as isOverflow,ct as isOverflowByActualUsage,st as lookupModelLimits,ut as performCompaction,tt as pruneToolOutputs,ot as snipOldestMessageGroup,et as summarizeConversation};
1
+ const st=2e4,lt=.55,B=[[32e3,.7],[128e3,.75],[512e3,.8],[Number.POSITIVE_INFINITY,.85]];function T(t){if(t<=0)return .55;for(const[e,o]of B)if(t<e)return o;return .85}const j=4e4,F=2e4,G=.5,K=.1,W=new Set(["skill","todo_write","todo_read"]),y={read_file:0,Read:0,grep:0,Grep:0,glob:0,Glob:0,"contextweaver_codebase-retrieval":0,Edit:1,edit:1,Write:1,write:1,write_file:1,webfetch:2,WebFetch:2,WebSearch:2,websearch_web_search_exa:2,bash:3,Bash:3,run_terminal_command:3,playwright_browser_:4},k=2;function D(t){if(!t)return k;if(y[t]!==void 0)return y[t];const e=Object.keys(y).filter(o=>t.startsWith(o)).sort((o,n)=>n.length-o.length);return e.length>0?y[e[0]]:k}const M=128e3,C=8192,$=8,X=6e3,b=500,L="ACode context compaction summary:",J="ACode runtime resources:",ct=["Please summarize the conversation above using the following structured format.","Keep each section concise but preserve all actionable details.","Omit any section that has no relevant content.","","## Goal","The user's primary objective in this conversation (1-2 sentences).","","## Known Facts","Key facts already established: decisions, findings, errors, constraints, and user-stated preferences.","","## Done","Tasks that have been completed (do not redo these).","","## In Progress","What is currently being worked on but not yet finished: which step it stopped at and any partial results.","","## Next Steps","The immediate next actions to take to continue the work.","","## Files","Files read, modified, or created with brief context.","","Output only the summary, no preamble."].join(`
2
+ `),H=1.5,R=4,q=1.15,V=2e3,Y=8;function at(t,e,o){const n=Math.floor(t*T(t)),s=o??t,l=Math.min(2e4,e),i=s-l;return Math.min(n,i)}function ut(t,e){const o=e&&e>0?e:t;return o>0?o:t}const g={"claude-4":{contextLimit:2e5,maxOutput:8192},"claude-sonnet-4":{contextLimit:2e5,maxOutput:8192},"claude-3-5-sonnet":{contextLimit:2e5,maxOutput:8192},"claude-3-opus":{contextLimit:2e5,maxOutput:8192},"claude-3-haiku":{contextLimit:2e5,maxOutput:8192},"claude-2":{contextLimit:1e5,maxOutput:4096},"gpt-4o":{contextLimit:128e3,maxOutput:16384},"gpt-4-turbo":{contextLimit:128e3,maxOutput:4096},"gpt-4":{contextLimit:8192,maxOutput:4096},"gpt-3.5-turbo":{contextLimit:16384,maxOutput:4096},o1:{contextLimit:2e5,maxOutput:1e5},"o3-mini":{contextLimit:2e5,maxOutput:1e5},"gemini-2.0-flash":{contextLimit:1048576,maxOutput:8192},"gemini-2.5-pro":{contextLimit:1048576,maxOutput:8192},"gemini-1.5-pro":{contextLimit:2097152,maxOutput:8192},"gemini-1.5-flash":{contextLimit:1048576,maxOutput:8192},deepseek:{contextLimit:64e3,maxOutput:8192},"deepseek-chat":{contextLimit:64e3,maxOutput:8192},"deepseek-reasoner":{contextLimit:64e3,maxOutput:8192},"qwen-max":{contextLimit:32e3,maxOutput:8192},"qwen-plus":{contextLimit:128e3,maxOutput:8192},"qwen-turbo":{contextLimit:1e6,maxOutput:8192},"glm-4":{contextLimit:128e3,maxOutput:4096},"yi-":{contextLimit:2e5,maxOutput:4096},"llama-3":{contextLimit:8192,maxOutput:4096},"llama-2":{contextLimit:4096,maxOutput:4096},mistral:{contextLimit:32e3,maxOutput:4096},mixtral:{contextLimit:32e3,maxOutput:4096},codestral:{contextLimit:256e3,maxOutput:8192},grok:{contextLimit:131072,maxOutput:4096},"nova-":{contextLimit:2e5,maxOutput:8192}};function ft(t,e){if(e?.contextLimit&&e.contextLimit>0)return{contextLimit:e.contextLimit,maxOutput:e.maxOutput??C};if(!t)return{contextLimit:M,maxOutput:C};const o=t.toLowerCase().trim();if(g[o])return g[o];const n=Object.keys(g).filter(s=>o.startsWith(s)).sort((s,l)=>l.length-s.length);return n.length>0?g[n[0]]:{contextLimit:M,maxOutput:C}}function Q(t){if(!t)return 0;let e=0,o=0;for(const n of t)n>"\xFF"?e++:o++;return Math.ceil(e/H+o/R)}function A(t){return t?Math.ceil(Q(t)*q):0}function Z(t){if(typeof t=="object"&&t!==null){const e=t;return e.type==="text"&&typeof e.text=="string"?A(e.text):e.type==="image_url"||e.type==="document"?V:Math.ceil(JSON.stringify(t).length/R)}return typeof t=="string"?A(t):0}function I(t){return Buffer.byteLength(t,"utf8")}function N(t){let e=16;if(typeof t.content=="string")e+=I(t.content);else if(Array.isArray(t.content))for(const o of t.content)typeof o=="object"&&o!==null&&(e+=I(JSON.stringify(o)));return t.tool_calls&&(e+=I(JSON.stringify(t.tool_calls))),t.tool_call_id&&(e+=I(t.tool_call_id)),e}function _t(t){let e=0;for(const o of t)e+=N(o);return e}function x(t){let e=0;for(const o of t){if(typeof o.content=="string")e+=A(o.content);else if(Array.isArray(o.content))for(const n of o.content)e+=Z(n);o.tool_calls&&(e+=Y+Math.ceil(JSON.stringify(o.tool_calls).length/R))}return e}function v(t){let e=0;for(const o of t)e+=N(o);return Math.round(e/1024*10)/10}function mt(t,e,o){if(e<=0)return!1;const n=x(t),s=Math.floor(e*T(e));return n>=s}function pt(t,e,o){if(o<=0)return!1;const n=t+e,s=Math.floor(o*T(o));return n>=s}function tt(t){return t.role==="tool"}function et(t,e,o){if(!(t.role!=="tool"||!t.tool_call_id))for(let n=o-1;n>=0;n--){const s=e[n];if(s&&s.role==="assistant"&&Array.isArray(s.tool_calls)){for(const l of s.tool_calls)if(typeof l=="object"&&l!==null&&"id"in l&&l.id===t.tool_call_id){const i=l.function;return i?String(i.name??""):void 0}}}}function ot(t,e=M){if(t.length===0)return{prunedCount:0,freedTokens:0};const o=Math.min(j,Math.floor(e*G)),n=Math.min(F,Math.floor(e*K));let s=0;const l=[],i=[];let a=0;for(let r=t.length-1;r>=0;r--){const c=t[r];if(c.role==="user"&&a++,a<2||!tt(c))continue;const _=et(c,t,r);if(_&&W.has(_))continue;const u=typeof c.content=="string"?c.content:"",p=A(u);if(s+=p,s>o){const h=_?D(_):k,d={msg:c,tokens:p,name:_??""};h<=1?i.push(d):l.push(d)}}l.sort((r,c)=>c.tokens-r.tokens),i.sort((r,c)=>r.tokens-c.tokens);const f=[];let m=0;for(const r of l){if(m>=n)break;m+=r.tokens,f.push(r.msg)}if(m<n){for(const r of i)if(m+=r.tokens,f.push(r.msg),m>=n)break}if(m<n)return{prunedCount:0,freedTokens:0};for(const r of f)r.content="[Old tool result content cleared]";return{prunedCount:f.length,freedTokens:m}}function z(t){return t.role==="system"&&typeof t.content=="string"&&t.content.startsWith(L)}function nt(t){return t.role==="system"&&typeof t.content=="string"&&t.content.startsWith(J)}function U(t,e){const o=typeof t.content=="string"?t.content:Array.isArray(t.content)?t.content.map(l=>typeof l=="object"&&l!==null?JSON.stringify(l):String(l)).join(" "):"",n=o.length>b?`${o.slice(0,b)}\u2026`:o,s=[`${e+1}. ${t.role}`];if(t.tool_calls&&Array.isArray(t.tool_calls)&&t.tool_calls.length>0){const l=t.tool_calls.map(i=>{if(typeof i=="object"&&i!==null){const a=i.function;return a?String(a.name??""):""}return""}).filter(Boolean).join(", ");l&&s.push(`tool_calls=${l}`)}return t.tool_call_id&&s.push(`tool_call_id=${t.tool_call_id}`),n&&s.push(`content=${n}`),s.join(" | ")}async function rt(t,e){const o=t.filter(r=>r.role==="system"&&!z(r)&&!nt(r)),n=t.filter(r=>r.role!=="system"||z(r)),s=Math.max(0,n.length-$);if(s===0)return 0;const l=n.slice(0,s);let i=n.slice(s);const a=new Set;for(const r of i)if(r.role==="assistant"&&r.tool_calls?.length)for(const c of r.tool_calls)typeof c=="object"&&c!==null&&typeof c.id=="string"&&a.add(c.id);i=i.filter(r=>{if(r.role==="tool"){const c=typeof r.tool_call_id=="string"?r.tool_call_id.trim():"";return c!==""&&a.has(c)}return!0});let f=!0;for(;f;){f=!1;const r=new Set;for(const u of i)if(u.role==="assistant"&&u.tool_calls?.length)for(const p of u.tool_calls)typeof p=="object"&&p!==null&&typeof p.id=="string"&&r.add(p.id);const c=new Set;for(const u of i)u.role==="tool"&&u.tool_call_id&&c.add(u.tool_call_id);const _=i.filter(u=>{if(u.role==="tool"){const p=typeof u.tool_call_id=="string"?u.tool_call_id.trim():"";return p!==""&&r.has(p)}if(u.role==="assistant"&&u.tool_calls?.length){const p=new Set;for(const d of u.tool_calls)typeof d=="object"&&d!==null&&typeof d.id=="string"&&p.add(d.id);if(p.size===0)return!0;let h=!0;for(const d of p)if(!c.has(d)){h=!1;break}return h}return!0});_.length!==i.length&&(f=!0,i=_)}if(i.length===0)return 0;let m=null;if(e?.llmSummarizer)try{const r=l.map((c,_)=>U(c,_)).join(`
3
+ `);m=await e.llmSummarizer({conversationText:r,messageCount:s,contextLimit:e.contextLimit??M})}catch{m=null}if(t.length=0,t.push(...o),m!==null)t.push({role:"system",content:[L,`${s} earlier conversation messages were summarized by LLM to free context space.`,"Preserve the user's goal, known facts, completed work, in-progress work, next steps, file paths, and errors from this summary.","Continue from where the work left off \u2014 do not redo completed tasks.","Recent messages below remain authoritative.","",m].join(`
4
+ `)});else{const c=l.map((_,u)=>U(_,u)).join(`
5
+ `).slice(0,X);t.push({role:"system",content:[L,`${s} earlier conversation messages were summarized to free context space.`,"Preserve the user's goal, known facts, completed work, in-progress work, next steps, file paths, and errors from this summary.","Continue from where the work left off \u2014 do not redo completed tasks.","Recent messages below remain authoritative.","",c].join(`
6
+ `)})}return t.push(...i),s}function it(t){if(t.length<=1)return 0;let e=0;for(;e<t.length&&t[e].role==="system";)e++;if(e>=t.length)return 0;let o=t.length;for(let i=e+1;i<t.length;i++)if(t[i].role==="user"){o=i;break}if(o>=t.length)return 0;const n=new Set;for(let i=e;i<o;i++){const a=t[i];if(a.role==="assistant"&&Array.isArray(a.tool_calls))for(const f of a.tool_calls)typeof f=="object"&&f!==null&&typeof f.id=="string"&&n.add(f.id)}const s=o-e;t.splice(e,s);let l=0;for(let i=t.length-1;i>=e;i--){const a=t[i];if(a.role!=="tool")continue;const f=typeof a.tool_call_id=="string"?a.tool_call_id.trim():"";(f===""||n.has(f))&&(t.splice(i,1),l++)}return s+l}async function dt(t,e,o=C,n){const s=v(t),l=t.length,i=x(t);let a="none",f=0,m=0,r=0,c=!1;n?.onPhase&&n.onPhase({phase:"prune_start",messageCount:t.length});const _=ot(t,e);_.prunedCount>0&&(a="prune",f=_.prunedCount,r+=_.freedTokens),n?.onPhase&&n.onPhase({phase:"prune_end",prunedCount:_.prunedCount,freedTokens:_.freedTokens});const u=x(t);if((n?.actualUsedTokens?Math.max(u,Math.max(n.actualUsedTokens,i)-r):u)>=Math.floor(e*T(e))){n?.onPhase&&n.onPhase({phase:"summarize_start",messageCount:t.length});const w=await rt(t,{llmSummarizer:n?.llmSummarizer,contextLimit:e});if(w>0){a=a==="prune"?"prune+summarize":"summarize",m=w;const O=x(t);r=Math.max(r,i-O),c=!!t.find(E=>E.role==="system"&&typeof E.content=="string"&&E.content.includes("summarized by LLM"))}else{const O=it(t);if(O>0){a=a==="prune"?"prune+summarize":"summarize",m=O;const P=x(t);r=Math.max(r,i-P)}}n?.onPhase&&n.onPhase({phase:"summarize_end",summarizedCount:m,usedLLM:c})}const h=v(t),d=t.length,S=x(t);return a==="none"?{strategy:"none",freedTokens:0,sizeBeforeKB:s,sizeAfterKB:s,tokensBefore:i,tokensAfter:S,messageCountBefore:l,messageCountAfter:d,prunedToolMessages:0,summarizedMessages:0}:{strategy:a,freedTokens:r,sizeBeforeKB:s,sizeAfterKB:h,tokensBefore:i,tokensAfter:S,messageCountBefore:l,messageCountAfter:d,prunedToolMessages:f,summarizedMessages:m}}export{st as COMPACTION_BUFFER,ct as COMPACTION_LLM_PROMPT_TEMPLATE,lt as COMPACTION_TRIGGER_RATIO,F as PRUNE_MINIMUM,j as PRUNE_PROTECT,J as RUNTIME_RESOURCES_PREFIX,at as calculateCompactionThreshold,_t as conversationSizeBytes,v as conversationSizeKB,x as estimateConversationTokens,Q as estimateTextTokens,A as estimateTokens,T as getCompactionTriggerRatio,z as isCompactionSummaryMessage,mt as isOverflow,pt as isOverflowByActualUsage,nt as isRuntimeResourcesMessage,ft as lookupModelLimits,dt as performCompaction,ot as pruneToolOutputs,ut as resolveReplayWindow,it as snipOldestMessageGroup,rt as summarizeConversation};
7
7
 
@@ -1,2 +1,2 @@
1
- const m=new Set(["length","max_tokens","max_output_tokens","max_completion_tokens","max_tokens_reached","output_limit","output_token_limit","token_limit"]),f=new Set(["context_exceeded","context_length_exceeded","context_window_exceeded","model_context_window_exceeded","max_context_length_exceeded","context_overflow","prompt_too_long","input_too_long"]),x=["context_length_exceeded","context length","maximum context","max context","token limit","tokens exceed","too many tokens","input is too long","prompt is too long","request too large","413"],p=6,d=["type","code","reason","stopReason","stop_reason","name"];function R(e){const t=[{source:"finish_reason",value:e.finishReason},{source:"stop_reason",value:e.stopReason}];for(const o of t){const n=i(o.value);if(n&&m.has(n))return{kind:"output_limit",marker:n}}for(const o of t){const n=i(o.value);if(n&&f.has(n))return{kind:"context_overflow",marker:n,source:o.source}}return{kind:"none"}}function h(e){let t=e;const o=new WeakSet;for(let n=0;n<=p;n+=1){if(t==null)return!1;if(typeof t=="string")return!!_(t);if(typeof t!="object"||o.has(t))return!1;o.add(t);const r=t;for(const c of d){const s=i(u(r[c]));if(s&&f.has(s))return!0}for(const c of["context","error","details"]){const s=r[c];if(k(s))for(const l of d){const a=i(u(s[l]));if(a&&f.has(a))return!0}}if(_(u(r.message)))return!0;t=r.cause??r.lastError??r.error}return!1}function i(e){if(e==null)return;const t=e.trim().toLowerCase();return t.length>0?t:void 0}function u(e){if(typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e))return String(e)}function _(e){if(!e)return!1;const t=e.toLowerCase();return x.some(o=>t.includes(o))}function k(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}export{h as isContextOverflowError,R as resolveFinishReasonOverflow};
1
+ const x=new Set(["length","max_tokens","max_output_tokens","max_completion_tokens","max_tokens_reached","output_limit","output_token_limit","token_limit"]),f=new Set(["context_exceeded","context_length_exceeded","context_window_exceeded","model_context_window_exceeded","max_context_length_exceeded","context_overflow","prompt_too_long","input_too_long","payload_too_large","request_entity_too_large"]),p=["context_length_exceeded","context length","maximum context","max context","token limit","tokens exceed","too many tokens","input is too long","prompt is too long","request too large","payload too large","entity too large","413"],g=6,_=["type","code","reason","stopReason","stop_reason","name"];function R(e){const t=[{source:"finish_reason",value:e.finishReason},{source:"stop_reason",value:e.stopReason}];for(const n of t){const o=i(n.value);if(o&&x.has(o))return{kind:"output_limit",marker:o}}for(const n of t){const o=i(n.value);if(o&&f.has(o))return{kind:"context_overflow",marker:o,source:n.source}}return{kind:"none"}}function h(e){let t=e;const n=new WeakSet;for(let o=0;o<=g;o+=1){if(t==null)return!1;if(typeof t=="string")return!!l(t);if(typeof t!="object"||n.has(t))return!1;n.add(t);const r=t;for(const c of _){const s=i(a(r[c]));if(s&&f.has(s))return!0}if(u(r.statusCode)||u(r.status))return!0;for(const c of["context","error","details"]){const s=r[c];if(k(s)){for(const m of _){const d=i(a(s[m]));if(d&&f.has(d))return!0}if(u(s.statusCode)||u(s.status))return!0}}if(l(a(r.message)))return!0;t=r.cause??r.lastError??r.error}return!1}function i(e){if(e==null)return;const t=e.trim().toLowerCase();return t.length>0?t:void 0}function a(e){if(typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e))return String(e)}function l(e){if(!e)return!1;const t=e.toLowerCase();return p.some(n=>t.includes(n))}function u(e){return a(e)==="413"}function k(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}export{h as isContextOverflowError,R as resolveFinishReasonOverflow};
2
2
 
@@ -4,6 +4,7 @@ export * from './commands/commandParser.js';
4
4
  export * from './config.js';
5
5
  export * from './hooks/hookBus.js';
6
6
  export * from './runtime.js';
7
+ export * from './runtime-environment.js';
7
8
  export * from './types.js';
8
9
  export * from './sub-agent-types.js';
9
10
  export * from './sub-agent-store.js';
@@ -1,2 +1,2 @@
1
- export*from"./commands/commandRegistry.js";export*from"./commands/commandLoader.js";export*from"./commands/commandParser.js";export*from"./config.js";export*from"./hooks/hookBus.js";export*from"./runtime.js";export*from"./types.js";export*from"./sub-agent-types.js";export*from"./sub-agent-store.js";export*from"./sub-agent-manager.js";export*from"./sub-agent-tools.js";export*from"./built-in-file-tools.js";export*from"./read-file-state.js";export*from"./tool-concurrency/index.js";export*from"./terminal-types.js";export*from"./plugin-types.js";export*from"./tool-group-manager.js";export*from"./parsers/types.js";export*from"./parsers/tree-sitter-loader.js";export*from"./parsers/ast-cache.js";export*from"./parsers/language-detector.js";export*from"./parsers/language-queries.js";export*from"./parsers/symbol-extractor.js";export*from"./built-in-symbols-tool.js";
1
+ export*from"./commands/commandRegistry.js";export*from"./commands/commandLoader.js";export*from"./commands/commandParser.js";export*from"./config.js";export*from"./hooks/hookBus.js";export*from"./runtime.js";export*from"./runtime-environment.js";export*from"./types.js";export*from"./sub-agent-types.js";export*from"./sub-agent-store.js";export*from"./sub-agent-manager.js";export*from"./sub-agent-tools.js";export*from"./built-in-file-tools.js";export*from"./read-file-state.js";export*from"./tool-concurrency/index.js";export*from"./terminal-types.js";export*from"./plugin-types.js";export*from"./tool-group-manager.js";export*from"./parsers/types.js";export*from"./parsers/tree-sitter-loader.js";export*from"./parsers/ast-cache.js";export*from"./parsers/language-detector.js";export*from"./parsers/language-queries.js";export*from"./parsers/symbol-extractor.js";export*from"./built-in-symbols-tool.js";
2
2
 
@@ -4,3 +4,7 @@ export declare function getSemanticToolName(toolName: string): string;
4
4
  export declare function isMcpPollingToolName(toolName: string): boolean;
5
5
 
6
6
  export declare function isMcpBlockingToolName(toolName: string): boolean;
7
+
8
+ export declare function isMcpIndefinitelyBlockingToolName(toolName: string): boolean;
9
+
10
+ export declare function isMcpBatchExcludedToolName(toolName: string): boolean;
@@ -1,2 +1,2 @@
1
- const o=new Set(["poll_message","get_message","send_private"]),s=new Set(["create_meeting"]);function n(e){const t=e.trim().toLowerCase();return t.split(/__|[./]/).filter(Boolean).at(-1)??t}function a(e){return o.has(n(e))}function i(e){return s.has(n(e))}export{n as getSemanticToolName,i as isMcpBlockingToolName,a as isMcpPollingToolName};
1
+ const s=new Set(["poll_message","get_message","send_private"]),i=new Set(["create_meeting"]),o=new Set(["poll_message","create_meeting"]);function t(e){const n=e.trim().toLowerCase();return n.split(/__|[./]/).filter(Boolean).at(-1)??n}function a(e){return s.has(t(e))}function c(e){return i.has(t(e))}function l(e){return o.has(t(e))}function m(e){return o.has(t(e))}export{t as getSemanticToolName,m as isMcpBatchExcludedToolName,c as isMcpBlockingToolName,l as isMcpIndefinitelyBlockingToolName,a as isMcpPollingToolName};
2
2
 
@@ -1,3 +1,5 @@
1
1
  import { type ShellExecutable } from "./builtins/shellCommandPreparation.js";
2
2
 
3
3
  export declare function buildRuntimeEnvironmentPrompt(platform?: NodeJS.Platform, release?: string, shell?: ShellExecutable): string;
4
+
5
+ export declare function buildResumeContextBlock(snapshot: string): string;
@@ -1,3 +1,4 @@
1
- import r from"node:os";import m from"node:path";import{shellExecutable as a}from"./builtins/shellCommandPreparation.js";function c(n=process.platform,o=r.release(),i=a()){const s=n==="win32"?"Windows":n==="darwin"?"macOS":n==="linux"?"Linux":n,e=m.basename(i.command).toLowerCase(),l=n==="win32"?`Shell: ${e} (Windows) \u2014 commands run in a Windows shell, not a POSIX shell; Unix-only commands (rm, grep, sed, ...) may be unavailable, prefer Windows equivalents (rd, findstr, ...) or the built-in file tools.`:`Shell: ${e} \u2014 commands run in a POSIX shell.`;return["[Runtime Environment]",`Platform: ${s} (${n}, release ${o})`,l].join(`
2
- `)}export{c as buildRuntimeEnvironmentPrompt};
1
+ import l from"node:os";import r from"node:path";import{shellExecutable as m}from"./builtins/shellCommandPreparation.js";function c(e=process.platform,n=l.release(),i=m()){const s=e==="win32"?"Windows":e==="darwin"?"macOS":e==="linux"?"Linux":e,o=r.basename(i.command).toLowerCase(),t=e==="win32"?`Shell: ${o} (Windows) \u2014 commands run in a Windows shell, not a POSIX shell; Unix-only commands (rm, grep, sed, ...) may be unavailable, prefer Windows equivalents (rd, findstr, ...) or the built-in file tools.`:`Shell: ${o} \u2014 commands run in a POSIX shell.`;return["[Runtime Environment]",`Platform: ${s} (${e}, release ${n})`,t].join(`
2
+ `)}function h(e){const n=e.trim();return n?["[Resume Context]","\u4EE5\u4E0B\u5185\u5BB9\u53D6\u81EA\u4F60\u4E0A\u4E00\u6B21\u8FD0\u884C\u5230\u8BE5\u5B9E\u4F8B\u4F11\u7720\u4E3A\u6B62\u7684\u8FDB\u5EA6\u5FEB\u7167\uFF08\u7531\u7CFB\u7EDF\u5728\u4F11\u7720\u65F6\u81EA\u52A8\u4FDD\u5B58\uFF09\u3002","\u5B83\u4E0D\u662F\u65B0\u7684\u7528\u6237\u6D88\u606F\uFF0C\u4E5F\u4E0D\u662F\u65B0\u7684\u4EFB\u52A1\u6307\u4EE4\uFF0C\u800C\u662F\u4F60\u81EA\u5DF1\u7684\u8BB0\u5FC6\u63A5\u7EED\u70B9\u3002","","\u63A5\u7EED\u89C4\u5219\uFF1A","1. \u4E0A\u8FF0\u5FEB\u7167\u91CC\u5DF2\u7ECF\u5B8C\u6210\u7684\u5DE5\u4F5C\u4E0D\u8981\u91CD\u505A\uFF0C\u5DF2\u786E\u8BA4\u7684\u7ED3\u8BBA\u76F4\u63A5\u6CBF\u7528\u3002","2. \u5FEB\u7167\u4E2D\u6807\u6CE8\u4E3A\u5F85\u5904\u7406/\u8FDB\u884C\u4E2D\u7684\u4E8B\u9879\uFF0C\u662F\u4F60\u8981\u7EE7\u7EED\u63A8\u8FDB\u7684\u76EE\u6807\u3002","3. \u82E5\u5FEB\u7167\u4FE1\u606F\u4E0D\u8DB3\u4EE5\u5224\u65AD\u4E0B\u4E00\u6B65\uFF0C\u5148\u8BFB\u53D6\u76F8\u5173\u6587\u4EF6\u6216\u8C03\u7528 poll_message \u83B7\u53D6\u6700\u65B0\u6D88\u606F\uFF0C\u518D\u884C\u52A8\u3002","","--- \u8FDB\u5EA6\u5FEB\u7167\u5F00\u59CB ---",n,"--- \u8FDB\u5EA6\u5FEB\u7167\u7ED3\u675F ---"].join(`
3
+ `):""}export{h as buildResumeContextBlock,c as buildRuntimeEnvironmentPrompt};
3
4
 
@@ -1,13 +1,17 @@
1
1
  import { EventEmitter } from "node:events";
2
2
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
3
  import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
4
- import { type JsonObject, type ToolPermissionPolicy } from "./built-in-file-tools.js";
5
- import type { ACodeRuntimeConfig } from "./types.js";
4
+ import { type ACodeBuiltInTool, type EditFailureSnapshot, type JsonObject, type ToolPermissionPolicy } from "./built-in-file-tools.js";
5
+ import type { ACodeMcpServerSpec, ACodeRuntimeConfig } from "./types.js";
6
6
  export interface ACodeMcpConnection {
7
7
  serverName: string;
8
8
  client: Client;
9
9
  transport: Transport;
10
10
  tools: ACodeMcpTool[];
11
+
12
+ instructions?: string;
13
+
14
+ spec?: ACodeMcpServerSpec;
11
15
  }
12
16
  interface ACodeMcpTool {
13
17
  kind: "mcp";
@@ -17,13 +21,52 @@ interface ACodeMcpTool {
17
21
  description?: string;
18
22
  inputSchema: JsonObject;
19
23
  }
24
+ type ACodeExposedTool = ACodeMcpTool | ACodeBuiltInTool;
25
+ interface ChatTextContentPart {
26
+ type: "text";
27
+ text: string;
28
+ }
29
+ interface ChatImageContentPart {
30
+ type: "image_url";
31
+ image_url: {
32
+ url: string;
33
+ };
34
+ }
35
+ type ChatContentPart = ChatTextContentPart | ChatImageContentPart;
36
+ interface ChatMessage {
37
+ role: "system" | "user" | "assistant" | "tool";
38
+ content: string | ChatContentPart[] | null;
39
+ tool_call_id?: string;
40
+ tool_calls?: ChatToolCall[];
41
+ }
42
+ interface ChatToolCall {
43
+ id: string;
44
+ type: "function";
45
+ function: {
46
+ name: string;
47
+ arguments: string;
48
+ };
49
+ }
20
50
 
21
51
  export interface ACodeSubmitOptions {
22
52
 
23
- skipProactiveCompaction?: boolean;
24
-
25
53
  resume?: boolean;
26
54
  }
55
+
56
+ export declare const TOOL_GROUP_MANIFEST_PREFIX = "ACODE_TOOL_GROUPS_V1:";
57
+
58
+ export declare function parseToolGroupManifest(instructions: string | undefined): Array<{
59
+ key: string;
60
+ label: string;
61
+ toolNames: string[];
62
+ }>;
63
+
64
+ export declare function humanReadableInstructions(instructions: string | undefined): string | undefined;
65
+
66
+ export declare function hasExplicitRequestBodyByteCap(): boolean;
67
+
68
+ export declare function resolveMaxRequestBodyBytes(contextLimit: number): number;
69
+ export declare function toToolErrorResultText(tool: ACodeExposedTool, error: unknown, snapshot?: EditFailureSnapshot): string;
27
70
  export declare class ACodeRuntime extends EventEmitter {
28
71
  private readonly config;
29
72
  private readonly hookBus;
@@ -51,11 +94,15 @@ export declare class ACodeRuntime extends EventEmitter {
51
94
  private abortForceSettleTimer;
52
95
  private activeTurn;
53
96
 
97
+ private activeBlockingToolCalls;
98
+
99
+ hasActiveBlockingToolCall(): boolean;
100
+
101
+ private static isLongBlockingMcpToolName;
102
+
54
103
  private forceMessagePending;
55
104
 
56
105
  private turnPromptPushed;
57
-
58
- private turnSkipProactiveCompaction;
59
106
  private abortRequested;
60
107
 
61
108
  private toolSettleSlots;
@@ -125,6 +172,10 @@ export declare class ACodeRuntime extends EventEmitter {
125
172
 
126
173
  notifyForceMessage(): void;
127
174
 
175
+ exportConversation(): ChatMessage[];
176
+
177
+ importTranscript(transcript: ChatMessage[]): Promise<number>;
178
+
128
179
  addBuiltInTools(tools: unknown[]): number;
129
180
 
130
181
  removeBuiltInToolsByPrefix(prefix: string): number;
@@ -139,8 +190,6 @@ export declare class ACodeRuntime extends EventEmitter {
139
190
  private isTurnSuperseded;
140
191
  private executeSubmit;
141
192
 
142
- markSkipNextCompaction(): void;
143
-
144
193
  abort(): Promise<void>;
145
194
 
146
195
  private buildAskUserQuestionDeps;
@@ -189,9 +238,13 @@ export declare class ACodeRuntime extends EventEmitter {
189
238
  private requestChatCompletion;
190
239
 
191
240
  private compactForContextOverflow;
241
+
242
+ private rebuildRuntimeResourcesMessage;
192
243
  private readChatCompletionStream;
193
244
  private handleToolCalls;
194
245
 
246
+ private emitToolBatchStart;
247
+
195
248
  private executePreparedToolCallsConcurrently;
196
249
 
197
250
  private executePreparedToolCallsSerially;
@@ -210,6 +263,8 @@ export declare class ACodeRuntime extends EventEmitter {
210
263
 
211
264
  private runMcpToolCall;
212
265
 
266
+ private withBlockingToolCallTracking;
267
+
213
268
  private classifyToolError;
214
269
 
215
270
  private commitToolOutcome;
@@ -248,6 +303,7 @@ export declare class ACodeRuntime extends EventEmitter {
248
303
  private createRuntimeStopWaiter;
249
304
 
250
305
  private notifyRuntimeStop;
306
+
251
307
  private appendSyntheticMultimodalUserMessage;
252
308
 
253
309
  private expandCommandsInPolledResult;
@@ -258,6 +314,10 @@ export declare class ACodeRuntime extends EventEmitter {
258
314
  private filterSharedMcpConnectionsForSubAgent;
259
315
  private connectMcpServers;
260
316
 
317
+ private registerMcpCollapsedGroup;
318
+
319
+ private registerToolGroupsFromMcp;
320
+
261
321
  requestMcpToolsRefresh(serverName?: string): void;
262
322
 
263
323
  recoverHiddenMcpTool(toolName: string): Promise<boolean>;