agent-workbench-connector 0.3.2 → 0.3.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/README.md +1 -1
- package/dist/agent.mjs +37 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,6 @@ agent-workbench-connector --env-file ./agent.env
|
|
|
56
56
|
|
|
57
57
|
日常发布可在 GitHub **Actions → Release Agent → Run workflow** 选择 main 和 `patch` / `minor` / `major`。流程自动更新本包版本、提交并打标签,再启动现有 CI / CD 检查和 npm 发布;最终发布状态查看 CI / CD,而非仅看 Release Agent。main / 标签保护必须允许该机器人的推送,否则继续使用版本 PR 和手动标签,不绕过仓库规则。现有 npm Trusted Publisher 仍是 `ci-cd.yml`,无需更换。
|
|
58
58
|
|
|
59
|
-
在工作台仓库运行 `pnpm agent:pack`,生成 `dist/device-agent/agent-workbench-connector-0.3.
|
|
59
|
+
在工作台仓库运行 `pnpm agent:pack`,生成 `dist/device-agent/agent-workbench-connector-0.3.3.tgz`。包内只包含编译后的连接器、说明、许可证和包元数据;上下文工作区代码已打包,无 `workspace:*` 运行时依赖,ACP SDK 由包管理器安装。源码改动后必须重新打包。
|
|
60
60
|
|
|
61
61
|
CI / CD 在 `agent-vX.Y.Z` 标签推送后执行完整检查,再发布同一次构建的 tgz。标签版本必须与本包版本一致,提交必须已合入 main;PR 和普通 main 提交只打包不发布。发布使用独立的 GitHub `npm` Environment 和 npm Trusted Publisher(`Gausons/auto-workflow`、`ci-cd.yml`、Environment `npm`),首次发布也可配置临时 `NPM_TOKEN` Secret。具体初始化步骤见仓库 README 的“连接器 npm 发布”。本机 npm 登录状态不会传递给 CI;包版本一旦发布不能覆盖。安装或构建本身不会自动发布,也不会要求用户在安装机器上构建。
|
package/dist/agent.mjs
CHANGED
|
@@ -1140,6 +1140,23 @@ async function switchGitBranch(cwd, branch, create = false) {
|
|
|
1140
1140
|
}
|
|
1141
1141
|
}
|
|
1142
1142
|
//#endregion
|
|
1143
|
+
//#region ../../src/agentExecutionError.ts
|
|
1144
|
+
/** Older Codex ACP adapters turn provider failures into assistant text followed by
|
|
1145
|
+
* end_turn. Accept only a whole error envelope, optionally after the adapter's
|
|
1146
|
+
* metadata warning; never scan quoted examples or tool output for error words. */
|
|
1147
|
+
function codexProviderError(output) {
|
|
1148
|
+
const text = (output || "").trim().replace(/^Warning: Model metadata for [^\n]+ not found\. Defaulting to fallback metadata; this can degrade performance and cause issues\.\s*/, "");
|
|
1149
|
+
try {
|
|
1150
|
+
const value = JSON.parse(text);
|
|
1151
|
+
if (!value || typeof value !== "object" || !("type" in value) || value.type !== "error" || !("status" in value) || typeof value.status !== "number" || value.status < 400 || value.status > 599 || !("error" in value)) return;
|
|
1152
|
+
const error = value.error;
|
|
1153
|
+
if (!error || typeof error !== "object" || !("type" in error) || typeof error.type !== "string" || !("message" in error) || typeof error.message !== "string" || !error.message.trim()) return;
|
|
1154
|
+
return error.message.slice(0, 4e3);
|
|
1155
|
+
} catch {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
//#endregion
|
|
1143
1160
|
//#region ../../src/codexDesktopBridge.ts
|
|
1144
1161
|
var record$2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1145
1162
|
async function readDesktopTerminal(file, turnId) {
|
|
@@ -1363,6 +1380,7 @@ function configuredAcpAgents(environment = process.env) {
|
|
|
1363
1380
|
function childEnvironment(agent, environment) {
|
|
1364
1381
|
const result = { ...environment };
|
|
1365
1382
|
if (agent === "codex" && !result.INITIAL_AGENT_MODE) result.INITIAL_AGENT_MODE = "agent";
|
|
1383
|
+
if (agent === "codex" && !result.CODEX_PATH) result.CODEX_PATH = resolveCodexExecutable({ environment });
|
|
1366
1384
|
return result;
|
|
1367
1385
|
}
|
|
1368
1386
|
function textFromUpdate(update) {
|
|
@@ -1703,7 +1721,8 @@ var AcpTaskRunner = class {
|
|
|
1703
1721
|
protocol: "acp"
|
|
1704
1722
|
};
|
|
1705
1723
|
this.jobs.set(job.id, job);
|
|
1706
|
-
const
|
|
1724
|
+
const agent = job.agent || this.agent;
|
|
1725
|
+
const launch = resolveAcpLaunch(agent, this.environment);
|
|
1707
1726
|
if (!launch) throw new Error("ACP Agent 未配置");
|
|
1708
1727
|
const retained = job.resumeSessionId ? this.retained.get(job.resumeSessionId) : null;
|
|
1709
1728
|
const connection = retained && !retained.closed ? retained : this.connectionFactory ? this.connectionFactory({
|
|
@@ -1774,16 +1793,20 @@ var AcpTaskRunner = class {
|
|
|
1774
1793
|
acceptingUpdates = true;
|
|
1775
1794
|
promptDispatched = true;
|
|
1776
1795
|
connection.prompt(job.prompt, job.promptImages, job.contextMarkdownPath).then((result) => {
|
|
1777
|
-
const
|
|
1796
|
+
const error = agent === "codex" ? codexProviderError(job.output) : void 0;
|
|
1797
|
+
const status = error ? "failed" : result.stopReason === "end_turn" ? "completed" : result.stopReason === "cancelled" ? "interrupted" : "failed";
|
|
1778
1798
|
this.publish(job, {
|
|
1779
1799
|
status,
|
|
1780
1800
|
request: null,
|
|
1781
1801
|
...job.promptImages?.length ? { contextImageDelivery: connection.supportsImages?.() ? "native" : "file-reference" } : {},
|
|
1782
|
-
message: status === "completed" ? "ACP 本轮执行完成" : `ACP 执行结束:${result.stopReason}`
|
|
1802
|
+
message: error || (status === "completed" ? "ACP 本轮执行完成" : `ACP 执行结束:${result.stopReason}`)
|
|
1783
1803
|
});
|
|
1784
1804
|
this.connections.delete(job.id);
|
|
1785
|
-
if (job.conversationId) this.retained.set(session.sessionId, connection);
|
|
1786
|
-
else
|
|
1805
|
+
if (job.conversationId && status === "completed") this.retained.set(session.sessionId, connection);
|
|
1806
|
+
else {
|
|
1807
|
+
this.retained.delete(session.sessionId);
|
|
1808
|
+
connection.close();
|
|
1809
|
+
}
|
|
1787
1810
|
}).catch((error) => {
|
|
1788
1811
|
this.publish(job, {
|
|
1789
1812
|
status: "unknown",
|
|
@@ -3762,7 +3785,7 @@ var RemoteCodexWorker = class {
|
|
|
3762
3785
|
signal;
|
|
3763
3786
|
invoked = /* @__PURE__ */ new Set();
|
|
3764
3787
|
selections = /* @__PURE__ */ new Set();
|
|
3765
|
-
constructor({ request, signal, onPending, deviceId, directory, workspace, runnerFactory, directoryPicker = (root) => pickNativeDirectory(root, signal), contextSource }) {
|
|
3788
|
+
constructor({ request, signal, onPending, deviceId, directory, workspace, runnerFactory, directoryPicker = (root) => pickNativeDirectory(root, signal), contextSource, environment = process.env }) {
|
|
3766
3789
|
this.request = request;
|
|
3767
3790
|
this.deviceId = deviceId;
|
|
3768
3791
|
this.directory = directory;
|
|
@@ -3787,25 +3810,27 @@ var RemoteCodexWorker = class {
|
|
|
3787
3810
|
};
|
|
3788
3811
|
this.runner = runnerFactory ? runnerFactory(update) : (() => {
|
|
3789
3812
|
const fallback = new CodexRunner({
|
|
3790
|
-
executable:
|
|
3813
|
+
executable: environment.CODEX_EXECUTABLE || "codex",
|
|
3814
|
+
environment,
|
|
3791
3815
|
onUpdate: update,
|
|
3792
3816
|
desktopOpener: async () => {}
|
|
3793
3817
|
});
|
|
3794
3818
|
const entries = [["codex", new AcpPreferredRunner({
|
|
3795
3819
|
primary: new AcpTaskRunner({
|
|
3796
3820
|
agent: "codex",
|
|
3797
|
-
environment
|
|
3821
|
+
environment,
|
|
3798
3822
|
onUpdate: update,
|
|
3799
3823
|
threadNamer: async (threadId, name) => (await fallback.connect()).call("thread/name/set", {
|
|
3800
3824
|
threadId,
|
|
3801
3825
|
name
|
|
3802
3826
|
})
|
|
3803
3827
|
}),
|
|
3804
|
-
fallback
|
|
3828
|
+
fallback,
|
|
3829
|
+
synchronizeModels: true
|
|
3805
3830
|
})]];
|
|
3806
|
-
for (const agent of configuredAcpAgents(
|
|
3831
|
+
for (const agent of configuredAcpAgents(environment)) if (agent !== "codex") entries.push([agent, new AcpTaskRunner({
|
|
3807
3832
|
agent,
|
|
3808
|
-
environment
|
|
3833
|
+
environment,
|
|
3809
3834
|
onUpdate: update
|
|
3810
3835
|
})]);
|
|
3811
3836
|
return new AgentRunnerSet(entries);
|
|
@@ -4986,6 +5011,7 @@ async function runAuthenticatedConnector({ environment, once, signal, onReady, d
|
|
|
4986
5011
|
return request(method, body, method === "GET" && !endpoint ? `/api/task-center/device-state?${deviceParams}` : endpoint);
|
|
4987
5012
|
};
|
|
4988
5013
|
const worker = defaults.execute ? new RemoteCodexWorker({
|
|
5014
|
+
environment,
|
|
4989
5015
|
request: workerRequest,
|
|
4990
5016
|
signal: stopping.signal,
|
|
4991
5017
|
onPending: () => wakeControls(),
|