@tencent-ai/agent-harness 0.2.0-beta.2 → 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 +26 -2
- package/cli/CHANGELOG.md +64 -0
- package/cli/dist-server/shared.cjs +379 -315
- 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 +8 -1
- 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 +3 -2
- package/cli/dist-server/types/node/server/types.d.ts +59 -7
- package/cli/dist-server/types/node/tools/tool-protocol.d.ts +16 -2
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +31 -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 +26 -3
- package/cli/dist-server/types/vendor/cbc-core/node/agent/index.d.ts +3 -0
- 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 +25 -9
- 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 +9 -8
- 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/session/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +8 -0
- 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 +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 +7 -3
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +47 -5
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-run-state-machine-protocol.d.ts +14 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/stream-timeout-retry-budget.d.ts +8 -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 +4 -4
- 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/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/model/model-errors.d.ts +30 -2
- 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 +3 -3
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts +6 -0
- 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 +21 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/external-link-authentication-provider.d.ts +20 -4
- package/cli/dist-server/types/workspace/authentication/lib/common/index.d.ts +1 -0
- 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 +31 -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 +26 -3
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/index.d.ts +3 -0
- 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 +25 -9
- 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 +9 -8
- 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/session/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +8 -0
- 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 +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 +7 -3
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +47 -5
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-run-state-machine-protocol.d.ts +14 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/stream-timeout-retry-budget.d.ts +8 -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 +4 -4
- 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/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/model/model-errors.d.ts +30 -2
- package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-service.d.ts +5 -0
- package/cli/dist-server/types/workspace/core/lib/common/protocol.d.ts +8 -1
- package/cli/dist-server/types/workspace/product/lib/common/index.d.ts +1 -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/types/config.d.ts +12 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +1 -9
- package/cli/dist-server/types/workspace/product/lib/common/types/product.d.ts +15 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/center-protocol.generated.d.ts +5 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/file-policy.d.ts +4 -1
- 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 +3 -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 +11 -7
- package/cli/product.ioa.json +32 -24
- package/cli/product.json +45 -17
- 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/in-process.md +26 -2
- package/docs/protocol.md +7 -1
- package/docs/server.md +2 -0
- package/lib/agent/v2.js +1 -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/{acp/acp-prompt-input.d.ts → session/prompt-input.d.ts} +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/integration/agent-integration.d.ts +5 -0
- package/lib/runtime/private-runtime-role.js +1 -1
- package/lib/session/agent-backend.d.ts +3 -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/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-mcp.js +1 -1
- package/package.json +20 -19
- 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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# -e leaves stdin available for zip -@, archive comments and streamed input.
|
|
3
|
+
if [ "${CODEBUDDY_NODE_RUN_AS_NODE:-}" = "1" ]; then export ELECTRON_RUN_AS_NODE=1; fi
|
|
4
|
+
NODE_OPTIONS= exec "${CODEBUDDY_NODE_BIN:-node}" -e '
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const os = require("node:os");
|
|
8
|
+
const { spawnSync } = require("node:child_process");
|
|
9
|
+
const wrapper = fs.realpathSync(process.argv[1]);
|
|
10
|
+
const program = path.basename(process.argv[1]);
|
|
11
|
+
const shimRoot = path.dirname(path.dirname(wrapper));
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
const brokerClient = process.env.CODEBUDDY_BROKER_IPC_CLIENT || path.join(shimRoot, "broker-ipc-client.cjs");
|
|
14
|
+
const { checkProgramPolicy } = require(path.join(shimRoot, "broker-program-policy-check.cjs"));
|
|
15
|
+
const policy = checkProgramPolicy(program, "archive-wrapper", { brokerClientPath: brokerClient });
|
|
16
|
+
if (policy.code) {
|
|
17
|
+
console.error(policy.error);
|
|
18
|
+
process.exit(policy.code);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Only single-archive options are tracked. Do not guess targets for -m, split
|
|
22
|
+
// archives, --out, log files or options injected through ZIPOPT.
|
|
23
|
+
function zipTarget() {
|
|
24
|
+
if (process.env.ZIPOPT) { return undefined; }
|
|
25
|
+
let archive;
|
|
26
|
+
let literal = false;
|
|
27
|
+
for (const arg of args) {
|
|
28
|
+
if (!literal && arg === "--") { literal = true; continue; }
|
|
29
|
+
if (!literal && arg.startsWith("-") && arg !== "-") {
|
|
30
|
+
// Conservatively exclude any cluster containing lf before parsing.
|
|
31
|
+
// Even ll+f must be separate arguments to retain rollback tracking.
|
|
32
|
+
if (arg.includes("lf")) { return undefined; }
|
|
33
|
+
if (arg === "-FS") { continue; }
|
|
34
|
+
for (let i = 1; i < arg.length; i++) {
|
|
35
|
+
// Info-ZIP matches two-character options before single flags,
|
|
36
|
+
// including inside clusters (e.g. -qlf consumes a log path).
|
|
37
|
+
const pair = arg.slice(i, i + 2);
|
|
38
|
+
if (["db", "dc", "dd", "dg", "ds", "du", "dv", "DF", "fd", "fz", "ll", "lf", "la", "li"].includes(pair)) {
|
|
39
|
+
if (!["dc", "dd", "dg", "du", "fd", "fz", "ll"].includes(pair)) { return undefined; }
|
|
40
|
+
i++;
|
|
41
|
+
} else if (!/^[0-9rqjXDdufgoyl@cze]$/.test(arg[i])) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else if (archive === undefined) {
|
|
46
|
+
archive = arg;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (archive === "") { return undefined; }
|
|
50
|
+
if (archive === undefined || archive === "-") { return null; }
|
|
51
|
+
return path.resolve(path.basename(archive).includes(".") ? archive : archive + ".zip");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function commandArchiveTarget() {
|
|
55
|
+
const rar = program === "rar";
|
|
56
|
+
if (rar && !args.includes("-cfg-")) {
|
|
57
|
+
const home = process.env.HOME || os.homedir();
|
|
58
|
+
const config = process.env.XDG_CONFIG_HOME || path.join(home, ".config");
|
|
59
|
+
if (process.env.RARINISWITCHES || [path.join(home, ".rarrc"), "/etc/.rarrc", path.join(config, "rar")]
|
|
60
|
+
.some(file => fs.existsSync(file))) { return undefined; }
|
|
61
|
+
}
|
|
62
|
+
let command;
|
|
63
|
+
let archive;
|
|
64
|
+
let type = rar ? "rar" : "7z";
|
|
65
|
+
let literal = false;
|
|
66
|
+
for (const arg of args) {
|
|
67
|
+
if (!literal && arg === "--") { literal = true; continue; }
|
|
68
|
+
if (!literal && arg.startsWith("-")) {
|
|
69
|
+
if (!rar && /^-t(7z|zip)$/.test(arg)) { type = arg.slice(2); continue; }
|
|
70
|
+
const supported = rar
|
|
71
|
+
? /^(?:-cfg-|-r[0-]?|-m[0-5]|-ma[45]|-id[a-z]+|-y|-s-?|-ep[123]?|-p.*|-hp.*)$/
|
|
72
|
+
: /^(?:-r[0-]?|-y|-mx=?[0-9]|-mmt(?:=?[0-9]+)?|-p.*|-bb[0-3]|-bd|-b[spo][0-2])$/;
|
|
73
|
+
if (!supported.test(arg)) { return undefined; }
|
|
74
|
+
} else if (!command) {
|
|
75
|
+
command = arg;
|
|
76
|
+
} else if (archive === undefined) {
|
|
77
|
+
archive = arg;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!(rar ? ["a", "u", "f"] : ["a", "u"]).includes(command)) { return undefined; }
|
|
81
|
+
if (!archive || archive.startsWith("@") || /[*?]/.test(archive)) { return undefined; }
|
|
82
|
+
// RAR first tries an existing exact path; 7-Zip instead appends its default
|
|
83
|
+
// extension. A trailing dot has special 7-Zip naming semantics we do not infer.
|
|
84
|
+
if (!rar && archive.endsWith(".")) { return undefined; }
|
|
85
|
+
if (rar && fs.existsSync(path.resolve(archive))) { return path.resolve(archive); }
|
|
86
|
+
return path.resolve(path.basename(archive).includes(".") ? archive : archive + "." + type);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function tarTarget() {
|
|
90
|
+
if (process.env.TAR_OPTIONS) { return undefined; }
|
|
91
|
+
let archive;
|
|
92
|
+
let create = false;
|
|
93
|
+
let literal = false;
|
|
94
|
+
const modes = new Set(["--create", "--gzip", "--bzip2", "--xz", "--auto-compress", "--verbose"]);
|
|
95
|
+
for (let i = 0; i < args.length; i++) {
|
|
96
|
+
const arg = args[i];
|
|
97
|
+
if (literal) { continue; }
|
|
98
|
+
if (arg === "--") { literal = true; continue; }
|
|
99
|
+
if (modes.has(arg)) { if (arg === "--create") { create = true; } continue; }
|
|
100
|
+
if (arg === "--file" || arg === "--directory") {
|
|
101
|
+
const value = args[++i];
|
|
102
|
+
if (value === undefined) { return undefined; }
|
|
103
|
+
if (arg === "--file") {
|
|
104
|
+
if (archive !== undefined) { return undefined; }
|
|
105
|
+
archive = value;
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (arg.startsWith("--file=")) {
|
|
110
|
+
if (archive !== undefined) { return undefined; }
|
|
111
|
+
archive = arg.slice(7); continue;
|
|
112
|
+
}
|
|
113
|
+
if (arg.startsWith("--directory=")) { continue; }
|
|
114
|
+
if (arg.startsWith("--")) { return undefined; }
|
|
115
|
+
const oldStyle = i === 0 && /^[cvzjJahfC]+$/.test(arg);
|
|
116
|
+
if (!arg.startsWith("-") && !oldStyle) { continue; }
|
|
117
|
+
const flags = oldStyle ? arg : arg.slice(1);
|
|
118
|
+
for (let j = 0; j < flags.length; j++) {
|
|
119
|
+
const flag = flags[j];
|
|
120
|
+
if (flag === "c") { create = true; }
|
|
121
|
+
else if ("vzjJah".includes(flag)) { continue; }
|
|
122
|
+
else if (flag === "f" || flag === "C") {
|
|
123
|
+
const value = !oldStyle && j + 1 < flags.length ? flags.slice(j + 1) : args[++i];
|
|
124
|
+
if (value === undefined) { return undefined; }
|
|
125
|
+
if (flag === "f") {
|
|
126
|
+
if (archive !== undefined) { return undefined; }
|
|
127
|
+
archive = value;
|
|
128
|
+
}
|
|
129
|
+
if (!oldStyle) { break; }
|
|
130
|
+
} else { return undefined; }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!create || !archive) { return undefined; }
|
|
134
|
+
if (archive === "-") { return null; }
|
|
135
|
+
if (archive.includes(":")) { return undefined; }
|
|
136
|
+
return path.resolve(archive);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const brokerEnabled = Boolean(process.env.CODEBUDDY_SANDBOX_BROKER_IPC_ADDRESS
|
|
140
|
+
&& process.env.CODEBUDDY_SANDBOX_BROKER_SESSION_ID);
|
|
141
|
+
const target = program === "zip" ? zipTarget() : program === "tar" ? tarTarget() : commandArchiveTarget();
|
|
142
|
+
let send;
|
|
143
|
+
function notify(command) {
|
|
144
|
+
const response = send({ command, operation: "write", path: target,
|
|
145
|
+
sessionId: process.env.CODEBUDDY_SANDBOX_BROKER_SESSION_ID,
|
|
146
|
+
toolCallId: process.env.CODEBUDDY_SANDBOX_BROKER_TOOL_CALL_ID,
|
|
147
|
+
brokerTraceId: process.env.CODEBUDDY_SANDBOX_BROKER_TRACE_ID,
|
|
148
|
+
runtime: "archive-wrapper" });
|
|
149
|
+
if (!response || (response.ok !== true && response.decision !== "sandbox")) {
|
|
150
|
+
throw new Error(response?.error || "Archive rollback registration denied");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (brokerEnabled && target === undefined) {
|
|
154
|
+
console.error("WorkBuddy: file rollback is not tracked for these " + program + " options.");
|
|
155
|
+
}
|
|
156
|
+
if (brokerEnabled && target) {
|
|
157
|
+
try {
|
|
158
|
+
const command = process.env.CODEBUDDY_SANDBOX_FILE_TOKEN_OPERATION_COMMAND;
|
|
159
|
+
if (!command) { throw new Error("Archive write preflight unavailable"); }
|
|
160
|
+
send = require(brokerClient).sendBrokerRequestSync;
|
|
161
|
+
notify(command);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error(error.message);
|
|
164
|
+
process.exit(13);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Preserve the native command, excluding aliases of this wrapper to avoid recursion.
|
|
169
|
+
const nativePath = (process.env.PATH || "").split(path.delimiter).filter(dir => {
|
|
170
|
+
try { return fs.realpathSync(path.resolve(dir, program)) !== wrapper; }
|
|
171
|
+
catch { return true; }
|
|
172
|
+
}).join(path.delimiter);
|
|
173
|
+
const result = spawnSync(program, args, { stdio: "inherit", env: { ...process.env, PATH: nativePath } });
|
|
174
|
+
let status = result.status ?? (result.error?.code === "ENOENT" ? 127 : 1);
|
|
175
|
+
if (result.error) { console.error(result.error.message); }
|
|
176
|
+
// Nonzero exit can still leave an archive. The host checks existence and remembers
|
|
177
|
+
// whether this path was missing at preflight; never infer that from the exit code.
|
|
178
|
+
if (send) {
|
|
179
|
+
try { notify("FileWriteCompleted"); }
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error("WorkBuddy: " + program + " rollback registration failed: " + error.message);
|
|
182
|
+
if (status === 0) { status = 13; }
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (result.signal) { process.kill(process.pid, result.signal); }
|
|
186
|
+
else { process.exit(status); }
|
|
187
|
+
' "$0" "$@"
|
package/docs/in-process.md
CHANGED
|
@@ -64,13 +64,26 @@ await harness.close();
|
|
|
64
64
|
| `tools` | 工具预设或显式工具数组,见下文。默认使用 `default`。 |
|
|
65
65
|
| `mcp.toolsSyncTtlMs` | 工具目录的兜底刷新间隔,默认 15 分钟;`null` 关闭过期刷新,变更通知仍生效。 |
|
|
66
66
|
| `strictMcpConfig` | 为 `true` 时只使用会话显式传入的 MCP;默认还发现用户和插件 MCP。 |
|
|
67
|
-
| `telemetry` |
|
|
67
|
+
| `telemetry` | Harness 的结构化日志 sink、队列和刷新设置;传入的 sink 由 Harness flush/close。Agent 内核日志在本地模式默认写入 `configDir/logs`,与此 sink 分开。 |
|
|
68
68
|
| `signal` | Harness 的生命周期取消信号,覆盖创建和运行阶段。 |
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
每个进程同时支持一个 Harness。不同窗口或工作区使用同一 Harness 的多个 Client/Session。完整关闭后可以创建新实例:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
const first = await createHarness({ configDir: firstConfigDir });
|
|
74
|
+
// 使用 first …
|
|
75
|
+
await first.close();
|
|
76
|
+
const second = await createHarness({ configDir: secondConfigDir });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`close()` 等待执行任务与连接释放,`closed` 也可以用于等待关闭完成。关闭失败时应处理错误,当前进程不会接纳新实例。旧实例的 `close()` 可以重复调用;连接和会话需要在新实例上重新创建或恢复。
|
|
80
|
+
|
|
81
|
+
配置目录是进程级设置;关闭后恢复 Harness 写入的环境配置,宿主期间主动修改的值保留。文件系统、会话历史及 user/project/local settings 使用现有本地实现。
|
|
71
82
|
|
|
72
83
|
项目 Skills、命令、Agent 定义及已启用插件的 persona、MCP、Skills、命令、Agent 和 hooks 随会话的 `cwd` 装载并隔离。磁盘文件与插件提供的 output style、插件 LSP 暂不在多工作区库模式下启用;应用仍可通过 Product 提供 output style。
|
|
73
84
|
|
|
85
|
+
支持 Desktop 的 welcome-mode + interaction-mode + prompt-common 组合,沿用 CLI 的模板与工具声明规则。插件按会话启用,切换模式后下一轮采用新的指令和工具列表。未声明 `tools` 时继承宿主工具;显式 `tools: []` 清空内置及宿主注册的裸名工具,命名空间 MCP 工具仍沿用原有的 MCP 筛选规则。插件声明只筛选已有工具,宿主仍通过 `createHarness.tools` 注册实现。
|
|
86
|
+
|
|
74
87
|
`host` 描述应用,`clientInfo` 描述具体连接;账号、Product 模式和凭据仍通过 Client 协商和设置。模型、权限、工作区目录、插件和 Skills 使用现有会话及领域 API。参见 [认证接入](authentication-guide.md)、[Product 配置](product.md) 和 [Client 指南](client.md)。
|
|
75
88
|
|
|
76
89
|
`productConfig` 在创建时复制;后续修改原对象不会改变 Harness。应用应先解析自己的配置文件和环境选择,再传入结果。需要指定公开 feature 名称时,也可传入 [Product 配置文件](product.md#2-product-文件) 的版本化对象及 `presentation`。
|
|
@@ -80,6 +93,8 @@ managed Product 由 Harness 基于这份启动配置和账号解析;external P
|
|
|
80
93
|
|
|
81
94
|
库入口不安装进程信号处理器,也不会调用 `process.exit()`。独立进程的 listener、网络认证以及 Windows 宿主进程树回收由入口负责,见 [Server 装配](server.md)。
|
|
82
95
|
|
|
96
|
+
本地 Harness 默认启用 Agent 的文件日志和 shell snapshot;日志写入 `configDir/logs`,snapshot 暂存于 `configDir/shell-snapshots`(未指定目录时使用 `~/.codebuddy`)。宿主可在创建 Harness 前设置 `CODEBUDDY_DISABLE_FILE_LOGS=1` 或 `CODEBUDDY_DISABLE_SHELL_SNAPSHOT=1` 分别关闭。shell snapshot 在没有 Git Bash 的 Windows 环境仍按 Agent 的平台规则跳过。直接使用 Agent `./server` 的云端宿主保持原有的默认关闭行为。
|
|
97
|
+
|
|
83
98
|
Windows 上的 Bash 使用非交互 pipe 输出,支持前台、后台任务和终端输出通知;沙箱规则与权限审批照常生效。
|
|
84
99
|
Linux 上安装了对应架构的 `@tencent-ai/sandbox-cli-linux-*` 原生包时,Harness 默认开启平台支持,Session Config Options 提供 `sandbox` 开关。宿主也可通过 `WORKBUDDY_ENABLE_LINUX_SANDBOX_CLI=0` 关闭,或设为 `1` 显式开启(需提供可用的原生程序)。工作区外的 `ask` 规则通过 ACP 请求权限。
|
|
85
100
|
|
|
@@ -148,6 +163,15 @@ const { sessionId } = await client.session.new({
|
|
|
148
163
|
|
|
149
164
|
本地 Transport 不写入历史。重新连接或冷恢复会话时重新提供 `mcpServers`;关闭会话或 Client 会关闭其已建立的 MCP 连接。会话挂载 MCP 时,Harness 通过 Executor 发现工具并建立目录;Agent 与 MCP 管理 API 使用同一份会话视图,工具调用也经过 Executor。
|
|
150
165
|
|
|
166
|
+
会话空闲时,可通过 `session.resume()` 替换完整的 Client MCP 列表,下一次 prompt 使用新目录。省略 `mcpServers` 或传 `[]` 会移除 Client 提供的服务器,用户配置和插件中的 MCP 仍按原合并规则生效。省略 `replayFrom` 不回放历史:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
await client.session.resume({ sessionId, cwd, mcpServers: nextServers });
|
|
170
|
+
await client.session.resume({ sessionId, cwd, mcpServers: [] });
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
替换成功会关闭被移除的 MCP 连接并释放 Client 的 Transport 注册;准备失败则保留原列表。前台或 Subagent 仍在执行时,替换返回 busy,待任务结束后重试。多个 Client 共享会话时,由当前持有 MCP 的 Client 更新;旁观 Client 不会接管另一连接的 MCP。
|
|
174
|
+
|
|
151
175
|
普通 HTTP/stdio MCP 描述仍然受支持。`mcpServers` 属于会话,`tools` 属于应用;两者可以一起使用。
|
|
152
176
|
|
|
153
177
|
|
package/docs/protocol.md
CHANGED
|
@@ -51,6 +51,8 @@ Harness 在进程内装配 Agent CLI `./server` 与原有管理组件。MCP 的
|
|
|
51
51
|
|
|
52
52
|
默认按 Host > 用户 > 插件的优先级合并 MCP。以 `--strict-mcp-config` 启动时,只接受 `session/new` / `session/resume` 的 `mcpServers`;省略或空数组表示无 MCP。该选项在冷恢复和插件选择变更后继续生效,不影响插件的 Commands、Skills、Agents、Hooks、LSP 等组件。
|
|
53
53
|
|
|
54
|
+
`session/resume.mcpServers` 表示本次 Client 的完整列表,已挂载会话也可以在空闲时替换。省略或空数组会清空 Client 提供的部分;`replayFrom` 独立控制是否回放历史。前台或 Subagent 运行期间不替换连接,返回 busy 供 Client 稍后重试。多连接共享会话时,MCP 的更新权属于当前持有这些连接的 Client。
|
|
55
|
+
|
|
54
56
|
## 会话与事件
|
|
55
57
|
|
|
56
58
|
`session/prompt` 返回接受 ACK,其中 `_meta['codebuddy.ai/requestId']` 标识本轮执行。ACK 不代表模型执行完成。应用通过 `session/update` 的 `state_update` 观察前台 running / idle 与 stopReason;后台任务在前台 idle 后仍可运行,完成后可触发自动续跑。
|
|
@@ -99,7 +101,7 @@ Prompt 接受 ACP content,包括 text、image、resource 与 resource_link。A
|
|
|
99
101
|
|
|
100
102
|
管理目录与会话当前执行目录是两个视图。`plugin/list`、`skills/list` 和 `agent/list` 用于查询可发现的组件;会话可执行命令以 `available_commands_update` 的完整快照为准。
|
|
101
103
|
|
|
102
|
-
`config/read` 省略 cwd 时读取 user scope;显式 cwd 时合并相应 workspace 的配置。持久化写入支持版本冲突检测;失败分类见 [错误契约](errors.md)。`session/set_config_option` 只接受该会话 response 或 update
|
|
104
|
+
`config/read` 省略 cwd 时读取 user scope;显式 cwd 时合并相应 workspace 的配置。持久化写入支持版本冲突检测;失败分类见 [错误契约](errors.md)。`session/set_config_option` 只接受该会话 response 或 update 已声明的选项;它不会改写用户或项目配置。Harness 只为同一 session 的恢复保留显式选择,sandbox 的展示默认值从当前有效配置读取;其他选项按各自的 Product 和会话初始化规则解析。新选择记录使用独立的 `.selections.json` 文件,不覆盖旧版记录;降级不会恢复新版期间修改的选择。
|
|
103
105
|
|
|
104
106
|
配置写入与 ConfigChange hooks 已接通。活跃会话的 config/plugin/skill 全量 reload 仍受配置缓存与加载边界限制;不能将写入成功视为所有已加载会话已重载。新建、恢复及插件选择后的命令目录可在提问前取得。
|
|
105
107
|
|
|
@@ -108,3 +110,7 @@ Prompt 接受 ACP content,包括 text、image、resource 与 resource_link。A
|
|
|
108
110
|
JSON-RPC 边界返回稳定错误分类,不暴露内部异常栈、凭据或上游完整响应。执行期间的诊断通过 error update 交付,并由终态结束前台执行;详情见 [错误契约](errors.md)。
|
|
109
111
|
|
|
110
112
|
`client.close()` 关闭连接并终止该 Client 实例。进程宿主在 stdin EOF 后会关闭会话与执行设施,再自然退出。网络连接断开后的会话归属、恢复顺序和历史合并见 [ACP v2](acp-v2.md);应用应使用持久化 sessionId 恢复,而不是假定传输连接本身持有历史。
|
|
113
|
+
|
|
114
|
+
会话配置恢复保留旧版模型、模式等选择,仅丢弃旧版错误投影的 `sandbox:false`。
|
|
115
|
+
首次 Agent 配置帧用于同步展示;后续实际配置变更更新当前会话的选择记录,不写入全局设置。
|
|
116
|
+
配置默认值在装载及显式 reload 时刷新,不在每次 prompt 确认前读取。读取失败保留已有展示。
|
package/docs/server.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
完整应用的 `createHarness()` 与本地工具接入见 [同进程接入](in-process.md)。
|
|
4
4
|
|
|
5
|
+
Harness 的 Agent 接入使用 `subscribe(sessionId, listener, { format: 'acp-v2' })`,由 Agent Server 直接投影原生事件。消息、附件和工具编码与历史回放共用;Harness 负责连接、配置和权限等宿主策略。
|
|
6
|
+
|
|
5
7
|
本文面向实现 Harness 领域模块、装配 Server 或扩展 Transport 的开发者。
|
|
6
8
|
IDE、CLI、TUI 等应用的接入方式见 [Client 接入指南](client.md),完整 binary 的启动与
|
|
7
9
|
进程管理见 [启动进程与接入](client-processes.md)。
|