@liberseek/boft-cli-win32-arm64 0.6.7 → 0.6.8
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 +18 -14
- package/app/host-runtime.mjs +672 -363
- package/app/plugins/antigravity/plugin.mjs +45 -198
- package/app/plugins/claude-code/plugin.mjs +245 -58
- package/app/plugins/codebuddy/assets/icon.svg +1 -0
- package/app/plugins/codebuddy/manifest.json +13 -0
- package/app/plugins/codebuddy/plugin.mjs +23179 -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 +22713 -0
- package/app/plugins/enabled.json +3 -1
- package/app/plugins/opencode/plugin.mjs +24 -5
- package/app/plugins/pi/plugin.mjs +0 -12
- package/app/renderer-extension.js +264 -98
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/licenses/Agent-Client-Protocol-SDK-LICENSE.txt +191 -0
- package/package.json +1 -1
|
@@ -15645,7 +15645,7 @@ var harnessBrokerServerFrameSchema = external_exports.union([
|
|
|
15645
15645
|
var harnessBrokerDescriptorSchema = external_exports.object({
|
|
15646
15646
|
schemaVersion: external_exports.literal(1),
|
|
15647
15647
|
protocolVersion: external_exports.literal(HARNESS_BROKER_PROTOCOL_VERSION),
|
|
15648
|
-
harnessId:
|
|
15648
|
+
harnessId: harnessPluginIdSchema,
|
|
15649
15649
|
generation: external_exports.string().uuid(),
|
|
15650
15650
|
ownerPid: external_exports.number().int().positive(),
|
|
15651
15651
|
socketPath: external_exports.string().min(1).max(512),
|
|
@@ -15700,22 +15700,34 @@ function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
|
15700
15700
|
const home = environment.HOME || os.homedir();
|
|
15701
15701
|
return path.join(home, ".codexhost", "harness-broker");
|
|
15702
15702
|
}
|
|
15703
|
-
function defaultHarnessBrokerDescriptorPath(environment = process.env) {
|
|
15703
|
+
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
15704
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
15705
|
+
if (harnessId !== "claude-code")
|
|
15706
|
+
return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
15704
15707
|
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
15705
15708
|
}
|
|
15706
15709
|
|
|
15707
15710
|
// ../../harness-broker/dist/validation.js
|
|
15708
15711
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
15712
|
+
var brokerEnvironmentSchema = external_exports.object({
|
|
15713
|
+
CODEXHOST_CLI_PATH: external_exports.string().max(16384).optional(),
|
|
15714
|
+
CODEXHOST_RUNTIME_ENDPOINT: external_exports.string().max(16384).optional(),
|
|
15715
|
+
CODEXHOST_RUNTIME_TOKEN: external_exports.string().max(16384).optional(),
|
|
15716
|
+
CODEXHOST_THREAD_ID: external_exports.string().max(256).optional()
|
|
15717
|
+
}).strict();
|
|
15709
15718
|
var createSchema = external_exports.object({
|
|
15710
15719
|
kind: external_exports.literal("create"),
|
|
15711
15720
|
cwd: cwdSchema,
|
|
15712
15721
|
executionPolicy: external_exports.enum(["default", "unattended-full-access"]).optional(),
|
|
15722
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15713
15723
|
model: harnessModelRefSchema.optional(),
|
|
15714
15724
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15715
15725
|
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15716
15726
|
}).strict();
|
|
15717
15727
|
var resumeSchema = external_exports.object({
|
|
15718
15728
|
kind: external_exports.literal("resume"),
|
|
15729
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15730
|
+
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15719
15731
|
model: harnessModelRefSchema.optional(),
|
|
15720
15732
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15721
15733
|
nativeRef: nativeSessionRefSchema,
|
|
@@ -15724,12 +15736,14 @@ var resumeSchema = external_exports.object({
|
|
|
15724
15736
|
}).strict();
|
|
15725
15737
|
var forkSchema = external_exports.object({
|
|
15726
15738
|
kind: external_exports.literal("fork"),
|
|
15739
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15727
15740
|
sourceRef: nativeSessionRefSchema,
|
|
15728
15741
|
checkpoint: nativeCheckpointRefSchema,
|
|
15729
15742
|
cwd: cwdSchema
|
|
15730
15743
|
}).strict();
|
|
15731
15744
|
var rollbackSchema = external_exports.object({
|
|
15732
15745
|
kind: external_exports.literal("rollbackLastTurn"),
|
|
15746
|
+
environment: brokerEnvironmentSchema.optional(),
|
|
15733
15747
|
model: harnessModelRefSchema.optional(),
|
|
15734
15748
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15735
15749
|
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
@@ -15990,37 +16004,43 @@ function parseSessionMetadata(value) {
|
|
|
15990
16004
|
async function readDescriptor(descriptorPath) {
|
|
15991
16005
|
const metadata = await lstat(descriptorPath);
|
|
15992
16006
|
if (metadata.isSymbolicLink())
|
|
15993
|
-
throw new Error("
|
|
16007
|
+
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
15994
16008
|
if (!metadata.isFile())
|
|
15995
|
-
throw new Error("
|
|
16009
|
+
throw new Error("Aqua Harness broker descriptor is not a file");
|
|
15996
16010
|
if (process.platform !== "win32") {
|
|
15997
16011
|
if ((metadata.mode & 63) !== 0)
|
|
15998
|
-
throw new Error("
|
|
16012
|
+
throw new Error("Aqua Harness broker descriptor is not owner-only");
|
|
15999
16013
|
if (process.getuid && metadata.uid !== process.getuid()) {
|
|
16000
|
-
throw new Error("
|
|
16014
|
+
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
16001
16015
|
}
|
|
16002
16016
|
}
|
|
16003
16017
|
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile(descriptorPath, "utf8")));
|
|
16004
16018
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
16005
|
-
throw new Error("
|
|
16019
|
+
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
16006
16020
|
}
|
|
16007
16021
|
if (process.platform !== "win32") {
|
|
16008
16022
|
const socket = await lstat(descriptor.socketPath);
|
|
16009
16023
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
16010
|
-
throw new Error("
|
|
16024
|
+
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
16011
16025
|
}
|
|
16012
16026
|
if ((socket.mode & 63) !== 0 || process.getuid && socket.uid !== process.getuid()) {
|
|
16013
|
-
throw new Error("
|
|
16027
|
+
throw new Error("Aqua Harness broker endpoint is not owner-only");
|
|
16014
16028
|
}
|
|
16015
16029
|
}
|
|
16016
16030
|
try {
|
|
16017
16031
|
process.kill(descriptor.ownerPid, 0);
|
|
16018
16032
|
} catch {
|
|
16019
|
-
throw new Error("
|
|
16033
|
+
throw new Error("Aqua Harness broker owner process is unavailable");
|
|
16020
16034
|
}
|
|
16021
16035
|
return descriptor;
|
|
16022
16036
|
}
|
|
16023
16037
|
var BrokerConnection = class _BrokerConnection {
|
|
16038
|
+
#onClose;
|
|
16039
|
+
onClose(callback) {
|
|
16040
|
+
this.#onClose = callback;
|
|
16041
|
+
if (this.#closed)
|
|
16042
|
+
callback();
|
|
16043
|
+
}
|
|
16024
16044
|
#descriptor;
|
|
16025
16045
|
#socket;
|
|
16026
16046
|
#pending = /* @__PURE__ */ new Map();
|
|
@@ -16033,14 +16053,16 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16033
16053
|
this.#descriptor = descriptor;
|
|
16034
16054
|
this.#socket = socket;
|
|
16035
16055
|
consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error52) => this.#fail(error52));
|
|
16036
|
-
socket.once("close", () => this.#fail(new Error("
|
|
16056
|
+
socket.once("close", () => this.#fail(new Error("Aqua Harness broker connection closed")));
|
|
16037
16057
|
socket.once("error", (error52) => this.#fail(error52));
|
|
16038
16058
|
}
|
|
16039
|
-
static async connect(descriptorPath) {
|
|
16059
|
+
static async connect(descriptorPath, harnessId) {
|
|
16040
16060
|
const descriptor = await readDescriptor(descriptorPath);
|
|
16061
|
+
if (descriptor.harnessId !== harnessId)
|
|
16062
|
+
throw new Error("Aqua broker belongs to another Harness");
|
|
16041
16063
|
const socket = net.createConnection(descriptor.socketPath);
|
|
16042
16064
|
await new Promise((resolve2, reject) => {
|
|
16043
|
-
const timeout = setTimeout(() => reject(new Error("Timed out connecting to
|
|
16065
|
+
const timeout = setTimeout(() => reject(new Error("Timed out connecting to Aqua Harness broker")), HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
16044
16066
|
socket.once("connect", () => {
|
|
16045
16067
|
clearTimeout(timeout);
|
|
16046
16068
|
resolve2();
|
|
@@ -16067,29 +16089,38 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16067
16089
|
const id = "__hello__";
|
|
16068
16090
|
const timeout = setTimeout(() => {
|
|
16069
16091
|
this.#pending.delete(id);
|
|
16070
|
-
reject(new Error("
|
|
16092
|
+
reject(new Error("Aqua Harness broker authentication timed out"));
|
|
16071
16093
|
}, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
16072
16094
|
this.#pending.set(id, { resolve: () => resolve2(), reject, timeout });
|
|
16073
16095
|
});
|
|
16074
16096
|
}
|
|
16075
16097
|
register(session) {
|
|
16098
|
+
if (this.#closed)
|
|
16099
|
+
throw new Error("Aqua Harness broker connection closed while opening Session");
|
|
16076
16100
|
this.#sessions.set(session.sessionId, session);
|
|
16077
16101
|
}
|
|
16102
|
+
get closed() {
|
|
16103
|
+
return this.#closed;
|
|
16104
|
+
}
|
|
16078
16105
|
unregister(sessionId) {
|
|
16079
16106
|
this.#sessions.delete(sessionId);
|
|
16080
16107
|
}
|
|
16108
|
+
async dispose() {
|
|
16109
|
+
await Promise.allSettled([...this.#sessions.values()].map((session) => session.close()));
|
|
16110
|
+
this.close();
|
|
16111
|
+
}
|
|
16081
16112
|
async request(method, params) {
|
|
16082
16113
|
if (this.#closed)
|
|
16083
|
-
throw new Error("
|
|
16114
|
+
throw new Error("Aqua Harness broker connection is closed");
|
|
16084
16115
|
if (this.#pending.size >= HARNESS_BROKER_MAX_PENDING_REQUESTS) {
|
|
16085
|
-
throw new Error("
|
|
16116
|
+
throw new Error("Aqua Harness broker request limit exceeded");
|
|
16086
16117
|
}
|
|
16087
16118
|
this.#inputSequence += 1;
|
|
16088
16119
|
const id = randomUUID();
|
|
16089
16120
|
const response = new Promise((resolve2, reject) => {
|
|
16090
16121
|
const timeout = setTimeout(() => {
|
|
16091
16122
|
this.#pending.delete(id);
|
|
16092
|
-
reject(new Error(`
|
|
16123
|
+
reject(new Error(`Aqua Harness broker ${method} timed out`));
|
|
16093
16124
|
}, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
16094
16125
|
this.#pending.set(id, { resolve: resolve2, reject, timeout });
|
|
16095
16126
|
});
|
|
@@ -16109,12 +16140,14 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16109
16140
|
return;
|
|
16110
16141
|
this.#closed = true;
|
|
16111
16142
|
this.#socket.destroy();
|
|
16112
|
-
this.#fail(new Error("
|
|
16143
|
+
this.#fail(new Error("Aqua Harness broker connection closed"));
|
|
16113
16144
|
}
|
|
16114
16145
|
#frame(raw) {
|
|
16146
|
+
if (this.#closed)
|
|
16147
|
+
return;
|
|
16115
16148
|
const frame = harnessBrokerServerFrameSchema.parse(raw);
|
|
16116
16149
|
if (frame.generation !== this.#descriptor.generation || frame.sequence !== this.#outputSequence + 1) {
|
|
16117
|
-
this.#fail(new Error("
|
|
16150
|
+
this.#fail(new Error("Aqua Harness broker response generation or sequence is invalid"));
|
|
16118
16151
|
return;
|
|
16119
16152
|
}
|
|
16120
16153
|
this.#outputSequence = frame.sequence;
|
|
@@ -16136,7 +16169,7 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16136
16169
|
}
|
|
16137
16170
|
const pending = this.#pending.get(frame.id);
|
|
16138
16171
|
if (!pending) {
|
|
16139
|
-
this.#fail(new Error("
|
|
16172
|
+
this.#fail(new Error("Aqua Harness broker returned an unknown response ID"));
|
|
16140
16173
|
return;
|
|
16141
16174
|
}
|
|
16142
16175
|
clearTimeout(pending.timeout);
|
|
@@ -16152,6 +16185,8 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16152
16185
|
this.#failed = true;
|
|
16153
16186
|
if (!this.#closed)
|
|
16154
16187
|
this.#closed = true;
|
|
16188
|
+
this.#socket.destroy();
|
|
16189
|
+
this.#onClose?.();
|
|
16155
16190
|
for (const pending of this.#pending.values()) {
|
|
16156
16191
|
clearTimeout(pending.timeout);
|
|
16157
16192
|
pending.reject(error52);
|
|
@@ -16162,7 +16197,10 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
16162
16197
|
}
|
|
16163
16198
|
};
|
|
16164
16199
|
var BrokeredHarnessSession = class {
|
|
16165
|
-
|
|
16200
|
+
openInput;
|
|
16201
|
+
reconnect;
|
|
16202
|
+
onClose;
|
|
16203
|
+
harnessId;
|
|
16166
16204
|
outputs;
|
|
16167
16205
|
#channel = new HarnessOutputChannel();
|
|
16168
16206
|
#connection;
|
|
@@ -16170,9 +16208,18 @@ var BrokeredHarnessSession = class {
|
|
|
16170
16208
|
#metadata;
|
|
16171
16209
|
#faulted = false;
|
|
16172
16210
|
#closed = false;
|
|
16173
|
-
|
|
16211
|
+
#state;
|
|
16212
|
+
#recovery;
|
|
16213
|
+
constructor(connection, metadata, harnessId, openInput, reconnect, onClose) {
|
|
16214
|
+
this.openInput = openInput;
|
|
16215
|
+
this.reconnect = reconnect;
|
|
16216
|
+
this.onClose = onClose;
|
|
16217
|
+
this.harnessId = harnessId;
|
|
16218
|
+
if (metadata.initialState.nativeRef && metadata.initialState.nativeRef.harnessId !== harnessId)
|
|
16219
|
+
throw new Error("Broker Session identity belongs to another Harness");
|
|
16174
16220
|
this.#connection = connection;
|
|
16175
16221
|
this.#metadata = metadata;
|
|
16222
|
+
this.#state = structuredClone(metadata.initialState);
|
|
16176
16223
|
this.outputs = this.#channel.outputs;
|
|
16177
16224
|
if (metadata.commands) {
|
|
16178
16225
|
this.commands = {
|
|
@@ -16216,6 +16263,10 @@ var BrokeredHarnessSession = class {
|
|
|
16216
16263
|
if (this.#closed || generation !== this.#metadata.sessionGeneration)
|
|
16217
16264
|
return;
|
|
16218
16265
|
const value = harnessOutputSchema.parse(output);
|
|
16266
|
+
if (value.kind === "event" && value.event.type === "session.state.changed") {
|
|
16267
|
+
const nativeRef = value.event.state.nativeRef ?? this.#state.nativeRef;
|
|
16268
|
+
this.#state = { ...structuredClone(value.event.state), ...nativeRef ? { nativeRef } : {} };
|
|
16269
|
+
}
|
|
16219
16270
|
if (value.kind === "event" && value.event.type === "session.faulted" || isAuthenticationTerminal(value)) {
|
|
16220
16271
|
this.#faulted = true;
|
|
16221
16272
|
}
|
|
@@ -16234,6 +16285,13 @@ var BrokeredHarnessSession = class {
|
|
|
16234
16285
|
await this.#request("session.refreshUsage", {});
|
|
16235
16286
|
}
|
|
16236
16287
|
async readSnapshot() {
|
|
16288
|
+
if (this.#closed)
|
|
16289
|
+
return { ok: false, error: unavailable("Aqua Harness broker Session is closed", false) };
|
|
16290
|
+
if (this.#connection.closed) {
|
|
16291
|
+
const recovered = await this.#ensureRecovery();
|
|
16292
|
+
if (!recovered.ok)
|
|
16293
|
+
return recovered;
|
|
16294
|
+
}
|
|
16237
16295
|
try {
|
|
16238
16296
|
return parseHarnessResult(await this.#request("session.readSnapshot", {}));
|
|
16239
16297
|
} catch (error52) {
|
|
@@ -16245,20 +16303,11 @@ var BrokeredHarnessSession = class {
|
|
|
16245
16303
|
}
|
|
16246
16304
|
async execute(command) {
|
|
16247
16305
|
if (this.#closed)
|
|
16248
|
-
return { ok: false, error: unavailable("
|
|
16306
|
+
return { ok: false, error: unavailable("Aqua Harness broker Session is closed", false) };
|
|
16249
16307
|
if (this.#faulted && command.type === "turn.start") {
|
|
16250
|
-
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
return reopened;
|
|
16254
|
-
this.#metadata = parseSessionMetadata(reopened.value);
|
|
16255
|
-
this.#faulted = false;
|
|
16256
|
-
} catch (error52) {
|
|
16257
|
-
return {
|
|
16258
|
-
ok: false,
|
|
16259
|
-
error: unavailable(error52 instanceof Error ? error52.message : String(error52))
|
|
16260
|
-
};
|
|
16261
|
-
}
|
|
16308
|
+
const recovered = await this.#ensureRecovery();
|
|
16309
|
+
if (!recovered.ok)
|
|
16310
|
+
return recovered;
|
|
16262
16311
|
}
|
|
16263
16312
|
try {
|
|
16264
16313
|
return parseHarnessResult(await this.#request("session.execute", { command }));
|
|
@@ -16273,9 +16322,69 @@ var BrokeredHarnessSession = class {
|
|
|
16273
16322
|
if (this.#closed)
|
|
16274
16323
|
return;
|
|
16275
16324
|
this.#closed = true;
|
|
16325
|
+
await this.#recovery?.catch(() => {
|
|
16326
|
+
});
|
|
16276
16327
|
this.#connection.unregister(this.sessionId);
|
|
16277
16328
|
await this.#request("session.close", {}).catch(() => void 0);
|
|
16278
16329
|
this.#channel.end();
|
|
16330
|
+
this.onClose();
|
|
16331
|
+
}
|
|
16332
|
+
async #ensureRecovery() {
|
|
16333
|
+
try {
|
|
16334
|
+
this.#recovery ??= this.#recover().finally(() => {
|
|
16335
|
+
this.#recovery = void 0;
|
|
16336
|
+
});
|
|
16337
|
+
return await this.#recovery;
|
|
16338
|
+
} catch (error52) {
|
|
16339
|
+
return {
|
|
16340
|
+
ok: false,
|
|
16341
|
+
error: unavailable(error52 instanceof Error ? error52.message : String(error52))
|
|
16342
|
+
};
|
|
16343
|
+
}
|
|
16344
|
+
}
|
|
16345
|
+
async #recover() {
|
|
16346
|
+
const previous = this.#connection;
|
|
16347
|
+
const connection = previous.closed ? await this.reconnect() : previous;
|
|
16348
|
+
const nativeRef = this.#state.nativeRef;
|
|
16349
|
+
if (!nativeRef)
|
|
16350
|
+
return {
|
|
16351
|
+
ok: false,
|
|
16352
|
+
error: unavailable("Cannot recover a Session without confirmed native identity", false)
|
|
16353
|
+
};
|
|
16354
|
+
const result = parseHarnessResult(await (connection === previous ? this.#request("session.reopen", {}) : connection.request("adapter.open", {
|
|
16355
|
+
kind: "resume",
|
|
16356
|
+
cwd: this.openInput.cwd,
|
|
16357
|
+
nativeRef,
|
|
16358
|
+
...this.openInput.environment ? { environment: this.openInput.environment } : {},
|
|
16359
|
+
...this.#state.effectiveModel ? { model: this.#state.effectiveModel } : {},
|
|
16360
|
+
...this.#state.effectiveThinkingOptionId ? { thinkingOptionId: this.#state.effectiveThinkingOptionId } : {},
|
|
16361
|
+
...this.#state.effectivePermissionModeId ? { permissionModeId: this.#state.effectivePermissionModeId } : {}
|
|
16362
|
+
})));
|
|
16363
|
+
if (!result.ok)
|
|
16364
|
+
return result;
|
|
16365
|
+
const metadata = parseSessionMetadata(result.value), observed = metadata.initialState.nativeRef;
|
|
16366
|
+
if (this.#closed || connection.closed || !observed || observed.harnessId !== nativeRef.harnessId || observed.nativeSessionId !== nativeRef.nativeSessionId || observed.formatVersion !== nativeRef.formatVersion) {
|
|
16367
|
+
await connection.request("session.close", {
|
|
16368
|
+
sessionId: metadata.sessionId,
|
|
16369
|
+
sessionGeneration: metadata.sessionGeneration
|
|
16370
|
+
}).catch(() => {
|
|
16371
|
+
});
|
|
16372
|
+
return {
|
|
16373
|
+
ok: false,
|
|
16374
|
+
error: unavailable("Broker recovery did not preserve the live native Session identity", false)
|
|
16375
|
+
};
|
|
16376
|
+
}
|
|
16377
|
+
previous.unregister(this.sessionId);
|
|
16378
|
+
this.#connection = connection;
|
|
16379
|
+
this.#metadata = metadata;
|
|
16380
|
+
this.#state = structuredClone(metadata.initialState);
|
|
16381
|
+
connection.register(this);
|
|
16382
|
+
this.#faulted = false;
|
|
16383
|
+
this.#channel.emit({
|
|
16384
|
+
kind: "event",
|
|
16385
|
+
event: { type: "session.state.changed", state: structuredClone(this.#state) }
|
|
16386
|
+
});
|
|
16387
|
+
return { ok: true, value: void 0 };
|
|
16279
16388
|
}
|
|
16280
16389
|
#request(method, extra) {
|
|
16281
16390
|
return this.#connection.request(method, {
|
|
@@ -16286,9 +16395,11 @@ var BrokeredHarnessSession = class {
|
|
|
16286
16395
|
}
|
|
16287
16396
|
};
|
|
16288
16397
|
var BrokeredHarnessAdapter = class {
|
|
16398
|
+
#sessions = /* @__PURE__ */ new Set();
|
|
16289
16399
|
commandCatalog;
|
|
16290
|
-
harnessId
|
|
16400
|
+
harnessId;
|
|
16291
16401
|
#descriptorPath;
|
|
16402
|
+
#forwardEnvironment;
|
|
16292
16403
|
#connection = null;
|
|
16293
16404
|
#closed = false;
|
|
16294
16405
|
#sessionImportListing = null;
|
|
@@ -16383,9 +16494,11 @@ var BrokeredHarnessAdapter = class {
|
|
|
16383
16494
|
}
|
|
16384
16495
|
}
|
|
16385
16496
|
constructor(input = {}) {
|
|
16497
|
+
this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
|
|
16498
|
+
this.#forwardEnvironment = input.forwardDelegationEnvironment === true;
|
|
16386
16499
|
if (input.commandCatalog)
|
|
16387
16500
|
this.commandCatalog = input.commandCatalog;
|
|
16388
|
-
this.#descriptorPath = input.descriptorPath ?? defaultHarnessBrokerDescriptorPath(input.environment);
|
|
16501
|
+
this.#descriptorPath = input.descriptorPath ?? defaultHarnessBrokerDescriptorPath(input.environment, this.harnessId);
|
|
16389
16502
|
}
|
|
16390
16503
|
async inspectAccount() {
|
|
16391
16504
|
if (this.#closed)
|
|
@@ -16399,7 +16512,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
16399
16512
|
}
|
|
16400
16513
|
async inspect(input = {}) {
|
|
16401
16514
|
if (this.#closed)
|
|
16402
|
-
return failedInspection("
|
|
16515
|
+
return failedInspection("Aqua Harness broker adapter is closed");
|
|
16403
16516
|
try {
|
|
16404
16517
|
return harnessInspectionSchema.parse(await (await this.#connect()).request("adapter.inspect", input));
|
|
16405
16518
|
} catch (error52) {
|
|
@@ -16409,18 +16522,33 @@ var BrokeredHarnessAdapter = class {
|
|
|
16409
16522
|
}
|
|
16410
16523
|
async open(input) {
|
|
16411
16524
|
if (this.#closed)
|
|
16412
|
-
return { ok: false, error: unavailable("
|
|
16525
|
+
return { ok: false, error: unavailable("Aqua Harness broker adapter is closed", false) };
|
|
16526
|
+
let connection;
|
|
16413
16527
|
try {
|
|
16414
16528
|
const safeInput = { ...input };
|
|
16415
16529
|
delete safeInput.environment;
|
|
16416
|
-
|
|
16530
|
+
if (this.#forwardEnvironment && input.environment) {
|
|
16531
|
+
const allowed2 = [
|
|
16532
|
+
"CODEXHOST_CLI_PATH",
|
|
16533
|
+
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
16534
|
+
"CODEXHOST_RUNTIME_TOKEN",
|
|
16535
|
+
"CODEXHOST_THREAD_ID"
|
|
16536
|
+
];
|
|
16537
|
+
const environment = Object.fromEntries(Object.entries(input.environment).filter(([key, value]) => allowed2.includes(key) && value !== void 0));
|
|
16538
|
+
if (Object.keys(environment).length)
|
|
16539
|
+
safeInput.environment = environment;
|
|
16540
|
+
}
|
|
16541
|
+
connection = await this.#connect();
|
|
16542
|
+
const result = parseHarnessResult(await connection.request("adapter.open", safeInput));
|
|
16417
16543
|
if (!result.ok)
|
|
16418
16544
|
return result;
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16545
|
+
const session = new BrokeredHarnessSession(connection, parseSessionMetadata(result.value), this.harnessId, safeInput, () => this.#connect(), () => {
|
|
16546
|
+
this.#sessions.delete(session);
|
|
16547
|
+
});
|
|
16548
|
+
this.#sessions.add(session);
|
|
16549
|
+
return { ok: true, value: session };
|
|
16423
16550
|
} catch (error52) {
|
|
16551
|
+
connection?.close();
|
|
16424
16552
|
this.#connection = null;
|
|
16425
16553
|
return {
|
|
16426
16554
|
ok: false,
|
|
@@ -16430,13 +16558,29 @@ var BrokeredHarnessAdapter = class {
|
|
|
16430
16558
|
}
|
|
16431
16559
|
async close() {
|
|
16432
16560
|
this.#closed = true;
|
|
16561
|
+
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
16562
|
+
this.#sessions.clear();
|
|
16433
16563
|
const connection = await this.#connection?.catch(() => null);
|
|
16434
|
-
connection?.
|
|
16564
|
+
await connection?.dispose();
|
|
16435
16565
|
this.#connection = null;
|
|
16436
16566
|
}
|
|
16437
16567
|
#connect() {
|
|
16438
|
-
if (
|
|
16439
|
-
|
|
16568
|
+
if (this.#closed)
|
|
16569
|
+
return Promise.reject(new Error("Aqua Harness broker adapter is closed"));
|
|
16570
|
+
if (!this.#connection) {
|
|
16571
|
+
const pending = BrokerConnection.connect(this.#descriptorPath, this.harnessId).then((connection) => {
|
|
16572
|
+
connection.onClose(() => {
|
|
16573
|
+
if (this.#connection === pending)
|
|
16574
|
+
this.#connection = null;
|
|
16575
|
+
});
|
|
16576
|
+
return connection;
|
|
16577
|
+
}).catch((error52) => {
|
|
16578
|
+
if (this.#connection === pending)
|
|
16579
|
+
this.#connection = null;
|
|
16580
|
+
throw error52;
|
|
16581
|
+
});
|
|
16582
|
+
this.#connection = pending;
|
|
16583
|
+
}
|
|
16440
16584
|
return this.#connection;
|
|
16441
16585
|
}
|
|
16442
16586
|
};
|
|
@@ -45087,6 +45231,16 @@ function allowed(toolUseId, input, suggestions) {
|
|
|
45087
45231
|
...suggestions ? { updatedPermissions: suggestions } : {}
|
|
45088
45232
|
};
|
|
45089
45233
|
}
|
|
45234
|
+
function canDeliverSettlementImmediately(event, pendingEvents) {
|
|
45235
|
+
if (event.type !== "subagent.settled")
|
|
45236
|
+
return false;
|
|
45237
|
+
return !pendingEvents.some((pending) => {
|
|
45238
|
+
if (pending.type !== "subagent.started" && pending.type !== "subagent.updated" && pending.type !== "subagent.completed") {
|
|
45239
|
+
return false;
|
|
45240
|
+
}
|
|
45241
|
+
return event.callId !== void 0 && pending.callId === event.callId || pending.nativeSubagentId === event.nativeSubagentId;
|
|
45242
|
+
});
|
|
45243
|
+
}
|
|
45090
45244
|
var ClaudeSdkTransport = class {
|
|
45091
45245
|
sessionId;
|
|
45092
45246
|
#children = [];
|
|
@@ -45108,6 +45262,7 @@ var ClaudeSdkTransport = class {
|
|
|
45108
45262
|
#autonomous = null;
|
|
45109
45263
|
#autonomousTurnHandler = null;
|
|
45110
45264
|
#idleHandler = null;
|
|
45265
|
+
#threadEventHandler = null;
|
|
45111
45266
|
#idleLive = false;
|
|
45112
45267
|
#idleAccumulator = null;
|
|
45113
45268
|
#closePromise = null;
|
|
@@ -45140,6 +45295,9 @@ var ClaudeSdkTransport = class {
|
|
|
45140
45295
|
setIdleTurnHandler(handler) {
|
|
45141
45296
|
this.#idleHandler = handler;
|
|
45142
45297
|
}
|
|
45298
|
+
setThreadEventHandler(handler) {
|
|
45299
|
+
this.#threadEventHandler = handler;
|
|
45300
|
+
}
|
|
45143
45301
|
setIdleLive(live) {
|
|
45144
45302
|
this.#idleLive = live;
|
|
45145
45303
|
if (!live)
|
|
@@ -45528,8 +45686,13 @@ var ClaudeSdkTransport = class {
|
|
|
45528
45686
|
autonomous.nativeTurnKey = message.uuid;
|
|
45529
45687
|
}
|
|
45530
45688
|
const interpreted = autonomous.accumulator.consume(message);
|
|
45531
|
-
for (const event of interpreted.events)
|
|
45689
|
+
for (const event of interpreted.events) {
|
|
45690
|
+
if (this.#threadEventHandler && canDeliverSettlementImmediately(event, autonomous.events)) {
|
|
45691
|
+
this.#threadEventHandler(event);
|
|
45692
|
+
continue;
|
|
45693
|
+
}
|
|
45532
45694
|
autonomous.events.push({ ...event, observedAtMs });
|
|
45695
|
+
}
|
|
45533
45696
|
if (interpreted.terminal) {
|
|
45534
45697
|
this.#autonomous = null;
|
|
45535
45698
|
const nativeTurnKey = autonomous.nativeTurnKey ?? `autonomous-${Date.now()}`;
|
|
@@ -46673,6 +46836,7 @@ var ClaudeHarnessSession = class {
|
|
|
46673
46836
|
agentMessageStartedAtMs: null,
|
|
46674
46837
|
reasoningStartedAtMs: /* @__PURE__ */ new Map(),
|
|
46675
46838
|
held: false,
|
|
46839
|
+
rootSegmentActive: true,
|
|
46676
46840
|
completion,
|
|
46677
46841
|
resolveCompletion
|
|
46678
46842
|
};
|
|
@@ -46781,6 +46945,7 @@ var ClaudeHarnessSession = class {
|
|
|
46781
46945
|
agentMessageStartedAtMs: null,
|
|
46782
46946
|
reasoningStartedAtMs: /* @__PURE__ */ new Map(),
|
|
46783
46947
|
held: false,
|
|
46948
|
+
rootSegmentActive: true,
|
|
46784
46949
|
completion,
|
|
46785
46950
|
resolveCompletion
|
|
46786
46951
|
};
|
|
@@ -47198,11 +47363,21 @@ var ClaudeHarnessSession = class {
|
|
|
47198
47363
|
});
|
|
47199
47364
|
this.#transport = transport;
|
|
47200
47365
|
transport.setAutonomousTurnHandler((turn) => this.#handleAutonomousTurn(turn));
|
|
47366
|
+
transport.setThreadEventHandler((event) => {
|
|
47367
|
+
if (event.type === "subagent.settled") {
|
|
47368
|
+
this.#settleBackgroundSubagent(event.status, event.nativeSubagentId, event.callId, event.resultSummary);
|
|
47369
|
+
}
|
|
47370
|
+
});
|
|
47201
47371
|
transport.setIdleTurnHandler({
|
|
47202
47372
|
onEvent: (event) => {
|
|
47203
47373
|
const active = this.#active;
|
|
47204
|
-
if (active)
|
|
47374
|
+
if (active) {
|
|
47205
47375
|
this.#handleTurnEvent(active, event);
|
|
47376
|
+
return;
|
|
47377
|
+
}
|
|
47378
|
+
if (event.type === "subagent.settled") {
|
|
47379
|
+
this.#settleBackgroundSubagent(event.status, event.nativeSubagentId, event.callId, event.resultSummary);
|
|
47380
|
+
}
|
|
47206
47381
|
},
|
|
47207
47382
|
onTerminal: (result) => {
|
|
47208
47383
|
const active = this.#active;
|
|
@@ -47284,12 +47459,14 @@ var ClaudeHarnessSession = class {
|
|
|
47284
47459
|
return;
|
|
47285
47460
|
switch (event.type) {
|
|
47286
47461
|
case "segment.started":
|
|
47287
|
-
this.#observeRootOutput();
|
|
47462
|
+
this.#observeRootOutput(active);
|
|
47288
47463
|
return;
|
|
47289
47464
|
case "subagents.live":
|
|
47290
47465
|
this.#occupancy.observeLive(event.nativeSubagentIds);
|
|
47466
|
+
this.#armContinuationQuiescence(active);
|
|
47291
47467
|
return;
|
|
47292
47468
|
case "compaction.started":
|
|
47469
|
+
this.#observeRootOutput(active);
|
|
47293
47470
|
this.#startCompaction(active);
|
|
47294
47471
|
return;
|
|
47295
47472
|
case "compaction.completed":
|
|
@@ -47297,12 +47474,12 @@ var ClaudeHarnessSession = class {
|
|
|
47297
47474
|
return;
|
|
47298
47475
|
case "text.delta":
|
|
47299
47476
|
if (event.delta.length > 0)
|
|
47300
|
-
this.#observeRootOutput();
|
|
47477
|
+
this.#observeRootOutput(active);
|
|
47301
47478
|
this.#appendText(active, event.messageId, event.delta);
|
|
47302
47479
|
return;
|
|
47303
47480
|
case "reasoning.delta":
|
|
47304
47481
|
if (event.delta.length > 0)
|
|
47305
|
-
this.#observeRootOutput();
|
|
47482
|
+
this.#observeRootOutput(active);
|
|
47306
47483
|
this.#activateAssistantMessage(active, event.messageId);
|
|
47307
47484
|
this.#appendReasoning(active, event.messageId, event.delta);
|
|
47308
47485
|
return;
|
|
@@ -47310,6 +47487,7 @@ var ClaudeHarnessSession = class {
|
|
|
47310
47487
|
this.#completeReasoning(active, event.messageId, { status: "succeeded" });
|
|
47311
47488
|
return;
|
|
47312
47489
|
case "message.completed": {
|
|
47490
|
+
this.#observeRootOutput(active);
|
|
47313
47491
|
if (event.lastRequestUsage) {
|
|
47314
47492
|
this.#requestUsageBoundary += 1;
|
|
47315
47493
|
this.#applyLatestRequestUsage(active, event.lastRequestUsage);
|
|
@@ -47326,7 +47504,7 @@ var ClaudeHarnessSession = class {
|
|
|
47326
47504
|
return;
|
|
47327
47505
|
}
|
|
47328
47506
|
case "tool.started":
|
|
47329
|
-
this.#observeRootOutput();
|
|
47507
|
+
this.#observeRootOutput(active);
|
|
47330
47508
|
for (const messageId of [...active.reasoningItems.keys()]) {
|
|
47331
47509
|
this.#completeReasoning(active, messageId, { status: "succeeded" });
|
|
47332
47510
|
}
|
|
@@ -47340,7 +47518,7 @@ var ClaudeHarnessSession = class {
|
|
|
47340
47518
|
active.tools.complete(active.command.turnId, event, active.cancellationRequested);
|
|
47341
47519
|
return;
|
|
47342
47520
|
case "subagent.started":
|
|
47343
|
-
this.#observeRootOutput();
|
|
47521
|
+
this.#observeRootOutput(active);
|
|
47344
47522
|
for (const messageId of [...active.reasoningItems.keys()]) {
|
|
47345
47523
|
this.#completeReasoning(active, messageId, { status: "succeeded" });
|
|
47346
47524
|
}
|
|
@@ -47389,6 +47567,7 @@ var ClaudeHarnessSession = class {
|
|
|
47389
47567
|
return;
|
|
47390
47568
|
}
|
|
47391
47569
|
case "interaction.requested":
|
|
47570
|
+
this.#observeRootOutput(active);
|
|
47392
47571
|
this.#startInteraction(active, event.request);
|
|
47393
47572
|
return;
|
|
47394
47573
|
case "interaction.closed":
|
|
@@ -47690,6 +47869,7 @@ var ClaudeHarnessSession = class {
|
|
|
47690
47869
|
agentMessageStartedAtMs: null,
|
|
47691
47870
|
reasoningStartedAtMs: /* @__PURE__ */ new Map(),
|
|
47692
47871
|
held: false,
|
|
47872
|
+
rootSegmentActive: true,
|
|
47693
47873
|
completion,
|
|
47694
47874
|
resolveCompletion
|
|
47695
47875
|
};
|
|
@@ -47728,6 +47908,9 @@ var ClaudeHarnessSession = class {
|
|
|
47728
47908
|
}
|
|
47729
47909
|
#settleBackgroundSubagent(status, nativeSubagentId2, callId, resultSummary) {
|
|
47730
47910
|
this.#occupancy.notify(callId, nativeSubagentId2);
|
|
47911
|
+
const active = this.#active;
|
|
47912
|
+
if (active?.held)
|
|
47913
|
+
this.#armContinuationQuiescence(active);
|
|
47731
47914
|
if (!nativeSubagentId2)
|
|
47732
47915
|
return;
|
|
47733
47916
|
this.#event({
|
|
@@ -47745,6 +47928,7 @@ var ClaudeHarnessSession = class {
|
|
|
47745
47928
|
#finishResult(active, result) {
|
|
47746
47929
|
if (this.#active !== active || this.#hardCancelTask)
|
|
47747
47930
|
return;
|
|
47931
|
+
active.rootSegmentActive = false;
|
|
47748
47932
|
if (result.status === "succeeded" && (active.tools.size > 0 || active.subagents.size > 0)) {
|
|
47749
47933
|
this.#finishFailed(active, transportFailure("protocol"));
|
|
47750
47934
|
} else if (result.status === "succeeded") {
|
|
@@ -48022,13 +48206,15 @@ var ClaudeHarnessSession = class {
|
|
|
48022
48206
|
}
|
|
48023
48207
|
/** Completes held work after a quiet period with no further Root output. */
|
|
48024
48208
|
#armContinuationQuiescence(active) {
|
|
48025
|
-
this.#
|
|
48026
|
-
if (!this.#occupancy.awaitingContinuation)
|
|
48209
|
+
if (this.#active !== active || !active.held || active.rootSegmentActive || this.#phase !== "open" || !this.#occupancy.awaitingContinuation) {
|
|
48027
48210
|
return;
|
|
48211
|
+
}
|
|
48212
|
+
this.#clearContinuationQuiescence();
|
|
48028
48213
|
const quiescence = setTimeout(() => {
|
|
48029
48214
|
this.#continuationQuiescence = null;
|
|
48030
|
-
if (this.#active !== active || !active.held || this.#phase !== "open")
|
|
48215
|
+
if (this.#active !== active || !active.held || active.rootSegmentActive || this.#phase !== "open") {
|
|
48031
48216
|
return;
|
|
48217
|
+
}
|
|
48032
48218
|
this.#occupancy.releaseContinuations();
|
|
48033
48219
|
if (this.#occupancy.unsettled)
|
|
48034
48220
|
return;
|
|
@@ -48043,7 +48229,8 @@ var ClaudeHarnessSession = class {
|
|
|
48043
48229
|
clearTimeout(this.#continuationQuiescence);
|
|
48044
48230
|
this.#continuationQuiescence = null;
|
|
48045
48231
|
}
|
|
48046
|
-
#observeRootOutput() {
|
|
48232
|
+
#observeRootOutput(active) {
|
|
48233
|
+
active.rootSegmentActive = true;
|
|
48047
48234
|
this.#clearContinuationQuiescence();
|
|
48048
48235
|
}
|
|
48049
48236
|
#finish(active, outcome) {
|
|
@@ -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>
|