@tencent-ai/agent-harness 0.2.0-beta.1 → 0.2.0-beta.3
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 +44 -0
- package/README.md +1 -1
- package/cli/CHANGELOG.md +135 -0
- package/cli/dist-server/shared.cjs +455 -387
- package/cli/dist-server/types/node/acp/acp-protocol.d.ts +40 -12
- package/cli/dist-server/types/node/acp/usage-by-category-calculator.d.ts +21 -0
- package/cli/dist-server/types/node/bash-sandbox/bash-sandbox-protocol.d.ts +3 -0
- package/cli/dist-server/types/node/cli/cli-protocol.d.ts +3 -0
- package/cli/dist-server/types/node/cli/stream-json-protocol.d.ts +23 -2
- package/cli/dist-server/types/node/data-fs/index.d.ts +13 -1
- package/cli/dist-server/types/node/hooks/hook-protocol.d.ts +2 -2
- package/cli/dist-server/types/node/sensitive-content/sensitive-content-protocol.d.ts +7 -0
- package/cli/dist-server/types/node/server/boot.d.ts +7 -4
- package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-error-model.d.ts +1 -1
- package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-protocol.d.ts +2 -3
- package/cli/dist-server/types/node/server/formats/acp/index.d.ts +12 -0
- package/cli/dist-server/types/node/server/formats/acp/projection.d.ts +10 -0
- package/cli/dist-server/types/node/server/index.d.ts +1 -1
- package/cli/dist-server/types/node/server/sessions.d.ts +27 -2
- package/cli/dist-server/types/node/server/types.d.ts +65 -7
- package/cli/dist-server/types/node/settings/settings-protocol.d.ts +5 -0
- package/cli/dist-server/types/node/tools/tool-protocol.d.ts +128 -4
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +60 -2
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-protocol.d.ts +8 -4
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-scope.d.ts +46 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-service.d.ts +28 -3
- package/cli/dist-server/types/vendor/cbc-core/node/agent/index.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/interceptors/input-interceptors.d.ts +1 -6
- package/cli/dist-server/types/vendor/cbc-core/node/agent/model-call-failure.d.ts +9 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/model-step-sequence.d.ts +11 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/runner-factory.d.ts +56 -20
- package/cli/dist-server/types/vendor/cbc-core/node/agent/speaker-label.d.ts +44 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-detector-service.d.ts +5 -4
- package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
- package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-pattern.d.ts +16 -4
- package/cli/dist-server/types/vendor/cbc-core/node/context/compaction-lineage.d.ts +39 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/context-compact-summarizer.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/context-protocol.d.ts +17 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/pre-message-compact-strategy.d.ts +1 -2
- package/cli/dist-server/types/vendor/cbc-core/node/hooks/agent-trigger.d.ts +6 -22
- package/cli/dist-server/types/vendor/cbc-core/node/hooks/hook-protocol.d.ts +4 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/idle-queue-drain-service.d.ts +4 -56
- package/cli/dist-server/types/vendor/cbc-core/node/session/index.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +63 -9
- package/cli/dist-server/types/vendor/cbc-core/node/session/model-request-retry-phase.d.ts +16 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/model-response-interceptors.d.ts +33 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/recovery-budget.d.ts +55 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-hook-manager.d.ts +15 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager-host-protocol.d.ts +3 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager.d.ts +17 -4
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-persistence-error.d.ts +43 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +110 -9
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-run-state-machine-protocol.d.ts +15 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-runtime-lifecycle.d.ts +5 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-store.d.ts +150 -4
- package/cli/dist-server/types/vendor/cbc-core/node/session/stream-timeout-retry-budget.d.ts +20 -1
- package/cli/dist-server/types/vendor/cbc-core/node/trace/turn-context.d.ts +28 -1
- package/cli/dist-server/types/vendor/cbc-core/node/utils/command-message-utils.d.ts +20 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/history-utils.d.ts +27 -4
- package/cli/dist-server/types/vendor/cbc-core/node/utils/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/input-item-utils.d.ts +8 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/message-utils.d.ts +12 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/model-utils.d.ts +7 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/queue-dispatch-utils.d.ts +24 -2
- package/cli/dist-server/types/vendor/cbc-core/node/utils/session-utils.d.ts +4 -1
- package/cli/dist-server/types/vendor/cbc-core/node/utils/string-retention-utils.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/token-utils.d.ts +3 -1
- package/cli/dist-server/types/vendor/cbc-shared/node/agent/openai-agents-types.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/checkpoint/checkpoint-types.d.ts +6 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/hooks/hook-types.d.ts +7 -1
- package/cli/dist-server/types/vendor/cbc-shared/node/index.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/model/model-errors.d.ts +36 -4
- package/cli/dist-server/types/vendor/cbc-shared/node/tools/tool-names.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/utils/retry-backoff.d.ts +30 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/utils/retry-policy.d.ts +26 -0
- package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/sandbox-rule-context.d.ts +38 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/account-scoped-external-link-authentication-provider.d.ts +5 -5
- package/cli/dist-server/types/workspace/authentication/lib/common/account-utils.d.ts +25 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts +8 -2
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-observation.d.ts +36 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-protocol.d.ts +40 -2
- package/cli/dist-server/types/workspace/authentication/lib/common/external-link-authentication-provider.d.ts +21 -5
- package/cli/dist-server/types/workspace/authentication/lib/common/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/wx-authentication-provider.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-protocol.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-service.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +60 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-protocol.d.ts +8 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-scope.d.ts +46 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-service.d.ts +28 -3
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/index.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/interceptors/input-interceptors.d.ts +1 -6
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-call-failure.d.ts +9 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-step-sequence.d.ts +11 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/runner-factory.d.ts +56 -20
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/speaker-label.d.ts +44 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-detector-service.d.ts +5 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-pattern.d.ts +16 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/compaction-lineage.d.ts +39 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-compact-summarizer.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-protocol.d.ts +17 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/pre-message-compact-strategy.d.ts +1 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/agent-trigger.d.ts +6 -22
- package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/hook-protocol.d.ts +4 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/idle-queue-drain-service.d.ts +4 -56
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/index.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +63 -9
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-request-retry-phase.d.ts +16 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-response-interceptors.d.ts +33 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/recovery-budget.d.ts +55 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-hook-manager.d.ts +15 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager-host-protocol.d.ts +3 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager.d.ts +17 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-persistence-error.d.ts +43 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +110 -9
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-run-state-machine-protocol.d.ts +15 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-runtime-lifecycle.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-store.d.ts +150 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/stream-timeout-retry-budget.d.ts +20 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/trace/turn-context.d.ts +28 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/command-message-utils.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/history-utils.d.ts +27 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/input-item-utils.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/message-utils.d.ts +12 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/model-utils.d.ts +7 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/queue-dispatch-utils.d.ts +24 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/session-utils.d.ts +4 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/string-retention-utils.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/token-utils.d.ts +3 -1
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/openai-agents-types.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/checkpoint/checkpoint-types.d.ts +6 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/hooks/hook-types.d.ts +7 -1
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/model/model-errors.d.ts +36 -4
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/tools/tool-names.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/retry-backoff.d.ts +30 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/retry-policy.d.ts +26 -0
- package/cli/dist-server/types/workspace/cbc-workflow/lib/node/workflow/workflow-execution.d.ts +14 -1
- package/cli/dist-server/types/workspace/cbc-workflow/lib/node/workflow/workflow-manager.d.ts +7 -0
- package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-service.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-session.d.ts +3 -0
- package/cli/dist-server/types/workspace/core/lib/common/protocol.d.ts +8 -1
- package/cli/dist-server/types/workspace/product/lib/common/cloud-product-provider.d.ts +9 -0
- package/cli/dist-server/types/workspace/product/lib/common/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/product/lib/common/pick-market-skill-id.d.ts +13 -0
- package/cli/dist-server/types/workspace/product/lib/common/tencent-docs-endpoint.d.ts +37 -0
- package/cli/dist-server/types/workspace/product/lib/common/tool-control-catalog.d.ts +2 -2
- package/cli/dist-server/types/workspace/product/lib/common/types/config.d.ts +12 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +63 -11
- package/cli/dist-server/types/workspace/product/lib/common/types/language-model.d.ts +66 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/product.d.ts +22 -1
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/backup-policy.d.ts +10 -1
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/center-protocol.generated.d.ts +375 -4
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/file-policy.d.ts +5 -2
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/http-policy.d.ts +20 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/rule-config.d.ts +10 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/node/sandbox-center-client.d.ts +219 -0
- package/cli/dist-server/types/workspace/telemetry/lib/common/event/types/craft.d.ts +43 -3
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +4 -4
- package/cli/product.internal.json +268 -45
- package/cli/product.ioa.json +354 -161
- package/cli/product.json +338 -352
- package/cli/product.selfhosted.json +2 -2
- package/cli/vendor/shim/brokered-bin/7z +675 -0
- package/cli/vendor/shim/brokered-bin/7za +675 -0
- package/cli/vendor/shim/brokered-bin/7zz +675 -0
- package/cli/vendor/shim/brokered-bin/rar +675 -0
- package/cli/vendor/shim/brokered-bin/tar +675 -0
- package/cli/vendor/shim/brokered-bin/zip +187 -0
- package/docs/README.md +1 -0
- package/docs/in-process.md +42 -2
- package/docs/protocol.md +7 -1
- package/docs/server.md +2 -0
- package/lib/agent/v2.js +1 -1
- package/lib/application/services.d.ts +3 -1
- package/lib/application/services.js +1 -1
- package/lib/client/client.js +1 -1
- package/lib/client/mcp.d.ts +1 -1
- package/lib/client/mcp.js +1 -1
- package/lib/components/acp-mcp-transport.d.mts +84 -1
- package/lib/components/question-elicitation.d.mts +20 -1
- package/lib/components/sandbox-center.d.mts +2 -0
- package/lib/components/sandbox-center.mjs +1 -0
- package/lib/components/{acp/acp-prompt-input.d.ts → session/prompt-input.d.ts} +1 -1
- package/lib/components/session-config.d.mts +2 -0
- package/lib/components/session-config.mjs +1 -1
- package/lib/components/session-replay.d.mts +6 -7
- package/lib/components/session-replay.mjs +1 -1
- package/lib/effect-runtime/mcp-lifecycle.mjs +1 -1
- package/lib/harness/create-harness.js +1 -1
- package/lib/harness/runtime.js +1 -1
- package/lib/harness/types.d.ts +3 -0
- package/lib/integration/agent-integration.d.ts +5 -0
- package/lib/integration/executor-supervisor.js +1 -1
- package/lib/public.d.ts +1 -0
- package/lib/runtime/private-runtime-role.js +1 -1
- package/lib/runtime/sandbox-center.d.ts +21 -0
- package/lib/runtime/sandbox-center.js +1 -0
- package/lib/server/public.d.ts +1 -0
- package/lib/session/agent-backend.d.ts +5 -0
- package/lib/session/agent-backend.js +1 -1
- package/lib/session/config-defaults.d.ts +4 -0
- package/lib/session/config-defaults.js +1 -0
- package/lib/session/config-store.d.ts +1 -1
- package/lib/session/config-store.js +1 -1
- package/lib/session/local-fs.js +1 -1
- package/lib/session/replay.d.ts +2 -2
- package/lib/session/replay.js +1 -1
- package/lib/session/server-config.d.ts +11 -2
- package/lib/session/server-config.js +1 -1
- package/lib/session/server-events.d.ts +10 -8
- package/lib/session/server-events.js +1 -1
- package/lib/session/server-interactions.js +1 -1
- package/lib/session/server-mcp.js +1 -1
- package/package.json +27 -16
- package/lib/components/acp/acp-client-channel.d.ts +0 -36
- package/lib/components/acp/acp-mcp-transport.d.ts +0 -84
- package/lib/components/acp/acp-question-elicitation.d.ts +0 -20
- package/lib/session/local-options.d.ts +0 -50
- package/lib/session/local-options.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var g=(I,t)=>y(I,"name",{value:t,configurable:!0});import{isRecord as l}from"../internal/guards.js";import{AGENT_HARNESS_ERROR_META_KEY as f,AGENT_HARNESS_ERROR_UPDATE as _,agentHarnessErrorSchema as b}from"../protocol/error.js";import{replayCodecs as c}from"./replay.js";export class ServerSessionEvents{static{g(this,"ServerSessionEvents")}constructor(t,o,n,a){this.sessionId=t,this.deliver=o,this.config=n,this.persistConfiguration=a,this.delivery=Promise.resolve(),this.compactions=new Set,this.interactions=new Map,this.toolStreams=new Map,this.toolParsers=new Map,this.pendingTools=new Map}get meta(){return this.requestId?{"codebuddy.ai/requestId":this.requestId,"codebuddy.ai/rootRequestId":this.requestId}:{}}async interaction(t,o){const n=o["codebuddy.ai/requestId"];if(typeof n!="string")return;const a=Math.max(0,(this.interactions.get(n)??0)+(t?1:-1));a?this.interactions.set(n,a):this.interactions.delete(n),(!t&&a===0||t&&a===1)&&(o["codebuddy.ai/subagent"]||this.requestId===n)&&await this.send({sessionUpdate:"state_update",state:t?"requires_action":"running"},o)}async begin(t){const o=Promise.withResolvers();o.promise.catch(()=>{}),this.completion={runId:t,outcome:o},this.requestId||await this.start(t)}async start(t){this.requestId!==t&&(this.requestId=t,this.foregroundError=void 0,this.resultError=void 0,await this.send({sessionUpdate:"state_update",state:"running"},this.meta))}waitForCompletion(t){return this.completion?.runId!==t?Promise.reject(new Error("No matching foreground run")):this.completion.outcome.promise}fail(t){this.completion?.outcome.reject(t)}async end(t){const o=t.stopReason==="error"?this.foregroundError??(this.resultError?.runId===t.runId?this.resultError.error:void 0)??(await c()).projectAgentError(t.errorMessage??"Agent execution failed"):void 0;o&&!this.foregroundError&&await this.send({sessionUpdate:_,error:o,willRetry:!1},this.meta),await this.finishTools(n=>!n["codebuddy.ai/subagent"]&&n["codebuddy.ai/requestId"]===t.runId,t.stopReason==="aborted"?"Tool execution cancelled":"Tool did not complete"),await this.send({sessionUpdate:"state_update",state:"idle",stopReason:t.stopReason==="aborted"?"cancelled":t.stopReason==="error"?_:"end_turn",...t.usage?{usage:t.usage}:{}},{...this.meta,...o?{[f]:o}:{}}),this.requestId=void 0,this.interactions.delete(t.runId),this.completion?.runId===t.runId&&this.completion.outcome.resolve(t)}async restoreUsage(t,o){this.accounting=(await c()).createSessionUsage(this.sessionId,t,o),this.lastContextTokens=this.accounting.context?.used??(t.length===0?0:void 0)}async configuration(t){await this.send({sessionUpdate:"config_option_update",configOptions:t}),this.lastContextTokens!==void 0&&await this.usage(this.lastContextTokens)}send(t,o={}){const n={sessionId:this.sessionId,update:{...t,_meta:{...o,...l(t._meta)?t._meta:{}}}};return t.sessionUpdate===_&&t.willRetry===!1&&this.requestId!==void 0&&n.update._meta["codebuddy.ai/requestId"]===this.requestId&&!n.update._meta["codebuddy.ai/subagent"]&&(this.foregroundError=b.parse(t.error)),t.sessionUpdate==="tool_call_update"&&typeof t.toolCallId=="string"&&(t.status==="completed"||t.status==="failed"||t.status==="cancelled"?(this.pendingTools.delete(t.toolCallId),this.toolParsers.delete(t.toolCallId)):(t.status==="pending"||t.status==="in_progress")&&this.pendingTools.set(t.toolCallId,n.update._meta)),this.delivery=this.delivery.then(()=>this.deliver(n)),this.delivery}async finishTools(t,o){for(const[n,a]of this.pendingTools)t(a)&&await this.send({sessionUpdate:"tool_call_update",toolCallId:n,status:"failed",content:[{type:"content",content:{type:"text",text:o}}]},a);for(const[n,a]of this.toolStreams){for(const[r,u]of a)this.pendingTools.has(u)||a.delete(r);a.size===0&&this.toolStreams.delete(n)}}async usage(t,o,n={}){const a=this.config?.contextSize(o),r=n["codebuddy.ai/subagent"],u=l(r)&&typeof r.sessionId=="string"?r.sessionId:this.sessionId,p=this.accounting?.snapshot(u).cost;a!==void 0&&await this.send({sessionUpdate:"usage_update",used:t,size:a,...p?{cost:p}:{}},n)}async accept(t){if("session_id"in t&&t.session_id!==this.sessionId)return;if(t.type==="run_started"){await this.start(t.runId);return}if(t.type==="run_completed"){if(!this.requestId&&this.completion?.runId===t.runId&&(this.requestId=t.runId,this.foregroundError=void 0,this.resultError=void 0),t.session_id===this.sessionId&&t.runId===this.requestId){const{type:e,session_id:i,_meta:s,...d}=t;await this.end(d)}return}if(t.type==="ai-title"||t.type==="topic"){t.session_id===this.sessionId&&await this.send({sessionUpdate:"session_info_update",title:t.type==="ai-title"?t.aiTitle:t.topic});return}if("parent_tool_use_id"in t&&t.parent_tool_use_id&&!t.origin?.subagent)return;const o={...t.origin===void 0?this.meta:{},...t._meta,...t.origin?.requestId?{"codebuddy.ai/requestId":t.origin.requestId}:{},...t.origin?.rootRequestId?{"codebuddy.ai/rootRequestId":t.origin.rootRequestId}:{},...t.origin?.subagent?{"codebuddy.ai/subagent":t.origin.subagent}:{}},n=g(e=>this.send(e,o),"send"),a=g(e=>e.sessionUpdate==="_codebuddy.ai/compaction"&&typeof e.compactionId=="string"&&this.compactions.has(e.compactionId)?Promise.resolve():n(e),"sendItem"),r=t.item??(t.type==="agent_event"&&t.event.type==="input"?t.event.data:void 0);if(r){this.accounting??=(await c()).createSessionUsage(this.sessionId);const e=o["codebuddy.ai/subagent"],i=l(e)&&typeof e.sessionId=="string"?e.sessionId:this.sessionId;this.accounting.accept(r,i);const s=t.origin?.requestId??t._meta?.["codebuddy.ai/requestId"]??r.providerData?.conversationRequestId;if(i===this.sessionId&&typeof s=="string"&&s===this.requestId){const d=(await c()).projectAgentItemError(r);d&&(this.resultError={runId:s,error:d})}}if(t.type==="result"){const e=t.origin?.requestId??t._meta?.["codebuddy.ai/requestId"];if(t.is_error&&"errors"in t&&typeof e=="string"&&e===this.requestId&&!t.origin?.subagent&&!t._meta?.["codebuddy.ai/subagent"]){const i=t.errors_info?.findIndex(s=>s!=null)??-1;this.resultError={runId:e,error:(await c()).projectAgentError(t.errors[i<0?0:i]??"Agent execution failed",i<0?void 0:t.errors_info?.[i])}}return}if(t.type==="agent_event"){if(t.event.type==="compaction"&&t.event.data.status==="in_progress"&&this.compactions.add(t.event.data.compactionId),t.event.type==="subagent_status"&&(this.accounting??=(await c()).createSessionUsage(this.sessionId),this.accounting.child(t.event.data.sessionId,t.event.data.parentSessionId,t.event.data.parentToolCallId)),t.event.type==="subagent_status"&&t.event.data.status!=="running"){const e=t.event.data.sessionId;this.interactions.delete(t.event.data.conversationRequestId),await this.finishTools(i=>l(i["codebuddy.ai/subagent"])&&i["codebuddy.ai/subagent"].sessionId===e,"Subagent tool did not complete")}if(t.event.type==="configuration"){const e=t.origin?.subagent?void 0:this.config?.copy();e?.update(t.event.data)&&(await this.persistConfiguration?.(e),this.config.replace(e),await n({sessionUpdate:"config_option_update",configOptions:e.snapshot()}))}else if(t.event.type==="usage")t.origin?.subagent||(this.lastContextTokens=t.event.data.contextTokens),await this.usage(t.event.data.contextTokens,t.event.data.modelId,o),t.origin?.subagent&&this.lastContextTokens!==void 0&&await this.usage(this.lastContextTokens);else{const{projectAgentEvent:e}=await c();for(const i of await e(t))await(t.event.type==="input"?a(i.update):n(i.update));t.event.type==="input"&&this.completeToolInvocation(t.event.data)}t.event.type==="compaction"&&t.event.data.status!=="in_progress"&&this.compactions.delete(t.event.data.compactionId);return}if(t.item){const{projectAgentItem:e}=await c();for(const i of await e(this.sessionId,t.item))await a(i.update);this.completeToolInvocation(t.item);return}const u=t._meta?.["codebuddy.ai/messageId"],p=typeof u=="string"&&u.length>0?u:void 0;if(t.type==="stream_event"){const e=t.event,i=JSON.stringify([o["codebuddy.ai/requestId"],t.origin?.subagent?.sessionId]);if(e.type==="message_start"&&this.toolStreams.set(i,new Map),e.type==="content_block_start"&&e.content_block.type==="tool_use"){const s=e.content_block;let d=this.toolStreams.get(i);d||this.toolStreams.set(i,d=new Map),d.set(e.index,s.id);const{createToolInputParser:h}=await c();this.toolParsers.set(s.id,h()),await n({sessionUpdate:"tool_call_update",toolCallId:s.id,name:s.name,title:s.name,status:"pending"})}if(e.type==="content_block_delta"&&e.delta.type==="input_json_delta"){const s=this.toolStreams.get(i)?.get(e.index),d=s?this.toolParsers.get(s):void 0;if(s&&d){const h=e.delta.partial_json;await n({sessionUpdate:"tool_call_update",toolCallId:s,rawInput:d(h),content:[{type:"content",content:{type:"text",text:h}}]})}}if(e.type==="message_stop"&&this.toolStreams.delete(i),e.type==="content_block_delta"&&p){const s=e.delta;if(s.type==="text_delta"||s.type==="thinking_delta"){const d=s.type==="thinking_delta",h=d?s.thinking:s.text;await n({sessionUpdate:d?"agent_thought_chunk":"agent_message_chunk",messageId:p,content:{type:"text",text:h}})}}return}if(t.type==="assistant"){const e=p??t.uuid,i=[],s=[];for(const d of t.message.content)d.type==="text"||d.type==="thinking"?(d.type==="thinking"?s:i).push({type:"text",text:d.type==="thinking"?d.thinking:d.text}):d.type==="tool_use"&&await n({sessionUpdate:"tool_call_update",toolCallId:d.id,name:d.name,title:d.name,status:"in_progress",rawInput:d.input});s.length&&await n({sessionUpdate:"agent_thought",messageId:e,content:s}),(i.length||t.message.content.length===0)&&await n({sessionUpdate:"agent_message",messageId:e,content:i});return}if(t.type==="user"){const e=t.message.content,i=Array.isArray(e)?e.filter(s=>l(s)&&s.type==="tool_result"):[];for(const s of i)l(s)&&s.type==="tool_result"&&typeof s.tool_use_id=="string"&&await n({sessionUpdate:"tool_call_update",toolCallId:s.tool_use_id,status:s.is_error?"failed":"completed",rawOutput:s.content})}}completeToolInvocation(t){l(t)&&t.type==="function_call_result"&&t.status==="completed"&&typeof t.callId=="string"&&(this.pendingTools.delete(t.callId),this.toolParsers.delete(t.callId))}}
|
|
1
|
+
var g=Object.defineProperty;var u=(l,t)=>g(l,"name",{value:t,configurable:!0});import{isRecord as r}from"../internal/guards.js";import{AGENT_HARNESS_ERROR_META_KEY as p,AGENT_HARNESS_ERROR_UPDATE as h,agentHarnessErrorSchema as I}from"../protocol/error.js";import{replayCodecs as a}from"./replay.js";export class ServerSessionEvents{static{u(this,"ServerSessionEvents")}constructor(t,e,s,n){this.sessionId=t,this.deliver=e,this.config=s,this.persistConfig=n,this.delivery=Promise.resolve(),this.configurationObserved=!1,this.interactions=new Map,this.pendingTools=new Map}get meta(){return this.requestId?{"codebuddy.ai/requestId":this.requestId,"codebuddy.ai/rootRequestId":this.requestId}:{}}async interaction(t,e){const s=e["codebuddy.ai/requestId"];if(typeof s!="string")return;const n=Math.max(0,(this.interactions.get(s)??0)+(t?1:-1));n?this.interactions.set(s,n):this.interactions.delete(s),(!t&&n===0||t&&n===1)&&(e["codebuddy.ai/subagent"]||this.requestId===s)&&await this.send({sessionUpdate:"state_update",state:t?"requires_action":"running"},e)}async begin(t){const e=Promise.withResolvers();e.promise.catch(()=>{}),this.completion={runId:t,outcome:e},this.requestId||await this.start(t)}async start(t){this.requestId!==t&&(this.requestId=t,this.foregroundError=void 0,this.resultError=void 0,await this.send({sessionUpdate:"state_update",state:"running"},this.meta))}waitForCompletion(t){return this.completion?.runId!==t?Promise.reject(new Error("No matching foreground run")):this.completion.outcome.promise}fail(t){this.completion?.outcome.reject(t)}async end(t){const e=t.stopReason==="error"?this.foregroundError??(this.resultError?.runId===t.runId?this.resultError.error:void 0)??(await a()).projectAgentError(t.errorMessage??"Agent execution failed"):void 0;e&&!this.foregroundError&&await this.send({sessionUpdate:h,error:e,willRetry:!1},this.meta),await this.finishTools(s=>!s["codebuddy.ai/subagent"]&&s["codebuddy.ai/requestId"]===t.runId,t.stopReason==="aborted"?"Tool execution cancelled":"Tool did not complete"),await this.send({sessionUpdate:"state_update",state:"idle",stopReason:t.stopReason==="aborted"?"cancelled":t.stopReason==="error"?h:"end_turn",...t.usage?{usage:t.usage}:{}},{...this.meta,...e?{[p]:e}:{}}),this.requestId=void 0,this.interactions.delete(t.runId),this.completion?.runId===t.runId&&this.completion.outcome.resolve(t)}async restoreUsage(t,e){this.accounting=(await a()).createSessionUsage(this.sessionId,t,e),this.lastContextTokens=this.accounting.context?.used??(t.length===0?0:void 0)}async configuration(t){await this.send({sessionUpdate:"config_option_update",configOptions:t}),this.lastContextTokens!==void 0&&await this.usage(this.lastContextTokens)}send(t,e={}){const s={sessionId:this.sessionId,update:{...t,_meta:{...e,...r(t._meta)?t._meta:{}}}};return t.sessionUpdate===h&&t.willRetry===!1&&this.requestId!==void 0&&s.update._meta["codebuddy.ai/requestId"]===this.requestId&&!s.update._meta["codebuddy.ai/subagent"]&&(this.foregroundError=I.parse(t.error)),t.sessionUpdate==="tool_call_update"&&typeof t.toolCallId=="string"&&(t.status==="completed"||t.status==="failed"||t.status==="cancelled"?this.pendingTools.delete(t.toolCallId):(t.status==="pending"||t.status==="in_progress")&&this.pendingTools.set(t.toolCallId,s.update._meta)),this.delivery=this.delivery.then(()=>this.deliver(s)),this.delivery}async finishTools(t,e){for(const[s,n]of this.pendingTools)t(n)&&await this.send({sessionUpdate:"tool_call_update",toolCallId:s,status:"failed",content:[{type:"content",content:{type:"text",text:e}}]},n)}async usage(t,e,s={}){const n=this.config?.contextSize(e),i=s["codebuddy.ai/subagent"],o=r(i)&&typeof i.sessionId=="string"?i.sessionId:this.sessionId,d=this.accounting?.snapshot(o).cost;n!==void 0&&await this.send({sessionUpdate:"usage_update",used:t,size:n,...d?{cost:d}:{}},s)}async catalog(t){const e=await a();for(const s of await e.projectAgentEvent({type:"agent_event",session_id:this.sessionId,event:{type:"catalog",data:t}}))await this.accept({type:"acp_update",notification:s})}async accept(t){if("session_id"in t&&t.session_id!==this.sessionId)return;if(t.type==="run_started"){await this.start(t.runId);return}if(t.type==="run_completed"){if(!this.requestId&&this.completion?.runId===t.runId&&(this.requestId=t.runId,this.foregroundError=void 0,this.resultError=void 0),t.session_id===this.sessionId&&t.runId===this.requestId){const{type:i,session_id:o,_meta:d,...c}=t;await this.end(c)}return}const e={...t.origin===void 0?this.meta:{},...t._meta,...t.origin?.requestId?{"codebuddy.ai/requestId":t.origin.requestId}:{},...t.origin?.rootRequestId?{"codebuddy.ai/rootRequestId":t.origin.rootRequestId}:{},...t.origin?.subagent?{"codebuddy.ai/subagent":t.origin.subagent}:{}},s=u(i=>this.send(i,e),"send"),n=t.item??(t.type==="agent_event"&&t.event.type==="input"?t.event.data:void 0);if(n){this.accounting??=(await a()).createSessionUsage(this.sessionId);const i=e["codebuddy.ai/subagent"],o=r(i)&&typeof i.sessionId=="string"?i.sessionId:this.sessionId;this.accounting.accept(n,o);const d=t.origin?.requestId??t._meta?.["codebuddy.ai/requestId"]??n.providerData?.conversationRequestId;if(o===this.sessionId&&typeof d=="string"&&d===this.requestId){const c=(await a()).projectAgentItemError(n);c&&(this.resultError={runId:d,error:c})}}if(t.type==="acp_update"){t.notification.sessionId===this.sessionId&&await s(t.notification.update);return}if(t.type==="agent_event"){if(t.event.type==="subagent_status"&&(this.accounting??=(await a()).createSessionUsage(this.sessionId),this.accounting.child(t.event.data.sessionId,t.event.data.parentSessionId,t.event.data.parentToolCallId)),t.event.type==="subagent_status"&&t.event.data.status!=="running"){const i=t.event.data.sessionId;this.interactions.delete(t.event.data.conversationRequestId),await this.finishTools(o=>r(o["codebuddy.ai/subagent"])&&o["codebuddy.ai/subagent"].sessionId===i,"Subagent tool did not complete")}if(t.event.type==="error"){const i=t.origin?.requestId;i&&i===this.requestId&&!t.origin?.subagent&&this.resultError?.runId!==i&&(this.resultError={runId:i,error:(await a()).projectAgentFailure(t.event.data)})}else if(t.event.type==="configuration"){const i=t.origin?.subagent?void 0:this.config?.copy(),o=JSON.stringify(this.config?.selections()),d=i?.update(t.event.data,this.configurationObserved);i&&(this.configurationObserved=!0),i&&d&&(this.config.replace(i),JSON.stringify(i.selections())!==o&&await this.persistConfig?.(i),await s({sessionUpdate:"config_option_update",configOptions:i.snapshot()}))}else t.event.type==="usage"?(t.origin?.subagent||(this.lastContextTokens=t.event.data.contextTokens),await this.usage(t.event.data.contextTokens,t.event.data.modelId,e),t.origin?.subagent&&this.lastContextTokens!==void 0&&await this.usage(this.lastContextTokens)):t.event.type==="input"&&this.completeToolInvocation(t.event.data)}}completeToolInvocation(t){r(t)&&t.type==="function_call_result"&&t.status==="completed"&&typeof t.callId=="string"&&this.pendingTools.delete(t.callId)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var s=(o,t)=>h(o,"name",{value:t,configurable:!0});import{createAskUserQuestionElicitation as q,normalizeAskUserQuestionElicitationAnswers as
|
|
1
|
+
var h=Object.defineProperty;var s=(o,t)=>h(o,"name",{value:t,configurable:!0});import{createAskUserQuestionElicitation as q,normalizeAskUserQuestionElicitationAnswers as A}from"#agent-harness-components/question-elicitation";import{abortable as k}from"../internal/async.js";import{isRecord as b}from"../internal/guards.js";function _(o){if(!Array.isArray(o.questions)||o.questions.length===0)throw new Error("AskUserQuestion requires questions");return{questions:o.questions.map(t=>{if(!b(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(!b(a)||typeof a.label!="string")throw new Error("Invalid AskUserQuestion option");return{label:a.label,description:typeof a.description=="string"?a.description:""}})}})}}s(_,"questionsFrom");export function serverCanUseTool(o,t,a){return async(d,n,e)=>{const i=s(r=>({behavior:"deny",message:r}),"deny");if(e.signal.aborted)return i("Interaction cancelled");const{id:g,meta:y}=t(),l=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}:{}}:y,f=s(async r=>{await a?.(!0,l);try{return await k(r(),e.signal)}finally{e.signal.aborted||await a?.(!1,l)}},"interact");if(d==="AskUserQuestion"){if(!o.clientCapabilities.elicitation?.form)return i("Client does not support form elicitation");const r=_(n),w=await f(()=>o.callbacks.createElicitation(q(r,g,e.toolUseID,l),{signal:e.signal}));return e.signal.aborted||w.action!=="accept"?{...i("User declined to answer"),interrupt:!0}:{behavior:"allow",updatedInput:{...n,answers:A(r,w.content)}}}const c=e.suggestions?.length?structuredClone(e.suggestions):void 0,I={sessionId:g,title:e.title??e.displayName??d,...e.description?{description:e.description}:{},subject:{type:"tool_call",toolCall:{toolCallId:e.toolUseID,title:d,rawInput:n,...e.blockedPath?{locations:[{path:e.blockedPath}]}:{}}},options:[{optionId:"allow_once",name:"Allow once",kind:"allow_once"},...c?[{optionId:"allow_always",name:c.every(r=>r.destination==="session")?"Allow for this session":"Always allow",kind:"allow_always"}]:[],{optionId:"reject_once",name:"Reject",kind:"reject_once"}],_meta:l},u=await f(()=>o.callbacks.requestPermission(I,{signal:e.signal}));return e.signal.aborted||u.outcome.outcome!=="selected"?i("Permission request cancelled"):u.outcome.optionId==="allow_once"?{behavior:"allow",updatedInput:n,decisionClassification:"user_temporary"}:u.outcome.optionId==="allow_always"&&c?{behavior:"allow",updatedInput:n,updatedPermissions:c,decisionClassification:"user_permanent"}:{...i("Permission denied"),decisionClassification:"user_reject"}}}s(serverCanUseTool,"serverCanUseTool");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var r=(b,i)=>h(b,"name",{value:i,configurable:!0});import{Schema as t}from"effect";import{McpPeerTransport as f}from"../integration/mcp-peer-transport.js";import{abortable as y}from"../internal/async.js";import{AgentHarnessInvalidParamsError as p}from"../server/errors.js";const u=t.decodeUnknownSync(t.Struct({description:t.optionalKey(t.String),alwaysLoad:t.optionalKey(t.Boolean),defer_loading:t.optionalKey(t.Boolean),repl_expose:t.optionalKey(t.Boolean),transparent_proxy:t.optionalKey(t.Boolean),builtin_tools:t.optionalKey(t.Array(t.String)),tools:t.optionalKey(t.Record(t.String,t.Struct({defer_loading:t.optionalKey(t.Boolean),server_name:t.optionalKey(t.String),bare_name:t.optionalKey(t.Boolean),prompt_cache_stability:t.optionalKey(t.Literals(["stable","volatile"])),tool_control_id:t.optionalKey(t.String),tool_control_compatibility_ids:t.optionalKey(t.Array(t.String))})))}),{reportInput:!1});export class ServerSessionMcp{static{r(this,"ServerSessionMcp")}constructor(i,s){this.callbacks=i,this.currentSignal=s,this.lifetime=new AbortController,this.transports=new Set}configure(i,s){if(i.length===0)return
|
|
1
|
+
var h=Object.defineProperty;var r=(b,i)=>h(b,"name",{value:i,configurable:!0});import{Schema as t}from"effect";import{McpPeerTransport as f}from"../integration/mcp-peer-transport.js";import{abortable as y}from"../internal/async.js";import{AgentHarnessInvalidParamsError as p}from"../server/errors.js";const u=t.decodeUnknownSync(t.Struct({description:t.optionalKey(t.String),alwaysLoad:t.optionalKey(t.Boolean),defer_loading:t.optionalKey(t.Boolean),repl_expose:t.optionalKey(t.Boolean),transparent_proxy:t.optionalKey(t.Boolean),builtin_tools:t.optionalKey(t.Array(t.String)),tools:t.optionalKey(t.Record(t.String,t.Struct({defer_loading:t.optionalKey(t.Boolean),server_name:t.optionalKey(t.String),bare_name:t.optionalKey(t.Boolean),prompt_cache_stability:t.optionalKey(t.Literals(["stable","volatile"])),tool_control_id:t.optionalKey(t.String),tool_control_compatibility_ids:t.optionalKey(t.Array(t.String))})))}),{reportInput:!1});export class ServerSessionMcp{static{r(this,"ServerSessionMcp")}constructor(i,s){this.callbacks=i,this.currentSignal=s,this.lifetime=new AbortController,this.transports=new Set}configure(i,s){if(i.length===0)return{...s};if(!this.callbacks.mcpConnect||!this.callbacks.mcpDisconnect||!this.callbacks.mcpMessage||!this.callbacks.mcpNotification)throw new p("Session MCP requires Harness connection callbacks");const a={...s};for(const n of i){if(n.type!=="acp"||typeof n.serverId!="string"||typeof n.name!="string")throw new p("Harness must materialize MCP servers before binding the Agent session");if(Object.hasOwn(a,n.name))throw new p(`Duplicate MCP server: ${n.name}`);const c=n.serverId;let o;try{o=u(n._meta??{})}catch{throw new p(`Invalid MCP metadata: ${n.name}`)}const d={...o,builtin_tools:o.builtin_tools?[...o.builtin_tools]:void 0,tools:o.tools?Object.fromEntries(Object.entries(o.tools).map(([m,e])=>[m,{...e,tool_control_compatibility_ids:e.tool_control_compatibility_ids?[...e.tool_control_compatibility_ids]:void 0}])):void 0,type:"transport",transport:r(()=>this.connect(c),"transport")};Object.defineProperty(a,n.name,{enumerable:!0,configurable:!0,writable:!0,value:d})}return a}close(){return this.closing??=(async()=>{this.lifetime.abort(),await Promise.allSettled([...this.transports].map(i=>i.close())),await this.callbacks.mcpPeerClosed?.()})()}async connect(i){const s=[this.lifetime.signal,this.currentSignal()].filter(e=>!!e),a=AbortSignal.any(s);a.throwIfAborted();const n=this.callbacks.mcpConnect({serverId:i},{request:r((e,l)=>o.receiveRequest(e.method,e.params,l?.signal),"request"),notify:r(async e=>o.receiveNotification(e.method,e.params),"notify")},{signal:a});let c;try{c=await y(n,a)}catch(e){throw a.aborted&&n.then(l=>this.callbacks.mcpDisconnect({connectionId:l.connectionId})).catch(()=>{}),e}const o=new f(c.connectionId,{request:r((e,l)=>this.callbacks.mcpMessage(e,l),"request"),notify:r(e=>this.callbacks.mcpNotification(e),"notify")}),d=o.close.bind(o);let m;return o.close=()=>m??=(async()=>{this.transports.delete(o),await d(),await this.callbacks.mcpDisconnect({connectionId:c.connectionId})})(),this.transports.add(o),a.aborted&&(await o.close(),a.throwIfAborted()),o}}
|
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.3",
|
|
4
4
|
"description": "Standalone JSON-RPC agent harness backed by CodeBuddy Code",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"types": "./lib/components/session-config.d.mts",
|
|
37
37
|
"default": "./lib/components/session-config.mjs"
|
|
38
38
|
},
|
|
39
|
+
"#agent-harness-components/sandbox-center": {
|
|
40
|
+
"types": "./lib/components/sandbox-center.d.mts",
|
|
41
|
+
"default": "./lib/components/sandbox-center.mjs"
|
|
42
|
+
},
|
|
39
43
|
"#agent-harness-components/session-replay": {
|
|
40
44
|
"types": "./lib/components/session-replay.d.mts",
|
|
41
45
|
"default": "./lib/components/session-replay.mjs"
|
|
@@ -144,7 +148,8 @@
|
|
|
144
148
|
"executor/lib/types.cjs",
|
|
145
149
|
"executor/lib/types.d.cts",
|
|
146
150
|
"lib/**",
|
|
147
|
-
"README.md"
|
|
151
|
+
"README.md",
|
|
152
|
+
"CHANGELOG.md"
|
|
148
153
|
],
|
|
149
154
|
"publishConfig": {
|
|
150
155
|
"access": "public",
|
|
@@ -192,6 +197,7 @@
|
|
|
192
197
|
},
|
|
193
198
|
"dependencies": {
|
|
194
199
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
200
|
+
"@agentclientprotocol/sdk-server": "npm:@agentclientprotocol/sdk@1.4.0",
|
|
195
201
|
"@effect/platform-node": "4.0.0-rc.115",
|
|
196
202
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
197
203
|
"ajv": "^8.20.0",
|
|
@@ -209,16 +215,18 @@
|
|
|
209
215
|
"@lydell/node-pty-linux-x64": "1.2.0-beta.14",
|
|
210
216
|
"@lydell/node-pty-win32-arm64": "1.2.0-beta.14",
|
|
211
217
|
"@lydell/node-pty-win32-x64": "1.2.0-beta.14",
|
|
212
|
-
"@tencent-ai/sandbox-cli-darwin-arm64": "5.
|
|
213
|
-
"@tencent-ai/sandbox-cli-darwin-x64": "5.
|
|
214
|
-
"@tencent-ai/sandbox-cli-
|
|
215
|
-
"@tencent-ai/
|
|
216
|
-
"@tencent-ai/
|
|
217
|
-
"@tencent-ai/agent-harness-
|
|
218
|
-
"@tencent-ai/agent-harness-
|
|
219
|
-
"@tencent-ai/agent-harness-linux-
|
|
220
|
-
"@tencent-ai/agent-harness-linux-
|
|
221
|
-
"@tencent-ai/agent-harness-
|
|
218
|
+
"@tencent-ai/sandbox-cli-darwin-arm64": "5.8.0-beta.7",
|
|
219
|
+
"@tencent-ai/sandbox-cli-darwin-x64": "5.8.0-beta.7",
|
|
220
|
+
"@tencent-ai/sandbox-cli-linux-arm64": "5.8.0-beta.7",
|
|
221
|
+
"@tencent-ai/sandbox-cli-linux-x64": "5.8.0-beta.7",
|
|
222
|
+
"@tencent-ai/sandbox-cli-win32-x64": "5.8.0-beta.7",
|
|
223
|
+
"@tencent-ai/agent-harness-darwin-arm64": "0.2.0-beta.3",
|
|
224
|
+
"@tencent-ai/agent-harness-darwin-x64": "0.2.0-beta.3",
|
|
225
|
+
"@tencent-ai/agent-harness-linux-arm64": "0.2.0-beta.3",
|
|
226
|
+
"@tencent-ai/agent-harness-linux-arm64-musl": "0.2.0-beta.3",
|
|
227
|
+
"@tencent-ai/agent-harness-linux-x64": "0.2.0-beta.3",
|
|
228
|
+
"@tencent-ai/agent-harness-linux-x64-musl": "0.2.0-beta.3",
|
|
229
|
+
"@tencent-ai/agent-harness-win32-x64": "0.2.0-beta.3"
|
|
222
230
|
},
|
|
223
231
|
"devDependencies": {
|
|
224
232
|
"@anthropic-ai/sandbox-runtime": "0.0.17",
|
|
@@ -233,6 +241,7 @@
|
|
|
233
241
|
"@genie/cbc-shared": "0.0.0",
|
|
234
242
|
"@genie/core": "0.0.0",
|
|
235
243
|
"@genie/product": "0.0.0",
|
|
244
|
+
"@genie/sandbox-cli": "0.0.0",
|
|
236
245
|
"@genie/style-guide": "0.0.0",
|
|
237
246
|
"@genie/telemetry": "0.0.0",
|
|
238
247
|
"@genie/vitest-config": "0.0.0",
|
|
@@ -245,9 +254,11 @@
|
|
|
245
254
|
"@oven/bun-linux-x64-musl": "1.4.2",
|
|
246
255
|
"@oven/bun-windows-x64": "1.4.2",
|
|
247
256
|
"@rspack/core": "^1.7.6",
|
|
248
|
-
"@tencent-ai/sandbox-cli-darwin-arm64": "5.
|
|
249
|
-
"@tencent-ai/sandbox-cli-darwin-x64": "5.
|
|
250
|
-
"@tencent-ai/sandbox-cli-
|
|
257
|
+
"@tencent-ai/sandbox-cli-darwin-arm64": "5.8.0-beta.7",
|
|
258
|
+
"@tencent-ai/sandbox-cli-darwin-x64": "5.8.0-beta.7",
|
|
259
|
+
"@tencent-ai/sandbox-cli-linux-arm64": "5.8.0-beta.7",
|
|
260
|
+
"@tencent-ai/sandbox-cli-linux-x64": "5.8.0-beta.7",
|
|
261
|
+
"@tencent-ai/sandbox-cli-win32-x64": "5.8.0-beta.7",
|
|
251
262
|
"@types/node": "22",
|
|
252
263
|
"@types/sinon": "^10.0.15",
|
|
253
264
|
"@types/which": "^3.0.4",
|
|
@@ -401,7 +412,7 @@
|
|
|
401
412
|
"build": "pnpm --workspace-root exec nx run @genie/agent-harness:build --skipSync",
|
|
402
413
|
"build:lib": "pnpm --workspace-root exec nx run @genie/agent-harness:build:lib --skipSync",
|
|
403
414
|
"build:components": "node scripts/build-components.mjs",
|
|
404
|
-
"compile:run": "pnpm run build:components && tsc --build executor/tsconfig.json
|
|
415
|
+
"compile:run": "pnpm run build:components && tsc --build executor/tsconfig.json && tsc --build tsconfig.lib.json",
|
|
405
416
|
"build:lib:run": "pnpm run clean && pnpm run compile:run && pnpm --dir executor run build:capsule && node scripts/write-product-schema.mjs && node scripts/prune-library.mjs && node scripts/minify-library.mjs",
|
|
406
417
|
"build:run": "pnpm run build:lib:run && pnpm run sync:codebuddy:runtime",
|
|
407
418
|
"build:sfe": "node scripts/build-sfe.mjs",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type AgentContext, type CompleteElicitationNotification, type CreateElicitationRequest, type CreateElicitationResponse, type CreateTerminalRequest, type KillTerminalResponse, type ReadTextFileRequest, type ReadTextFileResponse, type ReleaseTerminalResponse, type RequestPermissionRequest, type RequestPermissionResponse, type SendRequestOptions, type SessionNotification, type TerminalOutputResponse, type WaitForTerminalExitResponse, type WriteTextFileRequest, type WriteTextFileResponse } from '@agentclientprotocol/sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Agent CLI 业务实际依赖的终端句柄。
|
|
4
|
-
*
|
|
5
|
-
* 不直接暴露 SDK `TerminalHandle` class,避免业务代码依赖其私有连接实现;
|
|
6
|
-
* compatibility transport 与 AgentContext adapter 返回的句柄都满足此接口。
|
|
7
|
-
*/
|
|
8
|
-
export interface AcpTerminalHandle {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
currentOutput(): Promise<TerminalOutputResponse>;
|
|
11
|
-
waitForExit(): Promise<WaitForTerminalExitResponse>;
|
|
12
|
-
kill(): Promise<KillTerminalResponse>;
|
|
13
|
-
release(): Promise<ReleaseTerminalResponse | void>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Agent 到 ACP client 的连接级调用通道。
|
|
17
|
-
*
|
|
18
|
-
* 该 facade 只描述 Agent CLI 的出站调用面,不绑定 SDK 的连接生命周期实现。
|
|
19
|
-
* compatibility 与 official runtime 都通过 {@link createAcpClientChannel}
|
|
20
|
-
* 从 connection-scoped `AgentContext` 构造同一调用面。
|
|
21
|
-
*/
|
|
22
|
-
export interface AcpClientChannel {
|
|
23
|
-
sessionUpdate(params: SessionNotification): Promise<void>;
|
|
24
|
-
requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse>;
|
|
25
|
-
readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
|
|
26
|
-
writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
|
|
27
|
-
createTerminal(params: CreateTerminalRequest): Promise<AcpTerminalHandle>;
|
|
28
|
-
createElicitation(params: CreateElicitationRequest): Promise<CreateElicitationResponse>;
|
|
29
|
-
completeElicitation(params: CompleteElicitationNotification): Promise<void>;
|
|
30
|
-
request<Response = unknown, Params = unknown>(method: string, params?: Params, options?: SendRequestOptions): Promise<Response>;
|
|
31
|
-
notify<Params = unknown>(method: string, params?: Params): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 将 SDK handler 收到的 AgentContext 适配成 Agent CLI 连接级调用通道。
|
|
35
|
-
*/
|
|
36
|
-
export declare function createAcpClientChannel(context: AgentContext): AcpClientChannel;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { type AgentContext, type JsonRpcId as AcpJsonRpcId, type MessageMcpNotification, type MessageMcpRequest } from '@agentclientprotocol/sdk/experimental/v2';
|
|
2
|
-
import type { Transport, TransportSendOptions } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
3
|
-
import { type JSONRPCMessage, type RequestId } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
-
type McpClientContext = Pick<AgentContext, 'request' | 'notify'>;
|
|
5
|
-
type AcpMcpParams = Record<string, unknown> | null | undefined;
|
|
6
|
-
export interface AcpMcpPeerRegistration {
|
|
7
|
-
readonly peer: AcpMcpPeer;
|
|
8
|
-
dispose(reason?: unknown): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export interface AcpMcpTransportOptions {
|
|
11
|
-
readonly routeId: string;
|
|
12
|
-
readonly serverId: string;
|
|
13
|
-
/** Cancels acquisition without transferring ownership of an established connection. */
|
|
14
|
-
readonly signal?: AbortSignal;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Registers the client side of one live ACP v2 connection.
|
|
18
|
-
*
|
|
19
|
-
* Session MCP configuration crosses the Agent CLI's internal HTTP boundary, so
|
|
20
|
-
* it carries only the opaque route id and resolves the live `AgentContext`
|
|
21
|
-
* here. A route is exact and cannot be replaced while it is active.
|
|
22
|
-
*/
|
|
23
|
-
export declare function registerAcpMcpPeer(routeId: string, client: McpClientContext, signal: AbortSignal): AcpMcpPeerRegistration;
|
|
24
|
-
export declare function requireAcpMcpPeer(routeId: string): AcpMcpPeer;
|
|
25
|
-
/**
|
|
26
|
-
* Connection-scoped MCP-over-ACP dispatcher. One peer may own many physical
|
|
27
|
-
* MCP connections, each selected by the provider-generated `connectionId`.
|
|
28
|
-
*/
|
|
29
|
-
export declare class AcpMcpPeer {
|
|
30
|
-
private readonly client;
|
|
31
|
-
private readonly rootSignal;
|
|
32
|
-
private readonly transports;
|
|
33
|
-
private isClosed;
|
|
34
|
-
constructor(client: McpClientContext, rootSignal: AbortSignal);
|
|
35
|
-
get closed(): boolean;
|
|
36
|
-
connect(serverId: string, signal: AbortSignal): Promise<string>;
|
|
37
|
-
attach(connectionId: string, transport: AcpMcpTransport): void;
|
|
38
|
-
request(transport: AcpMcpTransport, connectionId: string, method: string, params: AcpMcpParams, signal: AbortSignal): Promise<unknown>;
|
|
39
|
-
notify(transport: AcpMcpTransport, connectionId: string, method: string, params: AcpMcpParams): Promise<void>;
|
|
40
|
-
disconnect(transport: AcpMcpTransport, connectionId: string): Promise<void>;
|
|
41
|
-
disconnectUnattached(connectionId: string): Promise<void>;
|
|
42
|
-
receiveRequest(params: MessageMcpRequest, requestId: AcpJsonRpcId, signal: AbortSignal): Promise<unknown>;
|
|
43
|
-
receiveNotification(params: MessageMcpNotification): void;
|
|
44
|
-
closeFromRoot(reason?: unknown): Promise<void>;
|
|
45
|
-
private requireTransport;
|
|
46
|
-
private assertAttached;
|
|
47
|
-
private assertOpen;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* MCP SDK transport backed by the standard ACP v2 MCP methods.
|
|
51
|
-
*
|
|
52
|
-
* ACP intentionally omits the inner JSON-RPC envelope. The outer request id is
|
|
53
|
-
* the id observed by the MCP provider, while this transport restores the local
|
|
54
|
-
* MCP SDK's id when it delivers the response back to the SDK.
|
|
55
|
-
*/
|
|
56
|
-
export declare class AcpMcpTransport implements Transport {
|
|
57
|
-
private readonly options;
|
|
58
|
-
private state;
|
|
59
|
-
private peer?;
|
|
60
|
-
private connectionIdValue?;
|
|
61
|
-
private startController?;
|
|
62
|
-
private closePromise?;
|
|
63
|
-
private closeNotified;
|
|
64
|
-
private readonly outbound;
|
|
65
|
-
private readonly inbound;
|
|
66
|
-
onclose?: () => void;
|
|
67
|
-
onerror?: (error: Error) => void;
|
|
68
|
-
onmessage?: <T extends JSONRPCMessage>(message: T) => void;
|
|
69
|
-
constructor(options: AcpMcpTransportOptions);
|
|
70
|
-
get sessionId(): string | undefined;
|
|
71
|
-
start(): Promise<void>;
|
|
72
|
-
send(message: JSONRPCMessage, _options?: TransportSendOptions): Promise<void>;
|
|
73
|
-
close(): Promise<void>;
|
|
74
|
-
closeFromPeer(reason?: unknown): Promise<void>;
|
|
75
|
-
receiveRequest(requestId: RequestId, method: string, params: AcpMcpParams, signal: AbortSignal): Promise<unknown>;
|
|
76
|
-
receiveNotification(method: string, params: AcpMcpParams): void;
|
|
77
|
-
private sendRequest;
|
|
78
|
-
private sendNotification;
|
|
79
|
-
private settleInbound;
|
|
80
|
-
private finishClose;
|
|
81
|
-
private deliver;
|
|
82
|
-
private notifyClose;
|
|
83
|
-
}
|
|
84
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CreateElicitationRequest, ElicitationSchema } from '@agentclientprotocol/sdk';
|
|
2
|
-
export interface AskUserQuestionInput {
|
|
3
|
-
questions: Array<{
|
|
4
|
-
question: string;
|
|
5
|
-
header: string;
|
|
6
|
-
options: Array<{
|
|
7
|
-
label: string;
|
|
8
|
-
description: string;
|
|
9
|
-
}>;
|
|
10
|
-
multiSelect?: boolean;
|
|
11
|
-
}>;
|
|
12
|
-
metadata?: {
|
|
13
|
-
source?: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare function createAskUserQuestionElicitation(input: AskUserQuestionInput, sessionId: string, toolCallId: string, meta?: Record<string, unknown>): CreateElicitationRequest & {
|
|
17
|
-
mode: 'form';
|
|
18
|
-
requestedSchema: ElicitationSchema;
|
|
19
|
-
};
|
|
20
|
-
export declare function normalizeAskUserQuestionElicitationAnswers(input: AskUserQuestionInput, content: unknown): Record<string, string>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import { AgentDiscovery } from '../agent-registry/discovery.js';
|
|
3
|
-
import type { SessionOpenOptions } from './runtime.js';
|
|
4
|
-
/** Host filesystem discovery is assembled here; AgentBackend consumes query inputs. */
|
|
5
|
-
export declare const localQueryOptions: (open: SessionOpenOptions) => Effect.Effect<{
|
|
6
|
-
_meta?: Record<string, unknown> | null;
|
|
7
|
-
cwd?: string;
|
|
8
|
-
agent?: string;
|
|
9
|
-
multitask?: boolean;
|
|
10
|
-
sandboxEnabled?: boolean;
|
|
11
|
-
remoteAgentsUrl?: string;
|
|
12
|
-
permissionMode?: `${import("../../cli/dist-server/types/node/settings/settings-protocol.js").PermissionMode}`;
|
|
13
|
-
model?: string;
|
|
14
|
-
contextWindow?: number | null;
|
|
15
|
-
tools?: Array<string | import("#agent-harness-codebuddy/server").SdkMcpToolDefinition> | import("../../cli/dist-server/types/node/server/tool-presets.js").ToolsPreset;
|
|
16
|
-
allowedTools?: string[];
|
|
17
|
-
disallowedTools?: string[];
|
|
18
|
-
maxTurns?: number;
|
|
19
|
-
abortController?: AbortController;
|
|
20
|
-
thinking?: {
|
|
21
|
-
type: 'adaptive';
|
|
22
|
-
} | {
|
|
23
|
-
type: 'enabled';
|
|
24
|
-
budget_tokens?: number;
|
|
25
|
-
} | {
|
|
26
|
-
type: 'disabled';
|
|
27
|
-
};
|
|
28
|
-
effort?: import("../../cli/dist-server/types/node/settings/settings-protocol.js").ReasoningEffortLevel | null;
|
|
29
|
-
maxThinkingTokens?: number;
|
|
30
|
-
additionalDirectories?: string[];
|
|
31
|
-
persistSession?: boolean;
|
|
32
|
-
systemPrompt?: string | string[] | {
|
|
33
|
-
type: 'preset';
|
|
34
|
-
preset: 'default';
|
|
35
|
-
append?: string;
|
|
36
|
-
};
|
|
37
|
-
includePartialMessages?: boolean;
|
|
38
|
-
sandbox?: import("#agent-harness-codebuddy/server").SandboxFactory | import("#agent-harness-codebuddy/server").SandboxDriver;
|
|
39
|
-
fs?: import("../../cli/dist-server/types/node/data-fs/index.js").FileSystem;
|
|
40
|
-
settings?: import("../../cli/dist-server/types/node/settings/settings-protocol.js").Settings;
|
|
41
|
-
mcpServers?: import("../../cli/dist-server/types/node/mcp/mcp-protocol.js").PartialMcpDataValue;
|
|
42
|
-
product?: Partial<import("../../cli/dist-server/types/workspace/product/lib/common/product-protocol.js").ProductConfiguration>;
|
|
43
|
-
freezeToolsDuringRun?: boolean;
|
|
44
|
-
auth?: import("#agent-harness-codebuddy/server").RunAuth;
|
|
45
|
-
account?: import("#agent-harness-codebuddy/server").RunAccount;
|
|
46
|
-
headers?: Record<string, string>;
|
|
47
|
-
canUseTool?: import("../../cli/dist-server/types/node/server/types.js").CanUseTool;
|
|
48
|
-
hooks?: import("#agent-harness-codebuddy/server").QueryHooks;
|
|
49
|
-
agents: Record<string, import("../../cli/dist-server/types/node/product/agent-conversion-utils.js").ExternalAgentDefinition>;
|
|
50
|
-
}, Error, AgentDiscovery>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var t=(o,i)=>a(o,"name",{value:i,configurable:!0});import{Effect as c}from"effect";import{AgentDiscovery as l}from"../agent-registry/discovery.js";import{workspaceQueryOptions as y}from"./agent-backend.js";export const localQueryOptions=c.fn("localQueryOptions")(function*(o){const i=yield*y(o),e=yield*l,r=o.workspace.canonicalCwd,s=yield*c.tryPromise({try:t(n=>e.loadAgentDefinitions(r,{signal:AbortSignal.any([n,o.signal])}),"try"),catch:t(n=>n instanceof Error?n:new Error("Agent definition discovery failed",{cause:n}),"catch")});return{...i,agents:s}});
|