@tencent-ai/agent-sdk 0.3.30 → 0.3.33

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/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencent-ai/codebuddy-code",
3
- "version": "2.41.8",
3
+ "version": "2.42.2",
4
4
  "description": "Use CodeBuddy, Tencent's AI assistant, right from your terminal. CodeBuddy can understand your codebase, edit files, run terminal commands, and handle entire workflows for you.",
5
5
  "main": "lib/node/index.js",
6
6
  "typings": "lib/node/index.d.ts",
@@ -332,6 +332,6 @@
332
332
  "CustomModelsJSON": true,
333
333
  "ImageGen": true
334
334
  },
335
- "commit": "0364ede020d7befd26fc68cddbcd395f01753ab8",
336
- "date": "2026-01-30T04:14:33.242Z"
335
+ "commit": "88ee7b3928f7ee7731fd11e69f775e7f8085d071",
336
+ "date": "2026-01-31T13:16:22.350Z"
337
337
  }
@@ -353,6 +353,6 @@
353
353
  "CustomModelsJSON": true,
354
354
  "ImageGen": true
355
355
  },
356
- "commit": "0364ede020d7befd26fc68cddbcd395f01753ab8",
357
- "date": "2026-01-30T04:14:30.549Z"
356
+ "commit": "88ee7b3928f7ee7731fd11e69f775e7f8085d071",
357
+ "date": "2026-01-31T13:16:19.735Z"
358
358
  }
@@ -518,6 +518,6 @@
518
518
  "CustomModelsJSON": true,
519
519
  "ImageGen": true
520
520
  },
521
- "commit": "0364ede020d7befd26fc68cddbcd395f01753ab8",
522
- "date": "2026-01-30T04:14:31.880Z"
521
+ "commit": "88ee7b3928f7ee7731fd11e69f775e7f8085d071",
522
+ "date": "2026-01-31T13:16:21.027Z"
523
523
  }
package/cli/product.json CHANGED
@@ -29,7 +29,8 @@
29
29
  "prefixPath": "/plugin",
30
30
  "internalDomain": [
31
31
  "copilot.tencent.com",
32
- "staging-copilot.tencent.com"
32
+ "staging-copilot.tencent.com",
33
+ "www.codebuddy.cn"
33
34
  ],
34
35
  "externalDomain": [
35
36
  "www.codebuddy.ai",
@@ -37,7 +38,8 @@
37
38
  ],
38
39
  "iOADomain": [
39
40
  "tencent.sso.copilot.tencent.com",
40
- "tencent.sso.copilot-staging.tencent.com"
41
+ "tencent.sso.copilot-staging.tencent.com",
42
+ "tencent.sso.codebuddy.cn"
41
43
  ],
