@codexhost/cli-darwin-x64 0.6.1 → 0.7.0
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/THIRD_PARTY_NOTICES.txt +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/desktop-controller.mjs +3 -1
- package/app/host-runtime.mjs +1000 -472
- package/app/plugins/antigravity/plugin.mjs +54 -205
- package/app/plugins/claude-code/plugin.mjs +223 -49
- package/app/plugins/codebuddy/assets/icon.svg +1 -0
- package/app/plugins/codebuddy/manifest.json +13 -0
- package/app/plugins/codebuddy/plugin.mjs +23045 -0
- package/app/plugins/cursor-cli/assets/icon.svg +1 -0
- package/app/plugins/cursor-cli/manifest.json +13 -0
- package/app/plugins/cursor-cli/plugin.mjs +22579 -0
- package/app/plugins/deepseek-harness/plugin.mjs +7695 -10516
- package/app/plugins/enabled.json +3 -1
- package/app/plugins/grok/plugin.mjs +921 -74
- package/app/plugins/kiro-cli/plugin.mjs +29 -6
- package/app/plugins/pi/plugin.mjs +0 -12
- package/app/renderer-extension.js +746 -344
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/licenses/Agent-Client-Protocol-SDK-LICENSE.txt +191 -0
- package/package.json +1 -1
|
@@ -15612,7 +15612,7 @@ var harnessBrokerServerFrameSchema = external_exports.union([
|
|
|
15612
15612
|
var harnessBrokerDescriptorSchema = external_exports.object({
|
|
15613
15613
|
schemaVersion: external_exports.literal(1),
|
|
15614
15614
|
protocolVersion: external_exports.literal(HARNESS_BROKER_PROTOCOL_VERSION),
|
|
15615
|
-
harnessId:
|
|
15615
|
+
harnessId: harnessPluginIdSchema,
|
|
15616
15616
|
generation: external_exports.string().uuid(),
|
|
15617
15617
|
ownerPid: external_exports.number().int().positive(),
|
|
15618
15618
|
socketPath: external_exports.string().min(1).max(512),
|
|
@@ -15667,22 +15667,34 @@ function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
|
15667
15667
|
const home = environment.HOME || os.homedir();
|
|
15668
15668
|
return path.join(home, ".codexhost", "harness-broker");
|
|
15669
15669
|
}
|
|
15670
|
-
function defaultHarnessBrokerDescriptorPath(environment = process.env) {
|
|
15670
|
+
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
15671
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
15672
|
+
if (harnessId !== "claude-code")
|
|
15673
|
+
return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
15671
15674
|
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
15672
15675
|
}
|
|
15673
15676
|
|
|
15674
15677
|
// ../../harness-broker/dist/validation.js
|
|
15675
15678
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
15679
|
+
var brokerEnvironmentSchema = external_exports.object({
|
|
15680
|
+
CODEXHOST_CLI_PATH: external_exports.string().max(16384).optional(),
|
|
15681
|
+
CODEXHOST_RUNTIME_ENDPOINT: external_exports.string().max(16384).optional(),
|
|
15682
|
+
CODEXHOST_RUNTIME_TOKEN: external_exports.string().max(16384).optional(),
|
|
15683
|
+
CODEXHOST_THREAD_ID: external_exports.string().max(256).optional()
|
|
15684
|
+
}).strict();
|
|
15676
15685
|
var createSchema = external_exports.object({
|
|
15677
15686
|
kind: external_exports.literal("create"),
|
|
15678
15687
|
cwd: cwdSchema,
|
|
15679
15688
|
executionPolicy: external_exports.enum(["default", "unattended-full-access"]).optional(),
|
|
15689
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15680
15690
|
model: harnessModelRefSchema.optional(),
|
|
15681
15691
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15682
15692
|
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15683
15693
|
}).strict();
|
|
15684
15694
|
var resumeSchema = external_exports.object({
|
|
15685
15695
|
kind: external_exports.literal("resume"),
|
|
15696
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15697
|
+
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15686
15698
|
model: harnessModelRefSchema.optional(),
|
|
15687
15699
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15688
15700
|
nativeRef: nativeSessionRefSchema,
|
|
@@ -15691,12 +15703,14 @@ var resumeSchema = external_exports.object({
|
|
|
15691
15703
|
}).strict();
|
|
15692
15704
|
var forkSchema = external_exports.object({
|
|
15693
15705
|
kind: external_exports.literal("fork"),
|
|
15706
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15694
15707
|
sourceRef: nativeSessionRefSchema,
|
|
15695
15708
|
checkpoint: nativeCheckpointRefSchema,
|
|
15696
15709
|
cwd: cwdSchema
|
|
15697
15710
|
}).strict();
|
|
15698
15711
|
var rollbackSchema = external_exports.object({
|
|
15699
15712
|
kind: external_exports.literal("rollbackLastTurn"),
|
|
15713
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15700
15714
|
model: harnessModelRefSchema.optional(),
|
|
15701
15715
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15702
15716
|
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
@@ -15936,37 +15950,43 @@ function parseSessionMetadata(value) {
|
|
|
15936
15950
|
async function readDescriptor(descriptorPath) {
|
|
15937
15951
|
const metadata = await lstat(descriptorPath);
|
|
15938
15952
|
if (metadata.isSymbolicLink())
|
|
15939
|
-
throw new Error("
|
|
15953
|
+
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
15940
15954
|
if (!metadata.isFile())
|
|
15941
|
-
throw new Error("
|
|
15955
|
+
throw new Error("Aqua Harness broker descriptor is not a file");
|
|
15942
15956
|
if (process.platform !== "win32") {
|
|
15943
15957
|
if ((metadata.mode & 63) !== 0)
|
|
15944
|
-
throw new Error("
|
|
15958
|
+
throw new Error("Aqua Harness broker descriptor is not owner-only");
|
|
15945
15959
|
if (process.getuid && metadata.uid !== process.getuid()) {
|
|
15946
|
-
throw new Error("
|
|
15960
|
+
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
15947
15961
|
}
|
|
15948
15962
|
}
|
|
15949
15963
|
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile(descriptorPath, "utf8")));
|
|
15950
15964
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
15951
|
-
throw new Error("
|
|
15965
|
+
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
15952
15966
|
}
|
|
15953
15967
|
if (process.platform !== "win32") {
|
|
15954
15968
|
const socket = await lstat(descriptor.socketPath);
|
|
15955
15969
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
15956
|
-
throw new Error("
|
|
15970
|
+
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
15957
15971
|
}
|
|
15958
15972
|
if ((socket.mode & 63) !== 0 || process.getuid && socket.uid !== process.getuid()) {
|
|
15959
|
-
throw new Error("
|
|
15973
|
+
throw new Error("Aqua Harness broker endpoint is not owner-only");
|
|
15960
15974
|
}
|
|
15961
15975
|
}
|
|
15962
15976
|
try {
|
|
15963
15977
|
process.kill(descriptor.ownerPid, 0);
|
|
15964
15978
|
} catch {
|
|
15965
|
-
throw new Error("
|
|
15979
|
+
throw new Error("Aqua Harness broker owner process is unavailable");
|
|
15966
15980
|
}
|
|
15967
15981
|
return descriptor;
|
|
15968
15982
|
}
|
|
15969
15983
|
var BrokerConnection = class _BrokerConnection {
|
|
15984
|
+
#onClose;
|
|
15985
|
+
onClose(callback) {
|
|
15986
|
+
this.#onClose = callback;
|
|
15987
|
+
if (this.#closed)
|
|
15988
|
+
callback();
|
|
15989
|
+
}
|
|
15970
15990
|
#descriptor;
|
|
15971
15991
|
#socket;
|
|
15972
15992
|
#pending = /* @__PURE__ */ new Map();
|
|
@@ -15979,14 +15999,16 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
15979
15999
|
this.#descriptor = descriptor;
|
|
15980
16000
|
this.#socket = socket;
|
|
15981
16001
|
consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error52) => this.#fail(error52));
|
|
15982
|
-
socket.once("close", () => this.#fail(new Error("
|
|
16002
|
+
socket.once("close", () => this.#fail(new Error("Aqua Harness broker connection closed")));
|
|
15983
16003
|
socket.once("error", (error52) => this.#fail(error52));
|
|
15984
16004
|
}
|
|
15985
|
-
static async connect(descriptorPath) {
|
|
16005
|
+
static async connect(descriptorPath, harnessId) {
|
|
15986
16006
|
const descriptor = await readDescriptor(descriptorPath);
|
|
16007
|
+
if (descriptor.harnessId !== harnessId)
|
|
16008
|
+
throw new Error("Aqua broker belongs to another Harness");
|
|
15987
16009
|
const socket = net.createConnection(descriptor.socketPath);
|
|
15988
16010
|
await new Promise((resolve2, reject) => {
|
|
15989
|
-
const timeout = setTimeout(() => reject(new Error("Timed out connecting to
|
|
16011
|
+
const timeout = setTimeout(() => reject(new Error("Timed out connecting to Aqua Harness broker")), HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
15990
16012
|
socket.once("connect", () => {
|
|
15991
16013
|
clearTimeout(timeout);
|
|
15992
16014
|
resolve2();
|
|
@@ -16013,29 +16035,38 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16013
16035
|
const id = "__hello__";
|
|
16014
16036
|
const timeout = setTimeout(() => {
|
|
16015
16037
|
this.#pending.delete(id);
|
|
16016
|
-
reject(new Error("
|
|
16038
|
+
reject(new Error("Aqua Harness broker authentication timed out"));
|
|
16017
16039
|
}, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
16018
16040
|
this.#pending.set(id, { resolve: () => resolve2(), reject, timeout });
|
|
16019
16041
|
});
|
|
16020
16042
|
}
|
|
16021
16043
|
register(session) {
|
|
16044
|
+
if (this.#closed)
|
|
16045
|
+
throw new Error("Aqua Harness broker connection closed while opening Session");
|
|
16022
16046
|
this.#sessions.set(session.sessionId, session);
|
|
16023
16047
|
}
|
|
16048
|
+
get closed() {
|
|
16049
|
+
return this.#closed;
|
|
16050
|
+
}
|
|
16024
16051
|
unregister(sessionId) {
|
|
16025
16052
|
this.#sessions.delete(sessionId);
|
|
16026
16053
|
}
|
|
16054
|
+
async dispose() {
|
|
16055
|
+
await Promise.allSettled([...this.#sessions.values()].map((session) => session.close()));
|
|
16056
|
+
this.close();
|
|
16057
|
+
}
|
|
16027
16058
|
async request(method, params) {
|
|
16028
16059
|
if (this.#closed)
|
|
16029
|
-
throw new Error("
|
|
16060
|
+
throw new Error("Aqua Harness broker connection is closed");
|
|
16030
16061
|
if (this.#pending.size >= HARNESS_BROKER_MAX_PENDING_REQUESTS) {
|
|
16031
|
-
throw new Error("
|
|
16062
|
+
throw new Error("Aqua Harness broker request limit exceeded");
|
|
16032
16063
|
}
|
|
16033
16064
|
this.#inputSequence += 1;
|
|
16034
16065
|
const id = randomUUID();
|
|
16035
16066
|
const response = new Promise((resolve2, reject) => {
|
|
16036
16067
|
const timeout = setTimeout(() => {
|
|
16037
16068
|
this.#pending.delete(id);
|
|
16038
|
-
reject(new Error(`
|
|
16069
|
+
reject(new Error(`Aqua Harness broker ${method} timed out`));
|
|
16039
16070
|
}, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
16040
16071
|
this.#pending.set(id, { resolve: resolve2, reject, timeout });
|
|
16041
16072
|
});
|
|
@@ -16055,12 +16086,14 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16055
16086
|
return;
|
|
16056
16087
|
this.#closed = true;
|
|
16057
16088
|
this.#socket.destroy();
|
|
16058
|
-
this.#fail(new Error("
|
|
16089
|
+
this.#fail(new Error("Aqua Harness broker connection closed"));
|
|
16059
16090
|
}
|
|
16060
16091
|
#frame(raw) {
|
|
16092
|
+
if (this.#closed)
|
|
16093
|
+
return;
|
|
16061
16094
|
const frame = harnessBrokerServerFrameSchema.parse(raw);
|
|
16062
16095
|
if (frame.generation !== this.#descriptor.generation || frame.sequence !== this.#outputSequence + 1) {
|
|
16063
|
-
this.#fail(new Error("
|
|
16096
|
+
this.#fail(new Error("Aqua Harness broker response generation or sequence is invalid"));
|
|
16064
16097
|
return;
|
|
16065
16098
|
}
|
|
16066
16099
|
this.#outputSequence = frame.sequence;
|
|
@@ -16082,7 +16115,7 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16082
16115
|
}
|
|
16083
16116
|
const pending = this.#pending.get(frame.id);
|
|
16084
16117
|
if (!pending) {
|
|
16085
|
-
this.#fail(new Error("
|
|
16118
|
+
this.#fail(new Error("Aqua Harness broker returned an unknown response ID"));
|
|
16086
16119
|
return;
|
|
16087
16120
|
}
|
|
16088
16121
|
clearTimeout(pending.timeout);
|
|
@@ -16098,6 +16131,8 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16098
16131
|
this.#failed = true;
|
|
16099
16132
|
if (!this.#closed)
|
|
16100
16133
|
this.#closed = true;
|
|
16134
|
+
this.#socket.destroy();
|
|
16135
|
+
this.#onClose?.();
|
|
16101
16136
|
for (const pending of this.#pending.values()) {
|
|
16102
16137
|
clearTimeout(pending.timeout);
|
|
16103
16138
|
pending.reject(error52);
|
|
@@ -16108,7 +16143,10 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16108
16143
|
}
|
|
16109
16144
|
};
|
|
16110
16145
|
var BrokeredHarnessSession = class {
|
|
16111
|
-
|
|
16146
|
+
openInput;
|
|
16147
|
+
reconnect;
|
|
16148
|
+
onClose;
|
|
16149
|
+
harnessId;
|
|
16112
16150
|
outputs;
|
|
16113
16151
|
#channel = new HarnessOutputChannel();
|
|
16114
16152
|
#connection;
|
|
@@ -16116,9 +16154,18 @@ var BrokeredHarnessSession = class {
|
|
|
16116
16154
|
#metadata;
|
|
16117
16155
|
#faulted = false;
|
|
16118
16156
|
#closed = false;
|
|
16119
|
-
|
|
16157
|
+
#state;
|
|
16158
|
+
#recovery;
|
|
16159
|
+
constructor(connection, metadata, harnessId, openInput, reconnect, onClose) {
|
|
16160
|
+
this.openInput = openInput;
|
|
16161
|
+
this.reconnect = reconnect;
|
|
16162
|
+
this.onClose = onClose;
|
|
16163
|
+
this.harnessId = harnessId;
|
|
16164
|
+
if (metadata.initialState.nativeRef && metadata.initialState.nativeRef.harnessId !== harnessId)
|
|
16165
|
+
throw new Error("Broker Session identity belongs to another Harness");
|
|
16120
16166
|
this.#connection = connection;
|
|
16121
16167
|
this.#metadata = metadata;
|
|
16168
|
+
this.#state = structuredClone(metadata.initialState);
|
|
16122
16169
|
this.outputs = this.#channel.outputs;
|
|
16123
16170
|
if (metadata.commands) {
|
|
16124
16171
|
this.commands = {
|
|
@@ -16162,6 +16209,10 @@ var BrokeredHarnessSession = class {
|
|
|
16162
16209
|
if (this.#closed || generation !== this.#metadata.sessionGeneration)
|
|
16163
16210
|
return;
|
|
16164
16211
|
const value = harnessOutputSchema.parse(output);
|
|
16212
|
+
if (value.kind === "event" && value.event.type === "session.state.changed") {
|
|
16213
|
+
const nativeRef = value.event.state.nativeRef ?? this.#state.nativeRef;
|
|
16214
|
+
this.#state = { ...structuredClone(value.event.state), ...nativeRef ? { nativeRef } : {} };
|
|
16215
|
+
}
|
|
16165
16216
|
if (value.kind === "event" && value.event.type === "session.faulted" || isAuthenticationTerminal(value)) {
|
|
16166
16217
|
this.#faulted = true;
|
|
16167
16218
|
}
|
|
@@ -16180,6 +16231,13 @@ var BrokeredHarnessSession = class {
|
|
|
16180
16231
|
await this.#request("session.refreshUsage", {});
|
|
16181
16232
|
}
|
|
16182
16233
|
async readSnapshot() {
|
|
16234
|
+
if (this.#closed)
|
|
16235
|
+
return { ok: false, error: unavailable("Aqua Harness broker Session is closed", false) };
|
|
16236
|
+
if (this.#connection.closed) {
|
|
16237
|
+
const recovered = await this.#ensureRecovery();
|
|
16238
|
+
if (!recovered.ok)
|
|
16239
|
+
return recovered;
|
|
16240
|
+
}
|
|
16183
16241
|
try {
|
|
16184
16242
|
return parseHarnessResult(await this.#request("session.readSnapshot", {}));
|
|
16185
16243
|
} catch (error52) {
|
|
@@ -16191,20 +16249,11 @@ var BrokeredHarnessSession = class {
|
|
|
16191
16249
|
}
|
|
16192
16250
|
async execute(command) {
|
|
16193
16251
|
if (this.#closed)
|
|
16194
|
-
return { ok: false, error: unavailable("
|
|
16252
|
+
return { ok: false, error: unavailable("Aqua Harness broker Session is closed", false) };
|
|
16195
16253
|
if (this.#faulted && command.type === "turn.start") {
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
return reopened;
|
|
16200
|
-
this.#metadata = parseSessionMetadata(reopened.value);
|
|
16201
|
-
this.#faulted = false;
|
|
16202
|
-
} catch (error52) {
|
|
16203
|
-
return {
|
|
16204
|
-
ok: false,
|
|
16205
|
-
error: unavailable(error52 instanceof Error ? error52.message : String(error52))
|
|
16206
|
-
};
|
|
16207
|
-
}
|
|
16254
|
+
const recovered = await this.#ensureRecovery();
|
|
16255
|
+
if (!recovered.ok)
|
|
16256
|
+
return recovered;
|
|
16208
16257
|
}
|
|
16209
16258
|
try {
|
|
16210
16259
|
return parseHarnessResult(await this.#request("session.execute", { command }));
|
|
@@ -16219,9 +16268,69 @@ var BrokeredHarnessSession = class {
|
|
|
16219
16268
|
if (this.#closed)
|
|
16220
16269
|
return;
|
|
16221
16270
|
this.#closed = true;
|
|
16271
|
+
await this.#recovery?.catch(() => {
|
|
16272
|
+
});
|
|
16222
16273
|
this.#connection.unregister(this.sessionId);
|
|
16223
16274
|
await this.#request("session.close", {}).catch(() => void 0);
|
|
16224
16275
|
this.#channel.end();
|
|
16276
|
+
this.onClose();
|
|
16277
|
+
}
|
|
16278
|
+
async #ensureRecovery() {
|
|
16279
|
+
try {
|
|
16280
|
+
this.#recovery ??= this.#recover().finally(() => {
|
|
16281
|
+
this.#recovery = void 0;
|
|
16282
|
+
});
|
|
16283
|
+
return await this.#recovery;
|
|
16284
|
+
} catch (error52) {
|
|
16285
|
+
return {
|
|
16286
|
+
ok: false,
|
|
16287
|
+
error: unavailable(error52 instanceof Error ? error52.message : String(error52))
|
|
16288
|
+
};
|
|
16289
|
+
}
|
|
16290
|
+
}
|
|
16291
|
+
async #recover() {
|
|
16292
|
+
const previous = this.#connection;
|
|
16293
|
+
const connection = previous.closed ? await this.reconnect() : previous;
|
|
16294
|
+
const nativeRef = this.#state.nativeRef;
|
|
16295
|
+
if (!nativeRef)
|
|
16296
|
+
return {
|
|
16297
|
+
ok: false,
|
|
16298
|
+
error: unavailable("Cannot recover a Session without confirmed native identity", false)
|
|
16299
|
+
};
|
|
16300
|
+
const result = parseHarnessResult(await (connection === previous ? this.#request("session.reopen", {}) : connection.request("adapter.open", {
|
|
16301
|
+
kind: "resume",
|
|
16302
|
+
cwd: this.openInput.cwd,
|
|
16303
|
+
nativeRef,
|
|
16304
|
+
...this.openInput.environment ? { environment: this.openInput.environment } : {},
|
|
16305
|
+
...this.#state.effectiveModel ? { model: this.#state.effectiveModel } : {},
|
|
16306
|
+
...this.#state.effectiveThinkingOptionId ? { thinkingOptionId: this.#state.effectiveThinkingOptionId } : {},
|
|
16307
|
+
...this.#state.effectivePermissionModeId ? { permissionModeId: this.#state.effectivePermissionModeId } : {}
|
|
16308
|
+
})));
|
|
16309
|
+
if (!result.ok)
|
|
16310
|
+
return result;
|
|
16311
|
+
const metadata = parseSessionMetadata(result.value), observed = metadata.initialState.nativeRef;
|
|
16312
|
+
if (this.#closed || connection.closed || !observed || observed.harnessId !== nativeRef.harnessId || observed.nativeSessionId !== nativeRef.nativeSessionId || observed.formatVersion !== nativeRef.formatVersion) {
|
|
16313
|
+
await connection.request("session.close", {
|
|
16314
|
+
sessionId: metadata.sessionId,
|
|
16315
|
+
sessionGeneration: metadata.sessionGeneration
|
|
16316
|
+
}).catch(() => {
|
|
16317
|
+
});
|
|
16318
|
+
return {
|
|
16319
|
+
ok: false,
|
|
16320
|
+
error: unavailable("Broker recovery did not preserve the live native Session identity", false)
|
|
16321
|
+
};
|
|
16322
|
+
}
|
|
16323
|
+
previous.unregister(this.sessionId);
|
|
16324
|
+
this.#connection = connection;
|
|
16325
|
+
this.#metadata = metadata;
|
|
16326
|
+
this.#state = structuredClone(metadata.initialState);
|
|
16327
|
+
connection.register(this);
|
|
16328
|
+
this.#faulted = false;
|
|
16329
|
+
this.#channel.emit({
|
|
16330
|
+
kind: "event",
|
|
16331
|
+
event: { type: "session.state.changed", state: structuredClone(this.#state) }
|
|
16332
|
+
});
|
|
16333
|
+
return { ok: true, value: void 0 };
|
|
16225
16334
|
}
|
|
16226
16335
|
#request(method, extra) {
|
|
16227
16336
|
return this.#connection.request(method, {
|
|
@@ -16232,9 +16341,11 @@ var BrokeredHarnessSession = class {
|
|
|
16232
16341
|
}
|
|
16233
16342
|
};
|
|
16234
16343
|
var BrokeredHarnessAdapter = class {
|
|
16344
|
+
#sessions = /* @__PURE__ */ new Set();
|
|
16235
16345
|
commandCatalog;
|
|
16236
|
-
harnessId
|
|
16346
|
+
harnessId;
|
|
16237
16347
|
#descriptorPath;
|
|
16348
|
+
#forwardEnvironment;
|
|
16238
16349
|
#connection = null;
|
|
16239
16350
|
#closed = false;
|
|
16240
16351
|
subagents = {
|
|
@@ -16250,9 +16361,11 @@ var BrokeredHarnessAdapter = class {
|
|
|
16250
16361
|
}
|
|
16251
16362
|
};
|
|
16252
16363
|
constructor(input = {}) {
|
|
16364
|
+
this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
|
|
16365
|
+
this.#forwardEnvironment = input.forwardDelegationEnvironment === true;
|
|
16253
16366
|
if (input.commandCatalog)
|
|
16254
16367
|
this.commandCatalog = input.commandCatalog;
|
|
16255
|
-
this.#descriptorPath = input.descriptorPath ?? defaultHarnessBrokerDescriptorPath(input.environment);
|
|
16368
|
+
this.#descriptorPath = input.descriptorPath ?? defaultHarnessBrokerDescriptorPath(input.environment, this.harnessId);
|
|
16256
16369
|
}
|
|
16257
16370
|
async inspectAccount() {
|
|
16258
16371
|
if (this.#closed)
|
|
@@ -16266,7 +16379,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
16266
16379
|
}
|
|
16267
16380
|
async inspect(input = {}) {
|
|
16268
16381
|
if (this.#closed)
|
|
16269
|
-
return failedInspection("
|
|
16382
|
+
return failedInspection("Aqua Harness broker adapter is closed");
|
|
16270
16383
|
try {
|
|
16271
16384
|
return harnessInspectionSchema.parse(await (await this.#connect()).request("adapter.inspect", input));
|
|
16272
16385
|
} catch (error52) {
|
|
@@ -16276,18 +16389,33 @@ var BrokeredHarnessAdapter = class {
|
|
|
16276
16389
|
}
|
|
16277
16390
|
async open(input) {
|
|
16278
16391
|
if (this.#closed)
|
|
16279
|
-
return { ok: false, error: unavailable("
|
|
16392
|
+
return { ok: false, error: unavailable("Aqua Harness broker adapter is closed", false) };
|
|
16393
|
+
let connection;
|
|
16280
16394
|
try {
|
|
16281
16395
|
const safeInput = { ...input };
|
|
16282
16396
|
delete safeInput.environment;
|
|
16283
|
-
|
|
16397
|
+
if (this.#forwardEnvironment && input.environment) {
|
|
16398
|
+
const allowed2 = [
|
|
16399
|
+
"CODEXHOST_CLI_PATH",
|
|
16400
|
+
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
16401
|
+
"CODEXHOST_RUNTIME_TOKEN",
|
|
16402
|
+
"CODEXHOST_THREAD_ID"
|
|
16403
|
+
];
|
|
16404
|
+
const environment = Object.fromEntries(Object.entries(input.environment).filter(([key, value]) => allowed2.includes(key) && value !== void 0));
|
|
16405
|
+
if (Object.keys(environment).length)
|
|
16406
|
+
safeInput.environment = environment;
|
|
16407
|
+
}
|
|
16408
|
+
connection = await this.#connect();
|
|
16409
|
+
const result = parseHarnessResult(await connection.request("adapter.open", safeInput));
|
|
16284
16410
|
if (!result.ok)
|
|
16285
16411
|
return result;
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16412
|
+
const session = new BrokeredHarnessSession(connection, parseSessionMetadata(result.value), this.harnessId, safeInput, () => this.#connect(), () => {
|
|
16413
|
+
this.#sessions.delete(session);
|
|
16414
|
+
});
|
|
16415
|
+
this.#sessions.add(session);
|
|
16416
|
+
return { ok: true, value: session };
|
|
16290
16417
|
} catch (error52) {
|
|
16418
|
+
connection?.close();
|
|
16291
16419
|
this.#connection = null;
|
|
16292
16420
|
return {
|
|
16293
16421
|
ok: false,
|
|
@@ -16297,13 +16425,29 @@ var BrokeredHarnessAdapter = class {
|
|
|
16297
16425
|
}
|
|
16298
16426
|
async close() {
|
|
16299
16427
|
this.#closed = true;
|
|
16428
|
+
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
16429
|
+
this.#sessions.clear();
|
|
16300
16430
|
const connection = await this.#connection?.catch(() => null);
|
|
16301
|
-
connection?.
|
|
16431
|
+
await connection?.dispose();
|
|
16302
16432
|
this.#connection = null;
|
|
16303
16433
|
}
|
|
16304
16434
|
#connect() {
|
|
16305
|
-
if (
|
|
16306
|
-
|
|
16435
|
+
if (this.#closed)
|
|
16436
|
+
return Promise.reject(new Error("Aqua Harness broker adapter is closed"));
|
|
16437
|
+
if (!this.#connection) {
|
|
16438
|
+
const pending = BrokerConnection.connect(this.#descriptorPath, this.harnessId).then((connection) => {
|
|
16439
|
+
connection.onClose(() => {
|
|
16440
|
+
if (this.#connection === pending)
|
|
16441
|
+
this.#connection = null;
|
|
16442
|
+
});
|
|
16443
|
+
return connection;
|
|
16444
|
+
}).catch((error52) => {
|
|
16445
|
+
if (this.#connection === pending)
|
|
16446
|
+
this.#connection = null;
|
|
16447
|
+
throw error52;
|
|
16448
|
+
});
|
|
16449
|
+
this.#connection = pending;
|
|
16450
|
+
}
|
|
16307
16451
|
return this.#connection;
|
|
16308
16452
|
}
|
|
16309
16453
|
};
|
|
@@ -44358,6 +44502,16 @@ function allowed(toolUseId, input, suggestions) {
|
|
|
44358
44502
|
...suggestions ? { updatedPermissions: suggestions } : {}
|
|
44359
44503
|
};
|
|
44360
44504
|
}
|
|
44505
|
+
function canDeliverSettlementImmediately(event, pendingEvents) {
|
|
44506
|
+
if (event.type !== "subagent.settled")
|
|
44507
|
+
return false;
|
|
44508
|
+
return !pendingEvents.some((pending) => {
|
|
44509
|
+
if (pending.type !== "subagent.started" && pending.type !== "subagent.updated" && pending.type !== "subagent.completed") {
|
|
44510
|
+
return false;
|
|
44511
|
+
}
|
|
44512
|
+
return event.callId !== void 0 && pending.callId === event.callId || pending.nativeSubagentId === event.nativeSubagentId;
|
|
44513
|
+
});
|
|
44514
|
+
}
|
|
44361
44515
|
var ClaudeSdkTransport = class {
|
|
44362
44516
|
sessionId;
|
|
44363
44517
|
#children = [];
|
|
@@ -44379,6 +44533,7 @@ var ClaudeSdkTransport = class {
|
|
|
44379
44533
|
#autonomous = null;
|
|
44380
44534
|
#autonomousTurnHandler = null;
|
|
44381
44535
|
#idleHandler = null;
|
|
44536
|
+
#threadEventHandler = null;
|
|
44382
44537
|
#idleLive = false;
|
|
44383
44538
|
#idleAccumulator = null;
|
|
44384
44539
|
#closePromise = null;
|
|
@@ -44411,6 +44566,9 @@ var ClaudeSdkTransport = class {
|
|
|
44411
44566
|
setIdleTurnHandler(handler) {
|
|
44412
44567
|
this.#idleHandler = handler;
|
|
44413
44568
|
}
|
|
44569
|
+
setThreadEventHandler(handler) {
|
|
44570
|
+
this.#threadEventHandler = handler;
|
|
44571
|
+
}
|
|
44414
44572
|
setIdleLive(live) {
|
|
44415
44573
|
this.#idleLive = live;
|
|
44416
44574
|
if (!live)
|
|
@@ -44797,7 +44955,13 @@ var ClaudeSdkTransport = class {
|
|
|
44797
44955
|
autonomous.nativeTurnKey = message.uuid;
|
|
44798
44956
|
}
|
|
44799
44957
|
const interpreted = autonomous.accumulator.consume(message);
|
|
44800
|
-
|
|
44958
|
+
for (const event of interpreted.events) {
|
|
44959
|
+
if (this.#threadEventHandler && canDeliverSettlementImmediately(event, autonomous.events)) {
|
|
44960
|
+
this.#threadEventHandler(event);
|
|
44961
|
+
continue;
|
|
44962
|
+
}
|
|
44963
|
+
autonomous.events.push(event);
|
|
44964
|
+
}
|
|
44801
44965
|
if (interpreted.terminal) {
|
|
44802
44966
|
this.#autonomous = null;
|
|
44803
44967
|
const nativeTurnKey = autonomous.nativeTurnKey ?? `autonomous-${Date.now()}`;
|
|
@@ -46430,11 +46594,21 @@ var ClaudeHarnessSession = class {
|
|
|
46430
46594
|
});
|
|
46431
46595
|
this.#transport = transport;
|
|
46432
46596
|
transport.setAutonomousTurnHandler((turn) => this.#handleAutonomousTurn(turn));
|
|
46597
|
+
transport.setThreadEventHandler((event) => {
|
|
46598
|
+
if (event.type === "subagent.settled") {
|
|
46599
|
+
this.#settleBackgroundSubagent(event.status, event.nativeSubagentId, event.callId, event.resultSummary);
|
|
46600
|
+
}
|
|
46601
|
+
});
|
|
46433
46602
|
transport.setIdleTurnHandler({
|
|
46434
46603
|
onEvent: (event) => {
|
|
46435
46604
|
const active = this.#active;
|
|
46436
|
-
if (active)
|
|
46605
|
+
if (active) {
|
|
46437
46606
|
this.#handleTurnEvent(active, event);
|
|
46607
|
+
return;
|
|
46608
|
+
}
|
|
46609
|
+
if (event.type === "subagent.settled") {
|
|
46610
|
+
this.#settleBackgroundSubagent(event.status, event.nativeSubagentId, event.callId, event.resultSummary);
|
|
46611
|
+
}
|
|
46438
46612
|
},
|
|
46439
46613
|
onTerminal: (result) => {
|
|
46440
46614
|
const active = this.#active;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"><g clip-path="url(#clip0_4958_10776)"><rect x="-0.00146484" width="40" height="40" rx="8.63158" fill="#6C4DFF"></rect><path d="M30.5918 3.12856C30.984 2.77679 31.0078 2.7632 31.2955 2.74593C31.7615 2.71193 32.1882 2.93586 32.9147 3.59728C34.6119 5.13959 36.9755 8.30995 38.4449 11.0177L39.0125 12.0691L39.8143 12.4677C40.5885 12.8589 41.8587 13.6611 42.389 14.0913C42.6286 14.2894 42.6626 14.2934 42.912 14.1964C44.0375 13.7583 45.6494 14.3393 47.0714 15.7033C48.3516 16.9303 49.5781 19.0269 50.0478 20.7767C50.1164 21.0582 50.2074 21.6636 50.2405 22.1144C50.3477 23.6973 49.84 24.9617 48.8624 25.5341C48.6628 25.6493 48.6492 25.6807 48.6548 26.1783C48.6998 28.5492 48.0606 30.9165 46.7768 33.2244C45.3276 35.8156 42.7467 38.496 39.2544 41.0214C37.3789 42.3862 32.9421 44.9717 30.9361 45.8792C26.1304 48.0428 22.278 48.8718 18.9316 48.4618C16.9356 48.22 14.6761 47.4417 13.3392 46.5373C12.9873 46.294 12.9318 46.2791 12.6629 46.3561C11.2318 46.7671 9.35752 45.9219 7.76528 44.1544C7.13027 43.448 6.10508 41.7136 5.77273 40.7853C5.00409 38.6128 5.15721 36.6516 6.18105 35.4808C6.44522 35.1797 6.4538 35.1667 6.39603 34.6598C6.30065 33.8298 6.25703 32.6017 6.30061 31.809L6.33535 31.0683L5.22371 29.1019C3.50212 26.0386 2.40857 23.4663 1.98661 21.501C1.76389 20.4233 1.77734 19.9446 2.05091 19.5908C2.21741 19.3773 2.76347 19.1568 3.42155 19.0352C5.07869 18.7442 8.69327 19.0065 12.7142 19.7165L13.1316 19.789L14.0497 18.977C15.5733 17.6274 16.5858 16.8705 18.4518 15.707C20.3967 14.4901 22.5922 13.4895 25.064 12.6968L25.8564 12.4423L26.2926 11.2974C27.8535 7.17701 29.452 4.13917 30.5918 3.12856ZM17.5169 24.2439C15.7528 25.2625 14.8705 25.7716 14.2223 26.3423C11.5975 28.6536 10.6172 32.3151 11.7346 35.6292C12.0106 36.4475 12.5193 37.3301 13.5378 39.0941C14.5563 40.8582 15.0662 41.7401 15.637 42.3882C17.9483 45.0128 21.6091 45.9938 24.923 44.8764C25.7414 44.6004 26.6233 44.0909 28.3875 43.0724L38.5362 37.213C40.3004 36.1945 41.1826 35.6854 41.8308 35.1147C44.4555 32.8034 45.4363 29.1426 44.319 25.8286C44.043 25.0103 43.5343 24.1277 42.5158 22.3637C41.4974 20.5997 40.9873 19.7177 40.4166 19.0696C38.1053 16.4448 34.4441 15.4631 31.1301 16.5806C30.3118 16.8565 29.4297 17.3661 27.6656 18.3846L17.5169 24.2439Z" fill="white"></path><rect x="18.4944" y="31.334" width="4.00904" height="8.32646" rx="2.00452" transform="rotate(-30 18.4944 31.334)" fill="white"></rect><rect x="29.311" y="25.0898" width="4.00904" height="8.32646" rx="2.00452" transform="rotate(-30 29.311 25.0898)" fill="white"></rect></g><defs><clipPath id="clip0_4958_10776"><rect x="-0.00146484" width="40" height="40" rx="8.63158" fill="white"></rect></clipPath></defs></svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifestVersion": 1,
|
|
3
|
+
"id": "codebuddy",
|
|
4
|
+
"name": "CodeBuddy",
|
|
5
|
+
"version": "0.0.0",
|
|
6
|
+
"links": {
|
|
7
|
+
"documentation": "https://www.codebuddy.ai/docs/zh/cli/acp",
|
|
8
|
+
"installation": "https://www.codebuddy.ai/docs/zh/cli/overview"
|
|
9
|
+
},
|
|
10
|
+
"adapterApiVersion": 1,
|
|
11
|
+
"entry": "plugin.mjs",
|
|
12
|
+
"icon": "./assets/icon.svg"
|
|
13
|
+
}
|