aws-runtime-bridge 1.9.162 → 1.9.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +304 -0
- package/dist/adapter/AcodeSdkAdapter.d.ts +31 -3
- package/dist/adapter/AcodeSdkAdapter.js +4 -9
- package/dist/adapter/ClaudeSdkAdapter.d.ts +2 -0
- package/dist/adapter/ClaudeSdkAdapter.js +3 -3
- package/dist/adapter/CodexSdkAdapter.d.ts +2 -0
- package/dist/adapter/CodexSdkAdapter.js +3 -3
- package/dist/adapter/OpencodeSdkAdapter.d.ts +2 -0
- package/dist/adapter/OpencodeSdkAdapter.js +3 -3
- package/dist/adapter/prompts.d.ts +1 -1
- package/dist/adapter/prompts.js +1 -1
- package/dist/adapter/types.d.ts +41 -4
- package/dist/adapter/types.js +1 -1
- package/dist/browser/frame-encode.d.ts +25 -0
- package/dist/browser/frame-encode.js +2 -0
- package/dist/browser/screencast-differ.d.ts +2 -3
- package/dist/browser/screencast-differ.js +1 -1
- package/dist/browser/screencast-manager.js +1 -1
- package/dist/browser/types.d.ts +5 -1
- package/dist/browser/types.js +1 -1
- package/dist/desktop/desktop-mcp-client.js +2 -2
- package/dist/routes/background-tasks.js +3 -3
- package/dist/routes/capabilities.js +1 -1
- package/dist/routes/dashboard.d.ts +2 -0
- package/dist/routes/dashboard.js +4 -4
- package/dist/routes/git.js +22 -22
- package/dist/routes/instance.js +1 -1
- package/dist/routes/launch.js +10 -10
- package/dist/routes/mcp-extra.js +2 -2
- package/dist/routes/mcp.d.ts +4 -0
- package/dist/routes/mcp.js +1 -1
- package/dist/routes/plugins.js +1 -1
- package/dist/routes/pty.d.ts +11 -3
- package/dist/routes/pty.js +3 -3
- package/dist/routes/runtime-binding.js +1 -1
- package/dist/routes/sessions.js +1 -1
- package/dist/routes/skills.js +1 -1
- package/dist/routes/sub-agents.js +8 -8
- package/dist/routes/terminal.d.ts +16 -2
- package/dist/routes/terminal.js +34 -36
- package/dist/services/agent-process-manager.js +1 -1
- package/dist/services/agent-pty-manager.js +4 -4
- package/dist/services/aws-client-agent-mcp.js +2 -2
- package/dist/services/capability-config.d.ts +8 -0
- package/dist/services/capability-config.js +2 -2
- package/dist/services/desktop-mcp-manager.d.ts +3 -1
- package/dist/services/desktop-mcp-manager.js +1 -1
- package/dist/services/instance-ai-config-service.js +1 -1
- package/dist/services/instance-features.d.ts +10 -0
- package/dist/services/instance-features.js +1 -1
- package/dist/services/instance-init-service.js +1 -1
- package/dist/services/launch-manager.d.ts +9 -1
- package/dist/services/launch-manager.js +6 -6
- package/dist/services/launch-metrics.d.ts +1 -1
- package/dist/services/launch-metrics.js +4 -3
- package/dist/services/mcp-deploy.d.ts +4 -0
- package/dist/services/mcp-env-injector.d.ts +12 -0
- package/dist/services/mcp-env-injector.js +2 -0
- package/dist/services/mcp-launch-binding-queue.d.ts +8 -0
- package/dist/services/mcp-launch-binding-queue.js +1 -1
- package/dist/services/orphan-monitor.js +1 -1
- package/dist/services/panel-env.d.ts +6 -2
- package/dist/services/panel-env.js +1 -1
- package/dist/services/plugin-manager.js +9 -9
- package/dist/services/process-detector.d.ts +23 -3
- package/dist/services/process-detector.js +13 -13
- package/dist/services/runtime-resources-snapshot.d.ts +3 -0
- package/dist/services/runtime-resources-snapshot.js +3 -0
- package/dist/services/session-output.d.ts +13 -0
- package/dist/services/session-output.js +4 -4
- package/dist/services/tunnel-client.js +1 -1
- package/dist/services/workspace-files.js +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/utils/env-safety.d.ts +15 -0
- package/dist/utils/env-safety.js +2 -0
- package/dist/utils/lifecycle-log.d.ts +2 -0
- package/dist/utils/lifecycle-log.js +3 -0
- package/dist/utils/mcp-utils.js +1 -1
- package/package/acode/dist/background-command-manager.js +4 -4
- package/package/acode/dist/built-in-file-tools.d.ts +13 -0
- package/package/acode/dist/built-in-file-tools.js +2 -2
- package/package/acode/dist/builtins/shellCommandPreparation.d.ts +2 -0
- package/package/acode/dist/builtins/shellCommandPreparation.js +2 -2
- package/package/acode/dist/compaction.d.ts +10 -0
- package/package/acode/dist/compaction.js +6 -6
- package/package/acode/dist/context-overflow.js +1 -1
- package/package/acode/dist/index.d.ts +1 -0
- package/package/acode/dist/index.js +1 -1
- package/package/acode/dist/mcpToolNames.d.ts +4 -0
- package/package/acode/dist/mcpToolNames.js +1 -1
- package/package/acode/dist/runtime-environment.d.ts +2 -0
- package/package/acode/dist/runtime-environment.js +3 -2
- package/package/acode/dist/runtime.d.ts +68 -8
- package/package/acode/dist/runtime.js +28 -27
- package/package/acode/dist/sub-agent-manager.js +1 -1
- package/package/acode/dist/tool-allocation.js +1 -1
- package/package/acode/dist/tool-group-manager.d.ts +12 -0
- package/package/acode/dist/tool-group-manager.js +8 -4
- package/package/acode/dist/types.d.ts +8 -0
- package/package/acode/package.json +1 -1
- package/package/aws-client-agent-mcp/README.md +1 -0
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts +20 -8
- package/package/aws-client-agent-mcp/dist/agent-client.js +1 -1
- package/package/aws-client-agent-mcp/dist/http-client.d.ts +10 -0
- package/package/aws-client-agent-mcp/dist/http-client.js +1 -1
- package/package/aws-client-agent-mcp/dist/logger.d.ts +2 -1
- package/package/aws-client-agent-mcp/dist/logger.js +2 -2
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +19 -2
- package/package/aws-client-agent-mcp/dist/mcp-server.js +18 -18
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +13 -4
- package/package/aws-client-agent-mcp/dist/mcp-tools.js +79 -29
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/memory-store.js +3 -3
- package/package/aws-client-agent-mcp/dist/message-buffer.js +1 -1
- package/package/aws-client-agent-mcp/dist/office/office-workspace.d.ts +15 -0
- package/package/aws-client-agent-mcp/dist/office/office-workspace.js +1 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.js +1 -1
- package/package/aws-client-agent-mcp/dist/tool-groups.d.ts +4 -0
- package/package/aws-client-agent-mcp/dist/tool-groups.js +2 -2
- package/package/aws-client-agent-mcp/dist/types.d.ts +50 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.js +1 -1
- package/package/aws-client-agent-mcp/package.json +1 -1
- 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
|
|
2
|
-
`)
|
|
3
|
-
`);
|
|
4
|
-
`)});else{const
|
|
5
|
-
`).slice(0,
|
|
6
|
-
`)})}return t.push(...i),
|
|
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
|
|
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
|
|
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
|
|
2
|
-
`)}
|
|
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>;
|