@tencent-ai/agent-harness 0.2.0-beta.5 → 0.2.0-beta.7
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 +25 -0
- package/cli/CHANGELOG.md +49 -0
- package/cli/dist-server/shared.cjs +174 -173
- package/cli/dist-server/types/node/server/types.d.ts +11 -2
- package/cli/dist-server/types/node/tools/tool-protocol.d.ts +2 -1
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +5 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/background-task-protocol.d.ts +14 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-interruption-host-protocol.d.ts +3 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +2 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-store.d.ts +13 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/truncation-recovery.d.ts +8 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/input-item-utils.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/message-utils.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/tools/tool-names.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/utils/concurrency-utils.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/background-task-protocol.d.ts +14 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-interruption-host-protocol.d.ts +3 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-store.d.ts +13 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/truncation-recovery.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/input-item-utils.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/message-utils.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/tools/tool-names.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/concurrency-utils.d.ts +5 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +34 -22
- package/cli/dist-server/types/workspace/product/lib/common/types/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/language-model.d.ts +5 -1
- package/cli/dist-server/types/workspace/product/lib/common/types/product.d.ts +7 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/workspace-report.d.ts +119 -0
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +1 -1
- package/cli/product.internal.json +1 -1
- package/cli/product.ioa.json +1 -1
- package/cli/product.json +1 -1
- package/cli/product.selfhosted.json +1 -1
- package/docs/client.md +26 -0
- package/lib/session/server-config.d.ts +4 -2
- package/lib/session/server-config.js +1 -1
- package/lib/session/server-interactions.js +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"agents":[{"name":"cli","instructions":"cli-agent-prompt","description":"cli agent","models":["codewise-chat"],"modelTags":["craft"],"commands":["init","compact","statusline","insights"],"tools":["Agent","Read","Write","Edit","Bash","PowerShell","Glob","Grep","EnterPlanMode","ExitPlanMode","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","TaskStop","TaskOutput","Skill","AskUserQuestion","AskUserForStructuredInput","StructuredOutput","ToolSearch","DeferExecuteTool","SendMessage","SendUserMessage","TeamCreate","TeamDelete","NotebookEdit","LSP","EnterWorktree","LeaveWorktree","CronCreate","CronDelete","CronList","DelegateTool","WeChatReply","WeComReply","PushNotification","ReportFindings","ComputerUse","ListMcpResources","ReadMcpResource","WaitForMcpServers","Workflow","Monitor","REPL","A2AGetAgentCard","A2ASendMessage","A2AGetTask","A2ACancelTask"],"tags":["cli","default","model:craft"]},{"name":"general-purpose","instructions":"cli-agent-prompt","description":"general-purpose agent","tools":["Read","Write","Edit","Bash","PowerShell","Glob","Grep","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","TaskStop","TaskOutput","Skill","AskUserQuestion","AskUserForStructuredInput","ToolSearch","DeferExecuteTool","StructuredOutput","SendMessage","SendUserMessage","NotebookEdit","LSP","ComputerUse","ImageGen","ImageEdit","Artifact","ArtifactControl","ListMcpResources","ReadMcpResource","WaitForMcpServers","REPL"],"tags":["cli","general-purpose"]},{"name":"compact","instructions":"compact-agent-prompt","description":"compact agent","tools":["Read"],"commands":["_compact"],"tags":["cli","compact"]},{"name":"contextSummary","instructions":"context-summary-agent-prompt","description":"Context summary agent for conversation compaction and max-token recovery","tools":[],"tags":["cli","contextSummary"]},{"name":"contentAnalyzer","instructions":"content-analyzer-agent-instructions","description":"content analyzer agent","tags":["cli","content-analyzer"],"tools":[]},{"name":"terminalTitleGenerator","instructions":"terminal-title-generator-instructions","description":"Generate terminal window titles from conversation topics.","tags":["cli","terminal-title-generator"],"tools":[]},{"name":"promptSuggestion","instructions":"prompt-suggestion-instructions","description":"Suggest the user's next prompt after a conversation turn.","tags":["cli","prompt-suggestion"],"tools":[]},{"name":"memorySelector","instructions":"memory-selector-instructions","description":"Select relevant memories for the current query.","models":["lite"],"tags":["cli","memory-selector"],"tools":[]},{"name":"summaryGenerator","instructions":"summary-generator-instructions","description":"Generate session summaries from conversation content.","tags":["cli","summary-generator"],"tools":[]},{"name":"securityReviewer","instructions":"security-reviewer-instructions","description":"Review bounded security decisions without tools.","models":["lite"],"tags":["cli","security-reviewer"],"tools":[]},{"name":"autoModeClassifier","instructions":"auto-mode-classifier-instructions","description":"Classify auto mode tool permission risk.","models":["lite"],"tags":["cli","auto-mode-classifier"],"tools":[]},{"name":"promptHookEvaluator","instructions":"prompt-hook-evaluator-instructions","description":"Evaluates prompt hooks using LLM to determine if conditions are met","models":["lite"],"tags":["cli","prompt-hook-evaluator"],"tools":[]},{"name":"insightsAnalyzer","instructions":"base-agent-instructions","description":"Analyzes user usage data facets for the /insights command","tags":["cli","insights-analyzer"],"tools":[]},{"name":"agentInstructions","instructions":"agent-instructions","description":"generating agent instructions","tags":["cli","agent-instructions"],"tools":[]},{"name":"statusline-setup","instructions":"agent-statusline-instructions","description":"Use this agent to configure the user's Codebuddy Code status line setting.","tools":["Read","Write","Edit","ToolSearch","DeferExecuteTool"],"asTool":true,"tags":["cli","sub-agent"]},{"name":"Explore","instructions":"agent-explore-instructions","description":"Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. \"src/components/**/*.tsx\"), search code for keywords (eg. \"API endpoints\"), or answer questions about the codebase (eg. \"how do API endpoints work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"very thorough\" for comprehensive analysis across multiple locations and naming conventions.","models":["lite"],"tools":["Read","Bash","PowerShell","Glob","Grep","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","Skill","SendMessage","SendUserMessage","ToolSearch","DeferExecuteTool"],"asTool":true,"tags":["cli","sub-agent"]},{"name":"Plan","instructions":"agent-plan-instructions","description":"Software architect agent for designing implementation plans. Use this when you need to plan the implementation strategy for a multi-step task before writing code. Returns step-by-step plans, identifies critical files, and considers architectural trade-offs. Read-only: it designs but does not modify files or exit plan mode; the caller reviews the plan and implements it.","tools":["Read","Bash","PowerShell","Glob","Grep","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","Skill","ToolSearch","DeferExecuteTool","TeamCreate","TeamDelete","SendMessage","SendUserMessage"],"asTool":true,"tags":["cli","sub-agent"]}],"models":[{"credits":"x0.01 credits","id":"codewise-chat","name":"Codewise-Chat","vendor":"tencent","maxOutputTokens":8192,"maxInputTokens":128000,"supportsToolCall":true,"supportsImages":false,"disabledMultimodal":true,"maxAllowedSize":56000}],"links":{"officialWebsite":"https://copilot.tencent.com/cli","helpDocument":"https://copilot.tencent.com/docs/cli","issueFeedback":"https://cnb.cool/codebuddy/codebuddy-code/-/issues","issueCreation":"https://cnb.cool/codebuddy/codebuddy-code/-/issues/new","mcpHelpDocument":"https://copilot.tencent.com/docs/cli/mcp","hooksHelpDocument":"https://copilot.tencent.com/docs/cli/hooks","sandboxHelpDocument":"https://copilot.tencent.com/docs/cli/bash-sandboxing","upgradeUrl":""},"productFeatures":{"BillingNotice":false,"ShareLink":true,"Artifact":true,"CodeAdoptionRate":false,"CloudAgentsSmartMerge":true,"CustomModelsJSON":true,"CustomModelIdPrefix":true,"DeferToolLoading":true,"ScheduledTasks":true,"SkipToolCallSupportCheck":true},"commit":"
|
|
1
|
+
{"agents":[{"name":"cli","instructions":"cli-agent-prompt","description":"cli agent","models":["codewise-chat"],"modelTags":["craft"],"commands":["init","compact","statusline","insights"],"tools":["Agent","Read","Write","Edit","Bash","PowerShell","Glob","Grep","EnterPlanMode","ExitPlanMode","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","TaskStop","TaskOutput","Skill","AskUserQuestion","AskUserForStructuredInput","StructuredOutput","ToolSearch","DeferExecuteTool","SendMessage","SendUserMessage","TeamCreate","TeamDelete","NotebookEdit","LSP","EnterWorktree","LeaveWorktree","CronCreate","CronDelete","CronList","DelegateTool","WeChatReply","WeComReply","PushNotification","ReportFindings","ComputerUse","ListMcpResources","ReadMcpResource","WaitForMcpServers","Workflow","Monitor","REPL","A2AGetAgentCard","A2ASendMessage","A2AGetTask","A2ACancelTask"],"tags":["cli","default","model:craft"]},{"name":"general-purpose","instructions":"cli-agent-prompt","description":"general-purpose agent","tools":["Read","Write","Edit","Bash","PowerShell","Glob","Grep","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","TaskStop","TaskOutput","Skill","AskUserQuestion","AskUserForStructuredInput","ToolSearch","DeferExecuteTool","StructuredOutput","SendMessage","SendUserMessage","NotebookEdit","LSP","ComputerUse","ImageGen","ImageEdit","Artifact","ArtifactControl","ListMcpResources","ReadMcpResource","WaitForMcpServers","REPL"],"tags":["cli","general-purpose"]},{"name":"compact","instructions":"compact-agent-prompt","description":"compact agent","tools":["Read"],"commands":["_compact"],"tags":["cli","compact"]},{"name":"contextSummary","instructions":"context-summary-agent-prompt","description":"Context summary agent for conversation compaction and max-token recovery","tools":[],"tags":["cli","contextSummary"]},{"name":"contentAnalyzer","instructions":"content-analyzer-agent-instructions","description":"content analyzer agent","tags":["cli","content-analyzer"],"tools":[]},{"name":"terminalTitleGenerator","instructions":"terminal-title-generator-instructions","description":"Generate terminal window titles from conversation topics.","tags":["cli","terminal-title-generator"],"tools":[]},{"name":"promptSuggestion","instructions":"prompt-suggestion-instructions","description":"Suggest the user's next prompt after a conversation turn.","tags":["cli","prompt-suggestion"],"tools":[]},{"name":"memorySelector","instructions":"memory-selector-instructions","description":"Select relevant memories for the current query.","models":["lite"],"tags":["cli","memory-selector"],"tools":[]},{"name":"summaryGenerator","instructions":"summary-generator-instructions","description":"Generate session summaries from conversation content.","tags":["cli","summary-generator"],"tools":[]},{"name":"securityReviewer","instructions":"security-reviewer-instructions","description":"Review bounded security decisions without tools.","models":["lite"],"tags":["cli","security-reviewer"],"tools":[]},{"name":"autoModeClassifier","instructions":"auto-mode-classifier-instructions","description":"Classify auto mode tool permission risk.","models":["lite"],"tags":["cli","auto-mode-classifier"],"tools":[]},{"name":"promptHookEvaluator","instructions":"prompt-hook-evaluator-instructions","description":"Evaluates prompt hooks using LLM to determine if conditions are met","models":["lite"],"tags":["cli","prompt-hook-evaluator"],"tools":[]},{"name":"insightsAnalyzer","instructions":"base-agent-instructions","description":"Analyzes user usage data facets for the /insights command","tags":["cli","insights-analyzer"],"tools":[]},{"name":"agentInstructions","instructions":"agent-instructions","description":"generating agent instructions","tags":["cli","agent-instructions"],"tools":[]},{"name":"statusline-setup","instructions":"agent-statusline-instructions","description":"Use this agent to configure the user's Codebuddy Code status line setting.","tools":["Read","Write","Edit","ToolSearch","DeferExecuteTool"],"asTool":true,"tags":["cli","sub-agent"]},{"name":"Explore","instructions":"agent-explore-instructions","description":"Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. \"src/components/**/*.tsx\"), search code for keywords (eg. \"API endpoints\"), or answer questions about the codebase (eg. \"how do API endpoints work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"very thorough\" for comprehensive analysis across multiple locations and naming conventions.","models":["lite"],"tools":["Read","Bash","PowerShell","Glob","Grep","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","Skill","SendMessage","SendUserMessage","ToolSearch","DeferExecuteTool"],"asTool":true,"tags":["cli","sub-agent"]},{"name":"Plan","instructions":"agent-plan-instructions","description":"Software architect agent for designing implementation plans. Use this when you need to plan the implementation strategy for a multi-step task before writing code. Returns step-by-step plans, identifies critical files, and considers architectural trade-offs. Read-only: it designs but does not modify files or exit plan mode; the caller reviews the plan and implements it.","tools":["Read","Bash","PowerShell","Glob","Grep","TaskCreate","TaskGet","TaskUpdate","TaskList","WebFetch","WebSearch","Skill","ToolSearch","DeferExecuteTool","TeamCreate","TeamDelete","SendMessage","SendUserMessage"],"asTool":true,"tags":["cli","sub-agent"]}],"models":[{"credits":"x0.01 credits","id":"codewise-chat","name":"Codewise-Chat","vendor":"tencent","maxOutputTokens":8192,"maxInputTokens":128000,"supportsToolCall":true,"supportsImages":false,"disabledMultimodal":true,"maxAllowedSize":56000}],"links":{"officialWebsite":"https://copilot.tencent.com/cli","helpDocument":"https://copilot.tencent.com/docs/cli","issueFeedback":"https://cnb.cool/codebuddy/codebuddy-code/-/issues","issueCreation":"https://cnb.cool/codebuddy/codebuddy-code/-/issues/new","mcpHelpDocument":"https://copilot.tencent.com/docs/cli/mcp","hooksHelpDocument":"https://copilot.tencent.com/docs/cli/hooks","sandboxHelpDocument":"https://copilot.tencent.com/docs/cli/bash-sandboxing","upgradeUrl":""},"productFeatures":{"BillingNotice":false,"ShareLink":true,"Artifact":true,"CodeAdoptionRate":false,"CloudAgentsSmartMerge":true,"CustomModelsJSON":true,"CustomModelIdPrefix":true,"DeferToolLoading":true,"ScheduledTasks":true,"SkipToolCallSupportCheck":true},"commit":"d5cd5f8fbbaa71808a6fa3648103e540ddb77745","date":"2026-09-30T05:49:29.879Z"}
|
package/docs/client.md
CHANGED
|
@@ -77,6 +77,11 @@ client.on('session/request_permission', (request, context) =>
|
|
|
77
77
|
`void | Promise<void>`;各 listener 都会被调用并等待完成,一个 listener 失败不会阻止
|
|
78
78
|
同一通知的其他 listener。
|
|
79
79
|
|
|
80
|
+
权限弹窗按 `request.options` 展示,并返回用户选择的 `optionId`。普通工具提供
|
|
81
|
+
`kind: 'allow_always'` 时,表示允许该工具在本会话继续使用;未提供时只允许本次操作。
|
|
82
|
+
Defer 工具的 `title` 显示实际目标名称,授权不会覆盖整个 Defer 工具集合。强制审批不会因该授权跳过。
|
|
83
|
+
通过会话配置进入 Plan 会记录当前权限模式,退出 Plan 后恢复它。
|
|
84
|
+
|
|
80
85
|
沙箱审批的展示信息位于 `request.subject.toolCall._meta`(先确认 `subject.type === 'tool_call'`),
|
|
81
86
|
包括 `codebuddy.ai/sandboxIntercept`、`interceptType`、`target`、`operation`、`description`、
|
|
82
87
|
`sandboxRuleContext` 和 `bulkDeleteInfo` 等 `codebuddy.ai/` 字段。沙箱命令的“本次会话内允许”
|
|
@@ -130,6 +135,27 @@ steer 返回同一 requestId,不新开一轮。ACK 表示输入已进入待消
|
|
|
130
135
|
返回值的 `_meta['codebuddy.ai/requestId']` 是维护操作 ID;完成状态通过 `session/update` 交付,
|
|
131
136
|
不会创建用户 turn。也可以通过 prompt 提交 `/compact` 命令,按命令解析规则执行。
|
|
132
137
|
|
|
138
|
+
## 提问元数据
|
|
139
|
+
|
|
140
|
+
通过 `session.prompt._meta` 传入 W3C 追踪上下文。`baggage` 按标准传播为内置模型 HTTP 请求的同名 header,也供本轮遥测使用:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
await client.session.prompt({
|
|
144
|
+
sessionId,
|
|
145
|
+
prompt: [{ type: 'text', text: '解释这段代码' }],
|
|
146
|
+
_meta: {
|
|
147
|
+
baggage: 'x-agent-intent=ask,example.source=editor',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`x-agent-intent` 是合法的自定义 W3C Baggage 键,无需再加 namespace。键名区分大小写,请使用小写形式;其他业务字段可使用 `your-org.source` 等前缀避免冲突。
|
|
153
|
+
`x-agent-intent` 按同名约定映射到模型请求头 `X-Agent-Intent`,常用值为 `craft`、`ask`、`plan`、`expert`,也支持自定义归因值;省略或不合法的 HTTP header 值使用 `craft`。
|
|
154
|
+
现有遥测的 `mode` 字段仍使用原枚举,自定义值可通过 baggage 属性读取。其他 baggage 条目保持在 `baggage` header 中,不展开成独立 header;`x-` 前缀不授予覆写认证、会话或追踪头的权限。W3C 标准不定义条目到独立 header 的展开映射。
|
|
155
|
+
场景不切换权限模式,也不选择 Agent;这些仍通过会话配置设置。新增的 baggage 传播和意图映射只用于内置模型,遵守 `CODEBUDDY_SKIP_INTERNAL_HEADERS`;自定义或第三方模型维持原有请求头策略,不接收这些宿主扩展。
|
|
156
|
+
元数据按本次 query 捕获,子任务继承所属请求;下一次提问不继承上次的 `_meta`。后台自动续跑保留场景,但创建新的追踪和请求标识。
|
|
157
|
+
旧调用方的 `_meta['codebuddy.ai'].mode` 仅在 baggage 未提供场景时兼容,新调用方无需传入。
|
|
158
|
+
|
|
133
159
|
## 读取 Subagent 历史
|
|
134
160
|
|
|
135
161
|
连接已创建或 resume 根会话后,可以列出子会话,并单独读取它们的历史:
|
|
@@ -4,7 +4,7 @@ import type { AcpV2ClientCapabilities, AcpV2SetSessionConfigOptionRequest } from
|
|
|
4
4
|
import type { WorkspaceSessionModelConfigOption } from '../runtime/product-manager.js';
|
|
5
5
|
import type { SessionConfigValues } from './config-store.js';
|
|
6
6
|
export type SessionConfigProjector = (options: QueryOptions, catalog?: WorkspaceSessionModelConfigOption) => SessionConfigOption[];
|
|
7
|
-
type ConfigQueryOptions = Pick<QueryOptions, 'model' | 'permissionMode' | 'thinking' | 'effort' | 'contextWindow' | 'agent' | 'multitask' | 'sandboxEnabled'>;
|
|
7
|
+
type ConfigQueryOptions = Pick<QueryOptions, 'model' | 'permissionMode' | 'permissionModeBeforePlan' | 'thinking' | 'effort' | 'contextWindow' | 'agent' | 'multitask' | 'sandboxEnabled'>;
|
|
8
8
|
export interface SessionConfigDefaults {
|
|
9
9
|
readonly sandboxEnabled?: boolean;
|
|
10
10
|
readonly readFailed?: boolean;
|
|
@@ -27,16 +27,18 @@ export declare class ServerSessionConfig {
|
|
|
27
27
|
get queryOptions(): ConfigQueryOptions;
|
|
28
28
|
copy(): ServerSessionConfig;
|
|
29
29
|
replace(config: ServerSessionConfig): void;
|
|
30
|
+
/** Persisted session state, including private Plan restoration metadata; ACP uses snapshot(). */
|
|
30
31
|
selections(): SessionConfigValues;
|
|
31
32
|
restore(values: SessionConfigValues): void;
|
|
32
33
|
snapshot(): SessionConfigOption[];
|
|
33
34
|
contextSize(modelId?: string): number | undefined;
|
|
34
|
-
update(values: Pick<ConfigQueryOptions, 'permissionMode' | 'agent' | 'multitask'>, rememberChanges?: boolean): boolean;
|
|
35
|
+
update(values: Pick<ConfigQueryOptions, 'permissionMode' | 'permissionModeBeforePlan' | 'agent' | 'multitask'>, rememberChanges?: boolean): boolean;
|
|
35
36
|
lockAgent(): void;
|
|
36
37
|
initializeBlank(): void;
|
|
37
38
|
set(params: AcpV2SetSessionConfigOptionRequest): void;
|
|
38
39
|
private reconcileSelections;
|
|
39
40
|
private remember;
|
|
41
|
+
private setPermissionMode;
|
|
40
42
|
private apply;
|
|
41
43
|
}
|
|
42
44
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var
|
|
1
|
+
var h=Object.defineProperty;var c=(r,e)=>h(r,"name",{value:e,configurable:!0});import{AgentHarnessInvalidParamsError as l}from"../server/errors.js";function d(r){return r?.type==="select"&&Array.isArray(r.options)}c(d,"isSelect");export class ServerSessionConfig{static{c(this,"ServerSessionConfig")}constructor(e,i,s,o,t){this.options=e,this.catalog=i,this.project=s,this.restoreProject=o,this.projectContextSize=t,this.explicitSelections={},this.agentLocked=!1;const n=e.model??i?.currentValue;if(this.modelExplicit=e.model!==void 0,n&&i&&!i.options.some(a=>a.value===n))throw new l("Agent model is outside the admitted Harness catalog");this.values={model:n,permissionMode:e.permissionMode??e.settings?.permissions?.defaultMode??"default",...e.thinking?{thinking:e.thinking}:{},...e.effort!==void 0?{effort:e.effort}:{},...e.contextWindow!==void 0?{contextWindow:e.contextWindow}:{},...e.agent!==void 0?{agent:e.agent}:{},...e.multitask!==void 0?{multitask:e.multitask}:{},...e.sandboxEnabled!==void 0?{sandboxEnabled:e.sandboxEnabled}:{}},this.values.permissionMode==="plan"&&(this.values.permissionModeBeforePlan=e.permissionModeBeforePlan??"default")}static async create(e,i,s={},o={}){const{createSessionConfigProjector:t,projectSessionContextSize:n}=await import("#agent-harness-components/session-config"),a=o.sandboxEnabled===void 0?{...e}:{...e,settings:{...e.settings,sandbox:{...e.settings?.sandbox,enabled:o.sandboxEnabled}}},u=await t(a,{_meta:{"codebuddy.ai":{mainAgentSupport:!0}}});return new ServerSessionConfig(a,i,await t(a,s),u,n)}refreshDefaults(e){if(e.readFailed)return!1;const i=JSON.stringify(this.snapshot());return this.options.settings={...this.options.settings,sandbox:{...this.options.settings?.sandbox,enabled:e.sandboxEnabled}},i!==JSON.stringify(this.snapshot())}get queryOptions(){return{...this.values}}copy(){const e=new ServerSessionConfig(this.options,this.catalog,this.project,this.restoreProject,this.projectContextSize);return e.replace(this),e}replace(e){for(const i of Object.keys(this.values))delete this.values[i];Object.assign(this.values,structuredClone(e.values)),this.explicitSelections=structuredClone(e.explicitSelections),this.agentLocked=e.agentLocked,this.modelExplicit=e.modelExplicit}selections(){return{...structuredClone(this.explicitSelections),...this.explicitSelections.mode==="plan"?{permissionModeBeforePlan:this.values.permissionModeBeforePlan??"default"}:{}}}restore(e){const i=e.model,s=typeof i=="string"&&this.catalog!==void 0&&!this.catalog.options.some(o=>o.value===i);for(const o of["multitask","sandbox","agent","model","mode","context_window","thought_level"]){if(s&&["model","context_window","thought_level"].includes(o))continue;const t=e[o];if(t!==void 0)try{this.apply(typeof t=="boolean"?{sessionId:"",configId:o,type:"boolean",value:t}:{sessionId:"",configId:o,type:"id",value:t},this.restoreProject),this.remember(o)}catch(n){if(!(n instanceof l))throw n}}if(this.values.permissionMode==="plan"&&typeof e.permissionModeBeforePlan=="string"){const o=this.restoreProject({...this.options,...this.values},this.catalog).find(n=>n.configId==="mode"),t=d(o)?o.options.flatMap(n=>"options"in n?n.options:[n]):[];e.permissionModeBeforePlan!=="plan"&&t.some(n=>n.value===e.permissionModeBeforePlan)&&(this.values.permissionModeBeforePlan=e.permissionModeBeforePlan)}}snapshot(){return this.project({...this.options,...this.values},this.catalog)}contextSize(e){return this.projectContextSize({...this.options,...this.values},e)}update(e,i=!1){const s=Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0));if(Object.entries(s).every(([t,n])=>this.values[t]===n))return!1;const o=Object.keys(s).filter(t=>this.values[t]!==s[t]);if(e.permissionMode&&this.setPermissionMode(e.permissionMode),Object.assign(this.values,s),i)for(const t of o)this.remember(t==="permissionMode"?"mode":t);return!0}lockAgent(){this.agentLocked=!0}initializeBlank(){const e=this.snapshot().find(i=>i.configId==="agent");d(e)&&!this.values.agent&&this.apply({sessionId:"",configId:"agent",type:"id",value:e.currentValue},this.project)}set(e){this.apply(e,this.project),this.remember(e.configId)}reconcileSelections(){const e=new Map(this.restoreProject({...this.options,...this.values},this.catalog).map(i=>[i.configId,i.currentValue]));for(const[i,s]of Object.entries(this.explicitSelections))e.get(i)!==s&&delete this.explicitSelections[i]}remember(e){this.reconcileSelections();const i=this.restoreProject({...this.options,...this.values},this.catalog).find(s=>s.configId===e);(typeof i?.currentValue=="string"||typeof i?.currentValue=="boolean")&&(this.explicitSelections[e]=i.currentValue)}setPermissionMode(e){e==="plan"?this.values.permissionMode!=="plan"&&(this.values.permissionModeBeforePlan=this.values.permissionMode??"default"):delete this.values.permissionModeBeforePlan,this.values.permissionMode=e}apply(e,i){const s=i({...this.options,...this.values},this.catalog).find(t=>t.configId===e.configId);if(!s)throw new l(`Unknown Agent configuration option: ${e.configId}`);if(s.type==="boolean"){if(e.type!=="boolean"||typeof e.value!="boolean")throw new l("Agent boolean configuration requires a boolean value");if(e.configId==="multitask"){this.values.multitask=e.value;return}if(e.configId==="sandbox"){this.values.sandboxEnabled=e.value;return}throw new l(`Unsupported Agent configuration option: ${e.configId}`)}if(e.type!=="id"||typeof e.value!="string")throw new l("Agent select configuration requires an option id");if(!(d(s)?s.options.flatMap(t=>"options"in t?t.options:[t]):[]).some(t=>t.value===e.value))throw new l(`Unknown Agent configuration option: ${e.configId}=${e.value}`);switch(e.configId){case"agent":if(this.agentLocked)throw new l("Main Agent can only change in a blank session");if(e.value==="minimal"&&this.values.multitask)throw new l("Disable Multitask before selecting Minimal");if(this.values.agent=e.value,!this.modelExplicit){const t=this.options.product?.agents?.find(n=>n.name===e.value)?.declaredModel;t&&(!this.catalog||this.catalog.options.some(n=>n.value===t))&&(this.values.model=t)}e.value==="minimal"&&this.values.permissionMode==="plan"&&this.setPermissionMode("default");return;case"mode":this.setPermissionMode(e.value);return;case"model":{this.modelExplicit=!0,this.values.model=e.value,(this.values.thinking!==void 0||this.values.effort!==void 0)&&(this.values.thinking={type:"adaptive"},this.values.effort=null);const t=this.snapshot().find(n=>n.configId==="context_window");this.values.contextWindow!=null&&(!d(t)||!t.options.some(n=>"value"in n&&n.value===String(this.values.contextWindow)))&&(this.values.contextWindow=null);return}case"thought_level":this.values.thinking={type:e.value==="disabled"?"disabled":"adaptive"},this.values.effort=e.value==="disabled"||e.value==="enabled"?null:e.value;return;case"context_window":this.values.contextWindow=Number(e.value);return;default:throw new l(`Unsupported Agent configuration option: ${e.configId}`)}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var l=(o,t)=>h(o,"name",{value:t,configurable:!0});import{createAskUserQuestionElicitation as A,normalizeAskUserQuestionElicitationAnswers as m}from"#agent-harness-components/question-elicitation";import{FILE_DIRECTORY_APPROVAL_OPTION_ID as q,parseSandboxPermissionMetadata as k}from"#agent-harness-components/sandbox";import{abortable as C}from"../internal/async.js";import{isRecord as
|
|
1
|
+
var h=Object.defineProperty;var l=(o,t)=>h(o,"name",{value:t,configurable:!0});import{createAskUserQuestionElicitation as A,normalizeAskUserQuestionElicitationAnswers as m}from"#agent-harness-components/question-elicitation";import{FILE_DIRECTORY_APPROVAL_OPTION_ID as q,parseSandboxPermissionMetadata as k}from"#agent-harness-components/sandbox";import{abortable as C}from"../internal/async.js";import{isRecord as I}from"../internal/guards.js";function v(o){if(!Array.isArray(o.questions)||o.questions.length===0)throw new Error("AskUserQuestion requires questions");return{questions:o.questions.map(t=>{if(!I(t)||typeof t.question!="string"||!Array.isArray(t.options))throw new Error("Invalid AskUserQuestion question");return{question:t.question,header:typeof t.header=="string"?t.header:"",multiSelect:t.multiSelect===!0,options:t.options.map(a=>{if(!I(a)||typeof a.label!="string")throw new Error("Invalid AskUserQuestion option");return{label:a.label,description:typeof a.description=="string"?a.description:""}})}})}}l(v,"questionsFrom");export function serverCanUseTool(o,t,a){return async(d,n,e)=>{const i=l(r=>({behavior:"deny",message:r}),"deny");if(e.signal.aborted)return i("Interaction cancelled");const{id:b,meta:p}=t(),c=e.origin?{...e.origin.requestId?{"codebuddy.ai/requestId":e.origin.requestId}:{},...e.origin.rootRequestId?{"codebuddy.ai/rootRequestId":e.origin.rootRequestId}:{},...e.origin.subagent?{"codebuddy.ai/subagent":e.origin.subagent}:{}}:p,g=l(async r=>{await a?.(!0,c);try{return await C(r(),e.signal)}finally{e.signal.aborted||await a?.(!1,c)}},"interact");if(d==="AskUserQuestion"){if(!o.clientCapabilities.elicitation?.form)return i("Client does not support form elicitation");const r=v(n),y=await g(()=>o.callbacks.createElicitation(A(r,b,e.toolUseID,c),{signal:e.signal}));return e.signal.aborted||y.action!=="accept"?{...i("User declined to answer"),interrupt:!0}:{behavior:"allow",updatedInput:{...n,answers:m(r,y.content)}}}const u=e.suggestions?.length?structuredClone(e.suggestions):void 0,f=e.metadata?structuredClone(e.metadata):void 0,{fileApprovalScope:w}=f?.["codebuddy.ai/sandboxIntercept"]===!0?k(f):{},_={sessionId:b,title:e.title??e.displayName??d,...e.description?{description:e.description}:{},subject:{type:"tool_call",toolCall:{toolCallId:e.toolUseID,title:e.displayName??d,rawInput:n,...e.blockedPath?{locations:[{path:e.blockedPath}]}:{},...f?{_meta:{...f,"codebuddy.ai/toolName":d}}:{}}},options:[{optionId:"allow_once",name:"Allow once",kind:"allow_once"},...u&&!w?[{optionId:"allow_always",name:u.every(r=>r.destination==="session")?"Allow for this session":"Always allow",kind:"allow_always"}]:[],{optionId:"reject_once",name:"Reject",kind:"reject_once"}],_meta:c},s=await g(()=>o.callbacks.requestPermission(_,{signal:e.signal}));return e.signal.aborted||s.outcome.outcome!=="selected"?i("Permission request cancelled"):s.outcome.optionId==="allow_once"?{behavior:"allow",updatedInput:n,decisionClassification:"user_temporary"}:s.outcome.optionId===q&&w?{behavior:"allow",updatedInput:n,decisionClassification:"user_permanent",metadata:{_fileDirectoryApprovalResponderVersion:1}}:s.outcome.optionId==="allow_always"&&w?{behavior:"allow",updatedInput:n,decisionClassification:"user_temporary"}:s.outcome.optionId==="allow_always"&&u?{behavior:"allow",updatedInput:n,updatedPermissions:u,decisionClassification:"user_permanent"}:{...i("Permission denied"),decisionClassification:"user_reject"}}}l(serverCanUseTool,"serverCanUseTool");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tencent-ai/agent-harness",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.7",
|
|
4
4
|
"description": "Standalone JSON-RPC agent harness backed by CodeBuddy Code",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -225,13 +225,13 @@
|
|
|
225
225
|
"@tencent-ai/sandbox-cli-linux-x64": "5.8.0-beta.7",
|
|
226
226
|
"@tencent-ai/sandbox-cli-win32-x64": "5.8.0-beta.7",
|
|
227
227
|
"esbuild": "^0.25.12",
|
|
228
|
-
"@tencent-ai/agent-harness-darwin-arm64": "0.2.0-beta.
|
|
229
|
-
"@tencent-ai/agent-harness-darwin-x64": "0.2.0-beta.
|
|
230
|
-
"@tencent-ai/agent-harness-linux-arm64": "0.2.0-beta.
|
|
231
|
-
"@tencent-ai/agent-harness-linux-arm64-musl": "0.2.0-beta.
|
|
232
|
-
"@tencent-ai/agent-harness-linux-x64": "0.2.0-beta.
|
|
233
|
-
"@tencent-ai/agent-harness-linux-x64-musl": "0.2.0-beta.
|
|
234
|
-
"@tencent-ai/agent-harness-win32-x64": "0.2.0-beta.
|
|
228
|
+
"@tencent-ai/agent-harness-darwin-arm64": "0.2.0-beta.7",
|
|
229
|
+
"@tencent-ai/agent-harness-darwin-x64": "0.2.0-beta.7",
|
|
230
|
+
"@tencent-ai/agent-harness-linux-arm64": "0.2.0-beta.7",
|
|
231
|
+
"@tencent-ai/agent-harness-linux-arm64-musl": "0.2.0-beta.7",
|
|
232
|
+
"@tencent-ai/agent-harness-linux-x64": "0.2.0-beta.7",
|
|
233
|
+
"@tencent-ai/agent-harness-linux-x64-musl": "0.2.0-beta.7",
|
|
234
|
+
"@tencent-ai/agent-harness-win32-x64": "0.2.0-beta.7"
|
|
235
235
|
},
|
|
236
236
|
"devDependencies": {
|
|
237
237
|
"@anthropic-ai/sandbox-runtime": "0.0.17",
|