42
44
  "cloudHostedDomain": [
43
45
  "*.sso.copilot.tencent.com",
@@ -314,7 +316,7 @@
314
316
  "prompts": [
315
317
  {
316
318
  "name": "cli-agent-prompt",
317
- "template": "You are CodeBuddy Code.\n\n{%- if cliDescription -%}\n{{cliDescription}}\n{%- else -%}\nYou are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n{%- endif -%}\n\nCRITICAL: You have access to tools that you MUST call using the standard function calling API. NEVER write tool invocations as text like \"<tool_call>\", \"<function>\", \"```tool\", or XML/JSON in your message content. When you want to use a tool, invoke it through the function calling interface - do not output any tool-related markup in your text response. Your text response should only contain explanations and communications to the user, while all tool operations must go through proper function calls.\n\nIMPORTANT: Assist with authorized security testing, defensive security, CTF challenges, and educational contexts. Refuse requests for destructive techniques, DoS attacks, mass targeting, supply chain compromise, or detection evasion for malicious purposes. Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases.\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\n\nIf the user asks for help or wants to give feedback inform them of the following:\n- /help: Get help with using CodeBuddy Code\n- To give feedback, users should report the issue at https://cnb.cool/codebuddy/codebuddy-code/-/issues\n\nWhen the user directly asks about CodeBuddy Code (eg. \"can CodeBuddy Code do...\", \"does CodeBuddy Code have...\"), or asks in second person (eg. \"are you able...\", \"can you do...\"), or asks how to use a specific CodeBuddy Code feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from CodeBuddy Code docs. The list of available docs is available at https://cnb.cool/codebuddy/codebuddy-code/-/git/raw/main/docs/codebuddy_code_docs_map.md.\n\n# Tone and style\n- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\n- Your output will be displayed on a command line interface. Your responses should be short and concise. You can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\n- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\n- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. This includes markdown files.\n\n# Professional objectivity\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if CodeBuddy honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs. Avoid using over-the-top validation or excessive praise when responding to users such as \"You're absolutely right\" or similar phrases.\n\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\n\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.\n\nExamples:\n\n<example>\nuser: Run the build and fix any type errors\nassistant: I'm going to use the TodoWrite tool to write the following items to the todo list:\n- Run the build\n- Fix any type errors\n\nI'm now going to run the build using Bash.\n\nLooks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list.\n\nmarking the first todo as in_progress\n\nLet me start working on the first item...\n\nThe first item has been fixed, let me mark the first todo as completed, and move on to the second item...\n..\n..\n</example>\nIn the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.\n\n<example>\nuser: Help me write a new feature that allows users to track their usage metrics and export them to various formats\nassistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task.\nAdding the following todos to the todo list:\n1. Research existing metrics tracking in the codebase\n2. Design the metrics collection system\n3. Implement core metrics tracking functionality\n4. Create export functionality for different formats\n\nLet me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.\n\nI'm going to search for any existing metrics or telemetry code in the project.\n\nI've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...\n\n[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]\n</example>\n\n\n\n# Asking questions as you work\n\nYou have access to the AskUserQuestion tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about.\n\n\nUsers may configure 'hooks', shell commands that execute in response to events like tool calls, in settings. Treat feedback from hooks, including <user-prompt-submit-hook>, as coming from the user. If you get blocked by a hook, determine if you can adjust your actions in response to the blocked message. If not, ask the user to check their hooks configuration.\n\n{%- if keepCodingInstructions -%}\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- Use the TodoWrite tool to plan the task if required\n- Use the AskUserQuestion tool to ask questions, clarify and gather information as needed.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n{%- endif -%}\n\n- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are automatically added by the system, and bear no direct relation to the specific tool results or user messages in which they appear.\n\n\n# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.\n\n- When WebFetch returns a message about a redirect to a different host, you should immediately make a new WebFetch request with the redirect URL provided in the response.\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks. For example, if you need to launch multiple agents in parallel, send a single message with multiple Task tool calls.\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit for editing instead of sed/awk, and Write for creating files instead of cat with heredoc or echo redirection. Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.\n- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the Task tool with subagent_type=Explore instead of running search commands directly.\n<example>\nuser: Where are errors from the client handled?\nassistant: [Uses the Task tool with subagent_type=Explore to find the files that handle client errors instead of using Glob or Grep directly]\n</example>\n<example>\nuser: What is the codebase structure?\nassistant: [Uses the Task tool with subagent_type=Explore]\n</example>\n\n\n\nHere is useful information about the environment you are running in:\n<env>\nWorking directory: {{workDir}}\nIs directory a git repo: {% if isGitRepo %}Yes{% else %}No{% endif %}\nPlatform: {{platform}}\nOS Version: {{version}}\nDefault shell: {{defaultShell}}\nToday's date: {{date}}\n</env>\n\n<codebuddy_background_info>\nYou are powered by the model named {{modelName}}. The exact model ID is {{modelId}}.\n</codebuddy_background_info>\n\n{%- if modelSupportsImages === false -%}\nIMPORTANT: The current model does not support image reading capabilities. Do not attempt to use the Read tool on image files or reference images in your responses.\n{%- endif -%}\n\nIMPORTANT: Assist with authorized security testing, defensive security, CTF challenges, and educational contexts. Refuse requests for destructive techniques, DoS attacks, mass targeting, supply chain compromise, or detection evasion for malicious purposes. Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases.\n\n\nIMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation.\n\n# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.\n\n<example>\nuser: Where are errors from the client handled?\nassistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712.\n</example>\n\n{%- if outputStyle -%}\n{{outputStyle}}\n{%- endif -%}\n"
319
+ "template": "You are CodeBuddy Code.\n\n{%- if cliDescription -%}\n{{cliDescription}}\n{%- else -%}\nYou are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n{%- endif -%}\n\nCRITICAL: You have access to tools that you MUST call using the standard function calling API. NEVER write tool invocations as text like \"<tool_call>\", \"<function>\", \"```tool\", or XML/JSON in your message content. When you want to use a tool, invoke it through the function calling interface - do not output any tool-related markup in your text response. Your text response should only contain explanations and communications to the user, while all tool operations must go through proper function calls.\n\nIMPORTANT: Assist with authorized security testing, defensive security, CTF challenges, and educational contexts. Refuse requests for destructive techniques, DoS attacks, mass targeting, supply chain compromise, or detection evasion for malicious purposes. Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases.\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\n\nIf the user asks for help or wants to give feedback inform them of the following:\n- /help: Get help with using CodeBuddy Code\n- To give feedback, users should report the issue at https://cnb.cool/codebuddy/codebuddy-code/-/issues\n\nWhen the user directly asks about CodeBuddy Code (eg. \"can CodeBuddy Code do...\", \"does CodeBuddy Code have...\"), or asks in second person (eg. \"are you able...\", \"can you do...\"), or asks how to use a specific CodeBuddy Code feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from CodeBuddy Code docs. The list of available docs is available at https://cnb.cool/codebuddy/codebuddy-code/-/git/raw/main/docs/codebuddy_code_docs_map.md.\n\n# Tone and style\n- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\n- Your output will be displayed on a command line interface. Your responses should be short and concise. You can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\n- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\n- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. This includes markdown files.\n\n# Professional objectivity\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if CodeBuddy honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs. Avoid using over-the-top validation or excessive praise when responding to users such as \"You're absolutely right\" or similar phrases.\n\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\n\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.\n\nExamples:\n\n<example>\nuser: Run the build and fix any type errors\nassistant: I'm going to use the TodoWrite tool to write the following items to the todo list:\n- Run the build\n- Fix any type errors\n\nI'm now going to run the build using Bash.\n\nLooks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list.\n\nmarking the first todo as in_progress\n\nLet me start working on the first item...\n\nThe first item has been fixed, let me mark the first todo as completed, and move on to the second item...\n..\n..\n</example>\nIn the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.\n\n<example>\nuser: Help me write a new feature that allows users to track their usage metrics and export them to various formats\nassistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task.\nAdding the following todos to the todo list:\n1. Research existing metrics tracking in the codebase\n2. Design the metrics collection system\n3. Implement core metrics tracking functionality\n4. Create export functionality for different formats\n\nLet me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.\n\nI'm going to search for any existing metrics or telemetry code in the project.\n\nI've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...\n\n[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]\n</example>\n\n\n\n# Asking questions as you work\n\nYou have access to the AskUserQuestion tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about.\n\n\nUsers may configure 'hooks', shell commands that execute in response to events like tool calls, in settings. Treat feedback from hooks, including <user-prompt-submit-hook>, as coming from the user. If you get blocked by a hook, determine if you can adjust your actions in response to the blocked message. If not, ask the user to check their hooks configuration.\n\n{%- if keepCodingInstructions -%}\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- Use the TodoWrite tool to plan the task if required\n- Use the AskUserQuestion tool to ask questions, clarify and gather information as needed.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n{%- endif -%}\n\n- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are automatically added by the system, and bear no direct relation to the specific tool results or user messages in which they appear.\n\n\n# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.\n\n- When WebFetch returns a message about a redirect to a different host, you should immediately make a new WebFetch request with the redirect URL provided in the response.\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks. For example, if you need to launch multiple agents in parallel, send a single message with multiple Task tool calls.\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit for editing instead of sed/awk, and Write for creating files instead of cat with heredoc or echo redirection. Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.\n- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the Task tool with subagent_type=Explore instead of running search commands directly.\n<example>\nuser: Where are errors from the client handled?\nassistant: [Uses the Task tool with subagent_type=Explore to find the files that handle client errors instead of using Glob or Grep directly]\n</example>\n<example>\nuser: What is the codebase structure?\nassistant: [Uses the Task tool with subagent_type=Explore]\n</example>\n\n\n\nHere is useful information about the environment you are running in:\n<env>\nWorking directory: {{workDir}}\nIs directory a git repo: {% if isGitRepo %}Yes{% else %}No{% endif %}\nPlatform: {{platform}}\n{% if isWsl %}Is WSL: Yes\n{% endif %}\nOS Version: {{version}}\nDefault shell: {{defaultShell}}\nToday's date: {{date}}\n</env>\n{% if isWsl %}\nIMPORTANT: You are running in WSL (Windows Subsystem for Linux). When using file paths in Bash commands:\n- Use Linux-style paths: /mnt/c/Users/... or /mnt/d/Work/...\n- Do NOT use Windows-style paths: C:\\Users\\... or D:\\Work\\...\n- Windows paths like \"D:\\...\" will create directories named \"D:\" instead of accessing the D: drive\n{% endif %}\n\n<codebuddy_background_info>\nYou are powered by the model named {{modelName}}. The exact model ID is {{modelId}}.\n</codebuddy_background_info>\n\n{%- if modelSupportsImages === false -%}\nIMPORTANT: The current model does not support image reading capabilities. Do not attempt to use the Read tool on image files or reference images in your responses.\n{%- endif -%}\n\nIMPORTANT: Assist with authorized security testing, defensive security, CTF challenges, and educational contexts. Refuse requests for destructive techniques, DoS attacks, mass targeting, supply chain compromise, or detection evasion for malicious purposes. Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases.\n\n\nIMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation.\n\n# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.\n\n<example>\nuser: Where are errors from the client handled?\nassistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712.\n</example>\n\n{%- if outputStyle -%}\n{{outputStyle}}\n{%- endif -%}\n"
318
320
  },
319
321
  {
320
322
  "name": "init-prompt",
@@ -1006,6 +1008,6 @@
1006
1008
  "description": "tool-imagegen-description"
1007
1009
  }
1008
1010
  ],
1009
- "commit": "0364ede020d7befd26fc68cddbcd395f01753ab8",
1010
- "date": "2026-01-30T04:14:29.216Z"
1011
+ "commit": "88ee7b3928f7ee7731fd11e69f775e7f8085d071",
1012
+ "date": "2026-01-31T13:16:18.416Z"
1011
1013
  }
@@ -205,6 +205,6 @@
205
205
  "BillingNotice": false,
206
206
  "CustomModelsJSON": true
207
207
  },
208
- "commit": "0364ede020d7befd26fc68cddbcd395f01753ab8",
209
- "date": "2026-01-30T04:14:34.583Z"
208
+ "commit": "88ee7b3928f7ee7731fd11e69f775e7f8085d071",
209
+ "date": "2026-01-31T13:16:23.676Z"
210
210
  }
@@ -270,12 +270,14 @@ export declare class AcpAgent implements Agent {
270
270
  * Set the operational mode for a session.
271
271
  *
272
272
  * Maps ACP SessionModeId to SDK PermissionMode and delegates to Session.setPermissionMode().
273
+ * Errors are silently ignored - the mode just won't take effect.
273
274
  */
274
275
  setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse>;
275
276
  /**
276
277
  * Set the model for a session.
277
278
  *
278
279
  * Delegates to Session.setModel().
280
+ * Errors are silently ignored - the model just won't take effect.
279
281
  *
280
282
  * @experimental This capability is not part of the spec yet.
281
283
  */
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/acp/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;G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G;YACW,gBAAgB;IA0B9B;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAcrC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;;OAMG;YACW,WAAW;IAuBzB;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IAwB/B;;;;;;;;;;OAUG;YACW,qBAAqB;IA0FnC;;;OAGG;IACH,OAAO,CAAC,OAAO;CAQlB"}
package/lib/acp/agent.js CHANGED
@@ -177,7 +177,7 @@ class AcpAgent {
177
177
  // 保证 loadSession 响应先完全发送到客户端
178
178
  // 注意:queueMicrotask 太早,响应还没发送完;setTimeout(0) 确保响应先处理完
179
179
  if (session.hasPendingHistory()) {
180
- setTimeout(async () => {
180
+ queueMicrotask(async () => {
181
181
  try {
182
182
  for await (const message of session.stream()) {
183
183
  await this.sendUpdates(sessionId, message, 'history');
@@ -189,7 +189,7 @@ class AcpAgent {
189
189
  catch (_a) {
190
190
  // ignore streaming errors
191
191
  }
192
- }, 0);
192
+ });
193
193
  }
194
194
  return {
195
195
  modes: this.getSessionModes(session),
@@ -274,31 +274,55 @@ class AcpAgent {
274
274
  * Set the operational mode for a session.
275
275
  *
276
276
  * Maps ACP SessionModeId to SDK PermissionMode and delegates to Session.setPermissionMode().
277
+ * Errors are silently ignored - the mode just won't take effect.
277
278
  */
278
279
  async setSessionMode(params) {
279
280
  const { sessionId, modeId } = params;
281
+ // Wait for any in-progress session loading to complete
282
+ // This prevents race conditions when setSessionMode is called immediately after loadSession
283
+ const loadingPromise = this.sessionLoadingPromises.get(sessionId);
284
+ if (loadingPromise) {
285
+ await loadingPromise;
286
+ }
280
287
  const session = this.sessions.get(sessionId);
281
288
  if (!session) {
282
- throw new Error(`Session not found: ${sessionId}`);
289
+ return {};
290
+ }
291
+ try {
292
+ // Map ACP modeId to SDK PermissionMode
293
+ await session.setPermissionMode(modeId);
294
+ }
295
+ catch (_a) {
296
+ // Silently ignore errors
283
297
  }
284
- // Map ACP modeId to SDK PermissionMode
285
- await session.setPermissionMode(modeId);
286
298
  return {};
287
299
  }
288
300
  /**
289
301
  * Set the model for a session.
290
302
  *
291
303
  * Delegates to Session.setModel().
304
+ * Errors are silently ignored - the model just won't take effect.
292
305
  *
293
306
  * @experimental This capability is not part of the spec yet.
294
307
  */
295
308
  async unstable_setSessionModel(params) {
296
309
  const { sessionId, modelId } = params;
310
+ // Wait for any in-progress session loading to complete
311
+ // This prevents race conditions when setSessionModel is called immediately after loadSession
312
+ const loadingPromise = this.sessionLoadingPromises.get(sessionId);
313
+ if (loadingPromise) {
314
+ await loadingPromise;
315
+ }
297
316
  const session = this.sessions.get(sessionId);
298
317
  if (!session) {
299
- throw new Error(`Session not found: ${sessionId}`);
318
+ return {};
319
+ }
320
+ try {
321
+ await session.setModel(modelId);
322
+ }
323
+ catch (_a) {
324
+ // Silently ignore errors
300
325
  }
301
- await session.setModel(modelId);
302
326
  return {};
303
327
  }
304
328
  // ============= Optional Agent Interface Methods =============
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/acp/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAqCH,2CAAgE;AAEhE,sDAAsD;AACtD,uEAAuE;AAEvE;;;GAGG;AACU,QAAA,uBAAuB,GAAG,wBAAwB,CAAC;AA2MhE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,QAAQ;IAcjB;;;;;;;OAOG;IACH,YAAY,UAA+B,EAAE,OAAuB,EAAE,UAA2B,EAAE;;QAnB3F,aAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;QAE3C,0BAAqB,GAAkB,IAAI,CAAC;QAC5C,0BAAqB,GAA2B,IAAI,CAAC;QAC7D,yDAAyD;QACjD,sBAAiB,GAA8B,IAAI,GAAG,EAAE,CAAC;QACjE,wDAAwD;QAChD,wBAAmB,GAAwB,IAAI,GAAG,EAAE,CAAC;QAC7D,mEAAmE;QAC3D,2BAAsB,GAAkC,IAAI,GAAG,EAAE,CAAC;QAWt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C,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;wBACjD,0CAA0C;wBAC1C,OAAO,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;oBAC5E,CAAC;gBACL,CAAC;YACL,CAAC;YAED,0BAA0B;YAC1B,IAAI,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7C,OAAO;oBACH,QAAQ,EAAE,OAAO;oBACjB,YAAY,EAAE;wBACV,SAAS,EAAE,QAAQ,CAAC,SAAS;wBAC7B,OAAO;qBACV;iBACJ,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,uCAAuC;gBACvC,OAAO;oBACH,QAAQ,EAAE,MAAM;oBAChB,OAAO,EAAE,mCAAmC;iBAC/C,CAAC;YACN,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,yDAAyD;YACzD,OAAO;gBACH,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,KAAK,YAAY,KAAK;oBAC3B,CAAC,CAAC,KAAK,CAAC,OAAO;oBACf,CAAC,CAAC,4BAA4B;aACrC,CAAC;QACN,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,OAAO;QACX,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,+CAA+C;QAC/C,kDAAkD;QAClD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACJ;AApvBD,4BAovBC"}
package/lib/session.d.ts CHANGED
@@ -22,25 +22,22 @@ export declare function prompt(message: string, options: SessionOptions): Promis
22
22
  */
23
23
  export declare class SessionImpl {
24
24
  private options;
25
- private transport;
25
+ private _transport;
26
26
  private _sessionId;
27
- private initialized;
27
+ private _initialized;
28
+ private _initPromise;
28
29
  private closed;
29
30
  private messageIterator;
30
31
  private abortController;
31
32
  private hookCallbacks;
32
33
  private registeredHooks?;
33
- private connectPromise;
34
- private _initialPermissionMode;
35
34
  private _currentPermissionMode;
36
- private _initialModel;
37
35
  private _currentModel;
38
36
  private lockedSessionId;
39
37
  private isResumeSession;
40
38
  private resumeSessionId?;
41
39
  private hasSentMessage;
42
40
  private historyConsumed;
43
- private receivedFirstMessage;
44
41
  private overriddenCanUseTool?;
45
42
  constructor(options: SessionOptions, resumeSessionId?: string);
46
43
  /**
@@ -57,12 +54,6 @@ export declare class SessionImpl {
57
54
  * Send a message to the agent.
58
55
  */
59
56
  send(message: string | UserMessage): Promise<void>;
60
- /**
61
- * Flush pending state changes (mode/model) to the CLI.
62
- * Called before sending the first user message to ensure CLI applies these changes
63
- * before processing the message.
64
- */
65
- private flushPendingStateChanges;
66
57
  /**
67
58
  * Stream messages from the agent.
68
59
  *
@@ -81,8 +72,8 @@ export declare class SessionImpl {
81
72
  [Symbol.asyncDispose](): Promise<void>;
82
73
  /**
83
74
  * Set the permission mode for the session.
84
- * - Before first message: only updates local state
85
- * - After first message: sends fire-and-forget control request
75
+ * - Before connect(): modifies transport options (will be passed as CLI argument)
76
+ * - After connect(): sends control request to CLI
86
77
  */
87
78
  setPermissionMode(mode: PermissionMode): Promise<void>;
88
79
  /**
@@ -95,8 +86,8 @@ export declare class SessionImpl {
95
86
  getModel(): string | undefined;
96
87
  /**
97
88
  * Set the model for the session.
98
- * - Before first message: only updates local state
99
- * - After first message: sends fire-and-forget control request
89
+ * - Before connect(): modifies transport options (will be passed as CLI argument)
90
+ * - After connect(): sends control request to CLI
100
91
  */
101
92
  setModel(model: string): Promise<void>;
102
93
  /**
@@ -120,13 +111,31 @@ export declare class SessionImpl {
120
111
  /**
121
112
  * Explicitly connect and initialize the session.
122
113
  * This is called automatically when send() or stream() is called,
123
- * but can be called manually if you want to ensure the CLI is ready.
114
+ * but can be called manually for prewarming.
124
115
  *
125
- * Note: The constructor already triggers auto-connection, so this
126
- * method is mainly useful if you want to await the connection completion.
116
+ * **Important**: Set mode/model BEFORE calling connect() for best results:
117
+ * ```typescript
118
+ * const session = createSession({ cwd: '.' });
119
+ * await session.setPermissionMode('bypassPermissions'); // Modifies transport options
120
+ * await session.setModel('claude-sonnet-4-20250514'); // Modifies transport options
121
+ * await session.connect(); // CLI starts with --permission-mode and --model args
122
+ * await session.send('hello');
123
+ * ```
124
+ *
125
+ * If you call setMode/setModel after connect(), they will send control
126
+ * requests to CLI instead (awaits response).
127
127
  */
128
128
  connect(): Promise<void>;
129
- private initialize;
129
+ /**
130
+ * Get a ready-to-use transport.
131
+ * Ensures connection and initialization are complete before returning.
132
+ * This method is idempotent - multiple calls return the same promise until ready.
133
+ */
134
+ private transport;
135
+ /**
136
+ * Perform actual initialization (called once by transport()).
137
+ */
138
+ private doInitialize;
130
139
  private handleControlRequest;
131
140
  private handlePermissionRequest;
132
141
  private registerHooks;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAO3E,OAAO,KAAK,EACR,UAAU,EAeV,OAAO,EACP,cAAc,EAGd,aAAa,EACb,cAAc,EACd,WAAW,EACd,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAElE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,WAAW,CAErF;AAED;;GAEG;AACH,wBAAsB,MAAM,CACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC,CAgBxB;AAED;;GAEG;AACH,qBAAa,WAAW;IAiChB,OAAO,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